From patchwork Mon Dec 5 09:51:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 631051 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2428619pvb; Mon, 5 Dec 2022 02:09:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf4KbFGL2+WoJRSiugS3dvYw+FMnu2VwHm0s/MN74+VGyXC4H88//zVo+E4+WgkblRU8W5BE X-Received: by 2002:a05:620a:8d3:b0:6fa:23d4:aecc with SMTP id z19-20020a05620a08d300b006fa23d4aeccmr55105528qkz.678.1670234994497; Mon, 05 Dec 2022 02:09:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670234994; cv=none; d=google.com; s=arc-20160816; b=Tab4GUX6C/kFH7iiLfo9i8MTzd3UoB15rRkcsl0xRq/svCGwEZnVw9CIX9R2UFGRWu 9gxHUbUh5RmKikJKpv8OXZypEPWoCeDhb+X66sDfDf/EmRXcDVphs9Bev7d8LdKoGVJj 0XgNdAK4mjI0ApeV7p3xmX89ODsR1pxXCbXZ8aiES1OTDeTE66QkHdltgAm6ZfAXklYn tmDtxpm/25bvyBN4m+Rlp7OZj7yWD+5HjLJGW5/wcCFFQYYG9ZAycmpCRUu+z+YYPLr9 jV9Uji8MTIYvyOfFt6gtjjHwAg3O4lyiUnS/ZTI/ArAnygKSrMh/9apJ+aUkIZ/pfPZd n2hA== 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=VpGPqFxym62K9GH7MKfAV+SJq1q0meLvnvyfpQU3Eqk=; b=L582j7zvoQz4+IMhiWboiTXbe6RnxK7ee5VjRqe0E7gWrsnYQGQfxCGr9KJoNizFcl o4ARV+a6qYYGNb/JFVj20nbYNa7U0VnrdxLvdZzJArPa6e/xpqxiY+R6svkqPX+VaZtR pzoy4d9+LTmnPO1/OmOJg0y7Quajtw5/6XLchHNQF109PbllRcE5vVb3/NKsbRAc2Z/4 O3sQRENw/PCgeT/k/tQCt3Frpp8ZUSqQjgyzznpdEBUN+OEgMuG66cxZ2cYS6OYbM39p xaJWJUE9ICqIolTJjj5LsbQfN8SGdDdLzm1e8iG4MkycOAvAKdqU+qjOF1i4m14fPjwm av3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PN9alLA+; 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 n6-20020a05620a294600b006f983fcbec5si8147279qkp.559.2022.12.05.02.09.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 05 Dec 2022 02:09:54 -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=PN9alLA+; 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 1p28Bb-000252-Dm; Mon, 05 Dec 2022 04:54:55 -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 1p28BN-0001sn-Es for qemu-devel@nongnu.org; Mon, 05 Dec 2022 04:54:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p28BJ-0006sS-3a for qemu-devel@nongnu.org; Mon, 05 Dec 2022 04:54:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670234076; 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=VpGPqFxym62K9GH7MKfAV+SJq1q0meLvnvyfpQU3Eqk=; b=PN9alLA+pQ55KGC0k9EGbY9UKHN9bkdEuvM3CiHPMFSPdxf0Gu+4iru0HNq0OwuSC7i0tV FMy1i3vN+orK3zAtFFQcfW8TAuZep1Lwmgv25dANBK/8dlpZEJxvECf5SpHhrWpMM6spTE 9eJaDSqUrxqTLS+hvMJiS+yEcOX7nTA= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-263-AUpsFNRrNQKqMyJYVcGvEQ-1; Mon, 05 Dec 2022 04:54:31 -0500 X-MC-Unique: AUpsFNRrNQKqMyJYVcGvEQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5E9A6299E755; Mon, 5 Dec 2022 09:54:30 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.135]) by smtp.corp.redhat.com (Postfix) with ESMTP id 32C382166B29; Mon, 5 Dec 2022 09:54:23 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Cc: Fam Zheng , Thomas Huth , Viresh Kumar , Kevin Wolf , Mathieu Poirier , Laurent Vivier , Eric Blake , Richard Henderson , Raphael Norwitz , Stefan Hajnoczi , Juan Quintela , virtio-fs@redhat.com, =?utf-8?q?Alex_Benn=C3=A9e?= , Christian Borntraeger , "Gonglei (Arei)" , qemu-block@nongnu.org, Xiaojuan Yang , Thomas Huth , Ilya Leoshkevich , Eduardo Habkost , Gerd Hoffmann , "Dr. David Alan Gilbert" , Alex Williamson , Eric Farman , Halil Pasic , Peter Maydell , Vladimir Sementsov-Ogievskiy , Jason Wang , Laurent Vivier , Song Gao , qemu-s390x@nongnu.org, Pavel Dovgalyuk , Klaus Jensen , John Snow , Michael Tokarev , qemu-arm@nongnu.org, Paolo Bonzini , "Michael S. Tsirkin" , Keith Busch , David Hildenbrand , qemu-trivial@nongnu.org, Hanna Reitz Subject: [PATCH v2 14/51] hw/virtio: add started_vu status field to vhost-user-gpio Date: Mon, 5 Dec 2022 10:51:51 +0100 Message-Id: <20221205095228.1314-15-quintela@redhat.com> In-Reply-To: <20221205095228.1314-1-quintela@redhat.com> References: <20221205095228.1314-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@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=unavailable 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; }