From patchwork Wed Nov 30 11:24:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 629471 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp793004pvb; Wed, 30 Nov 2022 03:26:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf5QZ4rx0TH9oYeHv4UxWwKLA4YGt9+f/sPzENs9vqWIcb0gNm8XVfk8Y0xNOdin290YIUiC X-Received: by 2002:ae9:d844:0:b0:6fa:b570:2da7 with SMTP id u65-20020ae9d844000000b006fab5702da7mr37855514qkf.597.1669807592925; Wed, 30 Nov 2022 03:26:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669807592; cv=none; d=google.com; s=arc-20160816; b=q9Am2F3IA0GPS4qkxtvMboMsFr+pNDYikMFOInFknKhDWRd+WhbK5GZOIjHw5I7yAx P0/dTvvIs0/cFYvqtkokTnDJ5kZXYNO8FxWJFIb/cosYNlCxylV3t0kWPdt22AUHGGj6 /ezU16xq0gqmI61srxMN7agIihFsvCmw0GmxZqNchVwe1AabcDdFZh4RH3/fmqjYnpKe itVl9S8FtevZXteXXXqRTvz4W7Msy0EfCNxPz7YZszPhnZTWLjCuvrKaxjEHtf+2L22L 5o7m7jVn10YBEp9WKNQY9r4l+DAZiVtAjf91EcE9Faw07aGwQxSVEC9x0gr8xxycpfec JU9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fhoXPC3rByieHAyt5C9yWMVAGH0bkDKM/ebHnq7keeE=; b=CRPilCAOM/oiu6nx/dsqi4QQ4Uq0t1MT8yoKx3e4DyMKo6V8dHzUITegrZLe+rvAZE 2/o4SqF3Q0orvbukBleLbX3RPLamBDwkUSOwm+qLKrmknaNTFSJkLtRIDSh9QCHLopd4 liZynoE3mCbXvga72WY3+itbZDiGUrrtaO64NH7SJDDp1fqUq0TTHfpt5zJJ6fMosua+ FwEezLNR8falcDABaHjN24ikfWZ+OHN73gSZqkyhl4PGHyRKR6TpIxYKUKatwpDN1uT7 vd6BqAGKtYTztoVWpwA03WR0FoEBYXpgxk7Um2d9E7G8myKzuQPbJft9NlzrS2bDAlLq JS9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IWcjhKxv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t8-20020ad45bc8000000b004bb9c173d31si575916qvt.287.2022.11.30.03.26.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 Nov 2022 03:26:32 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IWcjhKxv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0LCo-0004KZ-4v; Wed, 30 Nov 2022 06:24:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0LCm-0004K7-SX for qemu-devel@nongnu.org; Wed, 30 Nov 2022 06:24:44 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p0LCk-0004ei-RU for qemu-devel@nongnu.org; Wed, 30 Nov 2022 06:24:44 -0500 Received: by mail-wr1-x430.google.com with SMTP id w15so13375064wrl.9 for ; Wed, 30 Nov 2022 03:24:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fhoXPC3rByieHAyt5C9yWMVAGH0bkDKM/ebHnq7keeE=; b=IWcjhKxv9A59EbNQq/1lm6atlOCbaaWaF2QoRQVJFtLd3ftVp+BJxqaK5MnAXOef/0 hWG2Mwf6hnmZs6YbF2YqaANdVUgLcyOqIJvQbFziQjpkMtSRmk9hXddAIagYP4oZfuq+ ByRxl/+YlI9ngeVgniUpat34Wy9w3ckXnI1Jhjvrs7iJrYMJBTSLuGu7C21KDtebN8I/ rN63NIs+ZyiRH4Tkceyr0HqavV6A52L+Nx/byooswUtkhQvyHE5LSHbRP48SFev+tFjk f8YB948NNx+Jjo1VwKGbU+2kssj+safbrK/u5NdJ0QL6lwFemrw2CLtAmLsOqGdRwoji /Nrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fhoXPC3rByieHAyt5C9yWMVAGH0bkDKM/ebHnq7keeE=; b=HQnnXAnUyEukamgpql4eKAjHt0vDnafMdovTg6cWGXPeZ0CF1dB8YqWCotlUS8mwM1 gG/GY9n+7sCpxt3HGr67MqMqGGuCCS7/M7RBS/bqCNG+Z3cvTCcyVzHRCeYCGhN6aNKU AU/DcCFlzU3+d2MF3Oo5K4xv2YOA6oremgkKSsGA10SPv0EVPOXZTxGmqldxASshlQjs HYcq1eshqxRYuAVtbK5UvnlsnsggZaYuZgxmyxuTneKv0f342Ob9oRdAu4UflzZqy0+I rAJ1Vn36mftJTeUBV8MnrdzyD7e/cH/iNTrsJ6iDLsgT9rrYoDCnl23rP4PkM260aN+f QxMg== X-Gm-Message-State: ANoB5pkgMUKeF2rtSs0Fylv0kNO6OVabjsmUFOAGNiqCdHDr+sxvFpEm Yr5K7b7Sb07P4dq2TwvdH+yqKQ== X-Received: by 2002:adf:d84c:0:b0:236:6f1a:955 with SMTP id k12-20020adfd84c000000b002366f1a0955mr36453948wrl.111.1669807481250; Wed, 30 Nov 2022 03:24:41 -0800 (PST) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id g13-20020a05600c310d00b003a2f2bb72d5sm6551477wmo.45.2022.11.30.03.24.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Nov 2022 03:24:40 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C391C1FFBB; Wed, 30 Nov 2022 11:24:39 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, sgarzare@redhat.com, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v4 3/5] hw/virtio: add started_vu status field to vhost-user-gpio Date: Wed, 30 Nov 2022 11:24:37 +0000 Message-Id: <20221130112439.2527228-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221130112439.2527228-1-alex.bennee@linaro.org> References: <20221130112439.2527228-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org As per the fix to vhost-user-blk in f5b22d06fb (vhost: recheck dev state in the vhost_migration_log routine) we really should track the connection and starting separately. Signed-off-by: Alex Bennée Reviewed-by: Michael S. Tsirkin --- include/hw/virtio/vhost-user-gpio.h | 10 ++++++++++ hw/virtio/vhost-user-gpio.c | 11 ++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/include/hw/virtio/vhost-user-gpio.h b/include/hw/virtio/vhost-user-gpio.h index 4fe9aeecc0..a9305c5e6c 100644 --- a/include/hw/virtio/vhost-user-gpio.h +++ b/include/hw/virtio/vhost-user-gpio.h @@ -28,7 +28,17 @@ struct VHostUserGPIO { VhostUserState vhost_user; VirtQueue *command_vq; VirtQueue *interrupt_vq; + /** + * There are at least two steps of initialization of the + * vhost-user device. The first is a "connect" step and + * second is a "start" step. Make a separation between + * those initialization phases by using two fields. + * + * @connected: see vu_gpio_connect()/vu_gpio_disconnect() + * @started_vu: see vu_gpio_start()/vu_gpio_stop() + */ bool connected; + bool started_vu; /*< public >*/ }; diff --git a/hw/virtio/vhost-user-gpio.c b/hw/virtio/vhost-user-gpio.c index 0b40ebd15a..be9be08b4c 100644 --- a/hw/virtio/vhost-user-gpio.c +++ b/hw/virtio/vhost-user-gpio.c @@ -86,6 +86,7 @@ static int vu_gpio_start(VirtIODevice *vdev) error_report("Error starting vhost-user-gpio: %d", ret); goto err_guest_notifiers; } + gpio->started_vu = true; /* * guest_notifier_mask/pending not used yet, so just unmask @@ -126,16 +127,12 @@ static void vu_gpio_stop(VirtIODevice *vdev) struct vhost_dev *vhost_dev = &gpio->vhost_dev; int ret; - if (!k->set_guest_notifiers) { + if (!gpio->started_vu) { return; } + gpio->started_vu = false; - /* - * We can call vu_gpio_stop multiple times, for example from - * vm_state_notify and the final object finalisation. Check we - * aren't already stopped before doing so. - */ - if (!vhost_dev_is_started(vhost_dev)) { + if (!k->set_guest_notifiers) { return; }