d_config->vkbs = x_vkbs;
d_config->num_vfbs = d_config->num_vkbs = nvfbs;
- /*
- * VNC or SDL info must also be set in libxl_domain_build_info
- * for HVM domains. Use the first vfb device.
- */
- if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
- libxl_domain_build_info *b_info = &d_config->b_info;
- libxl_device_vfb vfb = d_config->vfbs[0];
-
- if (libxl_defbool_val(vfb.vnc.enable)) {
- libxl_defbool_set(&b_info->u.hvm.vnc.enable, true);
- if (VIR_STRDUP(b_info->u.hvm.vnc.listen, vfb.vnc.listen) < 0)
- goto error;
- if (VIR_STRDUP(b_info->u.hvm.vnc.passwd, vfb.vnc.passwd) < 0)
- goto error;
- b_info->u.hvm.vnc.display = vfb.vnc.display;
- libxl_defbool_set(&b_info->u.hvm.vnc.findunused,
- libxl_defbool_val(vfb.vnc.findunused));
- } else if (libxl_defbool_val(vfb.sdl.enable)) {
- libxl_defbool_set(&b_info->u.hvm.sdl.enable, true);
- libxl_defbool_set(&b_info->u.hvm.sdl.opengl,
- libxl_defbool_val(vfb.sdl.opengl));
- if (VIR_STRDUP(b_info->u.hvm.sdl.display, vfb.sdl.display) < 0)
- goto error;
- if (VIR_STRDUP(b_info->u.hvm.sdl.xauthority, vfb.sdl.xauthority) < 0)
- goto error;
- }
-
- if (VIR_STRDUP(b_info->u.hvm.keymap, vfb.keymap) < 0)
- goto error;
- }
-
return 0;
error:
return -1;
}
+/*
+ * Populate vfb info in libxl_domain_build_info struct for HVM domains.
+ * Use first libxl_device_vfb device in libxl_domain_config->vfbs.
+ * Prior to calling this function, libxlMakeVfbList must be called to
+ * populate libxl_domain_config->vfbs.
+ */
+static int
+libxlMakeBuildInfoVfb(virDomainDefPtr def, libxl_domain_config *d_config)
+{
+ libxl_domain_build_info *b_info = &d_config->b_info;
+ libxl_device_vfb x_vfb;
+
+ if (def->os.type != VIR_DOMAIN_OSTYPE_HVM)
+ return 0;
+
+ if (d_config->num_vfbs == 0)
+ return 0;
+
+ x_vfb = d_config->vfbs[0];
+
+ if (libxl_defbool_val(x_vfb.vnc.enable)) {
+ libxl_defbool_set(&b_info->u.hvm.vnc.enable, true);
+ if (VIR_STRDUP(b_info->u.hvm.vnc.listen, x_vfb.vnc.listen) < 0)
+ return -1;
+ if (VIR_STRDUP(b_info->u.hvm.vnc.passwd, x_vfb.vnc.passwd) < 0)
+ return -1;
+ b_info->u.hvm.vnc.display = x_vfb.vnc.display;
+ libxl_defbool_set(&b_info->u.hvm.vnc.findunused,
+ libxl_defbool_val(x_vfb.vnc.findunused));
+ } else if (libxl_defbool_val(x_vfb.sdl.enable)) {
+ libxl_defbool_set(&b_info->u.hvm.sdl.enable, true);
+ libxl_defbool_set(&b_info->u.hvm.sdl.opengl,
+ libxl_defbool_val(x_vfb.sdl.opengl));
+ if (VIR_STRDUP(b_info->u.hvm.sdl.display, x_vfb.sdl.display) < 0)
+ return -1;
+ if (VIR_STRDUP(b_info->u.hvm.sdl.xauthority, x_vfb.sdl.xauthority) < 0)
+ return -1;
+ }
+
+ if (VIR_STRDUP(b_info->u.hvm.keymap, x_vfb.keymap) < 0)
+ return -1;
+
+ return 0;
+}
+
/*
* Get domain0 autoballoon configuration. Honor user-specified
* setting in libxl.conf first. If not specified, autoballooning
if (libxlMakeVfbList(graphicsports, def, d_config) < 0)
return -1;
+ if (libxlMakeBuildInfoVfb(def, d_config) < 0)
+ return -1;
+
if (libxlMakePCIList(def, d_config) < 0)
return -1;