mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-11 06:01: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
|
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();
|
||||||
@ -7276,25 +7278,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,
|
remaining = virDomainChrSourceDefParseXML(&def->source.chr, cur, flags,
|
||||||
NULL, NULL, NULL, 0);
|
NULL, NULL, NULL, 0);
|
||||||
if (remaining != 0)
|
if (remaining < 0)
|
||||||
goto error;
|
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 &&
|
||||||
@ -7638,7 +7635,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,
|
||||||
@ -8186,7 +8183,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;
|
||||||
@ -9769,6 +9767,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;
|
||||||
@ -13192,7 +13191,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…
x
Reference in New Issue
Block a user