From: Kiarie Kahurani <davidkiarie4(a)gmail.com>
introduce function
xenFormatXMVif(virConfPtr conf, ........);
which formats Vif config instead
signed-off-by: David Kiarie<davidkiarie4(a)gmail.com>
---
src/xenxs/xen_xm.c | 60 ++++++++++++++++++++++++++++++++++--------------------
1 file changed, 38 insertions(+), 22 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index bb7979d..9a6a827 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -1803,16 +1803,49 @@ int xenFormatXMEventActions(virConfPtr conf, virDomainDefPtr def)
}
-virConfPtr xenFormatXM(virConnectPtr conn,
- virDomainDefPtr def,
- int xendConfigVersion)
+static
+int xenFormatXMVif(virConfPtr conf, virConnectPtr conn,
+ virDomainDefPtr def, int xendConfigVersion)
+{
+ virConfValuePtr netVal = NULL;
+ size_t i;
+ int hvm = STREQ(def->os.type, "hvm");
+
+ if (VIR_ALLOC(netVal) < 0)
+ goto cleanup;
+ netVal->type = VIR_CONF_LIST;
+ netVal->list = NULL;
+
+ for (i = 0; i < def->nnets; i++) {
+ if (xenFormatXMNet(conn, netVal, def->nets[i],
+ hvm, xendConfigVersion) < 0)
+ goto cleanup;
+ }
+
+ if (netVal->list != NULL) {
+ int ret = virConfSetValue(conf, "vif", netVal);
+ netVal = NULL;
+ if (ret < 0)
+ goto cleanup;
+ }
+
+ VIR_FREE(netVal);
+ return 0;
+
+ cleanup:
+ virConfFreeValue(netVal);
+ return -1;
+}
+
+
+virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def,
+ int xendConfigVersion)
{
virConfPtr conf = NULL;
int hvm = 0;
size_t i;
char *cpus = NULL;
virConfValuePtr diskVal = NULL;
- virConfValuePtr netVal = NULL;
if (!(conf = virConfNew()))
goto cleanup;
@@ -2102,24 +2135,8 @@ virConfPtr xenFormatXM(virConnectPtr conn,
}
VIR_FREE(diskVal);
- if (VIR_ALLOC(netVal) < 0)
+ if (xenFormatXMVif(conf, conn, def, xendConfigVersion) < 0)
goto cleanup;
- netVal->type = VIR_CONF_LIST;
- netVal->list = NULL;
-
- for (i = 0; i < def->nnets; i++) {
- if (xenFormatXMNet(conn, netVal, def->nets[i],
- hvm, xendConfigVersion) < 0)
- goto cleanup;
- }
- if (netVal->list != NULL) {
- int ret = virConfSetValue(conf, "vif", netVal);
- netVal = NULL;
- if (ret < 0)
- goto cleanup;
- }
- VIR_FREE(netVal);
-
if (xenFormatXMPCI(conf, def) < 0)
goto cleanup;
@@ -2214,7 +2231,6 @@ virConfPtr xenFormatXM(virConnectPtr conn,
cleanup:
virConfFreeValue(diskVal);
- virConfFreeValue(netVal);
VIR_FREE(cpus);
if (conf)
virConfFree(conf);
--
1.8.4.5