From: Kiarie Kahurani <davidkiarie4(a)gmail.com>
introduce function
xenFormatXMDomainDisks(virConfPtr conf,.........);
which formats domain disks config instead
signed-off-by: David Kiarie<davidkiarie4(a)gmail.com>
---
src/xenxs/xen_xm.c | 72 +++++++++++++++++++++++++++++++++---------------------
1 file changed, 44 insertions(+), 28 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 6752b27..5a585ce 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -1892,6 +1892,49 @@ xenFormatXMCharDev(virConfPtr conf, virDomainDefPtr def)
}
+static int
+xenFormatXMDomainDisks(virConfPtr conf, virDomainDefPtr def,
+ int xendConfigVersion)
+{
+ virConfValuePtr diskVal = NULL;
+ size_t i = 0;
+ int hvm = STREQ(def->os.type, "hvm");
+
+ if (VIR_ALLOC(diskVal) < 0)
+ goto cleanup;
+
+ diskVal->type = VIR_CONF_LIST;
+ diskVal->list = NULL;
+
+ for (i = 0; i < def->ndisks; i++) {
+ if (xendConfigVersion == XEND_CONFIG_VERSION_3_0_2 &&
+ def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM &&
+ def->disks[i]->dst &&
+ STREQ(def->disks[i]->dst, "hdc")) {
+ continue;
+ }
+
+ if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY)
+ continue;
+
+ if (xenFormatXMDisk(diskVal, def->disks[i],
+ hvm, xendConfigVersion) < 0)
+ goto cleanup;
+ }
+
+ if (diskVal->list != NULL) {
+ int ret = virConfSetValue(conf, "disk", diskVal);
+ diskVal = NULL;
+ if (ret < 0)
+ goto cleanup;
+ }
+
+ return 0;
+
+ cleanup:
+ virConfFreeValue(diskVal);
+ return -1;
+}
/* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
either 32, or 64 on a platform where long is big enough. */
verify(MAX_VIRT_CPUS <= sizeof(1UL) * CHAR_BIT);
@@ -1905,7 +1948,6 @@ xenFormatXM(virConnectPtr conn,
int hvm = 0;
size_t i;
char *cpus = NULL;
- virConfValuePtr diskVal = NULL;
virConfValuePtr netVal = NULL;
if (!(conf = virConfNew()))
@@ -2173,33 +2215,8 @@ xenFormatXM(virConnectPtr conn,
}
}
- /* analyze of the devices */
- if (VIR_ALLOC(diskVal) < 0)
+ if (xenFormatXMDomainDisks(conf, def, xendConfigVersion) < 0)
goto cleanup;
- diskVal->type = VIR_CONF_LIST;
- diskVal->list = NULL;
-
- for (i = 0; i < def->ndisks; i++) {
- if (xendConfigVersion == XEND_CONFIG_VERSION_3_0_2 &&
- def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM &&
- def->disks[i]->dst &&
- STREQ(def->disks[i]->dst, "hdc")) {
- continue;
- }
- if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY)
- continue;
-
- if (xenFormatXMDisk(diskVal, def->disks[i],
- hvm, xendConfigVersion) < 0)
- goto cleanup;
- }
- if (diskVal->list != NULL) {
- int ret = virConfSetValue(conf, "disk", diskVal);
- diskVal = NULL;
- if (ret < 0)
- goto cleanup;
- }
- VIR_FREE(diskVal);
if (VIR_ALLOC(netVal) < 0)
goto cleanup;
@@ -2243,7 +2260,6 @@ xenFormatXM(virConnectPtr conn,
return conf;
cleanup:
- virConfFreeValue(diskVal);
virConfFreeValue(netVal);
VIR_FREE(cpus);
if (conf)
--
1.8.4.5