mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
qemu: report a nicer error when USB is disabled
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 Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
c17666419b
commit
1cdc9ecebd
@ -5225,7 +5225,7 @@ virDomainDiskDefValidate(const virDomainDiskDef *disk)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool
|
||||
bool
|
||||
virDomainDefHasUSB(const virDomainDef *def)
|
||||
{
|
||||
size_t i;
|
||||
|
@ -2700,6 +2700,8 @@ int virDomainDefPostParse(virDomainDefPtr def,
|
||||
unsigned int parseFlags,
|
||||
virDomainXMLOptionPtr xmlopt,
|
||||
void *parseOpaque);
|
||||
bool
|
||||
virDomainDefHasUSB(const virDomainDef *def);
|
||||
|
||||
int virDomainDeviceValidateAliasForHotplug(virDomainObjPtr vm,
|
||||
virDomainDeviceDefPtr dev,
|
||||
|
@ -276,6 +276,7 @@ virDomainDefGetVcpusTopology;
|
||||
virDomainDefHasDeviceAddress;
|
||||
virDomainDefHasMemballoon;
|
||||
virDomainDefHasMemoryHotplug;
|
||||
virDomainDefHasUSB;
|
||||
virDomainDefHasVcpusOffline;
|
||||
virDomainDefLifecycleActionAllowed;
|
||||
virDomainDefMaybeAddController;
|
||||
|
@ -2701,6 +2701,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;
|
||||
}
|
||||
|
||||
if (data.count > available_ports)
|
||||
hubs_needed = VIR_DIV_UP(data.count - available_ports + 1,
|
||||
VIR_DOMAIN_USB_HUB_PORTS - 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user