mirror of https://github.com/xqemu/xqemu.git
chardev: Properly initialize ChardevCommon components
Commit d0d7708b
forgot to parse logging for spice chardevs and
virtual consoles. This requires making qemu_chr_parse_common()
non-static. While at it, use a temporary variable to make the
code shorter, as well as reduce the churn when a later patch
alters the layout of simple unions.
Signed-off-by: Eric Blake <eblake@redhat.com>
CC: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1455927587-28033-2-git-send-email-eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
d61524486c
commit
21a933ea33
|
@ -114,6 +114,16 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,
|
||||||
void (*init)(struct CharDriverState *s),
|
void (*init)(struct CharDriverState *s),
|
||||||
Error **errp);
|
Error **errp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @qemu_chr_parse_common:
|
||||||
|
*
|
||||||
|
* Parse the common options available to all character backends.
|
||||||
|
*
|
||||||
|
* @opts the options that still need parsing
|
||||||
|
* @backend a new backend
|
||||||
|
*/
|
||||||
|
void qemu_chr_parse_common(QemuOpts *opts, ChardevCommon *backend);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @qemu_chr_new:
|
* @qemu_chr_new:
|
||||||
*
|
*
|
||||||
|
|
|
@ -3490,7 +3490,7 @@ fail:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qemu_chr_parse_common(QemuOpts *opts, ChardevCommon *backend)
|
void qemu_chr_parse_common(QemuOpts *opts, ChardevCommon *backend)
|
||||||
{
|
{
|
||||||
const char *logfile = qemu_opt_get(opts, "logfile");
|
const char *logfile = qemu_opt_get(opts, "logfile");
|
||||||
|
|
||||||
|
|
|
@ -366,26 +366,30 @@ static void qemu_chr_parse_spice_vmc(QemuOpts *opts, ChardevBackend *backend,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
const char *name = qemu_opt_get(opts, "name");
|
const char *name = qemu_opt_get(opts, "name");
|
||||||
|
ChardevSpiceChannel *spicevmc;
|
||||||
|
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
error_setg(errp, "chardev: spice channel: no name given");
|
error_setg(errp, "chardev: spice channel: no name given");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
backend->u.spicevmc = g_new0(ChardevSpiceChannel, 1);
|
spicevmc = backend->u.spicevmc = g_new0(ChardevSpiceChannel, 1);
|
||||||
backend->u.spicevmc->type = g_strdup(name);
|
qemu_chr_parse_common(opts, qapi_ChardevSpiceChannel_base(spicevmc));
|
||||||
|
spicevmc->type = g_strdup(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qemu_chr_parse_spice_port(QemuOpts *opts, ChardevBackend *backend,
|
static void qemu_chr_parse_spice_port(QemuOpts *opts, ChardevBackend *backend,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
const char *name = qemu_opt_get(opts, "name");
|
const char *name = qemu_opt_get(opts, "name");
|
||||||
|
ChardevSpicePort *spiceport;
|
||||||
|
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
error_setg(errp, "chardev: spice port: no name given");
|
error_setg(errp, "chardev: spice port: no name given");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
backend->u.spiceport = g_new0(ChardevSpicePort, 1);
|
spiceport = backend->u.spiceport = g_new0(ChardevSpicePort, 1);
|
||||||
backend->u.spiceport->fqdn = g_strdup(name);
|
qemu_chr_parse_common(opts, qapi_ChardevSpicePort_base(spiceport));
|
||||||
|
spiceport->fqdn = g_strdup(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void register_types(void)
|
static void register_types(void)
|
||||||
|
|
20
ui/console.c
20
ui/console.c
|
@ -2060,31 +2060,33 @@ static void qemu_chr_parse_vc(QemuOpts *opts, ChardevBackend *backend,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
int val;
|
int val;
|
||||||
|
ChardevVC *vc;
|
||||||
|
|
||||||
backend->u.vc = g_new0(ChardevVC, 1);
|
vc = backend->u.vc = g_new0(ChardevVC, 1);
|
||||||
|
qemu_chr_parse_common(opts, qapi_ChardevVC_base(vc));
|
||||||
|
|
||||||
val = qemu_opt_get_number(opts, "width", 0);
|
val = qemu_opt_get_number(opts, "width", 0);
|
||||||
if (val != 0) {
|
if (val != 0) {
|
||||||
backend->u.vc->has_width = true;
|
vc->has_width = true;
|
||||||
backend->u.vc->width = val;
|
vc->width = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
val = qemu_opt_get_number(opts, "height", 0);
|
val = qemu_opt_get_number(opts, "height", 0);
|
||||||
if (val != 0) {
|
if (val != 0) {
|
||||||
backend->u.vc->has_height = true;
|
vc->has_height = true;
|
||||||
backend->u.vc->height = val;
|
vc->height = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
val = qemu_opt_get_number(opts, "cols", 0);
|
val = qemu_opt_get_number(opts, "cols", 0);
|
||||||
if (val != 0) {
|
if (val != 0) {
|
||||||
backend->u.vc->has_cols = true;
|
vc->has_cols = true;
|
||||||
backend->u.vc->cols = val;
|
vc->cols = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
val = qemu_opt_get_number(opts, "rows", 0);
|
val = qemu_opt_get_number(opts, "rows", 0);
|
||||||
if (val != 0) {
|
if (val != 0) {
|
||||||
backend->u.vc->has_rows = true;
|
vc->has_rows = true;
|
||||||
backend->u.vc->rows = val;
|
vc->rows = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue