[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] libxl: introduce LIBXL_DOMAIN_TYPE_INVALID


  • To: xen-changelog@xxxxxxxxxxxxxxxxxxx
  • From: Xen patchbot-unstable <patchbot@xxxxxxx>
  • Date: Thu, 07 Jun 2012 02:44:09 +0000
  • Delivery-date: Thu, 07 Jun 2012 02:44:20 +0000
  • List-id: "Change log for Mercurial \(receive only\)" <xen-changelog.lists.xen.org>

# HG changeset patch
# User Dario Faggioli <raistlin@xxxxxxxx>
# Date 1338994628 -3600
# Node ID f2f9745c81b74dac74b4d378bef4695eece181d7
# Parent  a24ffff4e18d3313be6ff66eb895071fd8dfef84
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.

Signed-off-by: Dario Faggioli <dario.faggioli@xxxxxxxxxx>
Signed-off-by: Christoph Egger <Christoph.Egger@xxxxxxx>
Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
[ ijc -- use LIBXL_DOMAIN_TYPE_INVALID instead of -1 for
         libxl_domain_build_info.type's keyvar_init_val.
      -- what used to be libxl_primary_console_exec is now in
         libxl__primary_console_find so resolve the rejected hunk
         accordingly ]
Committed-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---


diff -r a24ffff4e18d -r f2f9745c81b7 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Wed Jun 06 13:53:59 2012 +0100
+++ b/tools/libxl/libxl.c       Wed Jun 06 15:57:08 2012 +0100
@@ -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);
@@ -1313,11 +1318,9 @@ static int libxl__primary_console_find(l
             *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();
         }
diff -r a24ffff4e18d -r f2f9745c81b7 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c    Wed Jun 06 13:53:59 2012 +0100
+++ b/tools/libxl/libxl_dm.c    Wed Jun 06 15:57:08 2012 +0100
@@ -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;
+    default:
+        abort();
     }
     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;
+    default:
+        abort();
     }
 
     ram_size = libxl__sizekb_to_mb(b_info->max_memkb - b_info->video_memkb);
diff -r a24ffff4e18d -r f2f9745c81b7 tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c   Wed Jun 06 13:53:59 2012 +0100
+++ b/tools/libxl/libxl_dom.c   Wed Jun 06 15:57:08 2012 +0100
@@ -32,10 +32,11 @@ libxl_domain_type libxl__domain_type(lib
     int 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
diff -r a24ffff4e18d -r f2f9745c81b7 tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl       Wed Jun 06 13:53:59 2012 +0100
+++ b/tools/libxl/libxl_types.idl       Wed Jun 06 15:57:08 2012 +0100
@@ -28,6 +28,7 @@ MemKB = UInt(64, init_val = "LIBXL_MEMKB
 #
 
 libxl_domain_type = Enumeration("domain_type", [
+    (-1, "INVALID"),
     (1, "HVM"),
     (2, "PV"),
     ])
@@ -310,7 +311,8 @@ libxl_domain_build_info = Struct("domain
                                       # Use host's E820 for PCI passthrough.
                                       ("e820_host", libxl_defbool),
                                       ])),
-                 ], keyvar_init_val = "-1")),
+                 ("invalid", Struct(None, [])),
+                 ], keyvar_init_val = "LIBXL_DOMAIN_TYPE_INVALID")),
     ], dir=DIR_IN
 )
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.