All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kamala Narasimhan <kamala.narasimhan@gmail.com>
To: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: [PATCH 4/5] xl block-attach refactoring to reuse xl parsing code
Date: Mon, 07 Feb 2011 16:53:23 -0500	[thread overview]
Message-ID: <4D5069D3.4020206@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 132 bytes --]

Attached changes reuse disk parsing code for block-attach.

Signed-off-by: Kamala Narasimhan <kamala.narasimhan@citrix.com>

Kamala

[-- Attachment #2: xl-disk-block-attach.diff --]
[-- Type: text/x-diff, Size: 2248 bytes --]

diff -r -u libxl-parsing-changes/xl_cmdimpl.c libxl/xl_cmdimpl.c
--- libxl-parsing-changes/xl_cmdimpl.c	2011-02-07 16:25:11.000000000 -0500
+++ libxl/xl_cmdimpl.c	2011-02-07 16:45:07.000000000 -0500
@@ -4408,8 +4408,7 @@
 
 int main_blockattach(int argc, char **argv)
 {
-    int opt;
-    const char *tok;
+    int opt, ret_val;
     uint32_t fe_domid, be_domid = 0;
     libxl_device_disk disk = { 0 };
 
@@ -4428,40 +4427,15 @@
         return 0;
     }
 
-    tok = strtok(argv[optind+1], ":");
-    if (!strcmp(tok, "phy")) {
-        disk.backend = DISK_BACKEND_BLKBACK;
-    } else if (!strcmp(tok, "file")) {
-        disk.backend = DISK_BACKEND_TAPDISK2;
-    } else if (!strcmp(tok, "tap")) {
-        tok = strtok(NULL, ":");
-        if (!strcmp(tok, "aio")) {
-            disk.backend = DISK_BACKEND_TAPDISK2;
-        } else if (!strcmp(tok, "vhd")) {
-            disk.format = DISK_FORMAT_VHD;
-            disk.backend = DISK_BACKEND_TAPDISK2;
-        } else if (!strcmp(tok, "qcow")) {
-            disk.format = DISK_FORMAT_QCOW;
-            disk.backend = DISK_BACKEND_QEMU;
-        } else if (!strcmp(tok, "qcow2")) {
-            disk.format = DISK_FORMAT_QCOW2;
-            disk.backend = DISK_BACKEND_QEMU;
-        } 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'));
+    ret_val = parse_disk_pdev_info(&disk, argv[optind+1]);
+    if ( ret_val )
+        return ret_val; 
+    ret_val = parse_disk_vdev_info(&disk, argv[optind+2]); 
+    if ( ret_val )
+        return ret_val; 
+    ret_val = parse_disk_attrib(&disk, argv[optind+3]);
+    if ( ret_val ) 
+        return ret_val;
 
     if (domain_qualifier_to_domid(argv[optind], &fe_domid, 0) < 0) {
         fprintf(stderr, "%s is an invalid domain identifier\n", argv[optind]);

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

             reply	other threads:[~2011-02-07 21:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-07 21:53 Kamala Narasimhan [this message]
2011-02-08 16:44 ` [PATCH 4/5] xl block-attach refactoring to reuse xl parsing code Stefano Stabellini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D5069D3.4020206@gmail.com \
    --to=kamala.narasimhan@gmail.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.