From: Kiarie Kahurani <davidkiarie4(a)gmail.com>
introduce function
xenParseXMEmulatedDevices(virConfPtr conf,.......)
which parses the emulated hardware instead
signed-off-by: David Kiarie<davidkiarie4(a)gmail.com>
---
src/xenxs/xen_xm.c | 93 +++++++++++++++++++++++++++---------------------------
1 file changed, 47 insertions(+), 46 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index e6a1b7d..5959892 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -1164,6 +1164,51 @@ int xenParseXMVif(virConfPtr conf, virDomainDefPtr def)
}
+static
+int xenParseXMEmulatedDevices(virConfPtr conf, virDomainDefPtr def)
+{
+ const char *str;
+
+ if (STREQ(def->os.type, "hvm")) {
+ if (xenXMConfigGetString(conf, "soundhw", &str, NULL) < 0)
+ return -1;
+
+ if (str &&
+ xenParseSxprSound(def, str) < 0)
+ return -1;
+
+ if (xenXMConfigGetString(conf, "usbdevice", &str, NULL) < 0)
+ return -1;
+
+ if (str &&
+ (STREQ(str, "tablet") ||
+ STREQ(str, "mouse") ||
+ STREQ(str, "keyboard"))) {
+ virDomainInputDefPtr input;
+ if (VIR_ALLOC(input) < 0)
+ return -1;
+
+ input->bus = VIR_DOMAIN_INPUT_BUS_USB;
+ if (STREQ(str, "mouse"))
+ input->type = VIR_DOMAIN_INPUT_TYPE_MOUSE;
+ else if (STREQ(str, "tablet"))
+ input->type = VIR_DOMAIN_INPUT_TYPE_TABLET;
+ else if (STREQ(str, "keyboard"))
+ input->type = VIR_DOMAIN_INPUT_TYPE_KBD;
+ if (VIR_ALLOC_N(def->inputs, 1) < 0) {
+ virDomainInputDefFree(input);
+ return -1;
+
+ }
+ def->inputs[0] = input;
+ def->ninputs = 1;
+ }
+ }
+
+ return 0;
+}
+
+
virDomainDefPtr
xenParseXM(virConfPtr conf, int xendConfigVersion,
virCapsPtr caps)
@@ -1171,30 +1216,23 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
const char *str;
int hvm = 0;
virDomainDefPtr def = NULL;
- virDomainDiskDefPtr disk = NULL;
- virDomainNetDefPtr net = NULL;
const char *defaultMachine;
- char *script = NULL;
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;
-
-
if ((xenXMConfigGetString(conf, "builder", &str, "linux") ==
0) &&
STREQ(str, "hvm"))
hvm = 1;
if (VIR_STRDUP(def->os.type, hvm ? "hvm" : "xen") < 0)
goto cleanup;
-
def->os.arch =
virCapabilitiesDefaultGuestArch(caps,
def->os.type,
@@ -1233,51 +1271,14 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
goto cleanup;
if (xenParseXMPCI(conf, def) < 0)
goto cleanup;
- if (hvm) {
- if (xenXMConfigGetString(conf, "usbdevice", &str, NULL) < 0)
- goto cleanup;
- if (str &&
- (STREQ(str, "tablet") ||
- STREQ(str, "mouse") ||
- STREQ(str, "keyboard"))) {
- virDomainInputDefPtr input;
- if (VIR_ALLOC(input) < 0)
- goto cleanup;
- input->bus = VIR_DOMAIN_INPUT_BUS_USB;
- if (STREQ(str, "mouse"))
- input->type = VIR_DOMAIN_INPUT_TYPE_MOUSE;
- else if (STREQ(str, "tablet"))
- input->type = VIR_DOMAIN_INPUT_TYPE_TABLET;
- else if (STREQ(str, "keyboard"))
- input->type = VIR_DOMAIN_INPUT_TYPE_KBD;
- if (VIR_ALLOC_N(def->inputs, 1) < 0) {
- virDomainInputDefFree(input);
- goto cleanup;
- }
- def->inputs[0] = input;
- def->ninputs = 1;
- }
- }
-
+ if (xenParseXMEmulatedDevices(conf, def) < 0)
+ goto cleanup;
if (xenParseXMCharDev(conf, def) < 0)
goto cleanup;
- if (hvm) {
- if (xenXMConfigGetString(conf, "soundhw", &str, NULL) < 0)
- goto cleanup;
-
- if (str &&
- xenParseSxprSound(def, str) < 0)
- goto cleanup;
- }
-
- VIR_FREE(script);
return def;
cleanup:
- virDomainNetDefFree(net);
- virDomainDiskDefFree(disk);
virDomainDefFree(def);
- VIR_FREE(script);
return NULL;
}
--
1.8.4.5