introduce function
xenFormatXMVfb(virConfPtr conf,.........);
which formats Vfb config instead
signed-off-by: Kiarie Kahurani <davidkiarie4(a)gmail.com>
Signed-off-by: Kiarie Kahurani <davidkiarie4(a)gmail.com>
---
src/xenxs/xen_xm.c | 171 ++++++++++++++++++++++++++++++-----------------------
1 file changed, 97 insertions(+), 74 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 9db159d..bf5a23a 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -2087,108 +2087,65 @@ xenFormatXMOS(virConfPtr conf, virDomainDefPtr def,
return 0;
}
-/* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
- either 32, or 64 on a platform where long is big enough. */
-verify(MAX_VIRT_CPUS <= sizeof(1UL) * CHAR_BIT);
-
-virConfPtr
-xenFormatXM(virConnectPtr conn,
- virDomainDefPtr def,
- int xendConfigVersion)
-{
- virConfPtr conf = NULL;
- int hvm = 0;
- size_t i;
- virConfValuePtr netVal = NULL;
-
- if (!(conf = virConfNew()))
- goto cleanup;
-
- if (xenFormatXMGeneralMeta(conf, def) < 0)
- goto cleanup;
-
- if (xenFormatXMMem(conf, def) < 0)
- goto cleanup;
-
- if (xenFormatXMCPUFeatures(conf, def, xendConfigVersion) < 0)
- goto cleanup;
-
- hvm = STREQ(def->os.type, "hvm");
- if (xenFormatXMOS(conf, def, xendConfigVersion) < 0)
- goto cleanup;
-
- if (xenFormatXMTimeOffset(conf, def, xendConfigVersion) < 0)
- goto cleanup;
- if (xenFormatXMEventActions(conf, def) < 0)
- goto cleanup;
-
- if (hvm) {
- for (i = 0; i < def->ninputs; i++) {
- if (def->inputs[i]->bus == VIR_DOMAIN_INPUT_BUS_USB) {
- if (xenXMConfigSetInt(conf, "usb", 1) < 0)
- goto cleanup;
- switch (def->inputs[i]->type) {
- case VIR_DOMAIN_INPUT_TYPE_MOUSE:
- if (xenXMConfigSetString(conf, "usbdevice",
"mouse") < 0)
- goto cleanup;
- break;
- case VIR_DOMAIN_INPUT_TYPE_TABLET:
- if (xenXMConfigSetString(conf, "usbdevice",
"tablet") < 0)
- goto cleanup;
- break;
- case VIR_DOMAIN_INPUT_TYPE_KBD:
- if (xenXMConfigSetString(conf, "usbdevice",
"keyboard") < 0)
- goto cleanup;
- break;
- }
- break;
- }
- }
- }
+static int
+xenFormatXMVfb(virConfPtr conf, virDomainDefPtr def,
+ int xendConfigVersion)
+{
+ int hvm = STREQ(def->os.type, "hvm");
if (def->ngraphics == 1) {
if (hvm || (xendConfigVersion < XEND_CONFIG_MIN_VERS_PVFB_NEWCONF)) {
if (def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL) {
if (xenXMConfigSetInt(conf, "sdl", 1) < 0)
- goto cleanup;
+ return -1;
+
if (xenXMConfigSetInt(conf, "vnc", 0) < 0)
- goto cleanup;
+ return -1;
+
if (def->graphics[0]->data.sdl.display &&
xenXMConfigSetString(conf, "display",
def->graphics[0]->data.sdl.display) < 0)
- goto cleanup;
+ return -1;
+
if (def->graphics[0]->data.sdl.xauth &&
xenXMConfigSetString(conf, "xauthority",
def->graphics[0]->data.sdl.xauth) < 0)
- goto cleanup;
+ return -1;
+
} else {
const char *listenAddr;
if (xenXMConfigSetInt(conf, "sdl", 0) < 0)
- goto cleanup;
+ return -1;
+
if (xenXMConfigSetInt(conf, "vnc", 1) < 0)
- goto cleanup;
+ return -1;
+
if (xenXMConfigSetInt(conf, "vncunused",
def->graphics[0]->data.vnc.autoport ? 1 : 0) < 0)
- goto cleanup;
+ return -1;
+
if (!def->graphics[0]->data.vnc.autoport &&
xenXMConfigSetInt(conf, "vncdisplay",
def->graphics[0]->data.vnc.port - 5900) < 0)
- goto cleanup;
+ return -1;
+
listenAddr = virDomainGraphicsListenGetAddress(def->graphics[0], 0);
if (listenAddr &&
xenXMConfigSetString(conf, "vnclisten", listenAddr) <
0)
- goto cleanup;
+ return -1;
+
if (def->graphics[0]->data.vnc.auth.passwd &&
xenXMConfigSetString(conf, "vncpasswd",
def->graphics[0]->data.vnc.auth.passwd)
< 0)
- goto cleanup;
+ return -1;
+
if (def->graphics[0]->data.vnc.keymap &&
xenXMConfigSetString(conf, "keymap",
def->graphics[0]->data.vnc.keymap) < 0)
- goto cleanup;
+ return -1;
}
} else {
virConfValuePtr vfb, disp;
@@ -2221,20 +2178,20 @@ xenFormatXM(virConnectPtr conn,
virBufferAsprintf(&buf, ",keymap=%s",
def->graphics[0]->data.vnc.keymap);
}
+
if (virBufferCheckError(&buf) < 0)
- goto cleanup;
+ return -1;
vfbstr = virBufferContentAndReset(&buf);
-
if (VIR_ALLOC(vfb) < 0) {
VIR_FREE(vfbstr);
- goto cleanup;
+ return -1;
}
if (VIR_ALLOC(disp) < 0) {
VIR_FREE(vfb);
VIR_FREE(vfbstr);
- goto cleanup;
+ return -1;
}
vfb->type = VIR_CONF_LIST;
@@ -2243,10 +2200,76 @@ xenFormatXM(virConnectPtr conn,
disp->str = vfbstr;
if (virConfSetValue(conf, "vfb", vfb) < 0)
- goto cleanup;
+ return -1;
+ }
+ }
+
+ return 0;
+}
+/* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
+ either 32, or 64 on a platform where long is big enough. */
+verify(MAX_VIRT_CPUS <= sizeof(1UL) * CHAR_BIT);
+
+virConfPtr
+xenFormatXM(virConnectPtr conn,
+ virDomainDefPtr def,
+ int xendConfigVersion)
+{
+ virConfPtr conf = NULL;
+ int hvm = 0;
+ size_t i;
+ virConfValuePtr netVal = NULL;
+
+ if (!(conf = virConfNew()))
+ goto cleanup;
+
+ if (xenFormatXMGeneralMeta(conf, def) < 0)
+ goto cleanup;
+
+ if (xenFormatXMMem(conf, def) < 0)
+ goto cleanup;
+
+ if (xenFormatXMCPUFeatures(conf, def, xendConfigVersion) < 0)
+ goto cleanup;
+
+ hvm = STREQ(def->os.type, "hvm");
+
+ if (xenFormatXMOS(conf, def, xendConfigVersion) < 0)
+ goto cleanup;
+
+ if (xenFormatXMTimeOffset(conf, def, xendConfigVersion) < 0)
+ goto cleanup;
+
+ if (xenFormatXMEventActions(conf, def) < 0)
+ goto cleanup;
+
+ if (hvm) {
+ for (i = 0; i < def->ninputs; i++) {
+ if (def->inputs[i]->bus == VIR_DOMAIN_INPUT_BUS_USB) {
+ if (xenXMConfigSetInt(conf, "usb", 1) < 0)
+ goto cleanup;
+ switch (def->inputs[i]->type) {
+ case VIR_DOMAIN_INPUT_TYPE_MOUSE:
+ if (xenXMConfigSetString(conf, "usbdevice",
"mouse") < 0)
+ goto cleanup;
+ break;
+ case VIR_DOMAIN_INPUT_TYPE_TABLET:
+ if (xenXMConfigSetString(conf, "usbdevice",
"tablet") < 0)
+ goto cleanup;
+ break;
+ case VIR_DOMAIN_INPUT_TYPE_KBD:
+ if (xenXMConfigSetString(conf, "usbdevice",
"keyboard") < 0)
+ goto cleanup;
+ break;
+ }
+ break;
+ }
}
}
+ if (xenFormatXMVfb(conf, def, xendConfigVersion) < 0)
+ goto cleanup;
+
if (xenFormatXMDomainDisks(conf, def, xendConfigVersion) < 0)
goto cleanup;
--
1.8.4.5