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

[Xen-devel] [PATCH 17 of 26 V3] libxl: make boolean members of libxl_domain_create_info into libxl_defbool



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1330000277 0
# Node ID a27058f39b2cb2064e3370dfc216f08c49f0517d
# Parent  de102741f1e7dd0dec7df9edae7fda684bf7aa7b
libxl: make boolean members of libxl_domain_create_info into libxl_defbool

This allows them to be set via the _init/_setdefault methods.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>

diff -r de102741f1e7 -r a27058f39b2c tools/libxl/gentest.py
--- a/tools/libxl/gentest.py    Thu Feb 23 12:31:17 2012 +0000
+++ b/tools/libxl/gentest.py    Thu Feb 23 12:31:17 2012 +0000
@@ -20,8 +20,7 @@ def randomize_case(s):
 def randomize_enum(e):
     return random.choice([v.name for v in e.values])
 
-handcoded = ["libxl_defbool", # Temp until a user appears in the next patch
-             "libxl_cpumap", "libxl_key_value_list",
+handcoded = ["libxl_cpumap", "libxl_key_value_list",
              "libxl_cpuid_policy_list", "libxl_file_reference",
              "libxl_string_list"]
 
diff -r de102741f1e7 -r a27058f39b2c tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c        Thu Feb 23 12:31:17 2012 +0000
+++ b/tools/libxl/libxl_create.c        Thu Feb 23 12:31:17 2012 +0000
@@ -53,8 +53,6 @@ void libxl_domain_config_dispose(libxl_d
 void libxl_domain_create_info_init(libxl_domain_create_info *c_info)
 {
     memset(c_info, '\0', sizeof(*c_info));
-    c_info->hap = 1;
-    c_info->oos = 1;
 }
 
 int libxl__domain_create_info_setdefault(libxl__gc *gc,
@@ -63,6 +61,11 @@ int libxl__domain_create_info_setdefault
     if (!c_info->type)
         return ERROR_INVAL;
 
+    if (c_info->type == LIBXL_DOMAIN_TYPE_HVM) {
+        libxl_defbool_setdefault(&c_info->hap, true);
+        libxl_defbool_setdefault(&c_info->oos, true);
+    }
+
     return 0;
 }
 
@@ -365,8 +368,8 @@ int libxl__domain_make(libxl__gc *gc, li
     flags = 0;
     if (info->type == LIBXL_DOMAIN_TYPE_HVM) {
         flags |= XEN_DOMCTL_CDF_hvm_guest;
-        flags |= info->hap ? XEN_DOMCTL_CDF_hap : 0;
-        flags |= info->oos ? 0 : XEN_DOMCTL_CDF_oos_off;
+        flags |= libxl_defbool_val(info->hap) ? XEN_DOMCTL_CDF_hap : 0;
+        flags |= libxl_defbool_val(info->oos) ? 0 : XEN_DOMCTL_CDF_oos_off;
     }
     *domid = -1;
 
@@ -518,6 +521,9 @@ static int do_domain_create(libxl__gc *g
     ret = libxl__domain_create_info_setdefault(gc, &d_config->c_info);
     if (ret) goto error_out;
 
+    ret = libxl__domain_create_info_setdefault(gc, &d_config->c_info);
+    if (ret) goto error_out;
+
     ret = libxl__domain_make(gc, &d_config->c_info, &domid);
     if (ret) {
         LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot make domain: %d", ret);
diff -r de102741f1e7 -r a27058f39b2c tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl       Thu Feb 23 12:31:17 2012 +0000
+++ b/tools/libxl/libxl_types.idl       Thu Feb 23 12:31:17 2012 +0000
@@ -205,8 +205,8 @@ libxl_version_info = Struct("version_inf
 
 libxl_domain_create_info = Struct("domain_create_info",[
     ("type",         libxl_domain_type),
-    ("hap",          bool),
-    ("oos",          bool),
+    ("hap",          libxl_defbool),
+    ("oos",          libxl_defbool),
     ("ssidref",      uint32),
     ("name",         string),
     ("uuid",         libxl_uuid),
diff -r de102741f1e7 -r a27058f39b2c tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Thu Feb 23 12:31:17 2012 +0000
+++ b/tools/libxl/xl_cmdimpl.c  Thu Feb 23 12:31:17 2012 +0000
@@ -556,8 +556,7 @@ static void parse_config_data(const char
         !strncmp(buf, "hvm", strlen(buf)))
         c_info->type = LIBXL_DOMAIN_TYPE_HVM;
 
-    if (!xlu_cfg_get_long (config, "hap", &l, 0))
-        c_info->hap = l;
+    xlu_cfg_get_defbool(config, "hap", &c_info->hap, 0);
 
     if (xlu_cfg_replace_string (config, "name", &c_info->name, 0)) {
         fprintf(stderr, "Domain name must be specified.\n");
@@ -573,8 +572,7 @@ static void parse_config_data(const char
         libxl_uuid_generate(&c_info->uuid);
     }
 
-    if (!xlu_cfg_get_long(config, "oos", &l, 0))
-        c_info->oos = l;
+    xlu_cfg_get_defbool(config, "oos", &c_info->oos, 0);
 
     if (!xlu_cfg_get_string (config, "pool", &buf, 0)) {
         c_info->poolid = -1;
diff -r de102741f1e7 -r a27058f39b2c tools/libxl/xl_sxp.c
--- a/tools/libxl/xl_sxp.c      Thu Feb 23 12:31:17 2012 +0000
+++ b/tools/libxl/xl_sxp.c      Thu Feb 23 12:31:17 2012 +0000
@@ -41,8 +41,8 @@ void printf_info_sexp(int domid, libxl_d
     printf("(domain\n\t(domid %d)\n", domid);
     printf("\t(create_info)\n");
     printf("\t(hvm %d)\n", c_info->type == LIBXL_DOMAIN_TYPE_HVM);
-    printf("\t(hap %d)\n", c_info->hap);
-    printf("\t(oos %d)\n", c_info->oos);
+    printf("\t(hap %s)\n", libxl_defbool_to_string(c_info->hap));
+    printf("\t(oos %s)\n", libxl_defbool_to_string(c_info->oos));
     printf("\t(ssidref %d)\n", c_info->ssidref);
     printf("\t(name %s)\n", c_info->name);
 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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