Blame SOURCES/kvm-s390x-refuse-to-start-guests-backed-by-hugetlbfs.patch

1359fb
From 92fc5d11a4501a3734acc77b7d6a57190bd56154 Mon Sep 17 00:00:00 2001
1359fb
From: Cornelia Huck <cohuck@redhat.com>
1359fb
Date: Wed, 21 Nov 2018 10:17:06 +0100
1359fb
Subject: [PATCH 01/14] s390x: refuse to start guests backed by hugetlbfs
1359fb
1359fb
RH-Author: Cornelia Huck <cohuck@redhat.com>
1359fb
Message-id: <20181121101706.17562-1-cohuck@redhat.com>
1359fb
Patchwork-id: 83089
1359fb
O-Subject: [PATCH RHEL-7.6.z qemu-kvm-ma BZ1650580] s390x: refuse to start guests backed by hugetlbfs
1359fb
Bugzilla: 1672919
1359fb
RH-Acked-by: David Hildenbrand <david@redhat.com>
1359fb
RH-Acked-by: Thomas Huth <thuth@redhat.com>
1359fb
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
1359fb
1359fb
In RHEL-ALT 7.x, running s390x guests with hugetlbfs backing
1359fb
will not work due to missing support in the kernel. Unfortunately,
1359fb
the guest will try to start and only then crash. This will lead
1359fb
to problems when e.g. migrating a hugetlbfs backed guest from
1359fb
RHEL 8 (where this is supported, but no new machine type has
1359fb
been introduced.)
1359fb
1359fb
Fix this by bailing out with an error message immediately. This
1359fb
way, an incoming migration of a hugetlbfs backed guest will fail
1359fb
immediately and properly fall back to the source.
1359fb
1359fb
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
1359fb
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
1359fb
---
1359fb
 target/s390x/kvm.c | 18 ++++++++++++++++++
1359fb
 1 file changed, 18 insertions(+)
1359fb
1359fb
diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
1359fb
index ca8c32e..c27e628 100644
1359fb
--- a/target/s390x/kvm.c
1359fb
+++ b/target/s390x/kvm.c
1359fb
@@ -34,6 +34,7 @@
1359fb
 #include "qapi/error.h"
1359fb
 #include "qemu/error-report.h"
1359fb
 #include "qemu/timer.h"
1359fb
+#include "qemu/mmap-alloc.h"
1359fb
 #include "sysemu/sysemu.h"
1359fb
 #include "sysemu/hw_accel.h"
1359fb
 #include "hw/hw.h"
1359fb
@@ -282,10 +283,27 @@ void kvm_s390_crypto_reset(void)
1359fb
     }
1359fb
 }
1359fb
 
1359fb
+static int kvm_s390_configure_mempath_backing(KVMState *s)
1359fb
+{
1359fb
+    size_t path_psize = qemu_mempath_getpagesize(mem_path);
1359fb
+
1359fb
+    if (path_psize == 4096) {
1359fb
+        return 0;
1359fb
+    }
1359fb
+
1359fb
+    /* Disabled in Red Hat Enterprise Linux 7 (KVM support missing) */
1359fb
+    error_report("This QEMU does not support huge page mappings");
1359fb
+    return -EINVAL;
1359fb
+}
1359fb
+
1359fb
 int kvm_arch_init(MachineState *ms, KVMState *s)
1359fb
 {
1359fb
     MachineClass *mc = MACHINE_GET_CLASS(ms);
1359fb
 
1359fb
+    if (mem_path && kvm_s390_configure_mempath_backing(s)) {
1359fb
+        return -EINVAL;
1359fb
+    }
1359fb
+
1359fb
     mc->default_cpu_type = S390_CPU_TYPE_NAME("host");
1359fb
     cap_sync_regs = kvm_check_extension(s, KVM_CAP_SYNC_REGS);
1359fb
     cap_async_pf = kvm_check_extension(s, KVM_CAP_ASYNC_PF);
1359fb
-- 
1359fb
1.8.3.1
1359fb