mirror of https://github.com/xemu-project/xemu.git
char: Allow devices to use a single multiplexed chardev.
This fixes regression caused by commit
2d6c1ef40f
("char: Prevent multiple devices opening same chardev"):
-nodefaults -nographic -chardev stdio,id=stdio,mux=on,signal=off \
-mon stdio -device virtio-serial-pci \
-device virtconsole,chardev=stdio -device isa-serial,chardev=stdio
fails with:
qemu-system-x86_64: -device isa-serial,chardev=stdio: Property 'isa-serial.chardev' can't take value 'stdio', it's in use
Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
This commit is contained in:
parent
cd8f7df289
commit
d5b27167e1
|
@ -354,10 +354,10 @@ static int parse_chr(DeviceState *dev, Property *prop, const char *str)
|
||||||
if (*ptr == NULL) {
|
if (*ptr == NULL) {
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
if ((*ptr)->assigned) {
|
if ((*ptr)->avail_connections < 1) {
|
||||||
return -EEXIST;
|
return -EEXIST;
|
||||||
}
|
}
|
||||||
(*ptr)->assigned = 1;
|
--(*ptr)->avail_connections;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -199,7 +199,7 @@ void qemu_chr_add_handlers(CharDriverState *s,
|
||||||
{
|
{
|
||||||
if (!opaque) {
|
if (!opaque) {
|
||||||
/* chr driver being released. */
|
/* chr driver being released. */
|
||||||
s->assigned = 0;
|
++s->avail_connections;
|
||||||
}
|
}
|
||||||
s->chr_can_read = fd_can_read;
|
s->chr_can_read = fd_can_read;
|
||||||
s->chr_read = fd_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));
|
snprintf(base->label, len, "%s-base", qemu_opts_id(opts));
|
||||||
chr = qemu_chr_open_mux(base);
|
chr = qemu_chr_open_mux(base);
|
||||||
chr->filename = base->filename;
|
chr->filename = base->filename;
|
||||||
|
chr->avail_connections = MAX_MUX;
|
||||||
QTAILQ_INSERT_TAIL(&chardevs, chr, next);
|
QTAILQ_INSERT_TAIL(&chardevs, chr, next);
|
||||||
|
} else {
|
||||||
|
chr->avail_connections = 1;
|
||||||
}
|
}
|
||||||
chr->label = qemu_strdup(qemu_opts_id(opts));
|
chr->label = qemu_strdup(qemu_opts_id(opts));
|
||||||
return chr;
|
return chr;
|
||||||
|
|
|
@ -72,7 +72,7 @@ struct CharDriverState {
|
||||||
char *label;
|
char *label;
|
||||||
char *filename;
|
char *filename;
|
||||||
int opened;
|
int opened;
|
||||||
int assigned; /* chardev assigned to a device */
|
int avail_connections;
|
||||||
QTAILQ_ENTRY(CharDriverState) next;
|
QTAILQ_ENTRY(CharDriverState) next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue