From: Wei Liu <wei.liu2@citrix.com>
To: xen-devel@lists.xen.org
Cc: Ian Jackson <ian.jackson@eu.citrix.com>,
Wei Liu <wei.liu2@citrix.com>,
Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH V3] xl: create VFB for PV guest when VNC is specified
Date: Mon, 16 Dec 2013 17:39:36 +0000 [thread overview]
Message-ID: <1387215576-17455-1-git-send-email-wei.liu2@citrix.com> (raw)
This replicates a Xend behavior, when you specify:
vnc=1
vnclisten=XXXX
vncpasswd=XXXX
in a PV guest's config file, it creates a VFB for you.
Fixes bug #25.
http://bugs.xenproject.org/xen/bug/25
Reported-by: Konrad Wilk <konrad.wilk@oracle.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
---
Changes in V3:
* ARRAY_EXTEND macro
* make parse_top_level_vnc_options a function
Changes in V2:
* use macros to reduce code duplication
* vfb=[] take precedence over top level VNC options
---
tools/libxl/xl_cmdimpl.c | 89 ++++++++++++++++++++++++++++++++++++----------
1 file changed, 70 insertions(+), 19 deletions(-)
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index bd26bcc..6a22e17 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -315,6 +315,13 @@ static void *xrealloc(void *ptr, size_t sz) {
return r;
}
+#define ARRAY_EXTEND(array,count) \
+ do { \
+ (array) = xrealloc((array), \
+ sizeof(typeof(*(array))) * ((count) + 1)); \
+ (count) = (count) + 1; \
+ } while (0)
+
#define LOG(_f, _a...) dolog(__FILE__, __LINE__, __func__, _f "\n", ##_a)
static void dolog(const char *file, int line, const char *func, char *fmt, ...)
@@ -686,6 +693,22 @@ static int vcpupin_parse(char *cpu, libxl_bitmap *cpumap)
return rc;
}
+static void parse_top_level_vnc_options(XLU_Config *config,
+ libxl_defbool *enable,
+ char **listen,
+ char **passwd,
+ int *display,
+ libxl_defbool *unused)
+{
+ long l;
+ xlu_cfg_get_defbool(config, "vnc", enable, 0);
+ xlu_cfg_replace_string (config, "vnclisten", listen, 0);
+ xlu_cfg_replace_string (config, "vncpasswd", passwd, 0);
+ if (!xlu_cfg_get_long (config, "vncdisplay", &l, 0))
+ *display = l;
+ xlu_cfg_get_defbool(config, "vncunused", unused, 0);
+}
+
static void parse_config_data(const char *config_source,
const char *config_data,
int config_len,
@@ -1357,11 +1380,12 @@ skip_nic:
fprintf(stderr, "WARNING: vif2: netchannel2 is deprecated and not supported by xl\n");
}
+ d_config->num_vfbs = 0;
+ d_config->num_vkbs = 0;
+ d_config->vfbs = NULL;
+ d_config->vkbs = NULL;
+
if (!xlu_cfg_get_list (config, "vfb", &cvfbs, 0, 0)) {
- d_config->num_vfbs = 0;
- d_config->num_vkbs = 0;
- d_config->vfbs = NULL;
- d_config->vkbs = NULL;
while ((buf = xlu_cfg_get_listitem (cvfbs, d_config->num_vfbs)) != NULL) {
libxl_device_vfb *vfb;
libxl_device_vkb *vkb;
@@ -1369,13 +1393,13 @@ skip_nic:
char *buf2 = strdup(buf);
char *p, *p2;
- d_config->vfbs = (libxl_device_vfb *) realloc(d_config->vfbs, sizeof(libxl_device_vfb) * (d_config->num_vfbs + 1));
- vfb = d_config->vfbs + d_config->num_vfbs;
+ ARRAY_EXTEND(d_config->vfbs, d_config->num_vfbs);
+ vfb = d_config->vfbs + (d_config->num_vfbs - 1);
libxl_device_vfb_init(vfb);
vfb->devid = d_config->num_vfbs;
- d_config->vkbs = (libxl_device_vkb *) realloc(d_config->vkbs, sizeof(libxl_device_vkb) * (d_config->num_vkbs + 1));
- vkb = d_config->vkbs + d_config->num_vkbs;
+ ARRAY_EXTEND(d_config->vkbs, d_config->num_vkbs);
+ vkb = d_config->vkbs + (d_config->num_vkbs - 1);
libxl_device_vkb_init(vkb);
vkb->devid = d_config->num_vkbs;
@@ -1418,8 +1442,6 @@ skip_nic:
skip_vfb:
free(buf2);
- d_config->num_vfbs++;
- d_config->num_vkbs++;
}
}
@@ -1608,6 +1630,44 @@ skip_vfb:
#undef parse_extra_args
+ /* If we've already got vfb=[] for PV guestthen ignore top level
+ * VNC config. */
+ if (c_info->type == LIBXL_DOMAIN_TYPE_PV && !d_config->num_vfbs) {
+ long vnc_enabled = 0;
+
+ if (!xlu_cfg_get_long (config, "vnc", &l, 0))
+ vnc_enabled = l;
+
+ if (vnc_enabled) {
+ libxl_device_vfb *vfb;
+ libxl_device_vkb *vkb;
+
+ ARRAY_EXTEND(d_config->vfbs, d_config->num_vfbs);
+ vfb = d_config->vfbs + (d_config->num_vfbs - 1);
+ libxl_device_vfb_init(vfb);
+ vfb->devid = d_config->num_vfbs;
+
+ ARRAY_EXTEND(d_config->vkbs, d_config->num_vkbs);
+ vkb = d_config->vkbs + (d_config->num_vkbs - 1);
+ libxl_device_vkb_init(vkb);
+ vkb->devid = d_config->num_vkbs;
+
+ parse_top_level_vnc_options(config,
+ &vfb->vnc.enable,
+ &vfb->vnc.listen,
+ &vfb->vnc.passwd,
+ &vfb->vnc.display,
+ &vfb->vnc.findunused);
+ }
+ } else {
+ parse_top_level_vnc_options(config,
+ &b_info->u.hvm.vnc.enable,
+ &b_info->u.hvm.vnc.listen,
+ &b_info->u.hvm.vnc.passwd,
+ &b_info->u.hvm.vnc.display,
+ &b_info->u.hvm.vnc.findunused);
+ }
+
if (c_info->type == LIBXL_DOMAIN_TYPE_HVM) {
if (!xlu_cfg_get_string (config, "vga", &buf, 0)) {
if (!strcmp(buf, "stdvga")) {
@@ -1622,15 +1682,6 @@ skip_vfb:
b_info->u.hvm.vga.kind = l ? LIBXL_VGA_INTERFACE_TYPE_STD :
LIBXL_VGA_INTERFACE_TYPE_CIRRUS;
- 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;
- 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);
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);
--
1.7.10.4
next reply other threads:[~2013-12-16 17:39 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-16 17:39 Wei Liu [this message]
2013-12-16 17:46 ` [PATCH V3] xl: create VFB for PV guest when VNC is specified Ian Campbell
2013-12-17 11:28 ` Wei Liu
2013-12-17 11:36 ` Andrew Cooper
2013-12-17 11:40 ` Wei Liu
2013-12-17 11:41 ` Ian Campbell
2013-12-17 11:49 ` Wei Liu
2013-12-17 15:02 ` Ian Jackson
2013-12-17 15:16 ` Wei Liu
2013-12-17 16:15 ` Ian Jackson
2013-12-17 16:40 ` Ian Campbell
2013-12-17 16:52 ` Wei Liu
2013-12-17 18:04 ` Ian Jackson
2013-12-17 21:51 ` Wei Liu
2013-12-17 14:44 ` Ian Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1387215576-17455-1-git-send-email-wei.liu2@citrix.com \
--to=wei.liu2@citrix.com \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.