Skip to contentSkip to conversation

libxl: make libxl_vncviewer_exec work with stubdom

PATCH In review Wei Liu 2 participants 2 messages Oct 21, 2015 – Oct 22, 2015

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH 1/1 libxl: make libxl_vncviewer_exec work with stubdom

The xenstore path to look at when stubdom is in used is different. Libxl should look at stubdom path instead.

---
 tools/libxl/libxl.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
tools/libxl/libxl.c +13 -4
index 22bbc29..fb98043 100644
@@ -1921,6 +1921,7 @@ int libxl_vncviewer_exec(libxl_ctx *ctx, uint32_t domid, int autopass)
     GC_INIT(ctx);
     const char *vnc_port;
     const char *vnc_listen = NULL, *vnc_pass = NULL;
+    uint32_t stubdom_id, vnc_domid = domid;
     int port = 0, autopass_fd = -1;
     char *vnc_bin, *args[] = {
         "vncviewer",
@@ -1929,11 +1930,19 @@ int libxl_vncviewer_exec(libxl_ctx *ctx, uint32_t domid, int autopass)
         NULL,
     };
 
+    stubdom_id = libxl_get_stubdom_id(ctx, domid);
+    if (stubdom_id != 0)
+        vnc_domid = stubdom_id;
+
     vnc_port = libxl__xs_read(gc, XBT_NULL,
                             libxl__sprintf(gc,
-                            "/local/domain/%d/console/vnc-port", domid));
+                            "/local/domain/%d/console/vnc-port", vnc_domid));
     if (!vnc_port) {
-        LOG(ERROR, "Cannot get vnc-port of domain %d", domid);
+        if (stubdom_id != 0)
+            LOG(ERROR, "Cannot get vnc-port of domain %d (stubdom %d)",
+                domid, stubdom_id);
+        else
+            LOG(ERROR, "Cannot get vnc-port of domain %d", domid);
         goto x_fail;
     }
 
@@ -1941,12 +1950,12 @@ int libxl_vncviewer_exec(libxl_ctx *ctx, uint32_t domid, int autopass)
 
     vnc_listen = libxl__xs_read(gc, XBT_NULL,
                                 libxl__sprintf(gc,
-                            "/local/domain/%d/console/vnc-listen", domid));
+                            "/local/domain/%d/console/vnc-listen", vnc_domid));
 
     if ( autopass )
         vnc_pass = libxl__xs_read(gc, XBT_NULL,
                                   libxl__sprintf(gc,
-                            "/local/domain/%d/console/vnc-pass", domid));
+                            "/local/domain/%d/console/vnc-pass", vnc_domid));
 
     if ( NULL == vnc_listen )
         vnc_listen = "localhost";
Signature · 1 line
2.1.4
#1 lore raw
Quoted 2 lines · Wei Liu

The xenstore path to look at when stubdom is in used is different. Libxl should look at stubdom path instead.

It took me a while to work this out, so please mention that the VNC in question is the backend corresponding to the stubdom's PVFB (into which it writes the emulated VGA content) and that the port for that is written into the PVFB frontend dir, i.e. on the stubdom path.

Or alternatively since semantically this is the guest's console (albiet laundered through a stubdom) perhaps we should be writing these vnc-* keys there instead/as well?

Either way these vnc-* keys need to be documented in docs/misc/xenstore -paths.markdown, either directly or by a reference to pvfb.h (which would then need to talk about them), so we know what they mean and where they should live (which in turn may render at least half what I said above moot).

Ian.