From patchwork Fri Jul 31 09:26: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: 11694559 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 B13A0138C for ; Fri, 31 Jul 2020 09:29:22 +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 78D29208E4 for ; Fri, 31 Jul 2020 09:29:22 +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="e8V465pn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 78D29208E4 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]:46560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1RLt-00012U-Jr for patchwork-qemu-devel@patchwork.kernel.org; Fri, 31 Jul 2020 05:29:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41942) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1RJL-0007bD-5p; Fri, 31 Jul 2020 05:26:43 -0400 Received: from mout.web.de ([212.227.15.4]:39459) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1RJI-0003Fv-Uu; Fri, 31 Jul 2020 05:26:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1596187595; bh=e7XrG0q0BggR4NGeAWzNMkAErCEdihn+gE4jYSP5rWc=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=e8V465pnppyUEPGK4GWEKL3urJQn5QNNRLAEeQUWYYSbB6uBb+4HKns4AvXUlMXcP 8I3cZ4XTgwXFmkAbEqdGXyKwwFZSDkJK4Mn5leZni4tjk6g50VotGusHB7f/6R9qnx JHL5n8G7oyoDPkXhnlJDSK1lhNdZMpDibjNiwHO8= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([88.130.61.42]) by smtp.web.de (mrweb002 [213.165.67.108]) with ESMTPSA (Nemesis) id 0LpOKb-1kfkD81cKj-00fDVF; Fri, 31 Jul 2020 11:26:35 +0200 Date: Fri, 31 Jul 2020 11:26:34 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v6 1/9] Introduce yank feature Message-ID: <48e682c12802af768f99a6fbc32f2a163d7f508f.1596184200.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:EmEr73zI2BFlut3t2aFjGkVd+p1oq3kCqhgyzrNfaNGeI9QavkX OOv/C4YFP5SHb8uLVij91vnLlbXKfeO0u9bjMfYItVSj5b8oTQuaGaveQESmbrd2K1awZAS pWJgMfI44n9Yc1kcYyt4ODAvud8grWaBul5IRgIivONPAXsWdWFp7PV6Tb8n5+3WBbX4DCS 6+2fpmUuXfffH1uVJR3BA== X-UI-Out-Filterresults: notjunk:1;V03:K0:R/PyQxy+cUQ=:15BeITMb+itL+pMtixCrkk Z2OoUrur26MSjnQogPHjHsqIIk/oAJZmA2j0lYTvHWwJjeCYSDHGvCjETW9QLuK49ovkK0DvI lFU9WEuIh9GdDexxLxa0ZE+u52W8ViwHe3/pg1z9V4x2++jDDq2JZz0JDfqutQwiPnjbhXiK9 5umfccqXXF5ge7ca+bizBpSVlLtdtky4vANIIj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ZWk Rh8hsqJ/DcphqPYx3lNpKNUDsPMRDAPfaw9YHMA== 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/07/31 05:26:39 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" 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 Reviewed-by: Daniel P. Berrangé Acked-by: Stefan Hajnoczi --- include/qemu/yank.h | 79 +++++++++++++++++++ qapi/misc.json | 45 +++++++++++ util/Makefile.objs | 1 + util/yank.c | 179 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 304 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..294094ba74 --- /dev/null +++ b/include/qemu/yank.h @@ -0,0 +1,79 @@ +/* + * 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. + */ +void yank_register_instance(const char *instance_name); + +/** + * 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 149c925246..4bd17270ed 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -1614,3 +1614,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..4e66d5a2c2 --- /dev/null +++ b/util/yank.c @@ -0,0 +1,179 @@ +/* + * 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) +{ + struct YankInstance *instance; + + qemu_mutex_lock(&lock); + assert(!yank_find_instance(instance_name)); + + 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 Fri Jul 31 09:26:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 11694561 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 07E4B138C for ; Fri, 31 Jul 2020 09:29:25 +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 C3A70208E4 for ; Fri, 31 Jul 2020 09:29:24 +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="dtYzHAcY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C3A70208E4 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]:46656 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1RLv-00014p-TD for patchwork-qemu-devel@patchwork.kernel.org; Fri, 31 Jul 2020 05:29:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41964) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1RJP-0007dQ-N5; Fri, 31 Jul 2020 05:26:47 -0400 Received: from mout.web.de ([212.227.17.11]:44495) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1RJN-0003GW-DB; Fri, 31 Jul 2020 05:26:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1596187599; bh=MuCNjqd9H4ALndDqG0jP1AQMY+cLODy92P04oBv1UFk=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=dtYzHAcYN0AV4R+Z/BMuoq+oC7f9sVdLOSPm01UBLXFGlpcy1kdDrBWJ3eo+gIWij vM328TZ3A3RLEjdmv87MNRRxpxuKbVY7Niz2xTOMGepT2I2yoeqCQpHccy5qPeRcNl uc38kBmi2IGQsNsOuizWJsHNXo5K81YURucAvw4k= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([88.130.61.42]) by smtp.web.de (mrweb103 [213.165.67.124]) with ESMTPSA (Nemesis) id 0M6mTI-1kxYB108iC-00wTn0; Fri, 31 Jul 2020 11:26:39 +0200 Date: Fri, 31 Jul 2020 11:26:37 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v6 2/9] block/nbd.c: Add yank feature Message-ID: <238b513ddef19cf91c8bfd379277f78e00a00f1a.1596184200.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:k1CgawiDO0JIvBgUj19o6QQsJZK6ILIpO+fe3n/VlG7p4fWZfEz M9nevYPqr8idVL1Bqn39rcfaOJyDkzEsgAJdVfOVBvAxv+xmm+FIhMzu4SPtS8AJeKh7QvE U0g5rXdXEOWHGBFq6tY9Mg2SXE/8B5szKfAW/nACkl2m0pL8TffvTCsldSr5VE62BJVRN0S ItYCajJw3NQ7PIYNBvukw== X-UI-Out-Filterresults: notjunk:1;V03:K0:KPHwng5b8tw=:PJksNSFa8Bx50LQS0SsV0A PyVCSGwJFbtCdCthNPqUnjvRkEfJOtMHDwQFd1wUbv9+6PPIUxtZB0kJhvuPSWkYGFJFDsIo8 gu4Pl2JRBLCTux371tynII+aXBua9os0vk+/uw9LQuxWfhHFZpVnDFsCtt3UWPYXC8zIgB1hl NrJ3QxanK2t2eTbzU817X3/WGR63P7AqRt9dEccMYqtDjPGBR0vt4UhSFyj2GIvgPv54S6mZb +PRkNJbBkovxWXSZaBFmFdtlFMZFugrUmWEdQ0Zam6snANTR7m4CCJ17oCsvLKSJmeDLdwbly xlDbSi9x0InYbRHI57l30QX1mit3LIAghLGtkBiFYjDEqv1FKL/XuwzSOLOpEz3qb40jWlNdX 3jzh4OVlGdDnf2m2D7ajpdSPiw1mVRXcWADnIrCKoWA8E2GTwsVm5e3De7uT8V3PdTza+jGo5 pvK3cYfL+bCrl9Gaei0B+evgdeWehpd2Jr6DX77m4pvG3VOVL9GvqNLt/fgRKwJ8eDvGOLCpW zIGBM0xCQbSkPdlHo5vswr99Yk68rX8wgJo0ldKc5cYhjZfsKaimM4DKjJZnfE8EwMt7t2hGi lc2MhhLQtzr9XjAAewnlN5qE4xmba79Zp++BGhuobjAgDK+nTG+PDllgDjed6yJq+VSxtAN+a HKxU7zYLkoI9UJbAyyNkfA0U6OHun8rgdcUkjJZyLS4IuHxBI6LBDegTMmIFBgGj+C8P6AKZ8 2IZ/rWWioM/Ato7msL4Zxz+b5+KH27hSZD78ZtriKhYZ8PdalaCNbZg+PpPBlLVJ5GGjrwyF+ d7SbPeL+S2WO/ji1YM0arZUuS4LCjrhH//hNv3ashf6EB1c2DKSmmeMKkcBFwW4vd5gcFLrTw 7IF/YBb5eQOD9ry7fpMUU3sIZxDjYOMOUu03NlJfTeew7vV3jVx+pI5fEF6YPUAX5K/Z4C5Da LVCXZtNHZ0NtZCpzYqSHA9RDURoLyw5S4zA2pe+Pesr6wtqd6OUGXasi+Vq1exrtI9JDpR/f3 ISkBLp4HWt+YImjUnVLGaH/lX6Q2Ca6saYeoD4cCsbqZTXCGoIUO1BiC37tBAFL294QGD1F/X jIodKxdgAMqgnjIF2RhQw+WfSl4FdNK4P7A+J5wcymV2NkhCWNYWbqNLmMLx5k0QM8oJ3Izhd Q6lBMggfQgpVSMHdUvisPHcBmJOxkuEDJY2IHZbtW1uFuuKMSXMuz0zOG60HHifh5WvhDyl2p rkOemMjY2saRtswwU3qEPbVSSuP+z1gEYTBCTVA== 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/07/31 05:26:43 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 --- block/nbd.c | 123 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 74 insertions(+), 49 deletions(-) -- 2.20.1 diff --git a/block/nbd.c b/block/nbd.c index 7bb881fef4..e37b0f6ab0 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) { @@ -1928,18 +1947,23 @@ static int nbd_open(BlockDriverState *bs, QDict *options, int flags, s->bs = bs; 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); /* * 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 +2021,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 Fri Jul 31 09:26: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: 11694571 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 1D9CE913 for ; Fri, 31 Jul 2020 09:35:13 +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 E81DC20829 for ; Fri, 31 Jul 2020 09:35:12 +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="mAHkGzuh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E81DC20829 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]:55914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1RRY-0005By-1T for patchwork-qemu-devel@patchwork.kernel.org; Fri, 31 Jul 2020 05:35:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1RJS-0007fq-KP; Fri, 31 Jul 2020 05:26:50 -0400 Received: from mout.web.de ([212.227.15.3]:53807) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1RJQ-0003Gk-P7; Fri, 31 Jul 2020 05:26:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1596187603; bh=Y55RT1Puo45w6Y+NNfi0kCvRF0dtXGvI+GyKGpQgDuI=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=mAHkGzuhXofkypUc7/XjNaRg541socihF1WwHU1vRW2jnOMr9bALqbYKdi4fXU1RM FyVVEQe8xcuOSdeZb6r9omX6bOJsTJcvAqC88q2crtNN4fsABOAOJK47UFIWDs5JsJ 4jADwic2bkS4qLyeYiaYKOzwXFsc1X60d0ptjnO8= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([88.130.61.42]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0LfzgJ-1kXSkS0bPP-00peH3; Fri, 31 Jul 2020 11:26:43 +0200 Date: Fri, 31 Jul 2020 11:26:41 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v6 3/9] chardev/char-socket.c: Add yank feature Message-ID: <6c504d77050ff2f944349f98c4573f388145969b.1596184200.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:yBLacbn3lFKMc3KzTt5HeRK54fyw4cNb+ZqAjqo9WTWV53c42rG ZOmzguwacuRymgJlE71sjCTP/9lJISLSobRhyF4AHdR9R+8drfrUUOgyOagwnQ4c0glMdDU 1bHB/kNUMlJlHX35eB214DIOWuw7R0ibPVoBHgh80N40rMM7aG8LfUIhU2nZ4vdUrivmLwh 4OvR97hgJJ475L9vXM7ZA== X-UI-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Y/1AvFNYx GrWAjQRD89XlhkzggO1tzoJM8311bJDP1f2THGQaICW9zoxniuCHCUeoi4ApUok5W8Kdj1idf F0jGQHj5mU82J0wnZAmHnlDmdDtlC1suSQmivJKmTUJy+0dwCEfdWU86c5PQSY7ERqqbvDJ1c jP/Ei6cLBjPz3fuYC9JqDP7Cq/p1bQQpKfGSKlaPVPN6EH3lTROWZd1CynXka3Qt/rjT1UTQu UkBOfTL72UmT66sEUsgUP6q/DIr90HROin59FWQ== 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/07/31 05:10:35 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 Reviewed-by: Daniel P. Berrangé Acked-by: Stefan Hajnoczi --- chardev/char-socket.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) -- 2.20.1 diff --git a/chardev/char-socket.c b/chardev/char-socket.c index ef62dbf3d7..c0ce4dc606 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,8 @@ static void char_socket_finalize(Object *obj) object_unref(OBJECT(s->tls_creds)); } g_free(s->tls_authz); + yank_unregister_instance(s->yank_name); + g_free(s->yank_name); qemu_chr_be_event(chr, CHR_EVENT_CLOSED); } @@ -1085,6 +1102,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 +1137,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 +1381,9 @@ 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); + /* be isn't opened until we get a connection */ *be_opened = false; From patchwork Fri Jul 31 09:26: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: 11694565 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 3FEE713B6 for ; Fri, 31 Jul 2020 09:33: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 06976208E4 for ; Fri, 31 Jul 2020 09:33: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="crUpuB2t" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 06976208E4 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]:52540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1RPV-0003hb-29 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 31 Jul 2020 05:33:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41988) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1RJW-0007hD-UJ; Fri, 31 Jul 2020 05:26:55 -0400 Received: from mout.web.de ([212.227.17.12]:39677) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1RJU-0003Gy-5B; Fri, 31 Jul 2020 05:26:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1596187607; bh=wrF87AxrlvPP8Zny62NkjRU+1B5hmL1ZilzlmOqAocY=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=crUpuB2toA7muLJ5c1tkF6CFO6bFpy844Tl5jpyxVmE0QrMm8sgDfi5dOtVPTWDIa CObQ53LXkc6pJ8oP40Lk4LounQPg3rl1Wr7ZNRjIM1q+X4hlG3Gtc+lJ+T/fJPRCRo t/1bHSVtgtc6Om9hSEyHR5Z9I/nXAEzUhO+axrcU= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([88.130.61.42]) by smtp.web.de (mrweb106 [213.165.67.124]) with ESMTPSA (Nemesis) id 1MDMzM-1jt9qy3dJ8-00AVSm; Fri, 31 Jul 2020 11:26:46 +0200 Date: Fri, 31 Jul 2020 11:26:45 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v6 4/9] migration: Add yank feature Message-ID: <7ed75e5566229179827f025c6393f460e3a726a2.1596184200.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:nOYWEBwxDAKj7jiSvoauAr1N9o5OkOD1swv3yhL/SIbWOckhnZG W4DXE1D7jKxWeuAOvx+S3c6e60oCcU9cMJ8jFf7yMgrmlpDOeu2Q96QppUKzpT4pm+6X7oJ 2d8LZFIdAPkCSYf3hJM6OeZlyp2Umw21oHb8QcABWzPRVzJcDAf/L/PrRiIXO5qsVE0AEeY aMHDwT0aD5YVwe8vaAEBg== X-UI-Out-Filterresults: notjunk:1;V03:K0:VpzTzLDA9zA=:q/hv1pkateKiDvBafH9OTQ s6MYCSYnxfO7RIIfYdaCKSSLLAleUBnQmI/COWNDpGJBXO7tfl0tfhVMsmaqmAWseFNDSX5T/ 2p74IFIMSQsLoEY5o3KzShNqaz3hg/BTeN3oJgATXNnzHteIPvYcY5FLJ3NSYOgjTeApi8vF+ C9wsAFHw+nPk1pvKYxQGgtC7y8jjOr7j+R99htsp4JawgQU5cgwBH+vnN3rqrSoIVPOkN8EXw 2T63yauQuWksZYkPYNGvZloxvGLGz0hyCwpM2V/43f8JPnZf4f77yDHmS4+5wrfY5ku/RgqLj nJIyqYWG9n7dr93x4icO5g3R01U0+6VT+Ae21/KPURQUfhHJh8ZjKvzqVpdxuej3ofjPeZJrA I/ZxA9fk/IxcIOaJFzKUT78ayBKpnVBPZo00inCKU/ydj8zgDoqzYF2d83OQ4G/znIVVbYDaH I18NvpzVRbzL7yMk+y06SkVD/q3LilmOIemi5W64AY3hQ89PyzOrzSraoupMts5A4yNbDUoGB bzSSdIxXjBooxO4KXFyFUkBbFnRdD3hw9vPUtfzkmhCReQu9lIGBIWy9DOIO3ZZoGDMDwEsvq ECIaB1PYvV8xTnGPFGAyJ6oJdsT8bgjF/UJv5eI0FFCP3J1Pv1q6yVDOSXAfDX8s0SyBXyJxJ yheMWQmMMqte6y71ufrm9PwD3UoeMG5BtHPBOpfpfmoKYA6iCny++5w4wCqMYxuWrmbBsguQ4 NHrOPZ3AZajs7WDOdgs9z3m4nUpUSPk0yCLP/bRJhBG/vxPrfBdFOQl8XOI3F1XkeU2i0DJu6 FeWC1a23eF2Hmbv0DTiIi/cOuorDxd9Ysi3MYPJv27x0E4MExz07OmWBAeTF5B46SsbJ8Rbgc lUtps/ug6pZj8XmTAKit3WdIi4pg0cPXDi3DP+lQXdzjX3OfMqi0EySC2lZa76F5Wvp7MxEIb EyvhGDgYVTFO5OGRM1ZJD5DUdiVTmysVrTufD3kk9z6fUBIWfEw1HkLlrQd4pbXK0XFtDWdv0 iQ1pekyTbfwBFc/PPXH5NhMyDoK84Kacxw9WhwDaBORdpzonl1KR1VL3AibcNXtQRFVP2b+rB Iw8GbQy+qfpPgZjSNYeko7YDbyi9Wn8q2Pfw1EITOHhe/j8r9I2uHnsUO7OTc49AgBgwiSLUx wVIlf52+eSHAFhuFsFS3/nMtveMSFWJmlqF3RfGSeBUkt7TlmelqvTMzVncZJxnH7QuqqsBOb VYw9naukWcOeJlXnotkHER8jKGEF7yPmMAtPVeA== 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/07/31 05:26:36 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" Register yank functions on sockets to shut them down. Signed-off-by: Lukas Straub Reviewed-by: Daniel P. Berrangé Acked-by: Stefan Hajnoczi --- migration/channel.c | 12 ++++++++++++ migration/migration.c | 18 +++++++++++++++++- migration/multifd.c | 10 ++++++++++ migration/qemu-file-channel.c | 6 ++++++ migration/savevm.c | 2 ++ tests/Makefile.include | 2 +- 6 files changed, 48 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..29fefcb7dc 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) @@ -380,7 +383,9 @@ void qemu_start_incoming_migration(const char *uri, Error **errp) const char *p; qapi_event_send_migration(MIGRATION_STATUS_SETUP); + yank_register_instance("migration"); 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 +400,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 +1668,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 +1942,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 +2079,9 @@ 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"); + } if (strstart(uri, "tcp:", &p)) { tcp_start_outgoing_migration(s, p, &local_err); #ifdef CONFIG_RDMA @@ -2085,6 +2095,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 +2107,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..bbbdbd8ea2 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,7 @@ int load_snapshot(const char *name, Error **errp) qemu_system_reset(SHUTDOWN_CAUSE_NONE); mis->from_src_file = f; + yank_register_instance("migration"); 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 Fri Jul 31 09:26: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: 11694573 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 AA4041392 for ; Fri, 31 Jul 2020 09:38:53 +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 70D4C20829 for ; Fri, 31 Jul 2020 09:38:53 +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="i3GwPA/l" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 70D4C20829 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]:33908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1RV6-0007yp-IF for patchwork-qemu-devel@patchwork.kernel.org; Fri, 31 Jul 2020 05:38:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42000) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1RJZ-0007hp-Nv; Fri, 31 Jul 2020 05:26:58 -0400 Received: from mout.web.de ([212.227.15.4]:48459) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1RJX-0003H8-FI; Fri, 31 Jul 2020 05:26:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1596187610; bh=7v/Mv0F5waUUMT/mHpp598uQEuJxOezfSzawUfXZvyU=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=i3GwPA/lZ+CV2VmYt/ISKai+dXHY+N3dmPBj8e6yEDQShWMUoo67bK14XSVERVAjn d2mL+cDMFWhcSaY2gN0VIGoBr6wqFQiGjjCKXyOrT1QcXDY6XiTNjyq07f4O2YhRKL hzSZ3AEtdsp89zPUo7gfwc/Le7ouj0hv/dGf+0KU= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([88.130.61.42]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1M91LW-1k6PO81z4o-006AMq; Fri, 31 Jul 2020 11:26:50 +0200 Date: Fri, 31 Jul 2020 11:26:49 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v6 5/9] 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:3oBWF9KpN6NLJMkfUcQJJaqq1/J8stWp7K7+rPwYLgnffevZjCi EM05jsyLChGltRbG9HdPzthPtNxXAj/i/Iyup+TgUVyqJKG4Z5IXLtDHI1QIaeSQtMV//fO gJP9eve9xgKQ0lExQomQAB5WV3RHA2Nx4hfTnCfSqgjQ1aUUU41nndobvmKfyP7q/GLk94L ZpGysaK5pJuDmlWu/Ok5w== X-UI-Out-Filterresults: notjunk:1;V03:K0:pk9OdU03prE=:ZCQwh0CnBWXyZ75pCWVyE0 5pgEqVJumIGTIScoTDKenXVpKUAM0Wjm928gJYeayHqgKfutqtAg94jdH17VBSvKc216WKsEN J7fEHpR1gld4ll/yxuAH3z4Sz6ZKnAVObfl27NEExtZQ4CRX4guDjH6rzcxzqm7jWz9O5gcHT yZkWkMevOCa6W0DUdUCEQUMwTKR6S4ItZ9KQkQvBWjhQ/q6WLQ+UKh7PLclkQS5kOniVnScqY Tehr8dOD+K/EcVy2eruz45nUqNpM4epgl/9st39I+EbUk50BMSUr1s0eQ80H34OeLNZh2G8Va OB9XBpzUtVWUM7+CbJEMEze5NrACBF66kcD04Wg25r2bg/OVnyT1fQbJM8cNJ1wIyATULAl2h u3ruKzFuL7KOc1re9qwXUWVBD7TBns774ulrF3sjd2XKYL2MaNxaR1H6H5OufAnv0I3QiTTS9 ZAUhrg5RElvH890KdfdZZwzXm8ECQaN6nzvSKnD5DvAMO+hAS06xp24MgW0+sUjJlJ5ditOpy RT1WtGMlDcEjLd4VnNC+DIF4PcCnpKRZ1cULIP3bzkhD1WkSnssoBSWEo8BuD4WMJlzc0XuZH +xRGYAau9wNZ/z0cN//KGSnJpQul6RUUoO2PTDsYGMU4i5Ai6/7QWGIc/4w0SueyBczKFoWtC Arzm5PjsGuylwxXKbq8Y7C4Zbcb4PgRJoXwhwH4LuiqA3dyiacZAHTVImcbBSVDQTY4gfLNNj HUtUgtY+1mB5kx3uqt11KtjkQttGiHn6+uuSOCS+erF4BqsZI8a1dZnswr8AVqWpKJfOPn160 jXU0fOBPWrpt57/EdGuw1/pmYge+7BA3dX3wDYioE6/LVT5gD6JB8AlqSD3vxvPFTkVUHk5u9 i4mWIZRFka/jpWS4gw8+f2G4sJOG+rU0Tb78cSO9WT+Zceby4x00zCAD54/tb0ds9wkqQ8fGs aplmjnpwrdEQgEaCkDo7r9O2M3LJJoiEQDcvyW1FUBCrKnHr1yq/SLuko6bpFIu1/ZAswk9CV CbOYlXUp61stJEqVvSbCCyGfI9Esdgmr7zPJ7j0BIme6m2fD43wdJDgJep6CRlFVlxRF80/U7 JdC98MfAssvUUMBUsKbCwjzhIPJTGcmXfRL7sHSKILjUZyCn4siEBBuS4y9xVAXBXnoftoyOv 2nckBRxDTTmei7EZhwL9AdCUotYmWY+4KvgBcY8jwcsQf6pnUhnf7Z/ofCpThPqx4xztCYhOc dGjLwujU6a8Z/8MU+KP/3VhA0enGOLWDA9cX1vw== 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/07/31 05:26:39 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" 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 Fri Jul 31 09:26: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: 11694575 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 6B585912 for ; Fri, 31 Jul 2020 09:41:45 +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 4301822B40 for ; Fri, 31 Jul 2020 09:41:45 +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="Ax/ApSlv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4301822B40 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]:40484 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1RXr-0002UX-Ki for patchwork-qemu-devel@patchwork.kernel.org; Fri, 31 Jul 2020 05:41:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1RJf-0007jJ-LX; Fri, 31 Jul 2020 05:27:03 -0400 Received: from mout.web.de ([217.72.192.78]:54765) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1RJc-0003HV-L8; Fri, 31 Jul 2020 05:27:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1596187615; bh=3A0rurnJ9LqQrMozklTVo+u7yORYQfvynASd2zRGHlk=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=Ax/ApSlvzQSFuLnV0cKnUgDTIWnq4wDJ8SZfUesF9p43l1pyBuyAMJ4ByppOITAxR oqD1rzbLhJGWr4JW/B6VvalR+T4tzrPVGEAi6reM1q12Dnbom5UKsCIO5tnGm4v2ce kneL6Ts72KacACUsirKgMZ28KyMpw7rt1hiieRz4= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([88.130.61.42]) by smtp.web.de (mrweb103 [213.165.67.124]) with ESMTPSA (Nemesis) id 0M3T5g-1ks1rq3PtY-00r0Gf; Fri, 31 Jul 2020 11:26:54 +0200 Date: Fri, 31 Jul 2020 11:26:53 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v6 6/9] io: Document thread-safety of qio_channel_shutdown Message-ID: <1d059059640fe6d02e05d4fe617e6665c7640dbc.1596184200.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:zq7HdZxZPtFz0sRJ18izJysmYjt3uAkakonGsaRYfwWmDBnkB/d TKULpbiZiFx5XfNDruImCicx5G21Ozc+SkCs/QzaQyidJkFp3y6+xC+M00iTR7OinsKzvmd I1TpG39x0tKCDJboHWOZE2G9EfYPeUkFW5nwfwVW0g6S5prD0wJlD8heRyo/kBcCX4qYsIW No+DiwBUGWdfW4epZWTMQ== X-UI-Out-Filterresults: notjunk:1;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FB hOOz0l5mZ3CJwXyolB8myWjFap30DcIJSylOAqZwgEBHkndZOZq+8RAebOcyM7ZvYDAlUf2Bb nzIU9dqPwj/DlkuqvIkkZ9/PvNrukCMd9DuGqVlmIAXNWhuAum8K1wqFVsGrbhM0omItSxg4j iTMe8fEfm4tNLH72qG1CGdbggOSx7ETmRoy1REiItmFT7f+oa7n6I+tRqC59rLDLJ16fjVLxi abos6NYGgrBNQK2mV0yoWa/TQSCPwpTtAZNXULw== 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/07/31 03:52:36 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" 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 Fri Jul 31 09:27:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 11694579 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 5AA151392 for ; Fri, 31 Jul 2020 09:44:27 +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 20CEA20829 for ; Fri, 31 Jul 2020 09:44:27 +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="c7Oezxlb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 20CEA20829 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]:42826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1RaU-0003iI-7z for patchwork-qemu-devel@patchwork.kernel.org; Fri, 31 Jul 2020 05:44:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42052) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1RJk-0007oJ-Jd; Fri, 31 Jul 2020 05:27:08 -0400 Received: from mout.web.de ([212.227.15.3]:36171) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1RJi-0003Iv-Um; Fri, 31 Jul 2020 05:27:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1596187622; bh=EuJZnhDdT/XNOaCKZvdlajlxeYo8brk4aoRtdHhMqZw=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=c7Oezxlb0shLuK2NvAs1GhGQPamxnyINjMtGmy9O5I8U+z8IdIue9OA2XdoTa03DO TDtsaFXcuq3iq5ruB/jXk7PUFFayjwnaw/TnIyQAU/AYMzmT5IaCw0jzbQ7FPnsNSA 5zdfUmWnmyYMFfMrbnYlW/669UZfKY8Kc/YMUb+o= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([88.130.61.42]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MVaYi-1kBEvK0QjM-00RWVu; Fri, 31 Jul 2020 11:27:02 +0200 Date: Fri, 31 Jul 2020 11:27:00 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v6 7/9] MAINTAINERS: Add myself as maintainer for yank feature Message-ID: <14a7a25d32cb021d9b4f03318dd7ef9bb47133f3.1596184200.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:psJT6U/QISliVQvFy7CpWW6m4Rr19kTOMdoNMIYEexy3xvELOYS +O/FHqzaiFgvHKx+w5IbTAP3EHN9cxOlGuWQtPbUhft/cEbXCXNPEYHDW0fX2/aBCmKsJVm D01SMRfV3ZWtPDG30bPug1asUa10kzYmMOkIID0XcbuOl8nV6znzSYxUGrEMyZ6YWQIEaId jyi8P31Qe4nOwJZAEN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E1kQiFoM TFbOFGzROQt1cVksKIio/yQHMbhvzmbor+zPLqOTVo72tLlcjZQOjv2eFCluCfpYcbPUUrimT vNNscuRcX+FvawObtF7FQ1Vrx6MGZO/EQ6gWo8pcpl29JRwcc/PibsWbQdbk16Bdo7YtT6wT4 sFZZtAw3JTrKM80IYuGS55xDnUnBDW54zQKAhLfXImNqoUPHtn6hb8jjIDV9NOcpBsVFL6lYy 3myGjY7J+DNiE/UAZaCwganD7YGi+JvgD03MpWw== 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/07/31 05:10:35 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" 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 Fri Jul 31 09:27:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 11694569 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 70584912 for ; Fri, 31 Jul 2020 09:35:09 +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 4758720829 for ; Fri, 31 Jul 2020 09:35:09 +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="bxzYYSdx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4758720829 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]:55806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1RRU-00059D-Cr for patchwork-qemu-devel@patchwork.kernel.org; Fri, 31 Jul 2020 05:35:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42070) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1RJp-0007sF-9J; Fri, 31 Jul 2020 05:27:13 -0400 Received: from mout.web.de ([217.72.192.78]:44603) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1RJn-0003JH-Hp; Fri, 31 Jul 2020 05:27:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1596187625; bh=NSowfk+zdZfBN/U0N2yBWTJeqtU0sa+7Wn61uH1ecNA=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=bxzYYSdxqLVscnidGrbqaUlRaya6/sTI0Bs3sDDqzBb/9fYL+YQqrjFatF4nqQXh5 cLONVZP96AI0E0+xn3fLGgijdM1AEOsiTt5HYjZTKTKbQ7+gdA+9LZqZ8GX6OwN2TA B3lx05RyKNtTLUnLpXPfqjRnCXg/+U2l1ahgj9wM= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([88.130.61.42]) by smtp.web.de (mrweb106 [213.165.67.124]) with ESMTPSA (Nemesis) id 1M43Kc-1k1RJh30jo-000154; Fri, 31 Jul 2020 11:27:05 +0200 Date: Fri, 31 Jul 2020 11:27:04 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v6 8/9] chardev/char.c: Check for duplicate id before creating chardev Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:f1CtYLThf3u08hoLWCEmQjAxIGLMDlS9MedX3jm4SsU3viGlXOd TrvQX0JeM54bfTubYHR2Jbx8cauWxvFY9GXlFFTDiDzVNvd6CnOo3mbqAHFtUqN+t/yE2q+ nnflLogIF9STqBbDpUKyKwX6HBVVgKnzsoiWD0E2g2WL8hIQ3W84BBROF77Zaq00diE65Lk zYwSDnm2DUNuCICIF4EOA== X-UI-Out-Filterresults: notjunk:1;V03:K0:zU0f4ePo6I0=:UO0w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sXvXjMbSzxddlnIE5xaPRniuy1aYuyG+ QtIQCJ08+2v8bJtk/vhO6Y8du9TCrtDppYtWHjej1lhehbKyXWuYR14l45JtDKbxGF8MwonIw MQ55se8RR2TlDev7dyjP1cZasRlZ2PvpC4XVjpgy6jRZP0TTeUV5k7ZV2vinpHpxL09KlE7Ys rf9qDZkFs00XPIHLgtB1CgWFQA2iHsETGc7aJ1w== 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/07/31 03:52:36 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" yank_register_instance (called when creating the new chardev object) aborts if the instance already exists. So check for duplicate id before creating the new chardev to prevent this. Signed-off-by: Lukas Straub --- chardev/char.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) -- 2.20.1 diff --git a/chardev/char.c b/chardev/char.c index 77e7ec814f..ce041dface 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -951,6 +951,11 @@ static Chardev *chardev_new(const char *id, const char *typename, assert(g_str_has_prefix(typename, "chardev-")); + if (id && object_resolve_path_component(get_chardevs_root(), id)) { + error_setg(errp, "Chardev '%s' already exists", id); + return NULL; + } + obj = object_new(typename); chr = CHARDEV(obj); chr->label = g_strdup(id); @@ -969,11 +974,7 @@ static Chardev *chardev_new(const char *id, const char *typename, } if (id) { - object_property_try_add_child(get_chardevs_root(), id, obj, - &local_err); - if (local_err) { - goto end; - } + object_property_add_child(get_chardevs_root(), id, obj); object_unref(obj); } From patchwork Fri Jul 31 09:27:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 11694567 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 6C584912 for ; Fri, 31 Jul 2020 09:35:05 +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 438FB20829 for ; Fri, 31 Jul 2020 09:35:05 +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="kk87AzeG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 438FB20829 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]:55676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1RRQ-00054V-CQ for patchwork-qemu-devel@patchwork.kernel.org; Fri, 31 Jul 2020 05:35:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42086) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1RJr-0007uo-OI; Fri, 31 Jul 2020 05:27:15 -0400 Received: from mout.web.de ([212.227.15.3]:45275) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1RJp-0003JR-VH; Fri, 31 Jul 2020 05:27:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1596187629; bh=nbwft+EOV2AEzRxoXJpN4IeXwIqjDnslmRUPqCBD2B8=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=kk87AzeGpwgRR/8HOBfqK0pihi2uHZn/X/RNjHVuYRnmhZflseGHbfzpe6rt2o57X GMMH1I60703KGQQvGZmahSYCDXKAjzSfn8PlpimHfNaOrp0MtPiIIALZ6FHYXrAbk5 CHkFIT/DXqEXu6/d60pRQ1i486nRdFejEMwOryGo= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([88.130.61.42]) by smtp.web.de (mrweb002 [213.165.67.108]) with ESMTPSA (Nemesis) id 0LwI74-1kqNAh0p4w-017zzk; Fri, 31 Jul 2020 11:27:09 +0200 Date: Fri, 31 Jul 2020 11:27:07 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v6 9/9] tests/test-char.c: Wait for the chardev to connect in char_socket_client_dupid_test Message-ID: <1a011dc69f075b0bc4f9b0b3232573a6007c8dcd.1596184200.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:WhU0El/+ThIpCvz20wnDR7VnoF/0ndY1P+rxcioLO+VT5FRM4ti /8ycAgPnvP+7ACOX0fPH1OnSjXKkY0L3XNStyNUjOybTly9PQvx/o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2wBBSKjcN1yKs1OqJUNF76rqhEioaFxpnFweuSz ntx10TuiMFwW9tUrrSZ0gWQOteEyRkOeR1UD6Xz4yqwl8wGp8KNWiYur+SSarUlfs8g6NpFz4 pI3w7MIHPBHTKd9+9ZHZkbA3+PBlq04p+OFsyk/6k7vcS7mJ75CZyMsBIVwz9VA7F5LfIREr/ w4F/3ti37xuOjCNo+4ents0c6xGul0/DLDXjMM5kA2rsjBRNC5tSbrtvEIXXl1qwhfkicmTka dwEhukMqKW5iGw+rpnKVNdw9iek8YTC84NoPFknaZ6xjnA10fuK6G25xUmUV5xiQSE7xLMGzq 3QwalmzjJUVZnkqTKF03a7L7jpLo7HeM6SpDB8g== 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/07/31 05:10:35 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" 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 --- 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);