[PATCH 1/3] qemu_domain.c: make qemuDomainGetMemoryModuleSizeAlignment() public

Daniel Henrique Barboza danielhb413 at gmail.com
Sat Feb 29 17:51:12 UTC 2020


This function will be used in qemu_hotplug.c in the next patch.

While we're at it, we can remove the virDomainMemoryDef argument
since the alignment size doesn't change with this object. The
only existent caller can also be brought out of a loop which
iterates in a virDomainMemoryDef list.

Signed-off-by: Daniel Henrique Barboza <danielhb413 at gmail.com>
---
 src/qemu/qemu_domain.c | 7 +++----
 src/qemu/qemu_domain.h | 2 ++
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 3dfa71650d..27f400005e 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -12308,9 +12308,8 @@ qemuDomainGetMemorySizeAlignment(virDomainDefPtr def)
 }
 
 
-static unsigned long long
-qemuDomainGetMemoryModuleSizeAlignment(const virDomainDef *def,
-                                       const virDomainMemoryDef *mem G_GNUC_UNUSED)
+unsigned long long
+qemuDomainGetMemoryModuleSizeAlignment(const virDomainDef *def)
 {
     /* PPC requires the memory sizes to be rounded to 256MiB increments, so
      * round them to the size always. */
@@ -12368,8 +12367,8 @@ qemuDomainAlignMemorySizes(virDomainDefPtr def)
     }
 
     /* Align memory module sizes */
+    align = qemuDomainGetMemoryModuleSizeAlignment(def);
     for (i = 0; i < def->nmems; i++) {
-        align = qemuDomainGetMemoryModuleSizeAlignment(def, def->mems[i]);
         def->mems[i]->size = VIR_ROUND_UP(def->mems[i]->size, align);
         hotplugmem += def->mems[i]->size;
 
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index f8fb48f2ff..d27d7e78d9 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -996,6 +996,8 @@ int qemuDomainDefValidateMemoryHotplug(const virDomainDef *def,
                                        virQEMUCapsPtr qemuCaps,
                                        const virDomainMemoryDef *mem);
 
+unsigned long long qemuDomainGetMemoryModuleSizeAlignment(const virDomainDef *def);
+
 bool qemuDomainSupportsNewVcpuHotplug(virDomainObjPtr vm);
 bool qemuDomainHasVcpuPids(virDomainObjPtr vm);
 pid_t qemuDomainGetVcpuPid(virDomainObjPtr vm, unsigned int vcpuid);
-- 
2.24.1





More information about the libvir-list mailing list