From nobody Mon Apr 29 15:22:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493898258370557.5037857131376; Thu, 4 May 2017 04:44:18 -0700 (PDT) Received: from localhost ([::1]:41181 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FBA-0003jy-VU for importer@patchew.org; Thu, 04 May 2017 07:44:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45764) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6F9j-0002H6-JV for qemu-devel@nongnu.org; Thu, 04 May 2017 07:42:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6F9i-0004Dj-Gr for qemu-devel@nongnu.org; Thu, 04 May 2017 07:42:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50378) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6F9i-0004DZ-7b for qemu-devel@nongnu.org; Thu, 04 May 2017 07:42:46 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2872D63E21; Thu, 4 May 2017 11:42:45 +0000 (UTC) Received: from localhost (ovpn-117-244.ams2.redhat.com [10.36.117.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id E11D57D94C; Thu, 4 May 2017 11:42:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2872D63E21 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2872D63E21 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 4 May 2017 15:42:12 +0400 Message-Id: <20170504114232.20318-2-marcandre.lureau@redhat.com> In-Reply-To: <20170504114232.20318-1-marcandre.lureau@redhat.com> References: <20170504114232.20318-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 04 May 2017 11:42:45 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 01/21] char: remove qemu_chr_be_generic_open X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stefanha@gmail.com, Paolo Bonzini , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The function simply alias and hides the real event function. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/sysemu/char.h | 1 - chardev/char-pty.c | 2 +- chardev/char-socket.c | 2 +- chardev/char.c | 10 ++-------- ui/console.c | 2 +- ui/gtk.c | 2 +- 6 files changed, 6 insertions(+), 13 deletions(-) diff --git a/include/sysemu/char.h b/include/sysemu/char.h index 450881d42c..a30ff3fa80 100644 --- a/include/sysemu/char.h +++ b/include/sysemu/char.h @@ -427,7 +427,6 @@ void qemu_chr_fe_set_handlers(CharBackend *b, */ void qemu_chr_fe_take_focus(CharBackend *b); =20 -void qemu_chr_be_generic_open(Chardev *s); void qemu_chr_fe_accept_input(CharBackend *be); int qemu_chr_add_client(Chardev *s, int fd); Chardev *qemu_chr_find(const char *name); diff --git a/chardev/char-pty.c b/chardev/char-pty.c index a6337be8aa..aa9d0cb2c3 100644 --- a/chardev/char-pty.c +++ b/chardev/char-pty.c @@ -185,7 +185,7 @@ static gboolean qemu_chr_be_generic_open_func(gpointer = opaque) PtyChardev *s =3D PTY_CHARDEV(opaque); =20 s->open_tag =3D 0; - qemu_chr_be_generic_open(chr); + qemu_chr_be_event(chr, CHR_EVENT_OPENED); return FALSE; } =20 diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 36ab0d633a..2789eb1f40 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -489,7 +489,7 @@ static void tcp_chr_connect(void *opaque) tcp_chr_read, chr, NULL); } - qemu_chr_be_generic_open(chr); + qemu_chr_be_event(chr, CHR_EVENT_OPENED); } =20 static void tcp_chr_update_read_handler(Chardev *chr, diff --git a/chardev/char.c b/chardev/char.c index 3df116350b..aad639b620 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -66,12 +66,6 @@ void qemu_chr_be_event(Chardev *s, int event) be->chr_event(be->opaque, event); } =20 -void qemu_chr_be_generic_open(Chardev *s) -{ - qemu_chr_be_event(s, CHR_EVENT_OPENED); -} - - /* Not reporting errors from writing to logfile, as logs are * defined to be "best effort" only */ static void qemu_chr_fe_write_log(Chardev *s, @@ -469,7 +463,7 @@ static void muxes_realize_done(Notifier *notifier, void= *unused) /* mark mux as OPENED so any new FEs will immediately receive * OPENED event */ - qemu_chr_be_generic_open(chr); + qemu_chr_be_event(chr, CHR_EVENT_OPENED); } } muxes_realized =3D true; @@ -581,7 +575,7 @@ void qemu_chr_fe_set_handlers(CharBackend *b, /* We're connecting to an already opened device, so let's make sur= e we also get the open event */ if (s->be_open) { - qemu_chr_be_generic_open(s); + qemu_chr_be_event(s, CHR_EVENT_OPENED); } } =20 diff --git a/ui/console.c b/ui/console.c index 189eecfd29..ac66b3c910 100644 --- a/ui/console.c +++ b/ui/console.c @@ -2076,7 +2076,7 @@ static void text_console_do_init(Chardev *chr, Displa= yState *ds) s->t_attrib =3D s->t_attrib_default; } =20 - qemu_chr_be_generic_open(chr); + qemu_chr_be_event(chr, CHR_EVENT_OPENED); } =20 static void vc_chr_open(Chardev *chr, diff --git a/ui/gtk.c b/ui/gtk.c index a86848f3b0..7479ceef35 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1868,7 +1868,7 @@ static GSList *gd_vc_vte_init(GtkDisplayState *s, Vir= tualConsole *vc, gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook), vc->tab_item, gtk_label_new(vc->label)); =20 - qemu_chr_be_generic_open(vc->vte.chr); + qemu_chr_be_event(vc->vte.chr, CHR_EVENT_OPENED); =20 return group; } --=20 2.12.0.191.gc5d8de91d From nobody Mon Apr 29 15:22:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493898273772975.6167467171913; Thu, 4 May 2017 04:44:33 -0700 (PDT) Received: from localhost ([::1]:41182 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FBP-0003wb-6A for importer@patchew.org; Thu, 04 May 2017 07:44:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45792) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6F9s-0002Sa-R5 for qemu-devel@nongnu.org; Thu, 04 May 2017 07:42:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6F9n-0004G0-Qs for qemu-devel@nongnu.org; Thu, 04 May 2017 07:42:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50480) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6F9n-0004Fj-Hi for qemu-devel@nongnu.org; Thu, 04 May 2017 07:42:51 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7869C64DB8; Thu, 4 May 2017 11:42:50 +0000 (UTC) Received: from localhost (ovpn-117-244.ams2.redhat.com [10.36.117.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD55877559; Thu, 4 May 2017 11:42:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7869C64DB8 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7869C64DB8 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 4 May 2017 15:42:13 +0400 Message-Id: <20170504114232.20318-3-marcandre.lureau@redhat.com> In-Reply-To: <20170504114232.20318-1-marcandre.lureau@redhat.com> References: <20170504114232.20318-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 04 May 2017 11:42:50 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 02/21] mux: simplfy muxes_realize_done X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stefanha@gmail.com, Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" mux_chr_event() already send events to all backends, rename it, export it, and use it from muxes_realize_done. This should help abstract away mux implementation. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- chardev/char-mux.h | 2 +- chardev/char-mux.c | 11 ++++++++--- chardev/char.c | 9 ++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/chardev/char-mux.h b/chardev/char-mux.h index 9a2fffce91..3f41dfcfd2 100644 --- a/chardev/char-mux.h +++ b/chardev/char-mux.h @@ -58,6 +58,6 @@ typedef struct MuxChardev { =20 void mux_chr_set_handlers(Chardev *chr, GMainContext *context); void mux_set_focus(Chardev *chr, int focus); -void mux_chr_send_event(MuxChardev *d, int mux_nr, int event); +void mux_chr_send_all_event(Chardev *chr, int event); =20 #endif /* CHAR_MUX_H */ diff --git a/chardev/char-mux.c b/chardev/char-mux.c index 5547a36a0a..37d42c65c6 100644 --- a/chardev/char-mux.c +++ b/chardev/char-mux.c @@ -114,7 +114,7 @@ static void mux_print_help(Chardev *chr) } } =20 -void mux_chr_send_event(MuxChardev *d, int mux_nr, int event) +static void mux_chr_send_event(MuxChardev *d, int mux_nr, int event) { CharBackend *be =3D d->backends[mux_nr]; =20 @@ -222,9 +222,9 @@ static void mux_chr_read(void *opaque, const uint8_t *b= uf, int size) =20 bool muxes_realized; =20 -static void mux_chr_event(void *opaque, int event) +void mux_chr_send_all_event(Chardev *chr, int event) { - MuxChardev *d =3D MUX_CHARDEV(opaque); + MuxChardev *d =3D MUX_CHARDEV(chr); int i; =20 if (!muxes_realized) { @@ -237,6 +237,11 @@ static void mux_chr_event(void *opaque, int event) } } =20 +static void mux_chr_event(void *opaque, int event) +{ + mux_chr_send_all_event(CHARDEV(opaque), event); +} + static GSource *mux_chr_add_watch(Chardev *s, GIOCondition cond) { MuxChardev *d =3D MUX_CHARDEV(s); diff --git a/chardev/char.c b/chardev/char.c index aad639b620..674c097fbe 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -451,22 +451,17 @@ static void muxes_realize_done(Notifier *notifier, vo= id *unused) { Chardev *chr; =20 + muxes_realized =3D true; QTAILQ_FOREACH(chr, &chardevs, next) { if (CHARDEV_IS_MUX(chr)) { - MuxChardev *d =3D MUX_CHARDEV(chr); - int i; - /* send OPENED to all already-attached FEs */ - for (i =3D 0; i < d->mux_cnt; i++) { - mux_chr_send_event(d, i, CHR_EVENT_OPENED); - } + mux_chr_send_all_event(CHARDEV(chr), CHR_EVENT_OPENED); /* mark mux as OPENED so any new FEs will immediately receive * OPENED event */ qemu_chr_be_event(chr, CHR_EVENT_OPENED); } } - muxes_realized =3D true; } =20 static Notifier muxes_realize_notify =3D { --=20 2.12.0.191.gc5d8de91d From nobody Mon Apr 29 15:22:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493898421590752.2743068363217; Thu, 4 May 2017 04:47:01 -0700 (PDT) Received: from localhost ([::1]:41196 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FDn-00066X-B5 for importer@patchew.org; Thu, 04 May 2017 07:46:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45843) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FA3-0002uO-02 for qemu-devel@nongnu.org; Thu, 04 May 2017 07:43:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6F9x-0004Ia-B4 for qemu-devel@nongnu.org; Thu, 04 May 2017 07:43:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50672) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6F9x-0004IG-54 for qemu-devel@nongnu.org; Thu, 04 May 2017 07:43:01 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 038D94E339; Thu, 4 May 2017 11:43:00 +0000 (UTC) Received: from localhost (ovpn-117-244.ams2.redhat.com [10.36.117.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id 279B480DEF; Thu, 4 May 2017 11:42:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 038D94E339 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 038D94E339 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 4 May 2017 15:42:14 +0400 Message-Id: <20170504114232.20318-4-marcandre.lureau@redhat.com> In-Reply-To: <20170504114232.20318-1-marcandre.lureau@redhat.com> References: <20170504114232.20318-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 04 May 2017 11:43:00 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 03/21] xen: use a better chardev type check X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anthony Perard , stefanha@gmail.com, Stefano Stabellini , "open list:X86" , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/xen/xen-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c index ae76150e8a..a9055e9eba 100644 --- a/hw/xen/xen-common.c +++ b/hw/xen/xen-common.c @@ -38,7 +38,7 @@ static int store_dev_info(int domid, Chardev *cs, const c= har *string) int ret =3D -1; =20 /* Only continue if we're talking to a pty. */ - if (strncmp(cs->filename, "pty:", 4)) { + if (!CHARDEV_IS_PTY(cs)) { return 0; } pts =3D cs->filename + 4; --=20 2.12.0.191.gc5d8de91d From nobody Mon Apr 29 15:22:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493898293348986.8180616275583; Thu, 4 May 2017 04:44:53 -0700 (PDT) Received: from localhost ([::1]:41184 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FBj-0004Gw-Kf for importer@patchew.org; Thu, 04 May 2017 07:44:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45872) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FA7-00034m-VH for qemu-devel@nongnu.org; Thu, 04 May 2017 07:43:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6FA3-0004KF-15 for qemu-devel@nongnu.org; Thu, 04 May 2017 07:43:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38724) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6FA2-0004Jx-R4 for qemu-devel@nongnu.org; Thu, 04 May 2017 07:43:06 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B95C880C22; Thu, 4 May 2017 11:43:05 +0000 (UTC) Received: from localhost (ovpn-117-244.ams2.redhat.com [10.36.117.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0DDB95DD67; Thu, 4 May 2017 11:43:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B95C880C22 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B95C880C22 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 4 May 2017 15:42:15 +0400 Message-Id: <20170504114232.20318-5-marcandre.lureau@redhat.com> In-Reply-To: <20170504114232.20318-1-marcandre.lureau@redhat.com> References: <20170504114232.20318-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 04 May 2017 11:43:05 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 04/21] container: don't leak container reference X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stefanha@gmail.com, =?UTF-8?q?Andreas=20F=C3=A4rber?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" object_property_add_child() references the child, unref it after to avoid ref leaks. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- qom/container.c | 1 + 1 file changed, 1 insertion(+) diff --git a/qom/container.c b/qom/container.c index c9eb49b01e..f6ccaf7ea7 100644 --- a/qom/container.c +++ b/qom/container.c @@ -40,6 +40,7 @@ Object *container_get(Object *root, const char *path) if (!child) { child =3D object_new("container"); object_property_add_child(obj, parts[i], child, NULL); + object_unref(child); } } =20 --=20 2.12.0.191.gc5d8de91d From nobody Mon Apr 29 15:22:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493898443406521.6219862708704; Thu, 4 May 2017 04:47:23 -0700 (PDT) Received: from localhost ([::1]:41197 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FE9-0006PO-RE for importer@patchew.org; Thu, 04 May 2017 07:47:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FAD-0003BE-R6 for qemu-devel@nongnu.org; Thu, 04 May 2017 07:43:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6FAC-0004On-Hx for qemu-devel@nongnu.org; Thu, 04 May 2017 07:43:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50952) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6FAC-0004NP-7z for qemu-devel@nongnu.org; Thu, 04 May 2017 07:43:16 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3B2204E357; Thu, 4 May 2017 11:43:15 +0000 (UTC) Received: from localhost (ovpn-117-244.ams2.redhat.com [10.36.117.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC46B7D94B; Thu, 4 May 2017 11:43:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3B2204E357 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3B2204E357 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 4 May 2017 15:42:16 +0400 Message-Id: <20170504114232.20318-6-marcandre.lureau@redhat.com> In-Reply-To: <20170504114232.20318-1-marcandre.lureau@redhat.com> References: <20170504114232.20318-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 04 May 2017 11:43:15 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 05/21] char: add a /chardevs container X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , stefanha@gmail.com, Jason Wang , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add a /chardevs container object to hold the list of chardevs. (Note: QTAILQ chardevs is going away in the following commits) Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/sysemu/char.h | 8 -------- chardev/char.c | 50 +++++++++++++++++++++++++++++------------= ---- gdbstub.c | 4 ++-- hw/usb/ccid-card-passthru.c | 2 +- hw/usb/redirect.c | 2 +- net/vhost-user.c | 2 +- tests/test-char.c | 8 ++++---- tests/vhost-user-test.c | 2 +- 8 files changed, 42 insertions(+), 36 deletions(-) diff --git a/include/sysemu/char.h b/include/sysemu/char.h index a30ff3fa80..98903f31e4 100644 --- a/include/sysemu/char.h +++ b/include/sysemu/char.h @@ -171,14 +171,6 @@ int qemu_chr_fe_wait_connected(CharBackend *be, Error = **errp); Chardev *qemu_chr_new_noreplay(const char *label, const char *filename); =20 /** - * @qemu_chr_delete: - * - * Destroy a character backend and remove it from the list of - * identified character backends. - */ -void qemu_chr_delete(Chardev *chr); - -/** * @qemu_chr_fe_set_echo: * * Ask the backend to override its normal echo setting. This only really diff --git a/chardev/char.c b/chardev/char.c index 674c097fbe..5456fb2e3a 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -45,6 +45,11 @@ static QTAILQ_HEAD(ChardevHead, Chardev) chardevs =3D QTAILQ_HEAD_INITIALIZER(chardevs); =20 +static Object *get_chardevs_root(void) +{ + return container_get(object_get_root(), "/chardevs"); +} + void qemu_chr_be_event(Chardev *s, int event) { CharBackend *be =3D s->be; @@ -413,6 +418,9 @@ static void char_finalize(Object *obj) { Chardev *chr =3D CHARDEV(obj); =20 + if (QTAILQ_IN_USE(chr, next)) { + QTAILQ_REMOVE(&chardevs, chr, next); + } if (chr->be) { chr->be->chr =3D NULL; } @@ -946,7 +954,7 @@ Chardev *qemu_chr_new_from_opts(QemuOpts *opts, backend->u.mux.data->chardev =3D g_strdup(bid); mux =3D qemu_chardev_add(id, TYPE_CHARDEV_MUX, backend, errp); if (mux =3D=3D NULL) { - qemu_chr_delete(chr); + object_unparent(OBJECT(chr)); chr =3D NULL; goto out; } @@ -1060,12 +1068,6 @@ void qemu_chr_fe_disconnect(CharBackend *be) } } =20 -void qemu_chr_delete(Chardev *chr) -{ - QTAILQ_REMOVE(&chardevs, chr, next); - object_unref(OBJECT(chr)); -} - ChardevInfoList *qmp_query_chardev(Error **errp) { ChardevInfoList *chr_list =3D NULL; @@ -1225,22 +1227,23 @@ void qemu_chr_set_feature(Chardev *chr, } =20 Chardev *qemu_chardev_new(const char *id, const char *typename, - ChardevBackend *backend, Error **errp) + ChardevBackend *backend, + Error **errp) { + Object *obj; Chardev *chr =3D NULL; Error *local_err =3D NULL; bool be_opened =3D true; =20 assert(g_str_has_prefix(typename, "chardev-")); =20 - chr =3D CHARDEV(object_new(typename)); + obj =3D object_new(typename); + chr =3D CHARDEV(obj); chr->label =3D g_strdup(id); =20 qemu_char_open(chr, backend, &be_opened, &local_err); if (local_err) { - error_propagate(errp, local_err); - object_unref(OBJECT(chr)); - return NULL; + goto end; } =20 if (!chr->filename) { @@ -1250,6 +1253,21 @@ Chardev *qemu_chardev_new(const char *id, const char= *typename, qemu_chr_be_event(chr, CHR_EVENT_OPENED); } =20 + if (id) { + object_property_add_child(get_chardevs_root(), id, obj, &local_err= ); + if (local_err) { + goto end; + } + object_unref(obj); + } + +end: + if (local_err) { + error_propagate(errp, local_err); + object_unref(obj); + return NULL; + } + return chr; } =20 @@ -1298,16 +1316,12 @@ void qmp_chardev_remove(const char *id, Error **err= p) "Chardev '%s' cannot be unplugged in record/replay mode", id); return; } - qemu_chr_delete(chr); + object_unparent(OBJECT(chr)); } =20 void qemu_chr_cleanup(void) { - Chardev *chr, *tmp; - - QTAILQ_FOREACH_SAFE(chr, &chardevs, next, tmp) { - qemu_chr_delete(chr); - } + object_unparent(get_chardevs_root()); } =20 static void register_types(void) diff --git a/gdbstub.c b/gdbstub.c index 991115361e..07ebfe9626 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1611,7 +1611,7 @@ void gdb_exit(CPUArchState *env, int code) =20 #ifndef CONFIG_USER_ONLY qemu_chr_fe_deinit(&s->chr); - qemu_chr_delete(chr); + object_unparent(OBJECT(chr)); #endif } =20 @@ -1912,7 +1912,7 @@ int gdbserver_start(const char *device) monitor_init(mon_chr, 0); } else { if (qemu_chr_fe_get_driver(&s->chr)) { - qemu_chr_delete(qemu_chr_fe_get_driver(&s->chr)); + object_unparent(OBJECT(qemu_chr_fe_get_driver(&s->chr))); } mon_chr =3D s->mon_chr; memset(s, 0, sizeof(GDBState)); diff --git a/hw/usb/ccid-card-passthru.c b/hw/usb/ccid-card-passthru.c index daab0d56cf..a41b0d6ec5 100644 --- a/hw/usb/ccid-card-passthru.c +++ b/hw/usb/ccid-card-passthru.c @@ -267,7 +267,7 @@ static void ccid_card_vscard_drop_connection(PassthruSt= ate *card) Chardev *chr =3D qemu_chr_fe_get_driver(&card->cs); =20 qemu_chr_fe_deinit(&card->cs); - qemu_chr_delete(chr); + object_unparent(OBJECT(chr)); card->vscard_in_pos =3D card->vscard_in_hdr =3D 0; } =20 diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 0efe62f725..b001a27f05 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -1433,7 +1433,7 @@ static void usbredir_unrealize(USBDevice *udev, Error= **errp) Chardev *chr =3D qemu_chr_fe_get_driver(&dev->cs); =20 qemu_chr_fe_deinit(&dev->cs); - qemu_chr_delete(chr); + object_unparent(OBJECT(chr)); =20 /* Note must be done after qemu_chr_close, as that causes a close even= t */ qemu_bh_delete(dev->chardev_close_bh); diff --git a/net/vhost-user.c b/net/vhost-user.c index e7e63408a1..00a0c1cbc5 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -154,7 +154,7 @@ static void vhost_user_cleanup(NetClientState *nc) Chardev *chr =3D qemu_chr_fe_get_driver(&s->chr); =20 qemu_chr_fe_deinit(&s->chr); - qemu_chr_delete(chr); + object_unparent(OBJECT(chr)); } =20 qemu_purge_queued_packets(nc); diff --git a/tests/test-char.c b/tests/test-char.c index da69f110e4..71de4b35ee 100644 --- a/tests/test-char.c +++ b/tests/test-char.c @@ -53,7 +53,7 @@ static void char_stdio_test_subprocess(void) g_assert_cmpint(ret, =3D=3D, 4); =20 qemu_chr_fe_deinit(&be); - qemu_chr_delete(chr); + object_unparent(OBJECT(chr)); } =20 static void char_stdio_test(void) @@ -103,7 +103,7 @@ static void char_ringbuf_test(void) g_free(data); =20 qemu_chr_fe_deinit(&be); - qemu_chr_delete(chr); + object_unparent(OBJECT(chr)); } =20 static void char_mux_test(void) @@ -179,7 +179,7 @@ static void char_mux_test(void) =20 qemu_chr_fe_deinit(&chr_be1); qemu_chr_fe_deinit(&chr_be2); - qemu_chr_delete(chr); + object_unparent(OBJECT(chr)); } =20 static void char_null_test(void) @@ -222,7 +222,7 @@ static void char_null_test(void) g_assert_cmpint(ret, =3D=3D, 4); =20 qemu_chr_fe_deinit(&be); - qemu_chr_delete(chr); + object_unparent(OBJECT(chr)); } =20 static void char_invalid_test(void) diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index a61896c32d..9095af267e 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -491,7 +491,7 @@ static gboolean _test_server_free(TestServer *server) Chardev *chr =3D qemu_chr_fe_get_driver(&server->chr); =20 qemu_chr_fe_deinit(&server->chr); - qemu_chr_delete(chr); + object_unparent(OBJECT(chr)); =20 for (i =3D 0; i < server->fds_num; i++) { close(server->fds[i]); --=20 2.12.0.191.gc5d8de91d From nobody Mon Apr 29 15:22:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493898577857330.7699709206581; Thu, 4 May 2017 04:49:37 -0700 (PDT) Received: from localhost ([::1]:41205 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FGK-0008WJ-D7 for importer@patchew.org; Thu, 04 May 2017 07:49:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45970) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FAJ-0003Fa-3t for qemu-devel@nongnu.org; Thu, 04 May 2017 07:43:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6FAI-0004Ql-CX for qemu-devel@nongnu.org; Thu, 04 May 2017 07:43:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40302) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6FAI-0004QP-66 for qemu-devel@nongnu.org; Thu, 04 May 2017 07:43:22 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1FB1D64D27; Thu, 4 May 2017 11:43:21 +0000 (UTC) Received: from localhost (ovpn-117-244.ams2.redhat.com [10.36.117.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id 61ACA7E2F6; Thu, 4 May 2017 11:43:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1FB1D64D27 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1FB1D64D27 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 4 May 2017 15:42:17 +0400 Message-Id: <20170504114232.20318-7-marcandre.lureau@redhat.com> In-Reply-To: <20170504114232.20318-1-marcandre.lureau@redhat.com> References: <20170504114232.20318-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 04 May 2017 11:43:21 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 06/21] vl: add todo note about root container cleanup X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stefanha@gmail.com, Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau --- vl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/vl.c b/vl.c index f46e070e0d..150e8ebf17 100644 --- a/vl.c +++ b/vl.c @@ -4727,6 +4727,7 @@ int main(int argc, char **argv, char **envp) audio_cleanup(); monitor_cleanup(); qemu_chr_cleanup(); + /* TODO: unref root container, check all devices are ok */ =20 return 0; } --=20 2.12.0.191.gc5d8de91d From nobody Mon Apr 29 15:22:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149389840481668.08528448706022; Thu, 4 May 2017 04:46:44 -0700 (PDT) Received: from localhost ([::1]:41195 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FDX-0005w2-DP for importer@patchew.org; Thu, 04 May 2017 07:46:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FAO-0003Km-M8 for qemu-devel@nongnu.org; Thu, 04 May 2017 07:43:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6FAN-0004SB-Pd for qemu-devel@nongnu.org; Thu, 04 May 2017 07:43:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39500) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6FAN-0004Rp-Gr for qemu-devel@nongnu.org; Thu, 04 May 2017 07:43:27 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6D06B8048C; Thu, 4 May 2017 11:43:26 +0000 (UTC) Received: from localhost (ovpn-117-244.ams2.redhat.com [10.36.117.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id E3D65176C6; Thu, 4 May 2017 11:43:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6D06B8048C Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6D06B8048C From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 4 May 2017 15:42:18 +0400 Message-Id: <20170504114232.20318-8-marcandre.lureau@redhat.com> In-Reply-To: <20170504114232.20318-1-marcandre.lureau@redhat.com> References: <20170504114232.20318-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 04 May 2017 11:43:26 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 07/21] char: use /chardevs container instead of chardevs list X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stefanha@gmail.com, Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Use object_resolve_path_component() and object_child_foreach() on /chardevs container instead of iterating over chardevs list. Signed-off-by: Marc-Andr=C3=A9 Lureau --- chardev/char.c | 66 ++++++++++++++++++++++++++++++++----------------------= ---- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/chardev/char.c b/chardev/char.c index 5456fb2e3a..1859680bea 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -455,21 +455,24 @@ static const TypeInfo char_type_info =3D { * mux will receive CHR_EVENT_OPENED notifications for the BE * immediately. */ -static void muxes_realize_done(Notifier *notifier, void *unused) +static int open_muxes(Object *child, void *opaque) { - Chardev *chr; + if (CHARDEV_IS_MUX(child)) { + /* send OPENED to all already-attached FEs */ + mux_chr_send_all_event(CHARDEV(child), CHR_EVENT_OPENED); + /* mark mux as OPENED so any new FEs will immediately receive + * OPENED event + */ + qemu_chr_be_event(CHARDEV(child), CHR_EVENT_OPENED); + } =20 + return 0; +} + +static void muxes_realize_done(Notifier *notifier, void *unused) +{ muxes_realized =3D true; - QTAILQ_FOREACH(chr, &chardevs, next) { - if (CHARDEV_IS_MUX(chr)) { - /* send OPENED to all already-attached FEs */ - mux_chr_send_all_event(CHARDEV(chr), CHR_EVENT_OPENED); - /* mark mux as OPENED so any new FEs will immediately receive - * OPENED event - */ - qemu_chr_be_event(chr, CHR_EVENT_OPENED); - } - } + object_child_foreach(get_chardevs_root(), open_muxes, NULL); } =20 static Notifier muxes_realize_notify =3D { @@ -1068,21 +1071,29 @@ void qemu_chr_fe_disconnect(CharBackend *be) } } =20 +static int qmp_query_chardev_foreach(Object *obj, void *data) +{ + Chardev *chr =3D CHARDEV(obj); + ChardevInfoList **list =3D data; + ChardevInfoList *info =3D g_malloc0(sizeof(*info)); + + info->value =3D g_malloc0(sizeof(*info->value)); + info->value->label =3D g_strdup(chr->label); + info->value->filename =3D g_strdup(chr->filename); + info->value->frontend_open =3D chr->be && chr->be->fe_open; + + info->next =3D *list; + *list =3D info; + + return 0; +} + ChardevInfoList *qmp_query_chardev(Error **errp) { ChardevInfoList *chr_list =3D NULL; - Chardev *chr; - - QTAILQ_FOREACH(chr, &chardevs, next) { - ChardevInfoList *info =3D g_malloc0(sizeof(*info)); - info->value =3D g_malloc0(sizeof(*info->value)); - info->value->label =3D g_strdup(chr->label); - info->value->filename =3D g_strdup(chr->filename); - info->value->frontend_open =3D chr->be && chr->be->fe_open; =20 - info->next =3D chr_list; - chr_list =3D info; - } + object_child_foreach(get_chardevs_root(), + qmp_query_chardev_foreach, &chr_list); =20 return chr_list; } @@ -1110,14 +1121,9 @@ ChardevBackendInfoList *qmp_query_chardev_backends(E= rror **errp) =20 Chardev *qemu_chr_find(const char *name) { - Chardev *chr; + Object *obj =3D object_resolve_path_component(get_chardevs_root(), nam= e); =20 - QTAILQ_FOREACH(chr, &chardevs, next) { - if (strcmp(chr->label, name) !=3D 0) - continue; - return chr; - } - return NULL; + return obj ? CHARDEV(obj) : NULL; } =20 QemuOptsList qemu_chardev_opts =3D { --=20 2.12.0.191.gc5d8de91d From nobody Mon Apr 29 15:22:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493898397808615.4997938487335; Thu, 4 May 2017 04:46:37 -0700 (PDT) Received: from localhost ([::1]:41194 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FDP-0005o3-TZ for importer@patchew.org; Thu, 04 May 2017 07:46:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46045) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FAY-0003TU-9v for qemu-devel@nongnu.org; Thu, 04 May 2017 07:43:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6FAT-0004Tn-Ao for qemu-devel@nongnu.org; Thu, 04 May 2017 07:43:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40468) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6FAT-0004TU-2o for qemu-devel@nongnu.org; Thu, 04 May 2017 07:43:33 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0563D635D2; Thu, 4 May 2017 11:43:32 +0000 (UTC) Received: from localhost (ovpn-117-244.ams2.redhat.com [10.36.117.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3FA425DD67; Thu, 4 May 2017 11:43:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0563D635D2 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0563D635D2 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 4 May 2017 15:42:19 +0400 Message-Id: <20170504114232.20318-9-marcandre.lureau@redhat.com> In-Reply-To: <20170504114232.20318-1-marcandre.lureau@redhat.com> References: <20170504114232.20318-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 04 May 2017 11:43:32 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 08/21] char: remove qemu_chardev_add X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stefanha@gmail.com, Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" qemu_chardev_new() now uses object_new_with_props() with /chardevs parent container. It will fail to insert the object if the same "id" already exists. "chardevs" list usage has been removed in previous commits. Signed-off-by: Marc-Andr=C3=A9 Lureau --- chardev/char.c | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/chardev/char.c b/chardev/char.c index 1859680bea..276d27f403 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -805,26 +805,6 @@ static const ChardevClass *char_get_class(const char *= driver, Error **errp) return cc; } =20 -static Chardev *qemu_chardev_add(const char *id, const char *typename, - ChardevBackend *backend, Error **errp) -{ - Chardev *chr; - - chr =3D qemu_chr_find(id); - if (chr) { - error_setg(errp, "Chardev '%s' already exists", id); - return NULL; - } - - chr =3D qemu_chardev_new(id, typename, backend, errp); - if (!chr) { - return NULL; - } - - QTAILQ_INSERT_TAIL(&chardevs, chr, next); - return chr; -} - static const struct ChardevAlias { const char *typename; const char *alias; @@ -941,9 +921,10 @@ Chardev *qemu_chr_new_from_opts(QemuOpts *opts, backend->u.null.data =3D ccom; /* Any ChardevCommon member would w= ork */ } =20 - chr =3D qemu_chardev_add(bid ? bid : id, + chr =3D qemu_chardev_new(bid ? bid : id, object_class_get_name(OBJECT_CLASS(cc)), backend, errp); + if (chr =3D=3D NULL) { goto out; } @@ -955,7 +936,7 @@ Chardev *qemu_chr_new_from_opts(QemuOpts *opts, backend->type =3D CHARDEV_BACKEND_KIND_MUX; backend->u.mux.data =3D g_new0(ChardevMux, 1); backend->u.mux.data->chardev =3D g_strdup(bid); - mux =3D qemu_chardev_add(id, TYPE_CHARDEV_MUX, backend, errp); + mux =3D qemu_chardev_new(id, TYPE_CHARDEV_MUX, backend, errp); if (mux =3D=3D NULL) { object_unparent(OBJECT(chr)); chr =3D NULL; @@ -1289,7 +1270,7 @@ ChardevReturn *qmp_chardev_add(const char *id, Charde= vBackend *backend, return NULL; } =20 - chr =3D qemu_chardev_add(id, object_class_get_name(OBJECT_CLASS(cc)), + chr =3D qemu_chardev_new(id, object_class_get_name(OBJECT_CLASS(cc)), backend, errp); if (!chr) { return NULL; --=20 2.12.0.191.gc5d8de91d From nobody Mon Apr 29 15:22:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493898601627772.5293373860812; Thu, 4 May 2017 04:50:01 -0700 (PDT) Received: from localhost ([::1]:41206 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FGh-0000TV-CE for importer@patchew.org; Thu, 04 May 2017 07:49:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46068) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FAa-0003Vb-B3 for qemu-devel@nongnu.org; Thu, 04 May 2017 07:43:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6FAZ-0004Vq-Ku for qemu-devel@nongnu.org; Thu, 04 May 2017 07:43:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46390) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6FAZ-0004VV-EI for qemu-devel@nongnu.org; Thu, 04 May 2017 07:43:39 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 64D4DC04B941; Thu, 4 May 2017 11:43:38 +0000 (UTC) Received: from localhost (ovpn-117-244.ams2.redhat.com [10.36.117.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id 158E67D511; Thu, 4 May 2017 11:43:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 64D4DC04B941 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 64D4DC04B941 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 4 May 2017 15:42:20 +0400 Message-Id: <20170504114232.20318-10-marcandre.lureau@redhat.com> In-Reply-To: <20170504114232.20318-1-marcandre.lureau@redhat.com> References: <20170504114232.20318-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 04 May 2017 11:43:38 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 09/21] char: remove chardevs list X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stefanha@gmail.com, Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The list is now empty, the chardev cleanup is taken care of by the unref of the root container. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/sysemu/char.h | 1 - chardev/char.c | 6 ------ 2 files changed, 7 deletions(-) diff --git a/include/sysemu/char.h b/include/sysemu/char.h index 98903f31e4..729d186d01 100644 --- a/include/sysemu/char.h +++ b/include/sysemu/char.h @@ -95,7 +95,6 @@ struct Chardev { int be_open; guint fd_in_tag; DECLARE_BITMAP(features, QEMU_CHAR_FEATURE_LAST); - QTAILQ_ENTRY(Chardev) next; }; =20 /** diff --git a/chardev/char.c b/chardev/char.c index 276d27f403..aee8b4555d 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -42,9 +42,6 @@ /***********************************************************/ /* character device */ =20 -static QTAILQ_HEAD(ChardevHead, Chardev) chardevs =3D - QTAILQ_HEAD_INITIALIZER(chardevs); - static Object *get_chardevs_root(void) { return container_get(object_get_root(), "/chardevs"); @@ -418,9 +415,6 @@ static void char_finalize(Object *obj) { Chardev *chr =3D CHARDEV(obj); =20 - if (QTAILQ_IN_USE(chr, next)) { - QTAILQ_REMOVE(&chardevs, chr, next); - } if (chr->be) { chr->be->chr =3D NULL; } --=20 2.12.0.191.gc5d8de91d From nobody Mon Apr 29 15:22:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 14938987247355.431994669278765; Thu, 4 May 2017 04:52:04 -0700 (PDT) Received: from localhost ([::1]:41220 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FIf-0002XU-DX for importer@patchew.org; Thu, 04 May 2017 07:52:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46119) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FAh-0003bf-5q for qemu-devel@nongnu.org; Thu, 04 May 2017 07:43:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6FAd-0004XI-EZ for qemu-devel@nongnu.org; Thu, 04 May 2017 07:43:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40648) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6FAd-0004Wq-8h for qemu-devel@nongnu.org; Thu, 04 May 2017 07:43:43 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 334C99D4F0; Thu, 4 May 2017 11:43:42 +0000 (UTC) Received: from localhost (ovpn-117-244.ams2.redhat.com [10.36.117.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4AA627D511; Thu, 4 May 2017 11:43:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 334C99D4F0 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 334C99D4F0 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 4 May 2017 15:42:21 +0400 Message-Id: <20170504114232.20318-11-marcandre.lureau@redhat.com> In-Reply-To: <20170504114232.20318-1-marcandre.lureau@redhat.com> References: <20170504114232.20318-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 04 May 2017 11:43:42 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 10/21] char: useless NULL check X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stefanha@gmail.com, Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" g_strdup(NULL) returns NULL already. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- chardev/char.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chardev/char.c b/chardev/char.c index aee8b4555d..33dbab6981 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -764,7 +764,7 @@ void qemu_chr_parse_common(QemuOpts *opts, ChardevCommo= n *backend) const char *logfile =3D qemu_opt_get(opts, "logfile"); =20 backend->has_logfile =3D logfile !=3D NULL; - backend->logfile =3D logfile ? g_strdup(logfile) : NULL; + backend->logfile =3D g_strdup(logfile); =20 backend->has_logappend =3D true; backend->logappend =3D qemu_opt_get_bool(opts, "logappend", false); --=20 2.12.0.191.gc5d8de91d From nobody Mon Apr 29 15:22:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493898744831855.2869950813395; Thu, 4 May 2017 04:52:24 -0700 (PDT) Received: from localhost ([::1]:41221 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FJ1-0002sS-GU for importer@patchew.org; Thu, 04 May 2017 07:52:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46162) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FAn-0003gt-Kv for qemu-devel@nongnu.org; Thu, 04 May 2017 07:43:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6FAm-0004bS-NP for qemu-devel@nongnu.org; Thu, 04 May 2017 07:43:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40802) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6FAm-0004b2-H4 for qemu-devel@nongnu.org; Thu, 04 May 2017 07:43:52 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7003261D38; Thu, 4 May 2017 11:43:51 +0000 (UTC) Received: from localhost (ovpn-117-244.ams2.redhat.com [10.36.117.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id C17AF1748C; Thu, 4 May 2017 11:43:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7003261D38 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7003261D38 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 4 May 2017 15:42:22 +0400 Message-Id: <20170504114232.20318-12-marcandre.lureau@redhat.com> In-Reply-To: <20170504114232.20318-1-marcandre.lureau@redhat.com> References: <20170504114232.20318-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 04 May 2017 11:43:51 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 11/21] char-socket: introduce update_disconnected_filename() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stefanha@gmail.com, Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This helper will be used in yet another place in the following patch. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- chardev/char-socket.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 2789eb1f40..511a82960d 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -366,6 +366,15 @@ static char *SocketAddress_to_str(const char *prefix, = SocketAddress *addr, } } =20 +static void update_disconnected_filename(SocketChardev *s) +{ + Chardev *chr =3D CHARDEV(s); + + g_free(chr->filename); + chr->filename =3D SocketAddress_to_str("disconnected:", s->addr, + s->is_listen, s->is_telnet); +} + static void tcp_chr_disconnect(Chardev *chr) { SocketChardev *s =3D SOCKET_CHARDEV(chr); @@ -380,8 +389,7 @@ static void tcp_chr_disconnect(Chardev *chr) s->listen_tag =3D qio_channel_add_watch( QIO_CHANNEL(s->listen_ioc), G_IO_IN, tcp_chr_accept, chr, NULL= ); } - chr->filename =3D SocketAddress_to_str("disconnected:", s->addr, - s->is_listen, s->is_telnet); + update_disconnected_filename(s); qemu_chr_be_event(chr, CHR_EVENT_CLOSED); if (s->reconnect_time) { qemu_chr_socket_restart_timer(chr); @@ -875,8 +883,7 @@ static void qmp_chardev_open_socket(Chardev *chr, /* be isn't opened until we get a connection */ *be_opened =3D false; =20 - chr->filename =3D SocketAddress_to_str("disconnected:", - addr, is_listen, is_telnet); + update_disconnected_filename(s); =20 if (is_listen) { if (is_telnet) { --=20 2.12.0.191.gc5d8de91d From nobody Mon Apr 29 15:22:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493898563881171.62552923467342; Thu, 4 May 2017 04:49:23 -0700 (PDT) Received: from localhost ([::1]:41204 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FG6-0008Lv-EC for importer@patchew.org; Thu, 04 May 2017 07:49:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46234) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FAy-0003r1-9M for qemu-devel@nongnu.org; Thu, 04 May 2017 07:44:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6FAt-0004dc-6o for qemu-devel@nongnu.org; Thu, 04 May 2017 07:44:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47405) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6FAt-0004dR-0q for qemu-devel@nongnu.org; Thu, 04 May 2017 07:43:59 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E7D02C059744; Thu, 4 May 2017 11:43:57 +0000 (UTC) Received: from localhost (ovpn-117-244.ams2.redhat.com [10.36.117.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id 558DC777EB; Thu, 4 May 2017 11:43:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E7D02C059744 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E7D02C059744 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 4 May 2017 15:42:23 +0400 Message-Id: <20170504114232.20318-13-marcandre.lureau@redhat.com> In-Reply-To: <20170504114232.20318-1-marcandre.lureau@redhat.com> References: <20170504114232.20318-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 04 May 2017 11:43:58 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 12/21] char-socket: update local address after listen X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stefanha@gmail.com, Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This is mainly useful to know the actual bound port when using port 0. For example, when starting qemu with socket on port 0, before: QEMU waiting for connection on: disconnected:tcp:localhost:0,server After: QEMU waiting for connection on: disconnected:tcp:localhost:32454,server Signed-off-by: Marc-Andr=C3=A9 Lureau --- chardev/char-socket.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 511a82960d..f24961ad16 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -911,6 +911,11 @@ static void qmp_chardev_open_socket(Chardev *chr, if (qio_channel_socket_listen_sync(sioc, s->addr, errp) < 0) { goto error; } + + qapi_free_SocketAddress(s->addr); + s->addr =3D socket_local_address(sioc->fd, errp); + update_disconnected_filename(s); + s->listen_ioc =3D sioc; if (is_waitconnect && qemu_chr_wait_connected(chr, errp) < 0) { --=20 2.12.0.191.gc5d8de91d From nobody Mon Apr 29 15:22:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493898862402178.038436429385; Thu, 4 May 2017 04:54:22 -0700 (PDT) Received: from localhost ([::1]:41229 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FKu-0005EV-H0 for importer@patchew.org; Thu, 04 May 2017 07:54:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46261) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FB3-0003wH-Oa for qemu-devel@nongnu.org; Thu, 04 May 2017 07:44:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6FB2-0004gk-Tu for qemu-devel@nongnu.org; Thu, 04 May 2017 07:44:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41160) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6FB2-0004gP-Mu for qemu-devel@nongnu.org; Thu, 04 May 2017 07:44:08 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9C7D5624CC; Thu, 4 May 2017 11:44:07 +0000 (UTC) Received: from localhost (ovpn-117-244.ams2.redhat.com [10.36.117.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0779277E28; Thu, 4 May 2017 11:44:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9C7D5624CC Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9C7D5624CC From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 4 May 2017 15:42:24 +0400 Message-Id: <20170504114232.20318-14-marcandre.lureau@redhat.com> In-Reply-To: <20170504114232.20318-1-marcandre.lureau@redhat.com> References: <20170504114232.20318-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 04 May 2017 11:44:07 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 13/21] char-socket: add 'addr' property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stefanha@gmail.com, Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add a property to lookup the connection details. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- chardev/char-socket.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index f24961ad16..5a5840edb1 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -1009,6 +1009,15 @@ static void qemu_chr_parse_socket(QemuOpts *opts, Ch= ardevBackend *backend, sock->addr =3D addr; } =20 +static void +char_socket_get_addr(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + SocketChardev *s =3D SOCKET_CHARDEV(obj); + + visit_type_SocketAddress(v, name, &s->addr, errp); +} + static void char_socket_class_init(ObjectClass *oc, void *data) { ChardevClass *cc =3D CHARDEV_CLASS(oc); @@ -1024,6 +1033,10 @@ static void char_socket_class_init(ObjectClass *oc, = void *data) cc->chr_add_client =3D tcp_chr_add_client; cc->chr_add_watch =3D tcp_chr_add_watch; cc->chr_update_read_handler =3D tcp_chr_update_read_handler; + + object_class_property_add(oc, "addr", "SocketAddress", + char_socket_get_addr, NULL, + NULL, NULL, &error_abort); } =20 static const TypeInfo char_socket_type_info =3D { --=20 2.12.0.191.gc5d8de91d From nobody Mon Apr 29 15:22:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493898556255758.5895305318843; Thu, 4 May 2017 04:49:16 -0700 (PDT) Received: from localhost ([::1]:41203 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FFy-0008CU-E0 for importer@patchew.org; Thu, 04 May 2017 07:49:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46361) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FBE-00046g-2J for qemu-devel@nongnu.org; Thu, 04 May 2017 07:44:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6FBD-0004ln-26 for qemu-devel@nongnu.org; Thu, 04 May 2017 07:44:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47136) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6FBC-0004lX-Su for qemu-devel@nongnu.org; Thu, 04 May 2017 07:44:19 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CCFE8C04B943; Thu, 4 May 2017 11:44:17 +0000 (UTC) Received: from localhost (ovpn-117-244.ams2.redhat.com [10.36.117.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9BAA61715E; Thu, 4 May 2017 11:44:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CCFE8C04B943 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com CCFE8C04B943 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 4 May 2017 15:42:25 +0400 Message-Id: <20170504114232.20318-15-marcandre.lureau@redhat.com> In-Reply-To: <20170504114232.20318-1-marcandre.lureau@redhat.com> References: <20170504114232.20318-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 04 May 2017 11:44:17 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 14/21] char-socket: add 'connected' property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stefanha@gmail.com, Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- chardev/char-socket.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 5a5840edb1..0118252002 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -1018,6 +1018,14 @@ char_socket_get_addr(Object *obj, Visitor *v, const = char *name, visit_type_SocketAddress(v, name, &s->addr, errp); } =20 +static bool +char_socket_get_connected(Object *obj, Error **errp) +{ + SocketChardev *s =3D SOCKET_CHARDEV(obj); + + return s->connected; +} + static void char_socket_class_init(ObjectClass *oc, void *data) { ChardevClass *cc =3D CHARDEV_CLASS(oc); @@ -1037,6 +1045,9 @@ static void char_socket_class_init(ObjectClass *oc, v= oid *data) object_class_property_add(oc, "addr", "SocketAddress", char_socket_get_addr, NULL, NULL, NULL, &error_abort); + + object_class_property_add_bool(oc, "connected", char_socket_get_connec= ted, + NULL, &error_abort); } =20 static const TypeInfo char_socket_type_info =3D { --=20 2.12.0.191.gc5d8de91d From nobody Mon Apr 29 15:22:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493898704586991.4897163665671; Thu, 4 May 2017 04:51:44 -0700 (PDT) Received: from localhost ([::1]:41217 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FIN-0002GX-24 for importer@patchew.org; Thu, 04 May 2017 07:51:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46482) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FBM-0004E2-49 for qemu-devel@nongnu.org; Thu, 04 May 2017 07:44:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6FBL-0004q3-7L for qemu-devel@nongnu.org; Thu, 04 May 2017 07:44:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43582) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6FBL-0004pc-14 for qemu-devel@nongnu.org; Thu, 04 May 2017 07:44:27 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E1C8E83F43; Thu, 4 May 2017 11:44:25 +0000 (UTC) Received: from localhost (ovpn-117-244.ams2.redhat.com [10.36.117.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id 473387D94E; Thu, 4 May 2017 11:44:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E1C8E83F43 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E1C8E83F43 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 4 May 2017 15:42:26 +0400 Message-Id: <20170504114232.20318-16-marcandre.lureau@redhat.com> In-Reply-To: <20170504114232.20318-1-marcandre.lureau@redhat.com> References: <20170504114232.20318-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 04 May 2017 11:44:26 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 15/21] char-udp: flush as much buffer as possible X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stefanha@gmail.com, Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Instead of flushing the buffer byte by byte, call qemu_chr_be_write() with as much byte possible accepted by the front-end. Factor out buffer flushing in a common function udp_chr_flush_buffer(). Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- chardev/char-udp.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/chardev/char-udp.c b/chardev/char-udp.c index 804bd22efa..1958c36de4 100644 --- a/chardev/char-udp.c +++ b/chardev/char-udp.c @@ -51,6 +51,18 @@ static int udp_chr_write(Chardev *chr, const uint8_t *bu= f, int len) s->ioc, (const char *)buf, len, NULL); } =20 +static void udp_chr_flush_buffer(UdpChardev *s) +{ + Chardev *chr =3D CHARDEV(s); + + while (s->max_size > 0 && s->bufptr < s->bufcnt) { + int n =3D MIN(s->max_size, s->bufcnt - s->bufptr); + qemu_chr_be_write(chr, &s->buf[s->bufptr], n); + s->bufptr +=3D n; + s->max_size =3D qemu_chr_be_can_write(chr); + } +} + static int udp_chr_read_poll(void *opaque) { Chardev *chr =3D CHARDEV(opaque); @@ -61,11 +73,8 @@ static int udp_chr_read_poll(void *opaque) /* If there were any stray characters in the queue process them * first */ - while (s->max_size > 0 && s->bufptr < s->bufcnt) { - qemu_chr_be_write(chr, &s->buf[s->bufptr], 1); - s->bufptr++; - s->max_size =3D qemu_chr_be_can_write(chr); - } + udp_chr_flush_buffer(s); + return s->max_size; } =20 @@ -85,13 +94,8 @@ static gboolean udp_chr_read(QIOChannel *chan, GIOCondit= ion cond, void *opaque) return FALSE; } s->bufcnt =3D ret; - s->bufptr =3D 0; - while (s->max_size > 0 && s->bufptr < s->bufcnt) { - qemu_chr_be_write(chr, &s->buf[s->bufptr], 1); - s->bufptr++; - s->max_size =3D qemu_chr_be_can_write(chr); - } + udp_chr_flush_buffer(s); =20 return TRUE; } --=20 2.12.0.191.gc5d8de91d From nobody Mon Apr 29 15:22:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493898845776285.12762026454845; Thu, 4 May 2017 04:54:05 -0700 (PDT) Received: from localhost ([::1]:41228 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FKe-00050E-6q for importer@patchew.org; Thu, 04 May 2017 07:54:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46593) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FBW-0004Nv-VZ for qemu-devel@nongnu.org; Thu, 04 May 2017 07:44:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6FBS-0004sK-1i for qemu-devel@nongnu.org; Thu, 04 May 2017 07:44:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39588) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6FBR-0004rn-SJ for qemu-devel@nongnu.org; Thu, 04 May 2017 07:44:33 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C27BB3E9; Thu, 4 May 2017 11:44:32 +0000 (UTC) Received: from localhost (ovpn-117-244.ams2.redhat.com [10.36.117.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id B7E517E2F6; Thu, 4 May 2017 11:44:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C27BB3E9 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C27BB3E9 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 4 May 2017 15:42:27 +0400 Message-Id: <20170504114232.20318-17-marcandre.lureau@redhat.com> In-Reply-To: <20170504114232.20318-1-marcandre.lureau@redhat.com> References: <20170504114232.20318-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 04 May 2017 11:44:32 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 16/21] tests: add alias check in /char/ringbuf X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau --- tests/test-char.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test-char.c b/tests/test-char.c index 71de4b35ee..2811644bcd 100644 --- a/tests/test-char.c +++ b/tests/test-char.c @@ -104,6 +104,16 @@ static void char_ringbuf_test(void) =20 qemu_chr_fe_deinit(&be); object_unparent(OBJECT(chr)); + + /* check alias */ + opts =3D qemu_opts_create(qemu_find_opts("chardev"), "memory-label", + 1, &error_abort); + qemu_opt_set(opts, "backend", "memory", &error_abort); + qemu_opt_set(opts, "size", "2", &error_abort); + chr =3D qemu_chr_new_from_opts(opts, NULL); + g_assert_nonnull(chr); + object_unparent(OBJECT(chr)); + qemu_opts_del(opts); } =20 static void char_mux_test(void) --=20 2.12.0.191.gc5d8de91d From nobody Mon Apr 29 15:22:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493898943433156.61935679416263; Thu, 4 May 2017 04:55:43 -0700 (PDT) Received: from localhost ([::1]:41242 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FME-0006TY-62 for importer@patchew.org; Thu, 04 May 2017 07:55:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46617) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FBZ-0004Qf-RM for qemu-devel@nongnu.org; Thu, 04 May 2017 07:44:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6FBY-0004uX-Sg for qemu-devel@nongnu.org; Thu, 04 May 2017 07:44:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47530) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6FBY-0004uF-JR for qemu-devel@nongnu.org; Thu, 04 May 2017 07:44:40 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 890BEC04BD37; Thu, 4 May 2017 11:44:39 +0000 (UTC) Received: from localhost (ovpn-117-244.ams2.redhat.com [10.36.117.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6805A7E2F6; Thu, 4 May 2017 11:44:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 890BEC04BD37 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 890BEC04BD37 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 4 May 2017 15:42:28 +0400 Message-Id: <20170504114232.20318-18-marcandre.lureau@redhat.com> In-Reply-To: <20170504114232.20318-1-marcandre.lureau@redhat.com> References: <20170504114232.20318-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 04 May 2017 11:44:39 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 17/21] tests: add /char/pipe test X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau --- tests/test-char.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 90 insertions(+) diff --git a/tests/test-char.c b/tests/test-char.c index 2811644bcd..2b155ffcb7 100644 --- a/tests/test-char.c +++ b/tests/test-char.c @@ -1,4 +1,5 @@ #include "qemu/osdep.h" +#include =20 #include "qemu-common.h" #include "qemu/config-file.h" @@ -7,12 +8,28 @@ #include "qapi/error.h" #include "qmp-commands.h" =20 +static bool quit; + typedef struct FeHandler { int read_count; int last_event; char read_buf[128]; } FeHandler; =20 +#ifndef _WIN32 +static void main_loop(void) +{ + bool nonblocking; + int last_io =3D 0; + + quit =3D false; + do { + nonblocking =3D last_io > 0; + last_io =3D main_loop_wait(nonblocking); + } while (!quit); +} +#endif + static int fe_can_read(void *opaque) { FeHandler *h =3D opaque; @@ -28,6 +45,7 @@ static void fe_read(void *opaque, const uint8_t *buf, int= size) =20 memcpy(h->read_buf + h->read_count, buf, size); h->read_count +=3D size; + quit =3D true; } =20 static void fe_event(void *opaque, int event) @@ -35,6 +53,7 @@ static void fe_event(void *opaque, int event) FeHandler *h =3D opaque; =20 h->last_event =3D event; + quit =3D true; } =20 #ifdef CONFIG_HAS_GLIB_SUBPROCESS_TESTS @@ -192,6 +211,72 @@ static void char_mux_test(void) object_unparent(OBJECT(chr)); } =20 +#ifndef _WIN32 +static void char_pipe_test(void) +{ + gchar *tmp_path =3D g_dir_make_tmp("qemu-test-char.XXXXXX", NULL); + gchar *tmp, *in, *out, *pipe =3D g_build_filename(tmp_path, "pipe", NU= LL); + Chardev *chr; + CharBackend be; + int ret, fd; + char buf[10]; + FeHandler fe =3D { 0, }; + + in =3D g_strdup_printf("%s.in", pipe); + if (mkfifo(in, 0600) < 0) { + abort(); + } + out =3D g_strdup_printf("%s.out", pipe); + if (mkfifo(out, 0600) < 0) { + abort(); + } + + tmp =3D g_strdup_printf("pipe:%s", pipe); + chr =3D qemu_chr_new("pipe", tmp); + g_assert_nonnull(chr); + g_free(tmp); + + qemu_chr_fe_init(&be, chr, &error_abort); + + ret =3D qemu_chr_fe_write(&be, (void *)"pipe-out", 9); + g_assert_cmpint(ret, =3D=3D, 9); + + fd =3D open(out, O_RDWR); + ret =3D read(fd, buf, sizeof(buf)); + g_assert_cmpint(ret, =3D=3D, 9); + g_assert_cmpstr(buf, =3D=3D, "pipe-out"); + close(fd); + + fd =3D open(in, O_WRONLY); + ret =3D write(fd, "pipe-in", 8); + g_assert_cmpint(ret, =3D=3D, 8); + close(fd); + + qemu_chr_fe_set_handlers(&be, + fe_can_read, + fe_read, + fe_event, + &fe, + NULL, true); + + main_loop(); + + g_assert_cmpint(fe.read_count, =3D=3D, 8); + g_assert_cmpstr(fe.read_buf, =3D=3D, "pipe-in"); + + qemu_chr_fe_deinit(&be); + object_unparent(OBJECT(chr)); + + g_assert(g_unlink(in) =3D=3D 0); + g_assert(g_unlink(out) =3D=3D 0); + g_assert(g_rmdir(tmp_path) =3D=3D 0); + g_free(in); + g_free(out); + g_free(tmp_path); + g_free(pipe); +} +#endif + static void char_null_test(void) { Error *err =3D NULL; @@ -245,6 +330,8 @@ static void char_invalid_test(void) =20 int main(int argc, char **argv) { + qemu_init_main_loop(&error_abort); + g_test_init(&argc, &argv, NULL); =20 module_call_init(MODULE_INIT_QOM); @@ -258,6 +345,9 @@ int main(int argc, char **argv) g_test_add_func("/char/stdio/subprocess", char_stdio_test_subprocess); g_test_add_func("/char/stdio", char_stdio_test); #endif +#ifndef _WIN32 + g_test_add_func("/char/pipe", char_pipe_test); +#endif =20 return g_test_run(); } --=20 2.12.0.191.gc5d8de91d From nobody Mon Apr 29 15:22:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493899005531282.8289005608973; Thu, 4 May 2017 04:56:45 -0700 (PDT) Received: from localhost ([::1]:41245 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FND-0007Mq-2m for importer@patchew.org; Thu, 04 May 2017 07:56:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46663) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FBj-0004Zr-Hf for qemu-devel@nongnu.org; Thu, 04 May 2017 07:44:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6FBf-0004vi-CC for qemu-devel@nongnu.org; Thu, 04 May 2017 07:44:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33068) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6FBf-0004vT-3B for qemu-devel@nongnu.org; Thu, 04 May 2017 07:44:47 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0BA0E7AE9E; Thu, 4 May 2017 11:44:46 +0000 (UTC) Received: from localhost (ovpn-117-244.ams2.redhat.com [10.36.117.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id C958717990; Thu, 4 May 2017 11:44:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0BA0E7AE9E Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0BA0E7AE9E From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 4 May 2017 15:42:29 +0400 Message-Id: <20170504114232.20318-19-marcandre.lureau@redhat.com> In-Reply-To: <20170504114232.20318-1-marcandre.lureau@redhat.com> References: <20170504114232.20318-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 04 May 2017 11:44:46 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 18/21] tests: add /char/file test X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau --- tests/test-char.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 71 insertions(+) diff --git a/tests/test-char.c b/tests/test-char.c index 2b155ffcb7..87a4e2986d 100644 --- a/tests/test-char.c +++ b/tests/test-char.c @@ -277,6 +277,76 @@ static void char_pipe_test(void) } #endif =20 +static void char_file_test(void) +{ + char *tmp_path =3D g_dir_make_tmp("qemu-test-char.XXXXXX", NULL); + char *out =3D g_build_filename(tmp_path, "out", NULL); + char *contents =3D NULL; + ChardevFile file =3D { .out =3D out }; + ChardevBackend backend =3D { .type =3D CHARDEV_BACKEND_KIND_FILE, + .u.file.data =3D &file }; + Chardev *chr; + gsize length; + int ret; + + chr =3D qemu_chardev_new(NULL, TYPE_CHARDEV_FILE, &backend, + &error_abort); + ret =3D qemu_chr_write_all(chr, (uint8_t *)"hello!", 6); + g_assert_cmpint(ret, =3D=3D, 6); + object_unref(OBJECT(chr)); + + ret =3D g_file_get_contents(out, &contents, &length, NULL); + g_assert(ret =3D=3D TRUE); + g_assert_cmpint(length, =3D=3D, 6); + g_assert(strncmp(contents, "hello!", 6) =3D=3D 0); + g_free(contents); + +#ifndef _WIN32 + { + CharBackend be; + FeHandler fe =3D { 0, }; + char *fifo =3D g_build_filename(tmp_path, "fifo", NULL); + int fd; + + if (mkfifo(fifo, 0600) < 0) { + abort(); + } + + fd =3D open(fifo, O_RDWR); + ret =3D write(fd, "fifo-in", 8); + g_assert_cmpint(ret, =3D=3D, 8); + + file.in =3D fifo; + file.has_in =3D true; + chr =3D qemu_chardev_new(NULL, TYPE_CHARDEV_FILE, &backend, + &error_abort); + + qemu_chr_fe_init(&be, chr, &error_abort); + qemu_chr_fe_set_handlers(&be, + fe_can_read, + fe_read, + fe_event, + &fe, NULL, true); + + main_loop(); + + close(fd); + + g_assert_cmpint(fe.read_count, =3D=3D, 8); + g_assert_cmpstr(fe.read_buf, =3D=3D, "fifo-in"); + qemu_chr_fe_deinit(&be); + object_unref(OBJECT(chr)); + g_unlink(fifo); + g_free(fifo); + } +#endif + + g_unlink(out); + g_rmdir(tmp_path); + g_free(tmp_path); + g_free(out); +} + static void char_null_test(void) { Error *err =3D NULL; @@ -348,6 +418,7 @@ int main(int argc, char **argv) #ifndef _WIN32 g_test_add_func("/char/pipe", char_pipe_test); #endif + g_test_add_func("/char/file", char_file_test); =20 return g_test_run(); } --=20 2.12.0.191.gc5d8de91d From nobody Mon Apr 29 15:22:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493898986241928.7508075578422; Thu, 4 May 2017 04:56:26 -0700 (PDT) Received: from localhost ([::1]:41244 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FMu-00076D-RN for importer@patchew.org; Thu, 04 May 2017 07:56:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46677) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FBm-0004cF-3i for qemu-devel@nongnu.org; Thu, 04 May 2017 07:44:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6FBl-0004xs-67 for qemu-devel@nongnu.org; Thu, 04 May 2017 07:44:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33220) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6FBk-0004xc-Te for qemu-devel@nongnu.org; Thu, 04 May 2017 07:44:53 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CD5B37AE93; Thu, 4 May 2017 11:44:51 +0000 (UTC) Received: from localhost (ovpn-117-244.ams2.redhat.com [10.36.117.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id E15F577552; Thu, 4 May 2017 11:44:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CD5B37AE93 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com CD5B37AE93 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 4 May 2017 15:42:30 +0400 Message-Id: <20170504114232.20318-20-marcandre.lureau@redhat.com> In-Reply-To: <20170504114232.20318-1-marcandre.lureau@redhat.com> References: <20170504114232.20318-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 04 May 2017 11:44:51 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 19/21] tests: add /char/socket test X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau --- tests/test-char.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 112 insertions(+), 2 deletions(-) diff --git a/tests/test-char.c b/tests/test-char.c index 87a4e2986d..9971498391 100644 --- a/tests/test-char.c +++ b/tests/test-char.c @@ -3,9 +3,11 @@ =20 #include "qemu-common.h" #include "qemu/config-file.h" +#include "qemu/sockets.h" #include "sysemu/char.h" #include "sysemu/sysemu.h" #include "qapi/error.h" +#include "qom/qom-qobject.h" #include "qmp-commands.h" =20 static bool quit; @@ -16,7 +18,6 @@ typedef struct FeHandler { char read_buf[128]; } FeHandler; =20 -#ifndef _WIN32 static void main_loop(void) { bool nonblocking; @@ -28,7 +29,6 @@ static void main_loop(void) last_io =3D main_loop_wait(nonblocking); } while (!quit); } -#endif =20 static int fe_can_read(void *opaque) { @@ -211,6 +211,114 @@ static void char_mux_test(void) object_unparent(OBJECT(chr)); } =20 +typedef struct SocketIdleData { + GMainLoop *loop; + Chardev *chr; + bool conn_expected; + CharBackend *be; + CharBackend *client_be; +} SocketIdleData; + +static gboolean char_socket_test_idle(gpointer user_data) +{ + SocketIdleData *data =3D user_data; + + if (object_property_get_bool(OBJECT(data->chr), "connected", NULL) + =3D=3D data->conn_expected) { + quit =3D true; + return FALSE; + } + + return TRUE; +} + +static void socket_read(void *opaque, const uint8_t *buf, int size) +{ + SocketIdleData *data =3D opaque; + + g_assert_cmpint(size, =3D=3D, 1); + g_assert_cmpint(*buf, =3D=3D, 'Z'); + + size =3D qemu_chr_fe_write(data->be, (const uint8_t *)"hello", 5); + g_assert_cmpint(size, =3D=3D, 5); +} + +static int socket_can_read(void *opaque) +{ + return 10; +} + +static void socket_read_hello(void *opaque, const uint8_t *buf, int size) +{ + g_assert_cmpint(size, =3D=3D, 5); + g_assert(strncmp((char *)buf, "hello", 5) =3D=3D 0); + + quit =3D true; +} + +static int socket_can_read_hello(void *opaque) +{ + return 10; +} + +static void char_socket_test(void) +{ + Chardev *chr =3D qemu_chr_new("server", "tcp:127.0.0.1:0,server,nowait= "); + Chardev *chr_client; + QObject *addr; + QDict *qdict, *data; + const char *port; + SocketIdleData d =3D { .chr =3D chr }; + CharBackend be; + CharBackend client_be; + char *tmp; + + d.be =3D &be; + d.client_be =3D &be; + + g_assert_nonnull(chr); + g_assert(!object_property_get_bool(OBJECT(chr), "connected", &error_ab= ort)); + + addr =3D object_property_get_qobject(OBJECT(chr), "addr", &error_abort= ); + qdict =3D qobject_to_qdict(addr); + data =3D qdict_get_qdict(qdict, "data"); + port =3D qdict_get_str(data, "port"); + tmp =3D g_strdup_printf("tcp:127.0.0.1:%s", port); + QDECREF(qdict); + + qemu_chr_fe_init(&be, chr, &error_abort); + qemu_chr_fe_set_handlers(&be, socket_can_read, socket_read, + NULL, &d, NULL, true); + + chr_client =3D qemu_chr_new("client", tmp); + qemu_chr_fe_init(&client_be, chr_client, &error_abort); + qemu_chr_fe_set_handlers(&client_be, socket_can_read_hello, + socket_read_hello, + NULL, &d, NULL, true); + g_free(tmp); + + d.conn_expected =3D true; + guint id =3D g_idle_add(char_socket_test_idle, &d); + g_source_set_name_by_id(id, "test-idle"); + g_assert_cmpint(id, >, 0); + main_loop(); + + g_assert(object_property_get_bool(OBJECT(chr), "connected", &error_abo= rt)); + g_assert(object_property_get_bool(OBJECT(chr_client), + "connected", &error_abort)); + + qemu_chr_write_all(chr_client, (const uint8_t *)"Z", 1); + main_loop(); + + object_unparent(OBJECT(chr_client)); + + d.conn_expected =3D false; + g_idle_add(char_socket_test_idle, &d); + main_loop(); + + object_unparent(OBJECT(chr)); +} + #ifndef _WIN32 static void char_pipe_test(void) { @@ -401,6 +509,7 @@ static void char_invalid_test(void) int main(int argc, char **argv) { qemu_init_main_loop(&error_abort); + socket_init(); =20 g_test_init(&argc, &argv, NULL); =20 @@ -419,6 +528,7 @@ int main(int argc, char **argv) g_test_add_func("/char/pipe", char_pipe_test); #endif g_test_add_func("/char/file", char_file_test); + g_test_add_func("/char/socket", char_socket_test); =20 return g_test_run(); } --=20 2.12.0.191.gc5d8de91d From nobody Mon Apr 29 15:22:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493899112844445.617800454841; Thu, 4 May 2017 04:58:32 -0700 (PDT) Received: from localhost ([::1]:41260 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FOx-0000hS-KX for importer@patchew.org; Thu, 04 May 2017 07:58:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46693) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FBq-0004g2-CA for qemu-devel@nongnu.org; Thu, 04 May 2017 07:45:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6FBp-0004zL-Gb for qemu-devel@nongnu.org; Thu, 04 May 2017 07:44:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43938) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6FBp-0004zB-AT for qemu-devel@nongnu.org; Thu, 04 May 2017 07:44:57 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3D963804E4; Thu, 4 May 2017 11:44:56 +0000 (UTC) Received: from localhost (ovpn-117-244.ams2.redhat.com [10.36.117.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id B8DE317A71; Thu, 4 May 2017 11:44:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3D963804E4 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3D963804E4 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 4 May 2017 15:42:31 +0400 Message-Id: <20170504114232.20318-21-marcandre.lureau@redhat.com> In-Reply-To: <20170504114232.20318-1-marcandre.lureau@redhat.com> References: <20170504114232.20318-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 04 May 2017 11:44:56 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 20/21] tests: add /char/udp test X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau --- tests/test-char.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tests/test-char.c b/tests/test-char.c index 9971498391..19707bfcda 100644 --- a/tests/test-char.c +++ b/tests/test-char.c @@ -385,6 +385,51 @@ static void char_pipe_test(void) } #endif =20 +static void char_udp_test(void) +{ + struct sockaddr_in addr =3D { 0, }, other; + SocketIdleData d =3D { 0, }; + Chardev *chr; + CharBackend be; + socklen_t alen =3D sizeof(addr); + int ret, sock =3D qemu_socket(PF_INET, SOCK_DGRAM, 0); + char buf[10]; + char *tmp; + + g_assert_cmpint(sock, >, 0); + addr.sin_family =3D AF_INET ; + addr.sin_addr.s_addr =3D htonl(INADDR_ANY); + addr.sin_port =3D 0; + ret =3D bind(sock, (struct sockaddr *)&addr, sizeof(addr)); + g_assert_cmpint(ret, =3D=3D, 0); + ret =3D getsockname(sock, (struct sockaddr *)&addr, &alen); + g_assert_cmpint(ret, =3D=3D, 0); + + tmp =3D g_strdup_printf("udp:127.0.0.1:%d", + ntohs(addr.sin_port)); + chr =3D qemu_chr_new("client", tmp); + g_assert_nonnull(chr); + + d.chr =3D chr; + qemu_chr_fe_init(&be, chr, &error_abort); + qemu_chr_fe_set_handlers(&be, socket_can_read_hello, socket_read_hello, + NULL, &d, NULL, true); + ret =3D qemu_chr_write_all(chr, (uint8_t *)"hello", 5); + g_assert_cmpint(ret, =3D=3D, 5); + + alen =3D sizeof(addr); + ret =3D recvfrom(sock, buf, sizeof(buf), 0, + (struct sockaddr *)&other, &alen); + g_assert_cmpint(ret, =3D=3D, 5); + ret =3D sendto(sock, buf, 5, 0, (struct sockaddr *)&other, alen); + g_assert_cmpint(ret, =3D=3D, 5); + + main_loop(); + + close(sock); + g_free(tmp); +} + static void char_file_test(void) { char *tmp_path =3D g_dir_make_tmp("qemu-test-char.XXXXXX", NULL); @@ -529,6 +574,7 @@ int main(int argc, char **argv) #endif g_test_add_func("/char/file", char_file_test); g_test_add_func("/char/socket", char_socket_test); + g_test_add_func("/char/udp", char_udp_test); =20 return g_test_run(); } --=20 2.12.0.191.gc5d8de91d From nobody Mon Apr 29 15:22:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493898714736482.0089381841981; Thu, 4 May 2017 04:51:54 -0700 (PDT) Received: from localhost ([::1]:41218 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FIX-0002Ot-9U for importer@patchew.org; Thu, 04 May 2017 07:51:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46735) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6FBy-0004nU-9j for qemu-devel@nongnu.org; Thu, 04 May 2017 07:45:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6FBx-000512-Fw for qemu-devel@nongnu.org; Thu, 04 May 2017 07:45:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44028) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6FBx-00050p-AS for qemu-devel@nongnu.org; Thu, 04 May 2017 07:45:05 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3EF0E83F45; Thu, 4 May 2017 11:45:04 +0000 (UTC) Received: from localhost (ovpn-117-244.ams2.redhat.com [10.36.117.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B6C77D941; Thu, 4 May 2017 11:44:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3EF0E83F45 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3EF0E83F45 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 4 May 2017 15:42:32 +0400 Message-Id: <20170504114232.20318-22-marcandre.lureau@redhat.com> In-Reply-To: <20170504114232.20318-1-marcandre.lureau@redhat.com> References: <20170504114232.20318-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 04 May 2017 11:45:04 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 21/21] tests: add /char/console test X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau --- tests/test-char.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/tests/test-char.c b/tests/test-char.c index 19707bfcda..773a1c36ba 100644 --- a/tests/test-char.c +++ b/tests/test-char.c @@ -57,6 +57,32 @@ static void fe_event(void *opaque, int event) } =20 #ifdef CONFIG_HAS_GLIB_SUBPROCESS_TESTS +#ifdef _WIN32 +static void char_console_test_subprocess(void) +{ + QemuOpts *opts; + Chardev *chr; + + opts =3D qemu_opts_create(qemu_find_opts("chardev"), "console-label", + 1, &error_abort); + qemu_opt_set(opts, "backend", "console", &error_abort); + + chr =3D qemu_chr_new_from_opts(opts, NULL); + g_assert_nonnull(chr); + + qemu_chr_write_all(chr, (const uint8_t *)"CONSOLE", 7); + + qemu_opts_del(opts); + object_unparent(OBJECT(chr)); +} + +static void char_console_test(void) +{ + g_test_trap_subprocess("/char/console/subprocess", 0, 0); + g_test_trap_assert_passed(); + g_test_trap_assert_stdout("CONSOLE"); +} +#endif static void char_stdio_test_subprocess(void) { Chardev *chr; @@ -83,7 +109,6 @@ static void char_stdio_test(void) } #endif =20 - static void char_ringbuf_test(void) { QemuOpts *opts; @@ -566,6 +591,10 @@ int main(int argc, char **argv) g_test_add_func("/char/ringbuf", char_ringbuf_test); g_test_add_func("/char/mux", char_mux_test); #ifdef CONFIG_HAS_GLIB_SUBPROCESS_TESTS +#ifdef _WIN32 + g_test_add_func("/char/console/subprocess", char_console_test_subproce= ss); + g_test_add_func("/char/console", char_console_test); +#endif g_test_add_func("/char/stdio/subprocess", char_stdio_test_subprocess); g_test_add_func("/char/stdio", char_stdio_test); #endif --=20 2.12.0.191.gc5d8de91d