aboutsummaryrefslogtreecommitdiff
path: root/spice-qemu-char.c
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2016-01-11 12:44:41 +0000
committerPaolo Bonzini <pbonzini@redhat.com>2016-01-15 18:58:02 +0100
commitd0d7708ba29cbcc343364a46bff981e0ff88366f (patch)
treec8cdee194dc2a941021082b68dfd5cbeff9752db /spice-qemu-char.c
parentf1c17521e79df863a5771d96974fab0d07f02be0 (diff)
qemu-char: add logfile facility to all chardev backends
Typically a UNIX guest OS will log boot messages to a serial port in addition to any graphical console. An admin user may also wish to use the serial port for an interactive console. A virtualization management system may wish to collect system boot messages by logging the serial port, but also wish to allow admins interactive access. Currently providing such a feature forces the mgmt app to either provide 2 separate serial ports, one for logging boot messages and one for interactive console login, or to proxy all output via a separate service that can multiplex the two needs onto one serial port. While both are valid approaches, they each have their own downsides. The former causes confusion and extra setup work for VM admins creating disk images. The latter places an extra burden to re-implement much of the QEMU chardev backends logic in libvirt or even higher level mgmt apps and adds extra hops in the data transfer path. A simpler approach that is satisfactory for many use cases is to allow the QEMU chardev backends to have a "logfile" property associated with them. $QEMU -chardev socket,host=localhost,port=9000,\ server=on,nowait,id-charserial0,\ logfile=/var/log/libvirt/qemu/test-serial0.log -device isa-serial,chardev=charserial0,id=serial0 This patch introduces a 'ChardevCommon' struct which is setup as a base for all the ChardevBackend types. Ideally this would be registered directly as a base against ChardevBackend, rather than each type, but the QAPI generator doesn't allow that since the ChardevBackend is a non-discriminated union. The ChardevCommon struct provides the optional 'logfile' parameter, as well as 'logappend' which controls whether QEMU truncates or appends (default truncate). Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Message-Id: <1452516281-27519-1-git-send-email-berrange@redhat.com> [Call qemu_chr_parse_common if cd->parse is NULL. - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'spice-qemu-char.c')
-rw-r--r--spice-qemu-char.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/spice-qemu-char.c b/spice-qemu-char.c
index e70e0f7366..8951d7ca37 100644
--- a/spice-qemu-char.c
+++ b/spice-qemu-char.c
@@ -271,13 +271,18 @@ static void spice_chr_accept_input(struct CharDriverState *chr)
}
static CharDriverState *chr_open(const char *subtype,
- void (*set_fe_open)(struct CharDriverState *, int))
-
+ void (*set_fe_open)(struct CharDriverState *,
+ int),
+ ChardevCommon *backend,
+ Error **errp)
{
CharDriverState *chr;
SpiceCharDriver *s;
- chr = qemu_chr_alloc();
+ chr = qemu_chr_alloc(backend, errp);
+ if (!chr) {
+ return NULL;
+ }
s = g_malloc0(sizeof(SpiceCharDriver));
s->chr = chr;
s->active = false;
@@ -303,6 +308,7 @@ static CharDriverState *qemu_chr_open_spice_vmc(const char *id,
{
const char *type = backend->u.spicevmc->type;
const char **psubtype = spice_server_char_device_recognized_subtypes();
+ ChardevCommon *common = qapi_ChardevSpiceChannel_base(backend->u.spicevmc);
for (; *psubtype != NULL; ++psubtype) {
if (strcmp(type, *psubtype) == 0) {
@@ -315,7 +321,7 @@ static CharDriverState *qemu_chr_open_spice_vmc(const char *id,
return NULL;
}
- return chr_open(type, spice_vmc_set_fe_open);
+ return chr_open(type, spice_vmc_set_fe_open, common, errp);
}
#if SPICE_SERVER_VERSION >= 0x000c02
@@ -325,6 +331,7 @@ static CharDriverState *qemu_chr_open_spice_port(const char *id,
Error **errp)
{
const char *name = backend->u.spiceport->fqdn;
+ ChardevCommon *common = qapi_ChardevSpicePort_base(backend->u.spiceport);
CharDriverState *chr;
SpiceCharDriver *s;
@@ -333,7 +340,10 @@ static CharDriverState *qemu_chr_open_spice_port(const char *id,
return NULL;
}
- chr = chr_open("port", spice_port_set_fe_open);
+ chr = chr_open("port", spice_port_set_fe_open, common, errp);
+ if (!chr) {
+ return NULL;
+ }
s = chr->opaque;
s->sin.portname = g_strdup(name);