Re: [libvirt] [PATCHv2.5 02/10] qemu: Implement setup of memory hotplug parameters

2015-03-12 Thread John Ferlan


On 03/04/2015 11:24 AM, Peter Krempa wrote:
> To enable memory hotplug the maximum memory size and slot count need to
> be specified. As qemu supports now other units than mebibytes when
> specifying memory, use the new interface in this case.
> ---
>  docs/formatdomain.html.in  |  2 +-
>  src/qemu/qemu_command.c| 34 
> ++
>  src/qemu/qemu_domain.c |  8 ++---
>  .../qemuxml2argv-memory-hotplug-nonuma.xml | 22 ++
>  .../qemuxml2argv-memory-hotplug.args   |  6 
>  .../qemuxml2argv-memory-hotplug.xml| 34 
> ++
>  tests/qemuxml2argvtest.c   |  4 +++
>  tests/qemuxml2xmltest.c|  3 ++
>  8 files changed, 102 insertions(+), 11 deletions(-)
>  create mode 100644 
> tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-nonuma.xml
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug.args
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug.xml
> 

ACK

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCHv2.5 02/10] qemu: Implement setup of memory hotplug parameters

2015-03-04 Thread Peter Krempa
To enable memory hotplug the maximum memory size and slot count need to
be specified. As qemu supports now other units than mebibytes when
specifying memory, use the new interface in this case.
---
 docs/formatdomain.html.in  |  2 +-
 src/qemu/qemu_command.c| 34 ++
 src/qemu/qemu_domain.c |  8 ++---
 .../qemuxml2argv-memory-hotplug-nonuma.xml | 22 ++
 .../qemuxml2argv-memory-hotplug.args   |  6 
 .../qemuxml2argv-memory-hotplug.xml| 34 ++
 tests/qemuxml2argvtest.c   |  4 +++
 tests/qemuxml2xmltest.c|  3 ++
 8 files changed, 102 insertions(+), 11 deletions(-)
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-nonuma.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 1f0f770..fcb4ca2 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -724,7 +724,7 @@
 Note that due to alignment of the memory chunks added via memory
 hotplug the full size allocation specified by this element may be
 impossible to achieve.
-Since 1.2.14
+Since 1.2.14 supported by the QEMU driver.
   

   currentMemory
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f76b89c..d7e28cd 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8355,13 +8355,35 @@ qemuBuildCommandLine(virConnectPtr conn,
 if (qemuDomainAlignMemorySizes(def) < 0)
 goto error;

-/* Set '-m MB' based on maxmem, because the lower 'memory' limit
- * is set post-startup using the balloon driver. If balloon driver
- * is not supported, then they're out of luck anyway.  Update the
- * XML to reflect our rounding.
- */
 virCommandAddArg(cmd, "-m");
-virCommandAddArgFormat(cmd, "%llu", virDomainDefGetMemoryInitial(def)  / 
1024);
+
+if (def->mem.max_memory) {
+if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PC_DIMM)) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+   _("memory hotplug isn't supported by this QEMU 
binary"));
+goto error;
+}
+
+/* due to guest support, qemu would silently enable NUMA with one node
+ * once the memory hotplug backend is enabled. To avoid possible
+ * confusion we will enforce user originated numa configuration along
+ * with memory hotplug. */
+if (virDomainNumaGetNodeCount(def->numa) == 0) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+   _("At least one numa node has to be configured when 
"
+ "enabling memory hotplug"));
+goto error;
+}
+
+/* Use the 'k' suffix to let qemu handle the units */
+virCommandAddArgFormat(cmd, "size=%lluk,slots=%u,maxmem=%lluk",
+   virDomainDefGetMemoryInitial(def),
+   def->mem.memory_slots,
+   def->mem.max_memory);
+
+} else {
+   virCommandAddArgFormat(cmd, "%llu", virDomainDefGetMemoryInitial(def) / 
1024);
+}

 if (def->mem.nhugepages && !virDomainNumaGetNodeCount(def->numa)) {
 const long system_page_size = virGetSystemPageSizeKB();
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 5c31fb2..a654d2e 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1052,10 +1052,6 @@ qemuDomainDefPostParse(virDomainDefPtr def,
   VIR_DOMAIN_INPUT_BUS_USB) < 0)
 return -1;

-/* memory hotplug tunables are not supported by this driver */
-if (virDomainDefCheckUnsupportedMemoryHotplug(def) < 0)
-return -1;
-
 return 0;
 }

@@ -2875,5 +2871,9 @@ qemuDomainAlignMemorySizes(virDomainDefPtr def)
 mem = virDomainDefGetMemoryInitial(def);
 virDomainDefSetMemoryInitial(def, VIR_ROUND_UP(mem, 1024));

+/* Align maximum memory size. QEMU requires rounding to next 4KiB block.
+ * We'll take the "traditional" path and round it to 1MiB*/
+def->mem.max_memory = VIR_ROUND_UP(def->mem.max_memory, 1024);
+
 return 0;
 }
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-nonuma.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-nonuma.xml
new file mode 100644
index 000..5c807ed
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-nonuma.xml
@@ -0,0 +1,22 @@
+
+  QEMUGuest1
+  c7a5fdbd-edaf-9455-926a-d65c16db1809
+  1233456789
+  219136
+  219136
+  1
+  
+hvm
+
+  
+  
+  destroy
+  restart
+  destroy
+  
+/usr/bin/qemu
+
+
+
+  
+
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-memo