From patchwork Mon May 16 20:54:09 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: 572982 Delivered-To: patch@linaro.org Received: by 2002:a5d:5051:0:0:0:0:0 with SMTP id h17csp770091wrt; Mon, 16 May 2022 14:48:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrMrfdrdqw6H7mfp3W5yAvi+l9soLKjumDUFpM78L55DyE+eRksKIey2dtgiQpeAzGASBn X-Received: by 2002:a05:622a:1114:b0:2f3:a16b:e912 with SMTP id e20-20020a05622a111400b002f3a16be912mr16820562qty.640.1652737735607; Mon, 16 May 2022 14:48:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652737735; cv=none; d=google.com; s=arc-20160816; b=hlum1doc4zLsn5yhT0Rm9oecz56pzwpfnavWto3fJ7LxU4DbW/BuGlAN1DJVY2zsiY HF08pbvAyNTarkLdEZd47n1x2ej/a92wuV2NhBJXA59ANTjqhoALFC5t7UDB0V7EaQ3I tXP1TnJDq8K8r0C3ZzD7FRrA5sb76ik8fu6eMFQ8QuDwfsPMT+ZH6wAw0tK6Y4GBqw7O S1WtgrYmLlnDMZ6fAaL/0bPv/kU8bsk82RIqSD/ExXkre6SA4E9cHwcmBwZeiJvc8Vlz igMGBgnqsOczUBabjIoOo/2R5wziv7jsxg1uIyRIpKBbHjJoAiPpTNt+UHmgbzezUgsO iRWg== 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=dTl414t0bLnqbbbHPkJ++SqYY30ITC7Eof+Drpd+b/U=; b=R5e7nHbGmPsyEkwyv20MnoKHpVZiYY0JeI7RoXtlOMAYCD4kCSQLqSdNx3suXPpx8h gRFFmtXIiqgiCnQ/JDeuL0TqfTnEU1Nzql8nc/Jx3kFOUpcCGGp5IOksRjl/4oQg0qdr iiY+XmJaRd1DPrSOAQcEHMQkfbHoBmOZECmnXyRl7QQrGC8toFI7Z/eXxCVqZJd7+RdN R/lyitV/jYnFlTPsriV50WAGHXEWl2emUQTIsAvtpcMC5VC8Z3Xp7Ixm1yF95/oI2ekF wTvZ+ObMC0CZiLEsA+0gfiBy0pRjb3dRLnwMhJumrn9NZI2Rfs/kgI3yXZ/KSXYkpPhu 9r5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=erlz2nTq; 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 iw5-20020a0562140f2500b0045a84a562bdsi6968864qvb.410.2022.05.16.14.48.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 May 2022 14:48:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=erlz2nTq; 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]:59648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqiaF-0004Lj-4R for patch@linaro.org; Mon, 16 May 2022 17:48:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59334) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqhjd-0001Vh-1c for qemu-devel@nongnu.org; Mon, 16 May 2022 16:54:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51150) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqhjV-0006kk-Gy for qemu-devel@nongnu.org; Mon, 16 May 2022 16:54:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652734465; 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=dTl414t0bLnqbbbHPkJ++SqYY30ITC7Eof+Drpd+b/U=; b=erlz2nTqT9Tz47834/zBvMrhd2QxTlo5SxpG64K9gsv/UWRaCtMJn+0cN2kcOo+J4EwN0a 5//tjQAd18lLrXpDMEqtEy5GVCfFdUfSrRcyxmG/OyZwjE15AoHbojFvcUMh0nuhzHVVAk YxGNQyoTLnRVZ7NMirrHNRIlpjRIVUo= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-202-fDpLrJpVPV-DeUxITSzJYQ-1; Mon, 16 May 2022 16:54:16 -0400 X-MC-Unique: fDpLrJpVPV-DeUxITSzJYQ-1 Received: by mail-ed1-f70.google.com with SMTP id y1-20020a056402170100b0042aa8f679fdso3611681edu.1 for ; Mon, 16 May 2022 13:54:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=dTl414t0bLnqbbbHPkJ++SqYY30ITC7Eof+Drpd+b/U=; b=GPBQ2FCNnuj0Z6xt4RnwQHBMV3/6hFGOrAfczEvKqEq1+WMX9mijhTwzuwgw4etaon dTW63RcpMToPRq+D8WyuRZiYsPIVQKQEDiavAikeXyzP2XZBbKgdiBr/KELQ4YmcRHP+ TaO0yK3wcGiOWlGgWw0+hVhIEi6thuJBZe5tUN+HRDh6NIZkTNOV7Gt4zkdA3fvLE7pf Y+zAZbsG13F3mRDuh6nWzRHM4ZTwErTRbuUZFmmfKoJRy3WhUmRclOp2p3aqxNCm/su7 GiAochWaZKuz1u6Er7KKRI/jIntoBKiXsFv5DOPQzLQJYQO2qElFIigHee1qps0Vkd1Q H8RA== X-Gm-Message-State: AOAM533DOlV1rhOKa2fdYHlIFBjmhKKjGfRZnRg7qU72NLOuIK4a++md P8aq1Wk7ysEI6v7eU/Fl/Wr2kqjtEJhrR/uQCohvyZsGniVSK8XJE71MZnb96sOiqvEkBrIjR30 NPqNxwypsuU17yNHmjEdGwNWz3cFEeeclEJx1x82eCfjGe6V8aVEzjSvAyWPV X-Received: by 2002:a17:907:c27:b0:6fe:5636:6020 with SMTP id ga39-20020a1709070c2700b006fe56366020mr2304318ejc.730.1652734453897; Mon, 16 May 2022 13:54:13 -0700 (PDT) X-Received: by 2002:a17:907:c27:b0:6fe:5636:6020 with SMTP id ga39-20020a1709070c2700b006fe56366020mr2304296ejc.730.1652734453479; Mon, 16 May 2022 13:54:13 -0700 (PDT) Received: from redhat.com ([2.55.131.38]) by smtp.gmail.com with ESMTPSA id hg23-20020a1709072cd700b006f3ef214decsm171219ejc.82.2022.05.16.13.54.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 13:54:13 -0700 (PDT) Date: Mon, 16 May 2022 16:54:09 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Raphael Norwitz , "Dr. David Alan Gilbert" , Stefan Hajnoczi , Mathieu Poirier , David Hildenbrand , Eric Auger , virtio-fs@redhat.com Subject: [PULL v2 58/86] hw/virtio: move virtio-pci.h into shared include space Message-ID: <20220516204913.542894-59-mst@redhat.com> References: <20220516204913.542894-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220516204913.542894-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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée This allows other device classes that will be exposed via PCI to be able to do so in the appropriate hw/ directory. I resisted the temptation to re-order headers to be more aesthetically pleasing. Signed-off-by: Alex Bennée Message-Id: <20200925125147.26943-4-alex.bennee@linaro.org> Message-Id: <20220321153037.3622127-2-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- {hw => include/hw}/virtio/virtio-pci.h | 0 hw/virtio/vhost-scsi-pci.c | 2 +- hw/virtio/vhost-user-blk-pci.c | 2 +- hw/virtio/vhost-user-fs-pci.c | 2 +- hw/virtio/vhost-user-i2c-pci.c | 2 +- hw/virtio/vhost-user-input-pci.c | 2 +- hw/virtio/vhost-user-rng-pci.c | 2 +- hw/virtio/vhost-user-scsi-pci.c | 2 +- hw/virtio/vhost-user-vsock-pci.c | 2 +- hw/virtio/vhost-vsock-pci.c | 2 +- hw/virtio/virtio-9p-pci.c | 2 +- hw/virtio/virtio-balloon-pci.c | 2 +- hw/virtio/virtio-blk-pci.c | 2 +- hw/virtio/virtio-input-host-pci.c | 2 +- hw/virtio/virtio-input-pci.c | 2 +- hw/virtio/virtio-iommu-pci.c | 2 +- hw/virtio/virtio-net-pci.c | 2 +- hw/virtio/virtio-pci.c | 2 +- hw/virtio/virtio-rng-pci.c | 2 +- hw/virtio/virtio-scsi-pci.c | 2 +- hw/virtio/virtio-serial-pci.c | 2 +- 21 files changed, 20 insertions(+), 20 deletions(-) rename {hw => include/hw}/virtio/virtio-pci.h (100%) diff --git a/hw/virtio/virtio-pci.h b/include/hw/virtio/virtio-pci.h similarity index 100% rename from hw/virtio/virtio-pci.h rename to include/hw/virtio/virtio-pci.h diff --git a/hw/virtio/vhost-scsi-pci.c b/hw/virtio/vhost-scsi-pci.c index cb71a294fa..08980bc23b 100644 --- a/hw/virtio/vhost-scsi-pci.c +++ b/hw/virtio/vhost-scsi-pci.c @@ -21,7 +21,7 @@ #include "hw/virtio/vhost-scsi.h" #include "qapi/error.h" #include "qemu/module.h" -#include "virtio-pci.h" +#include "hw/virtio/virtio-pci.h" #include "qom/object.h" typedef struct VHostSCSIPCI VHostSCSIPCI; diff --git a/hw/virtio/vhost-user-blk-pci.c b/hw/virtio/vhost-user-blk-pci.c index 33b404d8a2..eef8641a98 100644 --- a/hw/virtio/vhost-user-blk-pci.c +++ b/hw/virtio/vhost-user-blk-pci.c @@ -26,7 +26,7 @@ #include "qapi/error.h" #include "qemu/error-report.h" #include "qemu/module.h" -#include "virtio-pci.h" +#include "hw/virtio/virtio-pci.h" #include "qom/object.h" typedef struct VHostUserBlkPCI VHostUserBlkPCI; diff --git a/hw/virtio/vhost-user-fs-pci.c b/hw/virtio/vhost-user-fs-pci.c index 2ed8492b3f..6829b8b743 100644 --- a/hw/virtio/vhost-user-fs-pci.c +++ b/hw/virtio/vhost-user-fs-pci.c @@ -14,7 +14,7 @@ #include "qemu/osdep.h" #include "hw/qdev-properties.h" #include "hw/virtio/vhost-user-fs.h" -#include "virtio-pci.h" +#include "hw/virtio/virtio-pci.h" #include "qom/object.h" struct VHostUserFSPCI { diff --git a/hw/virtio/vhost-user-i2c-pci.c b/hw/virtio/vhost-user-i2c-pci.c index 70b7b65fd9..00ac10941f 100644 --- a/hw/virtio/vhost-user-i2c-pci.c +++ b/hw/virtio/vhost-user-i2c-pci.c @@ -9,7 +9,7 @@ #include "qemu/osdep.h" #include "hw/qdev-properties.h" #include "hw/virtio/vhost-user-i2c.h" -#include "virtio-pci.h" +#include "hw/virtio/virtio-pci.h" struct VHostUserI2CPCI { VirtIOPCIProxy parent_obj; diff --git a/hw/virtio/vhost-user-input-pci.c b/hw/virtio/vhost-user-input-pci.c index c9d3e9113a..b858898a36 100644 --- a/hw/virtio/vhost-user-input-pci.c +++ b/hw/virtio/vhost-user-input-pci.c @@ -9,7 +9,7 @@ #include "hw/virtio/virtio-input.h" #include "qapi/error.h" #include "qemu/error-report.h" -#include "virtio-pci.h" +#include "hw/virtio/virtio-pci.h" #include "qom/object.h" typedef struct VHostUserInputPCI VHostUserInputPCI; diff --git a/hw/virtio/vhost-user-rng-pci.c b/hw/virtio/vhost-user-rng-pci.c index c83dc86813..f64935453b 100644 --- a/hw/virtio/vhost-user-rng-pci.c +++ b/hw/virtio/vhost-user-rng-pci.c @@ -9,7 +9,7 @@ #include "qemu/osdep.h" #include "hw/qdev-properties.h" #include "hw/virtio/vhost-user-rng.h" -#include "virtio-pci.h" +#include "hw/virtio/virtio-pci.h" struct VHostUserRNGPCI { VirtIOPCIProxy parent_obj; diff --git a/hw/virtio/vhost-user-scsi-pci.c b/hw/virtio/vhost-user-scsi-pci.c index d5343412a1..75882e3cf9 100644 --- a/hw/virtio/vhost-user-scsi-pci.c +++ b/hw/virtio/vhost-user-scsi-pci.c @@ -30,7 +30,7 @@ #include "hw/pci/msix.h" #include "hw/loader.h" #include "sysemu/kvm.h" -#include "virtio-pci.h" +#include "hw/virtio/virtio-pci.h" #include "qom/object.h" typedef struct VHostUserSCSIPCI VHostUserSCSIPCI; diff --git a/hw/virtio/vhost-user-vsock-pci.c b/hw/virtio/vhost-user-vsock-pci.c index 72a96199cd..e5a86e8013 100644 --- a/hw/virtio/vhost-user-vsock-pci.c +++ b/hw/virtio/vhost-user-vsock-pci.c @@ -10,7 +10,7 @@ #include "qemu/osdep.h" -#include "virtio-pci.h" +#include "hw/virtio/virtio-pci.h" #include "hw/qdev-properties.h" #include "hw/virtio/vhost-user-vsock.h" #include "qom/object.h" diff --git a/hw/virtio/vhost-vsock-pci.c b/hw/virtio/vhost-vsock-pci.c index 205da8d1f5..9f34414d38 100644 --- a/hw/virtio/vhost-vsock-pci.c +++ b/hw/virtio/vhost-vsock-pci.c @@ -13,7 +13,7 @@ #include "qemu/osdep.h" -#include "virtio-pci.h" +#include "hw/virtio/virtio-pci.h" #include "hw/qdev-properties.h" #include "hw/virtio/vhost-vsock.h" #include "qemu/module.h" diff --git a/hw/virtio/virtio-9p-pci.c b/hw/virtio/virtio-9p-pci.c index e07adcd9ea..94c14f0b98 100644 --- a/hw/virtio/virtio-9p-pci.c +++ b/hw/virtio/virtio-9p-pci.c @@ -15,7 +15,7 @@ #include "qemu/osdep.h" -#include "virtio-pci.h" +#include "hw/virtio/virtio-pci.h" #include "hw/9pfs/virtio-9p.h" #include "hw/qdev-properties.h" #include "qemu/module.h" diff --git a/hw/virtio/virtio-balloon-pci.c b/hw/virtio/virtio-balloon-pci.c index 79a3ba979a..ce2645ba71 100644 --- a/hw/virtio/virtio-balloon-pci.c +++ b/hw/virtio/virtio-balloon-pci.c @@ -14,7 +14,7 @@ #include "qemu/osdep.h" -#include "virtio-pci.h" +#include "hw/virtio/virtio-pci.h" #include "hw/qdev-properties.h" #include "hw/virtio/virtio-balloon.h" #include "qapi/error.h" diff --git a/hw/virtio/virtio-blk-pci.c b/hw/virtio/virtio-blk-pci.c index 9d5795810c..9743bee965 100644 --- a/hw/virtio/virtio-blk-pci.c +++ b/hw/virtio/virtio-blk-pci.c @@ -19,7 +19,7 @@ #include "hw/qdev-properties.h" #include "hw/virtio/virtio-blk.h" -#include "virtio-pci.h" +#include "hw/virtio/virtio-pci.h" #include "qapi/error.h" #include "qemu/module.h" #include "qom/object.h" diff --git a/hw/virtio/virtio-input-host-pci.c b/hw/virtio/virtio-input-host-pci.c index 0ac360de4f..cf8a9cf9e8 100644 --- a/hw/virtio/virtio-input-host-pci.c +++ b/hw/virtio/virtio-input-host-pci.c @@ -8,7 +8,7 @@ #include "qemu/osdep.h" -#include "virtio-pci.h" +#include "hw/virtio/virtio-pci.h" #include "hw/virtio/virtio-input.h" #include "qemu/module.h" #include "qom/object.h" diff --git a/hw/virtio/virtio-input-pci.c b/hw/virtio/virtio-input-pci.c index 48e9ff38e2..a9d0992389 100644 --- a/hw/virtio/virtio-input-pci.c +++ b/hw/virtio/virtio-input-pci.c @@ -8,7 +8,7 @@ #include "qemu/osdep.h" -#include "virtio-pci.h" +#include "hw/virtio/virtio-pci.h" #include "hw/qdev-properties.h" #include "hw/virtio/virtio-input.h" #include "qemu/module.h" diff --git a/hw/virtio/virtio-iommu-pci.c b/hw/virtio/virtio-iommu-pci.c index 6a1df7fe50..844d647704 100644 --- a/hw/virtio/virtio-iommu-pci.c +++ b/hw/virtio/virtio-iommu-pci.c @@ -11,7 +11,7 @@ #include "qemu/osdep.h" -#include "virtio-pci.h" +#include "hw/virtio/virtio-pci.h" #include "hw/virtio/virtio-iommu.h" #include "hw/qdev-properties.h" #include "hw/qdev-properties-system.h" diff --git a/hw/virtio/virtio-net-pci.c b/hw/virtio/virtio-net-pci.c index aa0b3caecb..e03543a70a 100644 --- a/hw/virtio/virtio-net-pci.c +++ b/hw/virtio/virtio-net-pci.c @@ -19,7 +19,7 @@ #include "hw/qdev-properties.h" #include "hw/virtio/virtio-net.h" -#include "virtio-pci.h" +#include "hw/virtio/virtio-pci.h" #include "qapi/error.h" #include "qemu/module.h" #include "qom/object.h" diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 7cf1231c1c..602be7f83d 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -33,7 +33,7 @@ #include "hw/pci/msix.h" #include "hw/loader.h" #include "sysemu/kvm.h" -#include "virtio-pci.h" +#include "hw/virtio/virtio-pci.h" #include "qemu/range.h" #include "hw/virtio/virtio-bus.h" #include "qapi/visitor.h" diff --git a/hw/virtio/virtio-rng-pci.c b/hw/virtio/virtio-rng-pci.c index c1f916268b..151ece6f94 100644 --- a/hw/virtio/virtio-rng-pci.c +++ b/hw/virtio/virtio-rng-pci.c @@ -11,7 +11,7 @@ #include "qemu/osdep.h" -#include "virtio-pci.h" +#include "hw/virtio/virtio-pci.h" #include "hw/virtio/virtio-rng.h" #include "qapi/error.h" #include "qemu/module.h" diff --git a/hw/virtio/virtio-scsi-pci.c b/hw/virtio/virtio-scsi-pci.c index 97fab74236..e8e3442f38 100644 --- a/hw/virtio/virtio-scsi-pci.c +++ b/hw/virtio/virtio-scsi-pci.c @@ -18,7 +18,7 @@ #include "hw/qdev-properties.h" #include "hw/virtio/virtio-scsi.h" #include "qemu/module.h" -#include "virtio-pci.h" +#include "hw/virtio/virtio-pci.h" #include "qom/object.h" typedef struct VirtIOSCSIPCI VirtIOSCSIPCI; diff --git a/hw/virtio/virtio-serial-pci.c b/hw/virtio/virtio-serial-pci.c index 35bcd961c9..cea31adcc4 100644 --- a/hw/virtio/virtio-serial-pci.c +++ b/hw/virtio/virtio-serial-pci.c @@ -20,7 +20,7 @@ #include "hw/qdev-properties.h" #include "hw/virtio/virtio-serial.h" #include "qemu/module.h" -#include "virtio-pci.h" +#include "hw/virtio/virtio-pci.h" #include "qom/object.h" typedef struct VirtIOSerialPCI VirtIOSerialPCI; From patchwork Mon May 16 20:54:13 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: 572985 Delivered-To: patch@linaro.org Received: by 2002:a5d:5051:0:0:0:0:0 with SMTP id h17csp772168wrt; Mon, 16 May 2022 14:54:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfCmXQiORgLP12mJipzUHiFvwV+Ku9njZ5xKkP6IgUiNDEvSGDDQARxUckADlCtjt0RuC8 X-Received: by 2002:a05:6214:518d:b0:45a:933f:965d with SMTP id kl13-20020a056214518d00b0045a933f965dmr17758531qvb.94.1652738074659; Mon, 16 May 2022 14:54:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652738074; cv=none; d=google.com; s=arc-20160816; b=Y5Nycfbzn37JFzXk/FyMVL/U5Lo4pKfPF96U00snIeXYWGFi62b81Iivw6pl0OEPJF Kw+x88WrH9Ck5cIL8WKqQ97nIcSx1/1omp9kw5EJgLAbKcIpMWRGH8VSt6nj5R890q6g B3ZtHMe9fKwY3nbIBLoA66xRymUBQXrxWKMg1k2fBtYLdQpGVCJva+yO0s5fdBO/Wwjc wVfGZM5/ef7d0vSil/s0duKvIrJxJ4tPXnkd81eY7boOT8qTCos8tO+EfRelXx0bncyq ZtBUTnermNrIENv+9SRDQcf01ZiGADjhMQQsazFDn5On4aID9gvvRix1xk0fR/WmW0UG H08Q== 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=n6WXp9xMmKMm1v0MT4LZmWjQcAIeqsOeuNoimR/qMv4=; b=jzydwQhQrcwajsn17/tXYnsnGZPq8Hhzw1tjxKJWu3b/5SUBCw+s5M4chOonBRPAxA 0LcpCYGxfTCWYQWPqB3zHemTWX6tbgtMMfKBpSqNY5Wc8su2fCCzdLolXX3ZycySXWH7 mScSKAwSx+pC5RWFNiECrGiLNb93jG28aEMjMQuS+FsZkLCHQA3N7QdLJe2DQrYkettA 2ZdjjhCve8PPa+K34YWhyCal9Mc/QXgtmMagg2DJnETHxBhNCVnroJMAuOxNj7YUppdH Ll7VbLBYKWVX9A0lsdXB2+0LOhWdtDzIsfW8ENSeJybx/r1bgKE7u8cwfLiV0R7vzv4n PANA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TKwDyJbJ; 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 e13-20020a0562141d0d00b0045a8e328d28si7524991qvd.569.2022.05.16.14.54.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 May 2022 14:54: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=TKwDyJbJ; 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]:48428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqifh-0007TX-TB for patch@linaro.org; Mon, 16 May 2022 17:54:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59298) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqhjS-00019V-Ij for qemu-devel@nongnu.org; Mon, 16 May 2022 16:54:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:58120) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqhjQ-0006kL-V7 for qemu-devel@nongnu.org; Mon, 16 May 2022 16:54:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652734460; 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=n6WXp9xMmKMm1v0MT4LZmWjQcAIeqsOeuNoimR/qMv4=; b=TKwDyJbJvGvnYvoWjz70xWK6WTsF2A8+2RxbqHnZdkQHpVJF1l19KkmaWK2u1zovyi5jjE d1olM8uCTJEeerY5f8V1Enof0OZ+NeSTvc9ge/IIiQU5Mln4FibgfzEnCn4lND8rCPZtEY JZWLywCM4tFN82J3EPOqCmeeYmNwkVU= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-169-5919fSliM3aCN7LMqn5kUg-1; Mon, 16 May 2022 16:54:18 -0400 X-MC-Unique: 5919fSliM3aCN7LMqn5kUg-1 Received: by mail-ej1-f70.google.com with SMTP id sc20-20020a1709078a1400b006f4a358c817so6339354ejc.16 for ; Mon, 16 May 2022 13:54:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=n6WXp9xMmKMm1v0MT4LZmWjQcAIeqsOeuNoimR/qMv4=; b=Tb3UWhUfkdw0Ya4Knpws2ehEFVic41daVBD6JgtRFqOO94gGPMLNYN4C8rRSZaxbHB HJdQ6DPi8Ptv8lbm0PqVqcimyJzTLhWmdx/2yNFWSECcrSd647+/MFSWaS1tkAPW9Rrb +7dyhcQoxxjvFVm12JBZ7HUcjLzj+jTbUUeB2uv4HCRyUUoIyUUc7hn8/mfyYociTizK P+NmP+m/JqxKh398IzVMfHJ63sZl4P/lkOIR7Rm4MPzvRao9qazATiumPOv0H0FuLnDK lgVkNK5rSzYf6Oxhv4PkhrZTuzkv8xpzpftllPeWLxpDs5RdvViRmkvS4L0rteXm9UF4 knfQ== X-Gm-Message-State: AOAM531sCyh/BtJ29pz8l8Wr7zxtslEmqYeHNgD8/M31m5mE1HA6JYa7 WPTEU0k+ph79ioJMycDEnUp/e0d1kvjKfPr5pb++NyyOnwUW+q5YmOjW0BDwOd8BpW5yPn+Mv2B jfCG8TawxI5uZNFy9ekx9w5XJO3UedCXzmKLsFCWc5eXQlSp7BKLQ3VAFevhL X-Received: by 2002:a05:6402:294e:b0:425:f016:24e7 with SMTP id ed14-20020a056402294e00b00425f01624e7mr15343419edb.111.1652734457310; Mon, 16 May 2022 13:54:17 -0700 (PDT) X-Received: by 2002:a05:6402:294e:b0:425:f016:24e7 with SMTP id ed14-20020a056402294e00b00425f01624e7mr15343395edb.111.1652734457048; Mon, 16 May 2022 13:54:17 -0700 (PDT) Received: from redhat.com ([2.55.131.38]) by smtp.gmail.com with ESMTPSA id h16-20020a056402095000b0042ac43be19dsm156054edz.3.2022.05.16.13.54.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 13:54:16 -0700 (PDT) Date: Mon, 16 May 2022 16:54:13 -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 v2 59/86] virtio-pci: add notification trace points Message-ID: <20220516204913.542894-60-mst@redhat.com> References: <20220516204913.542894-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220516204913.542894-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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20200925125147.26943-6-alex.bennee@linaro.org> Signed-off-by: Alex Bennée Message-Id: <20220321153037.3622127-3-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.c | 3 +++ hw/virtio/trace-events | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 602be7f83d..0566ad7d00 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -38,6 +38,7 @@ #include "hw/virtio/virtio-bus.h" #include "qapi/visitor.h" #include "sysemu/replay.h" +#include "trace.h" #define VIRTIO_PCI_REGION_SIZE(dev) VIRTIO_PCI_CONFIG_OFF(msix_present(dev)) @@ -1380,6 +1381,7 @@ static void virtio_pci_notify_write(void *opaque, hwaddr addr, unsigned queue = addr / virtio_pci_queue_mem_mult(proxy); if (vdev != NULL && queue < VIRTIO_QUEUE_MAX) { + trace_virtio_pci_notify_write(addr, val, size); virtio_queue_notify(vdev, queue); } } @@ -1393,6 +1395,7 @@ static void virtio_pci_notify_write_pio(void *opaque, hwaddr addr, unsigned queue = val; if (vdev != NULL && queue < VIRTIO_QUEUE_MAX) { + trace_virtio_pci_notify_write_pio(addr, val, size); virtio_queue_notify(vdev, queue); } } diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 333348d9d5..7a6576d833 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -89,7 +89,12 @@ virtio_mmio_guest_page(uint64_t size, int shift) "guest page size 0x%" PRIx64 " virtio_mmio_queue_write(uint64_t value, int max_size) "mmio_queue write 0x%" PRIx64 " max %d" virtio_mmio_setting_irq(int level) "virtio_mmio setting IRQ %d" -# virtio-iommu.c +# virtio-pci.c +virtio_pci_notify(uint16_t vector) "virtio_pci_notify vec 0x%x" +virtio_pci_notify_write(uint64_t addr, uint64_t val, unsigned int size) "0x%" PRIx64" = 0x%" PRIx64 " (%d)" +virtio_pci_notify_write_pio(uint64_t addr, uint64_t val, unsigned int size) "0x%" PRIx64" = 0x%" PRIx64 " (%d)" + +# hw/virtio/virtio-iommu.c virtio_iommu_device_reset(void) "reset!" virtio_iommu_system_reset(void) "system reset!" virtio_iommu_get_features(uint64_t features) "device supports features=0x%"PRIx64 From patchwork Mon May 16 20:54:17 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: 572980 Delivered-To: patch@linaro.org Received: by 2002:a5d:5051:0:0:0:0:0 with SMTP id h17csp769241wrt; Mon, 16 May 2022 14:46:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyBTP27x7boZ1TZ7wKa83Xm5Rt3IkXoje0Nzyf3DyvXn+IAF8lAcurfcYojh1ntShA9QcI X-Received: by 2002:a05:622a:216:b0:2f3:b25a:2e33 with SMTP id b22-20020a05622a021600b002f3b25a2e33mr17449754qtx.301.1652737609685; Mon, 16 May 2022 14:46:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652737609; cv=none; d=google.com; s=arc-20160816; b=zm8Z0fcFVM6eM2p5IAPoLdsLyorJITAUiGjWTeEvrJczglCe2sZ02/2gslXeuw0DgD 1Dpse6e+KQQAJ1OYDGuQmzIjW6BrVDifuovvYpjplEhYCFJdzet9qfJuZMROODPukq1H SJV2gj4OQJ4ovu9m8fWTzjl3ZyV9FEkDrN5bWkcapSLIkxoJbp0tqmewokwyKGPDq+UE HoFFLouGGUZAmpEdbLeP1tg27FBtBw1wRJz5KtJPMvfrhuIMTLtvQ/NrJnyNs1aa7DRU nA7wSLKEIWJe69ashXT2qfDT+pj/Mj6l+AJuH463NqPu3Fp9WneVGoPBMwxV/26gDgSf Gcmg== 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=er6c1eR6RwDHZXwxcu4HK3IQCJPdNMZNebVVRQV+U8s=; b=TjICbs8YtnqdpJxvfQwqBtuJ3MTTXS38pBL05qiAwyULmXUNIueHDcLS0NrSRD0rUy oImjlEe6bA9ksNp/eI/7Ty7YpmEN0vE6e/YFaOjGdhQMg8/Txk7ewVyYJ77eJDqLviy9 DBJUV0Beamx7suUjt3QwMzcOre2diwi46C0qG+AiGUIowHBra3sfJN7No2zzUNq0MYdY ScFEzs40xFQ7HKDzu0xpldpCdOLQd7G/I6dDHnAB4CbQloLW+HDP33728ZSv7SYQlEZj OKyxJHiCGW0M4c3abDb8etr9cKLIoUe2DjRsTGAhfiGilBKlK3KT92gWCI41mFQqzbNu ilSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=F6plD1GH; 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 g74-20020a379d4d000000b0069ff5113115si6227295qke.437.2022.05.16.14.46.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 May 2022 14:46:49 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=F6plD1GH; 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]:50994 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqiYD-0006qu-5Z for patch@linaro.org; Mon, 16 May 2022 17:46:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59312) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqhjV-0001JM-29 for qemu-devel@nongnu.org; Mon, 16 May 2022 16:54:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49004) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqhjT-0006kZ-Ja for qemu-devel@nongnu.org; Mon, 16 May 2022 16:54:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652734463; 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=er6c1eR6RwDHZXwxcu4HK3IQCJPdNMZNebVVRQV+U8s=; b=F6plD1GHIqrsASq/GdLnqPtCupIqxINBKKlMy3Kw8I1r01urpsFRbsI/L+wABEV3eiB+94 Qy/a7H93V7thUACaoXdFfZuRMmFfWJuXxv2WNBlXdOHhUcTGTP1KbBNOomRb3QYjvESnVe W39Tr0aqsYWIdmLEFDLnZhc/tEn67Vg= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-232-5YS_7wdGNiaNsdD8nkJ4RQ-1; Mon, 16 May 2022 16:54:22 -0400 X-MC-Unique: 5YS_7wdGNiaNsdD8nkJ4RQ-1 Received: by mail-ej1-f72.google.com with SMTP id x2-20020a1709065ac200b006d9b316257fso6372699ejs.12 for ; Mon, 16 May 2022 13:54:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=er6c1eR6RwDHZXwxcu4HK3IQCJPdNMZNebVVRQV+U8s=; b=caiY1K9n2T38t1+91o3IqpAzXG5r7gtGa40MEONxU9JvCddbFtHo/vkORCE9Y66+2Y EJwqJAPcDZeKKMh5yNCIQLmv7SNWkxi/rAbXbbk6WU/68tSGFIi/JQ2eVcgS3Cg3omYz c8u7MRzVKfLcVTgC2DvlL5AEl1muiIFwtCxUt9nu0HOPwaEoBZliAGDj9hSOjo4vrPmy 51R5TnBQTUP4Iypt1cevIp5PSD5yTcHEBw2IdFS03Ya07RLLF6DIvnqhE9RLPPwELbsz geFDSHoZgEjgEeaJRqHXh+AdrCsZECmLx3nVufCwVV7qPwPsQOACFNL7xuxk5VXE2Rou eY/Q== X-Gm-Message-State: AOAM532+czuBFrW9DjexqQblwpybzyo8M2P1Dgw6j+ITAaX0UJFC8uee Ybb2jb92yXT+3bAL5gA8GEc54SrIP6fLWycAmcs/Zk8Q5hWl3+ZAIanA9+J0H1QlZ8poQEzYek6 Iq4wWZL5MZGuNn540+ZfYzPbo4mXSot9UJt5C1VC4pyPfikyFuxqQ2LyirouR X-Received: by 2002:a17:907:3f8c:b0:6fa:8b15:66fe with SMTP id hr12-20020a1709073f8c00b006fa8b1566femr17400753ejc.142.1652734460717; Mon, 16 May 2022 13:54:20 -0700 (PDT) X-Received: by 2002:a17:907:3f8c:b0:6fa:8b15:66fe with SMTP id hr12-20020a1709073f8c00b006fa8b1566femr17400737ejc.142.1652734460378; Mon, 16 May 2022 13:54:20 -0700 (PDT) Received: from redhat.com ([2.55.131.38]) by smtp.gmail.com with ESMTPSA id s10-20020a170906778a00b006f3ef214de3sm175276ejm.73.2022.05.16.13.54.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 13:54:19 -0700 (PDT) Date: Mon, 16 May 2022 16:54:17 -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 v2 60/86] hw/virtio: add vhost_user_[read|write] trace points Message-ID: <20220516204913.542894-61-mst@redhat.com> References: <20220516204913.542894-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220516204913.542894-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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée These are useful when trying to debug the initial vhost-user negotiation, especially when it hard to get logging from the low level library on the other side. Signed-off-by: Alex Bennée Message-Id: <20220321153037.3622127-4-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 | 4 ++++ hw/virtio/trace-events | 2 ++ 2 files changed, 6 insertions(+) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index afd51f79b3..6c8f722262 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -489,6 +489,8 @@ static int vhost_user_write(struct vhost_dev *dev, VhostUserMsg *msg, return ret < 0 ? -saved_errno : -EIO; } + trace_vhost_user_write(msg->hdr.request, msg->hdr.flags); + return 0; } @@ -542,6 +544,8 @@ static int vhost_user_set_log_base(struct vhost_dev *dev, uint64_t base, } } + trace_vhost_user_read(msg.hdr.request, msg.hdr.flags); + return 0; } diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 7a6576d833..65e3b704ec 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -21,6 +21,8 @@ vhost_user_set_mem_table_withfd(int index, const char *name, uint64_t memory_siz vhost_user_postcopy_waker(const char *rb, uint64_t rb_offset) "%s + 0x%"PRIx64 vhost_user_postcopy_waker_found(uint64_t client_addr) "0x%"PRIx64 vhost_user_postcopy_waker_nomatch(const char *rb, uint64_t rb_offset) "%s + 0x%"PRIx64 +vhost_user_read(uint32_t req, uint32_t flags) "req:%d flags:0x%"PRIx32"" +vhost_user_write(uint32_t req, uint32_t flags) "req:%d flags:0x%"PRIx32"" # vhost-vdpa.c vhost_vdpa_dma_map(void *vdpa, int fd, uint32_t msg_type, uint64_t iova, uint64_t size, uint64_t uaddr, uint8_t perm, uint8_t type) "vdpa:%p fd: %d msg_type: %"PRIu32" iova: 0x%"PRIx64" size: 0x%"PRIx64" uaddr: 0x%"PRIx64" perm: 0x%"PRIx8" type: %"PRIu8 From patchwork Mon May 16 20:54:30 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: 572987 Delivered-To: patch@linaro.org Received: by 2002:a5d:5051:0:0:0:0:0 with SMTP id h17csp773593wrt; Mon, 16 May 2022 14:58:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIxaCWiqPRkJ8Fg9TSsRIAhc+LuGJNTJOqE+DLUHihkh458hzW+qkwWRJ2MldLG9aoOvIe X-Received: by 2002:a05:622a:15cb:b0:2f3:f90f:1939 with SMTP id d11-20020a05622a15cb00b002f3f90f1939mr17364526qty.374.1652738303815; Mon, 16 May 2022 14:58:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652738303; cv=none; d=google.com; s=arc-20160816; b=I4e4SWKjzclMUzp8znzgVC2/E7HQICLbooOUn+GDM4nY+q+7bbgqj8xp+2ccu/ewsy eNlWTEtz1R9gtX3tOAbmeIgqk+6+Ms2Uk45eg2tIlSr8im/M5uz8P8CqXpbqfsEXSvLe y3+G9BsVUv5lwCuRx8fw2EAZuY5LJ6fEt9D/roycvX4Dd8hA+Ncz7Xy7zj+hDYLukZpZ nWnguDMF0bXgoEaWIiLb9fPkgg5Hpj0x720iDom+72NWsMhANa5hA/LP5C1LTYEFDSHk YxMLPn6scF5+aJjdqeYEIEjWiAKQt2fH1PBZzHsM9hbQi9OZzaoi4t0s1rNjQsZmjZ08 qYUA== 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=6TBSwgl4erp1QVjV6hUdkH53hYVNMfCm5ztMd9UNMOM=; b=JQKOl+6s8ItdydmrVOUDouMKc1ac02H332W41XXZ+THkEHyMrTj0J4iu6Xm7XGl/bm GkXVFG7JvbmbAjcy2IpkJ4gJ6YTU0Al9PnmKAeuCTyzTYXmD/DoVlsmlMvG05P84iSss ubLSjvSbwxDKmA+Kc5Mswo13ffc03rZFWaCfPtIjLucr0K/xdTdjJAGVFSdbghLouNLT aNb4VD2mKEXxNRYQEUMEAMvyyAn0cq4rMApA1DfBDwDzPXeaMTerm6oCjHQez1YZDqRx QHsHT7VocCwBcFOjH5NP963Q0G9hqq3j95HiWePTJGcvt6gcbNMbpd5fUrS0ZKaipWNa AlQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QRS4SFD5; 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 12-20020a05621420cc00b00461dc6f69c9si110908qve.503.2022.05.16.14.58.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 May 2022 14:58:23 -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=QRS4SFD5; 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]:56812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqijP-0004rg-A4 for patch@linaro.org; Mon, 16 May 2022 17:58:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59402) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqhjj-0001vG-Mp for qemu-devel@nongnu.org; Mon, 16 May 2022 16:54:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:42649) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqhjh-0006ms-PN for qemu-devel@nongnu.org; Mon, 16 May 2022 16:54:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652734477; 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=6TBSwgl4erp1QVjV6hUdkH53hYVNMfCm5ztMd9UNMOM=; b=QRS4SFD5htlGPz+5HGk64eauPbQEw4pisOk9YgX31cA/SigZuB6BRwMYojrK+kc5TqHEsQ oxqg/6VC0nA2foqhgr9+qSRh2uXUWHz6Ipfzy5Y91nhUYrSJJ8IR2QrtHHNEifJDLibClO rKyyS0PkatVrCzgp9NOQaE7ehj6bREY= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-661-MmZpWV5JPrq1WCu4DRdfeQ-1; Mon, 16 May 2022 16:54:35 -0400 X-MC-Unique: MmZpWV5JPrq1WCu4DRdfeQ-1 Received: by mail-ed1-f70.google.com with SMTP id ay24-20020a056402203800b0042a96a76ba5so4445711edb.20 for ; Mon, 16 May 2022 13:54:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=6TBSwgl4erp1QVjV6hUdkH53hYVNMfCm5ztMd9UNMOM=; b=7CKMI5lccsG1bAUch/dvGasBbv9yBY+NnUBp4t9V8owHlEbCVlJ0WEfbbi6FE2rXUO z3xLeXfiKpmQF6V+xUeKlavmZnFJd9H3beFrd4B1qH4821rwutZbjYi69JgmUMtTtbxZ gwn9utRNWBIojOnaiZfY7cBcbZhYPxzDoPKoP/Ge7fjlI59ZFd2vyHIYoDWRTY0HjaOE r1YMh9ALltWPr/1MgiMwRDZbmWzwDzAtueUD1Fmr1LrEZS6cIls2OeTH03sLainHt1WJ RkO6+dyfzouqKiS+msGbDdNysg4sq4JkNO8d5K9Vd0pp3LDT35tnZmX0I6tOAfD1O1ky iDng== X-Gm-Message-State: AOAM53029TAv67VMJ2mNdYpg7busZDitTjGEdkujeciPNyfXHn78xcbz mX5hH6wk5nGQVBYNtNrR2HjWDpe7fmtvK0C/L6zv0WzZQriUKxGqCrXbOfdtfafsTuqjAicp3T6 YljcInYCPPmzVvQFgK+Yv5j/7lcIRnU/D2aC5xq230RrZZ2igpkX480PScOJr X-Received: by 2002:a17:907:1b1e:b0:6d7:31b0:e821 with SMTP id mp30-20020a1709071b1e00b006d731b0e821mr16994538ejc.334.1652734474374; Mon, 16 May 2022 13:54:34 -0700 (PDT) X-Received: by 2002:a17:907:1b1e:b0:6d7:31b0:e821 with SMTP id mp30-20020a1709071b1e00b006d731b0e821mr16994514ejc.334.1652734474062; Mon, 16 May 2022 13:54:34 -0700 (PDT) Received: from redhat.com ([2.55.131.38]) by smtp.gmail.com with ESMTPSA id a17-20020a50ff11000000b0042a2d9af0f8sm5689009edu.79.2022.05.16.13.54.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 13:54:33 -0700 (PDT) Date: Mon, 16 May 2022 16:54:30 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Jiang Liu Subject: [PULL v2 64/86] vhost-user.rst: add clarifying language about protocol negotiation Message-ID: <20220516204913.542894-65-mst@redhat.com> References: <20220516204913.542894-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220516204913.542894-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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée Make the language about feature negotiation explicitly clear about the handling of the VHOST_USER_F_PROTOCOL_FEATURES feature bit. Try and avoid the sort of bug introduced in vhost.rs REPLY_ACK processing: https://github.com/rust-vmm/vhost/pull/24 Signed-off-by: Alex Bennée Cc: Jiang Liu Message-Id: <20210226111619.21178-1-alex.bennee@linaro.org> Message-Id: <20220321153037.3622127-8-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- docs/interop/vhost-user.rst | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index 9159476678..73e710fe32 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -332,6 +332,18 @@ bit was dedicated for this purpose:: #define VHOST_USER_F_PROTOCOL_FEATURES 30 +Note that VHOST_USER_F_PROTOCOL_FEATURES is the UNUSED (30) feature +bit defined in `VIRTIO 1.1 6.3 Legacy Interface: Reserved Feature Bits +`_. +VIRTIO devices do not advertise this feature bit and therefore VIRTIO +drivers cannot negotiate it. + +This reserved feature bit was reused by the vhost-user protocol to add +vhost-user protocol feature negotiation in a backwards compatible +fashion. Old vhost-user master and slave implementations continue to +work even though they are not aware of vhost-user protocol feature +negotiation. + Ring states ----------- @@ -890,7 +902,8 @@ Front-end message types Get the protocol feature bitmask from the underlying vhost implementation. Only legal if feature bit ``VHOST_USER_F_PROTOCOL_FEATURES`` is present in - ``VHOST_USER_GET_FEATURES``. + ``VHOST_USER_GET_FEATURES``. It does not need to be acknowledged by + ``VHOST_USER_SET_FEATURES``. .. Note:: Back-ends that report ``VHOST_USER_F_PROTOCOL_FEATURES`` must @@ -906,7 +919,8 @@ Front-end message types Enable protocol features in the underlying vhost implementation. Only legal if feature bit ``VHOST_USER_F_PROTOCOL_FEATURES`` is present in - ``VHOST_USER_GET_FEATURES``. + ``VHOST_USER_GET_FEATURES``. It does not need to be acknowledged by + ``VHOST_USER_SET_FEATURES``. .. Note:: Back-ends that report ``VHOST_USER_F_PROTOCOL_FEATURES`` must support From patchwork Mon May 16 20:54: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: 572984 Delivered-To: patch@linaro.org Received: by 2002:a5d:5051:0:0:0:0:0 with SMTP id h17csp771358wrt; Mon, 16 May 2022 14:52:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHGXEU6h6koN2RW/mAeqqYDy3G1VVOi6sM3xnMAJBJSn+Zu0TIdmGEvzD2SSp3G6VcZK2Q X-Received: by 2002:a37:a497:0:b0:6a0:a704:b49b with SMTP id n145-20020a37a497000000b006a0a704b49bmr14167695qke.453.1652737931906; Mon, 16 May 2022 14:52:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652737931; cv=none; d=google.com; s=arc-20160816; b=QRmbcrPRcIJ0dIYyLXggR8CqlnqtgpV0BZdjAK0JqXyLpNRE4+EVsUamrPaPl15E1w e5p+CyJK2Fk8b/gXUtuCFF7r/PWP0OeOPjy9jUbS38LSuS/pqix5vURIwZDarL41RtCw XRajXEuuxT4DNio/YLGHioagFLf1+353gdfZkZJJ6oErrBHAOJoeyzjPZxC5SUI1+d2f 2dtPVxwfPXZp+0J898o0PFH7UZL/76rjMv7Cqg5Fe0Mfo8N72xBd6F/j6SjxGPi0ZB6h XMj4OvLQpUisVA5BhzNW7TWgcpvPoI95kzxtsuA1PBhwjooIx3B0Ur7hUpQzx4rP+Uik HKhA== 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=4TnV0DctF1mNLxRYwoqBR3FQ0Y0vcC373ju/Bs6KrI4=; b=TptDwv+uQi97o+EzZ6nsPqZWXRUI3FWLMJrsc+PFm5x8zfJQLxmwNHRIr6zh09KV69 tyxCvG41XjlZpEYepzwh68aFr9EusVtbwk+zBIyf4UXNA8pjD2vJa1ahw86hmoOmHtpl VKr4KaDBkPYWhEQxJlSI0zoWjIklfydiuf9hsxIh+tp8jJlC38s6bJPYzcbVLJVDr21n 6pb1FCPBwwq7HFVQh15pT1Q4e3VkBZcHY/kQMniKMaU0PgaffjWmjSYmP67UfNfw1tML ly0eWat/snMRuELKo7icBBStglrDFWQUWFyGx7l+2n/Y9xBq74vJ00KRQJZ5PmmyXRbn OHdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WbOW8g2P; 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 jo30-20020a056214501e00b004467b52294fsi6413502qvb.492.2022.05.16.14.52.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 May 2022 14:52:11 -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=WbOW8g2P; 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]:40216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqidP-0001ty-C4 for patch@linaro.org; Mon, 16 May 2022 17:52:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59424) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqhjn-00028F-EG for qemu-devel@nongnu.org; Mon, 16 May 2022 16:54:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:43024) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqhjl-0006nH-Px for qemu-devel@nongnu.org; Mon, 16 May 2022 16:54:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652734481; 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=4TnV0DctF1mNLxRYwoqBR3FQ0Y0vcC373ju/Bs6KrI4=; b=WbOW8g2P4l1DhF+eoFSKmk4fdXkXSLn8/C5ViIJvWY0jwRErhL34F9mREZAIPOUftXJkQn aIk2RRic5lJd6zy1N0asagZiE3JunsSCnkwkn6u9mhzd9uhEdj2nSuvMfb0YiK4I3X5x+F 8JPGV22oh+nfrJVFROnsF2+UGvJogQc= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-88-nrtLtnAoPeeCmLG_HKVUfA-1; Mon, 16 May 2022 16:54:40 -0400 X-MC-Unique: nrtLtnAoPeeCmLG_HKVUfA-1 Received: by mail-ed1-f70.google.com with SMTP id n12-20020aa7c44c000000b0042ab2159b3eso2544702edr.8 for ; Mon, 16 May 2022 13:54:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=4TnV0DctF1mNLxRYwoqBR3FQ0Y0vcC373ju/Bs6KrI4=; b=nVshTAWZJbPx145FkRnBV1tpPWy/D0vf5FATd6Vvwz+rKQKb2KYuyylS/m9Wm7AWf0 4TcvSogB1rCClros+3LWoCrZq+np2Mq3RcIXBz8wdS6NFfms3rLeG2NaSeyp3WZM410h fR3+84hGQsyzzN19S/knB4Ft+Qiyhm9vGizNS5TuOTy/bz1pB/5v3JdeJagd+caMTaHU Ep0zTxi1clqsLqX4u2799GPOqubcUYQlz76xu4OF7PsJBKFtQ8pMCLWqkjvPLkKTZR0Z ak6+kqXF6t7at7VHrwr/B+uurAyUOiK6zvfxjwrQj3n6NNAsl+4Ng+ACkScnunwkAosG 4aTg== X-Gm-Message-State: AOAM532F33XQT/w5miGxnJkw2Xy2+bUyKOSWzeQgrnvFo55NP3G9O+so uh7zIqX5qNvplUGM2obNjglQS9Qnt4Oz98knzUVQFCbTQSINThIFdiTOYNG7EbWr4clnrbB8zeS ApaORnVVdFpkUiAUTkmmG/F7ViBIqeJYfM1pcAp18Q6YPDbxXRMgLO2QOnwl5 X-Received: by 2002:a17:906:c114:b0:6f5:db6f:71a1 with SMTP id do20-20020a170906c11400b006f5db6f71a1mr16617445ejc.338.1652734478576; Mon, 16 May 2022 13:54:38 -0700 (PDT) X-Received: by 2002:a17:906:c114:b0:6f5:db6f:71a1 with SMTP id do20-20020a170906c11400b006f5db6f71a1mr16617429ejc.338.1652734478346; Mon, 16 May 2022 13:54:38 -0700 (PDT) Received: from redhat.com ([2.55.131.38]) by smtp.gmail.com with ESMTPSA id gh24-20020a170906e09800b006f3ef214dc4sm178228ejb.42.2022.05.16.13.54.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 13:54:37 -0700 (PDT) Date: Mon, 16 May 2022 16:54:34 -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?= , Raphael Norwitz , David Hildenbrand , Kevin Wolf , Stefan Hajnoczi Subject: [PULL v2 65/86] libvhost-user: expose vu_request_to_string Message-ID: <20220516204913.542894-66-mst@redhat.com> References: <20220516204913.542894-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220516204913.542894-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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée This is useful for more human readable debug messages in vhost-user programs. Signed-off-by: Alex Bennée Message-Id: <20220321153037.3622127-9-alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- subprojects/libvhost-user/libvhost-user.h | 9 +++++++++ subprojects/libvhost-user/libvhost-user.c | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/subprojects/libvhost-user/libvhost-user.h b/subprojects/libvhost-user/libvhost-user.h index cde9f07bb3..aea7ec5061 100644 --- a/subprojects/libvhost-user/libvhost-user.h +++ b/subprojects/libvhost-user/libvhost-user.h @@ -473,6 +473,15 @@ bool vu_init(VuDev *dev, */ void vu_deinit(VuDev *dev); + +/** + * vu_request_to_string: return string for vhost message request + * @req: VhostUserMsg request + * + * Returns a const string, do not free. + */ +const char *vu_request_to_string(unsigned int req); + /** * vu_dispatch: * @dev: a VuDev context diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvhost-user/libvhost-user.c index d0041c864b..b4cc3c2d68 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -99,7 +99,7 @@ static inline bool vu_has_protocol_feature(VuDev *dev, unsigned int fbit) return has_feature(dev->protocol_features, fbit); } -static const char * +const char * vu_request_to_string(unsigned int req) { #define REQ(req) [req] = #req From patchwork Mon May 16 20:54: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: 572981 Delivered-To: patch@linaro.org Received: by 2002:a5d:5051:0:0:0:0:0 with SMTP id h17csp769272wrt; Mon, 16 May 2022 14:46:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLniEmxHUCOZNkDfxuqCIPUyJ7ULWnNeCWCMYOU6dSfrfV9u+35W0p73a0XXVsAVnO8+3B X-Received: by 2002:a05:620a:1249:b0:6a0:e2d3:d5c9 with SMTP id a9-20020a05620a124900b006a0e2d3d5c9mr13359742qkl.210.1652737615536; Mon, 16 May 2022 14:46:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652737615; cv=none; d=google.com; s=arc-20160816; b=JTCGlbX/ANVpNnJ5hvFmCPePA44B0P59owUtJBJLLf3v3F9srCkhAYpGwoFozUOFok uv+y2acrNID0squo16/2WvmoORFAMZyhoUHduDESBmmxjuFZL2OugBTb3F8V7oslZTg5 bneo7fe4JIDVpKk2s4gediq+yrH1zsxih7hkG9/w3Fc9sKtq25W1tcL9PLGNk54zue5e Hd7MDWrhfAN2botjDpEvANejxr8fZCyilD85kBL8MlsCc/znOS2znfTDBZL7cqXv8DcD vn13KjRDlCT4QqrROWR+1e1igqCYienZ1U9ZXdO2L2oZA+kfSig5TRgKnZe2MTAQo9rr +01g== 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=c9w3iT2kzWZXwmqWDUx+rSUtwr5cBul7vws3lLdpQ2Y=; b=fp1QnkrJKmioiadwxHkYCfdQhBHsP0gEN7eOetl820q956JNgUHDrcSxxYqTpnEZ9j yMKyXY2qrv6k3UUm+KNhTkBp/19aEj4NM7BLMniceP1xtb93tEhoJpcMZfBu8A4GGjMo OgXY9GNCyKs/lO0lCgJYwWPvwk3WQqgVQsve5D6WK+0+bGwyTz5ogeRazGZwKRN63FeV +LbxA5Y5VS99IBK1TL65rdJRnruaxdeUFlqU6TA1hnmrAjlV1s+LyHBZp8v+IlzfBQi8 Wlzh1SNylrYQAyOS0oH0OS20p+Ou9skwwIGVSJ+6i6vLQcRSHnaHDRNPWNbl0WbKB982 M6/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WK2dV2K+; 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 jk10-20020ad45d4a000000b00461c1f70137si3559688qvb.309.2022.05.16.14.46.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 May 2022 14:46:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WK2dV2K+; 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]:51534 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqiYJ-0007Ci-0h for patch@linaro.org; Mon, 16 May 2022 17:46:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqhjt-0002Ju-7A for qemu-devel@nongnu.org; Mon, 16 May 2022 16:54:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55513) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqhjr-0006nY-6D for qemu-devel@nongnu.org; Mon, 16 May 2022 16:54:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652734486; 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=c9w3iT2kzWZXwmqWDUx+rSUtwr5cBul7vws3lLdpQ2Y=; b=WK2dV2K+NEJIeNOZzAuSQVn/YC2VOHlph8drKay1mo52U4KWci0aMxjBx5Sld94WcH94eL oUj2kHXLJxm3BVNm0V0WpEyFl5RpB9u23tMlXnjCFsS++W0zWZ+GN8F62lNLTRv/FDHWrS g117OadMp9uCa/C9KIsZ0Gs6/gJucLk= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-502-Yk6fC7aAN86pk5brTk44MQ-1; Mon, 16 May 2022 16:54:45 -0400 X-MC-Unique: Yk6fC7aAN86pk5brTk44MQ-1 Received: by mail-ed1-f71.google.com with SMTP id l18-20020aa7d952000000b0042ab7be9adaso1913337eds.21 for ; Mon, 16 May 2022 13:54:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=c9w3iT2kzWZXwmqWDUx+rSUtwr5cBul7vws3lLdpQ2Y=; b=6f64p12gbn5TgxW99nc3YvhT8LXFgkYwdjblQY+TDIH4og4Q3C4w4BSEKg+grN3srK UL4XmT7cyDwaxooPFeX+AgdaEHbhFrYvCys6YnN2QuqGE2E/IPedwgQsg4pN8ggTb8Ki LK5B9WkBgSdBtr/Q6STHDp1s1Nu7oSGPq+aLc3plbK8qEq8Y+3vRyiLjOoolasPTsWSm DW4ZhX8ti5x7olW1ZQkb4+6xr6zQWEaaMCqP+6CHIYkO86uHtJi748cgFc0GQOPpdYsF KGS6TLRfjOnvE8lWj0fw8mbdSzYhlffebaEwQZXsze5nLYkE7OE3DdgGa8R9vQ/XFlj7 /bhg== X-Gm-Message-State: AOAM533r1elYzQqgVe8d72ZYLMJ2q1nzaT9Ljt9pFl/7j4eiy8I952+2 Wlr95YZkmtR3rznVm0QYbO0m+81SvxkPVwJsUub3DsO1L22YZg/Bz3OuaACEbM76Z7wgpmUlldK 3mx6+u79zwz4vUmJTXCUr8wgEsJGUm5oj7+s9ngmcmnhBUKOKDepr8GLEdT/G X-Received: by 2002:a17:907:6e18:b0:6fe:324a:65c1 with SMTP id sd24-20020a1709076e1800b006fe324a65c1mr6989743ejc.368.1652734483850; Mon, 16 May 2022 13:54:43 -0700 (PDT) X-Received: by 2002:a17:907:6e18:b0:6fe:324a:65c1 with SMTP id sd24-20020a1709076e1800b006fe324a65c1mr6989719ejc.368.1652734483538; Mon, 16 May 2022 13:54:43 -0700 (PDT) Received: from redhat.com ([2.55.131.38]) by smtp.gmail.com with ESMTPSA id t20-20020a056402525400b0042617ba63ccsm5916311edd.86.2022.05.16.13.54.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 13:54:43 -0700 (PDT) Date: Mon, 16 May 2022 16:54:38 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Stefan Hajnoczi , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9?= Lureau , Viresh Kumar , Mathieu Poirier , "Dr . David Alan Gilbert" , Kashyap Chamarthy , Richard Henderson Subject: [PULL v2 66/86] docs/devel: start documenting writing VirtIO devices Message-ID: <20220516204913.542894-67-mst@redhat.com> References: <20220516204913.542894-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220516204913.542894-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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée While writing my own VirtIO devices I've gotten confused with how things are structured and what sort of shared infrastructure there is. If we can document how everything is supposed to work we can then maybe start cleaning up inconsistencies in the code. Signed-off-by: Alex Bennée Cc: Stefan Hajnoczi Cc: "Michael S. Tsirkin" Cc: Gerd Hoffmann Cc: Marc-André Lureau Cc: Viresh Kumar Cc: Mathieu Poirier Cc: Dr. David Alan Gilbert Message-Id: <20220309164929.19395-1-alex.bennee@linaro.org> Message-Id: <20220321153037.3622127-10-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- docs/devel/index-internals.rst | 1 + docs/devel/virtio-backends.rst | 214 +++++++++++++++++++++++++++++++++ 2 files changed, 215 insertions(+) create mode 100644 docs/devel/virtio-backends.rst diff --git a/docs/devel/index-internals.rst b/docs/devel/index-internals.rst index a50889c556..e1a93df263 100644 --- a/docs/devel/index-internals.rst +++ b/docs/devel/index-internals.rst @@ -18,3 +18,4 @@ Details about QEMU's various subsystems including how to add features to them. tracing vfio-migration writing-monitor-commands + virtio-backends diff --git a/docs/devel/virtio-backends.rst b/docs/devel/virtio-backends.rst new file mode 100644 index 0000000000..9ff092e7a0 --- /dev/null +++ b/docs/devel/virtio-backends.rst @@ -0,0 +1,214 @@ +.. + Copyright (c) 2022, Linaro Limited + Written by Alex Bennée + +Writing VirtIO backends for QEMU +================================ + +This document attempts to outline the information a developer needs to +know to write device emulations in QEMU. It is specifically focused on +implementing VirtIO devices. For VirtIO the frontend is the driver +running on the guest. The backend is the everything that QEMU needs to +do to handle the emulation of the VirtIO device. This can be done +entirely in QEMU, divided between QEMU and the kernel (vhost) or +handled by a separate process which is configured by QEMU +(vhost-user). + +VirtIO Transports +----------------- + +VirtIO supports a number of different transports. While the details of +the configuration and operation of the device will generally be the +same QEMU represents them as different devices depending on the +transport they use. For example -device virtio-foo represents the foo +device using mmio and -device virtio-foo-pci is the same class of +device using the PCI transport. + +Using the QEMU Object Model (QOM) +--------------------------------- + +Generally all devices in QEMU are super classes of ``TYPE_DEVICE`` +however VirtIO devices should be based on ``TYPE_VIRTIO_DEVICE`` which +itself is derived from the base class. For example: + +.. code:: c + + static const TypeInfo virtio_blk_info = { + .name = TYPE_VIRTIO_BLK, + .parent = TYPE_VIRTIO_DEVICE, + .instance_size = sizeof(VirtIOBlock), + .instance_init = virtio_blk_instance_init, + .class_init = virtio_blk_class_init, + }; + +The author may decide to have a more expansive class hierarchy to +support multiple device types. For example the Virtio GPU device: + +.. code:: c + + static const TypeInfo virtio_gpu_base_info = { + .name = TYPE_VIRTIO_GPU_BASE, + .parent = TYPE_VIRTIO_DEVICE, + .instance_size = sizeof(VirtIOGPUBase), + .class_size = sizeof(VirtIOGPUBaseClass), + .class_init = virtio_gpu_base_class_init, + .abstract = true + }; + + static const TypeInfo vhost_user_gpu_info = { + .name = TYPE_VHOST_USER_GPU, + .parent = TYPE_VIRTIO_GPU_BASE, + .instance_size = sizeof(VhostUserGPU), + .instance_init = vhost_user_gpu_instance_init, + .instance_finalize = vhost_user_gpu_instance_finalize, + .class_init = vhost_user_gpu_class_init, + }; + + static const TypeInfo virtio_gpu_info = { + .name = TYPE_VIRTIO_GPU, + .parent = TYPE_VIRTIO_GPU_BASE, + .instance_size = sizeof(VirtIOGPU), + .class_size = sizeof(VirtIOGPUClass), + .class_init = virtio_gpu_class_init, + }; + +defines a base class for the VirtIO GPU and then specialises two +versions, one for the internal implementation and the other for the +vhost-user version. + +VirtIOPCIProxy +^^^^^^^^^^^^^^ + +[AJB: the following is supposition and welcomes more informed +opinions] + +Probably due to legacy from the pre-QOM days PCI VirtIO devices don't +follow the normal hierarchy. Instead the a standalone object is based +on the VirtIOPCIProxy class and the specific VirtIO instance is +manually instantiated: + +.. code:: c + + /* + * virtio-blk-pci: This extends VirtioPCIProxy. + */ + #define TYPE_VIRTIO_BLK_PCI "virtio-blk-pci-base" + DECLARE_INSTANCE_CHECKER(VirtIOBlkPCI, VIRTIO_BLK_PCI, + TYPE_VIRTIO_BLK_PCI) + + struct VirtIOBlkPCI { + VirtIOPCIProxy parent_obj; + VirtIOBlock vdev; + }; + + static Property virtio_blk_pci_properties[] = { + DEFINE_PROP_UINT32("class", VirtIOPCIProxy, class_code, 0), + DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags, + VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true), + DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, + DEV_NVECTORS_UNSPECIFIED), + DEFINE_PROP_END_OF_LIST(), + }; + + static void virtio_blk_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) + { + VirtIOBlkPCI *dev = VIRTIO_BLK_PCI(vpci_dev); + DeviceState *vdev = DEVICE(&dev->vdev); + + ... + + qdev_realize(vdev, BUS(&vpci_dev->bus), errp); + } + + static void virtio_blk_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); + + set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); + device_class_set_props(dc, virtio_blk_pci_properties); + k->realize = virtio_blk_pci_realize; + pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET; + pcidev_k->device_id = PCI_DEVICE_ID_VIRTIO_BLOCK; + pcidev_k->revision = VIRTIO_PCI_ABI_VERSION; + pcidev_k->class_id = PCI_CLASS_STORAGE_SCSI; + } + + static void virtio_blk_pci_instance_init(Object *obj) + { + VirtIOBlkPCI *dev = VIRTIO_BLK_PCI(obj); + + virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), + TYPE_VIRTIO_BLK); + object_property_add_alias(obj, "bootindex", OBJECT(&dev->vdev), + "bootindex"); + } + + static const VirtioPCIDeviceTypeInfo virtio_blk_pci_info = { + .base_name = TYPE_VIRTIO_BLK_PCI, + .generic_name = "virtio-blk-pci", + .transitional_name = "virtio-blk-pci-transitional", + .non_transitional_name = "virtio-blk-pci-non-transitional", + .instance_size = sizeof(VirtIOBlkPCI), + .instance_init = virtio_blk_pci_instance_init, + .class_init = virtio_blk_pci_class_init, + }; + +Here you can see the instance_init has to manually instantiate the +underlying ``TYPE_VIRTIO_BLOCK`` object and link an alias for one of +it's properties to the PCI device. + + +Back End Implementations +------------------------ + +There are a number of places where the implementation of the backend +can be done: + +* in QEMU itself +* in the host kernel (a.k.a vhost) +* in a separate process (a.k.a. vhost-user) + +vhost_ops vs TYPE_VHOST_USER_BACKEND +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +There are two choices to how to implement vhost code. Most of the code +which has to work with either vhost or vhost-user uses +``vhost_dev_init()`` to instantiate the appropriate backend. This +means including a ``struct vhost_dev`` in the main object structure. + +For vhost-user devices you also need to add code to track the +initialisation of the ``chardev`` device used for the control socket +between QEMU and the external vhost-user process. + +If you only need to implement a vhost-user backed the other option is +a use a QOM-ified version of vhost-user. + +.. code:: c + + static void + vhost_user_gpu_instance_init(Object *obj) + { + VhostUserGPU *g = VHOST_USER_GPU(obj); + + g->vhost = VHOST_USER_BACKEND(object_new(TYPE_VHOST_USER_BACKEND)); + object_property_add_alias(obj, "chardev", + OBJECT(g->vhost), "chardev"); + } + + static const TypeInfo vhost_user_gpu_info = { + .name = TYPE_VHOST_USER_GPU, + .parent = TYPE_VIRTIO_GPU_BASE, + .instance_size = sizeof(VhostUserGPU), + .instance_init = vhost_user_gpu_instance_init, + .instance_finalize = vhost_user_gpu_instance_finalize, + .class_init = vhost_user_gpu_class_init, + }; + +Using it this way entails adding a ``struct VhostUserBackend`` to your +core object structure and manually instantiating the backend. This +sub-structure tracks both the ``vhost_dev`` and ``CharDev`` types +needed for the connection. Instead of calling ``vhost_dev_init`` you +would call ``vhost_user_backend_dev_init`` which does what is needed +on your behalf. From patchwork Mon May 16 20:54: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: 572986 Delivered-To: patch@linaro.org Received: by 2002:a5d:5051:0:0:0:0:0 with SMTP id h17csp772269wrt; Mon, 16 May 2022 14:54:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyevqmzQlWPiLLo6fDtJzTHG8bCJCt97r3cMHkSWxCGNv/yRACD9FJrUjo7A7bN+fU5p8xi X-Received: by 2002:a37:9bcb:0:b0:69f:f3a7:4cab with SMTP id d194-20020a379bcb000000b0069ff3a74cabmr13837757qke.457.1652738091565; Mon, 16 May 2022 14:54:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652738091; cv=none; d=google.com; s=arc-20160816; b=Gic73YlQRx+oOc2zTx5gD3QPxxWf/U7cgepz+TQJ3LjTjSIyBDHs+HJ5X49CYO96Dk VIGlvR2euSXykEPVp177MpW8jq5uy0NjBIcVYFAlG18oTxS3rx/m3F1w1aP+RM7MmqrX eVsGSEn0AMJA3QjzPcbDRx1ASiQ3hy5hbHk2RauGakJoBw+sqqk4HhJIr0QDuS+tSVQ7 Y1bbwfEWdjeeq7VALBzdAcOSBlxV6t1BX+h8zPs5Ehf1D3TI3beMyIYGrWaRsU/ndNRA OnlK+iMnMlM/F9GvpwAQEu51R/nzqraJevOKVFpTKMvmxSTsxEKFmwhq+l/fEV/UYsT7 6ksQ== 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=B1nDZq61p1Fo9R+kfzgjGxckxAqyZiNflr6I94N0EOM=; b=rm+56/bbthqdtsjYz14zhKMRaoVGsck0Yivxgd8DwSQgD9s6e0zzomXrlpfDoa6u54 inpn7uh4SKukSRylF7a8jwyGDxRkpmUn2g0r57uSx02ClQtejQ8l9+bLHv0qFXjUgSER cZdRXe8Aj2dSB8VNgdq7BfO0YX45Z+WhNtJpGTOdQ60x/P7YfEuBK+2uwGvBe5u5YR9X toRWD3hCprPwKc/3A3ypE5UC4fiNooZKbuwd+fACj+1MwjhtnoXtpYA2Yt9a1uwidzAx JtWVWKQnUV+qO9AF7GgOW8Cc0gMa3tTbcTd94ikwcKFwz3ZEerK6uvma8jSN81/TfWEr Oa9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AwoHqTHo; 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 f129-20020a379c87000000b0069eea440dd9si5897342qke.396.2022.05.16.14.54.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 May 2022 14:54:51 -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=AwoHqTHo; 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]:48868 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqifz-0007lT-22 for patch@linaro.org; Mon, 16 May 2022 17:54:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59484) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqhjx-0002Vq-Bc for qemu-devel@nongnu.org; Mon, 16 May 2022 16:54:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:39930) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqhjv-0006nt-CO for qemu-devel@nongnu.org; Mon, 16 May 2022 16:54:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652734490; 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=B1nDZq61p1Fo9R+kfzgjGxckxAqyZiNflr6I94N0EOM=; b=AwoHqTHorB/5Aym+rTZl/H1iv7c9OrSTXWpRT3Ab7drHk+/JtNAJQPL9u+Mu4IQXZGL07/ w8BD4IEm9KslaJKH6yRY2zlT8MF630AKfFSjfu225iFKhtj17gxhit/XSB7PWh9LF12gem aUEhMl8+uROYPscCryUeDpaNEO4SXrM= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-617-ZpdjXfILO762nEEu52t6Bg-1; Mon, 16 May 2022 16:54:49 -0400 X-MC-Unique: ZpdjXfILO762nEEu52t6Bg-1 Received: by mail-ed1-f71.google.com with SMTP id s9-20020aa7c549000000b0042ab6ab62f0so2002781edr.14 for ; Mon, 16 May 2022 13:54:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=B1nDZq61p1Fo9R+kfzgjGxckxAqyZiNflr6I94N0EOM=; b=YEcmfH9Q2BbVs9XEk7empvG0tvuo/IZXv/QWwdk29B7pCenuqsyEhilcEMS4lNdb0S YdtyoGgCSRJPYPN6EV4YBHjszrEL7iYTE+ycXOLN0C+enlNvA5HSPKKz8BueSaSMnUSZ +7OtBhm4HJBk7lZr+MeEqmNb/Hsprs84mOTVKuJZCZ5LEEt5feONgFR/Xqf82vqCrkXt P5sXZ1JlGEM5NaRcwVfgHq0Fwkc8yXMgzuTk3m1FFLYD/ciwZRVie8GG5/imncCxiiQv e2cyldJlPjjHZG/eYdaxLB3eMu22mov6g1E18ygoVuDgG9BWsU1Wg2mU9z1/ViXM3fX1 FqRA== X-Gm-Message-State: AOAM530iMaAFkNTswXwDz7AYcjVs2hQi4Z4JNzY5Kn4UdQOEvHpEKmYQ xP9FyoDg1Bnm+jKJusXGaV2jhG4phknGY4sAkI2QRp0EBTb9NyWU23tD0ohesbWx07DHNpRoi5L aLYzCupnw8bh7IjEPNrjuU0vfh2wvh12vlS0kEFZndzo+nwxuObPER2JSoWff X-Received: by 2002:a17:907:7f1a:b0:6f4:6b52:adfd with SMTP id qf26-20020a1709077f1a00b006f46b52adfdmr16976513ejc.203.1652734487882; Mon, 16 May 2022 13:54:47 -0700 (PDT) X-Received: by 2002:a17:907:7f1a:b0:6f4:6b52:adfd with SMTP id qf26-20020a1709077f1a00b006f46b52adfdmr16976500ejc.203.1652734487640; Mon, 16 May 2022 13:54:47 -0700 (PDT) Received: from redhat.com ([2.55.131.38]) by smtp.gmail.com with ESMTPSA id r14-20020aa7cb8e000000b0042a9d52d811sm3872520edt.75.2022.05.16.13.54.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 13:54:47 -0700 (PDT) Date: Mon, 16 May 2022 16:54:43 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9?= Lureau Subject: [PULL v2 67/86] include/hw: start documenting the vhost API Message-ID: <20220516204913.542894-68-mst@redhat.com> References: <20220516204913.542894-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220516204913.542894-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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée While trying to get my head around the nest of interactions for vhost devices I though I could start by documenting the key API functions. This patch documents the main API hooks for creating and starting a vhost device as well as how the configuration changes are handled. Signed-off-by: Alex Bennée Cc: Michael S. Tsirkin Cc: Stefan Hajnoczi Cc: Marc-André Lureau Message-Id: <20220321153037.3622127-11-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost.h | 132 +++++++++++++++++++++++++++++++++++--- 1 file changed, 122 insertions(+), 10 deletions(-) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 58a73e7b7a..b291fe4e24 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -61,6 +61,12 @@ typedef struct VhostDevConfigOps { } VhostDevConfigOps; struct vhost_memory; + +/** + * struct vhost_dev - common vhost_dev structure + * @vhost_ops: backend specific ops + * @config_ops: ops for config changes (see @vhost_dev_set_config_notifier) + */ struct vhost_dev { VirtIODevice *vdev; MemoryListener memory_listener; @@ -108,15 +114,129 @@ struct vhost_net { NetClientState *nc; }; +/** + * vhost_dev_init() - initialise the vhost interface + * @hdev: the common vhost_dev structure + * @opaque: opaque ptr passed to backend (vhost/vhost-user/vdpa) + * @backend_type: type of backend + * @busyloop_timeout: timeout for polling virtqueue + * @errp: error handle + * + * The initialisation of the vhost device will trigger the + * initialisation of the backend and potentially capability + * negotiation of backend interface. Configuration of the VirtIO + * itself won't happen until the interface is started. + * + * Return: 0 on success, non-zero on error while setting errp. + */ int vhost_dev_init(struct vhost_dev *hdev, void *opaque, VhostBackendType backend_type, uint32_t busyloop_timeout, Error **errp); + +/** + * vhost_dev_cleanup() - tear down and cleanup vhost interface + * @hdev: the common vhost_dev structure + */ void vhost_dev_cleanup(struct vhost_dev *hdev); -int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev); -void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev); + +/** + * vhost_dev_enable_notifiers() - enable event notifiers + * @hdev: common vhost_dev structure + * @vdev: the VirtIODevice structure + * + * Enable notifications directly to the vhost device rather than being + * triggered by QEMU itself. Notifications should be enabled before + * the vhost device is started via @vhost_dev_start. + * + * Return: 0 on success, < 0 on error. + */ int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev); + +/** + * vhost_dev_disable_notifiers - disable event notifications + * @hdev: common vhost_dev structure + * @vdev: the VirtIODevice structure + * + * Disable direct notifications to vhost device. + */ void vhost_dev_disable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev); +/** + * vhost_dev_start() - start the vhost device + * @hdev: common vhost_dev structure + * @vdev: the VirtIODevice structure + * + * Starts the vhost device. From this point VirtIO feature negotiation + * can start and the device can start processing VirtIO transactions. + * + * Return: 0 on success, < 0 on error. + */ +int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev); + +/** + * vhost_dev_stop() - stop the vhost device + * @hdev: common vhost_dev structure + * @vdev: the VirtIODevice structure + * + * Stop the vhost device. After the device is stopped the notifiers + * can be disabled (@vhost_dev_disable_notifiers) and the device can + * be torn down (@vhost_dev_cleanup). + */ +void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev); + +/** + * DOC: vhost device configuration handling + * + * The VirtIO device configuration space is used for rarely changing + * or initialisation time parameters. The configuration can be updated + * by either the guest driver or the device itself. If the device can + * change the configuration over time the vhost handler should + * register a @VhostDevConfigOps structure with + * @vhost_dev_set_config_notifier so the guest can be notified. Some + * devices register a handler anyway and will signal an error if an + * unexpected config change happens. + */ + +/** + * vhost_dev_get_config() - fetch device configuration + * @hdev: common vhost_dev_structure + * @config: pointer to device appropriate config structure + * @config_len: size of device appropriate config structure + * + * Return: 0 on success, < 0 on error while setting errp + */ +int vhost_dev_get_config(struct vhost_dev *hdev, uint8_t *config, + uint32_t config_len, Error **errp); + +/** + * vhost_dev_set_config() - set device configuration + * @hdev: common vhost_dev_structure + * @data: pointer to data to set + * @offset: offset into configuration space + * @size: length of set + * @flags: @VhostSetConfigType flags + * + * By use of @offset/@size a subset of the configuration space can be + * written to. The @flags are used to indicate if it is a normal + * transaction or related to migration. + * + * Return: 0 on success, non-zero on error + */ +int vhost_dev_set_config(struct vhost_dev *dev, const uint8_t *data, + uint32_t offset, uint32_t size, uint32_t flags); + +/** + * vhost_dev_set_config_notifier() - register VhostDevConfigOps + * @hdev: common vhost_dev_structure + * @ops: notifier ops + * + * If the device is expected to change configuration a notifier can be + * setup to handle the case. + */ +void vhost_dev_set_config_notifier(struct vhost_dev *dev, + const VhostDevConfigOps *ops); + + /* Test and clear masked event pending status. * Should be called after unmask to avoid losing events. */ @@ -136,14 +256,6 @@ int vhost_net_set_backend(struct vhost_dev *hdev, struct vhost_vring_file *file); int vhost_device_iotlb_miss(struct vhost_dev *dev, uint64_t iova, int write); -int vhost_dev_get_config(struct vhost_dev *hdev, uint8_t *config, - uint32_t config_len, Error **errp); -int vhost_dev_set_config(struct vhost_dev *dev, const uint8_t *data, - uint32_t offset, uint32_t size, uint32_t flags); -/* notifier callback in case vhost device config space changed - */ -void vhost_dev_set_config_notifier(struct vhost_dev *dev, - const VhostDevConfigOps *ops); void vhost_dev_reset_inflight(struct vhost_inflight *inflight); void vhost_dev_free_inflight(struct vhost_inflight *inflight); From patchwork Mon May 16 20:54:48 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: 572983 Delivered-To: patch@linaro.org Received: by 2002:a5d:5051:0:0:0:0:0 with SMTP id h17csp770219wrt; Mon, 16 May 2022 14:49:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzibUVEg7fUkGuwwJfqFhAYxHAp2zKQAVqBf4+iXv/byuzscGi0ExIteBSfQJfpXdWpav8h X-Received: by 2002:ad4:5c8f:0:b0:456:3dbf:f58e with SMTP id o15-20020ad45c8f000000b004563dbff58emr17342790qvh.37.1652737751560; Mon, 16 May 2022 14:49:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652737751; cv=none; d=google.com; s=arc-20160816; b=B+xQIPtecpoALr2zdVGdjnnuEaeud+9lHGs2wBqgEHNFiWo/pI79lG04RY74JrYD2i 2fLzMvPADzDh5Zv3g6E8aMY8fRAyt8TlmlPG6W1LW3Hu1luwP/nWOU1fdPXKbtEgR78P fTPDVt4/uPYrRNO+tQ/AFzn6y/KHvnJB6e8ng8JamXpDOwRPR2vTLjH2ZW1yg8htGw8f +97B5voghOoP4JnVBO7KilbgXJAlr6+2hsAG6kfCne+iKrzjql4MvnnTunVagUmvGYZP WonX7GevIzzmTaOC0BOm7O+wNJmLuOs2NvwY+pdCDdH82PnwYXDwwTKmgZY9RH7nQcol WjuA== 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=8fsb11g7Z/r9felQ/mYfcCmnlXTX8/HfVlLGPmxAWLE=; b=f1Rs+WIz0BUiiGF1lobAUeWFrBGNG3VheHntgUn4LytyxqG/3rNhn0EJV9/U33RRT+ AxA4u47CNBNYlvphP/iGM+k1Iir/R4oFdKIkDWnJE0K3Khyat1E4JifVSZTiHO3QlAOW DPZUmicjmnZxwUEtPuKQTBG2mYMoteIaKmIk+qSg2dUD/+mzpTv86tKWvqxYxqHNLZ68 zzwop1Fvjz5r7Rkd4Cyh7JQ6Ae7b5khCV9tzECJ8WWIpBqQzoAGqma9gZ9VMdCpIWqtZ K3TmenNV+qRM2z6C9JmuswLvGkdWC+myAaa10m74RL13r8MhYj7O709oxDKI1AuuiI7B 4CXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aSEu8RnK; 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 o19-20020a05620a2a1300b0069ed3969d54si7596615qkp.681.2022.05.16.14.49.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 May 2022 14:49:11 -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=aSEu8RnK; 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]:60252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqiaV-0004l6-3A for patch@linaro.org; Mon, 16 May 2022 17:49:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59510) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqhk1-0002kR-GQ for qemu-devel@nongnu.org; Mon, 16 May 2022 16:54:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47279) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqhjz-0006oQ-OA for qemu-devel@nongnu.org; Mon, 16 May 2022 16:54:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652734495; 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=8fsb11g7Z/r9felQ/mYfcCmnlXTX8/HfVlLGPmxAWLE=; b=aSEu8RnKxr4RCLkXO8InHXtzTJ9evxXC6hljl0ZnloBhCwZMEEGskqUzreXLqht2NY+VW+ BF40QOQl1SWL2ZqmN1zJ45CVXyTu9BkcCGDVGkQUccnCJqniJ0GIzPhCCAQoSZL5HnGMDX YdIIArKhp20xDxf6c+ZfpBD+x5QPRjM= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-370-OgqDE45LPxG35v9rLO6MSA-1; Mon, 16 May 2022 16:54:54 -0400 X-MC-Unique: OgqDE45LPxG35v9rLO6MSA-1 Received: by mail-ed1-f69.google.com with SMTP id c17-20020a056402159100b0042ab2e56743so2405426edv.10 for ; Mon, 16 May 2022 13:54:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=8fsb11g7Z/r9felQ/mYfcCmnlXTX8/HfVlLGPmxAWLE=; b=PPb7TOGvQJg8dgUDKMamXuEU5+jL2hd2Tjwzo8zd0/nc2r31LQkdJGPg2tbUWlOpON OKqOi4nPw+w0OUKv2w8ZMKkGK4RiiYxeB5xFil8JuE7wNUmJAiX7DXohqMjIzuNqitJ8 r5n3McnNgnjZtrO3ukynZS8zGZgrP1pbw+kuVo9UT1WHa/MtT3zJFBGyzFmKD4daXXz8 Nczl++4g8qkoUBZRkaqmpjwVJTjTvoZRzy+mWebO0Zzx8NbUVAFEIIYruzuxCcUJQflw /TNvdzNCndL8O9A8KKSxyOvrdoEph2qmNj7cIUkmn2lWQe1KrEoSceiHAAvB8Lx1rMYg Jyiw== X-Gm-Message-State: AOAM530WpycsjewBklkYTXzwmcpUjn/g9BY8pv0FHbdffz1QWgu9Za8I dDlURhqR2+nXxpdeDAiWIhew0lXWgyFWMkbVRHc1eMu/abbExYC4S0niOQB5pXXzhzum14pm0nZ 7VKm1gPb/JS8CQAhyJDb/CWDhNE64BLCmneAhZPXuxYe0TFEt/QZh/V/GE8cE X-Received: by 2002:a05:6402:4492:b0:428:a206:8912 with SMTP id er18-20020a056402449200b00428a2068912mr15349121edb.279.1652734492631; Mon, 16 May 2022 13:54:52 -0700 (PDT) X-Received: by 2002:a05:6402:4492:b0:428:a206:8912 with SMTP id er18-20020a056402449200b00428a2068912mr15349091edb.279.1652734492377; Mon, 16 May 2022 13:54:52 -0700 (PDT) Received: from redhat.com ([2.55.131.38]) by smtp.gmail.com with ESMTPSA id u2-20020aa7db82000000b0042617ba63a7sm5714415edt.49.2022.05.16.13.54.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 13:54:51 -0700 (PDT) Date: Mon, 16 May 2022 16:54:48 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Maxime Coquelin , Stefan Hajnoczi , Raphael Norwitz , Paolo Bonzini , Fam Zheng Subject: [PULL v2 68/86] hw/virtio/vhost-user: don't suppress F_CONFIG when supported Message-ID: <20220516204913.542894-69-mst@redhat.com> References: <20220516204913.542894-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220516204913.542894-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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée Previously we would silently suppress VHOST_USER_PROTOCOL_F_CONFIG during the protocol negotiation if the QEMU stub hadn't implemented the vhost_dev_config_notifier. However this isn't the only way we can handle config messages, the existing vdc->get/set_config can do this as well. Lightly re-factor the code to check for both potential methods and instead of silently squashing the feature error out. It is unlikely that a vhost-user backend expecting to handle CONFIG messages will behave correctly if they never get sent. Fixes: 1c3e5a2617 ("vhost-user: back SET/GET_CONFIG requests with a protocol feature") Cc: Maxime Coquelin Cc: Michael S. Tsirkin Cc: Stefan Hajnoczi Signed-off-by: Alex Bennée Message-Id: <20220321153037.3622127-13-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-user.h | 1 + hw/scsi/vhost-user-scsi.c | 1 + hw/virtio/vhost-user.c | 44 ++++++++++++++++++++++++---------- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h index e44a41bb70..6e0e8a71a3 100644 --- a/include/hw/virtio/vhost-user.h +++ b/include/hw/virtio/vhost-user.h @@ -22,6 +22,7 @@ typedef struct VhostUserState { CharBackend *chr; VhostUserHostNotifier notifier[VIRTIO_QUEUE_MAX]; int memory_slots; + bool supports_config; } VhostUserState; bool vhost_user_init(VhostUserState *user, CharBackend *chr, Error **errp); diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c index 1b2f7eed98..9be21d07ee 100644 --- a/hw/scsi/vhost-user-scsi.c +++ b/hw/scsi/vhost-user-scsi.c @@ -121,6 +121,7 @@ static void vhost_user_scsi_realize(DeviceState *dev, Error **errp) vsc->dev.backend_features = 0; vqs = vsc->dev.vqs; + s->vhost_user.supports_config = true; ret = vhost_dev_init(&vsc->dev, &s->vhost_user, VHOST_BACKEND_TYPE_USER, 0, errp); if (ret < 0) { diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 6c8f722262..b0d417651d 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -1949,14 +1949,15 @@ static int vhost_user_postcopy_notifier(NotifierWithReturn *notifier, static int vhost_user_backend_init(struct vhost_dev *dev, void *opaque, Error **errp) { - uint64_t features, protocol_features, ram_slots; + uint64_t features, ram_slots; struct vhost_user *u; + VhostUserState *vus = (VhostUserState *) opaque; int err; assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER); u = g_new0(struct vhost_user, 1); - u->user = opaque; + u->user = vus; u->dev = dev; dev->opaque = u; @@ -1967,6 +1968,10 @@ static int vhost_user_backend_init(struct vhost_dev *dev, void *opaque, } if (virtio_has_feature(features, VHOST_USER_F_PROTOCOL_FEATURES)) { + bool supports_f_config = vus->supports_config || + (dev->config_ops && dev->config_ops->vhost_dev_config_notifier); + uint64_t protocol_features; + dev->backend_features |= 1ULL << VHOST_USER_F_PROTOCOL_FEATURES; err = vhost_user_get_u64(dev, VHOST_USER_GET_PROTOCOL_FEATURES, @@ -1976,19 +1981,34 @@ static int vhost_user_backend_init(struct vhost_dev *dev, void *opaque, return -EPROTO; } - dev->protocol_features = - protocol_features & VHOST_USER_PROTOCOL_FEATURE_MASK; + /* + * We will use all the protocol features we support - although + * we suppress F_CONFIG if we know QEMUs internal code can not support + * it. + */ + protocol_features &= VHOST_USER_PROTOCOL_FEATURE_MASK; - if (!dev->config_ops || !dev->config_ops->vhost_dev_config_notifier) { - /* Don't acknowledge CONFIG feature if device doesn't support it */ - dev->protocol_features &= ~(1ULL << VHOST_USER_PROTOCOL_F_CONFIG); - } else if (!(protocol_features & - (1ULL << VHOST_USER_PROTOCOL_F_CONFIG))) { - error_setg(errp, "Device expects VHOST_USER_PROTOCOL_F_CONFIG " - "but backend does not support it."); - return -EINVAL; + if (supports_f_config) { + if (!virtio_has_feature(protocol_features, + VHOST_USER_PROTOCOL_F_CONFIG)) { + error_setg(errp, "vhost-user device %s expecting " + "VHOST_USER_PROTOCOL_F_CONFIG but the vhost-user backend does " + "not support it.", dev->vdev->name); + return -EPROTO; + } + } else { + if (virtio_has_feature(protocol_features, + VHOST_USER_PROTOCOL_F_CONFIG)) { + warn_reportf_err(*errp, "vhost-user backend supports " + "VHOST_USER_PROTOCOL_F_CONFIG for " + "device %s but QEMU does not.", + dev->vdev->name); + protocol_features &= ~(1ULL << VHOST_USER_PROTOCOL_F_CONFIG); + } } + /* final set of protocol features */ + dev->protocol_features = protocol_features; err = vhost_user_set_protocol_features(dev, dev->protocol_features); if (err < 0) { error_setg_errno(errp, EPROTO, "vhost_backend_init failed"); From patchwork Mon May 16 20:54:52 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: 572988 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1590:0:0:0:0 with SMTP id w16csp1459328map; Mon, 16 May 2022 15:01:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxq35mqzmJPlSZqu9mSMnhk5+zpvD59mXKpkFACL7IKgL15sdWbmasPdtj0eWjo62HCCf7 X-Received: by 2002:ad4:5bac:0:b0:45a:e57e:d630 with SMTP id 12-20020ad45bac000000b0045ae57ed630mr17153099qvq.126.1652738483130; Mon, 16 May 2022 15:01:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652738483; cv=none; d=google.com; s=arc-20160816; b=MAUx/3Zf85rNopLPHvHeN9EF2i1xJ3taUuWXV9cGMemlANsyYcRaDiw1z1Z/W5iGoB oBEJkuUQV5b+ED9juVpPDKojCSGEMuC5RA+MK+Xg8354WEe3PJvyqC3ErHW4OXfBCQtl 8XZLO+1vDavR88wM8SA4Sdfw21gp3S1CpKzHAxyOJmK5b6ftFwKQlStzP1yQXZFYpcKH uYRPHaEkgOcVqRQRyvlw9r5lLEkf9WgTXHtTLXiIpbNwZEo7lB9O0pvOvbkj1KkQeHfS lnfJwMEO35Ae3KLIG5nPrlTEOVzEhi8URuzcx++ggGb2I/8Ray+gpylBhWyJ/CNkP6xp ynUg== 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=zhjEctiUTjiy6J9SwVBbKJpcUcTX173hG9QfVjtla+w=; b=eFBsA2LPsO6T31iWjhRBHcT7DZUVkCVASVtcvl2wQEE7Rd9qQOLqzSwLgfb5d0jW94 x1G6QxSBTkyveSetG07NlUk2gYMdY/+kHShGAvoBOI5M5L4v8hVXWT1gfQWkDz/42qGG rpYg3Eddx/POpBhFNpPSAvkOKvuhCfMqjQuH+DTSlSZqc8bJ73dOGAI1EoR71ADdxA5L 3rtmNonUFu8+W+pHfL7tat5Ae32mdwlu3O7YFxb0H1IdxamYA5IHsgqnV1+UhzyIevGo 9tAAGUeL5Vn6xc/aoQ9HJyaeq55lCA+psIk24Vci29d41If4fNTPrK9Oe6SrKizNDgcF IMtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dZorIzTZ; 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 1-20020a05621420a100b0045651b30915si7145138qvd.84.2022.05.16.15.01.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 May 2022 15:01:23 -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=dZorIzTZ; 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]:37096 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqimI-0002GW-Kk for patch@linaro.org; Mon, 16 May 2022 18:01:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59546) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqhk9-00039V-Bt for qemu-devel@nongnu.org; Mon, 16 May 2022 16:55:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:25590) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqhk3-0006oh-JM for qemu-devel@nongnu.org; Mon, 16 May 2022 16:55:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652734499; 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=zhjEctiUTjiy6J9SwVBbKJpcUcTX173hG9QfVjtla+w=; b=dZorIzTZwvCUZ9E/FLjILC3IUGqipe1zkSlbMUwvk6MC7H/jqtoe1Ad/V8tfZZ5kVvXXX+ TENlmR3aSWZAqVKtvXAYbYgtZiu7xS79oWM2u4O0BWPbBcWEyqD0RNgZtbbZyShBftOJk1 s+vDz3atfBhH/1jxCtYtxUfvJDwHS3g= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-27-NiomdnGSN5Klj24oFwzWHQ-1; Mon, 16 May 2022 16:54:57 -0400 X-MC-Unique: NiomdnGSN5Klj24oFwzWHQ-1 Received: by mail-ed1-f72.google.com with SMTP id f20-20020a50d554000000b0042abba35e60so1410084edj.15 for ; Mon, 16 May 2022 13:54:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=zhjEctiUTjiy6J9SwVBbKJpcUcTX173hG9QfVjtla+w=; b=wXXfmn0sJEeY3rpSHlrF2y4MKFKnSdnl9g2wV/6J2kXNk5OINPKx6doxKEzzq+rwof BTFP8vjtlaGOTjKEEILXzy9EWoFCIkdBRvANAx0NUs4GRfY4Y69g8r55LJjv8A31wlVt iub5UWKEMA9lwkC8X9gqPHCIZBf1Io/WgZK7kQQ5gweO+7pHAwm121VdtA56etRMO825 jcEEXUzTuUPt2qcAjWZB+r7UNvGtaJmM1HjUNGG7FirB2LkwbhGMQx6oQ9FhvH7crSfx XiFOp1vOjXZ7QH+Rna5qByEe2atxBh4Zl/apDl9Fe7ddmrL20rqeHRYiQfi04Muj9mFb +xrA== X-Gm-Message-State: AOAM532bD6W1qh6WUg2hnlG4V4tYWAkbEp0Wprlsy9C3MhjWQ/J+iNzG 2Sy8mlvOlRO+l0cCuyMGf/XEcnKwbtnhpYJpq3ebPKFBmIIofSFMLFs/hk3GxRcL3HSQ4Bg+lap 8yHdwVmMJPBpLUg+iRspnmMYjXWzXKj3jYEG9MQnQ4xHAdRMpiQbkKrn8FjSp X-Received: by 2002:a17:906:d9d1:b0:6fd:d8d5:5c9c with SMTP id qk17-20020a170906d9d100b006fdd8d55c9cmr16576170ejb.665.1652734495991; Mon, 16 May 2022 13:54:55 -0700 (PDT) X-Received: by 2002:a17:906:d9d1:b0:6fd:d8d5:5c9c with SMTP id qk17-20020a170906d9d100b006fdd8d55c9cmr16576145ejb.665.1652734495632; Mon, 16 May 2022 13:54:55 -0700 (PDT) Received: from redhat.com ([2.55.131.38]) by smtp.gmail.com with ESMTPSA id v27-20020a17090651db00b006f3ef214e06sm158855ejk.108.2022.05.16.13.54.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 13:54:55 -0700 (PDT) Date: Mon, 16 May 2022 16:54:52 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= Subject: [PULL v2 69/86] virtio/vhost-user: dynamically assign VhostUserHostNotifiers Message-ID: <20220516204913.542894-70-mst@redhat.com> References: <20220516204913.542894-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220516204913.542894-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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée At a couple of hundred bytes per notifier allocating one for every potential queue is very wasteful as most devices only have a few queues. Instead of having this handled statically dynamically assign them and track in a GPtrArray. [AJB: it's hard to trigger the vhost notifiers code, I assume as it requires a KVM guest with appropriate backend] Signed-off-by: Alex Bennée Message-Id: <20220321153037.3622127-14-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-user.h | 42 ++++++++++++++++- hw/virtio/vhost-user.c | 83 +++++++++++++++++++++++++++------- hw/virtio/trace-events | 1 + 3 files changed, 108 insertions(+), 18 deletions(-) diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h index 6e0e8a71a3..c6e693cd3f 100644 --- a/include/hw/virtio/vhost-user.h +++ b/include/hw/virtio/vhost-user.h @@ -11,21 +11,61 @@ #include "chardev/char-fe.h" #include "hw/virtio/virtio.h" +/** + * VhostUserHostNotifier - notifier information for one queue + * @rcu: rcu_head for cleanup + * @mr: memory region of notifier + * @addr: current mapped address + * @unmap_addr: address to be un-mapped + * @idx: virtioqueue index + * + * The VhostUserHostNotifier entries are re-used. When an old mapping + * is to be released it is moved to @unmap_addr and @addr is replaced. + * Once the RCU process has completed the unmap @unmap_addr is + * cleared. + */ typedef struct VhostUserHostNotifier { struct rcu_head rcu; MemoryRegion mr; void *addr; void *unmap_addr; + int idx; } VhostUserHostNotifier; +/** + * VhostUserState - shared state for all vhost-user devices + * @chr: the character backend for the socket + * @notifiers: GPtrArray of @VhostUserHostnotifier + * @memory_slots: + */ typedef struct VhostUserState { CharBackend *chr; - VhostUserHostNotifier notifier[VIRTIO_QUEUE_MAX]; + GPtrArray *notifiers; int memory_slots; bool supports_config; } VhostUserState; +/** + * vhost_user_init() - initialise shared vhost_user state + * @user: allocated area for storing shared state + * @chr: the chardev for the vhost socket + * @errp: error handle + * + * User can either directly g_new() space for the state or embed + * VhostUserState in their larger device structure and just point to + * it. + * + * Return: true on success, false on error while setting errp. + */ bool vhost_user_init(VhostUserState *user, CharBackend *chr, Error **errp); + +/** + * vhost_user_cleanup() - cleanup state + * @user: ptr to use state + * + * Cleans up shared state and notifiers, callee is responsible for + * freeing the @VhostUserState memory itself. + */ void vhost_user_cleanup(VhostUserState *user); #endif diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index b0d417651d..b040c1ad2b 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -1174,14 +1174,16 @@ static void vhost_user_host_notifier_free(VhostUserHostNotifier *n) n->unmap_addr = NULL; } -static void vhost_user_host_notifier_remove(VhostUserState *user, - VirtIODevice *vdev, int queue_idx) +/* + * clean-up function for notifier, will finally free the structure + * under rcu. + */ +static void vhost_user_host_notifier_remove(VhostUserHostNotifier *n, + VirtIODevice *vdev) { - VhostUserHostNotifier *n = &user->notifier[queue_idx]; - if (n->addr) { if (vdev) { - virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, false); + virtio_queue_set_host_notifier_mr(vdev, n->idx, &n->mr, false); } assert(!n->unmap_addr); n->unmap_addr = n->addr; @@ -1225,6 +1227,15 @@ static int vhost_user_set_vring_enable(struct vhost_dev *dev, int enable) return 0; } +static VhostUserHostNotifier *fetch_notifier(VhostUserState *u, + int idx) +{ + if (idx >= u->notifiers->len) { + return NULL; + } + return g_ptr_array_index(u->notifiers, idx); +} + static int vhost_user_get_vring_base(struct vhost_dev *dev, struct vhost_vring_state *ring) { @@ -1237,7 +1248,10 @@ static int vhost_user_get_vring_base(struct vhost_dev *dev, }; struct vhost_user *u = dev->opaque; - vhost_user_host_notifier_remove(u->user, dev->vdev, ring->index); + VhostUserHostNotifier *n = fetch_notifier(u->user, ring->index); + if (n) { + vhost_user_host_notifier_remove(n, dev->vdev); + } ret = vhost_user_write(dev, &msg, NULL, 0); if (ret < 0) { @@ -1502,6 +1516,29 @@ static int vhost_user_slave_handle_config_change(struct vhost_dev *dev) return dev->config_ops->vhost_dev_config_notifier(dev); } +/* + * Fetch or create the notifier for a given idx. Newly created + * notifiers are added to the pointer array that tracks them. + */ +static VhostUserHostNotifier *fetch_or_create_notifier(VhostUserState *u, + int idx) +{ + VhostUserHostNotifier *n = NULL; + if (idx >= u->notifiers->len) { + g_ptr_array_set_size(u->notifiers, idx); + } + + n = g_ptr_array_index(u->notifiers, idx); + if (!n) { + n = g_new0(VhostUserHostNotifier, 1); + n->idx = idx; + g_ptr_array_insert(u->notifiers, idx, n); + trace_vhost_user_create_notifier(idx, n); + } + + return n; +} + static int vhost_user_slave_handle_vring_host_notifier(struct vhost_dev *dev, VhostUserVringArea *area, int fd) @@ -1521,9 +1558,12 @@ static int vhost_user_slave_handle_vring_host_notifier(struct vhost_dev *dev, return -EINVAL; } - n = &user->notifier[queue_idx]; - - vhost_user_host_notifier_remove(user, vdev, queue_idx); + /* + * Fetch notifier and invalidate any old data before setting up + * new mapped address. + */ + n = fetch_or_create_notifier(user, queue_idx); + vhost_user_host_notifier_remove(n, vdev); if (area->u64 & VHOST_USER_VRING_NOFD_MASK) { return 0; @@ -2526,6 +2566,20 @@ static int vhost_user_set_inflight_fd(struct vhost_dev *dev, return vhost_user_write(dev, &msg, &inflight->fd, 1); } +static void vhost_user_state_destroy(gpointer data) +{ + VhostUserHostNotifier *n = (VhostUserHostNotifier *) data; + if (n) { + vhost_user_host_notifier_remove(n, NULL); + object_unparent(OBJECT(&n->mr)); + /* + * We can't free until vhost_user_host_notifier_remove has + * done it's thing so schedule the free with RCU. + */ + g_free_rcu(n, rcu); + } +} + bool vhost_user_init(VhostUserState *user, CharBackend *chr, Error **errp) { if (user->chr) { @@ -2534,23 +2588,18 @@ bool vhost_user_init(VhostUserState *user, CharBackend *chr, Error **errp) } user->chr = chr; user->memory_slots = 0; + user->notifiers = g_ptr_array_new_full(VIRTIO_QUEUE_MAX / 4, + &vhost_user_state_destroy); return true; } void vhost_user_cleanup(VhostUserState *user) { - int i; - VhostUserHostNotifier *n; - if (!user->chr) { return; } memory_region_transaction_begin(); - for (i = 0; i < VIRTIO_QUEUE_MAX; i++) { - n = &user->notifier[i]; - vhost_user_host_notifier_remove(user, NULL, i); - object_unparent(OBJECT(&n->mr)); - } + user->notifiers = (GPtrArray *) g_ptr_array_free(user->notifiers, true); memory_region_transaction_commit(); user->chr = NULL; } diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 65e3b704ec..ab8e095b73 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -23,6 +23,7 @@ vhost_user_postcopy_waker_found(uint64_t client_addr) "0x%"PRIx64 vhost_user_postcopy_waker_nomatch(const char *rb, uint64_t rb_offset) "%s + 0x%"PRIx64 vhost_user_read(uint32_t req, uint32_t flags) "req:%d flags:0x%"PRIx32"" vhost_user_write(uint32_t req, uint32_t flags) "req:%d flags:0x%"PRIx32"" +vhost_user_create_notifier(int idx, void *n) "idx:%d n:%p" # vhost-vdpa.c vhost_vdpa_dma_map(void *vdpa, int fd, uint32_t msg_type, uint64_t iova, uint64_t size, uint64_t uaddr, uint8_t perm, uint8_t type) "vdpa:%p fd: %d msg_type: %"PRIu32" iova: 0x%"PRIx64" size: 0x%"PRIx64" uaddr: 0x%"PRIx64" perm: 0x%"PRIx8" type: %"PRIu8