Introduce a qemu capability for -device nvdimm.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 9 +++++++++
src/qemu/qemu_capabilities.h | 1 +
2 files changed, 10 insertions(+)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 5a3b4ac50..2f459d128 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -359,6 +359,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"query-cpu-model-expansion", /* 245 */
"virtio-net.host_mtu",
"spice-rendernode",
+ "nvdimm",
);
@@ -1626,6 +1627,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
{ "ivshmem-plain", QEMU_CAPS_DEVICE_IVSHMEM_PLAIN },
{ "ivshmem-doorbell", QEMU_CAPS_DEVICE_IVSHMEM_DOORBELL },
{ "vhost-scsi", QEMU_CAPS_DEVICE_VHOST_SCSI },
+ { "nvdimm", QEMU_CAPS_DEVICE_NVDIMM },
};
static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBalloon[] = {
@@ -4545,6 +4547,13 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
virQEMUCapsProbeQMPGICCapabilities(qemuCaps, mon) < 0)
goto cleanup;
+ /* Prealloc on NVDIMMs is broken on older QEMUs leading to
+ * user data corruption. If we are dealing with such version
+ * of QEMU pretend we don't know how to NVDIMM. */
+ if (qemuCaps->version < 2009000 &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_NVDIMM))
+ virQEMUCapsClear(qemuCaps, QEMU_CAPS_DEVICE_NVDIMM);
+
ret = 0;
cleanup:
return ret;
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index cc9f46e65..1b4bcfb2f 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -394,6 +394,7 @@ typedef enum {
QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION, /* qmp query-cpu-model-expansion */
QEMU_CAPS_VIRTIO_NET_HOST_MTU, /* virtio-net-*.host_mtu */
QEMU_CAPS_SPICE_RENDERNODE, /* -spice rendernode */
+ QEMU_CAPS_DEVICE_NVDIMM, /* -device nvdimm */
QEMU_CAPS_LAST /* this must always be the last item */
} virQEMUCapsFlags;
--
2.11.0