aboutsummaryrefslogtreecommitdiff
path: root/target-s390x/kvm.c
diff options
context:
space:
mode:
authorDominik Dingel <dingel@linux.vnet.ibm.com>2015-03-12 13:53:50 +0100
committerCornelia Huck <cornelia.huck@de.ibm.com>2015-03-16 10:15:45 +0100
commit2b147555f78c3c20080b201fd1506467fa0ddf43 (patch)
tree9a12364b54d2643c6f5f53ec677d2af25c776c08 /target-s390x/kvm.c
parentd0a073a186e4a81ae81435bd5b7286b657a69bfd (diff)
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 <thuth@linux.vnet.ibm.com> Suggested-by: Thomas Huth <thuth@linux.vnet.ibm.com> Signed-off-by: Dominik Dingel <dingel@linux.vnet.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Message-Id: <1426164834-38648-3-git-send-email-jfrei@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Diffstat (limited to 'target-s390x/kvm.c')
-rw-r--r--target-s390x/kvm.c42
1 files changed, 7 insertions, 35 deletions
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index b21a348805..38887aa171 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)) {