Skip to content

Commit

Permalink
Add support for newer floppy device after Qemu 5.1.0
Browse files Browse the repository at this point in the history
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 <[email protected]>
Co-authored-by: Xu Han <[email protected]>
  • Loading branch information
pevogam and luckyh committed Aug 4, 2023
1 parent e20d6f4 commit 42ea6e2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions virttest/qemu_capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
15 changes: 12 additions & 3 deletions virttest/qemu_devices/qcontainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, )'
Expand Down Expand Up @@ -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')):
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 42ea6e2

Please sign in to comment.