Commit 456d6069 authored by Hans de Goede's avatar Hans de Goede Committed by Anthony Liguori
Browse files

qemu-char: Call fe_claim / fe_release when not using qdev chr properties



chardev-frontends need to explictly check, increase and decrement the
avail_connections "property" of the chardev when they are not using a
qdev-chardev-property for the chardev.

This fixes things like:
qemu-kvm -chardev stdio,id=foo -device isa-serial,chardev=foo \
  -mon chardev=foo

Working, where they should fail. Most of the changes here are due to
old hardware emulation code which is using serial_hds directly rather then
a qdev-chardev-property.

Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Message-id: 1364412581-3672-3-git-send-email-hdegoede@redhat.com
Signed-off-by: default avatarAnthony Liguori <aliguori@us.ibm.com>
parent 44c473de
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -149,6 +149,11 @@ static void rng_egd_opened(RngBackend *b, Error **errp)
        return;
    }

    if (qemu_chr_fe_claim(s->chr) != 0) {
        error_set(errp, QERR_DEVICE_IN_USE, s->chr_name);
        return;
    }

    /* FIXME we should resubmit pending requests when the CDS reconnects. */
    qemu_chr_add_handlers(s->chr, rng_egd_chr_can_read, rng_egd_chr_read,
                          NULL, s);
@@ -191,6 +196,7 @@ static void rng_egd_finalize(Object *obj)

    if (s->chr) {
        qemu_chr_add_handlers(s->chr, NULL, NULL, NULL, NULL);
        qemu_chr_fe_release(s->chr);
    }

    g_free(s->chr_name);
+1 −0
Original line number Diff line number Diff line
@@ -3025,6 +3025,7 @@ int gdbserver_start(const char *device)
        if (!chr)
            return -1;

        qemu_chr_fe_claim_no_fail(chr);
        qemu_chr_add_handlers(chr, gdb_chr_can_receive, gdb_chr_receive,
                              gdb_chr_event, NULL);
    }
+3 −1
Original line number Diff line number Diff line
@@ -1981,9 +1981,11 @@ static PXA2xxFIrState *pxa2xx_fir_init(MemoryRegion *sysmem,
    memory_region_init_io(&s->iomem, &pxa2xx_fir_ops, s, "pxa2xx-fir", 0x1000);
    memory_region_add_subregion(sysmem, base, &s->iomem);

    if (chr)
    if (chr) {
        qemu_chr_fe_claim_no_fail(chr);
        qemu_chr_add_handlers(chr, pxa2xx_fir_is_empty,
                        pxa2xx_fir_rx, pxa2xx_fir_event, s);
    }

    register_savevm(NULL, "pxa2xx_fir", 0, 0, pxa2xx_fir_save,
                    pxa2xx_fir_load, s);
+1 −0
Original line number Diff line number Diff line
@@ -439,6 +439,7 @@ CharDriverState *uart_hci_init(qemu_irq wakeup)
    s->chr.opaque = s;
    s->chr.chr_write = csrhci_write;
    s->chr.chr_ioctl = csrhci_ioctl;
    s->chr.avail_connections = 1;

    s->hci = qemu_next_hci();
    s->hci->opaque = s;
+1 −0
Original line number Diff line number Diff line
@@ -556,6 +556,7 @@ static int ipoctal_init(IPackDevice *ip)

            if (ch->dev) {
                index++;
                qemu_chr_fe_claim_no_fail(ch->dev);
                qemu_chr_add_handlers(ch->dev, hostdev_can_receive,
                                      hostdev_receive, hostdev_event, ch);
                DPRINTF("Redirecting channel %u to %s (%s)\n",
Loading