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

[Xen-changelog] [xen-unstable] libxl: provide _init and _setdefault for libxl_domain_create_info.



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1330604773 0
# Node ID bf72799de4d6039da71771df01fa3567a6ea118e
# Parent  c3198eb7c0028d0293a3bb6d4de4b55b5aa63a81
libxl: provide _init and _setdefault for libxl_domain_create_info.

Some fields require further scaffolding before they can use the
_init/_setdefault scheme and are handled in later patches.

It doesn't seem reasonable for the library to pick a default for the domain
type so reject as invalid.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---


diff -r c3198eb7c002 -r bf72799de4d6 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Thu Mar 01 12:26:13 2012 +0000
+++ b/tools/libxl/libxl.h       Thu Mar 01 12:26:13 2012 +0000
@@ -356,7 +356,7 @@
 int libxl_ctx_postfork(libxl_ctx *ctx);
 
 /* domain related functions */
-int libxl_init_create_info(libxl_ctx *ctx, libxl_domain_create_info *c_info);
+void libxl_domain_create_info_init(libxl_domain_create_info *c_info);
 int libxl_init_build_info(libxl_ctx *ctx,
                           libxl_domain_build_info *b_info,
                           libxl_domain_create_info *c_info);
diff -r c3198eb7c002 -r bf72799de4d6 tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c        Thu Mar 01 12:26:13 2012 +0000
+++ b/tools/libxl/libxl_create.c        Thu Mar 01 12:26:13 2012 +0000
@@ -50,16 +50,19 @@
     libxl_domain_build_info_dispose(&d_config->b_info);
 }
 
-int libxl_init_create_info(libxl_ctx *ctx, libxl_domain_create_info *c_info)
+void libxl_domain_create_info_init(libxl_domain_create_info *c_info)
 {
     memset(c_info, '\0', sizeof(*c_info));
-    c_info->xsdata = NULL;
-    c_info->platformdata = NULL;
     c_info->hap = 1;
-    c_info->type = LIBXL_DOMAIN_TYPE_HVM;
     c_info->oos = 1;
-    c_info->ssidref = 0;
-    c_info->poolid = 0;
+}
+
+int libxl__domain_create_info_setdefault(libxl__gc *gc,
+                                         libxl_domain_create_info *c_info)
+{
+    if (!c_info->type)
+        return ERROR_INVAL;
+
     return 0;
 }
 
@@ -470,6 +473,9 @@
 
     domid = 0;
 
+    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 c3198eb7c002 -r bf72799de4d6 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c    Thu Mar 01 12:26:13 2012 +0000
+++ b/tools/libxl/libxl_dm.c    Thu Mar 01 12:26:13 2012 +0000
@@ -705,7 +705,7 @@
         goto out;
     }
 
-    memset(&dm_config.c_info, 0x00, sizeof(libxl_domain_create_info));
+    libxl_domain_create_info_init(&dm_config.c_info);
     dm_config.c_info.type = LIBXL_DOMAIN_TYPE_PV;
     dm_config.c_info.name = libxl__sprintf(gc, "%s-dm",
                                     libxl__domid_to_name(gc, guest_domid));
@@ -740,6 +740,9 @@
     dm_config.vifs = guest_config->vifs;
     dm_config.num_vifs = guest_config->num_vifs;
 
+    ret = libxl__domain_create_info_setdefault(gc, &dm_config.c_info);
+    if (ret) goto out;
+
     libxl__vfb_and_vkb_from_hvm_guest_config(gc, guest_config, &vfb, &vkb);
     dm_config.vfbs = &vfb;
     dm_config.num_vfbs = 1;
diff -r c3198eb7c002 -r bf72799de4d6 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h      Thu Mar 01 12:26:13 2012 +0000
+++ b/tools/libxl/libxl_internal.h      Thu Mar 01 12:26:13 2012 +0000
@@ -187,6 +187,8 @@
  * version of the _evdisable_FOO function; the internal one is
  * used during cleanup.
  */
+_hidden int libxl__domain_create_info_setdefault(libxl__gc *gc,
+                                        libxl_domain_create_info *c_info);
 
 struct libxl__evgen_domain_death {
     uint32_t domid;
diff -r c3198eb7c002 -r bf72799de4d6 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Thu Mar 01 12:26:13 2012 +0000
+++ b/tools/libxl/xl_cmdimpl.c  Thu Mar 01 12:26:13 2012 +0000
@@ -535,8 +535,7 @@
         exit(1);
     }
 
-    if (libxl_init_create_info(ctx, c_info))
-        exit(1);
+    libxl_domain_create_info_init(c_info);
 
     if (!xlu_cfg_get_string (config, "seclabel", &buf, 0)) {
         e = libxl_flask_context_to_sid(ctx, (char *)buf, strlen(buf),

_______________________________________________
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®.