From nobody Mon May 13 11:50:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=web.de ARC-Seal: i=1; a=rsa-sha256; t=1609168257; cv=none; d=zohomail.com; s=zohoarc; b=XZqw8n9IEUbY1sSTVPsse50M0thUGqqk82WunfFLUsFg9k22IBDYyyF+x1P9kHiDYkWu8WKT8h1qUIVjx4l4ETySTnS3PsFtrVK2SwujXw/5F3YpHBc9TSYVxgWfSU/4HRTX645EwZBkXiOGFEB4ohqy5qRt+E/KYkvgMSXusD4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609168257; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=p0iho5yI5df7pK1nd+1MGq/AuKz7BLY+yFgYk40yf68=; b=AgZO/WkpFplI8EVWFKo9NXPk0205gp0MVUkkX3h+BjXOgGfHXdCHLA783qcd0fAMzLakED8Xk9rcAFUN/0haxtvUiSzpmqMKjxaBK08McGOpssXJPixOikPtOmmLbYLyWeoZNZDcieHr9lPwMluiMIW9nuGT4T4wmRHprEVZK/0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1609168256999898.2738701142546; Mon, 28 Dec 2020 07:10:56 -0800 (PST) Received: from localhost ([::1]:51362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ktuAh-0005os-DB for importer@patchew.org; Mon, 28 Dec 2020 10:10:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ktu8h-000435-32; Mon, 28 Dec 2020 10:08:51 -0500 Received: from mout.web.de ([212.227.15.14]:40929) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ktu8e-0001Af-Sz; Mon, 28 Dec 2020 10:08:50 -0500 Received: from gecko.fritz.box ([94.134.180.94]) by smtp.web.de (mrweb006 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MLzin-1kbxkJ3txp-00Hbgc; Mon, 28 Dec 2020 16:08:43 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1609168123; bh=oMEdTzgK3MRtvvWbiwxPD80drGYnlQnwkrzZuopySaI=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=nicMcRFnpRqyD7vTvCdRlftkE7RTz4q4pQ2FHcs6mGyJek1NsQJRzTpuOeynvpzIg TVbLT5kLEvuf3q1R42qSga5+kfMDhpuiZoVUwbsrphKOHX+2rCCxiWJAwV15fHWh2K BCqYadQDRAB2rsHtqNkik+0dxgd7a0m29KCT2cQY= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Date: Mon, 28 Dec 2020 16:08:41 +0100 From: Lukas Straub To: qemu-devel Subject: [PATCH v14 1/7] Introduce yank feature Message-ID: <69934ceacfd33a7dfe53db145ecc630ad39ee47c.1609167865.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/U2Qh_ed/bCg_HCgkXKD3M/O"; protocol="application/pgp-signature"; micalg=pgp-sha256 X-Provags-ID: V03:K1:a82/FqpvdF/rT/7r4hPmG+hWTtrdZJhc+dhmXMJvyGD2r83vy0Q EDW1cULokwZaZSh1J5i4NMrWRjZ2wbrZycasUXhW5NHEPC8yc36O3jOWSaj2nf7D53DkYCO SMZ9a9UAyl9a1TUcxLDPOs4rsKZKs//cJKDCuEFmmG6W6GECWfB9rKv9Aiaf9DnlgqvFM5Q VSCK42qWKOHacpBhilt7A== X-UI-Out-Filterresults: notjunk:1;V03:K0:kG4kDpNAXWs=:7BWci5jGYNxqMn7kNWx/v0 BuECJJ6uKQmcntogZ2INCrB6/Ht0cwlwOOrxRKSxRgRk0T4xDMebhkS2N0ZkABp6FO39TfUUw d6kM1o9qCq9tpgLn4ZI3wNbWThYRWILiAXuAeV2F+3x/U3PSOqDgm7YdeVLtSHP7fVz7ys+oo 8BAOP0cmiW7MmKAX0MsSyZ9mtaRuxyhopIiAp3BoQS5TTM7iBkvxtB8EMiJWwq1ps4JY9qAa/ VA645peznBFFxD6dE18LbRpwk+dplNodT04NMvnQ25AryyUXvS5LCQxWwd/rumxV3t5sm82y4 OhR9Srli3NxkCfqj+cUQyUK4WBooXyGt7mx3FlIPrr0YCZtghyFgqYZ/EoO03S8H1+e0aHSGc gc2pD+Xsmqblmorcx7fUsSZeVE7bIu6NHGZUjnkOmA9ivYGSJkL0cQZQFHQFMg08XJ6MAhwqT Tjo56NWHsQqFQnfxqAljVygxBFY/AWOXIJZLsiiNyVDHFYk72fAhKUOwC+IwODZt2yGQUg/mn u/c+aNdyDY3rZtLiK0oH0hmOjPUNeF6n98tQuHnWD0ZJB5/7I7WqvGs0x4Um03EyUK+i9W8me q/3boYyVCzPfpKr9HQehZmq3Cpw4tNG3rpNqzapF4o9GkgV2ZV4lOSPYGQpTEe1T/ITw8F+IT GYoa00eu1Xlt0N8xQZSwXj1B1LaNvmQIo2gLIEmGowGTRbcX23/wGa2Klcfc3QfPhMYu7Ryq0 6X8AA0GlzRdlgijUMsZvkd2i9VoasWArqkW5ta8CxKfXjUHC5faIMHtJDndi0W1+VVN7a+4P/ fkDC+xm5j4zH8OiZC6vlGf9UQobXJMixmV/dMGuSRNkcPS7QcPrQd7/XRCihy/C/uEY1bFB2r A9lcSUhVeRofRU1BJHSDbC4gshp11krnAvaJretuM= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=212.227.15.14; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 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_H2=-0.001, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Kevin Wolf , "Daniel P. =?UTF-8?B?QmVycmFuZ8Op?= =?UTF-8?B?XA==?=" , qemu-block , Juan Quintela , Markus Armbruster , "Dr. David Alan Gilbert" , Max Reitz , =?UTF-8?B?TWFyYy1BbmRyw6k=?= Lureau , Paolo Bonzini , =?UTF-8?B?TWFyYy1BbmRyw6k=?= Lureau Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-Zoho-Virus-Status: 1 X-ZohoMail-DKIM: fail (Header signature does not verify) --Sig_/U2Qh_ed/bCg_HCgkXKD3M/O Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The yank feature allows to recover from hanging qemu by "yanking" at various parts. Other qemu systems can register themselves and multiple yank functions. Then all yank functions for selected instances can be called by the 'yank' out-of-band qmp command. Available instances can be queried by a 'query-yank' oob command. Signed-off-by: Lukas Straub Acked-by: Stefan Hajnoczi Reviewed-by: Markus Armbruster --- MAINTAINERS | 7 ++ include/qemu/yank.h | 97 ++++++++++++++++++++ qapi/meson.build | 1 + qapi/qapi-schema.json | 1 + qapi/yank.json | 119 ++++++++++++++++++++++++ util/meson.build | 1 + util/yank.c | 207 ++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 433 insertions(+) create mode 100644 include/qemu/yank.h create mode 100644 qapi/yank.json create mode 100644 util/yank.c diff --git a/MAINTAINERS b/MAINTAINERS index 1e7c8f0488..f465a4045a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2716,6 +2716,13 @@ F: util/uuid.c F: include/qemu/uuid.h F: tests/test-uuid.c +Yank feature +M: Lukas Straub +S: Odd fixes +F: util/yank.c +F: include/qemu/yank.h +F: qapi/yank.json + COLO Framework M: zhanghailiang S: Maintained diff --git a/include/qemu/yank.h b/include/qemu/yank.h new file mode 100644 index 0000000000..5b93c70cbf --- /dev/null +++ b/include/qemu/yank.h @@ -0,0 +1,97 @@ +/* + * QEMU yank feature + * + * Copyright (c) Lukas Straub + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef YANK_H +#define YANK_H + +#include "qapi/qapi-types-yank.h" + +typedef void (YankFn)(void *opaque); + +/** + * yank_register_instance: Register a new instance. + * + * This registers a new instance for yanking. Must be called before any ya= nk + * function is registered for this instance. + * + * This function is thread-safe. + * + * @instance: The instance. + * @errp: Error object. + * + * Returns true on success or false if an error occured. + */ +bool yank_register_instance(const YankInstance *instance, Error **errp); + +/** + * yank_unregister_instance: Unregister a instance. + * + * This unregisters a instance. Must be called only after every yank funct= ion + * of the instance has been unregistered. + * + * This function is thread-safe. + * + * @instance: The instance. + */ +void yank_unregister_instance(const YankInstance *instance); + +/** + * yank_register_function: Register a yank function + * + * This registers a yank function. All limitations of qmp oob commands app= ly + * to the yank function as well. See docs/devel/qapi-code-gen.txt under + * "An OOB-capable command handler must satisfy the following conditions". + * + * This function is thread-safe. + * + * @instance: The instance. + * @func: The yank function. + * @opaque: Will be passed to the yank function. + */ +void yank_register_function(const YankInstance *instance, + YankFn *func, + void *opaque); + +/** + * yank_unregister_function: Unregister a yank function + * + * This unregisters a yank function. + * + * This function is thread-safe. + * + * @instance: The instance. + * @func: func that was passed to yank_register_function. + * @opaque: opaque that was passed to yank_register_function. + */ +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 =3D YANK_INSTANCE_TYPE_BLOCK_NODE, \ + .u.block_node.node_name =3D (the_node_name) }) + +#define CHARDEV_YANK_INSTANCE(the_id) (&(YankInstance) { \ + .type =3D YANK_INSTANCE_TYPE_CHARDEV, \ + .u.chardev.id =3D (the_id) }) + +#define MIGRATION_YANK_INSTANCE (&(YankInstance) { \ + .type =3D YANK_INSTANCE_TYPE_MIGRATION }) + +#endif diff --git a/qapi/meson.build b/qapi/meson.build index 0e98146f1f..ab68e7900e 100644 --- a/qapi/meson.build +++ b/qapi/meson.build @@ -47,6 +47,7 @@ qapi_all_modules =3D [ 'trace', 'transaction', 'ui', + 'yank', ] qapi_storage_daemon_modules =3D [ diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json index 0b444b76d2..3441c9a9ae 100644 --- a/qapi/qapi-schema.json +++ b/qapi/qapi-schema.json @@ -86,6 +86,7 @@ { 'include': 'machine.json' } { 'include': 'machine-target.json' } { 'include': 'replay.json' } +{ 'include': 'yank.json' } { 'include': 'misc.json' } { 'include': 'misc-target.json' } { 'include': 'audio.json' } diff --git a/qapi/yank.json b/qapi/yank.json new file mode 100644 index 0000000000..167a775594 --- /dev/null +++ b/qapi/yank.json @@ -0,0 +1,119 @@ +# -*- Mode: Python -*- +# vim: filetype=3Dpython +# + +## +# =3D Yank feature +## + +## +# @YankInstanceType: +# +# An enumeration of yank instance types. See @YankInstance for more +# information. +# +# Since: 6.0 +## +{ 'enum': 'YankInstanceType', + 'data': [ 'block-node', 'chardev', 'migration' ] } + +## +# @YankInstanceBlockNode: +# +# Specifies which block graph node to yank. See @YankInstance for more +# information. +# +# @node-name: the name of the block graph node +# +# Since: 6.0 +## +{ 'struct': 'YankInstanceBlockNode', + 'data': { 'node-name': 'str' } } + +## +# @YankInstanceChardev: +# +# Specifies which character device to yank. See @YankInstance for more +# information. +# +# @id: the chardev's ID +# +# Since: 6.0 +## +{ 'struct': 'YankInstanceChardev', + 'data': { 'id': 'str' } } + +## +# @YankInstance: +# +# A yank instance can be yanked with the @yank qmp command to recover from= a +# hanging QEMU. +# +# Currently implemented yank instances: +# - nbd block device: +# Yanking it will shut down the connection to the nbd server without +# attempting to reconnect. +# - socket chardev: +# Yanking it will shut down the connected socket. +# - migration: +# Yanking it will shut down all migration connections. Unlike +# @migrate_cancel, it will not notify the migration process, so migrati= on +# will go into @failed state, instead of @cancelled state. @yank should= be +# used to recover from hangs. +# +# Since: 6.0 +## +{ 'union': 'YankInstance', + 'base': { 'type': 'YankInstanceType' }, + 'discriminator': 'type', + 'data': { + 'block-node': 'YankInstanceBlockNode', + 'chardev': 'YankInstanceChardev' } } + +## +# @yank: +# +# Try to recover from hanging QEMU by yanking the specified instances. See +# @YankInstance for more information. +# +# Takes a list of @YankInstance as argument. +# +# Returns: - Nothing on success +# - @DeviceNotFound error, if any of the YankInstances doesn't ex= ist +# +# Example: +# +# -> { "execute": "yank", +# "arguments": { +# "instances": [ +# { "type": "block-node", +# "node-name": "nbd0" } +# ] } } +# <- { "return": {} } +# +# Since: 6.0 +## +{ 'command': 'yank', + 'data': { 'instances': ['YankInstance'] }, + 'allow-oob': true } + +## +# @query-yank: +# +# Query yank instances. See @YankInstance for more information. +# +# Returns: list of @YankInstance +# +# Example: +# +# -> { "execute": "query-yank" } +# <- { "return": [ +# { "type": "block-node", +# "node-name": "nbd0" } +# ] } +# +# Since: 6.0 +## +{ 'command': 'query-yank', + 'returns': ['YankInstance'], + 'allow-oob': true } diff --git a/util/meson.build b/util/meson.build index f359af0d46..f7c67344e1 100644 --- a/util/meson.build +++ b/util/meson.build @@ -50,6 +50,7 @@ endif if have_system util_ss.add(when: 'CONFIG_GIO', if_true: [files('dbus.c'), gio]) + util_ss.add(files('yank.c')) endif if have_block diff --git a/util/yank.c b/util/yank.c new file mode 100644 index 0000000000..fc08f65209 --- /dev/null +++ b/util/yank.c @@ -0,0 +1,207 @@ +/* + * QEMU yank feature + * + * Copyright (c) Lukas Straub + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu/thread.h" +#include "qemu/queue.h" +#include "qemu/lockable.h" +#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 { + YankFn *func; + void *opaque; + QLIST_ENTRY(YankFuncAndParam) next; +}; + +struct YankInstanceEntry { + YankInstance *instance; + QLIST_HEAD(, YankFuncAndParam) yankfns; + QLIST_ENTRY(YankInstanceEntry) next; +}; + +typedef struct YankFuncAndParam YankFuncAndParam; +typedef struct YankInstanceEntry YankInstanceEntry; + +/* + * This lock protects the yank_instance_list below. Because it's taken by + * OOB-capable commands, it must be "fast", i.e. it may only be held for a + * bounded, short time. See docs/devel/qapi-code-gen.txt for additional + * information. + */ +static QemuMutex yank_lock; + +static QLIST_HEAD(, YankInstanceEntry) yank_instance_list + =3D QLIST_HEAD_INITIALIZER(yank_instance_list); + +static bool yank_instance_equal(const YankInstance *a, const YankInstance = *b) +{ + if (a->type !=3D b->type) { + return false; + } + + switch (a->type) { + case YANK_INSTANCE_TYPE_BLOCK_NODE: + return g_str_equal(a->u.block_node.node_name, + b->u.block_node.node_name); + + case YANK_INSTANCE_TYPE_CHARDEV: + return g_str_equal(a->u.chardev.id, b->u.chardev.id); + + case YANK_INSTANCE_TYPE_MIGRATION: + return true; + + default: + abort(); + } +} + +static YankInstanceEntry *yank_find_entry(const YankInstance *instance) +{ + YankInstanceEntry *entry; + + QLIST_FOREACH(entry, &yank_instance_list, next) { + if (yank_instance_equal(entry->instance, instance)) { + return entry; + } + } + return NULL; +} + +bool yank_register_instance(const YankInstance *instance, Error **errp) +{ + YankInstanceEntry *entry; + + QEMU_LOCK_GUARD(&yank_lock); + + if (yank_find_entry(instance)) { + error_setg(errp, "duplicate yank instance"); + return false; + } + + entry =3D g_new0(YankInstanceEntry, 1); + entry->instance =3D QAPI_CLONE(YankInstance, instance); + QLIST_INIT(&entry->yankfns); + QLIST_INSERT_HEAD(&yank_instance_list, entry, next); + + return true; +} + +void yank_unregister_instance(const YankInstance *instance) +{ + YankInstanceEntry *entry; + + QEMU_LOCK_GUARD(&yank_lock); + entry =3D yank_find_entry(instance); + assert(entry); + + assert(QLIST_EMPTY(&entry->yankfns)); + QLIST_REMOVE(entry, next); + qapi_free_YankInstance(entry->instance); + g_free(entry); +} + +void yank_register_function(const YankInstance *instance, + YankFn *func, + void *opaque) +{ + YankInstanceEntry *entry; + YankFuncAndParam *func_entry; + + QEMU_LOCK_GUARD(&yank_lock); + entry =3D yank_find_entry(instance); + assert(entry); + + func_entry =3D g_new0(YankFuncAndParam, 1); + func_entry->func =3D func; + func_entry->opaque =3D opaque; + + QLIST_INSERT_HEAD(&entry->yankfns, func_entry, next); +} + +void yank_unregister_function(const YankInstance *instance, + YankFn *func, + void *opaque) +{ + YankInstanceEntry *entry; + YankFuncAndParam *func_entry; + + QEMU_LOCK_GUARD(&yank_lock); + entry =3D yank_find_entry(instance); + assert(entry); + + QLIST_FOREACH(func_entry, &entry->yankfns, next) { + if (func_entry->func =3D=3D func && func_entry->opaque =3D=3D opaq= ue) { + QLIST_REMOVE(func_entry, next); + g_free(func_entry); + return; + } + } + + abort(); +} + +void yank_generic_iochannel(void *opaque) +{ + QIOChannel *ioc =3D QIO_CHANNEL(opaque); + + qio_channel_shutdown(ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL); +} + +void qmp_yank(YankInstanceList *instances, + Error **errp) +{ + YankInstanceList *tail; + YankInstanceEntry *entry; + YankFuncAndParam *func_entry; + + QEMU_LOCK_GUARD(&yank_lock); + for (tail =3D instances; tail; tail =3D tail->next) { + entry =3D yank_find_entry(tail->value); + if (!entry) { + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, "Instance not fo= und"); + return; + } + } + for (tail =3D instances; tail; tail =3D tail->next) { + entry =3D yank_find_entry(tail->value); + assert(entry); + QLIST_FOREACH(func_entry, &entry->yankfns, next) { + func_entry->func(func_entry->opaque); + } + } +} + +YankInstanceList *qmp_query_yank(Error **errp) +{ + YankInstanceEntry *entry; + YankInstanceList *ret; + + ret =3D NULL; + + QEMU_LOCK_GUARD(&yank_lock); + QLIST_FOREACH(entry, &yank_instance_list, next) { + YankInstanceList *new_entry; + new_entry =3D g_new0(YankInstanceList, 1); + new_entry->value =3D QAPI_CLONE(YankInstance, entry->instance); + new_entry->next =3D ret; + ret =3D new_entry; + } + + return ret; +} + +static void __attribute__((__constructor__)) yank_init(void) +{ + qemu_mutex_init(&yank_lock); +} -- 2.29.2 --Sig_/U2Qh_ed/bCg_HCgkXKD3M/O Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEg/qxWKDZuPtyYo+kNasLKJxdslgFAl/p9PkACgkQNasLKJxd slhRBA/+JLk9u/SKq1FgLa4e2YbrLO6RV0PJZ24rIcS4nx45S1NMxNbRaThQ8KeQ r8DOr/aVtyfijMR7RAh/DuuNmt0NRqKXWApO7zAJcdF09KTBzn87WrBpeWIwGyZ0 cd/wCKtPjmP7FxLq6yQJ42Q+IaXjxIL+UH1Q81UPhTPrWjIEa/sbg9N/MuzWBkWP ht5CZ2SSjUHUU+oCgK1ZwWNs7TJ0ZJJRG92lGVQyZB01UIUCMx2oHITJz+psz90d yMZ/l35ISgixthB/LLzpVmyyE1GFxC+2KsgmbdZYxFkzMEbhqCbgVvhw438/sce4 m9FJ50/jCqKWx2Me13nWxYSFZUST89xgr/scYqrCmAP6c4WNYEhVzm6niii4Yl/a 1Do/kG+HkmniguTbHxPuDhtCjRcZWhFdVMST6NvvBoB5zknmNk5OgPbnD5/NDp/d vf4iBvLdeOiZOyrJBkltXYgZYQs818mqfk0vobyZzQ8bl+enpvpgJl9XCppHjZel 8nj2943YfoZcVTTD9zVd7rztRVy0kd0u8HLdKeLbWWpu+22ldpX3Ej7YK8FGFdKi 7Qyg7YXzKHaU5umhF9KZe8N5mzvBhn6Xqy26Azf8r8Pd9GeOhiawDiYGweMFbwKi iFU044AEbBXD32V9bmICW+1nbpkpNjIG3mCzPNiQbMYOfpwt8uU= =jtrm -----END PGP SIGNATURE----- --Sig_/U2Qh_ed/bCg_HCgkXKD3M/O-- From nobody Mon May 13 11:50:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=web.de ARC-Seal: i=1; a=rsa-sha256; t=1609168260; cv=none; d=zohomail.com; s=zohoarc; b=JwCAD1FDpqa9uIMtHDaRMvtikJcKBEZQu66RVuRr6x62hCZCAAQtfunosLWtpbze+gFgam7ThN8n9Wwv4GHBnSsvryN1h9AxRhvu2NOS/DQ/SXhgZYvnHxe/zvLH7dm5mPFtl34pnE0IEPkuW8CueYD/PIQZHIwr96euj9bt21A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609168260; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4PsKMlJsF1ocYy3Zl2WIh5dB0TaqU+Oi2zcxtC5dcq8=; b=dx6xhg8evUfIYlPgqjMRlgiOhxCxV8grFoftl0H8+rei+JWWFQyl2ZI3BvPgF55UCslIh70yK64dpCNYt9mwYvSCrQEMKRhkrVcwTiXvado/4CoIuIvDD+uRBldpmzjWHm47HhIu9d3KC3i1m7j1FHpK5a7FQAJhpIbVLXBgK5k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1609168260121579.0941727729594; Mon, 28 Dec 2020 07:11:00 -0800 (PST) Received: from localhost ([::1]:51576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ktuAl-00060V-8y for importer@patchew.org; Mon, 28 Dec 2020 10:10:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49554) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ktu8k-00044G-Jp; Mon, 28 Dec 2020 10:08:54 -0500 Received: from mout.web.de ([212.227.15.4]:54491) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ktu8i-0001Bd-Ec; Mon, 28 Dec 2020 10:08:54 -0500 Received: from gecko.fritz.box ([94.134.180.94]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MTh7A-1kTP1a1eNs-00QT5C; Mon, 28 Dec 2020 16:08:46 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1609168126; bh=HzJdhmVKC4KNQt1uEyNiaVmwoYST+6gQY5ZOC83n5lE=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=pOsIRxXNIKwXS3PIQ+D0mmODii/XPTTmFP/KAHIG8INcUMygc5Fss27QvigrnJt0E PCn4ZzUHsNT8OOmpdNAZGw64gVXWfld1VBi81Ag2R+/bQZOxYjdnQaklC8UGk/ycqm b8Cf5cZ29b3DLLOxOT5BiFMUuNCAlNCu4fzBYL9Q= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Date: Mon, 28 Dec 2020 16:08:44 +0100 From: Lukas Straub To: qemu-devel Subject: [PATCH v14 2/7] block/nbd.c: Add yank feature Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/0YkvLzqCyewAp/5R/Kw6tLE"; protocol="application/pgp-signature"; micalg=pgp-sha256 X-Provags-ID: V03:K1:faNgCXv9vKdC3sVL4tqCIKxeYlcuZ39FMV0auKunkXaVK84qlEl JUjU9QZc7ozKzm+k2qP0Jp6ULPddSiS4WlsW/exk7svAeNgK1ncQoI+RNVikRhEnv8Yqra0 UasjuAh7ie40Jl/MuRAciQSLPpJcwvpOVD5TCfLJ1fT2ijNfch3MG8x1lxF0NGSr/C/pWVT 2qjHGY9waMd6r4dgNII6w== X-UI-Out-Filterresults: notjunk:1;V03:K0:yI3/ajjI1Zg=:VQQotbtzV4ajs4KcjHlkjh z3WHmCf6YKFufu7QeHL/zIrw31MwW/Cwerjcqv6Pkao8umxoKrBgSbqne65YIkrVhwKDRCOtf UfV5DO+1Oeg9lDX1w0jjnC9OyZk2ZxgKhPsagGF43h5t2N1QRvdGLRCNZobRklszrJ1cEFyaZ T288LgeYWDvcdvfAGckcrlffpvK3jDHOALG661iqiLY/p5DcxhH9Y8taJ2bWA9GKmt0aXUJ4r KsUTUEg0AtmAk8ERvkyCCqWptyjvHPzStBdA/IDVNmcgmQYaXnU+PiTO8zauiFpyD++Xbqxs4 1XIqD9L1VCQJUBWCOT+1zHH0vAttcemauZG46en3XnmxCexi8osz8+DhGiFkoP0AQgC9rpYfE fv9voqZQqT1Zhqtx/7nUVZMrumYiArm2LlxTxV7+DakkjkhDpgD0P+vusoM2pnZEpPcr6AyZQ HJi8q2zpqVTpAq3vLACm0MraDEYIfbtzL90XCwItNDZoeVqiDp5NCf7gz+p1X9pyN4nsfDs50 rC9MtU3NiDNPa3bNZz/aVCets6Fem3Q2TWokICEPO6T1Z79TAaaIo2IKPtVgJEiqBkjFxZ9Cu TMKVn5Ku+L+g//EGUM2sOlTMcIcm8U25Vhqz2lpyCFF0dTMIOqI5AvR/Ebn+UsUMxxjUax9lC zrvxG/+J7PxXxv6Ad5uLyaUXgo3Xx2aL9mxJKHS+ZYC7t+jOcH7pLSJkT0/wrCkJ3vznx/QWY 8tMZ1mOJV9YxB+Zhur3e0orCUeBE4oVy9gJXU82gnY8UeYn2JM8npS9LUQFcX4SCCJOeR3zZu 3vQgv6T87vnkpNAeOJ8ktu/AObzKk4Rbw7fODBR0177gZKYHIWDf2MaFVYS8FtGgNI2NfCtFM v11PI9AeSIR6Dl79R3SenGBpJM/Ho/bM2Fxuna7V8= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=212.227.15.4; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 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, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Kevin Wolf , "Daniel P. =?UTF-8?B?QmVycmFuZ8Op?= =?UTF-8?B?XA==?=" , qemu-block , Juan Quintela , Markus Armbruster , "Dr. David Alan Gilbert" , Max Reitz , =?UTF-8?B?TWFyYy1BbmRyw6k=?= Lureau , Paolo Bonzini , =?UTF-8?B?TWFyYy1BbmRyw6k=?= Lureau Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-Zoho-Virus-Status: 1 X-ZohoMail-DKIM: fail (Header signature does not verify) --Sig_/0YkvLzqCyewAp/5R/Kw6tLE Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Register a yank function which shuts down the socket and sets s->state =3D NBD_CLIENT_QUIT. This is the same behaviour as if an error occured. Signed-off-by: Lukas Straub Acked-by: Stefan Hajnoczi Reviewed-by: Eric Blake --- block/nbd.c | 153 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 92 insertions(+), 61 deletions(-) diff --git a/block/nbd.c b/block/nbd.c index 42536702b6..0f8d17db6a 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -35,6 +35,7 @@ #include "qemu/option.h" #include "qemu/cutils.h" #include "qemu/main-loop.h" +#include "qemu/atomic.h" #include "qapi/qapi-visit-sockets.h" #include "qapi/qmp/qstring.h" @@ -44,6 +45,8 @@ #include "block/nbd.h" #include "block/block_int.h" +#include "qemu/yank.h" + #define EN_OPTSTR ":exportname=3D" #define MAX_NBD_REQUESTS 16 @@ -141,14 +144,13 @@ typedef struct BDRVNBDState { NBDConnectThread *connect_thread; } BDRVNBDState; -static QIOChannelSocket *nbd_establish_connection(SocketAddress *saddr, - Error **errp); -static QIOChannelSocket *nbd_co_establish_connection(BlockDriverState *bs, - Error **errp); +static int nbd_establish_connection(BlockDriverState *bs, SocketAddress *s= addr, + Error **errp); +static int nbd_co_establish_connection(BlockDriverState *bs, Error **errp); static void nbd_co_establish_connection_cancel(BlockDriverState *bs, bool detach); -static int nbd_client_handshake(BlockDriverState *bs, QIOChannelSocket *si= oc, - Error **errp); +static int nbd_client_handshake(BlockDriverState *bs, Error **errp); +static void nbd_yank(void *opaque); static void nbd_clear_bdrvstate(BDRVNBDState *s) { @@ -166,12 +168,12 @@ static void nbd_clear_bdrvstate(BDRVNBDState *s) static void nbd_channel_error(BDRVNBDState *s, int ret) { if (ret =3D=3D -EIO) { - if (s->state =3D=3D NBD_CLIENT_CONNECTED) { + if (qatomic_load_acquire(&s->state) =3D=3D NBD_CLIENT_CONNECTED) { s->state =3D s->reconnect_delay ? NBD_CLIENT_CONNECTING_WAIT : NBD_CLIENT_CONNECTING_NOWAIT; } } else { - if (s->state =3D=3D NBD_CLIENT_CONNECTED) { + if (qatomic_load_acquire(&s->state) =3D=3D NBD_CLIENT_CONNECTED) { qio_channel_shutdown(s->ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL); } s->state =3D NBD_CLIENT_QUIT; @@ -204,7 +206,7 @@ static void reconnect_delay_timer_cb(void *opaque) { BDRVNBDState *s =3D opaque; - if (s->state =3D=3D NBD_CLIENT_CONNECTING_WAIT) { + if (qatomic_load_acquire(&s->state) =3D=3D NBD_CLIENT_CONNECTING_WAIT)= { s->state =3D NBD_CLIENT_CONNECTING_NOWAIT; while (qemu_co_enter_next(&s->free_sema, NULL)) { /* Resume all queued requests */ @@ -216,7 +218,7 @@ static void reconnect_delay_timer_cb(void *opaque) static void reconnect_delay_timer_init(BDRVNBDState *s, uint64_t expire_ti= me_ns) { - if (s->state !=3D NBD_CLIENT_CONNECTING_WAIT) { + if (qatomic_load_acquire(&s->state) !=3D NBD_CLIENT_CONNECTING_WAIT) { return; } @@ -261,7 +263,7 @@ static void nbd_client_attach_aio_context(BlockDriverSt= ate *bs, * s->connection_co is either yielded from nbd_receive_reply or from * nbd_co_reconnect_loop() */ - if (s->state =3D=3D NBD_CLIENT_CONNECTED) { + if (qatomic_load_acquire(&s->state) =3D=3D NBD_CLIENT_CONNECTED) { qio_channel_attach_aio_context(QIO_CHANNEL(s->ioc), new_context); } @@ -287,7 +289,7 @@ static void coroutine_fn nbd_client_co_drain_begin(Bloc= kDriverState *bs) reconnect_delay_timer_del(s); - if (s->state =3D=3D NBD_CLIENT_CONNECTING_WAIT) { + if (qatomic_load_acquire(&s->state) =3D=3D NBD_CLIENT_CONNECTING_WAIT)= { s->state =3D NBD_CLIENT_CONNECTING_NOWAIT; qemu_co_queue_restart_all(&s->free_sema); } @@ -338,13 +340,14 @@ static void nbd_teardown_connection(BlockDriverState = *bs) static bool nbd_client_connecting(BDRVNBDState *s) { - return s->state =3D=3D NBD_CLIENT_CONNECTING_WAIT || - s->state =3D=3D NBD_CLIENT_CONNECTING_NOWAIT; + NBDClientState state =3D qatomic_load_acquire(&s->state); + return state =3D=3D NBD_CLIENT_CONNECTING_WAIT || + state =3D=3D NBD_CLIENT_CONNECTING_NOWAIT; } static bool nbd_client_connecting_wait(BDRVNBDState *s) { - return s->state =3D=3D NBD_CLIENT_CONNECTING_WAIT; + return qatomic_load_acquire(&s->state) =3D=3D NBD_CLIENT_CONNECTING_WA= IT; } static void connect_bh(void *opaque) @@ -424,12 +427,12 @@ static void *connect_thread_func(void *opaque) return NULL; } -static QIOChannelSocket *coroutine_fn +static int coroutine_fn nbd_co_establish_connection(BlockDriverState *bs, Error **errp) { + int ret; QemuThread thread; BDRVNBDState *s =3D bs->opaque; - QIOChannelSocket *res; NBDConnectThread *thr =3D s->connect_thread; qemu_mutex_lock(&thr->mutex); @@ -446,10 +449,12 @@ nbd_co_establish_connection(BlockDriverState *bs, Err= or **errp) case CONNECT_THREAD_SUCCESS: /* Previous attempt finally succeeded in background */ thr->state =3D CONNECT_THREAD_NONE; - res =3D thr->sioc; + s->sioc =3D thr->sioc; thr->sioc =3D NULL; + yank_register_function(BLOCKDEV_YANK_INSTANCE(bs->node_name), + nbd_yank, bs); qemu_mutex_unlock(&thr->mutex); - return res; + return 0; case CONNECT_THREAD_RUNNING: /* Already running, will wait */ break; @@ -481,8 +486,13 @@ nbd_co_establish_connection(BlockDriverState *bs, Erro= r **errp) thr->state =3D CONNECT_THREAD_NONE; error_propagate(errp, thr->err); thr->err =3D NULL; - res =3D thr->sioc; + s->sioc =3D thr->sioc; thr->sioc =3D NULL; + if (s->sioc) { + yank_register_function(BLOCKDEV_YANK_INSTANCE(bs->node_name), + nbd_yank, bs); + } + ret =3D (s->sioc ? 0 : -1); break; case CONNECT_THREAD_RUNNING: case CONNECT_THREAD_RUNNING_DETACHED: @@ -491,7 +501,7 @@ nbd_co_establish_connection(BlockDriverState *bs, Error= **errp) * failed. Still connect thread is executing in background, and its * result may be used for next connection attempt. */ - res =3D NULL; + ret =3D -1; error_setg(errp, "Connection attempt cancelled by other operation"= ); break; @@ -508,7 +518,7 @@ nbd_co_establish_connection(BlockDriverState *bs, Error= **errp) qemu_mutex_unlock(&thr->mutex); - return res; + return ret; } /* @@ -561,7 +571,6 @@ static coroutine_fn void nbd_reconnect_attempt(BDRVNBDS= tate *s) { int ret; Error *local_err =3D NULL; - QIOChannelSocket *sioc; if (!nbd_client_connecting(s)) { return; @@ -594,21 +603,22 @@ static coroutine_fn void nbd_reconnect_attempt(BDRVNB= DState *s) /* Finalize previous connection if any */ if (s->ioc) { qio_channel_detach_aio_context(QIO_CHANNEL(s->ioc)); + yank_unregister_function(BLOCKDEV_YANK_INSTANCE(s->bs->node_name), + nbd_yank, s->bs); object_unref(OBJECT(s->sioc)); s->sioc =3D NULL; object_unref(OBJECT(s->ioc)); s->ioc =3D NULL; } - sioc =3D nbd_co_establish_connection(s->bs, &local_err); - if (!sioc) { + if (nbd_co_establish_connection(s->bs, &local_err) < 0) { ret =3D -ECONNREFUSED; goto out; } bdrv_dec_in_flight(s->bs); - ret =3D nbd_client_handshake(s->bs, sioc, &local_err); + ret =3D nbd_client_handshake(s->bs, &local_err); if (s->drained) { s->wait_drained_end =3D true; @@ -640,7 +650,7 @@ static coroutine_fn void nbd_co_reconnect_loop(BDRVNBDS= tate *s) uint64_t timeout =3D 1 * NANOSECONDS_PER_SECOND; uint64_t max_timeout =3D 16 * NANOSECONDS_PER_SECOND; - if (s->state =3D=3D NBD_CLIENT_CONNECTING_WAIT) { + if (qatomic_load_acquire(&s->state) =3D=3D NBD_CLIENT_CONNECTING_WAIT)= { reconnect_delay_timer_init(s, qemu_clock_get_ns(QEMU_CLOCK_REALTIM= E) + s->reconnect_delay * NANOSECONDS_PER_SE= COND); } @@ -683,7 +693,7 @@ static coroutine_fn void nbd_connection_entry(void *opa= que) int ret =3D 0; Error *local_err =3D NULL; - while (s->state !=3D NBD_CLIENT_QUIT) { + while (qatomic_load_acquire(&s->state) !=3D NBD_CLIENT_QUIT) { /* * The NBD client can only really be considered idle when it has * yielded from qio_channel_readv_all_eof(), waiting for data. Thi= s is @@ -698,7 +708,7 @@ static coroutine_fn void nbd_connection_entry(void *opa= que) nbd_co_reconnect_loop(s); } - if (s->state !=3D NBD_CLIENT_CONNECTED) { + if (qatomic_load_acquire(&s->state) !=3D NBD_CLIENT_CONNECTED) { continue; } @@ -753,6 +763,8 @@ static coroutine_fn void nbd_connection_entry(void *opa= que) s->connection_co =3D NULL; if (s->ioc) { qio_channel_detach_aio_context(QIO_CHANNEL(s->ioc)); + yank_unregister_function(BLOCKDEV_YANK_INSTANCE(s->bs->node_name), + nbd_yank, s->bs); object_unref(OBJECT(s->sioc)); s->sioc =3D NULL; object_unref(OBJECT(s->ioc)); @@ -777,7 +789,7 @@ static int nbd_co_send_request(BlockDriverState *bs, qemu_co_queue_wait(&s->free_sema, &s->send_mutex); } - if (s->state !=3D NBD_CLIENT_CONNECTED) { + if (qatomic_load_acquire(&s->state) !=3D NBD_CLIENT_CONNECTED) { rc =3D -EIO; goto err; } @@ -804,7 +816,8 @@ static int nbd_co_send_request(BlockDriverState *bs, if (qiov) { qio_channel_set_cork(s->ioc, true); rc =3D nbd_send_request(s->ioc, request); - if (rc >=3D 0 && s->state =3D=3D NBD_CLIENT_CONNECTED) { + if (qatomic_load_acquire(&s->state) =3D=3D NBD_CLIENT_CONNECTED && + rc >=3D 0) { if (qio_channel_writev_all(s->ioc, qiov->iov, qiov->niov, NULL) < 0) { rc =3D -EIO; @@ -1129,7 +1142,7 @@ static coroutine_fn int nbd_co_do_receive_one_chunk( s->requests[i].receiving =3D true; qemu_coroutine_yield(); s->requests[i].receiving =3D false; - if (s->state !=3D NBD_CLIENT_CONNECTED) { + if (qatomic_load_acquire(&s->state) !=3D NBD_CLIENT_CONNECTED) { error_setg(errp, "Connection closed"); return -EIO; } @@ -1288,7 +1301,7 @@ static bool nbd_reply_chunk_iter_receive(BDRVNBDState= *s, NBDReply local_reply; NBDStructuredReplyChunk *chunk; Error *local_err =3D NULL; - if (s->state !=3D NBD_CLIENT_CONNECTED) { + if (qatomic_load_acquire(&s->state) !=3D NBD_CLIENT_CONNECTED) { error_setg(&local_err, "Connection closed"); nbd_iter_channel_error(iter, -EIO, &local_err); goto break_loop; @@ -1313,7 +1326,8 @@ static bool nbd_reply_chunk_iter_receive(BDRVNBDState= *s, } /* Do not execute the body of NBD_FOREACH_REPLY_CHUNK for simple reply= . */ - if (nbd_reply_is_simple(reply) || s->state !=3D NBD_CLIENT_CONNECTED) { + if (nbd_reply_is_simple(reply) || + qatomic_load_acquire(&s->state) !=3D NBD_CLIENT_CONNECTED) { goto break_loop; } @@ -1745,6 +1759,15 @@ static int nbd_client_reopen_prepare(BDRVReopenState= *state, return 0; } +static void nbd_yank(void *opaque) +{ + BlockDriverState *bs =3D opaque; + BDRVNBDState *s =3D (BDRVNBDState *)bs->opaque; + + qatomic_store_release(&s->state, NBD_CLIENT_QUIT); + qio_channel_shutdown(QIO_CHANNEL(s->sioc), QIO_CHANNEL_SHUTDOWN_BOTH, = NULL); +} + static void nbd_client_close(BlockDriverState *bs) { BDRVNBDState *s =3D (BDRVNBDState *)bs->opaque; @@ -1757,52 +1780,53 @@ static void nbd_client_close(BlockDriverState *bs) nbd_teardown_connection(bs); } -static QIOChannelSocket *nbd_establish_connection(SocketAddress *saddr, - Error **errp) +static int nbd_establish_connection(BlockDriverState *bs, + SocketAddress *saddr, + Error **errp) { ERRP_GUARD(); - QIOChannelSocket *sioc; + BDRVNBDState *s =3D (BDRVNBDState *)bs->opaque; - sioc =3D qio_channel_socket_new(); - qio_channel_set_name(QIO_CHANNEL(sioc), "nbd-client"); + s->sioc =3D qio_channel_socket_new(); + qio_channel_set_name(QIO_CHANNEL(s->sioc), "nbd-client"); - qio_channel_socket_connect_sync(sioc, saddr, errp); + qio_channel_socket_connect_sync(s->sioc, saddr, errp); if (*errp) { - object_unref(OBJECT(sioc)); - return NULL; + object_unref(OBJECT(s->sioc)); + s->sioc =3D NULL; + return -1; } - qio_channel_set_delay(QIO_CHANNEL(sioc), false); + yank_register_function(BLOCKDEV_YANK_INSTANCE(bs->node_name), nbd_yank= , bs); + qio_channel_set_delay(QIO_CHANNEL(s->sioc), false); - return sioc; + return 0; } -/* nbd_client_handshake takes ownership on sioc. On failure it is unref'ed= . */ -static int nbd_client_handshake(BlockDriverState *bs, QIOChannelSocket *si= oc, - Error **errp) +/* nbd_client_handshake takes ownership on s->sioc. On failure it's unref'= ed. */ +static int nbd_client_handshake(BlockDriverState *bs, Error **errp) { BDRVNBDState *s =3D (BDRVNBDState *)bs->opaque; AioContext *aio_context =3D bdrv_get_aio_context(bs); int ret; trace_nbd_client_handshake(s->export); - - s->sioc =3D sioc; - - qio_channel_set_blocking(QIO_CHANNEL(sioc), false, NULL); - qio_channel_attach_aio_context(QIO_CHANNEL(sioc), aio_context); + qio_channel_set_blocking(QIO_CHANNEL(s->sioc), false, NULL); + qio_channel_attach_aio_context(QIO_CHANNEL(s->sioc), aio_context); s->info.request_sizes =3D true; s->info.structured_reply =3D true; s->info.base_allocation =3D true; s->info.x_dirty_bitmap =3D g_strdup(s->x_dirty_bitmap); s->info.name =3D g_strdup(s->export ?: ""); - ret =3D nbd_receive_negotiate(aio_context, QIO_CHANNEL(sioc), s->tlscr= eds, + ret =3D nbd_receive_negotiate(aio_context, QIO_CHANNEL(s->sioc), s->tl= screds, s->hostname, &s->ioc, &s->info, errp); g_free(s->info.x_dirty_bitmap); g_free(s->info.name); if (ret < 0) { - object_unref(OBJECT(sioc)); + yank_unregister_function(BLOCKDEV_YANK_INSTANCE(bs->node_name), + nbd_yank, bs); + object_unref(OBJECT(s->sioc)); s->sioc =3D NULL; return ret; } @@ -1835,7 +1859,7 @@ static int nbd_client_handshake(BlockDriverState *bs,= QIOChannelSocket *sioc, } if (!s->ioc) { - s->ioc =3D QIO_CHANNEL(sioc); + s->ioc =3D QIO_CHANNEL(s->sioc); object_ref(OBJECT(s->ioc)); } @@ -1851,9 +1875,11 @@ static int nbd_client_handshake(BlockDriverState *bs= , QIOChannelSocket *sioc, { NBDRequest request =3D { .type =3D NBD_CMD_DISC }; - nbd_send_request(s->ioc ?: QIO_CHANNEL(sioc), &request); + nbd_send_request(s->ioc ?: QIO_CHANNEL(s->sioc), &request); - object_unref(OBJECT(sioc)); + yank_unregister_function(BLOCKDEV_YANK_INSTANCE(bs->node_name), + nbd_yank, bs); + object_unref(OBJECT(s->sioc)); s->sioc =3D NULL; return ret; @@ -2245,7 +2271,6 @@ static int nbd_open(BlockDriverState *bs, QDict *opti= ons, int flags, { int ret; BDRVNBDState *s =3D (BDRVNBDState *)bs->opaque; - QIOChannelSocket *sioc; ret =3D nbd_process_options(bs, options, errp); if (ret < 0) { @@ -2256,17 +2281,22 @@ static int nbd_open(BlockDriverState *bs, QDict *op= tions, int flags, qemu_co_mutex_init(&s->send_mutex); qemu_co_queue_init(&s->free_sema); + if (!yank_register_instance(BLOCKDEV_YANK_INSTANCE(bs->node_name), err= p)) { + return -EEXIST; + } + /* * establish TCP connection, return error if it fails * TODO: Configurable retry-until-timeout behaviour. */ - sioc =3D nbd_establish_connection(s->saddr, errp); - if (!sioc) { + if (nbd_establish_connection(bs, s->saddr, errp) < 0) { + yank_unregister_instance(BLOCKDEV_YANK_INSTANCE(bs->node_name)); return -ECONNREFUSED; } - ret =3D nbd_client_handshake(bs, sioc, errp); + ret =3D nbd_client_handshake(bs, errp); if (ret < 0) { + yank_unregister_instance(BLOCKDEV_YANK_INSTANCE(bs->node_name)); nbd_clear_bdrvstate(s); return ret; } @@ -2326,6 +2356,7 @@ static void nbd_close(BlockDriverState *bs) BDRVNBDState *s =3D bs->opaque; nbd_client_close(bs); + yank_unregister_instance(BLOCKDEV_YANK_INSTANCE(bs->node_name)); nbd_clear_bdrvstate(s); } -- 2.29.2 --Sig_/0YkvLzqCyewAp/5R/Kw6tLE Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEg/qxWKDZuPtyYo+kNasLKJxdslgFAl/p9PwACgkQNasLKJxd slgOBA/8CANcXgkSGyh2+N8+Y1nBtugWa40asbELzzrbBVRO3WRxr5GOVrWb0loW xS28MvWxjkUhFVFa5kv0Q+V0dS7b3ZwOvCwbDIwa8Ug2pu0b5RFWZ43MzHjRQ3Gh 2ZmskOK4mrDcWq1ZcYM7KU2RxP+zMQBKzGgS3lnBz0RijeB1xZnSjMlJQHjbyjag GMFUQeoPUCAZdAqeGM98jzNGMvhyFK7ns9Bg0Bfpe1DTrKsTUvpPYXTNJ1e0YIhb yGcPklwwvWWLhgZC9LAHjqGu9MWgwm++EPEtFfqXBHRPkSJDSMoWF9npbDOjqfDo WyoGKpf4d2gMnKoZxn9TeWUXANxMEx74yOQ83SHoFOFXQLBvgL9i/3R3ECPYlLGX BSJ/qJS3Pyh3GKjBZ0LAsepFZrtqslg6KZnejfIFcE7UIAkrRkp7aK/+X48ywM/C ozicRBLKCJ1JAm6fVaWgu9K3ZOc4b23+S3o7h7Z5MAoiV+et1dyuz0TCden+Mvba j4UtJTQ3/wl/CJu8bI5ST+yHXoXzPO3LxjRGpWQRLxqc7M7DqhQ5sKT3Tx88CJ3F BSpm3brRxDDzDtt2Nw7T9/4qJgLA6IeZbBSKzthhgX19QwyNtO+e9KPC3V0lGgH6 BJBSy4zjai7Woe5whn+BqKfi1NgCSwfxltpoPGBnrGxrC7wB0jc= =FUWp -----END PGP SIGNATURE----- --Sig_/0YkvLzqCyewAp/5R/Kw6tLE-- From nobody Mon May 13 11:50:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=web.de ARC-Seal: i=1; a=rsa-sha256; t=1609168429; cv=none; d=zohomail.com; s=zohoarc; b=MiOLWPsDQG2n3PWkh0ehN4NL9go7OaAref0GwIHHlRBedKpdWTa4a3zSJkfj34p3znBvTbJUDLrprDZg6IONe9xxE4WECwV27xutNdujLFnbFz724PO6JSn4ykmWQWjbuGceby6ilI83Blus+vR0L+O3B/jLK9pewnEei72Zixc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609168429; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=u1OlORKWfeLFvYFMnUIhJxw7jm+Np6Ho//WAXrCcqpA=; b=EIUtTXXuuJg0FhQnUfkYTcXpLIdYZIqO5BZVbk+6PAW7MK0Qf3uMNBjR1EsShncu5FiRmMrgEbsSc/mF9hi4wUhr+Xfr/EWkvlb7mxvNd1Se9E90yWVAwSVOhkpZRH/qjAAq7RZZ/iGAHMkZhs4kHqZ1cjMvcyCGDSyX57jcCwU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160916842935233.364694861491216; Mon, 28 Dec 2020 07:13:49 -0800 (PST) Received: from localhost ([::1]:58740 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ktuDU-0000bu-6E for importer@patchew.org; Mon, 28 Dec 2020 10:13:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49566) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ktu8n-00049Q-Cd; Mon, 28 Dec 2020 10:08:57 -0500 Received: from mout.web.de ([212.227.15.3]:46431) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ktu8l-0001CY-LW; Mon, 28 Dec 2020 10:08:57 -0500 Received: from gecko.fritz.box ([94.134.180.94]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MarqU-1kab8d3KP4-00KRGE; Mon, 28 Dec 2020 16:08:49 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1609168129; bh=FQMRDvxICk/7cfZU8X57AG2wI/ZBvqY1J2ViguU1hAo=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=ktX/lLMl0bRqvJnAnZy/AvIOQxeTxPBlcW+k2qdEFrjonHZJuNZpYNwsnaaExOOLP rqCJGZW0qCXz8S9TSadOvntbvEsNcfIAsb1Q1rbtODFOgbf6CgGoxWx8pmJH4oPox5 WDr0gOpP00sQGLw2gUASh+ML00piJPesR33/Siak= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Date: Mon, 28 Dec 2020 16:08:48 +0100 From: Lukas Straub To: qemu-devel Subject: [PATCH v14 3/7] chardev/char-socket.c: Add yank feature Message-ID: <1f4eeed1d066c6cbb8d05ffa9585f6e87b34aac6.1609167865.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/9ntZXmlJgT.ojQcWv+pigVb"; protocol="application/pgp-signature"; micalg=pgp-sha256 X-Provags-ID: V03:K1:ZWBORrIdBOIQCCuVwTSrEwrPAbzX9S4/7s1Hjd9cN5cLk6HNZJo 9k7zbtqXaYHT4ar4ZUlRB8wRQbpbr+76fj1EFd9Sxe6+jAe42tPeh/OayI4FdK5MPeXP8yo FrqTb1lLh/FyeZjZ6qJ7jmEH4i+n0lGVdUjuL9Acium37YOSMuj4Ao69I/EwS22Q7D5iTUR GIAVjrrgOruCCCiSGemAA== X-UI-Out-Filterresults: notjunk:1;V03:K0:QZdFIX+fAX4=:nqTUtJFQ+W77F5q8/0NUUX fzrjAi+7RjlfW6HP8gqnfwu63zPv6C4ECaywQDN5RFF9wRBmZSNt3dmIU5hFqLPHUv7DqccnY 0KQi1l+SLaBkOMVIwoI5QdIhRSQwdwq9Jl0yAeEcfqtSXF3OLjgUMM/xaFPqYzY9u6ZmG4Ysj QKJ7wUFiL1oTKId16zbTALf6sU8FBa8lR/+vfQWR543VNa6WA/9RkK700fosufKg1Q5Y7AwA4 RVR/bkhWhWzk3eFL8aB4AOdw9x+khk17jTK6twdT9uscrQjGT2GaXeiOEK8NDf+a5ZFD8KXh0 hg4HZTAOVtVn3F361jaPWpBRzwcpERddiGNiERpw56+0TIbNYzftaPEC6FpBdqOqjH6Src/Sq wIwIjIarDw+2ImMvCX7jEmHmNOVYS2x9UqpK/XcNm+4YZME6/AzjdeIHmBPZZqa0ph1T6WCdD M/XcmSztdzpymZ8tsi7+UN+v/nNZvRCa1y2zufRGPbuUxWjvWlDcTFZ1yU1eOQGrrvT24sSko OmZZy6IYMPL5DvhicQ98r1F3CWPGI2UwGrNf1xfG9Mniltr8D2GQHHOF5hKhjY9gcaMknRYJd UkeYA+AxfzHmqxJ/u3IV8mnG9s66pFMkOfwdOtaDXVIpxbjdK84sYG/X/1/GW8uJEv6l9AVJk /lx4NZeyDHYLR5BNX05SZO4yV8qjZUXRz8TY6cR3VlwyNzeZG7+LZu4XV/CB1sUAdtUOjrH3N d7KT31vzQgUGcqCsj7ekY8ZhjuxGdNBv4rkPMYONHal4IfxUJ3GKqWzXDr3ePcM7K9898Ok2E 32VH2fhDC0rP8qrGbytRFPuHrI825Xf3PF4cHnQSjwcExH/O1b+tUL3rIuN9tMDzMIT6BATY1 1Xzm5myCRY4JRgbSVdFobijiE4D3EggykpK5wRkDU= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=212.227.15.3; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 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, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Kevin Wolf , "Daniel P. =?UTF-8?B?QmVycmFuZ8Op?= =?UTF-8?B?XA==?=" , qemu-block , Juan Quintela , Markus Armbruster , "Dr. David Alan Gilbert" , Max Reitz , =?UTF-8?B?TWFyYy1BbmRyw6k=?= Lureau , Paolo Bonzini , =?UTF-8?B?TWFyYy1BbmRyw6k=?= Lureau Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-Zoho-Virus-Status: 1 X-ZohoMail-DKIM: fail (Header signature does not verify) --Sig_/9ntZXmlJgT.ojQcWv+pigVb Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Register a yank function to shutdown the socket on yank. Signed-off-by: Lukas Straub Acked-by: Stefan Hajnoczi Acked-by: Marc-Andr=C3=A9 Lureau --- chardev/char-socket.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 213a4c8dd0..8a707d766c 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -34,6 +34,7 @@ #include "qapi/error.h" #include "qapi/clone-visitor.h" #include "qapi/qapi-visit-sockets.h" +#include "qemu/yank.h" #include "chardev/char-io.h" #include "qom/object.h" @@ -70,6 +71,7 @@ struct SocketChardev { size_t read_msgfds_num; int *write_msgfds; size_t write_msgfds_num; + bool registered_yank; SocketAddress *addr; bool is_listen; @@ -415,6 +417,12 @@ static void tcp_chr_free_connection(Chardev *chr) tcp_set_msgfds(chr, NULL, 0); remove_fd_in_watch(chr); + if (s->state =3D=3D TCP_CHARDEV_STATE_CONNECTING + || s->state =3D=3D TCP_CHARDEV_STATE_CONNECTED) { + yank_unregister_function(CHARDEV_YANK_INSTANCE(chr->label), + yank_generic_iochannel, + QIO_CHANNEL(s->sioc)); + } object_unref(OBJECT(s->sioc)); s->sioc =3D NULL; object_unref(OBJECT(s->ioc)); @@ -932,6 +940,9 @@ static int tcp_chr_add_client(Chardev *chr, int fd) } tcp_chr_change_state(s, TCP_CHARDEV_STATE_CONNECTING); tcp_chr_set_client_ioc_name(chr, sioc); + yank_register_function(CHARDEV_YANK_INSTANCE(chr->label), + yank_generic_iochannel, + QIO_CHANNEL(sioc)); ret =3D tcp_chr_new_client(chr, sioc); object_unref(OBJECT(sioc)); return ret; @@ -946,6 +957,9 @@ static void tcp_chr_accept(QIONetListener *listener, tcp_chr_change_state(s, TCP_CHARDEV_STATE_CONNECTING); tcp_chr_set_client_ioc_name(chr, cioc); + yank_register_function(CHARDEV_YANK_INSTANCE(chr->label), + yank_generic_iochannel, + QIO_CHANNEL(cioc)); tcp_chr_new_client(chr, cioc); } @@ -961,6 +975,9 @@ static int tcp_chr_connect_client_sync(Chardev *chr, Er= ror **errp) object_unref(OBJECT(sioc)); return -1; } + yank_register_function(CHARDEV_YANK_INSTANCE(chr->label), + yank_generic_iochannel, + QIO_CHANNEL(sioc)); tcp_chr_new_client(chr, sioc); object_unref(OBJECT(sioc)); return 0; @@ -976,6 +993,9 @@ static void tcp_chr_accept_server_sync(Chardev *chr) tcp_chr_change_state(s, TCP_CHARDEV_STATE_CONNECTING); sioc =3D qio_net_listener_wait_client(s->listener); tcp_chr_set_client_ioc_name(chr, sioc); + yank_register_function(CHARDEV_YANK_INSTANCE(chr->label), + yank_generic_iochannel, + QIO_CHANNEL(sioc)); tcp_chr_new_client(chr, sioc); object_unref(OBJECT(sioc)); } @@ -1086,6 +1106,9 @@ static void char_socket_finalize(Object *obj) object_unref(OBJECT(s->tls_creds)); } g_free(s->tls_authz); + if (s->registered_yank) { + yank_unregister_instance(CHARDEV_YANK_INSTANCE(chr->label)); + } qemu_chr_be_event(chr, CHR_EVENT_CLOSED); } @@ -1101,6 +1124,9 @@ static void qemu_chr_socket_connected(QIOTask *task, = void *opaque) if (qio_task_propagate_error(task, &err)) { tcp_chr_change_state(s, TCP_CHARDEV_STATE_DISCONNECTED); + yank_unregister_function(CHARDEV_YANK_INSTANCE(chr->label), + yank_generic_iochannel, + QIO_CHANNEL(sioc)); check_report_connect_error(chr, err); goto cleanup; } @@ -1134,6 +1160,9 @@ static void tcp_chr_connect_client_async(Chardev *chr) tcp_chr_change_state(s, TCP_CHARDEV_STATE_CONNECTING); sioc =3D qio_channel_socket_new(); tcp_chr_set_client_ioc_name(chr, sioc); + yank_register_function(CHARDEV_YANK_INSTANCE(chr->label), + yank_generic_iochannel, + QIO_CHANNEL(sioc)); /* * Normally code would use the qio_channel_socket_connect_async * method which uses a QIOTask + qio_task_set_error internally @@ -1376,6 +1405,11 @@ static void qmp_chardev_open_socket(Chardev *chr, qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_FD_PASS); } + if (!yank_register_instance(CHARDEV_YANK_INSTANCE(chr->label), errp)) { + return; + } + s->registered_yank =3D true; + /* be isn't opened until we get a connection */ *be_opened =3D false; -- 2.29.2 --Sig_/9ntZXmlJgT.ojQcWv+pigVb Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEg/qxWKDZuPtyYo+kNasLKJxdslgFAl/p9QAACgkQNasLKJxd slh8hhAAgt8naTUhcXADlfJ3HKI4H4HOnxsnJxTnCErTwC7ON68cEwhlAeBXc3R+ vIzh/zePL2y/U/T0zULyFfr4nA9Pw/VPciH46lhAYdcj//hSKSX9qna49ozkWf1j FuBHpzbV4LDTInOFepcUJCojnRxXZzkaZLe3QWJLqxqI1HtkwYBfo0OO1VvDC3Cx JlNmgXuHi3aXprRL2bvL1QnWXRpdePZvPjgwsqIFoHIsqstT3ZRyKCuBUg6mDGz4 LCKYXTdSpvTKUDBks5csrKfDCDyuuAk2d2kvmiD3+5XKxs8AQAnOXBtp8XeOb+pV EVI7neX8bMT07LjZMHEhW0/xblr6V4zbaVOMb72TiDusRswfi1rKl7VzoM+FoT1o BudSEnD95Fd2g7cuo5uu353+LgcU1RkXef2+5nX8uGFoyF6um6HRRtlc+sMAAzeD UPx8punghnTvr43Tq6puzVyuEanfA90SHMG4/z6FW2J3Z5zFOITVsrQzzfcOiB17 bZbBJ89m2IGXkdwFB7AWHsdd6VaXy4JkRZuUS+nKv+R5nn9JvlQc3kar9Rpgaoke QaV8kfev+CooLH94bYNJJGHwxuDocQ/QSobGqJ9k0+E7dGSdl6iBkeEkH9akp+wo fZFc687qu4/PlQ9xV+ToMAetidWYyxfV3XPxZz1K3CfnaV2SzJ8= =1IsG -----END PGP SIGNATURE----- --Sig_/9ntZXmlJgT.ojQcWv+pigVb-- From nobody Mon May 13 11:50:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=web.de ARC-Seal: i=1; a=rsa-sha256; t=1609168278; cv=none; d=zohomail.com; s=zohoarc; b=l2VzY56Qe77jv9ysYL98Md4JQoqvuWKYKFxgvVWS61SZC/pYSpmsBlh/oYVQCfEYFf468uwPOW/TMHVYcVhWZ+N7JfokVe7g/AiVtsqaDqArPxkB5lunWY6l4KeNlAL1Xcc0fu4aQPkGTt6Y2Mrnn7cCR/0SxubOKn644D4L/qA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609168278; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ISQcmdUInC7YKDId+AJ7caQzZE3OiRAMWdepZs09SoE=; b=UfNfEYQKlOTJY3YaG3WwUz22xnGWB4o/z5PhHwGHnjtjwKqxX5PSYyDF3cvxOXrM8XOzgDCvx2+7gxiYDE9V4AYxL5+pZ4l3ifaEKF5G9ilct7MtUDhLz3k2WIzgXVrQ2kPEP3jplWNSHlU3fRWnf6wQ7TDkUe8xtIZ5l/idtlo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1609168278398368.01765559356454; Mon, 28 Dec 2020 07:11:18 -0800 (PST) Received: from localhost ([::1]:53220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ktuB2-0006gl-Ec for importer@patchew.org; Mon, 28 Dec 2020 10:11:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49580) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ktu8s-0004LY-3m; Mon, 28 Dec 2020 10:09:02 -0500 Received: from mout.web.de ([212.227.15.14]:38877) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ktu8q-0001Da-54; Mon, 28 Dec 2020 10:09:01 -0500 Received: from gecko.fritz.box ([94.134.180.94]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MuFD7-1k1Wy82lLB-00u9B0; Mon, 28 Dec 2020 16:08:53 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1609168133; bh=2za7JJ/kLW+KjYQ6X0pvk7YEZzm+aVrV3f8jauTm5AQ=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=FaNISJKfKEs7PfUmS4M1WOgNkGUU4StmCh3H7aXjjXfdbF/zvUKvtl7S2S1RAeqW1 wOP+we5HJ2kcnNMwGct4vRAhzXAILvSC1TiJLu+mUVEAiK+KOvknl4FYrcKX4/WUPf EX1gcezP0NNQYT3Jrq5XpPbBW3WLIvj9egfshZjg= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Date: Mon, 28 Dec 2020 16:08:52 +0100 From: Lukas Straub To: qemu-devel Subject: [PATCH v14 4/7] migration: Add yank feature Message-ID: <484c6a14cc2506bebedd5a237259b91363ff8f88.1609167865.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/xD4EVpXz3EkMTtB0Gx+ANUL"; protocol="application/pgp-signature"; micalg=pgp-sha256 X-Provags-ID: V03:K1:sQwHVoZ9cVBskt2vZ42HLQ9xNbNezTeHeoCkVSyYoyYw28x61J9 2gCCJDod/HME4j+dBI1fDhGFclShEfcLfLNIF9kIPjCfbhbv9xN8N6KUCdsI/qSopOp8Rgk ke93pN/P/vbi+mL3W2YzFYnXuK8pm4nyp+vfdediQQQIdKlLZv+ezHXuZlT5VZNTUJ9gegG cblcI2Bsk0L4Lfg/I2sTg== X-UI-Out-Filterresults: notjunk:1;V03:K0:VRRq5fmy6OM=:IAPSIZc+2NERo9UPSn9c31 Tr9SFtY7lLXBFp5Ly4Csij2F4XeYV5lLL6+S99ckma3qDYK+cki0tP+llxIgojc335Q5tECL2 seDUcVeCJTmwBC/ELjNQ84A8UmuGQV7pIVSFrJ3/OO62roySxeNwRAR06Gd4rGJPPbWYGKqff h5Y1ZedyGDw+jjjP6oO/lN3eAEtwcBjRlhHkcOEzSRIv2deR0n9WyP7uWlYioBuAk8e4IFpPo 3BzW/kDh8os7QZbyHWm7BRv70PwtaU3pPxH2dCpkma8T/whpAV7J/NOEBug+mhNCmqeQv2w1Q wDTRzPaSTru0vbBosZbLfO4oHJlIUAHFE048UdmeTadAq++ujwTg59DkjRxfhptbIxJS88RMI eca1oHVXXkmeBppGcjFFatVUbQO7U5jJebrgex6rDiT7jjogCBKwRNbpWBroRldGDnR8d1DFJ mxr+fyYqkjNwrhFxWzM+q1VMoeaT+w3jiGzzhLwFVgshKppqKCzDF0XvpS7iMJMGNtXWOZgRh 7oydv9VEJHEgOGuftqH3xKwsFWrPRl4phgQi8qcBdfm96UTs2n4F4FeUgZ+9wHUXEVagjbSl6 EgUnk95hr2vtSbID5wfw/hfGeefO1MymSEoKSBjbgZ1/35SzzDLiUzqYzy7cQC4UhXm8oD+Rq WUUendl79OwUwUInBJ7geF9RurKWNolfu/Ixv9dTNzf4nJog/5+ENAtZ5nKcbojmC9B+2CkZa mzRyuO+Ymzp6uU97WMCXhGjGZPFm7BpL5rOMjyI9LMXXQQixyY8/oxILV6Em9Mg0zhV2eqEDC E2ErESODJ8wnFIpOy89EFe9zkoS+VLu7gijTL3LSOYMAhgtrIW+PvZeIPI/rlOdxlTQ5NS63h MVUHrLsJVQ8+J+Zr9g0JS9wEndsgw418/9NyGioEI= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=212.227.15.14; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 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_H2=-0.001, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Kevin Wolf , "Daniel P. =?UTF-8?B?QmVycmFuZ8Op?= =?UTF-8?B?XA==?=" , qemu-block , Juan Quintela , Markus Armbruster , "Dr. David Alan Gilbert" , Max Reitz , =?UTF-8?B?TWFyYy1BbmRyw6k=?= Lureau , Paolo Bonzini , =?UTF-8?B?TWFyYy1BbmRyw6k=?= Lureau Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-Zoho-Virus-Status: 1 X-ZohoMail-DKIM: fail (Header signature does not verify) --Sig_/xD4EVpXz3EkMTtB0Gx+ANUL Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Register yank functions on sockets to shut them down. Signed-off-by: Lukas Straub Acked-by: Stefan Hajnoczi Acked-by: Dr. David Alan Gilbert --- migration/channel.c | 13 +++++++++++++ migration/migration.c | 22 ++++++++++++++++++++++ migration/multifd.c | 10 ++++++++++ migration/qemu-file-channel.c | 7 +++++++ migration/savevm.c | 5 +++++ 5 files changed, 57 insertions(+) diff --git a/migration/channel.c b/migration/channel.c index 8a783baa0b..35fe234e9c 100644 --- a/migration/channel.c +++ b/migration/channel.c @@ -18,6 +18,8 @@ #include "trace.h" #include "qapi/error.h" #include "io/channel-tls.h" +#include "io/channel-socket.h" +#include "qemu/yank.h" /** * @migration_channel_process_incoming - Create new incoming migration cha= nnel @@ -35,6 +37,11 @@ void migration_channel_process_incoming(QIOChannel *ioc) trace_migration_set_incoming_channel( ioc, object_get_typename(OBJECT(ioc))); + if (object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_SOCKET)) { + yank_register_function(MIGRATION_YANK_INSTANCE, yank_generic_iocha= nnel, + QIO_CHANNEL(ioc)); + } + if (s->parameters.tls_creds && *s->parameters.tls_creds && !object_dynamic_cast(OBJECT(ioc), @@ -67,6 +74,12 @@ void migration_channel_connect(MigrationState *s, ioc, object_get_typename(OBJECT(ioc)), hostname, error); if (!error) { + if (object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_SOCKET)) { + yank_register_function(MIGRATION_YANK_INSTANCE, + yank_generic_iochannel, + QIO_CHANNEL(ioc)); + } + if (s->parameters.tls_creds && *s->parameters.tls_creds && !object_dynamic_cast(OBJECT(ioc), diff --git a/migration/migration.c b/migration/migration.c index e0dbde4091..92f7cb70b2 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -56,6 +56,7 @@ #include "net/announce.h" #include "qemu/queue.h" #include "multifd.h" +#include "qemu/yank.h" #ifdef CONFIG_VFIO #include "hw/vfio/vfio-common.h" @@ -254,6 +255,8 @@ void migration_incoming_state_destroy(void) qapi_free_SocketAddressList(mis->socket_address_list); mis->socket_address_list =3D NULL; } + + yank_unregister_instance(MIGRATION_YANK_INSTANCE); } static void migrate_generate_event(int new_state) @@ -418,6 +421,10 @@ static void qemu_start_incoming_migration(const char *= uri, Error **errp) { const char *p =3D NULL; + if (!yank_register_instance(MIGRATION_YANK_INSTANCE, errp)) { + return; + } + qapi_event_send_migration(MIGRATION_STATUS_SETUP); if (strstart(uri, "tcp:", &p) || strstart(uri, "unix:", NULL) || @@ -432,6 +439,7 @@ static void qemu_start_incoming_migration(const char *u= ri, Error **errp) } else if (strstart(uri, "fd:", &p)) { fd_start_incoming_migration(p, errp); } else { + yank_unregister_instance(MIGRATION_YANK_INSTANCE); error_setg(errp, "unknown migration protocol: %s", uri); } } @@ -1737,6 +1745,7 @@ static void migrate_fd_cleanup(MigrationState *s) } notifier_list_notify(&migration_state_notifiers, s); block_cleanup_parameters(s); + yank_unregister_instance(MIGRATION_YANK_INSTANCE); } static void migrate_fd_cleanup_schedule(MigrationState *s) @@ -2011,6 +2020,7 @@ void qmp_migrate_recover(const char *uri, Error **err= p) * only re-setup the migration stream and poke existing migration * to continue using that newly established channel. */ + yank_unregister_instance(MIGRATION_YANK_INSTANCE); qemu_start_incoming_migration(uri, errp); } @@ -2148,6 +2158,12 @@ void qmp_migrate(const char *uri, bool has_blk, bool= blk, return; } + if (!(has_resume && resume)) { + if (!yank_register_instance(MIGRATION_YANK_INSTANCE, errp)) { + return; + } + } + if (strstart(uri, "tcp:", &p) || strstart(uri, "unix:", NULL) || strstart(uri, "vsock:", NULL)) { @@ -2161,6 +2177,9 @@ 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 { + if (!(has_resume && resume)) { + yank_unregister_instance(MIGRATION_YANK_INSTANCE); + } error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "uri", "a valid migration protocol"); migrate_set_state(&s->state, MIGRATION_STATUS_SETUP, @@ -2170,6 +2189,9 @@ void qmp_migrate(const char *uri, bool has_blk, bool = blk, } if (local_err) { + if (!(has_resume && resume)) { + yank_unregister_instance(MIGRATION_YANK_INSTANCE); + } migrate_fd_error(s, local_err); error_propagate(errp, local_err); return; diff --git a/migration/multifd.c b/migration/multifd.c index 45c690aa11..1a1e589064 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -25,6 +25,9 @@ #include "trace.h" #include "multifd.h" +#include "qemu/yank.h" +#include "io/channel-socket.h" + /* Multiple fd's */ #define MULTIFD_MAGIC 0x11223344U @@ -974,6 +977,13 @@ int multifd_load_cleanup(Error **errp) for (i =3D 0; i < migrate_multifd_channels(); i++) { MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; + if (object_dynamic_cast(OBJECT(p->c), TYPE_QIO_CHANNEL_SOCKET) + && OBJECT(p->c)->ref =3D=3D 1) { + yank_unregister_function(MIGRATION_YANK_INSTANCE, + yank_generic_iochannel, + QIO_CHANNEL(p->c)); + } + object_unref(OBJECT(p->c)); p->c =3D NULL; qemu_mutex_destroy(&p->mutex); diff --git a/migration/qemu-file-channel.c b/migration/qemu-file-channel.c index d2ce32f4b9..afc3a7f642 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 "qemu/yank.h" static ssize_t channel_writev_buffer(void *opaque, @@ -104,6 +105,12 @@ static int channel_close(void *opaque, Error **errp) int ret; QIOChannel *ioc =3D QIO_CHANNEL(opaque); ret =3D qio_channel_close(ioc, errp); + if (object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_SOCKET) + && OBJECT(ioc)->ref =3D=3D 1) { + yank_unregister_function(MIGRATION_YANK_INSTANCE, + yank_generic_iochannel, + QIO_CHANNEL(ioc)); + } object_unref(OBJECT(ioc)); return ret; } diff --git a/migration/savevm.c b/migration/savevm.c index 5f937a2762..b3c29776db 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -62,6 +62,7 @@ #include "migration/colo.h" #include "qemu/bitmap.h" #include "net/announce.h" +#include "qemu/yank.h" const unsigned int postcopy_ram_discard_version; @@ -3008,6 +3009,10 @@ int load_snapshot(const char *name, Error **errp) qemu_system_reset(SHUTDOWN_CAUSE_NONE); mis->from_src_file =3D f; + if (!yank_register_instance(MIGRATION_YANK_INSTANCE, errp)) { + ret =3D -EINVAL; + goto err_drain; + } aio_context_acquire(aio_context); ret =3D qemu_loadvm_state(f); migration_incoming_state_destroy(); -- 2.29.2 --Sig_/xD4EVpXz3EkMTtB0Gx+ANUL Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEg/qxWKDZuPtyYo+kNasLKJxdslgFAl/p9QQACgkQNasLKJxd slgevw/+Kjydxe6MCz+JUryToPW4MvbsOTtGWCSPV+60mWxUKeys9JwOVsXOV+3i SnFABNJ9voQS/j71iExezgx5cOB8to0reS9Wz3k3sAhvVFznj56NJIBYn6vtJA98 YYuBnXH9Y4aMSnzmqRDiqMvdL3MLc2eUHzxfPQMNTkEg+r9noD8BRtYXUAtiOIxR UX6eDEltFwkvXNEm4RTHjF+f0TZNwXu5mntaVbIIg02Z8PnJ+tYnegWNkO/K7GUR RxbtiK/X13sQNzyFXzNZIB+6BIrpfTUTNb0xygmbBa6r2LHRKM58h/2IFYcZZFJ2 eCnP770RmYrzJtjtTq/sQy1zkz4FS4BJJP7KxTxT3vINR+neOR0mVvhm6oODVl3c hc7iIEP0/rQuPHlgycpfyi+5Nazt/snCAnGF88KIKyL3lcSjHNck9JjLAZLTPOGi iDiZuj5rUAOs49CMjsoPPXptkGAvbjZsYr4sBpLg0DuYqqWn/5iJ5ADW7DqiVCrb +c7L23CYFxaFs8cVTNzdN/zmotlHVZkucCXVYtGWWCY7McQXHdlXTZWYfG/DzZAB Moxw65xt0j00FIiv92enxqx/ABeVJJ8ATXhTQPuuLPp9I26ingf4QFuwtSG7JVJY P1vsSJeSEIVW3QlwNvwjhzoZQVmP3kqv7BI5GhwJEiqutyuQNJU= =P/CI -----END PGP SIGNATURE----- --Sig_/xD4EVpXz3EkMTtB0Gx+ANUL-- From nobody Mon May 13 11:50:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=web.de ARC-Seal: i=1; a=rsa-sha256; t=1609168731; cv=none; d=zohomail.com; s=zohoarc; b=I4RRtVkZrfv/xjoI8RFxOb9LEZFGFVcKd4rLnoG0YTyJGMRuEnU2jr2Mvn2efSlfKCK2sSzgDIH6Ca/9R09hNb+TDZDnvAYJcQ9Re5cgIsWpivXnXxVYT8bwAHhdZlRF8Aim8kf9ix90zIOwK1a8bexhO1Vu77YeTj18I1inQy4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609168731; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LeH0SAj1DTGi1jmNDwrJGd3fLkEar+uCZxirGZN427Y=; b=SDiRscamMhGq17aamqoqC0khanZy2w8eAePo8jGHgmlopnGnCiiaNTQzidtgZ3euybIw5Fosen6gudUhbYCi1LOhdpa8MGaET6L2iQZ4ZHHnEmElFH00eh18UJvmaTuCk1Xc/uxqI1zxcPK+o0f1/hipG5t3EX942ey6sLDG4lI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1609168731334991.224684233094; Mon, 28 Dec 2020 07:18:51 -0800 (PST) Received: from localhost ([::1]:37428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ktuIM-0003wU-00 for importer@patchew.org; Mon, 28 Dec 2020 10:18:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49592) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ktu8u-0004PJ-3e; Mon, 28 Dec 2020 10:09:04 -0500 Received: from mout.web.de ([212.227.15.3]:49809) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ktu8s-0001EZ-HK; Mon, 28 Dec 2020 10:09:03 -0500 Received: from gecko.fritz.box ([94.134.180.94]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0Lb1rd-1k9Gj20MUD-00kfy2; Mon, 28 Dec 2020 16:08:57 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1609168137; bh=00EAiCU6NQFSqynFLpxVcMN9uW9kgzNco1ggwNTcC/0=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=FD1QyyqvkpHmfG+ONABG+oM+idtn4VWTxpZIZsUKAsFA/R8lYxL7pf1mkoEVm1aUv WQLLgknQ4TBeoUFk947aqT83jib71RqPpT9j3fp/h4RM65Qr9Dftiycm0rrvQJGCiL BmxIrpyClNojtA9BDm6I401BkuE4UtWEKqVB839I= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Date: Mon, 28 Dec 2020 16:08:55 +0100 From: Lukas Straub To: qemu-devel Subject: [PATCH v14 5/7] io/channel-tls.c: make qio_channel_tls_shutdown thread-safe Message-ID: <5bd8733f583f3558b32250fd0eb576b7aa756485.1609167865.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/scE93YRDVni0+txa/3euzwM"; protocol="application/pgp-signature"; micalg=pgp-sha256 X-Provags-ID: V03:K1:2d5XceAMn6EOZVFtE96Uu08bfkSxIOyp+j1/HkD/WtBmqLtC5CE vNi9/QTsf962Yro6zEq8KGtJuA81vBrPMG8EH4QqDaNJsZyC88K6+lOTYcQ28X5IkOe80Gu +OvG28WFgG+Rd4a60ozsXjuPEH4r2MWQ/A9C9uyZ9UWQ3GcWy8epq2W6FIqJJvY0NMAxRQh TyWxgA3KHKcHyYP1VoKKg== X-UI-Out-Filterresults: notjunk:1;V03:K0:yv5WJ8ovZfg=:8a2H7BKV9qgHzZO+nzU9eT i+UFHFd/wVnfN2w6bBmuTdjypwxkFqonZrKvK601JUlU1oUbvdExQtiykZLbitPEJMm7hOiIE 4KCL3Gj4JbFQH8jB33KKv3ArAuZNfJuWq+fomgjby2bGO+QGOApWgvYEIUy4wB/GEBtetjJpY mY/z6pmoQ5TtXPb78VzSgZ8uvM2JG3yzXucCAkDV6X+0wwqSbaiDTXYI2nJYB/eiCCb0W69OZ o/9tsSBQood2PczvmFclxAHledQOUQ1VisYKTt24oEFHfqZ9AQTAcEtqeQBHqjaI69qMTGlLb e5c0zPbEzXq0Hevp+kGYjmEQniJZHDr7V2vQzJ9qKqZtXRHrEAqw0ECrAj5TktWHaQBf7etes LLHjhFfsiWtdI8KEwX+KO4QXSPRhNo0+3bIM597S7oYRtVgsLh6T1Sviq31olRZpV1JPcae4Z sBIplo9LnH9bzThrjcBurQBFpzkmTMcTPnLUYh7eTFgyVa4AfIF6TgH3k9yKJyz8C/mXHMns4 LBDHpjcAwOcBaL4Qa0YAbPyqJbdcEb9VfrFIpZqlLn+VjKOmgehhukD1xo2ireVuPbSmxkpGs bHIIqb+/sIo1Cn3uXrLEQhiPTw6GoD2xueloqb2Pb/5keGI8V3hS/3kA5mfqDEFOpKJCNe4Wo 6ViP07oZM352xtnTVdafb8EnbN2F6QS2f3Llmc4ClimfCYLuDh2uY7Ev+dSJeg3nWWiWz9sjk IUGro4J0FpuTyfQyR/VC7QKoKKU+4JJg4pFwGmy5CvuaFsaM2PXob5oPUIt7SG79eZGP0cCj3 62hABDuof42KA6SO5wTJsyORXmIbFYGtI2eJeJzPEgKdKE0ySdN4euZNdE5q4SDVoviyfnFKC TTU1ioDBq6Xvf9IFysIH+3V8oH+f8UGY+dZ6VCGzg= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=212.227.15.3; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 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, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Kevin Wolf , "Daniel P. =?UTF-8?B?QmVycmFuZ8Op?= =?UTF-8?B?XA==?=" , qemu-block , Juan Quintela , Markus Armbruster , "Dr. David Alan Gilbert" , Max Reitz , =?UTF-8?B?TWFyYy1BbmRyw6k=?= Lureau , Paolo Bonzini , =?UTF-8?B?TWFyYy1BbmRyw6k=?= Lureau Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-Zoho-Virus-Status: 1 X-ZohoMail-DKIM: fail (Header signature does not verify) --Sig_/scE93YRDVni0+txa/3euzwM Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Make qio_channel_tls_shutdown thread-safe by using atomics when accessing tioc->shutdown. Signed-off-by: Lukas Straub Acked-by: Stefan Hajnoczi Reviewed-by: Daniel P. Berrang=C3=A9 --- io/channel-tls.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/io/channel-tls.c b/io/channel-tls.c index 388f019977..2ae1b92fc0 100644 --- a/io/channel-tls.c +++ b/io/channel-tls.c @@ -23,6 +23,7 @@ #include "qemu/module.h" #include "io/channel-tls.h" #include "trace.h" +#include "qemu/atomic.h" static ssize_t qio_channel_tls_write_handler(const char *buf, @@ -277,7 +278,8 @@ static ssize_t qio_channel_tls_readv(QIOChannel *ioc, return QIO_CHANNEL_ERR_BLOCK; } } else if (errno =3D=3D ECONNABORTED && - (tioc->shutdown & QIO_CHANNEL_SHUTDOWN_READ)) { + (qatomic_load_acquire(&tioc->shutdown) & + QIO_CHANNEL_SHUTDOWN_READ)) { return 0; } @@ -361,7 +363,7 @@ static int qio_channel_tls_shutdown(QIOChannel *ioc, { QIOChannelTLS *tioc =3D QIO_CHANNEL_TLS(ioc); - tioc->shutdown |=3D how; + qatomic_or(&tioc->shutdown, how); return qio_channel_shutdown(tioc->master, how, errp); } -- 2.29.2 --Sig_/scE93YRDVni0+txa/3euzwM Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEg/qxWKDZuPtyYo+kNasLKJxdslgFAl/p9QcACgkQNasLKJxd slhbIA//ZX4FIEmn0faamdQzIUVvyWbfe/RcPwfRomASZ+4VITUBasb6Ur25MqBb B6BSprvIZGVJOj8BK1NzSCoYJPt0LM8DucMR8yciXFMZgiy71DrLUiHmr6KWv90+ xQQM/fBxQ0Shp0IZ0XeW3Yd0f0rjTrBhSB/FYr/HikDzGMOBvTnRgv2RkjfYGCCa gO4EouO6hy9qPMkBhgX/LiF3SjY4RA4+tZRcvBl5+34vQVOY890ENdqX53bhSxXt SDab8dpCzYZgPaMPVvvZ/4nhwYtgq/HwmKfS1IOj4dvh0ilaCl4FOUdDpmgdg6gq 77UnotP6I1B/rhJJ+ePiKrNaCHi1EH1VvH7qZZxxIVMdnYgH+J4VfK2+5lAiCwH6 OKtkHH7sbRp2sGs3MOLTa8Mlz0SVoxD8RYM/1LIgG3wNrOFRnPizC0pDqeP481KH RcTTMCTe/qiw+twHI2tyf3SZM+gOm8FyJjWAKSEdO2AYOEvlAeYQzX2A3BQOndDg yBlAWwUKqMbQfO4M+i/HUwZ8jFoDW/ZBEUf1MmgD4hAEX2af32f9vVCpBxDfjjAY xDKOxCJupDb1/eCgw9Ev72QGjbUcBoTYN1n/kUyYSUl2AqOgfN7Ge55smqyEpIKS /SSXaglSIh8wRs2Ij48n9XdnTh8dv4yf+SVMcZ8RBUU8l1HEjmI= =iSRJ -----END PGP SIGNATURE----- --Sig_/scE93YRDVni0+txa/3euzwM-- From nobody Mon May 13 11:50:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=web.de ARC-Seal: i=1; a=rsa-sha256; t=1609168874; cv=none; d=zohomail.com; s=zohoarc; b=G5ZxlKkPhZ9Vs6bEvOcFt1Vg2S9zdxZHnFj5YaURnz/3gYLASE5liVv5i2G/5IIF4dY2vio4oeUg5u+gdjQQHBG1aPPWCjEeBEcmp2xh62rHRZBdgnuGfMHOygQwebD4xzey89P4dlnjLhtGapRWF2+UPp6ZnXWehwBTCCy08jE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609168874; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8lvZS8kz0o02Fx13iHkjdRnuGmt6qaXGyCZcw6n8PoM=; b=CjhRK3mHwAmc8fW6QsEPYLnrQPDmSihvKcoL8UTVAjPLs9s8gwRWTY9hJqMDly5CiBynuJZfV3NZYZbgfuAonw58JHI8rTD5cg0gPuRqS+lDH5KxGnsxohq08kCFSK/zhCow1vgjs8ecsehT2uq1xEaEjKa8z/RxqHKk48+Yr9A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1609168874340422.1552250877778; Mon, 28 Dec 2020 07:21:14 -0800 (PST) Received: from localhost ([::1]:42858 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ktuKe-0006Si-O2 for importer@patchew.org; Mon, 28 Dec 2020 10:21:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49604) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ktu8x-0004R3-EE; Mon, 28 Dec 2020 10:09:10 -0500 Received: from mout.web.de ([212.227.15.4]:46475) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ktu8v-0001FY-TC; Mon, 28 Dec 2020 10:09:07 -0500 Received: from gecko.fritz.box ([94.134.180.94]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0Lp712-1kQ32W2aGq-00etH4; Mon, 28 Dec 2020 16:09:00 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1609168140; bh=GOnxK4+9O/IKhTXEnVxyvzhcPj1ugtekiJoF+Pgp/68=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=du2ftOJuD/TvwcY1fH61MFybey3WoQ0SylrHkYPg6nfKA7ZSbBqMXiArmHdMebhIY aeiJEw6Vxms4TV3zWtoImboWVJGO+TLZqqRVmYKO0r7IMgWoeyHN0z+ncSqtK2Mp3B D/UrlkA9f0OosAIfdVAg9Pm+lXmfFsLY7iX2ZyeU= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Date: Mon, 28 Dec 2020 16:08:59 +0100 From: Lukas Straub To: qemu-devel Subject: [PATCH v14 6/7] io: Document qmp oob suitability of qio_channel_shutdown and io_shutdown Message-ID: <32b8c27e256da043f0f00db05bd7ab8fbc506070.1609167865.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/m73hAM._ZY9MlX_OGEchYj8"; protocol="application/pgp-signature"; micalg=pgp-sha256 X-Provags-ID: V03:K1:mQoab/4qD3ykZo1kxRKyh+Y48J3xPN0YqyjclstXx11F1w+YoMT abrhGXVQHhwOF8IFS0DNdSu0/pd5A3gb6kzxMPNfrcBM1legsTHjsW1qz6NparHPJJ4LDbs Wo/ol+02ZgtARsdScV5xsbhnEFfMA5YkqXaCnLoi8FqBHP9nlMCniAOAwMcm5JviNP1p3As e2rSePsj4k0nL/c/mzXiQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:S7fynHVW3ZA=:XkomK38hVc7jmvCGCayE80 CzHx+aSU/fd2mpAJOsjex4BQtPVg6x3rVvhoh5sbQK1Z3jysZonOZ60Fa4yllknz62f0kQDCZ F31uaGo21tnIvsIdlKXzszQ1nwFB99VFJ3Cjg9kFj4PSENG4Y0G1LGsvUJbR5mZLC7iL4MPb7 T2/kqdPUoM6U2OUEsxY4GCmHQy2PCbrSmQYnmg/aRHbNYdqRJx+gsBFSyiT7nVCRsR2WXQkGS Wz8dtXzf9MzSmQdK2iPhUpaAXb7nSy9QqdjORqzD4lA1ZS9fI/0ZVlBzYVFV96kAXA1gT6KuZ FfVxWutS+Hx1Ex0N66+KSVGkwysZmq8e07vv/YvFf7KxkRMBA09Y0LcbDKHGHT5r0kP08n7Ja qMssnDJtokDVekNl8UUDuxc23gILGzTDLHLeBM5eb5eFNqKmewUu/TMEs2JedQSAD24m2q4pw 0IkyNGI7nijr/xJlv9iewP7KjwDlvcE0FX+DeTfJuCaLAO0r/bTiP4To/i55MoBhACiIF0GaM Qeyjk2Ct8hCgfgE5bZACP74aAk7gQGbrVM0tLYafrUxl2l8UbivLNToCrHb4gWA9+3drpEhJo zKVRQU/Ij/afXkiA5zvkYjIfL/PBh/9/3XHU7g0e5/KUatlW5G5d+dlNSaJNx2EJXX/AQfrBs FByR1VidLxK/juRIDmNG9Irys+RADPrf0/Wx5jVcRrXMmcsMmPn1LuSWf7DbOYXCgdQwEyDu6 PUGgi0tKlLUV87+9DOQl3MmjcqmKiu0yTCct927/PtF3RigjUCRoQuIjkcSWpn5ydy2Q1WeZa CiKnYdYQzL8RuC30B/G9UADQ4t2D2Wr38KjrD2d9d2EAkr46tLXmldJV0/TNpsUQ+VHwRT5Xm KEqxAnRu2YTrLwU0mGjigdH0jYiJuFRPqJ0+xYAE0= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=212.227.15.4; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 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, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Kevin Wolf , "Daniel P. =?UTF-8?B?QmVycmFuZ8Op?= =?UTF-8?B?XA==?=" , qemu-block , Juan Quintela , Markus Armbruster , "Dr. David Alan Gilbert" , Max Reitz , =?UTF-8?B?TWFyYy1BbmRyw6k=?= Lureau , Paolo Bonzini , =?UTF-8?B?TWFyYy1BbmRyw6k=?= Lureau Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-Zoho-Virus-Status: 1 X-ZohoMail-DKIM: fail (Header signature does not verify) --Sig_/m73hAM._ZY9MlX_OGEchYj8 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Migration and yank code assume that qio_channel_shutdown is thread -safe and can be called from qmp oob handler. Document this after checking the code. Signed-off-by: Lukas Straub Acked-by: Stefan Hajnoczi Reviewed-by: Daniel P. Berrang=C3=A9 --- include/io/channel.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/io/channel.h b/include/io/channel.h index 4d6fe45f63..ab9ea77959 100644 --- a/include/io/channel.h +++ b/include/io/channel.h @@ -92,7 +92,8 @@ struct QIOChannel { * provide additional optional features. * * Consult the corresponding public API docs for a description - * of the semantics of each callback + * of the semantics of each callback. io_shutdown in particular + * must be thread-safe, terminate quickly and must not block. */ struct QIOChannelClass { ObjectClass parent; @@ -510,6 +511,8 @@ int qio_channel_close(QIOChannel *ioc, * QIO_CHANNEL_FEATURE_SHUTDOWN prior to calling * this method. * + * This function is thread-safe, terminates quickly and does not block. + * * Returns: 0 on success, -1 on error */ int qio_channel_shutdown(QIOChannel *ioc, -- 2.29.2 --Sig_/m73hAM._ZY9MlX_OGEchYj8 Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEg/qxWKDZuPtyYo+kNasLKJxdslgFAl/p9QsACgkQNasLKJxd slgnTw/9H4kMFGx6W7Up+bi46Ny+OEGwkTq4msLHscETvqYNfNG8yu9/7WW20Nwr 5/Lw0qy2FR3YlHNobGBQNUjo0zXmCnIWbAwZdojT6coqb4IvcRP5fnuJOupt7EO5 t0ghIcRh4SflEE2dEC7Ia/tIuoDmwnHx/Q/zllIMe9L0v/ABiQKyi2UeZN8UfxUu x5p01oVswbvP4KDd4YWg5Z/ZfF8UxxoD11ksVsYXy9LSoXlTbKlMsNMjqlxil0QW aTnV3O6OQKDDh2n/YE1OtaOzAQ71kikhYF4XNkM0vR4XncSk0Z+hn70Sow7r4b1I m7GFwCZlUt14lu1GTaZOIcdKMGvbP49BL9tDAgR/C8mhLCIICqWqdz/JlYI4OtYl /gZPvQBHbGp/rXUMls/WSmIK55LoJFOtY3Uy+c2X0M3m6ew5fH7BFWxkvcxstPPs ib0Xr3zsm3iN+cHX1hczx3HSMpwJzx43eQ7wx37NZRDe55Oo8hNiAP/zdU8yMUBR jkf42y5ltft6QPcX7oif29xatuz1SST4m7Aili+NuCgNBwR3RVNAPwe8hKY3C29n hRap3vlVwcPgbO5tf+G1nzPF2a95uX0lHUesXs96AQAOEDFNVcPippgjK3u0uTBM 1ivbIMWVThF6ThGgS/K0Eq1pdjNN/gO0H3/SDCTaY4HZlTB1w/A= =JGpk -----END PGP SIGNATURE----- --Sig_/m73hAM._ZY9MlX_OGEchYj8-- From nobody Mon May 13 11:50:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=web.de ARC-Seal: i=1; a=rsa-sha256; t=1609168614; cv=none; d=zohomail.com; s=zohoarc; b=TQXqUVG5lp+Lzg2zVEAu12xFNJdzVlRIHxvXTJ46nJcc6GccbKbJm1dOC8gpTj8rU5QDHdZF2y5+43aTiLHzg4femp0VPmdB8s2muHO/BehAAjpv/hYrvIefxyW/zHtdbRXnNihB3sN5mduX9pkkz6ndjP1J2szvg7cC3veJNhA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609168614; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fsZN/6/WdDq6wD1A5HIO2H5Y9nD5ApeHTguK7pSf6nI=; b=elogZnt2KQ7DO9i5LYp39y1n6djFaDdfUGCj/XK4eGlghCBcuSQjRFgMEvFlExIFf9JrOESn+Diu9J+Srv/HvYQv8ZQtYJ/+GKd0DvfuuXUlsSIyx3ouR4G9R91ZgiSfch7QVtbvll6kIqo8eaiYU5pMSf/Rd2pwY0tf8GYQZnA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16091686144471011.540690058755; Mon, 28 Dec 2020 07:16:54 -0800 (PST) Received: from localhost ([::1]:35046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ktuGT-0002pe-Gq for importer@patchew.org; Mon, 28 Dec 2020 10:16:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49634) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ktu92-0004SG-NE; Mon, 28 Dec 2020 10:09:13 -0500 Received: from mout.web.de ([212.227.15.4]:37735) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ktu8z-0001GY-ON; Mon, 28 Dec 2020 10:09:11 -0500 Received: from gecko.fritz.box ([94.134.180.94]) by smtp.web.de (mrweb006 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MwR05-1k3ipZ056z-00s2xT; Mon, 28 Dec 2020 16:09:04 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1609168144; bh=sM9e6f4aBQacCCeUALlQzHypc2fHkhjPOITtzrSkwps=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=MGwcyyQmHMGGvjLX7PBow42txnH/T/C8EaUlJKicM6KWVrxdhTug8ZgZgS3Eq/11b evuYR7ZQ82bjFGhOiVafZKF24VotekSenfwVNdyuyOuktJt/RugwZOTnec3fFb7aF2 HaTaB3cD4LCN30sSrRKlAi2MLMMXSIaqbdu/zzcM= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Date: Mon, 28 Dec 2020 16:09:02 +0100 From: Lukas Straub To: qemu-devel Subject: [PATCH v14 7/7] tests/test-char.c: Wait for the chardev to connect in char_socket_client_dupid_test Message-ID: <1445e97a5800e3f2ba024ad52b500a0315701632.1609167865.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/+Ht_S1PnncfnCrv6lSbhUQO"; protocol="application/pgp-signature"; micalg=pgp-sha256 X-Provags-ID: V03:K1:ovkMm11V2IIr4tPHyoYaaLX/GE4cONa3o0AZV1lW1Lmz/a8/rX0 ez5iHfMAcCeBlDxAGtb5UNOjOoJeC9CIifiSLZVPvXVn2xobRdhm7l47I+mDArrzQEneMsP WQOq7agsyzWikic6AcauZkIDDrFyWAtcSpW7Ijayj2ibxZO201pJvLBLsfYsMgfmZva+Csv NgO2I0ybftLfTyBIvju9w== X-UI-Out-Filterresults: notjunk:1;V03:K0:NwtyFFo8UaE=:YUeXoioSr8sbY73QyQyvLh LS6NzbuLPwpqr8VnRGTSoUPRXYMrMX8jboygxnoIaZTHxldyEVMWWDg0PTXper6raA/RM6R5l nL+K/Tsvr59Mij2uz/A4MyNYWwaEE28rE4QJZ7kYK8RvmJmzpGeM75CJzpG1x3LHsO4p4wt0Z XIMpSGk1g/k8od9p80BeXDU5NBXzHxuHjBlRt8UPOtp08dJ/awUKf80quF1Q8r4Yd1xQAW7o8 mURj9bZrYXAK/I9jdcaaKU1AtzMqejxRB1jBud+CrZw3eEsXV7Te+iLDttR5ADnrJrDuORELr WiBSNMUH8iOw3e9P8Zjcelsqrrno3MhfjPtpjXtJjQoZOZshTVCKMnpVj35VGLf3ZNfWD8Ojz RUJ1OThgQgKNLF21HrZoxFABQPbhF1VwPNK01hwCOIoXkeVJwrd5OfF/tx8WC8w89cJIu7Jgi UHSloCaBB8ehdMIlu1BHLSa90ScxGSKkj3vjyBaogzfWnri/hYZ/IOPrNXoVbMbmtZXVCS2pt KrLXbUuAaw6GnDNgPrFfy8DR/Q1XP/riAHVBAR+O7bUR6hXRtKH+fN8XY6keLZ6pkRCxExqF3 MwouQ7F5x3t9qP8aZEKy0gv85JEj+OMLPOqe5l1012vME9rz+/eWyc+fDIAgLzs/9CcVavMCr 4weB9ZhKLn5dlhiKXsxpuMEODXJdyP+5jK9Gk9AmALpl4wU50IdADgt+2JM5ZTKeur+qb7KIz FEXBc74n8JF54VGbZi+ZToIYxA95C0k/m31OAcFF6MY0D0Xkd2+Kw1v6Vd7xhu31Cq+7d+9fK Nyy0rRVdadsQ7mJvpGVY3r/dMgXPUifY56vsSyDSzg8P0WRAB2GTyU6sm+DGcRSCsycprJT3P TBg1dO70JjNjGXOrgf9deQYEmfI1oLqZ/8nMu+3mo= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=212.227.15.4; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 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, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Kevin Wolf , "Daniel P. =?UTF-8?B?QmVycmFuZ8Op?= =?UTF-8?B?XA==?=" , qemu-block , Juan Quintela , Markus Armbruster , "Dr. David Alan Gilbert" , Max Reitz , =?UTF-8?B?TWFyYy1BbmRyw6k=?= Lureau , Paolo Bonzini , =?UTF-8?B?TWFyYy1BbmRyw6k=?= Lureau Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-Zoho-Virus-Status: 1 X-ZohoMail-DKIM: fail (Header signature does not verify) --Sig_/+Ht_S1PnncfnCrv6lSbhUQO Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" A connecting chardev object has an additional reference by the connecting thread, so if the chardev is still connecting by the end of the test, then the chardev object won't be freed. This in turn means that the yank instance won't be unregistered and when running the next test-case yank_register_instance will abort, because the yank instance is already/still registered. Signed-off-by: Lukas Straub Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/test-char.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test-char.c b/tests/test-char.c index 953e0d1c1f..41a76410d8 100644 --- a/tests/test-char.c +++ b/tests/test-char.c @@ -937,6 +937,7 @@ static void char_socket_client_dupid_test(gconstpointer= opaque) g_assert_nonnull(opts); chr1 =3D qemu_chr_new_from_opts(opts, NULL, &error_abort); g_assert_nonnull(chr1); + qemu_chr_wait_connected(chr1, &error_abort); chr2 =3D qemu_chr_new_from_opts(opts, NULL, &local_err); g_assert_null(chr2); -- 2.29.2 --Sig_/+Ht_S1PnncfnCrv6lSbhUQO Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEg/qxWKDZuPtyYo+kNasLKJxdslgFAl/p9Q4ACgkQNasLKJxd sljndw//cgsX6o5fJKyUj58ECvTp32SHdeQz3o95IBApa3MtsAnfNridHbuUu+qJ wWpcs/5SY+qmYyVxrcNEDsqh0RfqM9atTMeAxMx47kGNCLkIi14SjQVUDhS2zI4k BEmUDbGD4ogdg4CeNIwaqJWuLcT9sP000yuyVnqAFpNRcGQ0rrarI5BWOJWPjjIl lOk2b6zgkIP4mpd+IIfUNrdl4J6wDf44MoIK33WYsLukGiurVq0EnWw486dwzt9R O2hUxVQi7poPcgilafuHx7SmqkkSAuDKIEXPdR31LgzylmyMBiASCJzm9v6BVmHV GwbVeslIl4053czH+eEYuXMlKkd8sdUcs01mEaTgtx7mewvr7ZrW5xIMfx0aZPgu +clIXWYkTqFd3n69yzw91MaicGDSfG/6qziwEk1JOrK7HB9djy4HbVsn9ujhDNRW zLuGEyYMxyaqnu0K1robkuerI8Wu40su2sfwoEfot1zI8kAo3B6ZDECQVylZ5Ykt stO1W7balFjUqN3n7uSxUE9Pz2PEnnrm7pPKvrscbFi8l/6JabppcLRvRXciQfbt l5QYLB2/qSPDWlP0Rp0mVgG/uXXsE9qkkG93zT3wBhxDh4Q1SwUwPFszz8tTk112 keRpTUzRdbRuqFp/yVumEiHoZKYLjswYrc4HeIMHTXNvINTXcjQ= =qVME -----END PGP SIGNATURE----- --Sig_/+Ht_S1PnncfnCrv6lSbhUQO--