/* Note: Pass buf and len to kernel. Start with one page and increase until buffer is sufficient or maxium size is reached  */
static void kvm_flic_save(QEMUFile *f, void *opaque)
/* Note: Pass buf and len to kernel. Start with one page and increase until buffer is sufficient or maxium size is reached  */
static void kvm_flic_save(QEMUFile *f, void *opaque)
{
    KVMS390FLICState *flic = opaque;
    int len = FLIC_SAVE_INITIAL_SIZE;
    void *buf;
    int count;
    flic_disable_wait_pfault((struct KVMS390FLICState *) opaque);
    buf = g_try_malloc0(len);
    if (!buf) {
        error_report("flic: couldn't allocate memory");
        qemu_put_be64(f, FLIC_FAILED);
        return;
    }
    count = __get_all_irqs(flic, &buf, len);
    if (count < 0) {
        error_report("flic: couldn't retrieve irqs from kernel, rc %d",
                     count);
        qemu_put_be64(f, FLIC_FAILED);
    } else {
        qemu_put_be64(f, count);
        qemu_put_buffer(f, (uint8_t *) buf,
                        count * sizeof(struct kvm_s390_irq));
    }
    g_free(buf);
}