From patchwork Thu Jul 28 13:55:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 12931353 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 67F73C04A68 for ; Thu, 28 Jul 2022 14:27:36 +0000 (UTC) Received: from localhost ([::1]:38114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oH4UB-0000M4-5K for qemu-devel@archiver.kernel.org; Thu, 28 Jul 2022 10:27:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38898) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oH3yy-0003lT-6R for qemu-devel@nongnu.org; Thu, 28 Jul 2022 09:55:21 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:37855) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oH3yu-0000Nf-Jm for qemu-devel@nongnu.org; Thu, 28 Jul 2022 09:55:19 -0400 Received: by mail-wr1-x436.google.com with SMTP id u5so2295335wrm.4 for ; Thu, 28 Jul 2022 06:55: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=WTel/fQ7Gj1d2ni3sryAwF0T/iksivK0kIXjy8395Xc=; b=kb1xxsEzQrWgYuE2LMINFYLvrfst53N1FSmkhmBZM5MO1Sf3yZ1DaaNLnIAspPktEr ZowhjUlj2EEvVaCi/L5sEL0LO3caPfxFse0PQ53R1w4MfZdiI6rlb9Vvpz5w42k1t6DC DC+Fzfmvawm3cANMWmAB3W8h4J1TlfmxNfnnwxiVVaB5ec2TGC3OzlBpREUXvyrF4gLQ fcWEapJgh2OkKQBrbLD4R2RecCNbiUAJZGlcfv9wquM3VLE7LXXpbUnG+scdL3x9oeGz gbZs6YLnRZEg309Zrrkt4NyZ5tILOKmitD1WpNoCxm2p3ZRtWtyx/XiskPMvvWrLFD7C TD+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=WTel/fQ7Gj1d2ni3sryAwF0T/iksivK0kIXjy8395Xc=; b=BOIDMrGfZ+c/EXX/GnapKpQWV69L+JQZnV26jNFSEWwGLOhYtUaV7s1/NwUJajbGjL PTcklEYMN49Y3Fw7tWh160Rt8TJmFTb8ET9JSyKdnTmfWIa4k6ZD8ky0cAkdeURaHQiQ x+I6RrVy2shL2EPrlytk/UZFZAYf35KIRF1EfQalzlJaMZaYbssPIGWkFy9MiXyYMjuY UY07YIMOTwifQHaOfTTYr4rKrLTKiy3P/MHKGTDawFFnpHTfC/Eop35gGQDKadfmVtuW 02UW2SsnARkBSRFC0FRT4/cbNqdQXW8sXUOGyNCzPL7/2qGjoogLE2R3u9ZHgg25z/Fp yITw== X-Gm-Message-State: AJIora9XG5A3s8PX09EN8s/zAqXy1R619Q7MpApWGx8ra2L3GRhqROX2 QSCfCUvg0VfyOC+v9BpNqmi2/z5txNG81Q== X-Google-Smtp-Source: AGRyM1sgupEzqc0OYq3gkYvgmmiVyjqtMnH8S6U3i8TflFaK4mTTKmwd+eWqZNsclgoSnsgmNoH0CQ== X-Received: by 2002:a05:6000:78b:b0:21e:a0fd:ce with SMTP id bu11-20020a056000078b00b0021ea0fd00cemr8658386wrb.309.1659016506054; Thu, 28 Jul 2022 06:55:06 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id v11-20020a5d43cb000000b0021ec76a0c36sm1005656wrr.106.2022.07.28.06.55.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 06:55:04 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id AE7731FFB8; Thu, 28 Jul 2022 14:55:03 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: mst@redhat.com, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v2 1/4] hw/virtio: incorporate backend features in features Date: Thu, 28 Jul 2022 14:55:00 +0100 Message-Id: <20220728135503.1060062-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220728135503.1060062-1-alex.bennee@linaro.org> References: <20220728135503.1060062-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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" There are some extra bits used over a vhost-user connection which are hidden from the device itself. We need to set them here to ensure we enable things like the protocol extensions. Currently net/vhost-user.c has it's own inscrutable way of persisting this data but it really should live in the core vhost_user code. Signed-off-by: Alex Bennée Message-Id: <20220726192150.2435175-7-alex.bennee@linaro.org> 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 75b8df21a4..1936a44e82 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -1460,7 +1460,14 @@ static int vhost_user_set_features(struct vhost_dev *dev, */ bool log_enabled = features & (0x1ULL << VHOST_F_LOG_ALL); - return vhost_user_set_u64(dev, VHOST_USER_SET_FEATURES, features, + /* + * We need to include any extra backend only feature bits that + * might be needed by our device. Currently this includes the + * VHOST_USER_F_PROTOCOL_FEATURES bit for enabling protocol + * features. + */ + return vhost_user_set_u64(dev, VHOST_USER_SET_FEATURES, + features | dev->backend_features, log_enabled); } From patchwork Thu Jul 28 13:55:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 12931350 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 29446C19F2C for ; Thu, 28 Jul 2022 14:23:43 +0000 (UTC) Received: from localhost ([::1]:33128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oH4QQ-0005Fv-7d for qemu-devel@archiver.kernel.org; Thu, 28 Jul 2022 10:23:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oH3yx-0003jg-AO for qemu-devel@nongnu.org; Thu, 28 Jul 2022 09:55:19 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:38777) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oH3yt-0000O8-Iz for qemu-devel@nongnu.org; Thu, 28 Jul 2022 09:55:18 -0400 Received: by mail-wr1-x434.google.com with SMTP id k8so106401wrd.5 for ; Thu, 28 Jul 2022 06:55: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=s3nGxeo53LwaMo+sziN/l2Vq3ARUUV/BFGaJ8lB68So=; b=MGrs9tXDlvLXSSn7iB84K2BjzlHGW4MRyLBsDK66IfpiJRcqVGx9gqgLojWQu6ZTmA bIOmPkjmey2DYXMe3Dm/gKxU6v89usiaFqKialqe6kzKeSRVRBqI2OTHwyDWReBqfOB3 yW1yeTsJdPqKaMDkkLdmQkZafyU60uUQ21gtRBzYdIWjweyJX49zsSAkPJ+wH2i2KgZB OQCUwqBRKS/uMUnczv/iYOmjdvkdIRr+sH5Tq0tlxNpBUri7qJO+t29trYN2bekaBBsm FkIA/q18c6fEQ++sBGfq7upoCRz5v60LlU6qOumPtIzyAlUkSp/aVgeO+eUB47m5qVHX L4wA== 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=s3nGxeo53LwaMo+sziN/l2Vq3ARUUV/BFGaJ8lB68So=; b=kVR7tdVa+z/Dt/rirWA6VN3sR9OhwhWKJqhmvPCxJkwXILFzumFRfwo9lDY3+bqyZt OpzqROSP4zrmXkKb8X1L8gEOJHeTHL4Oja3KCkYegym4U3fBkVixSCqF3v21+NAZ21v+ 1ryLHasvbR709ZwZi9HNmlAJM4SlbwV9K/wUPoFYhyAnwB4Yq/ZijRMyxkUy6aKs/Kl1 Os5napXwz1VDGBV9Wi0BYxxRdftCTS4QFKbYFi+VSUwmcF33daQIRS5m4C0JRX1LbUD9 NO8ArBNEemeKM+PKGqCVD65DaisUssLDCYLktg1OIEakVBLsGa/RphwOQlcK5+CNCgQB QCWA== X-Gm-Message-State: AJIora/9OrDEymwDGPQ37NElHUnJv+mpXD9y7SIvf/fND7jmq55yJ19v +UKu37I6Ih5nNsg9fim9ufG+UrXQ78E15g== X-Google-Smtp-Source: AGRyM1uPlByFFoPv3UiDPJRl1cyE8QuFEcDNHWIxbWL5pQVWEpAKeWK2sO1W6t+VBaGTgkydyOkFQg== X-Received: by 2002:a5d:648c:0:b0:21e:9872:5a38 with SMTP id o12-20020a5d648c000000b0021e98725a38mr10321607wri.556.1659016508197; Thu, 28 Jul 2022 06:55:08 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id n65-20020a1c2744000000b0039c54bb28f2sm1397186wmn.36.2022.07.28.06.55.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 06:55:04 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C53761FFBA; Thu, 28 Jul 2022 14:55:03 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: mst@redhat.com, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v2 2/4] hw/virtio: gracefully handle unset vhost_dev vdev Date: Thu, 28 Jul 2022 14:55:01 +0100 Message-Id: <20220728135503.1060062-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220728135503.1060062-1-alex.bennee@linaro.org> References: <20220728135503.1060062-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" I've noticed asserts firing because we query the status of vdev after a vhost connection is closed down. Rather than faulting on the NULL indirect just quietly reply false. Signed-off-by: Alex Bennée Message-Id: <20220726192150.2435175-8-alex.bennee@linaro.org> --- 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 Thu Jul 28 13:55:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 12931325 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C7C23C04A68 for ; Thu, 28 Jul 2022 14:08:00 +0000 (UTC) Received: from localhost ([::1]:39370 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oH4BD-0006Rm-QT for qemu-devel@archiver.kernel.org; Thu, 28 Jul 2022 10:07:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38984) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oH3zC-00040t-N0 for qemu-devel@nongnu.org; Thu, 28 Jul 2022 09:55:35 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:38778) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oH3yw-0000OI-B6 for qemu-devel@nongnu.org; Thu, 28 Jul 2022 09:55:34 -0400 Received: by mail-wr1-x435.google.com with SMTP id k8so106449wrd.5 for ; Thu, 28 Jul 2022 06:55: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=qn9sIffAzV9IF+yjjzIzifr78tit+1ZOBIt0UyqO2Rk=; b=sgPyErciTNQttlWPS4JPv27YVf7tmojFhsZR9M/WZngizsHWCfovQpwMgyaCu3WxyN +ZWRwuKuS4XX1chuuVcV6JTIEVeywSGfzz0iMHQ7+hBO0Uz10nO0wZxtdfuriBZeI3su +WuGzOonIXeVtU4Y1YQmHHXd6NwFNlE0NZs4HBGRSVbCdBSKjKPsYQqHfTYae42/tMcN RRMYRD1sNkK77Vmg5WXBTcOWeT+O9blgS8mWNLbpOqbL94u+RaJiqAK1NBDLduRTjOSI bW+S01sSi2lvy/XJudEcIXf20iGdBa/He+6CG6I2scyT48KHrG1+RD3jZrt8lgUPARd6 mz9A== 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=qn9sIffAzV9IF+yjjzIzifr78tit+1ZOBIt0UyqO2Rk=; b=0hGtfqPMELLiBe8nt6XgaDKdXKDoyVmDtlQG0/y0yR+i1dG9D9ERTvRQa13TL8tQfR QZ0R/JrrirLF5It5u8Lay3zCHIcay5rRM0fhU5c2iSasbNMyxFsYPitpex4SpHzNFsqU 3D3YR4oCMA8bAjfMUS02R/iNyd8Bj+t2baf6zTjoSqOgtvTrmgZxtDd8oJ/ll1geq+EC otsk06DdPxnaUK1Q5gfhgiKRjzFkDGphL+sHH/g6AC8Rf3tOjveixp7LsHh+cvzAYpX+ Emuc7AlnIVEAvRO0+MNLZXuqoq4eLu+OxPm5VOmXdhY7QaY45T7427EJrqKJBGM6vwVH lQpQ== X-Gm-Message-State: AJIora++aRlZ7oK1Pw8NM4Ry4bCLL+eYKAZaANbpnzPqZ2XkCS/GOBeD U9uSY360pC8bhXgmUvoh2zGlxNi+LMuB7w== X-Google-Smtp-Source: AGRyM1sRG6pgvhAHMH0Ny6QKbtFjgT401bL/pV0TdYiDaIfPFDWAPHUnsQZOlG93RyfFVb6YtminMA== X-Received: by 2002:a5d:6642:0:b0:21e:f918:b093 with SMTP id f2-20020a5d6642000000b0021ef918b093mr2098786wrw.173.1659016509030; Thu, 28 Jul 2022 06:55:09 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id l21-20020a05600c1d1500b003a326b84340sm6114560wms.44.2022.07.28.06.55.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 06:55:04 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id DB9871FFBB; Thu, 28 Jul 2022 14:55:03 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: mst@redhat.com, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v2 3/4] hw/virtio: handle un-configured shutdown in virtio-pci Date: Thu, 28 Jul 2022 14:55:02 +0100 Message-Id: <20220728135503.1060062-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220728135503.1060062-1-alex.bennee@linaro.org> References: <20220728135503.1060062-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, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The assert() protecting against leakage is a little aggressive and causes needless crashes if a device is shutdown without having been configured. In this case no descriptors are lost because none have been assigned. Signed-off-by: Alex Bennée Message-Id: <20220726192150.2435175-9-alex.bennee@linaro.org> --- hw/virtio/virtio-pci.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 45327f0b31..5ce61f9b45 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -996,9 +996,14 @@ static int virtio_pci_set_guest_notifiers(DeviceState *d, int nvqs, bool assign) nvqs = MIN(nvqs, VIRTIO_QUEUE_MAX); - /* When deassigning, pass a consistent nvqs value - * to avoid leaking notifiers. + /* + * When deassigning, pass a consistent nvqs value to avoid leaking + * notifiers. But first check we've actually been configured, exit + * early if we haven't. */ + if (!assign && !proxy->nvqs_with_notifiers) { + return 0; + } assert(assign || nvqs == proxy->nvqs_with_notifiers); proxy->nvqs_with_notifiers = nvqs; From patchwork Thu Jul 28 13:55:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 12931349 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 91C03C19F29 for ; Thu, 28 Jul 2022 14:23:42 +0000 (UTC) Received: from localhost ([::1]:33142 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oH4QP-0005GD-MD for qemu-devel@archiver.kernel.org; Thu, 28 Jul 2022 10:23:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38910) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oH3yz-0003lh-9H for qemu-devel@nongnu.org; Thu, 28 Jul 2022 09:55:21 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:33448) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oH3yw-0000Of-AU for qemu-devel@nongnu.org; Thu, 28 Jul 2022 09:55:20 -0400 Received: by mail-wm1-x32a.google.com with SMTP id a18-20020a05600c349200b003a30de68697so3399129wmq.0 for ; Thu, 28 Jul 2022 06:55:14 -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=5cs2obCibuFrGV6ezAp7TXix+CRt2n51MrtUoaGrvvI=; b=MrnT4XOU2T9Hl+vLx07czaWcVUXSw2LsafTLH/hmjIa1Ea9ftq2AA2jeTte5zxGdz8 ExMYhS6Ws/1l8HsbBsXgmAqXuawDQxNmJqVA9IQFP8SFbIt23lP+WqXqeoLIyGAq7HWv GFecnfQQY+qZgT2NKbjaxO3OFxCAF8vDbSm93slLwYn3lYHWUqaWTGKNMi7hlakqANSz Tjm5Xugeu4NbKbbzFhm6OHSxApun4idvy4ow6aJoo4rWSvKxI7RkJB7sdf6vVFUuOT4p wL9BIr0t+T3D5W4eQd/jLJeprK/c3MbMdXj+vKXjrcvxDwaVZ+HrWYuU+eOS6GOe/Rsr e5qA== 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=5cs2obCibuFrGV6ezAp7TXix+CRt2n51MrtUoaGrvvI=; b=44GOUUGcY0xdrcsDjAAMe/i6Hfnlf/y3ykJF6wBzzr2QkvFmxW6ni4XBbgaBFfWV9L Jm1yURH0l10dwzB72VPt30rEwA6GdJbozAvrcQmMqKL0lfBg6UMj/mvy8aj3cOKHzbLc rCnUX+8nhLz+d+MdJPG8++YooBZhteHp1yyts97dNHqw07uizH8edvsFgzyqd9Wji3h3 fi94xkWXYWzyD71GDMdlRnx8zEGWXisBxteYclRlV3sp7Vaw37N1Sb4HNTg9quRMZxbC mRRAynpVoTe5ZpWF8lTPuY1GtHEpfpxMfz0tSfNRbTDr4xZExffBb45pYXdBV54epAeM /p8A== X-Gm-Message-State: AJIora8jlO4TamIqknk9yKWqm9HT1fr2UyknQ1601iHPnyztERfMzq+/ WN0pW/J72leavXi3PyIddigW4w== X-Google-Smtp-Source: AGRyM1tzbg688udxUa8TGpS1SbldNgpcIFJ+YMHqqUGHkwCYmhdmciD6Vlexk8ij4DkU5d3gPjOoMA== X-Received: by 2002:a05:600c:190b:b0:3a3:45c5:9f43 with SMTP id j11-20020a05600c190b00b003a345c59f43mr6661857wmq.130.1659016511371; Thu, 28 Jul 2022 06:55:11 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id y8-20020adfdf08000000b0021e084d9133sm1296133wrl.27.2022.07.28.06.55.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 06:55:10 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E789B1FFBC; Thu, 28 Jul 2022 14:55:03 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: mst@redhat.com, =?utf-8?q?Alex_Benn=C3=A9e?= , Jason Wang Subject: [PATCH v2 4/4] hw/virtio: fix vhost_user_read tracepoint Date: Thu, 28 Jul 2022 14:55:03 +0100 Message-Id: <20220728135503.1060062-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220728135503.1060062-1-alex.bennee@linaro.org> References: <20220728135503.1060062-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" As reads happen in the callback we were never seeing them. We only really care about the header so move the tracepoint to when the header is complete. Fixes: 6ca6d8ee9d (hw/virtio: add vhost_user_[read|write] trace points) Signed-off-by: Alex Bennée Acked-by: Jason Wang Message-Id: <20220726192150.2435175-10-alex.bennee@linaro.org> --- hw/virtio/vhost-user.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 1936a44e82..c0b50deaf2 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -295,6 +295,8 @@ static int vhost_user_read_header(struct vhost_dev *dev, VhostUserMsg *msg) return -EPROTO; } + trace_vhost_user_read(msg->hdr.request, msg->hdr.flags); + return 0; } @@ -544,8 +546,6 @@ static int vhost_user_set_log_base(struct vhost_dev *dev, uint64_t base, } } - trace_vhost_user_read(msg.hdr.request, msg.hdr.flags); - return 0; }