From 42ea6e2c888ceee087cd6a61e52b4647f13573f2 Mon Sep 17 00:00:00 2001 From: Plamen Dimitrov Date: Thu, 13 Jul 2023 22:18:33 +0300 Subject: [PATCH] Add support for newer floppy device after Qemu 5.1.0 We keep compatibility with old floppy devices but add the new floppy support to re-enable unattended installs of older windows machines. Signed-off-by: Plamen Dimitrov Co-authored-by: Xu Han --- virttest/qemu_capabilities.py | 1 + virttest/qemu_devices/qcontainer.py | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/virttest/qemu_capabilities.py b/virttest/qemu_capabilities.py index 0fe9c00b90d..87c13274dbb 100644 --- a/virttest/qemu_capabilities.py +++ b/virttest/qemu_capabilities.py @@ -26,6 +26,7 @@ class Flags(object): MIGRATION_PARAMS = _auto_value() SEV_GUEST = _auto_value() TDX_GUEST = _auto_value() + FLOPPY_DEVICE = _auto_value() class MigrationParams(object): diff --git a/virttest/qemu_devices/qcontainer.py b/virttest/qemu_devices/qcontainer.py index c9e21b6660a..f3305483285 100644 --- a/virttest/qemu_devices/qcontainer.py +++ b/virttest/qemu_devices/qcontainer.py @@ -81,6 +81,7 @@ class DevContainer(object): BLOCKDEV_VERSION_SCOPE = '[2.12.0, )' SMP_DIES_VERSION_SCOPE = '[4.1.0, )' SMP_CLUSTERS_VERSION_SCOPE = '[7.0.0, )' + FLOPPY_DEVICE_VERSION_SCOPE = '[5.1.0, )' MIGRATION_DOWNTIME_LIMTT_VERSION_SCOPE = '[5.1.0, )' MIGRATION_MAX_BANDWIDTH_VERSION_SCOPE = '[5.1.0, )' @@ -302,6 +303,9 @@ def _probe_capabilities(self): # -object tdx-guest if self.has_object('tdx-guest'): self.caps.set_flag(Flags.TDX_GUEST) + # -device floppy,drive=$drive + if self.__qemu_ver in VersionInterval(self.FLOPPY_DEVICE_VERSION_SCOPE): + self.caps.set_flag(Flags.FLOPPY_DEVICE) if (self.has_qmp_cmd('migrate-set-parameters') and self.has_hmp_cmd('migrate_set_parameter')): @@ -2395,9 +2399,14 @@ def define_hbas(qtype, atype, bus, unit, port, qbus, pci_bus, iothread, devices[-1].set_param('port', unit) devices[-1].set_param('removable', removable, bool) elif fmt == 'floppy': - # Overwrite qdevices.QDevice with qdevices.QFloppy - devices[-1] = qdevices.QFloppy(unit, 'drive_%s' % name, name, - ({'busid': 'drive_%s' % name}, {'type': fmt})) + if Flags.FLOPPY_DEVICE in self.caps: + devices[-1] = qdevices.QDevice('floppy', aobject=name) + devices[-1].parent_bus += ({'busid': 'drive_%s' % name},) + devices[-1].set_param('unit', unit) + else: + # Overwrite qdevices.QDevice with qdevices.QFloppy + devices[-1] = qdevices.QFloppy(unit, 'drive_%s' % name, name, + ({'busid': 'drive_%s' % name}, {'type': fmt})) else: LOG.warn('Using default device handling (disk %s)', name) devices[-1].set_param('driver', fmt)