mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-03-08 04:58:29 +03:00
virtManager/addhardware: get supported disk bus types from libvirt
Libvirt provides domain capabilities where supported disk bus types are listed. Virt-manager should try to get those bus types. The old code remains as fallback if domain capabilities doesn't contain the disk bus types. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1387218 Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
67998282a7
commit
798a2e5080
@ -690,25 +690,38 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
|
||||
@staticmethod
|
||||
def populate_disk_bus_combo(vm, devtype, model):
|
||||
# try to get supported disk bus types from domain capabilities
|
||||
domcaps = vm.get_domain_capabilities()
|
||||
disk_bus_types = None
|
||||
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.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_conn():
|
||||
disk_bus_types.append("xen")
|
||||
|
||||
rows = []
|
||||
if vm.is_hvm():
|
||||
if not vm.get_xmlobj().os.is_q35():
|
||||
rows.append(["ide", "IDE"])
|
||||
rows.append(["sata", "SATA"])
|
||||
rows.append(["fdc", _("Floppy")])
|
||||
|
||||
if not vm.stable_defaults():
|
||||
rows.append(["scsi", "SCSI"])
|
||||
rows.append(["usb", "USB"])
|
||||
|
||||
if vm.get_hv_type() in ["qemu", "kvm", "test"]:
|
||||
rows.append(["sd", "SD"])
|
||||
rows.append(["virtio", "VirtIO"])
|
||||
if not rows.count(["scsi", "SCSI"]):
|
||||
rows.append(["scsi", "SCSI"])
|
||||
|
||||
if vm.conn.is_xen() or vm.conn.is_test_conn():
|
||||
rows.append(["xen", "Xen"])
|
||||
for bus in disk_bus_types:
|
||||
rows.append([bus, virtinst.VirtualDisk.pretty_disk_bus(bus)])
|
||||
|
||||
model.clear()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user