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 4/5] xl block-attach refactoring to reuse xl parsing c

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [xen-devel][PATCH 4/5] xl block-attach refactoring to reuse xl parsing code
From: Kamala Narasimhan <kamala.narasimhan@xxxxxxxxx>
Date: Mon, 07 Feb 2011 16:53:23 -0500
Delivery-date: Mon, 07 Feb 2011 13:55:17 -0800
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :subject:content-type; bh=hQnGOLhYuhkdsU5iyV13IWC+5qJ/J7Ac2Nn9701CznE=; b=OoL1P4wT3YXLrneFJOo8UqCaTOHidMJJR15SkGb+9lmV1e37jIwMPgaDItgjrfUShy rjrJ64gZ5wLPGLPFBr0pi1T7Vgg6OOm3YMo0AU/6R+POEa7AGMV+hte/bzjehbXqfqmW ErnKYgXkGg+tI0o2Atcg2ZTnoJtpTbWHZpqcs=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type; b=beF5zoRjFYnjR7wTTCcl9BbFzcJT0oKq/j2tOsUYF728Bd0twUMWJIXTf5P/kUhzgu vLHFmtunrXU/Y1hIDszphilCcNU8n9yGsKi73RgkXanRrRqy/MtV58THCTbJcGqN7DGi bK8IWiU19xNgJQa2uqpgJT1T0Ymq4AvPyFV+0=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.24 (X11/20101027)
Attached changes reuse disk parsing code for block-attach.

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

Kamala
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]);
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>