Re: [PATCH 5/5] qemu: auto-add a USB2 controller set for Q35 machines

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 11/19/2015 01:25 PM, Laine Stump wrote:
> Use virDomainDefAddUSBController() to add an EHCI1+UHCI1+UHCI2+UHCI3
> controller set to newly defined Q35 domains that don't have any USB
> controllers defined.
> ---
>  src/qemu/qemu_domain.c                       | 14 +++++++++++---
>  tests/qemuxml2argvdata/qemuxml2argv-q35.args |  5 +++++
>  2 files changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index 1f73709..fd87c25 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -1018,6 +1018,7 @@ qemuDomainDefPostParse(virDomainDefPtr def,
>      virQEMUDriverPtr driver = opaque;
>      virQEMUCapsPtr qemuCaps = NULL;
>      bool addDefaultUSB = true;
> +    int usbModel = -1; /* "default for machinetype" */

?machinetype?  Perhaps "obvious" that it only changes for one type of
machine if one looks.

ACK - don't care either way if comment is kept or dropped

John

>      bool addImplicitSATA = false;
>      bool addPCIRoot = false;
>      bool addPCIeRoot = false;
> @@ -1054,8 +1055,15 @@ qemuDomainDefPostParse(virDomainDefPtr def,
>          if (STRPREFIX(def->os.machine, "pc-q35") ||
>              STREQ(def->os.machine, "q35")) {
>              addPCIeRoot = true;
> -            addDefaultUSB = false;
>              addImplicitSATA = true;
> +
> +            /* add a USB2 controller set, but only if the
> +             * ich9-usb-ehci1 device is supported
> +             */
> +            if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_ICH9_USB_EHCI1))
> +                usbModel = VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_EHCI1;
> +            else
> +                addDefaultUSB = false;
>              break;
>          }
>          if (!STRPREFIX(def->os.machine, "pc-0.") &&
> @@ -1113,8 +1121,8 @@ qemuDomainDefPostParse(virDomainDefPtr def,
>      }
>  
>      if (addDefaultUSB &&
> -        virDomainDefMaybeAddController(
> -            def, VIR_DOMAIN_CONTROLLER_TYPE_USB, 0, -1) < 0)
> +        virDomainControllerFind(def, VIR_DOMAIN_CONTROLLER_TYPE_USB, 0) < 0 &&
> +        virDomainDefAddUSBController(def, 0, usbModel) < 0)
>          goto cleanup;
>  
>      if (addImplicitSATA &&
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35.args b/tests/qemuxml2argvdata/qemuxml2argv-q35.args
> index 7020e60..705c076 100644
> --- a/tests/qemuxml2argvdata/qemuxml2argv-q35.args
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-q35.args
> @@ -18,6 +18,11 @@ QEMU_AUDIO_DRV=none \
>  -boot c \
>  -device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \
>  -device pci-bridge,chassis_nr=56,id=pci.2,bus=pci.1,addr=0x1 \
> +-device ich9-usb-ehci1,id=usb,bus=pcie.0,addr=0x1d.0x7 \
> +-device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pcie.0,multifunction=on,\
> +addr=0x1d \
> +-device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pcie.0,addr=0x1d.0x1 \
> +-device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pcie.0,addr=0x1d.0x2 \
>  -drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-sata0-0-0,format=raw \
>  -device ide-drive,bus=ide.0,drive=drive-sata0-0-0,id=sata0-0-0 \
>  -vga qxl \
> 

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]