From patchwork Wed May 20 21:05:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 1294788 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; dmarc=none (p=none dis=none) header.from=web.de Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=web.de header.i=@web.de header.a=rsa-sha256 header.s=dbaedf251592 header.b=jN8JQPuk; 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 49S59b5c0sz9sTS for ; Thu, 21 May 2020 07:14:43 +1000 (AEST) Received: from localhost ([::1]:48236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbW2z-0000JC-Bf for incoming@patchwork.ozlabs.org; Wed, 20 May 2020 17:14:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46190) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbVuY-0002OT-CZ; Wed, 20 May 2020 17:05:58 -0400 Received: from mout.web.de ([212.227.15.3]:45821) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbVuX-0002Sw-AG; Wed, 20 May 2020 17:05:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1590008752; bh=ZT5paGKoMkxQIIK3do9eYhtJlP8tDd8KzO7ihZmKyFg=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=jN8JQPukWhbroWA6Nhx6lWlgaewQxPeY4r5MqilJIrGlITpSm+E9kwMvmFpN7sds5 UDxjZTT8N5H0W9gtbbCOENLrXeF1AXPqK7GB/5chdyelH0x1kMZkJxUPZU3iyls+XX jH/xOUeGzwxzL+bgjY2XH9POmJUA+orvI9zZVMdg= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([88.130.61.105]) by smtp.web.de (mrweb004 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MWeGR-1jZfAi40VP-00XweA; Wed, 20 May 2020 23:05:52 +0200 Date: Wed, 20 May 2020 23:05:50 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v2 4/4] migration: Add yank feature Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:OED8SphvAPMlmwdWiFINwLgEeKhUa5E5Vr0SVmxdzdgTzU3dPbQ cFsDGo84lys4jxKwIRC2AzMfb0HAvnHuwy1ATFJnPkwbfK5zNuQn/A9lfc7ICgdBJpvSIf1 acEIvJHEDkYUZeZ4M7m2EtAK+n/6VOHWrAHWo42K9NcWTx7S6YL/J7OUaauOt5ARMeaaCZF cyV6ROAEn2kKPnO9EG/Kg== X-UI-Out-Filterresults: notjunk:1;V03:K0:0iO+pklncoo=:u/XEMv949gD4atgEnMt3J2 3cfAWwqgaKN4FAAT9ACuMh7+RnYOS+n81/cBqD9/GGzOuKHzTaX3nCt8VROWcUS5HdYWfrnUN beB1AQzo9lxyBp6PNh3rImNE8WEjLaMEFaO8uxaPbWbkijK9VCn7bX3KitZLoFmg9i6M+vJAk o0qqQg0Qm86WUOL/54dOUKu8VW3ekHdXrRWdpGLm6v8vwTXZyAfZkOs6eMYUBHRi/e8vIXQ5T eT8EnqWTYZpLCzmDkBG8celKFDiyOY2bZzZnEKcHVk6bbpLrmnMQQlExYnLTr9OnEPjY1Tx9i bdBpBXVgiviwfBg27ITE8sSYldomSfKi9dQY9Tn9yTpp3EK5wDe/v/Yy8OlDGXbIfLZl+Dln0 gkTaiRSlGB10dXf/a51AMjffj5tmMNqrnXsS5anRXhEn3ZYwlLAFkIjVujdtzMoM0de9I9Ho1 zAGawGe17AQZknq3swYBfMm+njnvWc6kiWZi83n6GfgkRtwIGyrU0t9G/g7cLWRPggSQcN+22 HQedScU9ad/QSQTNlZV4I18kNzwBqN4oj8wtup5IpbMvJ9KK8JYM8MljloEdntVMpRT6fn/GU 4BttCmUhYor97Y521TO90f6s7pD2kuuIs7vnjj3QN6MjF2CnwZcQOL+zfUS1qVreBZzzz1tuV Q1vfh1QqKXfvW3lmpeki1lnxEDI4TXC+a4Le0DFCJB+T7xIqTc0rjxkO3BrK1hfSG6cZROXZQ uBQhYUXKg/6fHSWwUaeCluNAQk5UJCwfQQraPCk+rsv4N6lgbyyeDiDouGdi14trSKOXIbzJJ U7UxUZW5P6Nc+IBz82teOIMQwgSW4BJO0eXnfKdRKpnfD5m4A9HPOJ1ygkwUE3LkkhN3DhEOX lc6eTsQZYaPFlCqTmSOkTUESAxbFb3CjgthLDRAxlM+u34QAhDbTKM1HN2rYirMOnMQq/S+Vx svJTABr1fiKrAo54dGJJNraT5RzTHqVuZUfxJsOieA2f8MuJLYX+7EfvINnrXhk5nR2j2KN77 85wtDmqbItOY645AXu2oyM36/WQTtGampOnQ5YTPsVwnhsmEf/sZmIW2wD45LXsqjhyCnbhJO 5ZIetpe7XkRkQxljRCUrRiO419RIXDj05SbkOAFBQhz006ir4I0l4qPTrWiJTY7X1EzBGtU6n 5v/6X9B4az/JdbJOaW/OiHkUeIEUGrl8L73Znx2YzFiEG+7q6SeC2a/s7fwg+8I+berZBjqPl ltPleRJ0DxvEzZEtK Received-SPF: pass client-ip=212.227.15.3; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/20 16:42:20 X-ACL-Warn: Detected OS = Linux 3.11 and newer 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_PASS=-0.001 autolearn=_AUTOLEARN 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: Kevin Wolf , "Daniel P. =?utf-8?b?QmVycmFuZ8Op?= " , qemu-block , Juan Quintela , "Dr. David Alan Gilbert" , Max Reitz , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9?= Lureau Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Register yank functions on sockets to shut them down. Signed-off-by: Lukas Straub --- migration/migration.c | 9 +++++++++ migration/qemu-file-channel.c | 6 ++++++ migration/socket.c | 11 +++++++++++ 3 files changed, 26 insertions(+) -- 2.20.1 diff --git a/migration/migration.c b/migration/migration.c index 187ac0410c..f89fcba198 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -54,6 +54,7 @@ #include "net/announce.h" #include "qemu/queue.h" #include "multifd.h" +#include "yank.h" #define MAX_THROTTLE (32 << 20) /* Migration transfer speed throttling */ @@ -231,6 +232,8 @@ void migration_incoming_state_destroy(void) qapi_free_SocketAddressList(mis->socket_address_list); mis->socket_address_list = NULL; } + + yank_unregister_instance((char *) "migration"); } static void migrate_generate_event(int new_state) @@ -362,6 +365,7 @@ void qemu_start_incoming_migration(const char *uri, Error **errp) const char *p; qapi_event_send_migration(MIGRATION_STATUS_SETUP); + yank_register_instance((char *) "migration"); if (!strcmp(uri, "defer")) { deferred_incoming_migration(errp); } else if (strstart(uri, "tcp:", &p)) { @@ -377,6 +381,7 @@ void qemu_start_incoming_migration(const char *uri, Error **errp) } else if (strstart(uri, "fd:", &p)) { fd_start_incoming_migration(p, errp); } else { + yank_unregister_instance((char *) "migration"); error_setg(errp, "unknown migration protocol: %s", uri); } } @@ -1632,6 +1637,7 @@ static void migrate_fd_cleanup(MigrationState *s) } notifier_list_notify(&migration_state_notifiers, s); block_cleanup_parameters(s); + yank_unregister_instance((char *) "migration"); } static void migrate_fd_cleanup_schedule(MigrationState *s) @@ -2036,6 +2042,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, return; } + yank_register_instance((char *) "migration"); if (strstart(uri, "tcp:", &p)) { tcp_start_outgoing_migration(s, p, &local_err); #ifdef CONFIG_RDMA @@ -2049,6 +2056,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, } else if (strstart(uri, "fd:", &p)) { fd_start_outgoing_migration(s, p, &local_err); } else { + yank_unregister_instance((char *) "migration"); error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "uri", "a valid migration protocol"); migrate_set_state(&s->state, MIGRATION_STATUS_SETUP, @@ -2058,6 +2066,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, } if (local_err) { + yank_unregister_instance((char *) "migration"); migrate_fd_error(s, local_err); error_propagate(errp, local_err); return; diff --git a/migration/qemu-file-channel.c b/migration/qemu-file-channel.c index d2ce32f4b9..6224bda029 100644 --- a/migration/qemu-file-channel.c +++ b/migration/qemu-file-channel.c @@ -27,6 +27,7 @@ #include "qemu-file.h" #include "io/channel-socket.h" #include "qemu/iov.h" +#include "yank.h" static ssize_t channel_writev_buffer(void *opaque, @@ -104,6 +105,11 @@ static int channel_close(void *opaque, Error **errp) int ret; QIOChannel *ioc = QIO_CHANNEL(opaque); ret = qio_channel_close(ioc, errp); + if (object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_SOCKET) + && OBJECT(ioc)->ref == 2) { + yank_unregister_function((char *) "migration", yank_generic_iochannel, + QIO_CHANNEL(ioc)); + } object_unref(OBJECT(ioc)); return ret; } diff --git a/migration/socket.c b/migration/socket.c index 97c9efde59..bbca53cc49 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -26,6 +26,7 @@ #include "io/channel-socket.h" #include "io/net-listener.h" #include "trace.h" +#include "yank.h" struct SocketOutgoingArgs { @@ -35,6 +36,8 @@ struct SocketOutgoingArgs { void socket_send_channel_create(QIOTaskFunc f, void *data) { QIOChannelSocket *sioc = qio_channel_socket_new(); + yank_register_function((char *) "migration", yank_generic_iochannel, + QIO_CHANNEL(sioc)); qio_channel_socket_connect_async(sioc, outgoing_args.saddr, f, data, NULL, NULL); } @@ -42,6 +45,8 @@ void socket_send_channel_create(QIOTaskFunc f, void *data) int socket_send_channel_destroy(QIOChannel *send) { /* Remove channel */ + yank_unregister_function((char *) "migration", yank_generic_iochannel, + QIO_CHANNEL(send)); object_unref(OBJECT(send)); if (outgoing_args.saddr) { qapi_free_SocketAddress(outgoing_args.saddr); @@ -101,6 +106,8 @@ static void socket_outgoing_migration(QIOTask *task, Error *err = NULL; if (qio_task_propagate_error(task, &err)) { + yank_unregister_function((char *) "migration", yank_generic_iochannel, + QIO_CHANNEL(sioc)); trace_migration_socket_outgoing_error(error_get_pretty(err)); } else { trace_migration_socket_outgoing_connected(data->hostname); @@ -127,6 +134,8 @@ static void socket_start_outgoing_migration(MigrationState *s, } qio_channel_set_name(QIO_CHANNEL(sioc), "migration-socket-outgoing"); + yank_register_function((char *) "migration", yank_generic_iochannel, + QIO_CHANNEL(sioc)); qio_channel_socket_connect_async(sioc, saddr, socket_outgoing_migration, @@ -163,6 +172,8 @@ static void socket_accept_incoming_migration(QIONetListener *listener, trace_migration_socket_incoming_accepted(); qio_channel_set_name(QIO_CHANNEL(cioc), "migration-socket-incoming"); + yank_register_function((char *) "migration", yank_generic_iochannel, + QIO_CHANNEL(cioc)); migration_channel_process_incoming(QIO_CHANNEL(cioc)); if (migration_has_all_channels()) {