libxl: introduce LIBXL_DOMAIN_TYPE_INVALID
PATCH v6 1/1 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]
Also:
- have all the call sites of libxl__domain_type() return with error in case the function returns LIBXL_DOMAIN_TYPE_INVALID;
- adjust all other code segments where -Wswitch makes would claim that LIBXL_DOMAIN_TYPE_INVALID is not handled by adding a "default: abort();" clause.
Changes from v5:
* ERROR_INVAL converted in ERROR_FAIL in libxl_domain_remus_start()
* Error logging moved in libxl__domain_type()
* Forgot about libxl_domain_suspend() as requested
tools/libxl/libxl.c +6 -2
@@ -656,6 +656,11 @@ int libxl_domain_remus_start(libxl_ctx *libxl_domain_type type =libxl__domain_type (gc, domid);int rc =0 ; +if (type ==LIBXL_DOMAIN_TYPE_INVALID ) { + rc =ERROR_FAIL ; + goto remus_fail; + } +if (info ==NULL ) {LIBXL__LOG (ctx,LIBXL__LOG_ERROR ,"No remus_info structure supplied for domain %d" , domid);
@@ -1259,8 +1264,7 @@ int libxl_primary_console_exec(libxl_ctxcase LIBXL_DOMAIN_TYPE_PV : rc =libxl_console_exec (ctx, domid_vm,0 ,LIBXL_CONSOLE_TYPE_PV );break ; -case -1 : -LOG (ERROR ,"unable to get domain type for domid=%" PRIu32,domid_vm); +case LIBXL_DOMAIN_TYPE_INVALID : rc =ERROR_FAIL ;break ;default :
tools/libxl/libxl_dm.c +4 -0
@@ -257,6 +257,8 @@ static char ** libxl__build_device_modelfor (i =0 ; b_info->extra_hvm && b_info->extra_hvm[i] !=NULL ; i++)flexarray_append (dm_args, b_info->extra_hvm[i]);break ; +default : +abort (); }flexarray_append (dm_args,NULL );return (char **)flexarray_contents (dm_args);
@@ -505,6 +507,8 @@ static char ** libxl__build_device_modelfor (i =0 ; b_info->extra_hvm && b_info->extra_hvm[i] !=NULL ; i++)flexarray_append (dm_args, b_info->extra_hvm[i]);break ; +default : +abort (); } ram_size =libxl__sizekb_to_mb (b_info->max_memkb - b_info->video_memkb);
tools/libxl/libxl_dom.c +5 -4
@@ -32,10 +32,11 @@ libxl_domain_type libxl__domain_type(libint ret; ret =xc_domain_getinfolist (ctx->xch, domid,1 , &info); -if (ret !=1 ) -return -1 ; -if (info.domain != domid) -return -1 ; +if (ret !=1 || info.domain != domid) { +LIBXL__LOG (CTX ,LIBXL__LOG_ERROR , +"unable to get domain type for domid=%" PRIu32, domid); +return LIBXL_DOMAIN_TYPE_INVALID ; + }if (info.flags & XEN_DOMINF_hvm_guest)return LIBXL_DOMAIN_TYPE_HVM ;else
tools/libxl/libxl_types.idl +2 -0
@@ -28,6 +28,7 @@ MemKB = UInt(64, init_val = "LIBXL_MEMKB # libxl_domain_type = Enumeration("domain_type", [ + (-1, "INVALID"), (1, "HVM"), (2, "PV"), ])
@@ -310,6 +311,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 )
Quoted 11 lines · Dario Faggioli
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]Also:
- have all the call sites oflibxl__domain_type()return with error in case the function returnsLIBXL_DOMAIN_TYPE_INVALID;
- adjust all other code segments where -Wswitch makes would claim thatLIBXL_DOMAIN_TYPE_INVALIDis not handled by adding a "default:abort();" clause.
Quoted 2 lines
Signed-off-by Dario Faggioli <[email protected]>Signed-off-by Christoph Egger <[email protected]>
tools/libxl/libxl_types.idl libxl_domain_build_info = Struct("domain · line 315
Quoted 6 lines
tools/libxl/libxl_types.idl +1
-0@@ -310,6 +311,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")),
This -1 should => LIBXL_DOMAIN_TYPE_INVALID, but I'll just make that change as I commit it, if that's ok with you...
Quoted 2 lines
tools/libxl/libxl_types.idl +0
-0], dir=DIR_IN )
Quoted 5 lines · Ian Campbell
Quoted 2 lines
Signed-off-by Dario Faggioli <[email protected]>Signed-off-by Christoph Egger <[email protected]>Acked-by Ian Campbell <[email protected]>
Cool! :-)
Quoted 9 lines
tools/libxl/libxl_types.idl libxl_domain_build_info = Struct("domain · line 315
Quoted 6 lines
tools/libxl/libxl_types.idl +1
-0@@ -310,6 +311,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")),This -1 should =>
LIBXL_DOMAIN_TYPE_INVALID,
Oh, you're right, I just wasn't sure I could put i here... And then I forgot to try! :-P
Quoted 3 lines
but I'll just make that
change as I commit it, if that's ok with you...
It is, thanks.
Dario
Signature · 4 lines
<<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
[email protected]
http://lists.xen.org/xen-devel
Review int libxl_primary_console_exec(libxl_ctx · line 1270
Quoted 10 lines · Dario Faggioli
(quoted diff) +1
-2@@ -1259,8 +1264,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: - LOG(ERROR,"unable to get domain type for domid=%"PRIu32,domid_vm); + case LIBXL_DOMAIN_TYPE_INVALID: rc = ERROR_FAIL; break; default:
This hunk no longer applies due to 25454:123628d31cf2 from Bamvor. However the same code effectively exists in libxl__primary_console_find so I resolved it by applying the same there instead, which resulted in:
tools/libxl/libxl.c +1 -3
@@ -1313,11 +1313,9 @@ static int libxl__primary_console_find(libxl_ctx *ctx, uint32_t domid_vm, *cons_num =0 ; *type =LIBXL_CONSOLE_TYPE_PV ;break ; -case -1 : -LOG (ERROR ,"unable to get domain type for domid=%" PRIu32, domid_vm); +case LIBXL_DOMAIN_TYPE_INVALID : rc =ERROR_INVAL ; goto out; -break ;default :abort (); }
I'll commit this, assuming I can compile it etc.
Ian.
Quoted 11 lines · Dario Faggioli
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]Also:
- have all the call sites oflibxl__domain_type()return with error in case the function returnsLIBXL_DOMAIN_TYPE_INVALID;
- adjust all other code segments where -Wswitch makes would claim thatLIBXL_DOMAIN_TYPE_INVALIDis not handled by adding a "default:abort();" clause.
Quoted 2 lines
Signed-off-by Dario Faggioli <[email protected]>Signed-off-by Christoph Egger <[email protected]>
Committed with the two changes I mentioned. Please check I haven't made a mess of things...
Ian.
Quoted 12 lines · Ian Campbell
Quoted 11 lines · Dario Faggioli
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]Also:
- have all the call sites oflibxl__domain_type()return with error in case the function returnsLIBXL_DOMAIN_TYPE_INVALID;
- adjust all other code segments where -Wswitch makes would claim thatLIBXL_DOMAIN_TYPE_INVALIDis not handled by adding a "default:abort();" clause.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Dario Faggioli <[email protected]>Signed-off-by Christoph Egger <[email protected]>Committed with the two changes I mentioned. Please check I haven't made a mess of things...
I looked at it and it seems fine. Thanks for doing this, Dario
Signature · 4 lines
<<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
[email protected]
http://lists.xen.org/xen-devel