From 2b147555f78c3c20080b201fd1506467fa0ddf43 Mon Sep 17 00:00:00 2001 From: Dominik Dingel Date: Thu, 12 Mar 2015 13:53:50 +0100 Subject: s390x/kvm: make use of generic vm attribute check By using the new introduced generic interface we can remove redundancies and clean up. Reviewed-by: Thomas Huth Suggested-by: Thomas Huth Signed-off-by: Dominik Dingel Signed-off-by: Jens Freimann Message-Id: <1426164834-38648-3-git-send-email-jfrei@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck --- target-s390x/kvm.c | 42 +++++++----------------------------------- 1 file changed, 7 insertions(+), 35 deletions(-) (limited to 'target-s390x') diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c index b21a348..38887aa 100644 --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -55,6 +55,9 @@ do { } while (0) #endif +#define kvm_vm_check_mem_attr(s, attr) \ + kvm_vm_check_attr(s, KVM_S390_VM_MEM_CTRL, attr) + #define IPA0_DIAG 0x8300 #define IPA0_SIGP 0xae00 #define IPA0_B2 0xb200 @@ -122,16 +125,6 @@ static int cap_async_pf; static void *legacy_s390_alloc(size_t size, uint64_t *align); -static int kvm_s390_supports_mem_limit(KVMState *s) -{ - struct kvm_device_attr attr = { - .group = KVM_S390_VM_MEM_CTRL, - .attr = KVM_S390_VM_MEM_LIMIT_SIZE, - }; - - return (kvm_vm_ioctl(s, KVM_HAS_DEVICE_ATTR, &attr) == 0); -} - static int kvm_s390_query_mem_limit(KVMState *s, uint64_t *memory_limit) { struct kvm_device_attr attr = { @@ -153,7 +146,7 @@ int kvm_s390_set_mem_limit(KVMState *s, uint64_t new_limit, uint64_t *hw_limit) .addr = (uint64_t) &new_limit, }; - if (!kvm_s390_supports_mem_limit(s)) { + if (!kvm_vm_check_mem_attr(s, KVM_S390_VM_MEM_LIMIT_SIZE)) { return 0; } @@ -167,26 +160,6 @@ int kvm_s390_set_mem_limit(KVMState *s, uint64_t new_limit, uint64_t *hw_limit) return kvm_vm_ioctl(s, KVM_SET_DEVICE_ATTR, &attr); } -static int kvm_s390_check_clear_cmma(KVMState *s) -{ - struct kvm_device_attr attr = { - .group = KVM_S390_VM_MEM_CTRL, - .attr = KVM_S390_VM_MEM_CLR_CMMA, - }; - - return kvm_vm_ioctl(s, KVM_HAS_DEVICE_ATTR, &attr); -} - -static int kvm_s390_check_enable_cmma(KVMState *s) -{ - struct kvm_device_attr attr = { - .group = KVM_S390_VM_MEM_CTRL, - .attr = KVM_S390_VM_MEM_ENABLE_CMMA, - }; - - return kvm_vm_ioctl(s, KVM_HAS_DEVICE_ATTR, &attr); -} - void kvm_s390_clear_cmma_callback(void *opaque) { int rc; @@ -208,7 +181,8 @@ static void kvm_s390_enable_cmma(KVMState *s) .attr = KVM_S390_VM_MEM_ENABLE_CMMA, }; - if (kvm_s390_check_enable_cmma(s) || kvm_s390_check_clear_cmma(s)) { + if (!kvm_vm_check_mem_attr(s, KVM_S390_VM_MEM_ENABLE_CMMA) || + !kvm_vm_check_mem_attr(s, KVM_S390_VM_MEM_CLR_CMMA)) { return; } @@ -224,9 +198,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) cap_sync_regs = kvm_check_extension(s, KVM_CAP_SYNC_REGS); cap_async_pf = kvm_check_extension(s, KVM_CAP_ASYNC_PF); - if (kvm_check_extension(s, KVM_CAP_VM_ATTRIBUTES)) { - kvm_s390_enable_cmma(s); - } + kvm_s390_enable_cmma(s); if (!kvm_check_extension(s, KVM_CAP_S390_GMAP) || !kvm_check_extension(s, KVM_CAP_S390_COW)) { -- cgit v1.1