[virt-tools-list] [virt-manager PATCH] virtManager/addhardware: get supported disk bus types from libvirt

Cole Robinson crobinso at redhat.com
Sun Feb 5 21:51:57 UTC 2017


On 01/20/2017 10:21 AM, Pavel Hrdina wrote:
> 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 at redhat.com>
> ---
>  virtManager/addhardware.py | 49 +++++++++++++++++++++++++++++-----------------
>  1 file changed, 31 insertions(+), 18 deletions(-)
> 
> diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
> index aab90957..e63ad3d0 100644
> --- a/virtManager/addhardware.py
> +++ b/virtManager/addhardware.py
> @@ -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()
> +

Unfortunately libvirt's domcaps don't seem to be exhaustive. For example,
bus=sd isn't listed, which virt-manager supports in the existing code. So in
order to enable this we would need to 1) fix libvirt, 2) only use the domcaps
code from known good versions. That's kind of the general difficulty in
switching to these types of capabilities reporting APIs unfortunately...

Thanks,
Cole

> +        # 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()
>  
> 




More information about the virt-tools-list mailing list