Ian Campbell
2012-Nov-20 17:23 UTC
[PATCH 02 of 15] libxl: Add LIBXL_SHUTDOWN_REASON_UNKNOWN
# HG changeset patch # User Ian Campbell <ijc@hellion.org.uk> # Date 1353432141 0 # Node ID 8195cb0ebac691ae94e97939362f4d345891b4a7 # Parent 601dc257a740d3a6047667731007283a4dcb9600 libxl: Add LIBXL_SHUTDOWN_REASON_UNKNOWN libxl_dominfo.shutdown_reason is valid iff (shutdown||dying). This is a bit annoying when generating language bindings since it needs all sorts of special casing. Just introduce an explicit value instead. Signed-off-by: Ian Campbell <ian.cambell@citrix.com> diff -r 601dc257a740 -r 8195cb0ebac6 tools/libxl/libxl.c --- a/tools/libxl/libxl.c Tue Nov 20 17:22:16 2012 +0000 +++ b/tools/libxl/libxl.c Tue Nov 20 17:22:21 2012 +0000 @@ -526,7 +526,7 @@ static void xcinfo2xlinfo(const xc_domai if (xlinfo->shutdown || xlinfo->dying) xlinfo->shutdown_reason = (xcinfo->flags>>XEN_DOMINF_shutdownshift) & XEN_DOMINF_shutdownmask; else - xlinfo->shutdown_reason = ~0; + xlinfo->shutdown_reason = LIBXL_SHUTDOWN_REASON_UNKNOWN; xlinfo->current_memkb = PAGE_TO_MEMKB(xcinfo->tot_pages); xlinfo->shared_memkb = PAGE_TO_MEMKB(xcinfo->shr_pages); diff -r 601dc257a740 -r 8195cb0ebac6 tools/libxl/libxl_types.idl --- a/tools/libxl/libxl_types.idl Tue Nov 20 17:22:16 2012 +0000 +++ b/tools/libxl/libxl_types.idl Tue Nov 20 17:22:21 2012 +0000 @@ -118,14 +118,15 @@ libxl_scheduler = Enumeration("scheduler (7, "arinc653"), ]) -# Consistent with SHUTDOWN_* in sched.h +# Consistent with SHUTDOWN_* in sched.h (apart from UNKNOWN) libxl_shutdown_reason = Enumeration("shutdown_reason", [ + (-1, "unknown"), (0, "poweroff"), (1, "reboot"), (2, "suspend"), (3, "crash"), (4, "watchdog"), - ]) + ], init_val = "LIBXL_SHUTDOWN_REASON_UNKNOWN") libxl_vga_interface_type = Enumeration("vga_interface_type", [ (1, "CIRRUS"),
Rob Hoes
2012-Nov-26 14:18 UTC
Re: [PATCH 02 of 15] libxl: Add LIBXL_SHUTDOWN_REASON_UNKNOWN
> # HG changeset patch > # User Ian Campbell <ijc@hellion.org.uk> # Date 1353432141 0 # Node ID > 8195cb0ebac691ae94e97939362f4d345891b4a7 > # Parent 601dc257a740d3a6047667731007283a4dcb9600 > libxl: Add LIBXL_SHUTDOWN_REASON_UNKNOWN > > libxl_dominfo.shutdown_reason is valid iff (shutdown||dying). This is a bit > annoying when generating language bindings since it needs all sorts of > special casing. Just introduce an explicit value instead.I have a patch in my queue that is almost identical to this one, for exactly this reason. It is very handy for the ocaml binding to have all possible values of an enum explicitly defined in this way. Cheers, Rob> Signed-off-by: Ian Campbell <ian.cambell@citrix.com> > > diff -r 601dc257a740 -r 8195cb0ebac6 tools/libxl/libxl.c > --- a/tools/libxl/libxl.c Tue Nov 20 17:22:16 2012 +0000 > +++ b/tools/libxl/libxl.c Tue Nov 20 17:22:21 2012 +0000 > @@ -526,7 +526,7 @@ static void xcinfo2xlinfo(const xc_domai > if (xlinfo->shutdown || xlinfo->dying) > xlinfo->shutdown_reason = (xcinfo- > >flags>>XEN_DOMINF_shutdownshift) & XEN_DOMINF_shutdownmask; > else > - xlinfo->shutdown_reason = ~0; > + xlinfo->shutdown_reason = LIBXL_SHUTDOWN_REASON_UNKNOWN; > > xlinfo->current_memkb = PAGE_TO_MEMKB(xcinfo->tot_pages); > xlinfo->shared_memkb = PAGE_TO_MEMKB(xcinfo->shr_pages); diff -r > 601dc257a740 -r 8195cb0ebac6 tools/libxl/libxl_types.idl > --- a/tools/libxl/libxl_types.idl Tue Nov 20 17:22:16 2012 +0000 > +++ b/tools/libxl/libxl_types.idl Tue Nov 20 17:22:21 2012 +0000 > @@ -118,14 +118,15 @@ libxl_scheduler = Enumeration("scheduler > (7, "arinc653"), > ]) > > -# Consistent with SHUTDOWN_* in sched.h > +# Consistent with SHUTDOWN_* in sched.h (apart from UNKNOWN) > libxl_shutdown_reason = Enumeration("shutdown_reason", [ > + (-1, "unknown"), > (0, "poweroff"), > (1, "reboot"), > (2, "suspend"), > (3, "crash"), > (4, "watchdog"), > - ]) > + ], init_val = "LIBXL_SHUTDOWN_REASON_UNKNOWN") > > libxl_vga_interface_type = Enumeration("vga_interface_type", [ > (1, "CIRRUS"), > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel
Rob Hoes
2012-Nov-29 16:23 UTC
Re: [PATCH 02 of 15] libxl: Add LIBXL_SHUTDOWN_REASON_UNKNOWN
> libxl: Add LIBXL_SHUTDOWN_REASON_UNKNOWN > > libxl_dominfo.shutdown_reason is valid iff (shutdown||dying). This is a bit > annoying when generating language bindings since it needs all sorts of > special casing. Just introduce an explicit value instead. > > Signed-off-by: Ian Campbell <ian.cambell@citrix.com>This change is very useful from an ocaml-bindings point of view. Acked-by: Rob Hoes <rob.hoes@citrix.com>> diff -r 601dc257a740 -r 8195cb0ebac6 tools/libxl/libxl.c > --- a/tools/libxl/libxl.c Tue Nov 20 17:22:16 2012 +0000 > +++ b/tools/libxl/libxl.c Tue Nov 20 17:22:21 2012 +0000 > @@ -526,7 +526,7 @@ static void xcinfo2xlinfo(const xc_domai > if (xlinfo->shutdown || xlinfo->dying) > xlinfo->shutdown_reason = (xcinfo- > >flags>>XEN_DOMINF_shutdownshift) & XEN_DOMINF_shutdownmask; > else > - xlinfo->shutdown_reason = ~0; > + xlinfo->shutdown_reason = LIBXL_SHUTDOWN_REASON_UNKNOWN; > > xlinfo->current_memkb = PAGE_TO_MEMKB(xcinfo->tot_pages); > xlinfo->shared_memkb = PAGE_TO_MEMKB(xcinfo->shr_pages); diff -r > 601dc257a740 -r 8195cb0ebac6 tools/libxl/libxl_types.idl > --- a/tools/libxl/libxl_types.idl Tue Nov 20 17:22:16 2012 +0000 > +++ b/tools/libxl/libxl_types.idl Tue Nov 20 17:22:21 2012 +0000 > @@ -118,14 +118,15 @@ libxl_scheduler = Enumeration("scheduler > (7, "arinc653"), > ]) > > -# Consistent with SHUTDOWN_* in sched.h > +# Consistent with SHUTDOWN_* in sched.h (apart from UNKNOWN) > libxl_shutdown_reason = Enumeration("shutdown_reason", [ > + (-1, "unknown"), > (0, "poweroff"), > (1, "reboot"), > (2, "suspend"), > (3, "crash"), > (4, "watchdog"), > - ]) > + ], init_val = "LIBXL_SHUTDOWN_REASON_UNKNOWN") > > libxl_vga_interface_type = Enumeration("vga_interface_type", [ > (1, "CIRRUS"), > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel
Ian Campbell
2012-Dec-19 13:57 UTC
Re: [PATCH 02 of 15] libxl: Add LIBXL_SHUTDOWN_REASON_UNKNOWN
On Thu, 2012-11-29 at 16:23 +0000, Rob Hoes wrote:> > libxl: Add LIBXL_SHUTDOWN_REASON_UNKNOWN > > > > libxl_dominfo.shutdown_reason is valid iff (shutdown||dying). This is a bit > > annoying when generating language bindings since it needs all sorts of > > special casing. Just introduce an explicit value instead. > > > > Signed-off-by: Ian Campbell <ian.cambell@citrix.com> > > This change is very useful from an ocaml-bindings point of view. > > Acked-by: Rob Hoes <rob.hoes@citrix.com>Thanks. I think I''m actually going to defer on applying this one until we have a clearer idea what direction the bindings are taking. In particular if we decide to implement the "default" state with None/Some (see comment on patch 15/15) then that may be more appropriate than this change. Ian.