This function is going to make decisions based on the features set per each driver. For that we need the virDomainXMLOption object. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/conf/domain_conf.c | 165 ++++++++++++++++++++++++++++++------------------- 1 file changed, 102 insertions(+), 63 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b3feddc39..f4de4e288 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6402,7 +6402,8 @@ virDomainDeviceAddressParseXML(xmlNodePtr address, * @param node XML nodeset to parse for device address definition */ static int -virDomainDeviceInfoParseXML(xmlNodePtr node, +virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED, + xmlNodePtr node, virHashTablePtr bootHash, virDomainDeviceInfoPtr info, unsigned int flags) @@ -9177,7 +9178,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, } def->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; } else { - if (virDomainDeviceInfoParseXML(node, bootHash, &def->info, + if (virDomainDeviceInfoParseXML(xmlopt, node, bootHash, &def->info, flags | VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT) < 0) goto error; } @@ -9514,7 +9515,8 @@ virDomainControllerModelTypeToString(virDomainControllerDefPtr def, * @param node XML nodeset to parse for controller definition */ static virDomainControllerDefPtr -virDomainControllerDefParseXML(xmlNodePtr node, +virDomainControllerDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr node, xmlXPathContextPtr ctxt, unsigned int flags) { @@ -9663,7 +9665,8 @@ virDomainControllerDefParseXML(xmlNodePtr node, if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_USB && def->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE) { VIR_DEBUG("Ignoring device address for none model usb controller"); - } else if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) { + } else if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, + &def->info, flags) < 0) { goto error; } @@ -9890,7 +9893,8 @@ virDomainNetGenerateMAC(virDomainXMLOptionPtr xmlopt, * @param node XML nodeset to parse for disk definition */ static virDomainFSDefPtr -virDomainFSDefParseXML(xmlNodePtr node, +virDomainFSDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr node, xmlXPathContextPtr ctxt, unsigned int flags) { @@ -10047,7 +10051,7 @@ virDomainFSDefParseXML(xmlNodePtr node, def->dst = target; target = NULL; - if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, &def->info, flags) < 0) goto error; cleanup: @@ -10568,7 +10572,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, } def->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; } else { - if (virDomainDeviceInfoParseXML(node, bootHash, &def->info, + if (virDomainDeviceInfoParseXML(xmlopt, node, bootHash, &def->info, flags | VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT | VIR_DOMAIN_DEF_PARSE_ALLOW_ROM) < 0) goto error; @@ -11835,7 +11839,8 @@ virDomainChrDefParseXML(virDomainXMLOptionPtr xmlopt, if (def->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL && def->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD) { VIR_DEBUG("Ignoring device address for gustfwd channel"); - } else if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) { + } else if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, + &def->info, flags) < 0) { goto error; } @@ -11972,7 +11977,7 @@ virDomainSmartcardDefParseXML(virDomainXMLOptionPtr xmlopt, goto error; } - if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, &def->info, flags) < 0) goto error; if (def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID) { @@ -12005,7 +12010,8 @@ virDomainSmartcardDefParseXML(virDomainXMLOptionPtr xmlopt, * */ static virDomainTPMDefPtr -virDomainTPMDefParseXML(xmlNodePtr node, +virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr node, xmlXPathContextPtr ctxt, unsigned int flags) { @@ -12074,7 +12080,7 @@ virDomainTPMDefParseXML(xmlNodePtr node, goto error; } - if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, &def->info, flags) < 0) goto error; cleanup: @@ -12093,7 +12099,8 @@ virDomainTPMDefParseXML(xmlNodePtr node, } static virDomainPanicDefPtr -virDomainPanicDefParseXML(xmlNodePtr node, +virDomainPanicDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr node, unsigned int flags) { virDomainPanicDefPtr panic; @@ -12102,7 +12109,8 @@ virDomainPanicDefParseXML(xmlNodePtr node, if (VIR_ALLOC(panic) < 0) return NULL; - if (virDomainDeviceInfoParseXML(node, NULL, &panic->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, + &panic->info, flags) < 0) goto error; model = virXMLPropString(node, "model"); @@ -12125,7 +12133,8 @@ virDomainPanicDefParseXML(xmlNodePtr node, /* Parse the XML definition for an input device */ static virDomainInputDefPtr -virDomainInputDefParseXML(const virDomainDef *dom, +virDomainInputDefParseXML(virDomainXMLOptionPtr xmlopt, + const virDomainDef *dom, xmlNodePtr node, xmlXPathContextPtr ctxt, unsigned int flags) @@ -12236,7 +12245,7 @@ virDomainInputDefParseXML(const virDomainDef *dom, } } - if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, &def->info, flags) < 0) goto error; if (def->bus == VIR_DOMAIN_INPUT_BUS_USB && @@ -12276,7 +12285,9 @@ virDomainInputDefParseXML(const virDomainDef *dom, /* Parse the XML definition for a hub device */ static virDomainHubDefPtr -virDomainHubDefParseXML(xmlNodePtr node, unsigned int flags) +virDomainHubDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr node, + unsigned int flags) { virDomainHubDefPtr def; char *type = NULL; @@ -12298,7 +12309,7 @@ virDomainHubDefParseXML(xmlNodePtr node, unsigned int flags) goto error; } - if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, &def->info, flags) < 0) goto error; cleanup: @@ -13375,7 +13386,8 @@ virDomainSoundCodecDefParseXML(xmlNodePtr node) static virDomainSoundDefPtr -virDomainSoundDefParseXML(xmlNodePtr node, +virDomainSoundDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr node, xmlXPathContextPtr ctxt, unsigned int flags) { @@ -13427,7 +13439,7 @@ virDomainSoundDefParseXML(xmlNodePtr node, } } - if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, &def->info, flags) < 0) goto error; cleanup: @@ -13444,7 +13456,8 @@ virDomainSoundDefParseXML(xmlNodePtr node, static virDomainWatchdogDefPtr -virDomainWatchdogDefParseXML(xmlNodePtr node, +virDomainWatchdogDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr node, unsigned int flags) { @@ -13480,7 +13493,7 @@ virDomainWatchdogDefParseXML(xmlNodePtr node, } } - if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, &def->info, flags) < 0) goto error; cleanup: @@ -13592,7 +13605,7 @@ virDomainRNGDefParseXML(virDomainXMLOptionPtr xmlopt, break; } - if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, &def->info, flags) < 0) goto error; if (virDomainVirtioOptionsParseXML(virXPathNode("./driver", ctxt), @@ -13615,7 +13628,8 @@ virDomainRNGDefParseXML(virDomainXMLOptionPtr xmlopt, static virDomainMemballoonDefPtr -virDomainMemballoonDefParseXML(xmlNodePtr node, +virDomainMemballoonDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr node, xmlXPathContextPtr ctxt, unsigned int flags) { @@ -13661,7 +13675,8 @@ virDomainMemballoonDefParseXML(xmlNodePtr node, if (def->model == VIR_DOMAIN_MEMBALLOON_MODEL_NONE) VIR_DEBUG("Ignoring device address for none model Memballoon"); - else if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) + else if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, + &def->info, flags) < 0) goto error; if (virDomainVirtioOptionsParseXML(virXPathNode("./driver", ctxt), @@ -13682,7 +13697,8 @@ virDomainMemballoonDefParseXML(xmlNodePtr node, } static virDomainNVRAMDefPtr -virDomainNVRAMDefParseXML(xmlNodePtr node, +virDomainNVRAMDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr node, unsigned int flags) { virDomainNVRAMDefPtr def; @@ -13690,7 +13706,7 @@ virDomainNVRAMDefParseXML(xmlNodePtr node, if (VIR_ALLOC(def) < 0) return NULL; - if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, &def->info, flags) < 0) goto error; return def; @@ -13701,7 +13717,8 @@ virDomainNVRAMDefParseXML(xmlNodePtr node, } static virDomainShmemDefPtr -virDomainShmemDefParseXML(xmlNodePtr node, +virDomainShmemDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr node, xmlXPathContextPtr ctxt, unsigned int flags) { @@ -13785,7 +13802,7 @@ virDomainShmemDefParseXML(xmlNodePtr node, goto cleanup; } - if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, &def->info, flags) < 0) goto cleanup; @@ -14206,7 +14223,8 @@ virDomainVideoDriverDefParseXML(xmlNodePtr node) } static virDomainVideoDefPtr -virDomainVideoDefParseXML(xmlNodePtr node, +virDomainVideoDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr node, xmlXPathContextPtr ctxt, const virDomainDef *dom, unsigned int flags) @@ -14320,7 +14338,7 @@ virDomainVideoDefParseXML(xmlNodePtr node, } } - if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, &def->info, flags) < 0) goto error; def->driver = virDomainVideoDriverDefParseXML(node); @@ -14388,7 +14406,7 @@ virDomainHostdevDefParseXML(virDomainXMLOptionPtr xmlopt, } if (def->info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { - if (virDomainDeviceInfoParseXML(node, bootHash, def->info, + if (virDomainDeviceInfoParseXML(xmlopt, node, bootHash, def->info, flags | VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT | VIR_DOMAIN_DEF_PARSE_ALLOW_ROM) < 0) goto error; @@ -14475,7 +14493,7 @@ virDomainRedirdevDefParseXML(virDomainXMLOptionPtr xmlopt, if (def->source->type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) def->source->data.spicevmc = VIR_DOMAIN_CHR_SPICEVMC_USBREDIR; - if (virDomainDeviceInfoParseXML(node, bootHash, &def->info, + if (virDomainDeviceInfoParseXML(xmlopt, node, bootHash, &def->info, flags | VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT) < 0) goto error; @@ -14887,7 +14905,8 @@ virDomainMemoryTargetDefParseXML(xmlNodePtr node, static virDomainMemoryDefPtr -virDomainMemoryDefParseXML(xmlNodePtr memdevNode, +virDomainMemoryDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr memdevNode, xmlXPathContextPtr ctxt, unsigned int flags) { @@ -14941,7 +14960,8 @@ virDomainMemoryDefParseXML(xmlNodePtr memdevNode, if (virDomainMemoryTargetDefParseXML(node, ctxt, def) < 0) goto error; - if (virDomainDeviceInfoParseXML(memdevNode, NULL, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, memdevNode, + NULL, &def->info, flags) < 0) goto error; ctxt->node = save; @@ -15081,7 +15101,7 @@ virDomainDeviceDefParse(const char *xmlStr, goto error; break; case VIR_DOMAIN_DEVICE_FS: - if (!(dev->data.fs = virDomainFSDefParseXML(node, ctxt, flags))) + if (!(dev->data.fs = virDomainFSDefParseXML(xmlopt, node, ctxt, flags))) goto error; break; case VIR_DOMAIN_DEVICE_NET: @@ -15091,20 +15111,23 @@ virDomainDeviceDefParse(const char *xmlStr, goto error; break; case VIR_DOMAIN_DEVICE_INPUT: - if (!(dev->data.input = virDomainInputDefParseXML(def, node, + if (!(dev->data.input = virDomainInputDefParseXML(xmlopt, def, node, ctxt, flags))) goto error; break; case VIR_DOMAIN_DEVICE_SOUND: - if (!(dev->data.sound = virDomainSoundDefParseXML(node, ctxt, flags))) + if (!(dev->data.sound = virDomainSoundDefParseXML(xmlopt, node, + ctxt, flags))) goto error; break; case VIR_DOMAIN_DEVICE_WATCHDOG: - if (!(dev->data.watchdog = virDomainWatchdogDefParseXML(node, flags))) + if (!(dev->data.watchdog = virDomainWatchdogDefParseXML(xmlopt, + node, flags))) goto error; break; case VIR_DOMAIN_DEVICE_VIDEO: - if (!(dev->data.video = virDomainVideoDefParseXML(node, ctxt, def, flags))) + if (!(dev->data.video = virDomainVideoDefParseXML(xmlopt, node, + ctxt, def, flags))) goto error; break; case VIR_DOMAIN_DEVICE_HOSTDEV: @@ -15114,8 +15137,8 @@ virDomainDeviceDefParse(const char *xmlStr, goto error; break; case VIR_DOMAIN_DEVICE_CONTROLLER: - if (!(dev->data.controller = virDomainControllerDefParseXML(node, ctxt, - flags))) + if (!(dev->data.controller = virDomainControllerDefParseXML(xmlopt, node, + ctxt, flags))) goto error; break; case VIR_DOMAIN_DEVICE_GRAPHICS: @@ -15123,7 +15146,7 @@ virDomainDeviceDefParse(const char *xmlStr, goto error; break; case VIR_DOMAIN_DEVICE_HUB: - if (!(dev->data.hub = virDomainHubDefParseXML(node, flags))) + if (!(dev->data.hub = virDomainHubDefParseXML(xmlopt, node, flags))) goto error; break; case VIR_DOMAIN_DEVICE_REDIRDEV: @@ -15151,29 +15174,32 @@ virDomainDeviceDefParse(const char *xmlStr, goto error; break; case VIR_DOMAIN_DEVICE_MEMBALLOON: - if (!(dev->data.memballoon = virDomainMemballoonDefParseXML(node, + if (!(dev->data.memballoon = virDomainMemballoonDefParseXML(xmlopt, + node, ctxt, flags))) goto error; break; case VIR_DOMAIN_DEVICE_NVRAM: - if (!(dev->data.nvram = virDomainNVRAMDefParseXML(node, flags))) + if (!(dev->data.nvram = virDomainNVRAMDefParseXML(xmlopt, node, flags))) goto error; break; case VIR_DOMAIN_DEVICE_SHMEM: - if (!(dev->data.shmem = virDomainShmemDefParseXML(node, ctxt, flags))) + if (!(dev->data.shmem = virDomainShmemDefParseXML(xmlopt, node, + ctxt, flags))) goto error; break; case VIR_DOMAIN_DEVICE_TPM: - if (!(dev->data.tpm = virDomainTPMDefParseXML(node, ctxt, flags))) + if (!(dev->data.tpm = virDomainTPMDefParseXML(xmlopt, node, ctxt, flags))) goto error; break; case VIR_DOMAIN_DEVICE_PANIC: - if (!(dev->data.panic = virDomainPanicDefParseXML(node, flags))) + if (!(dev->data.panic = virDomainPanicDefParseXML(xmlopt, node, flags))) goto error; break; case VIR_DOMAIN_DEVICE_MEMORY: - if (!(dev->data.memory = virDomainMemoryDefParseXML(node, ctxt, flags))) + if (!(dev->data.memory = virDomainMemoryDefParseXML(xmlopt, node, + ctxt, flags))) goto error; break; case VIR_DOMAIN_DEVICE_IOMMU: @@ -18750,7 +18776,8 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; for (i = 0; i < n; i++) { - virDomainControllerDefPtr controller = virDomainControllerDefParseXML(nodes[i], + virDomainControllerDefPtr controller = virDomainControllerDefParseXML(xmlopt, + nodes[i], ctxt, flags); @@ -18816,7 +18843,9 @@ virDomainDefParseXML(xmlDocPtr xml, if (n && VIR_ALLOC_N(def->fss, n) < 0) goto error; for (i = 0; i < n; i++) { - virDomainFSDefPtr fs = virDomainFSDefParseXML(nodes[i], ctxt, + virDomainFSDefPtr fs = virDomainFSDefParseXML(xmlopt, + nodes[i], + ctxt, flags); if (!fs) goto error; @@ -18980,7 +19009,8 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; for (i = 0; i < n; i++) { - virDomainInputDefPtr input = virDomainInputDefParseXML(def, + virDomainInputDefPtr input = virDomainInputDefParseXML(xmlopt, + def, nodes[i], ctxt, flags); @@ -19022,7 +19052,8 @@ virDomainDefParseXML(xmlDocPtr xml, if (n && VIR_ALLOC_N(def->sounds, n) < 0) goto error; for (i = 0; i < n; i++) { - virDomainSoundDefPtr sound = virDomainSoundDefParseXML(nodes[i], + virDomainSoundDefPtr sound = virDomainSoundDefParseXML(xmlopt, + nodes[i], ctxt, flags); if (!sound) @@ -19041,7 +19072,8 @@ virDomainDefParseXML(xmlDocPtr xml, virDomainVideoDefPtr video; ssize_t insertAt = -1; - if (!(video = virDomainVideoDefParseXML(nodes[i], ctxt, def, flags))) + if (!(video = virDomainVideoDefParseXML(xmlopt, nodes[i], + ctxt, def, flags))) goto error; if (video->primary) { @@ -19110,8 +19142,9 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; } if (n > 0) { - virDomainWatchdogDefPtr watchdog = - virDomainWatchdogDefParseXML(nodes[0], flags); + virDomainWatchdogDefPtr watchdog; + + watchdog = virDomainWatchdogDefParseXML(xmlopt, nodes[0], flags); if (!watchdog) goto error; @@ -19129,8 +19162,9 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; } if (n > 0) { - virDomainMemballoonDefPtr memballoon = - virDomainMemballoonDefParseXML(nodes[0], ctxt, flags); + virDomainMemballoonDefPtr memballoon; + + memballoon = virDomainMemballoonDefParseXML(xmlopt, nodes[0], ctxt, flags); if (!memballoon) goto error; @@ -19164,7 +19198,7 @@ virDomainDefParseXML(xmlDocPtr xml, } if (n > 0) { - if (!(def->tpm = virDomainTPMDefParseXML(nodes[0], ctxt, flags))) + if (!(def->tpm = virDomainTPMDefParseXML(xmlopt, nodes[0], ctxt, flags))) goto error; } VIR_FREE(nodes); @@ -19178,7 +19212,7 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; } else if (n == 1) { virDomainNVRAMDefPtr nvram = - virDomainNVRAMDefParseXML(nodes[0], flags); + virDomainNVRAMDefParseXML(xmlopt, nodes[0], flags); if (!nvram) goto error; def->nvram = nvram; @@ -19191,7 +19225,9 @@ virDomainDefParseXML(xmlDocPtr xml, if (n && VIR_ALLOC_N(def->hubs, n) < 0) goto error; for (i = 0; i < n; i++) { - virDomainHubDefPtr hub = virDomainHubDefParseXML(nodes[i], flags); + virDomainHubDefPtr hub; + + hub = virDomainHubDefParseXML(xmlopt, nodes[i], flags); if (!hub) goto error; @@ -19247,7 +19283,9 @@ virDomainDefParseXML(xmlDocPtr xml, if (n && VIR_ALLOC_N(def->panics, n) < 0) goto error; for (i = 0; i < n; i++) { - virDomainPanicDefPtr panic = virDomainPanicDefParseXML(nodes[i], flags); + virDomainPanicDefPtr panic; + + panic = virDomainPanicDefParseXML(xmlopt, nodes[i], flags); if (!panic) goto error; @@ -19265,7 +19303,7 @@ virDomainDefParseXML(xmlDocPtr xml, for (i = 0; i < n; i++) { virDomainShmemDefPtr shmem; ctxt->node = nodes[i]; - shmem = virDomainShmemDefParseXML(nodes[i], ctxt, flags); + shmem = virDomainShmemDefParseXML(xmlopt, nodes[i], ctxt, flags); if (!shmem) goto error; @@ -19281,7 +19319,8 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; for (i = 0; i < n; i++) { - virDomainMemoryDefPtr mem = virDomainMemoryDefParseXML(nodes[i], + virDomainMemoryDefPtr mem = virDomainMemoryDefParseXML(xmlopt, + nodes[i], ctxt, flags); if (!mem) -- 2.13.6 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list