Skip to content

Commit

Permalink
qdevices: add insert() at QIOThreadbus
Browse files Browse the repository at this point in the history
add insert() at QIOThreadbus.

Signed-off-by: Houqi (Nick) Zuo <[email protected]>
  • Loading branch information
nickzhq committed Nov 20, 2023
1 parent fce0b8d commit 021e0b7
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions virttest/qemu_devices/qdevices.py
Original file line number Diff line number Diff line change
Expand Up @@ -3537,6 +3537,34 @@ def _update_device_props(self, device, addr):
"""Always set device iothread param."""
self._set_device_props(device, addr)

def insert(self, device):
"""
Insert device into this bus representation.
:param device: QBaseDevice device
:return: list of added devices on success,
string indicating the failure on failure.
"""
additional_devices = []
if not self._check_bus(device):
return "BusId"
try:
addr_pattern = self._dev2addr(device)
except (ValueError, LookupError):
return "BasicAddress"
addr = self.get_free_slot(addr_pattern)
if addr is None:
if None in addr_pattern:
return "NoFreeSlot"
else:
return "UsedSlot"
elif addr is False:
return "BadAddr(%s)" % addr
else:
additional_devices.extend(self._insert(device,
self._addr2stor(addr)))
return additional_devices


class QUnixSocketBus(QSparseBus):
"""
Expand Down

0 comments on commit 021e0b7

Please sign in to comment.