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

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