mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-05 19:29:33 +00:00
conf: add support for booting from redirected USB devices
Commit a4c19459aa8634c43b51e8138fb1d7eec4c17824 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 (cherry picked from commit cc244e24416b7785258c69995483015bbf8927dd)
This commit is contained in:
parent
b300c71fbf
commit
2484fb2ef7
@ -7240,11 +7240,13 @@ error:
|
||||
|
||||
static virDomainRedirdevDefPtr
|
||||
virDomainRedirdevDefParseXML(const xmlNodePtr node,
|
||||
virBitmapPtr bootMap,
|
||||
unsigned int flags)
|
||||
{
|
||||
xmlNodePtr cur;
|
||||
virDomainRedirdevDefPtr def;
|
||||
char *bus, *type = NULL;
|
||||
int remaining;
|
||||
|
||||
if (VIR_ALLOC(def) < 0) {
|
||||
virReportOOMError();
|
||||
@ -7276,25 +7278,20 @@ virDomainRedirdevDefParseXML(const xmlNodePtr node,
|
||||
}
|
||||
|
||||
cur = node->children;
|
||||
while (cur != NULL) {
|
||||
if (cur->type == XML_ELEMENT_NODE) {
|
||||
if (xmlStrEqual(cur->name, BAD_CAST "source")) {
|
||||
int remaining;
|
||||
|
||||
remaining = virDomainChrSourceDefParseXML(&def->source.chr, cur, flags,
|
||||
NULL, NULL, NULL, 0);
|
||||
if (remaining != 0)
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
cur = cur->next;
|
||||
}
|
||||
/* boot gets parsed in virDomainDeviceInfoParseXML
|
||||
* source gets parsed in virDomainChrSourceDefParseXML
|
||||
* we don't know any of the elements that might remain */
|
||||
remaining = virDomainChrSourceDefParseXML(&def->source.chr, cur, flags,
|
||||
NULL, NULL, NULL, 0);
|
||||
if (remaining < 0)
|
||||
goto error;
|
||||
|
||||
if (def->source.chr.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) {
|
||||
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;
|
||||
|
||||
if (def->bus == VIR_DOMAIN_REDIRDEV_BUS_USB &&
|
||||
@ -7638,7 +7635,7 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps,
|
||||
goto error;
|
||||
} else if (xmlStrEqual(node->name, BAD_CAST "redirdev")) {
|
||||
dev->type = VIR_DOMAIN_DEVICE_REDIRDEV;
|
||||
if (!(dev->data.redirdev = virDomainRedirdevDefParseXML(node, flags)))
|
||||
if (!(dev->data.redirdev = virDomainRedirdevDefParseXML(node, NULL, flags)))
|
||||
goto error;
|
||||
} else {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
@ -8186,7 +8183,8 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt,
|
||||
|
||||
if (virXPathULong("count(./devices/disk[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",
|
||||
_("cannot count boot devices"));
|
||||
goto cleanup;
|
||||
@ -9769,6 +9767,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
|
||||
goto no_memory;
|
||||
for (i = 0 ; i < n ; i++) {
|
||||
virDomainRedirdevDefPtr redirdev = virDomainRedirdevDefParseXML(nodes[i],
|
||||
bootMap,
|
||||
flags);
|
||||
if (!redirdev)
|
||||
goto error;
|
||||
@ -13192,7 +13191,8 @@ virDomainRedirdevDefFormat(virBufferPtr buf,
|
||||
virBufferAsprintf(buf, " <redirdev bus='%s'", bus);
|
||||
if (virDomainChrSourceDefFormat(buf, &def->source.chr, false, flags) < 0)
|
||||
return -1;
|
||||
if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
|
||||
if (virDomainDeviceInfoFormat(buf, &def->info,
|
||||
flags | VIR_DOMAIN_XML_INTERNAL_ALLOW_BOOT) < 0)
|
||||
return -1;
|
||||
virBufferAddLit(buf, " </redirdev>\n");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user