separate virDomainDefParseInterfaceInfo from virDomainDefParseXML,
move virDomainDefParseInterfaceInfo into virDomainDefParseDeviceInfo
---
src/conf/domain_conf.c | 82 +++++++++++++++++++++++++++++++-------------------
1 file changed, 51 insertions(+), 31 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 72ddbd7..3448c42 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -19981,6 +19981,56 @@ virDomainDefParseFilesystemInfo(virDomainParseTotalParamPtr
param)
static int
+virDomainDefParseInterfaceInfo(virDomainParseTotalParamPtr param)
+{
+ virDomainDefPtr def = param->def;
+ xmlXPathContextPtr ctxt = param->ctxt;
+ virDomainXMLOptionPtr xmlopt = param->xmlopt;
+ unsigned int flags = param->flags;
+ virHashTablePtr bootHash = param->bootHash;
+ virCapsPtr caps = param->caps;
+
+ int ret = -1;
+ int n = 0;
+ size_t i;
+ char *netprefix = NULL;
+ xmlNodePtr *nodes = NULL;
+
+ /* analysis of the network devices */
+ if ((n = virXPathNodeSet("./devices/interface", ctxt, &nodes)) < 0)
+ goto cleanup;
+ if (n && VIR_ALLOC_N(def->nets, n) < 0)
+ goto cleanup;
+ netprefix = caps->host.netprefix;
+ for (i = 0; i < n; i++) {
+ virDomainNetDefPtr net = virDomainNetDefParseXML(xmlopt,
+ nodes[i],
+ ctxt,
+ bootHash,
+ netprefix,
+ flags);
+ if (!net)
+ goto cleanup;
+
+ def->nets[def->nnets++] = net;
+
+ /* <interface type='hostdev'> (and <interface
type='net'>
+ * where the actual network type is already known to be
+ * hostdev) must also be in the hostdevs array.
+ */
+ if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_HOSTDEV &&
+ virDomainHostdevInsert(def, virDomainNetGetActualHostdev(net)) < 0) {
+ goto cleanup;
+ }
+ }
+ ret = 0;
+
+ cleanup:
+ VIR_FREE(nodes);
+ return ret;
+}
+
+static int
virDomainDefParseDeviceInfo(virDomainParseTotalParamPtr param)
{
typedef int (*virDomainPreaseDeviceFuc)(virDomainParseTotalParamPtr param);
@@ -19992,6 +20042,7 @@ virDomainDefParseDeviceInfo(virDomainParseTotalParamPtr param)
virDomainDefParseDisksInfo,
virDomainDefParseLeaseInfo,
virDomainDefParseFilesystemInfo,
+ virDomainDefParseInterfaceInfo,
NULL
};
@@ -20027,7 +20078,6 @@ virDomainDefParseXML(xmlDocPtr xml,
bool uuid_generated = false;
virHashTablePtr bootHash = NULL;
bool usb_none = false;
- char *netprefix = NULL;
virDomainParseTotalParam param = {
xml,
root,
@@ -20096,36 +20146,6 @@ virDomainDefParseXML(xmlDocPtr xml,
fun_index++;
}
- /* analysis of the network devices */
- if ((n = virXPathNodeSet("./devices/interface", ctxt, &nodes)) < 0)
- goto error;
- if (n && VIR_ALLOC_N(def->nets, n) < 0)
- goto error;
- netprefix = caps->host.netprefix;
- for (i = 0; i < n; i++) {
- virDomainNetDefPtr net = virDomainNetDefParseXML(xmlopt,
- nodes[i],
- ctxt,
- bootHash,
- netprefix,
- flags);
- if (!net)
- goto error;
-
- def->nets[def->nnets++] = net;
-
- /* <interface type='hostdev'> (and <interface
type='net'>
- * where the actual network type is already known to be
- * hostdev) must also be in the hostdevs array.
- */
- if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_HOSTDEV &&
- virDomainHostdevInsert(def, virDomainNetGetActualHostdev(net)) < 0) {
- goto error;
- }
- }
- VIR_FREE(nodes);
-
-
/* analysis of the smartcard devices */
if ((n = virXPathNodeSet("./devices/smartcard", ctxt, &nodes)) < 0)
goto error;
--
2.8.3