separate virDomainDefParseHostdevInfo from virDomainDefParseXML,
move virDomainDefParseHostdevInfo into virDomainDefParseDeviceInfo
---
src/conf/domain_conf.c | 91 +++++++++++++++++++++++++++++++-------------------
1 file changed, 56 insertions(+), 35 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e2a4ce2..1e44e76 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -20412,6 +20412,61 @@ virDomainDefParseVideoInfo(virDomainParseTotalParamPtr param)
static int
+virDomainDefParseHostdevInfo(virDomainParseTotalParamPtr param)
+{
+ virDomainDefPtr def = param->def;
+ xmlXPathContextPtr ctxt = param->ctxt;
+ virDomainXMLOptionPtr xmlopt = param->xmlopt;
+ virHashTablePtr bootHash = param->bootHash;
+ unsigned int flags = param->flags;
+
+ int ret = -1;
+ int n = 0;
+ size_t i;
+ xmlNodePtr *nodes = NULL;
+
+ /* analysis of the host devices */
+ if ((n = virXPathNodeSet("./devices/hostdev", ctxt, &nodes)) < 0)
+ goto cleanup;
+ if (n && VIR_REALLOC_N(def->hostdevs, def->nhostdevs + n) < 0)
+ goto cleanup;
+ for (i = 0; i < n; i++) {
+ virDomainHostdevDefPtr hostdev;
+
+ hostdev = virDomainHostdevDefParseXML(xmlopt, nodes[i], ctxt,
+ bootHash, flags);
+ if (!hostdev)
+ goto cleanup;
+
+ if (hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB
&&
+ param->usb_none) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Can't add host USB device: "
+ "USB is disabled in this host"));
+ virDomainHostdevDefFree(hostdev);
+ goto cleanup;
+ }
+
+ def->hostdevs[def->nhostdevs++] = hostdev;
+
+ /* For a domain definition, we need to check if the controller
+ * for this hostdev exists yet and if not add it. This cannot be
+ * done during virDomainHostdevAssignAddress (as part of device
+ * post processing) because that will result in the failure to
+ * load the controller during hostdev hotplug.
+ */
+ if (virDomainDefMaybeAddHostdevSCSIcontroller(def) < 0)
+ goto cleanup;
+ }
+ ret = 0;
+
+ cleanup:
+ VIR_FREE(nodes);
+ return ret;
+}
+
+
+static int
virDomainDefParseDeviceInfo(virDomainParseTotalParamPtr param)
{
typedef int (*virDomainPreaseDeviceFuc)(virDomainParseTotalParamPtr param);
@@ -20433,6 +20488,7 @@ virDomainDefParseDeviceInfo(virDomainParseTotalParamPtr param)
virDomainDefParseGraphicsInfo,
virDomainDefParseSoundInfo,
virDomainDefParseVideoInfo,
+ virDomainDefParseHostdevInfo,
NULL
};
@@ -20536,41 +20592,6 @@ virDomainDefParseXML(xmlDocPtr xml,
fun_index++;
}
- /* analysis of the host devices */
- if ((n = virXPathNodeSet("./devices/hostdev", ctxt, &nodes)) < 0)
- goto error;
- if (n && VIR_REALLOC_N(def->hostdevs, def->nhostdevs + n) < 0)
- goto error;
- for (i = 0; i < n; i++) {
- virDomainHostdevDefPtr hostdev;
-
- hostdev = virDomainHostdevDefParseXML(xmlopt, nodes[i], ctxt,
- bootHash, flags);
- if (!hostdev)
- goto error;
-
- if (hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB
&&
- usb_none) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("Can't add host USB device: "
- "USB is disabled in this host"));
- virDomainHostdevDefFree(hostdev);
- goto error;
- }
-
- def->hostdevs[def->nhostdevs++] = hostdev;
-
- /* For a domain definition, we need to check if the controller
- * for this hostdev exists yet and if not add it. This cannot be
- * done during virDomainHostdevAssignAddress (as part of device
- * post processing) because that will result in the failure to
- * load the controller during hostdev hotplug.
- */
- if (virDomainDefMaybeAddHostdevSCSIcontroller(def) < 0)
- goto error;
- }
- VIR_FREE(nodes);
-
/* analysis of the watchdog devices */
def->watchdog = NULL;
if ((n = virXPathNodeSet("./devices/watchdog", ctxt, &nodes)) < 0)
--
2.8.3