From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Jackson Subject: [PATCH 8/9] xl: xl block-attach -N (dry run) option Date: Thu, 2 Jun 2011 18:55:45 +0100 Message-ID: <1307037346-31251-9-git-send-email-ian.jackson@eu.citrix.com> References: <1307037346-31251-1-git-send-email-ian.jackson@eu.citrix.com> <1307037346-31251-2-git-send-email-ian.jackson@eu.citrix.com> <1307037346-31251-3-git-send-email-ian.jackson@eu.citrix.com> <1307037346-31251-4-git-send-email-ian.jackson@eu.citrix.com> <1307037346-31251-5-git-send-email-ian.jackson@eu.citrix.com> <1307037346-31251-6-git-send-email-ian.jackson@eu.citrix.com> <1307037346-31251-7-git-send-email-ian.jackson@eu.citrix.com> <1307037346-31251-8-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: In-Reply-To: <1307037346-31251-8-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: Ian Jackson , Ian Jackson List-Id: xen-devel@lists.xenproject.org This is mainly for debugging purposes at the moment. Eventually I hope all commands will gain this so that -N will be a global option. In the meantime this new option is not documented and should be regarded as unstable. Signed-off-by: Ian Jackson --- tools/libxl/xl_cmdimpl.c | 34 +++++++++++++++++++++++++++++++--- 1 files changed, 31 insertions(+), 3 deletions(-) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index d2e343d..ac6d719 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -4018,13 +4018,25 @@ int main_networkdetach(int argc, char **argv) int main_blockattach(int argc, char **argv) { - int opt; + int opt, dry_run = 0; 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; + while ((opt = getopt(argc, argv, "Nh")) != -1) { + switch (opt) { + case 'N': + /* fixme this should become a global option eventually */ + dry_run = 1; + break; + case 'h': + help("block-attach"); + return 0; + default: + fprintf(stderr, "option `%c' not supported.\n", optopt); + break; + } + } if ((argc-optind < 2)) { help("block-attach"); return 2; @@ -4041,6 +4053,22 @@ int main_blockattach(int argc, char **argv) disk.backend_domid = be_domid; + if (dry_run) { + /* fixme: this should be generated from the idl */ + /* fixme: enums (backend, format) should be converted to strings */ + printf("disk.backend_domid = %"PRIx32"\n", disk.backend_domid); + printf("disk.pdev_path = %s\n", disk.pdev_path); + printf("disk.vdev = %s\n", disk.vdev); + printf("disk.backend = %d\n", disk.backend); + printf("disk.format = %d\n", disk.format); + printf("disk.script = %s\n", disk.script); + printf("disk.removable = %d\n", disk.removable); + printf("disk.readwrite = %d\n", disk.readwrite); + printf("disk.is_cdrom = %d\n", disk.is_cdrom); + if (ferror(stdout) || fflush(stdout)) { perror("stdout"); exit(-1); } + return 0; + } + if (libxl_device_disk_add(ctx, fe_domid, &disk)) { fprintf(stderr, "libxl_device_disk_add failed.\n"); } -- 1.5.6.5