|
|
7a3408 |
From a8f30a71dbe0327b945e9a85e561cace913d17a4 Mon Sep 17 00:00:00 2001
|
|
|
7a3408 |
Message-Id: <a8f30a71dbe0327b945e9a85e561cace913d17a4@dist-git>
|
|
|
7a3408 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
7a3408 |
Date: Tue, 22 Sep 2015 16:59:38 +0200
|
|
|
7a3408 |
Subject: [PATCH] qemu: Make memory alignment helper more universal
|
|
|
7a3408 |
|
|
|
7a3408 |
https://bugzilla.redhat.com/show_bug.cgi?id=1252685
|
|
|
7a3408 |
|
|
|
7a3408 |
Extract the size determination into a separate function and reuse it
|
|
|
7a3408 |
across the memory device alignment functions. Since later we will need
|
|
|
7a3408 |
to decide the alignment size according to architecture let's pass def to
|
|
|
7a3408 |
the functions.
|
|
|
7a3408 |
|
|
|
7a3408 |
(cherry picked from commit 3fb0819830cef3b269fbcdea217d7f1de4b62e87)
|
|
|
7a3408 |
|
|
|
7a3408 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
7a3408 |
---
|
|
|
7a3408 |
src/qemu/qemu_domain.c | 26 ++++++++++++++++++--------
|
|
|
7a3408 |
src/qemu/qemu_domain.h | 3 ++-
|
|
|
7a3408 |
src/qemu/qemu_hotplug.c | 4 ++--
|
|
|
7a3408 |
3 files changed, 22 insertions(+), 11 deletions(-)
|
|
|
7a3408 |
|
|
|
7a3408 |
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
|
|
|
7a3408 |
index 9d9fb06..15cdf7b 100644
|
|
|
7a3408 |
--- a/src/qemu/qemu_domain.c
|
|
|
7a3408 |
+++ b/src/qemu/qemu_domain.c
|
|
|
7a3408 |
@@ -3158,30 +3158,39 @@ qemuDomainAgentAvailable(virDomainObjPtr vm,
|
|
|
7a3408 |
}
|
|
|
7a3408 |
|
|
|
7a3408 |
|
|
|
7a3408 |
+static unsigned long long
|
|
|
7a3408 |
+qemuDomainGetMemorySizeAlignment(virDomainDefPtr def ATTRIBUTE_UNUSED)
|
|
|
7a3408 |
+{
|
|
|
7a3408 |
+ /* Align memory size. QEMU requires rounding to next 4KiB block.
|
|
|
7a3408 |
+ * We'll take the "traditional" path and round it to 1MiB*/
|
|
|
7a3408 |
+
|
|
|
7a3408 |
+ return 1024;
|
|
|
7a3408 |
+}
|
|
|
7a3408 |
+
|
|
|
7a3408 |
+
|
|
|
7a3408 |
int
|
|
|
7a3408 |
qemuDomainAlignMemorySizes(virDomainDefPtr def)
|
|
|
7a3408 |
{
|
|
|
7a3408 |
unsigned long long mem;
|
|
|
7a3408 |
+ unsigned long long align = qemuDomainGetMemorySizeAlignment(def);
|
|
|
7a3408 |
size_t ncells = virDomainNumaGetNodeCount(def->numa);
|
|
|
7a3408 |
size_t i;
|
|
|
7a3408 |
|
|
|
7a3408 |
/* align NUMA cell sizes if relevant */
|
|
|
7a3408 |
for (i = 0; i < ncells; i++) {
|
|
|
7a3408 |
mem = virDomainNumaGetNodeMemorySize(def->numa, i);
|
|
|
7a3408 |
- virDomainNumaSetNodeMemorySize(def->numa, i, VIR_ROUND_UP(mem, 1024));
|
|
|
7a3408 |
+ virDomainNumaSetNodeMemorySize(def->numa, i, VIR_ROUND_UP(mem, align));
|
|
|
7a3408 |
}
|
|
|
7a3408 |
|
|
|
7a3408 |
/* align initial memory size */
|
|
|
7a3408 |
mem = virDomainDefGetMemoryInitial(def);
|
|
|
7a3408 |
- virDomainDefSetMemoryInitial(def, VIR_ROUND_UP(mem, 1024));
|
|
|
7a3408 |
+ virDomainDefSetMemoryInitial(def, VIR_ROUND_UP(mem, align));
|
|
|
7a3408 |
|
|
|
7a3408 |
- /* Align maximum memory size. QEMU requires rounding to next 4KiB block.
|
|
|
7a3408 |
- * We'll take the "traditional" path and round it to 1MiB*/
|
|
|
7a3408 |
- def->mem.max_memory = VIR_ROUND_UP(def->mem.max_memory, 1024);
|
|
|
7a3408 |
+ def->mem.max_memory = VIR_ROUND_UP(def->mem.max_memory, align);
|
|
|
7a3408 |
|
|
|
7a3408 |
/* Align memory module sizes */
|
|
|
7a3408 |
for (i = 0; i < def->nmems; i++)
|
|
|
7a3408 |
- qemuDomainMemoryDeviceAlignSize(def->mems[i]);
|
|
|
7a3408 |
+ def->mems[i]->size = VIR_ROUND_UP(def->mems[i]->size, align);
|
|
|
7a3408 |
|
|
|
7a3408 |
return 0;
|
|
|
7a3408 |
}
|
|
|
7a3408 |
@@ -3196,9 +3205,10 @@ qemuDomainAlignMemorySizes(virDomainDefPtr def)
|
|
|
7a3408 |
* size so this should be safe).
|
|
|
7a3408 |
*/
|
|
|
7a3408 |
void
|
|
|
7a3408 |
-qemuDomainMemoryDeviceAlignSize(virDomainMemoryDefPtr mem)
|
|
|
7a3408 |
+qemuDomainMemoryDeviceAlignSize(virDomainDefPtr def,
|
|
|
7a3408 |
+ virDomainMemoryDefPtr mem)
|
|
|
7a3408 |
{
|
|
|
7a3408 |
- mem->size = VIR_ROUND_UP(mem->size, 1024);
|
|
|
7a3408 |
+ mem->size = VIR_ROUND_UP(mem->size, qemuDomainGetMemorySizeAlignment(def));
|
|
|
7a3408 |
}
|
|
|
7a3408 |
|
|
|
7a3408 |
|
|
|
7a3408 |
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
|
|
|
7a3408 |
index 91eaea1..e283b58 100644
|
|
|
7a3408 |
--- a/src/qemu/qemu_domain.h
|
|
|
7a3408 |
+++ b/src/qemu/qemu_domain.h
|
|
|
7a3408 |
@@ -462,7 +462,8 @@ bool qemuDomainHasBlockjob(virDomainObjPtr vm, bool copy_only)
|
|
|
7a3408 |
ATTRIBUTE_NONNULL(1);
|
|
|
7a3408 |
|
|
|
7a3408 |
int qemuDomainAlignMemorySizes(virDomainDefPtr def);
|
|
|
7a3408 |
-void qemuDomainMemoryDeviceAlignSize(virDomainMemoryDefPtr mem);
|
|
|
7a3408 |
+void qemuDomainMemoryDeviceAlignSize(virDomainDefPtr def,
|
|
|
7a3408 |
+ virDomainMemoryDefPtr mem);
|
|
|
7a3408 |
|
|
|
7a3408 |
virDomainChrSourceDefPtr qemuFindAgentConfig(virDomainDefPtr def);
|
|
|
7a3408 |
|
|
|
7a3408 |
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
|
|
|
7a3408 |
index 31c56ae..f702c9f 100644
|
|
|
7a3408 |
--- a/src/qemu/qemu_hotplug.c
|
|
|
7a3408 |
+++ b/src/qemu/qemu_hotplug.c
|
|
|
7a3408 |
@@ -1801,7 +1801,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
|
|
|
7a3408 |
if (!(devstr = qemuBuildMemoryDeviceStr(mem, vm->def, priv->qemuCaps)))
|
|
|
7a3408 |
goto cleanup;
|
|
|
7a3408 |
|
|
|
7a3408 |
- qemuDomainMemoryDeviceAlignSize(mem);
|
|
|
7a3408 |
+ qemuDomainMemoryDeviceAlignSize(vm->def, mem);
|
|
|
7a3408 |
|
|
|
7a3408 |
if (qemuBuildMemoryBackendStr(mem->size, mem->pagesize,
|
|
|
7a3408 |
mem->targetNode, mem->sourceNodes, NULL,
|
|
|
7a3408 |
@@ -4282,7 +4282,7 @@ qemuDomainDetachMemoryDevice(virQEMUDriverPtr driver,
|
|
|
7a3408 |
return -1;
|
|
|
7a3408 |
}
|
|
|
7a3408 |
|
|
|
7a3408 |
- qemuDomainMemoryDeviceAlignSize(memdef);
|
|
|
7a3408 |
+ qemuDomainMemoryDeviceAlignSize(vm->def, memdef);
|
|
|
7a3408 |
|
|
|
7a3408 |
if ((idx = virDomainMemoryFindByDef(vm->def, memdef)) < 0) {
|
|
|
7a3408 |
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
|
7a3408 |
--
|
|
|
7a3408 |
2.5.3
|
|
|
7a3408 |
|