Dario Faggioli
2012-May-24 14:30 UTC
[PATCH v3] libxl: introduce LIBXL_DOMAIN_TYPE_INVALID
To avoid recent gcc complaining about: libxl.c: In function ‘libxl_primary_console_exec’: libxl.c:1233:9: error: case value ‘4294967295’ not in enumerated type ‘libxl_domain_type’ [-Werror=switch] Adjust code pieces where -Wswitch makes it claim that LIBXL_DOMAIN_TYPE_INVALID is not handled. Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com> Signed-off-by: Christoph Egger <Christoph.Egger@amd.com> diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -1230,7 +1230,7 @@ int libxl_primary_console_exec(libxl_ctx case LIBXL_DOMAIN_TYPE_PV: rc = libxl_console_exec(ctx, domid_vm, 0, LIBXL_CONSOLE_TYPE_PV); break; - case -1: + case LIBXL_DOMAIN_TYPE_INVALID: LOG(ERROR,"unable to get domain type for domid=%"PRIu32,domid_vm); rc = ERROR_FAIL; break; diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -257,6 +257,9 @@ static char ** libxl__build_device_model for (i = 0; b_info->extra_hvm && b_info->extra_hvm[i] != NULL; i++) flexarray_append(dm_args, b_info->extra_hvm[i]); break; + case LIBXL_DOMAIN_TYPE_INVALID: + LIBXL__LOG(CTX, LIBXL__LOG_ERROR, "invalid domain type"); + return NULL; } flexarray_append(dm_args, NULL); return (char **) flexarray_contents(dm_args); @@ -505,6 +508,10 @@ static char ** libxl__build_device_model for (i = 0; b_info->extra_hvm && b_info->extra_hvm[i] != NULL; i++) flexarray_append(dm_args, b_info->extra_hvm[i]); break; + case LIBXL_DOMAIN_TYPE_INVALID: + LIBXL__LOG(CTX, LIBXL__LOG_ERROR, "invalid domain type"); + return NULL; + break; } ram_size = libxl__sizekb_to_mb(b_info->max_memkb - b_info->video_memkb); diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -33,9 +33,9 @@ libxl_domain_type libxl__domain_type(lib ret = xc_domain_getinfolist(ctx->xch, domid, 1, &info); if (ret != 1) - return -1; + return LIBXL_DOMAIN_TYPE_INVALID; if (info.domain != domid) - return -1; + return LIBXL_DOMAIN_TYPE_INVALID; if (info.flags & XEN_DOMINF_hvm_guest) return LIBXL_DOMAIN_TYPE_HVM; else diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -30,6 +30,7 @@ MemKB = UInt(64, init_val = "LIBXL_MEMKB # libxl_domain_type = Enumeration("domain_type", [ + (-1, "INVALID"), (1, "HVM"), (2, "PV"), ]) @@ -315,6 +316,7 @@ libxl_domain_build_info = Struct("domain # Use host's E820 for PCI passthrough. ("e820_host", libxl_defbool), ])), + ("invalid", Struct(None, [])), ], keyvar_init_val = "-1")), ], dir=DIR_IN ) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Ian Campbell
2012-May-24 14:35 UTC
Re: [PATCH v3] libxl: introduce LIBXL_DOMAIN_TYPE_INVALID
On Thu, 2012-05-24 at 15:30 +0100, Dario Faggioli wrote:> To avoid recent gcc complaining about: > libxl.c: In function ‘libxl_primary_console_exec’: > libxl.c:1233:9: error: case value ‘4294967295’ not in enumerated type ‘libxl_domain_type’ [-Werror=switch] > > Adjust code pieces where -Wswitch makes it claim that > LIBXL_DOMAIN_TYPE_INVALID is not handled. > > Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com> > Signed-off-by: Christoph Egger <Christoph.Egger@amd.com> > > diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c > --- a/tools/libxl/libxl.c > +++ b/tools/libxl/libxl.c > @@ -1230,7 +1230,7 @@ int libxl_primary_console_exec(libxl_ctx > case LIBXL_DOMAIN_TYPE_PV: > rc = libxl_console_exec(ctx, domid_vm, 0, LIBXL_CONSOLE_TYPE_PV); > break; > - case -1: > + case LIBXL_DOMAIN_TYPE_INVALID: > LOG(ERROR,"unable to get domain type for domid=%"PRIu32,domid_vm); > rc = ERROR_FAIL; > break; > diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c > --- a/tools/libxl/libxl_dm.c > +++ b/tools/libxl/libxl_dm.c > @@ -257,6 +257,9 @@ static char ** libxl__build_device_model > for (i = 0; b_info->extra_hvm && b_info->extra_hvm[i] != NULL; i++) > flexarray_append(dm_args, b_info->extra_hvm[i]); > break; > + case LIBXL_DOMAIN_TYPE_INVALID: > + LIBXL__LOG(CTX, LIBXL__LOG_ERROR, "invalid domain type");I think you need a flexarray_free here...> + return NULL; > } > flexarray_append(dm_args, NULL); > return (char **) flexarray_contents(dm_args); > @@ -505,6 +508,10 @@ static char ** libxl__build_device_model > for (i = 0; b_info->extra_hvm && b_info->extra_hvm[i] != NULL; i++) > flexarray_append(dm_args, b_info->extra_hvm[i]); > break; > + case LIBXL_DOMAIN_TYPE_INVALID: > + LIBXL__LOG(CTX, LIBXL__LOG_ERROR, "invalid domain type");... and here.> + return NULL; > + break;The break is now redundant.> } > > ram_size = libxl__sizekb_to_mb(b_info->max_memkb - b_info->video_memkb); > diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c > --- a/tools/libxl/libxl_dom.c > +++ b/tools/libxl/libxl_dom.c > @@ -33,9 +33,9 @@ libxl_domain_type libxl__domain_type(lib > > ret = xc_domain_getinfolist(ctx->xch, domid, 1, &info); > if (ret != 1) > - return -1; > + return LIBXL_DOMAIN_TYPE_INVALID; > if (info.domain != domid) > - return -1; > + return LIBXL_DOMAIN_TYPE_INVALID; > if (info.flags & XEN_DOMINF_hvm_guest) > return LIBXL_DOMAIN_TYPE_HVM; > else > diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl > --- a/tools/libxl/libxl_types.idl > +++ b/tools/libxl/libxl_types.idl > @@ -30,6 +30,7 @@ MemKB = UInt(64, init_val = "LIBXL_MEMKB > # > > libxl_domain_type = Enumeration("domain_type", [ > + (-1, "INVALID"), > (1, "HVM"), > (2, "PV"), > ]) > @@ -315,6 +316,7 @@ libxl_domain_build_info = Struct("domain > # Use host's E820 for PCI passthrough. > ("e820_host", libxl_defbool), > ])), > + ("invalid", Struct(None, [])), > ], keyvar_init_val = "-1")), > ], dir=DIR_IN > )_______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Dario Faggioli
2012-May-24 14:51 UTC
Re: [PATCH v3] libxl: introduce LIBXL_DOMAIN_TYPE_INVALID
On Thu, 2012-05-24 at 15:35 +0100, Ian Campbell wrote:> > diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c > > --- a/tools/libxl/libxl_dm.c > > +++ b/tools/libxl/libxl_dm.c > > @@ -257,6 +257,9 @@ static char ** libxl__build_device_model > > for (i = 0; b_info->extra_hvm && b_info->extra_hvm[i] != NULL; i++) > > flexarray_append(dm_args, b_info->extra_hvm[i]); > > break; > > + case LIBXL_DOMAIN_TYPE_INVALID: > > + LIBXL__LOG(CTX, LIBXL__LOG_ERROR, "invalid domain type"); > > I think you need a flexarray_free here... >Ok. I tried to figure out whether or not I''d need some fee logic, and apparently I failed. :-P> > + return NULL; > > } > > flexarray_append(dm_args, NULL); > > return (char **) flexarray_contents(dm_args); > > @@ -505,6 +508,10 @@ static char ** libxl__build_device_model > > for (i = 0; b_info->extra_hvm && b_info->extra_hvm[i] != NULL; i++) > > flexarray_append(dm_args, b_info->extra_hvm[i]); > > break; > > + case LIBXL_DOMAIN_TYPE_INVALID: > > + LIBXL__LOG(CTX, LIBXL__LOG_ERROR, "invalid domain type"); > > ... and here. > > > + return NULL; > > + break; > > The break is now redundant. >Yep, result of a missing qpop/qpush. v4 coming ... Dario -- <<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://retis.sssup.it/people/faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel