[libvirt] [PATCH] qemu: report a nicer error when USB is disabled

Andrea Bolognani abologna at redhat.com
Thu Feb 8 16:37:36 UTC 2018


On Wed, 2017-09-20 at 16:18 +0200, Ján Tomko wrote:
> If the user tries to define a domain that has
> 
>   <controller type='usb' model='none'/>
> 
> and also some USB devices, we report an error:
>   error: internal error: No free USB ports
> 
> Which is technically still correct for a domain with no USB ports.
> 
> Change it to:
> 
> USB is disabled for this domain, but USB devices are present in the domain XML
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1347550

[...]
> @@ -2656,6 +2656,8 @@ int virDomainDefPostParse(virDomainDefPtr def,
>                            unsigned int parseFlags,
>                            virDomainXMLOptionPtr xmlopt,
>                            void *parseOpaque);
> +bool
> +virDomainDefHasUSB(const virDomainDef *def);

Have everything on a single line here.

[...]
> @@ -2644,6 +2644,13 @@ qemuDomainUSBAddressAddHubs(virDomainDefPtr def)
>                                                &data,
>                                                false));
>  
> +    if (data.count && !virDomainDefHasUSB(def)) {
> +        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +                       _("USB is disabled for this domain, but USB devices "
> +                         "are present in the domain XML"));
> +        return -1;
> +    }

I would prefer 'data.count > 0' here, but your version works
fine too.


Reviewed-by: Andrea Bolognani <abologna at redhat.com>
List-necromancy-by: Andrea Bolognani <abologna at redhat.com>

-- 
Andrea Bolognani / Red Hat / Virtualization




More information about the libvir-list mailing list