int kvm_s390_set_mem_limit(KVMState *s, uint64_t new_limit, uint64_t *hw_limit)

{

    int rc;



    struct kvm_device_attr attr = {

        .group = KVM_S390_VM_MEM_CTRL,

        .attr = KVM_S390_VM_MEM_LIMIT_SIZE,

        .addr = (uint64_t) &new_limit,

    };



    if (!kvm_s390_supports_mem_limit(s)) {

        return 0;

    }



    rc = kvm_s390_query_mem_limit(s, hw_limit);

    if (rc) {

        return rc;

    } else if (*hw_limit < new_limit) {

        return -E2BIG;

    }



    return kvm_vm_ioctl(s, KVM_SET_DEVICE_ATTR, &attr);

}

int kvm_s390_set_mem_limit(KVMState *s, uint64_t new_limit, uint64_t *hw_limit)

{

    int rc;



    struct kvm_device_attr attr = {

        .group = KVM_S390_VM_MEM_CTRL,

        .attr = KVM_S390_VM_MEM_LIMIT_SIZE,

        .addr = (uint64_t) &new_limit,

    };



    if (!kvm_s390_supports_mem_limit(s)) {

        return 0;

    }



    rc = kvm_s390_query_mem_limit(s, hw_limit);

    if (rc) {

        return rc;

    } else if (*hw_limit < new_limit) {

        return -E2BIG;

    }



    return kvm_vm_ioctl(s, KVM_SET_DEVICE_ATTR, &attr);

}

int FUNC_0(KVMState *VAR_0, uint64_t VAR_1, uint64_t *VAR_2)

{

    int VAR_3;



    struct kvm_device_attr VAR_4 = {

        .group = KVM_S390_VM_MEM_CTRL,

        .VAR_4 = KVM_S390_VM_MEM_LIMIT_SIZE,

        .addr = (uint64_t) &VAR_1,

    };



    if (!kvm_s390_supports_mem_limit(VAR_0)) {

        return 0;

    }



    VAR_3 = kvm_s390_query_mem_limit(VAR_0, VAR_2);

    if (VAR_3) {

        return VAR_3;

    } else if (*VAR_2 < VAR_1) {

        return -E2BIG;

    }



    return kvm_vm_ioctl(VAR_0, KVM_SET_DEVICE_ATTR, &VAR_4);

}

int FUNC_0(KVMState *VAR_0, uint64_t VAR_1, uint64_t *VAR_2)
{ int VAR_3; struct kvm_device_attr VAR_4 = { .group = KVM_S390_VM_MEM_CTRL,
.VAR_4 = KVM_S390_VM_MEM_LIMIT_SIZE,
.addr = (uint64_t) &VAR_1,
}; if (!kvm_s390_supports_mem_limit(VAR_0)) { return 0; } VAR_3 = kvm_s390_query_mem_limit(VAR_0, VAR_2); if (VAR_3) { return VAR_3; } else if (*VAR_2 < VAR_1) { return -E2BIG; } return kvm_vm_ioctl(VAR_0, KVM_SET_DEVICE_ATTR, &VAR_4); }