From patchwork Tue Aug 2 09:49:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 594852 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp4201613maz; Tue, 2 Aug 2022 03:03:16 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uMIpDuzWZf9CXfqu0sqZAqof/IPAZv+16uAhG5ao5Z4fYH+LjVjLS6sJ6SyaB4H6XaucYL X-Received: by 2002:a05:620a:2809:b0:6b6:5909:fca with SMTP id f9-20020a05620a280900b006b659090fcamr14973692qkp.607.1659434596667; Tue, 02 Aug 2022 03:03:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659434596; cv=none; d=google.com; s=arc-20160816; b=f7FJkuBoq8JRgxfm+ODfQYQO9g/LtHhXRXFt9NCWEQizG0zzYoPyUtwXbXimiXWnRz 9O0C1EPmgUuFUmdLTzMY93Bn/Fud1KHm/m1d2LcQQPqR1tectGkyiiEuQFY9KDQe/MCo LzYumc2FrOuyP3ghn3wwBp9QlT3rxU8DTws+cnWXSidB+QtzXtbVctvV433EMjAEJ6zr zd4lq1lM7deMaP+/4hzbv/6IfawOqaUsVQNnRiiHPaZqRewAhBi1usMjRWMtsqKhxcFe FvS9GFGrTap3jZkpEqkAjB5ef5ru0p2UGGPYxQTL20kvR7Y4fmj/b6cAomYSROGwfVXf A6vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WTel/fQ7Gj1d2ni3sryAwF0T/iksivK0kIXjy8395Xc=; b=ZSS84aH5n2t8QR8larl6kGkPNuNii1xksmqWqTTMLSUFCDs1Oem1E+sx4Dd1NWoBs2 ShpS8RLFSjTgRGugwVsjK2l53td4XoyQcvjsTIuGDvwC4YgT4Ha0hxNDya5UcqNGlBRD WnAaAuXFE6YW1CMqE3v7N3vuuXZDVqJItSGhDcMPB1xzOcq2mzP2GmTk8GMfTag+MamJ HZidLFn9NzUN+Av3QyRu42GEuQ9c7z2UWzQm3NgXFXn0VJtEeQXWzDicr6ztsClXTx6W 7HHhopuSWOuFQL2ZMe10xEajeITDyR2VygdZKh2eDZV0cK6Q1zq63aZexajZLLjh+JtK VTjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DHW+C+RY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r22-20020a05620a299600b006b8973f3736si5254452qkp.629.2022.08.02.03.03.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Aug 2022 03:03:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DHW+C+RY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:43284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIok8-00059O-6r for patch@linaro.org; Tue, 02 Aug 2022 06:03:16 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée Message-Id: <20220726192150.2435175-7-alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daudé --- 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 = features & (0x1ULL << VHOST_F_LOG_ALL); - 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); } From patchwork Tue Aug 2 09:49:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 594844 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp4196163maz; Tue, 2 Aug 2022 02:53:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR4oNqfPxuwlcuGgNqtPds4KeapT0Btkvy+EqSXf4scau/jugJxOZqWp04DDAnGPLJez3ARY X-Received: by 2002:a05:6214:519b:b0:473:1c23:f871 with SMTP id kl27-20020a056214519b00b004731c23f871mr17337724qvb.28.1659434036556; Tue, 02 Aug 2022 02:53:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659434036; cv=none; d=google.com; s=arc-20160816; b=DcBwTCJk5qO0SISvNto7zHPfY+3TAy5dTWk5RPa3HEalTO0ohkAELLhj3YIqVtcBoe gFT+I0YRMYZsUgr89EfRWGjkx7Hy2eCggR0KE2gjDMxkicVLbgj8xuP/O0//2EV3x9EH ApXf3f2PR0v3uB/swIZSJ5GsfEzSxh8mAAyziFZo7OeFVILxUOiOUNlL9gG9VF3OQwjB W8kglEEN5+Hng9BK7F9GfMnx0nroNz0/NFhy2NZQ1F0tA4KXLpWs2GncwwTFK6KLn058 +bFw2gPXAdHgg5iDiRMtGDcxKVFpp9/+BCnxpw1AIquGOsgPjvpMnc6688vtejzVg7EX tRCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=s3nGxeo53LwaMo+sziN/l2Vq3ARUUV/BFGaJ8lB68So=; b=B8iOa6aXWVQpBGS3FjLnvA31LoiZM984XVQGPXu4A+6acpDkkbmtscS1Yx/fbpBkTn sqIrzQYLMiMdQWQIXZDEGuMxuqsQN6k3n6vaHqTq+Ax7Cdbrbb4kSH8x3NsnyK4XCW9V iQpNwCLOVRcEBUrpu2g5Sv+C/P9As7HFfK6kd/DB9CdXxpnyIUkHLy0Kuz+Cec2H1Po5 Yo+75q8EHgf8WoEsrWFtB9+cK0DnCIk+N9hfbZw6g+bCWimxSf7dVo0fcJ7KXpTwS6ns a2ryxELx8xVKjFpbZ29VNPYzDtSOF8MbqB+3d+kFBlIaq1FH15ad46wqCtWaxqevn+vH 8cMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nuKTgJ7z; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e8-20020a0562140d8800b0047482b9c0d6si7687930qve.247.2022.08.02.02.53.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Aug 2022 02:53:56 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nuKTgJ7z; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIob6-00075S-3s for patch@linaro.org; Tue, 02 Aug 2022 05:53:56 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée Message-Id: <20220726192150.2435175-8-alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daudé --- 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_dev *dev, uint64_t size) dev->log_size = size; } -static int vhost_dev_has_iommu(struct vhost_dev *dev) +static bool vhost_dev_has_iommu(struct vhost_dev *dev) { VirtIODevice *vdev = dev->vdev; @@ -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; + } } static void *vhost_memory_map(struct vhost_dev *dev, hwaddr addr, From patchwork Tue Aug 2 09:49:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 594843 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp4196079maz; Tue, 2 Aug 2022 02:53:42 -0700 (PDT) X-Google-Smtp-Source: AA6agR4TTj/CuBtX0i33MNIjMhF8d6wJWaNjivcjJjFi2U3rxtV0/qnqQ1xmreCjvFYpLJ+PTwmL X-Received: by 2002:a05:6214:2aa7:b0:474:62ce:3e70 with SMTP id js7-20020a0562142aa700b0047462ce3e70mr17736606qvb.79.1659434022270; Tue, 02 Aug 2022 02:53:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659434022; cv=none; d=google.com; s=arc-20160816; b=aIFMs6isoFJMJ8LaUZlONhn3+o3SZSAvFeVRRxkZYga9xzt/qrafrFcKJ/qHd74eoU 7BaHeH0YFXj9sV8UXBjNEAoRfiOp7ykn3/DaJR4znLrt4n6OLUer7VhLfHePLFWbsZL+ kaeESDmPeLnkMUtrh8uSfYjtb+LnweEuEq5FRTCImEU12bHvZ6egnA/WnDYiNwmriw0m hJQ7VzYpaeLRhaBtpseh1WG8KH1bEig61MB8OBK7oGB7V/b5AAGYdnLVF3KlSW3Kmric N6HJvJbFOqxrsQV00742cg6IZVPLUfEaTLtBKNrF6Jqv7KJla+Cki4YQXonsFV2ZrAbx 76QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qn9sIffAzV9IF+yjjzIzifr78tit+1ZOBIt0UyqO2Rk=; b=xfwjWMWPsaE+sO1vZEVzlkG+I15gBhEKT3FuKOVQeodt71SS87PnvSrKMQ520Rq2os ggKH8B9PeuetjwjjXzEAOj6Yk44Qe/gpKdrM5RefYtfz4EnWxt+JBKSS+tnAvk08pZeQ h2nmGmAB3Dhmtaa+qN0xDYoOt1UZnSgUUi5kkUCWvpoqX591sQ5KwrYmLYSfl5Okko++ tcmz1rnI8ckqmgB3taLb87l9HWXf/VqiWN3zr/VImtu5oAB6xYvNu3ZJhK5EUh5S+F44 cOr+KmR9Ommry0XImlTOBhHc0AefZKyNllnNeMuXgS1L7r8cGZVBI/GagOHc5NvxMGkd 7Lsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=efF1G23J; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id dt35-20020a05620a47a300b006b5d3382524si8505696qkb.79.2022.08.02.02.53.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Aug 2022 02:53:42 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=efF1G23J; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49070 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIoar-0006dM-RN for patch@linaro.org; Tue, 02 Aug 2022 05:53:41 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée 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) nvqs = MIN(nvqs, VIRTIO_QUEUE_MAX); - /* 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 == proxy->nvqs_with_notifiers); proxy->nvqs_with_notifiers = nvqs; From patchwork Tue Aug 2 09:49:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 594846 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp4196901maz; Tue, 2 Aug 2022 02:55:29 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vYtwGIJLEQjFsHHg3Vb0NmUGdSe6NPuzBJUYqPyJvJUyVc7l6rbq5hodZv7Jz+i9TcxS7C X-Received: by 2002:a05:620a:17a4:b0:6b6:7ef7:643 with SMTP id ay36-20020a05620a17a400b006b67ef70643mr15002508qkb.759.1659434129467; Tue, 02 Aug 2022 02:55:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659434129; cv=none; d=google.com; s=arc-20160816; b=Bwc8rktR3qz38xbPmIgZOj6ikHjT9PSkeS4fZaTuhiJHwaFknjMh3sF2dww9Bm6q3m 6+ASWUdN3w5QW8RSkhQJb4GmcQG/GpSlZSd1lWf6wniEipkz8aUuV/OFPECEFPdi+qpL yWauNHV/X+ux3pRIZW50w/mQosrivZzeGjATDMTnZaSnn1HH6MrkzT8CejcAgcsMG75M tYaQJoPMWCbGDv/JP68piPm/3fZ6rT7UfK0pwiiSEjHheLyDImxD850Hjov0cwBvbsN5 cjBBxU/irjZnAsjE6dMtmIfijfM8G47auyMwPdEgDBOq61j00ig601RQSkHNj6xyulnK 81rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5cs2obCibuFrGV6ezAp7TXix+CRt2n51MrtUoaGrvvI=; b=0oEhw7YbsxY9pP/lvDrVaX3Dh71+hFYln5Ratt79DMWj8VfMjwqQ0FQDWjinEcd6b2 LYQLvi7zgSI8dhszlYCRsJYe8WdBuvwQFGF/zdrzIle98gNxDx7+SUSzZsuZ8jQfBA5T +wFr08MgQ7QOwDrUlsW08iAw4XUW1dGh/XnHjXCnLtsoNTCR61+vjFRIwIjEQUlARWD3 h20Ab8+4IlqqHAW1jW6T+QygnOGKSO32SYULYrI1B1yNu66nO1A2N1CmssTB5pPhvdzD jEwq7EMneH4VEfFKubHrzamXxOOZxMMQ3Sz815+qu4NhT2se04xAbqCdkXgLVlodwLFv r0Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cECP5XUY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f11-20020a0562141d2b00b00474182e2352si1477022qvd.305.2022.08.02.02.55.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Aug 2022 02:55:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cECP5XUY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:57104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIocb-0003g8-3A for patch@linaro.org; Tue, 02 Aug 2022 05:55:29 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée 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; } + trace_vhost_user_read(msg->hdr.request, msg->hdr.flags); + return 0; } @@ -544,8 +546,6 @@ static int vhost_user_set_log_base(struct vhost_dev *dev, uint64_t base, } } - trace_vhost_user_read(msg.hdr.request, msg.hdr.flags); - return 0; } From patchwork Tue Aug 2 09:49:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 594848 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp4198081maz; Tue, 2 Aug 2022 02:58:13 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sh+aRvb8vHSKoR+iveZu9MxCwMfO20f4XewTCtbmTZ45Z3T2M+s4DXnxV1stPu6eqCMEUe X-Received: by 2002:a05:622a:1453:b0:31f:4542:db80 with SMTP id v19-20020a05622a145300b0031f4542db80mr17605192qtx.570.1659434293487; Tue, 02 Aug 2022 02:58:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659434293; cv=none; d=google.com; s=arc-20160816; b=EphObsGTqP9mp5xWxBmzK0zAwvLaZBLPuzga0sKUcCXgtwsjUbbZMS5ZlL4+nPQgGr 9XbfoYqeFnBfMNifWPJK4fLwVcONLfvGrhIA8mniBq10jai835LXG+aInsBUfDIfzTyl NW7aIbulLBDxIB45SwvkZg07SvLSOq+OOsmNjUjSi1g+ZzQs3Wo57zsRtIQOKEr/a8sR x0jV0ZXCABUuVPZjYqG36pFvrgSLyfU4OKc1cUantFhV0XpG43Jd/a3/ZN4jjmme9iJU zMETlHHYqKYNaWEnbkRh1XTSFDXD7fK414SG5rl6DxlGnbqTBpXXIGnG32CDSbikxZSv xt7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6BvLwU4GMUiq3XaMcxliYSNhOBL1ZkQfbeog0e1G+vA=; b=ye0QikB6rJCtpQWjY3281OS3wDMPuQpQq0z9MykS1Aw91+YHP7HY5lNl53pdmKTxlx bUI5btmPd16uQBYdGNLJtBId1ur9FYvelIMeITIkR6uwBCMsXD67G66qkhjHdW2N3IvC pDvJ4HEYBF0aD2oiMl0F7g48SlZucU1Kj0+i6JM5ZnlmdwEvWRFlHaybPce9yDYzlYcw KCR8xWxP0qyHDZEoTILbBYr/4u0ZkdE97z2/B/HqfOuyOMOkLMp1hIoslF3jW7CPl5RG WsqASHN71//aj8OtsYkGzGcZTsfKF4d5TCQ8wfvg4REYinW0hjg+u6Yembxq/lVHJNQX I/hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g5KXnNSg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h11-20020a0562140dab00b0047472123cd2si9683126qvh.475.2022.08.02.02.58.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Aug 2022 02:58:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g5KXnNSg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIofF-0007ra-2b for patch@linaro.org; Tue, 02 Aug 2022 05:58:13 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée --- 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" -/* 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 #define VIRTIO_LEGACY_FEATURES ((0x1ULL << VIRTIO_F_BAD_FEATURE) | \ From patchwork Tue Aug 2 09:49:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 594849 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp4198255maz; Tue, 2 Aug 2022 02:58:36 -0700 (PDT) X-Google-Smtp-Source: AA6agR5BZcyjJOzeqWAxk/gftJGpC498fD6LfgmnEJxEIRdgVrg8440DjJtVkOYeHR4NPEQNJIHH X-Received: by 2002:a05:6214:2307:b0:46e:5fbc:3c30 with SMTP id gc7-20020a056214230700b0046e5fbc3c30mr17173771qvb.21.1659434316363; Tue, 02 Aug 2022 02:58:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659434316; cv=none; d=google.com; s=arc-20160816; b=nbTFjCZBK9ItsE0DAj78mpvSm5qRl01kt3B5t17UyuRzB5/pPZIJu1v6a/4es5yhT8 hVFJmCgjGamLmhQuZeZxCRRrsXKGII3OpnM1EXCJ3JLqWoQcPrLuF0EFCg3RCTIBiIXc UrczDWys+ltJpjQdrjvOsLBO+kHDoM4lhXRTgwCLQtEmtaPh15Y5l+99AkFwz+N0YYOd LflyaLCaY9JdIEa6B9+QF5BAPWm9Se5nGY/hKh0kb13ZQ2SmZwDFQbW4fSMweHw0bEo0 V1Bi8NUnV47ccnejQJ6R4/J0Dm5zLe42wYT7XNgMlaUBOmkALS+mU389pbsr3Z0TgWQG 7m+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=b2j/kb8GdcOCxPJdxE8uUIOafIPdVMpQHMJ+EKtT808=; b=GnGOAYEBCsJjbiSl/hJaxn0EyTij9DQ3ypUOp0wYM3MrN0oi5Aho4z1z4lJBnTbrvY wt7KSuYLymkxQRK1rsd9VLslrgv5kpjniJHCpe/Ka7LqcKVI628JF69z/C7texfSHVev fhZ9CLxit0gsfAVB10XltpQlaViUeWt01jd0Ub+sJPQMyeu3CYe4ztVVy2OFnCM2TITb Ap+beYSxHrDdyVvd7oC+zWKXJ86r5K5wtocGJxftn4xL8vavcZVreXxd2qBK2wuSx9t4 rnysHNbrWtmzM/BOlbjNSkgVOKVX4VAN/RIyUX9I5iYkPFVoCYGySUxqjR1O30rBxmBU jj3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VUtWBMO0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id fn4-20020ad45d64000000b00474730398cbsi7941412qvb.179.2022.08.02.02.58.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Aug 2022 02:58:36 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VUtWBMO0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:35778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIofa-0008Qm-BN for patch@linaro.org; Tue, 02 Aug 2022 05:58:34 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée Acked-by: Jason Wang Reviewed-by: Philippe Mathieu-Daudé --- 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; From patchwork Tue Aug 2 09:49:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 594842 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp4195870maz; Tue, 2 Aug 2022 02:53:16 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tNS1Yz58aPx1wF5GGOjNs1UxOER3BAKXk+MzxJgME0+/cDd2tCqJnK2Ys0jk8bSO1fosiw X-Received: by 2002:a05:622a:1194:b0:31f:3909:4e66 with SMTP id m20-20020a05622a119400b0031f39094e66mr17764940qtk.305.1659433996559; Tue, 02 Aug 2022 02:53:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659433996; cv=none; d=google.com; s=arc-20160816; b=eezqBjC2hi/cblfp9kbdmb70/zrz+Pc0aB23h9OTOPljtjnTHhiRneMX8Tys6dl3Om sR25DZa9i/GFklHxelSNfQ58axsHS7EoZMD0GND1g4tjMUgQ16/fRYRdCe8RDgmQ9Zcj p91ODNg5o5IZbfHrc8VnsxuU9rkduS/KIYch2+XgDFCfJRgA8yFnYVkiNs8rjeWhQuzw C/CgeBX/lcrAKikbNfcHjo6/V9SpltgfgwnYKDLqHU7KIcbA4HRrPfXwd1Bj+5jaJhd1 iJny3NmnSIEHDm2Is6CnUS2xYq3lVQWsrjVl1BKKcM6mDFR4Glmn7zWkXqU6p+b9w3Ub UkSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KjbLNdi3E1apNFwTGial5s5eMkKbrprSc8sGCh0PAC4=; b=oiSok9xv2ov271DaADXqo/kLkMpbfb3etUA3BRFEpLVznjuon26jDpPBu3NSy3nwxo aHB+Ad7KQyv55wlyWV36hBS1awYmPlkw9TD13eXR3YSSs0BO/RGBVYJcBoN4Zb//LE2W zTWl8xocs5iGb3f6gDQsyYaSAgZGcFz8P01Faux+MTjHw/oWJz1zQW4d9t1s4W1zqx60 DYi5qMXkpXceucsxFgBaNJNRxzWT/sGWVw0L8UOfdijXQfwywExfAIwrje1wlK0LsIuS 5dS2YEDfTZH3LwxB2lJQOAg161ziz2jbbIXPpFqwreZ7VzGyBdtr2IzdgliZ+U7dEwX5 JIMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QEtzfjEH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a27-20020ac8611b000000b0031f40346b77si8809417qtm.707.2022.08.02.02.53.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Aug 2022 02:53:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QEtzfjEH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIoaS-0005ul-5A for patch@linaro.org; Tue, 02 Aug 2022 05:53:16 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alex Bennée Acked-by: Jason Wang Reviewed-by: Philippe Mathieu-Daudé --- 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; #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 { 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; From patchwork Tue Aug 2 09:49:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 594851 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp4201411maz; Tue, 2 Aug 2022 03:03:02 -0700 (PDT) X-Google-Smtp-Source: AGRyM1suHz+JZiCz4AuWRa2rXEMl6/wvUYF7ROQOTk4rzZNCXhDACRgelr1IeEm3Vc/MOc3byw0O X-Received: by 2002:a37:ad12:0:b0:6b8:62a6:c876 with SMTP id f18-20020a37ad12000000b006b862a6c876mr13817038qkm.718.1659434581979; Tue, 02 Aug 2022 03:03:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659434581; cv=none; d=google.com; s=arc-20160816; b=IB78y0trnNepND5XK3KsLzyDefWto8ykL374mu5JGUiFmiPsh/6BxHFhrRnThlz5Xw H10NzcIM1RDGqaNnkLEK8/P4bz148sXN5ZGRH266z1hIe426avjZ7qaNX8SdDP3TRYhV KXqIl4J/iphAkIjxR4j2ewW89H5X485vL1RtBfmCZHdOH1PFyPqqUd9cG3loZEqdyWEa Dzn0ONlhvpiiRaYO5CNVXsOXlWgGzR1VdPx1CU6x8Nq1lZTLbJRin9AxtDi1EONLKVgq y2cSM7iya89qsubDOKbTOWCenKVCmcjxAMuOp8CVIakfK4rKhEq1riq1E2LXDMFTpVMj 8pGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FCj/56VzmS3/60OSoLTpgej5xNapP0emctIC1iwkYIU=; b=eQk40QroxszPKTDIQCFY80Spn+f3dIl637Qlc81+0/paA4RK4rzHoJ7AVaJW0eutaI gzN9wZbK9ML20km0kMuyNgZ8hiXL3bMjye2xEX9L6Dj8tOkonpXdARpsUI0mVnaQgW3N OuujAnQPudJdnKNgHT1qOQWMfToqHmGsXz3wyT9t7ARCoHzgOdAzxIPOTxGIcSvCmzjR HH3TxORFcC13AGznX54rhZkMESTrA7b4B5lGiVMKbPciMvb+ZKTOXc3uTBABu16rfYgG 7jKn9gk1fJHmZzen9Sh1Gh4xoRbEN30SAvwr94S6zKwC6NCyNHa/c2nfzt5BURmhQEab OCqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bFxJ3qwO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e15-20020a0562141d0f00b0047355815894si9017103qvd.229.2022.08.02.03.03.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Aug 2022 03:03:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bFxJ3qwO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIojt-0004RH-Gv for patch@linaro.org; Tue, 02 Aug 2022 06:03:01 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée 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) feature bit!\n", + __func__, vdev->name); + } + ret = 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. */ From patchwork Tue Aug 2 09:49:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 594845 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp4196812maz; Tue, 2 Aug 2022 02:55:17 -0700 (PDT) X-Google-Smtp-Source: AGRyM1slw0bd+e8UOaa7Qxxkvis/uuVnp75n2DkdaVwJQI1nmfFmgMlfCslkLlCnPT/7CO/cffqc X-Received: by 2002:a05:620a:2f8:b0:6b5:e8a2:cf3d with SMTP id a24-20020a05620a02f800b006b5e8a2cf3dmr13913711qko.447.1659434117460; Tue, 02 Aug 2022 02:55:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659434117; cv=none; d=google.com; s=arc-20160816; b=yTBYWcK13A8lICxR82T1mdTVSwqydhxsanRXQUQ4t09sUGXW0+2PA+ouOzu1IUYHjM WvgEaMlhOzoWd1UZGb0fmCWGbZ1vCyDOrg7e4sSOKFvBACvOeZgnZFObp3F3sKsfdO7j lvuMOyVPs3LNUajkOaR3GMgg8Jw4swsmjI/S34PrQCxjxaTBav5NeXsaO/UGj4Fa3qBw hG6Ff3Ixf9M0F93W7JkgSdpzDtC4hYwzzmw6RsPkpHGYORDLPhWtAvHpfr1d1F/6S4W9 d3Syx8mNoA1cZbkeYrZ/5Sa/EiGJyfL4eLuxEp87a94W78gNthUohvzTdNOxjEJGHyoW MShw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=H/ZcxJebFvV+fJPCaMkPj2jiRtkMtcjbXvy3+aTz3aU=; b=WWdEB4SOlHXIrk4c578mbbVB+RyhQdP2VXpK/Lxu986X46fNAYheVA02lSIxYEHmBr leZuzDc2Yydzc+RlcEWxd8lIXkaBj21D5vyGRXUzvfLZJ7pRzd3N3+wjkIfBR1kAFsZh OZESgRffE2snbNmwJRf4UnjLnyD2OcLQ3VK0q5k3RI5ST1heBOL43k8r5Cef6Rf/tr/t eaj3eeQQ/XuxhhkVYbSBiFpYK9D+xkKH8PgDTc+9VQOqG/y5g74o+iH3VX5euo4yadPt J132gtZmUhRz71bwOvnkChqbyCQ2hXgm1hAPBvTHQq6/2cFtV35AH6dTjgvxS35TTzkb 5prw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pu55oEKe; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h3-20020a37b703000000b006b5fd409bfdsi7278013qkf.387.2022.08.02.02.55.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Aug 2022 02:55:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pu55oEKe; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:56348 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIocP-0003B3-2s for patch@linaro.org; Tue, 02 Aug 2022 05:55:17 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" These are useful for tracing the lifetime of vhost-user connections. Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé --- 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; + trace_vhost_dev_cleanup(hdev); + for (i = 0; i < hdev->nvqs; ++i) { vhost_virtqueue_cleanup(hdev->vqs + i); } @@ -1783,6 +1785,8 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev) /* should only be called after backend is connected */ assert(hdev->vhost_ops); + trace_vhost_dev_start(hdev, vdev->name); + vdev->vhost_started = true; hdev->started = true; hdev->vdev = vdev; @@ -1869,6 +1873,8 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev) /* should only be called after backend is connected */ assert(hdev->vhost_ops); + 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" + # vhost-user.c vhost_user_postcopy_end_entry(void) "" From patchwork Tue Aug 2 09:49:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 594847 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp4196953maz; Tue, 2 Aug 2022 02:55:34 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vfGVk6vTa21qR6UyCZiTfV4PS73dTSU1bCrzfX4C8BWfTG3hFDVStT12RJ5aFvSWiJV4l8 X-Received: by 2002:ac8:5c13:0:b0:320:f3e2:ccb6 with SMTP id i19-20020ac85c13000000b00320f3e2ccb6mr14642880qti.246.1659434133919; Tue, 02 Aug 2022 02:55:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659434133; cv=none; d=google.com; s=arc-20160816; b=Xrfacthznu/C3P/ftLWYD6UgpERkvE+PH2mgptAcU7HPVOMLvdXHQhly+Ih0SNhdnE EhMImJ+E6UNZTUAqcLhnUwdcW+n35qU10TvPEstD3i7MXc1tH985epuDy4HHeQArVd5j 735+IMBPn8L0cvi6EtqfQubOecOERiNqeQxG66m6A3ZqNtt7QZ0kQkONEUaFxleKxkL4 9V5Io4dMhYcQBTA4xfwX9DcziRwJI5a1OJdXMAENvKcTCdYXGg2CF/jBKIT8NxhFSjIp R9VWq+gchimCtlmtaRThguZSexcUr8SrTB4oif4MT1ZLe/UyqPjA17rSGdrw8SBLFk/L S5bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=x448FCGsB6jl4t/PEZTiuqAxlBX+i+OighRCNvx3IrY=; b=NisDS/TsISR3kPlQbqeXN/8JICa7eXXT+Grew2x3JHqpFeHuCV1SXvxnWwDvxZy83n zniSQWNDbjkwfJCGIlRvpJ4xaWdUAZiky9GTXeaLklZAOijRRBBrzcV7HD21D5GtfU2M KqM2TtabfZlpx9td3kPGbKkeo60Jg22zWNbQOll5KY1jCSXl7wWJvFgXRD3LZb+xjxh/ yHQeuc6Yqs6d0tubl/HgvsD0bZsfSVznPoXg1DKuewA8TxQAND588FmV72AYdh+h4A4u p754QopbfiF3EEIop713i1sItYTN+ncsaSgq2enlp1p47YOed+5CkL7nEEOg0ElvcfaJ ozHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a2o70i6o; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ay15-20020a05620a178f00b006b67d1bc131si8683357qkb.691.2022.08.02.02.55.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Aug 2022 02:55:33 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a2o70i6o; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:57590 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIocf-00040M-D0 for patch@linaro.org; Tue, 02 Aug 2022 05:55:33 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée --- 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; } + if (!vdev->vm_running) { + return false; + } + return status & VIRTIO_CONFIG_S_DRIVER_OK; } 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 = VHOST_USER_FS(vdev); - bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; - - if (!vdev->vm_running) { - should_start = false; - } + bool should_start = virtio_device_started(vdev, status); if (fs->vhost_dev.started == 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 = VHOST_USER_I2C(vdev); - bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; - - if (!vdev->vm_running) { - should_start = false; - } + bool should_start = virtio_device_started(vdev, status); if (i2c->vhost_dev.started == 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 = VHOST_USER_RNG(vdev); - bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; - - if (!vdev->vm_running) { - should_start = false; - } + bool should_start = virtio_device_started(vdev, status); if (rng->vhost_dev.started == 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 = { static void vuv_set_status(VirtIODevice *vdev, uint8_t status) { VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev); - bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; - - if (!vdev->vm_running) { - should_start = false; - } + bool should_start = virtio_device_started(vdev, status); if (vvc->vhost_dev.started == 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, int start) static void vhost_vsock_set_status(VirtIODevice *vdev, uint8_t status) { VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev); - bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; + bool should_start = virtio_device_started(vdev, status); int ret; - if (!vdev->vm_running) { - should_start = false; - } - if (vvc->vhost_dev.started == should_start) { return; } From patchwork Tue Aug 2 09:49:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 594859 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp4214189maz; Tue, 2 Aug 2022 03:22:58 -0700 (PDT) X-Google-Smtp-Source: AA6agR4hLpYxv0jymtLwlKqYQyuk8xWywcR1EDWf4pqKd+TwLhkdZ8tqcSz1J5yHSmulEBW4M8jF X-Received: by 2002:a05:620a:46a4:b0:6b8:b7a4:42da with SMTP id bq36-20020a05620a46a400b006b8b7a442damr4604555qkb.714.1659435777903; Tue, 02 Aug 2022 03:22:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659435777; cv=none; d=google.com; s=arc-20160816; b=v0XgeZ0D64zqfHb5KYduXddA6/kTDHEULfGQY/HxQJ1EqHUyn810LACi1g9cksimVx UBsnj7MoNOxSFjnQ9RIKzbuSnT63dEHKVitB8zEJoKNoVvqy7sdYpIhjP/GnAvA/CaJc atFHGvQG78bMKi/B+5Kxmw8LwxG6MxmZYTwU4jSjdWI3IzI4Tbdqw3IIaDTOgwYLJqa+ gOMUzHo2a09+PJjUzvD5YoCYmXJXvprWcZkYrq99jGdtmAdPy3MKsL1OAskVYjPz9ni7 3N9IukAqy3NvkK5oknvSHWjLWXyXTC5dicWscaGn5yr4lmwNZM5DcSMCQKEa0//YX5fH aXWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BeukRfDDjs+xL5noIXV/lsICwMCkD6JOsmbjcLzfdS8=; b=Xx4WRVEJjFcvnMzmYydq2neNT9cWk6l7JF/oHyMKxBvl/ExldnZA8S5Eu8uf6I7874 ERGeI2BIOcsJQKq6HaB0GdbWAlSp0N7PD9iEPc/iHgW2Q++xn4SwoG4hR9XTCZKvSBL/ gjs8dKGFoVcgqYk56n5lrT6+YsAkl97pWCc/399pqIMdeeLNa44/x5g1bI5710rBoCXx 5jcYljWolHAK8pdwKDrHfcn9HC1Wg+kUpsEQZkqthUJxbm3bzjtYPUGRWsuqTRzrvniK a/pVi4B0XBe4yfdv0NmkjYnlUMsJvFETrz54XoFywn/v9u6LDmYjwsZpsOQNzcbaCujJ +38Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CUwEGBL5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o7-20020a05620a2a0700b006b598034977si9958054qkp.333.2022.08.02.03.22.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Aug 2022 03:22:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CUwEGBL5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42936 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIp3B-0007X3-Au for patch@linaro.org; Tue, 02 Aug 2022 06:22:57 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée 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 *vdev); +/** + * 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 *vdev, uint8_t status) return; } - if (s->dev.started == should_start) { + if (vhost_dev_is_started(&s->dev) == should_start) { return; } @@ -286,7 +286,7 @@ static void vhost_user_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq) return; } - if (s->dev.started) { + if (vhost_dev_is_started(&s->dev)) { return; } @@ -415,6 +415,12 @@ static void vhost_user_blk_event(void *opaque, QEMUChrEvent event) * the vhost migration code. If disconnect was caught there is an * option for the general vhost code to get the dev state without * 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 = 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, uint8_t val) start = false; } - if (vsc->dev.started == start) { + if (vhost_dev_is_started(&vsc->dev) == start) { return; } @@ -147,7 +147,7 @@ static int vhost_scsi_pre_save(void *opaque) /* 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)); 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 = VHOST_SCSI_COMMON(s); bool start = (status & VIRTIO_CONFIG_S_DRIVER_OK) && vdev->vm_running; - if (vsc->dev.started == start) { + if (vhost_dev_is_started(&vsc->dev) == start) { return; } 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 = VHOST_USER_FS(vdev); bool should_start = virtio_device_started(vdev, status); - if (fs->vhost_dev.started == should_start) { + if (vhost_dev_is_started(&fs->vhost_dev) == should_start) { return; } 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 = VHOST_USER_I2C(vdev); bool should_start = virtio_device_started(vdev, status); - if (i2c->vhost_dev.started == should_start) { + if (vhost_dev_is_started(&i2c->vhost_dev) == should_start) { return; } @@ -174,7 +174,7 @@ static void vu_i2c_disconnect(DeviceState *dev) } i2c->connected = false; - 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 = VHOST_USER_RNG(vdev); bool should_start = virtio_device_started(vdev, status); - if (rng->vhost_dev.started == should_start) { + if (vhost_dev_is_started(&rng->vhost_dev) == should_start) { return; } @@ -160,7 +160,7 @@ static void vu_rng_disconnect(DeviceState *dev) rng->connected = false; - 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 status) VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev); bool should_start = virtio_device_started(vdev, status); - if (vvc->vhost_dev.started == should_start) { + if (vhost_dev_is_started(&vvc->vhost_dev) == should_start) { return; } 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)); 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, uint8_t status) bool should_start = virtio_device_started(vdev, status); int ret; - if (vvc->vhost_dev.started == should_start) { + if (vhost_dev_is_started(&vvc->vhost_dev) == should_start) { return; } From patchwork Tue Aug 2 09:50:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 594857 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp4210151maz; Tue, 2 Aug 2022 03:16:05 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vEBO8jj6+YPcq2DOTVqdjtoETrp1TQjwAhUYpeEQOZJmGK8+EZlnNcwVzAg0YHdPl5ir9V X-Received: by 2002:a05:620a:4381:b0:6b5:da97:fe0f with SMTP id a1-20020a05620a438100b006b5da97fe0fmr14529144qkp.84.1659435365731; Tue, 02 Aug 2022 03:16:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659435365; cv=none; d=google.com; s=arc-20160816; b=VN2a5H/E8HzYdRZ1wFdYi7/vyLtwaO4fIN1Dsz0S+muRpWcYDSdMrC5VfE7yxNJavm Q6z28MDfnNTQeder7CguW5/TJvxMX8dkubQbY51N5UfThtNSMb+djv3wOCBZ0f4pZp90 bYyyziKq8fQDn5oe91cKfNsLsXPk9L1JruDE0Sze7JD9NzmAcwYonJZaNc1+FpV0v8hA Ic2U3B848GC9CDjaaYrLvPKimGv9evh7lcp/npjlqBM+O7zmMZq2EuNvbVFs1wDnA7Rw cchNjS+m3x+mN16vDNeOjI0hovL9vZ+RuJqgfAi+0MUl9Cv0o0jxyBOX2kRqjamLZKdO 1fBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dNNg43NsMDARYpRmEIG3YLqVxwvpF0e5jz6j1xR6WgI=; b=bmD38hZp5s+JVKr5sUOkKB1hcb3KzRgFxTcwJKFeYNoEDK9AW73HlrqbHpL7o56rVS S8LVWWP8axCK/EzJftkOd6CW1ZBIHbHzXsniNgEY0NXERf99rwJLu/yjvfRYohcv/iAX ku5O3Rv7SxaUeVC2QxpSIKWQzWWCODL6EiDArSCgUWy0gMHXG1KINEPVWitnSFqo7bln jje79+q0iXJ1FK0rvXGyfCxfQYYii0OM2G9YMa5sJuhhflk9/vWkq27eAlmuohwsfsH5 6ljPUSWhDOpphMLz2P5WU6Jf7wnXfhyBqX5jnWZaVMTP46p9JWD++S1IsPhYsCpzwRjQ 5NuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TTivSCfm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id gw2-20020a0562140f0200b004735e62133fsi8700311qvb.105.2022.08.02.03.16.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Aug 2022 03:16:05 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TTivSCfm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIowX-0001xo-92 for patch@linaro.org; Tue, 02 Aug 2022 06:16:05 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée Message-Id: <5390324a748194a21bc99b1538e19761a8c64092.1641987128.git.viresh.kumar@linaro.org> [AJB: fixes for qtest, tweaks to feature bits] Signed-off-by: Alex Bennée 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_features - 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[] = { + 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 = VHOST_USER_GPIO(vdev); + + memcpy(config, &gpio->config, sizeof(gpio->config)); +} + +static int vu_gpio_config_notifier(struct vhost_dev *dev) +{ + VHostUserGPIO *gpio = 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 = { + .vhost_dev_config_notifier = vu_gpio_config_notifier, +}; + +static int vu_gpio_start(VirtIODevice *vdev) +{ + BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); + VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); + struct vhost_dev *vhost_dev = &gpio->vhost_dev; + int ret, i; + + if (!k->set_guest_notifiers) { + error_report("binding does not support guest notifiers"); + return -ENOSYS; + } + + ret = vhost_dev_enable_notifiers(vhost_dev, vdev); + if (ret < 0) { + error_report("Error enabling host notifiers: %d", ret); + return ret; + } + + ret = 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_features); + + ret = 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 = 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 = vhost_dev->vhost_ops->vhost_set_vring_enable(vhost_dev, true); + if (ret == 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 = VHOST_USER_GPIO(vdev); + BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); + struct vhost_dev *vhost_dev = &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 = 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 = VHOST_USER_GPIO(vdev); + bool should_start = virtio_device_started(vdev, status); + + trace_virtio_gpio_set_status(status); + + if (!gpio->connected) { + return; + } + + if (vhost_dev_is_started(&gpio->vhost_dev) == 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 = 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 = 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 = NULL; + virtio_cleanup(vdev); + vhost_user_cleanup(&gpio->vhost_user); +} + +static int vu_gpio_connect(DeviceState *dev, Error **errp) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); + struct vhost_dev *vhost_dev = &gpio->vhost_dev; + int ret; + + if (gpio->connected) { + return 0; + } + gpio->connected = true; + + vhost_dev_set_config_notifier(vhost_dev, &gpio_ops); + gpio->vhost_user.supports_config = true; + + ret = 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 = VIRTIO_DEVICE(dev); + VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); + + if (!gpio->connected) { + return; + } + gpio->connected = false; + + vu_gpio_stop(vdev); + vhost_dev_cleanup(&gpio->vhost_dev); +} + +static void vu_gpio_event(void *opaque, QEMUChrEvent event) +{ + DeviceState *dev = opaque; + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); + Error *local_err = 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 = &gpio->parent_obj; + DeviceState *dev = &vdev->parent_obj; + struct vhost_dev *vhost_dev = &gpio->vhost_dev; + int ret; + + ret = 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 = vu_gpio_connect(dev, errp); + if (ret < 0) { + qemu_chr_fe_disconnect(&gpio->chardev); + return ret; + } + g_assert(gpio->connected); + + ret = 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 = VIRTIO_DEVICE(dev); + VHostUserGPIO *gpio = 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 = 2; + gpio->command_vq = virtio_add_queue(vdev, 256, vu_gpio_handle_output); + gpio->interrupt_vq = virtio_add_queue(vdev, 256, vu_gpio_handle_output); + gpio->vhost_dev.vqs = g_new0(struct vhost_virtqueue, gpio->vhost_dev.nvqs); + + gpio->connected = false; + + qemu_chr_fe_set_handlers(&gpio->chardev, NULL, NULL, vu_gpio_event, NULL, + dev, NULL, true); + + retries = REALIZE_CONNECTION_RETRIES; + g_assert(!*errp); + do { + if (*errp) { + error_prepend(errp, "Reconnecting after error: "); + error_report_err(*errp); + *errp = NULL; + } + ret = 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 = VIRTIO_DEVICE(dev); + VHostUserGPIO *gpio = 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 = { + .name = "vhost-user-gpio", + .unmigratable = 1, +}; + +static Property vu_gpio_properties[] = { + DEFINE_PROP_CHR("chardev", VHostUserGPIO, chardev), + DEFINE_PROP_END_OF_LIST(), +}; + +static void vu_gpio_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); + + device_class_set_props(dc, vu_gpio_properties); + dc->vmsd = &vu_gpio_vmstate; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); + vdc->realize = vu_gpio_device_realize; + vdc->unrealize = vu_gpio_device_unrealize; + vdc->get_features = vu_gpio_get_features; + vdc->get_config = vu_gpio_get_config; + vdc->set_status = vu_gpio_set_status; + vdc->guest_notifier_mask = vu_gpio_guest_notifier_mask; +} + +static const TypeInfo vu_gpio_info = { + .name = TYPE_VHOST_USER_GPIO, + .parent = TYPE_VIRTIO_DEVICE, + .instance_size = sizeof(VHostUserGPIO), + .class_init = 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/* +vhost-user-gpio +M: Alex Bennée +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-i2c.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c')) +virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-user-gpio.c')) virtio_pci_ss = 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=%" PRIu16 virtio_pmem_flush_request(void) "flush request" virtio_pmem_response(void) "flush response" virtio_pmem_flush_done(int type) "fsync return=%d" + +# virtio-gpio.c +virtio_gpio_start(void) "start" +virtio_gpio_stop(void) "stop" +virtio_gpio_set_status(uint8_t status) "0x%x" From patchwork Tue Aug 2 09:50:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 594856 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp4208461maz; Tue, 2 Aug 2022 03:13:11 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u06QBIwU5YiQNYSDI1/VnpjxniGR7mBX2iWqxQcvkwmo1EC9gBUrCeYeQP256wHa9VQq+G X-Received: by 2002:a05:620a:4310:b0:6ac:f9df:178d with SMTP id u16-20020a05620a431000b006acf9df178dmr15058557qko.773.1659435190894; Tue, 02 Aug 2022 03:13:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659435190; cv=none; d=google.com; s=arc-20160816; b=AOXX2tAdzVSFH998dqXg2/bmAAErYHzgbr8REi+RLx41EwkZjEH2dyjTy5VS7Hep8H AFrktl2zX5CyK4VB6TA+G3PrZ251mzKvmthq3+IP6XxwynT3fNBMbUv6ohURtzH09QFv HrrOGB7yZ8cXsoSS3Fe+397Vp16BoXW1M3WSmkBWAOiEJWUGrV4zm1Hd0y+2wYxAalZZ yY1tdIuEJryGjyW49CBGiEK28qPI53Ck1VXiPJb+coG9Tdbkn3JUjB3/SsMc83uyVNQR 5l4Bv1irPB3pBuqhVgJgMNtO8b649LCIozonJJ8TZ8GP+dyw5MUJf54Qp3ze9VNd9AVr 9pQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UmxR2E4mbxJZdFKpR2RK7UtJOZ7yVasaorcYyzhlbQs=; b=0wWKmm9g65j27GDvpDeMx+m2gI5jbmxa+1Q08BNV3h/aQaAZiw+1eA9hnSnbeLk7Jf DfjYVlWwFMyODE8eweYcfyF4wA+ob6iGNaYSnYX1QwdVdzOqQsT/JGscieQC02+W16wh n2CAHWTsn7xUdFx7kJaqPJDLPKJNdFsjrx9w37a+WkVr30LaXDFrEWvu/zSYkSuquKqw 6MPDvlkpTiV7zqInSLhayLlNEo60+DmNJYpzyeb/rxYs7grNm16gAnqU8yiFC9e5S0v9 k4lpZsxIPf/tkmYBdAQLRZ8DUwM2D9pM9ibcCu9Ns4BIGy8eS3fpLXTBGs2ri95TcDoz H8UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uGRZuCp+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id eq4-20020ad45964000000b00476b2567ddbsi2259133qvb.406.2022.08.02.03.13.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Aug 2022 03:13:10 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uGRZuCp+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:58180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIoti-00074f-F9 for patch@linaro.org; Tue, 02 Aug 2022 06:13:10 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée Message-Id: <5f560cab92d0d789b1c94295ec74b9952907d69d.1641987128.git.viresh.kumar@linaro.org> Signed-off-by: Alex Bennée --- 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-pci.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 = VHOST_USER_GPIO_PCI(vpci_dev); + DeviceState *vdev = DEVICE(&dev->vdev); + + vpci_dev->nvectors = 1; + qdev_realize(vdev, BUS(&vpci_dev->bus), errp); +} + +static void vhost_user_gpio_pci_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass); + PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass); + k->realize = vhost_user_gpio_pci_realize; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); + pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET; + pcidev_k->device_id = 0; /* Set by virtio-pci based on virtio id */ + pcidev_k->revision = 0x00; + pcidev_k->class_id = PCI_CLASS_COMMUNICATION_OTHER; +} + +static void vhost_user_gpio_pci_instance_init(Object *obj) +{ + VHostUserGPIOPCI *dev = 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 = { + .base_name = TYPE_VHOST_USER_GPIO_PCI, + .non_transitional_name = "vhost-user-gpio-pci", + .instance_size = sizeof(VHostUserGPIOPCI), + .instance_init = vhost_user_gpio_pci_instance_init, + .class_init = 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ée 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 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-i2c.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-user-gpio.c')) +virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_GPIO'], if_true: files('vhost-user-gpio-pci.c')) virtio_pci_ss = ss.source_set() virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-pci.c')) From patchwork Tue Aug 2 09:50:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 594853 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp4201703maz; Tue, 2 Aug 2022 03:03:24 -0700 (PDT) X-Google-Smtp-Source: AA6agR4q1D0hpw81hGiYdV+Od1W2bWMMIl8qSPY92XL4XwQzWL7Mtw3ywf1Qy0YMPW+9pDQWYTov X-Received: by 2002:a05:6214:1ccd:b0:46e:7427:2626 with SMTP id g13-20020a0562141ccd00b0046e74272626mr17760587qvd.101.1659434604449; Tue, 02 Aug 2022 03:03:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659434604; cv=none; d=google.com; s=arc-20160816; b=KQ8GrsnntK3RXor5qt8ZjgNiqVfAz7RIEQRr1Efx/CYPP53Gq3iu/XGNuwfK7gOv2Y cpjHP3qVJoULQB7sDVmEmau/3grE+7Cv/OmqSOGAsm7SrhKG5oTe9BNMqFJoE6/NMl66 VLPYvYBf6rMWNpd8p5mT4kuOaGdZS7jZGa4hyiCuiRVbLTK/gYAjMz33UpCyjPmPgj8g KVUWFi+9RU5cSmRpzAQEXxX+M5uKnzE/kQukRcjtDe3W3bTtoUdhMDwHUFDz9Lqe5zTS D1vOTTjoQSafF5hwmMT7unFQ/8jzPBvfJyaF7L6+BaOArJwy4A/Hnq6+N1DtVbf35Fkg XC/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=z6HPjsVGZtO92xLq+sdxQwAMWt569NUcAMZ4ONfdk+E=; b=0AEFkSE+6lSaqoeZqRaMiW5AH7FPNTgwNo9hSylNsG5AXQoAZQvjUDaVl/0p3qZgdm HzFn1wd5+OQ0PzXqRdoGF8QRs3p4YFwFgWqqSYazJiiultXGacRyvju0F0X6WZWlTrDO oQdD6nBTl1VNQbw7SDadyQXxKuiCI1l5vFSCA1kGFrX0L3CozyWDVQWF5HSsw6s9sMso hp27nvBBzISv5YaW8P/zVY0cZjYjZaVujqBBkUfo5nWsE6CJIJ7gWNSFuaB1bDyaUjkP EXB+87nd47pJo7XthpVQJhRM4CnF0JeujR1xXJueLOamlrO8zskOK1iUR7pNVXrdv5xB tRrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ORaO7+qh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bs40-20020a05620a472800b006b8dd12b4b5si179845qkb.300.2022.08.02.03.03.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Aug 2022 03:03:24 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ORaO7+qh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:43566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIokF-0005Lf-UL for patch@linaro.org; Tue, 02 Aug 2022 06:03:24 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée 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 = 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(); } From patchwork Tue Aug 2 09:50:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 594862 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp4218207maz; Tue, 2 Aug 2022 03:30:36 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sPD3CxqMm/hxfS6/4ogadATiN6Ob/1+2zPsfQpZ9ZEsmf4RvYEFGuecSMEwrEy21VSIxPZ X-Received: by 2002:a05:622a:49:b0:31f:27b7:ff54 with SMTP id y9-20020a05622a004900b0031f27b7ff54mr17624945qtw.602.1659436236117; Tue, 02 Aug 2022 03:30:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659436236; cv=none; d=google.com; s=arc-20160816; b=MgI3shlWkg2casx1pZ2rR3dK1mYubjEJ90RY3lrp4RA2KCBbBLkFX1TVt3DErx4g+I y0OE3Op3V1YIBZyOPU69zzoJB6QUuHnPI4ePX3gfKwt/zNcn6QPv5yTJHl41bXxe0tQq tRBqGKNKa1SY+achqe+yDE6nJ9lDFeb1bAcPbJLOZ+bsOW739tM3VrusNp3JoEFpxDks J4Zvsmjmj+SGhSjnJKBSPWPInq5rLZbnVNqPa0nML4c5ASD6JAPXcYfcxu25NwR8JeX6 hHQIYFJ87Z6NXquiBFUe0dgoq/jZCQ+AbMNhUwiz4bcTkFuRktQETEj/OYzJ8wVTZRm4 mqEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=c6gCqIJw8yCV7CUCpwJSaqkLGHMke2sDpgsD4kivFT0=; b=bvoA8sGgAZmPIn4Vj0ylikv9kirZmSgTaoOBRZDR23cl8P0a4zmuysBtwbGJ2aGEVQ XHc9q3LFZ4sxSFmYA/APcc6HyrvAeQOMaHHs2y32yze8fVLPyMAV+PD7Ckf8fDRhBWuF ZrQWCPI8WuA99HGvzFwu1hr+5qx0SCGpM0mVqBXgvLv8RtSD7WG1CeUN1MamMWQaq6Cs HtViZv3s8AF2CoadIGjV8TIvPZKy/KgP6s7fLFo9ZLMKBptdPuGRsXFptYAo5b+VEX54 6GC1WnOhSrDPDJsJKbPsM5PrTbWlPOIbPADBQ+oadyNndrQYKl4sCfMUCHCDpAEuvKNu z37Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=z6InKbnX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bv21-20020a05622a0a1500b0031814e04df1si7762249qtb.162.2022.08.02.03.30.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Aug 2022 03:30:36 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=z6InKbnX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIpAZ-0000pN-Be for patch@linaro.org; Tue, 02 Aug 2022 06:30:35 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Hangs have been observed in the tests and currently we don't timeout if a subprocess hangs. Rectify that. Signed-off-by: Alex Bennée Reviewed-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé --- 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 = 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(); From patchwork Tue Aug 2 09:50:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 594858 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp4211243maz; Tue, 2 Aug 2022 03:17:57 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tw/ASpDL9zp9xqhgapJaq3fX771i0y4eH8xrSkp0irqGhu1re9j8u2nNhdLQVcOaf5boQW X-Received: by 2002:ac8:5ac2:0:b0:31f:a8f:d4c5 with SMTP id d2-20020ac85ac2000000b0031f0a8fd4c5mr17483363qtd.642.1659435477431; Tue, 02 Aug 2022 03:17:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659435477; cv=none; d=google.com; s=arc-20160816; b=0C6CWRTO7+gMmKj4oKk97ly6k/qowSRjK2mBr+Q6jFU5/WB3B+abjInT4zZDN8VDv9 cnJ/wt6pEqmK7z3XkBUw8bxmtX9bl0CLDMp7jV3POEkPMWW+aXacTOk4xIH1AWskaXce bWQ5u4DPQTHCtE1ldvMr8dppU6ps/fGhaEmTwWunVY1rBc1hArE2dZgelPJaH3yATz6G 9+gONTQZjui7hBmfRDlKBLg8VJ+33Ve/7pV5jYozcXebv0G2tC99blIQ/+c9IrTr4FB2 yUO/Kk48rmxXiZIwLYrgRzJmVMRHh6u2VgVreefnYPlCOMfn6ZFc2m0UHj98Ki7sn1qR UG2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OHhq73fm8+f50i3SsK6KIm2w+P/uTjdSWyXaYAVfPmw=; b=kio8hrPmeFRrr4s/U9+xKBZ0v66YAV2462KUHUHNhZjAd2QI3UaV11hPmwCxzjNoqO VofPcOb3/JxVPhiBuHh0PpYiWWmBBe2XVVUDuniN6BUzxt9qvHfqOuejBh0Tc7wz8d2e BuahXLAE3YmBzO8WKT2RYoobyr0hkhDjflYDC6qcLom+NFgI0XZOAC5wz8/oK/y6lCWt 7CsqJt444RbdQI3oMb+WCb6H2AHPAZDNCUzWlbCR4BdudwrUmv5ViHx+0lcZsxH7s59r 6e6zj1BLj85mF5GuBThGZkxckgOZLPoK0rjeLGqPmXJDMZx/pP6cXTvdAYkhkI+xLI8K Cx/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d2PFGlNH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id gy2-20020a056214242200b00472efa62114si8723981qvb.584.2022.08.02.03.17.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Aug 2022 03:17:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d2PFGlNH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIoyK-0004HV-F3 for patch@linaro.org; Tue, 02 Aug 2022 06:17:56 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée --- 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 = envp; *env != 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" #include "libqos/malloc-pc.h" +#include "libqos/qgraph_internal.h" #include "hw/virtio/virtio-net.h" #include "standard-headers/linux/vhost_types.h" @@ -316,7 +317,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) } if (size != 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; } @@ -327,8 +328,8 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) p += VHOST_USER_HDR_SIZE; size = qemu_chr_fe_read_all(chr, p, msg.size); if (size != msg.size) { - g_test_message("Wrong message size received %d != %d", - size, msg.size); + qos_printf("%s: Wrong message size received %d != %d\n", + __func__, size, msg.size); return; } } @@ -450,7 +451,7 @@ static const char *init_hugepagefs(void) } 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 != 0 && errno == EINTR); if (ret != 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; } if (fs.f_type != 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; } From patchwork Tue Aug 2 09:50:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 594854 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp4206225maz; Tue, 2 Aug 2022 03:09:34 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uqX/IJK/r79DDew37hZq4KSHAfUtJe20KkpNlv6b6WXZDnBj60BmJ113dvZMp0ljvJGcoJ X-Received: by 2002:ac8:5a05:0:b0:31f:dc8:50ef with SMTP id n5-20020ac85a05000000b0031f0dc850efmr17266417qta.374.1659434973966; Tue, 02 Aug 2022 03:09:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659434973; cv=none; d=google.com; s=arc-20160816; b=0TcdoZ6mZFDVNllSiLY51YO5OZYX8hFmPoujoKPXD2yyv9qDOXsVHfX6gvyMvV7Ubr /aAy+t0auDqqDYepI1I2O+eNjI5v1KV9sRyrTZD8CwC+9lYPOg4NPWbwGOczDUlBjwcC 5Z92Fs4jjvaFJ6iJ8c3kEOLo+QYTS10EyfDHvyx0SRFvnFPQ2BfnVa4HdaVo+2mlg9Wt tsKiTlyFqhXfAmKbe0piYwJnKWECSvfFGNWdRhzSWMDobQotUEMNz1BWrgIUynwXjVCR GBLwsPfKDSF/PKrp+FnME+En7hk0Rj+HmY7ETf15Cc4hAskdf1bKgB/sWQOy2ORpbw3X Y6DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Go4zP69KIEX2yBSg0W79f2jSqF47viC9E/7rhCMdQ80=; b=JxqNa/dQu6cMBjhJ85T7kjeelRFkeqGcrxVSwcUO6Nzf7B4y0bkp7ybvhBAtvYpcEv Y3VSrO+STSkcB1AqDAYcKIT0ExOHAqFjGsDrfPop8hTqLgs6SBWn8HrcN+ZLmiqZWmkh eTwAJfYqt8lO7Gptm5i6DSeQ5W/KRg7wmbVLCNgD6nHR41nOeoAZ6ZEpv8iJcoBiz+co 1aRFjhSxYZUwiFi4t0wV8yZzLHQWa0vl8zir40pBpdS06ZHeIIPi5ZgwgBhSRX6fr+nS r4QBKWg0Wq1r2llmQJlSsD8xGuFM2XcqX40AGJ0tTmMlSuU2V+Rd3iv4Yo5Q7DnGikjA wwRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Zu/eBhMq"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bs23-20020ac86f17000000b0031f49179530si8117702qtb.490.2022.08.02.03.09.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Aug 2022 03:09:33 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Zu/eBhMq"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIoqD-0002Fp-Hb for patch@linaro.org; Tue, 02 Aug 2022 06:09:33 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée --- 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; + 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; + 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.u64); + 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 |= 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; + 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)=%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; } From patchwork Tue Aug 2 09:50:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 594850 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp4198316maz; Tue, 2 Aug 2022 02:58:44 -0700 (PDT) X-Google-Smtp-Source: AA6agR7/AON1EoGFzTkVT/wR3a6YWNKkRyY2rflVvEHceNFvQcf+qh+GpHfODLk1nr3z9mBgdbR7 X-Received: by 2002:a05:6214:2303:b0:473:2c6:8361 with SMTP id gc3-20020a056214230300b0047302c68361mr18109779qvb.70.1659434324484; Tue, 02 Aug 2022 02:58:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659434324; cv=none; d=google.com; s=arc-20160816; b=vZEzr3W6PJxYqZR8oEL/ASFXoLbgs1D+eeW4FmzcrnDyr2hJVDrScc9zzAge9qXUB8 wj5mCl7vkKfXHAS2c8ILQLGpF5UNcSPlkGiBu+vNOILeTNz832FRl5cH3WUPtWoiBYq4 MpQAyD+MTN8v8lMpeUyFGqHIto1ipCrpYX7Fnrv3Q1+IsPQlGewY99WDioMCsJA2vCuB j2lWAVlFLQbBCJh9/nuC2kzZWvMYlC4hIy+nae5yl6hqoQNOd4UPaZvnEk7lNPUmeanr 1OYhr50Xfjqonx2ugEjVB6096W7gpFfdymS7KXtpcGkptqQNSbHNEpF6evPvWnc74/Fm rRlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/benznZbSAEh098FVIlTeLDV1NXC1VfOpbQMrJp8HAc=; b=uzFmsSyESDlo68DYSXasD3NlmkSoYWzJrI0BhBG7UM7yQSZCfhrEzr1+t37mFoyu7g TWVwi4XMM14nRq2nM5N9nGJsbN/cKi7oLqnjKUU9EQ4qNYKGFYjXNrhskV6HsVcpOH0b g2FGhMs3wAt2Zc9BeMqeLjzDcB0KgaYnTWAwlkL2BGYD6g9XXpI4LdrKymmuXskjmp7t 4Z83ClDG46h2S8hGQelstdBYrpuTI/MwxgQhd2qumHFEu+uFhQB/qQ4c+ey5Th5nTvIl 5t3czyuC9yCP73eNgpFpO3I4ryH1cwZ+SwxfC2z6BoNSRPlgzPz+3u4TlEY//3ej9g+A C+vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Yt+1chp0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f6-20020a37ad06000000b006b2844bb5b5si7257834qkm.420.2022.08.02.02.58.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Aug 2022 02:58:44 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Yt+1chp0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:36120 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIofj-0000De-KJ for patch@linaro.org; Tue, 02 Aug 2022 05:58:43 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" checkpatch.pl warns that non-plain asserts should be avoided so convert the check to a plain g_assert. Signed-off-by: Alex Bennée --- 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, QGuestAllocator *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), !=, 0ULL); + g_assert(msg->payload.u64 & (0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES)); if (s->test_flags == TEST_FLAGS_DISCONNECT) { qemu_chr_fe_disconnect(chr); s->test_flags = TEST_FLAGS_BAD; From patchwork Tue Aug 2 09:50:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 594861 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp4217677maz; Tue, 2 Aug 2022 03:29:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR5rpzKwYKuG4IFPUx1eIakaeYhu0WGqYRQhfSkHk71lhW26ZezEn0yU3WnaRcDMJ4ThBLnZ X-Received: by 2002:ad4:5dee:0:b0:474:56:2d0c with SMTP id jn14-20020ad45dee000000b0047400562d0cmr18108635qvb.50.1659436175184; Tue, 02 Aug 2022 03:29:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659436175; cv=none; d=google.com; s=arc-20160816; b=ZmmHjWY2Sh6oYIo2NEBAamFyBAq/2Py8hDIa2RCujxdjcNfqNkilqZjU0CxyYP+eCd e2cph78sbZp5TTqUAxPZmLpfNsQRio9784ANs40yulgfxral7Eer74VA7NLAyB+Ej5Ry AT3cqLCbLkLI94iZ2Bija5aV9p/mN/n5J+xqj2SM6177+vnsMkVTDuYwxfT+dg/ZBxsP XZWQjiYJ1V8W9ISDjdo8lltqRvSQn/TALGAFNxtW50V9m+WtAqMOUNykD4oWC0MW0/2B cNcp78te1Do5NGl3vAax3kCOpnPjUw9RvKHZBJ1zo0IaRsekAfrPjStWnj31u8Obu5jZ LQnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PYaGkXjsZkoph9fA5YpZi9kVlMvB2mVtLyywEwpEssY=; b=CQGVuHLQi+PVyM8WRnLPFROg3iSvPQT5E1RMhkD1zmE9OmCKB9mOi1PHTPVAadAbuV /1bxtiIuKUQpyWTqzWZ6thFrLm15vh2NPwhjmITdXg6gVx9dolZH6ej5TipOUTWqD/wa 9YcvigJfxMWhgKqnFB/Tezf6vO44hjwdZdC7hseTIrMuVgj6FGJqkbwFRPt4xCBQWyJ4 VFPNTPwYVLzgB+1XHQbpUfCKp4EnyZ9kCAIhj0w3Vc1kzCz5XdIzM3iibuvPKsZmNHv7 0CZ3G9kRmK3FdeRIG78cjiZzGs/xIO3Ayv7d5Qm3Bw1mEobuk59Puv9d7wg6Io7XiBiV /QcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pTb7MGDE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p19-20020ac84093000000b0031efa390345si8778740qtl.7.2022.08.02.03.29.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Aug 2022 03:29:35 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pTb7MGDE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:58076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIp9a-0008KU-NN for patch@linaro.org; Tue, 02 Aug 2022 06:29:34 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée --- 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) void qvirtio_set_features(QVirtioDevice *d, uint64_t features) { + g_assert(!(features & QVIRTIO_F_BAD_FEATURE)); + d->features = features; d->bus->set_features(d, features); From patchwork Tue Aug 2 09:50:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 594860 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp4216349maz; Tue, 2 Aug 2022 03:26:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR4v7EjZK7pPC/756iKiY4/1kPnvpHPcAqSYqLlfUm+7kqQ0Wsj0L/L4BCmOItfjaFC7QU1t X-Received: by 2002:a0c:8d8e:0:b0:473:6406:9dbb with SMTP id t14-20020a0c8d8e000000b0047364069dbbmr17896724qvb.80.1659436016159; Tue, 02 Aug 2022 03:26:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659436016; cv=none; d=google.com; s=arc-20160816; b=v0LD+q/HgXT7i3/jpB2DHDKRCkJdRZIacGYjyWA+oD1U046RQoYfJdyh+s9KlOzxsg cfpuBNrZamUSCgbbkO61iaFQgwLiXd0kJJDqhiORe27nl51wRSwLvHlcPZSNgKAcY+Se uTYL2Lew/4Jq6xsnCbodV2d4gRpQoiPgKuqtIWjzCuCuUeb0+7C8+jKsYAQl0W+yg3dm aCDTEmqUyCpecNeuc+uhdQrikyPBCfBsf0fGdXIefJuliJmDxs5G50PzpBQXLbpHJUO9 TNyA0H/BXe0VdEJwFKsu4Ks7HUtnruPbjiDG8ImCN1d6LdzALvk+1IK9910KXAMiFoaB SiXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=g/o8m65biskhxapd/iISMtVnr5sb7Kumaq7aeEYhX/o=; b=NI0mcYzjyBLIjNW0NDqCD1eTU02nP9xQuuN+zlqTBVMSdsN4zgkuItBgFIgKkVIhwX iAKtjUb8S683YOf4mX5LfNoo9EptQn8/1eiRQZiTNPfv+stV8bLyS1OQ1AdGfutIe+ZJ 6jTKIxo3q9hdaZN3ejFn5FVh7KRQfDd6fArZJfYBRshNxUCIpXp7CtSPU7P+mfQbd2nj wKNo0RNeXb2ju79eV/ZMxqnS4czJqcvvEjZ9Nm6CUfz9QFhyllpKlUMPMKTd1uQ+AaUy cBfSy6S2pbxa0k37Ohwom7+W3Tazjq16G1dYxDAReRkMeai72ZyAntY4CDSLiS+73uvo Hvbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FE2Ao+wj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id fd9-20020a05622a4d0900b0031ef837a87dsi8120525qtb.594.2022.08.02.03.26.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Aug 2022 03:26:56 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FE2Ao+wj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:52398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIp71-0004t6-Gg for patch@linaro.org; Tue, 02 Aug 2022 06:26:55 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée --- 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 = 16, VHOST_USER_GET_QUEUE_NUM = 17, VHOST_USER_SET_VRING_ENABLE = 18, + VHOST_USER_GET_CONFIG = 24, + VHOST_USER_SET_CONFIG = 25, VHOST_USER_MAX } VhostUserRequest; @@ -372,6 +374,17 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) } break; + 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 |= VHOST_USER_REPLY_MASK; + p = (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 From patchwork Tue Aug 2 09:50:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 594855 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp4207429maz; Tue, 2 Aug 2022 03:11:25 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vA4TDdcx2vvtW8EXbNIYNrW+0S0kZ9nBYWXnzHLmcQ6kgirHSBTAaCZqXi6x3MPod+cSqQ X-Received: by 2002:a05:620a:2053:b0:6b5:ee04:9b6f with SMTP id d19-20020a05620a205300b006b5ee049b6fmr14856353qka.731.1659435085011; Tue, 02 Aug 2022 03:11:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659435085; cv=none; d=google.com; s=arc-20160816; b=G1C4Oi3ZM5NdqtGE6qp6+AnH3q2nCR+MEEN5Zl/jR+3cEanblf7ys2Ak3lKSYy50h9 QoojNtHy8sbwzqQI6Ks247C0vrotphAOYnng4Km9sHJV4mq/EGGxvRmIdc5Cn6Y8XH4J AAbH43rlPGhMK0WrsNeZ++NBmF6uUqJL1jxunVR3H0vd3W+VGHVApPWufPJ8pu9Fvkg5 J60ISBB3UHwssbFTiGSpAWh+hYaMSiVIPB1WCqHTCwCckbDS04zc826UvopyApUZeXKE 1fxmKnOqpSb0gBJQFdAbdDSKyoCacgy8ZJ3GP05esIjVsP8CcL2rPSog7WEFVAkoOwgT qDSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vdim50/4QWM59eJmuqXHbqgfci2iCoUWAD1+T4jr3FI=; b=iqKZkDObbeteoZohpIvucCIiq9gdbZC9d0mOPQrw4g1/kTwibfjbo3CQLrh78Q+ABH U2tvUpa0gY7B5h2jOxSpc4duJ3ZZbzMMoclr9dDixqADdSVCa0GrMeUZIlJ/EGf9W/ba jUld614Sy/CcO357OOE1+cn1c3DNC3RQkrZrce7RWskW+v3LE0cLHpKW9iL9V0LtXGSV BzLIGQkZtibkjfKP6JQ6cAavkrrT3eOgy8JEwm1Mgjis5kLt1iyho3YDv/wsbgmjDJNA 43/oCLpxZtwkTitpwsQnMnjRC/basFsvCNcaF2bNQwEo/C66ZeyfVlN21RKjMDdt0XFW q+Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gYsUZovi; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r4-20020ac87ee4000000b0031eb245dfe2si7073937qtc.381.2022.08.02.03.11.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Aug 2022 03:11:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gYsUZovi; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55082 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIos0-0004zY-Je for patch@linaro.org; Tue, 02 Aug 2022 06:11:24 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée --- 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); /* 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); }; static const char *init_hugepagefs(void); @@ -338,20 +339,22 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) 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 |= VHOST_USER_REPLY_MASK; msg.size = sizeof(m.payload.u64); - msg.payload.u64 = 0x1ULL << VHOST_F_LOG_ALL | - 0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES; - if (s->queues > 1) { - msg.payload.u64 |= 0x1ULL << VIRTIO_NET_F_MQ; - } + if (s->test_flags >= TEST_FLAGS_BAD) { msg.payload.u64 = 0; s->test_flags = TEST_FLAGS_END; + } else { + msg.payload.u64 = s->vu_ops->get_features(s); } - p = (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; case VHOST_USER_SET_FEATURES: @@ -993,8 +996,21 @@ static void test_multiqueue(void *obj, void *arg, QGuestAllocator *alloc) wait_for_rings_started(s, s->queues * 2); } + +static uint64_t vu_net_get_features(TestServer *s) +{ + uint64_t features = 0x1ULL << VHOST_F_LOG_ALL | + 0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES; + + if (s->queues > 1) { + features |= 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 == TEST_FLAGS_DISCONNECT) { @@ -1023,6 +1039,7 @@ static struct vhost_user_ops g_vu_net_ops = { .append_opts = append_vhost_net_opts, + .get_features = vu_net_get_features, .set_features = vu_net_set_features, .get_protocol_features = vu_net_get_protocol_features, }; From patchwork Tue Aug 2 09:50:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 594863 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp4220187maz; Tue, 2 Aug 2022 03:33:55 -0700 (PDT) X-Google-Smtp-Source: AA6agR5DWliNx1LlFNinTLJaL5uS1E4qheTH/ARPtlHDX3GyhwoeodqgocK/8kuMbX0Dn8dkOcKs X-Received: by 2002:a05:6214:3006:b0:46e:6be4:2b7d with SMTP id ke6-20020a056214300600b0046e6be42b7dmr17338583qvb.84.1659436435340; Tue, 02 Aug 2022 03:33:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659436435; cv=none; d=google.com; s=arc-20160816; b=FWglzist2CbMO1OevnUYB+7+ZIa19GS3PsuHhpRK6rZ6xx7m92+/QdSyQyfJviWQtT aY33Q0gbeCggigqdvfi56IMviX8tjNISu3DJH72Q/nCxjgFU1VfZEAbpxi4f0Lbxf8eJ 3vLC0Y/BO2ikoIXzXcwcOtQlgvvgiDZNLc2Tq1BfhQsKc5js01MIe/6J2LAhH4aIh1y2 eWWiu6yeSRwwzs8O4LZTg89D2czCqxDQe3oKc7Fp57YhD8/MMhiwaQUQ9aZCTJ6Imd7P D9Jvy7vUlKHKjGhmrQT5U1ACfKXeXeJiA7xoDnMJRW+8gLcps2eckf1ffGJ7y59NlOAF 2t8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ES3P1RAWW4Xg6DVYirTqKJQ7c1EO4knl3H0A5mgKf8M=; b=SxyPZ/4e+dprE6I1gmYwuJZ6kJDY72gdPLQCy/gx15pBEjMVX1myWAoo2r05/rsNTY mRCo+F7ryG4eKmC6JMwolh0rG+0BvW0nbWcIWlGff4KCAJHjCv3mNDxTppv5Wi18UUtg VsTF3vM8v7tPBfMn4Hs3VYwQGhoCVBk3E+Nays71/UN2YyzalzBtuMIhtbC6dnpweGBx e5q05KyHoKiDPM674wmRNZysg7U7HtDcyujGDP1JPXcp8lE/EJl/gh7TvjXqJQC9GRXZ +wuga+0tPubOHIFI2v1C82jqtvHP+N/rj6CD1880iQfazGL7PvbksOStaY3sskdqD89Z JpOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Cn/uODqp"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d15-20020ac8614f000000b00304bda024a2si9607062qtm.744.2022.08.02.03.33.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Aug 2022 03:33:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Cn/uODqp"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIpDm-00035Q-Sv for patch@linaro.org; Tue, 02 Aug 2022 06:33:54 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée 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-gpio.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-gpio.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 = gpio->vdev; + int i; + + for (i = 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 = gpio->vdev; + uint64_t features; + int i; + + features = qvirtio_get_features(vdev); + features &= ~QVIRTIO_F_BAD_FEATURE; + qvirtio_set_features(vdev, features); + + gpio->queues = g_new(QVirtQueue *, 2); + for (i = 0; i < 2; i++) { + gpio->queues[i] = 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 = object; + return qvirtio_gpio_get_driver(&v_gpio->gpio, interface); +} + +/* virtio-gpio (mmio) */ +static void qvirtio_gpio_device_destructor(QOSGraphObject *obj) +{ + QVhostUserGPIODevice *gpio_dev = (QVhostUserGPIODevice *) obj; + virtio_gpio_cleanup(&gpio_dev->gpio); +} + +static void qvirtio_gpio_device_start_hw(QOSGraphObject *obj) +{ + QVhostUserGPIODevice *gpio_dev = (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 = g_new0(QVhostUserGPIODevice, 1); + QVhostUserGPIO *interface = &virtio_device->gpio; + + interface->vdev = virtio_dev; + alloc = t_alloc; + + virtio_device->obj.get_driver = qvirtio_gpio_device_get_driver; + virtio_device->obj.start_hw = qvirtio_gpio_device_start_hw; + virtio_device->obj.destructor = qvirtio_gpio_device_destructor; + + return &virtio_device->obj; +} + +/* virtio-gpio-pci */ +static void qvirtio_gpio_pci_destructor(QOSGraphObject *obj) +{ + QVhostUserGPIOPCI *gpio_pci = (QVhostUserGPIOPCI *) obj; + QOSGraphObject *pci_vobj = &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 = (QVhostUserGPIOPCI *) obj; + QOSGraphObject *pci_vobj = &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 *interface) +{ + QVhostUserGPIOPCI *v_gpio = 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_alloc, + void *addr) +{ + QVhostUserGPIOPCI *virtio_spci = g_new0(QVhostUserGPIOPCI, 1); + QVhostUserGPIO *interface = &virtio_spci->gpio; + QOSGraphObject *obj = &virtio_spci->pci_vdev.obj; + + virtio_pci_init(&virtio_spci->pci_vdev, pci_bus, addr); + interface->vdev = &virtio_spci->pci_vdev.vdev; + alloc = t_alloc; + + obj->get_driver = qvirtio_gpio_pci_get_driver; + obj->start_hw = qvirtio_gpio_pci_start_hw; + obj->destructor = qvirtio_gpio_pci_destructor; + + return obj; +} + +static void virtio_gpio_register_nodes(void) +{ + QPCIAddress addr = { + .devfn = QPCI_DEVFN(4, 0), + }; + + QOSGraphEdgeOptions edge_opts = { }; + + /* vhost-user-gpio-device */ + edge_opts.extra_device_opts = "id=gpio0,chardev=chr-vhost-user-test"; + 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 = "id=gpio0,addr=04.0,chardev=chr-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 features) * This could be a separate function for drivers that want to access * configuration space before setting FEATURES_OK, but no existing users * need that and it's less code for callers if this is done implicitly. - */ + */ if (features & (1ull << VIRTIO_F_VERSION_1)) { uint8_t status = 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" #ifdef CONFIG_LINUX #include @@ -53,9 +54,12 @@ #define VHOST_MAX_VIRTQUEUES 0x100 #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 #define VHOST_LOG_PAGE 0x1000 @@ -140,6 +144,7 @@ enum { enum { VHOST_USER_NET, + VHOST_USER_GPIO, }; typedef struct TestServer { @@ -198,6 +203,19 @@ static void append_vhost_net_opts(TestServer *s, GString *cmd_line, chr_opts, s->chr_name); } +/* + * 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 |= VHOST_USER_REPLY_MASK; + msg->size = sizeof(m.payload.u64); + msg->payload.u64 = 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 = { + .type = VHOST_USER_GPIO, + + .append_opts = append_vhost_gpio_opts, + + .get_features = vu_gpio_get_features, + .set_features = vu_net_set_features, + .get_protocol_features = vu_gpio_get_protocol_features, +}; + +static void register_vhost_gpio_test(void) +{ + QOSGraphTestOptions opts = { + .before = vhost_user_test_setup, + .subprocess = true, + .arg = &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.* 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 = files( 'virtio-scsi.c', 'virtio-serial.c', 'virtio-iommu.c', + 'virtio-gpio.c', 'generic-pcihost.c', # qgraph machines: