libxl: populate build_info vfb in separate function
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/4 libxl: populate build_info vfb in separate function
For HVM domains, vfb info must be populated in the libxl_domain_build_info stuct. Currently this is done in the libxlMakeVfbList function, but IMO it would be cleaner to populate the build_info vfb in a separate libxlMakeBuildInfoVfb function. libxlMakeVfbList would then handle only vfb devices, simiar to the other libxlMake<device>List functions.
A future patch will extend libxlMakeBuildInfoVfb to support SPICE.
--- src/libxl/libxl_conf.c | 79 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 31 deletions(-)
src/libxl/libxl_conf.c +48 -31
@@ -1323,37 +1323,6 @@ libxlMakeVfbList(virPortAllocatorPtr graphicsports, 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:
@@ -1367,6 +1336,51 @@ libxlMakeVfbList(virPortAllocatorPtr graphicsports, }/* +* 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 * is disabled when domain0's memory is set with 'dom0_mem'.
@@ -1764,6 +1778,9 @@ libxlBuildDomainConfig(virPortAllocatorPtr graphicsports,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 ;
Signature · 1 line
1.8.4.5
PATCH 2/4 libxl: change reservedVNCPorts to reservedGraphicsPorts
In reply to a message not in the archiveA later change will use the PortAllocator for SPICE too.
--- src/libxl/libxl_conf.h | 2 +- src/libxl/libxl_domain.c | 4 ++-- src/libxl/libxl_driver.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
src/libxl/libxl_conf.h +1 -1
@@ -140,7 +140,7 @@ struct _libxlDriverPrivate {virObjectEventStatePtr domainEventState;/* Immutable pointer, self-locking APIs */ -virPortAllocatorPtr reservedVNCPorts; +virPortAllocatorPtr reservedGraphicsPorts;/* Immutable pointer, self-locking APIs */ virPortAllocatorPtr migrationPorts;
src/libxl/libxl_domain.c +2 -2
@@ -715,7 +715,7 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver, vm->def->graphics[0]->data.vnc.autoport) { vnc_port = vm->def->graphics[0 ]->data.vnc.port;if (vnc_port >=LIBXL_VNC_PORT_MIN ) { -if (virPortAllocatorRelease (driver->reservedVNCPorts, +if (virPortAllocatorRelease (driver->reservedGraphicsPorts, vnc_port) <0 )VIR_DEBUG ("Could not mark port %d as unused" , vnc_port); }
@@ -979,7 +979,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,VIR_FREE (managed_save_path); } -if (libxlBuildDomainConfig (driver->reservedVNCPorts, vm->def, +if (libxlBuildDomainConfig (driver->reservedGraphicsPorts, vm->def, cfg->ctx, &d_config) <0 ) goto cleanup;
src/libxl/libxl_driver.c +2 -2
@@ -410,7 +410,7 @@ libxlStateCleanup(void)virObjectUnref (libxl_driver->config);virObjectUnref (libxl_driver->xmlopt);virObjectUnref (libxl_driver->domains); -virObjectUnref (libxl_driver->reservedVNCPorts); +virObjectUnref (libxl_driver->reservedGraphicsPorts);virObjectUnref (libxl_driver->migrationPorts);virLockManagerPluginUnref (libxl_driver->lockManager);
@@ -523,7 +523,7 @@ libxlStateInitialize(bool privileged, }/* Allocate bitmap for vnc port reservation */ - if (!(libxl_driver->reservedVNCPorts = + if (!(libxl_driver->reservedGraphicsPorts = virPortAllocatorNew(_("VNC"), LIBXL_VNC_PORT_MIN, LIBXL_VNC_PORT_MAX,
Signature · 1 line
1.8.4.5
PATCH 3/4 libxl: support SPICE graphics for HVM domains
In reply to a message not in the archive--- src/libxl/libxl_conf.c | 72 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 66 insertions(+), 6 deletions(-)
src/libxl/libxl_conf.c +66 -6
@@ -1337,22 +1337,82 @@ libxlMakeVfbList(virPortAllocatorPtr graphicsports,/* * 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. +* Prefer SPICE, otherwise 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) +libxlMakeBuildInfoVfb (virPortAllocatorPtr graphicsports, +virDomainDefPtr def, +libxl_domain_config *d_config) {libxl_domain_build_info *b_info = &d_config->b_info;libxl_device_vfb x_vfb; +size_t i;if (def->os.type !=VIR_DOMAIN_OSTYPE_HVM )return 0 ; -if (d_config->num_vfbs ==0 ) +if (def->ngraphics ==0 )return 0 ; +for (i =0 ; i < def->ngraphics; i++) { +virDomainGraphicsDefPtr l_vfb = def->graphics[0 ]; +unsigned short port; +const char *listenAddr; + +if (l_vfb->type !=VIR_DOMAIN_GRAPHICS_TYPE_SPICE ) +continue ; + +libxl_defbool_set (&b_info->u.hvm.spice.enable, true); + +if (l_vfb->data.spice.autoport) { +if (virPortAllocatorAcquire (graphicsports, &port) <0 ) +return -1 ; + l_vfb->data.spice.port = port; + } + b_info->u.hvm.spice.port = l_vfb->data.spice.port; + + listenAddr =virDomainGraphicsListenGetAddress (l_vfb,0 ); +if (VIR_STRDUP (b_info->u.hvm.spice.host, listenAddr) <0 ) +return -1 ; + +if (VIR_STRDUP (b_info->u.hvm.keymap, l_vfb->data.spice.keymap) <0 ) +return -1 ; + +if (l_vfb->data.spice.auth.passwd) { +if (VIR_STRDUP (b_info->u.hvm.spice.passwd, + l_vfb->data.spice.auth.passwd) <0 ) +return -1 ; +libxl_defbool_set (&b_info->u.hvm.spice.disable_ticketing, false); + }else { +libxl_defbool_set (&b_info->u.hvm.spice.disable_ticketing, true); + } + +switch (l_vfb->data.spice.mousemode) { +/* client mouse mode is default in xl.cfg */ +case VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_DEFAULT : +case VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_CLIENT : +libxl_defbool_set (&b_info->u.hvm.spice.agent_mouse, true); +break ; +case VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_SERVER : +libxl_defbool_set (&b_info->u.hvm.spice.agent_mouse, false); +break ; + } + +#ifdef LIBXL_HAVE_SPICE_VDAGENT +if (l_vfb->data.spice.copypaste ==VIR_TRISTATE_BOOL_YES ) { +libxl_defbool_set (&b_info->u.hvm.spice.vdagent, true); +libxl_defbool_set (&b_info->u.hvm.spice.clipboard_sharing, true); + }else { +libxl_defbool_set (&b_info->u.hvm.spice.vdagent, false); +libxl_defbool_set (&b_info->u.hvm.spice.clipboard_sharing, false); + } +#endif + +return 0 ; + } + x_vfb = d_config->vfbs[0 ];if (libxl_defbool_val (x_vfb.vnc.enable)) {
@@ -1778,7 +1838,7 @@ libxlBuildDomainConfig(virPortAllocatorPtr graphicsports,if (libxlMakeVfbList (graphicsports, def, d_config) <0 )return -1 ; -if (libxlMakeBuildInfoVfb (def, d_config) <0 ) +if (libxlMakeBuildInfoVfb (graphicsports, def, d_config) <0 )return -1 ;if (libxlMakePCIList (def, d_config) <0 )
Signature · 1 line
1.8.4.5
PATCH 4/4 libxl: support QXL video device
In reply to a message not in the archivelibxl recently gained support for QXL video device. Support it in the libxl driver too.
---
Note:
Commit 161212ef in xen.git staging branch provides QXL support in libxl
src/libxl/libxl_conf.c | 11 +++++++++++ src/libxl/libxl_domain.c | 4 ++++ 2 files changed, 15 insertions(+)
src/libxl/libxl_conf.c +11 -0
@@ -1736,6 +1736,17 @@ libxlMakeVideo(virDomainDefPtr def, libxl_domain_config *d_config) }break ; +#ifdef LIBXL_HAVE_QXL +case VIR_DOMAIN_VIDEO_TYPE_QXL : + b_info->u.hvm.vga.kind =LIBXL_VGA_INTERFACE_TYPE_QXL ; +if (def->videos[0 ]->vram <128 *1024 ) { +virReportError (VIR_ERR_CONFIG_UNSUPPORTED ,"%s" , +_ ("videoram must be at least 128MB for QXL" )); +return -1 ; + } +break ; +#endif +default : virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("video type %s is not supported by libxl"),
src/libxl/libxl_domain.c +4 -0
@@ -324,6 +324,10 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, dev->data.video->vram =4 *1024 ; }break ; +case VIR_DOMAIN_VIDEO_TYPE_QXL : +if (dev->data.video->vram ==0 ) + dev->data.video->vram =128 *1024 ; +break ; } }
Signature · 1 line
1.8.4.5
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 2 lines · Jim Fehlig
For HVM domains, vfb info must be populated in the
libxl_domain_build_infostuct. Currently this is done in the libxlMakeVfbList function, but IMO
struct
Quoted 123 lines
it would be cleaner to populate the
build_infovfb in a separate libxlMakeBuildInfoVfb function. libxlMakeVfbList would then handle only vfb devices, simiar to the other libxlMake<device>List functions.A future patch will extend libxlMakeBuildInfoVfb to support SPICE.
Signed-off-by Jim Fehlig <[email protected]>--- src/libxl/libxl_conf.c | 79 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 31 deletions(-)src/libxl/libxl_conf.c +48
-31@@ -1323,37 +1323,6 @@ libxlMakeVfbList(virPortAllocatorPtr graphicsports, 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:@@ -1367,6 +1336,51 @@ libxlMakeVfbList(virPortAllocatorPtr graphicsports, }/* +* 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 * is disabled when domain0's memory is set with 'dom0_mem'. @@ -1764,6 +1778,9 @@ libxlBuildDomainConfig(virPortAllocatorPtr graphicsports,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 ;Signature · 7 lines
1.8.4.5 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 8 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Jim Fehlig
For HVM domains, vfb info must be populated in the
libxl_domain_build_infostuct. Currently this is done in the libxlMakeVfbList function, but IMOstruct
Thanks. I've fixed the typo in my local branch but will wait for additional comments before posting a V2 (if necessary).
Regards,
Jim
Quoted 126 lines
Quoted 124 lines
it would be cleaner to populate the
build_infovfb in a separate libxlMakeBuildInfoVfb function. libxlMakeVfbList would then handle only vfb devices, simiar to the other libxlMake<device>List functions.A future patch will extend libxlMakeBuildInfoVfb to support SPICE.
Signed-off-by Jim Fehlig <[email protected]>--- src/libxl/libxl_conf.c | 79 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 31 deletions(-)src/libxl/libxl_conf.c +48
-31@@ -1323,37 +1323,6 @@ libxlMakeVfbList(virPortAllocatorPtr graphicsports, 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:@@ -1367,6 +1336,51 @@ libxlMakeVfbList(virPortAllocatorPtr graphicsports, }/* +* 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 * is disabled when domain0's memory is set with 'dom0_mem'. @@ -1764,6 +1778,9 @@ libxlBuildDomainConfig(virPortAllocatorPtr graphicsports,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 ;Signature · 7 lines
1.8.4.5 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [libvirt] [PATCH 3/4] libxl: support SPICE graphics for HVM domains
Quoted 29 lines · Jim Fehlig
Signed-off-by Jim Fehlig <[email protected]>--- src/libxl/libxl_conf.c | 72 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 66 insertions(+), 6 deletions(-)src/libxl/libxl_conf.c +7
-4@@ -1337,22 +1337,82 @@ libxlMakeVfbList(virPortAllocatorPtr graphicsports,/* * 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. +* Prefer SPICE, otherwise 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) +libxlMakeBuildInfoVfb (virPortAllocatorPtr graphicsports, +virDomainDefPtr def, +libxl_domain_config *d_config) {libxl_domain_build_info *b_info = &d_config->b_info;libxl_device_vfb x_vfb; +size_t i;
src/libxl/libxl_conf.c libxlMakeVfbList(virPortAllocatorPtr graphicsports, · line 1360
Quoted 10 lines
src/libxl/libxl_conf.c +3
-1if (def->os.type !=VIR_DOMAIN_OSTYPE_HVM )return 0 ; -if (d_config->num_vfbs ==0 ) +if (def->ngraphics ==0 )return 0 ; +for (i =0 ; i < def->ngraphics; i++) { +virDomainGraphicsDefPtr l_vfb = def->graphics[0 ];
This seems really awkward to me. So you're using for() loop just to check if the first graphics card (assuming there can't be more than one anyway) is SPICE. If not, you could use 'continue' to continue with VNC. I think this obfucates the code. Just move this into a separate function and call it from here.
Quoted 60 lines
src/libxl/libxl_conf.c +55
-0+unsigned short port; +const char *listenAddr; + +if (l_vfb->type !=VIR_DOMAIN_GRAPHICS_TYPE_SPICE ) +continue ; + +libxl_defbool_set (&b_info->u.hvm.spice.enable, true); + +if (l_vfb->data.spice.autoport) { +if (virPortAllocatorAcquire (graphicsports, &port) <0 ) +return -1 ; + l_vfb->data.spice.port = port; + } + b_info->u.hvm.spice.port = l_vfb->data.spice.port; + + listenAddr =virDomainGraphicsListenGetAddress (l_vfb,0 ); +if (VIR_STRDUP (b_info->u.hvm.spice.host, listenAddr) <0 ) +return -1 ; + +if (VIR_STRDUP (b_info->u.hvm.keymap, l_vfb->data.spice.keymap) <0 ) +return -1 ; + +if (l_vfb->data.spice.auth.passwd) { +if (VIR_STRDUP (b_info->u.hvm.spice.passwd, + l_vfb->data.spice.auth.passwd) <0 ) +return -1 ; +libxl_defbool_set (&b_info->u.hvm.spice.disable_ticketing, false); + }else { +libxl_defbool_set (&b_info->u.hvm.spice.disable_ticketing, true); + } + +switch (l_vfb->data.spice.mousemode) { +/* client mouse mode is default in xl.cfg */ +case VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_DEFAULT : +case VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_CLIENT : +libxl_defbool_set (&b_info->u.hvm.spice.agent_mouse, true); +break ; +case VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_SERVER : +libxl_defbool_set (&b_info->u.hvm.spice.agent_mouse, false); +break ; + } + +#ifdef LIBXL_HAVE_SPICE_VDAGENT +if (l_vfb->data.spice.copypaste ==VIR_TRISTATE_BOOL_YES ) { +libxl_defbool_set (&b_info->u.hvm.spice.vdagent, true); +libxl_defbool_set (&b_info->u.hvm.spice.clipboard_sharing, true); + }else { +libxl_defbool_set (&b_info->u.hvm.spice.vdagent, false); +libxl_defbool_set (&b_info->u.hvm.spice.clipboard_sharing, false); + } +#endif + +return 0 ; + } + x_vfb = d_config->vfbs[0 ];if (libxl_defbool_val (x_vfb.vnc.enable)) {
src/libxl/libxl_conf.c libxlBuildDomainConfig(virPortAllocatorPtr graphicsports, · line 1844
Quoted 8 lines
src/libxl/libxl_conf.c +1
-1@@ -1778,7 +1838,7 @@ libxlBuildDomainConfig(virPortAllocatorPtr graphicsports,if (libxlMakeVfbList (graphicsports, def, d_config) <0 )return -1 ; -if (libxlMakeBuildInfoVfb (def, d_config) <0 ) +if (libxlMakeBuildInfoVfb (graphicsports, def, d_config) <0 )return -1 ;if (libxlMakePCIList (def, d_config) <0 )
Otherwise looking good.
Michal
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [libvirt] [PATCH 3/4] libxl: support SPICE graphics for HVM domains
Quoted 42 lines · Michal Privoznik
Quoted 39 lines · Jim Fehlig
Signed-off-by Jim Fehlig <[email protected]>---
src/libxl/libxl_conf.c| 72 +++++++++++++++++++++++++++++++++++++++++++++-----1 file changed, 66 insertions(+), 6 deletions(-)src/libxl/libxl_conf.c +3
-3@@ -1337,22 +1337,82 @@ libxlMakeVfbList(virPortAllocatorPtr graphicsports,/* * 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. +* Prefer SPICE, otherwise 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
src/libxl/libxl_conf.c +3
-1-libxlMakeBuildInfoVfb(virDomainDefPtr def, libxl_domain_config *d_config) +libxlMakeBuildInfoVfb(virPortAllocatorPtr graphicsports, + virDomainDefPtr def, + libxl_domain_config *d_config){ libxl_domain_build_info *b_info = &d_config->b_info; libxl_device_vfb x_vfb;src/libxl/libxl_conf.c +2
-1+size_t i;if (def->os.type !=VIR_DOMAIN_OSTYPE_HVM )return 0 ; -if (d_config->num_vfbs ==0 ) +if (def->ngraphics ==0 )return 0 ;
Quoted 8 lines
src/libxl/libxl_conf.c
Quoted 2 lines
src/libxl/libxl_conf.c +2
-0+for (i =0 ; i < def->ngraphics; i++) { +virDomainGraphicsDefPtr l_vfb = def->graphics[0 ];This seems really awkward to me. So you're using
for()loop just to check if the first graphics card (assuming there can't be more than one anyway) is SPICE. If not, you could use 'continue' to continue with VNC. I think this obfucates the code. Just move this into a separate function and call it from here.
That's actually a bug, it should be def->graphics[i]. The idea is to prefer SPICE, but fall back to the first graphics device if no SPICE device is found. I mentioned this in the function comment. Perhaps that part of the comment should be moved to the for loop?
Regards,
Jim
Quoted 73 lines
Quoted 60 lines
src/libxl/libxl_conf.c +55
-0+unsigned short port; +const char *listenAddr; + +if (l_vfb->type !=VIR_DOMAIN_GRAPHICS_TYPE_SPICE ) +continue ; + +libxl_defbool_set (&b_info->u.hvm.spice.enable, true); + +if (l_vfb->data.spice.autoport) { +if (virPortAllocatorAcquire (graphicsports, &port) <0 ) +return -1 ; + l_vfb->data.spice.port = port; + } + b_info->u.hvm.spice.port = l_vfb->data.spice.port; + + listenAddr =virDomainGraphicsListenGetAddress (l_vfb,0 ); +if (VIR_STRDUP (b_info->u.hvm.spice.host, listenAddr) <0 ) +return -1 ; + +if (VIR_STRDUP (b_info->u.hvm.keymap, l_vfb->data.spice.keymap) <0 ) +return -1 ; + +if (l_vfb->data.spice.auth.passwd) { +if (VIR_STRDUP (b_info->u.hvm.spice.passwd, + l_vfb->data.spice.auth.passwd) <0 ) +return -1 ; +libxl_defbool_set (&b_info->u.hvm.spice.disable_ticketing, false); + }else { +libxl_defbool_set (&b_info->u.hvm.spice.disable_ticketing, true); + } + +switch (l_vfb->data.spice.mousemode) { +/* client mouse mode is default in xl.cfg */ +case VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_DEFAULT : +case VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_CLIENT : +libxl_defbool_set (&b_info->u.hvm.spice.agent_mouse, true); +break ; +case VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_SERVER : +libxl_defbool_set (&b_info->u.hvm.spice.agent_mouse, false); +break ; + } + +#ifdef LIBXL_HAVE_SPICE_VDAGENT +if (l_vfb->data.spice.copypaste ==VIR_TRISTATE_BOOL_YES ) { +libxl_defbool_set (&b_info->u.hvm.spice.vdagent, true); +libxl_defbool_set (&b_info->u.hvm.spice.clipboard_sharing, true); + }else { +libxl_defbool_set (&b_info->u.hvm.spice.vdagent, false); +libxl_defbool_set (&b_info->u.hvm.spice.clipboard_sharing, false); + } +#endif + +return 0 ; + } + x_vfb = d_config->vfbs[0 ];if (libxl_defbool_val (x_vfb.vnc.enable)) {src/libxl/libxl_conf.c libxlBuildDomainConfig(virPortAllocatorPtr graphicsports, · line 1844
Quoted 8 lines
src/libxl/libxl_conf.c +1
-1@@ -1778,7 +1838,7 @@ libxlBuildDomainConfig(virPortAllocatorPtr graphicsports,if (libxlMakeVfbList (graphicsports, def, d_config) <0 )return -1 ; -if (libxlMakeBuildInfoVfb (def, d_config) <0 ) +if (libxlMakeBuildInfoVfb (graphicsports, def, d_config) <0 )return -1 ;if (libxlMakePCIList (def, d_config) <0 )Otherwise looking good.
Michal
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [libvirt] [PATCH 3/4] libxl: support SPICE graphics for HVM domains
Quoted 51 lines · Jim Fehlig
Quoted 42 lines · Michal Privoznik
Quoted 39 lines · Jim Fehlig
Signed-off-by Jim Fehlig <[email protected]>---
src/libxl/libxl_conf.c| 72 +++++++++++++++++++++++++++++++++++++++++++++-----1 file changed, 66 insertions(+), 6 deletions(-)src/libxl/libxl_conf.c +3
-3@@ -1337,22 +1337,82 @@ libxlMakeVfbList(virPortAllocatorPtr graphicsports,/* * 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. +* Prefer SPICE, otherwise 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
src/libxl/libxl_conf.c +3
-1-libxlMakeBuildInfoVfb(virDomainDefPtr def, libxl_domain_config *d_config) +libxlMakeBuildInfoVfb(virPortAllocatorPtr graphicsports, + virDomainDefPtr def, + libxl_domain_config *d_config){ libxl_domain_build_info *b_info = &d_config->b_info; libxl_device_vfb x_vfb;src/libxl/libxl_conf.c +2
-1+size_t i;if (def->os.type !=VIR_DOMAIN_OSTYPE_HVM )return 0 ; -if (d_config->num_vfbs ==0 ) +if (def->ngraphics ==0 )return 0 ;Quoted 8 lines
src/libxl/libxl_conf.c
Quoted 2 lines
src/libxl/libxl_conf.c +2
-0+for (i =0 ; i < def->ngraphics; i++) { +virDomainGraphicsDefPtr l_vfb = def->graphics[0 ];This seems really awkward to me. So you're using
for()loop just to check if the first graphics card (assuming there can't be more than one anyway) is SPICE. If not, you could use 'continue' to continue with VNC. I think this obfucates the code. Just move this into a separate function and call it from here.
Quoted 2 lines
That's actually a bug, it should be def->graphics[i]. The idea is to prefer SPICE, but fall back to the first graphics device if no SPICE device is found. I mentioned this in the function comment. Perhaps that part of the comment should be moved to the for loop?
Yes, that sounds reasonable to me.
Michal
Re: [libvirt] [PATCH 0/4] libxl: support SPICE graphics
In reply to a message not in the archiveQuoted 12 lines · Jim Fehlig
This series provides support for SPICE graphics in the libxl driver. The first patch is mostly code movement. The second patch is a trivial name change of a structure member. Patch3 populates the
libxl_domain_build_infostruct with SPICE info. SPICE isn't as nice without QXL, so patch4 provides support for QXL video device.Jim Fehlig (4):
libxl: populatebuild_infovfb in separate function
libxl: change reservedVNCPorts to reservedGraphicsPorts
libxl: support SPICE graphics for HVM domains
libxl: support QXL video device
Quoted 6 lines
src/libxl/libxl_conf.c | 150 +++++++++++++++++++++++++++++++++++++---------- src/libxl/libxl_conf.h | 2 +- src/libxl/libxl_domain.c | 8 ++- src/libxl/libxl_driver.c | 4 +- 4 files changed, 128 insertions(+), 36 deletions(-)
ACK to all, but please see my comment to 3/4 before pushing.
Even though we are in freeze, this has been lying around for a while therefore I think it's safe to push these.
Michal
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [libvirt] [PATCH 0/4] libxl: support SPICE graphics
Quoted 19 lines · Michal Privoznik
Quoted 12 lines · Jim Fehlig
This series provides support for SPICE graphics in the libxl driver. The first patch is mostly code movement. The second patch is a trivial name change of a structure member. Patch3 populates the
libxl_domain_build_infostruct with SPICE info. SPICE isn't as nice without QXL, so patch4 provides support for QXL video device.Jim Fehlig (4):
libxl: populatebuild_infovfb in separate function
libxl: change reservedVNCPorts to reservedGraphicsPorts
libxl: support SPICE graphics for HVM domains
libxl: support QXL video deviceQuoted 6 lines
src/libxl/libxl_conf.c | 150 +++++++++++++++++++++++++++++++++++++---------- src/libxl/libxl_conf.h | 2 +- src/libxl/libxl_domain.c | 8 ++- src/libxl/libxl_driver.c | 4 +- 4 files changed, 128 insertions(+), 36 deletions(-)
Quoted 4 lines
ACK to all, but please see my comment to 3/4 before pushing.
Even though we are in freeze, this has been lying around for a while therefore I think it's safe to push these.
Thanks for the review and finding the bug in 3/4! I changed it as we discussed and pushed the series.
Regards,
Jim