[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] xend deprecation



On Wed, 2013-09-04 at 10:04 -0400, Konrad Rzeszutek Wilk wrote:
> 
>  - No console in xl list -l, so can't get  tty console port. 

Together with the previous patch this can be resoled with the following,
I think. I'm not sure this is the best way to do it though, although
dominfo is mostly "runtime" info and this fits....

8<----------------------------

From 4cffdf9517c668a176f37fa58236f4eb2fd4bbb0 Mon Sep 17 00:00:00 2001
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Thu, 12 Sep 2013 14:41:06 +0100
Subject: [PATCH] libxl: expose the POV console tty in the dominfo.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
 tools/libxl/libxl.c         |   38 ++++++++++++++++++++++++++++----------
 tools/libxl/libxl_types.idl |    2 ++
 2 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 1bce4bb..8dea15f 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -510,9 +510,12 @@ int libxl_domain_preserve(libxl_ctx *ctx, uint32_t domid,
     return 0;
 }
 
-static void xcinfo2xlinfo(const xc_domaininfo_t *xcinfo,
+static void xcinfo2xlinfo(libxl__gc *gc,
+                          const xc_domaininfo_t *xcinfo,
                           libxl_dominfo *xlinfo)
 {
+    libxl_dominfo_init(xlinfo);
+
     memcpy(&(xlinfo->uuid), xcinfo->handle, sizeof(xen_domain_handle_t));
     xlinfo->domid = xcinfo->domain;
     xlinfo->ssidref = xcinfo->ssidref;
@@ -539,10 +542,17 @@ static void xcinfo2xlinfo(const xc_domaininfo_t *xcinfo,
     xlinfo->cpupool = xcinfo->cpupool;
     xlinfo->domain_type = (xcinfo->flags & XEN_DOMINF_hvm_guest) ?
         LIBXL_DOMAIN_TYPE_HVM : LIBXL_DOMAIN_TYPE_PV;
+
+    if (xcinfo->domaindomid && libxl_console_get_tty(CTX, xcinfo->domain, 0,
+                                                      LIBXL_CONSOLE_TYPE_PV,
+                                                      &xlinfo->console_tty) < 
0)
+        LOG(WARN, "unable to get dom%d pv console tty\n", xcinfo->domain);
+
 }
 
 libxl_dominfo * libxl_list_domain(libxl_ctx *ctx, int *nb_domain_out)
 {
+    GC_INIT(ctx);
     libxl_dominfo *ptr;
     int i, ret;
     xc_domaininfo_t info[1024];
@@ -551,38 +561,46 @@ libxl_dominfo * libxl_list_domain(libxl_ctx *ctx, int 
*nb_domain_out)
     ptr = calloc(size, sizeof(libxl_dominfo));
     if (!ptr) {
         LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "allocating domain info");
-        return NULL;
+        goto err;
     }
 
     ret = xc_domain_getinfolist(ctx->xch, 0, 1024, info);
     if (ret<0) {
         LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "geting domain info list");
         free(ptr);
-        return NULL;
+        ptr = NULL;
+        goto err;
     }
 
     for (i = 0; i < ret; i++) {
-        xcinfo2xlinfo(&info[i], &ptr[i]);
+        xcinfo2xlinfo(gc, &info[i], &ptr[i]);
     }
     *nb_domain_out = ret;
+err:
+    GC_FREE;
     return ptr;
 }
 
 int libxl_domain_info(libxl_ctx *ctx, libxl_dominfo *info_r,
-                      uint32_t domid) {
+                      uint32_t domid)
+{
+    GC_INIT(ctx);
     xc_domaininfo_t xcinfo;
-    int ret;
+    int ret, rc = ERROR_INVAL;
 
     ret = xc_domain_getinfolist(ctx->xch, domid, 1, &xcinfo);
     if (ret<0) {
         LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "geting domain info list");
         return ERROR_FAIL;
     }
-    if (ret==0 || xcinfo.domain != domid) return ERROR_INVAL;
+    if (ret==0 || xcinfo.domain != domid) goto err;;
 
     if (info_r)
-        xcinfo2xlinfo(&xcinfo, info_r);
-    return 0;
+        xcinfo2xlinfo(gc, &xcinfo, info_r);
+    rc = 0;
+err:
+    GC_FREE;
+    return rc;
 }
 
 static int cpupool_info(libxl__gc *gc,
@@ -3764,7 +3782,7 @@ retry_transaction:
         abort_transaction = 1;
         goto out;
     }
-    xcinfo2xlinfo(&info, &ptr);
+    xcinfo2xlinfo(gc, &info, &ptr);
     uuid = libxl__uuid2string(gc, ptr.uuid);
     libxl__xs_write(gc, t, libxl__sprintf(gc, "/vm/%s/memory", uuid),
             "%"PRIu32, new_target_memkb / 1024);
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 10f95f4..6de305b 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -200,6 +200,8 @@ libxl_dominfo = Struct("dominfo",[
     ("shutdown",    bool),
     ("dying",       bool),
 
+    ("console_tty", string),
+
     # Valid iff (shutdown||dying).
     #
     # Otherwise set to a value guaranteed not to clash with any valid
-- 
1.7.10.4




_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.