From: Kiarie Kahurani <davidkiarie4(a)gmail.com>
introduce function
xenFormatXMDiskList(virConfPtr conf, .....);
which formats xm disk config instead
signed-off-by: David Kiarie<davidkiarie4(a)gmail.com>
---
src/xenxs/xen_xm.c | 73 ++++++++++++++++++++++++++++++++++--------------------
1 file changed, 46 insertions(+), 27 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index f2b1267..2d975d5 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -2022,6 +2022,51 @@ int xenFormatXMCPUFeatures(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;
+}
+
+
virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def,
int xendConfigVersion)
{
@@ -2142,34 +2187,8 @@ virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def,
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 (xenFormatXMVif(conf, conn, def, xendConfigVersion) < 0)
goto cleanup;
if (xenFormatXMPCI(conf, def) < 0)
--
1.8.4.5