Message ID | 83795acd-ddfd-e039-80bb-78a785fb7669@de.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, 13 Jul 2017 09:11:34 +0200 Christian Borntraeger <borntraeger@de.ibm.com> wrote: > Thanks for the review, all valid. Claudio has provided me the following fixup. > > I plan to fold that in the base patch (retest pending). Looks good to me, and I have no further comments beyond those by Thomas.
On 13.07.2017 09:11, Christian Borntraeger wrote: > Thanks for the review, all valid. Claudio has provided me the following fixup. > > I plan to fold that in the base patch (retest pending). > > Christian > > > --- > hw/s390x/s390-stattrib-kvm.c | 26 +++++++++++++++++++------- > hw/s390x/s390-stattrib.c | 12 +++--------- > include/hw/s390x/storage-attributes.h | 9 +++++++++ > 3 files changed, 31 insertions(+), 16 deletions(-) > > diff --git a/hw/s390x/s390-stattrib-kvm.c b/hw/s390x/s390-stattrib-kvm.c > index 2e7f144..2ab3060 100644 > --- a/hw/s390x/s390-stattrib-kvm.c > +++ b/hw/s390x/s390-stattrib-kvm.c > @@ -11,7 +11,6 @@ > > #include "qemu/osdep.h" > #include "hw/boards.h" > -#include "qmp-commands.h" > #include "migration/qemu-file.h" > #include "hw/s390x/storage-attributes.h" > #include "qemu/error-report.h" > @@ -19,6 +18,15 @@ > #include "exec/ram_addr.h" > #include "cpu.h" > > +Object *kvm_s390_stattrib_create(void) > +{ > + if (kvm_enabled() && > + kvm_check_extension(kvm_state, KVM_CAP_S390_CMMA_MIGRATION)) { > + return object_new(TYPE_KVM_S390_STATTRIB); > + } > + return object_new(TYPE_QEMU_S390_STATTRIB); > +} I think you could also return NULL here instead of object_new(TYPE_QEMU_S390_STATTRIB) since ... > diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c > index b9533b4..bac9aea 100644 > --- a/hw/s390x/s390-stattrib.c > +++ b/hw/s390x/s390-stattrib.c > @@ -40,16 +40,10 @@ void s390_stattrib_init(void) > { > Object *obj; > > -#ifdef CONFIG_KVM > - if (kvm_enabled() && > - kvm_check_extension(kvm_state, KVM_CAP_S390_CMMA_MIGRATION)) { > - obj = object_new(TYPE_KVM_S390_STATTRIB); > - } else { > + obj = kvm_s390_stattrib_create(); > + if (!obj) { > obj = object_new(TYPE_QEMU_S390_STATTRIB); > } ... the object will be created here, too. Thomas
On 07/13/2017 09:35 AM, Thomas Huth wrote: > On 13.07.2017 09:11, Christian Borntraeger wrote: >> Thanks for the review, all valid. Claudio has provided me the following fixup. >> >> I plan to fold that in the base patch (retest pending). >> >> Christian >> >> >> --- >> hw/s390x/s390-stattrib-kvm.c | 26 +++++++++++++++++++------- >> hw/s390x/s390-stattrib.c | 12 +++--------- >> include/hw/s390x/storage-attributes.h | 9 +++++++++ >> 3 files changed, 31 insertions(+), 16 deletions(-) >> >> diff --git a/hw/s390x/s390-stattrib-kvm.c b/hw/s390x/s390-stattrib-kvm.c >> index 2e7f144..2ab3060 100644 >> --- a/hw/s390x/s390-stattrib-kvm.c >> +++ b/hw/s390x/s390-stattrib-kvm.c >> @@ -11,7 +11,6 @@ >> >> #include "qemu/osdep.h" >> #include "hw/boards.h" >> -#include "qmp-commands.h" >> #include "migration/qemu-file.h" >> #include "hw/s390x/storage-attributes.h" >> #include "qemu/error-report.h" >> @@ -19,6 +18,15 @@ >> #include "exec/ram_addr.h" >> #include "cpu.h" >> >> +Object *kvm_s390_stattrib_create(void) >> +{ >> + if (kvm_enabled() && >> + kvm_check_extension(kvm_state, KVM_CAP_S390_CMMA_MIGRATION)) { >> + return object_new(TYPE_KVM_S390_STATTRIB); >> + } >> + return object_new(TYPE_QEMU_S390_STATTRIB); >> +} > > I think you could also return NULL here instead of > object_new(TYPE_QEMU_S390_STATTRIB) since ... Yes, I like return NULL better so that we do not create the QEMU one in *kvm.c. Will also fixup. thanks > >> diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c >> index b9533b4..bac9aea 100644 >> --- a/hw/s390x/s390-stattrib.c >> +++ b/hw/s390x/s390-stattrib.c >> @@ -40,16 +40,10 @@ void s390_stattrib_init(void) >> { >> Object *obj; >> >> -#ifdef CONFIG_KVM >> - if (kvm_enabled() && >> - kvm_check_extension(kvm_state, KVM_CAP_S390_CMMA_MIGRATION)) { >> - obj = object_new(TYPE_KVM_S390_STATTRIB); >> - } else { >> + obj = kvm_s390_stattrib_create(); >> + if (!obj) { >> obj = object_new(TYPE_QEMU_S390_STATTRIB); >> } > > ... the object will be created here, too. > > Thomas >
diff --git a/hw/s390x/s390-stattrib-kvm.c b/hw/s390x/s390-stattrib-kvm.c index 2e7f144..2ab3060 100644 --- a/hw/s390x/s390-stattrib-kvm.c +++ b/hw/s390x/s390-stattrib-kvm.c @@ -11,7 +11,6 @@ #include "qemu/osdep.h" #include "hw/boards.h" -#include "qmp-commands.h" #include "migration/qemu-file.h" #include "hw/s390x/storage-attributes.h" #include "qemu/error-report.h" @@ -19,6 +18,15 @@ #include "exec/ram_addr.h" #include "cpu.h" +Object *kvm_s390_stattrib_create(void) +{ + if (kvm_enabled() && + kvm_check_extension(kvm_state, KVM_CAP_S390_CMMA_MIGRATION)) { + return object_new(TYPE_KVM_S390_STATTRIB); + } + return object_new(TYPE_QEMU_S390_STATTRIB); +} + static void kvm_s390_stattrib_instance_init(Object *obj) { KVMS390StAttribState *sas = KVM_S390_STATTRIB(obj); @@ -27,10 +35,10 @@ static void kvm_s390_stattrib_instance_init(Object *obj) } static int kvm_s390_stattrib_read_helper(S390StAttribState *sa, - uint64_t *start_gfn, - uint32_t count, - uint8_t *values, - uint32_t flags) + uint64_t *start_gfn, + uint32_t count, + uint8_t *values, + uint32_t flags) { KVMS390StAttribState *sas = KVM_S390_STATTRIB(sa); int r; @@ -43,7 +51,7 @@ static int kvm_s390_stattrib_read_helper(S390StAttribState *sa, r = kvm_vm_ioctl(kvm_state, KVM_S390_GET_CMMA_BITS, &clog); if (r < 0) { - error_report("Error: %s", strerror(-r)); + error_report("KVM_S390_GET_CMMA_BITS failed: %s", strerror(-r)); return r; } @@ -79,7 +87,7 @@ static int kvm_s390_stattrib_set_stattr(S390StAttribState *sa, unsigned long max = machine->maxram_size / TARGET_PAGE_SIZE; if (start_gfn + count > max) { - error_report("Error: invalid address."); + error_report("Out of memory bounds when setting storage attributes"); return -1; } if (!sas->incoming_buffer) { @@ -110,6 +118,7 @@ static void kvm_s390_stattrib_synchronize(S390StAttribState *sa) clog.values = (uint64_t)(sas->incoming_buffer + cx * len); r = kvm_vm_ioctl(kvm_state, KVM_S390_SET_CMMA_BITS, &clog); if (r) { + error_report("KVM_S390_SET_CMMA_BITS failed: %s", strerror(-r)); return; } } @@ -118,6 +127,9 @@ static void kvm_s390_stattrib_synchronize(S390StAttribState *sa) clog.count = max - cx; clog.values = (uint64_t)(sas->incoming_buffer + cx * len); r = kvm_vm_ioctl(kvm_state, KVM_S390_SET_CMMA_BITS, &clog); + if (r) { + error_report("KVM_S390_SET_CMMA_BITS failed: %s", strerror(-r)); + } } g_free(sas->incoming_buffer); sas->incoming_buffer = NULL; diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c index b9533b4..bac9aea 100644 --- a/hw/s390x/s390-stattrib.c +++ b/hw/s390x/s390-stattrib.c @@ -40,16 +40,10 @@ void s390_stattrib_init(void) { Object *obj; -#ifdef CONFIG_KVM - if (kvm_enabled() && - kvm_check_extension(kvm_state, KVM_CAP_S390_CMMA_MIGRATION)) { - obj = object_new(TYPE_KVM_S390_STATTRIB); - } else { + obj = kvm_s390_stattrib_create(); + if (!obj) { obj = object_new(TYPE_QEMU_S390_STATTRIB); } -#else - obj = object_new(TYPE_QEMU_S390_STATTRIB); -#endif object_property_add_child(qdev_get_machine(), TYPE_S390_STATTRIB, obj, NULL); @@ -224,7 +218,7 @@ static int cmma_save(QEMUFile *f, void *opaque, int final) } ret = 1; - if (0 == reallen) { + if (!reallen) { break; } qemu_put_be64(f, (start_gfn << TARGET_PAGE_BITS) | STATTR_FLAG_MORE); diff --git a/include/hw/s390x/storage-attributes.h b/include/hw/s390x/storage-attributes.h index ccf4aa1..9be954d 100644 --- a/include/hw/s390x/storage-attributes.h +++ b/include/hw/s390x/storage-attributes.h @@ -66,6 +66,15 @@ typedef struct KVMS390StAttribState { void s390_stattrib_init(void); +#ifdef CONFIG_KVM +Object *kvm_s390_stattrib_create(void); +#else +static inline Object *kvm_s390_stattrib_create(void) +{ + return NULL; +} +#endif + void hmp_info_cmma(Monitor *mon, const QDict *qdict); void hmp_migrationmode(Monitor *mon, const QDict *qdict);