/*
 * Copyright (C) 2018 Virtual Open Systems
 *
 * setmaxmem command handler for aarch64
 * FIXME: this should be enabled only for AARCH64
 */
#include "qemu/osdep.h"
#include "sysemu/setmaxmem.h"
#include "qapi/error.h"

static void *setmaxmem_opaque;
static QEMUSetmaxmemEvent *setmaxmem_event_fn;

/* Call this from virtio-balloon.c::realize */
int qemu_add_setmaxmem_handler(QEMUSetmaxmemEvent *event_func, void *opaque)
{
    int out = 0;

    if (setmaxmem_event_fn) {
        out = -1;
    }

    /* virtio-balloon pointer */
    setmaxmem_opaque = opaque;
    setmaxmem_event_fn = event_func;

    return out;
}

void qmp_setmaxmem(int64_t target, Error **errp)
{
   setmaxmem_event_fn(setmaxmem_opaque, target);
}
