diff options
-rw-r--r-- | hw/qdev-properties.c | 4 | ||||
-rw-r--r-- | qemu-char.c | 5 | ||||
-rw-r--r-- | qemu-char.h | 2 |
3 files changed, 7 insertions, 4 deletions
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index 1088a26f8e..eff2d24945 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -354,10 +354,10 @@ static int parse_chr(DeviceState *dev, Property *prop, const char *str) if (*ptr == NULL) { return -ENOENT; } - if ((*ptr)->assigned) { + if ((*ptr)->avail_connections < 1) { return -EEXIST; } - (*ptr)->assigned = 1; + --(*ptr)->avail_connections; return 0; } diff --git a/qemu-char.c b/qemu-char.c index 710d98ffc4..eaf6571ac8 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -199,7 +199,7 @@ void qemu_chr_add_handlers(CharDriverState *s, { if (!opaque) { /* chr driver being released. */ - s->assigned = 0; + ++s->avail_connections; } s->chr_can_read = fd_can_read; s->chr_read = fd_read; @@ -2547,7 +2547,10 @@ CharDriverState *qemu_chr_open_opts(QemuOpts *opts, snprintf(base->label, len, "%s-base", qemu_opts_id(opts)); chr = qemu_chr_open_mux(base); chr->filename = base->filename; + chr->avail_connections = MAX_MUX; QTAILQ_INSERT_TAIL(&chardevs, chr, next); + } else { + chr->avail_connections = 1; } chr->label = qemu_strdup(qemu_opts_id(opts)); return chr; diff --git a/qemu-char.h b/qemu-char.h index 2f8512e528..892c6da9aa 100644 --- a/qemu-char.h +++ b/qemu-char.h @@ -72,7 +72,7 @@ struct CharDriverState { char *label; char *filename; int opened; - int assigned; /* chardev assigned to a device */ + int avail_connections; QTAILQ_ENTRY(CharDriverState) next; }; |