diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 0b1b478b2a..7f07bb7f55 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -8330,6 +8330,7 @@ qemu-kvm -net nic,model=? /dev/null <label> <size unit='KiB'>128</size> </label> + <readonly/> </target> </memory> <memory model='nvdimm'> @@ -8465,19 +8466,39 @@ qemu-kvm -net nic,model=? /dev/null NUMA nodes configured.

- For NVDIMM type devices one can optionally use - label and its subelement size - to configure the size of namespaces label storage - within the NVDIMM module. The size element - has usual meaning described - here. - For QEMU domains the following restrictions apply: + The following optional elements may be used:

-
    -
  1. the minimum label size is 128KiB,
  2. -
  3. the remaining size (total-size - label-size) has to be aligned to - 4KiB
  4. -
+ +
+
label
+
+

+ For NVDIMM type devices one can optionally use + label and its subelement size + to configure the size of namespaces label storage + within the NVDIMM module. The size element + has usual meaning described + here. + For QEMU domains the following restrictions apply: +

+
    +
  1. the minimum label size is 128KiB,
  2. +
  3. the remaining size (total-size - label-size) will be aligned + to 4KiB as default.
  4. +
+
+ +
readonly
+
+

+ The readonly element is used to mark the vNVDIMM + as read-only. Only the real NVDIMM device backend can guarantee + the guest write persistence, so other backend types should use + the readonly element. + Since 5.0.0 +

+
+
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index a7b7164ad1..6518aff73a 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -5422,6 +5422,11 @@ + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9edaf6d493..222bb8c482 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15844,6 +15844,9 @@ virDomainMemoryTargetDefParseXML(xmlNodePtr node, _("label size must be smaller than NVDIMM size")); goto cleanup; } + + if (virXPathBoolean("boolean(./readonly)", ctxt)) + def->readonly = true; } ret = 0; @@ -22766,6 +22769,13 @@ virDomainMemoryDefCheckABIStability(virDomainMemoryDefPtr src, "source NVDIMM pmem flag")); return false; } + + if (src->readonly != dst->readonly) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Target NVDIMM readonly flag doesn't match " + "source NVDIMM readonly flag")); + return false; + } } return virDomainDeviceInfoCheckABIStability(&src->info, &dst->info); @@ -26344,6 +26354,8 @@ virDomainMemoryTargetDefFormat(virBufferPtr buf, virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); } + if (def->readonly) + virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a63afdca12..fae130668f 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2155,6 +2155,7 @@ struct _virDomainMemoryDef { int targetNode; unsigned long long size; /* kibibytes */ unsigned long long labelsize; /* kibibytes; valid only for NVDIMM */ + bool readonly; /* valid only for NVDIMM */ virDomainDeviceInfo info; }; diff --git a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-readonly.xml b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-readonly.xml new file mode 100644 index 0000000000..170992c9fc --- /dev/null +++ b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-readonly.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 + + + 523264 + 0 + + +
+ + + diff --git a/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-readonly.xml b/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-readonly.xml new file mode 120000 index 0000000000..10be8447a8 --- /dev/null +++ b/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-readonly.xml @@ -0,0 +1 @@ +../qemuxml2argvdata/memory-hotplug-nvdimm-readonly.xml \ No newline at end of file diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index ef3ece8902..82e2c0ee0f 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1118,6 +1118,7 @@ mymain(void) DO_TEST("memory-hotplug-nvdimm-label", NONE); DO_TEST("memory-hotplug-nvdimm-align", NONE); DO_TEST("memory-hotplug-nvdimm-pmem", NONE); + DO_TEST("memory-hotplug-nvdimm-readonly", NONE); DO_TEST("net-udp", NONE); DO_TEST("video-virtio-gpu-device", NONE);