Revision cfdf2c40 monitor.c

b/monitor.c
2053 2053
                                    vm_running, singlestep);
2054 2054
}
2055 2055

  
2056
static ram_addr_t balloon_get_value(void)
2057
{
2058
    ram_addr_t actual;
2059

  
2060
    if (kvm_enabled() && !kvm_has_sync_mmu()) {
2061
        qemu_error_new(QERR_KVM_MISSING_CAP, "synchronous MMU", "balloon");
2062
        return 0;
2063
    }
2064

  
2065
    actual = qemu_balloon_status();
2066
    if (actual == 0) {
2067
        qemu_error_new(QERR_DEVICE_NOT_ACTIVE, "balloon");
2068
        return 0;
2069
    }
2070

  
2071
    return actual;
2072
}
2073

  
2056 2074
/**
2057 2075
 * do_balloon(): Request VM to change its memory allocation
2058 2076
 */
2059 2077
static void do_balloon(Monitor *mon, const QDict *qdict, QObject **ret_data)
2060 2078
{
2061
    int value = qdict_get_int(qdict, "value");
2062
    ram_addr_t target = value;
2063
    qemu_balloon(target << 20);
2079
    if (balloon_get_value()) {
2080
        /* ballooning is active */
2081
        ram_addr_t value = qdict_get_int(qdict, "value");
2082
        qemu_balloon(value << 20);
2083
    }
2064 2084
}
2065 2085

  
2066 2086
static void monitor_print_balloon(Monitor *mon, const QObject *data)
......
2088 2108
{
2089 2109
    ram_addr_t actual;
2090 2110

  
2091
    actual = qemu_balloon_status();
2092
    if (kvm_enabled() && !kvm_has_sync_mmu())
2093
        qemu_error_new(QERR_KVM_MISSING_CAP, "synchronous MMU", "balloon");
2094
    else if (actual == 0)
2095
        qemu_error_new(QERR_DEVICE_NOT_ACTIVE, "balloon");
2096
    else
2111
    actual = balloon_get_value();
2112
    if (actual != 0) {
2097 2113
        *ret_data = qobject_from_jsonf("{ 'balloon': %" PRId64 "}",
2098 2114
                                       (int64_t) actual);
2115
    }
2099 2116
}
2100 2117

  
2101 2118
static qemu_acl *find_acl(Monitor *mon, const char *name)

Also available in: Unified diff