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

Re: [Xen-devel] [PATCH] xl cpupool-list: add option to list domains


  • To: Juergen Gross <juergen.gross@xxxxxxxxxxxxxx>
  • From: Juergen Gross <juergen.gross@xxxxxxxxxxxxxx>
  • Date: Tue, 04 Mar 2014 13:19:32 +0100
  • Cc: Ian.Jackson@xxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxx
  • Delivery-date: Tue, 04 Mar 2014 12:19:42 +0000
  • Domainkey-signature: s=s1536a; d=ts.fujitsu.com; c=nofws; q=dns; h=X-SBRSScore:X-IronPort-AV:Received:X-IronPort-AV: Received:Message-ID:Date:From:Organization:User-Agent: MIME-Version:To:CC:Subject:References:In-Reply-To: Content-Type:Content-Transfer-Encoding; b=e0oJX1Ocy3iYPJ5a8e6m942B+Zn2bENm0VVReLBpBEFDo6S+fKgLIIL0 OYazbvbf4yhrSNFSZxrga1D8bKklCoWKD9o0oBXhrkKL2kGZ3tZSevWwS QvqfrojK3z5Sr3b+ROmBI+LD6p9au5mM5wuPBG3GMwTMICwLefUfqyzpC eCwXEEaiZUxKI5K73S7qzU6XESNL7T7jUfFZ90PTBEgHB9HlolNazZr1z 0LpDB6v2W/IGyd+xgn6w104g2cfTp;
  • List-id: Xen developer discussion <xen-devel.lists.xen.org>

Ping?

On 18.02.2014 08:38, Juergen Gross wrote:
It is rather complicated to obtain the cpupool a domain lives in. Add an
option -d (or --domains) to list all domains running in a cpupool.

Signed-off-by: Juergen Gross <juergen.gross@xxxxxxxxxxxxxx>
---
  docs/man/xl.pod.1         |    5 ++++-
  tools/libxl/xl_cmdimpl.c  |   47 ++++++++++++++++++++++++++++++++++++++-------
  tools/libxl/xl_cmdtable.c |    5 +++--
  3 files changed, 47 insertions(+), 10 deletions(-)

diff --git a/docs/man/xl.pod.1 b/docs/man/xl.pod.1
index e7b9de2..547af6d 100644
--- a/docs/man/xl.pod.1
+++ b/docs/man/xl.pod.1
@@ -1019,10 +1019,13 @@ Use the given configuration file.

  =back

-=item B<cpupool-list> [I<-c|--cpus>] [I<cpu-pool>]
+=item B<cpupool-list> [I<-c|--cpus>] [I<-d|--domains>] [I<cpu-pool>]

  List CPU pools on the host.
  If I<-c> is specified, B<xl> prints a list of CPUs used by I<cpu-pool>.
+If I<-d> is specified, B<xl> prints a list of domains in I<cpu-pool> instead
+of the domain count.
+I<-c> and I<-d> are mutually exclusive.

  =item B<cpupool-destroy> I<cpu-pool>

diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index aff6f90..c7b9fce 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -6754,23 +6754,32 @@ int main_cpupoollist(int argc, char **argv)
      int opt;
      static struct option opts[] = {
          {"cpus", 0, 0, 'c'},
+        {"domains", 0, 0, 'd'},
          COMMON_LONG_OPTS,
          {0, 0, 0, 0}
      };
-    int opt_cpus = 0;
+    int opt_cpus = 0, opt_domains = 0;
      const char *pool = NULL;
      libxl_cpupoolinfo *poolinfo;
-    int n_pools, p, c, n;
+    libxl_dominfo *dominfo = NULL;
+    int n_pools, n_domains, p, c, n;
      uint32_t poolid;
      char *name;
      int ret = 0;

-    SWITCH_FOREACH_OPT(opt, "hc", opts, "cpupool-list", 0) {
+    SWITCH_FOREACH_OPT(opt, "hcd", opts, "cpupool-list", 0) {
      case 'c':
          opt_cpus = 1;
          break;
+    case 'd':
+        opt_domains = 1;
+        break;
      }

+    if (opt_cpus && opt_domains) {
+        fprintf(stderr, "specifying both cpu- and domain-list not allowed\n");
+        return -ERROR_FAIL;
+    }
      if (optind < argc) {
          pool = argv[optind];
          if (libxl_name_to_cpupoolid(ctx, pool, &poolid)) {
@@ -6784,12 +6793,21 @@ int main_cpupoollist(int argc, char **argv)
          fprintf(stderr, "error getting cpupool info\n");
          return -ERROR_NOMEM;
      }
+    if (opt_domains) {
+        dominfo = libxl_list_domain(ctx, &n_domains);
+        if (!dominfo) {
+            fprintf(stderr, "error getting domain info\n");
+            ret = -ERROR_NOMEM;
+            goto out;
+        }
+    }

      printf("%-19s", "Name");
      if (opt_cpus)
          printf("CPU list\n");
      else
-        printf("CPUs   Sched     Active   Domain count\n");
+        printf("CPUs   Sched     Active   Domain %s\n",
+               opt_domains ? "list" : "count");

      for (p = 0; p < n_pools; p++) {
          if (!ret && (!pool || (poolinfo[p].poolid == poolid))) {
@@ -6808,15 +6826,30 @@ int main_cpupoollist(int argc, char **argv)
                          n++;
                      }
                  if (!opt_cpus) {
-                    printf("%3d %9s       y       %4d", n,
-                           libxl_scheduler_to_string(poolinfo[p].sched),
-                           poolinfo[p].n_dom);
+                    printf("%3d %9s       y     ", n,
+                           libxl_scheduler_to_string(poolinfo[p].sched));
+                    if (opt_domains) {
+                        c = 0;
+                        for (n = 0; n < n_domains; n++) {
+                            if (poolinfo[p].poolid == dominfo[n].cpupool) {
+                                name = libxl_domid_to_name(ctx, 
dominfo[n].domid);
+                                printf("%s%s", c ? ", " : "", name);
+                                free(name);
+                                c++;
+                            }
+                        }
+                    }
+                    else
+                        printf("  %4d", poolinfo[p].n_dom);
                  }
                  printf("\n");
              }
          }
      }

+    if (dominfo)
+        libxl_dominfo_list_free(dominfo, n_domains);
+out:
      libxl_cpupoolinfo_list_free(poolinfo, n_pools);

      return ret;
diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c
index ebe0220..8a52d26 100644
--- a/tools/libxl/xl_cmdtable.c
+++ b/tools/libxl/xl_cmdtable.c
@@ -426,8 +426,9 @@ struct cmd_spec cmd_table[] = {
      { "cpupool-list",
        &main_cpupoollist, 0, 0,
        "List CPU pools on host",
-      "[-c|--cpus] [<CPU Pool>]",
-      "-c, --cpus                     Output list of CPUs used by a pool"
+      "[-c|--cpus] [-d|--domains] [<CPU Pool>]",
+      "-c, --cpus                     Output list of CPUs used by a pool\n"
+      "-d, --domains                  Output list of domains running in a pool"
      },
      { "cpupool-destroy",
        &main_cpupooldestroy, 0, 1,



--
Juergen Gross                 Principal Developer Operating Systems
PBG PDG ES&S SWE OS6                   Telephone: +49 (0) 89 62060 2932
Fujitsu                                   e-mail: juergen.gross@xxxxxxxxxxxxxx
Mies-van-der-Rohe-Str. 8                Internet: ts.fujitsu.com
D-80807 Muenchen                 Company details: ts.fujitsu.com/imprint.html

_______________________________________________
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®.