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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
bool
|
||||||
virDomainDefHasUSB(const virDomainDef *def)
|
virDomainDefHasUSB(const virDomainDef *def)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
@ -2700,6 +2700,8 @@ int virDomainDefPostParse(virDomainDefPtr def,
|
|||||||
unsigned int parseFlags,
|
unsigned int parseFlags,
|
||||||
virDomainXMLOptionPtr xmlopt,
|
virDomainXMLOptionPtr xmlopt,
|
||||||
void *parseOpaque);
|
void *parseOpaque);
|
||||||
|
bool
|
||||||
|
virDomainDefHasUSB(const virDomainDef *def);
|
||||||
|
|
||||||
int virDomainDeviceValidateAliasForHotplug(virDomainObjPtr vm,
|
int virDomainDeviceValidateAliasForHotplug(virDomainObjPtr vm,
|
||||||
virDomainDeviceDefPtr dev,
|
virDomainDeviceDefPtr dev,
|
||||||
|
@ -276,6 +276,7 @@ virDomainDefGetVcpusTopology;
|
|||||||
virDomainDefHasDeviceAddress;
|
virDomainDefHasDeviceAddress;
|
||||||
virDomainDefHasMemballoon;
|
virDomainDefHasMemballoon;
|
||||||
virDomainDefHasMemoryHotplug;
|
virDomainDefHasMemoryHotplug;
|
||||||
|
virDomainDefHasUSB;
|
||||||
virDomainDefHasVcpusOffline;
|
virDomainDefHasVcpusOffline;
|
||||||
virDomainDefLifecycleActionAllowed;
|
virDomainDefLifecycleActionAllowed;
|
||||||
virDomainDefMaybeAddController;
|
virDomainDefMaybeAddController;
|
||||||
|
@ -2701,6 +2701,13 @@ qemuDomainUSBAddressAddHubs(virDomainDefPtr def)
|
|||||||
&data,
|
&data,
|
||||||
false));
|
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)
|
if (data.count > available_ports)
|
||||||
hubs_needed = VIR_DIV_UP(data.count - available_ports + 1,
|
hubs_needed = VIR_DIV_UP(data.count - available_ports + 1,
|
||||||
VIR_DOMAIN_USB_HUB_PORTS - 1);
|
VIR_DOMAIN_USB_HUB_PORTS - 1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user