From: Ian Campbell Subject: Re: [PATCH 8/9] xl: xl block-attach -N (dry run) option Date: Fri, 3 Jun 2011 11:46:48 +0100 Message-ID: <1307098008.775.368.camel@zakaz.uk.xensource.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> <1307037346-31251-9-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1307037346-31251-9-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: Ian Jackson Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org On Thu, 2011-06-02 at 18:55 +0100, Ian Jackson wrote: > @@ -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 */ What capabilities do you think we want here? Does it need to be human or machine readable or both? What should the syntax be? Do you think we want functions to get a string of any field or just the entire structure? In principal making the idl generator to this is pretty easy. However if what it produces is only useful to xl because other toolstacks need e.g. xml or json output (or just human syntax which matches their style) then I'm not sure what the best answer is. We could support multiple syntaxes is in libxl (_to_string, _to_xml, _to_json etc etc), supply an IDL driven pretty-printer-printer library (so toolstacks can easily write their own) or supply a libxl function which takes a callback fn "void fn(const char *field, const char *value)" etc. What do you think? (I think I lean towards the final option, unless a single hardcoded syntax is thought to be sufficient). > + /* 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); Am I being too picky if I say I prefer right aligned ='s ? Maybe we should have two pretty print functions ;-) Ian. > + 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"); > }