WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] libxl: remove API for dominfolist and lis

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] libxl: remove API for dominfolist and list that returns xc_dominfo.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 30 Dec 2009 05:40:18 -0800
Delivery-date: Wed, 30 Dec 2009 05:43:05 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1262177113 0
# Node ID d4613b5217982fa82710adc96a9f1d8b4c0a491e
# Parent  49d0c3ff79433f687a2faffd950317d9f91a1c39
libxl: remove API for dominfolist and list that returns xc_dominfo.

fixup xl and part of libxl that use those API, to use simpler, faster
and less wasteful API (doesn't need to get the info about all domains
when looking for one specific domain).

Signed-off-by: Vincent Hanquez <vincent.hanquez@xxxxxxxxxxxxx>
---
 tools/libxl/libxl.c     |   65 ++++++------------------------------------------
 tools/libxl/libxl.h     |    4 --
 tools/libxl/libxl_dom.c |   22 +++++++---------
 tools/libxl/xl.c        |   23 ++++++----------
 4 files changed, 29 insertions(+), 85 deletions(-)

diff -r 49d0c3ff7943 -r d4613b521798 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Wed Dec 30 12:44:37 2009 +0000
+++ b/tools/libxl/libxl.c       Wed Dec 30 12:45:13 2009 +0000
@@ -321,49 +321,6 @@ redo:
     return ptr;
 }
 
-xc_dominfo_t * libxl_domain_infolist(struct libxl_ctx *ctx, int *nb_domain)
-{
-    int index, first_domain;
-    xc_dominfo_t *info;
-    int size = 1024;
-
-    first_domain = 0;
-    index = 0;
-    info = (xc_dominfo_t *) calloc(size, sizeof(xc_dominfo_t));
-    if (!info) {
-        *nb_domain = 0;
-        return NULL;
-    }
-    *nb_domain = xc_domain_getinfo(ctx->xch, first_domain, 1024, info);
-    return info;
-}
-
-xc_dominfo_t *libxl_domain_info(struct libxl_ctx *ctx, uint32_t domid)
-{
-    xc_dominfo_t *info;
-    int rc;
-
-    info = (xc_dominfo_t *) calloc(1, sizeof(xc_dominfo_t));
-    if (!info) {
-        return NULL;
-    }
-    rc = xc_domain_getinfo(ctx->xch, domid, 1, info);
-    if (rc != 1) {
-        free(info);
-        XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "Failed to get info for domain %u", 
-                        domid);
-        return NULL;
-    }
-    if (info->domid != domid) {
-        free(info);
-        XL_LOG(ctx, XL_LOG_ERROR, "Failed to get info for domain %u"
-                        ", seems to not exist anymore", domid);
-        return NULL;
-    }
-
-    return info;
-}
-
 int libxl_domain_suspend(struct libxl_ctx *ctx, libxl_domain_suspend_info 
*info,
                          uint32_t domid, int fd)
 {
@@ -503,28 +460,24 @@ int libxl_free_waiter(libxl_waiter *wait
     return 0;
 }
 
-int libxl_event_get_domain_death_info(struct libxl_ctx *ctx, uint32_t domid, 
libxl_event *event, xc_dominfo_t *info)
-{
-    int nb_domain, i, rc = 0;
-    xc_dominfo_t *list = NULL;
+int libxl_event_get_domain_death_info(struct libxl_ctx *ctx, uint32_t domid, 
libxl_event *event, xc_domaininfo_t *info)
+{
+    int rc = 0, ret;
 
     if (event && event->type == DOMAIN_DEATH) {
-        list = libxl_domain_infolist(ctx, &nb_domain);
-        for (i = 0; i < nb_domain; i++) {
-            if (domid == list[i].domid) {
-                if (list[i].running || (!list[i].shutdown && !list[i].crashed 
&& !list[i].dying))
+        ret = xc_domain_getinfolist(ctx->xch, domid, 1, info);
+        if (ret == 1 && info->domain == domid) {
+                if (info->flags & XEN_DOMINF_running ||
+                    (!(info->flags & XEN_DOMINF_shutdown) && !(info->flags & 
XEN_DOMINF_dying)))
                     goto out;
-                *info = list[i];
                 rc = 1;
                 goto out;
-            }
-        }
-        memset(info, 0x00, sizeof(xc_dominfo_t));
+        }
+        memset(info, 0, sizeof(xc_dominfo_t));
         rc = 1;
         goto out;
     }
 out:
-    free(list);
     return rc;
 }
 
diff -r 49d0c3ff7943 -r d4613b521798 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Wed Dec 30 12:44:37 2009 +0000
+++ b/tools/libxl/libxl.h       Wed Dec 30 12:45:13 2009 +0000
@@ -279,7 +279,7 @@ int libxl_free_event(libxl_event *event)
 int libxl_free_event(libxl_event *event);
 int libxl_free_waiter(libxl_waiter *waiter);
 
-int libxl_event_get_domain_death_info(struct libxl_ctx *ctx, uint32_t domid, 
libxl_event *event, xc_dominfo_t *info);
+int libxl_event_get_domain_death_info(struct libxl_ctx *ctx, uint32_t domid, 
libxl_event *event, xc_domaininfo_t *info);
 int libxl_event_get_disk_eject_info(struct libxl_ctx *ctx, uint32_t domid, 
libxl_event *event, libxl_device_disk *disk);
 
 
@@ -291,8 +291,6 @@ int libxl_console_attach(struct libxl_ct
 int libxl_console_attach(struct libxl_ctx *ctx, uint32_t domid, int cons_num);
 
 struct libxl_dominfo * libxl_domain_list(struct libxl_ctx *ctx, int 
*nb_domain);
-xc_dominfo_t * libxl_domain_infolist(struct libxl_ctx *ctx, int *nb_domain);
-xc_dominfo_t * libxl_domain_info(struct libxl_ctx *ctx, uint32_t domid);
 
 typedef struct libxl_device_model_starting libxl_device_model_starting;
 int libxl_create_device_model(struct libxl_ctx *ctx,
diff -r 49d0c3ff7943 -r d4613b521798 tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c   Wed Dec 30 12:44:37 2009 +0000
+++ b/tools/libxl/libxl_dom.c   Wed Dec 30 12:45:13 2009 +0000
@@ -245,19 +245,17 @@ static int core_suspend_callback(void *d
     }
     XL_LOG(si->ctx, XL_LOG_DEBUG, "wait for the guest to suspend");
     while (!strcmp(state, "suspend") && watchdog > 0) {
-        int nb_domain, i;
-        xc_dominfo_t *list = NULL;
+        xc_domaininfo_t info;
+
         usleep(100000);
-        list = libxl_domain_infolist(si->ctx, &nb_domain);
-        for (i = 0; i < nb_domain; i++) {
-            if (si->domid == list[i].domid) {
-                if (list[i].shutdown != 0 && list[i].shutdown_reason == 
SHUTDOWN_suspend) {
-                    free(list);
-                    return 1;
-                }
-            }
-        }
-        free(list);
+        ret = xc_domain_getinfolist(si->ctx->xch, si->domid, 1, &info);
+        if (ret == 1 && info.domain == si->domid && info.flags & 
XEN_DOMINF_shutdown) {
+            int shutdown_reason;
+
+            shutdown_reason = (info.flags >> XEN_DOMINF_shutdownshift) & 
XEN_DOMINF_shutdownmask;
+            if (shutdown_reason == SHUTDOWN_suspend)
+                return 1;
+        }
         state = libxl_xs_read(si->ctx, XBT_NULL, path);
         watchdog--;
     }
diff -r 49d0c3ff7943 -r d4613b521798 tools/libxl/xl.c
--- a/tools/libxl/xl.c  Wed Dec 30 12:44:37 2009 +0000
+++ b/tools/libxl/xl.c  Wed Dec 30 12:45:13 2009 +0000
@@ -808,7 +808,7 @@ start:
     while (1) {
         int ret;
         fd_set rfds;
-        xc_dominfo_t info;
+        xc_domaininfo_t info;
         libxl_event event;
         libxl_device_disk disk;
         memset(&info, 0x00, sizeof(xc_dominfo_t));
@@ -824,10 +824,11 @@ start:
             case DOMAIN_DEATH:
                 if (libxl_event_get_domain_death_info(&ctx, domid, &event, 
&info)) {
                     LOG("Domain %d is dead", domid);
-                    if (info.crashed || info.dying || (info.shutdown && 
(info.shutdown_reason != SHUTDOWN_suspend))) {
+                    if (info.flags & XEN_DOMINF_dying || (info.flags & 
XEN_DOMINF_shutdown && (((info.flags >> XEN_DOMINF_shutdownshift) & 
XEN_DOMINF_shutdownmask) != SHUTDOWN_suspend))) {
                         LOG("Domain %d needs to be clean: destroying the 
domain", domid);
                         libxl_domain_destroy(&ctx, domid, 0);
-                        if (info.shutdown && (info.shutdown_reason == 
SHUTDOWN_reboot)) {
+                        if (info.flags & XEN_DOMINF_shutdown &&
+                            (((info.flags >> XEN_DOMINF_shutdownshift) & 
XEN_DOMINF_shutdownmask) == SHUTDOWN_reboot)) {
                             libxl_free_waiter(w1);
                             libxl_free_waiter(w2);
                             free(w1);
@@ -1320,32 +1321,26 @@ void list_domains(void)
 void list_domains(void)
 {
     struct libxl_ctx ctx;
-    xc_dominfo_t *info;
+    struct libxl_dominfo *info;
     int nb_domain, i;
 
     libxl_ctx_init(&ctx);
     libxl_ctx_set_log(&ctx, log_callback, NULL);
 
-    info = libxl_domain_infolist(&ctx, &nb_domain);
+    info = libxl_domain_list(&ctx, &nb_domain);
 
     if (info < 0) {
         fprintf(stderr, "libxl_domain_infolist failed.\n");
         exit(1);
     }
-    printf("Name                                        ID   Mem 
VCPUs\tState\tTime(s)\n");
+    printf("Name                                        ID   \tState\n");
     for (i = 0; i < nb_domain; i++) {
-        printf("%-40s %5d %5lu %5d     %c%c%c%c%c%c %8.1f\n",
+        printf("%-40s %5d     %c%c%c\n",
                 libxl_domid_to_name(&ctx, info[i].domid),
                 info[i].domid,
-                info[i].nr_pages * XC_PAGE_SIZE/(1024*1024),
-                info[i].nr_online_vcpus,
                 info[i].running ? 'r' : '-',
-                info[i].blocked ? 'b' : '-',
                 info[i].paused ? 'p' : '-',
-                info[i].shutdown ? 's' : '-',
-                info[i].crashed ? 'c' : '-',
-                info[i].dying ? 'd' : '-',
-                ((float)info[i].cpu_time / 1e9));
+                info[i].dying ? 'd' : '-');
     }
     free(info);
 }

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] libxl: remove API for dominfolist and list that returns xc_dominfo., Xen patchbot-unstable <=