diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2019-02-13 14:18:13 +0100 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2019-02-13 14:23:39 +0100 |
commit | 4ad6f6cb149b03ab9399a63208918cde09248294 (patch) | |
tree | 7bb7be7dc3fbdd36e7f93e8d9f3ed4858a71eda3 /chardev | |
parent | 211ef6c4b6297a6275015c16b76bc72de35c56c3 (diff) | |
download | qemu-4ad6f6cb149b03ab9399a63208918cde09248294.zip qemu-4ad6f6cb149b03ab9399a63208918cde09248294.tar.gz qemu-4ad6f6cb149b03ab9399a63208918cde09248294.tar.bz2 |
char: allow specifying a GMainContext at opening time
This will be needed by vhost-user-test, when each test switches to
its own GMainLoop and GMainContext. Otherwise, for a reconnecting
socket the initial connection will happen on the default GMainContext,
and no one will be listening on it.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20190202110834.24880-1-pbonzini@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Diffstat (limited to 'chardev')
-rw-r--r-- | chardev/char.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/chardev/char.c b/chardev/char.c index b99f369..f6d61fa 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -636,7 +636,8 @@ ChardevBackend *qemu_chr_parse_opts(QemuOpts *opts, Error **errp) return backend; } -Chardev *qemu_chr_new_from_opts(QemuOpts *opts, Error **errp) +Chardev *qemu_chr_new_from_opts(QemuOpts *opts, GMainContext *context, + Error **errp) { const ChardevClass *cc; Chardev *chr = NULL; @@ -676,7 +677,7 @@ Chardev *qemu_chr_new_from_opts(QemuOpts *opts, Error **errp) chr = qemu_chardev_new(bid ? bid : id, object_class_get_name(OBJECT_CLASS(cc)), - backend, errp); + backend, context, errp); if (chr == NULL) { goto out; @@ -689,7 +690,7 @@ Chardev *qemu_chr_new_from_opts(QemuOpts *opts, Error **errp) backend->type = CHARDEV_BACKEND_KIND_MUX; backend->u.mux.data = g_new0(ChardevMux, 1); backend->u.mux.data->chardev = g_strdup(bid); - mux = qemu_chardev_new(id, TYPE_CHARDEV_MUX, backend, errp); + mux = qemu_chardev_new(id, TYPE_CHARDEV_MUX, backend, context, errp); if (mux == NULL) { object_unparent(OBJECT(chr)); chr = NULL; @@ -705,7 +706,7 @@ out: } Chardev *qemu_chr_new_noreplay(const char *label, const char *filename, - bool permit_mux_mon) + bool permit_mux_mon, GMainContext *context) { const char *p; Chardev *chr; @@ -720,7 +721,7 @@ Chardev *qemu_chr_new_noreplay(const char *label, const char *filename, if (!opts) return NULL; - chr = qemu_chr_new_from_opts(opts, &err); + chr = qemu_chr_new_from_opts(opts, context, &err); if (!chr) { error_report_err(err); goto out; @@ -738,10 +739,11 @@ out: static Chardev *qemu_chr_new_permit_mux_mon(const char *label, const char *filename, - bool permit_mux_mon) + bool permit_mux_mon, + GMainContext *context) { Chardev *chr; - chr = qemu_chr_new_noreplay(label, filename, permit_mux_mon); + chr = qemu_chr_new_noreplay(label, filename, permit_mux_mon, context); if (chr) { if (replay_mode != REPLAY_MODE_NONE) { qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_REPLAY); @@ -755,14 +757,16 @@ static Chardev *qemu_chr_new_permit_mux_mon(const char *label, return chr; } -Chardev *qemu_chr_new(const char *label, const char *filename) +Chardev *qemu_chr_new(const char *label, const char *filename, + GMainContext *context) { - return qemu_chr_new_permit_mux_mon(label, filename, false); + return qemu_chr_new_permit_mux_mon(label, filename, false, context); } -Chardev *qemu_chr_new_mux_mon(const char *label, const char *filename) +Chardev *qemu_chr_new_mux_mon(const char *label, const char *filename, + GMainContext *context) { - return qemu_chr_new_permit_mux_mon(label, filename, true); + return qemu_chr_new_permit_mux_mon(label, filename, true, context); } static int qmp_query_chardev_foreach(Object *obj, void *data) @@ -937,6 +941,7 @@ void qemu_chr_set_feature(Chardev *chr, Chardev *qemu_chardev_new(const char *id, const char *typename, ChardevBackend *backend, + GMainContext *gcontext, Error **errp) { Object *obj; @@ -949,6 +954,7 @@ Chardev *qemu_chardev_new(const char *id, const char *typename, obj = object_new(typename); chr = CHARDEV(obj); chr->label = g_strdup(id); + chr->gcontext = gcontext; qemu_char_open(chr, backend, &be_opened, &local_err); if (local_err) { @@ -993,7 +999,7 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend, } chr = qemu_chardev_new(id, object_class_get_name(OBJECT_CLASS(cc)), - backend, errp); + backend, NULL, errp); if (!chr) { return NULL; } @@ -1051,7 +1057,7 @@ ChardevReturn *qmp_chardev_change(const char *id, ChardevBackend *backend, } chr_new = qemu_chardev_new(NULL, object_class_get_name(OBJECT_CLASS(cc)), - backend, errp); + backend, chr->gcontext, errp); if (!chr_new) { return NULL; } |