From nobody Thu May 9 12:20:02 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1659434674; cv=none; d=zohomail.com; s=zohoarc; b=lL84BKumuOhIHIwLY8oItPMJkYPdj8Bgox+VMHpCXgIWLm3sqWSjd3Xlts9d+LIARJhZrZFVQpvFyqrp6Dvrj632r5jnN55cdeQRNUjwy6BHECJaku7pzx6MsTKSMyU5OK4E9ciyXDAvG0zIvM8DdoY9mUpSbCcgjuHUP7NObG8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659434674; 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=WTel/fQ7Gj1d2ni3sryAwF0T/iksivK0kIXjy8395Xc=; b=QINmrhFPBVArL0K4V7G86yOSDWVmgMCbCg4F0h17X46eNDXw/bq1J6IlrbZl2i2Vimzf97B9wWQ6XsTFuA+JjHhSN30D2YgPXmzUKMvWFc5fJlpnyzVPfGvNq57vW7vROiM3LpVFH7BRwPImiq/RuCVl5lv4YgKICUG1xxfL80M= 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 1659434674221892.4316801242352; Tue, 2 Aug 2022 03:04:34 -0700 (PDT) Received: from localhost ([::1]:47372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIolN-00082i-2W for importer@patchew.org; Tue, 02 Aug 2022 06:04:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33340) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIoXb-0001HG-5j for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:22 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:50935) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oIoXZ-0002Mv-4I for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:18 -0400 Received: by mail-wm1-x32c.google.com with SMTP id v5so6974712wmj.0 for ; Tue, 02 Aug 2022 02:50:15 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id o12-20020a05600c4fcc00b003a31d200a7dsm19650559wmq.9.2022.08.02.02.50.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 02:50:11 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id CA8501FFB8; Tue, 2 Aug 2022 10:50:10 +0100 (BST) 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; bh=WTel/fQ7Gj1d2ni3sryAwF0T/iksivK0kIXjy8395Xc=; b=DHW+C+RYNg6EOZJGS3DZi+htxLKjA8EWA92xqqdFN35ZUbyFIWjn5yNO5fHTTx/4Zc 8wGXW6wFRKOHu6jLqCE3i+mOVlH4rTsrlHO6BG5yyeuPstI7QgBLtQU9UPC56a91pF64 sefORvWjLZhxJFpqasRPTXH57mgOUr/vbpDTxifDHUVbsvyso2zvLrwYaBGBLm0utLQi Wjnqa91CMkfKQNOyFeMvDMSPRtfVtp7yzHAVRwCZAGnt8GAlMvu3NVEeFia/QuDKFmT1 TmfY5juQJDb6gE5Z50BhK7XauXcg2gWd9ikG0DdCH1wW3KbPQUbFs9eg0QH/8vfoSWvf 76rg== 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; bh=WTel/fQ7Gj1d2ni3sryAwF0T/iksivK0kIXjy8395Xc=; b=Sxi86RbGcpI2KkNSyQqieoE0wrZXmXmPIJF5/wm0NrkvqFezVyz+cj6JtLAiwDQ39G kjx0zLKBOoiR4t5W5fb9XxvRAqaVBC8UQ/XzF4117BaVss76uXTHh5sCFykaKvY4wcNj VtFFsidaXGbq0vv9krFAwYG25/VyRj38SGs8b5W1aweHdZc4IZhMKym1vJ+9hHUOtmcf eH+BXl0GKEheZ25FatCFm+ZJCdxbG83biJBpJIA6WVCfnqjSRLxGg2ZefurL78PbZ8ez eVvmfWpchttCrRgS167Cm0gaU7sSOp1Payjza+dl/mdgDSXPbmxKjPNPByJghm6Xf401 e1eg== X-Gm-Message-State: AJIora8HX2IYL017DLg0p7q6N/TKOWyIy2SKZQ+Hvs30Hn1GXvu02XGc 2hWLXuSbwffztQiWNqZUaMjAPA== X-Google-Smtp-Source: AGRyM1t2Z+L1bhmWY8rWZSMYIOnOYeoWJwXki/sHlXutW7qrgpP4C+5qS1+AJNsGWPuleGmiCmPHTQ== X-Received: by 2002:a05:600c:1ca8:b0:3a3:19c9:5448 with SMTP id k40-20020a05600c1ca800b003a319c95448mr13759641wms.40.1659433815022; Tue, 02 Aug 2022 02:50:15 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH v4 01/22] hw/virtio: incorporate backend features in features Date: Tue, 2 Aug 2022 10:49:49 +0100 Message-Id: <20220802095010.3330793-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220802095010.3330793-1-alex.bennee@linaro.org> References: <20220802095010.3330793-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::32c; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32c.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1659434675873100001 There are some extra bits used over a vhost-user connection which are hidden from the device itself. We need to set them here to ensure we enable things like the protocol extensions. Currently net/vhost-user.c has it's own inscrutable way of persisting this data but it really should live in the core vhost_user code. Signed-off-by: Alex Benn=C3=A9e Message-Id: <20220726192150.2435175-7-alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/virtio/vhost-user.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 75b8df21a4..1936a44e82 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -1460,7 +1460,14 @@ static int vhost_user_set_features(struct vhost_dev = *dev, */ bool log_enabled =3D features & (0x1ULL << VHOST_F_LOG_ALL); =20 - return vhost_user_set_u64(dev, VHOST_USER_SET_FEATURES, features, + /* + * We need to include any extra backend only feature bits that + * might be needed by our device. Currently this includes the + * VHOST_USER_F_PROTOCOL_FEATURES bit for enabling protocol + * features. + */ + return vhost_user_set_u64(dev, VHOST_USER_SET_FEATURES, + features | dev->backend_features, log_enabled); } =20 --=20 2.30.2 From nobody Thu May 9 12:20:02 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1659434061; cv=none; d=zohomail.com; s=zohoarc; b=CeCPVqcsV+qITiFalRIQqNUHKGtQMSrqQSKgmFPGnvFfJzgvRr/T2xmY+5DMtyKAaKYefHkp+kBV02x8GKTfqsDDVgus1BmhixhPkuqwewvOs/8hDNlNsEZahqQsUvnn2yZPVCdKrG6scvz77knu4DV3sngwsYvkzSbCQghJAuw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659434061; 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=s3nGxeo53LwaMo+sziN/l2Vq3ARUUV/BFGaJ8lB68So=; b=B2pJsDcH7vGc98uBbsI2dsmOrdG3k0c1VIrUviU7sJ1a8Anyjjl7aGnlhu3nAxlHVMfh+siVEc3a2hGuFRAQNEziWw9L0lJY1WgfsD63Zj1XFqAU3mpaAmn/w96v1thN2mXiesARAbJqCBfAPEkR519DjKip4ELARgswAxR/P4o= 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 165943406153561.020267609411576; Tue, 2 Aug 2022 02:54:21 -0700 (PDT) Received: from localhost ([::1]:53612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIobU-0001Mm-5b for importer@patchew.org; Tue, 02 Aug 2022 05:54:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33342) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIoXb-0001HH-4v for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:22 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:37554) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oIoXZ-0002Mu-4Y for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:18 -0400 Received: by mail-wr1-x432.google.com with SMTP id z17so12467092wrq.4 for ; Tue, 02 Aug 2022 02:50:16 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id j4-20020a5d6044000000b002205df9ce16sm8307240wrt.97.2022.08.02.02.50.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 02:50:11 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D66831FFBA; Tue, 2 Aug 2022 10:50:10 +0100 (BST) 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; bh=s3nGxeo53LwaMo+sziN/l2Vq3ARUUV/BFGaJ8lB68So=; b=nuKTgJ7zPvF6MD5Kz5loiYT79OGf2I6ozVWfeOFJhNSaHRJJOorc0myzYISRYYtABj OP4t9J7BUb01J2DFYLED6jahPDrUIT+FGL5orKyLwLD0mBwHKRk4qE5QmDZxK5KVVZIT 2zYeZD6ko5phv2cp9QfB7KgGKXSMlYTlzcijz4aIB2LEnyPHXoZe1ttBeqgefsrxpy19 ekl7BUTgXgr1/49G4/Pte36E7Cs8FfOEVW0nCIzUo8IkbILDyQ6zlxfhu2L3qULwxCsX nQWtS35g9Lp9JSzUykVJKnH+kM0EjtG2Y2peAWu4yA05Xnp8aHgrYyftAmaWf2vk0J8u yvow== 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; bh=s3nGxeo53LwaMo+sziN/l2Vq3ARUUV/BFGaJ8lB68So=; b=fOfd+JXbG9UXZQR/lLvEdzE1pQXbfLYPNP1Oe2T2U34T6X1v+/8L+cNRMDh/ZGREPL MrbjNgTTP4X6l3S49HVxDwGqaonbR5e8hdcFYuc8NYK8WPZ9eH5H1ZR717Ky5RwLraDV hJOLp3x+3cE8b3jIqdSoiZePcLfJkLtDPuOwMBZMxHg0MoavNZiMSdYBemSxQrkLc7mu mNaHhU52BezQOSCC6Hwur0kZVlQJ1d22TMklYguY1ETrc9UKpculiZVwYlgx4CgEFlQW GpPAWdONSie/d79tU7IIFX1lxSzo6ARlCZWn9wNrSdWBW2S2pEqEerJLlcCXYdpSMqSX 6mKw== X-Gm-Message-State: ACgBeo2YGX3w6aWYwXrz6C7nZSCv53aja+PZlDZQdXBYm+R3YeuvHgyf 509mcFNoVfVk/qk7alP6aiYU9w== X-Google-Smtp-Source: AA6agR4mVEw+AwyK2sAUkfmIMOJygRb6U5oBa2PG77rwVpvjZ08wn21i3mA+9MsaqFs+uYftLo3YMQ== X-Received: by 2002:a05:6000:1849:b0:21d:9ad7:f27f with SMTP id c9-20020a056000184900b0021d9ad7f27fmr12155808wri.445.1659433814394; Tue, 02 Aug 2022 02:50:14 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH v4 02/22] hw/virtio: gracefully handle unset vhost_dev vdev Date: Tue, 2 Aug 2022 10:49:50 +0100 Message-Id: <20220802095010.3330793-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220802095010.3330793-1-alex.bennee@linaro.org> References: <20220802095010.3330793-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::432; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x432.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1659434061756100001 I've noticed asserts firing because we query the status of vdev after a vhost connection is closed down. Rather than faulting on the NULL indirect just quietly reply false. Signed-off-by: Alex Benn=C3=A9e Message-Id: <20220726192150.2435175-8-alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/virtio/vhost.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 0827d631c0..f758f177bb 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -306,7 +306,7 @@ static inline void vhost_dev_log_resize(struct vhost_de= v *dev, uint64_t size) dev->log_size =3D size; } =20 -static int vhost_dev_has_iommu(struct vhost_dev *dev) +static bool vhost_dev_has_iommu(struct vhost_dev *dev) { VirtIODevice *vdev =3D dev->vdev; =20 @@ -316,8 +316,12 @@ static int vhost_dev_has_iommu(struct vhost_dev *dev) * does not have IOMMU, there's no need to enable this feature * which may cause unnecessary IOTLB miss/update transactions. */ - return virtio_bus_device_iommu_enabled(vdev) && - virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM); + if (vdev) { + return virtio_bus_device_iommu_enabled(vdev) && + virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM); + } else { + return false; + } } =20 static void *vhost_memory_map(struct vhost_dev *dev, hwaddr addr, --=20 2.30.2 From nobody Thu May 9 12:20:02 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1659434055; cv=none; d=zohomail.com; s=zohoarc; b=l4pqn6P4aUStf4QIOmLX7NRmloBs07Vu9ybZWCPGH/PJEOYTr1d/MCYMFq8xNYEZ4hYXaHD2WGqaaIvLvlMDCns4tGFGanyEuccBQp7loEGZV5jg5RZzjvOK2ubioSgqtEQb0gLIMeRF6EDKvCKRPrDE4x/mQ7ly4TmTBaDY2kE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659434055; 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=qn9sIffAzV9IF+yjjzIzifr78tit+1ZOBIt0UyqO2Rk=; b=MUqoEyWb9ssjemT5qgxhM2mxis0lkVZKIdnrqsyPi8IqnpulDNtf2mUsHZOgKbIolZGxFmA6ZtQXxzxkECkK+a/ZidjX4H6elMu1BGF6r5QG2xwNsFfOnJRZUtHGzVztfOmOwzthRTwHLjKtzQ8j7lDz/PMkAdlR1ZiWHzkuSaw= 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 1659434055017734.5346235333302; Tue, 2 Aug 2022 02:54:15 -0700 (PDT) Received: from localhost ([::1]:53024 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIobN-0000xU-K6 for importer@patchew.org; Tue, 02 Aug 2022 05:54:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33378) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIoXc-0001HL-Ct for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:22 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:43918) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oIoXa-0002ND-QD for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:20 -0400 Received: by mail-wr1-x42a.google.com with SMTP id bk11so7303294wrb.10 for ; Tue, 02 Aug 2022 02:50:18 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id d10-20020a5d6dca000000b0021b956da1dcsm14528615wrz.113.2022.08.02.02.50.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 02:50:11 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id ECB611FFBB; Tue, 2 Aug 2022 10:50:10 +0100 (BST) 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; bh=qn9sIffAzV9IF+yjjzIzifr78tit+1ZOBIt0UyqO2Rk=; b=efF1G23JZGBcKIp6YkFQGGk2fqRXWagTopKygNR1po59PbUd4t45kjdbsNpQhdOIp9 rN4irGKpt3YfkzxMTiDaMJ1gRkwHo5wHg4a+OVZVXS3SN8lu3nr5N0pl7t3szYTXZwOM /rQAm8SdInJ9UZ+MW0XKnCUhAybH98awbs0Q8X99VLNlAyPMZL3UIOdA9RHfmmKWfw8I HWV/UOlnuNz21LKpw/rHYto1QW+w/hm4IVU02VKdWQ99bCT6EdzCDERwei6OuUmIeSvQ PsFwuzZ+xjrcOXyyiaJtJ/ZaU9qmhkaaKDf1PfQcrEnxIEXz7W3C49pzS+k4GC68xNiS XbZQ== 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; bh=qn9sIffAzV9IF+yjjzIzifr78tit+1ZOBIt0UyqO2Rk=; b=MqciDGsmCi3P6IDoIwBr/03QBlHpEm0ihyczULxavqclrkp8iF/6z6AeZGP0GXehFI lZui+GZZzpwthTStKoXlbH2ctG1EkrTLortkHq48G3j7GvYboRrp0dDFEMR9qWJ4mKr8 HiaPky4Beirv6gqadIXBdAjqF/HjFBjOOK2J7ojItcwOy2dER5gPZXbA0oiLHosPP3cz gBksLLRIzE+sTtXC4XtAqkJ1iCzl8Gj5/M09lEVgvb9gLnPGHLAzHxuahx2/TWG2PfKw ADG19A6OesABejUf1Dz01BtfCPi8u1LBYEXhMY7BMgvHROxh2auD+AL3LWEJRxLY59o0 PtfA== X-Gm-Message-State: ACgBeo0yA5c0cZvB1fUZHKOEfY7Cw6UoXfmF6cbAhDmw67eiypoexg3B W0/VHkiH8U2vQWR/ASlR+fGsyA== X-Google-Smtp-Source: AA6agR6o/9O+Wa8d6ULbcE7q6RefoClwbZ7tggUNqcMfWXiwmDQ8Gs/xJGnef+Zsua7zuz90y/OZmw== X-Received: by 2002:a5d:6e89:0:b0:21e:ad87:ab24 with SMTP id k9-20020a5d6e89000000b0021ead87ab24mr12832977wrz.259.1659433817294; Tue, 02 Aug 2022 02:50:17 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH v4 03/22] hw/virtio: handle un-configured shutdown in virtio-pci Date: Tue, 2 Aug 2022 10:49:51 +0100 Message-Id: <20220802095010.3330793-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220802095010.3330793-1-alex.bennee@linaro.org> References: <20220802095010.3330793-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::42a; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42a.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1659434055768100003 The assert() protecting against leakage is a little aggressive and causes needless crashes if a device is shutdown without having been configured. In this case no descriptors are lost because none have been assigned. Signed-off-by: Alex Benn=C3=A9e Message-Id: <20220726192150.2435175-9-alex.bennee@linaro.org> --- hw/virtio/virtio-pci.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 45327f0b31..5ce61f9b45 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -996,9 +996,14 @@ static int virtio_pci_set_guest_notifiers(DeviceState = *d, int nvqs, bool assign) =20 nvqs =3D MIN(nvqs, VIRTIO_QUEUE_MAX); =20 - /* When deassigning, pass a consistent nvqs value - * to avoid leaking notifiers. + /* + * When deassigning, pass a consistent nvqs value to avoid leaking + * notifiers. But first check we've actually been configured, exit + * early if we haven't. */ + if (!assign && !proxy->nvqs_with_notifiers) { + return 0; + } assert(assign || nvqs =3D=3D proxy->nvqs_with_notifiers); =20 proxy->nvqs_with_notifiers =3D nvqs; --=20 2.30.2 From nobody Thu May 9 12:20:02 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1659434202; cv=none; d=zohomail.com; s=zohoarc; b=A3ay0TlF0tFWOuZW5dykIiuzjmSfhTURjtwXL9v4G8xKOlx7zNFf0KyK1J72QuC87WxKvuooqyI8vRJCVwzDdATMAbyvaZdUrl3nbBknauuZU+JHKasKuOmaWELpy0TWnZJnmdLsEoJhLyZZ4+lbV535vHScc+FiMuXaWdM1wCU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659434202; 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=5cs2obCibuFrGV6ezAp7TXix+CRt2n51MrtUoaGrvvI=; b=JvoexCexhiOhWi2X/RMSMm9t80IZrB4WnCrxfVjM+WQVhfCKUa2OSQaiqzi9bSjWIGoMkZPCd+p/HjC5Lt2lkvadTxG94EuN1w/5zGQvR/JUKAsFHEcvL8ChqamYjlOZOwWZSbCUTyrYCSInSsJxbNZfpMsl0XPuqBNNtzAkIeI= 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 1659434202658107.75559257068358; Tue, 2 Aug 2022 02:56:42 -0700 (PDT) Received: from localhost ([::1]:60276 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIodl-0005pg-6O for importer@patchew.org; Tue, 02 Aug 2022 05:56:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIoXb-0001HK-Tv for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:22 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:34489) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oIoXZ-0002N3-Kf for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:19 -0400 Received: by mail-wm1-x32a.google.com with SMTP id r1-20020a05600c35c100b003a326685e7cso384338wmq.1 for ; Tue, 02 Aug 2022 02:50:17 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id z5-20020a5d6405000000b0021f138e07acsm12063874wru.35.2022.08.02.02.50.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 02:50:16 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 045161FFBC; Tue, 2 Aug 2022 10:50:11 +0100 (BST) 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; bh=5cs2obCibuFrGV6ezAp7TXix+CRt2n51MrtUoaGrvvI=; b=cECP5XUY2z/lkBJFqiKOWxATL/VRg51L8ABqJ08XaYSpvPMczxbN21DUMxWEXFW+GO xeJybOb94+Wg8LrGqQJaPmhmuJnv7/oGm1gPoBg8TWvfvS23efR0aaTBBGcz33/L1wcO CSWs4jWzxyth82L0oRTK6Nkl7tPK3tBhrpfn82B1j8bYy+Q0sI9q6k3nMAh5Bm/SdHpy 1ML8J7w97qCyZE3XpeOOZkqV2lC2lHPJFfqlSySkz7b46YRAKbbFbt40Oo/ylDGXkVzo +NHw8OBr4mCCq8PyeZfthE71WpFQhR35MF7hevP7CfIHiqIuL61hLNGzaY+2ytpHLXt/ aj1g== 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; bh=5cs2obCibuFrGV6ezAp7TXix+CRt2n51MrtUoaGrvvI=; b=VXDWxpeaBxK5U/u1oYKU73kqy5H7MNSp5WwWP5GyryEWpoObPd930bdQsDitHnLegx EEUY4i5dT+JIySVcuwrikFQYi9dJYPNof1GYoRfY0YRzH//mpUNlB1e+9XYozxR54URC cD4tL3o2lhfNhcAbftA3bfTYSUhfPl171BcDdlJA4NXEIG8z3tfO1kN7CD+NpP6kjdl6 ZJOktUPlHpPeNk+iegTsaLH8N06MQd3yyHkplxJ+Ww7f7y3+87Ga5sEamLSxtqVcagoj +ftk6tU+k0Mdl3VPYjytwN7Zeb1vrS859kbWHtMaDWweTkPOyv2fx6BipQxtLLcuAmBW C+hw== X-Gm-Message-State: AJIora8UUvoy+Su6PVmkrL5slQCH8lXCxeZkluYd5Jv+WbCJzLHdcLfI Aar2bSTgwM6gFjSgApcnQ1rkrQ== X-Google-Smtp-Source: AGRyM1vJO1h+8fFqfkhwSJZ/uwd86VBNJ1BKwiS84jSWbMjb0YG5hjz/I7DV5yA22Qpkj6Jo0eVWag== X-Received: by 2002:a05:600c:154a:b0:3a3:2fae:9bae with SMTP id f10-20020a05600c154a00b003a32fae9baemr13955383wmg.23.1659433816391; Tue, 02 Aug 2022 02:50:16 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Jason Wang Subject: [PATCH v4 04/22] hw/virtio: fix vhost_user_read tracepoint Date: Tue, 2 Aug 2022 10:49:52 +0100 Message-Id: <20220802095010.3330793-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220802095010.3330793-1-alex.bennee@linaro.org> References: <20220802095010.3330793-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::32a; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32a.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1659434204666100001 As reads happen in the callback we were never seeing them. We only really care about the header so move the tracepoint to when the header is complete. Fixes: 6ca6d8ee9d (hw/virtio: add vhost_user_[read|write] trace points) Signed-off-by: Alex Benn=C3=A9e Acked-by: Jason Wang Message-Id: <20220726192150.2435175-10-alex.bennee@linaro.org> --- hw/virtio/vhost-user.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 1936a44e82..c0b50deaf2 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -295,6 +295,8 @@ static int vhost_user_read_header(struct vhost_dev *dev= , VhostUserMsg *msg) return -EPROTO; } =20 + trace_vhost_user_read(msg->hdr.request, msg->hdr.flags); + return 0; } =20 @@ -544,8 +546,6 @@ static int vhost_user_set_log_base(struct vhost_dev *de= v, uint64_t base, } } =20 - trace_vhost_user_read(msg.hdr.request, msg.hdr.flags); - return 0; } =20 --=20 2.30.2 From nobody Thu May 9 12:20:02 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1659434333; cv=none; d=zohomail.com; s=zohoarc; b=FklF4qbn6fsPyHZEca33N5vissjaEe8kk4G7ZhIdmQOkLia/gZbHhtDOaYI6eoVh6Hpc5l7217hEAz/IgLYOyyf05tciZuJXTg1U7awAVi20cI/sgHDsqM6CqHutMjKsvcll2E4FyXGA9xQQLaTSdJJhujhqO0W/jaywknTEnoY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659434333; 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=6BvLwU4GMUiq3XaMcxliYSNhOBL1ZkQfbeog0e1G+vA=; b=hTvCNDQ7auga9iyjL7qK0waVweYP4SE4QWjAh1zXrZzI7vMkwl79brIva70vprJ+DoqcM6kQ273F7l9/Rzdbfd5LDM9MDqX/T9Rxk/uTdnutSUWTtwR27nRrm/B3KswopNk3WshgL9nOjbUJEMCUQX+tLXuj3npwW0mhjTl8cow= 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 1659434333947448.95883716473065; Tue, 2 Aug 2022 02:58:53 -0700 (PDT) Received: from localhost ([::1]:37944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIofs-0001UM-Re for importer@patchew.org; Tue, 02 Aug 2022 05:58:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33420) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIoXf-0001Hf-7G for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:24 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:52961) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oIoXd-0002OZ-LK for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:22 -0400 Received: by mail-wm1-x329.google.com with SMTP id c22so6970240wmr.2 for ; Tue, 02 Aug 2022 02:50:21 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id u10-20020a05600c19ca00b003a31fd05e0fsm4190710wmq.2.2022.08.02.02.50.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 02:50:17 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 1ADC01FFBD; Tue, 2 Aug 2022 10:50:11 +0100 (BST) 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; bh=6BvLwU4GMUiq3XaMcxliYSNhOBL1ZkQfbeog0e1G+vA=; b=g5KXnNSg154aRqx6ZdjXfeEFD0K83wLKBGUyr3IGxbH/ozIiQ6JrbyVh/XdLtSAfUa 4aEFQrQN5MXkzeS4BImtCVFnAYxJkVOfnKRjgSFf2lVusaG7iYrIx9TGZHx3tzNOSTXg QW/J/cIuuqsaZtDNGZzi9p+nfhkgMS7UnsLR4dzG6tp5/KuNYuKkddFxyNBmYugppwwC tBoQ/rEcwGLPPoxLXJU6K0toXa/v4du5IvrP4o79gQY7GMajCESTZmY2b4XiFFXk9aa/ fK9RJBpbcbxHfNHC/Zy46yPSAQojlqxce6ks0HPYK+q8+PBSaNo7nbH3IDEYR+dE1Omx h0KA== 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; bh=6BvLwU4GMUiq3XaMcxliYSNhOBL1ZkQfbeog0e1G+vA=; b=EjRhzC8cjhgryJ/vvOCK+vZAGzCGXqMPk5A5DaPeZELqQ/x3z/0Qg2yjWMaZlYMs+u +UT63CBtF2CrACvHkCKpoynPLdR0niEsuzjQlSMGricROxOZQOnTAnozq7uF14sie5ED /++LTzbSkELIUFQUeqnUOsuuHvAEeSOXvpWCrmiM+V5I+6EFoxUL67UyWzcz0ey2EyeV R8GQBPpmf/6vyIYlxe6wd3otCswQFF4JZ/QsostojzFv1pMok7l7zHD00tKrYW5QsHYK JQn/2QNlSD/yFQmezz17y2X9DdYvt0U63RTocl0sNwn+hxkFtIou+UtLfrC3TUtPA7/L TopA== X-Gm-Message-State: AJIora9ljkOxr/qN+EHydpcEosKm0N8WE36hmJQ7UQmmzL6jeoRmbzHt N6+GW4cRJ9jFTS/ghOH76pBtaw== X-Google-Smtp-Source: AGRyM1sDPVh1O8jgPqxwE/fgI5aWqqY3JlEq27m6pMls6Do727/igYrCfnQIIgikTyP8G174X6FKbw== X-Received: by 2002:a1c:27c4:0:b0:3a3:365d:10a2 with SMTP id n187-20020a1c27c4000000b003a3365d10a2mr13815782wmn.61.1659433820190; Tue, 02 Aug 2022 02:50:20 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH v4 05/22] include/hw/virtio: more comment for VIRTIO_F_BAD_FEATURE Date: Tue, 2 Aug 2022 10:49:53 +0100 Message-Id: <20220802095010.3330793-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220802095010.3330793-1-alex.bennee@linaro.org> References: <20220802095010.3330793-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::329; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x329.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1659434334350100001 When debugging a new vhost user you may be surprised to see VHOST_USER_F_PROTOCOL getting squashed in the maze of backend_features, acked_features and guest_features. Expand the description here to help the next poor soul trying to work through this. Signed-off-by: Alex Benn=C3=A9e --- v3 - s/vhost/vhost-user/ --- include/hw/virtio/virtio.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index db1c0ddf6b..9bb2485415 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -24,7 +24,12 @@ #include "qom/object.h" #include "hw/virtio/vhost.h" =20 -/* A guest should never accept this. It implies negotiation is broken. */ +/* + * A guest should never accept this. It implies negotiation is broken + * between the driver frontend and the device. This bit is re-used for + * vhost-user to advertise VHOST_USER_F_PROTOCOL_FEATURES between QEMU + * and a vhost-user backend. + */ #define VIRTIO_F_BAD_FEATURE 30 =20 #define VIRTIO_LEGACY_FEATURES ((0x1ULL << VIRTIO_F_BAD_FEATURE) | \ --=20 2.30.2 From nobody Thu May 9 12:20:02 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1659434361; cv=none; d=zohomail.com; s=zohoarc; b=jbKtPzEWvxWlWS3+LoydtKs7/F/jRYGskqBa6AYx0s8QEmgaUrafpEkknG0M2qdTXRTEFtfjGVqrb+Ll/p19+33Q5q8ibpZ/GbJve3ll2FffgigbUFyImQ8SEkaEKypvS/qe/3NBcBIJHMAaunWwBo4U/1L7NFAuKFU2NunsetI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659434361; 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=b2j/kb8GdcOCxPJdxE8uUIOafIPdVMpQHMJ+EKtT808=; b=X6r63MVDlf7tHcKIdaYb8TFkVBiVGpzejSTMilWR6HFVTWmj/sEsGtuaxZIE+VPf1HboTFnIeajJfaWA1Bi+STEiMNPyhD99pYlZ0odpA99+VradY3Xr44ymsAN8fzPPtqJ7W5AJdOmrp2lxJ4XQxv1CGWEBrimay3U98JEYJec= 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 1659434361623487.10645646811645; Tue, 2 Aug 2022 02:59:21 -0700 (PDT) Received: from localhost ([::1]:38858 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIogK-00026c-En for importer@patchew.org; Tue, 02 Aug 2022 05:59:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33402) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIoXd-0001HS-Ex for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:23 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:39737) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oIoXb-0002Mq-TU for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:21 -0400 Received: by mail-wr1-x42c.google.com with SMTP id m13so13216320wrq.6 for ; Tue, 02 Aug 2022 02:50:19 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id t16-20020a5d42d0000000b0021f17542fe2sm10877072wrr.84.2022.08.02.02.50.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 02:50:17 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 26EFA1FFBE; Tue, 2 Aug 2022 10:50:11 +0100 (BST) 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; bh=b2j/kb8GdcOCxPJdxE8uUIOafIPdVMpQHMJ+EKtT808=; b=VUtWBMO0NTR4B5G8bJmReMeHCB5+5EghhApZ5v+JT53Tu9HnwJoqO/jafntZKmTsg+ s+5MS2QaAIzqt0CVeTHxQHcatcZdbJQc8N9NEHZAUTdQfBdr0JwfuSRjbyPQxhUMVgDL lBy3nydnZhASOh93V4wVf68SDTQmzF8xBw2BSJT0h2jitB2nZ3JwgxeB1zXz+AoesiM/ dfb9AHDxp9PXNUuyI67FfHQ6kFMwmTZA056DhV5bTLxYAQWJR7eEz1gdmxJD1lYvSeKn MVsmNdOKtI6RCMVU1GE4s+8iIng41VSxaCSq8sjoYufgD3dolynhTWmYMrNv/trTd/mc Fk9A== 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; bh=b2j/kb8GdcOCxPJdxE8uUIOafIPdVMpQHMJ+EKtT808=; b=u4/QPj4MYSfLm+ELIpIWEK2aGm++wWHy0tVhIEzja8RSB1e/EuQTUHukmXyhrIN8DT pESNxTOIXDvJR6suVSzUK+ynIS0p0CE2OB1sKcfv1MjQ43+hW09tdeJtp+oNDcn+/f3P 37w7EaQY4tPw7FOi+Rnhed4pJAPPAZkWk2WE3C2cVCY8v9aA23Cg+la+X0ns6lXmrCRQ xoMmXSbKFUS+YnLNFA4Ms+6IrnngqTn/9T+g22vM5euZb6hO1yxi+rmW6rU9NWi1AmsI ZNT/pJghF8T7n54KGHgYtIWNU1AEGlOp7IeaqGwKjAzsSt3Zi1j+Xw4PJ2eIDzU7H3IM zezQ== X-Gm-Message-State: ACgBeo15Jvi6C0ovk9FCM8A1r4njOgb8XbqbFuv6xjVzm9YsZFBEeCXI Vjvlgo3p2mMRK6sx0hzhjteaWw== X-Google-Smtp-Source: AA6agR6zTvoncdOSjGVCJxQdLgKH9N1yWZDX0IHiM0VaZaXzUGmnSoeeg6ODSLr1dqhMAlP/AOgrcw== X-Received: by 2002:a05:6000:887:b0:21e:24a0:f302 with SMTP id ca7-20020a056000088700b0021e24a0f302mr12097520wrb.466.1659433819206; Tue, 02 Aug 2022 02:50:19 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Jason Wang Subject: [PATCH v4 06/22] include/hw: document vhost_dev feature life-cycle Date: Tue, 2 Aug 2022 10:49:54 +0100 Message-Id: <20220802095010.3330793-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220802095010.3330793-1-alex.bennee@linaro.org> References: <20220802095010.3330793-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::42c; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42c.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1659434362663100003 Try and explicitly document the various state of feature bits as related to the vhost_dev structure. Importantly the backend_features can advertise things like VHOST_USER_F_PROTOCOL_FEATURES which is never exposed to the driver and is only present in the vhost-user feature negotiation. Signed-off-by: Alex Benn=C3=A9e Acked-by: Jason Wang Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/virtio/vhost.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index a346f23d13..586c5457e2 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -86,8 +86,11 @@ struct vhost_dev { /* if non-zero, minimum required value for max_queues */ int num_queues; uint64_t features; + /** @acked_features: final set of negotiated features */ uint64_t acked_features; + /** @backend_features: backend specific feature bits */ uint64_t backend_features; + /** @protocol_features: final negotiated protocol features */ uint64_t protocol_features; uint64_t max_queues; uint64_t backend_cap; --=20 2.30.2 From nobody Thu May 9 12:20:02 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1659434043; cv=none; d=zohomail.com; s=zohoarc; b=QdL3H9qSQ8gksbhdaHSGIQjpwFJpq88zTyAXe+RWBzU5gnzTzR+rBvnP6kca5ttuoCD+ZT+vDk3CN/PXrhH16ZaWDoHHHp8fYpieTjiU2sjBadyIc/+0ZdtWXt77svS5oW/IRFhJa8aHB4TVBADxR84a9C/kR6WFEvouFw9u3cE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659434043; 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=KjbLNdi3E1apNFwTGial5s5eMkKbrprSc8sGCh0PAC4=; b=A5q3ZcHzKS34MBz5QNBi9PrZEh7gu4FFYx0Qsin3Sx19fuUnBvMG6tzFV2Ry27etODS1kWK4Dy625e1saA4yjC/NWHQHx4ybtxZ5qHWD8i1Z+NtPM56V16r4JJ8fZJStph0N+ZsoR/8hFgiToZDAxlfnyb8TrYb8D1OTkDs5SfA= 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 1659434043176427.04009374411976; Tue, 2 Aug 2022 02:54:03 -0700 (PDT) Received: from localhost ([::1]:51912 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIobC-0000BD-1T for importer@patchew.org; Tue, 02 Aug 2022 05:54:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33490) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIoXk-0001L2-TX for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:29 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:45594) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oIoXf-0002Qp-Oq for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:28 -0400 Received: by mail-wr1-x42c.google.com with SMTP id z16so17094524wrh.12 for ; Tue, 02 Aug 2022 02:50:23 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id j4-20020a5d6044000000b002205df9ce16sm8307395wrt.97.2022.08.02.02.50.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 02:50:17 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 3E18C1FFBF; Tue, 2 Aug 2022 10:50:11 +0100 (BST) 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; bh=KjbLNdi3E1apNFwTGial5s5eMkKbrprSc8sGCh0PAC4=; b=QEtzfjEHObPZngplL0jW5i0a/FKoRYbv4BUQCKx/Yp6C8AdlEQuUx9doP39tV9rekZ 0hy3lrFUAMHm1+kPZbo9nw5K6OZLtZCdbCyJukO6aQYH61ce5Dpx5JPYEM5ZjYL4oloo vn2ZBmmGgOMRFxpk1+PZbYar3n69i3vM3jfoamyk2BB2s0eM3oZfkRhrzqaG2KhDY7Tr slSInS07bC0q4r/E0WdfpvYJpCQINFopX1l5zg3ZT44KTfu2HkLboXknJd/SFs0rj1Fa qq57Jz1HJP/a+kKsb7yKKwhqkgwD8KzGrih94o1hfPxfRXsLrqp/apKyK+OynJwT7LPJ 0YJA== 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; bh=KjbLNdi3E1apNFwTGial5s5eMkKbrprSc8sGCh0PAC4=; b=UHb4OtJ/dwumY6ycu0eVXwSyZfoA3NvxhFVNhLOyC2mnvxznml+HZWLjhPXvGVZsEE ns4GeRle8NydUVl36ULzKMqxV8ZZNOJOSrYr8WHqDs7GJeeQAHrKp5uiIuI9qFJVQcpO Cw0jtqMSmgYtaJCQxHAyHSGCG9RAO6czyUj9TApxGkMC+s+Ns1F9Si0wYhUNYNUHuEgK 5BbZlldyBmL2YeKrwCfsw+6BW4vzL3711oOvHntCGNG+Ot5j/DM9wlejffsMz9nR7lkg qHLAvQY/Alsm7x3fg6OjdNW12LTUXk0Y6LDzBjxdCqv4juUWoUQvUXgTZ/a0Nnb8+YvC Cg7Q== X-Gm-Message-State: ACgBeo2NjEXgYD+Tf7F2S/mkz612N/upRHEH3/SyiGlYd/U0MKDmcvnw 1Zhjf9lnyvZRVd4mzPJ+PpbPrg== X-Google-Smtp-Source: AA6agR5S5YEePJrk/nHViSK1vfVaByvPjgkZr6qgd7TuHxedjbm6aeKQeyxKBxkKxoqFSU3Z6Kf7lw== X-Received: by 2002:a05:6000:2aa:b0:21d:ac4b:95af with SMTP id l10-20020a05600002aa00b0021dac4b95afmr12207575wry.479.1659433822480; Tue, 02 Aug 2022 02:50:22 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Jason Wang Subject: [PATCH v4 07/22] hw/virtio: fix some coding style issues Date: Tue, 2 Aug 2022 10:49:55 +0100 Message-Id: <20220802095010.3330793-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220802095010.3330793-1-alex.bennee@linaro.org> References: <20220802095010.3330793-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::42c; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42c.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1659434043833100001 Signed-off-by: Alex Benn=C3=A9e Acked-by: Jason Wang Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/virtio/vhost-user.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index c0b50deaf2..b7c13e7e16 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -200,7 +200,7 @@ typedef struct { VhostUserRequest request; =20 #define VHOST_USER_VERSION_MASK (0x3) -#define VHOST_USER_REPLY_MASK (0x1<<2) +#define VHOST_USER_REPLY_MASK (0x1 << 2) #define VHOST_USER_NEED_REPLY_MASK (0x1 << 3) uint32_t flags; uint32_t size; /* the following payload size */ @@ -208,7 +208,7 @@ typedef struct { =20 typedef union { #define VHOST_USER_VRING_IDX_MASK (0xff) -#define VHOST_USER_VRING_NOFD_MASK (0x1<<8) +#define VHOST_USER_VRING_NOFD_MASK (0x1 << 8) uint64_t u64; struct vhost_vring_state state; struct vhost_vring_addr addr; @@ -248,7 +248,8 @@ struct vhost_user { size_t region_rb_len; /* RAMBlock associated with a given region */ RAMBlock **region_rb; - /* The offset from the start of the RAMBlock to the start of the + /* + * The offset from the start of the RAMBlock to the start of the * vhost region. */ ram_addr_t *region_rb_offset; --=20 2.30.2 From nobody Thu May 9 12:20:02 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1659434636; cv=none; d=zohomail.com; s=zohoarc; b=MQRXDIl8rzYPIGLY4Z5DSzrTMxZeledTt2MKwayN3mZkpXh9k7jtwQQVj3cc7x7dEyo5LzmfO4cLJ4G+91iOH0eZ30FWyCMfAhIfC2TI+9jyJnHY+W1J8z6YUtGOaqtyDTElidKhuovb39Ms+kITEjRPS4IdkBX1N71IUuPcEoE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659434636; 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=FCj/56VzmS3/60OSoLTpgej5xNapP0emctIC1iwkYIU=; b=lNPsEsfjxKvcCLMIt9xDrP5MX2m2o0SNkTIJzNfIFMjdrgDXKLg7auy0FCk5MayFawIeIvuKuFcIOe0HV7jg+rws98KddgMPfzbv2Rw8gIkCydQFwE67F3LvJ3CgbQ39eWvGuGi8AEqQe2ig79n/VxYAYLtdRqOymAjN1BD9CU0= 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 1659434636439352.15551752386716; Tue, 2 Aug 2022 03:03:56 -0700 (PDT) Received: from localhost ([::1]:46450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIokl-0007Qs-7q for importer@patchew.org; Tue, 02 Aug 2022 06:03:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33554) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIoXq-0001Rr-2i for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:34 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:34761) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oIoXn-0002W3-Jw for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:33 -0400 Received: by mail-wr1-x433.google.com with SMTP id j1so8785053wrw.1 for ; Tue, 02 Aug 2022 02:50:31 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id j3-20020a5d6043000000b0021efc75914esm14785094wrt.79.2022.08.02.02.50.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 02:50:18 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 4FEB01FFC0; Tue, 2 Aug 2022 10:50:11 +0100 (BST) 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; bh=FCj/56VzmS3/60OSoLTpgej5xNapP0emctIC1iwkYIU=; b=bFxJ3qwOb707nKyR4nNIQLKNKeQQR1+viFQR0dAVqlfiZY6ZGPAvUXTUppLVzqt1uE M1xsMXqeIEk7gLT8layS+87an46D+Ipx+oA3lgvDSDzixyYyrnw4hokeDA25e8ZpyJni XvU9PhJZR1ZopZpumVLwwD2/fjdskEoZFEoghBeaioEQupisUytFnj6FPtJsx2KV2Lm7 CBOKTlpGGVJd5sbbSGPFQJWbwzZmVxFI6mkmKWw9uUA4ijPPhMk9wKTjyinnzsqEpa0S FnsU5BzbkWUqDV1TJu1PBxUJmVa+dAFzAI9yPqcmLwhqopys2YfsBtjXDLAXa1h3VZSf b/nA== 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; bh=FCj/56VzmS3/60OSoLTpgej5xNapP0emctIC1iwkYIU=; b=Xgy4rCn6Q5KT2aTCjuG6PtxYIX/zp/q0FyO+ARBwkN72qXx0JytzL1ibJXXZnJPJqt jn0o6z2EGKqlwN0kS62I1q3UhkE2KdK8/2lgFpbOpkpv4/lrcxzzx9lNfOI4bC03TfWI +RGl9eZBM+wVBL1ZFuw0aqvLfX1iK8gdmWK6KpTCB6/NyWmf/3QASe+z93pFodHtzve8 7tgn0bK3JouT89XKzUx68m+Lzw2FgqZUNSGjE95l6Vcvb3IFXY3j80Q9GzssiPC70xd4 Jl7hR+zvEUVZlx7BxjWJhj6gkOOFJxpzyNkq+dbEyAw47w/x+P9tF7BktVxp1Hl08FtQ ez3g== X-Gm-Message-State: ACgBeo0lV7+1NNoYk29ye/ZrXpbfo4DdbIJ+i9rqwZOeXJmTZJNRtU5h 65uzRvTfCx4h2ywWPXrt6mG0Uw== X-Google-Smtp-Source: AA6agR66Ny/0zKkhcq8f7h1JtU/iKYT+19OgV2JzeP8cSJ4o7YLp+UeciK4997EDEBtmcGX2qXfHEg== X-Received: by 2002:adf:e10a:0:b0:21e:47f4:6a51 with SMTP id t10-20020adfe10a000000b0021e47f46a51mr12948639wrz.276.1659433830316; Tue, 02 Aug 2022 02:50:30 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Jason Wang Subject: [PATCH v4 08/22] hw/virtio: log potentially buggy guest drivers Date: Tue, 2 Aug 2022 10:49:56 +0100 Message-Id: <20220802095010.3330793-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220802095010.3330793-1-alex.bennee@linaro.org> References: <20220802095010.3330793-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::433; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x433.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1659434638229100001 If the guest driver attempts to use the UNUSED(30) bit it is potentially buggy as 6.3 Legacy Interface: Reserved Feature Bits states it "SHOULD NOT be negotiated". For now just log this guest error. Signed-off-by: Alex Benn=C3=A9e Acked-by: Jason Wang --- hw/virtio/virtio.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 5d607aeaa0..97a6307c0f 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2980,6 +2980,13 @@ int virtio_set_features(VirtIODevice *vdev, uint64_t= val) if (vdev->status & VIRTIO_CONFIG_S_FEATURES_OK) { return -EINVAL; } + + if (val & (1ull << VIRTIO_F_BAD_FEATURE)) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: guest driver for %s has enabled UNUSED(30) feat= ure bit!\n", + __func__, vdev->name); + } + ret =3D virtio_set_features_nocheck(vdev, val); if (virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { /* VIRTIO_RING_F_EVENT_IDX changes the size of the caches. */ --=20 2.30.2 From nobody Thu May 9 12:20:02 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1659434169; cv=none; d=zohomail.com; s=zohoarc; b=EGrVQnTVFOZehRicy2P0jJJFsNLwSNFD8wnAXxheyYpaTC6rPz3MMF0yQ9UcdLvSi0AkWJKQ+PpPmWwnXlSzJF3nY197KcveR2s5r72L1D29gkzUgH4jVqaNKB4r8FCRR4GfA/Ps7OquEnvJDZ56Sw42GioLKLeS4yeFpsz50Fw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659434169; 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=H/ZcxJebFvV+fJPCaMkPj2jiRtkMtcjbXvy3+aTz3aU=; b=RPNUvnKe9e7qn9TAymf7hlK7fdWO89e4+DqYgohNjNTyn72/D99Zgq3AkIK7PDxJ5b4ik3WhiKFeM+TaAgub2AuiCVifZRlLiwr+2XLOOXZSV9AmQecgYgfRAZ05XjYfBZffi6gjHEJa5QWEOKZKG6KHw22Ll97Wg6mA+Q8hMTM= 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 1659434169750941.018787144314; Tue, 2 Aug 2022 02:56:09 -0700 (PDT) Received: from localhost ([::1]:59410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIodE-0005G7-JY for importer@patchew.org; Tue, 02 Aug 2022 05:56:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33394) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIoXd-0001HR-1X for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:22 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:40453) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oIoXb-0002NJ-DO for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:20 -0400 Received: by mail-wr1-x42b.google.com with SMTP id l22so17178873wrz.7 for ; Tue, 02 Aug 2022 02:50:18 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id t16-20020a5d6a50000000b0022069ccb6a1sm4085507wrw.94.2022.08.02.02.50.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 02:50:18 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 683021FFC1; Tue, 2 Aug 2022 10:50:11 +0100 (BST) 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; bh=H/ZcxJebFvV+fJPCaMkPj2jiRtkMtcjbXvy3+aTz3aU=; b=pu55oEKeOTa2bxqKN+YN9NvrIJAbjZKCozOkzx2szI8V2uRhKtxINCZtpOOzndgbeS /Rb6B92+0vk/oSt0wUeDHUqh66O0ZXHzgJUVQaH+nDNnkK6aTAwMxsCyq0TuXxKus4vx ZrJo0BTnNHxs+94jo6K0V4EZfeNhIW7eZdlSXe7PBSz25AnjS5TQfW01g4tN2pLVcvcZ Lq3leBAoe3qHFAhne3VbaBo4UN7caDeX0VevsCOwAw3yZISZQRejnZ9tH4iIgvijjY8C iaD/Q9uwIpEXhvP7jfD7eS8mHPWne9+DsuiPIdfgROgvevT1cUu2XpAGHS1Y2I0yRwd7 6xRg== 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; bh=H/ZcxJebFvV+fJPCaMkPj2jiRtkMtcjbXvy3+aTz3aU=; b=A6gKm5tdvEZ5bKkGsXSnSN1NohniShFeTWEIehynYbnYLMUVNxVvieC7LxUZuepPxP u1kW/XGLO4wy2zTj466J0RqzclFT7VjTKtea0GjzRdOQDRbrww4mB9bm0cPfoK4I/NRE v4sxGtGYrXRHGI15Cpsx5Dwoqw+UIcz4CF61btWvUY6YqmLYBYgBrtNfpcrZTdMrLfyh o4jxtSWWW6QcLnozihEhlAD51VKlBno72jd7VdHtm0a0rbRierTEHDQsdJPd7gJWC35s OAyYW0LyDYiSfvTl3hA1o2LfS+GgriuXMspDtnFXRmHIAr9IZOE7xIo6LqjrGtKt6Mjy eddg== X-Gm-Message-State: ACgBeo0O8HxXT/JtBEG2tQQhMN/m6b1j8dMjTwbJA4klb6w8y3mr/Nrt XUy1bAPsuApcjky62vZUTfWtCQ== X-Google-Smtp-Source: AA6agR7DLPTMtZxpElEkMT8GuJx0RHB3820tAZV4LOh18vPu52jbVAFEaokWe4cQwXSrwlFT6KqDFQ== X-Received: by 2002:a5d:47a5:0:b0:220:5985:6710 with SMTP id 5-20020a5d47a5000000b0022059856710mr9084814wrb.633.1659433818106; Tue, 02 Aug 2022 02:50:18 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH v4 09/22] hw/virtio: add some vhost-user trace events Date: Tue, 2 Aug 2022 10:49:57 +0100 Message-Id: <20220802095010.3330793-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220802095010.3330793-1-alex.bennee@linaro.org> References: <20220802095010.3330793-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::42b; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42b.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1659434170478100001 These are useful for tracing the lifetime of vhost-user connections. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/virtio/vhost.c | 6 ++++++ hw/virtio/trace-events | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index f758f177bb..5185c15295 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1477,6 +1477,8 @@ void vhost_dev_cleanup(struct vhost_dev *hdev) { int i; =20 + trace_vhost_dev_cleanup(hdev); + for (i =3D 0; i < hdev->nvqs; ++i) { vhost_virtqueue_cleanup(hdev->vqs + i); } @@ -1783,6 +1785,8 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODev= ice *vdev) /* should only be called after backend is connected */ assert(hdev->vhost_ops); =20 + trace_vhost_dev_start(hdev, vdev->name); + vdev->vhost_started =3D true; hdev->started =3D true; hdev->vdev =3D vdev; @@ -1869,6 +1873,8 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODev= ice *vdev) /* should only be called after backend is connected */ assert(hdev->vhost_ops); =20 + trace_vhost_dev_stop(hdev, vdev->name); + if (hdev->vhost_ops->vhost_dev_start) { hdev->vhost_ops->vhost_dev_start(hdev, false); } diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 20af2e7ebd..887ca7afa8 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -8,6 +8,10 @@ vhost_region_add_section_aligned(const char *name, uint64_= t gpa, uint64_t size, vhost_section(const char *name) "%s" vhost_reject_section(const char *name, int d) "%s:%d" vhost_iotlb_miss(void *dev, int step) "%p step %d" +vhost_dev_cleanup(void *dev) "%p" +vhost_dev_start(void *dev, const char *name) "%p:%s" +vhost_dev_stop(void *dev, const char *name) "%p:%s" + =20 # vhost-user.c vhost_user_postcopy_end_entry(void) "" --=20 2.30.2 From nobody Thu May 9 12:20:02 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1659434212; cv=none; d=zohomail.com; s=zohoarc; b=FBRzJS5g5nd2oGoW2bE6bIDmL5RdCrZJNGAk61yPGYkkrXxjfdm5c7cm1fe7DkGQxE2yUKqeQEkchhuJyLmBvfAz5vSQRvSfLAEvhzHeIr2G1CA3suyU5WXlUw7freLPAfKxm5dOFYhOY2iV93jgGW1gdyER/oCNIFrLBEs1FXk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659434212; 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=x448FCGsB6jl4t/PEZTiuqAxlBX+i+OighRCNvx3IrY=; b=bRlrZ7J6nBzgK3Vf1Y6qzHdlrxtaJM02vnEhZRhYY96ApbFSPvU7AIqa9JQoaWHYjJAAY5/Y+3xu3EwPzByfa0VGTDuYy5Pg4qC7vW8sevU6GOzovzPFaig3jnRplsL7ARYbMdC6TfI/vNWwe5iN69A1fdvmEVyixkcNynZCls4= 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 1659434212933461.3870934298592; Tue, 2 Aug 2022 02:56:52 -0700 (PDT) Received: from localhost ([::1]:60662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIodu-0006CD-Vm for importer@patchew.org; Tue, 02 Aug 2022 05:56:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33492) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIoXl-0001L3-1m for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:29 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:37554) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oIoXj-0002Mu-7q for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:28 -0400 Received: by mail-wr1-x432.google.com with SMTP id z17so12467710wrq.4 for ; Tue, 02 Aug 2022 02:50:26 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id x12-20020a05600c21cc00b0039747cf8354sm17660436wmj.39.2022.08.02.02.50.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 02:50:18 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 7FAFB1FFC2; Tue, 2 Aug 2022 10:50:11 +0100 (BST) 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; bh=x448FCGsB6jl4t/PEZTiuqAxlBX+i+OighRCNvx3IrY=; b=a2o70i6ozgrkoN+0syJ6dPIbzVBJa9qJmDlahBv+BChgsvfUIast9YimY1+nJjhzEc Rp4qxINM/eb26p2DShObyo0xHy8Z6Xjbf16z+cMYY0Jwzn+Jx3tgAXZR3wBxQ46mwmlu dkJW5rcJmxcRC218sQeh0E8GOlL/p740hcxz4qFWgUB22oCwxARhtBpcXRM17NZ+7bOA gcRP2QgKO4lbjWf9Vt5ohl/Nhbg2bg8VrU5/KiGdeK/9WX+EnRaUlVNZzx0ym1FM9FPB 9MIdIqitVw3Hnxjih5SB5O0z4Io9GkYyAmpHXRLoJlLmioTXu4XmGwfRPohyVHqSZYWt E7pA== 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; bh=x448FCGsB6jl4t/PEZTiuqAxlBX+i+OighRCNvx3IrY=; b=oNBjFJufNuIVCjqUwPV9bVVSGlVGxgUJI0OtgJyNEpJ/njb7pRCsTksqqJuA/S272u A2wQ4t6jlBdbEL/4yqS9M7bOhRoZdh1bE1r3J+3lGzPxSDkNXq+Fr31OCVgjL9iFZhmT u7oGNDWR0Hf0xJYj5Idf+bxh0p94MZnLnTXHxa8wqldMhXDeNDuhXMJbl2WMcUUlvQs2 TzpEJgELG8ecAHzJYfLIsuvGr4td+fC79Ni+Kd3yXvFQarqDfaj0R16lXSTOJlEGDFhH CZbu1GpA+VjUD6be+ngpoTuFAyfBdLKaBWvLa9IfAlfIPt+WY5e06OXcqRek8sx1yfom /RFw== X-Gm-Message-State: ACgBeo3cF1lcWnr7Zl0VrSnCXsj5aJCPddJUWok7BcZ6AyUU4sHVnMq/ B3kGaT6ThBjx1aHR6+kQ/Nnnqw== X-Google-Smtp-Source: AA6agR5meWse+7HgSqjXMLgsqNKtCEqU4qvT3Btoa1U4hS/hLUVtFnxKbTW55JvlcxGDPBkv8TA0Aw== X-Received: by 2002:a5d:6c63:0:b0:220:5e4d:c6e9 with SMTP id r3-20020a5d6c63000000b002205e4dc6e9mr7856582wrz.250.1659433826495; Tue, 02 Aug 2022 02:50:26 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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, =?UTF-8?q?Alex=20Benn=C3=A9e?= , "Dr. David Alan Gilbert" , virtio-fs@redhat.com (open list:virtiofs) Subject: [PATCH v4 10/22] hw/virtio: move vm_running check to virtio_device_started Date: Tue, 2 Aug 2022 10:49:58 +0100 Message-Id: <20220802095010.3330793-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220802095010.3330793-1-alex.bennee@linaro.org> References: <20220802095010.3330793-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::432; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x432.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1659434214687100001 All the boilerplate virtio code does the same thing (or should at least) of checking to see if the VM is running before attempting to start VirtIO. Push the logic up to the common function to avoid getting a copy and paste wrong. Signed-off-by: Alex Benn=C3=A9e --- include/hw/virtio/virtio.h | 5 +++++ hw/virtio/vhost-user-fs.c | 6 +----- hw/virtio/vhost-user-i2c.c | 6 +----- hw/virtio/vhost-user-rng.c | 6 +----- hw/virtio/vhost-user-vsock.c | 6 +----- hw/virtio/vhost-vsock.c | 6 +----- 6 files changed, 10 insertions(+), 25 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 9bb2485415..74e7ad5a92 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -100,6 +100,7 @@ struct VirtIODevice VirtQueue *vq; MemoryListener listener; uint16_t device_id; + /* @vm_running: current VM running state via virtio_vmstate_change() */ bool vm_running; bool broken; /* device in invalid state, needs reset */ bool use_disabled_flag; /* allow use of 'disable' flag when needed */ @@ -376,6 +377,10 @@ 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 diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index e513e4fdda..d2bebba785 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -122,11 +122,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 status & VIRTIO_CONFIG_S_DRIVER_OK; - - if (!vdev->vm_running) { - should_start =3D false; - } + bool should_start =3D virtio_device_started(vdev, status); =20 if (fs->vhost_dev.started =3D=3D should_start) { return; diff --git a/hw/virtio/vhost-user-i2c.c b/hw/virtio/vhost-user-i2c.c index 6020eee093..b930cf6d5e 100644 --- a/hw/virtio/vhost-user-i2c.c +++ b/hw/virtio/vhost-user-i2c.c @@ -93,11 +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 status & VIRTIO_CONFIG_S_DRIVER_OK; - - if (!vdev->vm_running) { - should_start =3D false; - } + bool should_start =3D virtio_device_started(vdev, status); =20 if (i2c->vhost_dev.started =3D=3D should_start) { return; diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c index 3a7bf8e32d..a9c1c4bc79 100644 --- a/hw/virtio/vhost-user-rng.c +++ b/hw/virtio/vhost-user-rng.c @@ -90,11 +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 status & VIRTIO_CONFIG_S_DRIVER_OK; - - if (!vdev->vm_running) { - should_start =3D false; - } + bool should_start =3D virtio_device_started(vdev, status); =20 if (rng->vhost_dev.started =3D=3D should_start) { return; diff --git a/hw/virtio/vhost-user-vsock.c b/hw/virtio/vhost-user-vsock.c index 0f8ff99f85..22c1616ebd 100644 --- a/hw/virtio/vhost-user-vsock.c +++ b/hw/virtio/vhost-user-vsock.c @@ -55,11 +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 status & VIRTIO_CONFIG_S_DRIVER_OK; - - if (!vdev->vm_running) { - should_start =3D false; - } + bool should_start =3D virtio_device_started(vdev, status); =20 if (vvc->vhost_dev.started =3D=3D should_start) { return; diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index 0338de892f..8031c164a5 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -70,13 +70,9 @@ static int vhost_vsock_set_running(VirtIODevice *vdev, i= nt start) static void vhost_vsock_set_status(VirtIODevice *vdev, uint8_t status) { VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(vdev); - bool should_start =3D status & VIRTIO_CONFIG_S_DRIVER_OK; + bool should_start =3D virtio_device_started(vdev, status); int ret; =20 - if (!vdev->vm_running) { - should_start =3D false; - } - if (vvc->vhost_dev.started =3D=3D should_start) { return; } --=20 2.30.2 From nobody Thu May 9 12:20:02 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1659435825; cv=none; d=zohomail.com; s=zohoarc; b=UWqSlAo3gT3y6E41mjjTcgETN4N1dUZ2s9BitFZencM3wlUpKCUtG0e+2Z9LlPfoYs/cSDC8kkk7A/L/QH/eaw4sZLEyXNDcsLRx8puqQwoPd5qpYe1jlY0XHwWkWJWzWHv1SucsKYVijR7yRxMb9D9D41W5ICHeHYMdd9/2daE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659435825; 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=BeukRfDDjs+xL5noIXV/lsICwMCkD6JOsmbjcLzfdS8=; b=EeMwCNQrTZkbJ97Hbhl8lTfPYfG2Dc1rsAkaa9Xpzd2/M7p8EzDMPPfG8JtPMHu4D+T/FMu1gb8PYWMRqz9SU4/TS8bYn68+2TBrT3ssX6eyuVd4jX4xherDlGjemTmGvv3H1sYhWgWJph1rWAIpiM9G8PLiuLdAjWXpZhDl4PE= 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 1659435825872600.8811871338511; Tue, 2 Aug 2022 03:23:45 -0700 (PDT) Received: from localhost ([::1]:46998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIp3w-00021W-Hx for importer@patchew.org; Tue, 02 Aug 2022 06:23:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35332) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIohH-0004tZ-ER for qemu-devel@nongnu.org; Tue, 02 Aug 2022 06:00:19 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:37648) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oIohF-0006DB-8K for qemu-devel@nongnu.org; Tue, 02 Aug 2022 06:00:19 -0400 Received: by mail-wr1-x435.google.com with SMTP id z17so12497650wrq.4 for ; Tue, 02 Aug 2022 03:00:16 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id a4-20020adffb84000000b0021e51c039c5sm14656208wrr.80.2022.08.02.03.00.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 03:00:14 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id AEF741FFC3; Tue, 2 Aug 2022 10:50:11 +0100 (BST) 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; bh=BeukRfDDjs+xL5noIXV/lsICwMCkD6JOsmbjcLzfdS8=; b=CUwEGBL5C/JqKOJP/LBMM278xBWStj22K4nHZJAPkribGRw5iqexJFwPZBAez6ibLv tNuauOhaPA2UjJQ6D1uvPaeLHajCB3Lgbfawg71HQK7VJAWY+9CMjY82mR0IbUE7vYS6 fOYcNr8VdOPJ3eQCQBBA01JYLuIiFyHN2/dw5cauOp9PnvR4prnLwoW2ASx0rZoF5Daf Hb/jvCbdN8YL+ioeD+/Xxy1pcIeyMbelgel1uePoQsxMpQj0IBDykKW6k2fB7ODlvTQQ EtG5wesmUXzLPr49JjyOsEYJf+tuBQKn5w6ykduLhArNfvOOt47S9o6U8/+vbfnZXdVR 2PaA== 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; bh=BeukRfDDjs+xL5noIXV/lsICwMCkD6JOsmbjcLzfdS8=; b=PUW75qpbWQVVdNUONw/dD0mEHtKz2+7QUWE2U5K7a+OjBg6lvoHaE0KApi5VmZfEvy IAJEqE2aoDEekJv3OqBrOT0Vrx6EbQ7REYZ18xYwRXE1L+5UERDeKQ9iC6W47K9u1Ug7 Fm44x9898lsgfjYxQE/CvyWNbJEDpHwA3C5LjTpBmdhupOZ4ite1CrDCxTqUqGEN/UBf lIfWqBmiYLGD+Rd6e+How6sZQ+O9kXJgY9xkji33frTdd/ah42beogfin/kb7RIHusIj bfDcRDGlMrexsSTKF87fSiitCuEPh89HancnYRTz/aWqCZJnrOks+XmyRTrIIprSm38t EEtw== X-Gm-Message-State: ACgBeo0XO8T9S5oJIsMv+BK83b/xLZAoiJyVw9tEHDhWoZShoT0szvQF uD4pg3/gH35qJPz9l9BLjU0J7A== X-Google-Smtp-Source: AA6agR44fKH6EUhIbL5qmGxJ2mI7kf0rVMdw6Q8m0ArqbP4W6WOJZtpFfZcfLdnjr4+9Ov38zWz6FQ== X-Received: by 2002:adf:e542:0:b0:21e:c148:3ef2 with SMTP id z2-20020adfe542000000b0021ec1483ef2mr12520966wrm.533.1659434415386; Tue, 02 Aug 2022 03:00:15 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Raphael Norwitz , Kevin Wolf , Hanna Reitz , Paolo Bonzini , Fam Zheng , "Dr. David Alan Gilbert" , qemu-block@nongnu.org (open list:Block layer core), virtio-fs@redhat.com (open list:virtiofs) Subject: [PATCH v4 11/22] hw/virtio: move vhd->started check into helper and add FIXME Date: Tue, 2 Aug 2022 10:49:59 +0100 Message-Id: <20220802095010.3330793-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220802095010.3330793-1-alex.bennee@linaro.org> References: <20220802095010.3330793-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::435; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x435.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1659435827325100001 The `started` field is manipulated internally within the vhost code except for one place, vhost-user-blk via f5b22d06fb (vhost: recheck dev state in the vhost_migration_log routine). Mark that as a FIXME because it introduces a potential race. I think the referenced fix should be tracking its state locally. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Raphael Norwitz --- include/hw/virtio/vhost.h | 12 ++++++++++++ hw/block/vhost-user-blk.c | 10 ++++++++-- hw/scsi/vhost-scsi.c | 4 ++-- hw/scsi/vhost-user-scsi.c | 2 +- hw/virtio/vhost-user-fs.c | 3 ++- 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-common.c | 3 ++- hw/virtio/vhost-vsock.c | 2 +- 10 files changed, 33 insertions(+), 13 deletions(-) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 586c5457e2..61b957e927 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -94,6 +94,7 @@ struct vhost_dev { uint64_t protocol_features; uint64_t max_queues; uint64_t backend_cap; + /* @started: is the vhost device started? */ bool started; bool log_enabled; uint64_t log_size; @@ -165,6 +166,17 @@ int vhost_dev_enable_notifiers(struct vhost_dev *hdev,= VirtIODevice *vdev); */ void vhost_dev_disable_notifiers(struct vhost_dev *hdev, VirtIODevice *vde= v); =20 +/** + * vhost_dev_is_started() - report status of vhost device + * @hdev: common vhost_dev structure + * + * Return the started status of the vhost device + */ +static inline bool vhost_dev_is_started(struct vhost_dev *hdev) +{ + return hdev->started; +} + /** * vhost_dev_start() - start the vhost device * @hdev: common vhost_dev structure diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 9117222456..2bba42478d 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -229,7 +229,7 @@ static void vhost_user_blk_set_status(VirtIODevice *vde= v, uint8_t status) return; } =20 - if (s->dev.started =3D=3D should_start) { + if (vhost_dev_is_started(&s->dev) =3D=3D should_start) { return; } =20 @@ -286,7 +286,7 @@ static void vhost_user_blk_handle_output(VirtIODevice *= vdev, VirtQueue *vq) return; } =20 - if (s->dev.started) { + if (vhost_dev_is_started(&s->dev)) { return; } =20 @@ -415,6 +415,12 @@ static void vhost_user_blk_event(void *opaque, QEMUChr= Event event) * the vhost migration code. If disconnect was caught there is= an * option for the general vhost code to get the dev state with= out * knowing its type (in this case vhost-user). + * + * FIXME: this is sketchy to be reaching into vhost_dev + * now because we are forcing something that implies we + * have executed vhost_dev_stop() but that won't happen + * until vhost_user_blk_stop() gets called from the bh. + * Really this state check should be tracked locally. */ s->dev.started =3D false; } diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 3059068175..bdf337a7a2 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -120,7 +120,7 @@ static void vhost_scsi_set_status(VirtIODevice *vdev, u= int8_t val) start =3D false; } =20 - if (vsc->dev.started =3D=3D start) { + if (vhost_dev_is_started(&vsc->dev) =3D=3D start) { return; } =20 @@ -147,7 +147,7 @@ static int vhost_scsi_pre_save(void *opaque) =20 /* At this point, backend must be stopped, otherwise * it might keep writing to memory. */ - assert(!vsc->dev.started); + assert(!vhost_dev_is_started(&vsc->dev)); =20 return 0; } diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c index 1b2f7eed98..bc37317d55 100644 --- a/hw/scsi/vhost-user-scsi.c +++ b/hw/scsi/vhost-user-scsi.c @@ -49,7 +49,7 @@ static void vhost_user_scsi_set_status(VirtIODevice *vdev= , uint8_t status) VHostSCSICommon *vsc =3D VHOST_SCSI_COMMON(s); bool start =3D (status & VIRTIO_CONFIG_S_DRIVER_OK) && vdev->vm_runnin= g; =20 - if (vsc->dev.started =3D=3D start) { + if (vhost_dev_is_started(&vsc->dev) =3D=3D start) { return; } =20 diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index d2bebba785..ad0f91c607 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -20,6 +20,7 @@ #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h" #include "qemu/error-report.h" +#include "hw/virtio/vhost.h" #include "hw/virtio/vhost-user-fs.h" #include "monitor/monitor.h" #include "sysemu/sysemu.h" @@ -124,7 +125,7 @@ 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); =20 - if (fs->vhost_dev.started =3D=3D should_start) { + if (vhost_dev_is_started(&fs->vhost_dev) =3D=3D should_start) { return; } =20 diff --git a/hw/virtio/vhost-user-i2c.c b/hw/virtio/vhost-user-i2c.c index b930cf6d5e..bc58b6c0d1 100644 --- a/hw/virtio/vhost-user-i2c.c +++ b/hw/virtio/vhost-user-i2c.c @@ -95,7 +95,7 @@ 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); =20 - if (i2c->vhost_dev.started =3D=3D should_start) { + if (vhost_dev_is_started(&i2c->vhost_dev) =3D=3D should_start) { return; } =20 @@ -174,7 +174,7 @@ static void vu_i2c_disconnect(DeviceState *dev) } i2c->connected =3D false; =20 - if (i2c->vhost_dev.started) { + if (vhost_dev_is_started(&i2c->vhost_dev)) { vu_i2c_stop(vdev); } } diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c index a9c1c4bc79..bc1f36c5ac 100644 --- a/hw/virtio/vhost-user-rng.c +++ b/hw/virtio/vhost-user-rng.c @@ -92,7 +92,7 @@ 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); =20 - if (rng->vhost_dev.started =3D=3D should_start) { + if (vhost_dev_is_started(&rng->vhost_dev) =3D=3D should_start) { return; } =20 @@ -160,7 +160,7 @@ static void vu_rng_disconnect(DeviceState *dev) =20 rng->connected =3D false; =20 - if (rng->vhost_dev.started) { + if (vhost_dev_is_started(&rng->vhost_dev)) { vu_rng_stop(vdev); } } diff --git a/hw/virtio/vhost-user-vsock.c b/hw/virtio/vhost-user-vsock.c index 22c1616ebd..7b67e29d83 100644 --- a/hw/virtio/vhost-user-vsock.c +++ b/hw/virtio/vhost-user-vsock.c @@ -57,7 +57,7 @@ static void vuv_set_status(VirtIODevice *vdev, uint8_t st= atus) VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(vdev); bool should_start =3D virtio_device_started(vdev, status); =20 - if (vvc->vhost_dev.started =3D=3D should_start) { + if (vhost_dev_is_started(&vvc->vhost_dev) =3D=3D should_start) { return; } =20 diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index 7394818e00..29b9ab4f72 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -14,6 +14,7 @@ #include "hw/virtio/virtio-access.h" #include "qemu/error-report.h" #include "hw/qdev-properties.h" +#include "hw/virtio/vhost.h" #include "hw/virtio/vhost-vsock.h" #include "qemu/iov.h" #include "monitor/monitor.h" @@ -199,7 +200,7 @@ int vhost_vsock_common_pre_save(void *opaque) * At this point, backend must be stopped, otherwise * it might keep writing to memory. */ - assert(!vvc->vhost_dev.started); + assert(!vhost_dev_is_started(&vvc->vhost_dev)); =20 return 0; } diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index 8031c164a5..7dc3c73931 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -73,7 +73,7 @@ static void vhost_vsock_set_status(VirtIODevice *vdev, ui= nt8_t status) bool should_start =3D virtio_device_started(vdev, status); int ret; =20 - if (vvc->vhost_dev.started =3D=3D should_start) { + if (vhost_dev_is_started(&vvc->vhost_dev) =3D=3D should_start) { return; } =20 --=20 2.30.2 From nobody Thu May 9 12:20:02 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1659435452; cv=none; d=zohomail.com; s=zohoarc; b=dLuvnXcRilrPBibEQQbWNFllwCnpeP64Jfw4uehfOY8z7PsB5bpIoUrcYmRedOsW2Z5r3/81wPscNw2pONhg9DmoGDa2+nhEiO1kXUNrK702E7QKiXh41Xb5E7nXoDk6FQrdj1seNII2idBdZrzcFN8BoJBpWY9p1/Hcgy37stY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659435452; 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=dNNg43NsMDARYpRmEIG3YLqVxwvpF0e5jz6j1xR6WgI=; b=lE83Dm9mRh/WT1NOgPIUm7aBscDvyzEcb9aSogtEOBd3JvCoCJzR291IPAVlUxkRLXiTfVdcFXQK4eEh0Z20ZxPE2kfbTPzsn+s3lHOsg+gtJdJpJrTGUXbLMP4kFtPf4UpfdlsCrGQr43rkBKLzINxb+IeA9uahQNbV4yssa/Y= 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 1659435452578760.7604627083504; Tue, 2 Aug 2022 03:17:32 -0700 (PDT) Received: from localhost ([::1]:39072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIoxv-0004rx-FA for importer@patchew.org; Tue, 02 Aug 2022 06:17:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35482) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIohR-0005F0-No for qemu-devel@nongnu.org; Tue, 02 Aug 2022 06:00:29 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:45690) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oIohP-0006R8-6I for qemu-devel@nongnu.org; Tue, 02 Aug 2022 06:00:29 -0400 Received: by mail-wr1-x429.google.com with SMTP id z16so17125687wrh.12 for ; Tue, 02 Aug 2022 03:00:26 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id h1-20020a5d5041000000b002206261cb6esm6647407wrt.66.2022.08.02.03.00.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 03:00:22 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id CB1741FFC4; Tue, 2 Aug 2022 10:50:11 +0100 (BST) 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; bh=dNNg43NsMDARYpRmEIG3YLqVxwvpF0e5jz6j1xR6WgI=; b=TTivSCfmuscyLLiuYV0+KiZtXR1uHGxnu7ayxsS96f2QwkItQV9gXCjgMPZI7qSoRl 9H3qs5h7VWOQ9aeo6ir65VCDnqApU4VzKw05RfZ98w2smM4DXwaRy2GxOhzD1QmRiWJq ThLfD6obs3cL5N86mnuYCmaUJ9029R0rGk2lHshAvEAjlRHnRniJwGIiiRztYB8NmPNU P/EowyXZvNvi/2yBjLQM2BNHaPFko+e3PlKPH6LbvXBYHWi6xsBjS/0ppx4mcOEb7e96 K59PGCVvVqE38AzrCyR3BdRmkd3PYoMAc1ua+QFtijlrKjMCs6jAIriMwlydKOi9UL94 aQpQ== 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; bh=dNNg43NsMDARYpRmEIG3YLqVxwvpF0e5jz6j1xR6WgI=; b=C69g/sWnLr0nB+h3ZIH2opudPUYCmXFdg1cWL2eUgpxJU7RDiBzwgRp9iMkr9EYTTf DiulgdryYEO9HKl7mLifyIOIG5K1CN9DKBmIL/GGlLHuFikF6YucrpJPNtZuVygp9DA5 2SD+0A67dZphdgi+5oaXcdvzdP8mQJ7HzCLa0APz6hCwbSxWZLvg/3to3wZO65BZf7mx Yy+5t5BIVduVLgmw7nBwI6NP0SjG/l1EsuDkYZ3Wu13tdL/jc2i9mEaho3WtAndx+mch 6I0l9lGY5ppOSt5w4/pg4wfqw92OdXNHKtSlWhwwE9Z4zuT/+7k1vHiBlGFc9fu/8kvd 0ncA== X-Gm-Message-State: ACgBeo21qYkiqRp0P9QNPHbKQpBDGq742ESnFYeJTN80XtEqhZzX89kf RLpklHV+uoayWvHrqYPVW1b6tQ== X-Google-Smtp-Source: AA6agR5bW1UtnIOJh5Uc6s6UmfHlpOQdmPbBCQ56ofHg+vQ7tTOJNhcaydaaJ+qE+MOoi4AeEfIjPQ== X-Received: by 2002:adf:ee05:0:b0:21e:c76a:c2a with SMTP id y5-20020adfee05000000b0021ec76a0c2amr12994643wrn.651.1659434425620; Tue, 02 Aug 2022 03:00:25 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Vincent Whitchurch Subject: [PATCH v4 12/22] hw/virtio: add boilerplate for vhost-user-gpio device Date: Tue, 2 Aug 2022 10:50:00 +0100 Message-Id: <20220802095010.3330793-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220802095010.3330793-1-alex.bennee@linaro.org> References: <20220802095010.3330793-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::429; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x429.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1659435454887100001 From: Viresh Kumar This creates the QEMU side of the vhost-user-gpio device which connects to the remote daemon. It is based of vhost-user-i2c code. Signed-off-by: Viresh Kumar Reviewed-by: Alex Benn=C3=A9e Message-Id: <5390324a748194a21bc99b1538e19761a8c64092.1641987128.git.viresh= .kumar@linaro.org> [AJB: fixes for qtest, tweaks to feature bits] Signed-off-by: Alex Benn=C3=A9e Cc: Vincent Whitchurch --- v2 - set VIRTIO_F_VERSION_1 - set VHOST_USER_F_PROTOCOL_FEATURES - terminate feature_bits with VHOST_INVALID_FEATURE_BIT - ensure vdev->backend_features set - ensure vhost_dev.acked_features set v3 - break out vhost_dev structure for code flow reasons - use the vhost-user-blk connection lifecycle code - follow ->parent_obj style for VHostUserGPIO object - add all feature bits supported by the rust-vmm backend - clean-up errp propagation to avoid local_err and use ERRP_GAURD - s/vhost_dev->features/vdev->guest_features/ when calling vhost_ack_feat= ures - drop VHOST_USER_F_PROTOCOL_FEATURES definition (pushed to vhost-user) - explicitly call vhost_set_vring_enable due to properly negotiated VHOST= _USER_F_PROTOCOL_FEATURES - use virtio_device_started() check instead of open code. - update MAINTAINERS --- include/hw/virtio/vhost-user-gpio.h | 35 +++ hw/virtio/vhost-user-gpio.c | 411 ++++++++++++++++++++++++++++ MAINTAINERS | 7 + hw/virtio/Kconfig | 5 + hw/virtio/meson.build | 1 + hw/virtio/trace-events | 5 + 6 files changed, 464 insertions(+) create mode 100644 include/hw/virtio/vhost-user-gpio.h create mode 100644 hw/virtio/vhost-user-gpio.c diff --git a/include/hw/virtio/vhost-user-gpio.h b/include/hw/virtio/vhost-= user-gpio.h new file mode 100644 index 0000000000..4fe9aeecc0 --- /dev/null +++ b/include/hw/virtio/vhost-user-gpio.h @@ -0,0 +1,35 @@ +/* + * Vhost-user GPIO virtio device + * + * Copyright (c) 2021 Viresh Kumar + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef _QEMU_VHOST_USER_GPIO_H +#define _QEMU_VHOST_USER_GPIO_H + +#include "hw/virtio/virtio.h" +#include "hw/virtio/vhost.h" +#include "hw/virtio/vhost-user.h" +#include "standard-headers/linux/virtio_gpio.h" +#include "chardev/char-fe.h" + +#define TYPE_VHOST_USER_GPIO "vhost-user-gpio-device" +OBJECT_DECLARE_SIMPLE_TYPE(VHostUserGPIO, VHOST_USER_GPIO); + +struct VHostUserGPIO { + /*< private >*/ + VirtIODevice parent_obj; + CharBackend chardev; + struct virtio_gpio_config config; + struct vhost_virtqueue *vhost_vq; + struct vhost_dev vhost_dev; + VhostUserState vhost_user; + VirtQueue *command_vq; + VirtQueue *interrupt_vq; + bool connected; + /*< public >*/ +}; + +#endif /* _QEMU_VHOST_USER_GPIO_H */ diff --git a/hw/virtio/vhost-user-gpio.c b/hw/virtio/vhost-user-gpio.c new file mode 100644 index 0000000000..8b40fe450c --- /dev/null +++ b/hw/virtio/vhost-user-gpio.c @@ -0,0 +1,411 @@ +/* + * Vhost-user GPIO virtio device + * + * Copyright (c) 2022 Viresh Kumar + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/qdev-properties.h" +#include "hw/virtio/virtio-bus.h" +#include "hw/virtio/vhost-user-gpio.h" +#include "qemu/error-report.h" +#include "standard-headers/linux/virtio_ids.h" +#include "trace.h" + +#define REALIZE_CONNECTION_RETRIES 3 + +/* Features required from VirtIO */ +static const int feature_bits[] =3D { + VIRTIO_F_VERSION_1, + VIRTIO_F_NOTIFY_ON_EMPTY, + VIRTIO_RING_F_INDIRECT_DESC, + VIRTIO_RING_F_EVENT_IDX, + VIRTIO_GPIO_F_IRQ, + VHOST_INVALID_FEATURE_BIT +}; + +static void vu_gpio_get_config(VirtIODevice *vdev, uint8_t *config) +{ + VHostUserGPIO *gpio =3D VHOST_USER_GPIO(vdev); + + memcpy(config, &gpio->config, sizeof(gpio->config)); +} + +static int vu_gpio_config_notifier(struct vhost_dev *dev) +{ + VHostUserGPIO *gpio =3D VHOST_USER_GPIO(dev->vdev); + + memcpy(dev->vdev->config, &gpio->config, sizeof(gpio->config)); + virtio_notify_config(dev->vdev); + + return 0; +} + +const VhostDevConfigOps gpio_ops =3D { + .vhost_dev_config_notifier =3D vu_gpio_config_notifier, +}; + +static int vu_gpio_start(VirtIODevice *vdev) +{ + BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); + VHostUserGPIO *gpio =3D VHOST_USER_GPIO(vdev); + struct vhost_dev *vhost_dev =3D &gpio->vhost_dev; + int ret, i; + + if (!k->set_guest_notifiers) { + error_report("binding does not support guest notifiers"); + return -ENOSYS; + } + + ret =3D vhost_dev_enable_notifiers(vhost_dev, vdev); + if (ret < 0) { + error_report("Error enabling host notifiers: %d", ret); + return ret; + } + + ret =3D k->set_guest_notifiers(qbus->parent, vhost_dev->nvqs, true); + if (ret < 0) { + error_report("Error binding guest notifier: %d", ret); + goto err_host_notifiers; + } + + /* + * Before we start up we need to ensure we have the final feature + * set needed for the vhost configuration. The backend may also + * apply backend_features when the feature set is sent. + */ + vhost_ack_features(&gpio->vhost_dev, feature_bits, vdev->guest_feature= s); + + ret =3D vhost_dev_start(&gpio->vhost_dev, vdev); + if (ret < 0) { + error_report("Error starting vhost-user-gpio: %d", ret); + goto err_guest_notifiers; + } + + /* + * guest_notifier_mask/pending not used yet, so just unmask + * everything here. virtio-pci will do the right thing by + * enabling/disabling irqfd. + */ + for (i =3D 0; i < gpio->vhost_dev.nvqs; i++) { + vhost_virtqueue_mask(&gpio->vhost_dev, vdev, i, false); + } + + /* + * As we must have VHOST_USER_F_PROTOCOL_FEATURES (because + * VHOST_USER_GET_CONFIG requires it) we need to explicitly enable + * the vrings. + */ + g_assert(vhost_dev->vhost_ops && + vhost_dev->vhost_ops->vhost_set_vring_enable); + ret =3D vhost_dev->vhost_ops->vhost_set_vring_enable(vhost_dev, true); + if (ret =3D=3D 0) { + return 0; + } + + error_report("Failed to start vrings for vhost-user-gpio: %d", ret); + +err_guest_notifiers: + k->set_guest_notifiers(qbus->parent, gpio->vhost_dev.nvqs, false); +err_host_notifiers: + vhost_dev_disable_notifiers(&gpio->vhost_dev, vdev); + + return ret; +} + +static void vu_gpio_stop(VirtIODevice *vdev) +{ + VHostUserGPIO *gpio =3D VHOST_USER_GPIO(vdev); + BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); + struct vhost_dev *vhost_dev =3D &gpio->vhost_dev; + int ret; + + if (!k->set_guest_notifiers) { + return; + } + + /* + * 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)) { + return; + } + + vhost_dev_stop(vhost_dev, vdev); + + ret =3D k->set_guest_notifiers(qbus->parent, vhost_dev->nvqs, false); + if (ret < 0) { + error_report("vhost guest notifier cleanup failed: %d", ret); + return; + } + + vhost_dev_disable_notifiers(vhost_dev, 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); + + trace_virtio_gpio_set_status(status); + + if (!gpio->connected) { + return; + } + + if (vhost_dev_is_started(&gpio->vhost_dev) =3D=3D should_start) { + return; + } + + if (should_start) { + if (vu_gpio_start(vdev)) { + qemu_chr_fe_disconnect(&gpio->chardev); + } + } else { + vu_gpio_stop(vdev); + } +} + +static uint64_t vu_gpio_get_features(VirtIODevice *vdev, uint64_t features, + Error **errp) +{ + VHostUserGPIO *gpio =3D VHOST_USER_GPIO(vdev); + + return vhost_get_features(&gpio->vhost_dev, feature_bits, features); +} + +static void vu_gpio_handle_output(VirtIODevice *vdev, VirtQueue *vq) +{ + /* + * Not normally called; it's the daemon that handles the queue; + * however virtio's cleanup path can call this. + */ +} + +static void vu_gpio_guest_notifier_mask(VirtIODevice *vdev, int idx, bool = mask) +{ + VHostUserGPIO *gpio =3D VHOST_USER_GPIO(vdev); + + vhost_virtqueue_mask(&gpio->vhost_dev, vdev, idx, mask); +} + +static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserGPIO *gpio) +{ + virtio_delete_queue(gpio->command_vq); + virtio_delete_queue(gpio->interrupt_vq); + g_free(gpio->vhost_dev.vqs); + gpio->vhost_dev.vqs =3D NULL; + virtio_cleanup(vdev); + vhost_user_cleanup(&gpio->vhost_user); +} + +static int vu_gpio_connect(DeviceState *dev, Error **errp) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserGPIO *gpio =3D VHOST_USER_GPIO(vdev); + struct vhost_dev *vhost_dev =3D &gpio->vhost_dev; + int ret; + + if (gpio->connected) { + return 0; + } + gpio->connected =3D true; + + vhost_dev_set_config_notifier(vhost_dev, &gpio_ops); + gpio->vhost_user.supports_config =3D true; + + ret =3D vhost_dev_init(vhost_dev, &gpio->vhost_user, + VHOST_BACKEND_TYPE_USER, 0, errp); + if (ret < 0) { + return ret; + } + + /* restore vhost state */ + if (virtio_device_started(vdev, vdev->status)) { + vu_gpio_start(vdev); + } + + return 0; +} + +static void vu_gpio_disconnect(DeviceState *dev) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserGPIO *gpio =3D VHOST_USER_GPIO(vdev); + + if (!gpio->connected) { + return; + } + gpio->connected =3D false; + + vu_gpio_stop(vdev); + vhost_dev_cleanup(&gpio->vhost_dev); +} + +static void vu_gpio_event(void *opaque, QEMUChrEvent event) +{ + DeviceState *dev =3D opaque; + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserGPIO *gpio =3D VHOST_USER_GPIO(vdev); + Error *local_err =3D NULL; + + switch (event) { + case CHR_EVENT_OPENED: + if (vu_gpio_connect(dev, &local_err) < 0) { + qemu_chr_fe_disconnect(&gpio->chardev); + return; + } + break; + case CHR_EVENT_CLOSED: + vu_gpio_disconnect(dev); + break; + case CHR_EVENT_BREAK: + case CHR_EVENT_MUX_IN: + case CHR_EVENT_MUX_OUT: + /* Ignore */ + break; + } +} + +static int vu_gpio_realize_connect(VHostUserGPIO *gpio, Error **errp) +{ + VirtIODevice *vdev =3D &gpio->parent_obj; + DeviceState *dev =3D &vdev->parent_obj; + struct vhost_dev *vhost_dev =3D &gpio->vhost_dev; + int ret; + + ret =3D qemu_chr_fe_wait_connected(&gpio->chardev, errp); + if (ret < 0) { + return ret; + } + + /* + * vu_gpio_connect() may have already connected (via the event + * callback) in which case it will just report success. + */ + ret =3D vu_gpio_connect(dev, errp); + if (ret < 0) { + qemu_chr_fe_disconnect(&gpio->chardev); + return ret; + } + g_assert(gpio->connected); + + ret =3D vhost_dev_get_config(vhost_dev, (uint8_t *)&gpio->config, + sizeof(gpio->config), errp); + + if (ret < 0) { + error_report("vhost-user-gpio: get config failed"); + + qemu_chr_fe_disconnect(&gpio->chardev); + vhost_dev_cleanup(vhost_dev); + return ret; + } + + return 0; +} + +static void vu_gpio_device_realize(DeviceState *dev, Error **errp) +{ + ERRP_GUARD(); + + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserGPIO *gpio =3D VHOST_USER_GPIO(dev); + int retries, ret; + + if (!gpio->chardev.chr) { + error_setg(errp, "vhost-user-gpio: chardev is mandatory"); + return; + } + + if (!vhost_user_init(&gpio->vhost_user, &gpio->chardev, errp)) { + return; + } + + virtio_init(vdev, VIRTIO_ID_GPIO, sizeof(gpio->config)); + + gpio->vhost_dev.nvqs =3D 2; + gpio->command_vq =3D virtio_add_queue(vdev, 256, vu_gpio_handle_output= ); + gpio->interrupt_vq =3D virtio_add_queue(vdev, 256, vu_gpio_handle_outp= ut); + gpio->vhost_dev.vqs =3D g_new0(struct vhost_virtqueue, gpio->vhost_dev= .nvqs); + + gpio->connected =3D false; + + qemu_chr_fe_set_handlers(&gpio->chardev, NULL, NULL, vu_gpio_event, NU= LL, + dev, NULL, true); + + retries =3D REALIZE_CONNECTION_RETRIES; + g_assert(!*errp); + do { + if (*errp) { + error_prepend(errp, "Reconnecting after error: "); + error_report_err(*errp); + *errp =3D NULL; + } + ret =3D vu_gpio_realize_connect(gpio, errp); + } while (ret < 0 && retries--); + + if (ret < 0) { + do_vhost_user_cleanup(vdev, gpio); + } + + return; +} + +static void vu_gpio_device_unrealize(DeviceState *dev) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserGPIO *gpio =3D VHOST_USER_GPIO(dev); + + vu_gpio_set_status(vdev, 0); + qemu_chr_fe_set_handlers(&gpio->chardev, NULL, NULL, NULL, NULL, NULL,= NULL, + false); + vhost_dev_cleanup(&gpio->vhost_dev); + do_vhost_user_cleanup(vdev, gpio); +} + +static const VMStateDescription vu_gpio_vmstate =3D { + .name =3D "vhost-user-gpio", + .unmigratable =3D 1, +}; + +static Property vu_gpio_properties[] =3D { + DEFINE_PROP_CHR("chardev", VHostUserGPIO, chardev), + DEFINE_PROP_END_OF_LIST(), +}; + +static void vu_gpio_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_CLASS(klass); + + device_class_set_props(dc, vu_gpio_properties); + dc->vmsd =3D &vu_gpio_vmstate; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); + vdc->realize =3D vu_gpio_device_realize; + vdc->unrealize =3D vu_gpio_device_unrealize; + vdc->get_features =3D vu_gpio_get_features; + vdc->get_config =3D vu_gpio_get_config; + vdc->set_status =3D vu_gpio_set_status; + vdc->guest_notifier_mask =3D vu_gpio_guest_notifier_mask; +} + +static const TypeInfo vu_gpio_info =3D { + .name =3D TYPE_VHOST_USER_GPIO, + .parent =3D TYPE_VIRTIO_DEVICE, + .instance_size =3D sizeof(VHostUserGPIO), + .class_init =3D vu_gpio_class_init, +}; + +static void vu_gpio_register_types(void) +{ + type_register_static(&vu_gpio_info); +} + +type_init(vu_gpio_register_types) diff --git a/MAINTAINERS b/MAINTAINERS index 5ce4227ff6..2c4749a110 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2098,6 +2098,13 @@ F: hw/virtio/vhost-user-rng-pci.c F: include/hw/virtio/vhost-user-rng.h F: tools/vhost-user-rng/* =20 +vhost-user-gpio +M: Alex Benn=C3=A9e +R: Viresh Kumar +S: Maintained +F: hw/virtio/vhost-user-gpio.c +F: include/hw/virtio/vhost-user-gpio.h + virtio-crypto M: Gonglei S: Supported diff --git a/hw/virtio/Kconfig b/hw/virtio/Kconfig index e9ecae1f50..cbfd8c7173 100644 --- a/hw/virtio/Kconfig +++ b/hw/virtio/Kconfig @@ -80,3 +80,8 @@ config VHOST_USER_FS bool default y depends on VIRTIO && VHOST_USER + +config VHOST_USER_GPIO + bool + default y + depends on VIRTIO && VHOST_USER diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index 7e8877fd64..33c8e71fab 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -29,6 +29,7 @@ virtio_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files= ('virtio-iommu.c')) virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2= c.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rn= g.c')) +virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-user-g= pio.c')) =20 virtio_pci_ss =3D ss.source_set() virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-= pci.c')) diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 887ca7afa8..820dadc26c 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -144,3 +144,8 @@ virtio_mem_state_response(uint16_t state) "state=3D%" P= RIu16 virtio_pmem_flush_request(void) "flush request" virtio_pmem_response(void) "flush response" virtio_pmem_flush_done(int type) "fsync return=3D%d" + +# virtio-gpio.c +virtio_gpio_start(void) "start" +virtio_gpio_stop(void) "stop" +virtio_gpio_set_status(uint8_t status) "0x%x" --=20 2.30.2 From nobody Thu May 9 12:20:02 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1659435273; cv=none; d=zohomail.com; s=zohoarc; b=bQp9dj/N0Vr0BOEjZTdYCBtZeGbGX2r6t975ssvIXl3gPTrT5gT96nyIIoG5JyZDNKP55Z92rv4KJb0bLrmgyiwv4tNQNzzcSrByM6PTsPAneyupUJzREj82PoJczktj5LipaZnOBZNOeanWSHKQlfPFTG2C+GlkaFxrKEYlGPo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659435273; 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=UmxR2E4mbxJZdFKpR2RK7UtJOZ7yVasaorcYyzhlbQs=; b=ZTxuNKkx3/32X4SGzMus8CE7wz8PC80msgwrhQyVOHJ2OunCknFkB2PtUvXZT/Gbv75eA+nIHuMa3+1+FQzMyMcQJDfdsvhCO8d174hCyVfKaPfG3P/lj0KhLNgwKkmY1RWSLnSo9je4ankPI16UoyUXqbQD4Nt0Onmd0+n2uK4= 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 1659435273407557.0108227594735; Tue, 2 Aug 2022 03:14:33 -0700 (PDT) Received: from localhost ([::1]:33948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIov2-0001On-CO for importer@patchew.org; Tue, 02 Aug 2022 06:14:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIoXr-0001X7-FU for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:35 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:35554) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oIoXp-0002WD-Mf for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:35 -0400 Received: by mail-wm1-x335.google.com with SMTP id v131-20020a1cac89000000b003a4bb3f786bso2898128wme.0 for ; Tue, 02 Aug 2022 02:50:32 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id d14-20020adfef8e000000b0021d6dad334bsm14645190wro.4.2022.08.02.02.50.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 02:50:22 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E6B1B1FFC5; Tue, 2 Aug 2022 10:50:11 +0100 (BST) 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; bh=UmxR2E4mbxJZdFKpR2RK7UtJOZ7yVasaorcYyzhlbQs=; b=uGRZuCp+Zbp3xdIldAdE5QKkEql/6hR8zK2yfY/RMh3PejTP1GNesyFfYlaElvRR/t 52R4JI8rAdsBQqyjQeF2FhlcNCFkKtVXTqfoj9GXJ7CLoOiNREBvN/GjEhoEbObINRMJ pdhWOrLDHJtDZjKyrin74pdelsRH/aGHktLYkdcy+1qRXJt8Uje5mOuPpG//ZbI6Or2Q YDs1LnT06HdOde6zK8uU8/itOJZ0WokgHXzI1zBb9QDRARmsOiGOC9OwKCl4LAxjFd9Z sbYcM+tdwPIForc1YduWWhCGrXOMs0pYmNw03MCQv8dk2wk+W5lgrOAxA8ZFIpn2Jm89 6AFg== 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; bh=UmxR2E4mbxJZdFKpR2RK7UtJOZ7yVasaorcYyzhlbQs=; b=w5Xc88Ki3cUYMP5rTqRPKQZevD6tnkai4u74Lf42J/QctWLmvwORED1BhxVypKSsYc r2zjsy/sliDoZxRSePmF8i0R9gAJYvUxNshJsISIIJCHZcdAL64VHUbMZu4k1lo+YwRq 35Hd44l9oQeTVCXpcoX+fFpQdbSu+1td1nOE8BB0Wbs1bXBc4tWFXMEJEk8dndABZd9t rBOyuVzdpekJ+X2SyzV2Ah2/PXmSFzuyMqGcU/eL3Syea01ZS2JulQgwbX/QbJrjPfg4 hNN0jD2VFJ9nXC0bQjDYWunWbsVoxH4djmLP1ktEExroFK0ktOYbp8GHaeixrg2lSuyJ lWow== X-Gm-Message-State: AJIora9CtCqNZVmNQS2S8+Af+8S9Hhqs5yC15jKwRkIMQlDtWi8yGZ03 dKyev0EMyXLk7U8t4cMbPHQkjfImKK9txQ== X-Google-Smtp-Source: AGRyM1s9O4w1XAf4zhRrc/9jrGOHS8bKdGK0LKqGaxLHD9oMugZOIaXS8cU1/awjyagDCIcjCefPLA== X-Received: by 2002:a1c:7915:0:b0:3a3:11a3:7452 with SMTP id l21-20020a1c7915000000b003a311a37452mr13421975wme.27.1659433831298; Tue, 02 Aug 2022 02:50:31 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH v4 13/22] hw/virtio: add vhost-user-gpio-pci boilerplate Date: Tue, 2 Aug 2022 10:50:01 +0100 Message-Id: <20220802095010.3330793-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220802095010.3330793-1-alex.bennee@linaro.org> References: <20220802095010.3330793-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::335; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x335.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1659435274994100001 From: Viresh Kumar This allows is to instantiate a vhost-user-gpio device as part of a PCI bus. It is mostly boilerplate which looks pretty similar to the vhost-user-fs-pci device. Signed-off-by: Viresh Kumar Reviewed-by: Alex Benn=C3=A9e Message-Id: <5f560cab92d0d789b1c94295ec74b9952907d69d.1641987128.git.viresh= .kumar@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- v4 - tweak MAINTAINER --- hw/virtio/vhost-user-gpio-pci.c | 69 +++++++++++++++++++++++++++++++++ MAINTAINERS | 2 +- hw/virtio/meson.build | 1 + 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 hw/virtio/vhost-user-gpio-pci.c diff --git a/hw/virtio/vhost-user-gpio-pci.c b/hw/virtio/vhost-user-gpio-pc= i.c new file mode 100644 index 0000000000..b3028a24a1 --- /dev/null +++ b/hw/virtio/vhost-user-gpio-pci.c @@ -0,0 +1,69 @@ +/* + * Vhost-user gpio virtio device PCI glue + * + * Copyright (c) 2022 Viresh Kumar + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "hw/qdev-properties.h" +#include "hw/virtio/vhost-user-gpio.h" +#include "hw/virtio/virtio-pci.h" + +struct VHostUserGPIOPCI { + VirtIOPCIProxy parent_obj; + VHostUserGPIO vdev; +}; + +typedef struct VHostUserGPIOPCI VHostUserGPIOPCI; + +#define TYPE_VHOST_USER_GPIO_PCI "vhost-user-gpio-pci-base" + +DECLARE_INSTANCE_CHECKER(VHostUserGPIOPCI, VHOST_USER_GPIO_PCI, + TYPE_VHOST_USER_GPIO_PCI) + +static void vhost_user_gpio_pci_realize(VirtIOPCIProxy *vpci_dev, Error **= errp) +{ + VHostUserGPIOPCI *dev =3D VHOST_USER_GPIO_PCI(vpci_dev); + DeviceState *vdev =3D DEVICE(&dev->vdev); + + vpci_dev->nvectors =3D 1; + qdev_realize(vdev, BUS(&vpci_dev->bus), errp); +} + +static void vhost_user_gpio_pci_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + VirtioPCIClass *k =3D VIRTIO_PCI_CLASS(klass); + PCIDeviceClass *pcidev_k =3D PCI_DEVICE_CLASS(klass); + k->realize =3D vhost_user_gpio_pci_realize; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); + pcidev_k->vendor_id =3D PCI_VENDOR_ID_REDHAT_QUMRANET; + pcidev_k->device_id =3D 0; /* Set by virtio-pci based on virtio id */ + pcidev_k->revision =3D 0x00; + pcidev_k->class_id =3D PCI_CLASS_COMMUNICATION_OTHER; +} + +static void vhost_user_gpio_pci_instance_init(Object *obj) +{ + VHostUserGPIOPCI *dev =3D VHOST_USER_GPIO_PCI(obj); + + virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), + TYPE_VHOST_USER_GPIO); +} + +static const VirtioPCIDeviceTypeInfo vhost_user_gpio_pci_info =3D { + .base_name =3D TYPE_VHOST_USER_GPIO_PCI, + .non_transitional_name =3D "vhost-user-gpio-pci", + .instance_size =3D sizeof(VHostUserGPIOPCI), + .instance_init =3D vhost_user_gpio_pci_instance_init, + .class_init =3D vhost_user_gpio_pci_class_init, +}; + +static void vhost_user_gpio_pci_register(void) +{ + virtio_pci_types_register(&vhost_user_gpio_pci_info); +} + +type_init(vhost_user_gpio_pci_register); diff --git a/MAINTAINERS b/MAINTAINERS index 2c4749a110..bb526df674 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2102,7 +2102,7 @@ vhost-user-gpio M: Alex Benn=C3=A9e R: Viresh Kumar S: Maintained -F: hw/virtio/vhost-user-gpio.c +F: hw/virtio/vhost-user-gpio* F: include/hw/virtio/vhost-user-gpio.h =20 virtio-crypto diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index 33c8e71fab..c14e3db10a 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -30,6 +30,7 @@ virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('= virtio-mem.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2= c.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rn= g.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-user-g= pio.c')) +virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_GPIO'], if_tr= ue: files('vhost-user-gpio-pci.c')) =20 virtio_pci_ss =3D ss.source_set() virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-= pci.c')) --=20 2.30.2 From nobody Thu May 9 12:20:02 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1659434685; cv=none; d=zohomail.com; s=zohoarc; b=A35Dk9GcJVkWJ10Tov/fvZYEm/gaITSxH10qq14gVKJ4+UPk8buuSkkE5zyJxHFnREtbaEBlakEQcClbHq09vOOyttiLLnRynZviDtITzyEGVNXoCN+GaIowX9RfsQHHV8punddJLKJsQK60claHrhOziT/dShvbUOfq+Lw5r88= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659434685; 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=z6HPjsVGZtO92xLq+sdxQwAMWt569NUcAMZ4ONfdk+E=; b=I+A308jTIrH5yVYpPobJMXRrj74Wg9fRrmBMQ1ETvlHqgQPT/RdJZLbagRsvG4xu/oan1EUdrPVf+9mw9IoMtrvh4/3hi+zUVyQpjeeE1Ej7EImvRlRQraiapLRCRo7staxIJ49AUHUCH9lk6GxmEJXmCYeV8BpX6d4x2O/ymjU= 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 1659434685165612.8584073790274; Tue, 2 Aug 2022 03:04:45 -0700 (PDT) Received: from localhost ([::1]:47672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIolV-0008Fj-7t for importer@patchew.org; Tue, 02 Aug 2022 06:04:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33586) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIoXs-0001ZX-2A for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:36 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:34753) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oIoXq-0002WK-Hd for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:35 -0400 Received: by mail-wr1-x42a.google.com with SMTP id j1so8785220wrw.1 for ; Tue, 02 Aug 2022 02:50:34 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id i5-20020adff305000000b002206203ed3dsm6805777wro.29.2022.08.02.02.50.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 02:50:22 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id F2B681FFC6; Tue, 2 Aug 2022 10:50:11 +0100 (BST) 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; bh=z6HPjsVGZtO92xLq+sdxQwAMWt569NUcAMZ4ONfdk+E=; b=ORaO7+qhdJM/C9XoyX3QrS23RSo91AzkIybJbXO+6wnkzVdIDCtIuHNRaeeRlUKuC1 5baYida1gS4I3LM7EEI6l5zhub6RiinR4gGS0sHTkKsSgt2snVK1hnj59tXqygy4smGW YGDyZuqitXFG5W0TtnUixUAeGMtY6/uCyeu9zAafnLVgaD4pDlH3WrqDk9kgqJI/1QLU 2TCdK58kIXPvSyRV39vkfe3yPUQw2X76JvI62C2AVGXvri/j6ZGngyPXSno/ugLYcuSG 4txBXZfBZPp0LMlBqKTR5qaOXZh5nf9ymyIh6hTjJ0XG6HBVTbwea4C9vueSJH2U4rG2 Yy3w== 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; bh=z6HPjsVGZtO92xLq+sdxQwAMWt569NUcAMZ4ONfdk+E=; b=cs+TIXbbXdar+mEHTVMNWBRO15Jx+HvV58T9qLyRuTjWoLZJp0Ooxp5hUUO/e/a5jU 8oOoCfkfOzE7IbgjiHH7zs7Y1eFPqeepe6LRauXSH9NJN5cYPZsRFB//kRBUogN256H1 K74O6dplkaSLPR8ZD5EMI0od2WQLipcQQ7AsmIWlZ+VnANivus4xRcJL1uDBNadGGC2i 6q2PunCf1xow8N4GQZunV6/qAb4Unnl9gAfIX6QPz0tAx1WPO38TTXGWuYrDMIY/nCjS J30URRCL4uiiEDrirC/IF4QXte8xAzBpTmdGb6dVJxQ0I1un8rQjqD2tkuwd2YXJ3D0M gRSQ== X-Gm-Message-State: ACgBeo2b1UuoOteObJqS4pz+ddsTKO1BtWVCxv03gLN9iO704YAXwtDH 1CpRus+7CyXqBXIL3QkV0gN0xQ== X-Google-Smtp-Source: AA6agR59TSY+YT8CR+tmLQmdrj/BJ+r5qqaACsJ61ly/CS57LspK4/Lr2cX3DtNN0FCLBLOxujTkJA== X-Received: by 2002:a5d:684e:0:b0:220:63df:3760 with SMTP id o14-20020a5d684e000000b0022063df3760mr4593291wrw.508.1659433833224; Tue, 02 Aug 2022 02:50:33 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 14/22] tests/qtest: pass stdout/stderr down to subtests Date: Tue, 2 Aug 2022 10:50:02 +0100 Message-Id: <20220802095010.3330793-15-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220802095010.3330793-1-alex.bennee@linaro.org> References: <20220802095010.3330793-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::42a; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42a.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1659434685898100001 When trying to work out what the virtio-net-tests where doing it was hard because the g_test_trap_subprocess redirects all output to /dev/null. Lift this restriction by using the appropriate flags so you can see something similar to what the vhost-user-blk tests show when running. Signed-off-by: Alex Benn=C3=A9e Acked-by: Thomas Huth Message-Id: <20220407150042.2338562-1-alex.bennee@linaro.org> --- v2 - keep dumping of CLI behind the g_test_verbose flag v4 - fix overly long line --- tests/qtest/qos-test.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/qtest/qos-test.c b/tests/qtest/qos-test.c index f97d0a08fd..01a9393399 100644 --- a/tests/qtest/qos-test.c +++ b/tests/qtest/qos-test.c @@ -185,7 +185,9 @@ static void run_one_test(const void *arg) static void subprocess_run_one_test(const void *arg) { const gchar *path =3D arg; - g_test_trap_subprocess(path, 0, 0); + g_test_trap_subprocess(path, 0, + G_TEST_SUBPROCESS_INHERIT_STDOUT | + G_TEST_SUBPROCESS_INHERIT_STDERR); g_test_trap_assert_passed(); } =20 --=20 2.30.2 From nobody Thu May 9 12:20:02 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1659436314; cv=none; d=zohomail.com; s=zohoarc; b=V/hYBG5Vs9kgjOYlh30Qk426TMHYZwVVCru+A2++oS8NoieZwQxj79+Yod9GFnA5eK+8rKSHKRyRvMYm1/VtIGes7ehS+0AItI4Kr00zoidkQTUi1+vUTmLWw7Fkk2hrABIvkFqDPtQXxu9tTHFO04AZmxt8/IDFHXbNIXbo1MI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659436314; 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=c6gCqIJw8yCV7CUCpwJSaqkLGHMke2sDpgsD4kivFT0=; b=TZrX8oDugxJo98/W/nuZujZsoO8MMmFQj+kMr2yo4Eep/40BpxaDgOKwHIy/PkFQVKtz6QEiAGlgPSCKvJN4QOCwXMYua81v+lxpupuzM8+pG8OvtzoeKVHmzMUp2n51V07sKksKq7jww5yUMGXthAGBlRfdhwWnFUJwnuHoFrw= 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 16594363142061003.0489656464193; Tue, 2 Aug 2022 03:31:54 -0700 (PDT) Received: from localhost ([::1]:33132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIpBp-0002Jv-3G for importer@patchew.org; Tue, 02 Aug 2022 06:31:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35440) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIohN-00055Y-D4 for qemu-devel@nongnu.org; Tue, 02 Aug 2022 06:00:25 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:38773) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oIohI-0006Oa-Iw for qemu-devel@nongnu.org; Tue, 02 Aug 2022 06:00:25 -0400 Received: by mail-wr1-x434.google.com with SMTP id bv3so3283905wrb.5 for ; Tue, 02 Aug 2022 03:00:20 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id k18-20020a5d6292000000b0021ec32d130asm14765519wru.74.2022.08.02.03.00.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 03:00:14 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 143F91FFC7; Tue, 2 Aug 2022 10:50:12 +0100 (BST) 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; bh=c6gCqIJw8yCV7CUCpwJSaqkLGHMke2sDpgsD4kivFT0=; b=z6InKbnXMEFjzUDcE1l2HPIZfCAminWu0mPvyhTzaP+hTtpI4yJiBGyXfyRIGcEZcC 9IVlu3nXdNK9OlLdqpcPSqup7dxDAHtiXd5T9giGZA49a2Nqs6cxodsv/fP5/gly2BW5 +Q+5aUbvpyA21aHHyDPBSW9+HCSToixsRbNxNmUtmchz/mkEjCN4maTyQvDb4L4ZJB1/ cyU8VyrImvciokmcdWwq85HMDPy+WwQtwkTxqSXMQrdJ606SxcSpcTfDMy0GOLB2QGRS G3s20jd7gYjLwaAR8AYL8khzLzuLavEDY+kAjsxWd32stOc7GTvigwd3bX67JWpDHbdK 8Umw== 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; bh=c6gCqIJw8yCV7CUCpwJSaqkLGHMke2sDpgsD4kivFT0=; b=n0DgQ7HZaJMJQks2t+64k/z8tCUZiDH4opUmQdVb0J3WbILzx1C0Gh/Fe18FYBBaeU mpJTjjl8qLgf8L45wpMrx0Ut/N5PgJVqIiDnTXMlm8oG+UdXfLbVpFR78ZK52uzTXnWc 0LFl+jI0m2rnxkM2r9tcntuc1EMd+aM5HDKvJh7ZL0AxHL2X9w1gMmnUWLukN6qW2fXy Qnw4m+tCoLX/YwQGUXeUud/FpU+WateacUo642fm/6jfKFzHJ+mGcPfxu1hv07rcuNcr 0f0mN4pDiP5s0GOau8hh/hO9uuZJobjU0UxdjpefqNb2S82+KmuUw/ivkHUe9n/nUdrn dXWQ== X-Gm-Message-State: ACgBeo0b8U5NYpIwQia5q0eJ/dvs5F9Xjp0AfXONTi9f6SePMRjPuB7R gBJ+MBOUYkBmBtfZBZGFWVrqug== X-Google-Smtp-Source: AA6agR4MnUMGJlqpj5YowPI4nBvMfeu56k66slxoAjGVVJATj1uhl4k68tqfv1riBZpMVP0BA4S4AA== X-Received: by 2002:a05:6000:178d:b0:21d:a453:b7c6 with SMTP id e13-20020a056000178d00b0021da453b7c6mr13635813wrg.275.1659434419258; Tue, 02 Aug 2022 03:00:19 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 15/22] tests/qtest: add a timeout for subprocess_run_one_test Date: Tue, 2 Aug 2022 10:50:03 +0100 Message-Id: <20220802095010.3330793-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220802095010.3330793-1-alex.bennee@linaro.org> References: <20220802095010.3330793-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::434; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x434.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1659436314848100001 Hangs have been observed in the tests and currently we don't timeout if a subprocess hangs. Rectify that. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- v3 - expand timeout to 180 at Thomas' suggestion v4 - fix merge conflict with earlier patch --- tests/qtest/qos-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qtest/qos-test.c b/tests/qtest/qos-test.c index 01a9393399..d958ef4be3 100644 --- a/tests/qtest/qos-test.c +++ b/tests/qtest/qos-test.c @@ -185,7 +185,7 @@ static void run_one_test(const void *arg) static void subprocess_run_one_test(const void *arg) { const gchar *path =3D arg; - g_test_trap_subprocess(path, 0, + g_test_trap_subprocess(path, 180 * G_USEC_PER_SEC, G_TEST_SUBPROCESS_INHERIT_STDOUT | G_TEST_SUBPROCESS_INHERIT_STDERR); g_test_trap_assert_passed(); --=20 2.30.2 From nobody Thu May 9 12:20:02 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1659435607; cv=none; d=zohomail.com; s=zohoarc; b=Gm99WWX0d9BI+FyD8WkzQzx8X5EQBR2NpwBuq9ErtaWea0JE1J4L0ex2kIWu3eS12+aFU3walJ/HHNOrFrHd6eXckI19OaRSkHoMmoJ5nGp7jminXZ1KpNisky/ighJcMig1992+zqIx52pUhtttBp7XiRUsgFZLJucACDWKm40= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659435607; 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=OHhq73fm8+f50i3SsK6KIm2w+P/uTjdSWyXaYAVfPmw=; b=QhSti+TzGCYxCPNpOts/GkepHUfBTjV80YOe/a8nyCaa2lDhW/ZLVo3p7BPtwppiVElJDAXVEjZd/v+5M9YeUodWg9+4R3wATkAn9d8I0h6/cmSRvHIMEEkWRaDFThfuWd/1kAlyxpQN2GzEcNrvVXs7PLEbSOlN+BgTbUoXGnU= 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 165943560716128.617249261357642; Tue, 2 Aug 2022 03:20:07 -0700 (PDT) Received: from localhost ([::1]:42238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIp0L-00071Y-D1 for importer@patchew.org; Tue, 02 Aug 2022 06:20:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33598) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIoXt-0001dk-7H for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:37 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:41942) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oIoXr-0002WT-HC for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:36 -0400 Received: by mail-wr1-x429.google.com with SMTP id p10so12959300wru.8 for ; Tue, 02 Aug 2022 02:50:35 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id q17-20020a05600c2e5100b003a3186fa559sm17081020wmf.29.2022.08.02.02.50.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 02:50:22 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 225CB1FFC8; Tue, 2 Aug 2022 10:50:12 +0100 (BST) 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; bh=OHhq73fm8+f50i3SsK6KIm2w+P/uTjdSWyXaYAVfPmw=; b=d2PFGlNHyilP1qGhXUsSePE+kWq8KxNU9JRna/aRj95f5cBn7o/vWAxD9pWkIhl+gt b/mBbx4oVfTS0I5g0Xhv2VGBd9Af3/EBB0kPwSKnFhqsYof+x8GADDNQwtkvfRO+lRJx lVNNBiZbTwuqyNCuVmf/bsJI1WmzOaiW0bmYUjoFXU6k51JJboQbzb94SvSir05y9ce9 fdjwoK8I1uj2XQSWpYriY49Le3/LZ4DpXL56e71YusR+K9sGB7LOS4sG8zyn+tLnn8QL 2kjfjEbILCag/1yFxLZZEJskaxD/RhsSvYGL3Ab6jTHtNF7wCAU70NI+vCJyrugSRPNd ITWQ== 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; bh=OHhq73fm8+f50i3SsK6KIm2w+P/uTjdSWyXaYAVfPmw=; b=SdfzbcBH4UWK0NcMemKnkEN2g+MIcTaucQ/Vfbwrb1Si6vBCuTLuI0Lt4S+qkbQNt0 I9AAe959Q69VDih3znGOzXImhr9f0zAKJ0xeC03HIGKRU6h3nwcAH1xXPIgAg6pl+YFQ DXA92OQjiJw61GKvu8KIzbJr5ZfxVSsZWZvTHpqJHb2gAWjM4egGO7vFZwY/ZsCvAiAW H+kVKBOGfSmZGiUKgOfbdPPr+AsM9XKf0UVXcakY+pRynjGKL6aWDgyJsMnECwYv3Ig4 QuDXhVTrTyUHrOsfcsCQHL0NKs/EDHWPUHNA8OBMf3u1wljlRPMUX2WMdKMVmql2ll0i P4hQ== X-Gm-Message-State: ACgBeo1pF/omufxgrCjJWmDni6NVCAyulGCFcJM0i7j/GlU4D7iY46ly 7F2/vHkwNkzaR27I/cnKrHEzMw== X-Google-Smtp-Source: AA6agR7zYn7z2qUh4757aPAoIbaVe8OpTnO49J/BLd8uP/ylrTLql2lRr9tv819CudKgHDCjjJTS0g== X-Received: by 2002:a5d:64a3:0:b0:21d:ad9e:afd7 with SMTP id m3-20020a5d64a3000000b0021dad9eafd7mr12280767wrp.524.1659433834170; Tue, 02 Aug 2022 02:50:34 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 16/22] tests/qtest: use qos_printf instead of g_test_message Date: Tue, 2 Aug 2022 10:50:04 +0100 Message-Id: <20220802095010.3330793-17-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220802095010.3330793-1-alex.bennee@linaro.org> References: <20220802095010.3330793-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::429; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x429.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1659435607486100001 The vhost-user tests respawn qos-test as a standalone process. As a result the gtester framework squashes all messages coming out of it which make it hard to debug. As the test does not care about asserting certain messages just convert the tests to use the direct qos_printf. Signed-off-by: Alex Benn=C3=A9e --- tests/qtest/qos-test.c | 5 +++++ tests/qtest/vhost-user-test.c | 13 +++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/qtest/qos-test.c b/tests/qtest/qos-test.c index d958ef4be3..b30bbb30f7 100644 --- a/tests/qtest/qos-test.c +++ b/tests/qtest/qos-test.c @@ -321,6 +321,11 @@ static void walk_path(QOSGraphNode *orig_path, int len) int main(int argc, char **argv, char** envp) { g_test_init(&argc, &argv, NULL); + + if (g_test_subprocess()) { + qos_printf("qos_test running single test in subprocess\n"); + } + if (g_test_verbose()) { qos_printf("ENVIRONMENT VARIABLES: {\n"); for (char **env =3D envp; *env !=3D 0; env++) { diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index 8bf390be20..968113d591 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -26,6 +26,7 @@ #include "libqos/virtio-pci.h" =20 #include "libqos/malloc-pc.h" +#include "libqos/qgraph_internal.h" #include "hw/virtio/virtio-net.h" =20 #include "standard-headers/linux/vhost_types.h" @@ -316,7 +317,7 @@ static void chr_read(void *opaque, const uint8_t *buf, = int size) } =20 if (size !=3D VHOST_USER_HDR_SIZE) { - g_test_message("Wrong message size received %d", size); + qos_printf("%s: Wrong message size received %d\n", __func__, size); return; } =20 @@ -327,8 +328,8 @@ static void chr_read(void *opaque, const uint8_t *buf, = int size) p +=3D VHOST_USER_HDR_SIZE; size =3D qemu_chr_fe_read_all(chr, p, msg.size); if (size !=3D msg.size) { - g_test_message("Wrong message size received %d !=3D %d", - size, msg.size); + qos_printf("%s: Wrong message size received %d !=3D %d\n", + __func__, size, msg.size); return; } } @@ -450,7 +451,7 @@ static const char *init_hugepagefs(void) } =20 if (access(path, R_OK | W_OK | X_OK)) { - g_test_message("access on path (%s): %s", path, strerror(errno)); + qos_printf("access on path (%s): %s", path, strerror(errno)); g_test_fail(); return NULL; } @@ -460,13 +461,13 @@ static const char *init_hugepagefs(void) } while (ret !=3D 0 && errno =3D=3D EINTR); =20 if (ret !=3D 0) { - g_test_message("statfs on path (%s): %s", path, strerror(errno)); + qos_printf("statfs on path (%s): %s", path, strerror(errno)); g_test_fail(); return NULL; } =20 if (fs.f_type !=3D HUGETLBFS_MAGIC) { - g_test_message("Warning: path not on HugeTLBFS: %s", path); + qos_printf("Warning: path not on HugeTLBFS: %s", path); g_test_fail(); return NULL; } --=20 2.30.2 From nobody Thu May 9 12:20:02 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1659435003; cv=none; d=zohomail.com; s=zohoarc; b=iMbZ6QgAZXZC5bw4f1UgutA1cE3GwfSi0HmCkmTb+GbW4VDLwVx4qOi7wKmh08KHmAfSX50sR3Z0JSromVifI4yVM5bkjnsdr+Qwd/wHDC7ikIou8Go9t2iHqPMNKak1BF0ksrISz27PNbU9OeRRgT6V8mdZwvadaKGq64ny4Fk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659435003; 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=Go4zP69KIEX2yBSg0W79f2jSqF47viC9E/7rhCMdQ80=; b=f43C6mM7eymGzfdiRO20rh/M/0GNs2p1B10ixMl5QTZhPBCgmJaOJutdOkyPh5vKCvggZK0zBZ1H6fw5dlYsYqfxtQd/ciBmSMC+7l52b2of+dw6dfk/kHSGKPWWx4jVNl30/VGQYbmPzB0zHzjW5nBi2xpHL74gt9WF8dxnxG8= 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 1659435003463621.7027751924683; Tue, 2 Aug 2022 03:10:03 -0700 (PDT) Received: from localhost ([::1]:54124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIoqf-0004N3-Ah for importer@patchew.org; Tue, 02 Aug 2022 06:10:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33480) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIoXj-0001KP-Ne for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:28 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:39737) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oIoXi-0002Mq-4X for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:27 -0400 Received: by mail-wr1-x42c.google.com with SMTP id m13so13216605wrq.6 for ; Tue, 02 Aug 2022 02:50:25 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id i18-20020a1c5412000000b003a4c6e67f01sm9533635wmb.6.2022.08.02.02.50.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 02:50:22 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 387561FFC9; Tue, 2 Aug 2022 10:50:12 +0100 (BST) 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; bh=Go4zP69KIEX2yBSg0W79f2jSqF47viC9E/7rhCMdQ80=; b=Zu/eBhMqxZmJv23bC+/x/W6pmKMp+bSN2ox3VR+NVXDAX62dfO8/JqWPJeEbtP7UfG nlIwMkpYzWJ4wsyyXoE/WbO7fzFDAQdxuGYKx0xDMqBdUML5vZv5o3tPiE7DQJWLe1TI mBW77EsggRNHDn4s2lXwgtwb10/FJ+h7M9gIEJT6QejyM6xO7JTfv1CKR9sSaoKRB9aQ 1hJLn/YO7pHr3MtegncqpxV0vE6nYu0FwZ5qQ1lcO2Ip5YIDpE62PuB1BYKP7MpwA+co +YlbFmBoZtkOkWh0YQWBL/VUuhEZH1rDo2ojUZ5NAvY5GuuZ8q5OWhi0hxOnfWAU8MXS YaRw== 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; bh=Go4zP69KIEX2yBSg0W79f2jSqF47viC9E/7rhCMdQ80=; b=vTvaafHnHEZ4cypw+9Q506DJmoT8e0USYllzUaypz/J8tKWy726T9xRBpT+9U5Fwh0 HdKttgT6qY8j4joBN2yF0qUu9cZ27yXIvjIErAMhp3frJVhBhQuAowT63cnaupO9JBUV CuLH7e6ImXkYRwi009zBx+PRaI2MLeRckSK7d+oIoEq3s1eQBVeujNQFaAWsejhKIKwE GDJiJfrspN2IIay0bRQPXPiNPHlASg8lcwWTbRCAcAtpTVvZWEB/Z+Btvit8WfYxRrxa HHZhpABbv+MHW1vkdCqejetqYvhO3296pqh+jDSkApGAg0PsthVbWzjoWmmbAWBJE5gn clFw== X-Gm-Message-State: ACgBeo0DaDITEhS7t1ubgj+IcMOlUaOpEPcTtv8JPAnzBlusTnTArkfB bfVKA05kErks0NrUlTq5z9otzA== X-Google-Smtp-Source: AA6agR4odGMXGLJuRRI1qdqr7W1pdhJJYJi/TTGgiRCx8K3DE1vl9jV4jcVzNmFIs7Fy8SBz0mBvWg== X-Received: by 2002:a05:6000:a09:b0:220:638f:3b4a with SMTP id co9-20020a0560000a0900b00220638f3b4amr5113877wrb.626.1659433825485; Tue, 02 Aug 2022 02:50:25 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 17/22] tests/qtest: catch unhandled vhost-user messages Date: Tue, 2 Aug 2022 10:50:05 +0100 Message-Id: <20220802095010.3330793-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220802095010.3330793-1-alex.bennee@linaro.org> References: <20220802095010.3330793-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::42c; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42c.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1659435005061100003 We don't need to action every message but lets document the ones we are expecting to consume so future tests don't get confused about unhandled bits. Signed-off-by: Alex Benn=C3=A9e --- v1 - drop g_test_fail() when we get unexpected result, that just hangs v4 - include ring addresses in set_vring_addr output --- tests/qtest/vhost-user-test.c | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index 968113d591..f2c19839e0 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -358,12 +358,44 @@ static void chr_read(void *opaque, const uint8_t *buf= , int size) } break; =20 + case VHOST_USER_SET_OWNER: + /* + * We don't need to do anything here, the remote is just + * letting us know it is in charge. Just log it. + */ + qos_printf("set_owner: start of session\n"); + break; + case VHOST_USER_GET_PROTOCOL_FEATURES: if (s->vu_ops->get_protocol_features) { s->vu_ops->get_protocol_features(s, chr, &msg); } break; =20 + case VHOST_USER_SET_PROTOCOL_FEATURES: + /* + * We did set VHOST_USER_F_PROTOCOL_FEATURES so its valid for + * the remote end to send this. There is no handshake reply so + * just log the details for debugging. + */ + qos_printf("set_protocol_features: 0x%"PRIx64 "\n", msg.payload.u6= 4); + break; + + /* + * A real vhost-user backend would actually set the size and + * address of the vrings but we can simply report them. + */ + case VHOST_USER_SET_VRING_NUM: + qos_printf("set_vring_num: %d/%d\n", + msg.payload.state.index, msg.payload.state.num); + break; + case VHOST_USER_SET_VRING_ADDR: + qos_printf("set_vring_addr: 0x%"PRIx64"/0x%"PRIx64"/0x%"PRIx64"\n", + msg.payload.addr.avail_user_addr, + msg.payload.addr.desc_user_addr, + msg.payload.addr.used_user_addr); + break; + case VHOST_USER_GET_VRING_BASE: /* send back vring base to qemu */ msg.flags |=3D VHOST_USER_REPLY_MASK; @@ -428,7 +460,18 @@ static void chr_read(void *opaque, const uint8_t *buf,= int size) qemu_chr_fe_write_all(chr, p, VHOST_USER_HDR_SIZE + msg.size); break; =20 + case VHOST_USER_SET_VRING_ENABLE: + /* + * Another case we ignore as we don't need to respond. With a + * fully functioning vhost-user we would enable/disable the + * vring monitoring. + */ + qos_printf("set_vring(%d)=3D%s\n", msg.payload.state.index, + msg.payload.state.num ? "enabled" : "disabled"); + break; + default: + qos_printf("vhost-user: un-handled message: %d\n", msg.request); break; } =20 --=20 2.30.2 From nobody Thu May 9 12:20:02 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1659434367; cv=none; d=zohomail.com; s=zohoarc; b=WaF7LjsVdCPIVayOadw3uH2C9EMPrp24u9jZyxVuUkexUdzSXsqBbGg1C0+8dA3f9ycLNotOAUTCq3gaNouZZuC6IEVfoLFBjapdytoBRlAaOGzuNIwgh+6tPVUhv4wXpMcSv3Ob0xaX7EdSmf9QVAAW899qzi2n3RVDxTdNw6A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659434367; 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=/benznZbSAEh098FVIlTeLDV1NXC1VfOpbQMrJp8HAc=; b=moWcnWtth3Isy+7CGx71SwD4d6pjiYdmjSHKzkJcHFs+NyrjN8zlH6t4/OL0ynOwRjNSeSkW/NnRNGXpNbatCOoYLqyE00zfTCKlwMrdJ9LWiVgWXsPNguqSwfiR5xVhGfI2kukp/Xs2a+Lu7nQ+3Cbgkc4v+cjSLPmQ+hgJtNo= 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 1659434367500346.9116498407292; Tue, 2 Aug 2022 02:59:27 -0700 (PDT) Received: from localhost ([::1]:39152 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIogP-0002I2-Ek for importer@patchew.org; Tue, 02 Aug 2022 05:59:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33524) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIoXn-0001NQ-5z for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:31 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:46646) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oIoXl-0002Vi-PX for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:30 -0400 Received: by mail-wr1-x430.google.com with SMTP id l4so17171923wrm.13 for ; Tue, 02 Aug 2022 02:50:29 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id ay28-20020a05600c1e1c00b003a3200bc788sm22879367wmb.33.2022.08.02.02.50.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 02:50:22 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 441641FFCA; Tue, 2 Aug 2022 10:50:12 +0100 (BST) 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; bh=/benznZbSAEh098FVIlTeLDV1NXC1VfOpbQMrJp8HAc=; b=Yt+1chp0XIOPAk+JtsMy9tLIa5hu8uoCQ1FQebLybHpzlm44j5Rw0kFJAisQQK32pd WaROW8As560ogPJDGe4HjkW/ZvejiKaBlbzbBRgoqcqsYaliPgRfgvXoWvUU/G07i3Bi 15uGtu+pa7twv/q7mfd4lcwq6WHPjryAH9ot8DJLVv5Hrep2XoHqPOX3cW4kogDwZPok i4/Az73tZLKwbPmhjXbQuSDI6Gv6f4KR92kGt5SIKZZfHHrB6EARG4aEAPtvxwmOMHqK moJhOPBqZsN6bdwE3DkTpGr7g36kL0jfBtgAy/cHoDU5xq+FMnPdkHJ51VUplSYmfbGI fM6Q== 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; bh=/benznZbSAEh098FVIlTeLDV1NXC1VfOpbQMrJp8HAc=; b=iYrkRaaPPcSXGEu5SmCP3dqDpmyYj30UKbDWCd7DzmQQ541bzB6B2UCX838/jXAVJ5 Ovj6w5WiF7gWq1NncKHLEspY5mdOWd5I3cPwe3R2HR4duZThhoVBhh7TuXI8HgaPKVDo K6wZYZHAjrF2CHf/zfAdhYEhQAUv+6pW7RW+P1fYjJySJwmodEgS+72VB//C2mkUivp7 UDEMW+exR88APWZALVI04UU3jmQwx9NfpoyltDhq7JAeOo70Wt366Yw4Wf87Cwzgs7Fi VwE1CBrFn1EPCO9AjYwHlzspvkcyrcToWZKA/8s8EGvveiSCHj8dy5OzUcPQC+mCu7YJ Pveg== X-Gm-Message-State: ACgBeo0BEd3T7jMuKcs3dhqDCQtQ6E5lFsLPQwZyTK1MxPMVJMKPXMvA EzbiFrhsQFu9lZ24YJdGOmaBog== X-Google-Smtp-Source: AA6agR6XofuJQmEesDvEVyJcxIDJpZbTb5iK7gK25auhOqaE35FNTYALOiTOMyJNiJ/KFW2ZR7uuig== X-Received: by 2002:a05:6000:1acb:b0:21d:ad71:3585 with SMTP id i11-20020a0560001acb00b0021dad713585mr11930484wry.156.1659433828497; Tue, 02 Aug 2022 02:50:28 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 18/22] tests/qtest: plain g_assert for VHOST_USER_F_PROTOCOL_FEATURES Date: Tue, 2 Aug 2022 10:50:06 +0100 Message-Id: <20220802095010.3330793-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220802095010.3330793-1-alex.bennee@linaro.org> References: <20220802095010.3330793-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1659434368656100001 checkpatch.pl warns that non-plain asserts should be avoided so convert the check to a plain g_assert. Signed-off-by: Alex Benn=C3=A9e --- tests/qtest/vhost-user-test.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index f2c19839e0..4af031c971 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -983,8 +983,7 @@ static void test_multiqueue(void *obj, void *arg, QGues= tAllocator *alloc) static void vu_net_set_features(TestServer *s, CharBackend *chr, VhostUserMsg *msg) { - g_assert_cmpint(msg->payload.u64 & - (0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES), !=3D, 0ULL); + g_assert(msg->payload.u64 & (0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES)= ); if (s->test_flags =3D=3D TEST_FLAGS_DISCONNECT) { qemu_chr_fe_disconnect(chr); s->test_flags =3D TEST_FLAGS_BAD; --=20 2.30.2 From nobody Thu May 9 12:20:02 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1659436229; cv=none; d=zohomail.com; s=zohoarc; b=H3acKedNxG26auW3cjBR63Bi1j/JAqV5j4jYgY4x5tdXjXFiYIIcjpun4U43rVAHpR7rEhzH3WuzpcjBuEZ1ymUYKltdgnMgniAJleIP96GsyGuETfdNCizCukCurXbE9WhLaLjJN5JKCFhGidO0wi8hqM3HpJ6JKOAd3ExVwmE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659436229; 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=PYaGkXjsZkoph9fA5YpZi9kVlMvB2mVtLyywEwpEssY=; b=jkmZF7waHmu7dIvEcp+8sLICDCKyAD+j4PQmHFL71xRub2NfQOBwD6CyUmG1EhZrHhOLKlEoEu26o93cmKUls7iK/uXSfc4ANpvQqdY1xKcjThAra0qXgCOfdKSFiUMoPt02gp5CirRg4jLOSgovLe7kH84aMErR09xmamf1RL4= 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 1659436229460363.0873805796789; Tue, 2 Aug 2022 03:30:29 -0700 (PDT) Received: from localhost ([::1]:60154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIpAR-0001NV-US for importer@patchew.org; Tue, 02 Aug 2022 06:30:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35408) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIohM-00052h-1u for qemu-devel@nongnu.org; Tue, 02 Aug 2022 06:00:24 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:39840) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oIohH-0006OB-SU for qemu-devel@nongnu.org; Tue, 02 Aug 2022 06:00:23 -0400 Received: by mail-wr1-x42f.google.com with SMTP id m13so13247403wrq.6 for ; Tue, 02 Aug 2022 03:00:19 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id i5-20020adff305000000b002206203ed3dsm6834910wro.29.2022.08.02.03.00.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 03:00:14 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 59C041FFCB; Tue, 2 Aug 2022 10:50:12 +0100 (BST) 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; bh=PYaGkXjsZkoph9fA5YpZi9kVlMvB2mVtLyywEwpEssY=; b=pTb7MGDE78geiqxMCcCLvrZUJjBLV36BfFpG/6xA/WeXQ1W2hajMye79v9eEaM5CH1 ZOx0K0lVcLrPZUIFx7EW2HZaYmwilk/fID+lKhPJDxBtyIASVCVmvOs39k3/hcNoUKln nknd3k5+17SCURssRhrVBK/HQZkI9DENz3RPsz+f9fK3ZoljhomtoSkMxyrwQFukqfrj VEqU8y8BQp+3+ouX+lbhy6Mlrqy1BJphNRsikJc6D8yuU/NKIFOPrUO4RjFzT+g3XP8r 8WoSAM1i/FvnJGp8a6RN5mS4XBkskFUCLEl+FGSwOy4nyPImgSEqxenK+IQc45YefGKH ZS+g== 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; bh=PYaGkXjsZkoph9fA5YpZi9kVlMvB2mVtLyywEwpEssY=; b=dIBorwa55AvuouDXh5htUPbXZ1PJZPklNUhuyGEh2D4wOx6pbQl0UutMXYpjWbAQLm IaOWRWjGHrByGipST7MP4076KHXXpw2X6rZxnBp29zv0o61iAwfecbfdKRGG3T8qizRq eezETt3Gr2dRa0TGZOxHfNhiSrvgM/00j2lBJ5fqVQwjbBpyFk2urEVVSONgU2YQZbuw /Wlmztwl/h47udhb4/dCzmb9yLDZPpcvm9aA+aALjiAzQOg0N1vOTmD833tlsOgNEn6I pXSDgALyQcPAeu4Y5+h5r0Hh+P8y7TnfkTSaV77ZJcGRWXA5dcHLdWC+zivln13ymYce 5Olg== X-Gm-Message-State: ACgBeo2RVmiFQNamAOLyJexe6FxBHoyJkO2bXcDOYAqt/Mzwrc2hZYRR khTaW3yh0DFTAMcGYHXcYaCvag== X-Google-Smtp-Source: AA6agR7K1x0lUNHzTO2Mgnuj5Hve5ZdEdE86SkQ0MPsbIuk83T9ayUeNgI4rHewCRW9o4mBEHJyrqg== X-Received: by 2002:a5d:64ce:0:b0:220:6e13:c95 with SMTP id f14-20020a5d64ce000000b002206e130c95mr2027448wri.322.1659434418477; Tue, 02 Aug 2022 03:00:18 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 19/22] tests/qtest: add assert to catch bad features Date: Tue, 2 Aug 2022 10:50:07 +0100 Message-Id: <20220802095010.3330793-20-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220802095010.3330793-1-alex.bennee@linaro.org> References: <20220802095010.3330793-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::42f; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42f.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1659436230506100001 No device driver (which is what the qvirtio_ access functions represent) should be setting UNUSED(30) in the feature space. Although existing libqos users mask it out lets ensure nothing sneaks through. Signed-off-by: Alex Benn=C3=A9e --- tests/qtest/libqos/virtio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/qtest/libqos/virtio.c b/tests/qtest/libqos/virtio.c index 09ec09b655..03056e5187 100644 --- a/tests/qtest/libqos/virtio.c +++ b/tests/qtest/libqos/virtio.c @@ -101,6 +101,8 @@ uint64_t qvirtio_get_features(QVirtioDevice *d) =20 void qvirtio_set_features(QVirtioDevice *d, uint64_t features) { + g_assert(!(features & QVIRTIO_F_BAD_FEATURE)); + d->features =3D features; d->bus->set_features(d, features); =20 --=20 2.30.2 From nobody Thu May 9 12:20:02 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1659436091; cv=none; d=zohomail.com; s=zohoarc; b=XTLhZY7PiKdqL1YpRwKxOvn+Kdhmi7FLQtkwAtiLzhz+LT23aiKZ0u64jR33XX6mj7w2soc1c7d2yTSWQJB1cF3TM4ruj70L/VblzOqTE+0EoUGQRK/NH/30c9XWr7slEpIh3B+1DNyschvYRYo/2p1h+H9htNhaRqhHKWnD4Ts= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659436091; 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=g/o8m65biskhxapd/iISMtVnr5sb7Kumaq7aeEYhX/o=; b=blKUc2CWpHB5WwLMrZrBlDf4li0a6Mpl6DFmvUcDOff5hLbVvRGHBw6fyKfwWw6Hhybnqu8L3m1897ixWQG0B1dOvit0K+gmp29o9+wn6R23eYW52qCsFIGLGDblXVrt8+ZURG+MRGwAWvivZcrwrLXh0MhRlQdS1gDPzUDlaiE= 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 1659436091336422.1624247406844; Tue, 2 Aug 2022 03:28:11 -0700 (PDT) Received: from localhost ([::1]:56596 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIp8E-0007Ht-0k for importer@patchew.org; Tue, 02 Aug 2022 06:28:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35416) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIohM-00053O-CY for qemu-devel@nongnu.org; Tue, 02 Aug 2022 06:00:24 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:39846) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oIohF-0006DO-Sr for qemu-devel@nongnu.org; Tue, 02 Aug 2022 06:00:24 -0400 Received: by mail-wr1-x436.google.com with SMTP id m13so13247284wrq.6 for ; Tue, 02 Aug 2022 03:00:17 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id p8-20020a05600c1d8800b003a2e655f2e6sm1290939wms.21.2022.08.02.03.00.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 03:00:14 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 650651FFCC; Tue, 2 Aug 2022 10:50:12 +0100 (BST) 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; bh=g/o8m65biskhxapd/iISMtVnr5sb7Kumaq7aeEYhX/o=; b=FE2Ao+wjb6GPA5O7wRZp3M7kNFyPGOHF6bqGoRhTMopmkkbvxB0NLwpfUggyEzoC2D 8b8T0fAjMHohk9l5a8NS3isgVN1n303Sim3crVbuukDMcQ19uI+1Hw5LZiwXwA+QHk82 HeYKn+BtOQKTmrbYVhkoEuC9edXso69+cAeqbkK31YvSu8bTdX7tixAkDKfi6nIvx+IN +5cxmtqFnvQMzKFEdkXuwJ4vMzqeBSDfdQA8PK3MYTB0K/ohWj/OH1gDMoskStjKuXME roNu0oeZS/+/iAS9E8N4Qd0ql9fmGwps2hDRPm+oMRuCQ9o8ZSsuzpS4+MTOYIsf048Y Wpdw== 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; bh=g/o8m65biskhxapd/iISMtVnr5sb7Kumaq7aeEYhX/o=; b=13oytQljbEZt4W3lSlvLwAgB5LMU+ZQON6alHEKR2eBtiJmIlepWxWvuyw0E8TNmqS 0RM9dKFQo7xnK7QSDb25EVRipSDMrRwAthu+4VnbQxtnejCCnqAKoGjWjSeKtMq01uxa gudZfhD/dZRX2gYd9/+EAg8w+/O4Zg2+thPVru7QAjQcI/VXnlflFPta6JjZhveOLSRt Vy/pgFifmbq14PRDuK8m7xKvSiC42WSwe1HkMmkgnyPvzXX82Y5IEc1FWFdbbc/9IlCW ZXxx5NXzm/ptAVydNCxTjRJOnAXu8Zo0Fc0jlfGmlhWK2XivxRPqtUfXXVln+JQUBSO7 1bjA== X-Gm-Message-State: ACgBeo3fxs0TtAfdLivm4D47t/l3lh2UkLYMhaC1AUNLT0NHQ5GvBnIm V0AMAe59sn5qWHF2CxQ0FlsbSA== X-Google-Smtp-Source: AA6agR6U1N2l/Q96zGtnuLL+cZeU/fJS4c9/QJL8dFuHjhh1ai18gGjyhWMbFaSZUFKUtxg3/QkwTQ== X-Received: by 2002:a5d:634d:0:b0:220:5ff7:3969 with SMTP id b13-20020a5d634d000000b002205ff73969mr6642871wrw.709.1659434416540; Tue, 02 Aug 2022 03:00:16 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 20/22] tests/qtest: implement stub for VHOST_USER_GET_CONFIG Date: Tue, 2 Aug 2022 10:50:08 +0100 Message-Id: <20220802095010.3330793-21-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220802095010.3330793-1-alex.bennee@linaro.org> References: <20220802095010.3330793-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::436; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x436.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1659436092942100001 We don't implement the full solution because frankly none of the tests need to at the moment. We may end up re-implementing libvhostuser in the end. Signed-off-by: Alex Benn=C3=A9e --- tests/qtest/vhost-user-test.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index 4af031c971..61980bfc6a 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -79,6 +79,8 @@ typedef enum VhostUserRequest { VHOST_USER_SET_PROTOCOL_FEATURES =3D 16, VHOST_USER_GET_QUEUE_NUM =3D 17, VHOST_USER_SET_VRING_ENABLE =3D 18, + VHOST_USER_GET_CONFIG =3D 24, + VHOST_USER_SET_CONFIG =3D 25, VHOST_USER_MAX } VhostUserRequest; =20 @@ -372,6 +374,17 @@ static void chr_read(void *opaque, const uint8_t *buf,= int size) } break; =20 + case VHOST_USER_GET_CONFIG: + /* + * Treat GET_CONFIG as a NOP and just reply and let the guest + * consider we have updated its memory. Tests currently don't + * require working configs. + */ + msg.flags |=3D VHOST_USER_REPLY_MASK; + p =3D (uint8_t *) &msg; + qemu_chr_fe_write_all(chr, p, VHOST_USER_HDR_SIZE + msg.size); + break; + case VHOST_USER_SET_PROTOCOL_FEATURES: /* * We did set VHOST_USER_F_PROTOCOL_FEATURES so its valid for --=20 2.30.2 From nobody Thu May 9 12:20:02 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1659435153; cv=none; d=zohomail.com; s=zohoarc; b=jK7OyZAem0g8icXY1G5dSKFnE58NtB3unXi/VSg9DVKHWTgiv5Jn7hi56lmjqO6rxscVEnub4HVoEoZD12j6N+8pYBpyvGSm+dheKQAmNeg3T1YOvbfJXJxGWc/AyqbF0ttupe4/AZ0O+x1a0wtKU6FLmGqILnU9v02h1bAHOlU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659435153; 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=vdim50/4QWM59eJmuqXHbqgfci2iCoUWAD1+T4jr3FI=; b=Ym/3xKOEa4Ux1XJNMLxLi0QQvZcE9WfmFVUIECOu+cSfOYHOOlDVT6nbTWz2IRCUNInKqXCe+KT913yQ+s3+/lnu6xjFTjDPi1/ffq4amyU7WZc9pAaFxJOg0lhOoHbprbHQGYaHvpCX4O8ewbCqEr/Q6zKDdFhQ85GYUYrH99I= 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 1659435153669143.97045873811874; Tue, 2 Aug 2022 03:12:33 -0700 (PDT) Received: from localhost ([::1]:58658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIot5-0007NK-AQ for importer@patchew.org; Tue, 02 Aug 2022 06:12:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35464) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIohP-00058t-16 for qemu-devel@nongnu.org; Tue, 02 Aug 2022 06:00:27 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:34344) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oIohN-0006QU-3j for qemu-devel@nongnu.org; Tue, 02 Aug 2022 06:00:26 -0400 Received: by mail-wr1-x432.google.com with SMTP id j1so8815749wrw.1 for ; Tue, 02 Aug 2022 03:00:24 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id u13-20020a05600c19cd00b003a2e1883a27sm28459213wmq.18.2022.08.02.03.00.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 03:00:21 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 7C4BC1FFCD; Tue, 2 Aug 2022 10:50:12 +0100 (BST) 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; bh=vdim50/4QWM59eJmuqXHbqgfci2iCoUWAD1+T4jr3FI=; b=gYsUZoviNG20Yp8iVFGsqKJVFG6KjmJvAV+gErCRnbn1Ez/vfOtE3QE9U/Xxk1GEXh LAOZleDGvgqDorkSk2czqVF4B/l51jO+wLKlExweGpWZaQjSSVeoRcH/Sj/3yJVrmw2q dkRSpSqUeIRYNinFUVxqm68TnLNUiyx1YvtwpWYbJzamsRTQNaECO4EUr0sCLJVUJAPz e8DdBkhdZAfJXzRGGA67lpSJCdD1SkyyliMzfRUYfiyDK3UvxnZFaXTw4hyroTnkqLgH ZTaG3SUe32YHNhuMpwehFtqbdLMJvDe9YI5Kripl0e7y4p8g5HSYT4CvQvd0PjN0+EL9 SwFA== 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; bh=vdim50/4QWM59eJmuqXHbqgfci2iCoUWAD1+T4jr3FI=; b=JvbjA7i7VwRmsr5RDHesFCo1Ze+44xCHL1f8gg5Zj346Itm91XFVJdPqsUjVTO6eUL dFi6BctDQQ+/yD2MX5BgzBOhC1aFv1kLcE7MJFQK17Qc9ueEd81YjYg7Lc2U5wfre9/H zjvyM8mdyRZjvQ4FnehLPDuvUeye3EEqXDy6ZmS4r5NUk8G7yVGhnJaPAdCpTJZZSDRa +mXq+Hm4poSSzfb2nIHtuEkXLy9795zndm+UpF2x9Usmtcy1Z7HOsBgZItTjw5Dq1rCb v41vXpdVK68J0Gfn+g581RweYBD4rWAfDju1svQd+7ZWRhNaomNBmXs0nukp+YADRTWR cUDA== X-Gm-Message-State: ACgBeo2zLYL51Q+os1zR6WDwbicTYyz8NxEYcUtTzZxjIu9CQ47kWL0j DyyEEgTYIkDAEo5HY6yUSjpVlA== X-Google-Smtp-Source: AA6agR62jZMuvAIY132dMhgJgCD0UrMQMBStBbR3Z6iOfNXqgTL6PY79d+cNTHJL7TLbSJn9V/0MFQ== X-Received: by 2002:adf:fb83:0:b0:21d:649a:72d9 with SMTP id a3-20020adffb83000000b0021d649a72d9mr12115328wrr.688.1659434423706; Tue, 02 Aug 2022 03:00:23 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 21/22] tests/qtest: add a get_features op to vhost-user-test Date: Tue, 2 Aug 2022 10:50:09 +0100 Message-Id: <20220802095010.3330793-22-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220802095010.3330793-1-alex.bennee@linaro.org> References: <20220802095010.3330793-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::432; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x432.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1659435154315100001 As we expand this test for more virtio devices we will need to support different feature sets. Add a mandatory op field to fetch the list of features needed for the test itself. Signed-off-by: Alex Benn=C3=A9e --- tests/qtest/vhost-user-test.c | 37 +++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index 61980bfc6a..fe46e28cf2 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -171,10 +171,11 @@ struct vhost_user_ops { const char *chr_opts); =20 /* VHOST-USER commands. */ + uint64_t (*get_features)(TestServer *s); void (*set_features)(TestServer *s, CharBackend *chr, - VhostUserMsg *msg); + VhostUserMsg *msg); void (*get_protocol_features)(TestServer *s, - CharBackend *chr, VhostUserMsg *msg); + CharBackend *chr, VhostUserMsg *msg); }; =20 static const char *init_hugepagefs(void); @@ -338,20 +339,22 @@ static void chr_read(void *opaque, const uint8_t *buf= , int size) =20 switch (msg.request) { case VHOST_USER_GET_FEATURES: + /* Mandatory for tests to define get_features */ + g_assert(s->vu_ops->get_features); + /* send back features to qemu */ msg.flags |=3D VHOST_USER_REPLY_MASK; msg.size =3D sizeof(m.payload.u64); - msg.payload.u64 =3D 0x1ULL << VHOST_F_LOG_ALL | - 0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES; - if (s->queues > 1) { - msg.payload.u64 |=3D 0x1ULL << VIRTIO_NET_F_MQ; - } + if (s->test_flags >=3D TEST_FLAGS_BAD) { msg.payload.u64 =3D 0; s->test_flags =3D TEST_FLAGS_END; + } else { + msg.payload.u64 =3D s->vu_ops->get_features(s); } - p =3D (uint8_t *) &msg; - qemu_chr_fe_write_all(chr, p, VHOST_USER_HDR_SIZE + msg.size); + + qemu_chr_fe_write_all(chr, (uint8_t *) &msg, + VHOST_USER_HDR_SIZE + msg.size); break; =20 case VHOST_USER_SET_FEATURES: @@ -993,8 +996,21 @@ static void test_multiqueue(void *obj, void *arg, QGue= stAllocator *alloc) wait_for_rings_started(s, s->queues * 2); } =20 + +static uint64_t vu_net_get_features(TestServer *s) +{ + uint64_t features =3D 0x1ULL << VHOST_F_LOG_ALL | + 0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES; + + if (s->queues > 1) { + features |=3D 0x1ULL << VIRTIO_NET_F_MQ; + } + + return features; +} + static void vu_net_set_features(TestServer *s, CharBackend *chr, - VhostUserMsg *msg) + VhostUserMsg *msg) { g_assert(msg->payload.u64 & (0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES)= ); if (s->test_flags =3D=3D TEST_FLAGS_DISCONNECT) { @@ -1023,6 +1039,7 @@ static struct vhost_user_ops g_vu_net_ops =3D { =20 .append_opts =3D append_vhost_net_opts, =20 + .get_features =3D vu_net_get_features, .set_features =3D vu_net_set_features, .get_protocol_features =3D vu_net_get_protocol_features, }; --=20 2.30.2 From nobody Thu May 9 12:20:02 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1659436470; cv=none; d=zohomail.com; s=zohoarc; b=CIYfjuth23YMJwwCi3R/IOxnZtgP8/MrP3WRECxyf6FyRheSV8hDkPL99Fv0Gn+Q6ldnoFUyrRcJMRz5G/T5ScPV7fWSFefWx//TPCuCR97sMvU9ottIwa+daDjz7RM56beNKTlqAylss+FXEJdOFDgF5zwk6qLsicB7T4+H80I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659436470; 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=ES3P1RAWW4Xg6DVYirTqKJQ7c1EO4knl3H0A5mgKf8M=; b=etk3s49PEYTUpYHiRDhtCfK0GQ5nAvCSKKKXlqTpUSuDupEKAPp0GYgXpSHUME/Yu/mip/P7U6POZ46QSitZseq8alHRYhDW0/HQu1k8lpqi47tChHgaN3Yp7ViPPe+6M4Q+CxMabCddT/Dg4vLkkU3lOeqNuLwSnHX6LcHx8RU= 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 1659436470921687.4477679697736; Tue, 2 Aug 2022 03:34:30 -0700 (PDT) Received: from localhost ([::1]:36752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIpEL-0004jz-Nn for importer@patchew.org; Tue, 02 Aug 2022 06:34:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35486) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIohS-0005G4-3j for qemu-devel@nongnu.org; Tue, 02 Aug 2022 06:00:30 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:37648) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oIohK-0006DB-8O for qemu-devel@nongnu.org; Tue, 02 Aug 2022 06:00:29 -0400 Received: by mail-wr1-x435.google.com with SMTP id z17so12498011wrq.4 for ; Tue, 02 Aug 2022 03:00:21 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id q187-20020a1c43c4000000b003a302fb9df7sm4240923wma.21.2022.08.02.03.00.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 03:00:14 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A37861FFCE; Tue, 2 Aug 2022 10:50:12 +0100 (BST) 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; bh=ES3P1RAWW4Xg6DVYirTqKJQ7c1EO4knl3H0A5mgKf8M=; b=Cn/uODqppxqVEemKOblvb4+obYxHAx9C/sC794rr3wxk8cq3AacDOCYzQ21b5uH1lH mFW6zb64s4JbW2C658CP0eLhY7cQwII8X7oGXUbdNOppjGHZglbpzmFQF5GxUDW9XWsD euEySNVXRtDC9EMHwHH5RznUJB5XimaH28vOAmd2OWPEMkAuCL2p0uW0DVudSmQH5S89 sJVRUZGrdjEogVOmgBRJ2uOYczpLwzQzPoRP2FwF2OZISjNe3/E4FXvXfSl4Rg8ocHc1 Nx9BFOG4vNc4XUn3+DmfdxWnxf4idEAnyZ31b4schfGU/GyEsiQqrHceTZXawA/P0lz1 +nFQ== 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; bh=ES3P1RAWW4Xg6DVYirTqKJQ7c1EO4knl3H0A5mgKf8M=; b=z+NOizBpt5AROIidQceNBeyO5ytlhBQl/hTWoxDn1Dp74ULxs1b5nEqfBDzHUGtD// pj4sPatEYX5JeSzv/qpnGi1mEgflnFEowZcUAQOv2ogp1V/O8Wq4KfVHDcBWxZ7uSJGV ZveA+6YSoM9gbr69jri+GPO3wgW+6oDVwiAFkhZnTLlZJJlUV7z5i6JEwUBVXS1DzB7G rUQsqB77EsIWZaCb0XLsmU/vXwNcJMkoD2XtANyMQKtngFmzN821kkcdd1R4swuHCCsS WkSHCpOwglMxi8uBg+sSKFkYBnV1nxbc5lKjpik/fnLqFowYFKRPZekOSC9EaLsqLSqA V3Aw== X-Gm-Message-State: ACgBeo2qNiMs0n9L9/xHF1ATP/Uykae1/93bMyTMmFU8STom2FMZq4Z9 dTetKYPrRA8ZE8a+i0ytyDeLaQ== X-Google-Smtp-Source: AA6agR7NbqDdDb5XjjwXKvTcf7RbSODWqKv13AawQnd8bOyMP4o6UGdvpT8LhpEF7SzmiTGZDTkMzg== X-Received: by 2002:a5d:6d0b:0:b0:21d:9f54:efa2 with SMTP id e11-20020a5d6d0b000000b0021d9f54efa2mr12255842wrq.607.1659434421411; Tue, 02 Aug 2022 03:00:21 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Eric Auger , Thomas Huth , Laurent Vivier Subject: [PATCH v4 22/22] tests/qtest: enable tests for virtio-gpio Date: Tue, 2 Aug 2022 10:50:10 +0100 Message-Id: <20220802095010.3330793-23-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220802095010.3330793-1-alex.bennee@linaro.org> References: <20220802095010.3330793-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::435; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x435.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1659436472335100001 We don't have a virtio-gpio implementation in QEMU and only support a vhost-user backend. The QEMU side of the code is minimal so it should be enough to instantiate the device and pass some vhost-user messages over the control socket. To do this we hook into the existing vhost-user-test code and just add the bits required for gpio. Signed-off-by: Alex Benn=C3=A9e Cc: Viresh Kumar Cc: Paolo Bonzini Cc: Eric Auger Message-Id: <20220408155704.2777166-1-alex.bennee@linaro.org> --- v2 - add more of the missing boilerplate - don't request LOG_SHMD - use get_features op - report VIRTIO_F_VERSION_1 - more comments v4 - update MAINTAINERS --- tests/qtest/libqos/virtio-gpio.h | 35 +++++++ tests/qtest/libqos/virtio-gpio.c | 171 +++++++++++++++++++++++++++++++ tests/qtest/libqos/virtio.c | 2 +- tests/qtest/vhost-user-test.c | 66 ++++++++++++ MAINTAINERS | 1 + tests/qtest/libqos/meson.build | 1 + 6 files changed, 275 insertions(+), 1 deletion(-) create mode 100644 tests/qtest/libqos/virtio-gpio.h create mode 100644 tests/qtest/libqos/virtio-gpio.c diff --git a/tests/qtest/libqos/virtio-gpio.h b/tests/qtest/libqos/virtio-g= pio.h new file mode 100644 index 0000000000..f11d41bd19 --- /dev/null +++ b/tests/qtest/libqos/virtio-gpio.h @@ -0,0 +1,35 @@ +/* + * virtio-gpio structures + * + * Copyright (c) 2022 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef TESTS_LIBQOS_VIRTIO_GPIO_H +#define TESTS_LIBQOS_VIRTIO_GPIO_H + +#include "qgraph.h" +#include "virtio.h" +#include "virtio-pci.h" + +typedef struct QVhostUserGPIO QVhostUserGPIO; +typedef struct QVhostUserGPIOPCI QVhostUserGPIOPCI; +typedef struct QVhostUserGPIODevice QVhostUserGPIODevice; + +struct QVhostUserGPIO { + QVirtioDevice *vdev; + QVirtQueue **queues; +}; + +struct QVhostUserGPIOPCI { + QVirtioPCIDevice pci_vdev; + QVhostUserGPIO gpio; +}; + +struct QVhostUserGPIODevice { + QOSGraphObject obj; + QVhostUserGPIO gpio; +}; + +#endif diff --git a/tests/qtest/libqos/virtio-gpio.c b/tests/qtest/libqos/virtio-g= pio.c new file mode 100644 index 0000000000..762aa6695b --- /dev/null +++ b/tests/qtest/libqos/virtio-gpio.c @@ -0,0 +1,171 @@ +/* + * virtio-gpio nodes for testing + * + * Copyright (c) 2022 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "standard-headers/linux/virtio_config.h" +#include "../libqtest.h" +#include "qemu/module.h" +#include "qgraph.h" +#include "virtio-gpio.h" + +static QGuestAllocator *alloc; + +static void virtio_gpio_cleanup(QVhostUserGPIO *gpio) +{ + QVirtioDevice *vdev =3D gpio->vdev; + int i; + + for (i =3D 0; i < 2; i++) { + qvirtqueue_cleanup(vdev->bus, gpio->queues[i], alloc); + } + g_free(gpio->queues); +} + +/* + * This handles the VirtIO setup from the point of view of the driver + * frontend and therefor doesn't present any vhost specific features + * and in fact masks of the re-used bit. + */ +static void virtio_gpio_setup(QVhostUserGPIO *gpio) +{ + QVirtioDevice *vdev =3D gpio->vdev; + uint64_t features; + int i; + + features =3D qvirtio_get_features(vdev); + features &=3D ~QVIRTIO_F_BAD_FEATURE; + qvirtio_set_features(vdev, features); + + gpio->queues =3D g_new(QVirtQueue *, 2); + for (i =3D 0; i < 2; i++) { + gpio->queues[i] =3D qvirtqueue_setup(vdev, alloc, i); + } + qvirtio_set_driver_ok(vdev); +} + +static void *qvirtio_gpio_get_driver(QVhostUserGPIO *v_gpio, + const char *interface) +{ + if (!g_strcmp0(interface, "vhost-user-gpio")) { + return v_gpio; + } + if (!g_strcmp0(interface, "virtio")) { + return v_gpio->vdev; + } + + g_assert_not_reached(); +} + +static void *qvirtio_gpio_device_get_driver(void *object, + const char *interface) +{ + QVhostUserGPIODevice *v_gpio =3D object; + return qvirtio_gpio_get_driver(&v_gpio->gpio, interface); +} + +/* virtio-gpio (mmio) */ +static void qvirtio_gpio_device_destructor(QOSGraphObject *obj) +{ + QVhostUserGPIODevice *gpio_dev =3D (QVhostUserGPIODevice *) obj; + virtio_gpio_cleanup(&gpio_dev->gpio); +} + +static void qvirtio_gpio_device_start_hw(QOSGraphObject *obj) +{ + QVhostUserGPIODevice *gpio_dev =3D (QVhostUserGPIODevice *) obj; + virtio_gpio_setup(&gpio_dev->gpio); +} + +static void *virtio_gpio_device_create(void *virtio_dev, + QGuestAllocator *t_alloc, + void *addr) +{ + QVhostUserGPIODevice *virtio_device =3D g_new0(QVhostUserGPIODevice, 1= ); + QVhostUserGPIO *interface =3D &virtio_device->gpio; + + interface->vdev =3D virtio_dev; + alloc =3D t_alloc; + + virtio_device->obj.get_driver =3D qvirtio_gpio_device_get_driver; + virtio_device->obj.start_hw =3D qvirtio_gpio_device_start_hw; + virtio_device->obj.destructor =3D qvirtio_gpio_device_destructor; + + return &virtio_device->obj; +} + +/* virtio-gpio-pci */ +static void qvirtio_gpio_pci_destructor(QOSGraphObject *obj) +{ + QVhostUserGPIOPCI *gpio_pci =3D (QVhostUserGPIOPCI *) obj; + QOSGraphObject *pci_vobj =3D &gpio_pci->pci_vdev.obj; + + virtio_gpio_cleanup(&gpio_pci->gpio); + qvirtio_pci_destructor(pci_vobj); +} + +static void qvirtio_gpio_pci_start_hw(QOSGraphObject *obj) +{ + QVhostUserGPIOPCI *gpio_pci =3D (QVhostUserGPIOPCI *) obj; + QOSGraphObject *pci_vobj =3D &gpio_pci->pci_vdev.obj; + + qvirtio_pci_start_hw(pci_vobj); + virtio_gpio_setup(&gpio_pci->gpio); +} + +static void *qvirtio_gpio_pci_get_driver(void *object, const char *interfa= ce) +{ + QVhostUserGPIOPCI *v_gpio =3D object; + + if (!g_strcmp0(interface, "pci-device")) { + return v_gpio->pci_vdev.pdev; + } + return qvirtio_gpio_get_driver(&v_gpio->gpio, interface); +} + +static void *virtio_gpio_pci_create(void *pci_bus, QGuestAllocator *t_allo= c, + void *addr) +{ + QVhostUserGPIOPCI *virtio_spci =3D g_new0(QVhostUserGPIOPCI, 1); + QVhostUserGPIO *interface =3D &virtio_spci->gpio; + QOSGraphObject *obj =3D &virtio_spci->pci_vdev.obj; + + virtio_pci_init(&virtio_spci->pci_vdev, pci_bus, addr); + interface->vdev =3D &virtio_spci->pci_vdev.vdev; + alloc =3D t_alloc; + + obj->get_driver =3D qvirtio_gpio_pci_get_driver; + obj->start_hw =3D qvirtio_gpio_pci_start_hw; + obj->destructor =3D qvirtio_gpio_pci_destructor; + + return obj; +} + +static void virtio_gpio_register_nodes(void) +{ + QPCIAddress addr =3D { + .devfn =3D QPCI_DEVFN(4, 0), + }; + + QOSGraphEdgeOptions edge_opts =3D { }; + + /* vhost-user-gpio-device */ + edge_opts.extra_device_opts =3D "id=3Dgpio0,chardev=3Dchr-vhost-user-t= est"; + qos_node_create_driver("vhost-user-gpio-device", + virtio_gpio_device_create); + qos_node_consumes("vhost-user-gpio-device", "virtio-bus", &edge_opts); + qos_node_produces("vhost-user-gpio-device", "vhost-user-gpio"); + + /* virtio-gpio-pci */ + edge_opts.extra_device_opts =3D "id=3Dgpio0,addr=3D04.0,chardev=3Dchr-= vhost-user-test"; + add_qpci_address(&edge_opts, &addr); + qos_node_create_driver("vhost-user-gpio-pci", virtio_gpio_pci_create); + qos_node_consumes("vhost-user-gpio-pci", "pci-bus", &edge_opts); + qos_node_produces("vhost-user-gpio-pci", "vhost-user-gpio"); +} + +libqos_init(virtio_gpio_register_nodes); diff --git a/tests/qtest/libqos/virtio.c b/tests/qtest/libqos/virtio.c index 03056e5187..410513225f 100644 --- a/tests/qtest/libqos/virtio.c +++ b/tests/qtest/libqos/virtio.c @@ -110,7 +110,7 @@ void qvirtio_set_features(QVirtioDevice *d, uint64_t fe= atures) * This could be a separate function for drivers that want to access * configuration space before setting FEATURES_OK, but no existing use= rs * need that and it's less code for callers if this is done implicitly. - */ + */ if (features & (1ull << VIRTIO_F_VERSION_1)) { uint8_t status =3D d->bus->get_status(d) | VIRTIO_CONFIG_S_FEATURES_OK; diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index fe46e28cf2..d79bd28cd1 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -32,6 +32,7 @@ #include "standard-headers/linux/vhost_types.h" #include "standard-headers/linux/virtio_ids.h" #include "standard-headers/linux/virtio_net.h" +#include "standard-headers/linux/virtio_gpio.h" =20 #ifdef CONFIG_LINUX #include @@ -53,9 +54,12 @@ #define VHOST_MAX_VIRTQUEUES 0x100 =20 #define VHOST_USER_F_PROTOCOL_FEATURES 30 +#define VIRTIO_F_VERSION_1 32 + #define VHOST_USER_PROTOCOL_F_MQ 0 #define VHOST_USER_PROTOCOL_F_LOG_SHMFD 1 #define VHOST_USER_PROTOCOL_F_CROSS_ENDIAN 6 +#define VHOST_USER_PROTOCOL_F_CONFIG 9 =20 #define VHOST_LOG_PAGE 0x1000 =20 @@ -140,6 +144,7 @@ enum { =20 enum { VHOST_USER_NET, + VHOST_USER_GPIO, }; =20 typedef struct TestServer { @@ -198,6 +203,19 @@ static void append_vhost_net_opts(TestServer *s, GStri= ng *cmd_line, chr_opts, s->chr_name); } =20 +/* + * For GPIO there are no other magic devices we need to add (like + * block or netdev) so all we need to worry about is the vhost-user + * chardev socket. + */ +static void append_vhost_gpio_opts(TestServer *s, GString *cmd_line, + const char *chr_opts) +{ + g_string_append_printf(cmd_line, QEMU_CMD_CHR, + s->chr_name, s->socket_path, + chr_opts); +} + static void append_mem_opts(TestServer *server, GString *cmd_line, int size, enum test_memfd memfd) { @@ -1088,3 +1106,51 @@ static void register_vhost_user_test(void) test_multiqueue, &opts); } libqos_init(register_vhost_user_test); + +static uint64_t vu_gpio_get_features(TestServer *s) +{ + return 0x1ULL << VIRTIO_F_VERSION_1 | + 0x1ULL << VIRTIO_GPIO_F_IRQ | + 0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES; +} + +/* + * This stub can't handle all the message types but we should reply + * that we support VHOST_USER_PROTOCOL_F_CONFIG as gpio would use it + * talking to a read vhost-user daemon. + */ +static void vu_gpio_get_protocol_features(TestServer *s, CharBackend *chr, + VhostUserMsg *msg) +{ + /* send back features to qemu */ + msg->flags |=3D VHOST_USER_REPLY_MASK; + msg->size =3D sizeof(m.payload.u64); + msg->payload.u64 =3D 1ULL << VHOST_USER_PROTOCOL_F_CONFIG; + + qemu_chr_fe_write_all(chr, (uint8_t *)msg, VHOST_USER_HDR_SIZE + msg->= size); +} + +static struct vhost_user_ops g_vu_gpio_ops =3D { + .type =3D VHOST_USER_GPIO, + + .append_opts =3D append_vhost_gpio_opts, + + .get_features =3D vu_gpio_get_features, + .set_features =3D vu_net_set_features, + .get_protocol_features =3D vu_gpio_get_protocol_features, +}; + +static void register_vhost_gpio_test(void) +{ + QOSGraphTestOptions opts =3D { + .before =3D vhost_user_test_setup, + .subprocess =3D true, + .arg =3D &g_vu_gpio_ops, + }; + + qemu_add_opts(&qemu_chardev_opts); + + qos_add_test("read-guest-mem/memfile", + "vhost-user-gpio", test_read_guest_mem, &opts); +} +libqos_init(register_vhost_gpio_test); diff --git a/MAINTAINERS b/MAINTAINERS index bb526df674..a8a94da424 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2104,6 +2104,7 @@ R: Viresh Kumar S: Maintained F: hw/virtio/vhost-user-gpio* F: include/hw/virtio/vhost-user-gpio.h +F: tests/qtest/libqos/virtio-gpio.* =20 virtio-crypto M: Gonglei diff --git a/tests/qtest/libqos/meson.build b/tests/qtest/libqos/meson.build index fd5d6e5ae1..9dc815ddd4 100644 --- a/tests/qtest/libqos/meson.build +++ b/tests/qtest/libqos/meson.build @@ -45,6 +45,7 @@ libqos_srcs =3D files( 'virtio-scsi.c', 'virtio-serial.c', 'virtio-iommu.c', + 'virtio-gpio.c', 'generic-pcihost.c', =20 # qgraph machines: --=20 2.30.2