From nobody Sun May 5 06:20:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1667672301; cv=none; d=zohomail.com; s=zohoarc; b=h1vkdQApqlfmul55WMVj2m3VFm1ZDCPaqSTVi6uMqRESOgq7Pn6AMu90n1cPVVDz6IReRDwjcQahDar4kJcnwOKHs3sPbzkp8Jgux/ppt/hDZzTy+O9iq067CIN7Mjc5LRaE3JJ3QCfmF9QfBp3eaNM2mCpFitIoFkihCeG3zgU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667672301; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Tlg+GFFInRUWGqS9ZO5elj+yjNjfHU8IddwAAo9A4Bs=; b=L+CmYprVQKhwIbjYXigbHUAXtGHu26NhyqzV1Y6lB9fv7wY3l51VlNWSqFRjuWNFv0GaozUGYNZaELikoQKMdLJI7d2NG6DRCWsqAcjy4mgpEoFU8tTI7IPDvKyzQozxBBjsC4f24S7ErvkDlN7q247QsPg+D5W1RpcrnDL1hgI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1667672301734392.4686041928354; Sat, 5 Nov 2022 11:18:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1orNiT-0000Ye-Jk; Sat, 05 Nov 2022 14:16:25 -0400 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 1orNiS-0000YO-6s for qemu-devel@nongnu.org; Sat, 05 Nov 2022 14:16:24 -0400 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 1orNiQ-0007pC-6f for qemu-devel@nongnu.org; Sat, 05 Nov 2022 14:16:23 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-151--aDu5EaiPUy9lRLhjx_0kg-1; Sat, 05 Nov 2022 14:16:19 -0400 Received: by mail-wm1-f72.google.com with SMTP id m34-20020a05600c3b2200b003cf549cb32bso6068276wms.1 for ; Sat, 05 Nov 2022 11:16:19 -0700 (PDT) Received: from redhat.com ([169.150.226.216]) by smtp.gmail.com with ESMTPSA id d2-20020a056000114200b00236860e7e9esm2637484wrx.98.2022.11.05.11.16.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Nov 2022 11:16:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667672181; 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=Tlg+GFFInRUWGqS9ZO5elj+yjNjfHU8IddwAAo9A4Bs=; b=b8SbCZhh8e0BdAArZkDvv3JdOXCeCS+0yHuKwXqhqSyXS0KZ9lS4Gio5SEVxh77GeREBl6 ZJIQnLuuBoDISbh/blQzR8bV2I0RfmkoNQzjBoTFdNixxiKnpR5vcSX4vlMqo4mdHalhGf vN7Leyy/l0cPHtn2wiUIP7mwwCYX0rc= X-MC-Unique: -aDu5EaiPUy9lRLhjx_0kg-1 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=Tlg+GFFInRUWGqS9ZO5elj+yjNjfHU8IddwAAo9A4Bs=; b=S9LWp1t2mSzg6V1LWVUsvi3yYNrtJrwP5g3C9kiIUQ0czFxbDlJDt52IhlD7cCEQCD P23bVMqmHGKEX7/sRe4G6eEmfYMO4sPpeugpTMROhEIkW8HjC+fhyv53xft3XCkkZNAC PrxUa9QQFQo4yat+Z8L09Syw3a/o7YlXwiXVqFH5LRdN0/YOGSN8KF3dl6d5INwAsL0R x57vrTWC7UQWqbNMiWLtuctavMXUErm/Z61cTZKTT0ESU3PI2rLzPqoBYw6F/ETPXPMs X4Uxy9Bf5o+HDxVakcxN1rJdb6oC7Z1RzUwwT9P6m9QTfIL/jc1tIUMOcFIvybq06SG3 LsZA== X-Gm-Message-State: ACrzQf1nisqv07x3Um5zPUPVkgfHJYwZ8oU53qB35bjUW+YIBJ+kE6Wg Kq6pysf10NMk1KzRWHq728kUSmG3A07x5Pqb0NbnZuOH0Pxyym58z6M8afdxN2F2Bnjo26A97sO xdMfj4uowcLX+twrzP8KYyaP7+p3Y485zTC3DR/NefmaiCCyghItSyXaQmnl5 X-Received: by 2002:a05:600c:28ce:b0:3cf:6e78:e335 with SMTP id h14-20020a05600c28ce00b003cf6e78e335mr23005305wmd.142.1667672178338; Sat, 05 Nov 2022 11:16:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4NjW1cotBHWwW1UjzXdGO8wnOGtLOmDbWpIph3LX3Ggfxxa+P23XJ6vogKa9ZHMtSYZCDBuA== X-Received: by 2002:a05:600c:28ce:b0:3cf:6e78:e335 with SMTP id h14-20020a05600c28ce00b003cf6e78e335mr23005282wmd.142.1667672177955; Sat, 05 Nov 2022 11:16:17 -0700 (PDT) Date: Sat, 5 Nov 2022 14:16:13 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: "Dr. David Alan Gilbert" , Stefan Hajnoczi , Alex =?utf-8?Q?Benn=C3=A9e?= , Viresh Kumar , Mathieu Poirier , virtio-fs@redhat.com Subject: [PATCH RFC 1/3] virtio: distinguish between started and running Message-ID: <20221105172453.445049-2-mst@redhat.com> References: <20221105172453.445049-1-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <20221105172453.445049-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.045, 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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1667672303926100003 virtio core often needs to know whether device is started, this is what virtio_device_started already did. However, backends want to know whether virtio is actually running which also depends on whether vm is running. To address this we moved the check to virtio_device_started, but this changes virtio core behavior which wasn't intentional. Let's add a new API virtio_device_running just for the backends. Follow up patch will revert the change to virtio_device_started. Further, the old API was actually ignoring vm running state most of the time (when use_started property is set), The new API takes vm running state into account properly. Fixes: 9f6bcfd99f ("hw/virtio: move vm_running check to virtio_device_start= ed") Cc: "Alex Benn=C3=A9e" Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio.h | 9 +++++++++ hw/virtio/vhost-user-fs.c | 2 +- hw/virtio/vhost-user-i2c.c | 4 ++-- hw/virtio/vhost-user-rng.c | 4 ++-- hw/virtio/vhost-user-vsock.c | 2 +- hw/virtio/vhost-vsock.c | 2 +- 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 1423dba379..634c24513f 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -402,6 +402,15 @@ static inline bool virtio_device_started(VirtIODevice = *vdev, uint8_t status) return status & VIRTIO_CONFIG_S_DRIVER_OK; } =20 +static inline bool virtio_device_running(VirtIODevice *vdev, uint8_t statu= s) +{ + if (!vdev->vm_running) { + return false; + } + + return virtio_device_started(vdev, status); +} + static inline void virtio_set_started(VirtIODevice *vdev, bool started) { if (started) { diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index ad0f91c607..174c968179 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -123,7 +123,7 @@ static void vuf_stop(VirtIODevice *vdev) static void vuf_set_status(VirtIODevice *vdev, uint8_t status) { VHostUserFS *fs =3D VHOST_USER_FS(vdev); - bool should_start =3D virtio_device_started(vdev, status); + bool should_start =3D virtio_device_running(vdev, status); =20 if (vhost_dev_is_started(&fs->vhost_dev) =3D=3D should_start) { return; diff --git a/hw/virtio/vhost-user-i2c.c b/hw/virtio/vhost-user-i2c.c index bc58b6c0d1..cf4fd26cf4 100644 --- a/hw/virtio/vhost-user-i2c.c +++ b/hw/virtio/vhost-user-i2c.c @@ -93,7 +93,7 @@ static void vu_i2c_stop(VirtIODevice *vdev) static void vu_i2c_set_status(VirtIODevice *vdev, uint8_t status) { VHostUserI2C *i2c =3D VHOST_USER_I2C(vdev); - bool should_start =3D virtio_device_started(vdev, status); + bool should_start =3D virtio_device_running(vdev, status); =20 if (vhost_dev_is_started(&i2c->vhost_dev) =3D=3D should_start) { return; @@ -157,7 +157,7 @@ static int vu_i2c_connect(DeviceState *dev) i2c->connected =3D true; =20 /* restore vhost state */ - if (virtio_device_started(vdev, vdev->status)) { + if (virtio_device_running(vdev, vdev->status)) { vu_i2c_start(vdev); } =20 diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c index bc1f36c5ac..ba548dc83c 100644 --- a/hw/virtio/vhost-user-rng.c +++ b/hw/virtio/vhost-user-rng.c @@ -90,7 +90,7 @@ static void vu_rng_stop(VirtIODevice *vdev) static void vu_rng_set_status(VirtIODevice *vdev, uint8_t status) { VHostUserRNG *rng =3D VHOST_USER_RNG(vdev); - bool should_start =3D virtio_device_started(vdev, status); + bool should_start =3D virtio_device_running(vdev, status); =20 if (vhost_dev_is_started(&rng->vhost_dev) =3D=3D should_start) { return; @@ -144,7 +144,7 @@ static void vu_rng_connect(DeviceState *dev) rng->connected =3D true; =20 /* restore vhost state */ - if (virtio_device_started(vdev, vdev->status)) { + if (virtio_device_running(vdev, vdev->status)) { vu_rng_start(vdev); } } diff --git a/hw/virtio/vhost-user-vsock.c b/hw/virtio/vhost-user-vsock.c index 7b67e29d83..30228eaa21 100644 --- a/hw/virtio/vhost-user-vsock.c +++ b/hw/virtio/vhost-user-vsock.c @@ -55,7 +55,7 @@ const VhostDevConfigOps vsock_ops =3D { static void vuv_set_status(VirtIODevice *vdev, uint8_t status) { VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(vdev); - bool should_start =3D virtio_device_started(vdev, status); + bool should_start =3D virtio_device_running(vdev, status); =20 if (vhost_dev_is_started(&vvc->vhost_dev) =3D=3D should_start) { return; diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index 7dc3c73931..1c768ee196 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -70,7 +70,7 @@ static int vhost_vsock_set_running(VirtIODevice *vdev, in= t start) static void vhost_vsock_set_status(VirtIODevice *vdev, uint8_t status) { VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(vdev); - bool should_start =3D virtio_device_started(vdev, status); + bool should_start =3D virtio_device_running(vdev, status); int ret; =20 if (vhost_dev_is_started(&vvc->vhost_dev) =3D=3D should_start) { --=20 MST From nobody Sun May 5 06:20:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1667672297; cv=none; d=zohomail.com; s=zohoarc; b=KwR3kBWEgabEQYPXFVxFOwMWDWOSM4D8HTDocMcL9VZRatwwO6MXoUxRkx9pGfzWLlM8fL6m+7n1sx9/onOzPfCYZ6tfTjgA2hwoeX5uif0c8NeSb+kHQjHKx9/sdXON5qq42SlSPPg4uJQYLSgISJ2Rkh2uz3/wtBpyfB4V/MU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667672297; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HCumTYExZFxa+mUq1vvCATCLdsbTjyIn1a3PvxIM+9M=; b=nUQR0MlcOPe7+b+hOAyZqaTrjVclGjIFPTrh7k1KRg3pFuUz16G50IxgzlVxfkFmpdOuHwkkjNGWimJ93n6BUXKYSD9mxnPiQ8mOSK4/wgvzjv0vZNOWydJ2tqMtn5NvGx5SbCkrDJ6sNhunmqAydFI2QD5L01D0426ylE402og= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1667672297479184.2727174718956; Sat, 5 Nov 2022 11:18:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1orNiW-0000Z3-81; Sat, 05 Nov 2022 14:16:28 -0400 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 1orNiU-0000Yv-Po for qemu-devel@nongnu.org; Sat, 05 Nov 2022 14:16:27 -0400 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 1orNiT-0007pp-Cc for qemu-devel@nongnu.org; Sat, 05 Nov 2022 14:16:26 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-609-MSCj35T5MBaL3oWlGQxzvQ-1; Sat, 05 Nov 2022 14:16:23 -0400 Received: by mail-wm1-f71.google.com with SMTP id f62-20020a1c3841000000b003cf6d9aacbbso3885634wma.8 for ; Sat, 05 Nov 2022 11:16:23 -0700 (PDT) Received: from redhat.com ([169.150.226.216]) by smtp.gmail.com with ESMTPSA id h19-20020a05600c351300b003b4ff30e566sm19943300wmq.3.2022.11.05.11.16.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Nov 2022 11:16:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667672184; 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: in-reply-to:in-reply-to:references:references; bh=HCumTYExZFxa+mUq1vvCATCLdsbTjyIn1a3PvxIM+9M=; b=XleJh3K2FdkBD4kv72DIwGNmbPJWEk7bCGh7YRUlgCuBQHJepW/SfdCGvwbAp56OUPllcO s6GJww9d2uPowidzyhqZjG7T28QMGp+7+zGUW8HLGfdAQO0sYt20nSMEcJhXz/zvF5Hv3N i6oSvrUptlAcCIh0byDV1VQ9cgNdWME= X-MC-Unique: MSCj35T5MBaL3oWlGQxzvQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to: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=HCumTYExZFxa+mUq1vvCATCLdsbTjyIn1a3PvxIM+9M=; b=jpq+yYuaUp5XKvTyEecbE69ReHkIGlQzbmAC5Qx7iqltdbbeuE/qp2DRr+d4+hYsoe AdyP/GgtlkMV6nHRvJ5G8XyMYpS5IVpXzwSYEPJ3q+3WLmuwUce+Atvq4d7C/gFOgNlH EAmFhO54GzpXAK5OeshRFNQtOSfJkGKYPKt7Jn1P3APF2f2Oz5xv+okI+ITHMsmqedFL 9tte7EG0QorNtHGoI8ZDjsIbWFZ1flIqCMZid5+xbrKGVFT66t7tS6M7Ks5gXgbRya6q nAHdXDxPeVQhtxG55xLfLBBts4VYxp9FAusQWm9gXMTIz3zhXijI7+dC4eu/10l5z2tg J+/g== X-Gm-Message-State: ACrzQf0C9hhjxgLzuULIIVEBfIp9XKuT2QRBu2og4lKj0jSXFsQRn0Up yp+airrFsYR0cGXgpByzI4jb5WRBXJoeqGM3BnXQMjo2jZBAQYlNERTfHoLRzzFiIsxgX01IO+r tFzpiAnEdCT/pqh5mP8yVMybSjB2l3QtVoothk5KnXvGLa4Na3twH9Wes4wga X-Received: by 2002:a5d:6ac6:0:b0:236:84b5:6660 with SMTP id u6-20020a5d6ac6000000b0023684b56660mr26277513wrw.555.1667672181650; Sat, 05 Nov 2022 11:16:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Ivx8YsggX6Au2nVrdjA0cIlz2WJBWkCu1cripEIU+OZf+RRanl+an2I57k5IF1TKablafKw== X-Received: by 2002:a5d:6ac6:0:b0:236:84b5:6660 with SMTP id u6-20020a5d6ac6000000b0023684b56660mr26277498wrw.555.1667672181358; Sat, 05 Nov 2022 11:16:21 -0700 (PDT) Date: Sat, 5 Nov 2022 14:16:18 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: "Dr. David Alan Gilbert" , Stefan Hajnoczi , Alex =?utf-8?Q?Benn=C3=A9e?= , Viresh Kumar , Mathieu Poirier , virtio-fs@redhat.com Subject: [PATCH RFC 2/3] gpio: use virtio_device_running Message-ID: <20221105172453.445049-3-mst@redhat.com> References: <20221105172453.445049-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221105172453.445049-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.045, 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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1667672297818100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Same as other vhost-user devices, vhost-user-gpio cares whether device is running not whether frontend is started. Switch to that. Fixes: 27ba7b027f ("hw/virtio: add boilerplate for vhost-user-gpio device") Cc: "Viresh Kumar" Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-user-gpio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/vhost-user-gpio.c b/hw/virtio/vhost-user-gpio.c index 8b40fe450c..f34ee59b6e 100644 --- a/hw/virtio/vhost-user-gpio.c +++ b/hw/virtio/vhost-user-gpio.c @@ -152,7 +152,7 @@ static void vu_gpio_stop(VirtIODevice *vdev) static void vu_gpio_set_status(VirtIODevice *vdev, uint8_t status) { VHostUserGPIO *gpio =3D VHOST_USER_GPIO(vdev); - bool should_start =3D virtio_device_started(vdev, status); + bool should_start =3D virtio_device_running(vdev, status); =20 trace_virtio_gpio_set_status(status); =20 @@ -228,7 +228,7 @@ static int vu_gpio_connect(DeviceState *dev, Error **er= rp) } =20 /* restore vhost state */ - if (virtio_device_started(vdev, vdev->status)) { + if (virtio_device_running(vdev, vdev->status)) { vu_gpio_start(vdev); } =20 --=20 MST From nobody Sun May 5 06:20:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1667672297; cv=none; d=zohomail.com; s=zohoarc; b=ASErOGVD33tf98o8RwbnpMLclfHxt3iKU9CUKfCBA5b+Xc6Wxl8cKY4w2ole1bEWgX1Q0ru7trL//cWVOSXYMU4bpu/IaaB/tiFDAZMgkCUzLcprnXD8sI9tZtDOJt4ofNEemAsCaBz4Pr3wzaMvRzxbW0sMjhfXhPnOtC2ei10= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667672297; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xm/UpqJDCgQM8KXC7CHtk7A2yuPbSQwxvC5UgzVHNGc=; b=hWG0wcwXWhGfveetydADVU2iAUfq2q2zUmdq3PlacMtBP0OPw63lsYoFfEXw/sPxeWGFF8ZW9FCFHUeTzNZHZ8NmTR42addSUHKWq8uz4rzZNbAJ/IWnct+PQIJednyqFTNyw7uK9330jc0c5s6m2J/+KbrwFU2Rpa/pi7/I26M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1667672297677574.4756359083027; Sat, 5 Nov 2022 11:18:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1orNia-0000Zi-18; Sat, 05 Nov 2022 14:16:32 -0400 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 1orNiY-0000ZX-8Y for qemu-devel@nongnu.org; Sat, 05 Nov 2022 14:16:30 -0400 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 1orNiW-0007qZ-O6 for qemu-devel@nongnu.org; Sat, 05 Nov 2022 14:16:29 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-435-TIHGxkM2NMmaMEQNYPusJg-1; Sat, 05 Nov 2022 14:16:26 -0400 Received: by mail-wm1-f70.google.com with SMTP id 1-20020a05600c028100b003cf7833293cso6065729wmk.3 for ; Sat, 05 Nov 2022 11:16:26 -0700 (PDT) Received: from redhat.com ([169.150.226.216]) by smtp.gmail.com with ESMTPSA id c16-20020a5d5290000000b0022e36c1113fsm2743584wrv.13.2022.11.05.11.16.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Nov 2022 11:16:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667672188; 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=xm/UpqJDCgQM8KXC7CHtk7A2yuPbSQwxvC5UgzVHNGc=; b=f9alWkhYQP2pQ1JyZcnjx0zK1DDj7+0OFeqWoXpwR+FWcZXa9xwmE5DwPSrzM+pAmBG1fs xdvCpntN383HUYx05keLtrE+v4jKF+P1/2haGLbKwmHxyEW0pu0TenUDjBA9CddjnKnKow OuNpnhCKvFYlvSmQXBq00rcNRXrlFcs= X-MC-Unique: TIHGxkM2NMmaMEQNYPusJg-1 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=xm/UpqJDCgQM8KXC7CHtk7A2yuPbSQwxvC5UgzVHNGc=; b=HjIsZphLXv2yxeJVZYktpYfwOZLlnTYGBtMMqGsXZd32G2ThSYMtn/Vi8KlOVjuKf3 6Ahv7fS4HLa4UL6N+Vbcgb43TTB5cdx4HhjPeNGYVIG4fDRTKXegDb7k1ZIYTo1eIjO9 xEFF4TgruzfbVZvzoFRhTOYQxKw4V9PN8CXuuupx7qHekSK68BQOH7Pg/XdgQgT9t74i LCTvNrOh6fGLnrl7W/UelUiyaHkyLl3uPXRtu0XDyJJoCausMIB4RWsbtdqpf0T6SWsM NxxULItMwPgzt7lguq53/soIjFuCE7z7hUUqsNCRWlgvhOFmlkQGUzCGtJF3Y1zLwNQQ RwXw== X-Gm-Message-State: ACrzQf1bLeZh/FdWc/Zzm4q1G0zRj9nPmufyQRT9i0GqnLEvAMz1/h8v 1hCfazi6Ateu/JEImn9vvg8gk6L38NUQS0tY6g/jqKZDqrZOvSudRBewbtOCbozUtnVGqkrOBVu Zl8yqznfoxMBC8VzpJvolMay3a6F/Ch0cQkSkx+2o+WTCcwQ01UHhbuoGSldR X-Received: by 2002:a5d:5744:0:b0:236:5c21:177f with SMTP id q4-20020a5d5744000000b002365c21177fmr25858880wrw.449.1667672185550; Sat, 05 Nov 2022 11:16:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM41sLZsBjMmxFKsYPPP9xMharPXRR/EpmZy1ZwlR5Dv7GMH8NUM/CYXRt44D10xz56EMsY86A== X-Received: by 2002:a5d:5744:0:b0:236:5c21:177f with SMTP id q4-20020a5d5744000000b002365c21177fmr25858862wrw.449.1667672185254; Sat, 05 Nov 2022 11:16:25 -0700 (PDT) Date: Sat, 5 Nov 2022 14:16:21 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: "Dr. David Alan Gilbert" , Stefan Hajnoczi , Alex =?utf-8?Q?Benn=C3=A9e?= , Viresh Kumar , Mathieu Poirier , virtio-fs@redhat.com Subject: [PATCH RFC 3/3] virtio: revert changes to virtio_device_started Message-ID: <20221105172453.445049-4-mst@redhat.com> References: <20221105172453.445049-1-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <20221105172453.445049-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.045, 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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1667672299806100010 virtio core often needs to know whether device is started, this is what virtio_device_started already did. However, backends want to know whether virtio is actually running which also depends on whether vm is running. To address this we moved the check to virtio_device_started, but this changes virtio core behavior which wasn't intentional. Now that backends use the new virtio_device_running API, revert the change to virtio_device_started. Fixes: 9f6bcfd99f ("hw/virtio: move vm_running check to virtio_device_start= ed") Cc: "Alex Benn=C3=A9e" Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 634c24513f..de8d78af12 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -395,10 +395,6 @@ static inline bool virtio_device_started(VirtIODevice = *vdev, uint8_t status) return vdev->started; } =20 - if (!vdev->vm_running) { - return false; - } - return status & VIRTIO_CONFIG_S_DRIVER_OK; } =20 --=20 MST