s390x/storage attributes: fix CMMA_BLOCK_SIZE usage
PATCH v2 1/1 s390x/storage attributes: fix CMMA_BLOCK_SIZE usage
The macro CMMA_BLOCK_SIZE was defined but not used, and a hardcoded value was instead used in the code.
This patch fixes the value of CMMA_BLOCK_SIZE and uses it in the appropriate place in the code, and fixes another case of hardcoded value in the KVM backend, replacing it with the more appropriate constant KVM_S390_CMMA_SIZE_MAX.
--- hw/s390x/s390-stattrib-kvm.c | 3 ++- hw/s390x/s390-stattrib.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-)
hw/s390x/s390-stattrib-kvm.c +2 -1
@@ -105,7 +105,8 @@ static void kvm_s390_stattrib_synchronize(S390StAttribState *sa)KVMS390StAttribState *sas =KVM_S390_STATTRIB (sa);MachineState *machine =MACHINE (qdev_get_machine ());unsigned long max = machine->maxram_size /TARGET_PAGE_SIZE ; -unsigned long cx, len =1 <<19 ; +/* We do not need to reach the maximum buffer size allowed */ +unsigned long cx, len =KVM_S390_SKEYS_MAX /2 ;int r;struct kvm_s390_cmma_log clog = { .flags =0 ,
hw/s390x/s390-stattrib.c +3 -2
@@ -20,7 +20,8 @@#include "qapi/error.h" #include "qapi/qmp/qdict.h" -#define CMMA_BLOCK_SIZE (1 << 10) +/* 512kB cover 2GB of guest memory */ +#define CMMA_BLOCK_SIZE (1 << 19)#define STATTR_FLAG_EOS 0x01ULL#define STATTR_FLAG_MORE 0x02ULL
@@ -202,7 +203,7 @@ static int cmma_save(QEMUFile *f, void *opaque, int final)S390StAttribClass *sac =S390_STATTRIB_GET_CLASS (sas);uint8_t *buf;int r, cx, reallen =0 , ret =0 ; -uint32_t buflen =1 <<19 ;/* 512kB cover 2GB of guest memory */ +uint32_t buflen =CMMA_BLOCK_SIZE ;uint64_t start_gfn = sas->migration_cur_gfn; buf =g_try_malloc (buflen);
Signature · 1 line
2.7.4
Quoted 19 lines · On Mon, 2 Jul 2018 15:04:11 +0200 Claudio Imbrenda…
The macro
CMMA_BLOCK_SIZEwas defined but not used, and a hardcoded value was instead used in the code.This patch fixes the value of
CMMA_BLOCK_SIZEand uses it in the appropriate place in the code, and fixes another case of hardcoded value in the KVM backend, replacing it with the more appropriate constantKVM_S390_CMMA_SIZE_MAX.Signed-off-by Claudio Imbrenda <[email protected]>--- hw/s390x/s390-stattrib-kvm.c | 3 ++- hw/s390x/s390-stattrib.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-)hw/s390x/s390-stattrib.c +0
-0
hw/s390x/s390-stattrib.c line 24
Quoted 6 lines
hw/s390x/s390-stattrib.c +2
-1@@ -20,7 +20,8 @@#include "qapi/error.h" #include "qapi/qmp/qdict.h" -#define CMMA_BLOCK_SIZE (1 << 10) +/* 512kB cover 2GB of guest memory */ +#define CMMA_BLOCK_SIZE (1 << 19)
Hm, this doesn't apply to current master anymore. Do we want to switch to something based on the IEC binary prefix definitions here, or keep the 1 << 19?
Quoted 12 lines
hw/s390x/s390-stattrib.c +1
-1#define STATTR_FLAG_EOS 0x01ULL#define STATTR_FLAG_MORE 0x02ULL@@ -202,7 +203,7 @@ static int cmma_save(QEMUFile *f, void *opaque, int final)S390StAttribClass *sac =S390_STATTRIB_GET_CLASS (sas);uint8_t *buf;int r, cx, reallen =0 , ret =0 ; -uint32_t buflen =1 <<19 ;/* 512kB cover 2GB of guest memory */ +uint32_t buflen =CMMA_BLOCK_SIZE ;uint64_t start_gfn = sas->migration_cur_gfn; buf =g_try_malloc (buflen);