From patchwork Tue Jul 26 19:21:30 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: 593465 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b811:0:0:0:0 with SMTP id fc17csp3815546mab; Tue, 26 Jul 2022 12:23:55 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vEN2wWGZeX/xjTrJMlaHkPgd/GbqceMPy4BySkeWACiEHJJMMam2PTr/xNcR7lNNqAITui X-Received: by 2002:ad4:4ee8:0:b0:474:6f9c:a103 with SMTP id dv8-20020ad44ee8000000b004746f9ca103mr2340904qvb.47.1658863435719; Tue, 26 Jul 2022 12:23:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658863435; cv=none; d=google.com; s=arc-20160816; b=M2dg7yAAt6w6ynuFyE5Mc6zFxrXas13P1deTz58zHbNbINGIvMtpjMBeZi9TuIP8fQ WpUMbus7MOhi4X6Nem0EgwiYN1cJXYSAs2WupfUe6H86/iVJE+0g4SFryaV43X4aBWVX DTFunH0p0h3TWHXhCx2mh1/G6jpxONxA/MfTnx2VJ4PlludYfQFXJeLj/JGxOlqVKrYm Yve1HA1ug67EcN9LkxW0+ZxYOAEPkGI1bH+F6ui8f55YjmAwBmjEdZKqp9LCvDDvoiOK zUYs4cpR9Vx4iQz5IamopJvJWv+hdfnxYR3WAX8hR8PaKtrOBMnULQ/7j2D61+stFZiE WYpg== 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=JQupfMAsl84DSS66hGXbUx82Y5Mr3ljpvXZSWOoOqagRfKmJYIPifWR4He2yD1UHOq 0myZlOvUkE0MDyTwyymLonO0gr1vrcP13NzWBENctBCD2TfWU2VK5yrJ9xZXuGka3lKY tRCffm1H3r/b4yIvrf4ugX/3zRoAtF22oBCTtebuGaRYRBD8Hf67uscTtpy9uBooWXdY +D5qweyJGf+1e1ZnD3K9f3sKLwyi5la8SmQj/WFtifw0JLwO5Zt7gT/uwh+m+DRFKoa0 jZW9MZzN3bLpCrkwBQ5wINySYG7rUKvsyR8J7BqGe1WO2moo67Zi4MreyGHMIkzS5x3z t8OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mt1ohbEC; 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 o15-20020ad45c8f000000b004733c2889e8si10743009qvh.85.2022.07.26.12.23.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jul 2022 12:23: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=mt1ohbEC; 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]:53092 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGQ9r-0003D5-6u for patch@linaro.org; Tue, 26 Jul 2022 15:23:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGQ7x-0003A8-2j for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:21:58 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:34712) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGQ7v-0002HB-19 for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:21:56 -0400 Received: by mail-wr1-x431.google.com with SMTP id h8so21433247wrw.1 for ; Tue, 26 Jul 2022 12:21:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6BvLwU4GMUiq3XaMcxliYSNhOBL1ZkQfbeog0e1G+vA=; b=mt1ohbECoxDfdXXNDvr9KKtjfVbd+NVKnnkfCVDDhFvlwNG4HIIzvyNWQQLSD8wQmn pbdABLCpv7rjUNNO+WMOl1/jQyM37XEDX17CfpPQLbTIhNK7sBK2+BDLiEl+PT95O8B3 JVKEsl40oEk+idmRiGxMPGcDsk9zMERlqZ9n/9orfiDYL29ApEbSpWx9Lv81cgXLAFtr VbKksMkGBTlGNB5qxzkMouFyk1zWTPZovfBjxDPZ7P1lLQNBQIHg8jXMYiLkkyn2LF6i TmtZjpJ2LMe2yo/yhFEsxGvjWs/u7q552qERMgeZc97yQbrWrexNrUGg7+32gt9+nplV Xkcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6BvLwU4GMUiq3XaMcxliYSNhOBL1ZkQfbeog0e1G+vA=; b=ROfCGoZmL5FNmh2tHa7c2D2tnLHJNq+YAW2EMVZqS7DjcK90hVFoEX617nY4i5gtkO xgyyTFmhi1TR7/ktB7auTbry2gRl2OdqJT/OFrd3CodHQXA6phIzHYCkP1k3iEGAntOH Zf9qe5HUvKo4INZ3Mmu4Slg3rlJ6UZw8lxGKrIPk0WFyxwxlyYQXONZAxIClsG8MzF1i lIZ2puAa68o2aZpbwSOwC4LnT+gFXsVV/q9iVi1LJBHsqpyzaw6w2H4mZ9eskD/oU+Mm dtJ6HikB5BzQ2XK1pjTRZG0CO7yxOnguopgwL6ZEmzOtGDH1sGyYW/YiKs+Kl3P9MraO BuAQ== X-Gm-Message-State: AJIora+OLQihayU5YKcC0lTrhspvGFbYWVs8yucWI8dqcSo3f2P6KdkB ScWwdkpfr3sMf0BVKoTM4s3VXQ== X-Received: by 2002:a5d:64e2:0:b0:21d:38e8:2497 with SMTP id g2-20020a5d64e2000000b0021d38e82497mr11011148wri.142.1658863313836; Tue, 26 Jul 2022 12:21:53 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id v1-20020adfe281000000b0021e5adb92desm14236233wri.60.2022.07.26.12.21.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 12:21:51 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 728F11FFB8; Tue, 26 Jul 2022 20:21:50 +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, mark.cave-ayland@ilande.co.uk, jasowang@redhat.com, =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= Subject: [PATCH v3 01/21] include/hw/virtio: more comment for VIRTIO_F_BAD_FEATURE Date: Tue, 26 Jul 2022 20:21:30 +0100 Message-Id: <20220726192150.2435175-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220726192150.2435175-1-alex.bennee@linaro.org> References: <20220726192150.2435175-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x431.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 Jul 26 19:21:31 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: 593471 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b811:0:0:0:0 with SMTP id fc17csp3821603mab; Tue, 26 Jul 2022 12:33:49 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sL4MKBM8HVKyFtE+sjLW5Ll4LcGrgaq2xcKkaxxJAWYWI7OgHSc+jFvvPh5rMuZDk0nRkV X-Received: by 2002:a05:622a:612:b0:31e:f64a:6dbe with SMTP id z18-20020a05622a061200b0031ef64a6dbemr15704076qta.29.1658864029467; Tue, 26 Jul 2022 12:33:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658864029; cv=none; d=google.com; s=arc-20160816; b=vWyHLFEL4QTB2m09MvAqllBbkP+yNYLr7GoxoopqapfirqmqLlUzFKxaMYBTDG9OoB B8yZLhg8ai+0rq7I1MXcNAbtjzeJL1whbOxtjku7Bih9GmqRUgw4zg7z/Rs7Q7ACxg3b qUbwr0hjgXGOylMfXW8X9G/EZ4OqZ+cWGMZD9CYUSl04FnWXEsex99/pj/PDxUnM+jVc QML/gYQE2BNxnRWaKp/NeFEb/2NaPJiCIksqucfCjXw2lKplGvgZ1OXAi7zNSQdePDAp dEI3Oc1Tdx4Fivfj9XzW3Rv8Le5ai0dgkx3NWxV5UWnLWCWpvbXO+zfDZCwHhsJ2q1Ex IB/Q== 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=YA8bK0QimOlD2NvATId4ShuayIO9M3XtMDLWtyqNjMU=; b=jZ+EXwMwdQuGAoK7gAzpToBV1yZiiZTQWvG6LWRgJMoPZh8xmZLSr0ufn7lYfJucbB LlAximnbKgwCzHUG9ZKa5uLTafHQEI7UctcPLKV3v8kAinZquWgP6NfS5a09D4C89P+Q +t0ux9lDc5Dho4kb4OghGCKICggRQHb/I4Bs1lAW3fkVZvt780gvGfrcReFJiSQ/LMiJ AD3Wn8wx0g4pdQCYIMFa6ep3NhW5FhLiuQg59/10d+fOS46pPEciuyyv7CtJI+GzA7Hw 1gUZZjld10QyQj93rJPNUtjbcWRivF8uTTqRSE4YcK2oMaoFIJ6jrPkPA4KLokm+o5Y/ 6/ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rvCiJcli; 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 93-20020aed30e6000000b0031ee2477705si8462551qtf.632.2022.07.26.12.33.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jul 2022 12:33:49 -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=rvCiJcli; 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]:40702 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGQJQ-00061R-Tr for patch@linaro.org; Tue, 26 Jul 2022 15:33:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGQ7v-0003A5-T3 for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:21:58 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:40548) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGQ7t-0002Gz-Rr for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:21:55 -0400 Received: by mail-wr1-x431.google.com with SMTP id m17so21166314wrw.7 for ; Tue, 26 Jul 2022 12:21:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YA8bK0QimOlD2NvATId4ShuayIO9M3XtMDLWtyqNjMU=; b=rvCiJcliKYs27pOKccyWbWtEwBAGTJnUIVV3uD0ieM/Jj0FL/nfm1fESd0M6AaLIQ9 UtPCVOd+dJQUqnefBkpnS7b9Qrjsw93toP7BioknpsGhscDPCGth7OVMgyMu8r4wlr/K R46chISaJ0kVR9ouJ/mZODJDG07oHeJF3hq/Z6gWS5uSY1LoUf0T3RzbKtH1vZLh3e29 xOzX5TsbtKjCoPV3tPWWjsyDE/18Hwo305voq5+BmVUPLx+V0Nqj1/+1ohcJHxCnVJsJ sdUcwzKRNndiAlGNhHQFcZDTDtWAW4uJ0yh4wcsDIlVyZuPet60YWUrJ1wDrCw2DhEay GqHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YA8bK0QimOlD2NvATId4ShuayIO9M3XtMDLWtyqNjMU=; b=fSKa6cKkNVeMI9Wedeuxmz86fQvb+Kz0YosJDGLGIqgXeBERfTKoCvmHu7qjj+mvjP j6ycdBWOit5h28jriv4gGCOfvipaSmHomsId7htdBi0/rJyISBQ8j08oivK/wrtZjC6S M7ubLMx5G5nwUNDTjkjRBtOEk+XAust/hqOpNUXRGP10tF6eDfm2lHcSUeVsxum0akIr LHI+zE3YeQtHZsNCJoMIGjukNjMvmwbksfgRlnOgGncZ3BXY3BLFgKeI6gSAMuFj04WD gEHgo/bDDfmonbACJ9aXneBKgwwKk9fzC0+nXMB1oWwZPo+wbamovY+ufXrsifebhVrB RWhw== X-Gm-Message-State: AJIora94J0EAJhvahOUkcYrLt92PC5gzSXtfeWYdwxciaX7DHb6JulV7 CxYVglJwjNumfkIEhYs6VhBLkQ== X-Received: by 2002:a05:6000:2a8:b0:21d:8c81:7eb0 with SMTP id l8-20020a05600002a800b0021d8c817eb0mr11435997wry.460.1658863312083; Tue, 26 Jul 2022 12:21:52 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id h21-20020a05600c351500b003a31df6af2esm25229340wmq.1.2022.07.26.12.21.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 12:21:51 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 8A6AA1FFBA; Tue, 26 Jul 2022 20:21:50 +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, mark.cave-ayland@ilande.co.uk, jasowang@redhat.com, =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= Subject: [PATCH v3 02/21] include/hw: document vhost_dev feature life-cycle Date: Tue, 26 Jul 2022 20:21:31 +0100 Message-Id: <20220726192150.2435175-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220726192150.2435175-1-alex.bennee@linaro.org> References: <20220726192150.2435175-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x431.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 --- 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 Jul 26 19:21:32 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: 593464 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b811:0:0:0:0 with SMTP id fc17csp3815544mab; Tue, 26 Jul 2022 12:23:55 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t9mQMQB5VgL7DvbpIlA7QOMOo8l7/WdG47CDRCvFPT7tPrcqds75VO3O7gxPSRKmPDZvi3 X-Received: by 2002:a05:622a:1494:b0:31f:28a5:7ceb with SMTP id t20-20020a05622a149400b0031f28a57cebmr14534010qtx.521.1658863435632; Tue, 26 Jul 2022 12:23:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658863435; cv=none; d=google.com; s=arc-20160816; b=APPMz0xJEBOuEYKq/BXTVryRm5qvycDTtUe47MIspNdP8LQG4pBzCzPFOHF0vyX0PE qSGaylL25rbhcfuVlDxMeeLLBVDwVTWBD+tkR2vppBRcZAzYAHNktJxe4r2VelkL4W5G QK+vI9rvtovjpJExOBCxWrt+OnpWuYiAH3sDQQ2sZNcNtAaJV0s6VCtKFI2L88sqLKQV 38GdEsHhx+qwRDNM0vueSzbgDfSBtsZen9V1a4EZYWD5VG74vZdoYMffh1YpeLvE5wCQ dX0OEDEsROeTTlCMasxtNOOdk9m72I4rZuKM//eF9iWYORntlJyFnUCVrdNZSFR7d0MJ ol4A== 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=84wQKQaoKJK6iaVE173auQGOX9Kt1NYCFzy5qnZ8uJk=; b=ZgmTwnfIYS6bHdOtajtTTbNAx7zd1wEMtS0BKFoCh1Wep8eSJn6Uf9K7VfxiW4Cpw4 vG7n8ORpt2QTTYf8rcpxx/QF/r9jBHmP9mZDqOYH87PQOZHGuPahp3iKl7usqUSACj2K b5XcjKVwBFGBcgVzUOFedpOkAXwHlj0CGzdiLsAOXOxO8LrSnY/Y2BxtuB4TfD5ktExa JfD4vPkJ2OYMGCQJb4GYOkRQ7LASXYbULFrNPnTYO/TiWBmWPSXfEOZVl9Vl48pUkJNM FyWMyS6Fc8vp33bWId5UojQ/kMjM77/Yn8Trp7aKT+X8i3SHVZxnw4hqXcrtTwgUkLkk uNeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kch7zEt1; 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 r15-20020a056214212f00b004620464871asi10450361qvc.39.2022.07.26.12.23.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jul 2022 12:23: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=kch7zEt1; 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]:53170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGQ9r-0003GA-3U for patch@linaro.org; Tue, 26 Jul 2022 15:23:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48856) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGQ80-0003Cz-HR for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:22:00 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:36553) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGQ7y-0002HV-0i for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:21:59 -0400 Received: by mail-wr1-x436.google.com with SMTP id g2so13396966wru.3 for ; Tue, 26 Jul 2022 12:21:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=84wQKQaoKJK6iaVE173auQGOX9Kt1NYCFzy5qnZ8uJk=; b=kch7zEt17q5jtDmuSy/r4PrZ0BPhTdm93LGH5/AQ2qqOpD9tBfi4PVRFPzHSxRDC22 xtCuwNNEACgZbHpfRPtnnpM3Sbfq8vrEfySYWcBH2d4sVRSGN/bqwxql9XA02cZE/aaI TS1mLiyz4E4/16JX2qbG8Gkmg8BiYXR4X1C7r7u0PYV0jZZwHz6IlY5EVvob/a7I4oMO jsgaw8itkUk5tsUKOq/Oz2BWa+crPqxyzK4lpw8rK5huxgktACtL1yFDIfjQzCottYwr 0cLFbICEcAQL68TZVb6Tlge0sfH9doQBI5P7huFLAvwISkRBx+E6inh7tradlKTbTJ7R lygQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=84wQKQaoKJK6iaVE173auQGOX9Kt1NYCFzy5qnZ8uJk=; b=tLoOD6fQ5oaoFO9tgmjHgaCZydu8TeS/6UjcvrK4lFMIz7GLvYdeK0o2kberJEfspL 8UDmKveriKr+t1u+W61lzR19ovXuJpsw6AZNGjrubnOwG5ofrCy6FYHthLpgRIf6OwKn D4lWqwJAygu/qMlgbY6WNmUyBwTcOv/gnlMFhajU9D+Ong9PXywB3lhGMmZZEMuEN4Yq t4+gNGFxU/N1wPjLhNO/GOBdCz0pAOAcJSxCWMdGWYwdd6Wd0nNI9DOftgcRqFPfWHze 0D7MChyLAqH6hOfcQfCxDcvkt3fSGLT/KnyXPzWn6UC46hv6msjgfJztjJNZU3W5CkF6 GHrg== X-Gm-Message-State: AJIora9joVfhv3S6py34eZQWz4JqrwoyFEsfqMQDaSFnQDQHxE7TpKYV YwOPqNbdbFfKcEjchVwIBCclUQ== X-Received: by 2002:a05:6000:188b:b0:21d:b277:d492 with SMTP id a11-20020a056000188b00b0021db277d492mr12246772wri.311.1658863316526; Tue, 26 Jul 2022 12:21:56 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id g3-20020a5d5543000000b0021e4bc9edbfsm15095344wrw.112.2022.07.26.12.21.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 12:21:51 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 966EB1FFBB; Tue, 26 Jul 2022 20:21:50 +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, mark.cave-ayland@ilande.co.uk, jasowang@redhat.com, =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= Subject: [PATCH v3 03/21] hw/virtio: fix some coding style issues Date: Tue, 26 Jul 2022 20:21:32 +0100 Message-Id: <20220726192150.2435175-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220726192150.2435175-1-alex.bennee@linaro.org> References: <20220726192150.2435175-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" Signed-off-by: Alex Bennée Acked-by: Jason Wang --- 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 75b8df21a4..55fce18480 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 Jul 26 19:21:33 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: 593466 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b811:0:0:0:0 with SMTP id fc17csp3815569mab; Tue, 26 Jul 2022 12:23:58 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tBH+3gbpoMk/0TcGri3iokuOAtmhO7Nu2CnTKIzyfVlPSSP3d1UadNF20i4EIc8h5vUk23 X-Received: by 2002:a05:622a:1649:b0:31f:758:97e0 with SMTP id y9-20020a05622a164900b0031f075897e0mr15360233qtj.55.1658863438786; Tue, 26 Jul 2022 12:23:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658863438; cv=none; d=google.com; s=arc-20160816; b=uS6FbcuLVyf1U9QIUNTFKSNV3K+vvtuKWIdVV3NPl7q/qQY50DTmgYAfAoKiTGkxoe VUWbpILHr6+suYscdS/hqVdQdSV68LyweWRzwcvhbB8hpOunVQc/lvTZro1oyDjOC33z JRvT+ym+6CeD6xuGJMW6ynAC4tr+V61IIbh18dPpnpa05BQGvNhIA7AbtmTtKrd5dsx8 KcgIAfou5KpNox8aKTS/dorNM6yXi6hBNCRVY7oe+xm8TDbNLDo4oKg6ZWYYPJ6Tp76T 6kVnh4ZgtmGbdoUq1cNvMZMj2Ez5qnWzBwuv2WVDonSpsDoq0jaia5Z3PDoPY5Ksz59A 3xMQ== 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=kIauFkEBziEhsZfmDYmqUoKaLQlqvxSrwk3Mtb6urFc=; b=cIubtmkE4SM1jYtJDRqQ72Dg87a3Wl4K7glvRwCiLKglMebTGzdUbEI4Sz4aCda8It YySTUPX77g8FHx6t4ZNlq8xaJyMChSRvjxijmJ1FVBDtHzQ3iVROrjYxFrlajRQy4sHn XzqbawPRKsoGqlC5e3VN1X9al28KN3vruCaC7sEUtf1DpFIzzlxuzXFGhXAfM7iI/EoG 5jMwoIByO2m58g4zu0F/EAvxepdR6y2GrK8ifSt7Vb2d/L9K7B4xGc9x5boDFWA/D7Rb +WEFV5v++sEhS3bCbqW55J05eFW2iKXqNsXLbP/nRB1lQsoYZvOAcPcs11VCpzZlb75h VvwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CPInlFtb; 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 i17-20020a05620a249100b006b637e645c0si8077625qkn.609.2022.07.26.12.23.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jul 2022 12:23:58 -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=CPInlFtb; 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]:53212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGQ9u-0003Ix-CK for patch@linaro.org; Tue, 26 Jul 2022 15:23:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48916) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGQ83-0003F7-RX for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:22:05 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:39614) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGQ81-0002J0-3R for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:22:02 -0400 Received: by mail-wm1-x336.google.com with SMTP id i205-20020a1c3bd6000000b003a2fa488efdso6141019wma.4 for ; Tue, 26 Jul 2022 12:21:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kIauFkEBziEhsZfmDYmqUoKaLQlqvxSrwk3Mtb6urFc=; b=CPInlFtb/85r3ZO40q/xNOn/CdDUM4g0YYOTXgUknWgnTURFYwi+OvC2WwvbyKNbBu n3K9eATd/2S/cMZwUhjFQYDGdfRG7PXS7R/x9G2DuJaYu6MAKIuHi7HTVFKfrSa0p0yP 71ynElwzzRAPg84dNAOkUDNY5+PW+hFzH+NtX1DpnWkLg/gienInDvYVuRh5w4yGtNj5 ay9YkfdAZ2/dVfBX+XWB70zdvvhfHd2EC/N2xIDDE2Hgc3hXm1Szug50XW41VpKnOifW qb/ndMQuwAwkLgkT8SV0+Xi3N2xHgSJC+Eo4nEBP/lba9YtoJy0rgulVHaY9g68dobOK LGbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kIauFkEBziEhsZfmDYmqUoKaLQlqvxSrwk3Mtb6urFc=; b=oS8WDR8KjD7d2O0JHxW9Yx6lOkPxlZDQP9cCLc8+jsxIgu46sz/PvEdRa21yaVqfBr IdAYhiWM7Np+vfnruy8FtwBu3B5Dg+d3COeYNrmV3inHpshuXPhQEGDY2j9NCQBOLkKD kfQtE8rgBid8pPMeh1UAZnryuLA0bGp2Vb1XIziw+/xP45GqDOqXWZsW9LkGGILPFPl+ 9NwUIfORfCuGtCZgcrPaCS4knqhszcEwkfosNhq44dxFvbV3xpQ9nBLqG6umAHA7RQ30 +YlwU6ceiwazviwYSZ9UhiDo9s8+b6u4w0VWvsKyONmPiOKj8XU87Hyx8tkDeGIoGDLP WRpw== X-Gm-Message-State: AJIora9cGDFPpV56gO7NGBUKKOIbJEzhosVdAO5s+3MiFOSBemrhwXrv StcNLPeuCbPV0HJqrz9By9B2bQ== X-Received: by 2002:a7b:ce8a:0:b0:3a3:1181:20ae with SMTP id q10-20020a7bce8a000000b003a3118120aemr456964wmj.96.1658863318849; Tue, 26 Jul 2022 12:21:58 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id n124-20020a1c2782000000b003a2c67aa6c0sm21414582wmn.23.2022.07.26.12.21.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 12:21:52 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id ACE791FFBC; Tue, 26 Jul 2022 20:21:50 +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, mark.cave-ayland@ilande.co.uk, jasowang@redhat.com, =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= Subject: [PATCH v3 04/21] hw/virtio: log potentially buggy guest drivers Date: Tue, 26 Jul 2022 20:21:33 +0100 Message-Id: <20220726192150.2435175-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220726192150.2435175-1-alex.bennee@linaro.org> References: <20220726192150.2435175-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x336.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 Jul 26 19:21:34 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: 593474 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b811:0:0:0:0 with SMTP id fc17csp3824516mab; Tue, 26 Jul 2022 12:39:37 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vpHI28+LKNHKoAwLIQ2w6WoRB30ahyQl9/ouRJvGjPr/LMczO+/FskfE+BfpB9nCr9e37I X-Received: by 2002:a05:622a:5d2:b0:31e:e353:4f76 with SMTP id d18-20020a05622a05d200b0031ee3534f76mr16256388qtb.99.1658864377333; Tue, 26 Jul 2022 12:39:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658864377; cv=none; d=google.com; s=arc-20160816; b=gfpnZVa/Ukup9oWNR01JiJQD7+Vfz12ccpAfAgAy6rCX0jd5PgvYorCiJyIFqMu9aj T7jqC/jD0aQ+8s/kQfcDiHS0lGtibrJ1lPd5mjVY0/PJiaM7EJQSP2QmT1Iof8M1DZeo VvjDooExuiZsmxwOK9JClMS6wOK/NC47H6oVeKQ1lwWgHpIANROMUWoKAUGrmqXgoYyF JKpd/HSY/YFm47uiB3O7Dz79BjPFZOoZ+rQ8t6NlMmkRcFQSb3noSU/JoSupRhIZnWZN H1u8J8B5fs4U4ll0lDYcn5/MhdAaUZ9tFF5XP/c9+TwC2biYBHUa2jSXMgNMYrx7DFQ1 OhbA== 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=c6PIYMIE3JaTrY/DQKZRjBqoWth+KWJVDK8v0sIayL0=; b=pTQP/Z0AdifpG3kk4FzsEXwtoAxdzN8ERHH61r/hYwIXMl7epc5ElWAWNCj090+m/Q mIb/22XWMi5nS7b4xRQWLmr+Tt3/thqCzlCvPo2p6BNjyjTJMiTXtboR19x13xEbFLI/ OhJ6tRKIGRzkOn0532+jkEKQ30syXHZXONUoHSj4tZDK6ekApiEgIE34c8ThhpCKWGlE K7NSVFvAuvB1/ZPWzkjOOgqlgOi4igwFDkF+rtGejoVgcoTyY8R8mU0vqGvO7gsxgUy3 gz1bf9Du6aFWWDCiUicnEzp4e7CumUaKzM3raTs5KWjTZ7UxdgMP6MJ0diaS7lkiBHQr UZ9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Yd1RoS03; 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 q14-20020ad45cae000000b00474129f32ddsi9002637qvh.97.2022.07.26.12.39.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jul 2022 12:39:37 -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=Yd1RoS03; 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]:48322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGQOz-0003Ul-6w for patch@linaro.org; Tue, 26 Jul 2022 15:39:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGQ85-0003F9-1O for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:22:05 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:34653) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGQ83-0002Jm-Jm for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:22:04 -0400 Received: by mail-wm1-x333.google.com with SMTP id r1-20020a05600c35c100b003a326685e7cso1292854wmq.1 for ; Tue, 26 Jul 2022 12:22:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c6PIYMIE3JaTrY/DQKZRjBqoWth+KWJVDK8v0sIayL0=; b=Yd1RoS03X2dpWLourmcbXGS38aK3+3OavISnGFTifCiACdYTsYuAM/VnhG3XMXv1Jd s6kcKw9HFfzu3Xa0Z+jm9NP6xnKsteMi36yME18o6xLclNZuX+Xq7BuxATIqQUijw0Gr SIKuveVbEZ5EvAMUAaUoGZE/MbWIvk1dC9IMuFOO1aYsH93t/Ddt8z94WQ1VphMsnZny 6REMkZ8dS9zopGQNP4gHydFnWtk6KVWHlMCWdFU87mp1ebMYhj1c6mWENRRjLJugRG9+ 3aVQPO+k0cX9ax7FZoIF9pVYOknXhuFlX+3rlgu6httxTv9iUHb4W85giUi/LMO4RYiB 3xXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=c6PIYMIE3JaTrY/DQKZRjBqoWth+KWJVDK8v0sIayL0=; b=S96P140QL/Gt4fmneV2GI5ld2MnYBeQPaG6Kzy7/DgvSqjdtcFO6la+hG6rm/O6E4M xKLPtsNinZ5mVraDjwZ7BM9FQpsHeCw/gCqeTWU2GZF0BGF27mK7TCwW4XKXQy4BKxUX tiHwcClc3QnL7+gT6b2rfAYCL+/AfHsFB8+nf9kJVBooEDAclF5JkSLQZP7Lojq5CMg9 glrQMolchi2FrSxJsmsPnUDJcwqH+Rc6CkQG5f5DcUtrmYydgz6pY4VaKABA+KfDA7zS NddGp8b7K3h3B0KKfcXMNoOX/zy/ULUbmwyvqe1LLBd/v/Kk8QYd6HUbwfy7A2UgJ0Xd FsHA== X-Gm-Message-State: AJIora+qYAlx7owHLuDU7YehUStjNb5HnJ3TYcr/ALMHrpnwqFiLw1kZ sHmfvjXsofSRkhR8V25u1UtemQ== X-Received: by 2002:a1c:2981:0:b0:3a2:ffe9:945c with SMTP id p123-20020a1c2981000000b003a2ffe9945cmr478140wmp.38.1658863321016; Tue, 26 Jul 2022 12:22:01 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id bd6-20020a05600c1f0600b003a050a391e8sm19502099wmb.38.2022.07.26.12.21.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 12:21:58 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id B8A781FFBD; Tue, 26 Jul 2022 20:21:50 +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, mark.cave-ayland@ilande.co.uk, jasowang@redhat.com, =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Coiby Xu , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org (open list:Block layer core) Subject: [PATCH v3 05/21] block/vhost-user-blk-server: don't expose VHOST_USER_F_PROTOCOL_FEATURES Date: Tue, 26 Jul 2022 20:21:34 +0100 Message-Id: <20220726192150.2435175-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220726192150.2435175-1-alex.bennee@linaro.org> References: <20220726192150.2435175-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x333.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" This bit is unused in actual VirtIO feature negotiation and should only appear in the vhost-user messages between master and slave. [AJB: experiment, this doesn't break the tests but I'm not super confident of the range of tests] Signed-off-by: Alex Bennée --- block/export/vhost-user-blk-server.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/block/export/vhost-user-blk-server.c b/block/export/vhost-user-blk-server.c index 3409d9e02e..d31436006d 100644 --- a/block/export/vhost-user-blk-server.c +++ b/block/export/vhost-user-blk-server.c @@ -125,8 +125,7 @@ static uint64_t vu_blk_get_features(VuDev *dev) 1ull << VIRTIO_BLK_F_MQ | 1ull << VIRTIO_F_VERSION_1 | 1ull << VIRTIO_RING_F_INDIRECT_DESC | - 1ull << VIRTIO_RING_F_EVENT_IDX | - 1ull << VHOST_USER_F_PROTOCOL_FEATURES; + 1ull << VIRTIO_RING_F_EVENT_IDX ; if (!vexp->handler.writable) { features |= 1ull << VIRTIO_BLK_F_RO; From patchwork Tue Jul 26 19:21:35 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: 593477 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b811:0:0:0:0 with SMTP id fc17csp3826921mab; Tue, 26 Jul 2022 12:43:57 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tsaLyUmL7CGvxL18iCxww7kCb7lWHtAx6suaaAxnFOv7BTWpoLKIUl2h7ZzYx1fJLOm5RF X-Received: by 2002:ad4:5c62:0:b0:473:4585:292f with SMTP id i2-20020ad45c62000000b004734585292fmr16559453qvh.16.1658864637217; Tue, 26 Jul 2022 12:43:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658864637; cv=none; d=google.com; s=arc-20160816; b=UoGQuMdOMWrAe0BkeaXbAFDNPRnFlPGKhqQMcKdQzGJwtpaFTVndZcTzMXMr1gPy3w c4OA3nNlHUIDi+eemh1RGwamioXswP6vigdgOKQ3G4mTYS1FVIODOuxSd+RKJ34h6PU+ Q4CNdsq8oCNKBwiLZjlKQWHBV5VfRoyienu+di2dK9vVHmJkuQzGqkJ49GaBvNv/ucrB w0nEkOZn0jNq4bb89REbIM4oa8Wu+tPkilTHfnYsRT6efVN5tzLyaRm4Bss1c1VCKlG0 rinlVMgezCxsTLVafMrA3ioLLcrkjHfI+uX/VDKNi5/9oml78igiQlTDR77Bej2buYiZ ql7w== 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=LTNybQ3j99OfucIFux/yLfgRaMJqRwC34AP3ZvaRhZ0=; b=n1upYa9EPSZx103JRKklcxuz4TGELldbIkmDq3EAqvv7Cn/UE20kjZctf86PI4DrsD T+QNA0fGubB9+Ht+lDRsje2udS5fQyBpAiDEQ5DsgUkRo8iliUuZhUGR2NySArs160t3 DKxHHKYImG2kylCZRe7l6FtvLzsg/c7l7Qq3bUhjt/ym+2bH6DumIARjW2iEH1VbGOFp nKqoipsx/QwLdRRjrsn/dICYKs2ahdrBbOALzPp55XDPzZnROIVHlpVlZIQz3LmLa6hd bsEI/4D2AB1gD5HkL/QsfPi3awnRWABILLp9x9ZA7G0iGen8iyUyv06ZjOnd1v9jxev4 p+/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QUWI0g7D; 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 u33-20020a05622a19a100b0031f1bfeb91bsi10440017qtc.3.2022.07.26.12.43.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jul 2022 12:43: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=QUWI0g7D; 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]:55696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGQTE-0000Nh-Qe for patch@linaro.org; Tue, 26 Jul 2022 15:43:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48970) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGQ86-0003GB-8J for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:22:07 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:45589) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGQ83-0002Jw-KN for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:22:05 -0400 Received: by mail-wr1-x42c.google.com with SMTP id v13so13679311wru.12 for ; Tue, 26 Jul 2022 12:22:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LTNybQ3j99OfucIFux/yLfgRaMJqRwC34AP3ZvaRhZ0=; b=QUWI0g7DdWfKkgII/OjGbhRWXJcgm++PJpQC2QIKRNp5CXImPv9wBXpTWRkv572tz6 uS2Hsj5+D1c0LPrea1oZSOc4UBbuRIShpJjmSNFjs2iAjIS8w4iqZZdzhmvmZ6qhpQrn gdi6rthlOJsWFM2yrtR+QevuCGDssYHHv/JCzOKBtZHFARKpQoku1ngcEQgyyHGzSMf4 B8UgOnozsvXYToAfaWfd81CelY3kD8gznml5lNP+Xe3Wr5wI/zlZsTu5JQa0sRE9Ex5p DIQ9lNw6irSeMTo0EJfbl+73fc2V8Qd+oFFlIcP2IF+O4zzLxBueq/2zT/iVIjzjXrb9 kD5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LTNybQ3j99OfucIFux/yLfgRaMJqRwC34AP3ZvaRhZ0=; b=QNjtRGrV6W/5htguUW5DeiNVhmZ/pBIogkQV3VYWJxxHbTjgCLeMDABQk0645Rqw4K zt/pqQ5tNhpGyUgpTpBWgGpYFbb66MQcKQJxR7Kro1QwHO7NIEj0QbVEEFqUvlxJs80+ 8diT0Oa473ZP7LvFkvzxJvDxUd6eClqD9IP99l1g4MQHYZUOc2SCyYzcOQxNmKL1Q+sF Hca8XLp6n0Q+cQKdUyFjTlIta3ly9iS+r4iTdUOvJiklBWZ5VJ+rsXwm1N/ETbHXWZdE EpMoxFV+No9HIaPyrq3a7jrVLuWP7kIih51FWM/RfsZmCnzXwX7+AS4ygcLgYOD40TV4 tJ9A== X-Gm-Message-State: AJIora/3ljiHQ4CRF0Dv3GODAOpeL92EKDxLGanOogBN8xjktzITehdY NcfpN6Tl0vPYry365V+/5nyWIw== X-Received: by 2002:a05:6000:1841:b0:21e:81a3:e6ef with SMTP id c1-20020a056000184100b0021e81a3e6efmr8889243wri.369.1658863321806; Tue, 26 Jul 2022 12:22:01 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id k66-20020a1ca145000000b003a2fdde48d1sm18548865wme.25.2022.07.26.12.21.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 12:21:58 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D070D1FFBE; Tue, 26 Jul 2022 20:21:50 +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, mark.cave-ayland@ilande.co.uk, jasowang@redhat.com, =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= Subject: [PATCH v3 06/21] hw/virtio: incorporate backend features in features Date: Tue, 26 Jul 2022 20:21:35 +0100 Message-Id: <20220726192150.2435175-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220726192150.2435175-1-alex.bennee@linaro.org> References: <20220726192150.2435175-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" 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 --- 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 55fce18480..a96a586ebf 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -1461,7 +1461,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 Jul 26 19:21:36 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: 593470 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b811:0:0:0:0 with SMTP id fc17csp3818408mab; Tue, 26 Jul 2022 12:28:26 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vj0COf0gw9SSfhS/NSVfgIM5p09r1n7vs81ooS26mLys/gwcs/IGauBscmolknGyRxhd83 X-Received: by 2002:a05:620a:2f2:b0:6b5:cd55:9da4 with SMTP id a18-20020a05620a02f200b006b5cd559da4mr14021550qko.144.1658863706388; Tue, 26 Jul 2022 12:28:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658863706; cv=none; d=google.com; s=arc-20160816; b=wv4emM/3E7z3ndLq20hyLXCpXTnXDEUybNkd1dLdCK00aiDniWJApe+Np6b5OMIDt+ 0pgxV0m2B+Nk18EzgyWLjccocn0/KCadQPYLhqm1EDVUh5L/5G4gi75nCuIjidGv0HSs UjDnK0rZOlprKiqtsROWJ7e2qPPFrJF8HG6VDJp78119v9SGNg2MTmbQzicUJOBmxcno U0BStjN1xGGvs6e3BRynhq312QeHBM/u+C6MF6cN/wHnreGvAkOBqFUIIGAS/CfXGpw8 7dBbu41eXh2ambrRDGH+fmhHQgYaFXJfKpKsg9fq3Ly6jkUxYrn+j8+vpqsQI9lI9WMn vs4A== 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=YW2c5Ruij34p53cQgqpluStohGrUyVawQTLXfkuUxOo=; b=Ma0NeJ4x5ndEQ+rJx8Ti7HgXW9/yajbaoYiTh44sFLopxAXg8rrYeJ4wfaso6Ou+ab cL4NxcGqJhVHN8+Xw9T6gk34XJ4ZK5ey3qCrnZ7WyirhR81qVCBQItevbxpowaWpsaqA ufMSshb1o+Tt/10X8G5N+7XP70v1HpVuVScVzknQo3/H1n84ukB1eT7qaw6WgbU/tFtq IGAXdy85jcuZReatOjVRorLvzoFGaEpXi4ZFPGZRcti8bQVVdUErT1BLUSSas8G1Zj7f zb+FzN8KMUYsAXyzO2gSeQr7alUkkJ6+Cru7WKRdtYbEKrIiOz4FB0HS+iD84MaQ8ozV YLjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mxvYJxqy; 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 cq11-20020a05622a424b00b0031633309b42si9563220qtb.762.2022.07.26.12.28.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jul 2022 12:28:26 -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=mxvYJxqy; 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]:34184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGQED-0001N0-VT for patch@linaro.org; Tue, 26 Jul 2022 15:28:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48990) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGQ86-0003GD-NV for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:22:07 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:46824) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGQ85-0002Ll-4t for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:22:06 -0400 Received: by mail-wr1-x42b.google.com with SMTP id k12so3724140wrm.13 for ; Tue, 26 Jul 2022 12:22:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YW2c5Ruij34p53cQgqpluStohGrUyVawQTLXfkuUxOo=; b=mxvYJxqybnU5jakdvC8TcDlzX/usyNx5Wm0CRIsmFrTfR8pVOkJN0gLh32kz+stE69 +x0ewWu94fub2IgPadAZjXc/Loy432wGw76WssW8PLLNmrUKeJ2/VSh+c1Mz2K6lw7Vg az7/YAw5aZqAmxYsVGgmsnB8rY1uzcXn+mFwzgl4r5O+k72DZHVHQ2k6M50ZmWPBKGyR 8ZbE9WrahN8FEWI1S//DXA+C7x5EtkpMokn37ldhYJA77yNDMGV3r2BVr+lcYMntgziV 6Ga00M5/lEcegD/sFHDV2ODJjX/llNH5h+aZV5zKzWFC67JwFzCHxkKtEMKJCpD1LGox US+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YW2c5Ruij34p53cQgqpluStohGrUyVawQTLXfkuUxOo=; b=QOoV27PcLwtzsP4Llj6UD0a6mFqE6+s4vA0heqcBZLzogSV/jBgMKohTj5h2eSfil3 FC/QP51hPX1FUvYY83Mk3j/KxWHOFHKYwU++wHHUI4co+SfsaHd2pqqCvWXSqnyivHTA xWh7bAZHv8J+rYfCpzz8Zlhboed768z0SKmnfVH6hroDhjpEvo3HvB/OB/R1veOuqqe4 L/XSR4gyDZp8rsQEAeIza5qr2JG/A5w7RAFLn+6sv25M+GvmbmdnZAF596FAAGkCeg1u oXukCYmbDhXl3UnismCeHTByiSaYKLFuEgytORcdGerpHuIuFdqR9WS4A0dWjPTNNghg 2HuQ== X-Gm-Message-State: AJIora/dos5MSRiTfuTqLxdwynFGHze9CHRy5rZ3S/8B2jVDfk5Lo57q xaj8ufd2RYKKKxin3hKSe80PaQ== X-Received: by 2002:a5d:5a12:0:b0:21e:8327:7e03 with SMTP id bq18-20020a5d5a12000000b0021e83277e03mr8714054wrb.567.1658863323822; Tue, 26 Jul 2022 12:22:03 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id r10-20020a5d4e4a000000b0021e8cdd0c48sm5817324wrt.15.2022.07.26.12.21.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 12:21:58 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E72681FFBF; Tue, 26 Jul 2022 20:21:50 +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, mark.cave-ayland@ilande.co.uk, jasowang@redhat.com, =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= Subject: [PATCH v3 07/21] hw/virtio: gracefully handle unset vhost_dev vdev Date: Tue, 26 Jul 2022 20:21:36 +0100 Message-Id: <20220726192150.2435175-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220726192150.2435175-1-alex.bennee@linaro.org> References: <20220726192150.2435175-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" 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 --- 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 Jul 26 19:21:37 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: 593480 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b811:0:0:0:0 with SMTP id fc17csp3829461mab; Tue, 26 Jul 2022 12:48:46 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vdtJ7jvEDIRRusFJX03OhHk3VuITIbPM4ULxQRns1MImOjYSh/L/88HkcxpJOi4Qr7Lq3a X-Received: by 2002:a0c:b414:0:b0:473:8ccb:3811 with SMTP id u20-20020a0cb414000000b004738ccb3811mr15853917qve.65.1658864926412; Tue, 26 Jul 2022 12:48:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658864926; cv=none; d=google.com; s=arc-20160816; b=itSuMqb+s3+QQN1bJmG8xd9PZfyApuj5bXezd2YxTfqlnfXZn3w35MJWmAjOosSgp0 guBu1hRHNRiDFmsc5TUexNlLatAUHV7lzumUnRiZfCbY55+tZ5Gj82ez4Up0eW7qRVeG SPfP8/C168918gwpCypgoJwMn76FWDSkueoUo0kmuxCm+q+J/NR351NZ2sniFJUmrdgx 8b4BxL9b6+4mwvm0Wz8v4UhFJn/9rt61mAfu9JbhtRBB/j+HxEW9mNtd0Jo02/rt3Jj9 n56pYah6OqLWssLASKRGn6cXKslVvK9yzw20AuYwxf3GfLd6JzZ0S7hV9xkOI2keNnTq SGdw== 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=dtgiw49DbQeIrzltHG3Fc2GoOsMK1WlBSvR6Tgd5p8o=; b=RFs1fmgy+w41zhPiXTHSduUZrSAkDfL7iLQcvjkc4SIlMQcNyDKfQMsFOnX/zjJDQy cU3tmh1zdYjVapBcx1+ZLzHMbTQJNaG8ig1PYwcdbGLy3Rp64TJ2KMLM/Vv4zIby0RJ1 q5cWTFMx6ZbPat8KqByu4fhDKC4g8Tx0Xw98N+oiaVF0T2lby+sMjFk94IXSF2MjC3fw RPiNkgDK4U+HztSyz+6ZNiLo6YF+nxtoCaFCYtlzm20NlpXv7U5d1Gwp+oDJeuRvpzjS gxFKFGLAZsDsvEE/nZySvObIGpBTkKenOD1v5IkSdm9DnmbCeGJsSz79K+pdpoNVI7mM as9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I6++dGXR; 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 bp8-20020a05620a458800b0069c2a49989asi8621249qkb.480.2022.07.26.12.48.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jul 2022 12:48:46 -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=I6++dGXR; 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]:35854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGQXo-00068D-8o for patch@linaro.org; Tue, 26 Jul 2022 15:48:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49018) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGQ88-0003HN-Li for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:22:09 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:37768) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGQ86-0002MG-6o for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:22:07 -0400 Received: by mail-wm1-x334.google.com with SMTP id c187-20020a1c35c4000000b003a30d88fe8eso11898659wma.2 for ; Tue, 26 Jul 2022 12:22:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dtgiw49DbQeIrzltHG3Fc2GoOsMK1WlBSvR6Tgd5p8o=; b=I6++dGXR/r6EXe9HQKIYlBLX+SqqIxoZcw+d+iIfMwVYNxH/NSY9NygXDz8bBeZ0Es bfASyqOUHuvZxLxcE9QbCL4FiS807KLVrKpTqgafHNFfHzpOGvHhsRa4z6EY9mWXCVrm mGt706UgzQ/xCxXijQ5kyG6CpCQ4f+rNBO60kV2z0yZNveEzWYMJ5cHaPFTUM/IrFzur 72X+Mo7FVf64po3N3yV7qAgVp/AhSoLCKsRR2FhTVVRXnzEGvdIyffrhXmxtJUIq+YzP uvISeaaXkEg1cJWuSYWcetNf6yvMSAXiOjtskWIZZ2VDkJU0EQruugQy8eZxN/tsBycM QPyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dtgiw49DbQeIrzltHG3Fc2GoOsMK1WlBSvR6Tgd5p8o=; b=JqO/sa7V4o7bwYgiciNSnrgSUXkFH8imYrX0bvdqUPkUV0QQpz1GYWIhj74AYMKB7f LRafd2ppGc0blTHQ6n4LjPhbxJHX0SIPBmU72tHKACTEHQzu/uSw2r47dLxelTChdk08 Vvbiej9d7q8whmwwDZZlhHemYhvAtY1DSLQAg3JRw+bLhHBgnqUKJL8A9jlow+YY+apc 21VZwLESg73x7HsHdqqiUI86DrcgZJvAcqnmidoJ7V2mfT8CD0yNDRdRodBhScpiTm1w NmBY6Qr2XHxwj4cs61qsbnSkT571sT4d2B81D5g236HBxFLXVKb7KkYPYghM+fobCzNz BjyQ== X-Gm-Message-State: AJIora9BS/fJf2/IeIUjdrFy8UB7ROGPpr7wPsGLXSGMYKoDC3QQhK/E Ni1I8qc/TLHnrKrNasKUNtcr7g== X-Received: by 2002:a05:600c:3546:b0:3a3:2df8:42c9 with SMTP id i6-20020a05600c354600b003a32df842c9mr429614wmq.161.1658863324857; Tue, 26 Jul 2022 12:22:04 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id z11-20020a05600c0a0b00b003a17ab4e7c8sm27433520wmp.39.2022.07.26.12.21.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 12:21:58 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id F347A1FFC0; Tue, 26 Jul 2022 20:21:50 +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, mark.cave-ayland@ilande.co.uk, jasowang@redhat.com, =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= Subject: [PATCH v3 08/21] hw/virtio: handle un-configured shutdown in virtio-pci Date: Tue, 26 Jul 2022 20:21:37 +0100 Message-Id: <20220726192150.2435175-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220726192150.2435175-1-alex.bennee@linaro.org> References: <20220726192150.2435175-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x334.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 --- 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 Jul 26 19:21:38 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: 593469 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b811:0:0:0:0 with SMTP id fc17csp3818346mab; Tue, 26 Jul 2022 12:28:16 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tlpoQ3LvdS4viyl/f2bg8iSUiKu0sKI3DI4aLeSWwM6lp35Ozjb8zEcHYUkfFqO/TKfTpk X-Received: by 2002:a05:620a:2402:b0:6b6:1706:3bcf with SMTP id d2-20020a05620a240200b006b617063bcfmr14044459qkn.569.1658863696262; Tue, 26 Jul 2022 12:28:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658863696; cv=none; d=google.com; s=arc-20160816; b=fmwYrRISHV1vCNLnzcIfi4DDfaKW6kYP7+RlfIS/2tEkANrSvTFSTbEYbLxMDeWGLk Z5bK2BmsLRLQoSVvY2hHCh4JI4HqYROuWSFTjKmWxLGbXqTuIx93puo2Hh1nRte4PKs2 GiJ7puh6nBPGL7G4s033Cy0yH0zLMCxbTefJlME/oRL6xfNYlTkuCYa4fo5YGwfVVCkH ggBSsBFctuPdZcZgYJo3BrZeV2wPrRCczKBa7jTGatwpXH1/AuAh8iRbWB59PEj4+6F7 0uM9V3lhDv+by+ayXaRjbIc0mggPFiN2baGauFgf31Tg8vbteUZZVODyPMCM5a+sSXaI gi4g== 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=xHvKCgTFOboJAxlx1VRnV/BrW7lfE7earyZdZjM6gSA=; b=U442TKS4E/O25a8M16NXECrcOPKknak5liX5ejcVhwWvvwkS+IwcJhTsYjaH5hnm7x 2A1eSzPfTtdFxQ1pOFS5XH2wVg1eIBgmd0g2i44Aoq/XMcweLi2sHpKDye/Y46NR/keA /gUBnv8R54jtFwZkIupkOVA95bABPWR6pOpHtQuyIMAAnzPln0Nk5PqVHpChDNy62FMA boZlOL0o0HG+tmUIecpfi4JjYA7mmmxnu6mjXoIcDJguB7LacUpJQR8ueQ19cuqfNwRn vhiXDvaLlZSXoaAd+qbXXzK9lUXfub4ZB8Pzm5tks1OR+Uhyh+yVQlGo4+9d7nLaR5or oQIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Jzx3eeK3; 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 iw12-20020a0562140f2c00b004706ddc03a0si9511734qvb.278.2022.07.26.12.28.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jul 2022 12:28: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=Jzx3eeK3; 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]:33438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGQE3-0000sj-Rm for patch@linaro.org; Tue, 26 Jul 2022 15:28:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGQ89-0003Id-A0 for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:22:11 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:40548) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGQ87-0002Gz-Nn for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:22:08 -0400 Received: by mail-wr1-x431.google.com with SMTP id m17so21166989wrw.7 for ; Tue, 26 Jul 2022 12:22:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xHvKCgTFOboJAxlx1VRnV/BrW7lfE7earyZdZjM6gSA=; b=Jzx3eeK3Bd+7DFk/YQqrFhuAfovlpYNiDON5TdSKn+roVK5OiJj5M63gSMs9Z7pm0e x6jUJ/LkB1108z55lUHM9bxBHnP/qUEDRh4c7+A4tWNYJgaGLoJM9hfskWzKwAY/x7L3 Pdg9YIgfAkAwPeu6FN4zJYndSuG4nJqKbqYQqLu20HzU/Y7BnBKhGTmI9wwotgFf5zLW EXQwTkJwMYwkgOzJanDfK5CQkYV0wNPm48E2afrEXXjKH7FUvLK24IRv1qCZ+JMDw91P QwJL8zsQPxWpwsxn0/ntDL4XkCM/3JvkD+kEQwSJqSPpeYpTuqQpnx5YuReJNlMDh7LC P+2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xHvKCgTFOboJAxlx1VRnV/BrW7lfE7earyZdZjM6gSA=; b=NVYbdjzYDedkqHGTLW5c21EEsK45bfgCz4fnNle88b5MTl0W5NwmVKQzzj/izaA9m1 bpvA5MedXXpnEmUedc2xOBb4tYETYkP1vKsPNdg1zHlGGpQfao5ebGmaZOT7MnanZqqJ VACKk6nOHZN84AFh5GBfIIMPF26OYcLR4M9T6OmQzGgmuCeXG5VLGR5cZY0pfF1vkY/s 8ThHLBR/lcUj7152CyhaABHhqAhy6OjRGgPd5MqEz8EWGx4lzFcs6EFooeBih9kMCw43 pUi6r+inadDW+cbvxp14HRxE6neZcvDXA9No6B72V1S3zYMif7M+Iw10LAZk2MGAU33T yn9Q== X-Gm-Message-State: AJIora/aynVxELDT5T6xPaTS6v6LUUkhoOd1pxVfl70e3KlncsBkfqSv IcSPLCdWc80venlSqbizy3FaEQ== X-Received: by 2002:a5d:598e:0:b0:21e:7348:69bf with SMTP id n14-20020a5d598e000000b0021e734869bfmr10706399wri.157.1658863327071; Tue, 26 Jul 2022 12:22:07 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id c17-20020adffb51000000b0021d7fa77710sm15226747wrs.92.2022.07.26.12.21.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 12:21:59 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 14E4D1FFC1; Tue, 26 Jul 2022 20:21:51 +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, mark.cave-ayland@ilande.co.uk, jasowang@redhat.com, =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= Subject: [PATCH v3 09/21] hw/virtio: fix vhost_user_read tracepoint Date: Tue, 26 Jul 2022 20:21:38 +0100 Message-Id: <20220726192150.2435175-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220726192150.2435175-1-alex.bennee@linaro.org> References: <20220726192150.2435175-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x431.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 --- 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 a96a586ebf..b7c13e7e16 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -296,6 +296,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; } @@ -545,8 +547,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 Jul 26 19:21:39 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: 593476 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b811:0:0:0:0 with SMTP id fc17csp3826891mab; Tue, 26 Jul 2022 12:43:52 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sRgfR29Nxdj0Fj17WJVH6lD95ntD81NoHnJJZKX5Dv6xntyI/bV1C20plpFXGM8kNe81T4 X-Received: by 2002:a05:622a:60c:b0:31e:f64a:6d87 with SMTP id z12-20020a05622a060c00b0031ef64a6d87mr15477189qta.52.1658864632342; Tue, 26 Jul 2022 12:43:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658864632; cv=none; d=google.com; s=arc-20160816; b=I67HmPl/RiTqI1COxWPnRUAEgxfkg2IiXF5rWS80EuLSzcQXBvSBK6q3tgPX7t7lpz Ysqnm8EYIeunkj5G3JMttwZ7oZXUYKAebClzCmPPJn3PXTsWdLfo3sT2bEr/qokH5fke UfmMrsBQAEV5um2TJ43mnGD1K26jLy7pzg0iPGsRM27qaQ8KvXF80pIZ22/FkaY9tjAg IjuO80ig+MIq8YYVPhTyaYxB36SFq1qvW7NNa4+PvV1EqBtHmSLXvr7t+lbFlSS569aG VyAkZvCgW359o0t6EBkjo6E6XgUr86uOl06B3lpiZa6ABSldAe3rpWDfizai4UM8C14p 5JoQ== 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=ZzcKf8Q8HAil7IVWAbQSva4DY79b1SArDqgPqDv1RTT5Fi4UH2t2iTLORBWI2eUcAA C5U6iVsjex5+W9R5gr3sL35WQ2Y06BCOmCEg6rFke60gobLDCdjEuNF0/i+J6Lq8ftF0 /sngvoD+TZ/qAsibw4A5RUqhdQZPCK13QZOVHew+QW2sCssXf58FDW9AL7p8LJ42nD0f NUJmgkIByfIjpPR6qgj17fqWUUGYx18mZKiK2tDXR7tV7r1eGcwXzb5r2hnNcKrcCxzn chBTFOxx/aVwR6CK8dWnjI+pJPkM2MnKJXSOp02xHIb/O3j0pLbJE/di8KnQnciD9T42 Pdnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BIHOIza6; 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 cb8-20020a05622a1f8800b0031ee23a45d6si10027213qtb.63.2022.07.26.12.43.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jul 2022 12:43:52 -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=BIHOIza6; 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]:55276 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGQT9-0008Ub-SR for patch@linaro.org; Tue, 26 Jul 2022 15:43:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50702) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGQGF-0006c3-8c for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:30:35 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:39721) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGQGC-0003fN-C8 for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:30:31 -0400 Received: by mail-wr1-x435.google.com with SMTP id d8so21379829wrp.6 for ; Tue, 26 Jul 2022 12:30:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=H/ZcxJebFvV+fJPCaMkPj2jiRtkMtcjbXvy3+aTz3aU=; b=BIHOIza6CQ9fpueZJUYtrY+GVXvVmKOUei4TpHPySZ6oVyv0LPY7Qs3ltOpq7IQj1K Umgd3i7m/uJKXDFTIuLZEYXqoGbzb07fsiDgWR9e8tH1dG31MNti0Kv8vb+NiSs/RihU DBgO+SZvcONMaSLQYJgv0KshKJvWuQo4BDmyfilzi/IsSK6q+80FOdFxO0vmNPFoG14I Sd4rPKg8uLgUSlLYmntkG9owaF16Lqlj5c2FF5gRZczm/96zpSIbr3u4qLwgAdkwmP7E GWWlwiPhMjMnwdBT0qXuBPowfCY0OdpVfKI+UWX51CbUbwVnttAn81BOsowMQDewsgup LA8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=H/ZcxJebFvV+fJPCaMkPj2jiRtkMtcjbXvy3+aTz3aU=; b=gNzpohKQJFLFF4Io8Mv51VXolLC0AYkZ4bJad+Q/EKAkpyN60UqBZ55oh+8+KfaaSQ kIDBlqSd5+WLPCoP/G1ZH7KvBoM3BMnW+y3HNWE13AabpyOwm0qlAo4og6qCLfzr/EG3 CoCsix353tlYhdp5a7PvfNJ6ESpNhORcQr8SFV6tP4uj8zgAC8bufaRiQKGldHx/9f3p a2AUVuvIomuulsChM5tnsdDByk7zhyzlaO9vbqurqxxyc5PoD1sRg8Qm7gjfPT5bK3ry HBDvKwucPjFwD2RCsme3Xygd2tJadbvH/gD5UwBAznor1jWe245eg6rc21RGx1ifVEAi BLrg== X-Gm-Message-State: AJIora80eBAdC34ATRHSCAWga32RmvZDvuxOokDco/wrkJWdKJGpsoy7 DWG9vJGHsFM6TrNWSIZYBdlWoQ== X-Received: by 2002:a05:6000:1f8d:b0:21e:83a6:cf87 with SMTP id bw13-20020a0560001f8d00b0021e83a6cf87mr8288520wrb.559.1658863824683; Tue, 26 Jul 2022 12:30:24 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id c17-20020a5d5291000000b0021b956da1dcsm10679692wrv.113.2022.07.26.12.30.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 12:30:21 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 232BA1FFC2; Tue, 26 Jul 2022 20:21:51 +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, mark.cave-ayland@ilande.co.uk, jasowang@redhat.com, =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= Subject: [PATCH v3 10/21] hw/virtio: add some vhost-user trace events Date: Tue, 26 Jul 2022 20:21:39 +0100 Message-Id: <20220726192150.2435175-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220726192150.2435175-1-alex.bennee@linaro.org> References: <20220726192150.2435175-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" These are useful for tracing the lifetime of vhost-user connections. Signed-off-by: Alex Bennée --- 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 Jul 26 19:21:40 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: 593481 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b811:0:0:0:0 with SMTP id fc17csp3829767mab; Tue, 26 Jul 2022 12:49:19 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sIBfDNWgZSefdQn9TqCFdFksBfsbDJFXF2badN3ibf3Km2s2guJVIQJhgH5TT49Uee6tML X-Received: by 2002:ac8:5b94:0:b0:31f:4040:2c3b with SMTP id a20-20020ac85b94000000b0031f40402c3bmr4299185qta.320.1658864959469; Tue, 26 Jul 2022 12:49:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658864959; cv=none; d=google.com; s=arc-20160816; b=kBfDY0nG1t9qqwjBSFBBDL5n+J/sjsZNfku6Aok2vvWRqB6Xko5OD5UJGGJTlYEfDr Gf+/hXP7t5WV7b3h6SlmO+930aUoEBkMd6TunFiOPwDYGrfw6XIN3skowOEnKtapdqVS K6XESvb50KZENKoov9WmLgb96l9ByGhWRlmsvejYDpXgoz02t/sd5wZOMUkGpXzY1JEP YR/DLiG81CzTATej8fc3F3enaNv0PQpYeXoK8sN2QD42ZEsiu7VnEEy8bAuC4j/89A0/ 7vV4IS9J2ltVcdvfLIZk02Rz9EPU2Ka1ndoODaSAx/93WEIgg1vATWv9l/OlcV+AUryv lVEQ== 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=FoZeVp7JoBfeQWpKR+aNPS0/48Z7oPUNFcWapzaHubk=; b=ArhEeYwFRZcfvvmsCGuMEeJ4P6iKnsYHVl/7PooaW1BufRwA1b2/8kJjznv3E8jnDl f6jqU0T93fCbywLek1SPO9/GvAxB9SqgS4TTcw0hBHb53SKw6kUFsC52DQ0eLo7bIjcx 8cvo50MOpjVfLiCloGpnXup2y1EjwSiFdD5LP5V4VgB8mD5+xUjzOsr65GFbv+6hL0dh EmLoWV9fjjicu+RKCJpodXVUHHEoeyEQ+FbhgF9zqIF2qK/haNaL45+cRXuEsdgXefL9 PFqzAfQ/+t8g/j7BGoJq6+dSNFUmbpXMmqMAxNVEwIwGXVi6HCU8k7ScmN0Y0+DpsbGZ E3Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dsp73vam; 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 s3-20020ac87583000000b0031898a8698dsi8218486qtq.534.2022.07.26.12.49.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jul 2022 12:49:19 -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=dsp73vam; 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]:36304 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGQYQ-0006Qx-Px for patch@linaro.org; Tue, 26 Jul 2022 15:49:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50700) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGQGE-0006c2-R6 for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:30:35 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:55124) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGQG9-0003dD-3o for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:30:30 -0400 Received: by mail-wm1-x332.google.com with SMTP id n185so9334059wmn.4 for ; Tue, 26 Jul 2022 12:30:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FoZeVp7JoBfeQWpKR+aNPS0/48Z7oPUNFcWapzaHubk=; b=dsp73vam66eaXFJ+r3FrurH/C1Tfz9DUUk0szSTEr1Blw8xAIdRRsfDh8Kvn6uVR9+ VN4Zq8xxQ0EHWresOD60bOYH7aSpW2veNZI0hg2z96ESbVz+m06BuYSfugb+dhUAQjWn 37Nv7LD0DsKiGeuDIcYLUqtKtAU4KUwk5eOpMpxg63gufxWJ3J3WnxfiqTkJygw/92+4 uQdiJ0OrfEAM7VYaFilQLsoESQa2e+4GFlxKV2yyk/BYhtXW05pNE9P2PW2PDsiVuBYL 4fQ6rDtpPZYW5XIj69IFBukR5qdrtA2OFnhJBmm/VqJ+elwyeEKUahQvKlUnhm3jk27a 9Y2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FoZeVp7JoBfeQWpKR+aNPS0/48Z7oPUNFcWapzaHubk=; b=FUgt9rYrMf8kEeZzRpNIPQUdQLgnTF1KWuS5utOIjsq1xlASpPTOWVE9m7sU2Ayltk Z1lwVbv+jzC8UuCc2uyggX07TYI3aBRYbyDbVNXBIsGo7u1gAYBV9DNvNJvIVHE8o3KP 33TQf6OwY9asdjtCu4DzFGwrL3UNClRF2G110CAqC5+mPlr5K15RbmfXJCaBbj9CmLvP w91qTLZwnJXGY/LjKe5vx+WrA55coSmafiYyLrIKqqC8Kygq2I9pcUDRNpjr16q4xJus janTs/11J3GlSgWWO1DRDZIro3tp4GicVPMRSxoDxyAMfb4okDLxlyQisddFdKoWoEwf 65ZQ== X-Gm-Message-State: AJIora8D0S5vBzc0hJL3E/HXEMeMcodXI7A+qCmRx3LjsTg32QJsR1KO DLXM9FoKqsGffsLVtUBp/0d/ag== X-Received: by 2002:a05:600c:19c9:b0:3a3:469f:c1e7 with SMTP id u9-20020a05600c19c900b003a3469fc1e7mr450379wmq.141.1658863821384; Tue, 26 Jul 2022 12:30:21 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id h10-20020a5d548a000000b0021e6c52c921sm12383680wrv.54.2022.07.26.12.30.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 12:30:14 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 488711FFC3; Tue, 26 Jul 2022 20:21:51 +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, mark.cave-ayland@ilande.co.uk, jasowang@redhat.com, =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Vincent Whitchurch Subject: [PATCH v3 11/21] hw/virtio: add boilerplate for vhost-user-gpio device Date: Tue, 26 Jul 2022 20:21:40 +0100 Message-Id: <20220726192150.2435175-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220726192150.2435175-1-alex.bennee@linaro.org> References: <20220726192150.2435175-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x332.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 --- include/hw/virtio/vhost-user-gpio.h | 35 +++ hw/virtio/vhost-user-gpio.c | 414 ++++++++++++++++++++++++++++ hw/virtio/Kconfig | 5 + hw/virtio/meson.build | 1 + hw/virtio/trace-events | 5 + 5 files changed, 460 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..d487966c7e --- /dev/null +++ b/hw/virtio/vhost-user-gpio.c @@ -0,0 +1,414 @@ +/* + * 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->started) { + 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 = status & VIRTIO_CONFIG_S_DRIVER_OK; + + trace_virtio_gpio_set_status(status); + + if (!vdev->vm_running) { + should_start = false; + } + + if (!gpio->connected) { + return; + } + + if (gpio->vhost_dev.started == 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/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 Jul 26 19:21:41 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: 593486 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b811:0:0:0:0 with SMTP id fc17csp3697mab; Tue, 26 Jul 2022 13:11:58 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tqJrtmfBmt7FEkMABVsCRW6IHQPrSqgulOqc9uwhPU+VzZGO+wWtuqewmtHCJaK8Gc7CXa X-Received: by 2002:a05:620a:4091:b0:6b5:f03f:dd9b with SMTP id f17-20020a05620a409100b006b5f03fdd9bmr14305967qko.357.1658866317980; Tue, 26 Jul 2022 13:11:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658866317; cv=none; d=google.com; s=arc-20160816; b=tcS/g6756AYxTktdlYw7o1x+SGuX0WzctN2zXXhnWOLhzB49m3dCzILJKL3EK05SFK 7Sjpdx7eYQdLvu3onRx3oErSZ4O9SFNnkjWgSPBmwa62uuoskxcWKuU9tzFHjg7jeKi5 MSvN+mbLpMVqoLqeowJIFtqnY63EHKzZT5U1ttemdd0WJTy4pslC6UF76BrBHvg/VkvY dVLJTXvYKYlnQECeKNzV4YU4V0gn1+tiJECi7SAyYK2POpu9c4G2wNVJjuuL51D2cFqL SdgAfW7jPD94A+r9od2HUKvGRqR9AQ++Q4vnwhQ/oqWa3ESYPGcHAlFu1XMqAlqpgZsB FYhA== 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=TJYGQIz+rWx7e0twPEDMb7ZMcWZRr8Vc82PxTGHPmrg=; b=KjKxIb1l4lhK8AASqkntsZhdmUVbM6Zg6YJjqWygXlqq/cDwg61v6zIbViSoCSQ8sM 1Z0HE9EAzhQ9SCH7VzUeUpq1fLvWhz5cKPYoiqQPbP3hjqqGcSJAaI/JIBTJcTatnqqy go2xPEu/38UXO3gV+U3z93aTvyoV/+DPdMC7eX/h579daK1fL6CisEFOfmUDpwZrE7cb XLINE9Z6Zmlo6Uokc/yueyfkzCYp9AP9S0e3aVtIbIbE6k5/WdLbn/sfZbRUHImuow5A GVFYNFZ3+MEvCW0i2WQef8+KcSyO3Fu7bHo4dlccrsreVM9MPfBFKhdMrZvd85L45Jom gvbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rbC3RCkF; 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 f12-20020ac8014c000000b003189fcb89c2si10845461qtg.626.2022.07.26.13.11.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jul 2022 13:11: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=rbC3RCkF; 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]:44584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGQuL-000773-Ap for patch@linaro.org; Tue, 26 Jul 2022 16:11:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50644) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGQGA-0006bj-6V for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:30:35 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:34779) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGQG4-0003bF-3k for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:30:22 -0400 Received: by mail-wr1-x42c.google.com with SMTP id h8so21457802wrw.1 for ; Tue, 26 Jul 2022 12:30:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TJYGQIz+rWx7e0twPEDMb7ZMcWZRr8Vc82PxTGHPmrg=; b=rbC3RCkFQLOWSKwxagAYuVJF2zp2n0bmKFOy5vbWFv0oWniEMmWI8VGPrj00yOq/RY lmrijP9isQ0gJmD4ZjL1mJcPXzNfb2gyogn1amPM+wc5/ffM9jhvE496ilnfO3FFaKdP 1wz2FORZIdXkeaiy8juQbUQNO4YoENc+WW36Fstgu2KUMwYEcY6Y9TQsHtTdtVHyRGEW ZdzIYdpdixxW3mYd4s396W9WIElndQgkEUOVXS87JMUdC+zIs8c+su2yQR+ggjvbypeX Y/bcubCquOg1aUCH8BVRwqM+MMDkAGA+HSQu8kQJ62+6jOOh3yaexPFqoKFK8/fNZCAr jw9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TJYGQIz+rWx7e0twPEDMb7ZMcWZRr8Vc82PxTGHPmrg=; b=jiuYZ/TcMzPN+CjHikXny8TI+AsrIsuk8QdLrrhTIZNxfgIynMItFVw0KleBUKJdaI nPmDXT9rtV2l1aQoyqQFcMp1t2fER6Ut598r1WBgYsy1NJ0sZQMSEEE3B6B4nBiEHm6F GVeRvprU9GKFenNh6p9KO/vORgZ/lLSX00xYXhjyaA1/CRFKHiMbtIOfSTW8bcjft3hN f0xwtv7RCIpkw0dzyoBzdDDXfybQfRLbjSyVvgpjzthFJlVjwMybBt38Ix1iuZt5kP9z Sbh7BFLq9DVluvSSuIudQFjlP2UnxG89O5T/KrBB/3fevA4P3fSwFLkZJjtH7b8TkUbX Firg== X-Gm-Message-State: AJIora+StU0UN2GK2wqIbSrUZCIGUNAg2Cbk/NBQd5+5oRacEatXzDgy q8xqqvIlyUPbRkbF0lAUshaG3Q== X-Received: by 2002:a5d:460e:0:b0:21e:6d12:d308 with SMTP id t14-20020a5d460e000000b0021e6d12d308mr11951414wrq.419.1658863818534; Tue, 26 Jul 2022 12:30:18 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id i6-20020a5d5226000000b0021d6d9c0bd9sm15124735wra.82.2022.07.26.12.30.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 12:30:14 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 62CE21FFC4; Tue, 26 Jul 2022 20:21:51 +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, mark.cave-ayland@ilande.co.uk, jasowang@redhat.com, =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= Subject: [PATCH v3 12/21] hw/virtio: add vhost-user-gpio-pci boilerplate Date: Tue, 26 Jul 2022 20:21:41 +0100 Message-Id: <20220726192150.2435175-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220726192150.2435175-1-alex.bennee@linaro.org> References: <20220726192150.2435175-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" 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 --- hw/virtio/vhost-user-gpio-pci.c | 69 +++++++++++++++++++++++++++++++++ hw/virtio/meson.build | 1 + 2 files changed, 70 insertions(+) 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/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 Jul 26 19:21:42 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: 593484 Delivered-To: patch@linaro.org Received: by 2002:a5d:6682:0:0:0:0:0 with SMTP id l2csp2908897wru; Tue, 26 Jul 2022 13:00:19 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t+i/rVd0O4j6ACiLSy0yoH+DQup9+OgxUECtxnRkbxrqfz5NcnP3o0OdVWsh/M/LXt5+qI X-Received: by 2002:a05:622a:cd:b0:31e:f195:6196 with SMTP id p13-20020a05622a00cd00b0031ef1956196mr15956636qtw.95.1658865618841; Tue, 26 Jul 2022 13:00:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658865618; cv=none; d=google.com; s=arc-20160816; b=utLz5fLCKIP1El0Apkp5xRMa0rBApr6zJuOJwazoqZc6Gw6d371hAZ2Z/3HSvK3hyI a8X2zo8ur/QR19pHoJNVyP89Krj5ltErUEhRQ1JmyspaXXUVEScxmN6rTr6CYVw0TFKm kE0ljlnXL4xF+30g7ZpIDRrdhZxUqrxw9DZbUFpby2GR1O4inqAiqSrOs7IC2PE+yRnC 87xWpbaiZUIqlWjIw/2ndM2PVd9zBSNqYLL1XAAenF7YdJjjUjm16IwxhVHQxYDFI94X KacqB1LLJWLW6BEHK9zg1ZhashxENjQh/vjqAi716BUrvzPrNZCJTZxBVUqvZkeshUYx PrsA== 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=Pe5Zimqd2c5xifMUxUMxyry48TVU96KwaVMb7LRHl5I=; b=J+6obFvBzqrefnAbL04Evtn2vDG/TKanCDegd5e8pR2WpRsO1IyNV3SogM/EmWdItU hEn4sagEajN8Aa0k2hYSHlWFBphxHPO8S47TFYdCsvnMTU1GvEk759325qq+ruQEB74n EqulPvdosuoA17rS+V6CkT8AdrV5LYjm8xU1Ze1/vjJAOlxUfTxRN91wGkmAcNyOymcx WIMkTpCDeVSuIuGV0X4MzvPmODSgxk3YTRzYDD+gALD2Att3xkXrAYCkdv8AtqB/FpBG Rk2cK7ONOi1r2KwWZiokF2cH7OCjaYLYhaAXNrQkUUlTM80i0Cp63iZRfpk5cAmzLrFu dRsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zwzj80eC; 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 jp14-20020ad45f8e000000b00453c887d73csi10516440qvb.413.2022.07.26.13.00.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jul 2022 13:00:18 -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=zwzj80eC; 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]:57940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGQj4-0004bq-9s for patch@linaro.org; Tue, 26 Jul 2022 16:00:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGQG2-0006Yn-Pt for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:30:18 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:34668) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGQG0-0003aW-Vs for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:30:18 -0400 Received: by mail-wm1-x329.google.com with SMTP id r1-20020a05600c35c100b003a326685e7cso1301181wmq.1 for ; Tue, 26 Jul 2022 12:30:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Pe5Zimqd2c5xifMUxUMxyry48TVU96KwaVMb7LRHl5I=; b=zwzj80eC+gHx6S0MoXibeXV7C+sjg2dr+TLUyHkjnGt+Cg2Sf1+KAv5Ggc9hq3E1TV 0/lOeuGlI/RQ4BEoQHchHdjXTI6VdskcHTY8KmUxGxsRXvC9rOVlIFPc5LXZH84yvodX PLC5pN3IsB7mYgsbnxnyqtIgl08yCRvL5titeMOfiLRIg+zMd4UuMhcw8FmwgydutLdR B0YQ6Hqc8zSHqFQxZ2XnzCYDsG2/ey8l6P+ABSzWCalfgb67bFleLsaQtVacb6hsWsfz bLRSBCxgHapMa3oa4z7fmbZshin1lg0kgE+scV37f2TP2iC57u/OXa9LHVaDUl21YB5d S/oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Pe5Zimqd2c5xifMUxUMxyry48TVU96KwaVMb7LRHl5I=; b=SPTkS9rT5Jcr15IVQOp3uz1lVOrNwA7QJhW5AmbyCJPvQSngcKoI72XvJogL9JA02I GMo5BnnZYz1QEnDiWdcTKXvPhFldTzI5KikEAf0ri0x0ri7tbZpO1Wce+L5MqAG0o8oO QH8196tAqzi8j5Brxk/8dXAZWE1emwBqo+Z2EM8zEOzL+fx6u0m5g6e9nqOJCALZ5Rcr ALFVP+mCkrA/KZc+PiIJppC+9U1ArDVkMpP9lvd2VJ6EdwDh8hjxM+gyMyZsvUhWd3xL h9x/7KpaWUyEly5OOU8ZyG2jWBVw0i+Zyq6Wsc0/pl82W26Ra/R2r9vjLfCqHukO1dKw GSBA== X-Gm-Message-State: AJIora8PcaqkDG2g/mx2x6CHAJlY0ceUf+kT3SZfrqA2SB6j+Gglgcqr Jb0Tsa0JlX7iunG77eC8E7hxvA== X-Received: by 2002:a05:600c:600b:b0:3a3:1176:222d with SMTP id az11-20020a05600c600b00b003a31176222dmr510171wmb.42.1658863815304; Tue, 26 Jul 2022 12:30:15 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id p15-20020a05600c358f00b003a32297598csm23918246wmq.43.2022.07.26.12.30.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 12:30:14 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 6E6961FFC5; Tue, 26 Jul 2022 20:21:51 +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, mark.cave-ayland@ilande.co.uk, jasowang@redhat.com, =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v3 13/21] tests/qtest: pass stdout/stderr down to subtests Date: Tue, 26 Jul 2022 20:21:42 +0100 Message-Id: <20220726192150.2435175-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220726192150.2435175-1-alex.bennee@linaro.org> References: <20220726192150.2435175-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 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 --- tests/qtest/qos-test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/qtest/qos-test.c b/tests/qtest/qos-test.c index f97d0a08fd..7e1c8fc579 100644 --- a/tests/qtest/qos-test.c +++ b/tests/qtest/qos-test.c @@ -185,7 +185,8 @@ 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 Jul 26 19:21:43 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: 593478 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b811:0:0:0:0 with SMTP id fc17csp3826960mab; Tue, 26 Jul 2022 12:44:02 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u1rjrts9qOE5Je6b70nR/gCGFBSnioECxYsNeGvtJyGgayYUeH/zYrVr9diwq2pvHUEvEn X-Received: by 2002:a05:620a:24ce:b0:6a7:48c:f0d5 with SMTP id m14-20020a05620a24ce00b006a7048cf0d5mr13859840qkn.314.1658864642083; Tue, 26 Jul 2022 12:44:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658864642; cv=none; d=google.com; s=arc-20160816; b=SpRRPqcwkLEk937G2875rUufYAD3OyKT7S4Q4A5fiLw732CNMSfqSy47hVdMMaKGFy 43RSWij4dGwMMLzXj8L5Q2uYJMCHqOIYPB+zrYUMX56oHFQ4d4PGa4DbeWhwC2hHCY8z Bqw+pGSz2aEfy743T8Rg4htQPYfV4FL5CKi6gfZrfadM5eQsLmRu0f6GbK7RaNvyAyQz gpEv7EKMBoue1x1mVwBrYAHN+hu0BfV1e5cfenkfXDCHyUGGnBcY7aDgLmi4vTmU6hwq bBC2dqvI4J17P50RuENw+6W9JQM1MqbFlY08zkvpkcJ1KVOO0A0mVpsBdiQmL/zZtGNX yt9g== 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=P5Luishia3JsScTlemeh/OGK//MTXXlEPATJORqsFXk=; b=PdEJ2o+tG5s+o/KturTlYaHSrMQZNzMSetqYAyveugJCxY/dNgaWBii4fqdFYO0+hZ ov69KZxMM7cr4clEXSOmyeyq81yS8fK5dMgflIoLcnNlPDlUoueNEarVL7czGW3DIkQE mg/5acuITj/aKo4DUygtGzJx2hISSABd4PAe+WLpVMyHj3VS9jK1Fw2GV6/JtDv0pS5y XhBGmmPt5KZgepwe3KgVx3pEgkksS1ELgl2IbFAS81KpOTPv9mPlaS4sWE0uhpCFx5Qe iMSQ6HJTz4jo2woWckTZRD0Q4NrN1d2TNsdmC78KxA26ZCkdsTO7IgoRS65h2AtIJ03q mocQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FJ0ozNSO; 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 a19-20020ac84353000000b0031eeefd897esi9045759qtn.138.2022.07.26.12.44.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jul 2022 12:44:02 -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=FJ0ozNSO; 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]:56082 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGQTJ-0000ez-GQ for patch@linaro.org; Tue, 26 Jul 2022 15:44:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGQGE-0006bv-0e for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:30:35 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:42555) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGQGC-0003dw-3F for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:30:29 -0400 Received: by mail-wr1-x431.google.com with SMTP id bn9so10600628wrb.9 for ; Tue, 26 Jul 2022 12:30:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=P5Luishia3JsScTlemeh/OGK//MTXXlEPATJORqsFXk=; b=FJ0ozNSOgJ0610Goj99oH33uSlU2wu+o4mLZ6/mlIt/TQErfghJnvEi+Ni24CkcKbj sSt5PTn7rguP1jcg/zoKI2xEw48p4KlaHYrzna+YTW1tomW5xlmEidBXoH9OtdG20UFZ gKLpWPan0Erl2sAwJ8pTUzWqhKaZUMJKWflXthbAl7IwksYmlw7A8ZjKBuBGJRwSieQo i3cz8E17pVgsFyh9fhvPc1OcZ6IO074GVyVHlQDINcSckP/Qa1nSjOOoamy+B1P8+V4f Ci6lM/shr8i3LkUA5qt7oQ0FBsd/Uoh+6tR9K0riHODkEhosLDBqX82e/2e1NI3sBMkK ebBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=P5Luishia3JsScTlemeh/OGK//MTXXlEPATJORqsFXk=; b=bk9g7dkK8/MZN0IBY53rhrAsxa9Qu5ZKHKWq6XwwAA4HA0CrFt5px6NVn/AuLkDc1i ygtxpveXaPMa4GIQSzckCXCK+okXpxFQUA25oKYWg1MCMH1bA+6Jt2XrV5nd7GbBlAky wI77pdEhnBEXilSlF+bA9roxT4C7kra4UybXg+Vst7QHc6OMIM25VXOzjoFJloWH89UF D425Z4M7g6vHXhw/Lx2RhXGyIomUlriU/LZIckHebkkRFwIpFtGLGrDv0CXGRFsbDbtL RT88ywTmIY2m9CxK+YkDcZSMW35EkX3AV5uhNZ3klh9UNzijFLJWNrDgMbbP81UexOl9 N4BQ== X-Gm-Message-State: AJIora+EI7mwdafe7X2Uezktziv8mHOCakLFj8zHqnlzyS+YLUtfvTC9 vTM8DdfywKYXcezE2BHmWWTH6g== X-Received: by 2002:a5d:5086:0:b0:21e:4eea:eea with SMTP id a6-20020a5d5086000000b0021e4eea0eeamr11444818wrt.47.1658863822781; Tue, 26 Jul 2022 12:30:22 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id h7-20020a05600c2ca700b003a3253b706esm18044920wmc.34.2022.07.26.12.30.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 12:30:21 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 83A4B1FFC6; Tue, 26 Jul 2022 20:21:51 +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, mark.cave-ayland@ilande.co.uk, jasowang@redhat.com, =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v3 14/21] tests/qtest: add a timeout for subprocess_run_one_test Date: Tue, 26 Jul 2022 20:21:43 +0100 Message-Id: <20220726192150.2435175-15-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220726192150.2435175-1-alex.bennee@linaro.org> References: <20220726192150.2435175-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x431.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 --- v3 - expand timeout to 180 at Thomas' suggestion --- 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 7e1c8fc579..ac23def284 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 Jul 26 19:21:44 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: 593467 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b811:0:0:0:0 with SMTP id fc17csp3815578mab; Tue, 26 Jul 2022 12:23:59 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vFi76J5qyqWw5Mj+tlxyonXKv2exq3ceAjw33mfCfjgf+kXTmO7k63+aLeWqW5NAD5WKk+ X-Received: by 2002:a05:622a:1301:b0:31f:373e:b8b1 with SMTP id v1-20020a05622a130100b0031f373eb8b1mr9799075qtk.387.1658863439247; Tue, 26 Jul 2022 12:23:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658863439; cv=none; d=google.com; s=arc-20160816; b=KUe2kpzVDyTVGistSwL4bQqHIYi19vrgYBsmsgGvEQudj5/pqOwraoLvv11i47oHzt 7bql5HcTbBi6+3pGK/73AvyGdV9u7YTN+n+hffgBSWUpHhy5jXwxQslzdXfoHZwJez2W XLvxKmnqtBZpTK3cv6Mf8WExkRFZ3kbyqgK2cOvtdQGl3wi8ypcX6eTLpu9/AP3xS6Z9 sRSGMLD7JfuNCbDz2LHSYhI+b/gbuE0+1fNa7KNhezSmMgiiMInO7yI5TZvsYOCRFtIZ yUWMuCiG6nMu9vV7awOsIYfE0FaUAxGojp4tAuDNtYs3LGYObjbTJVlOH/seibjkuGeL 4aJQ== 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=rgdjLK+rHmGYzX+axfdcXU3cC80ktttNYMslWS8NxWI=; b=uK4jnKI7S9L+kLokTFzwgfw2QP/pdJ+7JNk/cZ/v99qFtIWoFef/Jr4gPFQkUrSvDk MO9sPIbNzCk414VYaP02V+lR6oJ4L1O6xSDRVSss2LkkOBzx5vQ7qL8NPRJkyvLOZp8M QvEShtltZ38IJnVLE5ScnkeySI8XQDZ0Eny6QcjBK+oGc9+lgI9knsw9fDW2I5WsBSEI 37+yfbQH+ZC8SWbkCE1k+XVx2X+PjSH2BPzu/K4xAB2F125AN2Iy8PL68RAm5R2qQSoy xpfQktsxU2c6kRVxEZz75Ui2V+O8wjbDRBwhuJaiiAm4/k5W7eKBVc0C6p7TdIHL6Tsg 3dpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bxqWqE5c; 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 k17-20020a05620a415100b006b59c3bdd88si11766413qko.243.2022.07.26.12.23.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jul 2022 12:23:59 -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=bxqWqE5c; 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]:53278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGQ9u-0003Nc-Nb for patch@linaro.org; Tue, 26 Jul 2022 15:23:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49048) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGQ8C-0003LR-DN for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:22:12 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:42996) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGQ8A-0002OI-9Z for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:22:11 -0400 Received: by mail-wr1-x429.google.com with SMTP id bn9so10575923wrb.9 for ; Tue, 26 Jul 2022 12:22:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rgdjLK+rHmGYzX+axfdcXU3cC80ktttNYMslWS8NxWI=; b=bxqWqE5cdTZyQNhToMXoxCgKMRyOYgZEl/xoUkm3uBAbqW1J3E3JcxNGIFFCYcik8R v1an9MAOYZ+Py5I3CKXRsjGiorpPEd8/6MsNlXctQ3PkSEF/CNepV6nRBQDE+CfaL9kz AUQ++dbXJoMY8clgcu/WNQvdMrVqakcmMWlpRTo/CA8CCP6j9ihRLX0nTvgzUEEDnnfL L1x5g8fBiotXQxH/sXDG1CRofmRLH2o5tkcE8KVDyD965oFnGXvCZ/W0hsVZQBI2ac4b bI3FLNUGDL/DxTpbFmrjzVBZZqYQ1X26LnR4R00mQwvbj6nvEgN0zoleH2FFlSj1nI/t M2Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rgdjLK+rHmGYzX+axfdcXU3cC80ktttNYMslWS8NxWI=; b=RVigpPd0v0Xxi7yj3HlbIdibeDLLjcxGja8EIodUa9yOGtcgWnVHU7sEkzUpNLUECg 1DTqdgUZbrFOztmQZLvQGIq+dC8iB3fCDwrzzhGQm1FNBG8r2IW/rrmUvLP1vyVVUd5P RXyj68cGdY2LILVtL+7MzeDiVv4L3N5DTL4kldDX/KtmcJBMt2IQmx1W/xj7M1R6y/O1 vYr8XteUTP5XRUvrlyvYHMbiyW3DVRjDVpQV6kwK4YYqHefxoI0EcOdBRO65KwpPQgyr uQbWWSzDlwFhFHdR7BzECI1bZAgl3quXAhDq0ZTgd049AmL2dMd1VkjH9oiVfNWM6Vax ujzw== X-Gm-Message-State: AJIora9Byg8cb7jxinwofLhpGBopL7HwS3QFAr3krompXdlN46Ihx6cf yrklziDpHEkei+AG4ECCymhdqA== X-Received: by 2002:a5d:588d:0:b0:21d:a5d2:42d5 with SMTP id n13-20020a5d588d000000b0021da5d242d5mr11559128wrf.588.1658863328911; Tue, 26 Jul 2022 12:22:08 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id y7-20020adfe6c7000000b0021e4f595590sm15502588wrm.28.2022.07.26.12.21.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 12:21:59 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 919121FFC7; Tue, 26 Jul 2022 20:21:51 +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, mark.cave-ayland@ilande.co.uk, jasowang@redhat.com, =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v3 15/21] tests/qtest: use qos_printf instead of g_test_message Date: Tue, 26 Jul 2022 20:21:44 +0100 Message-Id: <20220726192150.2435175-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220726192150.2435175-1-alex.bennee@linaro.org> References: <20220726192150.2435175-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 ac23def284..d0bdf06fad 100644 --- a/tests/qtest/qos-test.c +++ b/tests/qtest/qos-test.c @@ -320,6 +320,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 Jul 26 19:21:45 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: 593485 Delivered-To: patch@linaro.org Received: by 2002:a5d:6682:0:0:0:0:0 with SMTP id l2csp2913464wru; Tue, 26 Jul 2022 13:07:27 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sS3+moKqfMo8CYOx4F9zZ/9VdLRad6saTlx5lwvSaGkw1rCMAqoBZ70LmOtIdzT5zS6PUC X-Received: by 2002:a05:622a:19a1:b0:31e:d34f:c9c5 with SMTP id u33-20020a05622a19a100b0031ed34fc9c5mr15963726qtc.629.1658866046984; Tue, 26 Jul 2022 13:07:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658866046; cv=none; d=google.com; s=arc-20160816; b=PHc0j3Z70JdcyhjaZ04fZhSRtmsYs0J1ijVtRrL8ZONSw3RqNlpYeOcXd2JBwruRHW RGjLckuJcTqZNGVQezOz62Nnia9YlPkXtl2SvxFmLy21qQz8E6LXdKSMM2b/ClPDfDTk G6R15Lt9lPJrhcpZEpfEvoT9KNtpMUNHgUWniUTB/ozmF3JYR4h6HBXnE1X/uroFEA7Q WcN2rCKrTutYM4+19FEL1dy3o7vFE2e+jmdq2qkPj3Kw3+Xsiv7/WXT4v4U7SsnBm9u5 b01sXJknUakMrf/bfEGNVGs/SbC4GcGBOcp9llC2Y4BcSVVX9CsiqJHzlb4o/UE0AclI QDeQ== 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=xlxq1ZBU6AcDaP18E14EH8M6boLy3BklV7N6rZI3qJs=; b=ASnZpib9/WkKlZf/Bm8D+qSNPSvHLU8qXddgqqikBbabZ11J5NV6gd4w0214CnwjYG WySgFRHbavEpgJ+zfMC55SuIJVlVU81iOVtTXmBYfYiFH/WdzrDDBI35PyF1Avin6B8T ZjNIKsW0SoFIlYKzo4MurzL3qpU94Nach5d2SN1f9pOgbR8EvMpx5U0Ibbz0kwpEjnxk Q3zuzIaOygYL0qHJC0sVeXwlVUrUaNiWsntCCrBJuVR7Wv+FLEze3N/E+8pk2vBLmIu5 +59lg3iTZqlhJf2zWVUiTxYaT9JyYfaL1Ew8yaSiGzeoi+c6n41/43ByFx7shJu7TT3v TEAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jVEZ6Irk; 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 k10-20020a05620a414a00b006b56e96778csi11433416qko.44.2022.07.26.13.07.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jul 2022 13:07:26 -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=jVEZ6Irk; 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]:36164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGQpy-0001DZ-Ec for patch@linaro.org; Tue, 26 Jul 2022 16:07:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50610) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGQG4-0006Zb-JX for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:30:20 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:41630) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGQG1-0003ar-MJ for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:30:19 -0400 Received: by mail-wr1-x42e.google.com with SMTP id q18so11061097wrx.8 for ; Tue, 26 Jul 2022 12:30:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xlxq1ZBU6AcDaP18E14EH8M6boLy3BklV7N6rZI3qJs=; b=jVEZ6Irk8Wh2gVvq9LX+XUkphMQElCWlmKsJ/HVQuPtCdhI928/IDc+OCg7HyHVMyX qDJxTHRud0QAUVd1rwl0QLicifrbP4bQ7I0J/AyyMIYUoi8L/brqsmT7GbkVeP8pD2vz zXWwkFMJFdAq+yq7zF09j9kx3rtXLB8FSRn4EkhLqE8UEKKJ7P1YNql1zc5hfq8Bxz+0 DCg0M2wx6Exo6sxuzKLzavG/gQtoZI9Gj0wucxCuMHIXoLbFDugIvgjxxn1At3tuMOOz c+tqkOkbN49RIT/Zb1d9e3EP2sOoDDlIf+NBsMLMzoDFlH1rcbhLVILeMLrvvYMhZdfY Cpkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xlxq1ZBU6AcDaP18E14EH8M6boLy3BklV7N6rZI3qJs=; b=mlMgkPkeBgoZ2XbGQUaH5yGUjMlS0HHF33YP/nO9QivjyKxAc/VGaGmAXHeErfkkSt qfLV7nsS8ioztzH6ZAdx/nFRynqSRcuk7O/GbGD0wTWk/6OVuX/mwr0qZnyWR14rGb6x MFuiX+dxdEW2+kIv1Jjjw0a9BkGtIc6BrD6jLPCqA7gRXhTEe7Z/m/1qcbTgyycSVXCu 3R/5Tk3Q7oBkb0xSYcD9NbMOKlv60EIeC9tQ0IMmgLNI3jx5vdMHMTG4iCnLIzgku5iQ yUL5iUYGenv2PDCNQ8aXmnzA0E+sjrnyRM8VKHWPW5p2Qc8dgPh8rpR3xrDJT0RtDILZ PqJg== X-Gm-Message-State: AJIora/HrwrrBAXR0M9dSj8b10J8tItAtxXzOqBs3Zqf7Xdoc+pACl8U +JsaCz8cC346Pk8WtE5jOPs9pg== X-Received: by 2002:a05:6000:1541:b0:21d:b298:96be with SMTP id 1-20020a056000154100b0021db29896bemr11546897wry.206.1658863816126; Tue, 26 Jul 2022 12:30:16 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id c17-20020adffb51000000b0021d7fa77710sm15240057wrs.92.2022.07.26.12.30.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 12:30:14 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A864C1FFC8; Tue, 26 Jul 2022 20:21:51 +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, mark.cave-ayland@ilande.co.uk, jasowang@redhat.com, =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v3 16/21] tests/qtest: catch unhandled vhost-user messages Date: Tue, 26 Jul 2022 20:21:45 +0100 Message-Id: <20220726192150.2435175-17-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220726192150.2435175-1-alex.bennee@linaro.org> References: <20220726192150.2435175-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42e.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 --- tests/qtest/vhost-user-test.c | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index 968113d591..d0fa034601 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -358,12 +358,41 @@ 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:\n"); + break; + case VHOST_USER_GET_VRING_BASE: /* send back vring base to qemu */ msg.flags |= VHOST_USER_REPLY_MASK; @@ -428,7 +457,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 Jul 26 19:21:46 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: 593482 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b811:0:0:0:0 with SMTP id fc17csp3832378mab; Tue, 26 Jul 2022 12:54:04 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tJAxsB3ctGoPGL1jRnkqE+p0KE26znIG9CPcj0JrpmYPqHNpfoR3/GGlEnT0UkzMgR/6El X-Received: by 2002:ac8:7f92:0:b0:31f:3364:897e with SMTP id z18-20020ac87f92000000b0031f3364897emr12396839qtj.413.1658865244267; Tue, 26 Jul 2022 12:54:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658865244; cv=none; d=google.com; s=arc-20160816; b=h+6lHALIfQTR8eib1qqXmdfhMKZaa5tOmg9RWEPCZ4W9B0CTITRKI6yUoquMsRQOU8 FhqMXc7z39SRizZWa99UNoJs2AEYogYGJE3kUitlsdrsVLChDeojHZfuLBMxG43Mg51y sesTk+hrSFlfh9EF7bJzaoqY7xALgV2RoriqYOFEh1ydzi5C+Cw/Vu24etEeV4QgR2OG yFX/44uVwuX5Jo+dNhW9jQomsUP2VvNOHzAeR83Vo08jNbBWIIUksUnLHkj//+0nLpLj A8/nfATt7hpEGvHahjoiSfwmMMvARLFLd5IefiyA4vCM7szeptJXkU+TlwZ3BnMrOaWy GW7w== 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=M3AwLOO4tJSX2vgFnHe89rY8t5sl7yh4FwF2sza60a4=; b=nK7L5e6yUy229uRM3bWxNVtVyXBhSdzchxbIlGujgfC4BmCodA2c50zIaCGz+xgsn9 52jx69zhsCEdLSZvhdDMW0isVIJepAfbLQtVJdzHwEPPG0MYMjo3KLOyxMQQOw+BYIuu YWZtqxYkXkxeWvdd7jVNu8JmzLLKly0HwblNzl7BfFlcOyIel850X3NdgMB2mSs1gCGO fZU2sayOHJAytrE44/NN/wRlb45PHc3zy/OhsYKtrssaJXG/Jymycw4k8usQgyYP6b8y uqZ0fCluKFlhgyAOmTBnBHnFrBbGwNcTTyYA8D0WQJfUoBb3yyW8hxQ//h98gxNn/TSh 3Jvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YFZM3SAW; 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 l15-20020a05620a28cf00b006b60c96501asi11900481qkp.748.2022.07.26.12.54.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jul 2022 12:54:04 -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=YFZM3SAW; 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]:44108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGQd1-0003Qf-Lo for patch@linaro.org; Tue, 26 Jul 2022 15:54:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49076) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGQ8E-0003Mj-CE for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:22:14 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:33355) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGQ8C-0002OM-4e for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:22:13 -0400 Received: by mail-wr1-x42e.google.com with SMTP id h9so21496419wrm.0 for ; Tue, 26 Jul 2022 12:22:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=M3AwLOO4tJSX2vgFnHe89rY8t5sl7yh4FwF2sza60a4=; b=YFZM3SAWhCsWYiAAU+juFm/2nGYXO7JZo/FUKFvJIzyxBTSVomht3D7zRSZ0iGoitO d8lLhOzrd17TXUmiDmhyisnDgE5msVDiLUlJSgkozeBP3P1//WMcLSPhaKjPTuLsM3EH S3Pa6lC9KI8WiRkf9/AvvmueAq1K5NiczC+EuzZHiyRen3Ot5sn78elpSh+DXGG1ulBc Jv0DU9pRQk8Y6IiHfG7TQpWT3+vFrNM5h6q8Hmgu4pYUem4PzYo93yRBTWZ++1DK0XfH pzy40LBJbJTu/W2R2xV0ocw4EN3hMTH0IIBFHX5SCOMbGxDVQhDqJBYcS0iK3TplxUTW rapw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=M3AwLOO4tJSX2vgFnHe89rY8t5sl7yh4FwF2sza60a4=; b=vHLREeCoIHe9oXicuhFz9KymZFkZ5mpR5Q/LLq0k0Um0lVX2JYIBrYGZ1SPO1IYK7A 95lr/T0RunR3NMhUPvMOpSXFDU/1v4ebmF1J++YdonsM0Dqk1vjcq6miMi6tL9QZhIy8 s7+HI4FEYgGMvnDUQ5jbJiwpfrLEtIka32pPgHWlS2vOuGGj2O3hailkijSWF88i0Gj2 aWdq1qjh3X/inM770BQHSHL+z/AlfjaDiMNZACz9PRd3tyH70Er/aAl2SlMDpDT0/WC+ gACU7ZyX4q8idiHBzAl4oj34tobWMOanIP8H0TrSu5zljbmW1+KB3FzJdOWaAxJgsSfG jD5A== X-Gm-Message-State: AJIora+ErKY/P4WZk7rApodvZFTrucT6dVpcqudjZTlmIUI0cYZrs4Dv 8kjqdWcbR8WHhjkEyACwmtQnmQ== X-Received: by 2002:a05:6000:2a4:b0:21e:6e0e:df1f with SMTP id l4-20020a05600002a400b0021e6e0edf1fmr11614994wry.516.1658863329858; Tue, 26 Jul 2022 12:22:09 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id az14-20020adfe18e000000b0021e529efa60sm9911003wrb.1.2022.07.26.12.21.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 12:21:59 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id BF61B1FFC9; Tue, 26 Jul 2022 20:21:51 +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, mark.cave-ayland@ilande.co.uk, jasowang@redhat.com, =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v3 17/21] tests/qtest: plain g_assert for VHOST_USER_F_PROTOCOL_FEATURES Date: Tue, 26 Jul 2022 20:21:46 +0100 Message-Id: <20220726192150.2435175-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220726192150.2435175-1-alex.bennee@linaro.org> References: <20220726192150.2435175-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42e.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 d0fa034601..db18e0b664 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -980,8 +980,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 Jul 26 19:21:47 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: 593473 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b811:0:0:0:0 with SMTP id fc17csp3824391mab; Tue, 26 Jul 2022 12:39:22 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vyKv3aooUjbAtSuTtt9P/iQCQCVaL1DQKx3K1gU8qY3OcNaSxfnkKePUigJuL27eJ+ht6v X-Received: by 2002:a05:6214:2a82:b0:474:6a7d:ce7c with SMTP id jr2-20020a0562142a8200b004746a7dce7cmr3837481qvb.101.1658864362180; Tue, 26 Jul 2022 12:39:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658864362; cv=none; d=google.com; s=arc-20160816; b=iCmkA5ZlolBupcUjdvRwkczI08Zb3Ne/98FVxLKvEiidvNDDV1YC7m/nE+GPv7scCD 7K5ZOMQWyxKb9QGIIK82cz+1AokCIIx7XzrqMxV+ntbguRCiRXqX4KrVtSwvDsddxjQC rBGE86Y0KAhCYui4cdFohJ5W1eeG+9ASrQD2ddSlpGBYGt0RDyrGC/Uno/0noZZgDMuc H46Uu4YSJ+PqZ/mr8y+xL9uvLNbrS0+L2IHyJCUm2x72qTEOOS4I9/Kha1JrzVUFuAXi CJPJZQJbhRNAeMNo4hPumJ+H6AZBbvgLdl6wSWQwxFyZixM3Km2+YDB6Ophn5xe2aLsk tvqA== 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=ZkiF8vf7weQ0O7+L5ColWLiEtgIBwhFurWgrihHmVAL5x/6qkIZRCDyQ8rFcclgHxg PVS4QR8DFtNpWkJ7XjoZPnpoC9mKeUM4GutNSlUVXmfcq1qbJZB7lB9wE09yWWFgjupp 0xdxEPP7L8RwHWn8O7tcbsChha6WGkWQJoNF2TbyXIgYuNHr32bzVqwnx2insdPa6P1z pOAjw5MGBawJwqm/YpWCSU3GH7eptfK58nljOSyo6t5iJKgBwChWQgNCj5X/kA4fS/5K JU5Jl/255EbpdvF5athozwZ7Izk2t+wHTAtXV1NNGiRBQWF/9FgSr34R9FuFJIyGx5W5 qxqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ual7CBUu; 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 o11-20020a0562140e4b00b00474569d76b9si2307516qvc.430.2022.07.26.12.39.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jul 2022 12:39:22 -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=ual7CBUu; 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]:48172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGQOl-0003OB-H8 for patch@linaro.org; Tue, 26 Jul 2022 15:39:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50654) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGQGC-0006bt-BN for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:30:35 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:39720) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGQG6-0003bT-1y for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:30:24 -0400 Received: by mail-wr1-x435.google.com with SMTP id d8so21379539wrp.6 for ; Tue, 26 Jul 2022 12:30:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PYaGkXjsZkoph9fA5YpZi9kVlMvB2mVtLyywEwpEssY=; b=ual7CBUuvRDdw1MsLKJ5y9GezAGN+AST2WPzf2yk2Np9/RY3mmGfEDID+i+ed+M2h3 g8jLpNPySYjNuKdDSBLr3Ss9dOfDD+AoSxGU+45BFKwg3DJ0gxPAP4sSEC95FMW8nDsS fohp7/TfA0kv/qeuCvtzrwknoecHBdndJcwBKds/Hw0jPC0+oMA09sltLXolo31IV4Wh AUVXml4r7bEj2zIrM6M1FEKkO8wJeq27dJE5gjhxoK2wSZSuYEGl+cBf7Jpe5GpI8Q5w rqa4AcoeuTfU0dhP2WRfgzyp8PjIdSQGenvZ5epopNoyumjGkG3GUmAHEGgMUqpASi85 pFeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PYaGkXjsZkoph9fA5YpZi9kVlMvB2mVtLyywEwpEssY=; b=srdW51lmWNXKgsXhm648cZwVZJnV1lb52ZEr57DClHXn4vArepocgTChHs3+PHNeyE sCtHIfoqXkFEb0JzGb3kyqDqmTMi4vPfExCHp3mYPHSeVLc/4jlZyU1mzyYyAxx5iRTK t9uV18qyJImVPEd+6lSP5s2QFJNA3YvPAwwAQFA5q9u852iXjjSEYslWLLasrtFaxIAq IsDewfqSApgbuCMs8OP6dxDuCyvM5PxeeBYzEnxeQ8VCv0wIIKo2NNID54/2qZTNwy3m +7BMvbydoE67b5OpToxgznhXR7YW9738XbFGXPNoIoy0iQOqL4JpdxOWwyNLIAf/Iww8 q8Mg== X-Gm-Message-State: AJIora/qBKYQZAOOR9pt2SKoOM+R64+TxzAzXpSb7F3G6m0i/lT4PlUK 0pqRpa/QQZnKazafv09wIdSudA== X-Received: by 2002:a5d:59c6:0:b0:21e:86fe:fcc6 with SMTP id v6-20020a5d59c6000000b0021e86fefcc6mr8196415wry.139.1658863819519; Tue, 26 Jul 2022 12:30:19 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id q6-20020a1cf306000000b0039c5ab7167dsm21916848wmq.48.2022.07.26.12.30.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 12:30:14 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id CB3A41FFCA; Tue, 26 Jul 2022 20:21:51 +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, mark.cave-ayland@ilande.co.uk, jasowang@redhat.com, =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v3 18/21] tests/qtest: add assert to catch bad features Date: Tue, 26 Jul 2022 20:21:47 +0100 Message-Id: <20220726192150.2435175-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220726192150.2435175-1-alex.bennee@linaro.org> References: <20220726192150.2435175-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" 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 Jul 26 19:21:48 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: 593475 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b811:0:0:0:0 with SMTP id fc17csp3824609mab; Tue, 26 Jul 2022 12:39:47 -0700 (PDT) X-Google-Smtp-Source: AGRyM1udmYX7h813Cmpid94HN+j5zLZFZwrnzrudvx+irZPCUOUkBhfKq4toRhXh/jFY79kLrF1k X-Received: by 2002:a05:620a:44d3:b0:6b5:f5b7:8d6c with SMTP id y19-20020a05620a44d300b006b5f5b78d6cmr13956175qkp.319.1658864386957; Tue, 26 Jul 2022 12:39:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658864386; cv=none; d=google.com; s=arc-20160816; b=pVB7j/gFf3OXIXZ7BPl671W07aUfbqQnKiVDZ2rVoJfaeAwtydLjrpFBzl5Wa37N96 ++8Z9PrHl6ORMCAcUUJ1IaN7qb15JJaYAkhKF27fEdpw6lPHG7g9qmtNHmiu3XyBMNPm m66ocA65WBTgYDWxAn3vCwm34X1F9Kq7Uv2+0TkX9LRvk7DGyJSqAivxqonPSIMoFzrD GPCKHlyIV62Y5K+62zTMSzrlCIiT1ac9CHIMETC7m7wpMIe6CpB/3JS282ZLPshGiyx7 Pjga/srCrjfdZ6SBXGW8Ya/5HuE7yiwbAEYIDxHDzhKQiw0ZAqWGwoPDdjfNHjmqUdSR kpdQ== 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=hfKNVlrrL3u0vef+FWTAR3LbzLx2Gk+OTMM5YcoQN7Q=; b=rl0O1YheXmW1bsLsAb9xdN1lTiPRuwoCT3J2uA8qCzzBgPxBmtbqwShjwZy28Diu0x DS8AJ4zu3fVTrDj0royEBK6Y8+gOnLfZeXAFwd2oF3NBVUTSPT+aR0KHkyxruaICBqPo J3NQHXv28zXGJbiFR/BTTx0m/M/H6w2d3fkzc2nOBCPRFU6nMJ6z+8AevBSmDaW699JT TCtuZDssIdgkG7vtqUZaCVjou7VboXzLVB6ZY5YUHa5o9igZ0GaV7D/3zu2WMdM44aF5 qxAgwFMBdIp1dga2w+0QIKlj8TlTsX0O3i/nzj/vHD9mehzZFz2ofCFukhBlDKRr/pkc MQlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CP7lN+Tm; 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 x11-20020a05620a448b00b006b5da5fade8si12314931qkp.54.2022.07.26.12.39.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jul 2022 12:39:46 -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=CP7lN+Tm; 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]:48592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGQPC-0003gp-GG for patch@linaro.org; Tue, 26 Jul 2022 15:39:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49136) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGQ8H-0003Or-J5 for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:22:18 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:41555) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGQ8F-0002PG-VR for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:22:17 -0400 Received: by mail-wr1-x429.google.com with SMTP id q18so11037760wrx.8 for ; Tue, 26 Jul 2022 12:22:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hfKNVlrrL3u0vef+FWTAR3LbzLx2Gk+OTMM5YcoQN7Q=; b=CP7lN+TmZ3Pujh0mILQ2/noel6Xy+f6GVEdKkt7wPZTgcLy/3d+waBOSwnEauerGe6 GTIb4KE6LeUH6OvLAHCy0fVRV7IpoaC9KaD+glw+HCFliTQxbMQg0jzOLRR9/95aZ3r0 IxFp7nQuc0GqtVn3EuVklVS9wJtUhK6nmTvTbhPxhnDphkcrpFmDGE/CmOlvskhT7LAP HYt4hxlaYSVzFYeBux39dxQ5jz9MBSV7xv9HeGKEQKQvGN//IqlGthWESbN5kJVuvVgZ YbcQZaUAc97TozDJikyVxPRwbF3B2OWdkM8FjLFp7BsONr64zsCFSwxrbRDSq/0E/wmR LWRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hfKNVlrrL3u0vef+FWTAR3LbzLx2Gk+OTMM5YcoQN7Q=; b=RZ0oEyPvpBlaAdlG+ddP9govW8pEHRFlmBhskcsU7tFdF6sP8eZcXLELkRCbsI5uA7 01LIH7Lr2wbWhTW3qNscX6LoVfu1ETQNFsCKyQv7fRgayXhy3JMjXMUhI+hqx7rvxnk6 0e+V4vSTS7xS5sYYZaPKNx7qVUE2WFrz8x8RExX/9NIhJ2J85XJ2MJxj/9+K9fnRxCwz 8UMUBSwUacnNNdfTBJ8iDDrA4Jxujfxz3q6Rc7phVurDnVGjEqC+Q2RUYnC0oxH4X92Q EW8Tj135XEHJEo4OjahXOaeHSlerU1F/DzSP9t+QwSyg8ZMKUdxbeXNSatN38wCxYDOS tP4g== X-Gm-Message-State: AJIora+bmsr5g90rxNmeK1LlPBJC+XZsYm0uawbDIgooECBOG2zTNlna hv6BQ17bXFL48Z4xWOR5nGZlCA== X-Received: by 2002:a05:6000:1547:b0:21e:5be2:9ed3 with SMTP id 7-20020a056000154700b0021e5be29ed3mr11929957wry.459.1658863334633; Tue, 26 Jul 2022 12:22:14 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id p20-20020a05600c1d9400b003a3561d4f3fsm9574115wms.43.2022.07.26.12.21.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 12:22:07 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E1F9F1FFCB; Tue, 26 Jul 2022 20:21:51 +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, mark.cave-ayland@ilande.co.uk, jasowang@redhat.com, =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v3 19/21] tests/qtest: implement stub for VHOST_USER_GET_CONFIG Date: Tue, 26 Jul 2022 20:21:48 +0100 Message-Id: <20220726192150.2435175-20-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220726192150.2435175-1-alex.bennee@linaro.org> References: <20220726192150.2435175-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" 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 db18e0b664..d546721f5d 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 Jul 26 19:21: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: 593483 Delivered-To: patch@linaro.org Received: by 2002:a5d:6682:0:0:0:0:0 with SMTP id l2csp2907705wru; Tue, 26 Jul 2022 12:57:19 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uvvuPe6OLjJyMaKOYNhazaXnrfDRXWo2QJ04/uChnZpKwUmEYPWVKsZla/NWxHdotWIhHU X-Received: by 2002:a37:c12:0:b0:6b5:e41a:86db with SMTP id 18-20020a370c12000000b006b5e41a86dbmr14127273qkm.435.1658865438999; Tue, 26 Jul 2022 12:57:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658865438; cv=none; d=google.com; s=arc-20160816; b=w9TKT9CAFWm1T2QJI/gIKQ+dBdDtB66xGBmkQDjH81BCPX36GCsXTAsimqwrwHg4/k pV9KZSfSutCFZKua1VigQmucDMboI7HlYYGEEa90vuB1tsEqlevd6Pqa9UoQscwSaNeR 59YQIcDJrEoxICgZCYpBLabINh61SkOrxIPXTdMDac8Qj9eUUMoxbm+++ivVWV2kyMa9 VLvA8zm9FVa90CngfH5YpdvtPUvELASoy71KKLLpVvDZdmxABjM/0T/jlpy8I5jYlB18 7orabovXQY9UNTXTZ/PGKdTIAZv/WN53RwW9S9XwAqqyhfKdzPqxT43JjiPATFXywqoB CIjA== 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=5yuBY8XhniW5U3BckTrWu3/MUge9sIzVNIAB45zhSUM=; b=ruc7U/rGeQ3LaEfMCNE7uKnVfJ05CDCOWGUeU4PMbU3WsSL+lYaB9aM7/CZudh5YwW lFzOJyWGhEgbfqfL0IL/jOqhgV7VVmAn4cEaWWVIrnK0dtXAJjOsKFU+L14e1lq0tiZj VU1nf2w4AGghpLj80/yg9fnxj+23IsfTHWWxZDX1iHBZLNvrStcfQDteOvha9fDa1udV XtqkuZWHVb7iD8uiMd1YReAUl+WwkJYHAmMU+gotxtSyZcQ/WqHbglqKToe5r8qtI1y9 QrPWeFEShWQ87e0Tr1Hva1XlxOY7HEtRTvprSJC93AZwgEYUbeHYTCHWxgusavxJEOCI h45g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aYHkGrAW; 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 j7-20020a05620a410700b006b53fe19c44si12092205qko.494.2022.07.26.12.57.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jul 2022 12:57:18 -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=aYHkGrAW; 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]:51676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGQgA-0000Mi-HT for patch@linaro.org; Tue, 26 Jul 2022 15:57:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49106) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGQ8F-0003No-P4 for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:22:16 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:40548) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGQ8E-0002Gz-4p for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:22:15 -0400 Received: by mail-wr1-x431.google.com with SMTP id m17so21167266wrw.7 for ; Tue, 26 Jul 2022 12:22:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5yuBY8XhniW5U3BckTrWu3/MUge9sIzVNIAB45zhSUM=; b=aYHkGrAWWbmJzOEvdL6EsWf5rY3TvU1X5EE6dpqIPsw47NhrxzW/yzy9XPfdW3C8b6 dP72QJZGdWh1xuBDci+l80i8/QXQCO6JkA7hq16xQqNgyNaB3Cj6W4VipNxIg7FLdFI+ 3jY3kWIrecnk0MPCT2SE/wOliO6lJx77Pgs5Li2E+t+dMIvQ+H2YRxaviWEdBminb3op PvQ/GWI6aneYOkszsPNdUJhb8P4L7Rr95fUVt9AEcym/lRKPZa5ysYcaedzEXCWVNMRo 8Qe9Cisb+P8iVMuCmqnUiBXXGa2D9Ksbtj3HXV9RuqB5yWf25F09SSpHTNKFJBCpM82E 87gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5yuBY8XhniW5U3BckTrWu3/MUge9sIzVNIAB45zhSUM=; b=tefjm0eNX1ke9k+y16cPVzS8IrBan5/k40fJvJnSfkBozqH41O2vQAkh+BHvBmgBlF Q4E0FhqX1ER9p/mqZtMl3WpNYclD71eqYE5T4zC5MkNgoEowNgrhrh8QM5EDi5RUSYXo WwvsDrNwg/mU2POl6wKAiSnywkJXnXHsAPy0rRC44g0oljsdZc86ipQuyRR/pRF7AJHk RqmbbK+pqd+lhWFFD22yT650K1AK3mSnCZ00JXA1/kqTYOUmv45ZouiD+U3yfc3QHnpu 4u2bfppLj/SrKzodzqgk7IhqozjQnxA2kESecek1uQ2TKy+pFDV5AdlqONftAJVADSws AJAg== X-Gm-Message-State: AJIora+Y04BCQPzjqPlWyCtIDjVVRY3YSFMe8m1hqFkdKYB6Ue4A0IxA 8rxjVRFcD7dCXPYBz1Q5axzdrcP8RHwbig== X-Received: by 2002:adf:ed8d:0:b0:21e:c7fb:7945 with SMTP id c13-20020adfed8d000000b0021ec7fb7945mr158066wro.353.1658863332721; Tue, 26 Jul 2022 12:22:12 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id y2-20020a5d6142000000b0021d70a871cbsm15306184wrt.32.2022.07.26.12.21.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 12:22:07 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 053CF1FFCC; Tue, 26 Jul 2022 20:21:52 +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, mark.cave-ayland@ilande.co.uk, jasowang@redhat.com, =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v3 20/21] tests/qtest: add a get_features op to vhost-user-test Date: Tue, 26 Jul 2022 20:21:49 +0100 Message-Id: <20220726192150.2435175-21-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220726192150.2435175-1-alex.bennee@linaro.org> References: <20220726192150.2435175-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x431.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 d546721f5d..28b4cf28ec 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: @@ -990,8 +993,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) { @@ -1020,6 +1036,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 Jul 26 19:21: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: 593472 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b811:0:0:0:0 with SMTP id fc17csp3821697mab; Tue, 26 Jul 2022 12:33:57 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ulsuY5WJcIQcACX/LkW3lfAC90EQDPo5DrnUYMFspEhTQJq1X73WNzctEx3ABDve5qmMFC X-Received: by 2002:ac8:5803:0:b0:31e:f49b:ed3a with SMTP id g3-20020ac85803000000b0031ef49bed3amr15653396qtg.46.1658864037489; Tue, 26 Jul 2022 12:33:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658864037; cv=none; d=google.com; s=arc-20160816; b=e7Pjuch+RsAwkXeGfnEBxM8D32lqM/pKpcvqGD4Zb/BhiXu5lpPk3+pzoQIbENwZlv nwrsWIc5oQ7GhaeKZoV3DmRuwzpy9C6Tbpmy98JqqdZ0bSjNJ3sq5saZnlAQQGzR1Nou zUgEa0oX+wONpyuYHq2MPlqm3hevRvPotND1MlQm3OJ5dulXOVvSisK5CqaAm1q34Fxw kcC6EJLkvRq8jUK/4F6mXAJ+sZKeeqWKJ70ykN32eOL1oSdrMjfEyPFKmOm3tUs+AY8F kcn6DPb6ZoI8HduPiYxMXIHstrTHKFDmFljrkSjj60jRDrts0EGhq3pG48wcbq6Yuctd TuCQ== 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=mz38geXVMD8QvQyjK3HC1o/d5nv/Gs14NfsxQZWXhHg=; b=v83PTRt1NxObJXbovr5m1fckea3FJ2XGS7p5l+zyXf43BjsPGDM5Mz5lCxfAIFBt9g wnwr9oHyne/W41YA3lzPzAUA8d/2GnvlU2+e/CuIgRbZaAcWn+xOVXycf09N4/dWgiNu 1xP3AHhe9/9Z7fhScQ5kLfRZF5VMUolvIMT7/DC2sfV4rNmzFxkFh1l5LppuRM8c3xFX kShCD/8JRXAXeu88tGz9K67y8y6w/3Cx1V1/A/oIb2/d+cdG6yEH+aFp/fRs1dP9Gxr/ V4aQUeC8wpHA50BUNfSmtFFjNJ1cwBIHqwFa5ZPIjXoYb8X3cxoKSJhtystc8Fzr9cHg 8jHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="MUa/5g31"; 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 j17-20020a05620a289100b006b65a6cc214si4517949qkp.330.2022.07.26.12.33.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jul 2022 12:33: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="MUa/5g31"; 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]:41238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGQJY-0006Wq-TF for patch@linaro.org; Tue, 26 Jul 2022 15:33:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49130) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGQ8G-0003O3-TX for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:22:18 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:37832) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGQ8D-0002On-5k for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:22:16 -0400 Received: by mail-wr1-x435.google.com with SMTP id u5so21463745wrm.4 for ; Tue, 26 Jul 2022 12:22:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mz38geXVMD8QvQyjK3HC1o/d5nv/Gs14NfsxQZWXhHg=; b=MUa/5g31sVcHaZlm/9NUnQVWXsw8uGA+HiEoMdT17oPJkh/uhsMcj0TRySF1qfr7VG lUYKL045zjtlRNHKA47xf3sqX3yOhuKTcosg7Tc0IgfbTk+O4Z9HhUbMPvbPX6qd8t5Z JNaFXrDPPL86cEtlQOlkrdUSlhrBLlkkegnfshABGUFPs6RYEUdrM5wZxLTa/N+f+MUy yfCnU0OTbDCOHkJRbdF8ufSiPrkmgTjQUywhixU5opFRaUZGxs0Xco3oL5/C5WpExBv6 CJ9huTiGAHelqDFb4wwHjS4thwsmzQQAfKsGRRJZ/4gjqHz3KVPOyf6JTcS8Ei1wQlPe RiJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mz38geXVMD8QvQyjK3HC1o/d5nv/Gs14NfsxQZWXhHg=; b=VDAOdaeptrV2wnjwgc6KuC9h8KYESKU0gU2n7O2jrRfnIeNdT/77sMAxVt1LlzJH1g Lecrw78vFDulriDzxj/O3sBVUxXJXm3npokOSHTWK8RU5BGJCKGbnDXdaMCA8Z7Ko3r3 R5RPMWSNypkbWLRz5iINJbsXw5Apng+koydu0XkwuXWoA3QNWqGuw1haehfjEfdbyAhy AkTQ9FRdqzlOWsCMOtM2qO/y95h/WQBuR9h9kdCfZ6ds7nmLoRosGZQfKHSlYqxjWwJZ ecKMHJqsEzs/wbQpVF02zmH7o4HeFj9i3aFQoAyudMQisqPA8cP48IAWvOWTIE+wAJ5D v2aw== X-Gm-Message-State: AJIora9mraYi7alNBOWna4C7tZHKFGWkfXoZfCOqU11PA3nf8yS09YsF JuboHhfVKquoF3BYj0fTwKgDuA== X-Received: by 2002:adf:d084:0:b0:21e:5570:2b05 with SMTP id y4-20020adfd084000000b0021e55702b05mr11682866wrh.554.1658863331786; Tue, 26 Jul 2022 12:22:11 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id w17-20020a5d6811000000b0021e6effef8bsm9918372wru.50.2022.07.26.12.21.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 12:22:07 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 1C3701FFCD; Tue, 26 Jul 2022 20:21:52 +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, mark.cave-ayland@ilande.co.uk, jasowang@redhat.com, =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Paolo Bonzini , Eric Auger , Thomas Huth , Laurent Vivier Subject: [PATCH v3 21/21] tests/qtest: enable tests for virtio-gpio Date: Tue, 26 Jul 2022 20:21:50 +0100 Message-Id: <20220726192150.2435175-22-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220726192150.2435175-1-alex.bennee@linaro.org> References: <20220726192150.2435175-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 --- 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 ++++++++++++ tests/qtest/libqos/meson.build | 1 + 5 files changed, 274 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 28b4cf28ec..04950e8458 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) { @@ -1085,3 +1103,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/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: