-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add device address parameter for s390x #4010
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
|
||
:copyright: 2012-2013 Red Hat Inc. | ||
""" | ||
|
||
import json | ||
import logging | ||
import os | ||
|
@@ -63,7 +64,6 @@ def _build_cmd(cmd, args=None, q_id=None): | |
# Device objects | ||
# | ||
class QBaseDevice(object): | ||
|
||
"""Base class of qemu objects""" | ||
|
||
def __init__( | ||
|
@@ -378,7 +378,6 @@ def is_pcie_device(self): | |
|
||
|
||
class QStringDevice(QBaseDevice): | ||
|
||
""" | ||
General device which allows to specify methods by fixed or parametrizable | ||
strings in this format: | ||
|
@@ -444,7 +443,6 @@ def cmdline_nd(self): | |
|
||
|
||
class QCustomDevice(QBaseDevice): | ||
|
||
""" | ||
Representation of the '-$option $param1=$value1,$param2...' qemu object. | ||
This representation handles only cmdline. | ||
|
@@ -515,7 +513,6 @@ def cmdline_nd(self): | |
|
||
|
||
class QDrive(QCustomDevice): | ||
|
||
""" | ||
Representation of the '-drive' qemu object without hotplug support. | ||
""" | ||
|
@@ -545,7 +542,6 @@ def set_param(self, option, value, option_type=None): | |
|
||
|
||
class QOldDrive(QDrive): | ||
|
||
""" | ||
This is a variant for -drive without 'addr' support | ||
""" | ||
|
@@ -566,7 +562,6 @@ def set_param(self, option, value, option_type=None): | |
|
||
|
||
class QHPDrive(QDrive): | ||
|
||
""" | ||
Representation of the '-drive' qemu object with hotplug support. | ||
""" | ||
|
@@ -640,7 +635,6 @@ def unplug_hmp(self): | |
|
||
|
||
class QRHDrive(QDrive): | ||
|
||
""" | ||
Representation of the '-drive' qemu object with RedHat hotplug support. | ||
""" | ||
|
@@ -1118,7 +1112,6 @@ class QBlockdevProtocolFTPS(QBlockdevProtocol): | |
|
||
|
||
class QDevice(QCustomDevice): | ||
|
||
""" | ||
Representation of the '-device' qemu object. It supports all methods. | ||
:note: Use driver format in full form - 'driver' = '...' (usb-ehci, ide-hd) | ||
|
@@ -1309,7 +1302,6 @@ def _cmdline_json(self): | |
|
||
|
||
class QGlobal(QBaseDevice): | ||
|
||
""" | ||
Representation of qemu global setting (-global driver.property=value) | ||
""" | ||
|
@@ -1334,7 +1326,6 @@ def cmdline(self): | |
|
||
|
||
class QFloppy(QGlobal): | ||
|
||
""" | ||
Imitation of qemu floppy disk defined by -global isa-fdc.drive?=$drive | ||
""" | ||
|
@@ -1368,7 +1359,6 @@ def set_param(self, option, value, option_type=None): | |
|
||
|
||
class QObject(QCustomDevice): | ||
|
||
""" | ||
Representation of the '-object backend' qemu object. | ||
""" | ||
|
@@ -1616,7 +1606,6 @@ def verify_unplug(self, out, monitor): | |
|
||
|
||
class Memory(QObject): | ||
|
||
""" | ||
QOM memory object, support for pinning memory on host NUMA nodes. | ||
The existing options in __attributes__ are subsumed by the QOM objects | ||
|
@@ -2660,7 +2649,6 @@ def verify_hotplug(self, out, monitor): | |
# virtio-serial-bus | ||
# | ||
class QSparseBus(object): | ||
|
||
""" | ||
Universal bus representation object. | ||
|
||
|
@@ -3062,7 +3050,6 @@ def match_bus(self, bus_spec, type_test=True): | |
|
||
|
||
class QStrictCustomBus(QSparseBus): | ||
|
||
""" | ||
Similar to QSparseBus. The address starts with 1 and addr is always set | ||
""" | ||
|
@@ -3089,7 +3076,6 @@ def _update_device_props(self, device, addr): | |
|
||
|
||
class QNoAddrCustomBus(QSparseBus): | ||
|
||
""" | ||
This is the opposite of QStrictCustomBus. Even when addr is set it's not | ||
updated in the device's params. | ||
|
@@ -3103,7 +3089,6 @@ def _update_device_props(self, device, addr): | |
|
||
|
||
class QUSBBus(QSparseBus): | ||
|
||
""" | ||
USB bus representation including usb-hub handling. | ||
""" | ||
|
@@ -3179,7 +3164,6 @@ def _update_device_props(self, device, addr): | |
|
||
|
||
class QDriveBus(QSparseBus): | ||
|
||
""" | ||
QDrive bus representation (single slot, drive=...) | ||
""" | ||
|
@@ -3212,7 +3196,6 @@ def _update_device_props(self, device, addr): | |
|
||
|
||
class QDenseBus(QSparseBus): | ||
|
||
""" | ||
Dense bus representation. The only difference from SparseBus is the output | ||
string format. DenseBus iterates over all addresses and show free slots | ||
|
@@ -3252,7 +3235,6 @@ def _str_devices(self): | |
|
||
|
||
class QPCIBus(QSparseBus): | ||
|
||
""" | ||
PCI Bus representation (bus&addr, uses hex digits) | ||
""" | ||
|
@@ -3514,7 +3496,6 @@ def prepare_hotplug(self, device): | |
|
||
|
||
class QPCISwitchBus(QPCIBus): | ||
|
||
""" | ||
PCI Switch bus representation (creates downstream device while inserting | ||
a device). | ||
|
@@ -3569,7 +3550,6 @@ def _set_device_props(self, device, addr): | |
|
||
|
||
class QSCSIBus(QSparseBus): | ||
|
||
""" | ||
SCSI bus representation (bus + 2 leves, don't iterate over lun by default) | ||
""" | ||
|
@@ -3598,7 +3578,6 @@ def _increment_addr(self, addr, last_addr=None): | |
|
||
|
||
class QBusUnitBus(QDenseBus): | ||
|
||
"""Implementation of bus-unit/nr bus (ahci, ide, virtio-serial)""" | ||
|
||
def __init__( | ||
|
@@ -3663,7 +3642,6 @@ def _dev2addr(self, device): | |
|
||
|
||
class QSerialBus(QBusUnitBus): | ||
|
||
"""Serial bus representation""" | ||
|
||
def __init__(self, busid, bus_type, aobject=None, max_ports=32): | ||
|
@@ -3681,7 +3659,6 @@ def __init__(self, busid, bus_type, aobject=None, max_ports=32): | |
|
||
|
||
class QAHCIBus(QBusUnitBus): | ||
|
||
"""AHCI bus (ich9-ahci, ahci)""" | ||
|
||
def __init__(self, busid, aobject=None): | ||
|
@@ -3690,7 +3667,6 @@ def __init__(self, busid, aobject=None): | |
|
||
|
||
class QIDEBus(QBusUnitBus): | ||
|
||
"""IDE bus (piix3-ide)""" | ||
|
||
def __init__(self, busid, aobject=None): | ||
|
@@ -3699,7 +3675,6 @@ def __init__(self, busid, aobject=None): | |
|
||
|
||
class QFloppyBus(QDenseBus): | ||
|
||
""" | ||
Floppy bus (-global isa-fdc.drive?=$drive) | ||
""" | ||
|
@@ -3735,7 +3710,6 @@ def _set_device_props(self, device, addr): | |
|
||
|
||
class QOldFloppyBus(QDenseBus): | ||
|
||
""" | ||
Floppy bus (-drive index=n) | ||
""" | ||
|
@@ -3983,3 +3957,57 @@ def _cmdline_raw(self): | |
# -machine allows empty line | ||
return "" | ||
return super()._cmdline_raw() | ||
|
||
|
||
class QCSSBus(QSparseBus): | ||
""" | ||
CSS Bus representation (bus&ssid&devno, uses hex digits) | ||
""" | ||
|
||
def __init__(self, busid, bus_type, aobject): | ||
"""bus&ssid&devno, 4 ssid and 65536 device numbers""" | ||
super(QCSSBus, self).__init__( | ||
"bus", [["ssid", "devno"], [4, 65536]], busid, bus_type, aobject | ||
) | ||
|
||
@staticmethod | ||
def _addr2stor(addr): | ||
""" | ||
Converts internal addr to storable/hashable address | ||
:param addr: internal address [addr1, addr2, ...] | ||
:return: storable address "addr1-addr2-..." | ||
""" | ||
out = "" | ||
for value in addr: | ||
if value is None: | ||
out += "*-" | ||
else: | ||
out += "%s-" % value | ||
if out: | ||
return out[:-1] | ||
else: | ||
return "*" | ||
|
||
def _dev2addr(self, device): | ||
"""Read the values in base of 16 (hex)""" | ||
addr = device.get_param("addr") | ||
if isinstance(addr, int): # only addr | ||
return [0, addr] | ||
elif not addr: # not defined | ||
return [0, None] | ||
elif isinstance(addr, six.string_types): # ssid.addr | ||
addr = [int(_, 16) for _ in addr.split(".", 1)] | ||
if len(addr) < 2: # only addr | ||
addr.insert(0, 0) | ||
return addr | ||
|
||
def _set_device_props(self, device, addr): | ||
"""Convert addr to the format used by qtree""" | ||
if device.get_param("addr"): | ||
del device.params["addr"] | ||
device.set_param("devno", "fe.%s.%s" % ( | ||
hex(addr[0])[2:], f"{addr[1]:04x}")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as we can mark sure the ssid only with length There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And for |
||
|
||
def _update_device_props(self, device, addr): | ||
"""Always set properties""" | ||
self._set_device_props(device, addr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, here only cover
ssid
anddevno
, ascssid
setfe
by default. However, should we cover unusual test scenarios? from the qemu docwe can set cssid value rather than default
fe
, so how about includes the ssid but setfe
by default.