xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0 of 6] xl: network and block features
@ 2010-05-12 17:32 Eric Chanudet
  2010-05-12 17:32 ` [PATCH 1 of 6] xl: network-attach command Eric Chanudet
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Eric Chanudet @ 2010-05-12 17:32 UTC (permalink / raw)
  To: xen-devel


This patch series adds the following features to xl and libxenlight:
- network-{attach,list,detach}
- block-{attach,list,detach}

Some details :
- network-attach accel and rate parameters are not handled yet (they are not in
xm neither).
- devid attribution for PV nics now starts from 0 for nics described in
configuration file (used to start at 1, which made xm freeze when attaching more
than one PV nic, probably because of nextDeviceID xenstore entry).
- devid attribution do not rely on nextDeviceID xenstore entry in libxl
(comments, in python code, suggest this entry to be optional).

-- 
Eric Chanudet

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1 of 6] xl: network-attach command
  2010-05-12 17:32 [PATCH 0 of 6] xl: network and block features Eric Chanudet
@ 2010-05-12 17:32 ` Eric Chanudet
  2010-05-13  0:45   ` Yang Hongyang
  2010-05-12 17:32 ` [PATCH 2 of 6] xl: network-list command Eric Chanudet
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 10+ messages in thread
From: Eric Chanudet @ 2010-05-12 17:32 UTC (permalink / raw)
  To: xen-devel

This patch adds network-attach command to xl.

Usage: xl network-attach <Domain> [type=<type>] [mac=<mac>] [bridge=<bridge>]
[ip=<ip>] [script=<script>] [backend=<BackDomain>] [vifname=<name>]
[rate=<rate>] [model=<model>][accel=<accel>]

rate and accel parameters are not handled for now.

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -1420,6 +1420,8 @@ int libxl_device_nic_add(struct libxl_ct
     unsigned int boffset = 0;
     unsigned int foffset = 0;
     libxl_device device;
+    char *dompath, **l;
+    unsigned int nb;
 
     front = flexarray_make(16, 1);
     if (!front)
@@ -1428,6 +1430,19 @@ int libxl_device_nic_add(struct libxl_ct
     if (!back)
         return ERROR_NOMEM;
 
+    if (nic->devid == -1) {
+        if (!(dompath = libxl_xs_get_dompath(ctx, domid))) {
+            return ERROR_FAIL;
+        }
+        if (!(l = libxl_xs_directory(ctx, XBT_NULL,
+                                     libxl_sprintf(ctx, "%s/device/vif", dompath), &nb))) {
+            nic->devid = 0;
+        } else {
+            nic->devid = strtoul(l[nb - 1], NULL, 10) + 1;
+            libxl_free(ctx, l);
+        }
+    }
+
     device.backend_devid = nic->devid;
     device.backend_domid = nic->backend_domid;
     device.backend_kind = DEVICE_VIF;
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -573,7 +573,7 @@ static void parse_config_data(const char
             char *buf2 = strdup(buf);
             char *p, *p2;
             *vifs = (libxl_device_nic *) realloc(*vifs, sizeof (libxl_device_nic) * ((*num_vifs) + 1));
-            init_nic_info((*vifs) + (*num_vifs), (*num_vifs));
+            init_nic_info((*vifs) + (*num_vifs), (*num_vifs) + 1);
             p = strtok(buf2, ",");
             if (!p)
                 goto skip;
@@ -3058,3 +3058,86 @@ int main_trigger(int argc, char **argv)
 
     exit(0);
 }
+
+int main_networkattach(int argc, char **argv)
+{
+    int opt;
+    libxl_device_nic nic;
+    char *endptr, *tok;
+    int i;
+    unsigned int val;
+
+    if ((argc < 2) || (argc > 11)) {
+        help("network-attach");
+        exit(0);
+    }
+    while ((opt = getopt(argc, argv, "hl")) != -1) {
+        switch (opt) {
+        case 'h':
+            help("network-attach");
+            exit(0);
+        default:
+            fprintf(stderr, "option `%c' not supported.\n", opt);
+            break;
+        }
+    }
+
+    if (domain_qualifier_to_domid(argv[1], &domid, 0) < 0) {
+        fprintf(stderr, "%s is an invalid domain identifier\n", argv[1]);
+        exit(1);
+    }
+    init_nic_info(&nic, -1);
+    for (argv += 2, argc -= 2; argc > 0; ++argv, --argc) {
+        if (!strncmp("type=", *argv, 5)) {
+            if (!strncmp("vif", (*argv) + 5, 4)) {
+                nic.nictype = NICTYPE_VIF;
+            } else if (!strncmp("ioemu", (*argv) + 5, 5)) {
+                nic.nictype = NICTYPE_IOEMU;
+            } else {
+                fprintf(stderr, "Invalid parameter `type'.\n");
+                exit(1);
+            }
+        } else if (!strncmp("mac=", *argv, 4)) {
+            tok = strtok((*argv) + 4, ":");
+            for (i = 0; tok && i < 6; tok = strtok(NULL, ":"), ++i) {
+                val = strtoul(tok, &endptr, 16);
+                if ((tok == endptr) || (val > 255)) {
+                    fprintf(stderr, "Invalid parameter `mac'.\n");
+                    exit(1);
+                }
+                nic.mac[i] = val;
+            }
+        } else if (!strncmp("bridge=", *argv, 7)) {
+            nic.bridge = (*argv) + 7;
+        } else if (!strncmp("ip=", *argv, 3)) {
+            if (!inet_aton((*argv) + 3, &(nic.ip))) {
+                fprintf(stderr, "Invalid parameter `ip'.\n");
+                exit(1);
+            }
+        } else if (!strncmp("script=", *argv, 6)) {
+            nic.script = (*argv) + 6;
+        } else if (!strncmp("backend=", *argv, 8)) {
+            val = strtoul((*argv) + 8, &endptr, 10);
+            if (((*argv) + 8) == endptr) {
+                fprintf(stderr, "Invalid parameter `backend'.\n");
+                exit(1);
+            }
+            nic.backend_domid = val;
+        } else if (!strncmp("vifname=", *argv, 8)) {
+            nic.ifname = (*argv) + 8;
+        } else if (!strncmp("model=", *argv, 6)) {
+            nic.model = (*argv) + 6;
+        } else if (!strncmp("rate=", *argv, 5)) {
+        } else if (!strncmp("accel=", *argv, 6)) {
+        } else {
+            fprintf(stderr, "unrecognized argument `%s'\n", *argv);
+            exit(1);
+        }
+    }
+    nic.domid = domid;
+    if (libxl_device_nic_add(&ctx, domid, &nic)) {
+        fprintf(stderr, "libxl_device_nic_add failed.\n");
+        exit(1);
+    }
+    exit(0);
+}
diff --git a/tools/libxl/xl_cmdimpl.h b/tools/libxl/xl_cmdimpl.h
--- a/tools/libxl/xl_cmdimpl.h
+++ b/tools/libxl/xl_cmdimpl.h
@@ -39,5 +39,6 @@ int main_domid(int argc, char **argv);
 int main_domname(int argc, char **argv);
 int main_rename(int argc, char **argv);
 int main_trigger(int argc, char **argv);
+int main_networkattach(int argc, char **argv);
 
 void help(char *command);
diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c
+++ b/tools/libxl/xl_cmdtable.c
@@ -172,6 +172,10 @@ struct cmd_spec cmd_table[] = {
       "Send a trigger to a domain",
       "<Domain> <nmi|reset|init|power|sleep> [<VCPU>]",
     },
+    { "network-attach",
+      &main_networkattach,
+      "Create a new virtual network device"
+    },
 };
 
 int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 2 of 6] xl: network-list command
  2010-05-12 17:32 [PATCH 0 of 6] xl: network and block features Eric Chanudet
  2010-05-12 17:32 ` [PATCH 1 of 6] xl: network-attach command Eric Chanudet
@ 2010-05-12 17:32 ` Eric Chanudet
  2010-05-12 17:32 ` [PATCH 3 of 6] xl: network-detach command Eric Chanudet
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Eric Chanudet @ 2010-05-12 17:32 UTC (permalink / raw)
  To: xen-devel

This patch adds network-list command to xl.

Usage: xl network-list <Domain(s)>

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -1505,6 +1505,66 @@ int libxl_device_nic_del(struct libxl_ct
     return libxl_device_del(ctx, &device, wait);
 }
 
+libxl_nicinfo *libxl_list_nics(struct libxl_ctx *ctx, uint32_t domid, unsigned int *nb)
+{
+    char *dompath, *nic_path_fe;
+    char **l;
+    char *val, *tok;
+    unsigned int nb_nics, i;
+    libxl_nicinfo *res, *nics;
+
+    dompath = libxl_xs_get_dompath(ctx, domid);
+    if (!dompath) {
+        return NULL;
+    }
+    l = libxl_xs_directory(ctx, XBT_NULL,
+                           libxl_sprintf(ctx, "%s/device/vif", dompath), &nb_nics);
+    if (!l) {
+        return NULL;
+    }
+    res = libxl_calloc(ctx, nb_nics, sizeof (libxl_device_nic));
+    if (!res) {
+        libxl_free(ctx, l);
+        return NULL;
+    }
+    nics = res;
+    for (*nb = nb_nics; nb_nics > 0; --nb_nics, ++l, ++nics) {
+        nic_path_fe = libxl_sprintf(ctx, "%s/device/vif/%s", dompath, *l);
+
+        nics->backend = libxl_xs_read(ctx, XBT_NULL,
+                                      libxl_sprintf(ctx, "%s/backend", nic_path_fe));
+        val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/backend-id", nic_path_fe));
+        nics->backend_id = val ? strtoul(val, NULL, 10) : -1;
+
+        nics->devid = strtoul(*l, NULL, 10);
+        val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/state", nic_path_fe));
+        nics->state = val ? strtoul(val, NULL, 10) : -1;
+        val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/mac", nic_path_fe));
+        for (i = 0, tok = strtok(val, ":"); tok && (i < 6);
+             ++i, tok = strtok(NULL, ":")) {
+            nics->mac[i] = strtoul(tok, NULL, 16);
+        }
+        val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/event-channel", nic_path_fe));
+        nics->evtch = val ? strtol(val, NULL, 10) : -1;
+        val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/tx-ring-ref", nic_path_fe));
+        nics->rref_tx = val ? strtol(val, NULL, 10) : -1;
+        val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/rx-ring-ref", nic_path_fe));
+        nics->rref_rx = val ? strtol(val, NULL, 10) : -1;
+        nics->frontend = libxl_xs_read(ctx, XBT_NULL,
+                                       libxl_sprintf(ctx, "%s/frontend", nics->backend));
+        val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/frontend-id", nics->backend));
+        nics->frontend_id = val ? strtoul(val, NULL, 10) : -1;
+        nics->script = libxl_xs_read(ctx, XBT_NULL,
+                                     libxl_sprintf(ctx, "%s/script", nics->backend));
+
+        libxl_free(ctx, nic_path_fe);
+    }
+
+    libxl_free(ctx, l);
+    return res;
+}
+
+
 /******************************************************************************/
 int libxl_device_console_add(struct libxl_ctx *ctx, uint32_t domid, libxl_device_console *console)
 {
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -372,8 +372,23 @@ int libxl_device_disk_del(struct libxl_c
 libxl_device_disk *libxl_device_disk_list(struct libxl_ctx *ctx, uint32_t domid, int *num);
 int libxl_cdrom_insert(struct libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk);
 
+typedef struct {
+    char *backend;
+    uint32_t backend_id;
+    char *frontend;
+    uint32_t frontend_id;
+    int devid;
+    int state;
+    char *script;
+    uint8_t mac[6];
+    int evtch;
+    int rref_tx;
+    int rref_rx;
+} libxl_nicinfo;
+
 int libxl_device_nic_add(struct libxl_ctx *ctx, uint32_t domid, libxl_device_nic *nic);
 int libxl_device_nic_del(struct libxl_ctx *ctx, libxl_device_nic *nic, int wait);
+libxl_nicinfo *libxl_list_nics(struct libxl_ctx *ctx, uint32_t domid, unsigned int *nb);
 
 int libxl_device_console_add(struct libxl_ctx *ctx, uint32_t domid, libxl_device_console *console);
 
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -3141,3 +3141,51 @@ int main_networkattach(int argc, char **
     }
     exit(0);
 }
+
+int main_networklist(int argc, char **argv)
+{
+    int opt;
+    libxl_nicinfo *nics;
+    unsigned int nb;
+
+    if (argc < 2) {
+        help("network-list");
+        exit(1);
+    }
+    while ((opt = getopt(argc, argv, "hl")) != -1) {
+        switch (opt) {
+            case 'h':
+                help("network-list");
+                exit(0);
+            default:
+                fprintf(stderr, "option `%c' not supported.\n", opt);
+                break;
+        }
+    }
+
+    /*      Idx  BE   MAC   Hdl  Sta  evch txr/rxr  BE-path */
+    printf("%-3s %-2s %-17s %-6s %-5s %-6s %5s/%-5s %-30s\n",
+           "Idx", "BE", "Mac Addr.", "handle", "state", "evt-ch", "tx-", "rx-ring-ref", "BE-path");
+    for (++argv, --argc; argc > 0; --argc, ++argv) {
+        if (domain_qualifier_to_domid(*argv, &domid, 0) < 0) {
+            fprintf(stderr, "%s is an invalid domain identifier\n", *argv);
+            continue;
+        }
+        if (!(nics = libxl_list_nics(&ctx, domid, &nb))) {
+            continue;
+        }
+        for (; nb > 0; --nb, ++nics) {
+            /* Idx BE */
+            printf("%-3d %-2d ", nics->devid, nics->backend_id);
+            /* MAC */
+            printf("%02x:%02x:%02x:%02x:%02x:%02x ",
+                   nics->mac[0], nics->mac[1], nics->mac[2],
+                   nics->mac[3], nics->mac[4], nics->mac[5]);
+            /* Hdl  Sta  evch txr/rxr  BE-path */
+            printf("%6d %5d %6d %5d/%-11d %-30s\n",
+                   nics->devid, nics->state, nics->evtch,
+                   nics->rref_tx, nics->rref_rx, nics->backend);
+        }
+    }
+    exit(0);
+}
diff --git a/tools/libxl/xl_cmdimpl.h b/tools/libxl/xl_cmdimpl.h
--- a/tools/libxl/xl_cmdimpl.h
+++ b/tools/libxl/xl_cmdimpl.h
@@ -40,5 +40,6 @@ int main_domname(int argc, char **argv);
 int main_rename(int argc, char **argv);
 int main_trigger(int argc, char **argv);
 int main_networkattach(int argc, char **argv);
+int main_networklist(int argc, char **argv);
 
 void help(char *command);
diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c
+++ b/tools/libxl/xl_cmdtable.c
@@ -176,6 +176,10 @@ struct cmd_spec cmd_table[] = {
       &main_networkattach,
       "Create a new virtual network device"
     },
+    { "network-list",
+      &main_networklist,
+      "List virtual network interfaces for a domain"
+    },
 };
 
 int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 3 of 6] xl: network-detach command
  2010-05-12 17:32 [PATCH 0 of 6] xl: network and block features Eric Chanudet
  2010-05-12 17:32 ` [PATCH 1 of 6] xl: network-attach command Eric Chanudet
  2010-05-12 17:32 ` [PATCH 2 of 6] xl: network-list command Eric Chanudet
@ 2010-05-12 17:32 ` Eric Chanudet
  2010-05-12 17:32 ` [PATCH 4 of 6] xl: block-attach command Eric Chanudet
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Eric Chanudet @ 2010-05-12 17:32 UTC (permalink / raw)
  To: xen-devel

This patch adds network-detach command to xl.

Usage: xl network-detach <Domain> <DevId|mac>

diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c
--- a/tools/libxl/libxl_utils.c
+++ b/tools/libxl/libxl_utils.c
@@ -356,3 +356,77 @@ int libxl_pipe(struct libxl_ctx *ctx, in
     }
     return 0;
 }
+
+int libxl_mac_to_device_nic(struct libxl_ctx *ctx, uint32_t domid,
+                            const char *mac, libxl_device_nic *nic)
+{
+    libxl_nicinfo *nics;
+    unsigned int nb, i;
+    uint8_t mac_n[6];
+    uint8_t *a, *b;
+    const char *tok;
+    char *endptr;
+
+    nics = libxl_list_nics(ctx, domid, &nb);
+    if (!nics) {
+        return ERROR_FAIL;
+    }
+
+    for (i = 0, tok = mac; *tok && (i < 6); ++i, tok += 3) {
+        mac_n[i] = strtol(tok, &endptr, 16);
+        if (endptr != (tok + 2)) {
+            return ERROR_INVAL;
+        }
+    }
+    memset(nic, 0, sizeof (libxl_device_nic));
+    for (; nb; --nb, ++nics) {
+        for (i = 0, a = nics->mac, b = mac_n;
+             (b < mac_n + 6) && (*a == *b); ++a, ++b)
+            ;
+        if ((b >= mac_n + 6) && (*a == *b)) {
+            nic->backend_domid = nics->backend_id;
+            nic->domid = nics->frontend_id;
+            nic->devid = nics->devid;
+            memcpy(nic->mac, nics->mac, sizeof (nic->mac));
+            nic->script = nics->script;
+            libxl_free(ctx, nics);
+            return 0;
+        }
+    }
+
+    libxl_free(ctx, nics);
+    return 0;
+}
+
+int libxl_devid_to_device_nic(struct libxl_ctx *ctx, uint32_t domid,
+                              const char *devid, libxl_device_nic *nic)
+{
+    char *tok, *val;
+    char *dompath, *nic_path_fe, *nic_path_be;
+    unsigned int i;
+
+    memset(nic, 0, sizeof (libxl_device_nic));
+    dompath = libxl_xs_get_dompath(ctx, domid);
+    if (!dompath) {
+        return ERROR_FAIL;
+    }
+    nic_path_fe = libxl_sprintf(ctx, "%s/device/vif/%s", dompath, devid);
+    nic_path_be = libxl_xs_read(ctx, XBT_NULL,
+                                libxl_sprintf(ctx, "%s/backend", nic_path_fe));
+    val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/backend-id", nic_path_fe));
+    nic->backend_domid = strtoul(val, NULL, 10);
+    nic->devid = strtoul(devid, NULL, 10);
+    libxl_free(ctx, val);
+
+    val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/mac", nic_path_fe));
+    for (i = 0, tok = strtok(val, ":"); tok && (i < 6);
+         ++i, tok = strtok(NULL, ":")) {
+        nic->mac[i] = strtoul(tok, NULL, 16);
+    }
+    libxl_free(ctx, val);
+    nic->script = libxl_xs_read(ctx, XBT_NULL,
+                                libxl_sprintf(ctx, "%s/script", nic_path_be));
+    libxl_free(ctx, nic_path_fe);
+    libxl_free(ctx, nic_path_be);
+    return 0;
+}
diff --git a/tools/libxl/libxl_utils.h b/tools/libxl/libxl_utils.h
--- a/tools/libxl/libxl_utils.h
+++ b/tools/libxl/libxl_utils.h
@@ -55,6 +55,12 @@ void libxl_report_child_exitstatus(struc
     /* treats all exit statuses as errors; if that's not what you want,
      * check status yourself first */
 
+
+int libxl_mac_to_device_nic(struct libxl_ctx *ctx, uint32_t domid,
+                            const char *mac, libxl_device_nic *nic);
+int libxl_devid_to_device_nic(struct libxl_ctx *ctx, uint32_t domid,
+                              const char *devid, libxl_device_nic *nic);
+
 /* log levels: */
 #define XL_LOG_DEBUG 3
 #define XL_LOG_INFO 2
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -3189,3 +3189,45 @@ int main_networklist(int argc, char **ar
     }
     exit(0);
 }
+
+int main_networkdetach(int argc, char **argv)
+{
+    int opt;
+    libxl_device_nic nic;
+
+    if (argc != 3) {
+        help("network-detach");
+        exit(0);
+    }
+    while ((opt = getopt(argc, argv, "hl")) != -1) {
+        switch (opt) {
+        case 'h':
+            help("network-detach");
+            exit(0);
+        default:
+            fprintf(stderr, "option `%c' not supported.\n", opt);
+            break;
+        }
+    }
+
+    if (domain_qualifier_to_domid(argv[1], &domid, 0) < 0) {
+        fprintf(stderr, "%s is an invalid domain identifier\n", argv[1]);
+        exit(1);
+    }
+
+    if (!strchr(argv[2], ':')) {
+        if (libxl_devid_to_device_nic(&ctx, domid, argv[2], &nic)) {
+            fprintf(stderr, "Unknown device %s.\n", argv[2]);
+            exit(1);
+        }
+    } else {
+        if (libxl_mac_to_device_nic(&ctx, domid, argv[2], &nic)) {
+            fprintf(stderr, "Unknown device %s.\n", argv[2]);
+            exit(1);
+        }
+    }
+    if (libxl_device_nic_del(&ctx, &nic, 1)) {
+        fprintf(stderr, "libxl_device_nic_del failed.\n");
+    }
+    exit(0);
+}
diff --git a/tools/libxl/xl_cmdimpl.h b/tools/libxl/xl_cmdimpl.h
--- a/tools/libxl/xl_cmdimpl.h
+++ b/tools/libxl/xl_cmdimpl.h
@@ -41,5 +41,6 @@ int main_rename(int argc, char **argv);
 int main_trigger(int argc, char **argv);
 int main_networkattach(int argc, char **argv);
 int main_networklist(int argc, char **argv);
+int main_networkdetach(int argc, char **argv);
 
 void help(char *command);
diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c
+++ b/tools/libxl/xl_cmdtable.c
@@ -180,6 +180,10 @@ struct cmd_spec cmd_table[] = {
       &main_networklist,
       "List virtual network interfaces for a domain"
     },
+    { "network-detach",
+      &main_networkdetach,
+      "Destroy a domain's virtual network device"
+    },
 };
 
 int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 4 of 6] xl: block-attach command
  2010-05-12 17:32 [PATCH 0 of 6] xl: network and block features Eric Chanudet
                   ` (2 preceding siblings ...)
  2010-05-12 17:32 ` [PATCH 3 of 6] xl: network-detach command Eric Chanudet
@ 2010-05-12 17:32 ` Eric Chanudet
  2010-05-12 17:32 ` [PATCH 5 of 6] xl: block-list command Eric Chanudet
  2010-05-12 17:32 ` [PATCH 6 of 6] xl: block-detach command Eric Chanudet
  5 siblings, 0 replies; 10+ messages in thread
From: Eric Chanudet @ 2010-05-12 17:32 UTC (permalink / raw)
  To: xen-devel

This patch adds block-attach command to xl.

Usage: xl block-attach <Domain> <BackDev> <FrontDev> <Mode>
[BackDomain]

diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -3231,3 +3231,75 @@ int main_networkdetach(int argc, char **
     }
     exit(0);
 }
+
+int main_blockattach(int argc, char **argv)
+{
+    int opt;
+    char *tok;
+    uint32_t fe_domid, be_domid = 0;
+    libxl_device_disk disk = { 0 };
+
+    if ((argc < 3) || (argc > 6)) {
+        help("block-attach");
+        exit(0);
+    }
+    while ((opt = getopt(argc, argv, "h")) != -1) {
+        switch (opt) {
+        case 'h':
+            help("block-attach");
+            exit(0);
+        default:
+            fprintf(stderr, "option `%c' not supported.\n", opt);
+            break;
+        }
+    }
+
+    tok = strtok(argv[2], ":");
+    if (!strcmp(tok, "phy")) {
+        disk.phystype = PHYSTYPE_PHY;
+    } else if (!strcmp(tok, "file")) {
+        disk.phystype = PHYSTYPE_FILE;
+    } else if (!strcmp(tok, "tap")) {
+        tok = strtok(NULL, ":");
+        if (!strcmp(tok, "aio")) {
+            disk.phystype = PHYSTYPE_AIO;
+        } else if (!strcmp(tok, "vhd")) {
+            disk.phystype = PHYSTYPE_VHD;
+        } else if (!strcmp(tok, "qcow")) {
+            disk.phystype = PHYSTYPE_QCOW;
+        } else if (!strcmp(tok, "qcow2")) {
+            disk.phystype = PHYSTYPE_QCOW2;
+        } else {
+            fprintf(stderr, "Error: `%s' is not a valid disk image.\n", tok);
+            exit(1);
+        }
+    } else {
+        fprintf(stderr, "Error: `%s' is not a valid block device.\n", tok);
+        exit(1);
+    }
+    disk.physpath = strtok(NULL, "\0");
+    if (!disk.physpath) {
+        fprintf(stderr, "Error: missing path to disk image.\n");
+        exit(1);
+    }
+    disk.virtpath = argv[3];
+    disk.unpluggable = 1;
+    disk.readwrite = (argv[4][0] == 'w') ? 1 : 0;
+
+    if (domain_qualifier_to_domid(argv[1], &fe_domid, 0) < 0) {
+        fprintf(stderr, "%s is an invalid domain identifier\n", argv[1]);
+        exit(1);
+    }
+    if (argc == 6) {
+        if (domain_qualifier_to_domid(argv[5], &be_domid, 0) < 0) {
+            fprintf(stderr, "%s is an invalid domain identifier\n", argv[5]);
+            exit(1);
+        }
+    }
+    disk.domid = fe_domid;
+    disk.backend_domid = be_domid;
+    if (libxl_device_disk_add(&ctx, fe_domid, &disk)) {
+        fprintf(stderr, "libxl_device_disk_add failed.\n");
+    }
+    exit(0);
+}
diff --git a/tools/libxl/xl_cmdimpl.h b/tools/libxl/xl_cmdimpl.h
--- a/tools/libxl/xl_cmdimpl.h
+++ b/tools/libxl/xl_cmdimpl.h
@@ -42,5 +42,6 @@ int main_trigger(int argc, char **argv);
 int main_networkattach(int argc, char **argv);
 int main_networklist(int argc, char **argv);
 int main_networkdetach(int argc, char **argv);
+int main_blockattach(int argc, char **argv);
 
 void help(char *command);
diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c
+++ b/tools/libxl/xl_cmdtable.c
@@ -184,6 +184,10 @@ struct cmd_spec cmd_table[] = {
       &main_networkdetach,
       "Destroy a domain's virtual network device"
     },
+    { "block-attach",
+      &main_blockattach,
+      "Create a new virtual block device"
+    },
 };
 
 int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 5 of 6] xl: block-list command
  2010-05-12 17:32 [PATCH 0 of 6] xl: network and block features Eric Chanudet
                   ` (3 preceding siblings ...)
  2010-05-12 17:32 ` [PATCH 4 of 6] xl: block-attach command Eric Chanudet
@ 2010-05-12 17:32 ` Eric Chanudet
  2010-05-12 17:32 ` [PATCH 6 of 6] xl: block-detach command Eric Chanudet
  5 siblings, 0 replies; 10+ messages in thread
From: Eric Chanudet @ 2010-05-12 17:32 UTC (permalink / raw)
  To: xen-devel

This patch adds block-list command to xl.

Usage: xl block-list <Domain(s)>

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -1703,57 +1703,90 @@ int libxl_device_vkb_hard_shutdown(struc
 libxl_device_disk *libxl_device_disk_list(struct libxl_ctx *ctx, uint32_t domid, int *num)
 {
     char *be_path_tap, *be_path_vbd;
-    libxl_device_disk *disks = NULL;
-    char **l = NULL;
+    libxl_device_disk *dend, *disks, *ret = NULL;
+    char **b, **l = NULL;
     unsigned int numl;
-    int num_disks = 0, i;
     char *type;
 
     be_path_vbd = libxl_sprintf(ctx, "%s/backend/vbd/%d", libxl_xs_get_dompath(ctx, 0), domid);
     be_path_tap = libxl_sprintf(ctx, "%s/backend/tap/%d", libxl_xs_get_dompath(ctx, 0), domid);
 
-    l = libxl_xs_directory(ctx, XBT_NULL, be_path_vbd, &numl);
+    b = l = libxl_xs_directory(ctx, XBT_NULL, be_path_vbd, &numl);
     if (l) {
-        num_disks += numl;
-        disks = realloc(disks, sizeof(libxl_device_disk) * num_disks);
-        for (i = 0; i < numl; i++) {
-            disks[i].backend_domid = 0;
-            disks[i].domid = domid;
-            disks[i].physpath = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/%s/params", be_path_vbd, l[i]));
-            libxl_string_to_phystype(ctx, libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/%s/type", be_path_vbd, l[i])), &(disks[i].phystype));
-            disks[i].virtpath = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/%s/dev", be_path_vbd, l[i]));
-            disks[i].unpluggable = atoi(libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/%s/removable", be_path_vbd, l[i])));
-            if (!strcmp(libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/%s/mode", be_path_vbd, l[i])), "w"))
-                disks[i].readwrite = 1;
+        ret = realloc(ret, sizeof(libxl_device_disk) * numl);
+        disks = ret;
+        *num = numl;
+        dend = ret + *num;
+        for (; disks < dend; ++disks, ++l) {
+            disks->backend_domid = 0;
+            disks->domid = domid;
+            disks->physpath = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/%s/params", be_path_vbd, *l));
+            libxl_string_to_phystype(ctx, libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/%s/type", be_path_vbd, *l)), &(disks->phystype));
+            disks->virtpath = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/%s/dev", be_path_vbd, *l));
+            disks->unpluggable = atoi(libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/%s/removable", be_path_vbd, *l)));
+            if (!strcmp(libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/%s/mode", be_path_vbd, *l)), "w"))
+                disks->readwrite = 1;
             else
-                disks[i].readwrite = 0;
-            type = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/device-type", libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/%s/frontend", be_path_vbd, l[i]))));
-            disks[i].is_cdrom = !strcmp(type, "cdrom");
+                disks->readwrite = 0;
+            type = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/device-type", libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/%s/frontend", be_path_vbd, *l))));
+            disks->is_cdrom = !strcmp(type, "cdrom");
         }
-        free(l);
+        libxl_free(ctx, b);
     }
-    l = libxl_xs_directory(ctx, XBT_NULL, be_path_tap, &numl);
+    b = l = libxl_xs_directory(ctx, XBT_NULL, be_path_tap, &numl);
     if (l) {
-        num_disks += numl;
-        disks = realloc(disks, sizeof(libxl_device_disk) * num_disks);
-        for (i = 0; i < numl; i++) {
-            disks[i].backend_domid = 0;
-            disks[i].domid = domid;
-            disks[i].physpath = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/%s/params", be_path_tap, l[i]));
-            libxl_string_to_phystype(ctx, libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/%s/type", be_path_tap, l[i])), &(disks[i].phystype));
-            disks[i].virtpath = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/%s/dev", be_path_tap, l[i]));
-            disks[i].unpluggable = atoi(libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/%s/removable", be_path_tap, l[i])));
-            if (!strcmp(libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/%s/mode", be_path_tap, l[i])), "w"))
-                disks[i].readwrite = 1;
+        ret = realloc(ret, sizeof(libxl_device_disk) * (*num + numl));
+        disks = ret + *num;
+        *num += numl;
+        for (dend = ret + *num; disks < dend; ++disks, ++l) {
+            disks->backend_domid = 0;
+            disks->domid = domid;
+            disks->physpath = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/%s/params", be_path_tap, *l));
+            libxl_string_to_phystype(ctx, libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/%s/type", be_path_tap, *l)), &(disks->phystype));
+            disks->virtpath = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/%s/dev", be_path_tap, *l));
+            disks->unpluggable = atoi(libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/%s/removable", be_path_tap, *l)));
+            if (!strcmp(libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/%s/mode", be_path_tap, *l)), "w"))
+                disks->readwrite = 1;
             else
-                disks[i].readwrite = 0;
-            type = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/device-type", libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/%s/frontend", be_path_vbd, l[i]))));
-            disks[i].is_cdrom = !strcmp(type, "cdrom");
+                disks->readwrite = 0;
+            type = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/device-type", libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/%s/frontend", be_path_tap, *l))));
+            disks->is_cdrom = !strcmp(type, "cdrom");
         }
-        free(l);
+        libxl_free(ctx, b);
     }
-    *num = num_disks;
-    return disks;
+    return ret;
+}
+
+int libxl_device_disk_getinfo(struct libxl_ctx *ctx, uint32_t domid,
+                              libxl_device_disk *disk, libxl_diskinfo *diskinfo)
+{
+    char *dompath, *diskpath;
+    char *val;
+
+    dompath = libxl_xs_get_dompath(ctx, domid);
+    diskinfo->devid = device_disk_dev_number(disk->virtpath);
+
+    /* tap devices entries in xenstore are written as vbd devices. */
+    diskpath = libxl_sprintf(ctx, "%s/device/vbd/%d", dompath, diskinfo->devid);
+    diskinfo->backend = libxl_xs_read(ctx, XBT_NULL,
+                                      libxl_sprintf(ctx, "%s/backend", diskpath));
+    if (!diskinfo->backend) {
+        return ERROR_FAIL;
+    }
+    val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/backend-id", diskpath));
+    diskinfo->backend_id = val ? strtoul(val, NULL, 10) : -1;
+    val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/state", diskpath));
+    diskinfo->state = val ? strtoul(val, NULL, 10) : -1;
+    val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/event-channel", diskpath));
+    diskinfo->evtch = val ? strtoul(val, NULL, 10) : -1;
+    val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/ring-ref", diskpath));
+    diskinfo->rref = val ? strtoul(val, NULL, 10) : -1;
+    diskinfo->frontend = libxl_xs_read(ctx, XBT_NULL,
+                                       libxl_sprintf(ctx, "%s/frontend", diskinfo->backend));
+    val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/frontend-id", diskinfo->backend));
+    diskinfo->frontend_id = val ? strtoul(val, NULL, 10) : -1;
+
+    return 0;
 }
 
 int libxl_cdrom_insert(struct libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk)
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -367,9 +367,22 @@ int libxl_detach_device_model(struct lib
                               libxl_device_model_starting *starting);
   /* DM is detached even if error is returned */
 
+typedef struct {
+    char *backend;
+    uint32_t backend_id;
+    char *frontend;
+    uint32_t frontend_id;
+    int devid;
+    int state;
+    int evtch;
+    int rref;
+} libxl_diskinfo;
+
 int libxl_device_disk_add(struct libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk);
 int libxl_device_disk_del(struct libxl_ctx *ctx, libxl_device_disk *disk, int wait);
 libxl_device_disk *libxl_device_disk_list(struct libxl_ctx *ctx, uint32_t domid, int *num);
+int libxl_device_disk_getinfo(struct libxl_ctx *ctx, uint32_t domid,
+                              libxl_device_disk *disk, libxl_diskinfo *diskinfo);
 int libxl_cdrom_insert(struct libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk);
 
 typedef struct {
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -3303,3 +3303,48 @@ int main_blockattach(int argc, char **ar
     }
     exit(0);
 }
+
+int main_blocklist(int argc, char **argv)
+{
+    int opt;
+    int nb;
+    libxl_device_disk *disks;
+    libxl_diskinfo diskinfo;
+
+    if (argc < 2) {
+        help("block-list");
+        exit(0);
+    }
+    while ((opt = getopt(argc, argv, "h")) != -1) {
+        switch (opt) {
+        case 'h':
+            help("block-list");
+            exit(0);
+        default:
+            fprintf(stderr, "option `%c' not supported.\n", opt);
+            break;
+        }
+    }
+
+    printf("%-5s %-3s %-6s %-5s %-6s %-8s %-30s\n",
+           "Vdev", "BE", "handle", "state", "evt-ch", "ring-ref", "BE-path");
+    for (++argv, --argc; argc > 0; --argc, ++argv) {
+        if (domain_qualifier_to_domid(*argv, &domid, 0) < 0) {
+            fprintf(stderr, "%s is an invalid domain identifier\n", *argv);
+            continue;
+        }
+        disks = libxl_device_disk_list(&ctx, domid, &nb);
+        if (!disks) {
+            continue;
+        }
+        for (; nb > 0; --nb, ++disks) {
+            if (!libxl_device_disk_getinfo(&ctx, domid, disks, &diskinfo)) {
+                /*      Vdev BE   hdl  st   evch rref BE-path*/
+                printf("%-5d %-3d %-6d %-5d %-6d %-8d %-30s\n",
+                       diskinfo.devid, diskinfo.backend_id, diskinfo.frontend_id,
+                       diskinfo.state, diskinfo.evtch, diskinfo.rref, diskinfo.backend);
+            }
+        }
+    }
+    exit(0);
+}
diff --git a/tools/libxl/xl_cmdimpl.h b/tools/libxl/xl_cmdimpl.h
--- a/tools/libxl/xl_cmdimpl.h
+++ b/tools/libxl/xl_cmdimpl.h
@@ -43,5 +43,6 @@ int main_networkattach(int argc, char **
 int main_networklist(int argc, char **argv);
 int main_networkdetach(int argc, char **argv);
 int main_blockattach(int argc, char **argv);
+int main_blocklist(int argc, char **argv);
 
 void help(char *command);
diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c
+++ b/tools/libxl/xl_cmdtable.c
@@ -188,6 +188,10 @@ struct cmd_spec cmd_table[] = {
       &main_blockattach,
       "Create a new virtual block device"
     },
+    { "block-list",
+      &main_blocklist,
+      "List virtual block devices for a domain"
+    },
 };
 
 int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 6 of 6] xl: block-detach command
  2010-05-12 17:32 [PATCH 0 of 6] xl: network and block features Eric Chanudet
                   ` (4 preceding siblings ...)
  2010-05-12 17:32 ` [PATCH 5 of 6] xl: block-list command Eric Chanudet
@ 2010-05-12 17:32 ` Eric Chanudet
  5 siblings, 0 replies; 10+ messages in thread
From: Eric Chanudet @ 2010-05-12 17:32 UTC (permalink / raw)
  To: xen-devel

This patch adds block-detach command to xl.

Usage: xl block-detach <Domain> <DevId>

diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c
--- a/tools/libxl/libxl_utils.c
+++ b/tools/libxl/libxl_utils.c
@@ -430,3 +430,38 @@ int libxl_devid_to_device_nic(struct lib
     libxl_free(ctx, nic_path_be);
     return 0;
 }
+
+int libxl_devid_to_device_disk(struct libxl_ctx *ctx, uint32_t domid,
+                               const char *devid, libxl_device_disk *disk)
+{
+    char *endptr, *val;
+    char *dompath, *diskpath, *be_path;
+    unsigned int devid_n;
+
+    devid_n = strtoul(devid, &endptr, 10);
+    if (devid == endptr) {
+        return ERROR_INVAL;
+    }
+    dompath = libxl_xs_get_dompath(ctx, domid);
+    diskpath = libxl_sprintf(ctx, "%s/device/vbd/%s", dompath, devid);
+    if (!diskpath) {
+        return ERROR_FAIL;
+    }
+
+    val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/backend-id", diskpath));
+    disk->backend_domid = strtoul(val, NULL, 10);
+    disk->domid = domid;
+    be_path = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/backend", diskpath));
+    disk->physpath = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/params", be_path));
+    val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/type", be_path));
+    libxl_string_to_phystype(ctx, val, &(disk->phystype));
+    disk->virtpath = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/dev", be_path));
+    val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/removable", be_path));
+    disk->unpluggable = !strcmp(val, "1");
+    val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/mode", be_path));
+    disk->readwrite = !!strcmp(val, "w");
+    val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/device-type", diskpath));
+    disk->is_cdrom = !strcmp(val, "cdrom");
+
+    return 0;
+}
diff --git a/tools/libxl/libxl_utils.h b/tools/libxl/libxl_utils.h
--- a/tools/libxl/libxl_utils.h
+++ b/tools/libxl/libxl_utils.h
@@ -61,6 +61,9 @@ int libxl_mac_to_device_nic(struct libxl
 int libxl_devid_to_device_nic(struct libxl_ctx *ctx, uint32_t domid,
                               const char *devid, libxl_device_nic *nic);
 
+int libxl_devid_to_device_disk(struct libxl_ctx *ctx, uint32_t domid,
+                               const char *devid, libxl_device_disk *disk);
+
 /* log levels: */
 #define XL_LOG_DEBUG 3
 #define XL_LOG_INFO 2
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -3348,3 +3348,37 @@ int main_blocklist(int argc, char **argv
     }
     exit(0);
 }
+
+int main_blockdetach(int argc, char **argv)
+{
+    int opt;
+    libxl_device_disk disk;
+
+    if (argc != 3) {
+        help("block-detach");
+        exit(0);
+    }
+    while ((opt = getopt(argc, argv, "h")) != -1) {
+        switch (opt) {
+        case 'h':
+            help("block-detach");
+            exit(0);
+        default:
+            fprintf(stderr, "option `%c' not supported.\n", opt);
+            break;
+        }
+    }
+
+    if (domain_qualifier_to_domid(argv[1], &domid, 0) < 0) {
+        fprintf(stderr, "%s is an invalid domain identifier\n", argv[1]);
+        exit(1);
+    }
+    if (libxl_devid_to_device_disk(&ctx, domid, argv[2], &disk)) {
+        fprintf(stderr, "Error: Device %s not connected.\n", argv[2]);
+        exit(1);
+    }
+    if (libxl_device_disk_del(&ctx, &disk, 1)) {
+        fprintf(stderr, "libxl_device_del failed.\n");
+    }
+    exit(0);
+}
diff --git a/tools/libxl/xl_cmdimpl.h b/tools/libxl/xl_cmdimpl.h
--- a/tools/libxl/xl_cmdimpl.h
+++ b/tools/libxl/xl_cmdimpl.h
@@ -44,5 +44,6 @@ int main_networklist(int argc, char **ar
 int main_networkdetach(int argc, char **argv);
 int main_blockattach(int argc, char **argv);
 int main_blocklist(int argc, char **argv);
+int main_blockdetach(int argc, char **argv);
 
 void help(char *command);
diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c
+++ b/tools/libxl/xl_cmdtable.c
@@ -192,6 +192,10 @@ struct cmd_spec cmd_table[] = {
       &main_blocklist,
       "List virtual block devices for a domain"
     },
+    { "block-detach",
+      &main_blockdetach,
+      "Destroy a domain's virtual block device"
+    },
 };
 
 int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1 of 6] xl: network-attach command
  2010-05-12 17:32 ` [PATCH 1 of 6] xl: network-attach command Eric Chanudet
@ 2010-05-13  0:45   ` Yang Hongyang
  2010-05-13 13:24     ` Eric Chanudet (Intern)
  0 siblings, 1 reply; 10+ messages in thread
From: Yang Hongyang @ 2010-05-13  0:45 UTC (permalink / raw)
  To: Eric Chanudet; +Cc: xen-devel

Hi Eric,

On 05/13/2010 01:32 AM, Eric Chanudet wrote:
> This patch adds network-attach command to xl.
> 
> Usage: xl network-attach <Domain> [type=<type>] [mac=<mac>] [bridge=<bridge>]
> [ip=<ip>] [script=<script>] [backend=<BackDomain>] [vifname=<name>]
> [rate=<rate>] [model=<model>][accel=<accel>]
> 
> rate and accel parameters are not handled for now.
> 
> diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
> --- a/tools/libxl/libxl.c
> +++ b/tools/libxl/libxl.c
> @@ -1420,6 +1420,8 @@ int libxl_device_nic_add(struct libxl_ct
>      unsigned int boffset = 0;
>      unsigned int foffset = 0;
>      libxl_device device;
> +    char *dompath, **l;
> +    unsigned int nb;
>  
>      front = flexarray_make(16, 1);
>      if (!front)
> @@ -1428,6 +1430,19 @@ int libxl_device_nic_add(struct libxl_ct
>      if (!back)
>          return ERROR_NOMEM;
>  
> +    if (nic->devid == -1) {
> +        if (!(dompath = libxl_xs_get_dompath(ctx, domid))) {
> +            return ERROR_FAIL;
> +        }
> +        if (!(l = libxl_xs_directory(ctx, XBT_NULL,
> +                                     libxl_sprintf(ctx, "%s/device/vif", dompath), &nb))) {
> +            nic->devid = 0;
> +        } else {
> +            nic->devid = strtoul(l[nb - 1], NULL, 10) + 1;
> +            libxl_free(ctx, l);
> +        }
> +    }
> +
>      device.backend_devid = nic->devid;
>      device.backend_domid = nic->backend_domid;
>      device.backend_kind = DEVICE_VIF;
> diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
> --- a/tools/libxl/xl_cmdimpl.c
> +++ b/tools/libxl/xl_cmdimpl.c
> @@ -573,7 +573,7 @@ static void parse_config_data(const char
>              char *buf2 = strdup(buf);
>              char *p, *p2;
>              *vifs = (libxl_device_nic *) realloc(*vifs, sizeof (libxl_device_nic) * ((*num_vifs) + 1));
> -            init_nic_info((*vifs) + (*num_vifs), (*num_vifs));
> +            init_nic_info((*vifs) + (*num_vifs), (*num_vifs) + 1);
>              p = strtok(buf2, ",");
>              if (!p)
>                  goto skip;
> @@ -3058,3 +3058,86 @@ int main_trigger(int argc, char **argv)
>  
>      exit(0);
>  }
> +
> +int main_networkattach(int argc, char **argv)
> +{
> +    int opt;
> +    libxl_device_nic nic;
> +    char *endptr, *tok;
> +    int i;
> +    unsigned int val;
> +
> +    if ((argc < 2) || (argc > 11)) {
> +        help("network-attach");
> +        exit(0);
> +    }
> +    while ((opt = getopt(argc, argv, "hl")) != -1) {
> +        switch (opt) {
> +        case 'h':
> +            help("network-attach");
> +            exit(0);
> +        default:
> +            fprintf(stderr, "option `%c' not supported.\n", opt);
> +            break;
> +        }
> +    }
> +
> +    if (domain_qualifier_to_domid(argv[1], &domid, 0) < 0) {
> +        fprintf(stderr, "%s is an invalid domain identifier\n", argv[1]);
> +        exit(1);
> +    }
> +    init_nic_info(&nic, -1);
> +    for (argv += 2, argc -= 2; argc > 0; ++argv, --argc) {
> +        if (!strncmp("type=", *argv, 5)) {
> +            if (!strncmp("vif", (*argv) + 5, 4)) {
> +                nic.nictype = NICTYPE_VIF;
> +            } else if (!strncmp("ioemu", (*argv) + 5, 5)) {
> +                nic.nictype = NICTYPE_IOEMU;
> +            } else {
> +                fprintf(stderr, "Invalid parameter `type'.\n");
> +                exit(1);
> +            }
> +        } else if (!strncmp("mac=", *argv, 4)) {
> +            tok = strtok((*argv) + 4, ":");
> +            for (i = 0; tok && i < 6; tok = strtok(NULL, ":"), ++i) {
> +                val = strtoul(tok, &endptr, 16);
> +                if ((tok == endptr) || (val > 255)) {
> +                    fprintf(stderr, "Invalid parameter `mac'.\n");
> +                    exit(1);
> +                }
> +                nic.mac[i] = val;
> +            }
> +        } else if (!strncmp("bridge=", *argv, 7)) {
> +            nic.bridge = (*argv) + 7;
> +        } else if (!strncmp("ip=", *argv, 3)) {
> +            if (!inet_aton((*argv) + 3, &(nic.ip))) {
> +                fprintf(stderr, "Invalid parameter `ip'.\n");
> +                exit(1);
> +            }
> +        } else if (!strncmp("script=", *argv, 6)) {
> +            nic.script = (*argv) + 6;
> +        } else if (!strncmp("backend=", *argv, 8)) {
> +            val = strtoul((*argv) + 8, &endptr, 10);
> +            if (((*argv) + 8) == endptr) {
> +                fprintf(stderr, "Invalid parameter `backend'.\n");
> +                exit(1);
> +            }
> +            nic.backend_domid = val;
> +        } else if (!strncmp("vifname=", *argv, 8)) {
> +            nic.ifname = (*argv) + 8;
> +        } else if (!strncmp("model=", *argv, 6)) {
> +            nic.model = (*argv) + 6;
> +        } else if (!strncmp("rate=", *argv, 5)) {
> +        } else if (!strncmp("accel=", *argv, 6)) {
> +        } else {
> +            fprintf(stderr, "unrecognized argument `%s'\n", *argv);
> +            exit(1);
> +        }
> +    }
> +    nic.domid = domid;
> +    if (libxl_device_nic_add(&ctx, domid, &nic)) {
> +        fprintf(stderr, "libxl_device_nic_add failed.\n");
> +        exit(1);
> +    }
> +    exit(0);
> +}
> diff --git a/tools/libxl/xl_cmdimpl.h b/tools/libxl/xl_cmdimpl.h
> --- a/tools/libxl/xl_cmdimpl.h
> +++ b/tools/libxl/xl_cmdimpl.h
> @@ -39,5 +39,6 @@ int main_domid(int argc, char **argv);
>  int main_domname(int argc, char **argv);
>  int main_rename(int argc, char **argv);
>  int main_trigger(int argc, char **argv);
> +int main_networkattach(int argc, char **argv);
>  
>  void help(char *command);
> diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c
> --- a/tools/libxl/xl_cmdtable.c
> +++ b/tools/libxl/xl_cmdtable.c
> @@ -172,6 +172,10 @@ struct cmd_spec cmd_table[] = {
>        "Send a trigger to a domain",
>        "<Domain> <nmi|reset|init|power|sleep> [<VCPU>]",
>      },
> +    { "network-attach",
> +      &main_networkattach,
> +      "Create a new virtual network device"

You forgot to add usage and options here:)

> +    },
>  };
>  
>  int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
> 
> 


-- 
Regards
Yang Hongyang

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [PATCH 1 of 6] xl: network-attach command
  2010-05-13  0:45   ` Yang Hongyang
@ 2010-05-13 13:24     ` Eric Chanudet (Intern)
  2010-05-14  0:40       ` Yang Hongyang
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Chanudet (Intern) @ 2010-05-13 13:24 UTC (permalink / raw)
  To: Yang Hongyang; +Cc: xen-devel@lists.xensource.com

On 05/13/2010 01:45 AM, Yang Hongyang wrote:
> On 05/13/2010 01:32 AM, Eric Chanudet wrote:
>> +    { "network-attach",
>> +      &main_networkattach,
>> +      "Create a new virtual network device"
>
>You forgot to add usage and options here:)
>
>> +    },

Sorry about this omission. Here is the refreshed patch, with usage, for network-attach command :

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -1420,6 +1420,8 @@ int libxl_device_nic_add(struct libxl_ct
     unsigned int boffset = 0;
     unsigned int foffset = 0;
     libxl_device device;
+    char *dompath, **l;
+    unsigned int nb;
 
     front = flexarray_make(16, 1);
     if (!front)
@@ -1428,6 +1430,19 @@ int libxl_device_nic_add(struct libxl_ct
     if (!back)
         return ERROR_NOMEM;
 
+    if (nic->devid == -1) {
+        if (!(dompath = libxl_xs_get_dompath(ctx, domid))) {
+            return ERROR_FAIL;
+        }
+        if (!(l = libxl_xs_directory(ctx, XBT_NULL,
+                                     libxl_sprintf(ctx, "%s/device/vif", dompath), &nb))) {
+            nic->devid = 0;
+        } else {
+            nic->devid = strtoul(l[nb - 1], NULL, 10) + 1;
+            libxl_free(ctx, l);
+        }
+    }
+
     device.backend_devid = nic->devid;
     device.backend_domid = nic->backend_domid;
     device.backend_kind = DEVICE_VIF;
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -573,7 +573,7 @@ static void parse_config_data(const char
             char *buf2 = strdup(buf);
             char *p, *p2;
             *vifs = (libxl_device_nic *) realloc(*vifs, sizeof (libxl_device_nic) * ((*num_vifs) + 1));
-            init_nic_info((*vifs) + (*num_vifs), (*num_vifs));
+            init_nic_info((*vifs) + (*num_vifs), (*num_vifs) + 1);
             p = strtok(buf2, ",");
             if (!p)
                 goto skip;
@@ -3058,3 +3058,86 @@ int main_trigger(int argc, char **argv)
 
     exit(0);
 }
+
+int main_networkattach(int argc, char **argv)
+{
+    int opt;
+    libxl_device_nic nic;
+    char *endptr, *tok;
+    int i;
+    unsigned int val;
+
+    if ((argc < 2) || (argc > 11)) {
+        help("network-attach");
+        exit(0);
+    }
+    while ((opt = getopt(argc, argv, "hl")) != -1) {
+        switch (opt) {
+        case 'h':
+            help("network-attach");
+            exit(0);
+        default:
+            fprintf(stderr, "option `%c' not supported.\n", opt);
+            break;
+        }
+    }
+
+    if (domain_qualifier_to_domid(argv[1], &domid, 0) < 0) {
+        fprintf(stderr, "%s is an invalid domain identifier\n", argv[1]);
+        exit(1);
+    }
+    init_nic_info(&nic, -1);
+    for (argv += 2, argc -= 2; argc > 0; ++argv, --argc) {
+        if (!strncmp("type=", *argv, 5)) {
+            if (!strncmp("vif", (*argv) + 5, 4)) {
+                nic.nictype = NICTYPE_VIF;
+            } else if (!strncmp("ioemu", (*argv) + 5, 5)) {
+                nic.nictype = NICTYPE_IOEMU;
+            } else {
+                fprintf(stderr, "Invalid parameter `type'.\n");
+                exit(1);
+            }
+        } else if (!strncmp("mac=", *argv, 4)) {
+            tok = strtok((*argv) + 4, ":");
+            for (i = 0; tok && i < 6; tok = strtok(NULL, ":"), ++i) {
+                val = strtoul(tok, &endptr, 16);
+                if ((tok == endptr) || (val > 255)) {
+                    fprintf(stderr, "Invalid parameter `mac'.\n");
+                    exit(1);
+                }
+                nic.mac[i] = val;
+            }
+        } else if (!strncmp("bridge=", *argv, 7)) {
+            nic.bridge = (*argv) + 7;
+        } else if (!strncmp("ip=", *argv, 3)) {
+            if (!inet_aton((*argv) + 3, &(nic.ip))) {
+                fprintf(stderr, "Invalid parameter `ip'.\n");
+                exit(1);
+            }
+        } else if (!strncmp("script=", *argv, 6)) {
+            nic.script = (*argv) + 6;
+        } else if (!strncmp("backend=", *argv, 8)) {
+            val = strtoul((*argv) + 8, &endptr, 10);
+            if (((*argv) + 8) == endptr) {
+                fprintf(stderr, "Invalid parameter `backend'.\n");
+                exit(1);
+            }
+            nic.backend_domid = val;
+        } else if (!strncmp("vifname=", *argv, 8)) {
+            nic.ifname = (*argv) + 8;
+        } else if (!strncmp("model=", *argv, 6)) {
+            nic.model = (*argv) + 6;
+        } else if (!strncmp("rate=", *argv, 5)) {
+        } else if (!strncmp("accel=", *argv, 6)) {
+        } else {
+            fprintf(stderr, "unrecognized argument `%s'\n", *argv);
+            exit(1);
+        }
+    }
+    nic.domid = domid;
+    if (libxl_device_nic_add(&ctx, domid, &nic)) {
+        fprintf(stderr, "libxl_device_nic_add failed.\n");
+        exit(1);
+    }
+    exit(0);
+}
diff --git a/tools/libxl/xl_cmdimpl.h b/tools/libxl/xl_cmdimpl.h
--- a/tools/libxl/xl_cmdimpl.h
+++ b/tools/libxl/xl_cmdimpl.h
@@ -39,5 +39,6 @@ int main_domid(int argc, char **argv);
 int main_domname(int argc, char **argv);
 int main_rename(int argc, char **argv);
 int main_trigger(int argc, char **argv);
+int main_networkattach(int argc, char **argv);
 
 void help(char *command);
diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c
+++ b/tools/libxl/xl_cmdtable.c
@@ -172,6 +172,14 @@ struct cmd_spec cmd_table[] = {
       "Send a trigger to a domain",
       "<Domain> <nmi|reset|init|power|sleep> [<VCPU>]",
     },
+    { "network-attach",
+      &main_networkattach,
+      "Create a new virtual network device",
+      "<Domain> [type=<type>] [mac=<mac>] [bridge=<bridge>]"
+      " [ip=<ip>] [script=<script>] [backend=<BackDomain>]"
+      " [vifname=<name>] [rate=<rate>] [model=<model>]"
+      " [accel=<accel>]",
+    },
 };
 
 int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);

-- 
Eric Chanudet

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1 of 6] xl: network-attach command
  2010-05-13 13:24     ` Eric Chanudet (Intern)
@ 2010-05-14  0:40       ` Yang Hongyang
  0 siblings, 0 replies; 10+ messages in thread
From: Yang Hongyang @ 2010-05-14  0:40 UTC (permalink / raw)
  To: Eric Chanudet (Intern); +Cc: xen-devel@lists.xensource.com

Hi Eric,
On 05/13/2010 09:24 PM, Eric Chanudet (Intern) wrote:
> On 05/13/2010 01:45 AM, Yang Hongyang wrote:
>> On 05/13/2010 01:32 AM, Eric Chanudet wrote:
>>> +    { "network-attach",
>>> +      &main_networkattach,
>>> +      "Create a new virtual network device"
>>
>> You forgot to add usage and options here:)
>>
>>> +    },
> 
> Sorry about this omission. Here is the refreshed patch, with usage, for network-attach command :

I saw that Keir has already fix that when applying your patch on staging tree.:)

> 
> diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
> --- a/tools/libxl/libxl.c
> +++ b/tools/libxl/libxl.c
> @@ -1420,6 +1420,8 @@ int libxl_device_nic_add(struct libxl_ct
>      unsigned int boffset = 0;
>      unsigned int foffset = 0;
>      libxl_device device;
> +    char *dompath, **l;
> +    unsigned int nb;
>  
>      front = flexarray_make(16, 1);
>      if (!front)
> @@ -1428,6 +1430,19 @@ int libxl_device_nic_add(struct libxl_ct
>      if (!back)
>          return ERROR_NOMEM;
>  
> +    if (nic->devid == -1) {
> +        if (!(dompath = libxl_xs_get_dompath(ctx, domid))) {
> +            return ERROR_FAIL;
> +        }
> +        if (!(l = libxl_xs_directory(ctx, XBT_NULL,
> +                                     libxl_sprintf(ctx, "%s/device/vif", dompath), &nb))) {
> +            nic->devid = 0;
> +        } else {
> +            nic->devid = strtoul(l[nb - 1], NULL, 10) + 1;
> +            libxl_free(ctx, l);
> +        }
> +    }
> +
>      device.backend_devid = nic->devid;
>      device.backend_domid = nic->backend_domid;
>      device.backend_kind = DEVICE_VIF;
> diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
> --- a/tools/libxl/xl_cmdimpl.c
> +++ b/tools/libxl/xl_cmdimpl.c
> @@ -573,7 +573,7 @@ static void parse_config_data(const char
>              char *buf2 = strdup(buf);
>              char *p, *p2;
>              *vifs = (libxl_device_nic *) realloc(*vifs, sizeof (libxl_device_nic) * ((*num_vifs) + 1));
> -            init_nic_info((*vifs) + (*num_vifs), (*num_vifs));
> +            init_nic_info((*vifs) + (*num_vifs), (*num_vifs) + 1);
>              p = strtok(buf2, ",");
>              if (!p)
>                  goto skip;
> @@ -3058,3 +3058,86 @@ int main_trigger(int argc, char **argv)
>  
>      exit(0);
>  }
> +
> +int main_networkattach(int argc, char **argv)
> +{
> +    int opt;
> +    libxl_device_nic nic;
> +    char *endptr, *tok;
> +    int i;
> +    unsigned int val;
> +
> +    if ((argc < 2) || (argc > 11)) {
> +        help("network-attach");
> +        exit(0);
> +    }
> +    while ((opt = getopt(argc, argv, "hl")) != -1) {
> +        switch (opt) {
> +        case 'h':
> +            help("network-attach");
> +            exit(0);
> +        default:
> +            fprintf(stderr, "option `%c' not supported.\n", opt);
> +            break;
> +        }
> +    }
> +
> +    if (domain_qualifier_to_domid(argv[1], &domid, 0) < 0) {
> +        fprintf(stderr, "%s is an invalid domain identifier\n", argv[1]);
> +        exit(1);
> +    }
> +    init_nic_info(&nic, -1);
> +    for (argv += 2, argc -= 2; argc > 0; ++argv, --argc) {
> +        if (!strncmp("type=", *argv, 5)) {
> +            if (!strncmp("vif", (*argv) + 5, 4)) {
> +                nic.nictype = NICTYPE_VIF;
> +            } else if (!strncmp("ioemu", (*argv) + 5, 5)) {
> +                nic.nictype = NICTYPE_IOEMU;
> +            } else {
> +                fprintf(stderr, "Invalid parameter `type'.\n");
> +                exit(1);
> +            }
> +        } else if (!strncmp("mac=", *argv, 4)) {
> +            tok = strtok((*argv) + 4, ":");
> +            for (i = 0; tok && i < 6; tok = strtok(NULL, ":"), ++i) {
> +                val = strtoul(tok, &endptr, 16);
> +                if ((tok == endptr) || (val > 255)) {
> +                    fprintf(stderr, "Invalid parameter `mac'.\n");
> +                    exit(1);
> +                }
> +                nic.mac[i] = val;
> +            }
> +        } else if (!strncmp("bridge=", *argv, 7)) {
> +            nic.bridge = (*argv) + 7;
> +        } else if (!strncmp("ip=", *argv, 3)) {
> +            if (!inet_aton((*argv) + 3, &(nic.ip))) {
> +                fprintf(stderr, "Invalid parameter `ip'.\n");
> +                exit(1);
> +            }
> +        } else if (!strncmp("script=", *argv, 6)) {
> +            nic.script = (*argv) + 6;
> +        } else if (!strncmp("backend=", *argv, 8)) {
> +            val = strtoul((*argv) + 8, &endptr, 10);
> +            if (((*argv) + 8) == endptr) {
> +                fprintf(stderr, "Invalid parameter `backend'.\n");
> +                exit(1);
> +            }
> +            nic.backend_domid = val;
> +        } else if (!strncmp("vifname=", *argv, 8)) {
> +            nic.ifname = (*argv) + 8;
> +        } else if (!strncmp("model=", *argv, 6)) {
> +            nic.model = (*argv) + 6;
> +        } else if (!strncmp("rate=", *argv, 5)) {
> +        } else if (!strncmp("accel=", *argv, 6)) {
> +        } else {
> +            fprintf(stderr, "unrecognized argument `%s'\n", *argv);
> +            exit(1);
> +        }
> +    }
> +    nic.domid = domid;
> +    if (libxl_device_nic_add(&ctx, domid, &nic)) {
> +        fprintf(stderr, "libxl_device_nic_add failed.\n");
> +        exit(1);
> +    }
> +    exit(0);
> +}
> diff --git a/tools/libxl/xl_cmdimpl.h b/tools/libxl/xl_cmdimpl.h
> --- a/tools/libxl/xl_cmdimpl.h
> +++ b/tools/libxl/xl_cmdimpl.h
> @@ -39,5 +39,6 @@ int main_domid(int argc, char **argv);
>  int main_domname(int argc, char **argv);
>  int main_rename(int argc, char **argv);
>  int main_trigger(int argc, char **argv);
> +int main_networkattach(int argc, char **argv);
>  
>  void help(char *command);
> diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c
> --- a/tools/libxl/xl_cmdtable.c
> +++ b/tools/libxl/xl_cmdtable.c
> @@ -172,6 +172,14 @@ struct cmd_spec cmd_table[] = {
>        "Send a trigger to a domain",
>        "<Domain> <nmi|reset|init|power|sleep> [<VCPU>]",
>      },
> +    { "network-attach",
> +      &main_networkattach,
> +      "Create a new virtual network device",
> +      "<Domain> [type=<type>] [mac=<mac>] [bridge=<bridge>]"
> +      " [ip=<ip>] [script=<script>] [backend=<BackDomain>]"
> +      " [vifname=<name>] [rate=<rate>] [model=<model>]"
> +      " [accel=<accel>]",
> +    },
>  };
>  
>  int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);
> 


-- 
Regards
Yang Hongyang

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-05-14  0:40 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-12 17:32 [PATCH 0 of 6] xl: network and block features Eric Chanudet
2010-05-12 17:32 ` [PATCH 1 of 6] xl: network-attach command Eric Chanudet
2010-05-13  0:45   ` Yang Hongyang
2010-05-13 13:24     ` Eric Chanudet (Intern)
2010-05-14  0:40       ` Yang Hongyang
2010-05-12 17:32 ` [PATCH 2 of 6] xl: network-list command Eric Chanudet
2010-05-12 17:32 ` [PATCH 3 of 6] xl: network-detach command Eric Chanudet
2010-05-12 17:32 ` [PATCH 4 of 6] xl: block-attach command Eric Chanudet
2010-05-12 17:32 ` [PATCH 5 of 6] xl: block-list command Eric Chanudet
2010-05-12 17:32 ` [PATCH 6 of 6] xl: block-detach command Eric Chanudet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).