Skip to contentSkip to conversation

xl: Add "xl top" command

PATCH In review Yang Hongyang 2 participants 2 messages May 12, 2010 – May 21, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 xl: Add "xl top" command

Add "xl top" command, a clone of "xm top".

tools/libxl/xl_cmdimpl.c +20 -0
diff -r feb1b75800d6 -r 0efa1c583fb0 tools/libxl/xl_cmdimpl.c
@@ -3098,3 +3098,23 @@
 
     exit(0);
 }
+
+int main_top(int argc, char **argv)
+{
+    int opt;
+
+    while ((opt = getopt(argc, argv, "h")) != -1) {
+        switch (opt) {
+        case 'h':
+            help("top");
+            exit(0);
+        default:
+            fprintf(stderr, "option `%c' not supported.\n", opt);
+            break;
+        }
+    }
+
+    system("xentop");
+
+    exit(0);
+}
tools/libxl/xl_cmdimpl.h +1 -0
diff -r feb1b75800d6 -r 0efa1c583fb0 tools/libxl/xl_cmdimpl.h
@@ -40,5 +40,6 @@
 int main_rename(int argc, char **argv);
 int main_trigger(int argc, char **argv);
 int main_sysrq(int argc, char **argv);
+int main_top(int argc, char **argv);
 
 void help(char *command);
tools/libxl/xl_cmdtable.c +5 -0
diff -r feb1b75800d6 -r 0efa1c583fb0 tools/libxl/xl_cmdtable.c
@@ -177,6 +177,11 @@
       "Send a sysrq to a domain",
       "<Domain> <letter>",
     },
+    { "top",
+      &main_top,
+      "Monitor a host and the domains in real time",
+      "",
+    },
 };
 
 int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);
Signature · 2 lines
Regards
Yang Hongyang
#1 lore raw

Yang Hongyang writes ("[Xen-devel] [PATCH 2/2]xl: Add "xl top" command"):

Quoted 3 lines

Add "xl top" command, a clone of "xm top".

This is mostly OK, but:

Quoted 1 line

+ system("xentop");

1. You should probably use execlp rather than system.
2. You do not check the return value. This is a serious mistake.

Ian.