From: Kiarie Kahurani <davidkiarie4(a)gmail.com>
introduce function
xenParseXMOS(virConfPtr conf,.......)
which parses OS config instead
signed-off-by: David Kiarie<davidkiarie4(a)gmail.com>
---
src/xenxs/xen_xm.c | 132 ++++++++++++++++++++++++++++++-----------------------
1 file changed, 75 insertions(+), 57 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 38434be..62c7e62 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -848,6 +848,79 @@ int xenParseXMVfb(virConfPtr conf, virDomainDefPtr def,
}
+static
+int xenParseXMOS(virConfPtr conf, virDomainDefPtr def)
+{
+ size_t i;
+
+ if (STREQ(def->os.type, "hvm")) {
+ const char *boot;
+ if (xenXMConfigCopyStringOpt(conf, "device_model",
&def->emulator) < 0)
+ return -1;
+
+ if (xenXMConfigCopyStringOpt(conf, "device_model",
&def->emulator) < 0)
+ return -1;
+
+ if (xenXMConfigCopyString(conf, "kernel", &def->os.loader) <
0)
+ return -1;
+
+ if (xenXMConfigGetString(conf, "boot", &boot, "c") <
0)
+ return -1;
+
+ for (i = 0; i < VIR_DOMAIN_BOOT_LAST && boot[i]; i++) {
+ switch (*boot) {
+ case 'a':
+ def->os.bootDevs[i] = VIR_DOMAIN_BOOT_FLOPPY;
+ break;
+ case 'd':
+ def->os.bootDevs[i] = VIR_DOMAIN_BOOT_CDROM;
+ break;
+ case 'n':
+ def->os.bootDevs[i] = VIR_DOMAIN_BOOT_NET;
+ break;
+ case 'c':
+ default:
+ def->os.bootDevs[i] = VIR_DOMAIN_BOOT_DISK;
+ break;
+ }
+ def->os.nBootDevs++;
+ }
+ } else {
+ const char *extra, *root;
+
+ if (xenXMConfigCopyStringOpt(conf, "bootloader",
&def->os.bootloader) < 0)
+ return -1;
+
+ if (xenXMConfigCopyStringOpt(conf, "bootargs",
&def->os.bootloaderArgs) < 0)
+ return -1;
+
+ if (xenXMConfigCopyStringOpt(conf, "kernel", &def->os.kernel)
< 0)
+ return -1;
+
+ if (xenXMConfigCopyStringOpt(conf, "ramdisk", &def->os.initrd)
< 0)
+ return -1;
+
+ if (xenXMConfigGetString(conf, "extra", &extra, NULL) < 0)
+ return -1;
+
+ if (xenXMConfigGetString(conf, "root", &root, NULL) < 0)
+ return -1;
+
+ if (root) {
+ if (virAsprintf(&def->os.cmdline, "root=%s %s", root, extra)
< 0)
+ return -1;
+
+ } else {
+ if (VIR_STRDUP(def->os.cmdline, extra) < 0)
+ return -1;
+
+ }
+ }
+
+ return 0;
+}
+
+
virDomainDefPtr
xenParseXM(virConfPtr conf, int xendConfigVersion,
virCapsPtr caps)
@@ -858,8 +931,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
virDomainDefPtr def = NULL;
virDomainDiskDefPtr disk = NULL;
virDomainNetDefPtr net = NULL;
- virDomainGraphicsDefPtr graphics = NULL;
- size_t i;
const char *defaultMachine;
char *script = NULL;
char *listenAddr = NULL;
@@ -903,58 +974,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
goto cleanup;
}
- if (hvm) {
- const char *boot;
- if (xenXMConfigCopyString(conf, "kernel", &def->os.loader) <
0)
- goto cleanup;
-
- if (xenXMConfigGetString(conf, "boot", &boot, "c") <
0)
- goto cleanup;
-
- for (i = 0; i < VIR_DOMAIN_BOOT_LAST && boot[i]; i++) {
- switch (*boot) {
- case 'a':
- def->os.bootDevs[i] = VIR_DOMAIN_BOOT_FLOPPY;
- break;
- case 'd':
- def->os.bootDevs[i] = VIR_DOMAIN_BOOT_CDROM;
- break;
- case 'n':
- def->os.bootDevs[i] = VIR_DOMAIN_BOOT_NET;
- break;
- case 'c':
- default:
- def->os.bootDevs[i] = VIR_DOMAIN_BOOT_DISK;
- break;
- }
- def->os.nBootDevs++;
- }
- } else {
- const char *extra, *root;
-
- if (xenXMConfigCopyStringOpt(conf, "bootloader",
&def->os.bootloader) < 0)
- goto cleanup;
- if (xenXMConfigCopyStringOpt(conf, "bootargs",
&def->os.bootloaderArgs) < 0)
- goto cleanup;
-
- if (xenXMConfigCopyStringOpt(conf, "kernel", &def->os.kernel)
< 0)
- goto cleanup;
- if (xenXMConfigCopyStringOpt(conf, "ramdisk", &def->os.initrd)
< 0)
- goto cleanup;
- if (xenXMConfigGetString(conf, "extra", &extra, NULL) < 0)
- goto cleanup;
- if (xenXMConfigGetString(conf, "root", &root, NULL) < 0)
- goto cleanup;
-
- if (root) {
- if (virAsprintf(&def->os.cmdline, "root=%s %s", root, extra)
< 0)
- goto cleanup;
- } else {
- if (VIR_STRDUP(def->os.cmdline, extra) < 0)
- goto cleanup;
- }
- }
-
+ if (xenParseXMOS(conf, def) < 0)
+ goto cleanup;
if (xenParseXMMem(conf, def) < 0)
goto cleanup;
if (xenParseXMEventsActions(conf, def) < 0)
@@ -967,8 +988,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
goto cleanup;
if (xenParseXMVfb(conf, def, xendConfigVersion) < 0)
goto cleanup;
- if (xenXMConfigCopyStringOpt(conf, "device_model", &def->emulator)
< 0)
- goto cleanup;
list = virConfGetValue(conf, "vif");
if (list && list->type == VIR_CONF_LIST) {
list = list->list;
@@ -1235,7 +1254,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
return def;
cleanup:
- virDomainGraphicsDefFree(graphics);
virDomainNetDefFree(net);
virDomainDiskDefFree(disk);
virDomainDefFree(def);
--
1.8.4.5