From nobody Thu May 2 21:59:40 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 1486049360795394.7957585810975; Thu, 2 Feb 2017 07:29:20 -0800 (PST) Received: from localhost ([::1]:57272 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZJK2-0005P1-59 for importer@patchew.org; Thu, 02 Feb 2017 10:29:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39428) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIjn-0003sf-Vj for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:51:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZIjm-0003kv-TB for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:51:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36512) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZIjm-0003jt-LE for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:51:50 -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 C527C7E9DE for ; Thu, 2 Feb 2017 14:51:50 +0000 (UTC) Received: from localhost (ovpn-116-38.phx2.redhat.com [10.3.116.38]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v12EpmIH006273; Thu, 2 Feb 2017 09:51:49 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 2 Feb 2017 18:51:20 +0400 Message-Id: <20170202145141.17138-2-marcandre.lureau@redhat.com> In-Reply-To: <20170202145141.17138-1-marcandre.lureau@redhat.com> References: <20170202145141.17138-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.26]); Thu, 02 Feb 2017 14:51:50 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 01/22] 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 --- 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 27eb85f505..3756310f0c 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 4068dc5e52..00b7de3cc4 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -476,7 +476,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 abd525f75e..cec7224b98 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.11.0.295.gd7dffce1c.dirty From nobody Thu May 2 21:59:40 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 1486048717239285.30651463166544; Thu, 2 Feb 2017 07:18:37 -0800 (PST) Received: from localhost ([::1]:57212 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZJ9e-0003h0-O4 for importer@patchew.org; Thu, 02 Feb 2017 10:18:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39466) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIjw-00040t-MB for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZIjs-0003sE-Nc for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55424) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZIjs-0003qc-F5 for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:51:56 -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 8A16F80471 for ; Thu, 2 Feb 2017 14:51:56 +0000 (UTC) Received: from localhost (ovpn-116-38.phx2.redhat.com [10.3.116.38]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v12Epqdn009488; Thu, 2 Feb 2017 09:51:53 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 2 Feb 2017 18:51:21 +0400 Message-Id: <20170202145141.17138-3-marcandre.lureau@redhat.com> In-Reply-To: <20170202145141.17138-1-marcandre.lureau@redhat.com> References: <20170202145141.17138-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.28]); Thu, 02 Feb 2017 14:51:56 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 02/22] 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 --- 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 cec7224b98..9f02c6d5f1 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.11.0.295.gd7dffce1c.dirty From nobody Thu May 2 21:59:40 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 1486049636490678.1108141068117; Thu, 2 Feb 2017 07:33:56 -0800 (PST) Received: from localhost ([::1]:57299 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZJOT-00016M-Gb for importer@patchew.org; Thu, 02 Feb 2017 10:33:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39471) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIjx-00041K-6b for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZIjw-0003w4-FC for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44060) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZIjw-0003vH-9h for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:00 -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 60A343A76B0 for ; Thu, 2 Feb 2017 14:52:00 +0000 (UTC) Received: from localhost (ovpn-116-38.phx2.redhat.com [10.3.116.38]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v12EpvUS010269; Thu, 2 Feb 2017 09:51:59 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 2 Feb 2017 18:51:22 +0400 Message-Id: <20170202145141.17138-4-marcandre.lureau@redhat.com> In-Reply-To: <20170202145141.17138-1-marcandre.lureau@redhat.com> References: <20170202145141.17138-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]); Thu, 02 Feb 2017 14:52:00 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 03/22] 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 --- 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.11.0.295.gd7dffce1c.dirty From nobody Thu May 2 21:59:40 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 1486047921121777.0575012187913; Thu, 2 Feb 2017 07:05:21 -0800 (PST) Received: from localhost ([::1]:57132 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIwn-00081F-LI for importer@patchew.org; Thu, 02 Feb 2017 10:05:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39528) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIk2-0004Dx-6G for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZIk0-000429-Ta for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52456) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZIk0-00040u-ND for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:04 -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 CDE74C051665 for ; Thu, 2 Feb 2017 14:52:04 +0000 (UTC) Received: from localhost (ovpn-116-38.phx2.redhat.com [10.3.116.38]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v12Eq2Mx009615; Thu, 2 Feb 2017 09:52:03 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 2 Feb 2017 18:51:23 +0400 Message-Id: <20170202145141.17138-5-marcandre.lureau@redhat.com> In-Reply-To: <20170202145141.17138-1-marcandre.lureau@redhat.com> References: <20170202145141.17138-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.31]); Thu, 02 Feb 2017 14:52:04 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 04/22] 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.11.0.295.gd7dffce1c.dirty From nobody Thu May 2 21:59:40 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 1486049259684762.6874956411255; Thu, 2 Feb 2017 07:27:39 -0800 (PST) Received: from localhost ([::1]:57263 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZJIN-0003ht-R6 for importer@patchew.org; Thu, 02 Feb 2017 10:27:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39579) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIk6-0004Lk-5m for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZIk5-000469-2v for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44174) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZIk4-00045B-SX for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:08 -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 F3B1A3E9 for ; Thu, 2 Feb 2017 14:52:08 +0000 (UTC) Received: from localhost (ovpn-116-38.phx2.redhat.com [10.3.116.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF2F31CB9A5; Thu, 2 Feb 2017 14:52:07 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 2 Feb 2017 18:51:24 +0400 Message-Id: <20170202145141.17138-6-marcandre.lureau@redhat.com> In-Reply-To: <20170202145141.17138-1-marcandre.lureau@redhat.com> References: <20170202145141.17138-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]); Thu, 02 Feb 2017 14:52:09 +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 05/22] main: free root 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" This should eventually free all objects that are only referenced by their parents. 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 0b72b12878..945df1d17f 100644 --- a/vl.c +++ b/vl.c @@ -4640,6 +4640,7 @@ int main(int argc, char **argv, char **envp) audio_cleanup(); monitor_cleanup(); qemu_chr_cleanup(); + object_unref(object_get_root()); =20 return 0; } --=20 2.11.0.295.gd7dffce1c.dirty From nobody Thu May 2 21:59:40 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 1486048409467548.0621837251247; Thu, 2 Feb 2017 07:13:29 -0800 (PST) Received: from localhost ([::1]:57183 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZJ4h-0007Cl-Fp for importer@patchew.org; Thu, 02 Feb 2017 10:13:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39629) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIkA-0004Wm-AF for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZIk9-00048L-6K for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54690) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZIk8-000480-VC for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:13 -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 13779274873 for ; Thu, 2 Feb 2017 14:52:13 +0000 (UTC) Received: from localhost (ovpn-116-38.phx2.redhat.com [10.3.116.38]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v12EqA6H015503; Thu, 2 Feb 2017 09:52:12 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 2 Feb 2017 18:51:25 +0400 Message-Id: <20170202145141.17138-7-marcandre.lureau@redhat.com> In-Reply-To: <20170202145141.17138-1-marcandre.lureau@redhat.com> References: <20170202145141.17138-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.38]); Thu, 02 Feb 2017 14:52:13 +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 06/22] 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 | 3 ++- chardev/char.c | 46 ++++++++++++++++++++++++++++++++++++++-------- gdbstub.c | 2 +- hw/bt/hci-csr.c | 2 +- 4 files changed, 42 insertions(+), 11 deletions(-) diff --git a/include/sysemu/char.h b/include/sysemu/char.h index a30ff3fa80..e3f3a10d17 100644 --- a/include/sysemu/char.h +++ b/include/sysemu/char.h @@ -490,7 +490,8 @@ typedef struct ChardevClass { } ChardevClass; =20 Chardev *qemu_chardev_new(const char *id, const char *typename, - ChardevBackend *backend, Error **errp); + ChardevBackend *backend, bool enlist, + Error **errp); =20 extern int term_escape_char; =20 diff --git a/chardev/char.c b/chardev/char.c index 9f02c6d5f1..5a12a79c3b 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; @@ -804,7 +809,7 @@ static Chardev *qemu_chardev_add(const char *id, const = char *typename, return NULL; } =20 - chr =3D qemu_chardev_new(id, typename, backend, errp); + chr =3D qemu_chardev_new(id, typename, backend, true, errp); if (!chr) { return NULL; } @@ -1061,8 +1066,14 @@ void qemu_chr_fe_disconnect(CharBackend *be) =20 void qemu_chr_delete(Chardev *chr) { - QTAILQ_REMOVE(&chardevs, chr, next); - object_unref(OBJECT(chr)); + if (QTAILQ_IN_USE(chr, next)) { + QTAILQ_REMOVE(&chardevs, chr, next); + } + if (OBJECT(chr)->parent) { + object_unparent(OBJECT(chr)); + } else { + object_unref(OBJECT(chr)); + } } =20 ChardevInfoList *qmp_query_chardev(Error **errp) @@ -1224,22 +1235,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, bool enlist, + 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 (enlist) { + 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) { @@ -1249,6 +1271,14 @@ 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) { + qemu_chr_delete(chr); + } + return NULL; + } return chr; } =20 diff --git a/gdbstub.c b/gdbstub.c index 755a8e378d..613ac48fed 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1793,7 +1793,7 @@ int gdbserver_start(const char *device) =20 /* Initialize a monitor terminal for gdb */ mon_chr =3D qemu_chardev_new(NULL, TYPE_CHARDEV_GDB, - NULL, &error_abort); + NULL, false, &error_abort); monitor_init(mon_chr, 0); } else { if (qemu_chr_fe_get_driver(&s->chr)) { diff --git a/hw/bt/hci-csr.c b/hw/bt/hci-csr.c index 3c193848fc..9c211e89c4 100644 --- a/hw/bt/hci-csr.c +++ b/hw/bt/hci-csr.c @@ -503,7 +503,7 @@ static const TypeInfo char_hci_type_info =3D { Chardev *uart_hci_init(void) { return qemu_chardev_new(NULL, TYPE_CHARDEV_HCI, - NULL, &error_abort); + NULL, false, &error_abort); } =20 static void register_types(void) --=20 2.11.0.295.gd7dffce1c.dirty From nobody Thu May 2 21:59:40 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 1486048679937783.1111438634883; Thu, 2 Feb 2017 07:17:59 -0800 (PST) Received: from localhost ([::1]:57209 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZJ93-00034R-VT for importer@patchew.org; Thu, 02 Feb 2017 10:17:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39651) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIkH-0004eZ-KN for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZIkD-0004A8-H2 for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54712) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZIkD-00049n-8t for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:17 -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 59AE86196E for ; Thu, 2 Feb 2017 14:52:17 +0000 (UTC) Received: from localhost (ovpn-116-38.phx2.redhat.com [10.3.116.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 49DA11888C0; Thu, 2 Feb 2017 14:52:15 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 2 Feb 2017 18:51:26 +0400 Message-Id: <20170202145141.17138-8-marcandre.lureau@redhat.com> In-Reply-To: <20170202145141.17138-1-marcandre.lureau@redhat.com> References: <20170202145141.17138-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.38]); Thu, 02 Feb 2017 14:52:17 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 07/22] 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 5a12a79c3b..bdba808188 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -452,21 +452,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 { @@ -1076,21 +1079,29 @@ void qemu_chr_delete(Chardev *chr) } } =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; } @@ -1118,14 +1129,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.11.0.295.gd7dffce1c.dirty From nobody Thu May 2 21:59:40 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 1486049525197255.18515956668; Thu, 2 Feb 2017 07:32:05 -0800 (PST) Received: from localhost ([::1]:57292 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZJMf-0007nC-3w for importer@patchew.org; Thu, 02 Feb 2017 10:32:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39662) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIkI-0004fz-Il for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZIkH-0004E3-RU for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54760) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZIkH-0004DM-Lc for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:21 -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 BE70665737 for ; Thu, 2 Feb 2017 14:52:21 +0000 (UTC) Received: from localhost (ovpn-116-38.phx2.redhat.com [10.3.116.38]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v12EqJUP021703; Thu, 2 Feb 2017 09:52:20 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 2 Feb 2017 18:51:27 +0400 Message-Id: <20170202145141.17138-9-marcandre.lureau@redhat.com> In-Reply-To: <20170202145141.17138-1-marcandre.lureau@redhat.com> References: <20170202145141.17138-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.38]); Thu, 02 Feb 2017 14:52:21 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 08/22] 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 | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/chardev/char.c b/chardev/char.c index bdba808188..1103b08177 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -801,26 +801,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, true, errp); - if (!chr) { - return NULL; - } - - QTAILQ_INSERT_TAIL(&chardevs, chr, next); - return chr; -} - static const struct ChardevAlias { const char *typename; const char *alias; @@ -937,9 +917,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); + backend, true, errp); + if (chr =3D=3D NULL) { goto out; } @@ -951,7 +932,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, true, errp= ); if (mux =3D=3D NULL) { qemu_chr_delete(chr); chr =3D NULL; @@ -1300,8 +1281,8 @@ 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)), - backend, errp); + chr =3D qemu_chardev_new(id, object_class_get_name(OBJECT_CLASS(cc)), + backend, true, errp); if (!chr) { return NULL; } --=20 2.11.0.295.gd7dffce1c.dirty From nobody Thu May 2 21:59:40 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 1486049909042833.7233548843822; Thu, 2 Feb 2017 07:38:29 -0800 (PST) Received: from localhost ([::1]:57323 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZJSs-00066n-Vu for importer@patchew.org; Thu, 02 Feb 2017 10:38:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIkQ-0004we-WD for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZIkN-0004HW-2W for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45688) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZIkM-0004HA-Sa for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:26 -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 003E0804EE for ; Thu, 2 Feb 2017 14:52:27 +0000 (UTC) Received: from localhost (ovpn-116-38.phx2.redhat.com [10.3.116.38]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v12EqNaL010623; Thu, 2 Feb 2017 09:52:25 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 2 Feb 2017 18:51:28 +0400 Message-Id: <20170202145141.17138-10-marcandre.lureau@redhat.com> In-Reply-To: <20170202145141.17138-1-marcandre.lureau@redhat.com> References: <20170202145141.17138-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]); Thu, 02 Feb 2017 14:52: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 09/22] 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 | 8 -------- chardev/char.c | 15 --------------- vl.c | 1 - 3 files changed, 24 deletions(-) diff --git a/include/sysemu/char.h b/include/sysemu/char.h index e3f3a10d17..e273c94421 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 /** @@ -142,13 +141,6 @@ Chardev *qemu_chr_new(const char *label, const char *f= ilename); void qemu_chr_fe_disconnect(CharBackend *be); =20 /** - * @qemu_chr_cleanup: - * - * Delete all chardevs (when leaving qemu) - */ -void qemu_chr_cleanup(void); - -/** * @qemu_chr_fe_wait_connected: * * Wait for characted backend to be connected, return < 0 on error or diff --git a/chardev/char.c b/chardev/char.c index 1103b08177..f47d933828 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"); @@ -1050,9 +1047,6 @@ void qemu_chr_fe_disconnect(CharBackend *be) =20 void qemu_chr_delete(Chardev *chr) { - if (QTAILQ_IN_USE(chr, next)) { - QTAILQ_REMOVE(&chardevs, chr, next); - } if (OBJECT(chr)->parent) { object_unparent(OBJECT(chr)); } else { @@ -1317,15 +1311,6 @@ void qmp_chardev_remove(const char *id, Error **errp) qemu_chr_delete(chr); } =20 -void qemu_chr_cleanup(void) -{ - Chardev *chr, *tmp; - - QTAILQ_FOREACH_SAFE(chr, &chardevs, next, tmp) { - qemu_chr_delete(chr); - } -} - static void register_types(void) { type_register_static(&char_type_info); diff --git a/vl.c b/vl.c index 945df1d17f..7bce3b07e2 100644 --- a/vl.c +++ b/vl.c @@ -4639,7 +4639,6 @@ int main(int argc, char **argv, char **envp) net_cleanup(); audio_cleanup(); monitor_cleanup(); - qemu_chr_cleanup(); object_unref(object_get_root()); =20 return 0; --=20 2.11.0.295.gd7dffce1c.dirty From nobody Thu May 2 21:59:40 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 1486048193091565.8367290483502; Thu, 2 Feb 2017 07:09:53 -0800 (PST) Received: from localhost ([::1]:57163 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZJ1D-0003jI-7q for importer@patchew.org; Thu, 02 Feb 2017 10:09:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39686) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIkR-0004xY-Tn for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZIkR-0004Id-9c for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52744) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZIkR-0004IQ-4U for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:31 -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 38584C04D2EF for ; Thu, 2 Feb 2017 14:52:31 +0000 (UTC) Received: from localhost (ovpn-116-38.phx2.redhat.com [10.3.116.38]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v12EqSTJ010044; Thu, 2 Feb 2017 09:52:30 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 2 Feb 2017 18:51:29 +0400 Message-Id: <20170202145141.17138-11-marcandre.lureau@redhat.com> In-Reply-To: <20170202145141.17138-1-marcandre.lureau@redhat.com> References: <20170202145141.17138-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.31]); Thu, 02 Feb 2017 14:52: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 10/22] 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 --- chardev/char.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chardev/char.c b/chardev/char.c index f47d933828..4b633b9366 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -763,7 +763,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.11.0.295.gd7dffce1c.dirty From nobody Thu May 2 21:59:40 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 1486049804258328.30900925536275; Thu, 2 Feb 2017 07:36:44 -0800 (PST) Received: from localhost ([::1]:57317 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZJR9-0003bg-G2 for importer@patchew.org; Thu, 02 Feb 2017 10:36:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIkW-000527-Da for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZIkV-0004Jz-Lc for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37032) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZIkV-0004Jt-FP for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:35 -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 8CB7F7E9DE for ; Thu, 2 Feb 2017 14:52:35 +0000 (UTC) Received: from localhost (ovpn-116-38.phx2.redhat.com [10.3.116.38]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v12EqXxl010116; Thu, 2 Feb 2017 09:52:34 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 2 Feb 2017 18:51:30 +0400 Message-Id: <20170202145141.17138-12-marcandre.lureau@redhat.com> In-Reply-To: <20170202145141.17138-1-marcandre.lureau@redhat.com> References: <20170202145141.17138-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.26]); Thu, 02 Feb 2017 14:52: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 11/22] qcow2: remove 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() already handles the case where the argument is NULL. Signed-off-by: Marc-Andr=C3=A9 Lureau --- block/qcow2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 96fb8a8f16..9114218030 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2016,8 +2016,8 @@ static int qcow2_change_backing_file(BlockDriverState= *bs, g_free(s->image_backing_file); g_free(s->image_backing_format); =20 - s->image_backing_file =3D backing_file ? g_strdup(bs->backing_file) : = NULL; - s->image_backing_format =3D backing_fmt ? g_strdup(bs->backing_format)= : NULL; + s->image_backing_file =3D g_strdup(bs->backing_file); + s->image_backing_format =3D g_strdup(bs->backing_format); =20 return qcow2_update_header(bs); } --=20 2.11.0.295.gd7dffce1c.dirty From nobody Thu May 2 21:59:40 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 1486050066201449.05955097698836; Thu, 2 Feb 2017 07:41:06 -0800 (PST) Received: from localhost ([::1]:57340 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZJVM-0008K4-6k for importer@patchew.org; Thu, 02 Feb 2017 10:41:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39739) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIkf-00056l-3N for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZIkb-0004Ln-5U for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52820) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZIka-0004L1-VR for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:41 -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 1069EC04D2F2 for ; Thu, 2 Feb 2017 14:52:41 +0000 (UTC) Received: from localhost (ovpn-116-38.phx2.redhat.com [10.3.116.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB3F61888C0; Thu, 2 Feb 2017 14:52:38 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 2 Feb 2017 18:51:31 +0400 Message-Id: <20170202145141.17138-13-marcandre.lureau@redhat.com> In-Reply-To: <20170202145141.17138-1-marcandre.lureau@redhat.com> References: <20170202145141.17138-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.31]); Thu, 02 Feb 2017 14:52:41 +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 12/22] 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 00b7de3cc4..1f2377bb4e 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -353,6 +353,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); @@ -367,8 +376,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); @@ -862,8 +870,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.11.0.295.gd7dffce1c.dirty From nobody Thu May 2 21:59:40 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 1486048960785855.0549716577783; Thu, 2 Feb 2017 07:22:40 -0800 (PST) Received: from localhost ([::1]:57239 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZJDZ-0007Ub-IT for importer@patchew.org; Thu, 02 Feb 2017 10:22:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIkg-00057m-6N for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZIkf-0004Pb-EV for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55022) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZIkf-0004Os-8W for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:45 -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 5DEEB64C0 for ; Thu, 2 Feb 2017 14:52:45 +0000 (UTC) Received: from localhost (ovpn-116-38.phx2.redhat.com [10.3.116.38]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v12EqhLT015917; Thu, 2 Feb 2017 09:52:44 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 2 Feb 2017 18:51:32 +0400 Message-Id: <20170202145141.17138-14-marcandre.lureau@redhat.com> In-Reply-To: <20170202145141.17138-1-marcandre.lureau@redhat.com> References: <20170202145141.17138-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.38]); Thu, 02 Feb 2017 14:52:45 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 13/22] 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 1f2377bb4e..58c60d05fe 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -898,6 +898,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.11.0.295.gd7dffce1c.dirty From nobody Thu May 2 21:59:40 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 1486048457691292.31807349367705; Thu, 2 Feb 2017 07:14:17 -0800 (PST) Received: from localhost ([::1]:57186 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZJ5S-00088g-RG for importer@patchew.org; Thu, 02 Feb 2017 10:14:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIkk-0005BZ-HD for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZIkj-0004RZ-Qd for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35398) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZIkj-0004RM-Ke for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:49 -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 B7E4B3B702 for ; Thu, 2 Feb 2017 14:52:49 +0000 (UTC) Received: from localhost (ovpn-116-38.phx2.redhat.com [10.3.116.38]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v12EqlV7010935; Thu, 2 Feb 2017 09:52:48 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 2 Feb 2017 18:51:33 +0400 Message-Id: <20170202145141.17138-15-marcandre.lureau@redhat.com> In-Reply-To: <20170202145141.17138-1-marcandre.lureau@redhat.com> References: <20170202145141.17138-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.30]); Thu, 02 Feb 2017 14:52:49 +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 14/22] 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 58c60d05fe..075d6f671d 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -996,6 +996,15 @@ static void qemu_chr_parse_socket(QemuOpts *opts, Char= devBackend *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); @@ -1011,6 +1020,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.11.0.295.gd7dffce1c.dirty From nobody Thu May 2 21:59:40 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 1486050168746854.1211989798353; Thu, 2 Feb 2017 07:42:48 -0800 (PST) Received: from localhost ([::1]:57347 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZJX4-0001Zg-RQ for importer@patchew.org; Thu, 02 Feb 2017 10:42:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39821) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIks-0005I5-9o for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:53:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZIko-0004Sb-DG for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56046) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZIko-0004SP-7T for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:54 -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 4F4F78046F for ; Thu, 2 Feb 2017 14:52:54 +0000 (UTC) Received: from localhost (ovpn-116-38.phx2.redhat.com [10.3.116.38]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v12Eqp7H010974; Thu, 2 Feb 2017 09:52:53 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 2 Feb 2017 18:51:34 +0400 Message-Id: <20170202145141.17138-16-marcandre.lureau@redhat.com> In-Reply-To: <20170202145141.17138-1-marcandre.lureau@redhat.com> References: <20170202145141.17138-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]); Thu, 02 Feb 2017 14:52: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 15/22] 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 075d6f671d..175cc18269 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -1005,6 +1005,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); @@ -1024,6 +1032,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.11.0.295.gd7dffce1c.dirty From nobody Thu May 2 21:59:40 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 1486050325405594.772258052515; Thu, 2 Feb 2017 07:45:25 -0800 (PST) Received: from localhost ([::1]:57358 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZJZZ-00048h-HQ for importer@patchew.org; Thu, 02 Feb 2017 10:45:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39834) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIkw-0005Mg-BZ for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:53:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZIks-0004TZ-OK for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:53:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37232) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZIks-0004TJ-IX for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:52:58 -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 A652D7E9CD for ; Thu, 2 Feb 2017 14:52:58 +0000 (UTC) Received: from localhost (ovpn-116-38.phx2.redhat.com [10.3.116.38]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v12EquAx022180; Thu, 2 Feb 2017 09:52:57 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 2 Feb 2017 18:51:35 +0400 Message-Id: <20170202145141.17138-17-marcandre.lureau@redhat.com> In-Reply-To: <20170202145141.17138-1-marcandre.lureau@redhat.com> References: <20170202145141.17138-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]); Thu, 02 Feb 2017 14:52: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 16/22] 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 --- 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.11.0.295.gd7dffce1c.dirty From nobody Thu May 2 21:59:40 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 1486050598070765.7569768268069; Thu, 2 Feb 2017 07:49:58 -0800 (PST) Received: from localhost ([::1]:57386 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZJdy-00008a-Uk for importer@patchew.org; Thu, 02 Feb 2017 10:49:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39846) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIkx-0005O9-Qo for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:53:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZIkx-0004W8-3k for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:53:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35516) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZIkw-0004Vl-Tb for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:53:03 -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 E28FDC7043 for ; Thu, 2 Feb 2017 14:53:02 +0000 (UTC) Received: from localhost (ovpn-116-38.phx2.redhat.com [10.3.116.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id D56671888C0; Thu, 2 Feb 2017 14:53:01 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 2 Feb 2017 18:51:36 +0400 Message-Id: <20170202145141.17138-18-marcandre.lureau@redhat.com> In-Reply-To: <20170202145141.17138-1-marcandre.lureau@redhat.com> References: <20170202145141.17138-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.30]); Thu, 02 Feb 2017 14:53: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 17/22] 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 da69f110e4..aa9b18a61b 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); qemu_chr_delete(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); + qemu_chr_delete(chr); + qemu_opts_del(opts); } =20 static void char_mux_test(void) --=20 2.11.0.295.gd7dffce1c.dirty From nobody Thu May 2 21:59:40 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 1486049224709430.7639536483092; Thu, 2 Feb 2017 07:27:04 -0800 (PST) Received: from localhost ([::1]:57261 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZJHp-0003EI-L0 for importer@patchew.org; Thu, 02 Feb 2017 10:27:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39908) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIl7-0005XE-DZ for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:53:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZIl1-0004Y7-DJ for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:53:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35546) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZIl1-0004XM-4T for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:53:07 -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 3E39C3D945 for ; Thu, 2 Feb 2017 14:53:07 +0000 (UTC) Received: from localhost (ovpn-116-38.phx2.redhat.com [10.3.116.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 494451888C0; Thu, 2 Feb 2017 14:53:05 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 2 Feb 2017 18:51:37 +0400 Message-Id: <20170202145141.17138-19-marcandre.lureau@redhat.com> In-Reply-To: <20170202145141.17138-1-marcandre.lureau@redhat.com> References: <20170202145141.17138-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.30]); Thu, 02 Feb 2017 14:53:07 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 18/22] 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 aa9b18a61b..8166ace487 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) qemu_chr_delete(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); + qemu_chr_delete(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.11.0.295.gd7dffce1c.dirty From nobody Thu May 2 21:59:40 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 148605086375790.92994638078312; Thu, 2 Feb 2017 07:54:23 -0800 (PST) Received: from localhost ([::1]:57414 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZJiH-0004JS-Bn for importer@patchew.org; Thu, 02 Feb 2017 10:54:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39921) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIl9-0005Yd-1v for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:53:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZIl5-0004bg-P9 for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:53:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55334) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZIl5-0004b9-H5 for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:53:11 -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 9B61B65743 for ; Thu, 2 Feb 2017 14:53:11 +0000 (UTC) Received: from localhost (ovpn-116-38.phx2.redhat.com [10.3.116.38]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v12Er9Rp010527; Thu, 2 Feb 2017 09:53:10 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 2 Feb 2017 18:51:38 +0400 Message-Id: <20170202145141.17138-20-marcandre.lureau@redhat.com> In-Reply-To: <20170202145141.17138-1-marcandre.lureau@redhat.com> References: <20170202145141.17138-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]); Thu, 02 Feb 2017 14:53: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 19/22] 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 8166ace487..d543e897a0 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("file-out", TYPE_CHARDEV_FILE, &backend, + false, &error_abort); + ret =3D qemu_chr_write_all(chr, (uint8_t *)"hello!", 6); + g_assert_cmpint(ret, =3D=3D, 6); + qemu_chr_delete(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("file", TYPE_CHARDEV_FILE, &backend, + false, &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); + qemu_chr_delete(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.11.0.295.gd7dffce1c.dirty From nobody Thu May 2 21:59:40 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 1486051115426753.3387737051845; Thu, 2 Feb 2017 07:58:35 -0800 (PST) Received: from localhost ([::1]:57439 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZJmL-0000Rd-7u for importer@patchew.org; Thu, 02 Feb 2017 10:58:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39945) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIlB-0005ag-Fc for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:53:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZIlA-0004ea-5j for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:53:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37506) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZIl9-0004dq-Sy for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:53:16 -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 CE3EE7E9F2 for ; Thu, 2 Feb 2017 14:53:15 +0000 (UTC) Received: from localhost (ovpn-116-38.phx2.redhat.com [10.3.116.38]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v12ErDn8007357; Thu, 2 Feb 2017 09:53:14 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 2 Feb 2017 18:51:39 +0400 Message-Id: <20170202145141.17138-21-marcandre.lureau@redhat.com> In-Reply-To: <20170202145141.17138-1-marcandre.lureau@redhat.com> References: <20170202145141.17138-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.26]); Thu, 02 Feb 2017 14:53:15 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 20/22] 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 d543e897a0..e35e301a47 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) qemu_chr_delete(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(); + + qemu_chr_delete(chr_client); + + d.conn_expected =3D false; + g_idle_add(char_socket_test_idle, &d); + main_loop(); + + qemu_chr_delete(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.11.0.295.gd7dffce1c.dirty From nobody Thu May 2 21:59:40 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 1486048725701852.6673203059737; Thu, 2 Feb 2017 07:18:45 -0800 (PST) Received: from localhost ([::1]:57213 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZJ9n-0003qd-Vb for importer@patchew.org; Thu, 02 Feb 2017 10:18:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39965) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIlE-0005e7-Uf for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:53:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZIlE-0004fO-5x for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:53:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53272) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZIlE-0004fK-0i for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:53:20 -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 2219CC04D2B8 for ; Thu, 2 Feb 2017 14:53:20 +0000 (UTC) Received: from localhost (ovpn-116-38.phx2.redhat.com [10.3.116.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 36DD31CB9BA; Thu, 2 Feb 2017 14:53:18 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 2 Feb 2017 18:51:40 +0400 Message-Id: <20170202145141.17138-22-marcandre.lureau@redhat.com> In-Reply-To: <20170202145141.17138-1-marcandre.lureau@redhat.com> References: <20170202145141.17138-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.31]); Thu, 02 Feb 2017 14:53:20 +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 21/22] 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 e35e301a47..df2695e75d 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.11.0.295.gd7dffce1c.dirty From nobody Thu May 2 21:59:40 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 1486049005657731.8134284595752; Thu, 2 Feb 2017 07:23:25 -0800 (PST) Received: from localhost ([::1]:57242 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZJEJ-0008KI-Ny for importer@patchew.org; Thu, 02 Feb 2017 10:23:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39995) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIlN-0005jB-CP for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:53:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZIlJ-0004gt-9J for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:53:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54586) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZIlJ-0004gp-33 for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:53:25 -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 3066361BB0 for ; Thu, 2 Feb 2017 14:53:25 +0000 (UTC) Received: from localhost (ovpn-116-38.phx2.redhat.com [10.3.116.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 246F91B3989; Thu, 2 Feb 2017 14:53:22 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 2 Feb 2017 18:51:41 +0400 Message-Id: <20170202145141.17138-23-marcandre.lureau@redhat.com> In-Reply-To: <20170202145141.17138-1-marcandre.lureau@redhat.com> References: <20170202145141.17138-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.39]); Thu, 02 Feb 2017 14:53:25 +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 22/22] 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 df2695e75d..5eeed4dae8 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); + qemu_chr_delete(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.11.0.295.gd7dffce1c.dirty