提交 1cdc9ece 编写于 作者: J Ján Tomko

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=1347550Signed-off-by: NJán Tomko <jtomko@redhat.com>
上级 c1766641
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册