mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
conf: add support for booting from redirected USB devices
Commit a4c19459aa
only added the
QEMU capability flag, command line option and added the boot element
for redirdev's in the XML schema.
This patch adds support for parsing and writing the XML with redirdevs
with the boot flag. It also ignores unknown XML elements in redirdev
instead of failing with:
"error: An error occurred, but the cause is unknown"
Bug: https://bugzilla.redhat.com/show_bug.cgi?id=805414
This commit is contained in:
parent
f2f9ae426a
commit
cc244e2441
@ -7312,11 +7312,13 @@ error:
|
|||||||
|
|
||||||
static virDomainRedirdevDefPtr
|
static virDomainRedirdevDefPtr
|
||||||
virDomainRedirdevDefParseXML(const xmlNodePtr node,
|
virDomainRedirdevDefParseXML(const xmlNodePtr node,
|
||||||
|
virBitmapPtr bootMap,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
xmlNodePtr cur;
|
xmlNodePtr cur;
|
||||||
virDomainRedirdevDefPtr def;
|
virDomainRedirdevDefPtr def;
|
||||||
char *bus, *type = NULL;
|
char *bus, *type = NULL;
|
||||||
|
int remaining;
|
||||||
|
|
||||||
if (VIR_ALLOC(def) < 0) {
|
if (VIR_ALLOC(def) < 0) {
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
@ -7348,25 +7350,20 @@ virDomainRedirdevDefParseXML(const xmlNodePtr node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
cur = node->children;
|
cur = node->children;
|
||||||
while (cur != NULL) {
|
/* boot gets parsed in virDomainDeviceInfoParseXML
|
||||||
if (cur->type == XML_ELEMENT_NODE) {
|
* source gets parsed in virDomainChrSourceDefParseXML
|
||||||
if (xmlStrEqual(cur->name, BAD_CAST "source")) {
|
* we don't know any of the elements that might remain */
|
||||||
int remaining;
|
remaining = virDomainChrSourceDefParseXML(&def->source.chr, cur, flags,
|
||||||
|
NULL, NULL, NULL, 0);
|
||||||
remaining = virDomainChrSourceDefParseXML(&def->source.chr, cur, flags,
|
if (remaining < 0)
|
||||||
NULL, NULL, NULL, 0);
|
goto error;
|
||||||
if (remaining != 0)
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cur = cur->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (def->source.chr.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) {
|
if (def->source.chr.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) {
|
||||||
def->source.chr.data.spicevmc = VIR_DOMAIN_CHR_SPICEVMC_USBREDIR;
|
def->source.chr.data.spicevmc = VIR_DOMAIN_CHR_SPICEVMC_USBREDIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0)
|
if (virDomainDeviceInfoParseXML(node, bootMap, &def->info,
|
||||||
|
flags | VIR_DOMAIN_XML_INTERNAL_ALLOW_BOOT) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (def->bus == VIR_DOMAIN_REDIRDEV_BUS_USB &&
|
if (def->bus == VIR_DOMAIN_REDIRDEV_BUS_USB &&
|
||||||
@ -7711,7 +7708,7 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps,
|
|||||||
goto error;
|
goto error;
|
||||||
} else if (xmlStrEqual(node->name, BAD_CAST "redirdev")) {
|
} else if (xmlStrEqual(node->name, BAD_CAST "redirdev")) {
|
||||||
dev->type = VIR_DOMAIN_DEVICE_REDIRDEV;
|
dev->type = VIR_DOMAIN_DEVICE_REDIRDEV;
|
||||||
if (!(dev->data.redirdev = virDomainRedirdevDefParseXML(node, flags)))
|
if (!(dev->data.redirdev = virDomainRedirdevDefParseXML(node, NULL, flags)))
|
||||||
goto error;
|
goto error;
|
||||||
} else {
|
} else {
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
@ -8295,7 +8292,8 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt,
|
|||||||
|
|
||||||
if (virXPathULong("count(./devices/disk[boot]"
|
if (virXPathULong("count(./devices/disk[boot]"
|
||||||
"|./devices/interface[boot]"
|
"|./devices/interface[boot]"
|
||||||
"|./devices/hostdev[boot])", ctxt, &deviceBoot) < 0) {
|
"|./devices/hostdev[boot]"
|
||||||
|
"|./devices/redirdev[boot])", ctxt, &deviceBoot) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("cannot count boot devices"));
|
_("cannot count boot devices"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -10009,6 +10007,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
|
|||||||
goto no_memory;
|
goto no_memory;
|
||||||
for (i = 0 ; i < n ; i++) {
|
for (i = 0 ; i < n ; i++) {
|
||||||
virDomainRedirdevDefPtr redirdev = virDomainRedirdevDefParseXML(nodes[i],
|
virDomainRedirdevDefPtr redirdev = virDomainRedirdevDefParseXML(nodes[i],
|
||||||
|
bootMap,
|
||||||
flags);
|
flags);
|
||||||
if (!redirdev)
|
if (!redirdev)
|
||||||
goto error;
|
goto error;
|
||||||
@ -13449,7 +13448,8 @@ virDomainRedirdevDefFormat(virBufferPtr buf,
|
|||||||
virBufferAsprintf(buf, " <redirdev bus='%s'", bus);
|
virBufferAsprintf(buf, " <redirdev bus='%s'", bus);
|
||||||
if (virDomainChrSourceDefFormat(buf, &def->source.chr, false, flags) < 0)
|
if (virDomainChrSourceDefFormat(buf, &def->source.chr, false, flags) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
|
if (virDomainDeviceInfoFormat(buf, &def->info,
|
||||||
|
flags | VIR_DOMAIN_XML_INTERNAL_ALLOW_BOOT) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
virBufferAddLit(buf, " </redirdev>\n");
|
virBufferAddLit(buf, " </redirdev>\n");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user