From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xensource.com
Cc: Ian Jackson <ijackson@chiark.greenend.org.uk>
Subject: [PATCH 12/14] xl: disks: replace block-attach disk config parser with call to xlu_parse_disk
Date: Thu, 12 May 2011 15:36:42 +0100 [thread overview]
Message-ID: <1305211004-31687-13-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1305211004-31687-12-git-send-email-ian.jackson@eu.citrix.com>
From: Ian Jackson <ijackson@chiark.greenend.org.uk>
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
---
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
next prev parent reply other threads:[~2011-05-12 14:36 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-12 14:36 [PATCH/RFC 00/14] libxl: disk configuration handling Ian Jackson
2011-05-12 14:36 ` [PATCH 01/14] libxl: add missing copyright notices to some files Ian Jackson
2011-05-12 14:36 ` [PATCH 02/14] libxl: add missing copyright notices to autogenerated files Ian Jackson
2011-05-12 14:36 ` [PATCH 03/14] libxl: provide TOSTRING in libxl_internal.h and libxlu_internal.h Ian Jackson
2011-05-12 14:36 ` [PATCH 04/14] libxl: make libxl_ctx_free tolerate NULL ctx argument Ian Jackson
2011-05-12 14:36 ` [PATCH 05/14] libxl: disks: expose new "script" parameter for external block scripts Ian Jackson
2011-05-12 14:36 ` [PATCH 06/14] libxl: disks: rename disk param "unpluggable" to "removable" Ian Jackson
2011-05-12 14:36 ` [PATCH 07/14] libxl: disks: Make LIBXL_DISK_BACKEND_UNKNOWN work Ian Jackson
2011-05-12 14:36 ` [PATCH 08/14] libxl: disks: new xlu_disk_parse function Ian Jackson
2011-05-12 14:36 ` [PATCH 09/14] libxl: disks: commit libxlu_disk_l.[ch] flex output Ian Jackson
2011-05-12 14:36 ` [PATCH 10/14] docs: update xl-disk-configuration.txt to describe new syntax Ian Jackson
2011-05-12 14:36 ` [PATCH 11/14] xl: disks: replace config file disk spec parser with call to xlu_disk_parse Ian Jackson
2011-05-12 14:36 ` Ian Jackson [this message]
2011-05-12 14:36 ` [PATCH 13/14] libxl: disks: allow specification of "backendtype=phy|tap|qdisk" Ian Jackson
2011-05-12 14:36 ` [PATCH 14/14] xl: xl block-attach -N (dry run) option Ian Jackson
2011-05-13 12:56 ` Ian Campbell
2011-05-13 12:53 ` [PATCH 13/14] libxl: disks: allow specification of "backendtype=phy|tap|qdisk" Ian Campbell
2011-06-02 16:57 ` Ian Jackson
2011-05-12 14:42 ` [PATCH 12/14] xl: disks: replace block-attach disk config parser with call to xlu_parse_disk Ian Jackson
2011-05-13 12:50 ` Ian Campbell
2011-05-13 12:49 ` [PATCH 11/14] xl: disks: replace config file disk spec parser with call to xlu_disk_parse Ian Campbell
2011-05-13 12:45 ` [PATCH 10/14] docs: update xl-disk-configuration.txt to describe new syntax Ian Campbell
2011-05-18 10:31 ` Ian Jackson
2011-05-20 9:27 ` Ian Campbell
2011-05-20 10:21 ` Ian Jackson
2011-05-20 10:26 ` Ian Campbell
2011-05-13 10:49 ` [PATCH 09/14] libxl: disks: commit libxlu_disk_l.[ch] flex output Ian Campbell
2011-05-13 10:48 ` [PATCH 08/14] libxl: disks: new xlu_disk_parse function Ian Campbell
2011-06-02 16:50 ` Ian Jackson
2011-05-13 10:38 ` [PATCH 07/14] libxl: disks: Make LIBXL_DISK_BACKEND_UNKNOWN work Ian Campbell
2011-06-02 16:48 ` Ian Jackson
2011-05-13 10:36 ` [PATCH 06/14] libxl: disks: rename disk param "unpluggable" to "removable" Ian Campbell
2011-05-13 10:35 ` [PATCH 05/14] libxl: disks: expose new "script" parameter for external block scripts Ian Campbell
2011-06-02 16:48 ` Ian Jackson
2011-05-13 10:33 ` [PATCH/RFC 00/14] libxl: disk configuration handling Ian Campbell
2011-06-02 16:57 ` Ian Jackson
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=1305211004-31687-13-git-send-email-ian.jackson@eu.citrix.com \
--to=ian.jackson@eu.citrix.com \
--cc=ijackson@chiark.greenend.org.uk \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).