From patchwork Tue Aug 4 08:11:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 11699933 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D10D214E3 for ; Tue, 4 Aug 2020 08:13:58 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id CCBE92076C for ; Tue, 4 Aug 2020 08:13:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=web.de header.i=@web.de header.b="Dr4wLiuX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CCBE92076C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=web.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:44314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k2s57-0005C4-PR for patchwork-qemu-devel@patchwork.kernel.org; Tue, 04 Aug 2020 04:13:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51124) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2s2x-0003Tt-M6; Tue, 04 Aug 2020 04:11:43 -0400 Received: from mout.web.de ([212.227.15.3]:40871) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2s2v-0006YQ-ED; Tue, 04 Aug 2020 04:11:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1596528695; bh=n3bcMhJUMtsuhIlemqKrJB34futb6YIRpTnSTeJBGnI=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=Dr4wLiuXuzomvgw/qkCKoZWFu6fAY26EbnWSF23e90REUX44mGxSaLa58edhaxCg1 4V7EeFxXYg8xAZCCVi1nJQdcoY7WGsqUXMN+KBnoY/K8BWntWi0n0H3fMEZE2n+wxE LWkuegoFY3EuFCsKhahapPV6WuxP2abnBeNPlhSA= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([89.247.255.220]) by smtp.web.de (mrweb006 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MhFlm-1kh8o11pNy-00eM5N; Tue, 04 Aug 2020 10:11:35 +0200 Date: Tue, 4 Aug 2020 10:11:34 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v7 1/8] Introduce yank feature Message-ID: <0092d4fe5f64078a18db3790c46c508416dbdb6b.1596528468.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:Es88qH/Aqvply2anQKFgFbpXzprz9NwL4B6hgl1rTb5kN30bLgE oqL31Igh9KVjqNOjcr3G15p9x09+4zx2KP3IK7SviT2Z8V/J4tm+nHLzdGl7QjA5eQLfqTM 5Ah0P8Gd8AgW5uhk1V9zDZ3PjuDm4MwC0Nxn/j0KOd+EAW/XujfP6QuupEi1SPq6IgUVl2f 2QiSwrJtYt/wf21HD9/dA== X-UI-Out-Filterresults: notjunk:1;V03:K0:8THhKp3WRXE=:nxZTBFgceZf+bMeyaQrgT4 4h4GiDSNvfJNNoFEfQJw/MW9HDP0876ew/AUYpQdZKSuwxJij/4Mk9BtwetmN3Qg73/0NkSCH XbgfhaOsJtCNUOHvLhuzAl3yXhdeq+qWcjgGyH+RwbTdse8QWKmgz822tdd+sobfscXzKK0HD I9D78cc2efzviSRe8sQE4uU2X4FEkU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YjvQ+3eMG3/npOHN6tDo8zvy/5OA== 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/08/04 04:11:39 X-ACL-Warn: Detected OS = Linux 3.11 and newer X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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: Daniel P. Berrangé --- include/qemu/yank.h | 80 +++++++++++++++++++ qapi/misc.json | 45 +++++++++++ util/Makefile.objs | 1 + util/yank.c | 184 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 310 insertions(+) create mode 100644 include/qemu/yank.h create mode 100644 util/yank.c -- 2.20.1 diff --git a/include/qemu/yank.h b/include/qemu/yank.h new file mode 100644 index 0000000000..cd184fcd05 --- /dev/null +++ b/include/qemu/yank.h @@ -0,0 +1,80 @@ +/* + * QEMU yank feature + * + * Copyright (c) Lukas Straub + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef YANK_H +#define 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 yank + * function is registered for this instance. + * + * This function is thread-safe. + * + * @instance_name: The globally unique name of the instance. + * @errp: ... + */ +void yank_register_instance(const char *instance_name, Error **errp); + +/** + * yank_unregister_instance: Unregister a instance. + * + * This unregisters a instance. Must be called only after every yank function + * of the instance has been unregistered. + * + * This function is thread-safe. + * + * @instance_name: The name of the instance. + */ +void yank_unregister_instance(const char *instance_name); + +/** + * yank_register_function: Register a yank function + * + * This registers a yank function. All limitations of qmp oob commands apply + * to the yank function as well. + * + * This function is thread-safe. + * + * @instance_name: The name of the instance + * @func: The yank function + * @opaque: Will be passed to the yank function + */ +void yank_register_function(const char *instance_name, + YankFn *func, + void *opaque); + +/** + * yank_unregister_function: Unregister a yank function + * + * This unregisters a yank function. + * + * This function is thread-safe. + * + * @instance_name: The name of 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 char *instance_name, + YankFn *func, + void *opaque); + +/** + * yank_unregister_function: 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); +#endif diff --git a/qapi/misc.json b/qapi/misc.json index 9d32820dc1..0d6a8f20b7 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -1615,3 +1615,48 @@ ## { 'command': 'query-vm-generation-id', 'returns': 'GuidInfo' } +## +# @YankInstances: +# +# @instances: List of yank instances. +# +# Yank instances are named after the following schema: +# "blockdev:", "chardev:" and "migration" +# +# Since: 5.1 +## +{ 'struct': 'YankInstances', 'data': {'instances': ['str'] } } + +## +# @yank: +# +# Recover from hanging qemu by yanking the specified instances. +# +# Takes @YankInstances as argument. +# +# Returns: nothing. +# +# Example: +# +# -> { "execute": "yank", "arguments": { "instances": ["blockdev:nbd0"] } } +# <- { "return": {} } +# +# Since: 5.1 +## +{ 'command': 'yank', 'data': 'YankInstances', 'allow-oob': true } + +## +# @query-yank: +# +# Query yank instances. +# +# Returns: @YankInstances +# +# Example: +# +# -> { "execute": "query-yank" } +# <- { "return": { "instances": ["blockdev:nbd0"] } } +# +# Since: 5.1 +## +{ 'command': 'query-yank', 'returns': 'YankInstances', 'allow-oob': true } diff --git a/util/Makefile.objs b/util/Makefile.objs index cc5e37177a..13faa98425 100644 --- a/util/Makefile.objs +++ b/util/Makefile.objs @@ -45,6 +45,7 @@ util-obj-$(CONFIG_GIO) += dbus.o dbus.o-cflags = $(GIO_CFLAGS) dbus.o-libs = $(GIO_LIBS) util-obj-$(CONFIG_USER_ONLY) += selfmap.o +util-obj-y += yank.o ####################################################################### # code used by both qemu system emulation and qemu-img diff --git a/util/yank.c b/util/yank.c new file mode 100644 index 0000000000..b0cd27728b --- /dev/null +++ b/util/yank.c @@ -0,0 +1,184 @@ +/* + * QEMU yank feature + * + * Copyright (c) Lukas Straub + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu/thread.h" +#include "qemu/queue.h" +#include "qapi/qapi-commands-misc.h" +#include "io/channel.h" +#include "qemu/yank.h" + +struct YankFuncAndParam { + YankFn *func; + void *opaque; + QLIST_ENTRY(YankFuncAndParam) next; +}; + +struct YankInstance { + char *name; + QLIST_HEAD(, YankFuncAndParam) yankfns; + QLIST_ENTRY(YankInstance) next; +}; + +static QemuMutex lock; +static QLIST_HEAD(yankinst_list, YankInstance) head + = QLIST_HEAD_INITIALIZER(head); + +static struct YankInstance *yank_find_instance(const char *name) +{ + struct YankInstance *tmp, *instance; + instance = NULL; + QLIST_FOREACH(tmp, &head, next) { + if (!strcmp(tmp->name, name)) { + instance = tmp; + } + } + return instance; +} + +void yank_register_instance(const char *instance_name, Error **errp) +{ + struct YankInstance *instance; + + qemu_mutex_lock(&lock); + + if (yank_find_instance(instance_name)) { + error_setg(errp, "duplicate yank instance name: '%s'", instance_name); + qemu_mutex_unlock(&lock); + return; + } + + instance = g_slice_new(struct YankInstance); + instance->name = g_strdup(instance_name); + QLIST_INIT(&instance->yankfns); + QLIST_INSERT_HEAD(&head, instance, next); + + qemu_mutex_unlock(&lock); +} + +void yank_unregister_instance(const char *instance_name) +{ + struct YankInstance *instance; + + qemu_mutex_lock(&lock); + instance = yank_find_instance(instance_name); + assert(instance); + + assert(QLIST_EMPTY(&instance->yankfns)); + QLIST_REMOVE(instance, next); + g_free(instance->name); + g_slice_free(struct YankInstance, instance); + + qemu_mutex_unlock(&lock); +} + +void yank_register_function(const char *instance_name, + YankFn *func, + void *opaque) +{ + struct YankInstance *instance; + struct YankFuncAndParam *entry; + + qemu_mutex_lock(&lock); + instance = yank_find_instance(instance_name); + assert(instance); + + entry = g_slice_new(struct YankFuncAndParam); + entry->func = func; + entry->opaque = opaque; + + QLIST_INSERT_HEAD(&instance->yankfns, entry, next); + qemu_mutex_unlock(&lock); +} + +void yank_unregister_function(const char *instance_name, + YankFn *func, + void *opaque) +{ + struct YankInstance *instance; + struct YankFuncAndParam *entry; + + qemu_mutex_lock(&lock); + instance = yank_find_instance(instance_name); + assert(instance); + + QLIST_FOREACH(entry, &instance->yankfns, next) { + if (entry->func == func && entry->opaque == opaque) { + QLIST_REMOVE(entry, next); + g_slice_free(struct YankFuncAndParam, entry); + qemu_mutex_unlock(&lock); + return; + } + } + + abort(); +} + +void yank_generic_iochannel(void *opaque) +{ + QIOChannel *ioc = QIO_CHANNEL(opaque); + + qio_channel_shutdown(ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL); +} + +void qmp_yank(strList *instances, + Error **errp) +{ + strList *tmp; + struct YankInstance *instance; + struct YankFuncAndParam *entry; + + qemu_mutex_lock(&lock); + tmp = instances; + for (; tmp; tmp = tmp->next) { + instance = yank_find_instance(tmp->value); + if (!instance) { + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + "Instance '%s' not found", tmp->value); + qemu_mutex_unlock(&lock); + return; + } + } + tmp = instances; + for (; tmp; tmp = tmp->next) { + instance = yank_find_instance(tmp->value); + assert(instance); + QLIST_FOREACH(entry, &instance->yankfns, next) { + entry->func(entry->opaque); + } + } + qemu_mutex_unlock(&lock); +} + +YankInstances *qmp_query_yank(Error **errp) +{ + struct YankInstance *instance; + YankInstances *ret; + + ret = g_new0(YankInstances, 1); + ret->instances = NULL; + + qemu_mutex_lock(&lock); + QLIST_FOREACH(instance, &head, next) { + strList *entry; + entry = g_new0(strList, 1); + entry->value = g_strdup(instance->name); + entry->next = ret->instances; + ret->instances = entry; + } + qemu_mutex_unlock(&lock); + + return ret; +} + +static void __attribute__((__constructor__)) yank_init(void) +{ + qemu_mutex_init(&lock); +} From patchwork Tue Aug 4 08:11:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 11699953 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 26B4E913 for ; Tue, 4 Aug 2020 08:19:02 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 21D952076C for ; Tue, 4 Aug 2020 08:19:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=web.de header.i=@web.de header.b="WVmTnNZX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 21D952076C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=web.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:52020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k2sA1-0008VS-2O for patchwork-qemu-devel@patchwork.kernel.org; Tue, 04 Aug 2020 04:19:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51142) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2s31-0003Wa-TY; Tue, 04 Aug 2020 04:11:47 -0400 Received: from mout.web.de ([212.227.17.12]:41563) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2s2z-0006ZP-KY; Tue, 04 Aug 2020 04:11:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1596528699; bh=gYLkaLVifVVybkD4dZzByIAONcymChjA5zGr5nxBC4k=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=WVmTnNZXS8YWJsXUGRNZWZiYhu/JXFhETNum2gjkbkv8xO4j12BCbqSMidLnSc5Y3 ddLUU/arITmvXb3RQ4wNTYVikmH/S89nMjZDlof+JmHdR7eNl6Bc9d7czh2/En6yM2 kmgl/6InD4b/AGAWVXCbc8sm4tjDNtbEqncwyTO8= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([89.247.255.220]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MeSKR-1kO5x62UOd-00Q8VG; Tue, 04 Aug 2020 10:11:39 +0200 Date: Tue, 4 Aug 2020 10:11:37 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v7 2/8] block/nbd.c: Add yank feature Message-ID: <331864b96d198a6cfabd050581e94bc3452362aa.1596528468.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:RQvrVnOEw5VqZQ61FbfDNTJgN/jY2h+db6zwFQ//gDqUK2YzBWs YVZaJnsYcKB5t0/QyjhWufZqUGemmlIrnZwLFARs6ZXgahhwlu5bRvXBH22g2AlfNNNxWVK Ggpodglbql1NpU5jsbozVwjysIv4KR531m1fKKLjvf1ysl4cCs7aAKDw/54Por9DE7ms7c2 m35ByH5z7b912LZYsZRcg== X-UI-Out-Filterresults: notjunk:1;V03:K0:pCJd6LLGNZI=:Q5pHYFxlu6tHPNN09Nz05+ tw/mQSICLiuhiGdJBxo4y2qkJ592ArNfUKCWubC6ftcp3x3NKF8NtE/FQFqvJ/t9wULeh43oV dQMbXOvcX1D6bmFf7PADgj+zH8Xkj7yWEviMoNxyXBWNR3/EOd16jxx93bOLn0PaP1LZRcZzF KRof6d0+znSrCBx5hDRiT84ftDZWzv6ZkqxxWi7NmWGmshtpOO/TuS2kuM1oTt5rQrB8XGwAz uIUy8vLTWplafjOpkrscpISOVHXMpKOZ+PKpcdG2/WgPHP8VEtCTsdQbHmVanw0CgNPuNYaQe wbPMeXmVNglkTX5pTI50pVKmxWk+gwEiYKUAe1q2xZPhRtco2z4EmHYLZHqkPGTG8xuHH6t5R WynG3gGOiWCMQu/UrV3MDD+sYXBaQNAtOnexNsSJELlBKv18vJUbGTbazH404R3pvWy7dqQPu KKhFaoPC1bEF8W8zGbPs6sgZ8nMmfvc5I1ltRbZ/TdoZxv0dFPE4yNE7avv5S5OwqfZnN9fdY Jp1vAOT/PxFsf19g/jYAPIrPpFkyTf8J5yHzuptIbucmBP32KPhkZeNdKf+YyDstaR7iI/Pmz 9Ih2vB+RQmc0aOofTvbnBKSMYIoQkbeVmeHezfMmX46CG15ntO8NNjGX7WaVuMqPeLvxT08J5 oPE+3Xs6fsfoOtiqmf4ArQpz3IVCjnwythcHY0uWJHW4lOWl7AABKiqPS09izfq77pINhdPx1 5KDivcoL20cxl59od6nfeYBphWzrRG0lUWEwJqjVS/zhCSFZ+cDKhal6ePXjTwLSZ//jSelmX Bf/R0tEmPsPJCJOeXqoirnUqPUaRlV915iNpEkKvtmOPrAdoNKsluOKvT+awpGtjm1SeyOv1c gIBE8oDpe9VnpbmOZgNeR2/mXjascCOQxcVvovuIm+zTL7xBPMV5qgl5hquXvSYRGgK59Oi3s mptuJUS2NlDXPveaVsYCtB/VlmD0m2JAQW/eZQFsoWyaCWCKr5HGbP567zFP7ycUN2QYGKCdI Cf87sgi4/absZJRpieM10bloiPaVaHGZo+xUpcrlaYCZPnhzK0hhlHIyGCnuHj7o8+r1f1i/D +cukqPpm6j92gpldSG+QeWIE6a6gpE8OVH1jngoQ3LbV6VxIIn8pQyX78za06VZDALZlk2GL3 VWbO2euPhHO0zH9Tjn9BapoQ3QDpbmrz+ESeTI7kkLIoffcwLP7eq+oB3JLX15uQefTvaiE3S GcXjwB7qIgnDHMcToiPm13pApKeV+q7TneyDwuA== Received-SPF: pass client-ip=212.227.17.12; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/04 04:11:44 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Register a yank function which shuts down the socket and sets s->state = NBD_CLIENT_QUIT. This is the same behaviour as if an error occured. Signed-off-by: Lukas Straub Acked-by: Stefan Hajnoczi Reviewed-by: Daniel P. Berrangé --- block/nbd.c | 129 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 80 insertions(+), 49 deletions(-) -- 2.20.1 diff --git a/block/nbd.c b/block/nbd.c index 7bb881fef4..8632cf5340 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" @@ -43,6 +44,8 @@ #include "block/nbd.h" #include "block/block_int.h" +#include "qemu/yank.h" + #define EN_OPTSTR ":exportname=" #define MAX_NBD_REQUESTS 16 @@ -84,6 +87,8 @@ typedef struct BDRVNBDState { NBDReply reply; BlockDriverState *bs; + char *yank_name; + /* Connection parameters */ uint32_t reconnect_delay; SocketAddress *saddr; @@ -93,10 +98,10 @@ typedef struct BDRVNBDState { char *x_dirty_bitmap; } BDRVNBDState; -static QIOChannelSocket *nbd_establish_connection(SocketAddress *saddr, - Error **errp); -static int nbd_client_handshake(BlockDriverState *bs, QIOChannelSocket *sioc, - Error **errp); +static int nbd_establish_connection(BlockDriverState *bs, SocketAddress *saddr, + Error **errp); +static int nbd_client_handshake(BlockDriverState *bs, Error **errp); +static void nbd_yank(void *opaque); static void nbd_clear_bdrvstate(BDRVNBDState *s) { @@ -109,17 +114,19 @@ static void nbd_clear_bdrvstate(BDRVNBDState *s) s->tlscredsid = NULL; g_free(s->x_dirty_bitmap); s->x_dirty_bitmap = NULL; + g_free(s->yank_name); + s->yank_name = NULL; } static void nbd_channel_error(BDRVNBDState *s, int ret) { if (ret == -EIO) { - if (s->state == NBD_CLIENT_CONNECTED) { + if (atomic_load_acquire(&s->state) == NBD_CLIENT_CONNECTED) { s->state = s->reconnect_delay ? NBD_CLIENT_CONNECTING_WAIT : NBD_CLIENT_CONNECTING_NOWAIT; } } else { - if (s->state == NBD_CLIENT_CONNECTED) { + if (atomic_load_acquire(&s->state) == NBD_CLIENT_CONNECTED) { qio_channel_shutdown(s->ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL); } s->state = NBD_CLIENT_QUIT; @@ -170,7 +177,7 @@ static void nbd_client_attach_aio_context(BlockDriverState *bs, * s->connection_co is either yielded from nbd_receive_reply or from * nbd_co_reconnect_loop() */ - if (s->state == NBD_CLIENT_CONNECTED) { + if (atomic_load_acquire(&s->state) == NBD_CLIENT_CONNECTED) { qio_channel_attach_aio_context(QIO_CHANNEL(s->ioc), new_context); } @@ -237,20 +244,20 @@ static void nbd_teardown_connection(BlockDriverState *bs) static bool nbd_client_connecting(BDRVNBDState *s) { - return s->state == NBD_CLIENT_CONNECTING_WAIT || - s->state == NBD_CLIENT_CONNECTING_NOWAIT; + NBDClientState state = atomic_load_acquire(&s->state); + return state == NBD_CLIENT_CONNECTING_WAIT || + state == NBD_CLIENT_CONNECTING_NOWAIT; } static bool nbd_client_connecting_wait(BDRVNBDState *s) { - return s->state == NBD_CLIENT_CONNECTING_WAIT; + return atomic_load_acquire(&s->state) == NBD_CLIENT_CONNECTING_WAIT; } static coroutine_fn void nbd_reconnect_attempt(BDRVNBDState *s) { int ret; Error *local_err = NULL; - QIOChannelSocket *sioc; if (!nbd_client_connecting(s)) { return; @@ -283,21 +290,21 @@ static coroutine_fn void nbd_reconnect_attempt(BDRVNBDState *s) /* Finalize previous connection if any */ if (s->ioc) { nbd_client_detach_aio_context(s->bs); + yank_unregister_function(s->yank_name, nbd_yank, s->bs); object_unref(OBJECT(s->sioc)); s->sioc = NULL; object_unref(OBJECT(s->ioc)); s->ioc = NULL; } - sioc = nbd_establish_connection(s->saddr, &local_err); - if (!sioc) { + if (nbd_establish_connection(s->bs, s->saddr, &local_err) < 0) { ret = -ECONNREFUSED; goto out; } bdrv_dec_in_flight(s->bs); - ret = nbd_client_handshake(s->bs, sioc, &local_err); + ret = nbd_client_handshake(s->bs, &local_err); if (s->drained) { s->wait_drained_end = true; @@ -334,7 +341,7 @@ static coroutine_fn void nbd_co_reconnect_loop(BDRVNBDState *s) nbd_reconnect_attempt(s); while (nbd_client_connecting(s)) { - if (s->state == NBD_CLIENT_CONNECTING_WAIT && + if (atomic_load_acquire(&s->state) == NBD_CLIENT_CONNECTING_WAIT && qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - start_time_ns > delay_ns) { s->state = NBD_CLIENT_CONNECTING_NOWAIT; @@ -371,7 +378,7 @@ static coroutine_fn void nbd_connection_entry(void *opaque) int ret = 0; Error *local_err = NULL; - while (s->state != NBD_CLIENT_QUIT) { + while (atomic_load_acquire(&s->state) != 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. This is @@ -386,7 +393,7 @@ static coroutine_fn void nbd_connection_entry(void *opaque) nbd_co_reconnect_loop(s); } - if (s->state != NBD_CLIENT_CONNECTED) { + if (atomic_load_acquire(&s->state) != NBD_CLIENT_CONNECTED) { continue; } @@ -441,6 +448,7 @@ static coroutine_fn void nbd_connection_entry(void *opaque) s->connection_co = NULL; if (s->ioc) { nbd_client_detach_aio_context(s->bs); + yank_unregister_function(s->yank_name, nbd_yank, s->bs); object_unref(OBJECT(s->sioc)); s->sioc = NULL; object_unref(OBJECT(s->ioc)); @@ -465,7 +473,7 @@ static int nbd_co_send_request(BlockDriverState *bs, qemu_co_queue_wait(&s->free_sema, &s->send_mutex); } - if (s->state != NBD_CLIENT_CONNECTED) { + if (atomic_load_acquire(&s->state) != NBD_CLIENT_CONNECTED) { rc = -EIO; goto err; } @@ -492,7 +500,7 @@ static int nbd_co_send_request(BlockDriverState *bs, if (qiov) { qio_channel_set_cork(s->ioc, true); rc = nbd_send_request(s->ioc, request); - if (rc >= 0 && s->state == NBD_CLIENT_CONNECTED) { + if (rc >= 0 && atomic_load_acquire(&s->state) == NBD_CLIENT_CONNECTED) { if (qio_channel_writev_all(s->ioc, qiov->iov, qiov->niov, NULL) < 0) { rc = -EIO; @@ -807,7 +815,7 @@ static coroutine_fn int nbd_co_do_receive_one_chunk( s->requests[i].receiving = true; qemu_coroutine_yield(); s->requests[i].receiving = false; - if (s->state != NBD_CLIENT_CONNECTED) { + if (atomic_load_acquire(&s->state) != NBD_CLIENT_CONNECTED) { error_setg(errp, "Connection closed"); return -EIO; } @@ -966,7 +974,7 @@ static bool nbd_reply_chunk_iter_receive(BDRVNBDState *s, NBDReply local_reply; NBDStructuredReplyChunk *chunk; Error *local_err = NULL; - if (s->state != NBD_CLIENT_CONNECTED) { + if (atomic_load_acquire(&s->state) != NBD_CLIENT_CONNECTED) { error_setg(&local_err, "Connection closed"); nbd_iter_channel_error(iter, -EIO, &local_err); goto break_loop; @@ -991,7 +999,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 != NBD_CLIENT_CONNECTED) { + if (nbd_reply_is_simple(reply) || + atomic_load_acquire(&s->state) != NBD_CLIENT_CONNECTED) { goto break_loop; } @@ -1423,6 +1432,15 @@ static int nbd_client_reopen_prepare(BDRVReopenState *state, return 0; } +static void nbd_yank(void *opaque) +{ + BlockDriverState *bs = opaque; + BDRVNBDState *s = (BDRVNBDState *)bs->opaque; + + atomic_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 = (BDRVNBDState *)bs->opaque; @@ -1435,52 +1453,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 = (BDRVNBDState *)bs->opaque; - sioc = qio_channel_socket_new(); - qio_channel_set_name(QIO_CHANNEL(sioc), "nbd-client"); + s->sioc = qio_channel_socket_new(); + qio_channel_set_name(QIO_CHANNEL(s->sioc), "nbd-client"); + yank_register_function(s->yank_name, nbd_yank, bs); - 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; + yank_unregister_function(s->yank_name, nbd_yank, bs); + object_unref(OBJECT(s->sioc)); + s->sioc = NULL; + return -1; } - qio_channel_set_delay(QIO_CHANNEL(sioc), false); + 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 *sioc, - 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 = (BDRVNBDState *)bs->opaque; AioContext *aio_context = bdrv_get_aio_context(bs); int ret; trace_nbd_client_handshake(s->export); - - s->sioc = 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 = true; s->info.structured_reply = true; s->info.base_allocation = true; s->info.x_dirty_bitmap = g_strdup(s->x_dirty_bitmap); s->info.name = g_strdup(s->export ?: ""); - ret = nbd_receive_negotiate(aio_context, QIO_CHANNEL(sioc), s->tlscreds, + ret = nbd_receive_negotiate(aio_context, QIO_CHANNEL(s->sioc), s->tlscreds, 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(s->yank_name, nbd_yank, bs); + object_unref(OBJECT(s->sioc)); s->sioc = NULL; return ret; } @@ -1508,7 +1527,7 @@ static int nbd_client_handshake(BlockDriverState *bs, QIOChannelSocket *sioc, } if (!s->ioc) { - s->ioc = QIO_CHANNEL(sioc); + s->ioc = QIO_CHANNEL(s->sioc); object_ref(OBJECT(s->ioc)); } @@ -1524,9 +1543,10 @@ static int nbd_client_handshake(BlockDriverState *bs, QIOChannelSocket *sioc, { NBDRequest request = { .type = 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(s->yank_name, nbd_yank, bs); + object_unref(OBJECT(s->sioc)); s->sioc = NULL; return ret; @@ -1918,7 +1938,6 @@ static int nbd_open(BlockDriverState *bs, QDict *options, int flags, { int ret; BDRVNBDState *s = (BDRVNBDState *)bs->opaque; - QIOChannelSocket *sioc; ret = nbd_process_options(bs, options, errp); if (ret < 0) { @@ -1929,17 +1948,28 @@ static int nbd_open(BlockDriverState *bs, QDict *options, int flags, qemu_co_mutex_init(&s->send_mutex); qemu_co_queue_init(&s->free_sema); + s->yank_name = g_strconcat("blockdev:", bs->node_name, NULL); + yank_register_instance(s->yank_name, errp); + if (*errp) { + g_free(s->yank_name); + s->yank_name = NULL; + return -EEXIST; + } + /* * establish TCP connection, return error if it fails * TODO: Configurable retry-until-timeout behaviour. */ - sioc = nbd_establish_connection(s->saddr, errp); - if (!sioc) { + if (nbd_establish_connection(bs, s->saddr, errp) < 0) { + yank_unregister_instance(s->yank_name); + g_free(s->yank_name); + s->yank_name = NULL; return -ECONNREFUSED; } - ret = nbd_client_handshake(bs, sioc, errp); + ret = nbd_client_handshake(bs, errp); if (ret < 0) { + yank_unregister_instance(s->yank_name); nbd_clear_bdrvstate(s); return ret; } @@ -1997,6 +2027,7 @@ static void nbd_close(BlockDriverState *bs) BDRVNBDState *s = bs->opaque; nbd_client_close(bs); + yank_unregister_instance(s->yank_name); nbd_clear_bdrvstate(s); } From patchwork Tue Aug 4 08:11:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 11699935 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DEA0914E3 for ; Tue, 4 Aug 2020 08:14:06 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E92E52076C for ; Tue, 4 Aug 2020 08:14:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=web.de header.i=@web.de header.b="aPdMGOJj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E92E52076C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=web.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:44556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k2s5F-0005Hz-Q0 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 04 Aug 2020 04:14:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51154) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2s34-0003YW-BO; Tue, 04 Aug 2020 04:11:50 -0400 Received: from mout.web.de ([212.227.15.3]:35801) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2s32-0006aK-Em; Tue, 04 Aug 2020 04:11:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1596528703; bh=xEDe+zbBuVAXvPtAdZvI/hRMlZMB5Q4vXtnHyT3/2s0=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=aPdMGOJjV2YRFitkCwx+7ezT2NuDWgWLi81v8tb2gAbARBOecdrmtHGK/fmyNdMSs MNz/joZXnob5jSduaI5P1L8J0DA+6hgis/k0Wx3uafgYFsN3WmUJxsK7oRaCuCog2c lTHLafgwLJzpIqeIxRkL0c83EjaXRNf9vCKwkPi0= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([89.247.255.220]) by smtp.web.de (mrweb004 [213.165.67.108]) with ESMTPSA (Nemesis) id 0M8c2V-1kyXEa1oP5-00wFv9; Tue, 04 Aug 2020 10:11:43 +0200 Date: Tue, 4 Aug 2020 10:11:41 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v7 3/8] chardev/char-socket.c: Add yank feature Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:dG4H8LrPxo9gvV0K3JWJERG1ay+jx4IKXQ5xJcPwD4lnE+fEnkX OmnkNoFSsd2pkrSw3xp9tPzISSW/oUAkshI1Akx5CojK+HW9FEFqrVS8unYB+p7OQIDU0Fm Kibf9Kc2CJ8bpBhqFZZDHC95mvhPR4OvMByQWcvjV6MQApTN3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0oFl5q50ttY/RBxsv9vkcyO/hm0zybMXFrEfzcOKWB78vU8je7p6xlE b82N+h1pPovhqubxTWRkF1ESlyBaDF+j1MbJAvTbdczbtE+j7DMqncCgvCJCt8eYb1mtCTpIF 7EV5OjvPSIZQYUifQQj1ERbiaI+fWFGVAEg456m3ADXuqQvwJSBxFiuLA7WlgGquFpluctevv nZHasVNetuxM1Octtzg6fg5uwrbG8edKO0hAeEeotlbmycyJ0VgI5fvFXnPgs3ll4+DMPSVk1 to64bErWS1bKAz7dheOmkP3ezPCbjTw2OIsT0Zg== 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/08/04 04:11:39 X-ACL-Warn: Detected OS = Linux 3.11 and newer X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Register a yank function to shutdown the socket on yank. Signed-off-by: Lukas Straub Acked-by: Stefan Hajnoczi Reviewed-by: Daniel P. Berrangé --- chardev/char-socket.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) -- 2.20.1 diff --git a/chardev/char-socket.c b/chardev/char-socket.c index ef62dbf3d7..8e2865ca83 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" @@ -69,6 +70,7 @@ typedef struct { size_t read_msgfds_num; int *write_msgfds; size_t write_msgfds_num; + char *yank_name; SocketAddress *addr; bool is_listen; @@ -413,6 +415,11 @@ static void tcp_chr_free_connection(Chardev *chr) tcp_set_msgfds(chr, NULL, 0); remove_fd_in_watch(chr); + if (s->state == TCP_CHARDEV_STATE_CONNECTING + || s->state == TCP_CHARDEV_STATE_CONNECTED) { + yank_unregister_function(s->yank_name, yank_generic_iochannel, + QIO_CHANNEL(s->sioc)); + } object_unref(OBJECT(s->sioc)); s->sioc = NULL; object_unref(OBJECT(s->ioc)); @@ -916,6 +923,8 @@ 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(s->yank_name, yank_generic_iochannel, + QIO_CHANNEL(sioc)); ret = tcp_chr_new_client(chr, sioc); object_unref(OBJECT(sioc)); return ret; @@ -930,6 +939,8 @@ 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(s->yank_name, yank_generic_iochannel, + QIO_CHANNEL(cioc)); tcp_chr_new_client(chr, cioc); } @@ -945,6 +956,8 @@ static int tcp_chr_connect_client_sync(Chardev *chr, Error **errp) object_unref(OBJECT(sioc)); return -1; } + yank_register_function(s->yank_name, yank_generic_iochannel, + QIO_CHANNEL(sioc)); tcp_chr_new_client(chr, sioc); object_unref(OBJECT(sioc)); return 0; @@ -960,6 +973,8 @@ static void tcp_chr_accept_server_sync(Chardev *chr) tcp_chr_change_state(s, TCP_CHARDEV_STATE_CONNECTING); sioc = qio_net_listener_wait_client(s->listener); tcp_chr_set_client_ioc_name(chr, sioc); + yank_register_function(s->yank_name, yank_generic_iochannel, + QIO_CHANNEL(sioc)); tcp_chr_new_client(chr, sioc); object_unref(OBJECT(sioc)); } @@ -1070,6 +1085,10 @@ static void char_socket_finalize(Object *obj) object_unref(OBJECT(s->tls_creds)); } g_free(s->tls_authz); + if (s->yank_name) { + yank_unregister_instance(s->yank_name); + g_free(s->yank_name); + } qemu_chr_be_event(chr, CHR_EVENT_CLOSED); } @@ -1085,6 +1104,8 @@ 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(s->yank_name, yank_generic_iochannel, + QIO_CHANNEL(sioc)); check_report_connect_error(chr, err); goto cleanup; } @@ -1118,6 +1139,8 @@ static void tcp_chr_connect_client_async(Chardev *chr) tcp_chr_change_state(s, TCP_CHARDEV_STATE_CONNECTING); sioc = qio_channel_socket_new(); tcp_chr_set_client_ioc_name(chr, sioc); + yank_register_function(s->yank_name, 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 @@ -1360,6 +1383,14 @@ static void qmp_chardev_open_socket(Chardev *chr, qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_FD_PASS); } + s->yank_name = g_strconcat("chardev:", chr->label, NULL); + yank_register_instance(s->yank_name, errp); + if (*errp) { + g_free(s->yank_name); + s->yank_name = NULL; + return; + } + /* be isn't opened until we get a connection */ *be_opened = false; From patchwork Tue Aug 4 08:11:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 11699955 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 19DA5913 for ; Tue, 4 Aug 2020 08:19:47 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 148BA2076C for ; Tue, 4 Aug 2020 08:19:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=web.de header.i=@web.de header.b="fuTnhldl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 148BA2076C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=web.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:53100 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k2sAk-0000XI-0V for patchwork-qemu-devel@patchwork.kernel.org; Tue, 04 Aug 2020 04:19:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51168) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2s39-0003cr-Av; Tue, 04 Aug 2020 04:11:55 -0400 Received: from mout.web.de ([217.72.192.78]:34627) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2s37-0006bJ-3B; Tue, 04 Aug 2020 04:11:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1596528707; bh=7L3s5EjxRt+eOZ78W6TKKUDcFvSCE8Nn+E6n9Q/Tngo=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=fuTnhldlgBMm7KK9cofO2APIkNLcRFKwXo4veLbJYMLLo6tEF84Xd/NjydXih/ry6 kH+zgXHPYSOMIAUxKr64x/F3MhqC3EaqbJgc8PPV1I5ZMV8anRxfAIxQIquDABXhgC k3XijOrN8+bz7kt+jEn10nBeowzzrlQJ4xgg9ddo= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([89.247.255.220]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MXYeQ-1kHoPd20la-00WWUf; Tue, 04 Aug 2020 10:11:47 +0200 Date: Tue, 4 Aug 2020 10:11:45 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v7 4/8] migration: Add yank feature Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:A8ccW7cWdEW21ryWus8rORgRX/xmxI5cdCqcVHk/zds0i5oiNMi EyXFmykss08vN2LqKoQU/CDburAd2bZoaSbVGUKCUbHg6ha04pGaRoS1wEFiSGNoQjjRqJN cK/FDABsL4trrDUW47o6f8Qee8QReec0vG1Q5y7ODbQax+/5vmv95KHkPNd/i3sVc41fUU6 MxbxsD2OV/5wH/uNF6N4Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:IG8sV5X4tRI=:x8jcojFtI/Wt2OvrfXe3Em AqvbQ2K5E8MVF3W8Z2tNir06WgtgcQIMSYxXMIQYLGlchaaXqM2aWXa8jsj3JzXIlvX74A2Nl rOhpSGzCCCO+XzAF5oCU9oTuLMMtIr95PIHgllADnXQAOfG/QGtdeZc8SxbCGALngCYVkc7SN wcy8f0onPyC0YI7rH828qkbNsR/2lN5f5h4nInX6R+oqahYZX+TJKXjELK1XRTLBSVUO9/uwl Jec+mwd+kiYVx4/fd7M4gNE4rp0vLohlMz7jD1vdJpqLKDr7WF4rZuRvRew/3DcNodBZCTfxL ews6Q6F9NmgxSrtcsiGkeuSLVUHnbDpllzsQxKf+xuX7liXP5vxCRD/nZ7IV3dCSNPksHqSNh fn+JLZU8qLCHGqXjmjKugpZvgKu5SzK8fDtGpiXyQdzx11HnSbwC89vgyyeAS/tmuMEoyBcq8 pDHlDQoM/yrqlVYyXmME5+eWvM7xyX9Z0qMkcNIgtZSNQu2Toh4shX8nuQ3jWXb4pgCYjycxU MgQlt56MjTi9vshAXrwHEiqIDE5+AMc5uyh8BV5HzDJWgNNS/8w/bxD8ShtY69RUMFBn//xbq t+vSrAvFZq87lXl29nT0o7I1m46saYVI51bSrsfteJXoOqYpE6RJEiIQsXXgn9Pir5JoGNWdj Cb+Gwpwkt3vAdspRi+B0KTkGVk6niL9A+lcVP9ycnFG72Xxi6yAAPZGYbcGZIDiUfZ02lzFAT LT7oHs/NPggtjboNcu2FIz4avFyhEUlyK092D9o/e5zl99YDDd+BJEdiYG3t4QFdqrZM83t7r HOVjBO+F+2l+/8i1XNzlvqHPI4/uv1ahtQEeOFvT8fWxKVn5pJ/BobxEajq4OGSAXFIcic3lA X1ucVE21PazSmtsXJC6tGAy1M1v4AvJ0vJye8+iXNb/YAbppZ02IVeMtcO1TQzjDai4tksXt4 Om3jZ5e+drwKH0uAljX78U1Tf9L+T+bebF4q1jee+UC0zVfNRi6/YgTVnxEm4j8Z8ZlXMGHnd OvW2TmmiBaLi4s/4ZDOa9ATD/ZfPsJRJvgB8UpCyZSWllk0/OdZNjPkg7+iIS6u1ckc+ViJKU r7A1cTg2EKK/SHNrNkntjXrPk9GGfr4JgxQrAEIz5HFFJtkti9ZzNDZAtVwA7LN6IiD9A2eHI cA5g4mkDfmE+3rNvlILn8ArozZ1Fa6bvgNKws+zw9ZFkLAX/E9pl1HymRNimVr16APeBhPku0 gh9H3GDQK9zAZp5QDNK2MthYUBotZJ9yfVzq6Dg== Received-SPF: pass client-ip=217.72.192.78; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/04 04:11:51 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.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_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Register yank functions on sockets to shut them down. Signed-off-by: Lukas Straub Acked-by: Stefan Hajnoczi Reviewed-by: Daniel P. Berrangé --- migration/channel.c | 12 ++++++++++++ migration/migration.c | 25 ++++++++++++++++++++++++- migration/multifd.c | 10 ++++++++++ migration/qemu-file-channel.c | 6 ++++++ migration/savevm.c | 6 ++++++ tests/Makefile.include | 2 +- 6 files changed, 59 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/migration/channel.c b/migration/channel.c index 20e4c8e2dc..21fc8046b9 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 channel @@ -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_generic_iochannel, + QIO_CHANNEL(ioc)); + } + if (s->parameters.tls_creds && *s->parameters.tls_creds && !object_dynamic_cast(OBJECT(ioc), @@ -67,6 +74,11 @@ 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_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 8fe36339db..e4818edb2a 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -55,6 +55,7 @@ #include "net/announce.h" #include "qemu/queue.h" #include "multifd.h" +#include "qemu/yank.h" #define MAX_THROTTLE (32 << 20) /* Migration transfer speed throttling */ @@ -243,6 +244,8 @@ void migration_incoming_state_destroy(void) qapi_free_SocketAddressList(mis->socket_address_list); mis->socket_address_list = NULL; } + + yank_unregister_instance("migration"); } static void migrate_generate_event(int new_state) @@ -379,8 +382,14 @@ void qemu_start_incoming_migration(const char *uri, Error **errp) { const char *p; + yank_register_instance("migration", errp); + if (*errp) { + return; + } + qapi_event_send_migration(MIGRATION_STATUS_SETUP); if (!strcmp(uri, "defer")) { + yank_unregister_instance("migration"); deferred_incoming_migration(errp); } else if (strstart(uri, "tcp:", &p)) { tcp_start_incoming_migration(p, errp); @@ -395,6 +404,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("migration"); error_setg(errp, "unknown migration protocol: %s", uri); } } @@ -1662,6 +1672,7 @@ static void migrate_fd_cleanup(MigrationState *s) } notifier_list_notify(&migration_state_notifiers, s); block_cleanup_parameters(s); + yank_unregister_instance("migration"); } static void migrate_fd_cleanup_schedule(MigrationState *s) @@ -1935,6 +1946,7 @@ void qmp_migrate_recover(const char *uri, Error **errp) * only re-setup the migration stream and poke existing migration * to continue using that newly established channel. */ + yank_unregister_instance("migration"); qemu_start_incoming_migration(uri, errp); } @@ -2071,7 +2083,12 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, /* Error detected, put into errp */ return; } - + if (!(has_resume && resume)) { + yank_register_instance("migration", errp); + if (*errp) { + return; + } + } if (strstart(uri, "tcp:", &p)) { tcp_start_outgoing_migration(s, p, &local_err); #ifdef CONFIG_RDMA @@ -2085,6 +2102,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"); + } error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "uri", "a valid migration protocol"); migrate_set_state(&s->state, MIGRATION_STATUS_SETUP, @@ -2094,6 +2114,9 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, } if (local_err) { + if (!(has_resume && resume)) { + yank_unregister_instance("migration"); + } migrate_fd_error(s, local_err); error_propagate(errp, local_err); return; diff --git a/migration/multifd.c b/migration/multifd.c index d0441202aa..2c9863e770 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -24,6 +24,9 @@ #include "trace.h" #include "multifd.h" +#include "qemu/yank.h" +#include "io/channel-socket.h" + /* Multiple fd's */ #define MULTIFD_MAGIC 0x11223344U @@ -866,6 +869,13 @@ int multifd_load_cleanup(Error **errp) for (i = 0; i < migrate_multifd_channels(); i++) { MultiFDRecvParams *p = &multifd_recv_state->params[i]; + if (object_dynamic_cast(OBJECT(p->c), TYPE_QIO_CHANNEL_SOCKET) + && OBJECT(p->c)->ref == 1) { + yank_unregister_function("migration", + yank_generic_iochannel, + QIO_CHANNEL(p->c)); + } + object_unref(OBJECT(p->c)); p->c = NULL; qemu_mutex_destroy(&p->mutex); diff --git a/migration/qemu-file-channel.c b/migration/qemu-file-channel.c index d2ce32f4b9..d8f8384fea 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,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 == 1) { + yank_unregister_function("migration", yank_generic_iochannel, + QIO_CHANNEL(ioc)); + } object_unref(OBJECT(ioc)); return ret; } diff --git a/migration/savevm.c b/migration/savevm.c index a843d202b5..395b8fa704 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -63,6 +63,7 @@ #include "migration/colo.h" #include "qemu/bitmap.h" #include "net/announce.h" +#include "qemu/yank.h" const unsigned int postcopy_ram_discard_version = 0; @@ -2935,6 +2936,11 @@ int load_snapshot(const char *name, Error **errp) qemu_system_reset(SHUTDOWN_CAUSE_NONE); mis->from_src_file = f; + yank_register_instance("migration", errp); + if (*errp) { + ret = -EINVAL; + goto err_drain; + } aio_context_acquire(aio_context); ret = qemu_loadvm_state(f); migration_incoming_state_destroy(); diff --git a/tests/Makefile.include b/tests/Makefile.include index c7e4646ded..e733918269 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -452,7 +452,7 @@ tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \ $(test-qapi-obj-y) tests/test-vmstate$(EXESUF): tests/test-vmstate.o \ migration/vmstate.o migration/vmstate-types.o migration/qemu-file.o \ - migration/qemu-file-channel.o migration/qjson.o \ + migration/qemu-file-channel.o migration/qjson.o util/yank.o \ $(test-io-obj-y) tests/test-timed-average$(EXESUF): tests/test-timed-average.o $(test-util-obj-y) tests/test-base64$(EXESUF): tests/test-base64.o $(test-util-obj-y) From patchwork Tue Aug 4 08:11:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 11699941 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 629D014E3 for ; Tue, 4 Aug 2020 08:15:02 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6D5F22076C for ; Tue, 4 Aug 2020 08:15:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=web.de header.i=@web.de header.b="lMnaxeRt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6D5F22076C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=web.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k2s69-000615-C6 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 04 Aug 2020 04:15:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2s3C-0003ff-7k; Tue, 04 Aug 2020 04:11:58 -0400 Received: from mout.web.de ([212.227.15.14]:57289) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2s3A-0006bY-CT; Tue, 04 Aug 2020 04:11:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1596528711; bh=bSWjpbZspePlZ8BZSSi8m7220at3pdOLN8eqbLiQZjc=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=lMnaxeRtZMcN4k+f97ZauF6e5EK97IzOck4+TEHjwSKNV1Wdy+JEaTNni51vzT7Bb 6UyomwDzfBMzBqcFMUdtw9SO6t+63NoDR3LGXdrRVF4/ZZ0io5gUFaVa4n46dJJGUf Nm7uf1bQGZRPZujIjQ8jSv4Sjb763U7gw37Btgj0= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([89.247.255.220]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MeBVG-1kOMum2zMc-00Ptq5; Tue, 04 Aug 2020 10:11:50 +0200 Date: Tue, 4 Aug 2020 10:11:49 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v7 5/8] io/channel-tls.c: make qio_channel_tls_shutdown thread-safe Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:pJpYlpelk/Vm8ALqpszS5baQJuC3IPf6uDNhx3t3cZ9u+2r7NFx zMEffUQjWoiSlCq4qzRt9KVvJaq4CMiVZCM86/oaoEDtksK7kH2k74cAU29+CCEfkjEIV0H 6DC/Bp+CfyXL9LIj/pHwgB5epRAlBmkalRqFWxYXixIGBmiL4AS+PCX3MhHiHnS7pC/1Mr6 KwzgCGQXFxjyENOPnQtig== X-UI-Out-Filterresults: notjunk:1;V03:K0:sEma/SQcmFQ=:wo767FoEFaCsXz+hfsESw0 qWUrRSk5cYm6l+6NNV+9tLiiFcGR/P7V554MvyD+C9GAVcFIvcYIDPzRlyGF3i+qxI24MBQRD yfVL1Yj5yfVLZW+hM7KBTNjq2fGtb/q7wjWHbhH/DOKDjiBIvHNL8VPQFBdNPm5lTlIGFZwZI tNVhhRUYl1qU2sNCpUTCno0rzB1mdiAdaz2+NYGpfh+phY8SzD5V9VSkw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d4WRcYUHMHcvAeRRPeMRWCoWoifw== Received-SPF: pass client-ip=212.227.15.14; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/04 04:11:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.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_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Make qio_channel_tls_shutdown thread-safe by using atomics when accessing tioc->shutdown. Signed-off-by: Lukas Straub Reviewed-by: Daniel P. Berrangé Acked-by: Stefan Hajnoczi --- io/channel-tls.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/io/channel-tls.c b/io/channel-tls.c index 7ec8ceff2f..b350c84640 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 == ECONNABORTED && - (tioc->shutdown & QIO_CHANNEL_SHUTDOWN_READ)) { + (atomic_load_acquire(&tioc->shutdown) & + QIO_CHANNEL_SHUTDOWN_READ)) { return 0; } @@ -361,7 +363,7 @@ static int qio_channel_tls_shutdown(QIOChannel *ioc, { QIOChannelTLS *tioc = QIO_CHANNEL_TLS(ioc); - tioc->shutdown |= how; + atomic_or(&tioc->shutdown, how); return qio_channel_shutdown(tioc->master, how, errp); } From patchwork Tue Aug 4 08:11:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 11699957 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2B13A1392 for ; Tue, 4 Aug 2020 08:20:42 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 31A832177B for ; Tue, 4 Aug 2020 08:20:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=web.de header.i=@web.de header.b="ZptSlHCn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 31A832177B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=web.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:54066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k2sBd-00012V-5Y for patchwork-qemu-devel@patchwork.kernel.org; Tue, 04 Aug 2020 04:20:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2s3G-0003j9-3P; Tue, 04 Aug 2020 04:12:02 -0400 Received: from mout.web.de ([212.227.17.11]:45101) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2s3E-0006cB-E3; Tue, 04 Aug 2020 04:12:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1596528714; bh=GDIipmN+9j6zL/53PXYOAbRC04vVOsa/k8/m4RzVmUM=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=ZptSlHCnrSJ34uVU9C73l1g1omWy96JjwT96kEBzPGgqmlaRQKjcfVeu35LEjZZOb kHn34lJy+zyVngEWnbM0xTc4r3+5UFaoxkFvSrN9IdKs4OrO9alvtgAjVENCVVpIw1 aUIOfCHOjkEhYcScTTrvcGVp4qlNm0dTPCGCy8vw= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([89.247.255.220]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0Lk8gg-1kaYAi2DxS-00cBEU; Tue, 04 Aug 2020 10:11:54 +0200 Date: Tue, 4 Aug 2020 10:11:53 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v7 6/8] io: Document thread-safety of qio_channel_shutdown Message-ID: <5d49ec9f44d508ad675fdaed8154f0d80cd48739.1596528468.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:BWYySGjNEtMmGTy2mJ9CkFtiKzhXOwvmFU4v3MWGzaP5W5NXqFU F86ltWVskJykPp1xHCLacNSVI5EbALSdMebq0jah8VdhTKUaFPlBPU2GkoScY1IqiTpU1HT tFBrj6DTtW2kMuLzdQI6Iq9zujbHLn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Cb WQDLPdQPGMVbAOb6A5QN0GjXV34+a3bkl77RNkkgvhEa6dLUBV+BK6RbwCPesHrYSBdQd5vFB D69JmjVGMp2RbFaJlUfL5F1qJnl3Ben3Rt8hHaxZNuO47hr8yLk8BBn2O05ghcaB5OlRNC+VA oCuKXEF8AyTPjsmaxcAwDB65mvHtBr4+6fdnXg5fXXc+4R2wdDrtySLgtKYQb5NJ2u5ch/h08 eH9V30vWBwfnYsSveVd44YuzLQRceAkHksBl+5qTeKQZR7m0J/uxOGa8WvYVMBIXA8JN1zszZ KAk4uLfBCx5TouvVmjW4Xgx7H0lAeUnknvHpIhg== Received-SPF: pass client-ip=212.227.17.11; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/04 04:11:34 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Migration and yank code assume that qio_channel_shutdown is thread -safe. Document this after checking the code. Signed-off-by: Lukas Straub Reviewed-by: Daniel P. Berrangé Acked-by: Stefan Hajnoczi --- include/io/channel.h | 2 ++ 1 file changed, 2 insertions(+) -- 2.20.1 diff --git a/include/io/channel.h b/include/io/channel.h index d4557f0930..6b8a2b87b8 100644 --- a/include/io/channel.h +++ b/include/io/channel.h @@ -516,6 +516,8 @@ int qio_channel_close(QIOChannel *ioc, * QIO_CHANNEL_FEATURE_SHUTDOWN prior to calling * this method. * + * This function is thread-safe. + * * Returns: 0 on success, -1 on error */ int qio_channel_shutdown(QIOChannel *ioc, From patchwork Tue Aug 4 08:11:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 11699959 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F100F14B7 for ; Tue, 4 Aug 2020 08:26:16 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id F26942070A for ; Tue, 4 Aug 2020 08:26:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=web.de header.i=@web.de header.b="d+dsyFmu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F26942070A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=web.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:59238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k2sH1-0003RF-QQ for patchwork-qemu-devel@patchwork.kernel.org; Tue, 04 Aug 2020 04:26:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51226) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2s3J-0003m4-BK; Tue, 04 Aug 2020 04:12:05 -0400 Received: from mout.web.de ([212.227.15.4]:50781) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2s3H-0006cP-KX; Tue, 04 Aug 2020 04:12:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1596528718; bh=jJiANSLgv/H5Do6WJz6D84z5O0+cbPoWlrgPB0cClfg=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=d+dsyFmuFysBCHX+4mb9NpoOFqiX/HsMmRCHVuflWOrjFlsDw5sL4g7UDTOaqMutg 5egFcsoYQGzD0sP++bFpmhfl37dPb80ZvSxB4dRZWQQAXp6vmY4XFB2qsinBGYsNzy QWRlGl3Zy+9JZEkRyVRpxRvkHmi2A8Y8mojdPITQ= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([89.247.255.220]) by smtp.web.de (mrweb006 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MJWsm-1kIKV41SBs-00Jnta; Tue, 04 Aug 2020 10:11:58 +0200 Date: Tue, 4 Aug 2020 10:11:57 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v7 7/8] MAINTAINERS: Add myself as maintainer for yank feature Message-ID: <5562d48f00ccebc3694cb2bd332b56441c64bebe.1596528468.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:xEIHEBr1PXfi7MuijFwo8/qUx8Grn3ynlzFbrnDhUdIqk04iPDA DdCaou4cHN+kUK+SVUkbT5Tfvy/Yk7R31rgJm5lKenSmx5yKt7QikDgRa208TGBwg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FgGfLDe8k5QYUjC4UYE9q6tdNTx0xljHVXtWk1z9QmcHzxaoHV5247 4nx8GROlw4YDeItg8kSRkHBY/u/1YdjphXOmszxYNCog9qBEcFSwcc14FJ6vnDJvjjHA5iOBo w0cmceIqM8qZtB9t7SXGZCAJ9omFpIktmhjTRYwHCbX5DhNZKVYwSzOJeMsrFGiPJAGcbXU59 CPxWgPh9LLQj5nhpoiHycWnZu3jiknuYTDHjFFbzBB4hulmWi/pWoUpjk8AnDcD2YfpLfckyt dc7ZszcxD7w9tfoREpH/Ozd4Jqjg8An1YVuak3NFdxQBBfW8EPt8rVwo/ksEZDu4jNwPUyzTL W2hLLaZrCJD3zNL82sJQLMOcG2SHhfrHtF3czKA== Received-SPF: pass client-ip=212.227.15.4; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/04 04:12:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" I'll maintain this for now as the colo usecase is the first user of this functionality. Signed-off-by: Lukas Straub Reviewed-by: Daniel P. Berrangé Acked-by: Stefan Hajnoczi --- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.20.1 diff --git a/MAINTAINERS b/MAINTAINERS index 0886eb3d2b..bf5075a637 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2614,6 +2614,12 @@ 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 + COLO Framework M: zhanghailiang S: Maintained From patchwork Tue Aug 4 08:12:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 11699961 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E9A111392 for ; Tue, 4 Aug 2020 08:31:16 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id D38D4206DA for ; Tue, 4 Aug 2020 08:31:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=web.de header.i=@web.de header.b="a5L+4sC7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D38D4206DA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=web.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:33900 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k2sLr-0004uh-PB for patchwork-qemu-devel@patchwork.kernel.org; Tue, 04 Aug 2020 04:31:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2s3P-0003rX-LV; Tue, 04 Aug 2020 04:12:11 -0400 Received: from mout.web.de ([212.227.17.11]:34305) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2s3N-0006d0-Vd; Tue, 04 Aug 2020 04:12:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1596528722; bh=KEmy6YMSKvjy+8JKgUemriIQsd+cq5JBtEE6CKfv37Q=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=a5L+4sC7DiSQXw34/iZxuKfBD8qIi8JAtgpWVqsaZv1TAgM1DHjtX/qUPK7+ILCSD aeIJZxeVnOV36rFO1WjdBBAboGkSPri5Z1XhsDFXIOodkFGa82B4TaAiStLkUP7PZG 2yxEf/trElAMJgotGD4uRERmgTAEuVlG8MERtBcc= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([89.247.255.220]) by smtp.web.de (mrweb103 [213.165.67.124]) with ESMTPSA (Nemesis) id 0LtnvF-1klwIh2v8X-0118Xe; Tue, 04 Aug 2020 10:12:02 +0200 Date: Tue, 4 Aug 2020 10:12:01 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v7 8/8] tests/test-char.c: Wait for the chardev to connect in char_socket_client_dupid_test Message-ID: <0c2f168afb1f66ccadef7ed623808aabf604fb65.1596528468.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:JqlhMxM2Wvc+dVPQauu08XY9qCHu6PE/2EtCxKJ310dLgS6sEgY cwyE9Lf0TfT6H7JB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/WUd7YqtSFHKAkqxfn 11Fg8oemU80rzasu/FI2wF1iNeKStiJkbroH3xkWvVKlcrZCb1ufHPuA+JvHs0GdiEBw5lkQn 0rYTqjOXIcVgLjEO2FQfKT1kUa6zr2qBEhZXInnOmiSiAoEnp3RY0gdT5EcN8SYMDc1QIfA+e 5scZjQsEIdA2pOye+2jMOjZfuEo5amtq0gqfAEOEE1I/PgifKA6kzoypQjnIGn61G7k9kkNzr WOIGQWkgK9V/jPd9D4AJnadO2/IaPHaUHDeWepRzFWOwQ9SvdPzqeaVrS1VZ8MKnbVmg1z0bp kldbWeyQ7MjV4AohZNpG4KTre+e6SXqH0jK06bAPg30Nl1AtV8BmkBVp8/uFHbhr3BZu689K8 P1NtaiIdKMjHZNstfdc8iQK7P16q9Zna2llp12w== Received-SPF: pass client-ip=212.227.17.11; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/04 04:11:34 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- tests/test-char.c | 1 + 1 file changed, 1 insertion(+) -- 2.20.1 diff --git a/tests/test-char.c b/tests/test-char.c index d35cc839bc..2ced07de69 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 = qemu_chr_new_from_opts(opts, NULL, &error_abort); g_assert_nonnull(chr1); + qemu_chr_wait_connected(chr1, &error_abort); chr2 = qemu_chr_new_from_opts(opts, NULL, &local_err); g_assert_null(chr2);