Skip to contentSkip to conversation

xl: create VFB for PV guest when VNC is specified

PATCH In review Wei Liu 5 participants 12 messages Dec 13, 2013 – Dec 16, 2013

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH 1/1 xl: create VFB for PV guest when VNC is specified

This replicate 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

Cc Ian Campbell <[email protected]>
Cc Ian Jackson <[email protected]>
Cc Konrad Wilk <[email protected]>
---
 tools/libxl/xl_cmdimpl.c |   42 ++++++++++++++++++++++++++++++++++++++----
 1 file changed, 38 insertions(+), 4 deletions(-)
tools/libxl/xl_cmdimpl.c +38 -4
index bd26bcc..06c516c 100644
@@ -1357,11 +1357,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;
@@ -1608,6 +1609,39 @@ skip_vfb:
 
 #undef parse_extra_args
 
+    if (c_info->type == LIBXL_DOMAIN_TYPE_PV) {
+        libxl_defbool vnc_enabled;
+
+        xlu_cfg_get_defbool(config, "vnc", &vnc_enabled, 0);
+
+        if (libxl_defbool_val(vnc_enabled)) {
+            libxl_device_vfb *vfb;
+            libxl_device_vkb *vkb;
+
+            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;
+            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;
+            libxl_device_vkb_init(vkb);
+            vkb->devid = d_config->num_vkbs;
+
+            libxl_defbool_set(&vfb->vnc.enable, true);
+            xlu_cfg_replace_string(config, "vnclisten", &vfb->vnc.listen, 0);
+            xlu_cfg_replace_string(config, "vncpasswd", &vfb->vnc.passwd, 0);
+            if (!xlu_cfg_get_long (config, "vncdisplay", &l, 0))
+                vfb->vnc.display = l;
+            xlu_cfg_get_defbool(config, "vncunused", &vfb->vnc.findunused, 0);
+
+            d_config->num_vfbs++;
+            d_config->num_vkbs++;
+        }
+    }
+
     if (c_info->type == LIBXL_DOMAIN_TYPE_HVM) {
         if (!xlu_cfg_get_string (config, "vga", &buf, 0)) {
             if (!strcmp(buf, "stdvga")) {
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 8 lines · Wei Liu

This replicate 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.

Quoted 7 lines

Fixes bug #25.
http://bugs.xenproject.org/xen/bug/25

Cc Ian Campbell <[email protected]>
Cc Ian Jackson <[email protected]>
Cc Konrad Wilk <[email protected]>
Reported-by .. my name.

Hadn't tested it yet - I can do it on Tuesday if you are OK with it.

Quoted 68 lines
---
 tools/libxl/xl_cmdimpl.c |   42 ++++++++++++++++++++++++++++++++++++++----
 1 file changed, 38 insertions(+), 4 deletions(-)
tools/libxl/xl_cmdimpl.c +38 -4
index bd26bcc..06c516c 100644
@@ -1357,11 +1357,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;
@@ -1608,6 +1609,39 @@ skip_vfb:
 
 #undef parse_extra_args
 
+    if (c_info->type == LIBXL_DOMAIN_TYPE_PV) {
+        libxl_defbool vnc_enabled;
+
+        xlu_cfg_get_defbool(config, "vnc", &vnc_enabled, 0);
+
+        if (libxl_defbool_val(vnc_enabled)) {
+            libxl_device_vfb *vfb;
+            libxl_device_vkb *vkb;
+
+            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;
+            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;
+            libxl_device_vkb_init(vkb);
+            vkb->devid = d_config->num_vkbs;
+
+            libxl_defbool_set(&vfb->vnc.enable, true);
+            xlu_cfg_replace_string(config, "vnclisten", &vfb->vnc.listen, 0);
+            xlu_cfg_replace_string(config, "vncpasswd", &vfb->vnc.passwd, 0);
+            if (!xlu_cfg_get_long (config, "vncdisplay", &l, 0))
+                vfb->vnc.display = l;
+            xlu_cfg_get_defbool(config, "vncunused", &vfb->vnc.findunused, 0);
+
+            d_config->num_vfbs++;
+            d_config->num_vkbs++;
+        }
+    }
+
     if (c_info->type == LIBXL_DOMAIN_TYPE_HVM) {
         if (!xlu_cfg_get_string (config, "vga", &buf, 0)) {
             if (!strcmp(buf, "stdvga")) {
Signature · 1 line
1.7.10.4
#2 lore raw
Quoted 12 lines · Konrad Rzeszutek Wilk
Quoted 11 lines · Wei Liu

This replicate 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

Quoted 8 lines
Quoted 4 lines
Cc Ian Campbell <[email protected]>
Cc Ian Jackson <[email protected]>
Cc Konrad Wilk <[email protected]>
Reported-by .. my name.

Hadn't tested it yet - I can do it on Tuesday if you are OK with it.

Yes, I'm fine with it. Take your time.

Wei.

#3 lore raw
In reply to Wei Liu

Wei Liu writes ("[PATCH] xl: create VFB for PV guest when VNC is specified"):

Quoted 1 line

This replicate a Xend behavior, when you specify:

Thanks. I think the principle is sound. I have some quibbles.

tools/libxl/xl_cmdimpl.c skip_vfb: · line 1615

Quoted 4 lines
tools/libxl/xl_cmdimpl.c +4 -0
+    if (c_info->type == LIBXL_DOMAIN_TYPE_PV) {
+        libxl_defbool vnc_enabled;
+
+        xlu_cfg_get_defbool(config, "vnc", &vnc_enabled, 0);

Missing error check.

tools/libxl/xl_cmdimpl.c skip_vfb: · line 1622

Quoted 6 lines
tools/libxl/xl_cmdimpl.c +6 -0
+        if (libxl_defbool_val(vnc_enabled)) {
+            libxl_device_vfb *vfb;
+            libxl_device_vkb *vkb;
+
+            d_config->vfbs = (libxl_device_vfb *)
+                realloc(d_config->vfbs, sizeof(libxl_device_vfb) * (d_config->num_vfbs + 1));

This should be xrealloc, and wrapped to 80 columns. But see below.

tools/libxl/xl_cmdimpl.c skip_vfb: · line 1633

Quoted 11 lines
tools/libxl/xl_cmdimpl.c +11 -0
+            vfb = d_config->vfbs + d_config->num_vfbs;
+            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;
+            libxl_device_vkb_init(vkb);
+            vkb->devid = d_config->num_vkbs;
+
+            libxl_defbool_set(&vfb->vnc.enable, true);

There's a lot of this kind of boilerplate. I'm tempted to suggest making a macro to do this. Searching for "devid =" found 4 call sites if that line is included in the macro; searching for "realloc" found me 6 call sites if it isn't. And that's before your two additional ones. Ian C, what do you think ?

tools/libxl/xl_cmdimpl.c skip_vfb: · line 1638

Quoted 5 lines
tools/libxl/xl_cmdimpl.c +5 -0
+            xlu_cfg_replace_string(config, "vnclisten", &vfb->vnc.listen, 0);
+            xlu_cfg_replace_string(config, "vncpasswd", &vfb->vnc.passwd, 0);
+            if (!xlu_cfg_get_long (config, "vncdisplay", &l, 0))
+                vfb->vnc.display = l;
+            xlu_cfg_get_defbool(config, "vncunused", &vfb->vnc.findunused, 0);

This duplicates the HVM VNC option parsing. It should be factored out into a subroutine.

tools/libxl/xl_cmdimpl.c skip_vfb: · line 1643

Quoted 5 lines
tools/libxl/xl_cmdimpl.c +5 -0
+
+            d_config->num_vfbs++;
+            d_config->num_vkbs++;
+        }
+    }

Thanks,
Ian.

#4 lore raw
Quoted 13 lines · Ian Jackson

Wei Liu writes ("[PATCH] xl: create VFB for PV guest when VNC is specified"):

Quoted 1 line

This replicate a Xend behavior, when you specify:

Thanks. I think the principle is sound. I have some quibbles.

tools/libxl/xl_cmdimpl.c skip_vfb: · line 1615

Quoted 4 lines
tools/libxl/xl_cmdimpl.c +4 -0
+    if (c_info->type == LIBXL_DOMAIN_TYPE_PV) {
+        libxl_defbool vnc_enabled;
+
+        xlu_cfg_get_defbool(config, "vnc", &vnc_enabled, 0);

Missing error check.

Quoted 1 line

+ if (libxl_defbool_val(vnc_enabled)) {

The result of xlu_cfg_get_defbool can be neither true nor false, it can be "the default", which will cause this function to fail (abort even?).

I think you want xlu_cfg_get_long here and to use the normal boolean logic.

Quoted 7 lines

tools/libxl/xl_cmdimpl.c skip_vfb: · line 1622

Quoted 5 lines
tools/libxl/xl_cmdimpl.c +5 -0
+            libxl_device_vfb *vfb;
+            libxl_device_vkb *vkb;
+
+            d_config->vfbs = (libxl_device_vfb *)
+                realloc(d_config->vfbs, sizeof(libxl_device_vfb) * (d_config->num_vfbs + 1));

This should be xrealloc, and wrapped to 80 columns. But see below.

This also suggests that we might be trying to support both the "toplevel" vnc options and the "vfb = []" style at the same time.

IMHO the vfb option should take precedence -- i.e. we should ignore the toplevel options if it is present.

The alternative would be some sort of union of the toplevel options and the first vfb given, but that sounds a bit mad...

I suppose there is also the question of what xend did here.

Quoted 9 lines
Quoted 9 lines
tools/libxl/xl_cmdimpl.c +9 -0
+            vfb = d_config->vfbs + d_config->num_vfbs;
+            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;
+            libxl_device_vkb_init(vkb);
+            vkb->devid = d_config->num_vkbs;
Quoted 8 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+            libxl_defbool_set(&vfb->vnc.enable, true);

There's a lot of this kind of boilerplate. I'm tempted to suggest making a macro to do this. Searching for "devid =" found 4 call sites if that line is included in the macro; searching for "realloc" found me 6 call sites if it isn't. And that's before your two additional ones. Ian C, what do you think ?

Some helpers for dealing with allocating and resizing/appending to libxl Array types might be a useful addition to the library itself, i.e. idl generated? Otherwise an xl macro might indeed be handy.

I'm not sure what the 4 vs. 6 "if that line is/isn't included in" is referring too though.

Quoted 8 lines

tools/libxl/xl_cmdimpl.c skip_vfb: · line 1638

Quoted 5 lines
tools/libxl/xl_cmdimpl.c +5 -0
+            xlu_cfg_replace_string(config, "vnclisten", &vfb->vnc.listen, 0);
+            xlu_cfg_replace_string(config, "vncpasswd", &vfb->vnc.passwd, 0);
+            if (!xlu_cfg_get_long (config, "vncdisplay", &l, 0))
+                vfb->vnc.display = l;
+            xlu_cfg_get_defbool(config, "vncunused", &vfb->vnc.findunused, 0);

This duplicates the HVM VNC option parsing. It should be factored out into a subroutine.

Ack.

That makes me wonder if the top level options shouldn't be populating &b_info->u.pv.vnc.* (and if that shouldn't have been a non-keyed field) while vfb = fills in d_config->vfbs. That is a bigger change on the libxl side though and maybe doesn't make quite as much sense as with the .

Quoted 10 lines

tools/libxl/xl_cmdimpl.c skip_vfb: · line 1643

Quoted 6 lines
tools/libxl/xl_cmdimpl.c +5 -0
+
+            d_config->num_vfbs++;
+            d_config->num_vkbs++;
+        }
+    }

Thanks,
Ian.

author
#8 lore raw
In reply to Ian Jackson
Quoted 12 lines · Ian Jackson

Wei Liu writes ("[PATCH] xl: create VFB for PV guest when VNC is specified"):

Quoted 1 line

This replicate a Xend behavior, when you specify:

Thanks. I think the principle is sound. I have some quibbles.

tools/libxl/xl_cmdimpl.c skip_vfb: · line 1615

Quoted 4 lines
tools/libxl/xl_cmdimpl.c +4 -0
+    if (c_info->type == LIBXL_DOMAIN_TYPE_PV) {
+        libxl_defbool vnc_enabled;
+
+        xlu_cfg_get_defbool(config, "vnc", &vnc_enabled, 0);

Missing error check.

No call site ever error-checks this. Probably a separate patch to add error check to all of them?

Quoted 9 lines

tools/libxl/xl_cmdimpl.c skip_vfb: · line 1622

Quoted 6 lines
tools/libxl/xl_cmdimpl.c +6 -0
+        if (libxl_defbool_val(vnc_enabled)) {
+            libxl_device_vfb *vfb;
+            libxl_device_vkb *vkb;
+
+            d_config->vfbs = (libxl_device_vfb *)
+                realloc(d_config->vfbs, sizeof(libxl_device_vfb) * (d_config->num_vfbs + 1));

This should be xrealloc, and wrapped to 80 columns. But see below.

Ack.

Quoted 9 lines
Quoted 9 lines
tools/libxl/xl_cmdimpl.c +9 -0
+            vfb = d_config->vfbs + d_config->num_vfbs;
+            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;
+            libxl_device_vkb_init(vkb);
+            vkb->devid = d_config->num_vkbs;
Quoted 9 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+            libxl_defbool_set(&vfb->vnc.enable, true);

There's a lot of this kind of boilerplate. I'm tempted to suggest making a macro to do this. Searching for "devid =" found 4 call sites if that line is included in the macro; searching for "realloc" found me 6 call sites if it isn't. And that's before your two additional ones. Ian C, what do you think ?

I'm fine with either way. It's maintainers' call now. :-)

Quoted 9 lines

tools/libxl/xl_cmdimpl.c skip_vfb: · line 1638

Quoted 5 lines
tools/libxl/xl_cmdimpl.c +5 -0
+            xlu_cfg_replace_string(config, "vnclisten", &vfb->vnc.listen, 0);
+            xlu_cfg_replace_string(config, "vncpasswd", &vfb->vnc.passwd, 0);
+            if (!xlu_cfg_get_long (config, "vncdisplay", &l, 0))
+                vfb->vnc.display = l;
+            xlu_cfg_get_defbool(config, "vncunused", &vfb->vnc.findunused, 0);

This duplicates the HVM VNC option parsing. It should be factored out into a subroutine.

Ack.

Wei.

Quoted 8 lines

tools/libxl/xl_cmdimpl.c skip_vfb: · line 1643

Quoted 5 lines
tools/libxl/xl_cmdimpl.c +5 -0
+
+            d_config->num_vfbs++;
+            d_config->num_vkbs++;
+        }
+    }

Thanks,
Ian.

#5 lore raw
In reply to Ian Campbell

Ian Campbell writes ("Re: [PATCH] xl: create VFB for PV guest when VNC is specified"):

Quoted 8 lines · Ian Jackson
Quoted 1 line

This should be xrealloc, and wrapped to 80 columns. But see below.

This also suggests that we might be trying to support both the "toplevel" vnc options and the "vfb = []" style at the same time.

IMHO the vfb option should take precedence -- i.e. we should ignore the toplevel options if it is present.

Oh, yes. Good point.

Quoted 4 lines

The alternative would be some sort of union of the toplevel options and the first vfb given, but that sounds a bit mad...

I suppose there is also the question of what xend did here.

Perhaps Konrad can let us know...

Quoted 6 lines
Quoted 5 lines

There's a lot of this kind of boilerplate. I'm tempted to suggest making a macro to do this. Searching for "devid =" found 4 call sites if that line is included in the macro; searching for "realloc" found me 6 call sites if it isn't. And that's before your two additional ones. Ian C, what do you think ?

Quoted 6 lines

Some helpers for dealing with allocating and resizing/appending to libxl Array types might be a useful addition to the library itself, i.e. idl generated? Otherwise an xl macro might indeed be handy.

I'm not sure what the 4 vs. 6 "if that line is/isn't included in" is referring too though.

There are four instances of this kind of boilerplate which contain

            SPONGE->devid = d_config->num_SPONGEs;

and six that lack it.

Quoted 10 lines
Quoted 2 lines

This duplicates the HVM VNC option parsing. It should be factored out into a subroutine.

Ack.

That makes me wonder if the top level options shouldn't be populating &b_info->u.pv.vnc.* (and if that shouldn't have been a non-keyed field) while vfb = fills in d_config->vfbs. That is a bigger change on the libxl side though and maybe doesn't make quite as much sense as with the .

As with the "." ?

Ian.

#9 lore raw
In reply to Wei Liu

Wei Liu writes ("Re: [PATCH] xl: create VFB for PV guest when VNC is specified"):

Quoted 5 lines · Ian Jackson
Quoted 1 line

Missing error check.

No call site ever error-checks this. Probably a separate patch to add error check to all of them?

Maybe we should do something different. E.g., make all these functions return void and stash the fact that there was an error away somewhere, and provide and call a new "was the5re an error" function.

That way if you write multiple errors in the file you get them reported all at once.

Ian.

author
#10 lore raw
Quoted 7 lines · Ian Jackson

Wei Liu writes ("Re: [PATCH] xl: create VFB for PV guest when VNC is specified"):

Quoted 5 lines · Ian Jackson
Quoted 1 line

Missing error check.

No call site ever error-checks this. Probably a separate patch to add error check to all of them?

Quoted 7 lines

Maybe we should do something different. E.g., make all these functions return void and stash the fact that there was an error away somewhere, and provide and call a new "was the5re an error" function.

That way if you write multiple errors in the file you get them reported all at once.

IMHO this doesn't sound like 4.4 material, too big a patch for a bug fix...

Wei.

Quoted 1 line

Ian.

#11 lore raw

Wei Liu writes ("Re: [PATCH] xl: create VFB for PV guest when VNC is specified"):

Quoted 2 lines

IMHO this doesn't sound like 4.4 material, too big a patch for a bug fix...

Yes. So, err, carry on and don't care about the errors :-/

Ian.

#6 lore raw
In reply to Ian Jackson
Quoted 29 lines · Ian Jackson

Ian Campbell writes ("Re: [PATCH] xl: create VFB for PV guest when VNC is specified"):

Quoted 8 lines · Ian Jackson
Quoted 1 line

This should be xrealloc, and wrapped to 80 columns. But see below.

This also suggests that we might be trying to support both the "toplevel" vnc options and the "vfb = []" style at the same time.

IMHO the vfb option should take precedence -- i.e. we should ignore the toplevel options if it is present.

Oh, yes. Good point.

Quoted 4 lines

The alternative would be some sort of union of the toplevel options and the first vfb given, but that sounds a bit mad...

I suppose there is also the question of what xend did here.

Perhaps Konrad can let us know...

Quoted 10 lines
Quoted 5 lines

There's a lot of this kind of boilerplate. I'm tempted to suggest making a macro to do this. Searching for "devid =" found 4 call sites if that line is included in the macro; searching for "realloc" found me 6 call sites if it isn't. And that's before your two additional ones. Ian C, what do you think ?

Some helpers for dealing with allocating and resizing/appending to libxl Array types might be a useful addition to the library itself, i.e. idl generated? Otherwise an xl macro might indeed be handy.

Quoted 6 lines
Quoted 2 lines

I'm not sure what the 4 vs. 6 "if that line is/isn't included in" is referring too though.

There are four instances of this kind of boilerplate which contain

            SPONGE->devid = d_config->num_SPONGEs;

and six that lack it.

Oh right, yes.

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

This duplicates the HVM VNC option parsing. It should be factored out into a subroutine.

Ack.

Quoted 7 lines
Quoted 5 lines

That makes me wonder if the top level options shouldn't be populating &b_info->u.pv.vnc.* (and if that shouldn't have been a non-keyed field) while vfb = fills in d_config->vfbs. That is a bigger change on the libxl side though and maybe doesn't make quite as much sense as with the .

As with the "." ?

Erm... I think I was about to say something which was nonsense and only partially aborted...

What I *should* have said is that HVM has an emulated VGA card which is what &b_info->u.hvm.vnc is configuring and which is separate to any PVFB given to the guest. So it doesn't make sense to have b_info->u.pv.vnc because there is no VGA.

(Incidentally, I expect even xend only meant for the toplevel vnc options to configure the VGA and the leakage into PV guest's pvfb[0] is just an unfortunate art we need to deal with)

Ian.

author
#7 lore raw
In reply to Ian Campbell
Quoted 1 line · Ian Campbell

On Mon, 2013-12-16 at 12:17 +0000, Ian Jackson wrote:

[...]

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
tools/libxl/xl_cmdimpl.c +5 -0
+            libxl_device_vfb *vfb;
+            libxl_device_vkb *vkb;
+
+            d_config->vfbs = (libxl_device_vfb *)
+                realloc(d_config->vfbs, sizeof(libxl_device_vfb) * (d_config->num_vfbs + 1));
Quoted 5 lines
Quoted 1 line

This should be xrealloc, and wrapped to 80 columns. But see below.

This also suggests that we might be trying to support both the "toplevel" vnc options and the "vfb = []" style at the same time.

Yes this is done on purpose as I don't know the complete set of possible user config files. Probably Konrad can let us know what he expects.

Quoted 8 lines

IMHO the vfb option should take precedence -- i.e. we should ignore the toplevel options if it is present.

The alternative would be some sort of union of the toplevel options and the first vfb given, but that sounds a bit mad...

I suppose there is also the question of what xend did here.

I did look at Xend code, if there's top VNC option present it creates a VFB. That's why I said "replicates" a Xend behavior in commit message. I didn't go further than that though so I don't know one take precedence over the other.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
tools/libxl/xl_cmdimpl.c +4 -0
+            vfb = d_config->vfbs + d_config->num_vfbs;
+            libxl_device_vfb_init(vfb);
+            vfb->devid = d_config->num_vfbs;
+

[...]

Quoted 7 lines
Quoted 6 lines

tools/libxl/xl_cmdimpl.c skip_vfb: · line 1638

Quoted 3 lines
tools/libxl/xl_cmdimpl.c +3 -0
+            if (!xlu_cfg_get_long (config, "vncdisplay", &l, 0))
+                vfb->vnc.display = l;
+            xlu_cfg_get_defbool(config, "vncunused", &vfb->vnc.findunused, 0);

This duplicates the HVM VNC option parsing. It should be factored out into a subroutine.

Quoted 8 lines

Ack.

That makes me wonder if the top level options shouldn't be populating &b_info->u.pv.vnc.* (and if that shouldn't have been a non-keyed field) while vfb = fills in d_config->vfbs. That is a bigger change on the libxl side though and maybe doesn't make quite as much sense as with the .

with the what?

Wei.

Quoted 11 lines
Quoted 10 lines

tools/libxl/xl_cmdimpl.c skip_vfb: · line 1643

Quoted 6 lines
tools/libxl/xl_cmdimpl.c +5 -0
+
+            d_config->num_vfbs++;
+            d_config->num_vkbs++;
+        }
+    }

Thanks,
Ian.