render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
7a3408
From 524df098e7b82ea193e9f81b1244fae5cff0a937 Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <524df098e7b82ea193e9f81b1244fae5cff0a937@dist-git>
7a3408
From: Peter Krempa <pkrempa@redhat.com>
7a3408
Date: Tue, 22 Sep 2015 16:59:43 +0200
7a3408
Subject: [PATCH] conf: Rename max_balloon to total_memory
7a3408
7a3408
https://bugzilla.redhat.com/show_bug.cgi?id=1252685
7a3408
7a3408
The name of the variable was misleading. Rename it and it's setting
7a3408
accessor before other fixes.
7a3408
7a3408
(cherry picked from commit 8059a99025d15b12e62a294b7b6797e4c618eff8)
7a3408
7a3408
Conflicts:
7a3408
	src/libxl/libxl_driver.c - libxlAddDom0 is missing in RHEL
7a3408
7a3408
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7a3408
---
7a3408
 src/conf/domain_conf.c     | 18 +++++++++---------
7a3408
 src/conf/domain_conf.h     |  7 ++++---
7a3408
 src/hyperv/hyperv_driver.c |  2 +-
7a3408
 src/libvirt_private.syms   |  2 +-
7a3408
 src/libxl/libxl_driver.c   |  2 +-
7a3408
 src/lxc/lxc_driver.c       |  2 +-
7a3408
 src/lxc/lxc_native.c       |  4 ++--
7a3408
 src/phyp/phyp_driver.c     |  2 +-
7a3408
 src/qemu/qemu_command.c    |  4 ++--
7a3408
 src/qemu/qemu_domain.c     |  2 +-
7a3408
 src/qemu/qemu_driver.c     |  2 +-
7a3408
 src/test/test_driver.c     |  2 +-
7a3408
 src/uml/uml_driver.c       |  2 +-
7a3408
 src/vbox/vbox_common.c     |  4 ++--
7a3408
 src/vmx/vmx.c              |  2 +-
7a3408
 src/vz/vz_sdk.c            |  2 +-
7a3408
 src/xen/xm_internal.c      |  2 +-
7a3408
 src/xenapi/xenapi_driver.c |  2 +-
7a3408
 src/xenconfig/xen_common.c |  2 +-
7a3408
 src/xenconfig/xen_sxpr.c   |  2 +-
7a3408
 20 files changed, 34 insertions(+), 33 deletions(-)
7a3408
7a3408
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
7a3408
index 1e32557..b28daa6 100644
7a3408
--- a/src/conf/domain_conf.c
7a3408
+++ b/src/conf/domain_conf.c
7a3408
@@ -7672,27 +7672,27 @@ virDomainDefGetMemoryInitial(virDomainDefPtr def)
7a3408
     if ((ret = virDomainNumaGetMemorySize(def->numa)) > 0) {
7a3408
         return ret;
7a3408
     } else {
7a3408
-        ret = def->mem.max_balloon;
7a3408
+        ret = def->mem.total_memory;
7a3408
         for (i = 0; i < def->nmems; i++)
7a3408
             ret -= def->mems[i]->size;
7a3408
     }
7a3408
 
7a3408
-    return def->mem.max_balloon;
7a3408
+    return def->mem.total_memory;
7a3408
 }
7a3408
 
7a3408
 
7a3408
 /**
7a3408
- * virDomainDefSetMemoryInitial:
7a3408
+ * virDomainDefSetMemoryTotal:
7a3408
  * @def: domain definition
7a3408
  * @size: size to set
7a3408
  *
7a3408
- * Sets the initial memory size in @def.
7a3408
+ * Sets the total memory size in @def.
7a3408
  */
7a3408
 void
7a3408
-virDomainDefSetMemoryInitial(virDomainDefPtr def,
7a3408
-                             unsigned long long size)
7a3408
+virDomainDefSetMemoryTotal(virDomainDefPtr def,
7a3408
+                           unsigned long long size)
7a3408
 {
7a3408
-    def->mem.max_balloon = size;
7a3408
+    def->mem.total_memory = size;
7a3408
 }
7a3408
 
7a3408
 
7a3408
@@ -7714,7 +7714,7 @@ virDomainDefGetMemoryActual(virDomainDefPtr def)
7a3408
         for (i = 0; i < def->nmems; i++)
7a3408
             ret += def->mems[i]->size;
7a3408
     } else {
7a3408
-        ret = def->mem.max_balloon;
7a3408
+        ret = def->mem.total_memory;
7a3408
     }
7a3408
 
7a3408
     return ret;
7a3408
@@ -14611,7 +14611,7 @@ virDomainDefParseXML(xmlDocPtr xml,
7a3408
 
7a3408
     /* Extract domain memory */
7a3408
     if (virDomainParseMemory("./memory[1]", NULL, ctxt,
7a3408
-                             &def->mem.max_balloon, false, true) < 0)
7a3408
+                             &def->mem.total_memory, false, true) < 0)
7a3408
         goto error;
7a3408
 
7a3408
     if (virDomainParseMemory("./currentMemory[1]", NULL, ctxt,
7a3408
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
7a3408
index bac64b3..8099450 100644
7a3408
--- a/src/conf/domain_conf.h
7a3408
+++ b/src/conf/domain_conf.h
7a3408
@@ -2106,8 +2106,9 @@ typedef struct _virDomainMemtune virDomainMemtune;
7a3408
 typedef virDomainMemtune *virDomainMemtunePtr;
7a3408
 
7a3408
 struct _virDomainMemtune {
7a3408
-    unsigned long long max_balloon; /* in kibibytes, capped at ulong thanks
7a3408
-                                       to virDomainGetMaxMemory */
7a3408
+    /* total memory size including memory modules in kibibytes, this field
7a3408
+     * should be accessed only via accessors */
7a3408
+    unsigned long long total_memory;
7a3408
     unsigned long long cur_balloon; /* in kibibytes, capped at ulong thanks
7a3408
                                        to virDomainGetInfo */
7a3408
 
7a3408
@@ -2286,7 +2287,7 @@ struct _virDomainDef {
7a3408
 };
7a3408
 
7a3408
 unsigned long long virDomainDefGetMemoryInitial(virDomainDefPtr def);
7a3408
-void virDomainDefSetMemoryInitial(virDomainDefPtr def, unsigned long long size);
7a3408
+void virDomainDefSetMemoryTotal(virDomainDefPtr def, unsigned long long size);
7a3408
 unsigned long long virDomainDefGetMemoryActual(virDomainDefPtr def);
7a3408
 bool virDomainDefHasMemoryHotplug(const virDomainDef *def);
7a3408
 
7a3408
diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
7a3408
index b539541..1958bbe 100644
7a3408
--- a/src/hyperv/hyperv_driver.c
7a3408
+++ b/src/hyperv/hyperv_driver.c
7a3408
@@ -870,7 +870,7 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
7a3408
     if (VIR_STRDUP(def->description, virtualSystemSettingData->data->Notes) < 0)
7a3408
         goto cleanup;
7a3408
 
7a3408
-    virDomainDefSetMemoryInitial(def, memorySettingData->data->Limit * 1024); /* megabyte to kilobyte */
7a3408
+    virDomainDefSetMemoryTotal(def, memorySettingData->data->Limit * 1024); /* megabyte to kilobyte */
7a3408
     def->mem.cur_balloon = memorySettingData->data->VirtualQuantity * 1024; /* megabyte to kilobyte */
7a3408
 
7a3408
     def->vcpus = processorSettingData->data->VirtualQuantity;
7a3408
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
7a3408
index 335f8d0..b1b59b2 100644
7a3408
--- a/src/libvirt_private.syms
7a3408
+++ b/src/libvirt_private.syms
7a3408
@@ -225,7 +225,7 @@ virDomainDefParseFile;
7a3408
 virDomainDefParseNode;
7a3408
 virDomainDefParseString;
7a3408
 virDomainDefPostParse;
7a3408
-virDomainDefSetMemoryInitial;
7a3408
+virDomainDefSetMemoryTotal;
7a3408
 virDomainDeleteConfig;
7a3408
 virDomainDeviceAddressIsValid;
7a3408
 virDomainDeviceAddressTypeToString;
7a3408
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
7a3408
index 149ef70..f48bcf4 100644
7a3408
--- a/src/libxl/libxl_driver.c
7a3408
+++ b/src/libxl/libxl_driver.c
7a3408
@@ -1413,7 +1413,7 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
7a3408
         if (flags & VIR_DOMAIN_MEM_CONFIG) {
7a3408
             /* Help clang 2.8 decipher the logic flow.  */
7a3408
             sa_assert(persistentDef);
7a3408
-            virDomainDefSetMemoryInitial(persistentDef, newmem);
7a3408
+            virDomainDefSetMemoryTotal(persistentDef, newmem);
7a3408
             if (persistentDef->mem.cur_balloon > newmem)
7a3408
                 persistentDef->mem.cur_balloon = newmem;
7a3408
             ret = virDomainSaveConfig(cfg->configDir, persistentDef);
7a3408
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
7a3408
index 79f92c3..9a6e44e 100644
7a3408
--- a/src/lxc/lxc_driver.c
7a3408
+++ b/src/lxc/lxc_driver.c
7a3408
@@ -734,7 +734,7 @@ static int lxcDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
7a3408
         }
7a3408
 
7a3408
         if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
7a3408
-            virDomainDefSetMemoryInitial(persistentDef, newmem);
7a3408
+            virDomainDefSetMemoryTotal(persistentDef, newmem);
7a3408
             if (persistentDef->mem.cur_balloon > newmem)
7a3408
                 persistentDef->mem.cur_balloon = newmem;
7a3408
             if (virDomainSaveConfig(cfg->configDir, persistentDef) < 0)
7a3408
diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
7a3408
index 6faa701..2f95597 100644
7a3408
--- a/src/lxc/lxc_native.c
7a3408
+++ b/src/lxc/lxc_native.c
7a3408
@@ -770,7 +770,7 @@ lxcSetMemTune(virDomainDefPtr def, virConfPtr properties)
7a3408
         if (lxcConvertSize(value->str, &size) < 0)
7a3408
             return -1;
7a3408
         size = size / 1024;
7a3408
-        virDomainDefSetMemoryInitial(def, size);
7a3408
+        virDomainDefSetMemoryTotal(def, size);
7a3408
         def->mem.hard_limit = virMemoryLimitTruncate(size);
7a3408
     }
7a3408
 
7a3408
@@ -1010,7 +1010,7 @@ lxcParseConfigString(const char *config)
7a3408
     }
7a3408
 
7a3408
     vmdef->id = -1;
7a3408
-    virDomainDefSetMemoryInitial(vmdef, 64 * 1024);
7a3408
+    virDomainDefSetMemoryTotal(vmdef, 64 * 1024);
7a3408
 
7a3408
     vmdef->onReboot = VIR_DOMAIN_LIFECYCLE_RESTART;
7a3408
     vmdef->onCrash = VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY;
7a3408
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
7a3408
index 54dec70..2912fc4 100644
7a3408
--- a/src/phyp/phyp_driver.c
7a3408
+++ b/src/phyp/phyp_driver.c
7a3408
@@ -3281,7 +3281,7 @@ phypDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
7a3408
         goto err;
7a3408
     }
7a3408
 
7a3408
-    virDomainDefSetMemoryInitial(&def, memory);
7a3408
+    virDomainDefSetMemoryTotal(&def, memory);
7a3408
 
7a3408
     if ((def.mem.cur_balloon =
7a3408
          phypGetLparMem(dom->conn, managed_system, dom->id, 1)) == 0) {
7a3408
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
7a3408
index ade75e3..3fd695b 100644
7a3408
--- a/src/qemu/qemu_command.c
7a3408
+++ b/src/qemu/qemu_command.c
7a3408
@@ -12724,7 +12724,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
7a3408
 
7a3408
     def->id = -1;
7a3408
     def->mem.cur_balloon = 64 * 1024;
7a3408
-    virDomainDefSetMemoryInitial(def, def->mem.cur_balloon);
7a3408
+    virDomainDefSetMemoryTotal(def, def->mem.cur_balloon);
7a3408
     def->maxvcpus = 1;
7a3408
     def->vcpus = 1;
7a3408
     def->clock.offset = VIR_DOMAIN_CLOCK_OFFSET_UTC;
7a3408
@@ -12930,7 +12930,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
7a3408
                                _("cannot parse memory level '%s'"), val);
7a3408
                 goto error;
7a3408
             }
7a3408
-            virDomainDefSetMemoryInitial(def, mem * 1024);
7a3408
+            virDomainDefSetMemoryTotal(def, mem * 1024);
7a3408
             def->mem.cur_balloon = mem * 1024;
7a3408
         } else if (STREQ(arg, "-smp")) {
7a3408
             WANT_VALUE();
7a3408
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
7a3408
index 15cdf7b..67c2bb0 100644
7a3408
--- a/src/qemu/qemu_domain.c
7a3408
+++ b/src/qemu/qemu_domain.c
7a3408
@@ -3184,7 +3184,7 @@ qemuDomainAlignMemorySizes(virDomainDefPtr def)
7a3408
 
7a3408
     /* align initial memory size */
7a3408
     mem = virDomainDefGetMemoryInitial(def);
7a3408
-    virDomainDefSetMemoryInitial(def, VIR_ROUND_UP(mem, align));
7a3408
+    virDomainDefSetMemoryTotal(def, VIR_ROUND_UP(mem, align));
7a3408
 
7a3408
     def->mem.max_memory = VIR_ROUND_UP(def->mem.max_memory, align);
7a3408
 
7a3408
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
7a3408
index f15b14a..e77e548 100644
7a3408
--- a/src/qemu/qemu_driver.c
7a3408
+++ b/src/qemu/qemu_driver.c
7a3408
@@ -2370,7 +2370,7 @@ static int qemuDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
7a3408
                 goto endjob;
7a3408
             }
7a3408
 
7a3408
-            virDomainDefSetMemoryInitial(persistentDef, newmem);
7a3408
+            virDomainDefSetMemoryTotal(persistentDef, newmem);
7a3408
 
7a3408
             if (persistentDef->mem.cur_balloon > newmem)
7a3408
                 persistentDef->mem.cur_balloon = newmem;
7a3408
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
7a3408
index d38006f..9dcfe11 100644
7a3408
--- a/src/test/test_driver.c
7a3408
+++ b/src/test/test_driver.c
7a3408
@@ -2256,7 +2256,7 @@ static int testDomainSetMaxMemory(virDomainPtr domain,
7a3408
         return -1;
7a3408
 
7a3408
     /* XXX validate not over host memory wrt to other domains */
7a3408
-    virDomainDefSetMemoryInitial(privdom->def, memory);
7a3408
+    virDomainDefSetMemoryTotal(privdom->def, memory);
7a3408
 
7a3408
     virDomainObjEndAPI(&privdom);
7a3408
     return 0;
7a3408
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
7a3408
index c3c5fa7..2b61f73 100644
7a3408
--- a/src/uml/uml_driver.c
7a3408
+++ b/src/uml/uml_driver.c
7a3408
@@ -1828,7 +1828,7 @@ static int umlDomainSetMaxMemory(virDomainPtr dom, unsigned long newmax)
7a3408
         goto cleanup;
7a3408
     }
7a3408
 
7a3408
-    virDomainDefSetMemoryInitial(vm->def, newmax);
7a3408
+    virDomainDefSetMemoryTotal(vm->def, newmax);
7a3408
     ret = 0;
7a3408
 
7a3408
  cleanup:
7a3408
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
7a3408
index 91a61f8..3e6ed7a 100644
7a3408
--- a/src/vbox/vbox_common.c
7a3408
+++ b/src/vbox/vbox_common.c
7a3408
@@ -3898,7 +3898,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
7a3408
      * reading and while dumping xml
7a3408
      */
7a3408
     /* def->mem.max_balloon = maxMemorySize * 1024; */
7a3408
-    virDomainDefSetMemoryInitial(def, memorySize * 1024);
7a3408
+    virDomainDefSetMemoryTotal(def, memorySize * 1024);
7a3408
 
7a3408
     gVBoxAPI.UIMachine.GetCPUCount(machine, &CPUCount);
7a3408
     def->maxvcpus = def->vcpus = CPUCount;
7a3408
@@ -6051,7 +6051,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
7a3408
          * the notation here seems to be inconsistent while
7a3408
          * reading and while dumping xml
7a3408
          */
7a3408
-        virDomainDefSetMemoryInitial(def->dom, memorySize * 1024);
7a3408
+        virDomainDefSetMemoryTotal(def->dom, memorySize * 1024);
7a3408
         def->dom->os.type = VIR_DOMAIN_OSTYPE_HVM;
7a3408
         def->dom->os.arch = virArchFromHost();
7a3408
         gVBoxAPI.UIMachine.GetCPUCount(machine, &CPUCount);
7a3408
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
7a3408
index 9ba5848..84f71f7 100644
7a3408
--- a/src/vmx/vmx.c
7a3408
+++ b/src/vmx/vmx.c
7a3408
@@ -1379,7 +1379,7 @@ virVMXParseConfig(virVMXContext *ctx,
7a3408
         goto cleanup;
7a3408
     }
7a3408
 
7a3408
-    virDomainDefSetMemoryInitial(def, memsize * 1024); /* Scale from megabytes to kilobytes */
7a3408
+    virDomainDefSetMemoryTotal(def, memsize * 1024); /* Scale from megabytes to kilobytes */
7a3408
 
7a3408
     /* vmx:sched.mem.max -> def:mem.cur_balloon */
7a3408
     if (virVMXGetConfigLong(conf, "sched.mem.max", &sched_mem_max, memsize,
7a3408
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
7a3408
index a584940..61a0897 100644
7a3408
--- a/src/vz/vz_sdk.c
7a3408
+++ b/src/vz/vz_sdk.c
7a3408
@@ -1300,7 +1300,7 @@ prlsdkLoadDomain(vzConnPtr privconn,
7a3408
     /* get RAM parameters */
7a3408
     pret = PrlVmCfg_GetRamSize(sdkdom, &ram;;
7a3408
     prlsdkCheckRetGoto(pret, error);
7a3408
-    virDomainDefSetMemoryInitial(def, ram << 10); /* RAM size obtained in Mbytes,
7a3408
+    virDomainDefSetMemoryTotal(def, ram << 10); /* RAM size obtained in Mbytes,
7a3408
                                                      convert to Kbytes */
7a3408
     def->mem.cur_balloon = ram << 10;
7a3408
 
7a3408
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
7a3408
index 59b1cd4..baa7815 100644
7a3408
--- a/src/xen/xm_internal.c
7a3408
+++ b/src/xen/xm_internal.c
7a3408
@@ -606,7 +606,7 @@ xenXMDomainSetMaxMemory(virConnectPtr conn,
7a3408
     if (entry->def->mem.cur_balloon > memory)
7a3408
         entry->def->mem.cur_balloon = memory;
7a3408
 
7a3408
-    virDomainDefSetMemoryInitial(entry->def, memory);
7a3408
+    virDomainDefSetMemoryTotal(entry->def, memory);
7a3408
     /* If this fails, should we try to undo our changes to the
7a3408
      * in-memory representation of the config file. I say not!
7a3408
      */
7a3408
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
7a3408
index 11f6e91..3045c5a 100644
7a3408
--- a/src/xenapi/xenapi_driver.c
7a3408
+++ b/src/xenapi/xenapi_driver.c
7a3408
@@ -1492,7 +1492,7 @@ xenapiDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
7a3408
         VIR_FREE(val);
7a3408
     }
7a3408
     memory = xenapiDomainGetMaxMemory(dom);
7a3408
-    virDomainDefSetMemoryInitial(defPtr, memory);
7a3408
+    virDomainDefSetMemoryTotal(defPtr, memory);
7a3408
     if (xen_vm_get_memory_dynamic_max(session, &dynamic_mem, vm)) {
7a3408
         defPtr->mem.cur_balloon = (unsigned long) (dynamic_mem / 1024);
7a3408
     } else {
7a3408
diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
7a3408
index 0dfe60e..0890c73 100644
7a3408
--- a/src/xenconfig/xen_common.c
7a3408
+++ b/src/xenconfig/xen_common.c
7a3408
@@ -316,7 +316,7 @@ xenParseMem(virConfPtr conf, virDomainDefPtr def)
7a3408
         return -1;
7a3408
 
7a3408
     def->mem.cur_balloon *= 1024;
7a3408
-    virDomainDefSetMemoryInitial(def, memory * 1024);
7a3408
+    virDomainDefSetMemoryTotal(def, memory * 1024);
7a3408
 
7a3408
     return 0;
7a3408
 }
7a3408
diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c
7a3408
index 05e938a..66f67b5 100644
7a3408
--- a/src/xenconfig/xen_sxpr.c
7a3408
+++ b/src/xenconfig/xen_sxpr.c
7a3408
@@ -1154,7 +1154,7 @@ xenParseSxpr(const struct sexpr *root,
7a3408
         }
7a3408
     }
7a3408
 
7a3408
-    virDomainDefSetMemoryInitial(def, (sexpr_u64(root, "domain/maxmem") << 10));
7a3408
+    virDomainDefSetMemoryTotal(def, (sexpr_u64(root, "domain/maxmem") << 10));
7a3408
     def->mem.cur_balloon = (sexpr_u64(root, "domain/memory") << 10);
7a3408
 
7a3408
     if (def->mem.cur_balloon > virDomainDefGetMemoryActual(def))
7a3408
-- 
7a3408
2.5.3
7a3408