[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 20 of 26 V3] libxl: use defbool for graphics related options
# HG changeset patch # User Ian Campbell <ian.campbell@xxxxxxxxxx> # Date 1330000277 0 # Node ID 1620730643994e949b486b07dc919f74d17fa3e1 # Parent 7d012628126b838fcd19a9b65d141410d15705c8 libxl: use defbool for graphics related options This allows them to be set via the _init/_setdefault methods. Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx> Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> diff -r 7d012628126b -r 162073064399 tools/libxl/libxl.c --- a/tools/libxl/libxl.c Thu Feb 23 12:31:17 2012 +0000 +++ b/tools/libxl/libxl.c Thu Feb 23 12:31:17 2012 +0000 @@ -2257,22 +2257,23 @@ out: void libxl_device_vfb_init(libxl_device_vfb *vfb) { memset(vfb, 0x00, sizeof(libxl_device_vfb)); - vfb->vnc.enable = 1; - vfb->vnc.passwd = NULL; - vfb->vnc.display = 0; - vfb->vnc.findunused = 1; - vfb->keymap = NULL; - vfb->sdl.enable = 0; - vfb->sdl.opengl = 0; - vfb->sdl.display = NULL; - vfb->sdl.xauthority = NULL; } int libxl__device_vfb_setdefault(libxl__gc *gc, libxl_device_vfb *vfb) { - if (!vfb->vnc.listen) { - vfb->vnc.listen = strdup("127.0.0.1"); - if (!vfb->vnc.listen) return ERROR_NOMEM; + libxl_defbool_setdefault(&vfb->vnc.enable, true); + if (libxl_defbool_val(vfb->vnc.enable)) { + if (!vfb->vnc.listen) { + vfb->vnc.listen = strdup("127.0.0.1"); + if (!vfb->vnc.listen) return ERROR_NOMEM; + } + + libxl_defbool_setdefault(&vfb->vnc.findunused, true); + } + + libxl_defbool_setdefault(&vfb->sdl.enable, false); + if (libxl_defbool_val(vfb->sdl.enable)) { + libxl_defbool_setdefault(&vfb->sdl.opengl, false); } return 0; @@ -2321,17 +2322,17 @@ int libxl_device_vfb_add(libxl_ctx *ctx, flexarray_append_pair(back, "state", libxl__sprintf(gc, "%d", 1)); flexarray_append_pair(back, "domain", libxl__domid_to_name(gc, domid)); flexarray_append_pair(back, "vnc", - libxl__sprintf(gc, "%d", vfb->vnc.enable)); + libxl_defbool_val(vfb->vnc.enable) ? "1" : "0"); flexarray_append_pair(back, "vnclisten", vfb->vnc.listen); flexarray_append_pair(back, "vncpasswd", vfb->vnc.passwd); flexarray_append_pair(back, "vncdisplay", libxl__sprintf(gc, "%d", vfb->vnc.display)); flexarray_append_pair(back, "vncunused", - libxl__sprintf(gc, "%d", vfb->vnc.findunused)); + libxl_defbool_val(vfb->vnc.findunused) ? "1" : "0"); flexarray_append_pair(back, "sdl", - libxl__sprintf(gc, "%d", vfb->sdl.enable)); + libxl_defbool_val(vfb->sdl.enable) ? "1" : "0"); flexarray_append_pair(back, "opengl", - libxl__sprintf(gc, "%d", vfb->sdl.opengl)); + libxl_defbool_val(vfb->sdl.opengl) ? "1" : "0"); if (vfb->sdl.xauthority) { flexarray_append_pair(back, "xauthority", vfb->sdl.xauthority); } diff -r 7d012628126b -r 162073064399 tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Thu Feb 23 12:31:17 2012 +0000 +++ b/tools/libxl/libxl_create.c Thu Feb 23 12:31:17 2012 +0000 @@ -89,10 +89,7 @@ void libxl_domain_build_info_init(libxl_ b_info->u.hvm.firmware = NULL; b_info->u.hvm.timer_mode = LIBXL_TIMER_MODE_DEFAULT; - b_info->u.hvm.stdvga = 0; - b_info->u.hvm.vnc.enable = 1; b_info->u.hvm.vnc.display = 0; - b_info->u.hvm.vnc.findunused = 1; b_info->u.hvm.serial = NULL; b_info->u.hvm.usbdevice = NULL; break; @@ -158,13 +155,32 @@ int libxl__domain_build_info_setdefault( if (!b_info->u.hvm.boot) return ERROR_NOMEM; } - if (b_info->u.hvm.vnc.enable) { + libxl_defbool_setdefault(&b_info->u.hvm.stdvga, false); + libxl_defbool_setdefault(&b_info->u.hvm.vnc.enable, true); + if (libxl_defbool_val(b_info->u.hvm.vnc.enable)) { + libxl_defbool_setdefault(&b_info->u.hvm.vnc.findunused, true); if (!b_info->u.hvm.vnc.listen) { b_info->u.hvm.vnc.listen = strdup("127.0.0.1"); if (!b_info->u.hvm.vnc.listen) return ERROR_NOMEM; } } + libxl_defbool_setdefault(&b_info->u.hvm.sdl.enable, false); + if (libxl_defbool_val(b_info->u.hvm.sdl.enable)) { + libxl_defbool_setdefault(&b_info->u.hvm.sdl.opengl, false); + } + + libxl_defbool_setdefault(&b_info->u.hvm.spice.enable, false); + if (libxl_defbool_val(b_info->u.hvm.spice.enable)) { + libxl_defbool_setdefault(&b_info->u.hvm.spice.disable_ticketing, + false); + libxl_defbool_setdefault(&b_info->u.hvm.spice.agent_mouse, true); + } + + libxl_defbool_setdefault(&b_info->u.hvm.nographic, false); + + libxl_defbool_setdefault(&b_info->u.hvm.gfx_passthru, false); + break; case LIBXL_DOMAIN_TYPE_PV: libxl_defbool_setdefault(&b_info->u.pv.e820_host, false); diff -r 7d012628126b -r 162073064399 tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Thu Feb 23 12:31:17 2012 +0000 +++ b/tools/libxl/libxl_dm.c Thu Feb 23 12:31:17 2012 +0000 @@ -81,7 +81,7 @@ const libxl_vnc_info *libxl__dm_vnc(cons } else if (guest_config->num_vfbs > 0) { vnc = &guest_config->vfbs[0].vnc; } - return vnc && vnc->enable ? vnc : NULL; + return vnc && libxl_defbool_val(vnc->enable) ? vnc : NULL; } static const libxl_sdl_info *dm_sdl(const libxl_domain_config *guest_config) @@ -92,7 +92,7 @@ static const libxl_sdl_info *dm_sdl(cons } else if (guest_config->num_vfbs > 0) { sdl = &guest_config->vfbs[0].sdl; } - return sdl && sdl->enable ? sdl : NULL; + return sdl && libxl_defbool_val(sdl->enable) ? sdl : NULL; } static const char *dm_keymap(const libxl_domain_config *guest_config) @@ -154,13 +154,13 @@ static char ** libxl__build_device_model flexarray_append(dm_args, "-vnc"); flexarray_append(dm_args, vncarg); - if (vnc->findunused) { + if (libxl_defbool_val(vnc->findunused)) { flexarray_append(dm_args, "-vncunused"); } } if (sdl) { flexarray_append(dm_args, "-sdl"); - if (!sdl->opengl) { + if (!libxl_defbool_val(sdl->opengl)) { flexarray_append(dm_args, "-disable-opengl"); } /* XXX sdl->{display,xauthority} into $DISPLAY/$XAUTHORITY */ @@ -175,7 +175,7 @@ static char ** libxl__build_device_model flexarray_vappend(dm_args, "-serial", b_info->u.hvm.serial, NULL); } - if (b_info->u.hvm.nographic && (!sdl && !vnc)) { + if (libxl_defbool_val(b_info->u.hvm.nographic) && (!sdl && !vnc)) { flexarray_append(dm_args, "-nographic"); } @@ -185,7 +185,7 @@ static char ** libxl__build_device_model libxl__sizekb_to_mb(b_info->video_memkb)), NULL); } - if (b_info->u.hvm.stdvga) { + if (libxl_defbool_val(b_info->u.hvm.stdvga)) { flexarray_append(dm_args, "-std-vga"); } @@ -238,7 +238,7 @@ static char ** libxl__build_device_model if ( ioemu_vifs == 0 ) { flexarray_vappend(dm_args, "-net", "none", NULL); } - if (b_info->u.hvm.gfx_passthru) { + if (libxl_defbool_val(b_info->u.hvm.gfx_passthru)) { flexarray_append(dm_args, "-gfx_passthru"); } } else { @@ -291,7 +291,7 @@ static char *dm_spice_options(libxl__gc return NULL; } - if (!spice->disable_ticketing) { + if (!libxl_defbool_val(spice->disable_ticketing)) { if (!spice->passwd) { LIBXL__LOG(CTX, LIBXL__LOG_ERROR, "spice ticketing is enabled but missing password"); @@ -307,12 +307,12 @@ static char *dm_spice_options(libxl__gc spice->port, spice->tls_port); if (spice->host) opt = libxl__sprintf(gc, "%s,addr=%s", opt, spice->host); - if (spice->disable_ticketing) + if (libxl_defbool_val(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"); + libxl_defbool_val(spice->agent_mouse) ? "on" : "off"); return opt; } @@ -381,7 +381,7 @@ static char ** libxl__build_device_model if (vnc->passwd && vnc->passwd[0]) { vncarg = libxl__sprintf(gc, "%s,password", vncarg); } - if (vnc->findunused) { + if (libxl_defbool_val(vnc->findunused)) { /* This option asks to QEMU to try this number of port before to * give up. So QEMU will try ports between $display and $display + * 99. This option needs to be the last one of the vnc options. */ @@ -409,11 +409,11 @@ static char ** libxl__build_device_model flexarray_vappend(dm_args, "-serial", b_info->u.hvm.serial, NULL); } - if (b_info->u.hvm.nographic && (!sdl && !vnc)) { + if (libxl_defbool_val(b_info->u.hvm.nographic) && (!sdl && !vnc)) { flexarray_append(dm_args, "-nographic"); } - if (b_info->u.hvm.spice.enable) { + if (libxl_defbool_val(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) @@ -423,7 +423,7 @@ static char ** libxl__build_device_model flexarray_append(dm_args, spiceoptions); } - if (b_info->u.hvm.stdvga) { + if (libxl_defbool_val(b_info->u.hvm.stdvga)) { flexarray_vappend(dm_args, "-vga", "std", NULL); } @@ -483,7 +483,7 @@ static char ** libxl__build_device_model flexarray_append(dm_args, "-net"); flexarray_append(dm_args, "none"); } - if (b_info->u.hvm.gfx_passthru) { + if (libxl_defbool_val(b_info->u.hvm.gfx_passthru)) { flexarray_append(dm_args, "-gfx_passthru"); } } else { diff -r 7d012628126b -r 162073064399 tools/libxl/libxl_types.idl --- a/tools/libxl/libxl_types.idl Thu Feb 23 12:31:17 2012 +0000 +++ b/tools/libxl/libxl_types.idl Thu Feb 23 12:31:17 2012 +0000 @@ -123,31 +123,31 @@ libxl_shutdown_reason = Enumeration("shu # Complex libxl types # libxl_vnc_info = Struct("vnc_info", [ - ("enable", bool), + ("enable", libxl_defbool), # "address:port" that should be listened on ("listen", string), ("passwd", string), ("display", integer), # If set then try to find an unused port - ("findunused", bool), + ("findunused", libxl_defbool), ]) libxl_spice_info = Struct("spice_info", [ - ("enable", bool), + ("enable", libxl_defbool), # At least one of spice port or spicetls_post must be given ("port", integer), ("tls_port", integer), # Interface to bind to ("host", string), # enable client connection with no password - ("disable_ticketing", bool), + ("disable_ticketing", libxl_defbool), ("passwd", string), - ("agent_mouse", bool), + ("agent_mouse", libxl_defbool), ]) libxl_sdl_info = Struct("sdl_info", [ - ("enable", bool), - ("opengl", bool), + ("enable", libxl_defbool), + ("opengl", libxl_defbool), ("display", string), ("xauthority", string), ]) @@ -261,15 +261,15 @@ libxl_domain_build_info = Struct("domain ("timer_mode", libxl_timer_mode), ("nested_hvm", libxl_defbool), ("incr_generationid",libxl_defbool), - ("nographic", bool), - ("stdvga", bool), + ("nographic", libxl_defbool), + ("stdvga", libxl_defbool), ("vnc", libxl_vnc_info), # keyboard layout, default is en-us keyboard ("keymap", string), ("sdl", libxl_sdl_info), ("spice", libxl_spice_info), - ("gfx_passthru", bool), + ("gfx_passthru", libxl_defbool), ("serial", string), ("boot", string), diff -r 7d012628126b -r 162073064399 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Thu Feb 23 12:31:17 2012 +0000 +++ b/tools/libxl/xl_cmdimpl.c Thu Feb 23 12:31:17 2012 +0000 @@ -941,7 +941,7 @@ skip: break; *p2 = '\0'; if (!strcmp(p, "vnc")) { - vfb->vnc.enable = atoi(p2 + 1); + libxl_defbool_set(&vfb->vnc.enable, atoi(p2 + 1)); } else if (!strcmp(p, "vnclisten")) { free(vfb->vnc.listen); vfb->vnc.listen = strdup(p2 + 1); @@ -951,14 +951,14 @@ skip: } else if (!strcmp(p, "vncdisplay")) { vfb->vnc.display = atoi(p2 + 1); } else if (!strcmp(p, "vncunused")) { - vfb->vnc.findunused = atoi(p2 + 1); + libxl_defbool_set(&vfb->vnc.findunused, atoi(p2 + 1)); } else if (!strcmp(p, "keymap")) { free(vfb->keymap); vfb->keymap = strdup(p2 + 1); } else if (!strcmp(p, "sdl")) { - vfb->sdl.enable = atoi(p2 + 1); + libxl_defbool_set(&vfb->sdl.enable, atoi(p2 + 1)); } else if (!strcmp(p, "opengl")) { - vfb->sdl.opengl = atoi(p2 + 1); + libxl_defbool_set(&vfb->sdl.opengl, atoi(p2 + 1)); } else if (!strcmp(p, "display")) { free(vfb->sdl.display); vfb->sdl.display = strdup(p2 + 1); @@ -1158,41 +1158,35 @@ skip_vfb: #undef parse_extra_args if (c_info->type == LIBXL_DOMAIN_TYPE_HVM) { - if (!xlu_cfg_get_long (config, "stdvga", &l, 0)) - b_info->u.hvm.stdvga = l; - if (!xlu_cfg_get_long (config, "vnc", &l, 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); + xlu_cfg_get_defbool(config, "stdvga", &b_info->u.hvm.stdvga, 0); + xlu_cfg_get_defbool(config, "vnc", &b_info->u.hvm.vnc.enable, 0); + 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)) b_info->u.hvm.vnc.display = l; - if (!xlu_cfg_get_long (config, "vncunused", &l, 0)) - b_info->u.hvm.vnc.findunused = l; + xlu_cfg_get_defbool(config, "vncunused", + &b_info->u.hvm.vnc.findunused, 0); xlu_cfg_replace_string (config, "keymap", &b_info->u.hvm.keymap, 0); - if (!xlu_cfg_get_long (config, "sdl", &l, 0)) - b_info->u.hvm.sdl.enable = l; - if (!xlu_cfg_get_long (config, "opengl", &l, 0)) - b_info->u.hvm.sdl.opengl = l; - if (!xlu_cfg_get_long (config, "spice", &l, 0)) - b_info->u.hvm.spice.enable = l; + xlu_cfg_get_defbool(config, "sdl", &b_info->u.hvm.sdl.enable, 0); + xlu_cfg_get_defbool(config, "opengl", &b_info->u.hvm.sdl.opengl, 0); + xlu_cfg_get_defbool (config, "spice", &b_info->u.hvm.spice.enable, 0); if (!xlu_cfg_get_long (config, "spiceport", &l, 0)) b_info->u.hvm.spice.port = l; if (!xlu_cfg_get_long (config, "spicetls_port", &l, 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)) - b_info->u.hvm.spice.disable_ticketing = l; + xlu_cfg_get_defbool(config, "spicedisable_ticketing", + &b_info->u.hvm.spice.disable_ticketing, 0); xlu_cfg_replace_string (config, "spicepasswd", &b_info->u.hvm.spice.passwd, 0); - if (!xlu_cfg_get_long (config, "spiceagent_mouse", &l, 0)) - b_info->u.hvm.spice.agent_mouse = l; - else - b_info->u.hvm.spice.agent_mouse = 1; - if (!xlu_cfg_get_long (config, "nographic", &l, 0)) - b_info->u.hvm.nographic = l; - if (!xlu_cfg_get_long (config, "gfx_passthru", &l, 0)) - b_info->u.hvm.gfx_passthru = l; + xlu_cfg_get_defbool(config, "spiceagent_mouse", + &b_info->u.hvm.spice.agent_mouse, 0); + xlu_cfg_get_defbool(config, "nographic", &b_info->u.hvm.nographic, 0); + xlu_cfg_get_defbool(config, "gfx_passthru", + &b_info->u.hvm.gfx_passthru, 0); xlu_cfg_replace_string (config, "serial", &b_info->u.hvm.serial, 0); xlu_cfg_replace_string (config, "boot", &b_info->u.hvm.boot, 0); xlu_cfg_get_defbool(config, "usb", &b_info->u.hvm.usb, 0); diff -r 7d012628126b -r 162073064399 tools/libxl/xl_sxp.c --- a/tools/libxl/xl_sxp.c Thu Feb 23 12:31:17 2012 +0000 +++ b/tools/libxl/xl_sxp.c Thu Feb 23 12:31:17 2012 +0000 @@ -110,26 +110,34 @@ void printf_info_sexp(int domid, libxl_d libxl_defbool_to_string(b_info->u.hvm.nested_hvm)); printf("\t\t\t(no_incr_generationid %s)\n", libxl_defbool_to_string(b_info->u.hvm.incr_generationid)); - - 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(stdvga %s)\n", + libxl_defbool_to_string(b_info->u.hvm.stdvga)); + printf("\t\t\t(vnc %s)\n", + libxl_defbool_to_string(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(vncunused %s)\n", + libxl_defbool_to_string(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(sdl %s)\n", + libxl_defbool_to_string(b_info->u.hvm.sdl.enable)); + printf("\t\t\t(opengl %s)\n", + libxl_defbool_to_string(b_info->u.hvm.sdl.opengl)); + printf("\t\t\t(nographic %s)\n", + libxl_defbool_to_string(b_info->u.hvm.nographic)); + printf("\t\t\t(spice %s)\n", + libxl_defbool_to_string(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(spicedisable_ticketing %s)\n", + libxl_defbool_to_string(b_info->u.hvm.spice.disable_ticketing)); + printf("\t\t\t(spiceagent_mouse %s)\n", + libxl_defbool_to_string(b_info->u.hvm.spice.agent_mouse)); printf("\t\t\t(device_model %s)\n", b_info->device_model ? : "default"); - printf("\t\t\t(gfx_passthru %d)\n", b_info->u.hvm.gfx_passthru); + printf("\t\t\t(gfx_passthru %s)\n", + libxl_defbool_to_string(b_info->u.hvm.gfx_passthru)); printf("\t\t\t(serial %s)\n", b_info->u.hvm.serial); printf("\t\t\t(boot %s)\n", b_info->u.hvm.boot); printf("\t\t\t(usb %s)\n", libxl_defbool_to_string(b_info->u.hvm.usb)); @@ -204,13 +212,17 @@ void printf_info_sexp(int domid, libxl_d printf("\t\t\t(backend_domid %d)\n", d_config->vfbs[i].backend_domid); printf("\t\t\t(frontend_domid %d)\n", domid); printf("\t\t\t(devid %d)\n", d_config->vfbs[i].devid); - printf("\t\t\t(vnc %d)\n", d_config->vfbs[i].vnc.enable); + printf("\t\t\t(vnc %s)\n", + libxl_defbool_to_string(d_config->vfbs[i].vnc.enable)); printf("\t\t\t(vnclisten %s)\n", d_config->vfbs[i].vnc.listen); printf("\t\t\t(vncdisplay %d)\n", d_config->vfbs[i].vnc.display); - printf("\t\t\t(vncunused %d)\n", d_config->vfbs[i].vnc.findunused); + printf("\t\t\t(vncunused %s)\n", + libxl_defbool_to_string(d_config->vfbs[i].vnc.findunused)); printf("\t\t\t(keymap %s)\n", d_config->vfbs[i].keymap); - printf("\t\t\t(sdl %d)\n", d_config->vfbs[i].sdl.enable); - printf("\t\t\t(opengl %d)\n", d_config->vfbs[i].sdl.opengl); + printf("\t\t\t(sdl %s)\n", + libxl_defbool_to_string(d_config->vfbs[i].sdl.enable)); + printf("\t\t\t(opengl %s)\n", + libxl_defbool_to_string(d_config->vfbs[i].sdl.opengl)); printf("\t\t\t(display %s)\n", d_config->vfbs[i].sdl.display); printf("\t\t\t(xauthority %s)\n", d_config->vfbs[i].sdl.xauthority); printf("\t\t)\n"); _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |