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

[Xen-devel] [PATCH 23 of 26 V3] libxl: add libxl_domain_build_info_init_type



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1330000278 0
# Node ID 36a4fefcb0c78946a81c93c68302c9344a603f06
# Parent  1953cd5c411dfbf2f83f17b7de7063e05e441045
libxl: add libxl_domain_build_info_init_type

Use instead of parameterising libxl_domain_build_info_init. This allows callers
to initialise a libxl_domain_build_info but not to commit to a particular type
later on (e.g. after they've parsed the domain config)

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

diff -r 1953cd5c411d -r 36a4fefcb0c7 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Thu Feb 23 12:31:18 2012 +0000
+++ b/tools/libxl/libxl.h       Thu Feb 23 12:31:18 2012 +0000
@@ -382,8 +382,9 @@ int libxl_ctx_postfork(libxl_ctx *ctx);
 
 /* domain related functions */
 void libxl_domain_create_info_init(libxl_domain_create_info *c_info);
-void libxl_domain_build_info_init(libxl_domain_build_info *b_info,
-                          const libxl_domain_create_info *c_info);
+void libxl_domain_build_info_init(libxl_domain_build_info *b_info);
+void libxl_domain_build_info_init_type(libxl_domain_build_info *b_info,
+                                       libxl_domain_type type);
 typedef int (*libxl_console_ready)(libxl_ctx *ctx, uint32_t domid, void *priv);
 int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config, 
libxl_console_ready cb, void *priv, uint32_t *domid);
 int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config, 
libxl_console_ready cb, void *priv, uint32_t *domid, int restore_fd);
diff -r 1953cd5c411d -r 36a4fefcb0c7 tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c        Thu Feb 23 12:31:18 2012 +0000
+++ b/tools/libxl/libxl_create.c        Thu Feb 23 12:31:18 2012 +0000
@@ -69,23 +69,29 @@ int libxl__domain_create_info_setdefault
     return 0;
 }
 
-void libxl_domain_build_info_init(libxl_domain_build_info *b_info,
-                                  const libxl_domain_create_info *c_info)
+void libxl_domain_build_info_init(libxl_domain_build_info *b_info)
 {
     memset(b_info, '\0', sizeof(*b_info));
-    b_info->type = c_info->type;
+    b_info->type = -1;
 
     b_info->max_memkb = LIBXL_MEMKB_DEFAULT;
     b_info->target_memkb = LIBXL_MEMKB_DEFAULT;
     b_info->shadow_memkb = LIBXL_MEMKB_DEFAULT;
     b_info->video_memkb =  LIBXL_MEMKB_DEFAULT;
 
+}
+
+void libxl_domain_build_info_init_type(libxl_domain_build_info *b_info,
+                                       libxl_domain_type type)
+{
+    assert(b_info->type == -1);
+    b_info->type = type;
     switch (b_info->type) {
     case LIBXL_DOMAIN_TYPE_HVM:
         b_info->u.hvm.timer_mode = LIBXL_TIMER_MODE_DEFAULT;
         break;
     case LIBXL_DOMAIN_TYPE_PV:
-        b_info->u.pv.slack_memkb = 0;
+        b_info->u.pv.slack_memkb = LIBXL_MEMKB_DEFAULT;
         break;
     default:
         abort();
diff -r 1953cd5c411d -r 36a4fefcb0c7 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c    Thu Feb 23 12:31:18 2012 +0000
+++ b/tools/libxl/libxl_dm.c    Thu Feb 23 12:31:18 2012 +0000
@@ -711,7 +711,8 @@ static int libxl__create_stubdom(libxl__
 
     libxl_uuid_generate(&dm_config.c_info.uuid);
 
-    libxl_domain_build_info_init(&dm_config.b_info, &dm_config.c_info);
+    libxl_domain_build_info_init(&dm_config.b_info);
+    libxl_domain_build_info_init_type(&dm_config.b_info, LIBXL_DOMAIN_TYPE_PV);
 
     dm_config.b_info.max_vcpus = 1;
     dm_config.b_info.max_memkb = 32 * 1024;
diff -r 1953cd5c411d -r 36a4fefcb0c7 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Thu Feb 23 12:31:18 2012 +0000
+++ b/tools/libxl/xl_cmdimpl.c  Thu Feb 23 12:31:18 2012 +0000
@@ -583,7 +583,8 @@ static void parse_config_data(const char
         exit(1);
     }
 
-    libxl_domain_build_info_init(b_info, c_info);
+    libxl_domain_build_info_init(b_info);
+    libxl_domain_build_info_init_type(b_info, c_info->type);
 
     /* the following is the actual config parsing with overriding values in 
the structures */
     if (!xlu_cfg_get_long (config, "vcpus", &l, 0)) {
@@ -700,7 +701,7 @@ static void parse_config_data(const char
     if (!xlu_cfg_get_long (config, "videoram", &l, 0))
         b_info->video_memkb = l * 1024;
 
-    switch(c_info->type) {
+    switch(b_info->type) {
     case LIBXL_DOMAIN_TYPE_HVM:
         if (!xlu_cfg_get_string (config, "kernel", &buf, 0))
             fprintf(stderr, "WARNING: ignoring \"kernel\" directive for HVM 
guest. "

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