From patchwork Mon May 16 10:39:01 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: 572971 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1590:0:0:0:0 with SMTP id w16csp987977map; Mon, 16 May 2022 04:52:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMzI+BrySivTKHWLY2pnwxY1z4nQjGRxxiLZBQooW6aketjQymJVp5iPWyVCOhi6qGHYMB X-Received: by 2002:ac8:5e4b:0:b0:2f3:db53:403b with SMTP id i11-20020ac85e4b000000b002f3db53403bmr14597960qtx.667.1652701979472; Mon, 16 May 2022 04:52:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652701979; cv=none; d=google.com; s=arc-20160816; b=ScVc5G+DoojyXoQncL1FqnSDzZK3Xyc2zfEj30Lp1BqqdJB7WnZec0xQPwJk71OC1z fb5QNbZYQkp8mGXPvnCAA+2C8+5IdPA9R8jF+7P6Jztt4djxuMJFmHgR8CQimqju5TR0 N9ZvemH+p2Fvm9OLvMKrDDkqCd1oHr1URDkW740bNISaktkcArm+AeQTqNZ/azhQ0f1X Iy7TTG3fQlgaSYQh7sTIdlAZqAEg7etiZ4JfWVWlnOXXOYRgcwcvAQX9q9SmsTEBPCgX 7og0scuK1pEiNYOSf3hmd7pCB2MI8fIBKnakxhTslhavybeiDZsfVReGcb33MEdRzcFo OZOA== 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=S7Ja8xJz1hNorPiIJrIxdp8GaOhP38+rMRsiCHjjGcIboMG/bO2AIaBfSnydx/Usl4 SVEuP9Tii5ljHttVaMSSVIE1omhzdTSBjJyKIF1UpvD8zRS7M6QQ6pROEjE88xJAHz5r be8NTUzlFTuBS0PgHUl4ea1XnJahLf0CrFMD9jvjuTFZKkfonp/+2MfXKTzkyEPLqn6f XGLfB/BGul5gyFNfNTLSD0NNaETRMlqVAnlLKVrOLkFnTsoK4U/StWMEO+WsDbVYIuIW NpUW+tqgQlq/EofUCSpjDgZ36AJwAg1IHEKVKgnSmjUWtSNEuINdii03QTcDVWrdZVAM KI7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UH8HnQ3d; 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 m8-20020ad45dc8000000b0045a853e62d4si6334188qvh.123.2022.05.16.04.52.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 May 2022 04:52:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UH8HnQ3d; 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]:42184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqZHX-0007rl-2V for patch@linaro.org; Mon, 16 May 2022 07:52:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49106) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqY88-00014s-U7 for qemu-devel@nongnu.org; Mon, 16 May 2022 06:39:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:34713) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqY86-0005a2-Mf for qemu-devel@nongnu.org; Mon, 16 May 2022 06:39:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652697548; 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=UH8HnQ3dziwdzNOzOwVrh0e47s/VFJAuBtEva0kSJGq5SLR/JdC+WMYxRX2v52SfDGjD2C 2SEGKvXwUR0TtZZnyF4uKlRn1KsxamygnoUUK8/TF1gye47UqfHpRLCYIoiOq6Sa4eua6H 1D2nC8LiH1kvmJqX4JJfQT8ZWNas6M8= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-155-SHq2uohDPgKw6R58X419Gg-1; Mon, 16 May 2022 06:39:07 -0400 X-MC-Unique: SHq2uohDPgKw6R58X419Gg-1 Received: by mail-wm1-f72.google.com with SMTP id k35-20020a05600c1ca300b003946a9764baso10156430wms.1 for ; Mon, 16 May 2022 03:39:07 -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=BaJonM2qCLCLk0c6IkkK/RoauIvT1DLJ5kQh9dlapQtGGvHbQT5dY2uXNGKMZvCQjk 4YUfuaMwndIJo3F5SQzxWwQIsmkoD392qzMAwKAU5jxxEyUOe5dZSOGYPNEnLDnRF57J 7kOO0OwSt4FVi12++DIGgWjS9RS4BlEFfMo1nu+wOgXYX4IdoxCP3/WxXfM/8BYh8Oph kVAXWsuMwc5KY1nsszA3QbCKk3UbeEnhax8r5VZ8jjURpeX/xct1CuhTuMF2QC3CXMVu D2xUEr9WZSgpHGyiml4eH+155PJmqzb3vSKJGK3llL8qWMu0Y5IeSx/5g2wSaeNhYuhu pomw== X-Gm-Message-State: AOAM530X+8rEoAIRpsa1k0mUBmdLHUNJk/bHPFWB6f9nOZmTwCZe/apR MFgWcYQqibqgs0VpF/rNBPTmZIGKU9Kavgq21d0oxtNr9shYZYb6WQcmsuh12/FMBq5i6ovGXVt gOx3KwJFBU3y7VDiu73d01wQp/Ie/RUYVq248GFBytTZdgyfj4N4OkqrXgrs+ X-Received: by 2002:a7b:c041:0:b0:394:44a9:b017 with SMTP id u1-20020a7bc041000000b0039444a9b017mr16182671wmc.169.1652697545891; Mon, 16 May 2022 03:39:05 -0700 (PDT) X-Received: by 2002:a7b:c041:0:b0:394:44a9:b017 with SMTP id u1-20020a7bc041000000b0039444a9b017mr16182640wmc.169.1652697545571; Mon, 16 May 2022 03:39:05 -0700 (PDT) Received: from redhat.com ([2.55.141.66]) by smtp.gmail.com with ESMTPSA id p21-20020a05600c359500b00394755b4479sm14499436wmq.21.2022.05.16.03.39.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 03:39:05 -0700 (PDT) Date: Mon, 16 May 2022 06:39:01 -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 58/91] hw/virtio: move virtio-pci.h into shared include space Message-ID: <20220516095448.507876-59-mst@redhat.com> References: <20220516095448.507876-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220516095448.507876-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 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 10:39:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 572973 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1590:0:0:0:0 with SMTP id w16csp989674map; Mon, 16 May 2022 04:55:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDxQeZC2WZ6VBoXsIh+8zHZekczpNRqkCx6iKzJyzlIkvLcP2g2rLhU+juvuvLTai6OP71 X-Received: by 2002:a05:6214:cc5:b0:461:c073:6e69 with SMTP id 5-20020a0562140cc500b00461c0736e69mr7874337qvx.128.1652702111241; Mon, 16 May 2022 04:55:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652702111; cv=none; d=google.com; s=arc-20160816; b=WLwnRs6f5W6JV37GXvybpTpRMy/Myjic2KkeTKYd7Lkx/KygevqdTBL2Nl57OfG1Bb /DwhXpjc7lk+Oq62A1mxliboFcj9m6K9r1bwQb7dVqNCw3gzdmOBNYk0PwDB/IQRAZSo LvI526Oi6WS/WQVVrMabaWzVa6+QEmXx+9hJEquQ16fzYEFwIotD/ajm97+As7AM1cUi v4JpTAa+GNw+YJ1jDEptwb4QTwRXcZTBHAsIrKWS9l3bpMauvwusnOt6yucYRFW4T2YC /E279rFvvxZBGN90i4ibmvZv2PIOM5CkXV7nzA+z5DpWG0oOztd2+VJoge2L1EfXACsk t5WA== 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=ehtFMxVNS1kwOYYn2jGtehnKtgLm1EmwcKgS7eaJ+s8dTNOqLmXHAmY6IDBqMp1aiv BToSY67UFUGExU0oxP+iLT4J4FoEZWMQhayC6AKFQr/zAZ4+pIZShQfeg6OTRWlL5tnn qDYoCa/BLhq9064X8QTkloV9bFxjhq64Ii6wvdMlyuUfFYocTUYMUM3OEOqK4NCnVzv5 qAKItDSTtY2VwJraz5GfozvZaTOtnQakl0NcA99++i79hLKZwmkbE3Usm83MKINZoR5T rjf95DaiGdJ6iF7qjAUlhoTPylRY69NJJ662aNWYsOqpq4IeqomTJedrpovBQ/sHeGP4 7gkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QVcTwdE8; 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-20020a0562140d6c00b004464c6924b4si6713971qvs.89.2022.05.16.04.55.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 May 2022 04:55: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=QVcTwdE8; 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]:49584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqZJe-0004Xg-Q3 for patch@linaro.org; Mon, 16 May 2022 07:55:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49108) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqY88-00014w-VV for qemu-devel@nongnu.org; Mon, 16 May 2022 06:39:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:29374) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqY87-0005aO-BK for qemu-devel@nongnu.org; Mon, 16 May 2022 06:39:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652697550; 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=QVcTwdE85ItYEi92+WWWDMjNOL4BMSKhYWvJYK0A+qqtjog7/EZ451YN/rT4EYF+T/o5JC SNhV+Q8A5MFNpLd6w+WHL2tQQQT+Hw7Klue0PfOZEMDRUbjxmvFcKgBss+p9xw60B4Nc9f 1n55oNVeKed8P7EKlL48PtsIr5yU8x0= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-670-_P9Q7VSrMpOe6go5Y0UL9Q-1; Mon, 16 May 2022 06:39:09 -0400 X-MC-Unique: _P9Q7VSrMpOe6go5Y0UL9Q-1 Received: by mail-wr1-f71.google.com with SMTP id t9-20020a5d5349000000b0020d02cd51fbso469624wrv.13 for ; Mon, 16 May 2022 03:39:09 -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=ylml2Au4XVTGjhBjIOLHIyBA9/4O2pCxy1xHQkVk+o0p2wM5RKCVYZVVnF8m+9V2zU tGU31Ne1YnXL/47Xr32Zrs378O//r6A3XEKGk6SXmPKeHd9hEYLqo8kBP+L2cBfJAfJx XdWmleWyidt7V/xTbgmU5lfHrmA6bJ0iSLWUVqTiXr8NOhZEqlnpax9hlPPDGMvz6FRM llsFEJ6hWzp1+uZhmakavg5L7TnV1m2QzvZbZ9T7Zp42c60SJ3Bi2PFgd8XUIdii36Mz GY9371RvkddejeqGTMhga3fU9hEPCPghSzi/J2+hNEBLR1PEI/+RqUo+3HgSTiy8uZVQ rUZA== X-Gm-Message-State: AOAM530zBTd+rqk3BpuQVAWuhz+6o6fgfFEARJI5XjFWPBvu16sUWDxh 3zyq+Rhp5pvXEjipLkm3pRi4NxRklCQlBHIldt/LRnmzA3XsxotEI6D4Ab//TkLh2+pUoWi1ReF 6h1f5uKUMJykYktkM3mN/2WfYNIUeTYzdVVUV7OB8DV4dAjL2e2kozFZnOUXt X-Received: by 2002:a05:600c:4347:b0:393:fbae:a5da with SMTP id r7-20020a05600c434700b00393fbaea5damr26163745wme.205.1652697548379; Mon, 16 May 2022 03:39:08 -0700 (PDT) X-Received: by 2002:a05:600c:4347:b0:393:fbae:a5da with SMTP id r7-20020a05600c434700b00393fbaea5damr26163722wme.205.1652697548136; Mon, 16 May 2022 03:39:08 -0700 (PDT) Received: from redhat.com ([2.55.141.66]) by smtp.gmail.com with ESMTPSA id i13-20020adfb64d000000b0020ce1c1cf31sm9147938wre.21.2022.05.16.03.39.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 03:39:07 -0700 (PDT) Date: Mon, 16 May 2022 06:39:05 -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 59/91] virtio-pci: add notification trace points Message-ID: <20220516095448.507876-60-mst@redhat.com> References: <20220516095448.507876-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220516095448.507876-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 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 10:39:08 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: 572972 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1590:0:0:0:0 with SMTP id w16csp989357map; Mon, 16 May 2022 04:54:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxn7EjPYz31SGGNKVSMQbrNbZXwoGjQUeA6h6niABv/CPkP4iLySUSS3/FgXZVmrMjrT939 X-Received: by 2002:a37:9bce:0:b0:69f:a640:7297 with SMTP id d197-20020a379bce000000b0069fa6407297mr11769874qke.497.1652702087338; Mon, 16 May 2022 04:54:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652702087; cv=none; d=google.com; s=arc-20160816; b=S1GDziv7ehTSLB6+dizczffPo0ZHTAkF51Sa5iauLsWpf/XpNCRFUTdsNNZ68T0+c8 r8J/OsELDexKhhJ+ENaP2gX7FtwlGXmotsU/n5XJwAnvSSrX2xuwIBxJoZeAoZQi8V49 UpA6/o6FONEg6weVdFnQ0Q5m5Cd+WxhH63+t4tvvVD2ixiEb0mp3YQq7U6DO4zQRLhYS v26ZEuNT69r1KjVu6QtYmOG8zUyzOfdOofb7mvXYsuRQpLS3MBdclMH5qxtJsn9WPf+O dffH78mbRH1XRPfu6rvRE4pPUNKoYwJxZp8e0rprVAYUjHVLXXKr34Z5DCsivLWlUhx9 ASwA== 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=OtMWmKxvX+y2q/RrTA3ZffiiOrjMefAamebaP9Txn15iY5MAcWKHBuiPdVvvQ16EcF SAyjAGT+XRIgB5S74f4xSMU332PDUgDC5jQEXAKpYO15wrSwAMzhDG6SPqBfFHvj/QOS CNI8tMyR+iu9tf7wLOsEpwNu9KlwYuhlztg/iWgyml0kM1tHvVdC8mcPvUI4iJ/E4UBI 0MWGogYCsBkHgzP5Py9AoE+K6z50Gf49AWLYT5JSyKjTgK3i6RryQX2g/OYV3HvqFfS1 /ltFZ98AGCxR7j1Z9IRU2XA9pzUKoDYHY1o6oxjQmjOhD+ObC8r/WX/PiEFtYrbqKOCT sELw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YQNMKOzp; 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 a13-20020a0562140c2d00b0045a8584623bsi6617896qvd.247.2022.05.16.04.54.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 May 2022 04:54:47 -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=YQNMKOzp; 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]:48016 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqZJG-0003VN-Sf for patch@linaro.org; Mon, 16 May 2022 07:54:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49144) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqY8C-00015h-9b for qemu-devel@nongnu.org; Mon, 16 May 2022 06:39:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:37043) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqY8A-0005bo-6D for qemu-devel@nongnu.org; Mon, 16 May 2022 06:39:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652697553; 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=YQNMKOzpc1bUFL43vFFyPj4hZ9Uu7cK4/iTO0fH8HSlfglndPyFLY35ZyDWkR6QavMvv9t 6MtFMHSrifSlCSK6jiHynfiDJ86EAEdlA0jbr0GBVSuH1YzgsugwTUNCKTb7Bw5HMLhSaN j/MkDk1wgG5ubUM0xbmGigfvKumekss= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-447-9Kbe6WHTNTC4VXZ24I5Qlw-1; Mon, 16 May 2022 06:39:12 -0400 X-MC-Unique: 9Kbe6WHTNTC4VXZ24I5Qlw-1 Received: by mail-wm1-f72.google.com with SMTP id k5-20020a05600c0b4500b003941ca130f9so6568459wmr.0 for ; Mon, 16 May 2022 03:39:12 -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=zMqJxAd71Xnl/BlLeg6ZIgJV39OipG2thkNk7YJlA4wC8ge3zs/11skvupQBPeZCMw InH0j6mPscscVn50tKkNULpuZ0TKo6syY1b4m+KmvPIhjLl5cUA37Pb9as/89k6p6ndC rKKm4ujjeBcD17+dq/W3v4RZEQixAr0mSMcWlAeQFchOIXAXUy+FlHiKFiqD8FFXXWk9 f9k4zt2d24TXRiik5OnAkNn/jjS7sAgVfVTHgS+PHvGdvyyS151Bep/9c4bYkVDZ6zbN NkAJDvdibQgtraN34ODVCv66alEyjIYzW/irzWl+NwURLGZn4TlET4PrEN8VdEtJlEMB /eog== X-Gm-Message-State: AOAM531DVEVW/Ofb4EnzoS12JRhyQC18EPsT2f4+fUkPCLMIfmssEFnj GJWo2GDnd3OVkNfV/skvi0A6GAvyULaCtkjY7km7EZ9GSHaeOaciVLYJ9nTUbISXIvyOSXEZoCJ 8oHZKUBNQhRlvGhAHcnv4dlmMMvHG91JKUehsMOUgGP6YFqlMJbYsu6hK7Gw3 X-Received: by 2002:a05:6000:793:b0:20c:c809:9af1 with SMTP id bu19-20020a056000079300b0020cc8099af1mr13293435wrb.370.1652697551047; Mon, 16 May 2022 03:39:11 -0700 (PDT) X-Received: by 2002:a05:6000:793:b0:20c:c809:9af1 with SMTP id bu19-20020a056000079300b0020cc8099af1mr13293416wrb.370.1652697550724; Mon, 16 May 2022 03:39:10 -0700 (PDT) Received: from redhat.com ([2.55.141.66]) by smtp.gmail.com with ESMTPSA id z12-20020a7bc7cc000000b003942a244f39sm14968435wmk.18.2022.05.16.03.39.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 03:39:10 -0700 (PDT) Date: Mon, 16 May 2022 06:39:08 -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 60/91] hw/virtio: add vhost_user_[read|write] trace points Message-ID: <20220516095448.507876-61-mst@redhat.com> References: <20220516095448.507876-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220516095448.507876-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 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 10:39:19 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: 572977 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1590:0:0:0:0 with SMTP id w16csp1012036map; Mon, 16 May 2022 05:19:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzogkmKxFUOnsJi5iYTYpGkiuo0TriLQ+bkmcASNRjGTyk74zuPtIIFz/1bc+PaCpN9xOsC X-Received: by 2002:a05:620a:2807:b0:67d:6349:2577 with SMTP id f7-20020a05620a280700b0067d63492577mr11731902qkp.785.1652703590278; Mon, 16 May 2022 05:19:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652703590; cv=none; d=google.com; s=arc-20160816; b=eGveqcsba3t56t5nBuEmm0Bt1ShS9nCFyEgI37aktbhvuGtx1qkOK6YxTZNSJhjMPd QpttlO34ZCWvplbksYWuPHU4uHgpLoS52CsCt17VeEda1av8NzNeTcYzKOqkEPR8JkpZ ppHM+/IPgkGCY7HYaSucV8vjUl1eRvDtD35x7etTt13Dnl2SB2I0VDsfptxDSnQ9rpJT 8mjKIUFjmfx3SKPoAlUOumt2Ygw0jogzTSATohv0FFA4Ijw0SY0EHD3VCHdIDf16nDo+ Q50ce51scEMFCTQiCn6OpazKj1BBTdAxlCsXq4Ipat1fyjMpDuB8r8OkQ8LHh3+/1Xs3 rfvA== 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=Xn4yva12nZhCV5Ituz3FHdWlAFf/BOP/yxxeweZrhiS2fyoNPsLM4ZoWRglP3Cy9YC Ht3Pf0jnrfeQ2tENhK2x3w9j2NiqS11x+wsWrNcTtOmHQ6z2fo5o3fUjJFSU/V0KOjDi jxzsom+qOkSo68Lp9FeNzarH2oOTPT/A5SZ+nTyZ94ClZvecRnZ0Y7hyKuA0OSEC+lOG UiyFw7p4r3OUFEaPl46+Q8pv6Kni8a8fIRD9dxsO2ryBSw3MXn98zJ1tsjrng44hVeeC JZXfjCznMjmf/QXMRXqIWFp4o0uZvT9sH2uhxsxv9FKeR9VRrlVpxpceRbx2EYrtnY1E XSgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IMpupAlJ; 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 h186-20020a37b7c3000000b0069e60d938b7si5615610qkf.263.2022.05.16.05.19.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 May 2022 05:19:50 -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=IMpupAlJ; 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]:38918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqZhV-0003K7-Rx for patch@linaro.org; Mon, 16 May 2022 08:19:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49226) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqY8N-00017C-LB for qemu-devel@nongnu.org; Mon, 16 May 2022 06:39:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:54638) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqY8L-0005d8-LY for qemu-devel@nongnu.org; Mon, 16 May 2022 06:39:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652697565; 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=IMpupAlJseCLmp7ciMqYBzEpZcgFfr0y7QGt5/+hlJdyekJ+eO7y/IrdsWZAlJi5T6/iyT ey21yNpDWQbRCT4U073RxdPjg362mtDgDIH52tK/BYyov+X7sHIO9mhDTN2zp4ikinuL3t xEgAYqWYt5CbtD9Qkagp2PQzRYVHTyY= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-470-o3EmsFxFMxypjK0KWqklqQ-1; Mon, 16 May 2022 06:39:23 -0400 X-MC-Unique: o3EmsFxFMxypjK0KWqklqQ-1 Received: by mail-wm1-f71.google.com with SMTP id r186-20020a1c44c3000000b00393f52ed5ceso10139666wma.7 for ; Mon, 16 May 2022 03:39:23 -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=pbfk4tWT+YopzYcGsMGbEH6TkBFkp2EFKz/f9Jj/TfleidMSdk6+VCLWsh0jhIgF23 4OmhsGkecdlgnN40/+KnI+xOdBFX+oKq4f35u3ELRQFO5FtoOEzu1GT1uZT/IbO9xrfG JlTA/yFeNmQomuuc8HIC4XG+EhyEoR9EB8bxuezMqlskeCBQXLKoW7+WpoE8iMucloNv Mv06G4KPruic7B+sYsF4jfNw+G0LOJg3ZuO3crSyI5g5q9+cqyBd9aj4vUVRVYKFoDvG c92SLfuCtcqsDuia9D2csg45OGkjjwAlRGZmWcOsD+w1dbG51ZVYV0Q7mRFk42DmwGH+ AfqQ== X-Gm-Message-State: AOAM531o3+duMEt7EcWRy9NNKSqcogFSOdfpbTqGV8CzOY2ng8QQLpFg 6Epc/YCYfPPt1JR8fwheGqrbu+C3+OBPywlEo2rvlUJIpd6n3/eKg5Y09cnstED2CtPc+TNtl6x LzVAcqlcsi3Ui2Fj7uyeWBnV3lqaOnMhY7VAfOiB+KH5jT9OPGZQlNelCuz5z X-Received: by 2002:adf:e842:0:b0:20d:db6:9e7 with SMTP id d2-20020adfe842000000b0020d0db609e7mr1554569wrn.276.1652697562495; Mon, 16 May 2022 03:39:22 -0700 (PDT) X-Received: by 2002:adf:e842:0:b0:20d:db6:9e7 with SMTP id d2-20020adfe842000000b0020d0db609e7mr1554551wrn.276.1652697562221; Mon, 16 May 2022 03:39:22 -0700 (PDT) Received: from redhat.com ([2.55.141.66]) by smtp.gmail.com with ESMTPSA id u23-20020a05600c00d700b003942a244ec2sm9676936wmm.7.2022.05.16.03.39.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 03:39:21 -0700 (PDT) Date: Mon, 16 May 2022 06:39:19 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Jiang Liu Subject: [PULL 64/91] vhost-user.rst: add clarifying language about protocol negotiation Message-ID: <20220516095448.507876-65-mst@redhat.com> References: <20220516095448.507876-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220516095448.507876-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 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 10:39:22 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: 572978 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1590:0:0:0:0 with SMTP id w16csp1015800map; Mon, 16 May 2022 05:24:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzB72bA147oMli138Psf26PYB68CsQxRfJHu/ep13ojstFuScZeweVjI0e1Wul3IC8XYTFs X-Received: by 2002:a37:8a85:0:b0:6a2:fa5b:e7db with SMTP id m127-20020a378a85000000b006a2fa5be7dbmr1080759qkd.347.1652703891147; Mon, 16 May 2022 05:24:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652703891; cv=none; d=google.com; s=arc-20160816; b=fSIK33Vg5ES6uNSuAOcBfCQGnEcwI4vbo77krkwXfcMXkWWKNQ14rP494uVTycU4pz XFf07FiBZO8y6j9speta9ymmbw5JDLqcQ517LiG3XuGRMAWbA4aVdCmcxk9RJmG8gcBV JBRaNAF3Zkxq196Z3GJ6K7gVK2/5StHguPT8sicqz1F9raeGCoONnn0H+/zdr9H897Yr zdtoerOvFy4aGVj2mo+bj/C/0WMaDLDJSwMpnaSY+z0C2lrC8e+hklI0OUZrkXuI3IBv wi55DPxOMq1Mquu41/OqlEQBdVjfvebF8a9VagGpTGJxjS4D+eSqo75TEdpLyA8Q8umH NBPw== 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=TmMGWkj/NuLVatJpG7rVRA7wq3S/tXVU4ADrLzJApt76JFyGVgR6zuN0bRZz0Q7Ja8 aPdpRHb8wSEXlrH0KeLIIAloenqxVNhAmKksQ+4ANcXJ/A5MYCfe7nT3rNiEJti06WwI +yjdvWKFOQLBXKuMWRy3nx275XprjwKqsrOwDDZe+G77KYkIsj6po4XnDe7xXc6Ah4/b qLWjn7G1xFFGiQfuuhE23TfgxrtwwK+HxJvAjanfk71Kt50tFy1xuAG5eMDkvf8OauR9 Kp1/QtmDfI63GAIyjZHbmaVNXc+DpQrPA64F58RLUBRWofbI9wtmSjBNWJqn5+S52+op aBYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="aHe/LZ9t"; 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 p8-20020a05621421e800b0045ac6663710si5922780qvj.323.2022.05.16.05.24.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 May 2022 05:24: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="aHe/LZ9t"; 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]:47528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqZmM-000172-NS for patch@linaro.org; Mon, 16 May 2022 08:24:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49248) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqY8R-00018E-Bx for qemu-devel@nongnu.org; Mon, 16 May 2022 06:39:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:46042) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqY8P-0005dW-O7 for qemu-devel@nongnu.org; Mon, 16 May 2022 06:39:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652697569; 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=aHe/LZ9tjVWlt9+CCFAiN5BWaacmkTbYP8uXtlu5MRANVhWe6QEQG7/D8FbuI9raQW8atz uR4tGuzCZU8buNIyYIbLoIqM2dvOc1Z8+gJaYW6AVa4uliCksPQYiyjmVFfLnhEQjGOqwc Z7m808knGaaZlNC6vznQ4kr5mR7aJK4= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-489-MkK_0d-ePAGEYd8ayifXoA-1; Mon, 16 May 2022 06:39:27 -0400 X-MC-Unique: MkK_0d-ePAGEYd8ayifXoA-1 Received: by mail-wm1-f69.google.com with SMTP id k35-20020a05600c1ca300b003946a9764baso10156913wms.1 for ; Mon, 16 May 2022 03:39:27 -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=VPc8bLERBxmuNNNTxkuDn8IzcmxNBg0OYEBRKDLlm7uqNAWDZ38+aS6CFVLHv6J6iY eUZWMV1urTI/gGNTjzqy39tUzTxBSmVzRCj2MOfJSwlzcWSbk67S2Qi6CsKLo+ZAXZZT Wbil6GLiEiyVSm1GwdpXl/lgWpztu24tr3FTy1wvosoZAuUgBOUn2Xj5uksH2RbF4HxL 0iOHjgDYgwcK3ptI3FQVVOgHfvNtTyA/aePxofc+S9AkSe11TwLYdPyB7zO95XeZessl PtV/nPQD7E0tQbehCmPubyo7HUtleARbqnzka9JAPmjeLjx8jY5j4STxAJSxOp/SasqG 5cxQ== X-Gm-Message-State: AOAM532GB4fdAxcYbqiLBektUbHXtPD89wHI+h/MACp+ycVXB1OOu8Fz 7fuFHaRKuYMx0L/yVOMhPM/3+Kpgx8vGiUqpX/EU6R09ST1hvGv6zOb8E35ngWtbi1LpLVyqY+A LGmsd4GaLHGWv6VnEMcDZTriXHbWJRFOPTgWAkSV2XFJfaEyFBOCeqmRzysPs X-Received: by 2002:a05:6000:1563:b0:20c:5bcf:c531 with SMTP id 3-20020a056000156300b0020c5bcfc531mr13918588wrz.592.1652697566568; Mon, 16 May 2022 03:39:26 -0700 (PDT) X-Received: by 2002:a05:6000:1563:b0:20c:5bcf:c531 with SMTP id 3-20020a056000156300b0020c5bcfc531mr13918570wrz.592.1652697566336; Mon, 16 May 2022 03:39:26 -0700 (PDT) Received: from redhat.com ([2.55.141.66]) by smtp.gmail.com with ESMTPSA id v15-20020adf8b4f000000b0020d0c48d135sm1575535wra.15.2022.05.16.03.39.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 03:39:25 -0700 (PDT) Date: Mon, 16 May 2022 06:39:22 -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 , Stefan Hajnoczi , Kevin Wolf Subject: [PULL 65/91] libvhost-user: expose vu_request_to_string Message-ID: <20220516095448.507876-66-mst@redhat.com> References: <20220516095448.507876-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220516095448.507876-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 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 10:39:26 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: 572974 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1590:0:0:0:0 with SMTP id w16csp989823map; Mon, 16 May 2022 04:55:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz49+dSP+IbPcVjc6X54vauJaoAzE93MQ0/Tq9sswN1NrtisLyYvK1a70xOLgPzY3YcvgMn X-Received: by 2002:ad4:5e8e:0:b0:45b:477:892f with SMTP id jl14-20020ad45e8e000000b0045b0477892fmr14699563qvb.124.1652702125962; Mon, 16 May 2022 04:55:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652702125; cv=none; d=google.com; s=arc-20160816; b=Zl0f3zF7frBf0Lyn/KstJ5ODeVJx7Rc1aqGpqUcB1zamNHMxIft6ijcg/FzG35IQXT njSor/q9wpR97YayzCvY+5zB1+miKjcmTP/6h0nyqfq7l23+vD7xdXdrI3FZ+YybklXE hAOjmyuCavDechHTT9TKTmZmDzg45FNYucSHR8lWXU04Hhj03O6e/o5o+s4W4rwEF0u7 LllRNGy6+OQIYlYzlEeXjI/qD9q5BeyxcSTY3anNFDZ1EBW+YcIjVG8S+nXXOEHtGtxG dIRD5ix3eXRnH2CuxSEXYudSqM2fY6ZmzvaCGvBiG7AiWUsHCeeTGU5kpFJ9jut120QG YUkA== 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=V70FUX2NrNZsB9YTJc26IRoNQLd3oShNkPZsii2XqnhAklo+R7/GQzsUkyxO4ETfGI tctOzk9C2itrBIZMs80AXyPD36Vogsd1VlwePSCafnWYFnD5Tf1Uyt8vMP9h0795y5yF O3FRuchsrX8iTL6vOICWgqxq+pCYBS1lwn6N3QhTOyJ9tCzFmpigIgRsmvfA2esORM+K GeLdup7yRPviabyxq0+N6d/E8kCsjUQbzbTnwCg+mjEgD+T2slHJn1hSOwfalMI2V/fZ LPaKpEqUvL4TSnfLElEOWKYc+R1pxWn3kGa3n/3uELI2LbmiGTUBkfuSy2KfKUBLUnxW 5uLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NaW75Vnu; 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 14-20020a056214202e00b00456446ea6b3si4084874qvf.367.2022.05.16.04.55.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 May 2022 04:55:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NaW75Vnu; 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]:50846 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqZJt-0005N4-Gr for patch@linaro.org; Mon, 16 May 2022 07:55:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqY8V-0001Bg-R9 for qemu-devel@nongnu.org; Mon, 16 May 2022 06:39:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:31887) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqY8T-0005do-H7 for qemu-devel@nongnu.org; Mon, 16 May 2022 06:39:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652697572; 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=NaW75VnuiKMHg9X3N6ospnQXYEbuCnDpGTZ910Ut2tIdte/DIeEXiYsaatfsexEnDtPExz nWZg/DqqlBSa+2IWkTfR8ZadrHqdxbX89d0Yw4HDUHY4ErKSq2v3FFG/EGn058V5ZLsFuA vBWXbJhQ1n8cn0yxRvR/bza0vdXtKz8= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-281-JKXEs6LsOBS3qv16EF2YHQ-1; Mon, 16 May 2022 06:39:31 -0400 X-MC-Unique: JKXEs6LsOBS3qv16EF2YHQ-1 Received: by mail-wr1-f72.google.com with SMTP id ba21-20020a0560001c1500b0020ca6a45dfcso3800190wrb.9 for ; Mon, 16 May 2022 03:39:31 -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=6YBYxiF1wYJ5gm5SwE3enBicMZ2ePesx9NvyQ/5oeF8/G9RkBU+FM8h5CdyX2V2Veu YjtU5VayNoA+/8p9euXlyedB4C1t6d2ubQMdy1CHsuVCtGPjYy5Wj6DNW3yg0bHurfHU nWb4dP5TuMOAUFiz4VsfnsDY4en+j8QhZdYfoM+jRTNOIkz7jXfeMqd06zuXWjzAH1He Ls6u29QKFIbdo+q8N6pR1QhZ4zvmObkCXwpngYjhTPdOaoijn97nIyb0rkm6o/MHhXse fq9rskYWd8q6zv3ESUqJTsAvGWGn45CUUYSmlhpgUD6pGYblrZWeStu8aX76HMlQwH0U X3mA== X-Gm-Message-State: AOAM531iGyq3SBIKALM+1pPPKvniNkWWrSjEDmd+nOCS1dgct06JdQyo t0tBR9nlPzkYbzWyhNHGaNsfv6EI0mWXFkuWBDh3MNfJuLkPE1OtdYUWW8yyGc4GxcGUVhU+2g4 kvKTdu8kFTyjotrhYLn+LeCwedIT/a29S7DDPbKiD+V7FVO7iy3MtZPQXlM46 X-Received: by 2002:a05:600c:4f52:b0:394:63eb:ad27 with SMTP id m18-20020a05600c4f5200b0039463ebad27mr16415575wmq.35.1652697570261; Mon, 16 May 2022 03:39:30 -0700 (PDT) X-Received: by 2002:a05:600c:4f52:b0:394:63eb:ad27 with SMTP id m18-20020a05600c4f5200b0039463ebad27mr16415542wmq.35.1652697569941; Mon, 16 May 2022 03:39:29 -0700 (PDT) Received: from redhat.com ([2.55.141.66]) by smtp.gmail.com with ESMTPSA id o16-20020adf8b90000000b0020c5253d8e0sm9600626wra.44.2022.05.16.03.39.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 03:39:29 -0700 (PDT) Date: Mon, 16 May 2022 06:39:26 -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 66/91] docs/devel: start documenting writing VirtIO devices Message-ID: <20220516095448.507876-67-mst@redhat.com> References: <20220516095448.507876-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220516095448.507876-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 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 10:39: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: 572979 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1590:0:0:0:0 with SMTP id w16csp1021606map; Mon, 16 May 2022 05:32:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjXEbIfbNRnZrojKFoolAnHULK8C5++fEaGwMuQQIdkJnH1F5EazXUAAzaGu/3z5MieewS X-Received: by 2002:a05:620a:1981:b0:507:4a52:f310 with SMTP id bm1-20020a05620a198100b005074a52f310mr12219363qkb.611.1652704327758; Mon, 16 May 2022 05:32:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652704327; cv=none; d=google.com; s=arc-20160816; b=wN1Vy0lzBa3GqdyjrFT0p3m9SB6ZjyGXpiTJX78dSn3K/K8RkYZlEcboV5txzkLQhU UtlVG9BK8OFl4QGJXcfxZZKjhd+ODADSQAhtkeqE/j58mp+VuuYC737iXuWBh/xrE4NO QLOZQ55V9yTe5NVobgYhT6VzCCjay8o4LKdHT3AOG29M89HLYLZGhz9JEmcKXpElvswv n66Gb9S+v5drybIRsx3WlO6Aik5OQtxoCoAJeoh45Me2AYtkClDw3LbThDyg1icza7rS 1x8GWCZaOk1Yv1ULhIQK7XguAR8pkSXom1D0Y574h8k3/DiEPB1siCR492RB7pKcVdPg H++Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=B1nDZq61p1Fo9R+kfzgjGxckxAqyZiNflr6I94N0EOM=; b=YpO7pLsB37GP8thN9figCB/kszqudDLDFynjvzxYawXxNx5Oj8PzWLPOaCN30IxNxR NsSrlrxxt3F/XH6m5BduhC4tAO7myV/Z6s2TY2GwbWy1rnCLWJMWmjmUFSe6ZBRq0ZhE hxElvqKhPRx9Zj6aTEiVmUe+T5dT5UUxxU51ZAoMLTF0/raI4NsqFVflkbEEiK+cIODp YGLEgAjOstR75ZkVLo7tWMqzwhoeSnIHaM/2OGwxpDYKKNGLi75wCb/03deNLCdiYu5i tGtBOcJ7su8RSgJC7GYNiE1nmBrHtkG/9e9SrEgz+te/AzvdV3GTe+wC1w2uW+TWUsxH frqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Te1KlFh0; 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 j5-20020a05620a410500b0069f167f0d6asi7521740qko.16.2022.05.16.05.32.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 May 2022 05:32:07 -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=Te1KlFh0; 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]:59436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqZtO-0001QV-Ow for patch@linaro.org; Mon, 16 May 2022 08:32:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49298) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqY8Y-0001JI-DS for qemu-devel@nongnu.org; Mon, 16 May 2022 06:39:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:42010) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqY8W-0005eZ-GG for qemu-devel@nongnu.org; Mon, 16 May 2022 06:39:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652697575; 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=Te1KlFh0gHiCnQKOs780mNswy00OVYkF5uTsLO8/60pk5lzDWbOK22p4rjDkKOAam8c5cS iMDCwp+EVppr6nbSoSljuHTMDKj2lSSMnwl6h1lpnrNhNKDLRk7axLdQtjBVJzePod07HM YojjiIqB06qqSd1q45YXW71sMOLltLQ= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-515-tybkcoMtNhK8mMA3aFMhjA-1; Mon, 16 May 2022 06:39:34 -0400 X-MC-Unique: tybkcoMtNhK8mMA3aFMhjA-1 Received: by mail-wm1-f69.google.com with SMTP id z23-20020a05600c221700b003942fd37764so10138188wml.8 for ; Mon, 16 May 2022 03:39:34 -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=CkqoNO2BhDhf13EAdVjdfh2G5mQ3QVvkHN9eVDFRwqbYQLh6r7fwg+eFFlUOmcCoJ8 +as9bXf4WZJpLB4j8Ye5rcCXMPnbPro51n9aWJ9bN990QtyTDrRUucngJEIaE5M5xYAc PK7oSLFkkIfHa9ML8756+0eovMFLMJ+GwwPwC+iSf9CH7+LcrgRDGwRivQ2HjS+uVCr5 raFs2Ha0tyaIMHXTEbszLlmwsDPF4+fP0+U1ySTconhV2qwcIZkfdq4oGl5sZC9M/qST bar0aDJ/LA4SU2J/6F7Jk3lI5MRRthaWjtWeV+4PbXY164r2DTFgHdfM8JtkmdndtOC5 Z7vg== X-Gm-Message-State: AOAM530Bq0iyIcaPW20EQmQhugD+T3Y7UamBT/mylKAKaCxIDp+H6B00 BpjOIy7NJuL8lP0uKos+u4hESG7B02mbcXDHFoumlFE22Ur6X0Q3HYdLR74DlwDzn9jQWKvETAc dcBjCofXcTIkPFutn8rSUrSpgrKUn3EHirBF6d3BVVRt5duHzIq4/pR2UeyC5 X-Received: by 2002:adf:b60a:0:b0:20c:d5f0:82b5 with SMTP id f10-20020adfb60a000000b0020cd5f082b5mr13850612wre.329.1652697573291; Mon, 16 May 2022 03:39:33 -0700 (PDT) X-Received: by 2002:adf:b60a:0:b0:20c:d5f0:82b5 with SMTP id f10-20020adfb60a000000b0020cd5f082b5mr13850592wre.329.1652697572916; Mon, 16 May 2022 03:39:32 -0700 (PDT) Received: from redhat.com ([2.55.141.66]) by smtp.gmail.com with ESMTPSA id x16-20020adfbb50000000b0020d11ee1bcesm195648wrg.82.2022.05.16.03.39.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 03:39:32 -0700 (PDT) Date: Mon, 16 May 2022 06:39:30 -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 67/91] include/hw: start documenting the vhost API Message-ID: <20220516095448.507876-68-mst@redhat.com> References: <20220516095448.507876-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220516095448.507876-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 10:39:33 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: 572976 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1590:0:0:0:0 with SMTP id w16csp996173map; Mon, 16 May 2022 05:02:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9KgND2XWXGa5ccSeV+sKqY49sabz2KoN+6Sto6F84yaQzwuL/r7YWP0r8VpWCa6WyA3Y/ X-Received: by 2002:a9f:3592:0:b0:365:ef07:68c9 with SMTP id t18-20020a9f3592000000b00365ef0768c9mr5742753uad.60.1652702577003; Mon, 16 May 2022 05:02:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652702576; cv=none; d=google.com; s=arc-20160816; b=a6xRf2tVuPyHQdedAMyMKN/2YMRygNm6WzreowwETxrqvcUclMEHLzwnaGwUyHWsLZ NBDCrJXzBCfvSd9V+hYZlIx/m1Wa8zYsqlZUjgah5YjbODvomRxRL8uPZQQosry3Y0q+ 5zaRFQcY4bEwq0w6dH7t/DVqDaID/FSOobS1X9+YBr7Gj4yeDXn+y6Ew51bv69kag8yK blApbAtd7eIc8HAw0azTR3Z/NtuZseuQ3H+rtbCVIvY9ReKB6+9hS3i/lgPLwh84LGrV gFrcIkdfxCtnoYUbtYz806tXpF7p1vl93igsgD+nqvHeQOHPW9Z4JjoeD4eJpYwGvB8T d3lA== 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=zMgvRM8u/+o5DqNq6FJ1uTHjNZxDGHv80NUAhvPbEcF+p8nw5j+G02CgGqifRQapRS /f+mk+lvJh4wsZ4/WfgXR1YytZGy7EWLVrscWwmbvTtrmG6OvS4omX2DzUAaKR2izWzR Cx+gOSebE2EHnhPDcPEAhEp8JRmUSoZfeOVb4l9Tn7Zt6qHbx3jq1yUrHD4yIRa6FTOr du0foCwlvqIMBny1n1sfnL4tUJpbCn3ywE8I34zcO2gREZOWkoACiEcAxdunUgGH2XkP qWHwZQwNke4898QW+Ow2JaE9UIdqAH9cg2wwpCLnW6/t0CEFb/o4P+jYijrduPBVP8zS Nwew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bGr9sCMs; 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 b139-20020a1f1b91000000b00344d2e38cc2si1363451vkb.177.2022.05.16.05.02.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 May 2022 05:02:56 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bGr9sCMs; 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]:37342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqZRA-0007Ga-GW for patch@linaro.org; Mon, 16 May 2022 08:02:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49324) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqY8b-0001Rr-4X for qemu-devel@nongnu.org; Mon, 16 May 2022 06:39:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:53239) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqY8Z-0005ev-AF for qemu-devel@nongnu.org; Mon, 16 May 2022 06:39:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652697578; 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=bGr9sCMsurGKrcM/sTkwwnlPaNhSrTRizaj+IcMVNoVWkP7Dmn40rfF1pw6awUliiSbZWQ ZzTBsg99hT8TJBZs0TSKCv63/hreuA+TtHlkJlWNNaAB/P0Zn+A+kPBkK6hBnbnDKNXaHs lHB16kv8GGpXnPo5XTJt2wqGRorFDVQ= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-581-xnaEZzODPZ6X7ps8samlGA-1; Mon, 16 May 2022 06:39:37 -0400 X-MC-Unique: xnaEZzODPZ6X7ps8samlGA-1 Received: by mail-wr1-f69.google.com with SMTP id u11-20020a056000038b00b0020c9ea8b64fso3787258wrf.2 for ; Mon, 16 May 2022 03:39:37 -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=3rhvpRZKHzGu6b8lPdTMDko6yaOM9pjPWQLadrIOz93Q9PFAQqxVvccMGEP5twjm+8 5LE4WrifHEElk53bRAagK8Y3BuDhXap7Hl5uXx/qkCWjoonfr2i/s9GOdr5pDDI6wh6v EVNoN+btJuEoeFRrZg1YsBdtvJ+k8IjV5qN45Cw9ScaI/DCmG5/SdIXtvKpCuCOZgJh0 lveqSyUxIS8ZwdpwIlssFjvZ5IFftkDJ7/W9VjIqA1VFCkbe5CjLDFauh55+WrZfgRf9 SSQYL77bDEr73pD5N0QYaHSQVYv2SV/m/Vir74SDyhSh3sUuYXloxhvw6JbbNfZI3h5U 8pCg== X-Gm-Message-State: AOAM533ut6y5R3O69/r+Qq5kiRe7H4cDoGiow8kWpVGIihmT9cIf+buQ yyZBF/15yZYBqcEpsOWtlnwzg0pFUE5cyLcXkOUg92N0nHMP3eEEM/YduxvxvAlzI6G2MnXz6M1 aNHxtLAnakx8yL1JQsImmYGFjAvTj2jDFk7TeAlDyeh3ElnbzLnOECn6hdT3c X-Received: by 2002:a5d:64a5:0:b0:20d:af2:ed9f with SMTP id m5-20020a5d64a5000000b0020d0af2ed9fmr2524670wrp.271.1652697576186; Mon, 16 May 2022 03:39:36 -0700 (PDT) X-Received: by 2002:a5d:64a5:0:b0:20d:af2:ed9f with SMTP id m5-20020a5d64a5000000b0020d0af2ed9fmr2524642wrp.271.1652697575856; Mon, 16 May 2022 03:39:35 -0700 (PDT) Received: from redhat.com ([2.55.141.66]) by smtp.gmail.com with ESMTPSA id j10-20020adfc68a000000b0020c635ca28bsm9225755wrg.87.2022.05.16.03.39.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 03:39:35 -0700 (PDT) Date: Mon, 16 May 2022 06:39:33 -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 68/91] hw/virtio/vhost-user: don't suppress F_CONFIG when supported Message-ID: <20220516095448.507876-69-mst@redhat.com> References: <20220516095448.507876-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220516095448.507876-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 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 10:39:36 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: 572975 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1590:0:0:0:0 with SMTP id w16csp992539map; Mon, 16 May 2022 04:59:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz452CJhcOK8nAKxv1uFvcRWYkPj2PDZ2auygzBlSu1PNMtGKaJd+DQSVqWxe7jyFeI84oc X-Received: by 2002:a05:6214:20a2:b0:45a:7f91:6ffa with SMTP id 2-20020a05621420a200b0045a7f916ffamr14881091qvd.92.1652702346080; Mon, 16 May 2022 04:59:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652702346; cv=none; d=google.com; s=arc-20160816; b=wBu1G8ejVD5vy53qn8AdJ3FFqQbP2ScyX4d4WLon8Fxp8onzikhyc0NISEGQAVeFHP W4lZawQ9uo5pV7cTEVWoR/o5mouGtAVH+XgZSb02Lgup0RNlgroMGwgPO8u6XmyBbfCV cR04pt4QdvcrAWw7q+Iup+nTcnSjSY7J0rtsqgkJSJRqB8XEZtb9ZQksirhGaGP0jR0D /krDhhrqwTYcgm3LmnW4KwN0GSEw73n1Q5WqMJozs1OUq+2Xe8BHxuu81pwbjbUG6Bv9 HfGMhPZ+w+a9BKBRczfUANONsaIiFpUeyM3fjjwkjPF6kBhfBUU8aTKSUPvQAKkBNKUK VJLA== 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=S6OsIspB7XCUen2chub6BuI5HZrAlu2mjQ2mOIOWbPLSeSRB2k2zqzl8QQJ2Ve7anH hHup1mbTcd35qHv7g+E8lRbfVCOqlrxzCcraF6Mo1ttEcns+0KMGAR5PoUFyioD+Zk+l jzMCEKF3QCl1ckwMgLgd8j0wSPxMUPcveONlP0PdRQ5h8rGfh7tdOMryK8x4VCmIXda2 bOCEot5qesvUlBGRnWjakGg2X+opvtAuqH8135ss89afWw9e2bclYmz4aXbGzhQpMacG ksvSpbajmUzXRWERxOf2tyMBCpx9oPiNPtG0ssnmQ7AeXAP2j2D3Vh/46nhw5RO9Ty6r 8RVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="EIICgWV/"; 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 c10-20020ad45aea000000b004465ac9a7e9si6448338qvh.3.2022.05.16.04.59.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 May 2022 04:59:06 -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="EIICgWV/"; 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]:59456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqZNR-0002xC-Lw for patch@linaro.org; Mon, 16 May 2022 07:59:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49352) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqY8e-0001bD-NY for qemu-devel@nongnu.org; Mon, 16 May 2022 06:39:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47835) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqY8c-0005fI-LR for qemu-devel@nongnu.org; Mon, 16 May 2022 06:39:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652697582; 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=EIICgWV/jh212HR9wWy586qucFKDFGxCNdFu+taQecAudDnEZQvxjmeGpzn0NCnSHf2Fm7 tvwUCp4wHzzWE0y0r8IrGjTLw/+kvY52bP+8JK45UbBBn5SSnHTCQIfwSbNPNwfZZmf/Fz 72FXOVbwyQo0H0k/0fqzzRqpv0CpnGg= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-100-QuviZtQxNhmSwIZcHlC3cw-1; Mon, 16 May 2022 06:39:41 -0400 X-MC-Unique: QuviZtQxNhmSwIZcHlC3cw-1 Received: by mail-wm1-f70.google.com with SMTP id e9-20020a05600c4e4900b00394779649b1so10153671wmq.3 for ; Mon, 16 May 2022 03:39:40 -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=LgczT6mtkRgIiitVdGIqQXlTiNgjJmH9Bb22jtou/pZM4G2m7TBxHshg9m9yv25nY1 xQlHF+hXMFqNt7hsQ8DRUA2dMXee/mlgtvWioLpe20vUiDDRCAO3T2LKyugwTwI4u569 WVhmhKamKgeDbAByUOApE+y0uDAsvx3F2HYIeWUFejzSDzZGlslkLXF3v65TMflSNnon khX2mRn2jQ/LxdTIMpUyP6JcEwYAp1C6AP0ULI8To9CE0Mrq+a3o/6IvwiPKWawaFV/L 1HEfafrHn/rumdhFJVeU8dALw+hHGNf/FgM4YFfKbGn+5xBcCjaTlMW6UUjGTKmuXgL9 N7WA== X-Gm-Message-State: AOAM530FRu+gg+eEiiXVNwPBJ4wDD0RA9n1tNNS27+VSwV8956V+9OWN GfaiI7uCHzPIJckfIVoEYQ2BRxZpZi0AExtEke2kUpyOVBExpw9TxY+cvgvYAdKn36jZ8uC/5mz s4rQ5uk85/XWX7L94C9UBDrXsImUHcTKj0i4aZ/ZBenuptHI4ls+QLCHNTGXp X-Received: by 2002:a05:600c:3c9c:b0:394:8fb8:5589 with SMTP id bg28-20020a05600c3c9c00b003948fb85589mr16077537wmb.13.1652697579301; Mon, 16 May 2022 03:39:39 -0700 (PDT) X-Received: by 2002:a05:600c:3c9c:b0:394:8fb8:5589 with SMTP id bg28-20020a05600c3c9c00b003948fb85589mr16077503wmb.13.1652697578972; Mon, 16 May 2022 03:39:38 -0700 (PDT) Received: from redhat.com ([2.55.141.66]) by smtp.gmail.com with ESMTPSA id u23-20020a7bcb17000000b0039466988f6csm12692635wmj.31.2022.05.16.03.39.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 03:39:38 -0700 (PDT) Date: Mon, 16 May 2022 06:39:36 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= Subject: [PULL 69/91] virtio/vhost-user: dynamically assign VhostUserHostNotifiers Message-ID: <20220516095448.507876-70-mst@redhat.com> References: <20220516095448.507876-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220516095448.507876-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 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