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-devel

[Xen-devel] [PATCH 12/14] xl: disks: replace block-attach disk config pa

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 12/14] xl: disks: replace block-attach disk config parser with call to xlu_parse_disk
From: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Date: Thu, 12 May 2011 15:36:42 +0100
Cc: Ian Jackson <ijackson@xxxxxxxxxxxxxxxxxxxxxx>
Delivery-date: Thu, 12 May 2011 07:46:28 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1305211004-31687-12-git-send-email-ian.jackson@xxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <1305211004-31687-1-git-send-email-ian.jackson@xxxxxxxxxxxxx> <1305211004-31687-2-git-send-email-ian.jackson@xxxxxxxxxxxxx> <1305211004-31687-3-git-send-email-ian.jackson@xxxxxxxxxxxxx> <1305211004-31687-4-git-send-email-ian.jackson@xxxxxxxxxxxxx> <1305211004-31687-5-git-send-email-ian.jackson@xxxxxxxxxxxxx> <1305211004-31687-6-git-send-email-ian.jackson@xxxxxxxxxxxxx> <1305211004-31687-7-git-send-email-ian.jackson@xxxxxxxxxxxxx> <1305211004-31687-8-git-send-email-ian.jackson@xxxxxxxxxxxxx> <1305211004-31687-9-git-send-email-ian.jackson@xxxxxxxxxxxxx> <1305211004-31687-10-git-send-email-ian.jackson@xxxxxxxxxxxxx> <1305211004-31687-11-git-send-email-ian.jackson@xxxxxxxxxxxxx> <1305211004-31687-12-git-send-email-ian.jackson@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
From: Ian Jackson <ijackson@xxxxxxxxxxxxxxxxxxxxxx>

Signed-off-by: Ian Jackson <ijackson@xxxxxxxxxxxxxxxxxxxxxx>
---
 tools/libxl/xl_cmdimpl.c  |   50 ++++++--------------------------------------
 tools/libxl/xl_cmdtable.c |    2 +-
 2 files changed, 8 insertions(+), 44 deletions(-)

diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index b083e4d..ccffd26 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -3931,62 +3931,26 @@ int main_networkdetach(int argc, char **argv)
 int main_blockattach(int argc, char **argv)
 {
     int opt;
-    const char *tok;
     uint32_t fe_domid, be_domid = 0;
     libxl_device_disk disk = { 0 };
+    XLU_Config *config = 0;
 
     if ((opt = def_getopt(argc, argv, "", "block-attach", 2)) != -1)
         return opt;
-    if (argc-optind > 5) {
+    if ((argc-optind < 2)) {
         help("block-attach");
         return 2;
     }
 
-    tok = strtok(argv[optind+1], ":");
-    if (!strcmp(tok, "phy")) {
-        disk.backend = LIBXL_DISK_BACKEND_PHY;
-    } else if (!strcmp(tok, "file")) {
-        disk.backend = LIBXL_DISK_BACKEND_TAP;
-    } else if (!strcmp(tok, "tap")) {
-        tok = strtok(NULL, ":");
-        if (!strcmp(tok, "aio")) {
-            disk.backend = LIBXL_DISK_BACKEND_TAP;
-        } else if (!strcmp(tok, "vhd")) {
-            disk.format = LIBXL_DISK_FORMAT_VHD;
-            disk.backend = LIBXL_DISK_BACKEND_TAP;
-        } else if (!strcmp(tok, "qcow")) {
-            disk.format = LIBXL_DISK_FORMAT_QCOW;
-            disk.backend = LIBXL_DISK_BACKEND_QDISK;
-        } else if (!strcmp(tok, "qcow2")) {
-            disk.format = LIBXL_DISK_FORMAT_QCOW2;
-            disk.backend = LIBXL_DISK_BACKEND_QDISK;
-        } else {
-            fprintf(stderr, "Error: `%s' is not a valid disk image.\n", tok);
-            return 1;
-        }
-    } else {
-        fprintf(stderr, "Error: `%s' is not a valid block device.\n", tok);
-        return 1;
-    }
-    disk.pdev_path = strtok(NULL, "\0");
-    if (!disk.pdev_path) {
-        fprintf(stderr, "Error: missing path to disk image.\n");
-        return 1;
-    }
-    disk.vdev = argv[optind+2];
-    disk.removable = 1;
-    disk.readwrite = ((argc-optind <= 3) || (argv[optind+3][0] == 'w'));
-
     if (domain_qualifier_to_domid(argv[optind], &fe_domid, 0) < 0) {
         fprintf(stderr, "%s is an invalid domain identifier\n", argv[optind]);
         return 1;
     }
-    if (argc-optind == 5) {
-        if (domain_qualifier_to_domid(argv[optind+4], &be_domid, 0) < 0) {
-            fprintf(stderr, "%s is an invalid domain identifier\n", 
argv[optind+4]);
-            return 1;
-        }
-    }
+    optind++;
+
+    parse_disk_config_multistring
+        (&config, argc-optind, (const char* const*)argv + optind, &disk);
+
     disk.backend_domid = be_domid;
 
     if (libxl_device_disk_add(ctx, fe_domid, &disk)) {
diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c
index b14fb37..b7ee0f4 100644
--- a/tools/libxl/xl_cmdtable.c
+++ b/tools/libxl/xl_cmdtable.c
@@ -256,7 +256,7 @@ struct cmd_spec cmd_table[] = {
     { "block-attach",
       &main_blockattach,
       "Create a new virtual block device",
-      "<Domain> <BackDev> <FrontDev> [<Mode>] [BackDomain]",
+      "<Domain> <disk-spec-component(s)>...",
     },
     { "block-list",
       &main_blocklist,
-- 
1.7.2.5


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>