summary refs log tree commit diff stats
path: root/backends
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2024-06-06 11:33:06 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2024-06-08 10:33:38 +0200
commita2b6a96505097c54f5db4c77f66e9c47af4dad22 (patch)
tree4114a9480dc28e305404575b3e40b9ae953fec70 /backends
parent5d9a9a617053a97a76ef332896c386d8fc895631 (diff)
downloadfocaccia-qemu-a2b6a96505097c54f5db4c77f66e9c47af4dad22.tar.gz
focaccia-qemu-a2b6a96505097c54f5db4c77f66e9c47af4dad22.zip
machine, hostmem: improve error messages for unsupported features
Detect early unsupported MADV_MERGEABLE and MADV_DONTDUMP, and print a clearer
error message that points to the deficiency of the host.

Cc: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'backends')
-rw-r--r--backends/hostmem.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/backends/hostmem.c b/backends/hostmem.c
index 1edc0ede2a..6da3d7383e 100644
--- a/backends/hostmem.c
+++ b/backends/hostmem.c
@@ -170,6 +170,14 @@ static void host_memory_backend_set_merge(Object *obj, bool value, Error **errp)
 {
     HostMemoryBackend *backend = MEMORY_BACKEND(obj);
 
+    if (QEMU_MADV_MERGEABLE == QEMU_MADV_INVALID) {
+        if (value) {
+            error_setg(errp, "Memory merging is not supported on this host");
+        }
+        assert(!backend->merge);
+        return;
+    }
+
     if (!host_memory_backend_mr_inited(backend)) {
         backend->merge = value;
         return;
@@ -196,6 +204,14 @@ static void host_memory_backend_set_dump(Object *obj, bool value, Error **errp)
 {
     HostMemoryBackend *backend = MEMORY_BACKEND(obj);
 
+    if (QEMU_MADV_DONTDUMP == QEMU_MADV_INVALID) {
+        if (!value) {
+            error_setg(errp, "Dumping guest memory cannot be disabled on this host");
+        }
+        assert(backend->dump);
+        return;
+    }
+
     if (!host_memory_backend_mr_inited(backend)) {
         backend->dump = value;
         return;