Skip to contentSkip to conversation

libxl: build failure due to 'libxl_domain_type'

PATCH In review Christoph Egger 4 participants 24 messages May 18, 2012 – May 23, 2012

lore
Share & tools
lore
#0 lore raw

Hi,

I get this libxl build error:

libxl.c: In function 'libxl_primary_console_exec':
libxl.c:1233:9: error: case value '4294967295' not in enumerated type 'libxl_domain_type'

I see that libxl__domain_type() can returns -1 which is not part of 'enum libxl_domain_type'.

Christoph

Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85689 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
#1 lore raw

PATCH 1/1 libxl: Introduce LIBXL_DOMAIN_TYPE_INVALID to make gcc happy

Introduce LIBXL_DOMAIN_TYPE_INVALID.
Change libxl__domain_type() to return LIBXL_DOMAIN_TYPE_INVALID rather hardcoding -1.
Adjust code pieces where gcc 4.5.3 claims that LIBXL_DOMAIN_TYPE_INVALID is not handled.

This fixes the build error with gcc 4.5.3 reported here:
http://lists.xen.org/archives/html/xen-devel/2012-05/msg01269.html

Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85689 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
tools/libxl/libxl.c +1 -1
diff -r 99263132665b 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;
tools/libxl/libxl_dm.c +4 -0
diff -r 99263132665b tools/libxl/libxl_dm.c
@@ -257,6 +257,8 @@ 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:
+        break;
     }
     flexarray_append(dm_args, NULL);
     return (char **) flexarray_contents(dm_args);
@@ -505,6 +507,8 @@ 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:
+        break;
     }
 
     ram_size = libxl__sizekb_to_mb(b_info->max_memkb - b_info->video_memkb);
tools/libxl/libxl_dom.c +2 -2
diff -r 99263132665b 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

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#2 lore raw

Re: [PATCH] libxl: Introduce LIBXL_DOMAIN_TYPE_INVALID to make gcc happy

Quoted 9 lines · Christoph Egger

Introduce LIBXL_DOMAIN_TYPE_INVALID.
Change libxl__domain_type() to return LIBXL_DOMAIN_TYPE_INVALID rather hardcoding -1.
Adjust code pieces where gcc 4.5.3 claims that LIBXL_DOMAIN_TYPE_INVALID is not handled.

This fixes the build error with gcc 4.5.3 reported here:
http://lists.xen.org/archives/html/xen-devel/2012-05/msg01269.html

I was also running into that error and thus I applied this patch, which brought me here:

libxl.c: In function ‘libxl_primary_console_exec’:
libxl.c:1233:14: error: ‘LIBXL_DOMAIN_TYPE_INVALID’ undeclared (first use in this function) libxl.c:1233:14: note: each undeclared identifier is reported only once for each function it appears in

Which actually seems to be right:

$ grep LIBXL_DOMAIN_TYPE_INVALID tools/* -R
tools/libxl/libxl_dm.c:    case LIBXL_DOMAIN_TYPE_INVALID:
tools/libxl/libxl_dm.c:    case LIBXL_DOMAIN_TYPE_INVALID:
tools/libxl/libxl_dom.c:        return LIBXL_DOMAIN_TYPE_INVALID;
tools/libxl/libxl_dom.c:        return LIBXL_DOMAIN_TYPE_INVALID;
tools/libxl/libxl.c:        case LIBXL_DOMAIN_TYPE_INVALID:

Am I missing something?

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

#3 lore raw

Re: [PATCH] libxl: Introduce LIBXL_DOMAIN_TYPE_INVALID to make gcc happy

Quoted 19 lines · Dario Faggioli
Quoted 9 lines · Christoph Egger

Introduce LIBXL_DOMAIN_TYPE_INVALID.
Change libxl__domain_type() to return LIBXL_DOMAIN_TYPE_INVALID rather hardcoding -1.
Adjust code pieces where gcc 4.5.3 claims that LIBXL_DOMAIN_TYPE_INVALID is not handled.

This fixes the build error with gcc 4.5.3 reported here:
http://lists.xen.org/archives/html/xen-devel/2012-05/msg01269.html

I was also running into that error and thus I applied this patch, which brought me here:

libxl.c: In function ‘libxl_primary_console_exec’:
libxl.c:1233:14: error: ‘LIBXL_DOMAIN_TYPE_INVALID’ undeclared (first use in this function) libxl.c:1233:14: note: each undeclared identifier is reported only once for each function it appears in

Which actually seems to be right:

Quoted 8 lines
$ grep LIBXL_DOMAIN_TYPE_INVALID tools/* -R
tools/libxl/libxl_dm.c:    case LIBXL_DOMAIN_TYPE_INVALID:
tools/libxl/libxl_dm.c:    case LIBXL_DOMAIN_TYPE_INVALID:
tools/libxl/libxl_dom.c:        return LIBXL_DOMAIN_TYPE_INVALID;
tools/libxl/libxl_dom.c:        return LIBXL_DOMAIN_TYPE_INVALID;
tools/libxl/libxl.c:        case LIBXL_DOMAIN_TYPE_INVALID:

Am I missing something?

This should be defined in tools/libxl/libxl_types.idl but the patch doesn't seem to add it.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#4 lore raw

Re: [PATCH] libxl: Introduce LIBXL_DOMAIN_TYPE_INVALID to make gcc happy

Quoted 9 lines · Ian Campbell
Quoted 9 lines

Which actually seems to be right:

$ grep LIBXL_DOMAIN_TYPE_INVALID tools/* -R
tools/libxl/libxl_dm.c:    case LIBXL_DOMAIN_TYPE_INVALID:
tools/libxl/libxl_dm.c:    case LIBXL_DOMAIN_TYPE_INVALID:
tools/libxl/libxl_dom.c:        return LIBXL_DOMAIN_TYPE_INVALID;
tools/libxl/libxl_dom.c:        return LIBXL_DOMAIN_TYPE_INVALID;
tools/libxl/libxl.c:        case LIBXL_DOMAIN_TYPE_INVALID:
Quoted 5 lines
Quoted 1 line

Am I missing something?

This should be defined in tools/libxl/libxl_types.idl but the patch doesn't seem to add it.

Yep, I'm adding it myself with the attached patch, but I'm now getting this:

_libxl_types.c: In function ‘libxl_domain_build_info_dispose’:
_libxl_types.c:91:5: error: enumeration value ‘LIBXL_DOMAIN_TYPE_INVALID’ not handled in switch [-Werror=switch] _libxl_types.c: In function ‘libxl_domain_build_info_init_type’:
_libxl_types.c:284:5: error: enumeration value ‘LIBXL_DOMAIN_TYPE_INVALID’ not handled in switch [-Werror=switch] testidl.c: In function ‘libxl_domain_build_info_rand_init’:
testidl.c:366:5: error: enumeration value ‘LIBXL_DOMAIN_TYPE_INVALID’ not handled in switch [-Werror=switch] _libxl_types.c: In function ‘libxl_domain_build_info_gen_json’:
_libxl_types.c:1713:5: error: enumeration value ‘LIBXL_DOMAIN_TYPE_INVALID’ not handled in switch [-Werror=switch]
cc1: all warnings being treated as errors

:-O

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)
tools/libxl/libxl_types.idl +1 -0
diff -r 9bbc4059c2d1 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"),
     ])

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#5 lore raw

Re: [PATCH] libxl: Introduce LIBXL_DOMAIN_TYPE_INVALID to make gcc happy

Quoted 28 lines · Dario Faggioli
Quoted 9 lines · Ian Campbell
Quoted 9 lines

Which actually seems to be right:

$ grep LIBXL_DOMAIN_TYPE_INVALID tools/* -R
tools/libxl/libxl_dm.c:    case LIBXL_DOMAIN_TYPE_INVALID:
tools/libxl/libxl_dm.c:    case LIBXL_DOMAIN_TYPE_INVALID:
tools/libxl/libxl_dom.c:        return LIBXL_DOMAIN_TYPE_INVALID;
tools/libxl/libxl_dom.c:        return LIBXL_DOMAIN_TYPE_INVALID;
tools/libxl/libxl.c:        case LIBXL_DOMAIN_TYPE_INVALID:
Quoted 5 lines
Quoted 1 line

Am I missing something?

This should be defined in tools/libxl/libxl_types.idl but the patch doesn't seem to add it.

Yep, I'm adding it myself with the attached patch, but I'm now getting this:

_libxl_types.c: In function ‘libxl_domain_build_info_dispose’:
_libxl_types.c:91:5: error: enumeration value ‘LIBXL_DOMAIN_TYPE_INVALID’ not handled in switch [-Werror=switch] _libxl_types.c: In function ‘libxl_domain_build_info_init_type’:
_libxl_types.c:284:5: error: enumeration value ‘LIBXL_DOMAIN_TYPE_INVALID’ not handled in switch [-Werror=switch] testidl.c: In function ‘libxl_domain_build_info_rand_init’:
testidl.c:366:5: error: enumeration value ‘LIBXL_DOMAIN_TYPE_INVALID’ not handled in switch [-Werror=switch] _libxl_types.c: In function ‘libxl_domain_build_info_gen_json’:
_libxl_types.c:1713:5: error: enumeration value ‘LIBXL_DOMAIN_TYPE_INVALID’ not handled in switch [-Werror=switch]
cc1: all warnings being treated as errors

Quoted 1 line

:-O

I wonder if just changing the return type of libxl__domain_type to int would be better than this? I guess it'll probably be much the same.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#6 lore raw

Re: [PATCH] libxl: Introduce LIBXL_DOMAIN_TYPE_INVALID to make gcc happy

Quoted 3 lines · Ian Campbell

I wonder if just changing the return type of libxl__domain_type to int would be better than this? I guess it'll probably be much the same.

Well, the patch I'm attaching now let me at least build cleanly, _without_ any other patches (not Christoph's nor mine)... Did you mean something like that?

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)
tools/libxl/libxl_dom.c +2 -1
diff -r 745b9920dfa3 tools/libxl/libxl_dom.c
@@ -25,7 +25,8 @@
 
 #include "libxl_internal.h"
 
-libxl_domain_type libxl__domain_type(libxl__gc *gc, uint32_t domid)
+//libxl_domain_type
+int libxl__domain_type(libxl__gc *gc, uint32_t domid)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     xc_domaininfo_t info;
tools/libxl/libxl_internal.h +2 -1
diff -r 745b9920dfa3 tools/libxl/libxl_internal.h
@@ -714,7 +714,8 @@ int libxl__self_pipe_eatall(int fd); /* 
 
 
 /* from xl_dom */
-_hidden libxl_domain_type libxl__domain_type(libxl__gc *gc, uint32_t domid);
+//_hidden libxl_domain_type
+_hidden int libxl__domain_type(libxl__gc *gc, uint32_t domid);
 _hidden int libxl__domain_shutdown_reason(libxl__gc *gc, uint32_t domid);
 _hidden int libxl__sched_set_params(libxl__gc *gc, uint32_t domid, libxl_sched_params *scparams);
 #define LIBXL__DOMAIN_IS_TYPE(gc, domid, type) \

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#14 lore raw

Re: [PATCH] libxl: Introduce LIBXL_DOMAIN_TYPE_INVALID to make gcc happy

In reply to Ian Campbell
Quoted 29 lines · Ian Campbell
Quoted 28 lines · Dario Faggioli
Quoted 9 lines · Ian Campbell
Quoted 9 lines

Which actually seems to be right:

$ grep LIBXL_DOMAIN_TYPE_INVALID tools/* -R
tools/libxl/libxl_dm.c:    case LIBXL_DOMAIN_TYPE_INVALID:
tools/libxl/libxl_dm.c:    case LIBXL_DOMAIN_TYPE_INVALID:
tools/libxl/libxl_dom.c:        return LIBXL_DOMAIN_TYPE_INVALID;
tools/libxl/libxl_dom.c:        return LIBXL_DOMAIN_TYPE_INVALID;
tools/libxl/libxl.c:        case LIBXL_DOMAIN_TYPE_INVALID:
Quoted 5 lines
Quoted 1 line

Am I missing something?

This should be defined in tools/libxl/libxl_types.idl but the patch doesn't seem to add it.

Yep, I'm adding it myself with the attached patch, but I'm now getting this:

_libxl_types.c: In function ‘libxl_domain_build_info_dispose’:
_libxl_types.c:91:5: error: enumeration value ‘LIBXL_DOMAIN_TYPE_INVALID’ not handled in switch [-Werror=switch] _libxl_types.c: In function ‘libxl_domain_build_info_init_type’:
_libxl_types.c:284:5: error: enumeration value ‘LIBXL_DOMAIN_TYPE_INVALID’ not handled in switch [-Werror=switch] testidl.c: In function ‘libxl_domain_build_info_rand_init’:
testidl.c:366:5: error: enumeration value ‘LIBXL_DOMAIN_TYPE_INVALID’ not handled in switch [-Werror=switch] _libxl_types.c: In function ‘libxl_domain_build_info_gen_json’:
_libxl_types.c:1713:5: error: enumeration value ‘LIBXL_DOMAIN_TYPE_INVALID’ not handled in switch [-Werror=switch]
cc1: all warnings being treated as errors

Quoted 4 lines
Quoted 1 line

:-O

I wonder if just changing the return type of libxl__domain_type to int would be better than this? I guess it'll probably be much the same.

Is libxl_domain_type part of the API ? If yes then it is better to use 'int' and change the enum to #defines to be safe side. An enum used in the API has a backward-compatibility issue related to its size:

An enum is as small as possible to hold the largest value. Whatever 'as small as possible' means depends on the architecture.

Christoph

Signature · 12 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85689 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#15 lore raw

Re: [PATCH] libxl: Introduce LIBXL_DOMAIN_TYPE_INVALID to make gcc happy

Quoted 37 lines · Christoph Egger
Quoted 29 lines · Ian Campbell
Quoted 28 lines · Dario Faggioli
Quoted 9 lines · Ian Campbell
Quoted 9 lines

Which actually seems to be right:

$ grep LIBXL_DOMAIN_TYPE_INVALID tools/* -R
tools/libxl/libxl_dm.c:    case LIBXL_DOMAIN_TYPE_INVALID:
tools/libxl/libxl_dm.c:    case LIBXL_DOMAIN_TYPE_INVALID:
tools/libxl/libxl_dom.c:        return LIBXL_DOMAIN_TYPE_INVALID;
tools/libxl/libxl_dom.c:        return LIBXL_DOMAIN_TYPE_INVALID;
tools/libxl/libxl.c:        case LIBXL_DOMAIN_TYPE_INVALID:
Quoted 5 lines
Quoted 1 line

Am I missing something?

This should be defined in tools/libxl/libxl_types.idl but the patch doesn't seem to add it.

Yep, I'm adding it myself with the attached patch, but I'm now getting this:

_libxl_types.c: In function ‘libxl_domain_build_info_dispose’:
_libxl_types.c:91:5: error: enumeration value ‘LIBXL_DOMAIN_TYPE_INVALID’ not handled in switch [-Werror=switch] _libxl_types.c: In function ‘libxl_domain_build_info_init_type’:
_libxl_types.c:284:5: error: enumeration value ‘LIBXL_DOMAIN_TYPE_INVALID’ not handled in switch [-Werror=switch] testidl.c: In function ‘libxl_domain_build_info_rand_init’:
testidl.c:366:5: error: enumeration value ‘LIBXL_DOMAIN_TYPE_INVALID’ not handled in switch [-Werror=switch] _libxl_types.c: In function ‘libxl_domain_build_info_gen_json’:
_libxl_types.c:1713:5: error: enumeration value ‘LIBXL_DOMAIN_TYPE_INVALID’ not handled in switch [-Werror=switch]
cc1: all warnings being treated as errors

Quoted 4 lines
Quoted 1 line

:-O

I wonder if just changing the return type of libxl__domain_type to int would be better than this? I guess it'll probably be much the same.

Quoted 7 lines

Is libxl_domain_type part of the API ?
If yes then it is better to use
'int' and change the enum to #defines to be safe side. An enum used in the API has a backward-compatibility issue related to its size:

An enum is as small as possible to hold the largest value. Whatever 'as small as possible' means depends on the architecture.

It is an API, but libxl only guarantees a stable API, it doesn't guarantee a stable ABI, so I think these problems do not manifest.

Ian.

Quoted 2 lines

Christoph

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#7 lore raw

Re: [PATCH] libxl: Introduce LIBXL_DOMAIN_TYPE_INVALID to make gcc happy

In reply to Dario Faggioli
Quoted 7 lines · Dario Faggioli
Quoted 3 lines · Ian Campbell

I wonder if just changing the return type of libxl__domain_type to int would be better than this? I guess it'll probably be much the same.

Well, the patch I'm attaching now let me at least build cleanly, _without_ any other patches (not Christoph's nor mine)... Did you mean something like that?

I did, I guess we need to check that all callers can cope with this new return value though?

Ian.

#8 lore raw

Re: [PATCH] libxl: Introduce LIBXL_DOMAIN_TYPE_INVALID to make gcc happy

Quoted 7 lines · Ian Campbell
Quoted 3 lines

Well, the patch I'm attaching now let me at least build cleanly, _without_ any other patches (not Christoph's nor mine)... Did you mean something like that?

I did, I guess we need to check that all callers can cope with this new return value though?

Sure, that was only to be sure I got what you were saying. :-)

What I'm not getting right now is whether or not a proper patch doing such is still interesting or not? Also, how come am I almost the only one seeing that issue? Does it relate to gcc version? :-O

Thanks and Regards,
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

#9 lore raw

Re: [PATCH] libxl: Introduce LIBXL_DOMAIN_TYPE_INVALID to make gcc happy

Quoted 5 lines · Dario Faggioli
Quoted 4 lines · Ian Campbell
Quoted 3 lines

Well, the patch I'm attaching now let me at least build cleanly, _without_ any other patches (not Christoph's nor mine)... Did you mean something like that?

Quoted 8 lines
Quoted 3 lines

I did, I guess we need to check that all callers can cope with this new return value though?

Sure, that was only to be sure I got what you were saying. :-)

What I'm not getting right now is whether or not a proper patch doing such is still interesting or not? Also, how come am I almost the only one seeing that issue? Does it relate to gcc version? :-O

There's been a handful of other reports this week. It does seem to be to do with gcc version, yes.

Ian.

#10 lore raw

Re: [PATCH] libxl: Introduce LIBXL_DOMAIN_TYPE_INVALID to make gcc happy

Quoted 12 lines · Ian Campbell
Quoted 8 lines
Quoted 3 lines

I did, I guess we need to check that all callers can cope with this new return value though?

Sure, that was only to be sure I got what you were saying. :-)

What I'm not getting right now is whether or not a proper patch doing such is still interesting or not? Also, how come am I almost the only one seeing that issue? Does it relate to gcc version? :-O

There's been a handful of other reports this week. It does seem to be to do with gcc version, yes.

Ok then, I didn't notice that. I went through the callers and they seem to be fine with the change, as the return type of the function is pretty much always converted to the enum (i.e., libxl_domain_type) and used in a switch with a proper 'default' clause, in case they care about something different from _HVM or _PV.

So, the below is what I'm using to build (and run) these days... Or was it something different that you meant when saying "check that all callers can cope with this" ?

(I can repost as a separate mail if wanted)

Dario

8<---------------------------

libxl: make libxl__domain_type return 'int'

To avoid gcc > 4.6.3 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]

Callers have been checked and are fine with the change.

tools/libxl/libxl_dom.c +1 -1
diff -r 6dc80df50fa8 tools/libxl/libxl_dom.c
@@ -25,7 +25,7 @@
 
 #include "libxl_internal.h"
 
-libxl_domain_type libxl__domain_type(libxl__gc *gc, uint32_t domid)
+int libxl__domain_type(libxl__gc *gc, uint32_t domid)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     xc_domaininfo_t info;
tools/libxl/libxl_internal.h +1 -1
diff -r 6dc80df50fa8 tools/libxl/libxl_internal.h
@@ -714,7 +714,7 @@ int libxl__self_pipe_eatall(int fd); /* 
 
 
 /* from xl_dom */
-_hidden libxl_domain_type libxl__domain_type(libxl__gc *gc, uint32_t domid);
+_hidden int libxl__domain_type(libxl__gc *gc, uint32_t domid);
 _hidden int libxl__domain_shutdown_reason(libxl__gc *gc, uint32_t domid);
 _hidden int libxl__sched_set_params(libxl__gc *gc, uint32_t domid, libxl_sched_params *scparams);
 #define LIBXL__DOMAIN_IS_TYPE(gc, domid, type) \
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

#11 lore raw

Re: [PATCH] libxl: Introduce LIBXL_DOMAIN_TYPE_INVALID to make gcc happy

Quoted 25 lines · Dario Faggioli
Quoted 12 lines · Ian Campbell
Quoted 8 lines
Quoted 3 lines

I did, I guess we need to check that all callers can cope with this new return value though?

Sure, that was only to be sure I got what you were saying. :-)

What I'm not getting right now is whether or not a proper patch doing such is still interesting or not? Also, how come am I almost the only one seeing that issue? Does it relate to gcc version? :-O

There's been a handful of other reports this week. It does seem to be to do with gcc version, yes.

Ok then, I didn't notice that. I went through the callers and they seem to be fine with the change, as the return type of the function is pretty much always converted to the enum (i.e., libxl_domain_type) and used in a switch with a proper 'default' clause, in case they care about something different from _HVM or _PV.

So, the below is what I'm using to build (and run) these days... Or was it something different that you meant when saying "check that all callers can cope with this" ?

(I can repost as a separate mail if wanted)

Quoted 7 lines

Dario

8<---------------------------

libxl: make libxl__domain_type return 'int'

To avoid gcc > 4.6.3 complaining about:

I have gcc 4.5.3 and see this.
Christoph

Quoted 34 lines

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]

Callers have been checked and are fine with the change.

diff -r 6dc80df50fa8 tools/libxl/libxl_dom.c

tools/libxl/libxl_dom.c +1 -1
@@ -25,7 +25,7 @@
 
 #include "libxl_internal.h"
 
-libxl_domain_type libxl__domain_type(libxl__gc *gc, uint32_t domid)
+int libxl__domain_type(libxl__gc *gc, uint32_t domid)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     xc_domaininfo_t info;

diff -r 6dc80df50fa8 tools/libxl/libxl_internal.h

tools/libxl/libxl_internal.h +1 -1
@@ -714,7 +714,7 @@ int libxl__self_pipe_eatall(int fd); /* 
 
 
 /* from xl_dom */
-_hidden libxl_domain_type libxl__domain_type(libxl__gc *gc, uint32_t domid);
+_hidden int libxl__domain_type(libxl__gc *gc, uint32_t domid);
 _hidden int libxl__domain_shutdown_reason(libxl__gc *gc, uint32_t domid);
 _hidden int libxl__sched_set_params(libxl__gc *gc, uint32_t domid, libxl_sched_params *scparams);
 #define LIBXL__DOMAIN_IS_TYPE(gc, domid, type) \
Signature · 12 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85689 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#12 lore raw

Re: [PATCH] libxl: Introduce LIBXL_DOMAIN_TYPE_INVALID to make gcc happy

Quoted 10 lines · Christoph Egger
Quoted 5 lines

8<---------------------------

libxl: make libxl__domain_type return 'int'

To avoid gcc > 4.6.3 complaining about:

I have gcc 4.5.3 and see this.
Christoph

Ups! You said it earlier but I forgot to go and check your gcc version, and just considered mine. Sorry. :-P

Anyway, let's see what is the fix they want, then we'll decide about a proper changelog. :-)

Thanks and Regards,
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

#13 lore raw

Re: [PATCH] libxl: Introduce LIBXL_DOMAIN_TYPE_INVALID to make gcc happy

Quoted 5 lines · Dario Faggioli
Quoted 4 lines · Christoph Egger
Quoted 4 lines

8<---------------------------

libxl: make libxl__domain_type return 'int'

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

To avoid gcc > 4.6.3 complaining about:

I have gcc 4.5.3 and see this.
Christoph

Ups! You said it earlier but I forgot to go and check your gcc version, and just considered mine. Sorry. :-P

I think, this affects all gcc versions where -Wswitch is on by default. If we build libxl with passing -Wswitch in the build system then this should be reproducable with any gcc version.

Christoph

Quoted 7 lines

Anyway, let's see what is the fix they want, then we'll decide about a proper changelog. :-)

Thanks and Regards,
Dario

Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85689 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
#16 lore raw

Re: [PATCH] libxl: Introduce LIBXL_DOMAIN_TYPE_INVALID to make gcc happy

In reply to Ian Campbell

Ian Campbell writes ("Re: [Xen-devel] [PATCH] libxl: Introduce LIBXL_DOMAIN_TYPE_INVALID to make gcc happy"):

Quoted 2 lines

I wonder if just changing the return type of libxl__domain_type to int would be better than this? I guess it'll probably be much the same.

The upside of making it be an int is that we could have libxl_get_domain_type to return a proper libxl error code on failure, so that it could explain the cause of the failure more carefully. However, I think this is theoretical. A failure return is always going to be morally equivalent to ERROR_RETURN.

And the upside of making it be an enum is precisely

Quoted 3 lines · Dario Faggioli
Quoted 2 lines

_libxl_types.c: In function ‘libxl_domain_build_info_dispose’:
_libxl_types.c:91:5: error: enumeration value ‘LIBXL_DOMAIN_TYPE_INVALID’ not handled in switch [-Werror=switch]

these warnings, which are alerting us to call sites with broken error handling.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#17 lore raw

Re: [PATCH] libxl: Introduce LIBXL_DOMAIN_TYPE_INVALID to make gcc happy

Quoted 9 lines · Ian Jackson

And the upside of making it be an enum is precisely

Quoted 3 lines · Dario Faggioli
Quoted 2 lines

_libxl_types.c: In function ‘libxl_domain_build_info_dispose’:
_libxl_types.c:91:5: error: enumeration value ‘LIBXL_DOMAIN_TYPE_INVALID’ not handled in switch [-Werror=switch]

these warnings, which are alerting us to call sites with broken error handling.

I agree, and I can sue try looking at those call sites and see what it takes to add a proper 'case' or 'default' clause in there if you think that to be the way to go...

Thanks and Regards,
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

#18 lore raw

Re: [PATCH] libxl: Introduce LIBXL_DOMAIN_TYPE_INVALID to make gcc happy

Dario Faggioli writes ("Re: [Xen-devel] [PATCH] libxl: Introduce LIBXL_DOMAIN_TYPE_INVALID to make gcc happy"):

Quoted 7 lines · Ian Jackson
Quoted 6 lines

And the upside of making it be an enum is precisely

Quoted 3 lines · Dario Faggioli
Quoted 2 lines

_libxl_types.c: In function ‘libxl_domain_build_info_dispose’:
_libxl_types.c:91:5: error: enumeration value ‘LIBXL_DOMAIN_TYPE_INVALID’ not handled in switch [-Werror=switch]

Quoted 6 lines
Quoted 2 lines

these warnings, which are alerting us to call sites with broken error handling.

I agree, and I can sue try looking at those call sites and see what it takes to add a proper 'case' or 'default' clause in there if you think that to be the way to go...

I think that would be best, if you're willing, thanks.

I would recommend the use of "case" rather than "default" clauses in this case. That way if we introduce a new domain type the compiler will spot all the missing places for us.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#19 lore raw

Re: [PATCH] libxl: Introduce LIBXL_DOMAIN_TYPE_INVALID to make gcc happy

Quoted 2 lines · Ian Jackson

I think that would be best, if you're willing, thanks.

Doing it right now.

Quoted 4 lines

I would recommend the use of "case" rather than "default" clauses in this case. That way if we introduce a new domain type the compiler will spot all the missing places for us.

That's what I'm doing for any explicit usage of the enum. Problem arises with auto-generated code, e.g., in gentypes.py for build_info related functions. In this case, in fact, the libxl_domain_type enum is the key of the keyed-union. For those cases, I was thinking at something like the below:

if isinstance(ty, idl.KeyedUnion):
if parent is None:
raise Exception("KeyedUnion type must have a parent")
s += "switch (%s) {\n" % (parent + ty.keyvar.name) for f in ty.fields:
(nparent,fexpr) = ty.member(v, f, parent is None) s += "case %s:\n" % f.enumname
s += libxl_C_type_dispose(f.type, fexpr, indent + " ", nparent)
s += " break;\n"

+       s += "default:\n    break;\n";
        s += "}\n"

Would it make sense?

Thanks and Regards,
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

#20 lore raw

Re: [PATCH] libxl: Introduce LIBXL_DOMAIN_TYPE_INVALID to make gcc happy

Quoted 15 lines · Dario Faggioli

Problem arises
with auto-generated code, e.g., in gentypes.py for build_info related functions. In this case, in fact, the libxl_domain_type enum is the key of the keyed-union. For those cases, I was thinking at something like the below:

if isinstance(ty, idl.KeyedUnion):
if parent is None:
raise Exception("KeyedUnion type must have a parent")
s += "switch (%s) {\n" % (parent + ty.keyvar.name) for f in ty.fields:
(nparent,fexpr) = ty.member(v, f, parent is None) s += "case %s:\n" % f.enumname
s += libxl_C_type_dispose(f.type, fexpr, indent + " ", nparent)
s += " break;\n"

Quoted 5 lines
+       s += "default:\n    break;\n";
        s += "}\n"

Would it make sense?

Like this thing below.

Christoph, this ended up extending what you sent at the very beginning of this thread, so I think we should both sign-off-by it (and thus it took the liberty going ahead and adding yours), do you agree?

<-----------------------

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.

tools/libxl/gentest.py +2 -0
diff -r 6dc80df50fa8 tools/libxl/gentest.py
@@ -37,6 +37,8 @@ def gen_rand_init(ty, v, indent = "    "
             s += "case %s:\n" % f.enumname
             s += gen_rand_init(f.type, fexpr, indent + "    ", nparent)
             s += "    break;\n"
+        s += "default:\n";
+        s += "    break;\n";
         s += "}\n"
     elif isinstance(ty, idl.Struct) \
      and (parent is None or ty.json_fn is None):
tools/libxl/gentypes.py +6 -0
diff -r 6dc80df50fa8 tools/libxl/gentypes.py
@@ -65,6 +65,8 @@ def libxl_C_type_dispose(ty, v, indent =
             s += "case %s:\n" % f.enumname
             s += libxl_C_type_dispose(f.type, fexpr, indent + "    ", nparent)
             s += "    break;\n"
+        s += "default:\n";
+        s += "    break;\n";
         s += "}\n"
     elif isinstance(ty, idl.Struct) and (parent is None or ty.dispose_fn is None):
         for f in [f for f in ty.fields if not f.const]:
@@ -98,6 +100,8 @@ def _libxl_C_type_init(ty, v, indent = "
                 s += "case %s:\n" % f.enumname
                 s += _libxl_C_type_init(f.type, fexpr, "    ", nparent)
                 s += "    break;\n"
+            s += "default:\n";
+            s += "    break;\n";
             s += "}\n"
         else:
             if ty.keyvar.init_val:
@@ -177,6 +181,8 @@ def libxl_C_type_gen_json(ty, v, indent 
             s += "case %s:\n" % f.enumname
             s += libxl_C_type_gen_json(f.type, fexpr, indent + "    ", nparent)
             s += "    break;\n"
+        s += "default:\n";
+        s += "    break;\n";
         s += "}\n"
     elif isinstance(ty, idl.Struct) and (parent is None or ty.json_fn is None):
         s += "s = yajl_gen_map_open(hand);\n"
tools/libxl/libxl.c +1 -1
diff -r 6dc80df50fa8 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;
tools/libxl/libxl_dm.c +4 -0
diff -r 6dc80df50fa8 tools/libxl/libxl_dm.c
@@ -257,6 +257,8 @@ 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:
+        break;
     }
     flexarray_append(dm_args, NULL);
     return (char **) flexarray_contents(dm_args);
@@ -505,6 +507,8 @@ 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:
+        break;
     }
 
     ram_size = libxl__sizekb_to_mb(b_info->max_memkb - b_info->video_memkb);
tools/libxl/libxl_dom.c +2 -2
diff -r 6dc80df50fa8 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
tools/libxl/libxl_types.idl +1 -0
diff -r 6dc80df50fa8 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"),
     ])
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

#21 lore raw

Re: [PATCH] libxl: Introduce LIBXL_DOMAIN_TYPE_INVALID to make gcc happy

Quoted 19 lines · Dario Faggioli
Quoted 18 lines · Dario Faggioli

Problem arises
with auto-generated code, e.g., in gentypes.py for build_info related functions. In this case, in fact, the libxl_domain_type enum is the key of the keyed-union. For those cases, I was thinking at something like the below:

if isinstance(ty, idl.KeyedUnion):
if parent is None:
raise Exception("KeyedUnion type must have a parent")
s += "switch (%s) {\n" % (parent + ty.keyvar.name) for f in ty.fields:
(nparent,fexpr) = ty.member(v, f, parent is None) s += "case %s:\n" % f.enumname
s += libxl_C_type_dispose(f.type, fexpr, indent + " ", nparent)
s += " break;\n"

+       s += "default:\n    break;\n";
        s += "}\n"
Quoted 7 lines
Quoted 2 lines

Would it make sense?

Like this thing below.

Christoph, this ended up extending what you sent at the very beginning of this thread, so I think we should both sign-off-by it (and thus it took the liberty going ahead and adding yours), do you agree?

Yes, I agree.

Christoph

Quoted 118 lines

<-----------------------

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.

diff -r 6dc80df50fa8 tools/libxl/gentest.py

tools/libxl/gentest.py +2 -0
@@ -37,6 +37,8 @@ def gen_rand_init(ty, v, indent = "    "
             s += "case %s:\n" % f.enumname
             s += gen_rand_init(f.type, fexpr, indent + "    ", nparent)
             s += "    break;\n"
+        s += "default:\n";
+        s += "    break;\n";
         s += "}\n"
     elif isinstance(ty, idl.Struct) \
      and (parent is None or ty.json_fn is None):

diff -r 6dc80df50fa8 tools/libxl/gentypes.py

tools/libxl/gentypes.py +6 -0
@@ -65,6 +65,8 @@ def libxl_C_type_dispose(ty, v, indent =
             s += "case %s:\n" % f.enumname
             s += libxl_C_type_dispose(f.type, fexpr, indent + "    ", nparent)
             s += "    break;\n"
+        s += "default:\n";
+        s += "    break;\n";
         s += "}\n"
     elif isinstance(ty, idl.Struct) and (parent is None or ty.dispose_fn is None):
         for f in [f for f in ty.fields if not f.const]:
@@ -98,6 +100,8 @@ def _libxl_C_type_init(ty, v, indent = "
                 s += "case %s:\n" % f.enumname
                 s += _libxl_C_type_init(f.type, fexpr, "    ", nparent)
                 s += "    break;\n"
+            s += "default:\n";
+            s += "    break;\n";
             s += "}\n"
         else:
             if ty.keyvar.init_val:
@@ -177,6 +181,8 @@ def libxl_C_type_gen_json(ty, v, indent 
             s += "case %s:\n" % f.enumname
             s += libxl_C_type_gen_json(f.type, fexpr, indent + "    ", nparent)
             s += "    break;\n"
+        s += "default:\n";
+        s += "    break;\n";
         s += "}\n"
     elif isinstance(ty, idl.Struct) and (parent is None or ty.json_fn is None):
         s += "s = yajl_gen_map_open(hand);\n"

diff -r 6dc80df50fa8 tools/libxl/libxl.c

tools/libxl/libxl.c +1 -1
@@ -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 -r 6dc80df50fa8 tools/libxl/libxl_dm.c

tools/libxl/libxl_dm.c +4 -0
@@ -257,6 +257,8 @@ 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:
+        break;
     }
     flexarray_append(dm_args, NULL);
     return (char **) flexarray_contents(dm_args);
@@ -505,6 +507,8 @@ 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:
+        break;
     }
 
     ram_size = libxl__sizekb_to_mb(b_info->max_memkb - b_info->video_memkb);

diff -r 6dc80df50fa8 tools/libxl/libxl_dom.c

tools/libxl/libxl_dom.c +2 -2
@@ -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 -r 6dc80df50fa8 tools/libxl/libxl_types.idl

tools/libxl/libxl_types.idl +1 -0
@@ -30,6 +30,7 @@ MemKB = UInt(64, init_val = "LIBXL_MEMKB
 #
 
 libxl_domain_type = Enumeration("domain_type", [
+    (-1, "INVALID"),
     (1, "HVM"),
     (2, "PV"),
     ])
Signature · 12 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85689 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#22 lore raw

Re: [PATCH] libxl: Introduce LIBXL_DOMAIN_TYPE_INVALID to make gcc happy

In reply to Dario Faggioli

Dario Faggioli writes ("Re: [Xen-devel] [PATCH] libxl: Introduce LIBXL_DOMAIN_TYPE_INVALID to make gcc happy"):

Quoted 15 lines

That's what I'm doing for any explicit usage of the enum. Problem arises with auto-generated code, e.g., in gentypes.py for build_info related functions. In this case, in fact, the libxl_domain_type enum is the key of the keyed-union. For those cases, I was thinking at something like the below:

if isinstance(ty, idl.KeyedUnion):
if parent is None:
raise Exception("KeyedUnion type must have a parent")
s += "switch (%s) {\n" % (parent + ty.keyvar.name) for f in ty.fields:
(nparent,fexpr) = ty.member(v, f, parent is None) s += "case %s:\n" % f.enumname
s += libxl_C_type_dispose(f.type, fexpr, indent + " ", nparent)
s += " break;\n"

Quoted 4 lines
+       s += "default:\n    break;\n";
        s += "}\n"

Would it make sense?

No, I don't think so. Surely the idl should contain an explicitly empty structure ?

Ian.

#23 lore raw

Re: [PATCH] libxl: Introduce LIBXL_DOMAIN_TYPE_INVALID to make gcc happy

Quoted 12 lines · Ian Jackson
Quoted 12 lines

if isinstance(ty, idl.KeyedUnion):
if parent is None:
raise Exception("KeyedUnion type must have a parent")
s += "switch (%s) {\n" % (parent + ty.keyvar.name) for f in ty.fields:
(nparent,fexpr) = ty.member(v, f, parent is None) s += "case %s:\n" % f.enumname
s += libxl_C_type_dispose(f.type, fexpr, indent + " ", nparent)
s += " break;\n"

+       s += "default:\n    break;\n";
        s += "}\n"
Quoted 5 lines
Quoted 1 line

Would it make sense?

No, I don't think so. Surely the idl should contain an explicitly empty structure ?

Well, that would work either, of course. :-)

Here's what I did, and it builds cleanly:

tools/libxl/libxl_types.idl Wed May 23 17:19:52 2012 +0200 renamed from tools/libxl/libxl_types.idl Tue May 22 16:30:11 2012 +0200 +1 -0
diff -r 6dc80df50fa8 tools/libxl/libxl_types.idl
@@ -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")),
 

New patch coming in a separate thread.

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