From patchwork Mon Oct 10 17:28:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 613760 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2117248pvb; Mon, 10 Oct 2022 10:33:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7SgcgBiuZoVcUL7IJjppVGuHcbDXAuI2s5Q7keLnO+bsnaCBWF4dtJvNzpU7IeVpprxXB7 X-Received: by 2002:a05:622a:8a:b0:35d:5434:cd1 with SMTP id o10-20020a05622a008a00b0035d54340cd1mr15877380qtw.655.1665423205958; Mon, 10 Oct 2022 10:33:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665423205; cv=none; d=google.com; s=arc-20160816; b=hM43NwH8RGvR3FwP7t/K2TIOo78cinWM92yCZXmHVzmBeF5eLIU5O+vCLl5nsg2DKM v5+AG9a23Wn7aZ3uk3zlQkWs9BKIDVDZAmNqC5oL3PKT89iEev0wqwEFMBaEzuV9l83f a0xlt40UaU4+eQ3d4dlTxy7kWDIvD/l748F4XbRYNO0EpVlczlzodoKzDXLotKAUjzQD vT98rdCKDcdmKlbrIW4fxGmQMwLQte+Vz0JP9ymFmod62V/h1OK40bl6zMIgfSrJxX8S JVFJcG/Pg5eXlQvuBGDTMxjr1t0e0RTfbfmxhvsREWBHM+66Ir4w1SQZGzFsR9gDXj+s y4cA== 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:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=rfuSsgJ8/3kGgCVZkv5tOI5S+PHvx8Oz4NxCMhgWj98=; b=kChffh4nZVJV3v5YFPx8pXkO87uhxQHk8b+mUh5sXx/BFhwAjLVqInL8SDDcpKjRXi lHjUsFkl7CSjkU7hguuf34o3EVT3oaxMKNco/V72CoKXcfpcWBHmVi4WTWl3Zc+pMcBX JqbUFWwsfXA9ENayTyDurxDd5hq7K+ierGcocELZMLSnvqL3DRJJY+Ukt9DDguhr/gcT ygMmQryBSAtJNr15zYGfwdHA77EX8VHJLcgVwoTmW1O58lUwCnARHK09fok7hGQ1fdR8 fyhCti0DkMAHM6mqileVyTSXbditcalE4nYzKhrEzljBuNpdNk5YOOrnSukXDWqiYP02 WrgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=foacEpD4; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s12-20020a05620a29cc00b006ed1daa8056si1774725qkp.661.2022.10.10.10.33.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Oct 2022 10:33:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=foacEpD4; 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=redhat.com Received: from localhost ([::1]:52478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohweb-0002tW-Gi for patch@linaro.org; Mon, 10 Oct 2022 13:33:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56534) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwaG-0007ek-Sg for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:28:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:23675) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwaB-0006Ow-Cl for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:28:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665422930; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rfuSsgJ8/3kGgCVZkv5tOI5S+PHvx8Oz4NxCMhgWj98=; b=foacEpD4kKc+/BPbk2MFBrNj6Ryr6iCAyIOAlX/EZrbM4rLtRuuPQ9amREaHuTxwPiHIy2 LB17pMHbbRp4x8aaqs1XLzE7oZ5T8c1cd2DAjXUi9F3F+HJNwhp2tWFiVhHY7mJ4OENJUb lQtOTTMfVRGxlwwR9LmyJ+vW/etanEY= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-553-XR5EWz1kP-qh0nTlV7iA5A-1; Mon, 10 Oct 2022 13:28:47 -0400 X-MC-Unique: XR5EWz1kP-qh0nTlV7iA5A-1 Received: by mail-wm1-f69.google.com with SMTP id k2-20020a05600c1c8200b003c3dd3aa638so4806635wms.1 for ; Mon, 10 Oct 2022 10:28:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rfuSsgJ8/3kGgCVZkv5tOI5S+PHvx8Oz4NxCMhgWj98=; b=B0H+rsiKqDAy3uJvUkUT3GBbhCM45drGjOeSghJXK6Po1fjEpGItK9MhaSZay86ExV Vh11StvKzsk0MLT87TurbWjiKzuzmMh8rk53O+etc533CLYwOIVIIF6xo+MWSJVKrNYd YXCf2nWK3RevSV2iEv9f821txIItDdeMDXF/R5dG/nNaootqv4jz+mQMTqB/VL54qmFb YEvmHVJKzDlog8OMLL+qSPM/jA/BRMZArXoG41BqbgdTL8TwWSPAyRSbxBEZ3yrrHhHb y/S0UHjRAN4AycKKiuar6Zj7wJ6snlQDyZu2rTfygg2JEMVDMl1FigUwPvCCrei8ai5C iyjA== X-Gm-Message-State: ACrzQf2ffiGtoPTgPAg2rQ5AuA7H6MMg3PfcKTpTew+7Lart8yJNK0ZG QyFl0IP/C5BHgZOzh151H5Gsm9LVIyqXA88XnDuPN8wSAYhiy+sf/JJLYr4buZirBZdHipxmMfE 4t1ew6puPflLGhAEv0QfMhJNtsTQp/xZsiSw3k68bFOfRfCGl7edZXyU44xLa X-Received: by 2002:a5d:608d:0:b0:22e:7bde:c19d with SMTP id w13-20020a5d608d000000b0022e7bdec19dmr12336886wrt.494.1665422926188; Mon, 10 Oct 2022 10:28:46 -0700 (PDT) X-Received: by 2002:a5d:608d:0:b0:22e:7bde:c19d with SMTP id w13-20020a5d608d000000b0022e7bdec19dmr12336866wrt.494.1665422925889; Mon, 10 Oct 2022 10:28:45 -0700 (PDT) Received: from redhat.com ([2.55.183.131]) by smtp.gmail.com with ESMTPSA id u2-20020a7bc042000000b003b4e009deb2sm12924785wmc.41.2022.10.10.10.28.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 10:28:45 -0700 (PDT) Date: Mon, 10 Oct 2022 13:28:41 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Philippe =?utf-8?q?M?= =?utf-8?q?athieu-Daud=C3=A9?= Subject: [PULL 01/55] hw/virtio: incorporate backend features in features Message-ID: <20221010172813.204597-2-mst@redhat.com> References: <20221010172813.204597-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221010172813.204597-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 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: Alex Bennée 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> Message-Id: <20220802095010.3330793-2-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daudé --- hw/virtio/vhost-user.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 70748e61e0..0b7e41ffe8 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 Mon Oct 10 17:28:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 613762 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2120255pvb; Mon, 10 Oct 2022 10:39:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7GifouBNjVlb7FL5wkPfooNikq+hFyxSZ3oh06PpvBLUXVUZNmlyD3qLxh3r0cQDjyCnzX X-Received: by 2002:a05:622a:14d3:b0:35c:ccc3:eb2c with SMTP id u19-20020a05622a14d300b0035cccc3eb2cmr16335638qtx.77.1665423594223; Mon, 10 Oct 2022 10:39:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665423594; cv=none; d=google.com; s=arc-20160816; b=JH8pOMJn7JnXarSeb4m/WmRXqZsvLlrdPxQDh+VLclc2tU78BpgcD0dboe7cqd4jHy JK6MGEyxHHcWqEz7dO0xH5MDQdMHlHksFY4sviB6nUiX6A+60eSLjq0rJxnlvOJkgyUh UrVkb1mHXQx8s5Z4X0uhxu2XXI2EJxSiQ62B2W3U7UKJS7Tytnl1M18QuDIcKo+iTzcN duRU3xp5s+bgC42jYteq23hM3jg/2OpxnfSnPVK3fiSJd2spLEVk832PVwVNxKYChz9t PETXdjo/E+NCfzWSeIjM7JT2qnuA9gKuk1mUT002ox2aEPR0YGoPqeiROnq0RIIm080t pkVQ== 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:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=hp8rI8ket4FMKJXRLF3s2rnrP8cE0bwnLy3PoafAv4c=; b=S4FTnl1h2eI9G+svXDp1z2t+JGkwwzCrLIzAqmji4CnE2okRzpeGBgZ4EX8BrSUjq7 VuRbk3vkUeZywmvgmWADyHMEcP/WVIqRRLvApyr3KX9qhxbfVolhkvCrKqf1z8ld2Ese HOLruR94hPHQYrLT2Q8YpxdJqww2+KKXAbDVZTlFwPEtxX1jxVbGaW57PER4rulhf+0c HiKuYB6uuDGqLbeVI3TEI3Y0Og5pVGvABMTuBQTlsWZ0rJxeaGZdKB9QaBxeMKc8uw8+ 5LpAnmJs6b5C5pi0VyLtm0utK/HyNKAWEvLBc0nmkyXLl5p6MZOiaceViSq40v28fDH6 XfAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DUYSiBSt; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z28-20020a05620a261c00b006ea4e9101b4si4671559qko.510.2022.10.10.10.39.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Oct 2022 10:39:54 -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=@redhat.com header.s=mimecast20190719 header.b=DUYSiBSt; 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=redhat.com Received: from localhost ([::1]:40246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohwkr-00080D-MV for patch@linaro.org; Mon, 10 Oct 2022 13:39:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47798) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwaI-0007nA-PJ for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:28:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:43208) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwaD-0006PP-In for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:28:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665422932; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hp8rI8ket4FMKJXRLF3s2rnrP8cE0bwnLy3PoafAv4c=; b=DUYSiBStfh3SHd8+QzXKHxloKBX91ht9u/W3Qkm4qE6XLhj1jsrgeMC/L8XybIQES1OI11 n0p4/Y3w1dxnITsRlTjMwRvdEiBo0SmwNNNz3Dap37foRUC4qFc0jKEpUaOZHC/UwBYSDw kvoBZhK+Hd8E4dcv26U/SrekHgu8j/o= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-556-9lUqtD4aMJusv94hmeqVxg-1; Mon, 10 Oct 2022 13:28:51 -0400 X-MC-Unique: 9lUqtD4aMJusv94hmeqVxg-1 Received: by mail-wm1-f69.google.com with SMTP id t20-20020a7bc3d4000000b003c6bfea856aso477717wmj.1 for ; Mon, 10 Oct 2022 10:28:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hp8rI8ket4FMKJXRLF3s2rnrP8cE0bwnLy3PoafAv4c=; b=ira3tzNat8Zs4DAr0+7q9yos3U0nMs5I2p1jhkR5RQQli42Km09jgiVGNgEPF2gj2K 7lI7c16Pz+bMAsYDh6OnruzcciQEf7wcT1oa9KwxVLCR0t5AdZeOPKeMWWzftm5bYeOT h3vl3BPucpGPMg/WhCE1UPbRmzRyeS0dzs4M+Q/if7jHtxWBg9koDRGzs/m4qw5x8nrz wMW8zE2i0hdrfc8rmsoC74pQzarPDFiSihxpkRF0BxzAuK2+263v6UerXwWHgdNj6jfW UGifTbeUwc0DjhV+lWnj4CPoc8SGkA1whmDFQekLNMyt+0YKa9T5yCbvN1vQBRqX0sww fhUw== X-Gm-Message-State: ACrzQf2C5UJJvvOz3vDXHIsjfU7UG8XKy5HZya8dNAPpVTNTKqOtj+NY TPeSDaox8ef5u/2t7XL0C59iitxaCY/D3Zv3gY9BxkUO7rRjQVpSd2z6eC5Rkgul6CuH2NhsGil KWTYiEijZ6u4MKg3JffX6t0g8ZfyCSZUswsMZwZPSoPurqIG97jKQs40NOiFz X-Received: by 2002:a05:600c:46c6:b0:3b4:cad4:7d3e with SMTP id q6-20020a05600c46c600b003b4cad47d3emr20971370wmo.78.1665422930123; Mon, 10 Oct 2022 10:28:50 -0700 (PDT) X-Received: by 2002:a05:600c:46c6:b0:3b4:cad4:7d3e with SMTP id q6-20020a05600c46c600b003b4cad47d3emr20971342wmo.78.1665422929768; Mon, 10 Oct 2022 10:28:49 -0700 (PDT) Received: from redhat.com ([2.55.183.131]) by smtp.gmail.com with ESMTPSA id m29-20020a05600c3b1d00b003a1980d55c4sm914699wms.47.2022.10.10.10.28.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 10:28:49 -0700 (PDT) Date: Mon, 10 Oct 2022 13:28:46 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= Subject: [PULL 02/55] include/hw/virtio: more comment for VIRTIO_F_BAD_FEATURE Message-ID: <20221010172813.204597-3-mst@redhat.com> References: <20221010172813.204597-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221010172813.204597-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, 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 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: Alex Bennée 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 Message-Id: <20220802095010.3330793-6-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- 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 Mon Oct 10 17:28:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 613759 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2115501pvb; Mon, 10 Oct 2022 10:30:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6D+v8HQWes90QI14eX/Y46vLUeIrj7BQX72XgkyAm1ifBz3soBCVP8QgB4IiNp/1+IHaau X-Received: by 2002:ac8:7f42:0:b0:35c:b7f0:3411 with SMTP id g2-20020ac87f42000000b0035cb7f03411mr15866614qtk.210.1665423015640; Mon, 10 Oct 2022 10:30:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665423015; cv=none; d=google.com; s=arc-20160816; b=AQ88eepbzhkoTf/bImJMEl+ntsUqRUSuRC45Ht97zlZmFN8zRuBsMfD4eVh5ubaWhw Oj+YC/zXWrZFDUj8QC9cVj7Yg0f7PjTTau5pvykaPbInT9m0sHFMSEH48fWkBV8ez3jZ 4aKBbcxzcoYa+lmL8hEafq1X9VF/vOtcfqhS7j0hFDxuuWcfg652CNbdcJKxXGXcOEkF 4jZEfdMUJAtfwr09AqAUqy2tEVSIz4elGfW/UYvGRO9nGxSVIEZ4yvNee7eJavdhPvKc KkfluwgXxVkA2hV89F7ekomCZQ/CC0RLYfrvMezGJIAHIaqF+QPgm1I/m0SkFLsqA2Mp j+9w== 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:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=C17R4uZqGLEi0seyRZv7bdzpjpcef+51Q4h/UGlzozI=; b=fWFFXqH3eRRoE6q2MYgUIoEncWg/gB/AoiEWqcLY5a9SVyVY98KPRyLvNXJXItPM2b 7X4P1Fkj7w+Dyr+HoBc8aMrLN1EzEAwv77UrnDcux2C7xplibu68KsLeiRRQsnWXz1AG zycwnW+NyvhC8/lpE53XWo/IthHgYryVtkVZAzIddyxJrPcwHs1PjnWVtQJaHa5Vd2oh VEKe5OYP+uKWzfNZoKt5JaDQZYXeQ0nJoDPy+/+CmTNbfW/XA7VBD0wIhziPxDNKndn2 bCZDzthAxcqXKxNEd4t2hBZa8wverkee+xkR3LY7lHD8DMfMa9kHjrKMUW6ZCP47Zz8o VK/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Y+OB9/KF"; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id gh10-20020a05621429ca00b00498f6c644easi5417575qvb.374.2022.10.10.10.30.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Oct 2022 10:30:15 -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=@redhat.com header.s=mimecast20190719 header.b="Y+OB9/KF"; 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=redhat.com Received: from localhost ([::1]:48874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohwbW-0007xU-Vy for patch@linaro.org; Mon, 10 Oct 2022 13:30:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47800) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwaL-0007v3-Q5 for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:29:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:30351) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwaH-0006QY-Az for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:29:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665422936; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=C17R4uZqGLEi0seyRZv7bdzpjpcef+51Q4h/UGlzozI=; b=Y+OB9/KFgKj2khtazSClewo8GHZ2F5J05YfVLYb6oDjOFEthRIpCPsVC3D6tPkzerUrT2c t5bZnoouj10VIOhjIL+2n9612rAqR+CWyaCOuotY1B8aFD2J9s1TaPU4itMhEFDMkpaf6H RayS00/8AHpAtsrGV0pXB5uc0m4/fhs= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-60-tCd9lUVgO3uPgHdwj7OgTw-1; Mon, 10 Oct 2022 13:28:55 -0400 X-MC-Unique: tCd9lUVgO3uPgHdwj7OgTw-1 Received: by mail-wr1-f71.google.com with SMTP id k30-20020adfb35e000000b0022e04708c18so2982630wrd.22 for ; Mon, 10 Oct 2022 10:28:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=C17R4uZqGLEi0seyRZv7bdzpjpcef+51Q4h/UGlzozI=; b=MM5Y8CWOrBFU/yEr+H24n8dByhms4fLr3vcL9WXwoo86CuOIWpOO/D2hITllINJpB6 dG3D++TZOXCO86P8W3mIDe91SF8PrS3j47hHZPOS//weQzVZrLMvD/Tf/Dcdsfpov275 2Rr+oF1a1nrAVkmudHqYcAkNb3obYf0VmV3YamF4nMoPbPgZ/8xv76vGzQYmmSdXb6Rr BWnmBt9wcKEs1URszlp2EFpj+qEJ5TRi47igbTw5wMf5yMWlaUhqn5D8p6u8UVJOaUDN lEB89JxCibs/nA5OYBBcQospCH1hwP2IEMUxV80HVfwcmSiRq4T+tue8plVco6TKc7Cx t+Qg== X-Gm-Message-State: ACrzQf32exYkKews8dHCtIrK9brHijM0yzQ6wTysoMh4y04dC4zD2tJt yzJ1wDge7ht2w4B2I9e5NveQvZD99YcukS1aMB0RESVo7UWIjFxEHHhQBLFwgP8ys4n7Ocvr393 4V3fFUu0aV2Hz2LCG6mMHQhw/3Ruikk7r50xV1O93pTwPNBXrVGx98shNucff X-Received: by 2002:a05:600c:34c2:b0:3b4:7a98:5f5a with SMTP id d2-20020a05600c34c200b003b47a985f5amr13509088wmq.156.1665422934217; Mon, 10 Oct 2022 10:28:54 -0700 (PDT) X-Received: by 2002:a05:600c:34c2:b0:3b4:7a98:5f5a with SMTP id d2-20020a05600c34c200b003b47a985f5amr13509063wmq.156.1665422933862; Mon, 10 Oct 2022 10:28:53 -0700 (PDT) Received: from redhat.com ([2.55.183.131]) by smtp.gmail.com with ESMTPSA id i9-20020a5d5229000000b0022cd59331b2sm9540464wra.95.2022.10.10.10.28.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 10:28:53 -0700 (PDT) Date: Mon, 10 Oct 2022 13:28:50 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Jason Wang , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= Subject: [PULL 03/55] include/hw: document vhost_dev feature life-cycle Message-ID: <20221010172813.204597-4-mst@redhat.com> References: <20221010172813.204597-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221010172813.204597-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, 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 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: Alex Bennée 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 Message-Id: <20220802095010.3330793-7-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daudé --- include/hw/virtio/vhost.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index a346f23d13..586c5457e2 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -86,8 +86,11 @@ struct vhost_dev { /* if non-zero, minimum required value for max_queues */ int num_queues; uint64_t features; + /** @acked_features: final set of negotiated features */ uint64_t acked_features; + /** @backend_features: backend specific feature bits */ uint64_t backend_features; + /** @protocol_features: final negotiated protocol features */ uint64_t protocol_features; uint64_t max_queues; uint64_t backend_cap; From patchwork Mon Oct 10 17:28:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 613761 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2118701pvb; Mon, 10 Oct 2022 10:36:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM40jhTMla55WfMr7q8M5OKSK6tY95E53HzWNCZ6MBo/NE+eJY/7t/DRZWFEB+P43A4a7TLo X-Received: by 2002:ac8:7d0f:0:b0:398:3029:3328 with SMTP id g15-20020ac87d0f000000b0039830293328mr9405731qtb.99.1665423391932; Mon, 10 Oct 2022 10:36:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665423391; cv=none; d=google.com; s=arc-20160816; b=Vfh06Y1lAVrMolfB0Qnc8ph/0xZ1gl6+pDxbGFEDTu0Aynl2g48e+BcDq06HkwOHRb 8Oc6Pljoi9JVkc2nozKTVbU8jklWs0CoCVowRhe1zLcsJXvX6LSQzK7MLYwjMf0vppaf AOgUeHOptKy9AQs9s/mCaBfbD4B5x09aLIAkUDt0iES7r9w1TJUxVMd8RDiQbDWxm/s7 7LKmGBqfhVsaxWuYmYHdfXf42Fmqk/BYCRQkV5rmx4ACvJpb4Hc5Yqcwu+IUwK7rsPVN BJ2T47QRMZQ6ha4Hp7vxZbARMT7MI2UAPuzZhi8pIIX4Z4xcLyVMzvCH7CN2EcbF6Kdj XjZA== 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:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Utw17k59pDTuaZhHiKWHR5GCzq1rexlKpcJDjdcDlak=; b=pwZyPOQlYV3mmf+CMUa46tlykzXdROZpGeay9k16VKNxyMxcRtkkIQt6N9Ll+/ihjh rZ/i5aIFNn+R0pzpRY01SpGMkwuHLEX6DRRsVcmoaslnWZNYhxdTBNpIRpkgBmv84ZR0 z1Sk+RftPFcpDjxn2P1VNHWog6KusDWQI08mBo2V9LHJtbLXS/C4wrq0sGdrqWuOb2Eb Le12rL8qXkwjl62FnDZsUDH4T0mjznKNohHzQnNEEM4FVjSB2DyQrz/mBEvsGaupXx+u xd0npP035+VhsH7ZlIQWK97voVePXAkP2M1EnGEbqfs9wBH8FWIRDgHtFuL1tuq+CKAJ SOWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R6NIjFiC; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id fw10-20020a056214238a00b004afa0938207si5640324qvb.132.2022.10.10.10.36.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Oct 2022 10:36:31 -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=@redhat.com header.s=mimecast20190719 header.b=R6NIjFiC; 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=redhat.com Received: from localhost ([::1]:33170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohwha-00066O-E8 for patch@linaro.org; Mon, 10 Oct 2022 13:36:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40722) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwaP-000840-W7 for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:29:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49262) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwaL-0006RJ-9T for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:29:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665422940; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Utw17k59pDTuaZhHiKWHR5GCzq1rexlKpcJDjdcDlak=; b=R6NIjFiCyQc5dQVPvwlv3fWfoS+V0ARUiytgY76I4t/v2/k4TswDbURXl0oq64B0gHR1mF 4Ln9UpSC5Y7W5/RbXzvoNP7sG7789rGOeepDC4Zw0zuxaChCxXALMhgXbmacVYqrMnXzj6 z2Of4uy/FHQ8seDDylj4hjZHqI+yraA= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-508-KYge1n_QN1u7K6rj4Nu1SA-1; Mon, 10 Oct 2022 13:28:59 -0400 X-MC-Unique: KYge1n_QN1u7K6rj4Nu1SA-1 Received: by mail-wr1-f72.google.com with SMTP id e19-20020adfa453000000b0022e3608df56so2975819wra.10 for ; Mon, 10 Oct 2022 10:28:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Utw17k59pDTuaZhHiKWHR5GCzq1rexlKpcJDjdcDlak=; b=XsQncWk25TDwsi8PAh6BZfH95IfMPk9PoCy6pecq2gb5JhpRYjRR4bt2pJnPGTyo7G XWN2hAnwPhnsaNlxV20NK1SS9luqNTcoXlcqOBolBhulcB7qoHL4ntXUYUVtbzXSgpTu MBBDarde5EHbMrtJmk98HWnRQbNFdJg/sfZiBamsBBuGInNJrBQ4CoDr0aGOlKPid7T+ rMTCTCEjb1MOrBVX2iH+i8R1UcP+oIZOlYn6k1sV1b7SdvbMa4nuKgQ3XbMj6w5q2dgs Hq88YDhMPRj+iHkb2cflwwQYen8kQXZ/MR1Q/j7lduyoT3IGtN88VlqX2S1CESs0leO2 HcwA== X-Gm-Message-State: ACrzQf2UCOPsuk7nuR4+vp4VAmQsusF7/VSrXFEkEMctiCXFdG9iJwU7 qfeqEJJOCp2PFKEeuF/pgVFYve3vaslzk6xZl4x1CCkbOdTqF7hgLv13CJDF+ey3NLmv6NcIHPH ulJzyJ9K8qFEwcx/h9zuzXdHUZLdTI8zbcXMzyOjnZn7P8G5cCHtqIKl4vY5q X-Received: by 2002:a05:6000:1861:b0:22a:bb41:886d with SMTP id d1-20020a056000186100b0022abb41886dmr12185283wri.661.1665422937966; Mon, 10 Oct 2022 10:28:57 -0700 (PDT) X-Received: by 2002:a05:6000:1861:b0:22a:bb41:886d with SMTP id d1-20020a056000186100b0022abb41886dmr12185267wri.661.1665422937671; Mon, 10 Oct 2022 10:28:57 -0700 (PDT) Received: from redhat.com ([2.55.183.131]) by smtp.gmail.com with ESMTPSA id k18-20020a5d5192000000b00228dbf15072sm9388945wrv.62.2022.10.10.10.28.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 10:28:57 -0700 (PDT) Date: Mon, 10 Oct 2022 13:28:54 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Jason Wang , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= Subject: [PULL 04/55] hw/virtio: fix some coding style issues Message-ID: <20221010172813.204597-5-mst@redhat.com> References: <20221010172813.204597-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221010172813.204597-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, 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 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: Alex Bennée Signed-off-by: Alex Bennée Acked-by: Jason Wang Message-Id: <20220802095010.3330793-8-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daudé --- hw/virtio/vhost-user.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 0b7e41ffe8..03415b6c95 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 Mon Oct 10 17:28:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 613765 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2124852pvb; Mon, 10 Oct 2022 10:48:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5NBT1ZFzjph2PGtiPLoCKRCHvy+dcqNa390tPjB3R9l4UT3BVxwiyUH0c2STJL8or6mNur X-Received: by 2002:a05:6214:27ce:b0:4b1:92c9:611c with SMTP id ge14-20020a05621427ce00b004b192c9611cmr15707417qvb.115.1665424132584; Mon, 10 Oct 2022 10:48:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665424132; cv=none; d=google.com; s=arc-20160816; b=TEy8Q8zjrUUZ2NwpRE2Ev3Z0fF0jz9klDkNraNHEOS0ZgqB2ph3JU9RVRvLnhx1AMI 6PhT6NDrjdRCLK286kp5p/DsukB8mHTAtR2ffiLT2ANETpw5k72FsZfJpdMKLM0AsKoQ UTS+hKwfQgCyTYdXVj7ta2kCvUo/KgKTMD/+U6uow10wkGvpvYSPcT4QJIclCA3QzIw9 44hMSBMxaooUhCBn7twm9kxOR9E5QqsQz6ji04h1tX/7xUVDih3xN+6F1iUnXIdesW89 6iFlY2hBQuBnebFFqdmEJ9Bl+MnFXq3H2a5TeKQ6vAWLyk0LTmnCHzPNz2qt18O1v17H BQ7g== 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:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=nvGXlozHC+df8Bjp/q5u04uDCnJ0h7GQtmXnBTatQbk=; b=cekT2xIsfOaa+csG1V8nm3PhJq7TLuYUnVI2WNFYTYQD/49GJk8YAx1FClrbkSQ85e 8OZMehAhRG5gHGufL4SbDvErbK0JCFKCT8oDXh7c/e+r26UCodO+LOg3Z8B2b097XI5o RKoHMDvzzwi/UyyG3RIEBId/i3FtqN8LSCNgLkRzz1sPOmZByMTTDx3XBTcWE0cn6zYa gKSmFciFUT4Z0u5x94ZmzaDDzKKaQoNSr+TPmbqWxfAt7B8y4eHlKEwNYgBw5u7OpaC2 Hur6qFAKEVDAyf1NUKXtK6uXc3Nqk8k9Yfn92szDwMN1Y3aft13T2HhiGxQVM6PN8wGN T8gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YDGNasLZ; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a9-20020ac80009000000b0035ba1e5d423si4797781qtg.627.2022.10.10.10.48.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Oct 2022 10:48: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=@redhat.com header.s=mimecast20190719 header.b=YDGNasLZ; 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=redhat.com Received: from localhost ([::1]:50378 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohwtY-0005X6-3R for patch@linaro.org; Mon, 10 Oct 2022 13:48:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40724) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwaT-0008CO-Eb for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:29:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:52922) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwaP-0006SB-AE for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:29:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665422944; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nvGXlozHC+df8Bjp/q5u04uDCnJ0h7GQtmXnBTatQbk=; b=YDGNasLZjUH9sRfUCqUmv19Q4HdV6p/JJauseK6kW2FbRb6MdexVKMB/shYLgwwlfAWgKx a/xVTOkCvxOMcaBLHX9zI0bQvNZ7K2giz7gYGlZaGbt6YMFY/xuR/RV1KcufKO4x8v26u3 Md0YYKWd1qsDDIA7FG0GYixVCeO0ofw= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-408-YvHTMqN6M6uINC-rPaBPAA-1; Mon, 10 Oct 2022 13:29:03 -0400 X-MC-Unique: YvHTMqN6M6uINC-rPaBPAA-1 Received: by mail-wr1-f70.google.com with SMTP id u20-20020adfc654000000b0022cc05e9119so2950737wrg.16 for ; Mon, 10 Oct 2022 10:29:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nvGXlozHC+df8Bjp/q5u04uDCnJ0h7GQtmXnBTatQbk=; b=4zQQY6SEWKgB2Nkf1tDLSnqOSmu0LfAQlbKJ+RxEC5egKetR/u7CjjCODNsk/5mh+J Wzuvz9MlDgETrC2SWYVsigv3jP5StD9IBsuDrONJMMdxlNUEVcQaPjNxFVYsQkFWXjOj lD8IQK78ZoxtvxHHgZUfGXvVKut5TJb9yVBjWju2DadpM/sizn3uEzB2T5WogwvgAOya jXaQUY1Dei15RsOFgMBmFYfhsuZULCrnXHJLQQwnqItfSQzSguVsi6R/++qcP3Z8I4L7 14Iv7Xjl39EBbNKBz8o6L9DA65xHNRIX4GoQ/P/TvKYPTc7GNqpJQYsqYD06GCVnSm61 PlLA== X-Gm-Message-State: ACrzQf0IENGjv19yLH7XKve0NVZ83GhIlksZ0pWxN2RTJQpAO4ycfoq0 AjH8NIIei8xnazTEJydz5hJXt83rQ/w0slV9VOXi1xklrDE6F1uMjvaXki4bBxt5AAlKXK+oJ4T p280Sau/aizjBzMrGlfsCUc/LdgIrqtGfOR+w6I8U09VuBwGPr76EbaxVi0EG X-Received: by 2002:a05:6000:1885:b0:22e:7851:b257 with SMTP id a5-20020a056000188500b0022e7851b257mr12127296wri.418.1665422942159; Mon, 10 Oct 2022 10:29:02 -0700 (PDT) X-Received: by 2002:a05:6000:1885:b0:22e:7851:b257 with SMTP id a5-20020a056000188500b0022e7851b257mr12127279wri.418.1665422941861; Mon, 10 Oct 2022 10:29:01 -0700 (PDT) Received: from redhat.com ([2.55.183.131]) by smtp.gmail.com with ESMTPSA id u9-20020a5d4349000000b0022cdb687bf9sm12062396wrr.0.2022.10.10.10.28.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 10:29:01 -0700 (PDT) Date: Mon, 10 Oct 2022 13:28:57 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Jason Wang Subject: [PULL 05/55] hw/virtio: log potentially buggy guest drivers Message-ID: <20221010172813.204597-6-mst@redhat.com> References: <20221010172813.204597-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221010172813.204597-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, 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 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: Alex Bennée 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 Message-Id: <20220802095010.3330793-9-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- 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 Mon Oct 10 17:29:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 613763 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2121618pvb; Mon, 10 Oct 2022 10:42:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7bRjKjG9yL3xFu1eorhAmp2xzR2bGxl7uyJw0U+rb5ARzYvbG30cerhbWKyeG/4D4REALu X-Received: by 2002:ae9:f50a:0:b0:6e3:3b4f:2ab1 with SMTP id o10-20020ae9f50a000000b006e33b4f2ab1mr13460406qkg.314.1665423754448; Mon, 10 Oct 2022 10:42:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665423754; cv=none; d=google.com; s=arc-20160816; b=sb3vHIx+/XSR+0rz3kVRDmZqIKJiFzUfjJ+BPPCVf8C3F64h4xJ2b2R/lFfP9A2mG8 4//XSrAqXsnRxawzFI3+Gw4QJrIw4Zq4a19n3vOLZgHP1lswoKgIWtgq6eInnSH8d3cN 75U/SqgHM5OaAUMriSV2epODUznZPyGhJWbkLYIiZ39+vbVSqcA7ECwdcmwVoWJv9xOL NbLRkrIEWF6E6nqolK5QTjlfBb376kx+BmMfqvVJWu91sq13HgQODTs3n0Fy+JFpfmn8 VaNMoDTIvuxjIsxNOcVMB3tJSDvB7OIAjKh+nJ3fpzVq8ITbwi3v49sMQ4vUiT5C+QYj rIiA== 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:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/FuzALXECHqoocD8Ass+d81bVkCF0EOizPDi9GCy9zk=; b=HgAdoWqtNOwcuAIqsaTY7F5U6KGdv1dJIOAfVQszvGRttldwmNuHM/Du4AybMTJF5z rnkwmCxD1u9wu3A08nDgZfH92Qlt7pD69wLUyWpQmXQjyUzBlEFQ0zFXi3EKAnUi5VzW vX8ierbYQclE7Fd8KiPoafDLs77Pn/KUFqk86+AAb92fFhNRioVtScTNP3P/nTu5xJ6J 9KSKoW0AjAdFIxdQer4HV5VTnLisgnpuCoPdSkmfcgneNQjr+VTg2tPLre4kbIIUBJT+ yvQlgGGe7k4Uh4ulEA1IRYpVhqMhl9Zc9dSqzWvunZOVBxmYdksMfcakmV48V6dzdnrw EYhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=O6F4GQ2z; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bl3-20020a05620a1a8300b006b2543c5866si5575321qkb.18.2022.10.10.10.42.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Oct 2022 10:42:34 -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=@redhat.com header.s=mimecast20190719 header.b=O6F4GQ2z; 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=redhat.com Received: from localhost ([::1]:39554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohwnQ-0000Q2-Tr for patch@linaro.org; Mon, 10 Oct 2022 13:42:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40726) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwaW-0008KB-DN for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:29:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:56931) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwaT-0006T5-59 for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:29:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665422948; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/FuzALXECHqoocD8Ass+d81bVkCF0EOizPDi9GCy9zk=; b=O6F4GQ2z3ofTdKl+KqdIIhznfqYvr4I96SgMOP85wax8/uceb7K38WXHwncqsRt+zTOuJo YdyUuvEAzJW4dju/cMkQ6krGRufiTjypjzBCHF7n5cg+h0yBDKbPps2tRxiVqLi/vUbru4 j9Bu3WoSulbbiXTQpSorv8z2GmbQ20Q= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-389-y-5j2JHJO-21mHZSYQimMw-1; Mon, 10 Oct 2022 13:29:07 -0400 X-MC-Unique: y-5j2JHJO-21mHZSYQimMw-1 Received: by mail-wm1-f72.google.com with SMTP id c130-20020a1c3588000000b003b56be513e1so7308223wma.0 for ; Mon, 10 Oct 2022 10:29:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/FuzALXECHqoocD8Ass+d81bVkCF0EOizPDi9GCy9zk=; b=AxRfgi5KlokJaV4FBe/Ydhu+V6KnZK2hJ3Wv6rgMKqyaPfba0RDEQux0G/qfFZE732 5KKuD6nj7RqvMV3x2sAvlO2DDBqwXYpNSUOLnmOnebq8rxEmshQlazvWD+YedwRh8Anr 8tVXUlyo/mje35TOSLRh9zDKiCDYOtSkJ1UP9oqgFRYzoeXz8me545Vp6itBghf3jBCQ tY6V6unUXNmwKb/wUUVohBnt67WLZUAx9uncYLWkDikzxkFFP61aUC+D/mkvvGw4Rfrs /K+rJTd+Gmq/goBJ4GpVClHdadpsPMU7ENIeQAOxiyHV+w5b4FtmakD/zEO90rd9AHZL I6Xg== X-Gm-Message-State: ACrzQf2yJAhOMZI1VwDrtlSy5ZYDqoVduYRc1yRV+PwXEbIRwT7yOXK9 oPTDr/FiUFD+V/ERXf7lGNTYwcK5LEbkavCZoilD2lTBLI1pTxo5M7qLSF5oiTL5IcEM/w+VrXY 8Ph+/eGAnFXmw2a2YWkPJADrpuNbBphERYSEs5CJMFglEYWljZLgkf+QIZfCD X-Received: by 2002:a05:600c:4849:b0:3c6:7e82:a9d7 with SMTP id j9-20020a05600c484900b003c67e82a9d7mr4905679wmo.75.1665422946018; Mon, 10 Oct 2022 10:29:06 -0700 (PDT) X-Received: by 2002:a05:600c:4849:b0:3c6:7e82:a9d7 with SMTP id j9-20020a05600c484900b003c67e82a9d7mr4905662wmo.75.1665422945641; Mon, 10 Oct 2022 10:29:05 -0700 (PDT) Received: from redhat.com ([2.55.183.131]) by smtp.gmail.com with ESMTPSA id bv10-20020a0560001f0a00b00228fa832b7asm9286506wrb.52.2022.10.10.10.29.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 10:29:05 -0700 (PDT) Date: Mon, 10 Oct 2022 13:29:02 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Philippe =?utf-8?q?M?= =?utf-8?q?athieu-Daud=C3=A9?= Subject: [PULL 06/55] hw/virtio: add some vhost-user trace events Message-ID: <20221010172813.204597-7-mst@redhat.com> References: <20221010172813.204597-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221010172813.204597-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 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: Alex Bennée These are useful for tracing the lifetime of vhost-user connections. Signed-off-by: Alex Bennée Message-Id: <20220802095010.3330793-10-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daudé --- hw/virtio/vhost.c | 6 ++++++ hw/virtio/trace-events | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index f758f177bb..5185c15295 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1477,6 +1477,8 @@ void vhost_dev_cleanup(struct vhost_dev *hdev) { int i; + trace_vhost_dev_cleanup(hdev); + for (i = 0; i < hdev->nvqs; ++i) { vhost_virtqueue_cleanup(hdev->vqs + i); } @@ -1783,6 +1785,8 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev) /* should only be called after backend is connected */ assert(hdev->vhost_ops); + trace_vhost_dev_start(hdev, vdev->name); + vdev->vhost_started = true; hdev->started = true; hdev->vdev = vdev; @@ -1869,6 +1873,8 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev) /* should only be called after backend is connected */ assert(hdev->vhost_ops); + trace_vhost_dev_stop(hdev, vdev->name); + if (hdev->vhost_ops->vhost_dev_start) { hdev->vhost_ops->vhost_dev_start(hdev, false); } diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 20af2e7ebd..887ca7afa8 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -8,6 +8,10 @@ vhost_region_add_section_aligned(const char *name, uint64_t gpa, uint64_t size, vhost_section(const char *name) "%s" vhost_reject_section(const char *name, int d) "%s:%d" vhost_iotlb_miss(void *dev, int step) "%p step %d" +vhost_dev_cleanup(void *dev) "%p" +vhost_dev_start(void *dev, const char *name) "%p:%s" +vhost_dev_stop(void *dev, const char *name) "%p:%s" + # vhost-user.c vhost_user_postcopy_end_entry(void) "" From patchwork Mon Oct 10 17:29:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 613768 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2128098pvb; Mon, 10 Oct 2022 10:54:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6ALqVqmPsRAhxJ5WttJY8NTHmXq/1VXXIGQYUsalpe3XbTnlNXCMXWLJ3K/TUvbGb8AvaC X-Received: by 2002:ad4:5dc6:0:b0:4b3:5d60:f41c with SMTP id m6-20020ad45dc6000000b004b35d60f41cmr13448325qvh.100.1665424493183; Mon, 10 Oct 2022 10:54:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665424493; cv=none; d=google.com; s=arc-20160816; b=nzsB2AYet2Q1CRSJc1gnJBt8Lbi5/p4GTMDONP0MOrp6HM/dwlLvgin9/ZDPr1CL6c kBdb+T2ZLQ9D91n09T2bKXu4dhrvCL1jlbkm3O7S2cyP6wx1fc1flX+fEZNjnTba0glw 1oTv0P3kev2Ef1Wc+XgfcuoXOSjU4+4Q4hIBZRiDSLMCFv/nOSkMRLECUDzp0xYQlKvE VTfbBQVDvGlv8pCGSbEGQStzGy/HdeGZ9Kk1cPOw4GVIye90E9PB/WvMD4mL6VpNzI3R lHkQ7dHLAQarhhPLTuQC4SAcEoXq/J4iUuTCpqPQofpJG78pCOJbjIhy4lN5M90CMV1V erSw== 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:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=2l9JLwGuz3wzXzGkuYjtRaLlikVZCR4iaTnj7H8kZ3E=; b=xz89yS8j1cipXmk7yUvYtK0XjgcIrpJ7dHYrrX9XgVYjDPXD6AGUZZ1+JWWKcPK8zR HHboxJlWu1NHJrP6iGusVBtsj0FVNN2cYBgW5slhE3vLITiq4zEeACc6gOKclQlWmdgq jrfqmj1sAofp++LHuom6UW7kXWpic/rCbn8RdqoF1gugoRhlHa42g59vyqwRYDVKAwDa jgc5bHUS++AGv5C3AodLLsEoheGeRdKeHB5IMZ7jaap+wYJqjyYqumXFwG3haLf8BITV T/9aL4bSyd7p0/wq8sRgbEzbqf/BsBIlNyM3hMpo1Oa3WBfXS3aijOzyMF2HVFDert8N WKXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FqBXL88T; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d21-20020ac84e35000000b00392864bf2b2si5795088qtw.613.2022.10.10.10.54.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Oct 2022 10:54:53 -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=@redhat.com header.s=mimecast20190719 header.b=FqBXL88T; 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=redhat.com Received: from localhost ([::1]:53004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohwzM-0003Bx-Md for patch@linaro.org; Mon, 10 Oct 2022 13:54:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60256) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwae-0000Hh-Uh for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:29:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46795) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwaZ-0006V0-DI for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:29:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665422954; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2l9JLwGuz3wzXzGkuYjtRaLlikVZCR4iaTnj7H8kZ3E=; b=FqBXL88TFPUNgyHRQAIeREt3clOa4hKiYCF95/boryDO/8LIR9dLIfS1rd5omk69LwFJ4w 3cWKaSx3tWscRLnZXPRgt0K/pGvxcxqrNsV+rvs6xjpY+TMh8UxiHFOghwla1qVHbATEaq yaQ5ORjjqFzgsxZ3sWdUIqhVkDwvTac= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-370-UTqY8tbDPO6T0dyImkCGPw-1; Mon, 10 Oct 2022 13:29:11 -0400 X-MC-Unique: UTqY8tbDPO6T0dyImkCGPw-1 Received: by mail-wm1-f70.google.com with SMTP id h10-20020a1c210a000000b003c56437e529so707155wmh.2 for ; Mon, 10 Oct 2022 10:29:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2l9JLwGuz3wzXzGkuYjtRaLlikVZCR4iaTnj7H8kZ3E=; b=68AaFmVG3SobEV6WYhciX6I+0COCto14YWaC1r9Hl6r4SuKx/uxJATHDnFWOzILaKE ZT/WuexgwWJZKkkSaIxS8uPrvHUeCSh4EmdBZ2nEfWRZ4/a5jZ4NYHcGNu/bZsds0Rk5 MZXqWBxNcVP3dBHw1Jbpgt8YJE/3Pmej1jBmpziYbAAPtORukiTyBJQRHGwAyhOTCK8a g4cjrKqbxenOwtl74rxCoF9/hkOD+jgrT34czE79kTvxLaKFP766WhgS7K/zkbb/Erju /1eDXcE+w5WVMUC7JjBNgfYITsLV1gXvTjfeEqypbbjGiyY3Rt7mtPnmshd19yZATHdN mfxg== X-Gm-Message-State: ACrzQf3AVxOxCk0Yr45pI7KBb7xoQ+zId1Z23A9jhdTTIz7274xrn5hz Bb0535nGnDACKTtG0g103xXSwSLk4Hus49ys4rhEd9vYe0L1TclM2OwxVTXG3fFJXhOn9VAA9yw znj0IVVgl45AsGSAD0pMnaoreBnbcUmwWSrYG62pU1Ui9yv0FUBOvKIuuV9Lh X-Received: by 2002:a05:600c:4789:b0:3c4:dbb7:ab0c with SMTP id k9-20020a05600c478900b003c4dbb7ab0cmr8567763wmo.164.1665422950332; Mon, 10 Oct 2022 10:29:10 -0700 (PDT) X-Received: by 2002:a05:600c:4789:b0:3c4:dbb7:ab0c with SMTP id k9-20020a05600c478900b003c4dbb7ab0cmr8567740wmo.164.1665422950091; Mon, 10 Oct 2022 10:29:10 -0700 (PDT) Received: from redhat.com ([2.55.183.131]) by smtp.gmail.com with ESMTPSA id d9-20020adff2c9000000b0021badf3cb26sm11616044wrp.63.2022.10.10.10.29.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 10:29:09 -0700 (PDT) Date: Mon, 10 Oct 2022 13:29:05 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , "Dr. David Alan Gilbert" , Stefan Hajnoczi , Mathieu Poirier , virtio-fs@redhat.com Subject: [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started Message-ID: <20221010172813.204597-8-mst@redhat.com> References: <20221010172813.204597-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221010172813.204597-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, 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 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: Alex Bennée All the boilerplate virtio code does the same thing (or should at least) of checking to see if the VM is running before attempting to start VirtIO. Push the logic up to the common function to avoid getting a copy and paste wrong. Signed-off-by: Alex Bennée Message-Id: <20220802095010.3330793-11-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio.h | 5 +++++ hw/virtio/vhost-user-fs.c | 6 +----- hw/virtio/vhost-user-i2c.c | 6 +----- hw/virtio/vhost-user-rng.c | 6 +----- hw/virtio/vhost-user-vsock.c | 6 +----- hw/virtio/vhost-vsock.c | 6 +----- 6 files changed, 10 insertions(+), 25 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 9bb2485415..74e7ad5a92 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -100,6 +100,7 @@ struct VirtIODevice VirtQueue *vq; MemoryListener listener; uint16_t device_id; + /* @vm_running: current VM running state via virtio_vmstate_change() */ bool vm_running; bool broken; /* device in invalid state, needs reset */ bool use_disabled_flag; /* allow use of 'disable' flag when needed */ @@ -376,6 +377,10 @@ static inline bool virtio_device_started(VirtIODevice *vdev, uint8_t status) return vdev->started; } + if (!vdev->vm_running) { + return false; + } + return status & VIRTIO_CONFIG_S_DRIVER_OK; } diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index e513e4fdda..d2bebba785 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -122,11 +122,7 @@ static void vuf_stop(VirtIODevice *vdev) static void vuf_set_status(VirtIODevice *vdev, uint8_t status) { VHostUserFS *fs = VHOST_USER_FS(vdev); - bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; - - if (!vdev->vm_running) { - should_start = false; - } + bool should_start = virtio_device_started(vdev, status); if (fs->vhost_dev.started == should_start) { return; diff --git a/hw/virtio/vhost-user-i2c.c b/hw/virtio/vhost-user-i2c.c index 6020eee093..b930cf6d5e 100644 --- a/hw/virtio/vhost-user-i2c.c +++ b/hw/virtio/vhost-user-i2c.c @@ -93,11 +93,7 @@ static void vu_i2c_stop(VirtIODevice *vdev) static void vu_i2c_set_status(VirtIODevice *vdev, uint8_t status) { VHostUserI2C *i2c = VHOST_USER_I2C(vdev); - bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; - - if (!vdev->vm_running) { - should_start = false; - } + bool should_start = virtio_device_started(vdev, status); if (i2c->vhost_dev.started == should_start) { return; diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c index 3a7bf8e32d..a9c1c4bc79 100644 --- a/hw/virtio/vhost-user-rng.c +++ b/hw/virtio/vhost-user-rng.c @@ -90,11 +90,7 @@ static void vu_rng_stop(VirtIODevice *vdev) static void vu_rng_set_status(VirtIODevice *vdev, uint8_t status) { VHostUserRNG *rng = VHOST_USER_RNG(vdev); - bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; - - if (!vdev->vm_running) { - should_start = false; - } + bool should_start = virtio_device_started(vdev, status); if (rng->vhost_dev.started == should_start) { return; diff --git a/hw/virtio/vhost-user-vsock.c b/hw/virtio/vhost-user-vsock.c index 0f8ff99f85..22c1616ebd 100644 --- a/hw/virtio/vhost-user-vsock.c +++ b/hw/virtio/vhost-user-vsock.c @@ -55,11 +55,7 @@ const VhostDevConfigOps vsock_ops = { static void vuv_set_status(VirtIODevice *vdev, uint8_t status) { VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev); - bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; - - if (!vdev->vm_running) { - should_start = false; - } + bool should_start = virtio_device_started(vdev, status); if (vvc->vhost_dev.started == should_start) { return; diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index 0338de892f..8031c164a5 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -70,13 +70,9 @@ static int vhost_vsock_set_running(VirtIODevice *vdev, int start) static void vhost_vsock_set_status(VirtIODevice *vdev, uint8_t status) { VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev); - bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; + bool should_start = virtio_device_started(vdev, status); int ret; - if (!vdev->vm_running) { - should_start = false; - } - if (vvc->vhost_dev.started == should_start) { return; } From patchwork Mon Oct 10 17:29:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 613773 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2129769pvb; Mon, 10 Oct 2022 10:58:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM44+fO0NRsuRVxJiJTH5POOiycqHZeLEXbsFV1SF/yS70/OpiqKrMYVyla9AyrxJjkX6mtU X-Received: by 2002:a05:620a:450f:b0:6ce:1bd4:ec09 with SMTP id t15-20020a05620a450f00b006ce1bd4ec09mr13903277qkp.70.1665424700325; Mon, 10 Oct 2022 10:58:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665424700; cv=none; d=google.com; s=arc-20160816; b=uDU44WYrHF7VxXRTY7ebNn3lUDGUoqq1SLstzJow9s3cOF6q1Hgbwaowukv2K2B6/9 o/WSq4/eMNfaDItNFniLmoV+40Awez6/izM+zBNWY7bJAZCGDcUS4rB76J7tgT0B/WQL /Ewm1ywIqAhiESQ9t2FGjeqMbxC1ve+xfF4gpvBfyb0e6fuXO5FS5c6kAbn4K7+qn4C8 lwgQIGofJnBog6L0L3WqM7CuDWYnSKdzirytpMttNslO2AFq4y0CTOHB/NAm3pFftyOy 9a6CGDpduFLs0lzq7c4vaqm70Co5eWaxE2NORHQ+NDml9O6g8Jh4T0PFEmawxNPUjrCA Od1Q== 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:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=MQSvNFO358FNTLwJZfDEG2H4eIK7/uaYo60a2mg4/K8=; b=l55b4zE6vbPq7VC8Kz/X8Iv1TbatyjdC8zPjQ3SiWpHXGJYKP9HxJ73nd8PV0Ne1lp 4h7Wnf2LPfLUz0zv75zA9PQq91olvdHMpjv5/7VFqXouHpH0HAOyQVY6Nvc+ch6aNfwk o7NzAVDsNjxdSZXKu9CnUWAcgwBCtQdnRUO+sCnq8PPRGRAu+Id+P6TOET+x58LNnMQN vkK1QIqLMChvHtUZBqhi3CdmAQTaaeuhixik0CbX6ldeQ4HL9bBI5YoNMUSBGM9Qv6ZS 91r57HgZN2nfVnk1DRY4HcdUo5qaJnyznj7WyewlvksiMEQpwvfZqIbO86gxo40LqkRM /CCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SwklRjhM; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d26-20020ac8545a000000b0035d4b1aae21si2722657qtq.298.2022.10.10.10.58.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Oct 2022 10:58:20 -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=@redhat.com header.s=mimecast20190719 header.b=SwklRjhM; 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=redhat.com Received: from localhost ([::1]:41264 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohx2h-00015J-RN for patch@linaro.org; Mon, 10 Oct 2022 13:58:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwao-0000hA-UH for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:29:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:21993) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwae-0006WE-JD for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:29:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665422959; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MQSvNFO358FNTLwJZfDEG2H4eIK7/uaYo60a2mg4/K8=; b=SwklRjhMi22H8ljIbzchReXCXmSbk6l1S1A3Ghk+EvNur7rW2nC/dYQfq+KlqDHr2IXKM0 kHByEdEX4zPNkpjkFOI6+FcCiwsmVjPAEQvCo5TNEVAnt9UP48mxR8omkTFYBh0T5VsYE/ DMgBGQlUG/oYZI8acIi1tX3HdvSKHX8= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-361-LX8Nw0IaNLqMMDlATbLG5Q-1; Mon, 10 Oct 2022 13:29:18 -0400 X-MC-Unique: LX8Nw0IaNLqMMDlATbLG5Q-1 Received: by mail-wm1-f72.google.com with SMTP id k21-20020a7bc415000000b003b4fac53006so3260437wmi.3 for ; Mon, 10 Oct 2022 10:29:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=MQSvNFO358FNTLwJZfDEG2H4eIK7/uaYo60a2mg4/K8=; b=5+dRT25n2q796kgmIi4EDgdKO21KK/EELI0Eon0BUv/gggN1H7O3W2jmiJqlSnSCzd XOGmh3lheadaURdx78ZX0OQ+q9jPJgRskrzRyeQpbQcpao5tbBH4KFA1t0zjpAFLGGSO Z3hVg+ooNCGgB1Kgx3BVnFnh5B2Xkn5yQ0e2EfokgII9R/fGoUp5VVAUr9G4TFDGD3/b dEzIbv8+QAWT2l54PqhigYcktHIjDWb9ktK5tVSlhAqlBN26e+borWRmGhUuPmx/BGmF MlYi2o5T0iPpiMVPpl1hpWY7mGvvUZzLJ4esdKYU44Zuwi7Uankg+j1/AjHqJw1bk2LZ KUSw== X-Gm-Message-State: ACrzQf3Bw3gstHo4G4DH6TC2Mcmz3sk1I9mqJO8BEH2ZqUPiEqqLTD19 gst8Ft2M04L3PxCJTAAV0EAys1nHoxzXcNv5S6m9cr77ZRYkOzvY4cIGYGnoVNTUiRBDS+C+PVO CA39PYnQftx6KnR0ntBapUZIJrpEb2VpBfzRdjgPGfVHtaGl4esNJUFgyPGAc X-Received: by 2002:a05:6000:981:b0:22e:6b59:fe52 with SMTP id by1-20020a056000098100b0022e6b59fe52mr11674598wrb.188.1665422956548; Mon, 10 Oct 2022 10:29:16 -0700 (PDT) X-Received: by 2002:a05:6000:981:b0:22e:6b59:fe52 with SMTP id by1-20020a056000098100b0022e6b59fe52mr11674572wrb.188.1665422956219; Mon, 10 Oct 2022 10:29:16 -0700 (PDT) Received: from redhat.com ([2.55.183.131]) by smtp.gmail.com with ESMTPSA id p17-20020a5d4591000000b0022e32f4c06asm9187324wrq.11.2022.10.10.10.29.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 10:29:15 -0700 (PDT) Date: Mon, 10 Oct 2022 13:29:10 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Raphael Norwitz , Raphael Norwitz , Kevin Wolf , Hanna Reitz , Paolo Bonzini , Fam Zheng , "Dr. David Alan Gilbert" , Stefan Hajnoczi , Mathieu Poirier , qemu-block@nongnu.org, virtio-fs@redhat.com Subject: [PULL 08/55] hw/virtio: move vhd->started check into helper and add FIXME Message-ID: <20221010172813.204597-9-mst@redhat.com> References: <20221010172813.204597-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221010172813.204597-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 autolearn=unavailable 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: Alex Bennée The `started` field is manipulated internally within the vhost code except for one place, vhost-user-blk via f5b22d06fb (vhost: recheck dev state in the vhost_migration_log routine). Mark that as a FIXME because it introduces a potential race. I think the referenced fix should be tracking its state locally. Signed-off-by: Alex Bennée Message-Id: <20220802095010.3330793-12-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Raphael Norwitz --- include/hw/virtio/vhost.h | 12 ++++++++++++ hw/block/vhost-user-blk.c | 10 ++++++++-- hw/scsi/vhost-scsi.c | 4 ++-- hw/scsi/vhost-user-scsi.c | 2 +- hw/virtio/vhost-user-fs.c | 3 ++- hw/virtio/vhost-user-i2c.c | 4 ++-- hw/virtio/vhost-user-rng.c | 4 ++-- hw/virtio/vhost-user-vsock.c | 2 +- hw/virtio/vhost-vsock-common.c | 3 ++- hw/virtio/vhost-vsock.c | 2 +- 10 files changed, 33 insertions(+), 13 deletions(-) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 586c5457e2..61b957e927 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -94,6 +94,7 @@ struct vhost_dev { uint64_t protocol_features; uint64_t max_queues; uint64_t backend_cap; + /* @started: is the vhost device started? */ bool started; bool log_enabled; uint64_t log_size; @@ -165,6 +166,17 @@ int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev); */ void vhost_dev_disable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev); +/** + * vhost_dev_is_started() - report status of vhost device + * @hdev: common vhost_dev structure + * + * Return the started status of the vhost device + */ +static inline bool vhost_dev_is_started(struct vhost_dev *hdev) +{ + return hdev->started; +} + /** * vhost_dev_start() - start the vhost device * @hdev: common vhost_dev structure diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 9117222456..2bba42478d 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -229,7 +229,7 @@ static void vhost_user_blk_set_status(VirtIODevice *vdev, uint8_t status) return; } - if (s->dev.started == should_start) { + if (vhost_dev_is_started(&s->dev) == should_start) { return; } @@ -286,7 +286,7 @@ static void vhost_user_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq) return; } - if (s->dev.started) { + if (vhost_dev_is_started(&s->dev)) { return; } @@ -415,6 +415,12 @@ static void vhost_user_blk_event(void *opaque, QEMUChrEvent event) * the vhost migration code. If disconnect was caught there is an * option for the general vhost code to get the dev state without * knowing its type (in this case vhost-user). + * + * FIXME: this is sketchy to be reaching into vhost_dev + * now because we are forcing something that implies we + * have executed vhost_dev_stop() but that won't happen + * until vhost_user_blk_stop() gets called from the bh. + * Really this state check should be tracked locally. */ s->dev.started = false; } diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 3059068175..bdf337a7a2 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -120,7 +120,7 @@ static void vhost_scsi_set_status(VirtIODevice *vdev, uint8_t val) start = false; } - if (vsc->dev.started == start) { + if (vhost_dev_is_started(&vsc->dev) == start) { return; } @@ -147,7 +147,7 @@ static int vhost_scsi_pre_save(void *opaque) /* At this point, backend must be stopped, otherwise * it might keep writing to memory. */ - assert(!vsc->dev.started); + assert(!vhost_dev_is_started(&vsc->dev)); return 0; } diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c index 1b2f7eed98..bc37317d55 100644 --- a/hw/scsi/vhost-user-scsi.c +++ b/hw/scsi/vhost-user-scsi.c @@ -49,7 +49,7 @@ static void vhost_user_scsi_set_status(VirtIODevice *vdev, uint8_t status) VHostSCSICommon *vsc = VHOST_SCSI_COMMON(s); bool start = (status & VIRTIO_CONFIG_S_DRIVER_OK) && vdev->vm_running; - if (vsc->dev.started == start) { + if (vhost_dev_is_started(&vsc->dev) == start) { return; } diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index d2bebba785..ad0f91c607 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -20,6 +20,7 @@ #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h" #include "qemu/error-report.h" +#include "hw/virtio/vhost.h" #include "hw/virtio/vhost-user-fs.h" #include "monitor/monitor.h" #include "sysemu/sysemu.h" @@ -124,7 +125,7 @@ static void vuf_set_status(VirtIODevice *vdev, uint8_t status) VHostUserFS *fs = VHOST_USER_FS(vdev); bool should_start = virtio_device_started(vdev, status); - if (fs->vhost_dev.started == should_start) { + if (vhost_dev_is_started(&fs->vhost_dev) == should_start) { return; } diff --git a/hw/virtio/vhost-user-i2c.c b/hw/virtio/vhost-user-i2c.c index b930cf6d5e..bc58b6c0d1 100644 --- a/hw/virtio/vhost-user-i2c.c +++ b/hw/virtio/vhost-user-i2c.c @@ -95,7 +95,7 @@ static void vu_i2c_set_status(VirtIODevice *vdev, uint8_t status) VHostUserI2C *i2c = VHOST_USER_I2C(vdev); bool should_start = virtio_device_started(vdev, status); - if (i2c->vhost_dev.started == should_start) { + if (vhost_dev_is_started(&i2c->vhost_dev) == should_start) { return; } @@ -174,7 +174,7 @@ static void vu_i2c_disconnect(DeviceState *dev) } i2c->connected = false; - if (i2c->vhost_dev.started) { + if (vhost_dev_is_started(&i2c->vhost_dev)) { vu_i2c_stop(vdev); } } diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c index a9c1c4bc79..bc1f36c5ac 100644 --- a/hw/virtio/vhost-user-rng.c +++ b/hw/virtio/vhost-user-rng.c @@ -92,7 +92,7 @@ static void vu_rng_set_status(VirtIODevice *vdev, uint8_t status) VHostUserRNG *rng = VHOST_USER_RNG(vdev); bool should_start = virtio_device_started(vdev, status); - if (rng->vhost_dev.started == should_start) { + if (vhost_dev_is_started(&rng->vhost_dev) == should_start) { return; } @@ -160,7 +160,7 @@ static void vu_rng_disconnect(DeviceState *dev) rng->connected = false; - if (rng->vhost_dev.started) { + if (vhost_dev_is_started(&rng->vhost_dev)) { vu_rng_stop(vdev); } } diff --git a/hw/virtio/vhost-user-vsock.c b/hw/virtio/vhost-user-vsock.c index 22c1616ebd..7b67e29d83 100644 --- a/hw/virtio/vhost-user-vsock.c +++ b/hw/virtio/vhost-user-vsock.c @@ -57,7 +57,7 @@ static void vuv_set_status(VirtIODevice *vdev, uint8_t status) VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev); bool should_start = virtio_device_started(vdev, status); - if (vvc->vhost_dev.started == should_start) { + if (vhost_dev_is_started(&vvc->vhost_dev) == should_start) { return; } diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index 7394818e00..29b9ab4f72 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -14,6 +14,7 @@ #include "hw/virtio/virtio-access.h" #include "qemu/error-report.h" #include "hw/qdev-properties.h" +#include "hw/virtio/vhost.h" #include "hw/virtio/vhost-vsock.h" #include "qemu/iov.h" #include "monitor/monitor.h" @@ -199,7 +200,7 @@ int vhost_vsock_common_pre_save(void *opaque) * At this point, backend must be stopped, otherwise * it might keep writing to memory. */ - assert(!vvc->vhost_dev.started); + assert(!vhost_dev_is_started(&vvc->vhost_dev)); return 0; } diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index 8031c164a5..7dc3c73931 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -73,7 +73,7 @@ static void vhost_vsock_set_status(VirtIODevice *vdev, uint8_t status) bool should_start = virtio_device_started(vdev, status); int ret; - if (vvc->vhost_dev.started == should_start) { + if (vhost_dev_is_started(&vvc->vhost_dev) == should_start) { return; } From patchwork Mon Oct 10 17:29:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 613766 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2125218pvb; Mon, 10 Oct 2022 10:49:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7QUPZg3BDGKHDjuboETcar69fUoI6BP8D9hy31WypeqTETYU+icTtsWJ4zU+P5HDemrN6K X-Received: by 2002:a05:6214:4109:b0:4b1:d25f:e4e1 with SMTP id kc9-20020a056214410900b004b1d25fe4e1mr15883530qvb.49.1665424174452; Mon, 10 Oct 2022 10:49:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665424174; cv=none; d=google.com; s=arc-20160816; b=xka37a3tEQyZkZGRw9jGbMIpDctAZFgvSOaaDkQXKybPpUsM4PWknyIVYqPTckQkgW XCuz7uogKolM4/XVweAWyi2+793sHjnPwDZEr42NQSzOq2NG76Nc+wzvr+hSO1H9F2W9 Q3y/uE+fVrY0iPe+B4FLLltZBZDSeUhIHRNoKFKmjKEAZU8/xglLBihk4IieqSSPosVW f0W3Y9zQ+GhbE5jdiSRgR+wJn3A+1/K0ZuC6L14j31t0EBuqGIkBiSNSLAMRhPguNqsG w/AIlgjb6RYQEeKYxrtY5dw4IWVRcCxVT6q8mxTEp2OWFVrg7Cyc/wwvjvw96Y2ULVBz TQHQ== 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:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=gmZWIaLBbM0XIchBusCCbI3eKbKP0+13fR+gGociBYs=; b=e1B5Hjy7oL3FRbQXnPU0P/686KeHL2kJ0dxZF5rHNeJyNI87Nj0J1XChUaw1uXBZdO ztoHnBGKkYvglHxa0bej1T3R8Xp/CafJi47+AnfMPAQLKjvZzL7KabiUF1BkP3TfDwsD kqINQfNjJzLiknwGfsVLD1pbzIl0Tuzlbh+CCU19HOkgfcjnhFtI3eut0Lzv2pK9l4dZ Z5E4KI4a8s9XUdROMLjOvDgvqaibAuHu8rQt10J/96pQLjgYwbG1wZBTmB64VS2lj/t6 Ly79AdF+hEbKsbuqIJTZ7BcYaPRWfom5WkD8P5zUGJ+c3wMaKE3+wicYURzwn94+vdMg 76xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=d15uGAe5; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y10-20020a05620a25ca00b006d39dc9d861si6349028qko.664.2022.10.10.10.49.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Oct 2022 10:49:34 -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=@redhat.com header.s=mimecast20190719 header.b=d15uGAe5; 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=redhat.com Received: from localhost ([::1]:35842 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohwuD-0006f1-L0 for patch@linaro.org; Mon, 10 Oct 2022 13:49:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34436) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwav-0000qx-8s for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:29:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:42530) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwar-0006Zk-MD for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:29:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665422972; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gmZWIaLBbM0XIchBusCCbI3eKbKP0+13fR+gGociBYs=; b=d15uGAe53MGEyECCN2BIY0PZH3RY9+tItUyKy7Ao1elQnVmrlmQXXPNfUius3SE6MQX2Rg N704O71cYyN5sV0ffYHkrztQ8BJ/hkRieJGrv1Hw6LE610A+3xji6amNWfA7b8WqO6wIjI G1DEarXf0K5SNlEfkXnqdn5Yhi38KO8= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-155-lGNu9zJyO8WKW9BzPzFubg-1; Mon, 10 Oct 2022 13:29:23 -0400 X-MC-Unique: lGNu9zJyO8WKW9BzPzFubg-1 Received: by mail-wm1-f71.google.com with SMTP id ay21-20020a05600c1e1500b003b45fd14b53so5819064wmb.1 for ; Mon, 10 Oct 2022 10:29:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gmZWIaLBbM0XIchBusCCbI3eKbKP0+13fR+gGociBYs=; b=k04GLorGAjuR9z0ZcHRWnhJToBIcDwBx+NZaxFB43K+Ef1QZ9V/RDtoxtoElX0rXcH YIVN/quwAxthUFMX4FxqNpORjsK083/vfRJ/MuURLgJuqcX7nYe1Ss/Mc+U4PDMi/oZC Jch7GEwqATF1q7IrwCijJMSKj8AznMjyKblM0OWN/EuJhAhm9zVZx0+pl1XMcUtLtSCH GBxBqTZtqSj5E2TGjaWG0wxji91MIKOB7C1ATGXnYu1GB1s20K2ZT86Fh/zOCnu/aI5c FaQq+uZOhdL3GzVi1/Drd1Jm/e6C/DfxVP5jiGdjZATbFKUFYW6Ok6cmbxjJkwJ5RDxC 2qmA== X-Gm-Message-State: ACrzQf0Rt/PW045ROg37SbGyzqpT24QAV28+NrAKvxCw/ePoe/Kr3bHm 6bD6C5gj9oCOGIl//dZ5W4lXWaL049CyEoivhxA6tLgJ0pSnHT5QPNRXVKQ+ZbYmv8D4hdVcB/A 3KzIgiHFOiEvCpSP3KM3vvn1kWQnXUethHqDiLALgsrNIIOxUJFawlSXGWHeN X-Received: by 2002:a05:600c:b43:b0:3c3:64cd:6f39 with SMTP id k3-20020a05600c0b4300b003c364cd6f39mr11636172wmr.66.1665422961358; Mon, 10 Oct 2022 10:29:21 -0700 (PDT) X-Received: by 2002:a05:600c:b43:b0:3c3:64cd:6f39 with SMTP id k3-20020a05600c0b4300b003c364cd6f39mr11636137wmr.66.1665422960946; Mon, 10 Oct 2022 10:29:20 -0700 (PDT) Received: from redhat.com ([2.55.183.131]) by smtp.gmail.com with ESMTPSA id g20-20020a05600c4ed400b003b4ac05a8a4sm23754363wmq.27.2022.10.10.10.29.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 10:29:20 -0700 (PDT) Date: Mon, 10 Oct 2022 13:29:16 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Viresh Kumar , Alex =?utf-8?q?Benn=C3=A9e?= , Vincent Whitchurch Subject: [PULL 09/55] hw/virtio: add boilerplate for vhost-user-gpio device Message-ID: <20221010172813.204597-10-mst@redhat.com> References: <20221010172813.204597-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221010172813.204597-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 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 Message-Id: <20220802095010.3330793-13-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-user-gpio.h | 35 +++ hw/virtio/vhost-user-gpio.c | 411 ++++++++++++++++++++++++++++ MAINTAINERS | 7 + hw/virtio/Kconfig | 5 + hw/virtio/meson.build | 1 + hw/virtio/trace-events | 5 + 6 files changed, 464 insertions(+) create mode 100644 include/hw/virtio/vhost-user-gpio.h create mode 100644 hw/virtio/vhost-user-gpio.c diff --git a/include/hw/virtio/vhost-user-gpio.h b/include/hw/virtio/vhost-user-gpio.h new file mode 100644 index 0000000000..4fe9aeecc0 --- /dev/null +++ b/include/hw/virtio/vhost-user-gpio.h @@ -0,0 +1,35 @@ +/* + * Vhost-user GPIO virtio device + * + * Copyright (c) 2021 Viresh Kumar + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef _QEMU_VHOST_USER_GPIO_H +#define _QEMU_VHOST_USER_GPIO_H + +#include "hw/virtio/virtio.h" +#include "hw/virtio/vhost.h" +#include "hw/virtio/vhost-user.h" +#include "standard-headers/linux/virtio_gpio.h" +#include "chardev/char-fe.h" + +#define TYPE_VHOST_USER_GPIO "vhost-user-gpio-device" +OBJECT_DECLARE_SIMPLE_TYPE(VHostUserGPIO, VHOST_USER_GPIO); + +struct VHostUserGPIO { + /*< private >*/ + VirtIODevice parent_obj; + CharBackend chardev; + struct virtio_gpio_config config; + struct vhost_virtqueue *vhost_vq; + struct vhost_dev vhost_dev; + VhostUserState vhost_user; + VirtQueue *command_vq; + VirtQueue *interrupt_vq; + bool connected; + /*< public >*/ +}; + +#endif /* _QEMU_VHOST_USER_GPIO_H */ diff --git a/hw/virtio/vhost-user-gpio.c b/hw/virtio/vhost-user-gpio.c new file mode 100644 index 0000000000..8b40fe450c --- /dev/null +++ b/hw/virtio/vhost-user-gpio.c @@ -0,0 +1,411 @@ +/* + * Vhost-user GPIO virtio device + * + * Copyright (c) 2022 Viresh Kumar + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/qdev-properties.h" +#include "hw/virtio/virtio-bus.h" +#include "hw/virtio/vhost-user-gpio.h" +#include "qemu/error-report.h" +#include "standard-headers/linux/virtio_ids.h" +#include "trace.h" + +#define REALIZE_CONNECTION_RETRIES 3 + +/* Features required from VirtIO */ +static const int feature_bits[] = { + VIRTIO_F_VERSION_1, + VIRTIO_F_NOTIFY_ON_EMPTY, + VIRTIO_RING_F_INDIRECT_DESC, + VIRTIO_RING_F_EVENT_IDX, + VIRTIO_GPIO_F_IRQ, + VHOST_INVALID_FEATURE_BIT +}; + +static void vu_gpio_get_config(VirtIODevice *vdev, uint8_t *config) +{ + VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); + + memcpy(config, &gpio->config, sizeof(gpio->config)); +} + +static int vu_gpio_config_notifier(struct vhost_dev *dev) +{ + VHostUserGPIO *gpio = VHOST_USER_GPIO(dev->vdev); + + memcpy(dev->vdev->config, &gpio->config, sizeof(gpio->config)); + virtio_notify_config(dev->vdev); + + return 0; +} + +const VhostDevConfigOps gpio_ops = { + .vhost_dev_config_notifier = vu_gpio_config_notifier, +}; + +static int vu_gpio_start(VirtIODevice *vdev) +{ + BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); + VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); + struct vhost_dev *vhost_dev = &gpio->vhost_dev; + int ret, i; + + if (!k->set_guest_notifiers) { + error_report("binding does not support guest notifiers"); + return -ENOSYS; + } + + ret = vhost_dev_enable_notifiers(vhost_dev, vdev); + if (ret < 0) { + error_report("Error enabling host notifiers: %d", ret); + return ret; + } + + ret = k->set_guest_notifiers(qbus->parent, vhost_dev->nvqs, true); + if (ret < 0) { + error_report("Error binding guest notifier: %d", ret); + goto err_host_notifiers; + } + + /* + * Before we start up we need to ensure we have the final feature + * set needed for the vhost configuration. The backend may also + * apply backend_features when the feature set is sent. + */ + vhost_ack_features(&gpio->vhost_dev, feature_bits, vdev->guest_features); + + ret = vhost_dev_start(&gpio->vhost_dev, vdev); + if (ret < 0) { + error_report("Error starting vhost-user-gpio: %d", ret); + goto err_guest_notifiers; + } + + /* + * guest_notifier_mask/pending not used yet, so just unmask + * everything here. virtio-pci will do the right thing by + * enabling/disabling irqfd. + */ + for (i = 0; i < gpio->vhost_dev.nvqs; i++) { + vhost_virtqueue_mask(&gpio->vhost_dev, vdev, i, false); + } + + /* + * As we must have VHOST_USER_F_PROTOCOL_FEATURES (because + * VHOST_USER_GET_CONFIG requires it) we need to explicitly enable + * the vrings. + */ + g_assert(vhost_dev->vhost_ops && + vhost_dev->vhost_ops->vhost_set_vring_enable); + ret = vhost_dev->vhost_ops->vhost_set_vring_enable(vhost_dev, true); + if (ret == 0) { + return 0; + } + + error_report("Failed to start vrings for vhost-user-gpio: %d", ret); + +err_guest_notifiers: + k->set_guest_notifiers(qbus->parent, gpio->vhost_dev.nvqs, false); +err_host_notifiers: + vhost_dev_disable_notifiers(&gpio->vhost_dev, vdev); + + return ret; +} + +static void vu_gpio_stop(VirtIODevice *vdev) +{ + VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); + BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); + struct vhost_dev *vhost_dev = &gpio->vhost_dev; + int ret; + + if (!k->set_guest_notifiers) { + return; + } + + /* + * We can call vu_gpio_stop multiple times, for example from + * vm_state_notify and the final object finalisation. Check we + * aren't already stopped before doing so. + */ + if (!vhost_dev_is_started(vhost_dev)) { + return; + } + + vhost_dev_stop(vhost_dev, vdev); + + ret = k->set_guest_notifiers(qbus->parent, vhost_dev->nvqs, false); + if (ret < 0) { + error_report("vhost guest notifier cleanup failed: %d", ret); + return; + } + + vhost_dev_disable_notifiers(vhost_dev, vdev); +} + +static void vu_gpio_set_status(VirtIODevice *vdev, uint8_t status) +{ + VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); + bool should_start = virtio_device_started(vdev, status); + + trace_virtio_gpio_set_status(status); + + if (!gpio->connected) { + return; + } + + if (vhost_dev_is_started(&gpio->vhost_dev) == should_start) { + return; + } + + if (should_start) { + if (vu_gpio_start(vdev)) { + qemu_chr_fe_disconnect(&gpio->chardev); + } + } else { + vu_gpio_stop(vdev); + } +} + +static uint64_t vu_gpio_get_features(VirtIODevice *vdev, uint64_t features, + Error **errp) +{ + VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); + + return vhost_get_features(&gpio->vhost_dev, feature_bits, features); +} + +static void vu_gpio_handle_output(VirtIODevice *vdev, VirtQueue *vq) +{ + /* + * Not normally called; it's the daemon that handles the queue; + * however virtio's cleanup path can call this. + */ +} + +static void vu_gpio_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask) +{ + VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); + + vhost_virtqueue_mask(&gpio->vhost_dev, vdev, idx, mask); +} + +static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserGPIO *gpio) +{ + virtio_delete_queue(gpio->command_vq); + virtio_delete_queue(gpio->interrupt_vq); + g_free(gpio->vhost_dev.vqs); + gpio->vhost_dev.vqs = NULL; + virtio_cleanup(vdev); + vhost_user_cleanup(&gpio->vhost_user); +} + +static int vu_gpio_connect(DeviceState *dev, Error **errp) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); + struct vhost_dev *vhost_dev = &gpio->vhost_dev; + int ret; + + if (gpio->connected) { + return 0; + } + gpio->connected = true; + + vhost_dev_set_config_notifier(vhost_dev, &gpio_ops); + gpio->vhost_user.supports_config = true; + + ret = vhost_dev_init(vhost_dev, &gpio->vhost_user, + VHOST_BACKEND_TYPE_USER, 0, errp); + if (ret < 0) { + return ret; + } + + /* restore vhost state */ + if (virtio_device_started(vdev, vdev->status)) { + vu_gpio_start(vdev); + } + + return 0; +} + +static void vu_gpio_disconnect(DeviceState *dev) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); + + if (!gpio->connected) { + return; + } + gpio->connected = false; + + vu_gpio_stop(vdev); + vhost_dev_cleanup(&gpio->vhost_dev); +} + +static void vu_gpio_event(void *opaque, QEMUChrEvent event) +{ + DeviceState *dev = opaque; + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); + Error *local_err = NULL; + + switch (event) { + case CHR_EVENT_OPENED: + if (vu_gpio_connect(dev, &local_err) < 0) { + qemu_chr_fe_disconnect(&gpio->chardev); + return; + } + break; + case CHR_EVENT_CLOSED: + vu_gpio_disconnect(dev); + break; + case CHR_EVENT_BREAK: + case CHR_EVENT_MUX_IN: + case CHR_EVENT_MUX_OUT: + /* Ignore */ + break; + } +} + +static int vu_gpio_realize_connect(VHostUserGPIO *gpio, Error **errp) +{ + VirtIODevice *vdev = &gpio->parent_obj; + DeviceState *dev = &vdev->parent_obj; + struct vhost_dev *vhost_dev = &gpio->vhost_dev; + int ret; + + ret = qemu_chr_fe_wait_connected(&gpio->chardev, errp); + if (ret < 0) { + return ret; + } + + /* + * vu_gpio_connect() may have already connected (via the event + * callback) in which case it will just report success. + */ + ret = vu_gpio_connect(dev, errp); + if (ret < 0) { + qemu_chr_fe_disconnect(&gpio->chardev); + return ret; + } + g_assert(gpio->connected); + + ret = vhost_dev_get_config(vhost_dev, (uint8_t *)&gpio->config, + sizeof(gpio->config), errp); + + if (ret < 0) { + error_report("vhost-user-gpio: get config failed"); + + qemu_chr_fe_disconnect(&gpio->chardev); + vhost_dev_cleanup(vhost_dev); + return ret; + } + + return 0; +} + +static void vu_gpio_device_realize(DeviceState *dev, Error **errp) +{ + ERRP_GUARD(); + + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserGPIO *gpio = VHOST_USER_GPIO(dev); + int retries, ret; + + if (!gpio->chardev.chr) { + error_setg(errp, "vhost-user-gpio: chardev is mandatory"); + return; + } + + if (!vhost_user_init(&gpio->vhost_user, &gpio->chardev, errp)) { + return; + } + + virtio_init(vdev, VIRTIO_ID_GPIO, sizeof(gpio->config)); + + gpio->vhost_dev.nvqs = 2; + gpio->command_vq = virtio_add_queue(vdev, 256, vu_gpio_handle_output); + gpio->interrupt_vq = virtio_add_queue(vdev, 256, vu_gpio_handle_output); + gpio->vhost_dev.vqs = g_new0(struct vhost_virtqueue, gpio->vhost_dev.nvqs); + + gpio->connected = false; + + qemu_chr_fe_set_handlers(&gpio->chardev, NULL, NULL, vu_gpio_event, NULL, + dev, NULL, true); + + retries = REALIZE_CONNECTION_RETRIES; + g_assert(!*errp); + do { + if (*errp) { + error_prepend(errp, "Reconnecting after error: "); + error_report_err(*errp); + *errp = NULL; + } + ret = vu_gpio_realize_connect(gpio, errp); + } while (ret < 0 && retries--); + + if (ret < 0) { + do_vhost_user_cleanup(vdev, gpio); + } + + return; +} + +static void vu_gpio_device_unrealize(DeviceState *dev) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserGPIO *gpio = VHOST_USER_GPIO(dev); + + vu_gpio_set_status(vdev, 0); + qemu_chr_fe_set_handlers(&gpio->chardev, NULL, NULL, NULL, NULL, NULL, NULL, + false); + vhost_dev_cleanup(&gpio->vhost_dev); + do_vhost_user_cleanup(vdev, gpio); +} + +static const VMStateDescription vu_gpio_vmstate = { + .name = "vhost-user-gpio", + .unmigratable = 1, +}; + +static Property vu_gpio_properties[] = { + DEFINE_PROP_CHR("chardev", VHostUserGPIO, chardev), + DEFINE_PROP_END_OF_LIST(), +}; + +static void vu_gpio_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); + + device_class_set_props(dc, vu_gpio_properties); + dc->vmsd = &vu_gpio_vmstate; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); + vdc->realize = vu_gpio_device_realize; + vdc->unrealize = vu_gpio_device_unrealize; + vdc->get_features = vu_gpio_get_features; + vdc->get_config = vu_gpio_get_config; + vdc->set_status = vu_gpio_set_status; + vdc->guest_notifier_mask = vu_gpio_guest_notifier_mask; +} + +static const TypeInfo vu_gpio_info = { + .name = TYPE_VHOST_USER_GPIO, + .parent = TYPE_VIRTIO_DEVICE, + .instance_size = sizeof(VHostUserGPIO), + .class_init = vu_gpio_class_init, +}; + +static void vu_gpio_register_types(void) +{ + type_register_static(&vu_gpio_info); +} + +type_init(vu_gpio_register_types) diff --git a/MAINTAINERS b/MAINTAINERS index e1530b51a2..66d519fe35 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2098,6 +2098,13 @@ F: hw/virtio/vhost-user-rng-pci.c F: include/hw/virtio/vhost-user-rng.h F: tools/vhost-user-rng/* +vhost-user-gpio +M: Alex Bennée +R: Viresh Kumar +S: Maintained +F: hw/virtio/vhost-user-gpio.c +F: include/hw/virtio/vhost-user-gpio.h + virtio-crypto M: Gonglei S: Supported diff --git a/hw/virtio/Kconfig b/hw/virtio/Kconfig index e9ecae1f50..cbfd8c7173 100644 --- a/hw/virtio/Kconfig +++ b/hw/virtio/Kconfig @@ -80,3 +80,8 @@ config VHOST_USER_FS bool default y depends on VIRTIO && VHOST_USER + +config VHOST_USER_GPIO + bool + default y + depends on VIRTIO && VHOST_USER diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index 7e8877fd64..33c8e71fab 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -29,6 +29,7 @@ virtio_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files('virtio-iommu.c')) virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c')) +virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-user-gpio.c')) virtio_pci_ss = ss.source_set() virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-pci.c')) diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 887ca7afa8..820dadc26c 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -144,3 +144,8 @@ virtio_mem_state_response(uint16_t state) "state=%" PRIu16 virtio_pmem_flush_request(void) "flush request" virtio_pmem_response(void) "flush response" virtio_pmem_flush_done(int type) "fsync return=%d" + +# virtio-gpio.c +virtio_gpio_start(void) "start" +virtio_gpio_stop(void) "stop" +virtio_gpio_set_status(uint8_t status) "0x%x" From patchwork Mon Oct 10 17:29:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 613769 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2128147pvb; Mon, 10 Oct 2022 10:54:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6yY5yDJscLyVwkN6+7gTJMPFv1O+IP/rF7ep9CVT+00T87dbt45NyZayO9quT4SuE5UCO7 X-Received: by 2002:a05:620a:56f:b0:6ed:208f:7d0b with SMTP id p15-20020a05620a056f00b006ed208f7d0bmr3493241qkp.327.1665424498858; Mon, 10 Oct 2022 10:54:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665424498; cv=none; d=google.com; s=arc-20160816; b=xDQSe14OIj/uV7djoyH0K42pQTzBDKVRgyU/EWa5dOo5JmQii0c7iPDNYVxglt0YPm KsACzmDIgPmUJgh8hR9scK5suEFKHU43+7aGJD7P6udwjB1vryxvkFRaWK6DGwhmgNPf 8BAdjhbZTjBWqmLT/XXsy3EIdg9WKx4+dj6+aA37yWxd3uICSQNqRyjxVWMiRC39wlPx pGnB7z7RBZ8jEIvGg9Bx6Z+TC7GZZqJ5+DOVPEjS55J3ZYzg3LGQmuL1hbqcJib5Lu8J HfarITMoWQF6CsthrbTMm9MEPQ43HsvFGICMSNLfNsFo3wavada7tvS1EWjZqgkjEa1F 7PDQ== 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:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=8FzTRqu6X76Q9LWCqleedY0GTIZa238RHANVu9yOyt8=; b=idsfQL9Zo9wnsSo7qCfp5dqv+XVkhBbPqimTO3QeGNzmnYheGgJ9q9OyJOFNBwUQYI hgftbDSY32OenFRyz5ty/nEyuN+YweKbeRr6ZQ8g4o3fjQ8owYNFsYbDsl9wKXuSUJR9 9FlrVSsrM88W50fcWH7q+Kk3pwWgW2qs2S8AqCdPiSjNXAdVIdhQZEraySfgiyRyxLiQ ZZ/B8us81WFV7nsXzqMcuUrz+tl3lzpKkNRgY5Ot5m4j0Xdnp4NGQiXKPj/wS2CVh4cu P1hV9THHqU1BHvdGw+BDlr7fdqUt5wUpLE+hoSeNd91jPxpmf8yJmvi3rI3LExdoDoVa 2WwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Q1ByyL9r; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ay41-20020a05622a22a900b00397ab6a0413si4287096qtb.30.2022.10.10.10.54.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Oct 2022 10:54: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=@redhat.com header.s=mimecast20190719 header.b=Q1ByyL9r; 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=redhat.com Received: from localhost ([::1]:60250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohwzS-0003SK-BM for patch@linaro.org; Mon, 10 Oct 2022 13:54:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwav-0000qy-9E for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:29:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57949) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwan-0006Y2-RH for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:29:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665422969; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8FzTRqu6X76Q9LWCqleedY0GTIZa238RHANVu9yOyt8=; b=Q1ByyL9rTSpWWx+E02x/zruXf4ZiREt2mAdPFJHl1EZEk3+0NVzGLNn5MuDJB8G9N4HWhM ikgl8arNHfmYkumx975AJG2bdDydUp8k6gq6SJQCRggp5tASumhksFVcPbnY3s/2tud8Ay scLKwypOuBZ4/HsuHd7U9/7Sb8Zjij4= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-176-drUkLtInMXCm52P2XPdnTQ-1; Mon, 10 Oct 2022 13:29:27 -0400 X-MC-Unique: drUkLtInMXCm52P2XPdnTQ-1 Received: by mail-wr1-f70.google.com with SMTP id d22-20020adfa356000000b0022e224b21c0so2950599wrb.9 for ; Mon, 10 Oct 2022 10:29:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8FzTRqu6X76Q9LWCqleedY0GTIZa238RHANVu9yOyt8=; b=JE5yWs2/9STMLsKcq953bX3rwEIg+4r723TjDVuGRaBodFsAnWTces3bHE5jsWZvI6 0J578R8/WzoLHCGjGJ6wSXAcvk7DHMez/G8Su5Au5HfrL58quEmi/6WOPZ8xbMVe/wuQ nw1R4JmRsbyfaVyr4lKwUvkgLUlhBBB78vZlxeQScpFXfKg6wCxwqm01vkDJ899jGBen tuHXEgAvMgSnk+CtNe67RQdCijl1264ViekjeXdjsY0N/9x2jVq4VyY2RyEmXaIVdzMv yOSKZhg2PAxVYeRXwyT+xGMyfSZZa+j+ujLVD7Ky9/IPnpLnGzi8XL9Cgo/06UXKttkd hA+w== X-Gm-Message-State: ACrzQf0DPxwq3Oa9Zkdnj9AfTPO9rjbec6Ug/KeWbAP8dZkc9A4L8qAK GMaUnWupH+kF2c7iUp8mQCQjz4BZ5asVXoW0dkEArUxc6HUdh0HSCuSLiB4t+r00hs98tnpn4HP GkKG593CKKxrjLaw2npJfD4Mh/IqlREZZ+foyxX9L1XU7stQ7I4PNeyN77LWG X-Received: by 2002:a5d:64c2:0:b0:22e:41b0:42ca with SMTP id f2-20020a5d64c2000000b0022e41b042camr12556947wri.411.1665422965110; Mon, 10 Oct 2022 10:29:25 -0700 (PDT) X-Received: by 2002:a5d:64c2:0:b0:22e:41b0:42ca with SMTP id f2-20020a5d64c2000000b0022e41b042camr12556929wri.411.1665422964744; Mon, 10 Oct 2022 10:29:24 -0700 (PDT) Received: from redhat.com ([2.55.183.131]) by smtp.gmail.com with ESMTPSA id i18-20020a5d5592000000b0021e51c039c5sm9460696wrv.80.2022.10.10.10.29.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 10:29:24 -0700 (PDT) Date: Mon, 10 Oct 2022 13:29:21 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Viresh Kumar , Alex =?utf-8?q?Benn=C3=A9e?= Subject: [PULL 10/55] hw/virtio: add vhost-user-gpio-pci boilerplate Message-ID: <20221010172813.204597-11-mst@redhat.com> References: <20221010172813.204597-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221010172813.204597-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, 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, T_SPF_TEMPERROR=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 Message-Id: <20220802095010.3330793-14-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-user-gpio-pci.c | 69 +++++++++++++++++++++++++++++++++ MAINTAINERS | 2 +- hw/virtio/meson.build | 1 + 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 hw/virtio/vhost-user-gpio-pci.c diff --git a/hw/virtio/vhost-user-gpio-pci.c b/hw/virtio/vhost-user-gpio-pci.c new file mode 100644 index 0000000000..b3028a24a1 --- /dev/null +++ b/hw/virtio/vhost-user-gpio-pci.c @@ -0,0 +1,69 @@ +/* + * Vhost-user gpio virtio device PCI glue + * + * Copyright (c) 2022 Viresh Kumar + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "hw/qdev-properties.h" +#include "hw/virtio/vhost-user-gpio.h" +#include "hw/virtio/virtio-pci.h" + +struct VHostUserGPIOPCI { + VirtIOPCIProxy parent_obj; + VHostUserGPIO vdev; +}; + +typedef struct VHostUserGPIOPCI VHostUserGPIOPCI; + +#define TYPE_VHOST_USER_GPIO_PCI "vhost-user-gpio-pci-base" + +DECLARE_INSTANCE_CHECKER(VHostUserGPIOPCI, VHOST_USER_GPIO_PCI, + TYPE_VHOST_USER_GPIO_PCI) + +static void vhost_user_gpio_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) +{ + VHostUserGPIOPCI *dev = VHOST_USER_GPIO_PCI(vpci_dev); + DeviceState *vdev = DEVICE(&dev->vdev); + + vpci_dev->nvectors = 1; + qdev_realize(vdev, BUS(&vpci_dev->bus), errp); +} + +static void vhost_user_gpio_pci_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass); + PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass); + k->realize = vhost_user_gpio_pci_realize; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); + pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET; + pcidev_k->device_id = 0; /* Set by virtio-pci based on virtio id */ + pcidev_k->revision = 0x00; + pcidev_k->class_id = PCI_CLASS_COMMUNICATION_OTHER; +} + +static void vhost_user_gpio_pci_instance_init(Object *obj) +{ + VHostUserGPIOPCI *dev = VHOST_USER_GPIO_PCI(obj); + + virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), + TYPE_VHOST_USER_GPIO); +} + +static const VirtioPCIDeviceTypeInfo vhost_user_gpio_pci_info = { + .base_name = TYPE_VHOST_USER_GPIO_PCI, + .non_transitional_name = "vhost-user-gpio-pci", + .instance_size = sizeof(VHostUserGPIOPCI), + .instance_init = vhost_user_gpio_pci_instance_init, + .class_init = vhost_user_gpio_pci_class_init, +}; + +static void vhost_user_gpio_pci_register(void) +{ + virtio_pci_types_register(&vhost_user_gpio_pci_info); +} + +type_init(vhost_user_gpio_pci_register); diff --git a/MAINTAINERS b/MAINTAINERS index 66d519fe35..beccce4a7a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2102,7 +2102,7 @@ vhost-user-gpio M: Alex Bennée R: Viresh Kumar S: Maintained -F: hw/virtio/vhost-user-gpio.c +F: hw/virtio/vhost-user-gpio* F: include/hw/virtio/vhost-user-gpio.h virtio-crypto diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index 33c8e71fab..c14e3db10a 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -30,6 +30,7 @@ virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-user-gpio.c')) +virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_GPIO'], if_true: files('vhost-user-gpio-pci.c')) virtio_pci_ss = ss.source_set() virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-pci.c')) From patchwork Mon Oct 10 17:29:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 613764 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2122917pvb; Mon, 10 Oct 2022 10:45:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM518QMQIwvXtuk2ZZRXquxjIFaZzwy+/i5FzPcDdERv4dzia8RVQ/d5sKtwlkrZJL3jmJr3 X-Received: by 2002:a05:6214:d0d:b0:4b1:996d:c200 with SMTP id 13-20020a0562140d0d00b004b1996dc200mr15430297qvh.9.1665423924655; Mon, 10 Oct 2022 10:45:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665423924; cv=none; d=google.com; s=arc-20160816; b=qLypHpL346e4YMeFGevm6XEs/qRG8j3wy6hBtPkr8uucPceGIOyTRQsehaGKdjKR4O FBrlVtU9+Jv8CKvw4mQ2/vFuQXwdfqvFxVPpJbuQwhTeeyJNzcCv3dlukV1Fus9DcpCE 7CcNX6zlNe8RHMnWQi1MDvSGmmZ6fLLEy9IkdiKt5CnJj4cI9gkIhZEWwbGjDG3C5+3J nybmSe9qZ6rWj6gfZkvg2912oUa2NcNb3elHBvHhF0BSpzluVrYVLikzt6Eds0MVZ2IT sFfxHJZd6Jvkf1RhdPQCFMCi6sUvlgB+OSevQcZfZdzdrsCeYZ8ksepFwr8qBDIF2uwm LX2A== 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:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=2iwODXw0y1ZBoetM/4mM4qd7/Y+WK2plkhEqQ5sfQbQ=; b=xLkxoBG26HMDvV8s0RnWwvbzUoEpjeP6ffw8wnJzsM1dDufRYUF/dN5PPsr6w738pl pT2EggA08ElDdhO2NvlAUl3eay76OUyp+mEUwI3AEdE5hC5uSgNsSZOdFQIAnok8Xqw3 qwa7a1t0Rwh0VOETXkt3MYNDAscl4tj9lofV2wS8KqQi3dTqpRGKTw1IM4LWv9uZuDyc 7C5zya++pXYlQurMOeXcP7to2TP2GuoaJrWtYkw8emRC+mNZoZVF1ldkng0qjXNwWZjF XkYHUhZ1PO13tOaAl2On1uQXeYorBJgkHYbOUwPcFbyGrRS7TIZt/9dWPT07WNf8OsEw pLbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JHCuPQ1d; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t3-20020a0562140c6300b004991ad4f133si5278699qvj.328.2022.10.10.10.45.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Oct 2022 10:45:24 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JHCuPQ1d; 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=redhat.com Received: from localhost ([::1]:55242 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohwqC-0003oQ-69 for patch@linaro.org; Mon, 10 Oct 2022 13:45:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34440) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwax-0000wF-5X for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:29:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45452) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwar-0006Zh-Or for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:29:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665422972; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2iwODXw0y1ZBoetM/4mM4qd7/Y+WK2plkhEqQ5sfQbQ=; b=JHCuPQ1dAmOFeGoh8A7MnH8rzCoOeTSeOM28PZLr9vdFloY5pDllM+Hvp/m7GhPsY6p95p 1yjHr0SyXGoRrDKjpaaG9Acx3n4foO7/rP/GLYIvxZXB7s3vp+wdwMbyRmbWQuQeqEYnzJ LYPAxDSjSWu6DfQTH/XQOM9UPR028F4= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-498-F1Lmhsh5NrmAOjl1jyQD4A-1; Mon, 10 Oct 2022 13:29:31 -0400 X-MC-Unique: F1Lmhsh5NrmAOjl1jyQD4A-1 Received: by mail-wm1-f69.google.com with SMTP id fc12-20020a05600c524c00b003b5054c70d3so7291277wmb.5 for ; Mon, 10 Oct 2022 10:29:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2iwODXw0y1ZBoetM/4mM4qd7/Y+WK2plkhEqQ5sfQbQ=; b=gCRfQmoyEA5hbILX2H7poqZ6PND03ml/6nil9Yy7ou5EBtk+3YZySAbQBfVbltkyOh alyvCBulpkn1/j/jtc5an+i7wvYL7KLm5thy6zylkqzMH4PSsSE6beu4FiSL0Fw38ZCz 2Zh+3rDw4PsR25h0LXa/br0ellq+s2hrgHYt7JFcWUhlPg8TUTy3RomkC9UD6ySAUAwo 0UzGqosvoJ1zYuvqfwhiycRxwT83TLyeAXK559Un/7RsdRP90t8A5bP7DOuHfZxzCD1V 9Ry6I1Ntq51eQhIPE3mUnElT8yuCW2usd0kurqsfpw5U29XQ4tu4HsJvcw44zhtRt29F Pkig== X-Gm-Message-State: ACrzQf0n8dU5a4+hOWl+81yNfi1rWzFEzypblgTO0Aj/IyaBCGwrSfrd 1Fa559hTh6dGfx2C2ERvh4gvPwim9Ead1EvXLYpQJpdDxQhqPNRonJ1vvdQJ3XrKedM36w0liyM RsKRYHJo0EUIxah5TWHCUHALKKhAZlsrB57Gp8rW4kxjUHf64pj8+CosNG2Da X-Received: by 2002:adf:e112:0:b0:21d:7195:3a8d with SMTP id t18-20020adfe112000000b0021d71953a8dmr12813380wrz.371.1665422969920; Mon, 10 Oct 2022 10:29:29 -0700 (PDT) X-Received: by 2002:adf:e112:0:b0:21d:7195:3a8d with SMTP id t18-20020adfe112000000b0021d71953a8dmr12813361wrz.371.1665422969623; Mon, 10 Oct 2022 10:29:29 -0700 (PDT) Received: from redhat.com ([2.55.183.131]) by smtp.gmail.com with ESMTPSA id d4-20020adffbc4000000b00225307f43fbsm7281023wrs.44.2022.10.10.10.29.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 10:29:29 -0700 (PDT) Date: Mon, 10 Oct 2022 13:29:25 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PULL 11/55] tests/qtest: pass stdout/stderr down to subtests Message-ID: <20221010172813.204597-12-mst@redhat.com> References: <20221010172813.204597-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221010172813.204597-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, 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 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: Alex Bennée 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> Message-Id: <20220802095010.3330793-15-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/qos-test.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/qtest/qos-test.c b/tests/qtest/qos-test.c index 831db5cf2a..33cdada380 100644 --- a/tests/qtest/qos-test.c +++ b/tests/qtest/qos-test.c @@ -185,7 +185,9 @@ static void run_one_test(const void *arg) static void subprocess_run_one_test(const void *arg) { const gchar *path = arg; - g_test_trap_subprocess(path, 0, 0); + g_test_trap_subprocess(path, 0, + G_TEST_SUBPROCESS_INHERIT_STDOUT | + G_TEST_SUBPROCESS_INHERIT_STDERR); g_test_trap_assert_passed(); } From patchwork Mon Oct 10 17:29:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 613767 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2127148pvb; Mon, 10 Oct 2022 10:53:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5TGjb4poohr9eS3nHZYTDqdOy/9zVX1YGVA9D19M+0mxYBXf3o+cnlYPG8AkapBlUvFnB9 X-Received: by 2002:ac8:5c54:0:b0:35b:b247:9769 with SMTP id j20-20020ac85c54000000b0035bb2479769mr15584604qtj.443.1665424388290; Mon, 10 Oct 2022 10:53:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665424388; cv=none; d=google.com; s=arc-20160816; b=H0LcUpIwsBk4yMU7Mq6Yy49xfaA17A/s85mbswdcw1O9UmyWU7ipNE4uUPmQtspByi 0ndLXqaiFDglfbrn8dFCgl6LFTgYSPqFcSdGxddxqYhjwxv35066+B4qmc7VICjxniCs tZyRb8xVM3y1f7nDDd6SLYJs4QEBl59qc2BbmLRy/rRMNOjF/v6ZSKYXCG3q5501DtG8 dTQgC7x98obcTouMQwSueyKlaJYJXHTs3bYh0r7kvozk3t61YcoG/DlgVWNUTPOUJ+2w UQVlc2Uj5Ofkmdjs+hkv/CGjxRlD2XuJzL9zznOfk3b0BjMSuMrvuvxMOpxv9L4UNnGp Z1cg== 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:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Rf0XQwc/BmRyvyPNJvIiGLwnDIY+n+JfNAjnoyzxZeU=; b=NDkDKJXL+UVpX7x2nGtT7fq9+BT8g5O+CmzMS3x8rg57hUT/txJtJUwPgdhzqO43Ca aWulOjkDdhZycWQf+LRrKsA0f+wDXhpj7rPMyhMJ/pxvkCK4/sLpSxEgXdkU7SKU+65z /ujlwVB4MT0eyqqdckws862CC7H10NjHypsNpQ49gkQoRLrOWwh0jN0mVI3LlJ17xLX0 Ce9ydFNqrC9iaT53PmaTV1qOooko2YhW0ak81EgOj8STqvcnO6hUls5WrCMq3Eyo9HgP ZNAGDactly9M1jI7uR3CpjQE0idLjtBPJJjo0qCrwugW4hKAp/vTQV4AZFYZ4SvvGvp6 rtYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ufoe2x8l; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id im4-20020a056214246400b00498ff1b0932si2068489qvb.107.2022.10.10.10.53.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Oct 2022 10:53:08 -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=@redhat.com header.s=mimecast20190719 header.b=Ufoe2x8l; 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=redhat.com Received: from localhost ([::1]:44184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohwxf-0001Cd-P4 for patch@linaro.org; Mon, 10 Oct 2022 13:53:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43002) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwb9-0001Vd-2q for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:29:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:30056) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwb3-0006bo-IF for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:29:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665422984; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Rf0XQwc/BmRyvyPNJvIiGLwnDIY+n+JfNAjnoyzxZeU=; b=Ufoe2x8l9U+m/Zez6oPtjf9z8wtRR6B75jej+d/1MTJxKcyt/WU6gEseTkw/A0QceqZ26c 9/EnVGOLHzrjhpeZuYTOm0z6tV2OVU2y/eKC1ewdYtCQM5Z6lnHQmr0dioA7TO0KGCp7ls dnipucej8OcILnNaL1M/zlu6f41R8Zg= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-483-GRlA71w7PhqN71wKPcs7qQ-1; Mon, 10 Oct 2022 13:29:36 -0400 X-MC-Unique: GRlA71w7PhqN71wKPcs7qQ-1 Received: by mail-wm1-f69.google.com with SMTP id ay21-20020a05600c1e1500b003b45fd14b53so5819195wmb.1 for ; Mon, 10 Oct 2022 10:29:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Rf0XQwc/BmRyvyPNJvIiGLwnDIY+n+JfNAjnoyzxZeU=; b=1jMBjw5k3imc9ti9brVgRuqvIelMR9QmUpn/8maInV9IEgw/OPPJb2PNe+emOtC7VG rG8LyR5ttlZvZu9IsFQoFA8U6nJBw+NDlq+8WXAwiXrcEvIucoNWTfO7U1DzCTaXhzxy yigKcBPpF7k8oRmtXjakagl02ka2DcT13I5UFtMmvnHzWhG0wPZEicYt+fyuTWZuGkYD 9E3DJRBe+CuTiWmV3ibxi+HzXXHg62Q/1oG9ZGHrXDqlp5ojFkGu83eDwFabhq+EMqW4 zS4afbZ2IEqte7n4DCk7ABwB87U7ObrvCtTnbDCyBxC8KYWuNaeU1yJ9IEB3W5Ar4t6S 8miQ== X-Gm-Message-State: ACrzQf2rRX36zP9SLUqM04kQCQ/y2fAR/zILrdcoVBI93N8jDLH4JHoX T1Bj6jGiGj5DIAbWjUZPdguMzU6QDQn6k36QeSvIPRMaDQnXQY1MRUdo/IOg2wO6bVbBDo70nAG o138nKOJIKjeA1kX7vpMs83t98FpnbibeT/JRRjcRnzYySRo4szmBwnnyihSU X-Received: by 2002:adf:cf0a:0:b0:22e:3f43:a5f7 with SMTP id o10-20020adfcf0a000000b0022e3f43a5f7mr12321396wrj.634.1665422974565; Mon, 10 Oct 2022 10:29:34 -0700 (PDT) X-Received: by 2002:adf:cf0a:0:b0:22e:3f43:a5f7 with SMTP id o10-20020adfcf0a000000b0022e3f43a5f7mr12321377wrj.634.1665422974255; Mon, 10 Oct 2022 10:29:34 -0700 (PDT) Received: from redhat.com ([2.55.183.131]) by smtp.gmail.com with ESMTPSA id l22-20020a05600c089600b003c43dc42b4dsm7812799wmp.16.2022.10.10.10.29.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 10:29:33 -0700 (PDT) Date: Mon, 10 Oct 2022 13:29:29 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Thomas Huth , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Laurent Vivier , Paolo Bonzini Subject: [PULL 12/55] tests/qtest: add a timeout for subprocess_run_one_test Message-ID: <20221010172813.204597-13-mst@redhat.com> References: <20221010172813.204597-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221010172813.204597-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 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: Alex Bennée 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 Message-Id: <20220802095010.3330793-16-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daudé --- 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 33cdada380..566cb3b00b 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 Mon Oct 10 17:29:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 613771 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2129237pvb; Mon, 10 Oct 2022 10:57:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6HJUxTW/LBVd+QJssimCwFAyaCxsOYvLZOdJeOfgrzPJNlEq/2sqkHuoSvv5cPGgN5H05L X-Received: by 2002:ad4:574c:0:b0:4b1:87b5:c0dd with SMTP id q12-20020ad4574c000000b004b187b5c0ddmr16264499qvx.68.1665424636624; Mon, 10 Oct 2022 10:57:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665424636; cv=none; d=google.com; s=arc-20160816; b=ZWT8qD9kHi97vDf55mURRU+2dOx1p8QJdZcUFvJqhQjVbm1FdyblGku9SCCwZxhX0T c0RxQ9SE6isfQc7UjK6nkqdoYZnO0qtTvGgOgX2w2+oFg1JJjYHFfR9gCUJZpKJOw12q EOjtGfRuORqhAEzzhLsRTfCFY7imy7qJ3uyHmwapupPte1ITLU5DwMNc4bzH2MwzGnM5 PIXsYfBxp1Nyo/XXkW/2LWe7EDiTZwujKcOgJM4+1rg4usaI7R1S6TESeLDlWb4TYiki CdEuwgFYek3e8dl9QKpjTacrDGjGzglfM8zi8wYMlYJ/xfsgF5ntw5rF5AGSOYjH+0vu 6l/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=7npCfBPJ3SU6f/b3cEDN5Cf+Lw7VA1jtIVngNbIXD3s=; b=QjtiJsmyDY9/nb8DgjPW+LGYqYkb0HdasoAe9OwgrRE///pHXQQzrJx3IukVJMQwZO tJeGJMmQoXw04KVtKaIhuNuBUtRl/kyUu1pPz8I/Rz6LsSoi9zVAt0LHPl0ek3Guy/o4 sBA2KO9cSN9FUvof8A3ejMMov2+fcklaI3Zwd+At42MORtTT9YrVVRfr9no5g8xbYaFi MykxRNsbHagjL2lW4dJYH+LnpV1pQzn8AMreHiJ90XU7V+HArBAfXyC+QnIKkHfrgsv4 N5IAxetGQ3/qnWSaPzvkYu1LUcowEbCdJmbiTRqfghukULfjcD6j04beZm/cDMUj4Nsr L68A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DkOFXOGL; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t125-20020ae9df83000000b006e38697f537si5012795qkf.195.2022.10.10.10.57.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Oct 2022 10:57: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=@redhat.com header.s=mimecast20190719 header.b=DkOFXOGL; 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=redhat.com Received: from localhost ([::1]:60958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohx1g-000767-5M for patch@linaro.org; Mon, 10 Oct 2022 13:57:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43008) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwb9-0001Ys-Vo for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:29:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:60138) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwb0-0006b5-Ag for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:29:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665422981; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7npCfBPJ3SU6f/b3cEDN5Cf+Lw7VA1jtIVngNbIXD3s=; b=DkOFXOGLhGjKPS7FJLoVRtnf16aeARBM/W3VTy7opniRB1PYCX4US/Ji+YnvJ4S/O3IXHY YaQMkS8vfCls8jbmF9ZCA29NXX4k0u95zD/ZVwX33WyDxLesoCGIWpDayZusgwtz5GwaPx 89Tjn/BGWGqVMQrGCWYm+icbQxeF5SU= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-471-4TC5cJ_xNJaDYz2lcjLRGA-1; Mon, 10 Oct 2022 13:29:40 -0400 X-MC-Unique: 4TC5cJ_xNJaDYz2lcjLRGA-1 Received: by mail-wm1-f70.google.com with SMTP id f26-20020a7bcc1a000000b003c03db14864so3261411wmh.6 for ; Mon, 10 Oct 2022 10:29:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7npCfBPJ3SU6f/b3cEDN5Cf+Lw7VA1jtIVngNbIXD3s=; b=78Fo7r06OJHlTj/2fLihdFSwYSsDb6/sUWo5mXi+L4zGQr6J2BY6BvaFx+RA3xd3wU nc0ECxTRk6GY4IW5FvTcKgl+BoQvGxS4hnxCMy/D7wVlik8XpGgndjjZIz9ExYde3jZa /EUGMaTPU2i7cKx4ZqY2VMkZDfxJWnrKzvi/e8aoiZQisdVEHhS+K4p6PaOhfmaP0JCl 9serqI6a9zGq4K91DTiqFfjUkv1qDID57eOMFYmuy/weSRiWrL9lA6Lzx2vLI/mvk3Yr 3kGJU6upVJu+5bTqyc/JnYRwnEfFRWVUAdZ7t1NFWTrgUagqKTArZmanec2hwdK5WqeN ykfA== X-Gm-Message-State: ACrzQf1j9Cjim3zhrxj/DYh9gXJHpaX7I9Rck7TU9qkrKRefgzcizCom gilFFXW6Gyy8oNS52KM/5+sfEXVwiKD1zWED97oOwGQ5IQaD1vGLITM47jPkJOTJKkUR+QWamVn 1rAptoQ1A2UyEtlW8o7aSuSqVjYlwhD0RbxjYXLtVmoYAwOiUF5ubxoiiUAss X-Received: by 2002:adf:d1ec:0:b0:22e:3341:a8cb with SMTP id g12-20020adfd1ec000000b0022e3341a8cbmr11952006wrd.151.1665422978932; Mon, 10 Oct 2022 10:29:38 -0700 (PDT) X-Received: by 2002:adf:d1ec:0:b0:22e:3341:a8cb with SMTP id g12-20020adfd1ec000000b0022e3341a8cbmr11951984wrd.151.1665422978556; Mon, 10 Oct 2022 10:29:38 -0700 (PDT) Received: from redhat.com ([2.55.183.131]) by smtp.gmail.com with ESMTPSA id u16-20020adfdd50000000b002238ea5750csm11850269wrm.72.2022.10.10.10.29.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 10:29:38 -0700 (PDT) Date: Mon, 10 Oct 2022 13:29:34 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PULL 13/55] tests/qtest: use qos_printf instead of g_test_message Message-ID: <20221010172813.204597-14-mst@redhat.com> References: <20221010172813.204597-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221010172813.204597-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 autolearn=no 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: Alex Bennée 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 Message-Id: <20220802095010.3330793-17-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- 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 566cb3b00b..5da4091ec3 100644 --- a/tests/qtest/qos-test.c +++ b/tests/qtest/qos-test.c @@ -321,6 +321,11 @@ static void walk_path(QOSGraphNode *orig_path, int len) int main(int argc, char **argv, char** envp) { g_test_init(&argc, &argv, NULL); + + if (g_test_subprocess()) { + qos_printf("qos_test running single test in subprocess\n"); + } + if (g_test_verbose()) { qos_printf("ENVIRONMENT VARIABLES: {\n"); for (char **env = envp; *env != 0; env++) { diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index 84498941a6..99dc6080e5 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 Mon Oct 10 17:29:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 613770 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2128782pvb; Mon, 10 Oct 2022 10:56:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7z/DqCTCB/Im0AuOjkvM44grGJ3YPRXr9zZSgEbiaG0zNOccm8d8Jch7qIZhfWtPK+sUWX X-Received: by 2002:a05:620a:370d:b0:6ec:53fa:1d8f with SMTP id de13-20020a05620a370d00b006ec53fa1d8fmr6399059qkb.481.1665424572931; Mon, 10 Oct 2022 10:56:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665424572; cv=none; d=google.com; s=arc-20160816; b=vpZZeJLwB0jMtTP380wax3M2DiPUurMIOHBnd7qVifn3wL1p4/qlJb1GdONmAyRgbM jItLi7T90LOd1Ccsw52j1ex2hxnPOVeRibilKh/d4JmCA3QbBVjJ0bUT5TXBWWEoEx8A dpsNKLUIP7JVK3bHnZKZJe9NTIMzUXTFSphfEGJSX7dCq46xo41edoM4D2QRnm8joijI NF7wI72fpCBhzN1GS5zZ/18v64u4zIm7wL5eqJCswJ+FvjW1K4yqyz1j/er2htOAHGQJ TQPRO5Khv3tazbwoRK+kBSYMjvkzarmGJU11/KZ4B7TfBshFHOLzFRqAfpxPDljZ796E 5hww== 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:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=2BsOC0ZeJk0TSOpxBXS/s5koTGeCNaE/TuTHTvbRH+I=; b=JpUetsLFozgIVhy+0hltYNsqTf7IOTi5VLIc+xq1TCc8AaB2uwY+76r5KUa+Iw34PN FaWJ+MKaqsAHPXAvoqWLeuWkyXipxB2AXXS1M81kveVHB+9OWT6KRA0JHQ8pPo3u1Wxb 0UkdL8t98VVLbxT/5CMc+6/45wuGG11ttk68BCt2FXnqVRtG61DGBbtSfykSwycbUPG6 Aixk9MLan0k2WmQlVFZa8DmzwNC/G8BAyeRzt215n4NQ4yvHyFaMct7CUvqZ5Tj0V7sY 9ey1xs8UfX58L25A+pSpFT6PAFeYvlL6K42P8UbuE9Xg6x2CvJ+Gs9+4iK0FKhwWzMhc Wbnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RBoqLtek; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id fz22-20020a05622a5a9600b0035ade0f6e22si5639962qtb.273.2022.10.10.10.56.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Oct 2022 10:56:12 -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=@redhat.com header.s=mimecast20190719 header.b=RBoqLtek; 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=redhat.com Received: from localhost ([::1]:53512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohx0d-0004H9-SB for patch@linaro.org; Mon, 10 Oct 2022 13:56:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwbB-0001YP-D8 for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:29:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:43243) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwb4-0006bz-I3 for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:29:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665422985; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2BsOC0ZeJk0TSOpxBXS/s5koTGeCNaE/TuTHTvbRH+I=; b=RBoqLtekE+vW2Xa6u6HL5lcLyRx2+g1pwvIFohNELkGVyjIdhV98tNW+Xb6K0Fst8lmhB2 8qSlPWgKN8vsudD3WtkxM5ISx99ium4JZVoboI8I1vWYOpg65SsGV7/LjT7r0+YJTEI7YY uSUgrdIH+DHctksvYxsxxdGc2/Jdp+M= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-529-d-5MlkNKPNGlJdMkddBxpg-1; Mon, 10 Oct 2022 13:29:44 -0400 X-MC-Unique: d-5MlkNKPNGlJdMkddBxpg-1 Received: by mail-wm1-f69.google.com with SMTP id i5-20020a1c3b05000000b003c47c8569easo4142986wma.1 for ; Mon, 10 Oct 2022 10:29:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2BsOC0ZeJk0TSOpxBXS/s5koTGeCNaE/TuTHTvbRH+I=; b=z7UYo4pF/tx2bCL9Btawbat5R5pwXeKfxlQ4c+MELMkn3031Jt4ye8LIifCOWJIifI NRDDM3oLWKtBW990Nr0ugv/wiXdJLpT+zTCo8xQO2cgiEicfV/DMlr3dF41JdLSU3H4w dobieW6KFi3EI+me5iYIHlD4ttFDOfMPa2hIjIATyAYtSTUVczcs/OwBtuv74bs8NWxf o8xjgdSUzdlC60GUOfUXIwjrY62Tx4d+0+k9dZTNd5onPRr6dh5acnwkjbheI8WkbDZM COVUF8GRDgnn918/Yywd9w4s9y19zf0E+eYVocqXKU4hKK6N49GJunZVPKH/WPgvfHpT R7kQ== X-Gm-Message-State: ACrzQf24mEcNhpTGaJDq6xZ8bRWHS/R4BcoYXrwqMofAbWe1BLjKP8R2 yIbZZqFMyO6a7bJSU4Vf7tKU0oJ+bRA9edS3TI8fogMN1y050i80k2dSQu45geRVRNJpHagTwhA r7B/LtrNElwucZTyEWMNvovXOZhb0vYzek0qBMrLcSscgZfURy/3GJdnlvtii X-Received: by 2002:a05:600c:3c84:b0:3b4:eff4:ab69 with SMTP id bg4-20020a05600c3c8400b003b4eff4ab69mr20440321wmb.104.1665422983140; Mon, 10 Oct 2022 10:29:43 -0700 (PDT) X-Received: by 2002:a05:600c:3c84:b0:3b4:eff4:ab69 with SMTP id bg4-20020a05600c3c8400b003b4eff4ab69mr20440304wmb.104.1665422982851; Mon, 10 Oct 2022 10:29:42 -0700 (PDT) Received: from redhat.com ([2.55.183.131]) by smtp.gmail.com with ESMTPSA id a13-20020adff7cd000000b0022a403954c3sm9368022wrq.42.2022.10.10.10.29.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 10:29:42 -0700 (PDT) Date: Mon, 10 Oct 2022 13:29:38 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PULL 14/55] tests/qtest: catch unhandled vhost-user messages Message-ID: <20221010172813.204597-15-mst@redhat.com> References: <20221010172813.204597-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221010172813.204597-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Alex Bennée 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 Message-Id: <20220802095010.3330793-18-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/vhost-user-test.c | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index 99dc6080e5..8d2d4ba535 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -358,12 +358,44 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) } break; + case VHOST_USER_SET_OWNER: + /* + * We don't need to do anything here, the remote is just + * letting us know it is in charge. Just log it. + */ + qos_printf("set_owner: start of session\n"); + break; + case VHOST_USER_GET_PROTOCOL_FEATURES: if (s->vu_ops->get_protocol_features) { s->vu_ops->get_protocol_features(s, chr, &msg); } break; + case VHOST_USER_SET_PROTOCOL_FEATURES: + /* + * We did set VHOST_USER_F_PROTOCOL_FEATURES so its valid for + * the remote end to send this. There is no handshake reply so + * just log the details for debugging. + */ + qos_printf("set_protocol_features: 0x%"PRIx64 "\n", msg.payload.u64); + break; + + /* + * A real vhost-user backend would actually set the size and + * address of the vrings but we can simply report them. + */ + case VHOST_USER_SET_VRING_NUM: + qos_printf("set_vring_num: %d/%d\n", + msg.payload.state.index, msg.payload.state.num); + break; + case VHOST_USER_SET_VRING_ADDR: + qos_printf("set_vring_addr: 0x%"PRIx64"/0x%"PRIx64"/0x%"PRIx64"\n", + msg.payload.addr.avail_user_addr, + msg.payload.addr.desc_user_addr, + msg.payload.addr.used_user_addr); + break; + case VHOST_USER_GET_VRING_BASE: /* send back vring base to qemu */ msg.flags |= VHOST_USER_REPLY_MASK; @@ -428,7 +460,18 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) qemu_chr_fe_write_all(chr, p, VHOST_USER_HDR_SIZE + msg.size); break; + case VHOST_USER_SET_VRING_ENABLE: + /* + * Another case we ignore as we don't need to respond. With a + * fully functioning vhost-user we would enable/disable the + * vring monitoring. + */ + qos_printf("set_vring(%d)=%s\n", msg.payload.state.index, + msg.payload.state.num ? "enabled" : "disabled"); + break; + default: + qos_printf("vhost-user: un-handled message: %d\n", msg.request); break; } From patchwork Mon Oct 10 17:29:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 613777 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2133944pvb; Mon, 10 Oct 2022 11:05:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7uvnGO8d7aLny7apfwkGI/P4lMVLVc8ke1Fij+eCr9hr+wa7n33tk3JSRaV/81e0b5R429 X-Received: by 2002:a05:620a:2796:b0:6e2:2b21:2397 with SMTP id g22-20020a05620a279600b006e22b212397mr13748237qkp.195.1665425115708; Mon, 10 Oct 2022 11:05:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665425115; cv=none; d=google.com; s=arc-20160816; b=MwMlxWVjgCoCsHPs5Tfyb1ePmcu5PwoZIQlRhxKGjuNP9mvwyqyoUMnweYLqCcrV0U kENHLUlnUw+l+e2jRqMbxO6O5KCq02W9/VZMnlBjfHbuH1SRgo8yU5Rv6gq0PHVGnxK8 BomBLwq+bdP+gZpJOcLcqXhbKTnI+Ku5ipQnczVqQmiL9qyBPQ2usFYq1DxrKqGRxoLA wrPePVNH7u7FFvwmvTKtlmmf32DQ2EpAD6QyhrUN5Jvdtk9XrNRdPdo0YVFAa8quXWDR ppYsix2MMlWJoAeuHlwuRwCgvCoIhUpixXbFf1TVZLqjLKCbNRC+ZXBoS9oROxxkJgMG 6NQQ== 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:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5SkDIYazeL5AgpK2mExrNLbpNnLXzfMlqNa5jH9gxLw=; b=fGe46FB9nIPTR9DI3hhNeeVzmOGEjt9PCK4fnJ1oB4PIDWvdXwGytRmttXGpuoDzHK xum8z/Uogmub4iVHHD+kY2CLeNUW/Goe2W4FiLe8c3qpeDnQY/VeWV8rDTR/pIL9nIV0 13HyptA1knGeTEP/KM+uZdTYPxmTNdmMtWoHGhiW2qYUVsPx0tqahYSoGGUsScUk/0qi hVrptBgG6TTJKNS1qIhZrufHjMyfUl4Pou/S+fa925Joo1c248zlrpqwpq3Ye8QipK9C z1D//LutP85NYNJYgdzdE4gPe8pZlX0C/ukljUtIy9diwJTLV1qc7TGpDCd4x0XlZP5d w15A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DXP+zBqD; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c22-20020ac81116000000b0035d42e1ffc9si5610657qtj.147.2022.10.10.11.05.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Oct 2022 11:05:15 -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=@redhat.com header.s=mimecast20190719 header.b=DXP+zBqD; 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=redhat.com Received: from localhost ([::1]:49186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohx9P-0000Mp-4s for patch@linaro.org; Mon, 10 Oct 2022 14:05:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwbB-0001d6-Vd for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:29:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39207) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwb8-0006d6-Cz for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:29:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665422989; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5SkDIYazeL5AgpK2mExrNLbpNnLXzfMlqNa5jH9gxLw=; b=DXP+zBqDrZxzfOaW/67BqHQC83sgxFka+q1fxg4RO4JhdfYY50lEMcUQDgXkgwbGwGQrL2 x6elStXIXz9vlUcPhc91t2IDIKzmb2jZ4wKwHVyBkwsaxpYNaLZ4Z9eOA//48jRdzgO8Z8 w+F6uhL0/CbLXEXjf1NpmiGedD1mYvo= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-664-6g58VjdFMAWlCA0nVyYKuQ-1; Mon, 10 Oct 2022 13:29:48 -0400 X-MC-Unique: 6g58VjdFMAWlCA0nVyYKuQ-1 Received: by mail-wm1-f70.google.com with SMTP id h129-20020a1c2187000000b003bf635eac31so4254741wmh.4 for ; Mon, 10 Oct 2022 10:29:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5SkDIYazeL5AgpK2mExrNLbpNnLXzfMlqNa5jH9gxLw=; b=heFyOGZNLavZcXTYc8GE167xlG7dzmvlg+DaB9ScDhR6meKJgE75eKRNn16lltVszR JluDy4muYdPskSlPNOWysia7bSnIKS5k1xa2ViIi/mfBB0nG1p509txeZA1+X1LAMCDf Hl39U87KiwwUqRnPbhLHvkqNINnJqGri9do+NQiwGID3fCH70di57CmEvgyMJ/f/XIC8 v10MuqBErJkW+S1tFqbAhNJzgvyukkd3BkkMaQdw6pHOOizXQH0aBgtau+svH+jk2yts e+H7VEOUDPalzoEcM7ZfkQZm4Et7bVtNQ2TuxPG7Ady/FdOuqDIR9FYmNlKUTYjHiZpz Ra7Q== X-Gm-Message-State: ACrzQf0FtfRCcSNVXTp6ZN4FXWl4gSVD597nHsVe67Aqf9H96YqZkeNv tR01nVpv4ZThzu64auGw3YnCbDqNKHOxYuX5Pr2t/C12pGrw2PWAyl5JJRQ0UIdW4uV7hrCzgct cT+gUo4MLqHhyCIQuQbXe/os0TFdgfz2xghj0i1i9mAKUOjS6moLd/cIciSFy X-Received: by 2002:a05:6000:1683:b0:230:d0b5:72c9 with SMTP id y3-20020a056000168300b00230d0b572c9mr2857810wrd.336.1665422987492; Mon, 10 Oct 2022 10:29:47 -0700 (PDT) X-Received: by 2002:a05:6000:1683:b0:230:d0b5:72c9 with SMTP id y3-20020a056000168300b00230d0b572c9mr2857794wrd.336.1665422987253; Mon, 10 Oct 2022 10:29:47 -0700 (PDT) Received: from redhat.com ([2.55.183.131]) by smtp.gmail.com with ESMTPSA id l9-20020adfe589000000b0022e6178bd84sm9313795wrm.8.2022.10.10.10.29.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 10:29:46 -0700 (PDT) Date: Mon, 10 Oct 2022 13:29:43 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PULL 15/55] tests/qtest: plain g_assert for VHOST_USER_F_PROTOCOL_FEATURES Message-ID: <20221010172813.204597-16-mst@redhat.com> References: <20221010172813.204597-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221010172813.204597-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, 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 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: Alex Bennée 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 Message-Id: <20220802095010.3330793-19-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- 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 8d2d4ba535..a99f55ed84 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -985,8 +985,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 Mon Oct 10 17:29:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 613772 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2129724pvb; Mon, 10 Oct 2022 10:58:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4pHsVaONl8Wpy6x5FZqn7JlwW/PplB2kV9lxKK4z2BcPt8nzA5sBtX3I/31VRYAoN4LAEA X-Received: by 2002:ac8:7e94:0:b0:38e:2bea:9dd9 with SMTP id w20-20020ac87e94000000b0038e2bea9dd9mr15999669qtj.67.1665424695143; Mon, 10 Oct 2022 10:58:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665424695; cv=none; d=google.com; s=arc-20160816; b=Ahr3ymkzjV0mCXpPHzjV0H6DhkEY9SArPZ0pVX79U8FQanxoz8lOUu3AQ62biAEbqz sVRLK6aJKIyjPGK655yitVBBNtf6Pbg/r7T0qgLSEsvPTbILp+IwNxkwTkHcoDc9lZud QM1KLObYJuPINiluTzZHb5X4u1Jf4CsXopi6HrAQklT7jo1IfgoS4ksbQ3n5S44JKCQV T4vl8IvrrHgYpLaxxeKfkRe9Ck3sE6HhNhvEJ7nzCG2s+ljBIhkAloOaf8agtSIYN0yI /amj9sOH5q8Luava5bzp1jeI6iTVe84UQiV1rzjm2uhS8pCkOu+xBAxSuEwoUe6X1HOp 85Og== 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:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=yJ+3Ym4q6e4cRDvqrMY+ao2NcRPn7bSMxNJxA/MOCSY=; b=F3DThlJX0wrj7BUc5AveD7Bm8kZvZfmlpg5N1QLYzVp2Z7AUN/JHg4aVgEveiax+f1 M8JWr5GXuY+PXLNMQGGrsv1KHE39eIdEm1VbQ+Wke17oDygbe8EI4vI3z4DQfGT2JYeZ ihSl+cjMYywGstrGGygbdKhXh/ZykOZRM3CObomV/O9PXa8HXMPMr3U7Dv2xTAuxeSvm tYsR9CLEocGKJ1jL0OFMuFrl+lJSKPNo+3AoMIWtbNV6JgL8QXlxqLhIIX/Vj42B9tS3 pK4lgR1fEBQeGrsqV/Wx3b5xgqfNUQUjLt6fFhBnKHwVszeOOS/k9KI8+qWov8bmvE32 l4OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Mf7wFhSD; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ee7-20020a05620a800700b006e7808fc3casi6002660qkb.308.2022.10.10.10.58.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Oct 2022 10:58:15 -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=@redhat.com header.s=mimecast20190719 header.b=Mf7wFhSD; 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=redhat.com Received: from localhost ([::1]:33172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohx2c-0000s2-MB for patch@linaro.org; Mon, 10 Oct 2022 13:58:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46174) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwbK-0001vX-9o for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:30:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39934) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwbC-0006e2-P6 for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:30:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665422994; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yJ+3Ym4q6e4cRDvqrMY+ao2NcRPn7bSMxNJxA/MOCSY=; b=Mf7wFhSDT2Igw+5L7HjUxurjSM3FPGMSeSHelj7OUh0T6TkioGHhp34ySg82VOQEFuJtii Amo6SDPNSXxyC4CIor4sSsmJu/iZZc2mgoNH9r2uvlNOkqk9rD6cEZxCgDdi1mpcz1D6+e KXsGX66Ay010pgm6M4iWWaUejM7QPyw= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-114-fvOY0u2zOPGu41F1xT9XSg-1; Mon, 10 Oct 2022 13:29:53 -0400 X-MC-Unique: fvOY0u2zOPGu41F1xT9XSg-1 Received: by mail-wm1-f69.google.com with SMTP id v23-20020a1cf717000000b003bff630f31aso3259018wmh.5 for ; Mon, 10 Oct 2022 10:29:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yJ+3Ym4q6e4cRDvqrMY+ao2NcRPn7bSMxNJxA/MOCSY=; b=YMiKikjqgIT8/Z6uETKvl/DXUg04ggmWqYPqLBUlYG5IF9gc7Au93zvYEMUjMt3ZfO /4n30cUgsTQLD5RX36q0nbZH1FhF/p0XaAE0aT4mj8AUbAXOJg1jXWRZhVxaAm28DfoT wkDwrsywmi8Jyc3GNGMcKJUWdU1PrqxiKSU7Xxhc9rMmRstrcUjgnndLQJOTn4lxRe6x Fk0sErzufCOR2eZuX1/wfNtBZB4EuisAXxwbW3DTnRRvIAV7ealo6H9oXprmuofvVqQc TY2teRwlhIDU5w3YuZbWUhmcDuJaiGdIM2XEkFYzP7/hIEuSso9McjyQJ4P05rXSsyQH vZtg== X-Gm-Message-State: ACrzQf2om6G7CSxTkXhaWrBlalKZTPRXyScFP7GDPN2AKI8MHAjB/6gR /phwJSODLXw7mPUpqhxjyo2RiGK+HbxGzF0JKYhHugujkCpDIEC787Zfn+acduwOkI1Mn6Wo4PM gq3iNu0jzyrSV1KTvfQsDSbHxEEIiJ5R0TNnog95aFFx3NO2zdT65J2smDToq X-Received: by 2002:a7b:cc0c:0:b0:3c5:a58f:afbc with SMTP id f12-20020a7bcc0c000000b003c5a58fafbcmr6586031wmh.169.1665422991706; Mon, 10 Oct 2022 10:29:51 -0700 (PDT) X-Received: by 2002:a7b:cc0c:0:b0:3c5:a58f:afbc with SMTP id f12-20020a7bcc0c000000b003c5a58fafbcmr6586012wmh.169.1665422991374; Mon, 10 Oct 2022 10:29:51 -0700 (PDT) Received: from redhat.com ([2.55.183.131]) by smtp.gmail.com with ESMTPSA id k20-20020a05600c1c9400b003c131c5a997sm11680579wms.7.2022.10.10.10.29.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 10:29:50 -0700 (PDT) Date: Mon, 10 Oct 2022 13:29:47 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PULL 16/55] tests/qtest: add assert to catch bad features Message-ID: <20221010172813.204597-17-mst@redhat.com> References: <20221010172813.204597-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221010172813.204597-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, 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_PASS=-0.001, T_SPF_HELO_TEMPERROR=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: Alex Bennée 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 Message-Id: <20220802095010.3330793-20-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- 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 Mon Oct 10 17:29:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 613775 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2131720pvb; Mon, 10 Oct 2022 11:01:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6sT1rvih7FNQxGqN2V1IYGhUG4O7qk0H9MabCvtmlJesDvLj7c1OaEM5ktFE8rneoNKkv4 X-Received: by 2002:a05:620a:28d2:b0:6ec:558e:e63a with SMTP id l18-20020a05620a28d200b006ec558ee63amr5817859qkp.722.1665424900030; Mon, 10 Oct 2022 11:01:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665424900; cv=none; d=google.com; s=arc-20160816; b=SNlxJpon8cWD60pJ1A0bIVjxcS9pDg0+WjaptT+tSVPGebEeHOjFFhd+2FP0kP+HEQ SGP72LuU+duJr01sKV3OO/P89w/wB9tkwPTZUVZ5QcUGczk10TxEQwTM3z9jsKYVyg9t qycCirUVuzbEOYBgGbd6sp9cxl5RdcwSFizcE67Ao5kfsUTkObUIBrAq0Y7z6KmBmnDQ jM9FdOhYYFPmuDhdBXzxLBa7d4goAPgSvLP8bMXaCbpG66+qEU4C6dZlcV2WrEqkAm8K JDBgpLBt1Vx63l33gjba651pmOMaT5eNKfNOzMYk+IPXqzfoGVInXKdTWekmftLsXMEG DmvA== 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:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=jmsSQG3tgR/SeJWv4vUdgBQ5eNjunHANNe2NjKH/GKc=; b=I/zBYWf+1YTmFTn6pAmnVb1J1OM3eKuJvkCSyjwjyQO/xggMPqkPTe7Ez124E5BDWT DWIH3ixULYedTGB+JEVKRwhbY/UfKKitudGS8+0shuZQYm4GHaS0xJiODlN9sbT+85ey 7Oh0xdmSrYyNQLDZ9TE4NXO29mF+DMkuCBYwcmt04BDri1vOArbm/xCtsoUW6nWeeATx jMaH8KU2gwU+ngd6nSOGzbQwy06uW6iaZbTnUohEsyxvMjouWIIxpWJ7wa03gFQ+0Xru r1LDO+Sw8lPznFRkiQwJfF6QrC0b69sIu02+Ffbdbrb6VzhMOW79kq9+rgjJyKn95LAV f6WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bv1zbCC1; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id fn3-20020ad45d63000000b00499146ea37fsi5848460qvb.62.2022.10.10.11.01.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Oct 2022 11:01:40 -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=@redhat.com header.s=mimecast20190719 header.b=bv1zbCC1; 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=redhat.com Received: from localhost ([::1]:60294 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohx5v-0004Se-IB for patch@linaro.org; Mon, 10 Oct 2022 14:01:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwbM-000218-Al for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:30:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:51519) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwbH-0006fp-NN for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:30:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665422999; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jmsSQG3tgR/SeJWv4vUdgBQ5eNjunHANNe2NjKH/GKc=; b=bv1zbCC1joPeY513Fli5YVjjtN0Fw/dkyjardc8OD7yJVMtBYIH3FTIAvIIINGtNFKoAS2 kBN5lnw4TU+WwwvvJwUigNQBVpUxRYTrDuU61cRKFlB3xzUg+jnyTS3CdO6aG2lhvwIq0C xPIwjukd5zoMWq3FydVdpqWRpFSfdao= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-477-y8tcy04lOGeE4Za_ITBT0g-1; Mon, 10 Oct 2022 13:29:58 -0400 X-MC-Unique: y8tcy04lOGeE4Za_ITBT0g-1 Received: by mail-wm1-f72.google.com with SMTP id i5-20020a1c3b05000000b003c47c8569easo4143228wma.1 for ; Mon, 10 Oct 2022 10:29:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jmsSQG3tgR/SeJWv4vUdgBQ5eNjunHANNe2NjKH/GKc=; b=mloUVSgYFjf5iQwjKwyoioSXvaRyqVktEV5hIcH0vL3a4ODHl58KdDBrv/DhW3SqQL ZCLQti70M2KbpDyOxFxjFqyFpoLf2fesgbNMJf8Rjf0gc9y8QpFRsXO3R5gqUFjNJbRT gicpQN4Rl05BfYWznu6wB6+aJ7mdZFrGnDy0sKaFb5KOITJRaEnrTwu7d47Nq4h6IeNK 7etyeEGQ2uI0/9Kpejomg1BBsrLQr60SV6BQ+YsJW8W8N3hwLFgIifWKAY44gLlH/HcO OtZWdMDsLZyv8MVhWh47mt0eXA9FYinnamY2WT+4yE3b9Lynx+ainYguDKhHfpuAf9iK +sTg== X-Gm-Message-State: ACrzQf23O+1j6Or5x0FEY1oxyzdlOfiW/bEQO+XyjOA8dOx9jB3hWqpg /m087sYUG5CNYKNOad4Ix5ti3f8zeGhDfIvRwtIfNHNvA7I9LnKoIv93QDKqvSPFiGuPY5iRkcX 1ivuxs0WmtIJHzV1jpzlfsnMS/4/ZqnS3V6bZ3t2f/aFZB3EQ85gGnJkM+JmM X-Received: by 2002:a05:600c:a09:b0:3b5:2f6b:c7c5 with SMTP id z9-20020a05600c0a0900b003b52f6bc7c5mr13385641wmp.141.1665422996017; Mon, 10 Oct 2022 10:29:56 -0700 (PDT) X-Received: by 2002:a05:600c:a09:b0:3b5:2f6b:c7c5 with SMTP id z9-20020a05600c0a0900b003b52f6bc7c5mr13385616wmp.141.1665422995721; Mon, 10 Oct 2022 10:29:55 -0700 (PDT) Received: from redhat.com ([2.55.183.131]) by smtp.gmail.com with ESMTPSA id u19-20020a05600c19d300b003bf6da9d2cesm15887970wmq.28.2022.10.10.10.29.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 10:29:55 -0700 (PDT) Date: Mon, 10 Oct 2022 13:29:51 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PULL 17/55] tests/qtest: implement stub for VHOST_USER_GET_CONFIG Message-ID: <20221010172813.204597-18-mst@redhat.com> References: <20221010172813.204597-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221010172813.204597-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 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: Alex Bennée 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 Message-Id: <20220802095010.3330793-21-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- 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 a99f55ed84..3052386634 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 Mon Oct 10 17:29:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 613774 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2130245pvb; Mon, 10 Oct 2022 10:59:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4kdFOGAH7JyxRzRseUCykVdoZddpVr/dlhcSBVtxNEYjrpRaJT5px8JjVzXCWcutEolXZ6 X-Received: by 2002:a05:622a:1344:b0:395:4278:e9be with SMTP id w4-20020a05622a134400b003954278e9bemr15484631qtk.51.1665424750479; Mon, 10 Oct 2022 10:59:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665424750; cv=none; d=google.com; s=arc-20160816; b=PrXHnoAh2bZnr2a4oKh+m3TJG9l7IyhQzePeSE0WQE9LsxBMd90gHhS2Y+s9uO+kYz XFspEDBWDjzPJsPMLCise+4wNbv1Dl3JMwXzvGE/Sgk2SbN/w6bL2CFJMTkyXabudQOZ 0lDkNzZoeHn9+Baa8h6F8BhDR3VRDGw1eXW9bktsx+W3MZZug/eWbEI2fVz+UgdMUq/x KyWU5HwzCRrsJo8Lg5scGnwDvJbpE/UFKPgL2gNrPlBxEYxmClxnEttS7sOAivWbIBnL zNyQ74FHRawADvO+aWPJ0Hg/fAVf9K2payqXksnkA9i6D0A4C31L72tP5fie5DsGUXux ChFw== 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:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=wr3TVnZ7tk/u0Lm4bIhIKs4gYKeGgKd9uCvxQFfv5EM=; b=lB4Fl/6fbhq4cCUZpCJck51gkc2GFj794nHsHLaIjxpGnKWHl51/uVfm9dGj3SRAfG FRrHPFUtzqu/le1K/XAb9neTSAp3Ni+SZeikR+3PdmIOOhN9CQCnZcnMHpbxwk2yEchM RvR5nyq1lzVc8n8YbfAW8WP6/MRH1xkXTJgNzTTYwGqmRumA06zIN4O0vyXXTCRGIDhW Qxbj5UoqQnbWrf7mZ9qHKvuED+LN6HlnaHl6vCFuPbreF6TNF1b6LqlXR1ZRiyvnVV6P 06MtEter2lk7gIDnJhperyw3xZXgvb7+oFCEhWf1dRbq0ZN8x+3An2773ityJ4Kis6HR UNPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=d9WXmRBd; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m6-20020a05622a118600b0031ee8fa5b22si6623129qtk.542.2022.10.10.10.59.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Oct 2022 10:59:10 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=d9WXmRBd; 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=redhat.com Received: from localhost ([::1]:44538 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohx3V-0001lR-Oe for patch@linaro.org; Mon, 10 Oct 2022 13:59:09 -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 1ohwbQ-00027Z-Qe for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:30:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:39240) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwbM-0006ji-9N for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:30:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665423003; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wr3TVnZ7tk/u0Lm4bIhIKs4gYKeGgKd9uCvxQFfv5EM=; b=d9WXmRBdycEvi3VLKKaSkBZ5t9wr4wLBvEfZxjodT6O/D/RJ4p7/BaZzX2t97j2GsulZBZ C6oW8l2gpuP8KvimNYuHgUok2VHe2CLkWu8Y6sc/ijJPSJoGGiH0ViK8DXyT+T4edCeFwD +UmB/b0GdJUgt/YpOMCnwFkBCseGWRw= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-221-nPJt9wF4Oom_ktKMfcPCNw-1; Mon, 10 Oct 2022 13:30:02 -0400 X-MC-Unique: nPJt9wF4Oom_ktKMfcPCNw-1 Received: by mail-wm1-f71.google.com with SMTP id i5-20020a1c3b05000000b003c47c8569easo4143320wma.1 for ; Mon, 10 Oct 2022 10:30:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wr3TVnZ7tk/u0Lm4bIhIKs4gYKeGgKd9uCvxQFfv5EM=; b=62wHyI6kgeR2fOAznaYNAcp+Sms7dUZQw0REfQlKlX+gGPb4nXtHbWzc6Zp1mUWkQB WT/CXvxSWI7MtoD6q7lZAi3q/kuxkEsNUa0e42sPa8selVt6VsY+SoZCyvEyt4AtDhUe Tw1hoEbK0ivbS45gPdp2r0KH+BeiiswYdUO2BxV3SFxNmocUZ0dyLMTOyzVLxCslssNK LMb/nUqKhqB4TiD7uOS0OmksMeL0hXOrilgzJWqgrdRbRbVMeQstQLfv0pF61MaqIdQJ MDMfdgB+IRVnR5pSHTGmagpYCfuzCeWAxppfYiUba2XUCYm0H5guW6I4o3FIU/dEafY4 khrw== X-Gm-Message-State: ACrzQf26ijHEX64YmDZyR8JHVEAFUaBuEj1YaxbRbG31ajY5UJKTV1cR ygNQ4b0w9Vpv/sGnRF8XVJu/llHnSXiXsGrtjCXTIlGR4vtJ2G/LxMBgtzt58/hy14SlRWufyhM nh2rRvAIjryO2VQx299i3pjsyQ3ZVUydZrifuXlUWtTRMuC+ZjOcr+WtKc0vD X-Received: by 2002:a05:600c:3c84:b0:3b4:eff4:ab69 with SMTP id bg4-20020a05600c3c8400b003b4eff4ab69mr20441174wmb.104.1665423000747; Mon, 10 Oct 2022 10:30:00 -0700 (PDT) X-Received: by 2002:a05:600c:3c84:b0:3b4:eff4:ab69 with SMTP id bg4-20020a05600c3c8400b003b4eff4ab69mr20441153wmb.104.1665423000431; Mon, 10 Oct 2022 10:30:00 -0700 (PDT) Received: from redhat.com ([2.55.183.131]) by smtp.gmail.com with ESMTPSA id y8-20020a5d6208000000b0022c96d3b6f2sm11926483wru.54.2022.10.10.10.29.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 10:30:00 -0700 (PDT) Date: Mon, 10 Oct 2022 13:29:56 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PULL 18/55] tests/qtest: add a get_features op to vhost-user-test Message-ID: <20221010172813.204597-19-mst@redhat.com> References: <20221010172813.204597-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221010172813.204597-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 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: Alex Bennée 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 Message-Id: <20220802095010.3330793-22-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- 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 3052386634..4f4fcc09f5 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: @@ -995,8 +998,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) { @@ -1025,6 +1041,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 Mon Oct 10 17:30:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 613776 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2132835pvb; Mon, 10 Oct 2022 11:03:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7dqgWLazak41AlnB89Vlf8CGTXoQMv6HlUXB1xvgt8BHMVRtAXpyqz/3PMxs+YRxWD0VxR X-Received: by 2002:a05:620a:448e:b0:6ce:8dd2:bc46 with SMTP id x14-20020a05620a448e00b006ce8dd2bc46mr14038292qkp.705.1665425000018; Mon, 10 Oct 2022 11:03:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665425000; cv=none; d=google.com; s=arc-20160816; b=zYy6FU5tta05QoR0Oxz5bIVxDE1JAv60V+BeyWdPqIMClfZlghUtv7Q6t/eeyDrVOv CQWTjlKRx7cHr6AlkrDMpu98uSnBXr9uHLwXoRDfwZznUrtyrX89F9lyMLHxcd15OeGW NxAnbYIvka+76pzOXzH8bNoKfSFTSBIgEiBAsC1sH8vzBImSh/AXa+oxeceVJjxkgbP4 ehxv2FrqtDBFpuUaZmeGOzurcN9fH8C5foVPSqfPRG8DmC11PRMXRZcxAYHAzbslbqsy qz1ZjdEUSHNHd5tpi43Rk6FqRAgtfc9wc/hUPCcNIdgs0FcDyNRJp6XjYiRgh6B+bm0u XzAA== 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:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=pXh/xwoTWbI+N3CES2T4w4Es2zHnFfvO5ql2hJM0dgE=; b=WnLdgFSLAaXHjZANfAm8ihR9r398ooqgp4+e6+2SJroF0ZybQrTK/Mb2+sjWFyVg8b VIMJgGLMbKGNihn+RxZCFhtwnnMop6i9MM/wD7ioDCXpRjBDicC3EjM8uqxD4mwoSWqt ejebfppitAwhdeMGZgxBFced8G56UtMRnP9/i38B/iPEsGMNT0gwm6cFvdtXcLasH6jC 0d/8PH6qJNkcACRN4dPd124dDKRoVHgDQ6EgzpcZ71riX6oM9ripiLJoc1TeqXMbrTzt 109GydKQu66BMalrKPLk/+DOfItMDjKIW4xIIZZPD6PVn1RMZSyBh3KOXYR73qzkAEne 2CzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="f/JmTzjR"; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bm25-20020a05620a199900b006ec53a50b26si4037732qkb.22.2022.10.10.11.03.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Oct 2022 11:03:20 -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=@redhat.com header.s=mimecast20190719 header.b="f/JmTzjR"; 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=redhat.com Received: from localhost ([::1]:44454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohx7X-0006fv-E8 for patch@linaro.org; Mon, 10 Oct 2022 14:03:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49024) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwbU-00029Y-Bd for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:30:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:52059) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwbQ-0006uJ-Rr for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:30:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665423008; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pXh/xwoTWbI+N3CES2T4w4Es2zHnFfvO5ql2hJM0dgE=; b=f/JmTzjR/DpohPhrod06dlikNKDg5jyNF+PPUG3AqdbKSfjzqU34m3CKfAJpiPzzIcLKL9 nAwxMY1tTVRugMTkqqyZ1Tch8JF0IkvqDM3IypLufIqYdBgYk1yjHL/yn+XbRapZUTxtnq y+WiJspSo9DNBYAK9xs5z7iz3V7M68E= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-556-drVHpmOWNtaVZR-LKcIgDQ-1; Mon, 10 Oct 2022 13:30:07 -0400 X-MC-Unique: drVHpmOWNtaVZR-LKcIgDQ-1 Received: by mail-wr1-f72.google.com with SMTP id e14-20020adf9bce000000b0022d18139c79so2947385wrc.5 for ; Mon, 10 Oct 2022 10:30:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pXh/xwoTWbI+N3CES2T4w4Es2zHnFfvO5ql2hJM0dgE=; b=sH5auG0DaWP3SRNCWHdSQVUdiKSJEAMypNVhedZCYehhhHeC4SWt5ZzyPcdARSpAfB HGitLEVEESyMyF8Ptq2QBIXOoyflB/ulgpG8i2kwMt7HK8w4jlKd4G+2hRy5+Ig76uG0 7wS+3UEuubgMMLVKd9ACqeULQTewx+5X9YRx8MGFuM6IQvSIr6LF7+fSWp/nfWP5XWA9 6IO3AFR/HJu0nlnkyHuCHhFW1Z58GZ9LXaeVOOeWe2ADIp09ev9Ddyl/ByKoEtjXqM5e 1pa39S38qDGA2iG9LUqqr1Rit9KPkLcAU+TSC+g0c6LJAvpgNgUZoNvIxW7LExjCfmu+ 5I4A== X-Gm-Message-State: ACrzQf2wWoY6mSTqZUE+EMnUdCFCnoDp2/egLm7z7GC7oiWDQw7jG4Ts CAbqTI9PnEL9Qlyb3WVFwp+BalpKdGucwShutPduKe9qMvPKAAQzWunO5LnMsPj0aQZu/POSuod JTCMrAjTa2VKlT3ceAIbvBgxd3XDtFB2H8U9fhjvJh+EqtbBsXgGpwNHDyT0d X-Received: by 2002:adf:d842:0:b0:22e:33e2:f379 with SMTP id k2-20020adfd842000000b0022e33e2f379mr12162830wrl.23.1665423005370; Mon, 10 Oct 2022 10:30:05 -0700 (PDT) X-Received: by 2002:adf:d842:0:b0:22e:33e2:f379 with SMTP id k2-20020adfd842000000b0022e33e2f379mr12162804wrl.23.1665423005058; Mon, 10 Oct 2022 10:30:05 -0700 (PDT) Received: from redhat.com ([2.55.183.131]) by smtp.gmail.com with ESMTPSA id c8-20020a05600c0a4800b003b4fdbb6319sm18489197wmq.21.2022.10.10.10.30.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 10:30:04 -0700 (PDT) Date: Mon, 10 Oct 2022 13:30:00 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Viresh Kumar , Paolo Bonzini , Eric Auger , Thomas Huth , Laurent Vivier Subject: [PULL 19/55] tests/qtest: enable tests for virtio-gpio Message-ID: <20221010172813.204597-20-mst@redhat.com> References: <20221010172813.204597-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221010172813.204597-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, 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 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: Alex Bennée 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> Message-Id: <20220802095010.3330793-23-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/libqos/virtio-gpio.h | 35 +++++++ tests/qtest/libqos/virtio-gpio.c | 171 +++++++++++++++++++++++++++++++ tests/qtest/libqos/virtio.c | 2 +- tests/qtest/vhost-user-test.c | 66 ++++++++++++ MAINTAINERS | 1 + tests/qtest/libqos/meson.build | 1 + 6 files changed, 275 insertions(+), 1 deletion(-) create mode 100644 tests/qtest/libqos/virtio-gpio.h create mode 100644 tests/qtest/libqos/virtio-gpio.c diff --git a/tests/qtest/libqos/virtio-gpio.h b/tests/qtest/libqos/virtio-gpio.h new file mode 100644 index 0000000000..f11d41bd19 --- /dev/null +++ b/tests/qtest/libqos/virtio-gpio.h @@ -0,0 +1,35 @@ +/* + * virtio-gpio structures + * + * Copyright (c) 2022 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef TESTS_LIBQOS_VIRTIO_GPIO_H +#define TESTS_LIBQOS_VIRTIO_GPIO_H + +#include "qgraph.h" +#include "virtio.h" +#include "virtio-pci.h" + +typedef struct QVhostUserGPIO QVhostUserGPIO; +typedef struct QVhostUserGPIOPCI QVhostUserGPIOPCI; +typedef struct QVhostUserGPIODevice QVhostUserGPIODevice; + +struct QVhostUserGPIO { + QVirtioDevice *vdev; + QVirtQueue **queues; +}; + +struct QVhostUserGPIOPCI { + QVirtioPCIDevice pci_vdev; + QVhostUserGPIO gpio; +}; + +struct QVhostUserGPIODevice { + QOSGraphObject obj; + QVhostUserGPIO gpio; +}; + +#endif diff --git a/tests/qtest/libqos/virtio-gpio.c b/tests/qtest/libqos/virtio-gpio.c new file mode 100644 index 0000000000..762aa6695b --- /dev/null +++ b/tests/qtest/libqos/virtio-gpio.c @@ -0,0 +1,171 @@ +/* + * virtio-gpio nodes for testing + * + * Copyright (c) 2022 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "standard-headers/linux/virtio_config.h" +#include "../libqtest.h" +#include "qemu/module.h" +#include "qgraph.h" +#include "virtio-gpio.h" + +static QGuestAllocator *alloc; + +static void virtio_gpio_cleanup(QVhostUserGPIO *gpio) +{ + QVirtioDevice *vdev = gpio->vdev; + int i; + + for (i = 0; i < 2; i++) { + qvirtqueue_cleanup(vdev->bus, gpio->queues[i], alloc); + } + g_free(gpio->queues); +} + +/* + * This handles the VirtIO setup from the point of view of the driver + * frontend and therefor doesn't present any vhost specific features + * and in fact masks of the re-used bit. + */ +static void virtio_gpio_setup(QVhostUserGPIO *gpio) +{ + QVirtioDevice *vdev = gpio->vdev; + uint64_t features; + int i; + + features = qvirtio_get_features(vdev); + features &= ~QVIRTIO_F_BAD_FEATURE; + qvirtio_set_features(vdev, features); + + gpio->queues = g_new(QVirtQueue *, 2); + for (i = 0; i < 2; i++) { + gpio->queues[i] = qvirtqueue_setup(vdev, alloc, i); + } + qvirtio_set_driver_ok(vdev); +} + +static void *qvirtio_gpio_get_driver(QVhostUserGPIO *v_gpio, + const char *interface) +{ + if (!g_strcmp0(interface, "vhost-user-gpio")) { + return v_gpio; + } + if (!g_strcmp0(interface, "virtio")) { + return v_gpio->vdev; + } + + g_assert_not_reached(); +} + +static void *qvirtio_gpio_device_get_driver(void *object, + const char *interface) +{ + QVhostUserGPIODevice *v_gpio = object; + return qvirtio_gpio_get_driver(&v_gpio->gpio, interface); +} + +/* virtio-gpio (mmio) */ +static void qvirtio_gpio_device_destructor(QOSGraphObject *obj) +{ + QVhostUserGPIODevice *gpio_dev = (QVhostUserGPIODevice *) obj; + virtio_gpio_cleanup(&gpio_dev->gpio); +} + +static void qvirtio_gpio_device_start_hw(QOSGraphObject *obj) +{ + QVhostUserGPIODevice *gpio_dev = (QVhostUserGPIODevice *) obj; + virtio_gpio_setup(&gpio_dev->gpio); +} + +static void *virtio_gpio_device_create(void *virtio_dev, + QGuestAllocator *t_alloc, + void *addr) +{ + QVhostUserGPIODevice *virtio_device = g_new0(QVhostUserGPIODevice, 1); + QVhostUserGPIO *interface = &virtio_device->gpio; + + interface->vdev = virtio_dev; + alloc = t_alloc; + + virtio_device->obj.get_driver = qvirtio_gpio_device_get_driver; + virtio_device->obj.start_hw = qvirtio_gpio_device_start_hw; + virtio_device->obj.destructor = qvirtio_gpio_device_destructor; + + return &virtio_device->obj; +} + +/* virtio-gpio-pci */ +static void qvirtio_gpio_pci_destructor(QOSGraphObject *obj) +{ + QVhostUserGPIOPCI *gpio_pci = (QVhostUserGPIOPCI *) obj; + QOSGraphObject *pci_vobj = &gpio_pci->pci_vdev.obj; + + virtio_gpio_cleanup(&gpio_pci->gpio); + qvirtio_pci_destructor(pci_vobj); +} + +static void qvirtio_gpio_pci_start_hw(QOSGraphObject *obj) +{ + QVhostUserGPIOPCI *gpio_pci = (QVhostUserGPIOPCI *) obj; + QOSGraphObject *pci_vobj = &gpio_pci->pci_vdev.obj; + + qvirtio_pci_start_hw(pci_vobj); + virtio_gpio_setup(&gpio_pci->gpio); +} + +static void *qvirtio_gpio_pci_get_driver(void *object, const char *interface) +{ + QVhostUserGPIOPCI *v_gpio = object; + + if (!g_strcmp0(interface, "pci-device")) { + return v_gpio->pci_vdev.pdev; + } + return qvirtio_gpio_get_driver(&v_gpio->gpio, interface); +} + +static void *virtio_gpio_pci_create(void *pci_bus, QGuestAllocator *t_alloc, + void *addr) +{ + QVhostUserGPIOPCI *virtio_spci = g_new0(QVhostUserGPIOPCI, 1); + QVhostUserGPIO *interface = &virtio_spci->gpio; + QOSGraphObject *obj = &virtio_spci->pci_vdev.obj; + + virtio_pci_init(&virtio_spci->pci_vdev, pci_bus, addr); + interface->vdev = &virtio_spci->pci_vdev.vdev; + alloc = t_alloc; + + obj->get_driver = qvirtio_gpio_pci_get_driver; + obj->start_hw = qvirtio_gpio_pci_start_hw; + obj->destructor = qvirtio_gpio_pci_destructor; + + return obj; +} + +static void virtio_gpio_register_nodes(void) +{ + QPCIAddress addr = { + .devfn = QPCI_DEVFN(4, 0), + }; + + QOSGraphEdgeOptions edge_opts = { }; + + /* vhost-user-gpio-device */ + edge_opts.extra_device_opts = "id=gpio0,chardev=chr-vhost-user-test"; + qos_node_create_driver("vhost-user-gpio-device", + virtio_gpio_device_create); + qos_node_consumes("vhost-user-gpio-device", "virtio-bus", &edge_opts); + qos_node_produces("vhost-user-gpio-device", "vhost-user-gpio"); + + /* virtio-gpio-pci */ + edge_opts.extra_device_opts = "id=gpio0,addr=04.0,chardev=chr-vhost-user-test"; + add_qpci_address(&edge_opts, &addr); + qos_node_create_driver("vhost-user-gpio-pci", virtio_gpio_pci_create); + qos_node_consumes("vhost-user-gpio-pci", "pci-bus", &edge_opts); + qos_node_produces("vhost-user-gpio-pci", "vhost-user-gpio"); +} + +libqos_init(virtio_gpio_register_nodes); diff --git a/tests/qtest/libqos/virtio.c b/tests/qtest/libqos/virtio.c index 03056e5187..410513225f 100644 --- a/tests/qtest/libqos/virtio.c +++ b/tests/qtest/libqos/virtio.c @@ -110,7 +110,7 @@ void qvirtio_set_features(QVirtioDevice *d, uint64_t features) * This could be a separate function for drivers that want to access * configuration space before setting FEATURES_OK, but no existing users * need that and it's less code for callers if this is done implicitly. - */ + */ if (features & (1ull << VIRTIO_F_VERSION_1)) { uint8_t status = d->bus->get_status(d) | VIRTIO_CONFIG_S_FEATURES_OK; diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index 4f4fcc09f5..e8d2da7228 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) { @@ -1090,3 +1108,51 @@ static void register_vhost_user_test(void) test_multiqueue, &opts); } libqos_init(register_vhost_user_test); + +static uint64_t vu_gpio_get_features(TestServer *s) +{ + return 0x1ULL << VIRTIO_F_VERSION_1 | + 0x1ULL << VIRTIO_GPIO_F_IRQ | + 0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES; +} + +/* + * This stub can't handle all the message types but we should reply + * that we support VHOST_USER_PROTOCOL_F_CONFIG as gpio would use it + * talking to a read vhost-user daemon. + */ +static void vu_gpio_get_protocol_features(TestServer *s, CharBackend *chr, + VhostUserMsg *msg) +{ + /* send back features to qemu */ + msg->flags |= VHOST_USER_REPLY_MASK; + msg->size = sizeof(m.payload.u64); + msg->payload.u64 = 1ULL << VHOST_USER_PROTOCOL_F_CONFIG; + + qemu_chr_fe_write_all(chr, (uint8_t *)msg, VHOST_USER_HDR_SIZE + msg->size); +} + +static struct vhost_user_ops g_vu_gpio_ops = { + .type = VHOST_USER_GPIO, + + .append_opts = append_vhost_gpio_opts, + + .get_features = vu_gpio_get_features, + .set_features = vu_net_set_features, + .get_protocol_features = vu_gpio_get_protocol_features, +}; + +static void register_vhost_gpio_test(void) +{ + QOSGraphTestOptions opts = { + .before = vhost_user_test_setup, + .subprocess = true, + .arg = &g_vu_gpio_ops, + }; + + qemu_add_opts(&qemu_chardev_opts); + + qos_add_test("read-guest-mem/memfile", + "vhost-user-gpio", test_read_guest_mem, &opts); +} +libqos_init(register_vhost_gpio_test); diff --git a/MAINTAINERS b/MAINTAINERS index beccce4a7a..d0c0c8a55b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2104,6 +2104,7 @@ R: Viresh Kumar S: Maintained F: hw/virtio/vhost-user-gpio* F: include/hw/virtio/vhost-user-gpio.h +F: tests/qtest/libqos/virtio-gpio.* virtio-crypto M: Gonglei diff --git a/tests/qtest/libqos/meson.build b/tests/qtest/libqos/meson.build index cff83c86d9..a5b6d5197a 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: From patchwork Mon Oct 10 17:31:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 613778 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2143443pvb; Mon, 10 Oct 2022 11:23:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6YdW8lEzVk+2SqMioorQgiIngPElCYW9ZqLZyYSHC4609vs/8M+M7EU6bJKwzylHFqOkUl X-Received: by 2002:a05:620a:410b:b0:6ce:1edb:35f6 with SMTP id j11-20020a05620a410b00b006ce1edb35f6mr13579228qko.313.1665426216995; Mon, 10 Oct 2022 11:23:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665426216; cv=none; d=google.com; s=arc-20160816; b=tCNFW2HRWMu/jIa1pfQJRjkcBUI2Rs1FgJ5BAie7NPr9J1pzIa4XwA4FtGn5yHM/Qt 2GqcEIOjGVRDUZIp0YnSS6scS/cbOdBA/hXAw2hYt4dyqUufsGQofxaOBtVQjZQj2MCr w+BUQZ3pb30Zgr2lRep7YHQSlxjV1F5LExkEniDjIP1LynB8CPYEmQbUvP5RRYFm4Rou mTHG6QCwuVTJnS6nmCL/zxe7SHypeHescqNmntq5zwIwg6zRvETq1gTwNQ0uAU92Aj++ br1fqiFpXHmx4eWsU/H2eZZyqxVsDrhjrBndluZSqVsDG6Tczq0ufnsk3XLUQUuTZETX ks+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:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=9qGZK5jOcaN2rqu7K9/IEN4BfTBmzsuWuby5Dy3BdJ8=; b=q4BVdWlRRab2oiD3/qBDRBnARNolNW71yuEcGECVL19jq9uYLT2ioFQjt7emwTUPOH q/pUyhdBXFUUwv1Lkta2IL4SknRWZ8Ga8pGzQhtATrH/51r2I8q6QDUXbCtWAVqHfoJC w2YJVxaTPfEiLAenSN1PeGu10AZctuvAaWl7jg9B42Ir9chTM3BzLOS2+Mk4tRHEgMev h+3vhOUj3jFGaXQiC02DTTYF6GMH1S/DdyRt1cbzdRkwZIXCjv/bCKcaZC//xP+FwbBk LuugSIwwLmrV6+YOFeargaga1kf3H2z6XSf6GPP4Bt1PLR8cOEguaFAUg6uw6anCCtNk 9iyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=X5FSGc7A; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g21-20020ac842d5000000b0039a5de9b9desi1857851qtm.75.2022.10.10.11.23.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Oct 2022 11:23:36 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=X5FSGc7A; 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=redhat.com Received: from localhost ([::1]:59124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohxRA-0000uV-Gt for patch@linaro.org; Mon, 10 Oct 2022 14:23:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52656) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwd7-0003fE-0o for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:31:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51180) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwcg-0007Jp-FE for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:31:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665423085; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=9qGZK5jOcaN2rqu7K9/IEN4BfTBmzsuWuby5Dy3BdJ8=; b=X5FSGc7Avb11wFITVh9ruelHA9APR0yXnMLRQZrM2F424guMPpBAkjLotiRzsJWeoH/3VR HY6dACD5r/T4JHs4DGGOg96DLPmXbKQAolIjdadxaEYw1QQ8nFSSdLPsv0JfOI2tZ21ZCp eT5kArXbYYfPNhUIyGirM+bhi3VlWfo= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-6-RdqmnPJLPNqgZPDpkCT17Q-1; Mon, 10 Oct 2022 13:31:24 -0400 X-MC-Unique: RdqmnPJLPNqgZPDpkCT17Q-1 Received: by mail-wr1-f70.google.com with SMTP id j8-20020adfa548000000b0022e2bf8f48fso2980849wrb.23 for ; Mon, 10 Oct 2022 10:31:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=9qGZK5jOcaN2rqu7K9/IEN4BfTBmzsuWuby5Dy3BdJ8=; b=BhX8yGH8W8vShUYYveho9J6ZkLmuNVu81nxjb5omeehSxDM+QFitDsCKqxaJfzZEpL 7uSUlSol9iCBG8DpiNvyKsZjD6ApOCiII7exwG6ROBuNw2ZYO/6E4OPXnsywnbNK4rCO rgWoXxoDPODUUfCp0lqJbyEn+B1Pt8UU9aLB5zGc2HKOE35oAP4eteF3rVyuz6v5w7bi R1PoV/lNy5OS/BLipT8rMbKMkN66t/KJLWajG36bgcXqa65zA8WVFalNRTisWPW8seEl rs/Ps9tNBLezNF/+E/36g6MVrpm0Ufz3kNUW0jDQCqHybWo9Y0oY59BZKavxCkxOPffl zh2w== X-Gm-Message-State: ACrzQf1GlUNbhvnndlqdd7zdIV1LHnacwQrPoPBKW8BWtxov4GDZxiNi RGwDV0Bv5DNVDzoN2328/BtOIBX+7qCXh5ALb1ZQtciKi6h5n7XuU5XIFU18MoA2vbWiYYpLx7H 8L+Qny+t9rbgYUQO1vnunuxUrY0SLB7J0tiS0pqpd+uIzuiR7rqpcGBYXN8N/ X-Received: by 2002:a05:6000:170a:b0:22e:bd9c:2630 with SMTP id n10-20020a056000170a00b0022ebd9c2630mr11236374wrc.655.1665423083345; Mon, 10 Oct 2022 10:31:23 -0700 (PDT) X-Received: by 2002:a05:6000:170a:b0:22e:bd9c:2630 with SMTP id n10-20020a056000170a00b0022ebd9c2630mr11236352wrc.655.1665423083101; Mon, 10 Oct 2022 10:31:23 -0700 (PDT) Received: from redhat.com ([2.55.183.131]) by smtp.gmail.com with ESMTPSA id n19-20020a05600c4f9300b003b4cba4ef71sm17313837wmq.41.2022.10.10.10.31.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 10:31:22 -0700 (PDT) Date: Mon, 10 Oct 2022 13:31:19 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Richard Henderson , Paolo Bonzini , Marcel Apfelbaum Subject: [PULL 36/55] pci: Remove unused pci_get_*_by_mask() functions Message-ID: <20221010172813.204597-37-mst@redhat.com> References: <20221010172813.204597-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221010172813.204597-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, 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 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: Peter Maydell The helper functions pci_get_{byte,word,long,quad}_by_mask() were added in 2012 in commit c9f50cea70a1596. In the decade since we have never added a single use of them. The helpers clearly aren't that helpful, so drop them rather than carrying around dead code. Reviewed-by: Richard Henderson Signed-off-by: Peter Maydell Message-Id: <20220818135421.2515257-2-peter.maydell@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Paolo Bonzini --- include/hw/pci/pci.h | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index b54b6ef88f..c79144bc5e 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -692,13 +692,6 @@ pci_set_byte_by_mask(uint8_t *config, uint8_t mask, uint8_t reg) pci_set_byte(config, (~mask & val) | (mask & rval)); } -static inline uint8_t -pci_get_byte_by_mask(uint8_t *config, uint8_t mask) -{ - uint8_t val = pci_get_byte(config); - return (val & mask) >> ctz32(mask); -} - static inline void pci_set_word_by_mask(uint8_t *config, uint16_t mask, uint16_t reg) { @@ -707,13 +700,6 @@ pci_set_word_by_mask(uint8_t *config, uint16_t mask, uint16_t reg) pci_set_word(config, (~mask & val) | (mask & rval)); } -static inline uint16_t -pci_get_word_by_mask(uint8_t *config, uint16_t mask) -{ - uint16_t val = pci_get_word(config); - return (val & mask) >> ctz32(mask); -} - static inline void pci_set_long_by_mask(uint8_t *config, uint32_t mask, uint32_t reg) { @@ -722,13 +708,6 @@ pci_set_long_by_mask(uint8_t *config, uint32_t mask, uint32_t reg) pci_set_long(config, (~mask & val) | (mask & rval)); } -static inline uint32_t -pci_get_long_by_mask(uint8_t *config, uint32_t mask) -{ - uint32_t val = pci_get_long(config); - return (val & mask) >> ctz32(mask); -} - static inline void pci_set_quad_by_mask(uint8_t *config, uint64_t mask, uint64_t reg) { @@ -737,13 +716,6 @@ pci_set_quad_by_mask(uint8_t *config, uint64_t mask, uint64_t reg) pci_set_quad(config, (~mask & val) | (mask & rval)); } -static inline uint64_t -pci_get_quad_by_mask(uint8_t *config, uint64_t mask) -{ - uint64_t val = pci_get_quad(config); - return (val & mask) >> ctz32(mask); -} - PCIDevice *pci_new_multifunction(int devfn, bool multifunction, const char *name); PCIDevice *pci_new(int devfn, const char *name); From patchwork Mon Oct 10 17:31:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 613779 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2151437pvb; Mon, 10 Oct 2022 11:39:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6St7JjzrfW+QAx7S3S9VtVqMhRNODyuJbanQ4Yg+qD3+x8/7LEAitn/LEEnX5wirgBAeNS X-Received: by 2002:a05:620a:2113:b0:6ee:13dc:4cdb with SMTP id l19-20020a05620a211300b006ee13dc4cdbmr2115169qkl.74.1665427192701; Mon, 10 Oct 2022 11:39:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665427192; cv=none; d=google.com; s=arc-20160816; b=out77L7ie3xd9Yjhz9pavthfVDjioKRxSfuwzVD5ck2Oql56RufAlZzMx5p4tC1m+b Y3nkw/TY9QgdMoE/665s/O6kDiUcdZQWJKy8/6NFH71pPRrDMXj9iupSEWWoQ7Ty908o YOWLY+8DQXYbBvDuKfnPzlzVAvYRGPQ/wPLQ3S38X1376Xq04hDFussvza370xYVBFq5 i31JeRFq7tMVB2v2mjndFYCe4m2ThFRCHK5kEz58GWeTZysNav8tk5SdY2dH/2Ovn9aH wllXiUCxq0S8X7j3UIkzRgSdlnlfSzgUehbfbbpwl6wldyAuoxJB2E4ub9RGoE9D+oax R2Nw== 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:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=jYG4D+Osh2qvpF6MQt1stca/DHn+PvzorECJ71JvQWM=; b=SvRXncQFz1AJAfnfvhPqhqdEBxWllIdbzLURQek6PwlbIDfDwk+a+qkKwhyHOjrdSt Y+824ZULYjMmQoaSZ8tXgkNMSiriPmacMDPMsVkVnJUNQA08HNO91SZKl4OrSfjRYBF+ MKRouAgV3FjMBDDEEjy4vqaqqHMk5SWx1kgmM/BJ3Su49ZITnA9w/exoON07qQmXxNP1 YAyDodAMfSxlakYChPa6OFqqnGpNeqF+ZgsTXfynhDyfycKRqJkVJV/WtfKMD+nQzZuj 4dJ+rJx7dgGIGAGguy8uQ7/cV0GHEpVqlVzKjXpVW/iKi+kPc1CTS/U811483nXkme7o +xbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Oy+/1iUd"; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id gm13-20020a056214268d00b004af9e440f1bsi5583846qvb.227.2022.10.10.11.39.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Oct 2022 11:39: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=@redhat.com header.s=mimecast20190719 header.b="Oy+/1iUd"; 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=redhat.com Received: from localhost ([::1]:57454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohxgu-0001Rx-6N for patch@linaro.org; Mon, 10 Oct 2022 14:39:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52660) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwd8-0003jv-Vm for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:31:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:42926) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwcn-0007NO-Fr for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:31:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665423090; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=jYG4D+Osh2qvpF6MQt1stca/DHn+PvzorECJ71JvQWM=; b=Oy+/1iUdA8+SsxhdsBVflis/gX5Mx9C1zUWZ5dr1f7CWtf7GGanmJmQysrxKiGzMgyh5jS +k94HLJX8VtrdmdgJK4Ki2aPGTzWKVbpSIVz46uMUObBHLVbxm2tAOJVdix25RbezAO02W PvB3IQckmfKiDTOtw0ATsKnVfyPrN90= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-349-qvfJG8OrOpKhJODw-K60WQ-1; Mon, 10 Oct 2022 13:31:29 -0400 X-MC-Unique: qvfJG8OrOpKhJODw-K60WQ-1 Received: by mail-wr1-f70.google.com with SMTP id m20-20020adfa3d4000000b0022e2fa93dd1so2943298wrb.2 for ; Mon, 10 Oct 2022 10:31:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=jYG4D+Osh2qvpF6MQt1stca/DHn+PvzorECJ71JvQWM=; b=gJTGkPdVnYBLEHXvegJZFk9AI51X2AHENygDbusaC2jr0S+K9HHnPBX/Q9Z84AcF9i a1pkkvNn5WKDbaWP9oeu685fa1Pfjw3xFluNShTHu0RMrHlLQmhPsrgiVC4HHg1CUpAZ DFKc4FN2CUAWrYwO0pBWDsG89zFEVyLRudG+r3+6qGXMwid2OVozXxbDycwIVAvl3/IU zmXZuZEbVMjfY6m4ZK8cN0VGUqmWopuZVxLfMHev0Y8Or4ZQWiUGDblnckmYySiXj6GY Roq6Aspq08vLIOFpK402MbY8THqg+4ApCrOeAIxEwxLrT/D2uLZ/5YF89phlgU3s/8Pk GCZQ== X-Gm-Message-State: ACrzQf2/lHDXwpnCeV7Jf6ytz8sSdE5qAUEjXYdaASW0hdl4K1IyEM8p 5/2LNGdyQ/1wahN5krHkIpx0K039D8NDE/IW/8on1JNzr/UMAH5+57X/e93MWu9l6VoQ4Imb59e /9YGUDFXAatvp3VNJ+X0f3AYW2atUoKO9hiL5C9jny0jlVRHdPqFopS/T4LZn X-Received: by 2002:a05:6000:711:b0:22e:7b01:db9f with SMTP id bs17-20020a056000071100b0022e7b01db9fmr12847178wrb.38.1665423087884; Mon, 10 Oct 2022 10:31:27 -0700 (PDT) X-Received: by 2002:a05:6000:711:b0:22e:7b01:db9f with SMTP id bs17-20020a056000071100b0022e7b01db9fmr12847165wrb.38.1665423087540; Mon, 10 Oct 2022 10:31:27 -0700 (PDT) Received: from redhat.com ([2.55.183.131]) by smtp.gmail.com with ESMTPSA id k24-20020a05600c1c9800b003c6c182bef9sm951399wms.36.2022.10.10.10.31.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 10:31:27 -0700 (PDT) Date: Mon, 10 Oct 2022 13:31:23 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Richard Henderson , Paolo Bonzini , Marcel Apfelbaum Subject: [PULL 37/55] pci: Sanity check mask argument to pci_set_*_by_mask() Message-ID: <20221010172813.204597-38-mst@redhat.com> References: <20221010172813.204597-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221010172813.204597-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 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: Peter Maydell Coverity complains that in functions like pci_set_word_by_mask() we might end up shifting by more than 31 bits. This is true, but only if the caller passes in a zero mask. Help Coverity out by asserting that the mask argument is valid. Fixes: CID 1487168 Reviewed-by: Richard Henderson Signed-off-by: Peter Maydell Message-Id: <20220818135421.2515257-3-peter.maydell@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Paolo Bonzini --- include/hw/pci/pci.h | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index c79144bc5e..97937cc922 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -688,7 +688,10 @@ static inline void pci_set_byte_by_mask(uint8_t *config, uint8_t mask, uint8_t reg) { uint8_t val = pci_get_byte(config); - uint8_t rval = reg << ctz32(mask); + uint8_t rval; + + assert(mask); + rval = reg << ctz32(mask); pci_set_byte(config, (~mask & val) | (mask & rval)); } @@ -696,7 +699,10 @@ static inline void pci_set_word_by_mask(uint8_t *config, uint16_t mask, uint16_t reg) { uint16_t val = pci_get_word(config); - uint16_t rval = reg << ctz32(mask); + uint16_t rval; + + assert(mask); + rval = reg << ctz32(mask); pci_set_word(config, (~mask & val) | (mask & rval)); } @@ -704,7 +710,10 @@ static inline void pci_set_long_by_mask(uint8_t *config, uint32_t mask, uint32_t reg) { uint32_t val = pci_get_long(config); - uint32_t rval = reg << ctz32(mask); + uint32_t rval; + + assert(mask); + rval = reg << ctz32(mask); pci_set_long(config, (~mask & val) | (mask & rval)); } @@ -712,7 +721,10 @@ static inline void pci_set_quad_by_mask(uint8_t *config, uint64_t mask, uint64_t reg) { uint64_t val = pci_get_quad(config); - uint64_t rval = reg << ctz32(mask); + uint64_t rval; + + assert(mask); + rval = reg << ctz32(mask); pci_set_quad(config, (~mask & val) | (mask & rval)); }