[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 13 of 32 RFC] libxl: move HVM emulated GFX support into b_info->u.hvm
# HG changeset patch # User Ian Campbell <ian.campbell@xxxxxxxxxx> # Date 1326367192 0 # Node ID 0ef52f0b6c58344ee371d668ea343628aaecb714 # Parent 714cb45a8327bae6ede162f12e21cc8e0397ae1f libxl: move HVM emulated GFX support into b_info->u.hvm Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx> diff -r 714cb45a8327 -r 0ef52f0b6c58 tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Thu Jan 12 10:25:59 2012 +0000 +++ b/tools/libxl/libxl_create.c Thu Jan 12 11:19:52 2012 +0000 @@ -99,6 +99,16 @@ int libxl_init_build_info(libxl_ctx *ctx b_info->u.hvm.vpt_align = 1; b_info->u.hvm.timer_mode = 1; b_info->u.hvm.nested_hvm = 0; + + b_info->u.hvm.stdvga = 0; + b_info->u.hvm.vnc.enable = 1; + b_info->u.hvm.vnc.listen = strdup("127.0.0.1"); + b_info->u.hvm.vnc.display = 0; + b_info->u.hvm.vnc.findunused = 1; + b_info->u.hvm.keymap = NULL; + b_info->u.hvm.sdl.enable = 0; + b_info->u.hvm.sdl.opengl = 0; + b_info->u.hvm.nographic = 0; break; case LIBXL_DOMAIN_TYPE_PV: b_info->u.pv.slack_memkb = 8 * 1024; @@ -124,17 +134,7 @@ int libxl_init_dm_info(libxl_ctx *ctx, dm_info->device_model_version = LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL; dm_info->device_model_stubdomain = false; dm_info->device_model = NULL; - dm_info->videoram = libxl__sizekb_to_mb(b_info->video_memkb); - dm_info->stdvga = 0; - dm_info->vnc.enable = 1; - dm_info->vnc.listen = strdup("127.0.0.1"); - dm_info->vnc.display = 0; - dm_info->vnc.findunused = 1; - dm_info->keymap = NULL; - dm_info->sdl.enable = 0; - dm_info->sdl.opengl = 0; - dm_info->nographic = 0; dm_info->serial = NULL; dm_info->boot = strdup("cda"); dm_info->usb = 0; diff -r 714cb45a8327 -r 0ef52f0b6c58 tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Thu Jan 12 10:25:59 2012 +0000 +++ b/tools/libxl/libxl_dm.c Thu Jan 12 11:19:52 2012 +0000 @@ -86,7 +86,7 @@ static const libxl_vnc_info *dm_vnc(cons { const libxl_vnc_info *vnc = NULL; if (info->type == LIBXL_DOMAIN_TYPE_HVM) { - vnc = &info->vnc; + vnc = &guest_config->b_info.u.hvm.vnc; } else if (guest_config->num_vfbs > 0) { vnc = &guest_config->vfbs[0].vnc; } @@ -98,13 +98,24 @@ static const libxl_sdl_info *dm_sdl(cons { const libxl_sdl_info *sdl = NULL; if (info->type == LIBXL_DOMAIN_TYPE_HVM) { - sdl = &info->sdl; + sdl = &guest_config->b_info.u.hvm.sdl; } else if (guest_config->num_vfbs > 0) { sdl = &guest_config->vfbs[0].sdl; } return sdl && sdl->enable ? sdl : NULL; } +static const char *dm_keymap(const libxl_domain_config *guest_config, + const libxl_device_model_info *info) +{ + if (info->type == LIBXL_DOMAIN_TYPE_HVM) { + return guest_config->b_info.u.hvm.keymap; + } else if (guest_config->num_vfbs > 0) { + return guest_config->vfbs[0].keymap; + } else + return NULL; +} + static char ** libxl__build_device_model_args_old(libxl__gc *gc, const char *dm, const libxl_domain_config *guest_config, @@ -116,6 +127,7 @@ static char ** libxl__build_device_model const libxl_vnc_info *vnc = dm_vnc(guest_config, info); const libxl_sdl_info *sdl = dm_sdl(guest_config, info); const int num_vifs = guest_config->num_vifs; + const char *keymap = dm_keymap(guest_config, info); int i; flexarray_t *dm_args; dm_args = flexarray_make(16, 1); @@ -164,11 +176,8 @@ static char ** libxl__build_device_model } /* XXX sdl->{display,xauthority} into $DISPLAY/$XAUTHORITY */ } - if (info->keymap) { - flexarray_vappend(dm_args, "-k", info->keymap, NULL); - } - if (info->nographic && (!sdl && !vnc)) { - flexarray_append(dm_args, "-nographic"); + if (keymap) { + flexarray_vappend(dm_args, "-k", keymap, NULL); } if (info->serial) { flexarray_vappend(dm_args, "-serial", info->serial, NULL); @@ -176,10 +185,17 @@ static char ** libxl__build_device_model if (info->type == LIBXL_DOMAIN_TYPE_HVM) { int ioemu_vifs = 0; - if (info->videoram) { - flexarray_vappend(dm_args, "-videoram", libxl__sprintf(gc, "%d", info->videoram), NULL); + if (b_info->u.hvm.nographic && (!sdl && !vnc)) { + flexarray_append(dm_args, "-nographic"); } - if (info->stdvga) { + + if (b_info->video_memkb) { + flexarray_vappend(dm_args, "-videoram", + libxl__sprintf(gc, "%d", + libxl__sizekb_to_mb(b_info->video_memkb)), + NULL); + } + if (b_info->u.hvm.stdvga) { flexarray_append(dm_args, "-std-vga"); } @@ -233,7 +249,11 @@ static char ** libxl__build_device_model if (info->gfx_passthru) { flexarray_append(dm_args, "-gfx_passthru"); } + } else { + if (!sdl && !vnc) + flexarray_append(dm_args, "-nographic"); } + if (info->saved_state) { flexarray_vappend(dm_args, "-loadvm", info->saved_state, NULL); } @@ -268,6 +288,42 @@ static const char *qemu_disk_format_stri } } +static char *dm_spice_options(libxl__gc *gc, + const libxl_spice_info *spice) +{ + char *opt; + + if (!spice->port && !spice->tls_port) { + LIBXL__LOG(CTX, LIBXL__LOG_ERROR, + "at least one of the spiceport or tls_port must be provided"); + return NULL; + } + + if (!spice->disable_ticketing) { + if (!spice->passwd) { + LIBXL__LOG(CTX, LIBXL__LOG_ERROR, + "spice ticketing is enabled but missing password"); + return NULL; + } + else if (!spice->passwd[0]) { + LIBXL__LOG(CTX, LIBXL__LOG_ERROR, + "spice password can't be empty"); + return NULL; + } + } + opt = libxl__sprintf(gc, "port=%d,tls-port=%d", + spice->port, spice->tls_port); + if (spice->host) + opt = libxl__sprintf(gc, "%s,addr=%s", opt, spice->host); + if (spice->disable_ticketing) + opt = libxl__sprintf(gc, "%s,disable-ticketing", opt); + else + opt = libxl__sprintf(gc, "%s,password=%s", opt, spice->passwd); + opt = libxl__sprintf(gc, "%s,agent-mouse=%s", opt, + spice->agent_mouse ? "on" : "off"); + return opt; +} + static char ** libxl__build_device_model_args_new(libxl__gc *gc, const char *dm, const libxl_domain_config *guest_config, @@ -282,6 +338,7 @@ static char ** libxl__build_device_model const int num_vifs = guest_config->num_vifs; const libxl_vnc_info *vnc = dm_vnc(guest_config, info); const libxl_sdl_info *sdl = dm_sdl(guest_config, info); + const char *keymap = dm_keymap(guest_config, info); flexarray_t *dm_args; int i; @@ -340,61 +397,36 @@ static char ** libxl__build_device_model flexarray_append(dm_args, "-sdl"); /* XXX sdl->{display,xauthority} into $DISPLAY/$XAUTHORITY */ } - if (info->spice.enable) { - char *spiceoptions = NULL; - if (!info->spice.port && !info->spice.tls_port) { - LIBXL__LOG(ctx, LIBXL__LOG_ERROR, - "at least one of the spiceport or tls_port must be provided"); - return NULL; - } - if (!info->spice.disable_ticketing) { - if (!info->spice.passwd) { - LIBXL__LOG(ctx, LIBXL__LOG_ERROR, - "spice ticketing is enabled but missing password"); - return NULL; - } - else if (!info->spice.passwd[0]) { - LIBXL__LOG(ctx, LIBXL__LOG_ERROR, - "spice password can't be empty"); - return NULL; - } - } - spiceoptions = libxl__sprintf(gc, "port=%d,tls-port=%d", - info->spice.port, info->spice.tls_port); - if (info->spice.host) - spiceoptions = libxl__sprintf(gc, - "%s,addr=%s", spiceoptions, info->spice.host); - if (info->spice.disable_ticketing) - spiceoptions = libxl__sprintf(gc, "%s,disable-ticketing", - spiceoptions); - else - spiceoptions = libxl__sprintf(gc, - "%s,password=%s", spiceoptions, info->spice.passwd); - spiceoptions = libxl__sprintf(gc, "%s,agent-mouse=%s", spiceoptions, - info->spice.agent_mouse ? "on" : "off"); + /*if (info->type == LIBXL_DOMAIN_TYPE_PV && !b_info->nographic) { + flexarray_vappend(dm_args, "-vga", "xenfb", NULL); + } never was possible?*/ - flexarray_append(dm_args, "-spice"); - flexarray_append(dm_args, spiceoptions); + if (keymap) { + flexarray_vappend(dm_args, "-k", keymap, NULL); } - if (info->type == LIBXL_DOMAIN_TYPE_PV && !info->nographic) { - flexarray_vappend(dm_args, "-vga", "xenfb", NULL); - } - - if (info->keymap) { - flexarray_vappend(dm_args, "-k", info->keymap, NULL); - } - if (info->nographic && (!sdl && !vnc)) { - flexarray_append(dm_args, "-nographic"); - } if (info->serial) { flexarray_vappend(dm_args, "-serial", info->serial, NULL); } if (info->type == LIBXL_DOMAIN_TYPE_HVM) { int ioemu_vifs = 0; - if (info->stdvga) { + if (b_info->u.hvm.nographic && (!sdl && !vnc)) { + flexarray_append(dm_args, "-nographic"); + } + + if (b_info->u.hvm.spice.enable) { + const libxl_spice_info *spice = &b_info->u.hvm.spice; + char *spiceoptions = dm_spice_options(gc, spice); + if (!spiceoptions) + return NULL; + + flexarray_append(dm_args, "-spice"); + flexarray_append(dm_args, spiceoptions); + } + + if (b_info->u.hvm.stdvga) { flexarray_vappend(dm_args, "-vga", "std", NULL); } @@ -454,7 +486,12 @@ static char ** libxl__build_device_model if (info->gfx_passthru) { flexarray_append(dm_args, "-gfx_passthru"); } + } else { + if (!sdl && !vnc) { + flexarray_append(dm_args, "-nographic"); + } } + if (info->saved_state) { /* This file descriptor is meant to be used by QEMU */ int migration_fd = open(info->saved_state, O_RDONLY); @@ -563,19 +600,24 @@ static char ** libxl__build_device_model } } -static int libxl__vfb_and_vkb_from_device_model_info(libxl__gc *gc, - const libxl_device_model_info *info, +static int libxl__vfb_and_vkb_from_hvm_guest_config(libxl__gc *gc, + const libxl_domain_config *guest_config, libxl_device_vfb *vfb, libxl_device_vkb *vkb) { + const libxl_domain_build_info *b_info = &guest_config->b_info; + + if (b_info->type != LIBXL_DOMAIN_TYPE_HVM) + return ERROR_INVAL; + memset(vfb, 0x00, sizeof(libxl_device_vfb)); memset(vkb, 0x00, sizeof(libxl_device_vkb)); vfb->backend_domid = 0; vfb->devid = 0; - vfb->vnc = info->vnc; - vfb->keymap = info->keymap; - vfb->sdl = info->sdl; + vfb->vnc = b_info->u.hvm.vnc; + vfb->keymap = b_info->u.hvm.keymap; + vfb->sdl = b_info->u.hvm.sdl; vkb->backend_domid = 0; vkb->devid = 0; @@ -678,8 +720,7 @@ static int libxl__create_stubdom(libxl__ dm_config.vifs = guest_config->vifs; dm_config.num_vifs = guest_config->num_vifs; - libxl__vfb_and_vkb_from_device_model_info(gc, info, &vfb, &vkb); - + libxl__vfb_and_vkb_from_hvm_guest_config(gc, guest_config, &vfb, &vkb); dm_config.vfbs = &vfb; dm_config.num_vfbs = 1; dm_config.vkbs = &vkb; diff -r 714cb45a8327 -r 0ef52f0b6c58 tools/libxl/libxl_types.idl --- a/tools/libxl/libxl_types.idl Thu Jan 12 10:25:59 2012 +0000 +++ b/tools/libxl/libxl_types.idl Thu Jan 12 11:19:52 2012 +0000 @@ -219,6 +219,13 @@ libxl_domain_build_info = Struct("domain ("vpt_align", bool), ("timer_mode", integer), ("nested_hvm", bool), + ("nographic", bool), + ("stdvga", bool), + ("vnc", libxl_vnc_info), + # keyboard layout, default is en-us keyboard + ("keymap", string), + ("sdl", libxl_sdl_info), + ("spice", libxl_spice_info), ])), ("pv", Struct(None, [("kernel", libxl_file_reference), ("slack_memkb", uint32), @@ -247,15 +254,6 @@ libxl_device_model_info = Struct("device ("device_model", string), ("saved_state", string), ("type", libxl_domain_type), - # size of the videoram in MB - ("videoram", integer), - ("stdvga", bool), - ("vnc", libxl_vnc_info), - # keyboard layout, default is en-us keyboard - ("keymap", string), - ("sdl", libxl_sdl_info), - ("spice", libxl_spice_info), - ("nographic", bool), ("gfx_passthru", bool), ("serial", string), ("boot", string), diff -r 714cb45a8327 -r 0ef52f0b6c58 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Thu Jan 12 10:25:59 2012 +0000 +++ b/tools/libxl/xl_cmdimpl.c Thu Jan 12 11:19:52 2012 +0000 @@ -361,29 +361,29 @@ static void printf_info(int domid, printf("\t\t\t(timer_mode %d)\n", b_info->u.hvm.timer_mode); printf("\t\t\t(nestedhvm %d)\n", b_info->u.hvm.nested_hvm); + printf("\t\t\t(stdvga %d)\n", b_info->u.hvm.stdvga); + printf("\t\t\t(vnc %d)\n", b_info->u.hvm.vnc.enable); + printf("\t\t\t(vnclisten %s)\n", b_info->u.hvm.vnc.listen); + printf("\t\t\t(vncdisplay %d)\n", b_info->u.hvm.vnc.display); + printf("\t\t\t(vncunused %d)\n", b_info->u.hvm.vnc.findunused); + printf("\t\t\t(keymap %s)\n", b_info->u.hvm.keymap); + printf("\t\t\t(sdl %d)\n", b_info->u.hvm.sdl.enable); + printf("\t\t\t(opengl %d)\n", b_info->u.hvm.sdl.opengl); + printf("\t\t\t(nographic %d)\n", b_info->u.hvm.nographic); + printf("\t\t\t(spice %d)\n", b_info->u.hvm.spice.enable); + printf("\t\t\t(spiceport %d)\n", b_info->u.hvm.spice.port); + printf("\t\t\t(spicetls_port %d)\n", b_info->u.hvm.spice.tls_port); + printf("\t\t\t(spicehost %s)\n", b_info->u.hvm.spice.host); + printf("\t\t\t(spicedisable_ticketing %d)\n", + b_info->u.hvm.spice.disable_ticketing); + printf("\t\t\t(spiceagent_mouse %d)\n", b_info->u.hvm.spice.agent_mouse); + printf("\t\t\t(device_model %s)\n", dm_info->device_model ? : "default"); - printf("\t\t\t(videoram %d)\n", dm_info->videoram); - printf("\t\t\t(stdvga %d)\n", dm_info->stdvga); - printf("\t\t\t(vnc %d)\n", dm_info->vnc.enable); - printf("\t\t\t(vnclisten %s)\n", dm_info->vnc.listen); - printf("\t\t\t(vncdisplay %d)\n", dm_info->vnc.display); - printf("\t\t\t(vncunused %d)\n", dm_info->vnc.findunused); - printf("\t\t\t(keymap %s)\n", dm_info->keymap); - printf("\t\t\t(sdl %d)\n", dm_info->sdl.enable); printf("\t\t\t(gfx_passthru %d)\n", dm_info->gfx_passthru); - printf("\t\t\t(opengl %d)\n", dm_info->sdl.opengl); - printf("\t\t\t(nographic %d)\n", dm_info->nographic); printf("\t\t\t(serial %s)\n", dm_info->serial); printf("\t\t\t(boot %s)\n", dm_info->boot); printf("\t\t\t(usb %d)\n", dm_info->usb); printf("\t\t\t(usbdevice %s)\n", dm_info->usbdevice); - printf("\t\t\t(spice %d)\n", dm_info->spice.enable); - printf("\t\t\t(spiceport %d)\n", dm_info->spice.port); - printf("\t\t\t(spicetls_port %d)\n", dm_info->spice.tls_port); - printf("\t\t\t(spicehost %s)\n", dm_info->spice.host); - printf("\t\t\t(spicedisable_ticketing %d)\n", - dm_info->spice.disable_ticketing); - printf("\t\t\t(spiceagent_mouse %d)\n", dm_info->spice.agent_mouse); printf("\t\t)\n"); break; case LIBXL_DOMAIN_TYPE_PV: @@ -1175,37 +1175,38 @@ skip_vfb: if (c_info->type == LIBXL_DOMAIN_TYPE_HVM) { if (!xlu_cfg_get_long (config, "stdvga", &l, 0)) - dm_info->stdvga = l; + b_info->u.hvm.stdvga = l; if (!xlu_cfg_get_long (config, "vnc", &l, 0)) - dm_info->vnc.enable = l; - xlu_cfg_replace_string (config, "vnclisten", &dm_info->vnc.listen, 0); - xlu_cfg_replace_string (config, "vncpasswd", &dm_info->vnc.passwd, 0); + b_info->u.hvm.vnc.enable = l; + xlu_cfg_replace_string (config, "vnclisten", &b_info->u.hvm.vnc.listen, 0); + xlu_cfg_replace_string (config, "vncpasswd", &b_info->u.hvm.vnc.passwd, 0); if (!xlu_cfg_get_long (config, "vncdisplay", &l, 0)) - dm_info->vnc.display = l; + b_info->u.hvm.vnc.display = l; if (!xlu_cfg_get_long (config, "vncunused", &l, 0)) - dm_info->vnc.findunused = l; - xlu_cfg_replace_string (config, "keymap", &dm_info->keymap, 0); + b_info->u.hvm.vnc.findunused = l; + xlu_cfg_replace_string (config, "keymap", &b_info->u.hvm.keymap, 0); if (!xlu_cfg_get_long (config, "sdl", &l, 0)) - dm_info->sdl.enable = l; + b_info->u.hvm.sdl.enable = l; if (!xlu_cfg_get_long (config, "opengl", &l, 0)) - dm_info->sdl.opengl = l; + b_info->u.hvm.sdl.opengl = l; if (!xlu_cfg_get_long (config, "spice", &l, 0)) - dm_info->spice.enable = l; + b_info->u.hvm.spice.enable = l; if (!xlu_cfg_get_long (config, "spiceport", &l, 0)) - dm_info->spice.port = l; + b_info->u.hvm.spice.port = l; if (!xlu_cfg_get_long (config, "spicetls_port", &l, 0)) - dm_info->spice.tls_port = l; - xlu_cfg_replace_string (config, "spicehost", &dm_info->spice.host, 0); + b_info->u.hvm.spice.tls_port = l; + xlu_cfg_replace_string (config, "spicehost", + &b_info->u.hvm.spice.host, 0); if (!xlu_cfg_get_long (config, "spicedisable_ticketing", &l, 0)) - dm_info->spice.disable_ticketing = l; + b_info->u.hvm.spice.disable_ticketing = l; xlu_cfg_replace_string (config, "spicepasswd", - &dm_info->spice.passwd, 0); + &b_info->u.hvm.spice.passwd, 0); if (!xlu_cfg_get_long (config, "spiceagent_mouse", &l, 0)) - dm_info->spice.agent_mouse = l; + b_info->u.hvm.spice.agent_mouse = l; else - dm_info->spice.agent_mouse = 1; + b_info->u.hvm.spice.agent_mouse = 1; if (!xlu_cfg_get_long (config, "nographic", &l, 0)) - dm_info->nographic = l; + b_info->u.hvm.nographic = l; if (!xlu_cfg_get_long (config, "gfx_passthru", &l, 0)) dm_info->gfx_passthru = l; xlu_cfg_replace_string (config, "serial", &dm_info->serial, 0); _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |