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: Implement block-detach command

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xl: Implement block-detach command
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 14 May 2010 00:40:47 -0700
Delivery-date: Fri, 14 May 2010 00:43:31 -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 1273737167 -3600
# Node ID fa2f5dc5e0f98cdb3f6fdffb040f542eb8bb3026
# Parent  922962ef94c820cae4682b0f53948321f8c73db6
xl: Implement block-detach command

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

diff -r 922962ef94c8 -r fa2f5dc5e0f9 tools/libxl/libxl_utils.c
--- a/tools/libxl/libxl_utils.c Thu May 13 08:51:50 2010 +0100
+++ b/tools/libxl/libxl_utils.c Thu May 13 08:52:47 2010 +0100
@@ -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 -r 922962ef94c8 -r fa2f5dc5e0f9 tools/libxl/libxl_utils.h
--- a/tools/libxl/libxl_utils.h Thu May 13 08:51:50 2010 +0100
+++ b/tools/libxl/libxl_utils.h Thu May 13 08:52:47 2010 +0100
@@ -61,6 +61,9 @@ int libxl_devid_to_device_nic(struct lib
 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 -r 922962ef94c8 -r fa2f5dc5e0f9 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Thu May 13 08:51:50 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Thu May 13 08:52:47 2010 +0100
@@ -3461,3 +3461,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 -r 922962ef94c8 -r fa2f5dc5e0f9 tools/libxl/xl_cmdimpl.h
--- a/tools/libxl/xl_cmdimpl.h  Thu May 13 08:51:50 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.h  Thu May 13 08:52:47 2010 +0100
@@ -47,5 +47,6 @@ int main_networkdetach(int argc, char **
 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 -r 922962ef94c8 -r fa2f5dc5e0f9 tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c Thu May 13 08:51:50 2010 +0100
+++ b/tools/libxl/xl_cmdtable.c Thu May 13 08:52:47 2010 +0100
@@ -214,6 +214,11 @@ struct cmd_spec cmd_table[] = {
       "List virtual block devices for a domain",
       "<Domain(s)>",
     },
+    { "block-detach",
+      &main_blockdetach,
+      "Destroy a domain's virtual block 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: Implement block-detach command, Xen patchbot-unstable <=