From patchwork Thu Dec 1 07:38:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 629881 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp86694pvb; Wed, 30 Nov 2022 23:40:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf7rRi2n5DiOU5DV0BcQqn2Y1ZF6utayc8FKiiORlPfehBqc2rfTD1Y6ua0j+vhybjOaFwAP X-Received: by 2002:ac8:1184:0:b0:39c:f028:48b9 with SMTP id d4-20020ac81184000000b0039cf02848b9mr60186285qtj.369.1669880432542; Wed, 30 Nov 2022 23:40:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669880432; cv=none; d=google.com; s=arc-20160816; b=a7BkM4LfeWmBEke5Xqe+o0OdtHKFLq5FjL8cJRIql4UhxeG0UCNarE7rZ8GGBBEehL vURpTwyv9agII5xM6/+SSdFx6CuwbVozskl4Nf5CK8wGOIOZ5plPaHwtlfqwscQgS0p6 WJ6zUz+WPS/HwhxOWIzjwgtuKR1+H/pf639Ua9kRtXIrlk6lR4as5y6BfmgvFNqhBasR RXLlxVXxodM6dn2XfK2ngA8HkEUyPEsYnlvNhnAocvMOnaTX7+Kn0+gT6Xnf12L6OAfM V1M4pGazpKQ1qmY7pXHEUFiYAVfVjuwFYyhTIfcQpdTISTcqtQZu431+fZhjG9vW9Yz8 cPuw== 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:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Y5/7MrH+QtrO6VCSQCLTGZeCpdV+HusT1OZ+wFAoJKk=; b=xutTLVf3n9CdOYK/MPe7F+kyJ29Jxue7e6Q+rIxNKOCM2rsnIyyIrKU8OphYJET/yh 0sQatvb9ZEtaoh7/DtholgxsERW5Y/JLUgVlhW+hTQHZafUgN8kBfFHKLTk8Cpml2Dtv xhBfG+glUhoebjJcTlZTHPoLamCpfBq7z7102WG8V6+TR3qDGRCSmhC//YOcVhdm7bfL L4lmmpWODs3iAX5I+p40+HMluwqyUCcwFFlbZG7cczVlqD/zRitw5x0pl8+800ZtE0ZT IRivAVcdm8xiSHtZNWP1m7IzY4i7+2IA7s1Mtu9zV8R9e0xgVuk6hGTeZH8lUcn6dI5l CtcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="V/5DBSSt"; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s18-20020a05620a29d200b006fbeca246a0si2338331qkp.379.2022.11.30.23.40.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 Nov 2022 23:40: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=@redhat.com header.s=mimecast20190719 header.b="V/5DBSSt"; 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=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0e9k-0007iW-8k; Thu, 01 Dec 2022 02:38:52 -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 1p0e9f-0007gp-O6 for qemu-devel@nongnu.org; Thu, 01 Dec 2022 02:38:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0e9e-0007tV-3R for qemu-devel@nongnu.org; Thu, 01 Dec 2022 02:38:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669880324; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y5/7MrH+QtrO6VCSQCLTGZeCpdV+HusT1OZ+wFAoJKk=; b=V/5DBSSt9MhybZnPip1aFESUn+Tnj6ayQBpJZuDzypLuHbKBYQJ+UJ4pYaPfdcX+vUn/0j EPfgxKd8TyxYBvA8u7e1QCUd+f2yXSWaKNmttsg8D0er1gGHoCS7oVd6vkT+sBkBZbLS+z 8T+eZNgn5nNRXIG89PE+YFDuNheg/QM= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-602-YA28AxJqNkqJ4CbiuPJ6Dg-1; Thu, 01 Dec 2022 02:38:43 -0500 X-MC-Unique: YA28AxJqNkqJ4CbiuPJ6Dg-1 Received: by mail-wm1-f69.google.com with SMTP id c126-20020a1c3584000000b003cfffcf7c1aso2180285wma.0 for ; Wed, 30 Nov 2022 23:38:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Y5/7MrH+QtrO6VCSQCLTGZeCpdV+HusT1OZ+wFAoJKk=; b=UPmaooHc7+xwdihBOS/sIAxe03ZDXLi9E+6VCqnv+2ICN8xs6kiobHc8dzhiLZJIX2 +rP8MVWY5haeCFJgvD8JlQcal3spzBKrQAYS8v2rdlIEW+ErBVeO81Skuv4YVKLFch/n 21Yj2ukJ8ULUjRf0QQ5CXuPwevRKy4s/2gXGT1z3U+QuMlHTblPyAi81fRDJYk9/TOSw v06/uPAK7wpXpbdXaTU5TZeGtgT/nygJokVPJD9V8TvSwkkx+Om3qwS2AYO6MVcxvOoQ 7ji2Gmax49rrVYp0O8UvpOFQzy7mCmnCH+2t6Ndc7sNgvsZfXhd0QDvbaj7Lu8T9EhiO ipow== X-Gm-Message-State: ANoB5pltSMCfWpGc97yfaLO20np/DrBu0EwfaVZg0dM7S/oWsmpoLKYN szQsQaqRLGaG3myo96OPqQQmQCN2oYxMI8T71qRrjrNdhKT/wcK22qRHlIL95+efqtILogIdey4 OjrHuxHGZ3AlMlYS9DdfBnjT9Rf2Sc04nNrvcTFvVSTiyxspuwMtzV/fgfh7O X-Received: by 2002:a05:600c:5127:b0:3cf:a4c4:777e with SMTP id o39-20020a05600c512700b003cfa4c4777emr41190359wms.72.1669880321908; Wed, 30 Nov 2022 23:38:41 -0800 (PST) X-Received: by 2002:a05:600c:5127:b0:3cf:a4c4:777e with SMTP id o39-20020a05600c512700b003cfa4c4777emr41190334wms.72.1669880321597; Wed, 30 Nov 2022 23:38:41 -0800 (PST) Received: from redhat.com ([2.52.19.245]) by smtp.gmail.com with ESMTPSA id q128-20020a1c4386000000b003c71358a42dsm11088186wma.18.2022.11.30.23.38.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Nov 2022 23:38:41 -0800 (PST) Date: Thu, 1 Dec 2022 02:38:39 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Viresh Kumar Subject: [PULL 3/5] hw/virtio: add started_vu status field to vhost-user-gpio Message-ID: <20221201073725.44585-4-mst@redhat.com> References: <20221201073725.44585-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221201073725.44585-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 From: Alex Bennée 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 Message-Id: <20221130112439.2527228-4-alex.bennee@linaro.org> Signed-off-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; }