From nobody Fri May 3 21:10:35 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 1488203751644593.6005207037844; Mon, 27 Feb 2017 05:55:51 -0800 (PST) Received: from localhost ([::1]:52965 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLmI-0004B0-17 for importer@patchew.org; Mon, 27 Feb 2017 08:55:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLZ7-0001GE-3V for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciLZ6-0001NI-7A for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54614) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciLZ5-0001N4-VU for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:12 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 154777F09D for ; Mon, 27 Feb 2017 13:42:12 +0000 (UTC) Received: from localhost (ovpn-116-62.phx2.redhat.com [10.3.116.62]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1RDg9oi017775; Mon, 27 Feb 2017 08:42:10 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 17:41:42 +0400 Message-Id: <20170227134202.2991-2-marcandre.lureau@redhat.com> In-Reply-To: <20170227134202.2991-1-marcandre.lureau@redhat.com> References: <20170227134202.2991-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 27 Feb 2017 13:42:12 +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] [PATCH v2 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: pbonzini@redhat.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" The function simply alias and hides the real event function. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Eric Blake --- 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 ecf2c7a5c4..41c9095189 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 865c52762e..d201f869f8 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -486,7 +486,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 54cd5f4081..0f9d42980d 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 49d0740b40..992f35a5e7 100644 --- a/ui/console.c +++ b/ui/console.c @@ -2056,7 +2056,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 f21e9e7f7b..08cac2f47b 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1867,7 +1867,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.rc2.3.gc93709801 From nobody Fri May 3 21:10:35 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 148820342480791.08946050289728; Mon, 27 Feb 2017 05:50:24 -0800 (PST) Received: from localhost ([::1]:52933 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLh1-0007kF-JD for importer@patchew.org; Mon, 27 Feb 2017 08:50:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53139) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLZG-0001Or-WD for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciLZD-0001Rd-T6 for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35674) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciLZD-0001Qw-Jf for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:19 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 53971A89D for ; Mon, 27 Feb 2017 13:42:19 +0000 (UTC) Received: from localhost (ovpn-116-62.phx2.redhat.com [10.3.116.62]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1RDgGU5016386; Mon, 27 Feb 2017 08:42:18 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 17:41:43 +0400 Message-Id: <20170227134202.2991-3-marcandre.lureau@redhat.com> In-Reply-To: <20170227134202.2991-1-marcandre.lureau@redhat.com> References: <20170227134202.2991-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 27 Feb 2017 13:42:19 +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] [PATCH v2 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: pbonzini@redhat.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" 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 --- 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 0f9d42980d..4f253b3eca 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.rc2.3.gc93709801 From nobody Fri May 3 21:10:35 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 1488204835378600.7059288822967; Mon, 27 Feb 2017 06:13:55 -0800 (PST) Received: from localhost ([::1]:53064 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciM3l-00032g-7Y for importer@patchew.org; Mon, 27 Feb 2017 09:13:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLZQ-0001Xm-4v for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciLZN-0001Xd-1I for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39456) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciLZM-0001XO-Rm for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:28 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0B92BC04B93B for ; Mon, 27 Feb 2017 13:42:29 +0000 (UTC) Received: from localhost (ovpn-116-62.phx2.redhat.com [10.3.116.62]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1RDgK3U017868; Mon, 27 Feb 2017 08:42:28 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 17:41:44 +0400 Message-Id: <20170227134202.2991-4-marcandre.lureau@redhat.com> In-Reply-To: <20170227134202.2991-1-marcandre.lureau@redhat.com> References: <20170227134202.2991-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 27 Feb 2017 13:42:29 +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] [PATCH v2 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: pbonzini@redhat.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 Reviewed-by: Eric Blake --- xen-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen-common.c b/xen-common.c index fd2c92847e..d46685ef4e 100644 --- a/xen-common.c +++ b/xen-common.c @@ -34,7 +34,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.rc2.3.gc93709801 From nobody Fri May 3 21:10:35 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 1488204011888931.5590674336597; Mon, 27 Feb 2017 06:00:11 -0800 (PST) Received: from localhost ([::1]:52985 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLqT-0007yt-LT for importer@patchew.org; Mon, 27 Feb 2017 09:00:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53264) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLZT-0001bH-WB for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciLZT-0001ZL-75 for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49490) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciLZT-0001ZD-0r for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:35 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2890083F45 for ; Mon, 27 Feb 2017 13:42:35 +0000 (UTC) Received: from localhost (ovpn-116-62.phx2.redhat.com [10.3.116.62]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1RDgUFj016478; Mon, 27 Feb 2017 08:42:32 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 17:41:45 +0400 Message-Id: <20170227134202.2991-5-marcandre.lureau@redhat.com> In-Reply-To: <20170227134202.2991-1-marcandre.lureau@redhat.com> References: <20170227134202.2991-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 27 Feb 2017 13:42:35 +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] [PATCH v2 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: pbonzini@redhat.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" object_property_add_child() references the child, unref it after to avoid ref leaks. Signed-off-by: Marc-Andr=C3=A9 Lureau --- 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.rc2.3.gc93709801 From nobody Fri May 3 21:10:35 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 1488205106216685.4008615865143; Mon, 27 Feb 2017 06:18:26 -0800 (PST) Received: from localhost ([::1]:53094 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciM86-0006nc-VU for importer@patchew.org; Mon, 27 Feb 2017 09:18:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53306) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLZa-0001hy-TU for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciLZX-0001a8-PT for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35834) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciLZX-0001Zf-Fc for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:39 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 11FA71555A for ; Mon, 27 Feb 2017 13:42:39 +0000 (UTC) Received: from localhost (ovpn-116-62.phx2.redhat.com [10.3.116.62]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1RDgaaN006163; Mon, 27 Feb 2017 08:42:37 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 17:41:46 +0400 Message-Id: <20170227134202.2991-6-marcandre.lureau@redhat.com> In-Reply-To: <20170227134202.2991-1-marcandre.lureau@redhat.com> References: <20170227134202.2991-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 27 Feb 2017 13:42: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] [PATCH v2 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: pbonzini@redhat.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" 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 | 57 +++++++++++++++++++++++++++++++----------= ---- 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, 49 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 4f253b3eca..4e55f77dce 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,33 @@ 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)); + if (id) { + obj =3D object_new_with_props(typename, get_chardevs_root(), + id, &local_err, NULL); + } else { + obj =3D object_new(typename); + } + if (local_err) { + assert(!obj); + goto end; + } + + 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 +1263,18 @@ Chardev *qemu_chardev_new(const char *id, const char= *typename, qemu_chr_be_event(chr, CHR_EVENT_OPENED); } =20 +end: + if (local_err) { + error_propagate(errp, local_err); + if (chr) { + if (id) { + object_unparent(OBJECT(chr)); + } else { + object_unref(OBJECT(chr)); + } + } + return NULL; + } return chr; } =20 @@ -1298,16 +1323,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 77b8110f8c..4db26ca4b1 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 2c45c7b29f..3c0e75b797 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -490,7 +490,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.rc2.3.gc93709801 From nobody Fri May 3 21:10:35 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 14882037627771006.8009113337642; Mon, 27 Feb 2017 05:56:02 -0800 (PST) Received: from localhost ([::1]:52966 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLmR-0004K3-FH for importer@patchew.org; Mon, 27 Feb 2017 08:55:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53329) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLZc-0001jJ-9F for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciLZb-0001b9-Ds for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52922) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciLZb-0001ax-7n for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:43 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3F5FD8046B for ; Mon, 27 Feb 2017 13:42:43 +0000 (UTC) Received: from localhost (ovpn-116-62.phx2.redhat.com [10.3.116.62]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1RDgeJV028363; Mon, 27 Feb 2017 08:42:41 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 17:41:47 +0400 Message-Id: <20170227134202.2991-7-marcandre.lureau@redhat.com> In-Reply-To: <20170227134202.2991-1-marcandre.lureau@redhat.com> References: <20170227134202.2991-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 27 Feb 2017 13:42:43 +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] [PATCH v2 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: pbonzini@redhat.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 --- vl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/vl.c b/vl.c index e10a27bdd6..63e1665bf8 100644 --- a/vl.c +++ b/vl.c @@ -4685,6 +4685,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.rc2.3.gc93709801 From nobody Fri May 3 21:10:35 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 1488203685349841.2703635594944; Mon, 27 Feb 2017 05:54:45 -0800 (PST) Received: from localhost ([::1]:52957 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLlE-0003BI-1z for importer@patchew.org; Mon, 27 Feb 2017 08:54:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53357) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLZg-0001nI-FT for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciLZf-0001cj-Lw for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35916) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciLZf-0001cY-D6 for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:47 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 896DE2EF19F for ; Mon, 27 Feb 2017 13:42:47 +0000 (UTC) Received: from localhost (ovpn-116-62.phx2.redhat.com [10.3.116.62]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1RDgjuT018026; Mon, 27 Feb 2017 08:42:46 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 17:41:48 +0400 Message-Id: <20170227134202.2991-8-marcandre.lureau@redhat.com> In-Reply-To: <20170227134202.2991-1-marcandre.lureau@redhat.com> References: <20170227134202.2991-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 27 Feb 2017 13:42:47 +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] [PATCH v2 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: pbonzini@redhat.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" 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 4e55f77dce..82f3c939ba 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.rc2.3.gc93709801 From nobody Fri May 3 21:10:35 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 1488204303945538.3183939209994; Mon, 27 Feb 2017 06:05:03 -0800 (PST) Received: from localhost ([::1]:53009 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLv8-0003ZU-Kh for importer@patchew.org; Mon, 27 Feb 2017 09:04:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53385) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLZj-0001qZ-Tg for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciLZj-0001dN-4A for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:1091) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciLZi-0001dC-UN for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:51 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 10FAA811AC for ; Mon, 27 Feb 2017 13:42:51 +0000 (UTC) Received: from localhost (ovpn-116-62.phx2.redhat.com [10.3.116.62]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1RDgmmX028438; Mon, 27 Feb 2017 08:42:50 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 17:41:49 +0400 Message-Id: <20170227134202.2991-9-marcandre.lureau@redhat.com> In-Reply-To: <20170227134202.2991-1-marcandre.lureau@redhat.com> References: <20170227134202.2991-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 27 Feb 2017 13:42: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] [PATCH v2 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: pbonzini@redhat.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" 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 82f3c939ba..b3622be3f4 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; @@ -1296,7 +1277,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.rc2.3.gc93709801 From nobody Fri May 3 21:10:35 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 1488204590550622.669324251685; Mon, 27 Feb 2017 06:09:50 -0800 (PST) Received: from localhost ([::1]:53033 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLzl-0007n3-BA for importer@patchew.org; Mon, 27 Feb 2017 09:09:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53427) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLZn-0001uI-Nw for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciLZm-0001eJ-SC for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38808) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciLZm-0001dy-Lj for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:54 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BF69F4E4D4 for ; Mon, 27 Feb 2017 13:42:54 +0000 (UTC) Received: from localhost (ovpn-116-62.phx2.redhat.com [10.3.116.62]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1RDgqOi006317; Mon, 27 Feb 2017 08:42:53 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 17:41:50 +0400 Message-Id: <20170227134202.2991-10-marcandre.lureau@redhat.com> In-Reply-To: <20170227134202.2991-1-marcandre.lureau@redhat.com> References: <20170227134202.2991-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 27 Feb 2017 13:42:54 +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] [PATCH v2 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: pbonzini@redhat.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" 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 b3622be3f4..558fd8b31c 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.rc2.3.gc93709801 From nobody Fri May 3 21:10:35 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 1488203941481955.3774575910697; Mon, 27 Feb 2017 05:59:01 -0800 (PST) Received: from localhost ([::1]:52983 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLpM-0006zW-3t for importer@patchew.org; Mon, 27 Feb 2017 08:59:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53484) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLZt-0001zd-HO for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciLZq-0001fI-FB for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55024) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciLZq-0001f2-8o for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:58 -0500 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5E6A6883A4 for ; Mon, 27 Feb 2017 13:42:58 +0000 (UTC) Received: from localhost (ovpn-116-62.phx2.redhat.com [10.3.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8789C2D655; Mon, 27 Feb 2017 13:42:57 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 17:41:51 +0400 Message-Id: <20170227134202.2991-11-marcandre.lureau@redhat.com> In-Reply-To: <20170227134202.2991-1-marcandre.lureau@redhat.com> References: <20170227134202.2991-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.74 on 10.5.11.28 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 27 Feb 2017 13:42: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] [PATCH v2 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: pbonzini@redhat.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" 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 558fd8b31c..bb20d73fcf 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.rc2.3.gc93709801 From nobody Fri May 3 21:10:35 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 1488205389983191.96168408417066; Mon, 27 Feb 2017 06:23:09 -0800 (PST) Received: from localhost ([::1]:53144 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciMCh-0002Pp-Hl for importer@patchew.org; Mon, 27 Feb 2017 09:23:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53508) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLZv-000214-1z for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciLZu-0001hA-AR for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51802) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciLZu-0001gu-4S for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:02 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 423F561E4C for ; Mon, 27 Feb 2017 13:43:02 +0000 (UTC) Received: from localhost (ovpn-116-62.phx2.redhat.com [10.3.116.62]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1RDgxLL028570; Mon, 27 Feb 2017 08:43:01 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 17:41:52 +0400 Message-Id: <20170227134202.2991-12-marcandre.lureau@redhat.com> In-Reply-To: <20170227134202.2991-1-marcandre.lureau@redhat.com> References: <20170227134202.2991-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 27 Feb 2017 13:43:02 +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] [PATCH v2 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: pbonzini@redhat.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" This helper will be used in yet another place in the following patch. Signed-off-by: Marc-Andr=C3=A9 Lureau --- 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 d201f869f8..636a6ea5fa 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -363,6 +363,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); @@ -377,8 +386,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); @@ -872,8 +880,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.rc2.3.gc93709801 From nobody Fri May 3 21:10:35 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 1488204852173659.3894852391908; Mon, 27 Feb 2017 06:14:12 -0800 (PST) Received: from localhost ([::1]:53066 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciM40-0003HM-UQ for importer@patchew.org; Mon, 27 Feb 2017 09:14:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53530) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLZy-00024a-M7 for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciLZx-0001hw-UZ for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39834) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciLZx-0001ho-Oh for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:05 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DD355C04B93B for ; Mon, 27 Feb 2017 13:43:05 +0000 (UTC) Received: from localhost (ovpn-116-62.phx2.redhat.com [10.3.116.62]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1RDh3wA016793; Mon, 27 Feb 2017 08:43:04 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 17:41:53 +0400 Message-Id: <20170227134202.2991-13-marcandre.lureau@redhat.com> In-Reply-To: <20170227134202.2991-1-marcandre.lureau@redhat.com> References: <20170227134202.2991-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 27 Feb 2017 13: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] [PATCH v2 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: pbonzini@redhat.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" 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 636a6ea5fa..dbf2c54639 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -908,6 +908,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.rc2.3.gc93709801 From nobody Fri May 3 21:10:35 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 1488204219975791.6255961570866; Mon, 27 Feb 2017 06:03:39 -0800 (PST) Received: from localhost ([::1]:53006 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLtp-0002OU-JM for importer@patchew.org; Mon, 27 Feb 2017 09:03:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53576) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLa4-00029s-DJ for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciLa3-0001jM-JV for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36286) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciLa3-0001j6-Cw for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:11 -0500 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8230D3A7697 for ; Mon, 27 Feb 2017 13:43:11 +0000 (UTC) Received: from localhost (ovpn-116-62.phx2.redhat.com [10.3.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 958FA1DCCF; Mon, 27 Feb 2017 13:43:09 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 17:41:54 +0400 Message-Id: <20170227134202.2991-14-marcandre.lureau@redhat.com> In-Reply-To: <20170227134202.2991-1-marcandre.lureau@redhat.com> References: <20170227134202.2991-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.74 on 10.5.11.28 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 27 Feb 2017 13:43:11 +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] [PATCH v2 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: pbonzini@redhat.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" Add a property to lookup the connection details. Signed-off-by: Marc-Andr=C3=A9 Lureau --- chardev/char-socket.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index dbf2c54639..393b315225 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -1006,6 +1006,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); @@ -1021,6 +1030,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.rc2.3.gc93709801 From nobody Fri May 3 21:10:35 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 1488204020402583.4165012399487; Mon, 27 Feb 2017 06:00:20 -0800 (PST) Received: from localhost ([::1]:52986 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLqd-00085r-6X for importer@patchew.org; Mon, 27 Feb 2017 09:00:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53609) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLaB-0002GC-De for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciLa8-0001ju-BT for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53270) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciLa8-0001jn-5U for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:16 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 424E38046F for ; Mon, 27 Feb 2017 13:43:16 +0000 (UTC) Received: from localhost (ovpn-116-62.phx2.redhat.com [10.3.116.62]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1RDhDB9018327; Mon, 27 Feb 2017 08:43:14 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 17:41:55 +0400 Message-Id: <20170227134202.2991-15-marcandre.lureau@redhat.com> In-Reply-To: <20170227134202.2991-1-marcandre.lureau@redhat.com> References: <20170227134202.2991-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 27 Feb 2017 13:43:16 +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] [PATCH v2 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: pbonzini@redhat.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 --- chardev/char-socket.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 393b315225..412dcef85d 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -1015,6 +1015,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); @@ -1034,6 +1042,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.rc2.3.gc93709801 From nobody Fri May 3 21:10:35 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 1488204309596182.8141485796873; Mon, 27 Feb 2017 06:05:09 -0800 (PST) Received: from localhost ([::1]:53011 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLvH-0003hA-9Y for importer@patchew.org; Mon, 27 Feb 2017 09:05:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53619) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLaB-0002Gh-Vj for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciLaB-0001kQ-6W for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55234) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciLaB-0001kI-0U for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:19 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 22C537E9D9 for ; Mon, 27 Feb 2017 13:43:19 +0000 (UTC) Received: from localhost (ovpn-116-62.phx2.redhat.com [10.3.116.62]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1RDhG5b025160; Mon, 27 Feb 2017 08:43:18 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 17:41:56 +0400 Message-Id: <20170227134202.2991-16-marcandre.lureau@redhat.com> In-Reply-To: <20170227134202.2991-1-marcandre.lureau@redhat.com> References: <20170227134202.2991-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 27 Feb 2017 13:43:19 +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] [PATCH v2 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: pbonzini@redhat.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" 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 2c6c7ddd73..5364b5fc59 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.rc2.3.gc93709801 From nobody Fri May 3 21:10:35 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 148820565195355.26541001837313; Mon, 27 Feb 2017 06:27:31 -0800 (PST) Received: from localhost ([::1]:53178 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciMGv-0006Fr-Nt for importer@patchew.org; Mon, 27 Feb 2017 09:27:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53640) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLaG-0002Ku-Ej for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciLaF-0001l6-K1 for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46009) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciLaF-0001l0-E6 for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:23 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 89F5BC04B946 for ; Mon, 27 Feb 2017 13:43:23 +0000 (UTC) Received: from localhost (ovpn-116-62.phx2.redhat.com [10.3.116.62]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1RDhKki025208; Mon, 27 Feb 2017 08:43:22 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 17:41:57 +0400 Message-Id: <20170227134202.2991-17-marcandre.lureau@redhat.com> In-Reply-To: <20170227134202.2991-1-marcandre.lureau@redhat.com> References: <20170227134202.2991-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 27 Feb 2017 13:43:23 +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] [PATCH v2 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: pbonzini@redhat.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.rc2.3.gc93709801 From nobody Fri May 3 21:10:35 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 1488205121210494.092788718173; Mon, 27 Feb 2017 06:18:41 -0800 (PST) Received: from localhost ([::1]:53095 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciM8N-00070C-9g for importer@patchew.org; Mon, 27 Feb 2017 09:18:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53658) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLaM-0002Rf-Qw for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciLaJ-0001lO-NF for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53366) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciLaJ-0001lK-EM for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:27 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8ED8380465 for ; Mon, 27 Feb 2017 13:43:27 +0000 (UTC) Received: from localhost (ovpn-116-62.phx2.redhat.com [10.3.116.62]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1RDhP9M016969; Mon, 27 Feb 2017 08:43:26 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 17:41:58 +0400 Message-Id: <20170227134202.2991-18-marcandre.lureau@redhat.com> In-Reply-To: <20170227134202.2991-1-marcandre.lureau@redhat.com> References: <20170227134202.2991-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 27 Feb 2017 13:43:27 +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] [PATCH v2 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: pbonzini@redhat.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.rc2.3.gc93709801 From nobody Fri May 3 21:10:35 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 1488204574997899.3698516779717; Mon, 27 Feb 2017 06:09:34 -0800 (PST) Received: from localhost ([::1]:53032 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLzY-0007bR-C1 for importer@patchew.org; Mon, 27 Feb 2017 09:09:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53674) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLaP-0002TS-7O for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciLaN-0001n9-UN for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39126) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciLaN-0001mv-Ln for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:31 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C5C884E4D6 for ; Mon, 27 Feb 2017 13:43:31 +0000 (UTC) Received: from localhost (ovpn-116-62.phx2.redhat.com [10.3.116.62]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1RDhTW4028842; Mon, 27 Feb 2017 08:43:30 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 17:41:59 +0400 Message-Id: <20170227134202.2991-19-marcandre.lureau@redhat.com> In-Reply-To: <20170227134202.2991-1-marcandre.lureau@redhat.com> References: <20170227134202.2991-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 27 Feb 2017 13:43:31 +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] [PATCH v2 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: pbonzini@redhat.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.rc2.3.gc93709801 From nobody Fri May 3 21:10:35 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 14882045975171004.8764004526246; Mon, 27 Feb 2017 06:09:57 -0800 (PST) Received: from localhost ([::1]:53034 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLzw-0007vS-AR for importer@patchew.org; Mon, 27 Feb 2017 09:09:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53714) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLaS-0002WI-7b for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciLaR-0001oD-1M for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56768) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciLaQ-0001o2-PE for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:34 -0500 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E54C7C05AA6B for ; Mon, 27 Feb 2017 13:43:34 +0000 (UTC) Received: from localhost (ovpn-116-62.phx2.redhat.com [10.3.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 19D822D655; Mon, 27 Feb 2017 13:43:33 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 17:42:00 +0400 Message-Id: <20170227134202.2991-20-marcandre.lureau@redhat.com> In-Reply-To: <20170227134202.2991-1-marcandre.lureau@redhat.com> References: <20170227134202.2991-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.74 on 10.5.11.28 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 27 Feb 2017 13:43:34 +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] [PATCH v2 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: pbonzini@redhat.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.rc2.3.gc93709801 From nobody Fri May 3 21:10:35 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 1488204861190577.75379689388; Mon, 27 Feb 2017 06:14:21 -0800 (PST) Received: from localhost ([::1]:53068 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciM4A-0003PY-OQ for importer@patchew.org; Mon, 27 Feb 2017 09:14:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53771) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLaV-0002Z8-I3 for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciLaU-0001ph-JN for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55462) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciLaU-0001p8-Cq for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:38 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7F3977E9D1 for ; Mon, 27 Feb 2017 13:43:38 +0000 (UTC) Received: from localhost (ovpn-116-62.phx2.redhat.com [10.3.116.62]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1RDhang018498; Mon, 27 Feb 2017 08:43:37 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 17:42:01 +0400 Message-Id: <20170227134202.2991-21-marcandre.lureau@redhat.com> In-Reply-To: <20170227134202.2991-1-marcandre.lureau@redhat.com> References: <20170227134202.2991-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 27 Feb 2017 13: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] [PATCH v2 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: pbonzini@redhat.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.rc2.3.gc93709801 From nobody Fri May 3 21:10:35 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 1488205136133126.45345905414365; Mon, 27 Feb 2017 06:18:56 -0800 (PST) Received: from localhost ([::1]:53096 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciM8a-00079V-Tx for importer@patchew.org; Mon, 27 Feb 2017 09:18:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53794) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLaY-0002cb-T2 for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciLaY-0001qR-4f for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40100) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciLaX-0001qL-V1 for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:43:42 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 15B82C04B959 for ; Mon, 27 Feb 2017 13:43:42 +0000 (UTC) Received: from localhost (ovpn-116-62.phx2.redhat.com [10.3.116.62]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1RDhdnv028922; Mon, 27 Feb 2017 08:43:41 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 17:42:02 +0400 Message-Id: <20170227134202.2991-22-marcandre.lureau@redhat.com> In-Reply-To: <20170227134202.2991-1-marcandre.lureau@redhat.com> References: <20170227134202.2991-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 27 Feb 2017 13: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] [PATCH v2 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: pbonzini@redhat.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.rc2.3.gc93709801