addhardware: Move disk bus listing to virtinst
Drop the stable_default stuff as domcaps usage should make it obsolete for any cases we care about
This commit is contained in:
parent
a09a46289a
commit
63287c83fb
|
@ -469,50 +469,12 @@ class vmmAddHardware(vmmGObjectUI):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def populate_disk_bus_combo(vm, devtype, model):
|
def populate_disk_bus_combo(vm, devtype, model):
|
||||||
# try to get supported disk bus types from domain capabilities
|
|
||||||
domcaps = vm.get_domain_capabilities()
|
domcaps = vm.get_domain_capabilities()
|
||||||
disk_bus_types = None
|
buses = DeviceDisk.get_recommended_buses(vm.xmlobj, domcaps, devtype)
|
||||||
if "bus" in domcaps.devices.disk.enum_names():
|
|
||||||
disk_bus_types = domcaps.devices.disk.get_enum("bus").get_values()
|
|
||||||
|
|
||||||
# if there are no disk bus types in domain capabilities fallback to
|
|
||||||
# old code
|
|
||||||
if not disk_bus_types:
|
|
||||||
disk_bus_types = []
|
|
||||||
if vm.is_hvm():
|
|
||||||
if not vm.get_xmlobj().os.is_q35():
|
|
||||||
disk_bus_types.append("ide")
|
|
||||||
disk_bus_types.append("sata")
|
|
||||||
disk_bus_types.append("fdc")
|
|
||||||
|
|
||||||
if not vm.xmlobj.stable_defaults():
|
|
||||||
disk_bus_types.append("scsi")
|
|
||||||
disk_bus_types.append("usb")
|
|
||||||
|
|
||||||
if vm.get_hv_type() in ["qemu", "kvm", "test"]:
|
|
||||||
disk_bus_types.append("sd")
|
|
||||||
disk_bus_types.append("virtio")
|
|
||||||
if "scsi" not in disk_bus_types:
|
|
||||||
disk_bus_types.append("scsi")
|
|
||||||
|
|
||||||
if vm.conn.is_xen() or vm.conn.is_test():
|
|
||||||
disk_bus_types.append("xen")
|
|
||||||
|
|
||||||
rows = []
|
|
||||||
for bus in disk_bus_types:
|
|
||||||
rows.append([bus, DeviceDisk.pretty_disk_bus(bus)])
|
|
||||||
|
|
||||||
model.clear()
|
model.clear()
|
||||||
|
for bus in buses:
|
||||||
bus_map = {
|
model.append([bus, DeviceDisk.pretty_disk_bus(bus)])
|
||||||
"disk": ["ide", "sata", "scsi", "sd", "usb", "virtio", "xen"],
|
|
||||||
"floppy": ["fdc"],
|
|
||||||
"cdrom": ["ide", "sata", "scsi"],
|
|
||||||
"lun": ["scsi"],
|
|
||||||
}
|
|
||||||
for row in rows:
|
|
||||||
if row[0] in bus_map[devtype]:
|
|
||||||
model.append(row)
|
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -142,6 +142,44 @@ class DeviceDisk(Device):
|
||||||
|
|
||||||
error_policies = ["ignore", "stop", "enospace", "report"]
|
error_policies = ["ignore", "stop", "enospace", "report"]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_old_recommended_buses(guest):
|
||||||
|
ret = []
|
||||||
|
if guest.os.is_hvm() or guest.conn.is_test():
|
||||||
|
if not guest.os.is_q35():
|
||||||
|
ret.append("ide")
|
||||||
|
ret.append("sata")
|
||||||
|
ret.append("fdc")
|
||||||
|
ret.append("scsi")
|
||||||
|
ret.append("usb")
|
||||||
|
|
||||||
|
if guest.type in ["qemu", "kvm", "test"]:
|
||||||
|
ret.append("sd")
|
||||||
|
ret.append("virtio")
|
||||||
|
if "scsi" not in ret:
|
||||||
|
ret.append("scsi")
|
||||||
|
|
||||||
|
if guest.conn.is_xen() or guest.conn.is_test():
|
||||||
|
ret.append("xen")
|
||||||
|
|
||||||
|
return ret
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_recommended_buses(guest, domcaps, devtype):
|
||||||
|
# try to get supported disk bus types from domain capabilities
|
||||||
|
if "bus" in domcaps.devices.disk.enum_names():
|
||||||
|
buses = domcaps.devices.disk.get_enum("bus").get_values()
|
||||||
|
else:
|
||||||
|
buses = DeviceDisk.get_old_recommended_buses(guest)
|
||||||
|
|
||||||
|
bus_map = {
|
||||||
|
"disk": ["ide", "sata", "scsi", "sd", "usb", "virtio", "xen"],
|
||||||
|
"floppy": ["fdc"],
|
||||||
|
"cdrom": ["ide", "sata", "scsi"],
|
||||||
|
"lun": ["scsi"],
|
||||||
|
}
|
||||||
|
return [bus for bus in buses if bus in bus_map.get(devtype, [])]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def disk_type_to_xen_driver_name(disk_type):
|
def disk_type_to_xen_driver_name(disk_type):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue