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

[Xen-changelog] [xen-unstable] libxl: introduce a descriminating default value for memkb fields.



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1330604774 0
# Node ID 66d0a12239dac983785c0a692f4f1b5f2501cbd2
# Parent  0f0f126f4a99a35a89f6136c74a046ababfd7645
libxl: introduce a descriminating default value for memkb fields.

Consitently make such fields 64 bit values as used by dominfo.

It is not clear if ->video_memkb and/or shadow_memkb shouldn't be part of
->u.hvm but I have not changed that here.

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


diff -r 0f0f126f4a99 -r 66d0a12239da tools/libxl/gentest.py
--- a/tools/libxl/gentest.py    Thu Mar 01 12:26:14 2012 +0000
+++ b/tools/libxl/gentest.py    Thu Mar 01 12:26:14 2012 +0000
@@ -197,6 +197,7 @@
 }
 """)
     for ty in builtins + types:
+        if isinstance(ty, idl.Number): continue
         if ty.typename not in handcoded:
             f.write("static void %s_rand_init(%s);\n" % \
                     (ty.typename,
diff -r 0f0f126f4a99 -r 66d0a12239da tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Thu Mar 01 12:26:14 2012 +0000
+++ b/tools/libxl/libxl.h       Thu Mar 01 12:26:14 2012 +0000
@@ -246,6 +246,7 @@
 typedef struct libxl__ctx libxl_ctx;
 
 #define LIBXL_TIMER_MODE_DEFAULT -1
+#define LIBXL_MEMKB_DEFAULT ~0ULL
 
 #include "_libxl_types.h"
 
diff -r 0f0f126f4a99 -r 66d0a12239da tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c        Thu Mar 01 12:26:14 2012 +0000
+++ b/tools/libxl/libxl_create.c        Thu Mar 01 12:26:14 2012 +0000
@@ -70,19 +70,20 @@
                                   const libxl_domain_create_info *c_info)
 {
     memset(b_info, '\0', sizeof(*b_info));
-    b_info->max_memkb = 32 * 1024;
-    b_info->target_memkb = b_info->max_memkb;
     b_info->disable_migrate = 0;
     b_info->cpuid = NULL;
-    b_info->shadow_memkb = 0;
     b_info->type = c_info->type;
 
+    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;
+
     b_info->device_model_stubdomain = false;
     b_info->device_model = NULL;
 
     switch (b_info->type) {
     case LIBXL_DOMAIN_TYPE_HVM:
-        b_info->video_memkb = 8 * 1024;
         b_info->u.hvm.firmware = NULL;
         b_info->u.hvm.bios = 0;
         b_info->u.hvm.pae = 1;
@@ -133,8 +134,17 @@
         libxl_cpumap_set_any(&b_info->cpumap);
     }
 
+    if (b_info->max_memkb == LIBXL_MEMKB_DEFAULT)
+        b_info->max_memkb = 32 * 1024;
+    if (b_info->target_memkb == LIBXL_MEMKB_DEFAULT)
+        b_info->target_memkb = b_info->max_memkb;
+
     switch (b_info->type) {
     case LIBXL_DOMAIN_TYPE_HVM:
+        if (b_info->shadow_memkb == LIBXL_MEMKB_DEFAULT)
+            b_info->shadow_memkb = 0;
+        if (b_info->video_memkb == LIBXL_MEMKB_DEFAULT)
+            b_info->video_memkb = 8 * 1024;
         if (b_info->u.hvm.timer_mode == LIBXL_TIMER_MODE_DEFAULT)
             b_info->u.hvm.timer_mode =
                 LIBXL_TIMER_MODE_NO_DELAY_FOR_MISSED_TICKS;
@@ -153,6 +163,10 @@
 
         break;
     case LIBXL_DOMAIN_TYPE_PV:
+        if (b_info->shadow_memkb == LIBXL_MEMKB_DEFAULT)
+            b_info->shadow_memkb = 0;
+        if (b_info->u.pv.slack_memkb == LIBXL_MEMKB_DEFAULT)
+            b_info->u.pv.slack_memkb = 0;
         break;
     default:
         LIBXL__LOG(CTX, LIBXL__LOG_ERROR,
diff -r 0f0f126f4a99 -r 66d0a12239da tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c   Thu Mar 01 12:26:14 2012 +0000
+++ b/tools/libxl/libxl_dom.c   Thu Mar 01 12:26:14 2012 +0000
@@ -129,11 +129,12 @@
 
     ents = libxl__calloc(gc, 12 + (info->max_vcpus * 2) + 2, sizeof(char *));
     ents[0] = "memory/static-max";
-    ents[1] = libxl__sprintf(gc, "%d", info->max_memkb);
+    ents[1] = libxl__sprintf(gc, "%"PRId64, info->max_memkb);
     ents[2] = "memory/target";
-    ents[3] = libxl__sprintf(gc, "%d", info->target_memkb - info->video_memkb);
+    ents[3] = libxl__sprintf(gc, "%"PRId64,
+                             info->target_memkb - info->video_memkb);
     ents[4] = "memory/videoram";
-    ents[5] = libxl__sprintf(gc, "%d", info->video_memkb);
+    ents[5] = libxl__sprintf(gc, "%"PRId64, info->video_memkb);
     ents[6] = "domid";
     ents[7] = libxl__sprintf(gc, "%d", domid);
     ents[8] = "store/port";
diff -r 0f0f126f4a99 -r 66d0a12239da tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl       Thu Mar 01 12:26:14 2012 +0000
+++ b/tools/libxl/libxl_types.idl       Thu Mar 01 12:26:14 2012 +0000
@@ -18,6 +18,12 @@
 libxl_hwcap = Builtin("hwcap", passby=PASS_BY_REFERENCE)
 
 #
+# Specific integer types
+#
+
+MemKB = UInt(64, init_val = "LIBXL_MEMKB_DEFAULT")
+
+#
 # Constants / Enumerations
 #
 
@@ -170,9 +176,9 @@
     # Otherwise set to a value guaranteed not to clash with any valid
     # LIBXL_SHUTDOWN_REASON_* constant.
     ("shutdown_reason", libxl_shutdown_reason),
-    ("current_memkb",   uint64),
-    ("shared_memkb", uint64),
-    ("max_memkb",   uint64),
+    ("current_memkb",   MemKB),
+    ("shared_memkb", MemKB),
+    ("max_memkb",   MemKB),
     ("cpu_time",    uint64),
     ("vcpu_max_id", uint32),
     ("vcpu_online", uint32),
@@ -228,10 +234,10 @@
     ("cur_vcpus",       integer),
     ("cpumap",          libxl_cpumap),
     ("tsc_mode",        libxl_tsc_mode),
-    ("max_memkb",       uint32),
-    ("target_memkb",    uint32),
-    ("video_memkb",     uint32),
-    ("shadow_memkb",    uint32),
+    ("max_memkb",       MemKB),
+    ("target_memkb",    MemKB),
+    ("video_memkb",     MemKB),
+    ("shadow_memkb",    MemKB),
     ("disable_migrate", bool),
     ("cpuid",           libxl_cpuid_policy_list),
     ("type",            libxl_domain_type),
@@ -286,7 +292,7 @@
                                        ("xen_platform_pci", bool),
                                        ])),
                  ("pv", Struct(None, [("kernel", libxl_file_reference),
-                                      ("slack_memkb", uint32),
+                                      ("slack_memkb", MemKB),
                                       ("bootloader", string),
                                       ("bootloader_args", libxl_string_list),
                                       ("cmdline", string),
diff -r 0f0f126f4a99 -r 66d0a12239da tools/libxl/xl_sxp.c
--- a/tools/libxl/xl_sxp.c      Thu Mar 01 12:26:14 2012 +0000
+++ b/tools/libxl/xl_sxp.c      Thu Mar 01 12:26:14 2012 +0000
@@ -21,6 +21,7 @@
 #include "libxl_osdeps.h"
 
 #include <stdlib.h>
+#include <inttypes.h>
 
 #include "libxl.h"
 #include "libxl_utils.h"
@@ -68,8 +69,8 @@
     printf("\t(build_info)\n");
     printf("\t(max_vcpus %d)\n", b_info->max_vcpus);
     printf("\t(tsc_mode %s)\n", libxl_tsc_mode_to_string(b_info->tsc_mode));
-    printf("\t(max_memkb %d)\n", b_info->max_memkb);
-    printf("\t(target_memkb %d)\n", b_info->target_memkb);
+    printf("\t(max_memkb %"PRId64")\n", b_info->max_memkb);
+    printf("\t(target_memkb %"PRId64")\n", b_info->target_memkb);
     printf("\t(nomigrate %d)\n", b_info->disable_migrate);
 
     if (c_info->type == LIBXL_DOMAIN_TYPE_PV && b_info->u.pv.bootloader) {
@@ -88,8 +89,8 @@
     case LIBXL_DOMAIN_TYPE_HVM:
         printf("\t\t(hvm\n");
         printf("\t\t\t(firmware %s)\n", b_info->u.hvm.firmware);
-        printf("\t\t\t(video_memkb %d)\n", b_info->video_memkb);
-        printf("\t\t\t(shadow_memkb %d)\n", b_info->shadow_memkb);
+        printf("\t\t\t(video_memkb %"PRId64")\n", b_info->video_memkb);
+        printf("\t\t\t(shadow_memkb %"PRId64")\n", b_info->shadow_memkb);
         printf("\t\t\t(pae %d)\n", b_info->u.hvm.pae);
         printf("\t\t\t(apic %d)\n", b_info->u.hvm.apic);
         printf("\t\t\t(acpi %d)\n", b_info->u.hvm.acpi);

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