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] xl: replace block-attach disk config parser with cal

From: Ian Jackson <ijackson@xxxxxxxxxxxxxxxxxxxxxx>

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

diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 416de46..b1bc724 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -4281,9 +4281,9 @@ 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;
 
     while ((opt = getopt(argc, argv, "h")) != -1) {
         switch (opt) {
@@ -4300,40 +4300,7 @@ int main_blockattach(int argc, char **argv)
         return 0;
     }
 
-    tok = strtok(argv[optind+1], ":");
-    if (!strcmp(tok, "phy")) {
-        disk.backend = DISK_BACKEND_PHY;
-    } else if (!strcmp(tok, "file")) {
-        disk.backend = DISK_BACKEND_TAP;
-    } else if (!strcmp(tok, "tap")) {
-        tok = strtok(NULL, ":");
-        if (!strcmp(tok, "aio")) {
-            disk.backend = DISK_BACKEND_TAP;
-        } else if (!strcmp(tok, "vhd")) {
-            disk.format = DISK_FORMAT_VHD;
-            disk.backend = DISK_BACKEND_TAP;
-        } else if (!strcmp(tok, "qcow")) {
-            disk.format = DISK_FORMAT_QCOW;
-            disk.backend = DISK_BACKEND_QDISK;
-        } else if (!strcmp(tok, "qcow2")) {
-            disk.format = DISK_FORMAT_QCOW2;
-            disk.backend = 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.unpluggable = 1;
-    disk.readwrite = ((argc-optind <= 3) || (argv[optind+3][0] == 'w'));
+    parse_disk_config(&config, &disk, argv[optind+1]);
 
     if (domain_qualifier_to_domid(argv[optind], &fe_domid, 0) < 0) {
         fprintf(stderr, "%s is an invalid domain identifier\n", argv[optind]);
-- 
1.5.6.5


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