diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index a18d063473..a5d5a6fb24 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -8322,6 +8322,7 @@ qemu-kvm -net nic,model=? /dev/null
<memory model='nvdimm'>
<source>
<path>/tmp/nvdimm</path>
+ <alignsize unit='KiB'>2048</alignsize>
</source>
<target>
<size unit='KiB'>524288</size>
@@ -8403,10 +8404,25 @@ qemu-kvm -net nic,model=? /dev/null
- For model nvdimm
this element is mandatory and has a
- single child element path
that represents a path
- in the host that backs the nvdimm module in the guest.
+ For model nvdimm
this element is mandatory. The
+ mandatory child element path
represents a path in
+ the host that backs the nvdimm module in the guest. The following
+ optional elements may be used:
+
+
+ alignsize
+
+
+ The alignsize
element defines the page size
+ alignment used to mmap the address range for the backend
+ path
. If not supplied the host page size is used.
+ For example, to mmap a real NVDIMM device a 2M-aligned page may
+ be required.
+ Since 5.0.0
+
+
+
target
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 76b49aacc2..21006c3b1d 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -5384,9 +5384,16 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d8dfd1656f..7e59d8c528 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -15780,6 +15780,11 @@ virDomainMemorySourceDefParseXML(xmlNodePtr node,
_("path is required for model 'nvdimm'"));
goto cleanup;
}
+
+ if (virDomainParseMemory("./alignsize", "./alignsize/@unit", ctxt,
+ &def->alignsize, false, false) < 0)
+ goto cleanup;
+
break;
case VIR_DOMAIN_MEMORY_MODEL_NONE:
@@ -22735,13 +22740,22 @@ virDomainMemoryDefCheckABIStability(virDomainMemoryDefPtr src,
return false;
}
- if (src->model == VIR_DOMAIN_MEMORY_MODEL_NVDIMM &&
- src->labelsize != dst->labelsize) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Target NVDIMM label size '%llu' doesn't match "
- "source NVDIMM label size '%llu'"),
- src->labelsize, dst->labelsize);
- return false;
+ if (src->model == VIR_DOMAIN_MEMORY_MODEL_NVDIMM) {
+ if (src->labelsize != dst->labelsize) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Target NVDIMM label size '%llu' doesn't match "
+ "source NVDIMM label size '%llu'"),
+ src->labelsize, dst->labelsize);
+ return false;
+ }
+
+ if (src->alignsize != dst->alignsize) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Target NVDIMM alignment '%llu' doesn't match "
+ "source NVDIMM alignment '%llu'"),
+ src->alignsize, dst->alignsize);
+ return false;
+ }
}
return virDomainDeviceInfoCheckABIStability(&src->info, &dst->info);
@@ -26278,6 +26292,10 @@ virDomainMemorySourceDefFormat(virBufferPtr buf,
case VIR_DOMAIN_MEMORY_MODEL_NVDIMM:
virBufferEscapeString(buf, "%s \n", def->nvdimmPath);
+
+ if (def->alignsize)
+ virBufferAsprintf(buf, "%llu \n",
+ def->alignsize);
break;
case VIR_DOMAIN_MEMORY_MODEL_NONE:
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 5814997bdb..848bd94e12 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2147,6 +2147,7 @@ struct _virDomainMemoryDef {
virBitmapPtr sourceNodes;
unsigned long long pagesize; /* kibibytes */
char *nvdimmPath;
+ unsigned long long alignsize; /* kibibytes; valid only for NVDIMM */
/* target */
int model; /* virDomainMemoryModel */
diff --git a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-align.xml b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-align.xml
new file mode 100644
index 0000000000..a8c5198e9e
--- /dev/null
+++ b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-align.xml
@@ -0,0 +1,58 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 1099511627776
+ 1267710
+ 1267710
+ 2
+
+ hvm
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu-system-i686
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ /tmp/nvdimm
+ 2048
+
+
+ 523264
+ 0
+
+
+
+
+
diff --git a/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-align.xml b/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-align.xml
new file mode 120000
index 0000000000..9fc600126c
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-align.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/memory-hotplug-nvdimm-align.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 1062deee37..5161f4a5af 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -1116,6 +1116,7 @@ mymain(void)
DO_TEST("memory-hotplug-nvdimm", NONE);
DO_TEST("memory-hotplug-nvdimm-access", NONE);
DO_TEST("memory-hotplug-nvdimm-label", NONE);
+ DO_TEST("memory-hotplug-nvdimm-align", NONE);
DO_TEST("net-udp", NONE);
DO_TEST("video-virtio-gpu-device", NONE);