From 24543c6571e0a48b176c7b6438234a37c75e2e77 Mon Sep 17 00:00:00 2001 From: Kiarie Kahurani Date: Thu, 7 Aug 2014 21:33:00 +0300 Subject: [PATCH] src/xenxs: Refactor code parsing general config introduce function xenParseXMGeneralMeta(virConfPtr conf, .......); which parses general metadata instead Signed-off-by: Kiarie Kahurani --- src/xenxs/xen_xm.c | 57 +++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index f38884fcc7..59de886019 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1151,38 +1151,25 @@ xenParseXMEmulatedDevices(virConfPtr conf, virDomainDefPtr def) } -/* - * Turn a config record into a lump of XML describing the - * domain, suitable for later feeding for virDomainCreateXML - */ -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; - size_t i; - 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; - if (xenXMConfigGetUUID(conf, "uuid", def->uuid) < 0) - goto cleanup; + return -1; + if (xenXMConfigGetUUID(conf, "uuid", def->uuid) < 0) + 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, @@ -1192,7 +1179,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, @@ -1201,10 +1188,34 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, virDomainVirtTypeToString(def->virtType)); if (defaultMachine != NULL) { if (VIR_STRDUP(def->os.machine, defaultMachine) < 0) - goto cleanup; + return -1; } - if (hvm) { + return 0; +} + + +/* + * Turn a config record into a lump of XML describing the + * domain, suitable for later feeding for virDomainCreateXML + */ +virDomainDefPtr +xenParseXM(virConfPtr conf, int xendConfigVersion, + virCapsPtr caps) +{ + virDomainDefPtr def = NULL; + size_t i; + + 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 (STREQ(def->os.type, "hvm")) { const char *boot; if (xenXMConfigCopyString(conf, "kernel", &def->os.loader) < 0) goto cleanup;