Blame SOURCES/kvm-s390x-storage-attributes-fix-CMMA_BLOCK_SIZE-usage.patch

b38b0f
From aaec9beefcdc4e8cbef669d0115f4405498400de Mon Sep 17 00:00:00 2001
b38b0f
From: Cornelia Huck <cohuck@redhat.com>
b38b0f
Date: Wed, 17 Apr 2019 13:57:21 +0100
b38b0f
Subject: [PATCH 04/24] s390x/storage attributes: fix CMMA_BLOCK_SIZE usage
b38b0f
b38b0f
RH-Author: Cornelia Huck <cohuck@redhat.com>
b38b0f
Message-id: <20190417135741.25297-5-cohuck@redhat.com>
b38b0f
Patchwork-id: 85786
b38b0f
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH v2 04/24] s390x/storage attributes: fix CMMA_BLOCK_SIZE usage
b38b0f
Bugzilla: 1699070
b38b0f
RH-Acked-by: David Hildenbrand <david@redhat.com>
b38b0f
RH-Acked-by: Thomas Huth <thuth@redhat.com>
b38b0f
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
b38b0f
b38b0f
From: Claudio Imbrenda <imbrenda@linux.vnet.ibm.com>
b38b0f
b38b0f
The macro CMMA_BLOCK_SIZE was defined but not used, and a hardcoded
b38b0f
value was instead used in the code.
b38b0f
b38b0f
This patch fixes the value of CMMA_BLOCK_SIZE and uses it in the
b38b0f
appropriate place in the code, and fixes another case of hardcoded
b38b0f
value in the KVM backend, replacing it with the more appropriate
b38b0f
constant KVM_S390_CMMA_SIZE_MAX.
b38b0f
b38b0f
Signed-off-by: Claudio Imbrenda <imbrenda@linux.vnet.ibm.com>
b38b0f
Message-Id: <1530787170-3101-1-git-send-email-imbrenda@linux.vnet.ibm.com>
b38b0f
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
b38b0f
(cherry picked from commit 17f4566657df51c5e0cb40f30491e058d74d63c8)
b38b0f
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
b38b0f
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
b38b0f
---
b38b0f
 hw/s390x/s390-stattrib-kvm.c | 3 ++-
b38b0f
 hw/s390x/s390-stattrib.c     | 5 +++--
b38b0f
 2 files changed, 5 insertions(+), 3 deletions(-)
b38b0f
b38b0f
diff --git a/hw/s390x/s390-stattrib-kvm.c b/hw/s390x/s390-stattrib-kvm.c
b38b0f
index 480551c..c7e1f35 100644
b38b0f
--- a/hw/s390x/s390-stattrib-kvm.c
b38b0f
+++ b/hw/s390x/s390-stattrib-kvm.c
b38b0f
@@ -105,7 +105,8 @@ static void kvm_s390_stattrib_synchronize(S390StAttribState *sa)
b38b0f
     KVMS390StAttribState *sas = KVM_S390_STATTRIB(sa);
b38b0f
     MachineState *machine = MACHINE(qdev_get_machine());
b38b0f
     unsigned long max = machine->maxram_size / TARGET_PAGE_SIZE;
b38b0f
-    unsigned long cx, len = 1 << 19;
b38b0f
+    /* We do not need to reach the maximum buffer size allowed */
b38b0f
+    unsigned long cx, len = KVM_S390_SKEYS_MAX / 2;
b38b0f
     int r;
b38b0f
     struct kvm_s390_cmma_log clog = {
b38b0f
         .flags = 0,
b38b0f
diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c
b38b0f
index 5161a16..766f201 100644
b38b0f
--- a/hw/s390x/s390-stattrib.c
b38b0f
+++ b/hw/s390x/s390-stattrib.c
b38b0f
@@ -21,7 +21,8 @@
b38b0f
 #include "qapi/error.h"
b38b0f
 #include "qapi/qmp/qdict.h"
b38b0f
 
b38b0f
-#define CMMA_BLOCK_SIZE  (1 * KiB)
b38b0f
+/* 512KiB cover 2GB of guest memory */
b38b0f
+#define CMMA_BLOCK_SIZE  (512 * KiB)
b38b0f
 
b38b0f
 #define STATTR_FLAG_EOS     0x01ULL
b38b0f
 #define STATTR_FLAG_MORE    0x02ULL
b38b0f
@@ -203,7 +204,7 @@ static int cmma_save(QEMUFile *f, void *opaque, int final)
b38b0f
     S390StAttribClass *sac = S390_STATTRIB_GET_CLASS(sas);
b38b0f
     uint8_t *buf;
b38b0f
     int r, cx, reallen = 0, ret = 0;
b38b0f
-    uint32_t buflen = 1 << 19;   /* 512kB cover 2GB of guest memory */
b38b0f
+    uint32_t buflen = CMMA_BLOCK_SIZE;
b38b0f
     uint64_t start_gfn = sas->migration_cur_gfn;
b38b0f
 
b38b0f
     buf = g_try_malloc(buflen);
b38b0f
-- 
b38b0f
1.8.3.1
b38b0f