From patchwork Fri Mar 26 17:34:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 1458902 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=web.de header.i=@web.de header.a=rsa-sha256 header.s=dbaedf251592 header.b=YqWIyQs2; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4F6ThK4Ktzz9sRR for ; Sat, 27 Mar 2021 04:37:53 +1100 (AEDT) Received: from localhost ([::1]:34678 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPqP9-0008MV-KC for incoming@patchwork.ozlabs.org; Fri, 26 Mar 2021 13:37:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44316) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPqMW-0005Gx-O4 for qemu-devel@nongnu.org; Fri, 26 Mar 2021 13:35:08 -0400 Received: from mout.web.de ([212.227.17.12]:45159) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPqMR-0004So-6z for qemu-devel@nongnu.org; Fri, 26 Mar 2021 13:35:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1616780101; bh=yt0UMy2seKBXZxq/MjRn7d1+kwt5Ib7BhGGKWTAL6Bo=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=YqWIyQs2ZgtvWPz6oKQyZdtHl0PKDEhcq5CNjyDfgyIOFpGdzswLS69p68kVVZhDV 4o1mEu/Kc48HR1Kayrio2nSekGVBTDMWi9hQBrC8+JL+0IzNvXTSVk2ZK/Uxc6hh/j r+NUMM7Ha9JgH3GAa9VEcl5KDbIQzboF3tdpn0vU= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from gecko.fritz.box ([89.247.255.242]) by smtp.web.de (mrweb105 [213.165.67.124]) with ESMTPSA (Nemesis) id 1N5lnF-1ljZz53elH-016kpB; Fri, 26 Mar 2021 18:35:00 +0100 Date: Fri, 26 Mar 2021 18:34:59 +0100 From: Lukas Straub To: Peter Maydell Subject: [PULL 1/6] yank: Remove dependency on qiochannel Message-ID: <19be51edbb4a213baa1716fa79f7071475d1a9c0.1616779714.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:0kKx1P1WMThP/MsS3FKQez+ttLjyWvTbGULiQ6D8dRKHoS9Ytgq XZqlQyodV/XHD5DG6x9P51QGW5KZgcssqNQK9HRu4Y0/SU9t3Jghu+Zy5+efxdGqKb+hZvq AXLmubOwtoUQFjwZfumcmn5oAdVyebrl8krRDe3Z8Aq8kl4Fs3V423icstRmlk4XwnOQ9xL akSAoI2eckkErEt6wnHBw== X-UI-Out-Filterresults: notjunk:1;V03:K0:KXJnE9v0q4U=:0RGNqwkdXSAwwfZwktfgBg xNvE6wYciIRTcUoCdFLWN+bg+oPrXQGp0j1exaV5S81Wg1gV6Lb1PjLiWqrcFhvYpWG8CElp+ 7vNhfuNLW4imUtGUmwLKMgDXD1l0z30gkFZfVV54IQmAMfqgVMkb6v8W6KoWH3VW/ws5H4otG g8CjS2JVr07LLDYjxFHukXNt08sgHk2BDRO8WOfbXdgCOA6tiqeK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SPF: pass client-ip=212.227.17.12; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Remove dependency on qiochannel by removing yank_generic_iochannel and letting migration and chardev use their own yank function for iochannel. Signed-off-by: Lukas Straub Reviewed-by: Thomas Huth Reviewed-by: Marc-André Lureau --- MAINTAINERS | 1 + chardev/char-socket.c | 21 ++++++++++++++------- include/qemu/yank.h | 10 ---------- migration/channel.c | 6 ++++-- migration/meson.build | 1 + migration/multifd.c | 3 ++- migration/qemu-file-channel.c | 3 ++- migration/yank_functions.c | 20 ++++++++++++++++++++ migration/yank_functions.h | 17 +++++++++++++++++ stubs/yank.c | 6 ------ util/yank.c | 8 -------- 11 files changed, 61 insertions(+), 35 deletions(-) create mode 100644 migration/yank_functions.c create mode 100644 migration/yank_functions.h -- 2.30.2 diff --git a/MAINTAINERS b/MAINTAINERS index 9147e9a429..455775c4a3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2821,6 +2821,7 @@ M: Lukas Straub S: Odd fixes F: util/yank.c F: stubs/yank.c +F: migration/yank_functions* F: include/qemu/yank.h F: qapi/yank.json diff --git a/chardev/char-socket.c b/chardev/char-socket.c index f618bdec28..1d455ecca4 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -402,6 +402,13 @@ static void remove_hup_source(SocketChardev *s) } } +static void char_socket_yank_iochannel(void *opaque) +{ + QIOChannel *ioc = QIO_CHANNEL(opaque); + + qio_channel_shutdown(ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL); +} + static void tcp_chr_free_connection(Chardev *chr) { SocketChardev *s = SOCKET_CHARDEV(chr); @@ -424,7 +431,7 @@ static void tcp_chr_free_connection(Chardev *chr) (s->state == TCP_CHARDEV_STATE_CONNECTING || s->state == TCP_CHARDEV_STATE_CONNECTED)) { yank_unregister_function(CHARDEV_YANK_INSTANCE(chr->label), - yank_generic_iochannel, + char_socket_yank_iochannel, QIO_CHANNEL(s->sioc)); } object_unref(OBJECT(s->sioc)); @@ -946,7 +953,7 @@ static int tcp_chr_add_client(Chardev *chr, int fd) tcp_chr_set_client_ioc_name(chr, sioc); if (s->registered_yank) { yank_register_function(CHARDEV_YANK_INSTANCE(chr->label), - yank_generic_iochannel, + char_socket_yank_iochannel, QIO_CHANNEL(sioc)); } ret = tcp_chr_new_client(chr, sioc); @@ -965,7 +972,7 @@ static void tcp_chr_accept(QIONetListener *listener, tcp_chr_set_client_ioc_name(chr, cioc); if (s->registered_yank) { yank_register_function(CHARDEV_YANK_INSTANCE(chr->label), - yank_generic_iochannel, + char_socket_yank_iochannel, QIO_CHANNEL(cioc)); } tcp_chr_new_client(chr, cioc); @@ -985,7 +992,7 @@ static int tcp_chr_connect_client_sync(Chardev *chr, Error **errp) } if (s->registered_yank) { yank_register_function(CHARDEV_YANK_INSTANCE(chr->label), - yank_generic_iochannel, + char_socket_yank_iochannel, QIO_CHANNEL(sioc)); } tcp_chr_new_client(chr, sioc); @@ -1005,7 +1012,7 @@ static void tcp_chr_accept_server_sync(Chardev *chr) tcp_chr_set_client_ioc_name(chr, sioc); if (s->registered_yank) { yank_register_function(CHARDEV_YANK_INSTANCE(chr->label), - yank_generic_iochannel, + char_socket_yank_iochannel, QIO_CHANNEL(sioc)); } tcp_chr_new_client(chr, sioc); @@ -1138,7 +1145,7 @@ static void qemu_chr_socket_connected(QIOTask *task, void *opaque) tcp_chr_change_state(s, TCP_CHARDEV_STATE_DISCONNECTED); if (s->registered_yank) { yank_unregister_function(CHARDEV_YANK_INSTANCE(chr->label), - yank_generic_iochannel, + char_socket_yank_iochannel, QIO_CHANNEL(sioc)); } check_report_connect_error(chr, err); @@ -1176,7 +1183,7 @@ static void tcp_chr_connect_client_async(Chardev *chr) tcp_chr_set_client_ioc_name(chr, sioc); if (s->registered_yank) { yank_register_function(CHARDEV_YANK_INSTANCE(chr->label), - yank_generic_iochannel, + char_socket_yank_iochannel, QIO_CHANNEL(sioc)); } /* diff --git a/include/qemu/yank.h b/include/qemu/yank.h index 5b93c70cbf..5375a1f195 100644 --- a/include/qemu/yank.h +++ b/include/qemu/yank.h @@ -73,16 +73,6 @@ void yank_unregister_function(const YankInstance *instance, YankFn *func, void *opaque); -/** - * yank_generic_iochannel: Generic yank function for iochannel - * - * This is a generic yank function which will call qio_channel_shutdown on the - * provided QIOChannel. - * - * @opaque: QIOChannel to shutdown - */ -void yank_generic_iochannel(void *opaque); - #define BLOCKDEV_YANK_INSTANCE(the_node_name) (&(YankInstance) { \ .type = YANK_INSTANCE_TYPE_BLOCK_NODE, \ .u.block_node.node_name = (the_node_name) }) diff --git a/migration/channel.c b/migration/channel.c index 35fe234e9c..c9ee902021 100644 --- a/migration/channel.c +++ b/migration/channel.c @@ -20,6 +20,7 @@ #include "io/channel-tls.h" #include "io/channel-socket.h" #include "qemu/yank.h" +#include "yank_functions.h" /** * @migration_channel_process_incoming - Create new incoming migration channel @@ -38,7 +39,8 @@ void migration_channel_process_incoming(QIOChannel *ioc) ioc, object_get_typename(OBJECT(ioc))); if (object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_SOCKET)) { - yank_register_function(MIGRATION_YANK_INSTANCE, yank_generic_iochannel, + yank_register_function(MIGRATION_YANK_INSTANCE, + migration_yank_iochannel, QIO_CHANNEL(ioc)); } @@ -76,7 +78,7 @@ void migration_channel_connect(MigrationState *s, if (!error) { if (object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_SOCKET)) { yank_register_function(MIGRATION_YANK_INSTANCE, - yank_generic_iochannel, + migration_yank_iochannel, QIO_CHANNEL(ioc)); } diff --git a/migration/meson.build b/migration/meson.build index 9645f44005..2cfa8eed72 100644 --- a/migration/meson.build +++ b/migration/meson.build @@ -6,6 +6,7 @@ migration_files = files( 'vmstate.c', 'qemu-file-channel.c', 'qemu-file.c', + 'yank_functions.c', ) softmmu_ss.add(migration_files) diff --git a/migration/multifd.c b/migration/multifd.c index 03527c564c..a6677c45c8 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -27,6 +27,7 @@ #include "qemu/yank.h" #include "io/channel-socket.h" +#include "yank_functions.h" /* Multiple fd's */ @@ -989,7 +990,7 @@ int multifd_load_cleanup(Error **errp) if (object_dynamic_cast(OBJECT(p->c), TYPE_QIO_CHANNEL_SOCKET) && OBJECT(p->c)->ref == 1) { yank_unregister_function(MIGRATION_YANK_INSTANCE, - yank_generic_iochannel, + migration_yank_iochannel, QIO_CHANNEL(p->c)); } diff --git a/migration/qemu-file-channel.c b/migration/qemu-file-channel.c index afc3a7f642..876d05a540 100644 --- a/migration/qemu-file-channel.c +++ b/migration/qemu-file-channel.c @@ -28,6 +28,7 @@ #include "io/channel-socket.h" #include "qemu/iov.h" #include "qemu/yank.h" +#include "yank_functions.h" static ssize_t channel_writev_buffer(void *opaque, @@ -108,7 +109,7 @@ static int channel_close(void *opaque, Error **errp) if (object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_SOCKET) && OBJECT(ioc)->ref == 1) { yank_unregister_function(MIGRATION_YANK_INSTANCE, - yank_generic_iochannel, + migration_yank_iochannel, QIO_CHANNEL(ioc)); } object_unref(OBJECT(ioc)); diff --git a/migration/yank_functions.c b/migration/yank_functions.c new file mode 100644 index 0000000000..96c90e17dc --- /dev/null +++ b/migration/yank_functions.c @@ -0,0 +1,20 @@ +/* + * migration yank functions + * + * Copyright (c) Lukas Straub + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "io/channel.h" +#include "yank_functions.h" + +void migration_yank_iochannel(void *opaque) +{ + QIOChannel *ioc = QIO_CHANNEL(opaque); + + qio_channel_shutdown(ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL); +} diff --git a/migration/yank_functions.h b/migration/yank_functions.h new file mode 100644 index 0000000000..055ea22523 --- /dev/null +++ b/migration/yank_functions.h @@ -0,0 +1,17 @@ +/* + * migration yank functions + * + * Copyright (c) Lukas Straub + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +/** + * migration_yank_iochannel: yank function for iochannel + * + * This yank function will call qio_channel_shutdown on the provided QIOChannel. + * + * @opaque: QIOChannel to shutdown + */ +void migration_yank_iochannel(void *opaque); diff --git a/stubs/yank.c b/stubs/yank.c index 6090416065..11b24fc057 100644 --- a/stubs/yank.c +++ b/stubs/yank.c @@ -21,9 +21,3 @@ void yank_unregister_function(const YankInstance *instance, void *opaque) { } - -void yank_generic_iochannel(void *opaque) -{ -} - - diff --git a/util/yank.c b/util/yank.c index fc08f65209..abf47c346d 100644 --- a/util/yank.c +++ b/util/yank.c @@ -15,7 +15,6 @@ #include "qapi/qapi-commands-yank.h" #include "qapi/qapi-visit-yank.h" #include "qapi/clone-visitor.h" -#include "io/channel.h" #include "qemu/yank.h" struct YankFuncAndParam { @@ -151,13 +150,6 @@ void yank_unregister_function(const YankInstance *instance, abort(); } -void yank_generic_iochannel(void *opaque) -{ - QIOChannel *ioc = QIO_CHANNEL(opaque); - - qio_channel_shutdown(ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL); -} - void qmp_yank(YankInstanceList *instances, Error **errp) {