Skip to content

Commit

Permalink
Merge pull request #3719 from pevogam/floppy-device-capability
Browse files Browse the repository at this point in the history
Add support for newer floppy device after Qemu 5.1.0
  • Loading branch information
YongxueHong authored Aug 10, 2023
2 parents 12953f0 + 6222257 commit d001933
Show file tree
Hide file tree
Showing 2 changed files with 12 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
14 changes: 11 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,13 @@ 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, 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 d001933

Please sign in to comment.