From: Kiarie Kahurani <davidkiarie4(a)gmail.com>
introduce function
xenParseXMGeneralMeta(virConfPtr conf,......)
which parses features like hvm= ?, builder and sets
the default machine type incase its not specified
signed-off-by: David Kiarie<davidkiarie4(a)gmail.com>
---
src/xenxs/xen_xm.c | 43 ++++++++++++++++++++++++++++---------------
1 file changed, 28 insertions(+), 15 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 5959892..157d7d3 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -1209,30 +1209,28 @@ int xenParseXMEmulatedDevices(virConfPtr conf, virDomainDefPtr
def)
}
-virDomainDefPtr
-xenParseXM(virConfPtr conf, int xendConfigVersion,
- virCapsPtr caps)
+static
+int xenParseXMGeneralMeta(virConfPtr conf, virDomainDefPtr def,
+ virCapsPtr caps)
{
+
+ const char *defaultMachine;
const char *str;
int hvm = 0;
- virDomainDefPtr def = NULL;
- const char *defaultMachine;
-
- if (VIR_ALLOC(def) < 0)
- return NULL;
- def->virtType = VIR_DOMAIN_VIRT_XEN;
- def->id = -1;
if (xenXMConfigCopyString(conf, "name", &def->name) < 0)
- goto cleanup;
+ return -1;
+
if (xenXMConfigGetUUID(conf, "uuid", def->uuid) < 0)
- goto cleanup;
+ return -1;
+
if ((xenXMConfigGetString(conf, "builder", &str, "linux") ==
0) &&
STREQ(str, "hvm"))
hvm = 1;
if (VIR_STRDUP(def->os.type, hvm ? "hvm" : "xen") < 0)
- goto cleanup;
+ return -1;
+
def->os.arch =
virCapabilitiesDefaultGuestArch(caps,
def->os.type,
@@ -1241,7 +1239,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("no supported architecture for os type
'%s'"),
def->os.type);
- goto cleanup;
+ return -1;
}
defaultMachine = virCapabilitiesDefaultGuestMachine(caps,
@@ -1250,9 +1248,24 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
virDomainVirtTypeToString(def->virtType));
if (defaultMachine != NULL) {
if (VIR_STRDUP(def->os.machine, defaultMachine) < 0)
- goto cleanup;
+ return -1;
}
+ return 0;
+}
+virDomainDefPtr
+xenParseXM(virConfPtr conf, int xendConfigVersion,
+ virCapsPtr caps)
+{
+ virDomainDefPtr def = NULL;
+
+ if (VIR_ALLOC(def) < 0)
+ return NULL;
+
+ def->virtType = VIR_DOMAIN_VIRT_XEN;
+ def->id = -1;
+ if (xenParseXMGeneralMeta(conf, def, caps) < 0)
+ goto cleanup;
if (xenParseXMOS(conf, def) < 0)
goto cleanup;
if (xenParseXMMem(conf, def) < 0)
--
1.8.4.5