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] xl: network2-detach command

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xl: network2-detach command
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Sun, 06 Jun 2010 23:55:16 -0700
Delivery-date: Sun, 06 Jun 2010 23:56:13 -0700
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 1275891140 -3600
# Node ID 62447b8e0f2653aef259530c72504b1773135e66
# Parent  a08a8256e997cfbccca94d9470f44434ddbdd4a5
xl: network2-detach command

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

Signed-off-by: Eric Chanudet <eric.chanudet@xxxxxxxxxx>
---
 tools/libxl/libxl.c       |   14 +++++++++++++
 tools/libxl/libxl.h       |    2 +
 tools/libxl/libxl_utils.c |   48 ++++++++++++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl_utils.h |    3 ++
 tools/libxl/xl.h          |    1 
 tools/libxl/xl_cmdimpl.c  |   35 +++++++++++++++++++++++++++++++++
 tools/libxl/xl_cmdtable.c |    5 ++++
 7 files changed, 108 insertions(+)

diff -r a08a8256e997 -r 62447b8e0f26 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Mon Jun 07 07:11:15 2010 +0100
+++ b/tools/libxl/libxl.c       Mon Jun 07 07:12:20 2010 +0100
@@ -1754,6 +1754,20 @@ libxl_net2info *libxl_device_net2_list(s
 
     libxl_free(ctx, l);
     return res;
+}
+
+int libxl_device_net2_del(struct libxl_ctx *ctx, libxl_device_net2 *net2, int 
wait)
+{
+    libxl_device device;
+
+    device.backend_devid    = net2->devid;
+    device.backend_domid    = net2->backend_domid;
+    device.backend_kind     = DEVICE_VIF2;
+    device.devid            = net2->devid;
+    device.domid            = net2->domid;
+    device.kind             = DEVICE_VIF2;
+
+    return libxl_device_del(ctx, &device, wait);
 }
 
 
diff -r a08a8256e997 -r 62447b8e0f26 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Mon Jun 07 07:11:15 2010 +0100
+++ b/tools/libxl/libxl.h       Mon Jun 07 07:12:20 2010 +0100
@@ -571,6 +571,8 @@ int libxl_device_net2_add(struct libxl_c
                           libxl_device_net2 *net2);
 libxl_net2info *libxl_device_net2_list(struct libxl_ctx *ctx, uint32_t domid,
                                        unsigned int *nb);
+int libxl_device_net2_del(struct libxl_ctx *ctx, libxl_device_net2 *net2,
+                          int wait);
 
 /* common paths */
 const char *libxl_sbindir_path(void);
diff -r a08a8256e997 -r 62447b8e0f26 tools/libxl/libxl_utils.c
--- a/tools/libxl/libxl_utils.c Mon Jun 07 07:11:15 2010 +0100
+++ b/tools/libxl/libxl_utils.c Mon Jun 07 07:12:20 2010 +0100
@@ -468,6 +468,54 @@ int libxl_devid_to_device_disk(struct li
     return 0;
 }
 
+int libxl_devid_to_device_net2(struct libxl_ctx *ctx, uint32_t domid,
+                               const char *devid, libxl_device_net2 *net2)
+{
+    char *tok, *endptr, *val;
+    char *dompath, *net2path, *be_path;
+    unsigned int devid_n, i;
+
+    devid_n = strtoul(devid, &endptr, 10);
+    if (devid == endptr) {
+        return ERROR_INVAL;
+    }
+    dompath = libxl_xs_get_dompath(ctx, domid);
+    net2path = libxl_sprintf(ctx, "%s/device/vif2/%s", dompath, devid);
+    if (!net2path) {
+        return ERROR_FAIL;
+    }
+    memset(net2, 0, sizeof (libxl_device_net2));
+    be_path = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/backend", 
net2path));
+
+    net2->devid = devid_n;
+    val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/mac", net2path));
+    for (i = 0, tok = strtok(val, ":"); tok && (i < 6);
+         ++i, tok = strtok(NULL, ":")) {
+        net2->front_mac[i] = strtoul(tok, NULL, 16);
+    }
+    val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/remote-mac", 
net2path));
+    for (i = 0, tok = strtok(val, ":"); tok && (i < 6);
+         ++i, tok = strtok(NULL, ":")) {
+        net2->back_mac[i] = strtoul(tok, NULL, 16);
+    }
+    val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/backend-id", 
net2path));
+    net2->backend_domid = strtoul(val, NULL, 10);
+
+    net2->domid = domid;
+    val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/remote-trusted", 
be_path));
+    net2->trusted = strtoul(val, NULL, 10);
+    val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/local-trusted", 
be_path));
+    net2->back_trusted = strtoul(val, NULL, 10);
+    val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/filter-mac", 
be_path));
+    net2->filter_mac = strtoul(val, NULL, 10);
+    val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/filter-mac", 
net2path));
+    net2->front_filter_mac = strtoul(val, NULL, 10);
+    val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/max-bypasses", 
be_path));
+    net2->max_bypasses = strtoul(val, NULL, 10);
+
+    return 0;
+}
+
 int libxl_strtomac(const char *mac_s, uint8_t *mac)
 {
     const char *end = mac_s + 17;
diff -r a08a8256e997 -r 62447b8e0f26 tools/libxl/libxl_utils.h
--- a/tools/libxl/libxl_utils.h Mon Jun 07 07:11:15 2010 +0100
+++ b/tools/libxl/libxl_utils.h Mon Jun 07 07:12:20 2010 +0100
@@ -65,5 +65,8 @@ int libxl_devid_to_device_disk(struct li
 
 int libxl_strtomac(const char *mac_s, uint8_t *mac);
 
+int libxl_devid_to_device_net2(struct libxl_ctx *ctx, uint32_t domid,
+                               const char *devid, libxl_device_net2 *net2);
+
 #endif
 
diff -r a08a8256e997 -r 62447b8e0f26 tools/libxl/xl.h
--- a/tools/libxl/xl.h  Mon Jun 07 07:11:15 2010 +0100
+++ b/tools/libxl/xl.h  Mon Jun 07 07:12:20 2010 +0100
@@ -74,6 +74,7 @@ int main_tmem_shared_auth(int argc, char
 int main_tmem_shared_auth(int argc, char **argv);
 int main_network2attach(int argc, char **argv);
 int main_network2list(int argc, char **argv);
+int main_network2detach(int argc, char **argv);
 
 void help(char *command);
 
diff -r a08a8256e997 -r 62447b8e0f26 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Mon Jun 07 07:11:15 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Mon Jun 07 07:12:20 2010 +0100
@@ -3922,6 +3922,41 @@ int main_network2list(int argc, char **a
     exit(0);
 }
 
+int main_network2detach(int argc, char **argv)
+{
+    int opt;
+    libxl_device_net2 net2;
+
+    if (argc != 4) {
+        help("network2-detach");
+        exit(0);
+    }
+    while ((opt = getopt(argc, argv, "h")) != -1) {
+        switch (opt) {
+        case 'h':
+            help("network2-detach");
+            exit(0);
+        default:
+            fprintf(stderr, "option `%c' not supported.\n", opt);
+            break;
+        }
+    }
+
+    if (domain_qualifier_to_domid(argv[2], &domid, 0) < 0) {
+        fprintf(stderr, "%s is an invalid domain identifier\n", argv[2]);
+        exit(1);
+    }
+    if (libxl_devid_to_device_net2(&ctx, domid, argv[3], &net2)) {
+       fprintf(stderr, "Error: Device %s not connected.\n", argv[3]);
+        exit(1);
+    }
+    if (libxl_device_net2_del(&ctx, &net2, 1)) {
+        fprintf(stderr, "libxl_device_net2_del failed.\n");
+        exit(1);
+    }
+    exit(0);
+}
+
 static char *uptime_to_string(unsigned long time, int short_mode)
 {
     int sec, min, hour, day;
diff -r a08a8256e997 -r 62447b8e0f26 tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c Mon Jun 07 07:11:15 2010 +0100
+++ b/tools/libxl/xl_cmdtable.c Mon Jun 07 07:12:20 2010 +0100
@@ -300,6 +300,11 @@ struct cmd_spec cmd_table[] = {
       "list version 2 virtual network interfaces for a domain",
       "<Domain(s)>",
     },
+    { "network2-detach",
+      &main_network2detach,
+      "destroy a domain's version 2 virtual network device",
+      "<Domain> <DevId>",
+    },
 };
 
 int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);

_______________________________________________
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] xl: network2-detach command, Xen patchbot-unstable <=