From: Kiarie Kahurani <davidkiarie4(a)gmail.com>
Introduce function
xenFormatXMDomainDisks(virConfPtr conf, .....);
which formats disk config
signed-off-by: David Kiarie<davidkiarie4(a)gmail.com>
---
src/xenxs/xen_xm.c | 62 +++++++++++++++++++++++++++++++-----------------------
1 file changed, 36 insertions(+), 26 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 613730f..10f3d05 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -1956,6 +1956,41 @@ static int xenFormatXMVfb(virConfPtr conf, virDomainDefPtr def,
return 0;
}
+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)
+ return -1;
+ 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)
+ return -1;
+ }
+ if (diskVal->list != NULL) {
+ int ret = virConfSetValue(conf, "disk", diskVal);
+ diskVal = NULL;
+ if (ret < 0)
+ return -1;
+ }
+ VIR_FREE(diskVal);
+
+ return 0;
+}
virConfPtr xenFormatXM(virConnectPtr conn,
virDomainDefPtr def,
int xendConfigVersion)
@@ -2134,33 +2169,8 @@ virConfPtr xenFormatXM(virConnectPtr conn,
}
if (xenFormatXMVfb(conf, def, xendConfigVersion) < 0)
goto cleanup;
- /* 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 (xenFormatXMDomainNet(conf, conn, def, xendConfigVersion) < 0)
goto cleanup;
if (xenFormatXMPCI(conf, def) < 0)
--
1.8.4.5