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