From nobody Tue Feb 10 20:47:41 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1681488425; cv=none; d=zohomail.com; s=zohoarc; b=eF5NnnFQBIaw6aMWHBnlrc9jkJgo3lPzP4O1TDWQp09/fHkmaGV1OgsFMSueGPNFsh+YwWPz/TvhsvwmD0yx0CZRsOJapznpejq6+PL/KNwHZj5AGdyzCjPk8VvSva9mynTIknX87zsnbWvfUs13Oobkb5cOZNvUy8M90fYSZAo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681488425; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ac6OXeQsb/93HLbnF+qlx0Y/JMMvx4eaZHVLLhBGMnw=; b=Kd4nSnAnkxV4rlj3YZ3hD5m2J4WvIYqCZj6mX5P+gsXZbRJ5yTr9TfuvELWrQPTTdXW6ZPtWfOFgVG+lSHCgBF4T/SB6cfiX3QdwEnAfq5iq3qV9wmlrU79hmM3ckdP2aIhSlwMx2rkp/KcoCDftHMWsdSakunyrb86SYIOqoP8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1681488425461446.5649677788804; Fri, 14 Apr 2023 09:07:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pnLv7-0006mz-KE; Fri, 14 Apr 2023 12:05:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnLui-0006Rj-LH for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:47 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pnLue-0007yP-8E for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:39 -0400 Received: by mail-wm1-x332.google.com with SMTP id bi22-20020a05600c3d9600b003f0ad935166so2710937wmb.4 for ; Fri, 14 Apr 2023 09:04:35 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a1-20020a05600c224100b003f072b22dbbsm4557999wmm.16.2023.04.14.09.04.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 09:04:34 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id F07C51FFB8; Fri, 14 Apr 2023 17:04:33 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681488275; x=1684080275; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ac6OXeQsb/93HLbnF+qlx0Y/JMMvx4eaZHVLLhBGMnw=; b=RdaJOdn8FisdymopEgb4lrpOBYUrGosSgLoD8zlv0WiTwZFjeV8KjQmJ76VQFwJA7j MDcVYXVpkZXue1Tq0rsvBLC9raEUoAlAUhbpjKkLMCBQn7mnklvRuzxxFW2S37S4ddgx XqpsDd9xoSlltwSsw2qc03KPJzkl9hlM4EbqVPHY8BcE9C3X1kBgdZdlhJq3ImU/POl0 oBc24Tcrlx9iZc65cFw9J/AQ6IgK16TtyIEsKQp5kP9WOx/PWw84d8n3vHyIoqF7h1uV YVLsdc2AmQo1rgTB8dt+gsNrkFj49EhwJJQsHLq4JgrIZzcfWBmtoJl/cmCvrxlg6MpJ UcRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681488275; x=1684080275; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ac6OXeQsb/93HLbnF+qlx0Y/JMMvx4eaZHVLLhBGMnw=; b=VxucAbtAgDJR79N02sXIAIb6md16QYSBvdeIBnx0YcHegZBIR6f9Q6FRUwaudra+zz G3+46xO9WAsUu0JgCl+3T1TglDz9IkmjTJAZyOB5CSL/nOJ9RfDjGBcPsCeXlmB0oaSu q53cObcXbstXdKlGheF/vKfCTAXnF7MXqjNrjjgN4fLtNh7IbIdkxqiBtnjyr9bcHxO4 nUJnA5bq+unjdK06WlfG3dUWNQlpBTfSdLgFcIteckOw5qsj9X9rxcOQaghZxl3Efe0S DasE9T0rNRb7qUDWrVeEGwMWIjLx+ywveJoblX67ZzPrfQEMQje9Zadj054oRqK+HHz7 EJ0g== X-Gm-Message-State: AAQBX9fvASyxJTSrv3VU/x6/4fu1DmZ+2dN8HA0zANvMic7oCWk0xah7 jO0uutefv5kAdmFRCA3lqjLYvaaHIaXw/wYUD2k= X-Google-Smtp-Source: AKy350ZeDb18NdiZbLM234lqlDdrWUPlyZQiwRl/oZabytTlOgrzxxs4G0GTFzVbGdNyu4cFCFLcww== X-Received: by 2002:a05:600c:b49:b0:3ed:5d41:f998 with SMTP id k9-20020a05600c0b4900b003ed5d41f998mr4799643wmr.15.1681488274819; Fri, 14 Apr 2023 09:04:34 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Paolo Bonzini , "Michael S. Tsirkin" , virtio-fs@redhat.com, Erik Schilling , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Eduardo Habkost , Stefan Hajnoczi , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Jason Wang , Viresh Kumar , Mathieu Poirier , Gerd Hoffmann , Markus Armbruster Subject: [PATCH 01/12] hw/virtio: fix typo in VIRTIO_CONFIG_IRQ_IDX comments Date: Fri, 14 Apr 2023 17:04:22 +0100 Message-Id: <20230414160433.2096866-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414160433.2096866-1-alex.bennee@linaro.org> References: <20230414160433.2096866-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x332.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1681488427725100006 Fixes: 544f0278af (virtio: introduce macro VIRTIO_CONFIG_IRQ_IDX) Signed-off-by: Alex Benn=C3=A9e --- hw/display/vhost-user-gpu.c | 4 ++-- hw/net/virtio-net.c | 4 ++-- hw/virtio/vhost-user-fs.c | 4 ++-- hw/virtio/vhost-user-gpio.c | 2 +- hw/virtio/vhost-vsock-common.c | 4 ++-- hw/virtio/virtio-crypto.c | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index 71dfd956b8..7c61a7c3ac 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -489,7 +489,7 @@ vhost_user_gpu_guest_notifier_pending(VirtIODevice *vde= v, int idx) =20 /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ =20 @@ -506,7 +506,7 @@ vhost_user_gpu_guest_notifier_mask(VirtIODevice *vdev, = int idx, bool mask) =20 /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ =20 diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 53e1c32643..c53616a080 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3359,7 +3359,7 @@ static bool virtio_net_guest_notifier_pending(VirtIOD= evice *vdev, int idx) } /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return false */ =20 @@ -3391,7 +3391,7 @@ static void virtio_net_guest_notifier_mask(VirtIODevi= ce *vdev, int idx, } /* *Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ =20 diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index 83fc20e49e..49d699ffc2 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -161,7 +161,7 @@ static void vuf_guest_notifier_mask(VirtIODevice *vdev,= int idx, =20 /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ =20 @@ -177,7 +177,7 @@ static bool vuf_guest_notifier_pending(VirtIODevice *vd= ev, int idx) =20 /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ =20 diff --git a/hw/virtio/vhost-user-gpio.c b/hw/virtio/vhost-user-gpio.c index d6927b610a..3b013f2d0f 100644 --- a/hw/virtio/vhost-user-gpio.c +++ b/hw/virtio/vhost-user-gpio.c @@ -194,7 +194,7 @@ static void vu_gpio_guest_notifier_mask(VirtIODevice *v= dev, int idx, bool mask) =20 /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ =20 diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index d2b5519d5a..623bdf91cc 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -129,7 +129,7 @@ static void vhost_vsock_common_guest_notifier_mask(Virt= IODevice *vdev, int idx, =20 /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ =20 @@ -146,7 +146,7 @@ static bool vhost_vsock_common_guest_notifier_pending(V= irtIODevice *vdev, =20 /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ =20 diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index 802e1b9659..6b3e607329 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -1208,7 +1208,7 @@ static void virtio_crypto_guest_notifier_mask(VirtIOD= evice *vdev, int idx, =20 /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ =20 @@ -1227,7 +1227,7 @@ static bool virtio_crypto_guest_notifier_pending(Virt= IODevice *vdev, int idx) =20 /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ =20 --=20 2.39.2 From nobody Tue Feb 10 20:47:41 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1681488483; cv=none; d=zohomail.com; s=zohoarc; b=aTxKP+2BFLbee0DUzLrwshKobC91BT9V7S1FF6HVwIA7xzajPmVtA/iX9VH0FYUHHLwNh39PpWvW1E5wkn0Ye39fbbVBO16zKFRWCqZbY4v+ni8/yXcpCLm72nLy/S3pn6mUhmBNV3rts1qifaR/Xt/Jdfp5TZwf2LdI+gjPVsU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681488483; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KH5LwiCrOTvBSCuNpYnxQcsypFz8wThrZQsAnqkj0KQ=; b=A8CDa2yTuynlUXTvO4cO2QY8ZJQ0lrdhpxfa44xYrSXOzz4cSWFUpaUNzz4KvWpQc1747VpmtwZU1RKJDIa0ttHGYTLl0ucTJbn3uLU6uErOrfw2SW4Jbu/gQVdoC2O7uPDF455pjqFwdAmeY3Ck08xXE7FiaMQgu39jZQXY9cE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1681488483906272.5893207051862; Fri, 14 Apr 2023 09:08:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pnLvH-0007MB-Dj; Fri, 14 Apr 2023 12:05:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnLuk-0006S1-8A for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:47 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pnLui-0007yo-Ct for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:41 -0400 Received: by mail-wr1-x436.google.com with SMTP id l18so17963466wrb.9 for ; Fri, 14 Apr 2023 09:04:37 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id f17-20020adff8d1000000b002ef222822d5sm3855281wrq.74.2023.04.14.09.04.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 09:04:34 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 14A1B1FFBA; Fri, 14 Apr 2023 17:04:34 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681488276; x=1684080276; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KH5LwiCrOTvBSCuNpYnxQcsypFz8wThrZQsAnqkj0KQ=; b=Sdj8gbiDPb4tzbA4IYEDhfIDNGgL1BAPjP2dI1RtO2mEIx2afuqR93ODe/ARptkGMc OgrYZvwPP6KoAwSs5SjkutYwzuhrQlzjuuxr0G+o2LSvwb6Y1kvL6uIBJstB8P+wqtoe ZTeSWcIx1YWMUCxRL9wvz/X3q8WBD0U2tbl6amzaot3mxH6pnjcWbbuS5HFkfxiL+Bpy R53uVYPdY7iEmXSAU/7QL4cxkwptnm0QpBRPx3945N/rbB1S0votndKpLEDWbPuhOuy8 eyFgy61kF0I/tJipXdrdET3GXQ1o/RNL/WXgJfybuXLoV4+RUH/4OIyfpAieu92Jjpgs ueLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681488276; x=1684080276; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KH5LwiCrOTvBSCuNpYnxQcsypFz8wThrZQsAnqkj0KQ=; b=IvbW8syc2xUijUBtXHvA/Wau8DK/MSjoXmxi0S/qvnzpJWmcZEg/jN5Ke6BHeVj8oT TqS+qQeZ7jH5qNcxgww0wGtSYbyU5ZTEFiq5vMfAb83oAQpwQZTBv6P6y811Ed9ukcLh GAT/2ptNQhEt7ArzpyVgii2Sr64mAq+3Eg7lLV5qfyytka5p3oqTi1qZKgNDj9QlDUsL co6G2I8LsD1CfiX/fDaYIZSMiLGp7I3jycz68HDeC4afWGJEQvQeBLD7PaakG2B7tsAX OIrlRmLtnWu1Zfg9vWhuFzwe6zRznNWYqqyj2pGD7x/Wh+vF0yAwc3KhESGY+Xh59V8M Z8BQ== X-Gm-Message-State: AAQBX9fFnV4uDSwFRShnr3BJFU/NhIegutcjdIoByZndq9vNwB47o6kP 5ey2PZOLyKfiSks7rNsWVCQaDw== X-Google-Smtp-Source: AKy350b7UUcqk7rWrOD5NIBnjb+3ihRuH4AAZosRuVBnyVv+oWQcysHENDTjz8Gww8xeZylB/zD12A== X-Received: by 2002:adf:ee83:0:b0:2f5:39a2:fd99 with SMTP id b3-20020adfee83000000b002f539a2fd99mr4380381wro.71.1681488276102; Fri, 14 Apr 2023 09:04:36 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Paolo Bonzini , "Michael S. Tsirkin" , virtio-fs@redhat.com, Erik Schilling , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Eduardo Habkost , Stefan Hajnoczi , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Jason Wang , Viresh Kumar , Mathieu Poirier , Gerd Hoffmann , Markus Armbruster Subject: [PATCH 02/12] include/hw/virtio: document virtio_notify_config Date: Fri, 14 Apr 2023 17:04:23 +0100 Message-Id: <20230414160433.2096866-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414160433.2096866-1-alex.bennee@linaro.org> References: <20230414160433.2096866-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1681488486012100003 Signed-off-by: Alex Benn=C3=A9e --- include/hw/virtio/virtio.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index f236e94ca6..22ec098462 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -274,6 +274,13 @@ extern const VMStateInfo virtio_vmstate_info; =20 int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id); =20 +/** + * virtio_notify_config() - signal a change to device config + * @vdev: the virtio device + * + * Assuming the virtio device is up (VIRTIO_CONFIG_S_DRIVER_OK) this + * will trigger a guest interrupt and update the config version. + */ void virtio_notify_config(VirtIODevice *vdev); =20 bool virtio_queue_get_notification(VirtQueue *vq); --=20 2.39.2 From nobody Tue Feb 10 20:47:41 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1681488443; cv=none; d=zohomail.com; s=zohoarc; b=W7G7W9IjlxReYk3yIw0I91btxzxIMuYblnUurOCZjr+KAr838rHOejIzJwVz8YFAfmZ2KVhLOu87oJ0RW1tnP0kRGyWwIHTAvn8G+B4pTTCUpG6hMrHjyEUOJerwBW2o9sc0WbxknbzcEPrvkDXRlncmgS/o6axXxE9jAdnAFXo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681488443; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9tB5/chm/xr33XCg/P0FBnvaCeSkgyIRzyFrSzsSo0k=; b=BHCs8KAlj+f6mzKrqSuPzTaFbeDa1pdnoSrf2n9vwooati+QJgBQ4vxOlempjAVBVwmAqzAduDYKbMsLMGDcBtUHSLDPEgYR7EwNm+4iE4tr4Ge07w0b5IkVX95xSSGBNGOx1cTkOb98lFDFkzgce12dq1cI3/JyUfGJ4kWTaFA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1681488443133320.1085751624198; Fri, 14 Apr 2023 09:07:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pnLvD-00072H-1W; Fri, 14 Apr 2023 12:05:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnLui-0006Ri-LF for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:45 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pnLue-0007yT-Ka for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:39 -0400 Received: by mail-wm1-x334.google.com with SMTP id o6-20020a05600c4fc600b003ef6e6754c5so8378903wmq.5 for ; Fri, 14 Apr 2023 09:04:36 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id n16-20020a05600c3b9000b003dd1bd0b915sm8349256wms.22.2023.04.14.09.04.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 09:04:34 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 2C5471FFBB; Fri, 14 Apr 2023 17:04:34 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681488275; x=1684080275; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9tB5/chm/xr33XCg/P0FBnvaCeSkgyIRzyFrSzsSo0k=; b=nfBBBpcykoTEqquKkMJXT0yVy3hlK6944jFPb+9q/eLqYGwR6OqL1NKSzrzDZu4z5V aDTXWqxVpV6+PU1xcb26oAR56WQCQBD8X9IHbnAGfTGAvflVAZffs+BqKjdkaU8W0PCZ SOLzokotez54WLEyTiP8xIshpQDcPfgfVPWnEDoqCU/xZae902SRbgKJPNabP9k4sle9 d9MpjhkbOO5OchlXX/gtLJx0/DenVWuyB4C+olBQd9dKiLUB6kim93kCQlEQAoWlJtT3 g0k43sMM4yK4Od+sWIGf4FsN/Bz85625AhyE+dnsQsZPzIei7PpsvwgfRdUo5PS7kiFA pkKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681488275; x=1684080275; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9tB5/chm/xr33XCg/P0FBnvaCeSkgyIRzyFrSzsSo0k=; b=Hv8gIOqsBxoIxIeVt+SFo24y0HXqUXwXd+VJ1Q2NMIPCxYYeoW+jGf12l4P/J9djN4 oPQOe82UeL2X1w2bBS3KOeGP1edtd7qgQpc/bNxoInWfUthc45LSRnHdnV0sOAEghebX Gazf/GsE7GNn6bIkPuvzeSP18IKn1i07+v+zZzXM/VYrcP4tNgQIeIdFPZ8TPeDTsfL5 3lFY2+bprmmdB65/p9VCc6z9Q5USWMaoU9RgwmqoIDyYapuoLyJtClVGON938iWZqbRO f1mozvewWfWjHoMr1PASoD65WW9sJ2xfGKIs9PT9pTBMJAe8VxqBUlJ/jeBobDUnLhTG aFCA== X-Gm-Message-State: AAQBX9fZYpW5To9pm7bUussjW+K44EfOlU4RCFlhSmVJuTRsmp1k1qCD knQwXexLD/doISJ1YCt4heTlWQ== X-Google-Smtp-Source: AKy350YvjS/ZelnXfDEnB1bijmeYjpxKjPa5EsWPnLPx2fEs5vQ70XFc25Gh/PocxYHFNKg1xG+koQ== X-Received: by 2002:a7b:ca4d:0:b0:3f0:6ada:f445 with SMTP id m13-20020a7bca4d000000b003f06adaf445mr4631903wml.33.1681488275019; Fri, 14 Apr 2023 09:04:35 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Paolo Bonzini , "Michael S. Tsirkin" , virtio-fs@redhat.com, Erik Schilling , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Eduardo Habkost , Stefan Hajnoczi , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Jason Wang , Viresh Kumar , Mathieu Poirier , Gerd Hoffmann , Markus Armbruster Subject: [PATCH 03/12] include/hw/virtio: add kerneldoc for virtio_init Date: Fri, 14 Apr 2023 17:04:24 +0100 Message-Id: <20230414160433.2096866-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414160433.2096866-1-alex.bennee@linaro.org> References: <20230414160433.2096866-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1681488443716100001 Signed-off-by: Alex Benn=C3=A9e --- include/hw/virtio/virtio.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 22ec098462..1ba7a9dd74 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -217,6 +217,12 @@ struct VirtioDeviceClass { void virtio_instance_init_common(Object *proxy_obj, void *data, size_t vdev_size, const char *vdev_name); =20 +/** + * virtio_init() - initialise the common VirtIODevice structure + * @vdev: pointer to VirtIODevice + * @device_id: the VirtIO device ID (see virtio_ids.h) + * @config_size: size of the config space + */ void virtio_init(VirtIODevice *vdev, uint16_t device_id, size_t config_siz= e); =20 void virtio_cleanup(VirtIODevice *vdev); --=20 2.39.2 From nobody Tue Feb 10 20:47:41 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1681488363; cv=none; d=zohomail.com; s=zohoarc; b=UBCcMOT8a+8WirdaSAu0pOG3HjT1f/h2bGylTPiTVdgICl4riXbkJxZiWg84tAoAYcLbQ7A9OyrTAEI51thJUCoNyvHFfFXw2Vw9sSRhiz6oKizs5ljwWcX5x0WvpFgNUuBybdN9qO4TS23/l11DGaapaXu1MA48CXCiiXYDhZY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681488363; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uMkpUFkutd+rkxciDVz0OwgC4E2pyiYQdv8Xz2UBqBQ=; b=dhgZo68mjtI0uNzrAqsl+PDsI/Es4xc6vlrbfA+wwe3pwscnpkMrXgOrCigIzzjyArqcC2FjINLI4Z0xgJUa4GTGZYhpdrmg30Eg2f27gHun+RIrnuo7z3SmNXkVkFIWCHYjwPntUBOE65gOVGNlRRKEuOJR/6APHDFILoxj6Qs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1681488363721795.6277029521268; Fri, 14 Apr 2023 09:06:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pnLvQ-0007zf-LG; Fri, 14 Apr 2023 12:05:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnLuj-0006Rv-9g for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:47 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pnLuh-0007uB-7E for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:40 -0400 Received: by mail-wm1-x331.google.com with SMTP id r15so1090400wmo.1 for ; Fri, 14 Apr 2023 09:04:36 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id e2-20020a5d65c2000000b002ceacff44c7sm3807575wrw.83.2023.04.14.09.04.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 09:04:35 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 4416B1FFBC; Fri, 14 Apr 2023 17:04:34 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681488276; x=1684080276; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uMkpUFkutd+rkxciDVz0OwgC4E2pyiYQdv8Xz2UBqBQ=; b=ZDAQ4JDh77Z7nJTcc8Cyx2jNOtWdsdacBdEdLIskqZUBEJfISElHBRSNzucK5uIiom JLRB60GJHXNOJ70N5CXbtcxRu4KOiC5nZox3p4vMKUlDqMuHVeZoOmpG0fShBCKVXGse 8cjmUrEGkYhg45X0aBgkaxewoggWVhif7cYCESRCGaChFtW8N3Fn0q8nfxbcMFhNN9H2 8CPJu5Fx0qe+wIAWxJdg1tDPhEfvDzRTq7fddkWTkG/hDp/4aOQboduTYg3EnQT/fP9S v5N50Pxhcuo0JKZAfk1IVH6WY721yJDsb2oyBWqpoqYV0J9w3biurcufZt6UtStI0Guw LKtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681488276; x=1684080276; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uMkpUFkutd+rkxciDVz0OwgC4E2pyiYQdv8Xz2UBqBQ=; b=WDI1b+7JRsJZn69RVgpmIWCEDTcQNNSP167lgCzyZ5Lic9CuKt812CYk0uXoVEoTTA CDt1OdDmiMAmUWpwTqMX/F8R3CO2RDW2KrFwkB3bJuCMPHgXp6/HswXQFE6MSJgO0xpP lGK+pW5BQpuKXHNmgHxBWNBjIPwVQEi5YJttbsMCx/+doLiLux4CHDGcKNMnKOWl8XPG mN1O/xTcajLauBJpYCN39M3u1IaMfb7bYAGXVHR8B9C6AnigEt3I5Le0ZFrm2vLZlqgl GpBfPi7oDv2xu59mJmD49AseyckTFJOhPhB16JYXTq0MdGlP+qh4w1lKkjtNh08EQRY9 SbxA== X-Gm-Message-State: AAQBX9egJ9oLusml62CmX0L34sQAbfDriX64k5nmy1dDM1xYYILhhzXg nUQGy5lpkAqJ2Z3+bESKwqw7ow== X-Google-Smtp-Source: AKy350b+gWdgW8geLhlMjwQEXNAW/SY1Ts5ykdwuwZsP3ZlgVVB+OxUBXuL8FvCQa3gIZ4vLMi7zYw== X-Received: by 2002:a7b:c419:0:b0:3ee:672d:caa5 with SMTP id k25-20020a7bc419000000b003ee672dcaa5mr4433072wmi.17.1681488276405; Fri, 14 Apr 2023 09:04:36 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Paolo Bonzini , "Michael S. Tsirkin" , virtio-fs@redhat.com, Erik Schilling , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Eduardo Habkost , Stefan Hajnoczi , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Jason Wang , Viresh Kumar , Mathieu Poirier , Gerd Hoffmann , Markus Armbruster Subject: [PATCH 04/12] include/hw/virtio: document some more usage of notifiers Date: Fri, 14 Apr 2023 17:04:25 +0100 Message-Id: <20230414160433.2096866-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414160433.2096866-1-alex.bennee@linaro.org> References: <20230414160433.2096866-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1681488365460100003 Lets document some more of the core VirtIODevice structure. Signed-off-by: Alex Benn=C3=A9e --- include/hw/virtio/virtio.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 1ba7a9dd74..ef77e9ef0e 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -150,10 +150,18 @@ struct VirtIODevice VMChangeStateEntry *vmstate; char *bus_name; uint8_t device_endian; + /** + * @user_guest_notifier_mask: gate usage of ->guest_notifier_mask() ca= llback. + * This is used to suppress the masking of guest updates for + * vhost-user devices which are asynchronous by design. + */ bool use_guest_notifier_mask; AddressSpace *dma_as; QLIST_HEAD(, VirtQueue) *vector_queues; QTAILQ_ENTRY(VirtIODevice) next; + /** + * @config_notifier: the event notifier that handles config events + */ EventNotifier config_notifier; }; =20 --=20 2.39.2 From nobody Tue Feb 10 20:47:41 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1681488363; cv=none; d=zohomail.com; s=zohoarc; b=ltXgGgQ4eHMOgvY/HEZ9Cwgn9Q1DpLFHXy59UjK5075/qb/T6vuIBMBtxWg6U5PSo9gFAveK60Mbt5j6TFgqVfR2fbCPMx6D0wwGoq9qddRJ4CLNlxtRrDCp8YZbEG+npjpH9ofzZCJ4hsBwQc6FLHiVQJ/tIL8s0QIjEl76/NM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681488363; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dVJ8qhMaIj4CRymWVGCYn/io0gCtL6so6/34qr3Q4IM=; b=Dwl2yeDn7tG5CLPUP+sKKBQLZr6F0qkzrlNAVBqU1EanG0XtdVZUEBScDuWasISHYNbOLIxADEg4418MLW8sJjCIo4FCDMLMzD8xAUwLqV3mu+kDrbgxeAGr+eJnAmVRUDJ0YirT4W0zAZQ0PuAXn6VMt7iwn71TxqgGMbIFfhY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1681488363735489.244533327303; Fri, 14 Apr 2023 09:06:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pnLvH-0007M8-DX; Fri, 14 Apr 2023 12:05:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnLuk-0006S2-NB for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:47 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pnLuh-0007z1-NN for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:42 -0400 Received: by mail-wm1-x332.google.com with SMTP id q5so10625592wmo.4 for ; Fri, 14 Apr 2023 09:04:38 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id iv8-20020a05600c548800b003f09e294d5esm8088548wmb.6.2023.04.14.09.04.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 09:04:36 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 628E21FFBD; Fri, 14 Apr 2023 17:04:34 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681488277; x=1684080277; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dVJ8qhMaIj4CRymWVGCYn/io0gCtL6so6/34qr3Q4IM=; b=bds7EcdwVG3YzeinJ+j7Szh+sqm53B0ml1f/OflSsJMdq9zOhhRTZJsNTjzOBEtJdI 0wsKOP0OVooCTu07qsCjhk4qSqxCDvtPql2byUWGmX2NVwfnQZwAzKgIJX1ocqag5itW zKtlM9IR/rTFBue/1y3T9oPWTFr5NE3tsJ273gZPaiziwmsOpKX2K6O4vABTRFiMP0JA HfhBfyDsC97varWdJgcBymzSK6E99l8ouHZasn5jn7Y/UmB0GJ00i5QFOpQPv7a3JS38 tlSfeEzBMEtWep/AeEzXWiEAUJSrfXs1vAC2GyTiFyZ3cjKAfPfybVXPaCQmkbliLdX/ KMZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681488277; x=1684080277; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dVJ8qhMaIj4CRymWVGCYn/io0gCtL6so6/34qr3Q4IM=; b=X02/0v7SMQ3K1vZIZv3/Ajs+KOcLll5vMlJOocf2fItUci7i1LFMzfsDR67fZsgj9v LCQ614PcifAUfq7Kvw1hH3qEQ5taOL4pB8Rh+Kuh6e68zPB/hXgeMjqre6QiZhRB52iC d6KqlrOIVyJZAMjFFM3Tf7/zNJNRREa+ghPiosBmoSeIW+vMCLhXmg5PvsHyLtqg9/hF O78/tQLNsfVBZ2CxqKbdH/6q9AjCh73QilmYvh7vDOkd++NqxU4fwva9NofJbTVgalDU Y48mRmxIkWqvNWc/+L4y3XENNyoucpV4YToWYiVn+Ew9tpX1Ha98y/MhI0wxGjzm/TsA zerQ== X-Gm-Message-State: AAQBX9fc1q+Ejj69jFBm2iujLzL0LCyQLD427XXKFfUHjDwmxMc97QQ+ qkaBGJo/mh+S3FFeBlWU2oSRuA== X-Google-Smtp-Source: AKy350Z76Xd2kQCC3JlZ6YdwaaiRJVfVglkcuAeqoYjWudeBfTh8bNhTDhRqTvDtQ8eiMZSmFpcfmA== X-Received: by 2002:a1c:e903:0:b0:3f0:a023:2614 with SMTP id q3-20020a1ce903000000b003f0a0232614mr4592475wmc.6.1681488277344; Fri, 14 Apr 2023 09:04:37 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Paolo Bonzini , "Michael S. Tsirkin" , virtio-fs@redhat.com, Erik Schilling , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Eduardo Habkost , Stefan Hajnoczi , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Jason Wang , Viresh Kumar , Mathieu Poirier , Gerd Hoffmann , Markus Armbruster Subject: [PATCH 05/12] virtio: add generic vhost-user-device Date: Fri, 14 Apr 2023 17:04:26 +0100 Message-Id: <20230414160433.2096866-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414160433.2096866-1-alex.bennee@linaro.org> References: <20230414160433.2096866-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x332.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1681488365428100001 In theory we shouldn't need to repeat so much boilerplate to support vhost-user backends. This provides a generic vhost-user-device for which the user needs to provide the few bits of information that aren't currently provided by the vhost-user protocol. This should provide a baseline implementation from which the other vhost-user stub can specialise. Signed-off-by: Alex Benn=C3=A9e --- include/hw/virtio/vhost-user-device.h | 32 +++ hw/virtio/vhost-user-device.c | 303 ++++++++++++++++++++++++++ hw/virtio/meson.build | 2 + 3 files changed, 337 insertions(+) create mode 100644 include/hw/virtio/vhost-user-device.h create mode 100644 hw/virtio/vhost-user-device.c diff --git a/include/hw/virtio/vhost-user-device.h b/include/hw/virtio/vhos= t-user-device.h new file mode 100644 index 0000000000..8d77f06721 --- /dev/null +++ b/include/hw/virtio/vhost-user-device.h @@ -0,0 +1,32 @@ +/* + * Vhost-user generic virtio device + * + * Copyright (c) 2023 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef QEMU_VHOST_USER_DEVICE_H +#define QEMU_VHOST_USER_DEVICE_H + +#include "hw/virtio/vhost.h" +#include "hw/virtio/vhost-user.h" + +#define TYPE_VHOST_USER_DEVICE "vhost-user-device" +OBJECT_DECLARE_SIMPLE_TYPE(VHostUserDevice, VHOST_USER_DEVICE) + +struct VHostUserDevice { + VirtIODevice parent; + /* Properties */ + CharBackend chardev; + uint16_t virtio_id; + uint32_t num_vqs; + /* State tracking */ + VhostUserState vhost_user; + struct vhost_virtqueue *vhost_vq; + struct vhost_dev vhost_dev; + GPtrArray *vqs; + bool connected; +}; + +#endif /* QEMU_VHOST_USER_DEVICE_H */ diff --git a/hw/virtio/vhost-user-device.c b/hw/virtio/vhost-user-device.c new file mode 100644 index 0000000000..bfbf3b29cb --- /dev/null +++ b/hw/virtio/vhost-user-device.c @@ -0,0 +1,303 @@ +/* + * Generic vhost-user stub. This can be used to connect to any + * vhost-user backend. All configuration details must be handled by + * the vhost-user daemon itself + * + * Copyright (c) 2023 Linaro Ltd + * Author: Alex Benn=C3=A9e + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/qdev-properties.h" +#include "hw/virtio/virtio-bus.h" +#include "hw/virtio/vhost-user-device.h" +#include "qemu/error-report.h" + +static void vud_start(VirtIODevice *vdev) +{ + BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); + VHostUserDevice *vud =3D VHOST_USER_DEVICE(vdev); + int ret, i; + + if (!k->set_guest_notifiers) { + error_report("binding does not support guest notifiers"); + return; + } + + ret =3D vhost_dev_enable_notifiers(&vud->vhost_dev, vdev); + if (ret < 0) { + error_report("Error enabling host notifiers: %d", -ret); + return; + } + + ret =3D k->set_guest_notifiers(qbus->parent, vud->vhost_dev.nvqs, true= ); + if (ret < 0) { + error_report("Error binding guest notifier: %d", -ret); + goto err_host_notifiers; + } + + vud->vhost_dev.acked_features =3D vdev->guest_features; + + ret =3D vhost_dev_start(&vud->vhost_dev, vdev, true); + if (ret < 0) { + error_report("Error starting vhost-user-device: %d", -ret); + goto err_guest_notifiers; + } + + /* + * guest_notifier_mask/pending not used yet, so just unmask + * everything here. virtio-pci will do the right thing by + * enabling/disabling irqfd. + */ + for (i =3D 0; i < vud->vhost_dev.nvqs; i++) { + vhost_virtqueue_mask(&vud->vhost_dev, vdev, i, false); + } + + return; + +err_guest_notifiers: + k->set_guest_notifiers(qbus->parent, vud->vhost_dev.nvqs, false); +err_host_notifiers: + vhost_dev_disable_notifiers(&vud->vhost_dev, vdev); +} + +static void vud_stop(VirtIODevice *vdev) +{ + VHostUserDevice *vud =3D VHOST_USER_DEVICE(vdev); + BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); + int ret; + + if (!k->set_guest_notifiers) { + return; + } + + vhost_dev_stop(&vud->vhost_dev, vdev, true); + + ret =3D k->set_guest_notifiers(qbus->parent, vud->vhost_dev.nvqs, fals= e); + if (ret < 0) { + error_report("vhost guest notifier cleanup failed: %d", ret); + return; + } + + vhost_dev_disable_notifiers(&vud->vhost_dev, vdev); +} + +static void vud_set_status(VirtIODevice *vdev, uint8_t status) +{ + VHostUserDevice *vud =3D VHOST_USER_DEVICE(vdev); + bool should_start =3D virtio_device_should_start(vdev, status); + + if (vhost_dev_is_started(&vud->vhost_dev) =3D=3D should_start) { + return; + } + + if (should_start) { + vud_start(vdev); + } else { + vud_stop(vdev); + } +} + +/* + * For an implementation where everything is delegated to the backend + * we don't do anything other than return the full feature set offered + * by the daemon (module the reserved feature bit). + */ +static uint64_t vud_get_features(VirtIODevice *vdev, + uint64_t requested_features, Error **errp) +{ + VHostUserDevice *vud =3D VHOST_USER_DEVICE(vdev); + /* This should be set when the vhost connection initialises */ + g_assert(vud->vhost_dev.features); + return vud->vhost_dev.features & ~(1ULL << VHOST_USER_F_PROTOCOL_FEATU= RES); +} + +static void vud_handle_output(VirtIODevice *vdev, VirtQueue *vq) +{ + /* + * Not normally called; it's the daemon that handles the queue; + * however virtio's cleanup path can call this. + */ +} + +static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserDevice *vud) +{ + vhost_user_cleanup(&vud->vhost_user); + + for (int i =3D 0; i < vud->num_vqs; i++) { + VirtQueue *vq =3D g_ptr_array_index(vud->vqs, i); + virtio_delete_queue(vq); + } + + virtio_cleanup(vdev); +} + +static int vud_connect(DeviceState *dev) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserDevice *vud =3D VHOST_USER_DEVICE(vdev); + + if (vud->connected) { + return 0; + } + vud->connected =3D true; + + /* restore vhost state */ + if (virtio_device_started(vdev, vdev->status)) { + vud_start(vdev); + } + + return 0; +} + +static void vud_disconnect(DeviceState *dev) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserDevice *vud =3D VHOST_USER_DEVICE(vdev); + + if (!vud->connected) { + return; + } + vud->connected =3D false; + + if (vhost_dev_is_started(&vud->vhost_dev)) { + vud_stop(vdev); + } +} + +static void vud_event(void *opaque, QEMUChrEvent event) +{ + DeviceState *dev =3D opaque; + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserDevice *vud =3D VHOST_USER_DEVICE(vdev); + + switch (event) { + case CHR_EVENT_OPENED: + if (vud_connect(dev) < 0) { + qemu_chr_fe_disconnect(&vud->chardev); + return; + } + break; + case CHR_EVENT_CLOSED: + vud_disconnect(dev); + break; + case CHR_EVENT_BREAK: + case CHR_EVENT_MUX_IN: + case CHR_EVENT_MUX_OUT: + /* Ignore */ + break; + } +} + +static void vud_device_realize(DeviceState *dev, Error **errp) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserDevice *vud =3D VHOST_USER_DEVICE(dev); + int ret; + + if (!vud->chardev.chr) { + error_setg(errp, "vhost-user-device: missing chardev"); + return; + } + + if (!vud->virtio_id) { + error_setg(errp, "vhost-user-device: need to define device id"); + return; + } + + if (!vud->num_vqs) { + vud->num_vqs =3D 1; /* reasonable default? */ + } + + if (!vhost_user_init(&vud->vhost_user, &vud->chardev, errp)) { + return; + } + + virtio_init(vdev, vud->virtio_id, 0); + + /* + * Disable guest notifiers, by default all notifications will be via t= he + * asynchronous vhost-user socket. + */ + vdev->use_guest_notifier_mask =3D false; + + /* Allocate queues */ + vud->vqs =3D g_ptr_array_sized_new(vud->num_vqs); + for (int i =3D 0; i < vud->num_vqs; i++) { + g_ptr_array_add(vud->vqs, + virtio_add_queue(vdev, 4, vud_handle_output)); + } + + vud->vhost_dev.nvqs =3D vud->num_vqs; + vud->vhost_dev.vqs =3D g_new0(struct vhost_virtqueue, vud->vhost_dev.n= vqs); + + /* connect to backend */ + fprintf(stderr, "%s: doing vhost_dev_init()\n", __func__); + ret =3D vhost_dev_init(&vud->vhost_dev, &vud->vhost_user, + VHOST_BACKEND_TYPE_USER, 0, errp); + + if (ret < 0) { + do_vhost_user_cleanup(vdev, vud); + } + + qemu_chr_fe_set_handlers(&vud->chardev, NULL, NULL, vud_event, NULL, + dev, NULL, true); +} + +static void vud_device_unrealize(DeviceState *dev) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserDevice *vud =3D VHOST_USER_DEVICE(dev); + struct vhost_virtqueue *vhost_vqs =3D vud->vhost_dev.vqs; + + /* This will stop vhost backend if appropriate. */ + vud_set_status(vdev, 0); + vhost_dev_cleanup(&vud->vhost_dev); + g_free(vhost_vqs); + do_vhost_user_cleanup(vdev, vud); +} + +static const VMStateDescription vud_vmstate =3D { + .name =3D "vhost-user-device", + .unmigratable =3D 1, +}; + +static Property vud_properties[] =3D { + DEFINE_PROP_CHR("chardev", VHostUserDevice, chardev), + DEFINE_PROP_UINT16("virtio-id", VHostUserDevice, virtio_id, 0), + DEFINE_PROP_UINT32("num_vqs", VHostUserDevice, num_vqs, 1), + DEFINE_PROP_END_OF_LIST(), +}; + +static void vud_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_CLASS(klass); + + device_class_set_props(dc, vud_properties); + dc->vmsd =3D &vud_vmstate; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); + vdc->realize =3D vud_device_realize; + vdc->unrealize =3D vud_device_unrealize; + vdc->get_features =3D vud_get_features; + vdc->set_status =3D vud_set_status; +} + +static const TypeInfo vud_info =3D { + .name =3D TYPE_VHOST_USER_DEVICE, + .parent =3D TYPE_VIRTIO_DEVICE, + .instance_size =3D sizeof(VHostUserDevice), + .class_init =3D vud_class_init, +}; + +static void vud_register_types(void) +{ + type_register_static(&vud_info); +} + +type_init(vud_register_types) diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index bdec78bfc6..43e5fa3f7d 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -10,7 +10,9 @@ specific_virtio_ss.add(files('virtio-config-io.c', 'virti= o-qmp.c')) if have_vhost specific_virtio_ss.add(files('vhost.c', 'vhost-backend.c', 'vhost-iova-t= ree.c')) if have_vhost_user + # fixme - this really should be generic specific_virtio_ss.add(files('vhost-user.c')) + softmmu_virtio_ss.add(files('vhost-user-device.c')) endif if have_vhost_vdpa specific_virtio_ss.add(files('vhost-vdpa.c', 'vhost-shadow-virtqueue.c= ')) --=20 2.39.2 From nobody Tue Feb 10 20:47:41 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1681488341; cv=none; d=zohomail.com; s=zohoarc; b=S/KYNpsEqF14RP5+Nm70jc1VZHcT5GR8ndfuVnOFflcYqasBqRgjcB+ZCL69xZiYGgYSV0U4k7CrtX2bKUsM0fYS3AD9p+PEWgVBnyhqnzE8qylA3CTenXfGPWQTOXdsgqILxRMXgNTl/4Lkmtca4/vZruC0/AkZV+gSSEkCPxs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681488341; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qzkS2+7HizjSf39YyqA8Cq2rMvvTCIuBSsfqveXGmXY=; b=dBvvDO+N3ciOuCtuMQF7BcmZWgZ+4cjiV0S+jIiMD9d4yGK9Rl5bzs5OQg/479fzLfPTSkzDRs1A6bHGBQHjHLLGwLFoJDfPVtYfH0N1Lb/dhxFDkV1IDboei+pt9EkPe7fHbKSBiaTvrkFBwA7NCn3TC91s0TCY0GoI72OP81A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16814883417181020.2145802004707; Fri, 14 Apr 2023 09:05:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pnLv2-0006h4-Jn; Fri, 14 Apr 2023 12:05:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnLul-0006SG-Ah for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:47 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pnLui-0007zV-L1 for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:43 -0400 Received: by mail-wr1-x435.google.com with SMTP id v6so18017484wrv.8 for ; Fri, 14 Apr 2023 09:04:39 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id y18-20020adff6d2000000b002daf0b52598sm3865268wrp.18.2023.04.14.09.04.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 09:04:36 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 7DC7E1FFBE; Fri, 14 Apr 2023 17:04:34 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681488279; x=1684080279; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qzkS2+7HizjSf39YyqA8Cq2rMvvTCIuBSsfqveXGmXY=; b=oQki8JcCOBUDtxvcJydmEBkY0xGHK9Li0fWLu09OdcGLn/8/v105xW8W85N/lzoP7e aERWlwhD6ZoSOONni39zElEg3RM8o1w2rB8xzsYSGulSfCwSlJeACwdvvMHZURW6fF29 qzxcOOyPgNbLR2AELKGqAyDdL39d7FRgV8WBznDT7njOrlBu6vsFkUVPrfoeMp4fnTCk 9mij9WAJEFdNjNkV+/gO/ahfI/SSVohQtBZUuUY0kDg1jLxlpiwF57M52OYnY9eAXv40 Hy0/DbP0tLZ6/vHfilDyGeSEXqmgsn8hEU7mxV+TXVkNxlxO0+rSL35Zrt3NsKHQxgTb 0JrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681488279; x=1684080279; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qzkS2+7HizjSf39YyqA8Cq2rMvvTCIuBSsfqveXGmXY=; b=Ihprbsh7NiyHdMIIaFtxWpUyD9eUQyfPGRVdb8T7S/yZBWH/5nhbzKVRXiHS8xp/Xt UpSKcUn2rl0JAaRZ9X8l2DY6+i6pGV0j+JttP5lIBxwVc2bX3UYZlCoYfoVJlub4x5W5 EoOf22aRdN4TJTcZWfVMGIhfj5wH3roOHbQ2zK2agV08NNdiLkut0l646AKuhYiRIsWu 2/venQ1A7Y3wgeDt1R71vgj43F0LE7f4p88i4Mbgt34qL48tiGkL9vCvzB2e6Ks8gnfk bGb/gH6ac49Et7Q69mq/B15fSij5kwlOyR/cv8uhtS3KF4WX4QKyBZ5jWubgyWfLaF/T vl2Q== X-Gm-Message-State: AAQBX9dj5Ii/wtw8HVimCQhPAjHGGgw4ME/rECk/JP7f3y8KXYkg/iDs 7cFsdjMp9loVkpwWS2E3LT732w== X-Google-Smtp-Source: AKy350btELHfse4fJA2g0sJAEKYVihxwFO960wwCSDYwlcSOORMLZo7jYykL/gTAU94MS1glDqjR3g== X-Received: by 2002:a05:6000:1818:b0:2f5:4b0b:a323 with SMTP id m24-20020a056000181800b002f54b0ba323mr4631230wrh.7.1681488278774; Fri, 14 Apr 2023 09:04:38 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Paolo Bonzini , "Michael S. Tsirkin" , virtio-fs@redhat.com, Erik Schilling , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Eduardo Habkost , Stefan Hajnoczi , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Jason Wang , Viresh Kumar , Mathieu Poirier , Gerd Hoffmann , Markus Armbruster Subject: [PATCH 06/12] virtio: add PCI stub for vhost-user-device Date: Fri, 14 Apr 2023 17:04:27 +0100 Message-Id: <20230414160433.2096866-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414160433.2096866-1-alex.bennee@linaro.org> References: <20230414160433.2096866-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1681488343198100002 This is all pretty much boilerplate. Signed-off-by: Alex Benn=C3=A9e Tested-by: Erik Schilling --- hw/virtio/vhost-user-device-pci.c | 71 +++++++++++++++++++++++++++++++ hw/virtio/meson.build | 1 + 2 files changed, 72 insertions(+) create mode 100644 hw/virtio/vhost-user-device-pci.c diff --git a/hw/virtio/vhost-user-device-pci.c b/hw/virtio/vhost-user-devic= e-pci.c new file mode 100644 index 0000000000..96bf99d5fd --- /dev/null +++ b/hw/virtio/vhost-user-device-pci.c @@ -0,0 +1,71 @@ +/* + * Vhost-user generic virtio device PCI glue + * + * Copyright (c) 2023 Linaro Ltd + * Author: Alex Benn=C3=A9e + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "hw/qdev-properties.h" +#include "hw/virtio/vhost-user-device.h" +#include "hw/virtio/virtio-pci.h" + +struct VHostUserDevicePCI { + VirtIOPCIProxy parent_obj; + VHostUserDevice vdev; +}; + +typedef struct VHostUserDevicePCI VHostUserDevicePCI; + +#define TYPE_VHOST_USER_DEVICE_PCI "vhost-user-device-pci-base" + +DECLARE_INSTANCE_CHECKER(VHostUserDevicePCI, + VHOST_USER_DEVICE_PCI, + TYPE_VHOST_USER_DEVICE_PCI) + +static void vhost_user_device_pci_realize(VirtIOPCIProxy *vpci_dev, Error = **errp) +{ + VHostUserDevicePCI *dev =3D VHOST_USER_DEVICE_PCI(vpci_dev); + DeviceState *vdev =3D DEVICE(&dev->vdev); + + vpci_dev->nvectors =3D 1; + qdev_realize(vdev, BUS(&vpci_dev->bus), errp); +} + +static void vhost_user_device_pci_class_init(ObjectClass *klass, void *dat= a) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + VirtioPCIClass *k =3D VIRTIO_PCI_CLASS(klass); + PCIDeviceClass *pcidev_k =3D PCI_DEVICE_CLASS(klass); + k->realize =3D vhost_user_device_pci_realize; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); + pcidev_k->vendor_id =3D PCI_VENDOR_ID_REDHAT_QUMRANET; + pcidev_k->device_id =3D 0; /* Set by virtio-pci based on virtio id */ + pcidev_k->revision =3D 0x00; + pcidev_k->class_id =3D PCI_CLASS_COMMUNICATION_OTHER; +} + +static void vhost_user_device_pci_instance_init(Object *obj) +{ + VHostUserDevicePCI *dev =3D VHOST_USER_DEVICE_PCI(obj); + + virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), + TYPE_VHOST_USER_DEVICE); +} + +static const VirtioPCIDeviceTypeInfo vhost_user_device_pci_info =3D { + .base_name =3D TYPE_VHOST_USER_DEVICE_PCI, + .non_transitional_name =3D "vhost-user-device-pci", + .instance_size =3D sizeof(VHostUserDevicePCI), + .instance_init =3D vhost_user_device_pci_instance_init, + .class_init =3D vhost_user_device_pci_class_init, +}; + +static void vhost_user_device_pci_register(void) +{ + virtio_pci_types_register(&vhost_user_device_pci_info); +} + +type_init(vhost_user_device_pci_register); diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index 43e5fa3f7d..c0a86b94ae 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -13,6 +13,7 @@ if have_vhost # fixme - this really should be generic specific_virtio_ss.add(files('vhost-user.c')) softmmu_virtio_ss.add(files('vhost-user-device.c')) + softmmu_virtio_ss.add(when: 'CONFIG_VIRTIO_PCI', if_true: files('vhost= -user-device-pci.c')) endif if have_vhost_vdpa specific_virtio_ss.add(files('vhost-vdpa.c', 'vhost-shadow-virtqueue.c= ')) --=20 2.39.2 From nobody Tue Feb 10 20:47:41 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1681488501; cv=none; d=zohomail.com; s=zohoarc; b=jkazkqi+kpeRq3BnbV4VQ7USiszHxj2DmEo84Ghb0x0W4anwutfHOYJanOkm4MWDorBaswbLt2tWjqIv/crZ3voizGFoJP3vX7U5ACUq7aNxhbGiHzOLNIlp4u8nOcKuUAR4f+Syyzw45hU1CTxPu0l9IwD+9q8Phg4YRRaaD4Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681488501; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nVPcgNqV4+yTyF7JyxZthOMz/9y/APO3HAlemN7QWn4=; b=EzxmRRw0L0IjaBOQByZOpLkbqCzy51IkmKrBzZ8ZzDiEXrcNF2c263mV4wuQzrDUYCV3oytErTcNr0S7FEjtwe3g22rVEjKXl6svPvO5MQ5iXY/y5EaFik9jDKkT94xGJaytT/GsAzRIKyvNO3cqcGKXmgyS5HIyAlhk9NyrRYc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 168148850102225.495580355157472; Fri, 14 Apr 2023 09:08:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pnLvN-0007sG-70; Fri, 14 Apr 2023 12:05:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnLuk-0006S0-79 for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:47 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pnLuh-0007zC-In for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:41 -0400 Received: by mail-wr1-x42b.google.com with SMTP id l18so17963535wrb.9 for ; Fri, 14 Apr 2023 09:04:38 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id q13-20020adfcd8d000000b002e51195a3e2sm3832381wrj.79.2023.04.14.09.04.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 09:04:36 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 94B431FFBF; Fri, 14 Apr 2023 17:04:34 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681488277; x=1684080277; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nVPcgNqV4+yTyF7JyxZthOMz/9y/APO3HAlemN7QWn4=; b=Km+2PWccfqrAl6iXS+0QxP9ByJ0556FYve9PXciZyQzU1CJJ8I8scFfQK8XXBmXy5v kxCP5k0lOtBtlyhcAQ6Ik/03qQ6RmDQ6uS/fJhi6djAoAwMq8iy9MjYzmVFdJPZwQIYs Bj+0/RjbcQyU3webm69fVm/HEFtLNKhM4/Tnrdw3QUNmsG/9SS6iGWE55Aa7SiqLAoqh 90DyjEPjRGMgXevBbAaVDpLPWg2yNa9I2RZRk3nqI6VTAuqjMVHRZqx4TD0ZJXVph8Am Jq1XAUITDjnI/vmRKZJwwha5MCRh7FIWCZ9u/LW5ZdTsL27nmqk208OjB6hTVp15RfWV ZSzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681488277; x=1684080277; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nVPcgNqV4+yTyF7JyxZthOMz/9y/APO3HAlemN7QWn4=; b=F7nJUW9Q52nuaZjp2tL+/3heWuzYlmRnsm2hi435ExjlC9fTOXnV2FVbOpMtuEx5l6 VD4ILVi7kvsGuBhAHN5XuLItNavQT4PGq0urN5bddtlP90uxhUdsR98c7Fv8tK29ni2e L9I+JgFoEf+n5d4rE0FlUJefI+j8hkAwCzuWRz3uXjB9wxH0A4pJW8IsvlDv5WXu4KVU +y0TMw5xwRdoaG0zIIrIGD570Rxbw+ikV1S3bHlDXsUlIbyOnGBlX9XPUfw8PBtzG4jf bG4gUUDsQ7yjYyN0JqP3FQRVqdXbKjGCIDV2t99u48xNX7C59zvokHSlQb990fa4uyM2 XopA== X-Gm-Message-State: AAQBX9epdK6Is+ZgaCF2Tw/rpjPOQzOd/wKG3zEaSEq245meOlBkESae z0oRt3jFbfFQd6AahxhC6Hd+yw== X-Google-Smtp-Source: AKy350Y4JrxIzaH4hEXaTATTcEHOHoCPS/2+I5omQlxT1drifGUdW6/mcGhGj0Gu6/wKfm8NwYaBjQ== X-Received: by 2002:adf:e407:0:b0:2f4:cf53:c961 with SMTP id g7-20020adfe407000000b002f4cf53c961mr4436312wrm.54.1681488277718; Fri, 14 Apr 2023 09:04:37 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Paolo Bonzini , "Michael S. Tsirkin" , virtio-fs@redhat.com, Erik Schilling , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Eduardo Habkost , Stefan Hajnoczi , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Jason Wang , Viresh Kumar , Mathieu Poirier , Gerd Hoffmann , Markus Armbruster Subject: [PATCH 07/12] include: attempt to document device_class_set_props Date: Fri, 14 Apr 2023 17:04:28 +0100 Message-Id: <20230414160433.2096866-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414160433.2096866-1-alex.bennee@linaro.org> References: <20230414160433.2096866-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1681488502456100007 I'm still not sure how I achieve by use case of the parent class defining the following properties: static Property vud_properties[] =3D { DEFINE_PROP_CHR("chardev", VHostUserDevice, chardev), DEFINE_PROP_UINT16("id", VHostUserDevice, id, 0), DEFINE_PROP_UINT32("num_vqs", VHostUserDevice, num_vqs, 1), DEFINE_PROP_END_OF_LIST(), }; But for the specialisation of the class I want the id to default to the actual device id, e.g.: static Property vu_rng_properties[] =3D { DEFINE_PROP_UINT16("id", VHostUserDevice, id, VIRTIO_ID_RNG), DEFINE_PROP_UINT32("num_vqs", VHostUserDevice, num_vqs, 1), DEFINE_PROP_END_OF_LIST(), }; And so far the API for doing that isn't super clear. Signed-off-by: Alex Benn=C3=A9e --- include/hw/qdev-core.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index bd50ad5ee1..d4bbc30c92 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -776,6 +776,15 @@ BusState *sysbus_get_default(void); char *qdev_get_fw_dev_path(DeviceState *dev); char *qdev_get_own_fw_dev_path_from_handler(BusState *bus, DeviceState *de= v); =20 +/** + * device_class_set_props(): add a set of properties to an device + * @dc: the parent DeviceClass all devices inherit + * @props: an array of properties, terminate by DEFINE_PROP_END_OF_LIST() + * + * This will add a set of properties to the object. It will fault if + * you attempt to add an existing property defined by a parent class. + * To modify an inherited property you need to use???? + */ void device_class_set_props(DeviceClass *dc, Property *props); =20 /** --=20 2.39.2 From nobody Tue Feb 10 20:47:41 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1681488354; cv=none; d=zohomail.com; s=zohoarc; b=Xu6dIDuvOZHPpxroVU9bFi1gdjqmcFwS8gJO2zSVHKxtPl0kR4EM8P5csoWQCI/h9N6TiGl37qqaCYxycQYpyIb069uOGgPb5/eHZcvdVfRj/fczcVECP+Eae/O6xL+yVD2zhSCEGvsqwS6DvgBCxUp8nvimtyXPmK6ZGVbwld0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681488354; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=87Eys71a5bFDwpsmcqiXjalsGOMTQZkXpUaxljHCLjI=; b=QQvp4gNfMGqKTi+KPqz8oxIyHIMhSQ2jbmYP/0mdvqDB6xPJwKWlkIB7QV6il0IB6eNYO2mTaY6okDtwidoknb0KnMhoEZnOuCyPJKwMDbRld1RMJw+3VpvpxT19eSZD15l5zmb4GfBavQ/9pjkxj+NEssj3whLFRro4HF9T0z0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1681488354739982.6509747425933; Fri, 14 Apr 2023 09:05:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pnLvB-0006qo-Fw; Fri, 14 Apr 2023 12:05:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnLuk-0006S3-Q2 for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:47 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pnLui-0007z7-Du for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:42 -0400 Received: by mail-wr1-x431.google.com with SMTP id r20so2227606wra.5 for ; Fri, 14 Apr 2023 09:04:38 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id g4-20020a5d5404000000b002efb121b75fsm3830886wrv.58.2023.04.14.09.04.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 09:04:36 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id BBB191FFB7; Fri, 14 Apr 2023 17:04:34 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681488277; x=1684080277; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=87Eys71a5bFDwpsmcqiXjalsGOMTQZkXpUaxljHCLjI=; b=Lkv7hQWdIlA2sElrxSUtHPNg4UUF+/pMmmAB5iBfBiSP6hz/+L1/iAytdkjdaALLr8 F1GVjHMQ99qOBDE23t2pXSpoFe0kUvHQBbNg7jPSYR/BVBtOo3hRjuhRfNcd88/luB9N rBpCIzB1Y9tY+p72b+QRHqRtXGJC+4USvPU9TqNQZbbwJEfMPD0ivv8p/sNwonnMdH76 2IrAaCqe7w7YVX8cHy543Q2idXIgyZZDDDlg6pxvpUQMMzbCmVhfle3Clmw7mYNcKfE5 ANOQFG9xHDCz5+tkO6hd9ozTrgmcX9boEez6MwSvCZt4YwKcXBMe3PgChfnO+LdSdwG/ YmMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681488277; x=1684080277; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=87Eys71a5bFDwpsmcqiXjalsGOMTQZkXpUaxljHCLjI=; b=jpuUgpW3ZUSxFT5vC180nYckjg9G47WAOOQpsBsHvmGsyyP7Kndge6PXYLTkuO/nTC ZNQzULQww3/v7H3rghuz7AUUmYaSXXUOspcxj5A3ndI/Ld5A8G9JmsucMm7uygsa1sin HOyFXJbWejy7qa2IZP85FXjNAGM5V+6x6z/l1H/AzINLlByL6lnqAZI/xwaOCw2vH6f2 3jPqrXyg449rNVABSO6pxYi4JV9EzCXD6q4l8hVb2fSy3T+nCtZ7vgt5s52HmhpbExyf o7MQ+dGxfJhqJtdKhiqcxlJmVAq8WxLT7tX+RrVELSKviYG1kMAJQFYGiTqy/pHuUw2Z dfZA== X-Gm-Message-State: AAQBX9dSzAIMR/YfsiBCRWJ+K5JWkKxHth9Ytvm4NVWyU9PQsDKbOX0+ xqafG9bx+ayVgq+ALl65GVH9vA== X-Google-Smtp-Source: AKy350byxJ+PBV33IFiDvwwjeVrv5fTjj5ozDL9nB8qISHiD/79Sw9Bq3ynjrrvleZee23Mbd//GTQ== X-Received: by 2002:a5d:6587:0:b0:2ce:a6f6:edca with SMTP id q7-20020a5d6587000000b002cea6f6edcamr4865810wru.55.1681488277527; Fri, 14 Apr 2023 09:04:37 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Paolo Bonzini , "Michael S. Tsirkin" , virtio-fs@redhat.com, Erik Schilling , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Eduardo Habkost , Stefan Hajnoczi , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Jason Wang , Viresh Kumar , Mathieu Poirier , Gerd Hoffmann , Markus Armbruster Subject: [PATCH 08/12] qom: allow for properties to become "fixed" Date: Fri, 14 Apr 2023 17:04:29 +0100 Message-Id: <20230414160433.2096866-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414160433.2096866-1-alex.bennee@linaro.org> References: <20230414160433.2096866-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1681488355227100001 When specialising general purpose objects it is sometimes useful to "fix" some of the properties that were configurable by the base classes. We will use this facility when specialising vhost-user-device. Signed-off-by: Alex Benn=C3=A9e --- qapi/qom.json | 2 ++ include/qom/object.h | 16 +++++++++++++++- qom/object.c | 14 ++++++++++++++ qom/object_interfaces.c | 9 ++++++--- qom/qom-qmp-cmds.c | 1 + softmmu/qdev-monitor.c | 1 + 6 files changed, 39 insertions(+), 4 deletions(-) diff --git a/qapi/qom.json b/qapi/qom.json index a877b879b9..4cda191f00 100644 --- a/qapi/qom.json +++ b/qapi/qom.json @@ -33,12 +33,14 @@ # @description: if specified, the description of the property. # # @default-value: the default value, if any (since 5.0) +# @fixed: if specified if value has been fixed (since 8.1) # # Since: 1.2 ## { 'struct': 'ObjectPropertyInfo', 'data': { 'name': 'str', 'type': 'str', + 'fixed': 'bool', '*description': 'str', '*default-value': 'any' } } =20 diff --git a/include/qom/object.h b/include/qom/object.h index ef7258a5e1..f18d1a8254 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -97,6 +97,8 @@ struct ObjectProperty ObjectPropertyInit *init; void *opaque; QObject *defval; + /** @fixed: if the property has been fixed at its default */ + bool fixed; }; =20 /** @@ -1111,6 +1113,17 @@ void object_property_set_default_int(ObjectProperty = *prop, int64_t value); */ void object_property_set_default_uint(ObjectProperty *prop, uint64_t value= ); =20 +/** + * object_property_fix_default_uint: + * @prop: the property to be fixed + * @value: the fixed value to be written to the property + * + * When specialising an object it may make send to fix some values and + * not allow them to be changed. This can only be applied to + * properties that previously had a default and now cannot be changed. + */ +void object_property_fix_default_uint(ObjectProperty *prop, uint64_t value= ); + /** * object_property_find: * @obj: the object @@ -1961,13 +1974,14 @@ size_t object_type_get_instance_size(const char *ty= pename); * object_property_help: * @name: the name of the property * @type: the type of the property + * @fixed: has the value been fixed * @defval: the default value * @description: description of the property * * Returns: a user-friendly formatted string describing the property * for help purposes. */ -char *object_property_help(const char *name, const char *type, +char *object_property_help(const char *name, const char *type, bool fixed, QObject *defval, const char *description); =20 G_DEFINE_AUTOPTR_CLEANUP_FUNC(Object, object_unref) diff --git a/qom/object.c b/qom/object.c index e25f1e96db..b5aba3ffc8 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1584,6 +1584,20 @@ void object_property_set_default_uint(ObjectProperty= *prop, uint64_t value) object_property_set_default(prop, QOBJECT(qnum_from_uint(value))); } =20 +static void object_property_fix_default(ObjectProperty *prop, QObject *def= val) +{ + g_assert(prop->init =3D=3D object_property_init_defval); + g_assert(!prop->fixed); + + prop->defval =3D defval; + prop->fixed =3D true; +} + +void object_property_fix_default_uint(ObjectProperty *prop, uint64_t value) +{ + object_property_fix_default(prop, QOBJECT(qnum_from_uint(value))); +} + bool object_property_set_uint(Object *obj, const char *name, uint64_t value, Error **errp) { diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index 7d31589b04..e351938f8f 100644 --- a/qom/object_interfaces.c +++ b/qom/object_interfaces.c @@ -161,7 +161,7 @@ void user_creatable_add_qapi(ObjectOptions *options, Er= ror **errp) visit_free(v); } =20 -char *object_property_help(const char *name, const char *type, +char *object_property_help(const char *name, const char *type, bool fixed, QObject *defval, const char *description) { GString *str =3D g_string_new(NULL); @@ -179,7 +179,9 @@ char *object_property_help(const char *name, const char= *type, if (defval) { g_autofree char *def_json =3D g_string_free(qobject_to_json(defval= ), false); - g_string_append_printf(str, " (default: %s)", def_json); + g_string_append_printf(str, " (%s: %s)", + fixed ? "fixed" : "default", + def_json); } =20 return g_string_free(str, false); @@ -220,7 +222,8 @@ bool type_print_class_properties(const char *type) =20 g_ptr_array_add(array, object_property_help(prop->name, prop->type, - prop->defval, prop->descripti= on)); + prop->fixed, prop->defval, + prop->description)); } g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0); if (array->len > 0) { diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c index 7c087299de..f4cdf4ddde 100644 --- a/qom/qom-qmp-cmds.c +++ b/qom/qom-qmp-cmds.c @@ -55,6 +55,7 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, Er= ror **errp) =20 value->name =3D g_strdup(prop->name); value->type =3D g_strdup(prop->type); + value->fixed =3D prop->fixed; } =20 return props; diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index b8d2c4dadd..b56b2af2f2 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -315,6 +315,7 @@ int qdev_device_help(QemuOpts *opts) g_ptr_array_add(array, object_property_help(prop->value->name, prop->value->type, + prop->value->fixed, prop->value->default_value, prop->value->description)); } --=20 2.39.2 From nobody Tue Feb 10 20:47:41 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1681488379; cv=none; d=zohomail.com; s=zohoarc; b=gxMGq/MHWMQ4cghZggV3YSBEA63iO03JhR9+hVz4aZdjF3Stqc+Q1Z2pF/sNJYWN3uStzb10rCX7i+Yk9TwGBRZ1RCM0KtuMQ70DGwGAxq4ps/SZso5qE6O9Eerrug4x++fRXo5UMpgI/Jpo4+45BavYEdgEbzxABAjOFCrltvo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681488379; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ksXUcYDNEGnzuSF+MT7+XzXqFq6Xy1BiJwdlLWdbrp4=; b=dnr8drRcYDzelGAKq0IlPYQ/cmQ+XkgzI53w0NeZyRbFMg4RWTFeCRx5cxCsrZD3jOc+Sow9ulskr6yYiDyzjKPrDGD/Ba9DeYl6EAmbglL+8nHx1R7eOXyMfYcmDRVeLgF2QXhwVmK+am3JwwCI4epOJX3ED/gtohsoXsVn3yc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1681488379627619.3026532287847; Fri, 14 Apr 2023 09:06:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pnLvJ-0007V6-GJ; Fri, 14 Apr 2023 12:05:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnLun-0006SM-Dw for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:49 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pnLuj-0007zd-2W for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:45 -0400 Received: by mail-wr1-x429.google.com with SMTP id j12so1775896wrd.2 for ; Fri, 14 Apr 2023 09:04:40 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id r17-20020a5d4e51000000b002f01e181c4asm3886389wrt.5.2023.04.14.09.04.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 09:04:36 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D7E941FFC0; Fri, 14 Apr 2023 17:04:34 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681488279; x=1684080279; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ksXUcYDNEGnzuSF+MT7+XzXqFq6Xy1BiJwdlLWdbrp4=; b=t6YSyIEz8GhdIInpixE+F4RTmVYvtpLeHol0HJKKor/T4fR7NwHddwuhUsq8OhCVHu ZkrFHt4EQKXCRtMqeT5/tBSrwGyI5CZzq094NwOQHMokVtnxNQFaCwxFnmuMMTKJgpk3 A7tYghPUwjWOWFWkp8N723ys7rMJuWyDJiQX35rOrnEdvQTyC+WHES6/IZa159zcqnmr JYy0mE4HyjSEgqqMrjipe46gVp4qW/BVQzpsV+jSkHsbyKNwevcJEp0EsbF6OEuDwJxs BTVyy3T8U3FJzx7t8pK0eq7NOHfGFLtQbU7nFcOeyaQTK8v4iU6LD/eMnVbmJA7asAmc Jqlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681488279; x=1684080279; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ksXUcYDNEGnzuSF+MT7+XzXqFq6Xy1BiJwdlLWdbrp4=; b=XUwxFw5qR7PFDW2SsDntmiXU/uw2RLtIZCB8WkQ2ykoSY/kJ7GNZl0r57Vic2WJIYF u1O5j+cLpwrJ6jLUGyrQ8F9S7l27wxY+Hhd6bITN81gMsZ5Jj9SeALk5RQwWDhgubQhv M3mQiN3Fmi8GkRjSZ4Mmi3EbiWEKyk7iMKFpHTkB1jKk8/xl86zfKG5MfRNJKdIvrLp0 f7eORg3pvND6LRsqZuvIIZ+0QYJyjuYJK0OK49coTOAlwvIcDOp+W69r2ILJfgBwfbPI rO1HD5zTcuWv6rm7FZlOTxHsoBPcMhGqIbn/tdK0FlQpgGqYFp8luwJJiZ+z5wmIhhFN IOmw== X-Gm-Message-State: AAQBX9dGTQ3cuVE02W7RGNGIbgp/mFnt6PQaaNjKbnrlPzxAWRX4gScB cT9C3EQc2SQ1E2+gEGf0ahJJ7g== X-Google-Smtp-Source: AKy350YYMeV173fk9AD1hDj9XDRdxZhVB8dtReS3Vl4WurZxUlvgwzlt9Xn6L909nvWjfVyKB/s0OA== X-Received: by 2002:a5d:5908:0:b0:2f2:ad19:bddd with SMTP id v8-20020a5d5908000000b002f2ad19bdddmr4235792wrd.20.1681488279234; Fri, 14 Apr 2023 09:04:39 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Paolo Bonzini , "Michael S. Tsirkin" , virtio-fs@redhat.com, Erik Schilling , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Eduardo Habkost , Stefan Hajnoczi , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Jason Wang , Viresh Kumar , Mathieu Poirier , Gerd Hoffmann , Markus Armbruster Subject: [PATCH 09/12] hw/virtio: derive vhost-user-rng from vhost-user-device Date: Fri, 14 Apr 2023 17:04:30 +0100 Message-Id: <20230414160433.2096866-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414160433.2096866-1-alex.bennee@linaro.org> References: <20230414160433.2096866-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1681488381657100003 Now we can take advantage of our new base class and make vhost-user-rng a much simpler boilerplate wrapper. Signed-off-by: Alex Benn=C3=A9e --- include/hw/virtio/vhost-user-rng.h | 11 +- hw/virtio/vhost-user-rng.c | 264 +---------------------------- 2 files changed, 8 insertions(+), 267 deletions(-) diff --git a/include/hw/virtio/vhost-user-rng.h b/include/hw/virtio/vhost-u= ser-rng.h index ddd9f01eea..5be2999498 100644 --- a/include/hw/virtio/vhost-user-rng.h +++ b/include/hw/virtio/vhost-user-rng.h @@ -12,21 +12,14 @@ #include "hw/virtio/virtio.h" #include "hw/virtio/vhost.h" #include "hw/virtio/vhost-user.h" -#include "chardev/char-fe.h" +#include "hw/virtio/vhost-user-device.h" =20 #define TYPE_VHOST_USER_RNG "vhost-user-rng" OBJECT_DECLARE_SIMPLE_TYPE(VHostUserRNG, VHOST_USER_RNG) =20 struct VHostUserRNG { /*< private >*/ - VirtIODevice parent; - CharBackend chardev; - struct vhost_virtqueue *vhost_vq; - struct vhost_dev vhost_dev; - VhostUserState vhost_user; - VirtQueue *req_vq; - bool connected; - + VHostUserDevice parent; /*< public >*/ }; =20 diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c index efc54cd3fb..1f23442b81 100644 --- a/hw/virtio/vhost-user-rng.c +++ b/hw/virtio/vhost-user-rng.c @@ -3,7 +3,7 @@ * * Copyright (c) 2021 Mathieu Poirier * - * Implementation seriously tailored on vhost-user-i2c.c + * Simple wrapper of the generic vhost-user-device. * * SPDX-License-Identifier: GPL-2.0-or-later */ @@ -13,281 +13,29 @@ #include "hw/qdev-properties.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/vhost-user-rng.h" -#include "qemu/error-report.h" #include "standard-headers/linux/virtio_ids.h" =20 -static const int feature_bits[] =3D { - VIRTIO_F_RING_RESET, - VHOST_INVALID_FEATURE_BIT -}; - -static void vu_rng_start(VirtIODevice *vdev) -{ - VHostUserRNG *rng =3D VHOST_USER_RNG(vdev); - BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); - VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); - int ret; - int i; - - if (!k->set_guest_notifiers) { - error_report("binding does not support guest notifiers"); - return; - } - - ret =3D vhost_dev_enable_notifiers(&rng->vhost_dev, vdev); - if (ret < 0) { - error_report("Error enabling host notifiers: %d", -ret); - return; - } - - ret =3D k->set_guest_notifiers(qbus->parent, rng->vhost_dev.nvqs, true= ); - if (ret < 0) { - error_report("Error binding guest notifier: %d", -ret); - goto err_host_notifiers; - } - - rng->vhost_dev.acked_features =3D vdev->guest_features; - ret =3D vhost_dev_start(&rng->vhost_dev, vdev, true); - if (ret < 0) { - error_report("Error starting vhost-user-rng: %d", -ret); - goto err_guest_notifiers; - } - - /* - * guest_notifier_mask/pending not used yet, so just unmask - * everything here. virtio-pci will do the right thing by - * enabling/disabling irqfd. - */ - for (i =3D 0; i < rng->vhost_dev.nvqs; i++) { - vhost_virtqueue_mask(&rng->vhost_dev, vdev, i, false); - } - - return; - -err_guest_notifiers: - k->set_guest_notifiers(qbus->parent, rng->vhost_dev.nvqs, false); -err_host_notifiers: - vhost_dev_disable_notifiers(&rng->vhost_dev, vdev); -} - -static void vu_rng_stop(VirtIODevice *vdev) -{ - VHostUserRNG *rng =3D VHOST_USER_RNG(vdev); - BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); - VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); - int ret; - - if (!k->set_guest_notifiers) { - return; - } - - vhost_dev_stop(&rng->vhost_dev, vdev, true); - - ret =3D k->set_guest_notifiers(qbus->parent, rng->vhost_dev.nvqs, fals= e); - if (ret < 0) { - error_report("vhost guest notifier cleanup failed: %d", ret); - return; - } - - vhost_dev_disable_notifiers(&rng->vhost_dev, vdev); -} - -static void vu_rng_set_status(VirtIODevice *vdev, uint8_t status) -{ - VHostUserRNG *rng =3D VHOST_USER_RNG(vdev); - bool should_start =3D virtio_device_should_start(vdev, status); - - if (vhost_dev_is_started(&rng->vhost_dev) =3D=3D should_start) { - return; - } - - if (should_start) { - vu_rng_start(vdev); - } else { - vu_rng_stop(vdev); - } -} - -static uint64_t vu_rng_get_features(VirtIODevice *vdev, - uint64_t requested_features, Error **e= rrp) -{ - VHostUserRNG *rng =3D VHOST_USER_RNG(vdev); - - return vhost_get_features(&rng->vhost_dev, feature_bits, - requested_features); -} - -static void vu_rng_handle_output(VirtIODevice *vdev, VirtQueue *vq) -{ - /* - * Not normally called; it's the daemon that handles the queue; - * however virtio's cleanup path can call this. - */ -} - -static void vu_rng_guest_notifier_mask(VirtIODevice *vdev, int idx, bool m= ask) -{ - VHostUserRNG *rng =3D VHOST_USER_RNG(vdev); - - vhost_virtqueue_mask(&rng->vhost_dev, vdev, idx, mask); -} - -static bool vu_rng_guest_notifier_pending(VirtIODevice *vdev, int idx) -{ - VHostUserRNG *rng =3D VHOST_USER_RNG(vdev); - - return vhost_virtqueue_pending(&rng->vhost_dev, idx); -} - -static void vu_rng_connect(DeviceState *dev) -{ - VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); - VHostUserRNG *rng =3D VHOST_USER_RNG(vdev); - - if (rng->connected) { - return; - } - - rng->connected =3D true; - - /* restore vhost state */ - if (virtio_device_started(vdev, vdev->status)) { - vu_rng_start(vdev); - } -} - -static void vu_rng_disconnect(DeviceState *dev) -{ - VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); - VHostUserRNG *rng =3D VHOST_USER_RNG(vdev); - - if (!rng->connected) { - return; - } - - rng->connected =3D false; - - if (vhost_dev_is_started(&rng->vhost_dev)) { - vu_rng_stop(vdev); - } -} - -static void vu_rng_event(void *opaque, QEMUChrEvent event) -{ - DeviceState *dev =3D opaque; - - switch (event) { - case CHR_EVENT_OPENED: - vu_rng_connect(dev); - break; - case CHR_EVENT_CLOSED: - vu_rng_disconnect(dev); - break; - case CHR_EVENT_BREAK: - case CHR_EVENT_MUX_IN: - case CHR_EVENT_MUX_OUT: - /* Ignore */ - break; - } -} - -static void vu_rng_device_realize(DeviceState *dev, Error **errp) -{ - VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); - VHostUserRNG *rng =3D VHOST_USER_RNG(dev); - int ret; - - if (!rng->chardev.chr) { - error_setg(errp, "missing chardev"); - return; - } - - if (!vhost_user_init(&rng->vhost_user, &rng->chardev, errp)) { - return; - } - - virtio_init(vdev, VIRTIO_ID_RNG, 0); - - rng->req_vq =3D virtio_add_queue(vdev, 4, vu_rng_handle_output); - if (!rng->req_vq) { - error_setg_errno(errp, -1, "virtio_add_queue() failed"); - goto virtio_add_queue_failed; - } - - rng->vhost_dev.nvqs =3D 1; - rng->vhost_dev.vqs =3D g_new0(struct vhost_virtqueue, rng->vhost_dev.n= vqs); - ret =3D vhost_dev_init(&rng->vhost_dev, &rng->vhost_user, - VHOST_BACKEND_TYPE_USER, 0, errp); - if (ret < 0) { - error_setg_errno(errp, -ret, "vhost_dev_init() failed"); - goto vhost_dev_init_failed; - } - - qemu_chr_fe_set_handlers(&rng->chardev, NULL, NULL, vu_rng_event, NULL, - dev, NULL, true); - - return; - -vhost_dev_init_failed: - g_free(rng->vhost_dev.vqs); - virtio_delete_queue(rng->req_vq); -virtio_add_queue_failed: - virtio_cleanup(vdev); - vhost_user_cleanup(&rng->vhost_user); -} - -static void vu_rng_device_unrealize(DeviceState *dev) -{ - VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); - VHostUserRNG *rng =3D VHOST_USER_RNG(dev); - struct vhost_virtqueue *vhost_vqs =3D rng->vhost_dev.vqs; - - vu_rng_set_status(vdev, 0); - - vhost_dev_cleanup(&rng->vhost_dev); - g_free(vhost_vqs); - virtio_delete_queue(rng->req_vq); - virtio_cleanup(vdev); - vhost_user_cleanup(&rng->vhost_user); -} - -static struct vhost_dev *vu_rng_get_vhost(VirtIODevice *vdev) -{ - VHostUserRNG *rng =3D VHOST_USER_RNG(vdev); - return &rng->vhost_dev; -} - static const VMStateDescription vu_rng_vmstate =3D { .name =3D "vhost-user-rng", .unmigratable =3D 1, }; =20 -static Property vu_rng_properties[] =3D { - DEFINE_PROP_CHR("chardev", VHostUserRNG, chardev), - DEFINE_PROP_END_OF_LIST(), -}; - static void vu_rng_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); - VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_CLASS(klass); + ObjectProperty *op; =20 - device_class_set_props(dc, vu_rng_properties); dc->vmsd =3D &vu_rng_vmstate; set_bit(DEVICE_CATEGORY_INPUT, dc->categories); =20 - vdc->realize =3D vu_rng_device_realize; - vdc->unrealize =3D vu_rng_device_unrealize; - vdc->get_features =3D vu_rng_get_features; - vdc->set_status =3D vu_rng_set_status; - vdc->guest_notifier_mask =3D vu_rng_guest_notifier_mask; - vdc->guest_notifier_pending =3D vu_rng_guest_notifier_pending; - vdc->get_vhost =3D vu_rng_get_vhost; + op =3D object_class_property_find(klass, "virtio-id"); + g_assert(op); + object_property_fix_default_uint(op, VIRTIO_ID_RNG); } =20 static const TypeInfo vu_rng_info =3D { .name =3D TYPE_VHOST_USER_RNG, - .parent =3D TYPE_VIRTIO_DEVICE, + .parent =3D TYPE_VHOST_USER_DEVICE, .instance_size =3D sizeof(VHostUserRNG), .class_init =3D vu_rng_class_init, }; --=20 2.39.2 From nobody Tue Feb 10 20:47:41 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1681488500; cv=none; d=zohomail.com; s=zohoarc; b=P2YhAh6R/4pD93wDaMyJBcxnkrQ1xmy6xolZDAQSv8SF0Twp6ONXflTatkwoX5E04e/LOzAPivpVTNCXF5Vd8/IsB0MOpePy9+ZSH1mk2J6tDonjZM9u0ArbIXklQ+OSY9JbMULPK+I9Tk2DuLwAojEdhaZ3QBAy+t7r4bsLMxw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681488500; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8LanDirQaSq5LBuEyiFieoGUbbdGI81Zqz66tepS9FQ=; b=HaUqL2pBF6CuFndxZsFXobK7MvwDqGrLzUhsXToQGj7oADVgfoV6TFmRge7bA5OOKR+x6oOQUvBV8y5FFRNi5brZ6P66bIzfnGYVyMLZBt9uR1SV/LPVcl6OXuvhqGJCiK/AJ86Y1jsQgGfKiQjaf417lyIvn8WFiZcZaxp18rc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1681488500301605.9924228591015; Fri, 14 Apr 2023 09:08:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pnLvN-0007sF-6r; Fri, 14 Apr 2023 12:05:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnLul-0006SH-K9 for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:47 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pnLui-0007zc-Ln for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:43 -0400 Received: by mail-wm1-x329.google.com with SMTP id k27-20020a05600c1c9b00b003f0a9f022beso2257194wms.1 for ; Fri, 14 Apr 2023 09:04:40 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id x2-20020a05600c21c200b003f149715cb6sm1067151wmj.10.2023.04.14.09.04.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 09:04:36 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id F2B881FFB8; Fri, 14 Apr 2023 17:04:34 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681488279; x=1684080279; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8LanDirQaSq5LBuEyiFieoGUbbdGI81Zqz66tepS9FQ=; b=U+LgH173VoEnClmk7N0zz0J0Rbd4X7uGJOV6cb1+Vm9EpXFm77MJQJOHdsXWn5tQa6 RzHZyoSBqWlab3YUwF42OKbMZ/hcISl09QhqYXX8+OOT4TdzQ8y7lFnLeFfU3SXSG07S sqxYetcbQknkip75ZkqNrPqtOvFUuhBxn+4PxmAaUOw1nx53VG+QKQN6RfkqLzIHFXDN mlRm5NAOoa8fFcM9ttDD0kw2hI/W9+qpw7hNvTM+JCOVjw0iyawvPgAYTqATjS4LvGNB x2aJ0o20sJKrycdLO5aMw1PP2PgN+ypmh5D2RAdDudGPHMbBYtvnHBCk0pF3mL4Z0wwB 8T+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681488279; x=1684080279; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8LanDirQaSq5LBuEyiFieoGUbbdGI81Zqz66tepS9FQ=; b=Kh46m9qiJ/ObR6gOyxN5RjU+YakMRimROd1TL3x/ivmOdegI2wMKPf6TJHT5s/aZXk nBxsgez3JEjZEzHylnwxbG6SQXVuPHtdJ8eTQRyBrKsEWqxt1oaEaNuH1ooTMZIFCCFu bBGbZNmmPMxhAugF33UH87DO7ide/eCOqY9ld8fNfMgUs+V+mFbs92Yzzd3DnSFsAgHX iIc55k+CHay+zXWXfncK8WcC6PGvo3cEYY54AkA1BlRVvfS5z8PJUfRnl0rOlbsEX7pO /pO8XzrMNfvChueVxwo3+IzE/JvvBgm2vAfn9pM99derQbRofPfEtWsi0LmXt6eM9aUz 20mA== X-Gm-Message-State: AAQBX9cI2iP1JFi2N4Fs7PrXvEZR6YKjjncNNM5NxgY4rQXKA2GqFl5R pkWx4C/flC2rjCvwFWyAOpbOUw== X-Google-Smtp-Source: AKy350YCJF+OxYLnFvtHqPriQ7R3H2JXzXlzuDX7L7ecMBRJMlH1V50tdFIyYs6GlGheU9LpeKi7VQ== X-Received: by 2002:a1c:4c1a:0:b0:3f0:a9e5:3ae with SMTP id z26-20020a1c4c1a000000b003f0a9e503aemr4732344wmf.24.1681488279014; Fri, 14 Apr 2023 09:04:39 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Paolo Bonzini , "Michael S. Tsirkin" , virtio-fs@redhat.com, Erik Schilling , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Eduardo Habkost , Stefan Hajnoczi , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Jason Wang , Viresh Kumar , Mathieu Poirier , Gerd Hoffmann , Markus Armbruster Subject: [PATCH 10/12] hw/virtio: add config support to vhost-user-device Date: Fri, 14 Apr 2023 17:04:31 +0100 Message-Id: <20230414160433.2096866-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414160433.2096866-1-alex.bennee@linaro.org> References: <20230414160433.2096866-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1681488502188100002 To use the generic device the user will need to provide the config region size via the command line. We also add a notifier so the guest can be pinged if the remote daemon updates the config. With these changes: -device vhost-user-device-pci,virtio-id=3D41,num_vqs=3D2,config_size=3D8 is equivalent to: -device vhost-user-gpio-pci Signed-off-by: Alex Benn=C3=A9e --- include/hw/virtio/vhost-user-device.h | 1 + hw/virtio/vhost-user-device.c | 58 ++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/include/hw/virtio/vhost-user-device.h b/include/hw/virtio/vhos= t-user-device.h index 8d77f06721..cb98e0dcaa 100644 --- a/include/hw/virtio/vhost-user-device.h +++ b/include/hw/virtio/vhost-user-device.h @@ -21,6 +21,7 @@ struct VHostUserDevice { CharBackend chardev; uint16_t virtio_id; uint32_t num_vqs; + uint32_t config_size; /* State tracking */ VhostUserState vhost_user; struct vhost_virtqueue *vhost_vq; diff --git a/hw/virtio/vhost-user-device.c b/hw/virtio/vhost-user-device.c index bfbf3b29cb..977cfed247 100644 --- a/hw/virtio/vhost-user-device.c +++ b/hw/virtio/vhost-user-device.c @@ -117,6 +117,42 @@ static uint64_t vud_get_features(VirtIODevice *vdev, return vud->vhost_dev.features & ~(1ULL << VHOST_USER_F_PROTOCOL_FEATU= RES); } =20 +/* + * To handle VirtIO config we need to know the size of the config + * space. We don't cache the config but re-fetch it from the guest + * every time in case something has changed. + */ +static void vud_get_config(VirtIODevice *vdev, uint8_t *config) +{ + VHostUserDevice *vud =3D VHOST_USER_DEVICE(vdev); + Error *local_err =3D NULL; + + /* + * There will have been a warning during vhost_dev_init, but lets + * assert here as nothing will go right now. + */ + g_assert(vud->config_size && vud->vhost_user.supports_config =3D=3D tr= ue); + + if (vhost_dev_get_config(&vud->vhost_dev, config, + vud->config_size, &local_err)) { + error_report_err(local_err); + } +} + +/* + * When the daemon signals an update to the config we just need to + * signal the guest as we re-read the config on demand above. + */ +static int vud_config_notifier(struct vhost_dev *dev) +{ + virtio_notify_config(dev->vdev); + return 0; +} + +const VhostDevConfigOps vud_config_ops =3D { + .vhost_dev_config_notifier =3D vud_config_notifier, +}; + static void vud_handle_output(VirtIODevice *vdev, VirtQueue *vq) { /* @@ -141,12 +177,21 @@ static int vud_connect(DeviceState *dev) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VHostUserDevice *vud =3D VHOST_USER_DEVICE(vdev); + struct vhost_dev *vhost_dev =3D &vud->vhost_dev; =20 if (vud->connected) { return 0; } vud->connected =3D true; =20 + /* + * If we support VHOST_USER_GET_CONFIG we must enable the notifier + * so we can ping the guest when it updates. + */ + if (vud->vhost_user.supports_config) { + vhost_dev_set_config_notifier(vhost_dev, &vud_config_ops); + } + /* restore vhost state */ if (virtio_device_started(vdev, vdev->status)) { vud_start(vdev); @@ -214,11 +259,20 @@ static void vud_device_realize(DeviceState *dev, Erro= r **errp) vud->num_vqs =3D 1; /* reasonable default? */ } =20 + /* + * We can't handle config requests unless we know the size of the + * config region, specialisations of the vhost-user-device will be + * able to set this. + */ + if (vud->config_size) { + vud->vhost_user.supports_config =3D true; + } + if (!vhost_user_init(&vud->vhost_user, &vud->chardev, errp)) { return; } =20 - virtio_init(vdev, vud->virtio_id, 0); + virtio_init(vdev, vud->virtio_id, vud->config_size); =20 /* * Disable guest notifiers, by default all notifications will be via t= he @@ -271,6 +325,7 @@ static Property vud_properties[] =3D { DEFINE_PROP_CHR("chardev", VHostUserDevice, chardev), DEFINE_PROP_UINT16("virtio-id", VHostUserDevice, virtio_id, 0), DEFINE_PROP_UINT32("num_vqs", VHostUserDevice, num_vqs, 1), + DEFINE_PROP_UINT32("config_size", VHostUserDevice, config_size, 0), DEFINE_PROP_END_OF_LIST(), }; =20 @@ -285,6 +340,7 @@ static void vud_class_init(ObjectClass *klass, void *da= ta) vdc->realize =3D vud_device_realize; vdc->unrealize =3D vud_device_unrealize; vdc->get_features =3D vud_get_features; + vdc->get_config =3D vud_get_config; vdc->set_status =3D vud_set_status; } =20 --=20 2.39.2 From nobody Tue Feb 10 20:47:41 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1681488363; cv=none; d=zohomail.com; s=zohoarc; b=KFWyaukIH47wVeYqJq+ai2LxWJ0R06GPvGYJ0ziqggYyQHfDDuxwtPu6GkmjpKUWrid07V6v2WhE90+8+fPlj5G3QAYIi67KKLQPU2XmArsuZaw4SbO2XnZ4n0w703YImNchGFL5TkdD1qazmWPe+xT8/0IEkfXRPM3FzeCucEY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681488363; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4Ryfe6WB+la5kXKs32EYl/Vciz9ABPkj0uG+7/D/vdw=; b=kmgMZDfPEaCtadB6b45+xAYQUq8Yx4X4fvU3WfygUaYV8m3C/qeAh0cuen3Ub3ARwIwkX3acI/K7ZTk0+6Vpe7hJPxk7sAyu0PPU16VK6lLPH/lftCBdjZfcqqWK2Z6F90BjukR36UntVWFljsfQqTZSeqlrgnv1rXTLRyEcR0E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1681488363468606.9378512360352; Fri, 14 Apr 2023 09:06:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pnLvJ-0007V5-G5; Fri, 14 Apr 2023 12:05:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnLun-0006Sk-KV for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:49 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pnLuj-00080K-VP for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:45 -0400 Received: by mail-wr1-x431.google.com with SMTP id s2so14759625wra.7 for ; Fri, 14 Apr 2023 09:04:41 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id t1-20020a1c7701000000b003ede06f3178sm4579281wmi.31.2023.04.14.09.04.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 09:04:39 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 1B7011FFC1; Fri, 14 Apr 2023 17:04:35 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681488280; x=1684080280; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4Ryfe6WB+la5kXKs32EYl/Vciz9ABPkj0uG+7/D/vdw=; b=cIlExdGROySEk88B2tfqCGjQ/TsXCmyeL+AI5l+xTV5zYgHcP18HD77bdsFlJws1Z5 /1y+oaZGVgHfr0Pob9gIg0yzrYFc4JLbOxfFbNqm2ud9fQui7ldGQMwp20+w+tUojymX n6lrOg21PHSNxQA7SCuHnjBwfewvg4T2wwuiVoTD75TWh5d5jZUXsns2vB92gXcDYEWD E7zeQA7ridQlZcnhcTD1gCLSGYlko6YXVaWVB6YDvcZcbzz0tcrO/CK15BX68qvr/tKK IBQbPE1uV1mELnQlhhmsteGTCV4x9reuALpA3ioVT61EfZa1asPtdQC+zyzp48bAXLOR PIxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681488280; x=1684080280; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4Ryfe6WB+la5kXKs32EYl/Vciz9ABPkj0uG+7/D/vdw=; b=GdlZBWH9T9dmYs0sTlO8ooPMI+KClCtycC93bfG0nt6ExpzKC0ZwD8NsgMoj9NasZr 2tFLCJt88wS33zUHRHOGaieKYwo1TM67YIvB9TmzK+rO+OfBbb5YcNDVljHTeq4ZP7Dz g20w4uwFPX73ZtNHIiYPkU3xLBausUr6V03BW58gPx4D3UawFW3k+0ZZXI3+fsV1lGmu VrAY45oRe6iS5fYiFRMaPM/RNbZNxpvN135U/aXh9KiDZacvkQ0xP8xByNqbbTc1DERo KlSOt1RvujjDPSR6SJN1XVeRf6wOfA6tPYGUNKin3NLlWkVv7RJj+vRcXsjZaIOz/8BJ Pr3A== X-Gm-Message-State: AAQBX9eI356LBuvxd1T9HD886EnGwBUNoh3726cIblHS0tdVPeeox+/o THBXsdJgKiW+pNmNB8GDgPubEg== X-Google-Smtp-Source: AKy350bjxwU9YgSG3q+/5u4LpwhlbKQDBNKKVQqyppSZnj9+gaYUdjZ0Ym1mbQ6S3c5R8kx1s9JT4g== X-Received: by 2002:a05:6000:18cd:b0:2f7:2b68:1fbe with SMTP id w13-20020a05600018cd00b002f72b681fbemr1969217wrq.6.1681488280336; Fri, 14 Apr 2023 09:04:40 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Paolo Bonzini , "Michael S. Tsirkin" , virtio-fs@redhat.com, Erik Schilling , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Eduardo Habkost , Stefan Hajnoczi , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Jason Wang , Viresh Kumar , Mathieu Poirier , Gerd Hoffmann , Markus Armbruster Subject: [PATCH 11/12] hw/virtio: derive vhost-user-gpio from vhost-user-device (!BROKEN) Date: Fri, 14 Apr 2023 17:04:32 +0100 Message-Id: <20230414160433.2096866-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414160433.2096866-1-alex.bennee@linaro.org> References: <20230414160433.2096866-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1681488365542100004 Now we can take advantage of our new base class and make vhost-user-gpio a much simpler boilerplate wrapper. [AJB - and this breaks because of the class init propery hack leading to the config getting overriden and firing the assert. I need a clean QOM way to do this derived class] Signed-off-by: Alex Benn=C3=A9e --- include/hw/virtio/vhost-user-gpio.h | 23 +- hw/virtio/vhost-user-gpio.c | 405 ++-------------------------- 2 files changed, 17 insertions(+), 411 deletions(-) diff --git a/include/hw/virtio/vhost-user-gpio.h b/include/hw/virtio/vhost-= user-gpio.h index a9d3f9b049..82a2e36c21 100644 --- a/include/hw/virtio/vhost-user-gpio.h +++ b/include/hw/virtio/vhost-user-gpio.h @@ -12,33 +12,14 @@ #include "hw/virtio/virtio.h" #include "hw/virtio/vhost.h" #include "hw/virtio/vhost-user.h" -#include "standard-headers/linux/virtio_gpio.h" -#include "chardev/char-fe.h" +#include "hw/virtio/vhost-user-device.h" =20 #define TYPE_VHOST_USER_GPIO "vhost-user-gpio-device" OBJECT_DECLARE_SIMPLE_TYPE(VHostUserGPIO, VHOST_USER_GPIO); =20 struct VHostUserGPIO { /*< private >*/ - VirtIODevice parent_obj; - CharBackend chardev; - struct virtio_gpio_config config; - struct vhost_virtqueue *vhost_vqs; - struct vhost_dev vhost_dev; - VhostUserState vhost_user; - VirtQueue *command_vq; - VirtQueue *interrupt_vq; - /** - * There are at least two steps of initialization of the - * vhost-user device. The first is a "connect" step and - * second is a "start" step. Make a separation between - * those initialization phases by using two fields. - * - * @connected: see vu_gpio_connect()/vu_gpio_disconnect() - * @started_vu: see vu_gpio_start()/vu_gpio_stop() - */ - bool connected; - bool started_vu; + VHostUserDevice parent; /*< public >*/ }; =20 diff --git a/hw/virtio/vhost-user-gpio.c b/hw/virtio/vhost-user-gpio.c index 3b013f2d0f..c76af1fc69 100644 --- a/hw/virtio/vhost-user-gpio.c +++ b/hw/virtio/vhost-user-gpio.c @@ -11,413 +11,38 @@ #include "hw/qdev-properties.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/vhost-user-gpio.h" -#include "qemu/error-report.h" #include "standard-headers/linux/virtio_ids.h" -#include "trace.h" - -#define REALIZE_CONNECTION_RETRIES 3 -#define VHOST_NVQS 2 - -/* Features required from VirtIO */ -static const int feature_bits[] =3D { - VIRTIO_F_VERSION_1, - VIRTIO_F_NOTIFY_ON_EMPTY, - VIRTIO_RING_F_INDIRECT_DESC, - VIRTIO_RING_F_EVENT_IDX, - VIRTIO_GPIO_F_IRQ, - VIRTIO_F_RING_RESET, - VHOST_INVALID_FEATURE_BIT -}; - -static void vu_gpio_get_config(VirtIODevice *vdev, uint8_t *config) -{ - VHostUserGPIO *gpio =3D VHOST_USER_GPIO(vdev); - - memcpy(config, &gpio->config, sizeof(gpio->config)); -} - -static int vu_gpio_config_notifier(struct vhost_dev *dev) -{ - VHostUserGPIO *gpio =3D VHOST_USER_GPIO(dev->vdev); - - memcpy(dev->vdev->config, &gpio->config, sizeof(gpio->config)); - virtio_notify_config(dev->vdev); - - return 0; -} - -const VhostDevConfigOps gpio_ops =3D { - .vhost_dev_config_notifier =3D vu_gpio_config_notifier, -}; - -static int vu_gpio_start(VirtIODevice *vdev) -{ - BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); - VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); - VHostUserGPIO *gpio =3D VHOST_USER_GPIO(vdev); - struct vhost_dev *vhost_dev =3D &gpio->vhost_dev; - int ret, i; - - if (!k->set_guest_notifiers) { - error_report("binding does not support guest notifiers"); - return -ENOSYS; - } - - ret =3D vhost_dev_enable_notifiers(vhost_dev, vdev); - if (ret < 0) { - error_report("Error enabling host notifiers: %d", ret); - return ret; - } - - ret =3D k->set_guest_notifiers(qbus->parent, vhost_dev->nvqs, true); - if (ret < 0) { - error_report("Error binding guest notifier: %d", ret); - goto err_host_notifiers; - } - - /* - * Before we start up we need to ensure we have the final feature - * set needed for the vhost configuration. The backend may also - * apply backend_features when the feature set is sent. - */ - vhost_ack_features(&gpio->vhost_dev, feature_bits, vdev->guest_feature= s); - - ret =3D vhost_dev_start(&gpio->vhost_dev, vdev, false); - if (ret < 0) { - error_report("Error starting vhost-user-gpio: %d", ret); - goto err_guest_notifiers; - } - gpio->started_vu =3D true; - - /* - * guest_notifier_mask/pending not used yet, so just unmask - * everything here. virtio-pci will do the right thing by - * enabling/disabling irqfd. - */ - for (i =3D 0; i < gpio->vhost_dev.nvqs; i++) { - vhost_virtqueue_mask(&gpio->vhost_dev, vdev, i, false); - } - - /* - * As we must have VHOST_USER_F_PROTOCOL_FEATURES (because - * VHOST_USER_GET_CONFIG requires it) we need to explicitly enable - * the vrings. - */ - g_assert(vhost_dev->vhost_ops && - vhost_dev->vhost_ops->vhost_set_vring_enable); - ret =3D vhost_dev->vhost_ops->vhost_set_vring_enable(vhost_dev, true); - if (ret =3D=3D 0) { - return 0; - } - - error_report("Failed to start vrings for vhost-user-gpio: %d", ret); - -err_guest_notifiers: - k->set_guest_notifiers(qbus->parent, gpio->vhost_dev.nvqs, false); -err_host_notifiers: - vhost_dev_disable_notifiers(&gpio->vhost_dev, vdev); - - return ret; -} - -static void vu_gpio_stop(VirtIODevice *vdev) -{ - VHostUserGPIO *gpio =3D VHOST_USER_GPIO(vdev); - BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); - VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); - struct vhost_dev *vhost_dev =3D &gpio->vhost_dev; - int ret; - - if (!gpio->started_vu) { - return; - } - gpio->started_vu =3D false; - - if (!k->set_guest_notifiers) { - return; - } - - vhost_dev_stop(vhost_dev, vdev, false); - - ret =3D k->set_guest_notifiers(qbus->parent, vhost_dev->nvqs, false); - if (ret < 0) { - error_report("vhost guest notifier cleanup failed: %d", ret); - return; - } - - vhost_dev_disable_notifiers(vhost_dev, vdev); -} - -static void vu_gpio_set_status(VirtIODevice *vdev, uint8_t status) -{ - VHostUserGPIO *gpio =3D VHOST_USER_GPIO(vdev); - bool should_start =3D virtio_device_should_start(vdev, status); - - trace_virtio_gpio_set_status(status); - - if (!gpio->connected) { - return; - } - - if (vhost_dev_is_started(&gpio->vhost_dev) =3D=3D should_start) { - return; - } - - if (should_start) { - if (vu_gpio_start(vdev)) { - qemu_chr_fe_disconnect(&gpio->chardev); - } - } else { - vu_gpio_stop(vdev); - } -} - -static uint64_t vu_gpio_get_features(VirtIODevice *vdev, uint64_t features, - Error **errp) -{ - VHostUserGPIO *gpio =3D VHOST_USER_GPIO(vdev); - - return vhost_get_features(&gpio->vhost_dev, feature_bits, features); -} - -static void vu_gpio_handle_output(VirtIODevice *vdev, VirtQueue *vq) -{ - /* - * Not normally called; it's the daemon that handles the queue; - * however virtio's cleanup path can call this. - */ -} - -static void vu_gpio_guest_notifier_mask(VirtIODevice *vdev, int idx, bool = mask) -{ - VHostUserGPIO *gpio =3D VHOST_USER_GPIO(vdev); - - /* - * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the macro of configure interrupt's IDX, If this driver does not - * support, the function will return - */ - - if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { - return; - } - - vhost_virtqueue_mask(&gpio->vhost_dev, vdev, idx, mask); -} - -static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserGPIO *gpio) -{ - virtio_delete_queue(gpio->command_vq); - virtio_delete_queue(gpio->interrupt_vq); - g_free(gpio->vhost_vqs); - virtio_cleanup(vdev); - vhost_user_cleanup(&gpio->vhost_user); -} - -static int vu_gpio_connect(DeviceState *dev, Error **errp) -{ - VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); - VHostUserGPIO *gpio =3D VHOST_USER_GPIO(vdev); - struct vhost_dev *vhost_dev =3D &gpio->vhost_dev; - int ret; - - if (gpio->connected) { - return 0; - } - gpio->connected =3D true; - - vhost_dev_set_config_notifier(vhost_dev, &gpio_ops); - gpio->vhost_user.supports_config =3D true; - - gpio->vhost_dev.nvqs =3D VHOST_NVQS; - gpio->vhost_dev.vqs =3D gpio->vhost_vqs; - - ret =3D vhost_dev_init(vhost_dev, &gpio->vhost_user, - VHOST_BACKEND_TYPE_USER, 0, errp); - if (ret < 0) { - return ret; - } - - /* restore vhost state */ - if (virtio_device_started(vdev, vdev->status)) { - vu_gpio_start(vdev); - } - - return 0; -} - -static void vu_gpio_event(void *opaque, QEMUChrEvent event); - -static void vu_gpio_disconnect(DeviceState *dev) -{ - VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); - VHostUserGPIO *gpio =3D VHOST_USER_GPIO(vdev); - - if (!gpio->connected) { - return; - } - gpio->connected =3D false; - - vu_gpio_stop(vdev); - vhost_dev_cleanup(&gpio->vhost_dev); - - /* Re-instate the event handler for new connections */ - qemu_chr_fe_set_handlers(&gpio->chardev, - NULL, NULL, vu_gpio_event, - NULL, dev, NULL, true); -} - -static void vu_gpio_event(void *opaque, QEMUChrEvent event) -{ - DeviceState *dev =3D opaque; - VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); - VHostUserGPIO *gpio =3D VHOST_USER_GPIO(vdev); - Error *local_err =3D NULL; - - switch (event) { - case CHR_EVENT_OPENED: - if (vu_gpio_connect(dev, &local_err) < 0) { - qemu_chr_fe_disconnect(&gpio->chardev); - return; - } - break; - case CHR_EVENT_CLOSED: - /* defer close until later to avoid circular close */ - vhost_user_async_close(dev, &gpio->chardev, &gpio->vhost_dev, - vu_gpio_disconnect); - break; - case CHR_EVENT_BREAK: - case CHR_EVENT_MUX_IN: - case CHR_EVENT_MUX_OUT: - /* Ignore */ - break; - } -} - -static int vu_gpio_realize_connect(VHostUserGPIO *gpio, Error **errp) -{ - VirtIODevice *vdev =3D &gpio->parent_obj; - DeviceState *dev =3D &vdev->parent_obj; - struct vhost_dev *vhost_dev =3D &gpio->vhost_dev; - int ret; - - ret =3D qemu_chr_fe_wait_connected(&gpio->chardev, errp); - if (ret < 0) { - return ret; - } - - /* - * vu_gpio_connect() may have already connected (via the event - * callback) in which case it will just report success. - */ - ret =3D vu_gpio_connect(dev, errp); - if (ret < 0) { - qemu_chr_fe_disconnect(&gpio->chardev); - return ret; - } - g_assert(gpio->connected); - - ret =3D vhost_dev_get_config(vhost_dev, (uint8_t *)&gpio->config, - sizeof(gpio->config), errp); - - if (ret < 0) { - error_report("vhost-user-gpio: get config failed"); - - qemu_chr_fe_disconnect(&gpio->chardev); - vhost_dev_cleanup(vhost_dev); - return ret; - } - - return 0; -} - -static void vu_gpio_device_realize(DeviceState *dev, Error **errp) -{ - ERRP_GUARD(); - - VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); - VHostUserGPIO *gpio =3D VHOST_USER_GPIO(dev); - int retries, ret; - - if (!gpio->chardev.chr) { - error_setg(errp, "vhost-user-gpio: chardev is mandatory"); - return; - } - - if (!vhost_user_init(&gpio->vhost_user, &gpio->chardev, errp)) { - return; - } - - virtio_init(vdev, VIRTIO_ID_GPIO, sizeof(gpio->config)); - - gpio->command_vq =3D virtio_add_queue(vdev, 256, vu_gpio_handle_output= ); - gpio->interrupt_vq =3D virtio_add_queue(vdev, 256, vu_gpio_handle_outp= ut); - gpio->vhost_vqs =3D g_new0(struct vhost_virtqueue, VHOST_NVQS); - - gpio->connected =3D false; - - qemu_chr_fe_set_handlers(&gpio->chardev, NULL, NULL, vu_gpio_event, NU= LL, - dev, NULL, true); - - retries =3D REALIZE_CONNECTION_RETRIES; - g_assert(!*errp); - do { - if (*errp) { - error_prepend(errp, "Reconnecting after error: "); - error_report_err(*errp); - *errp =3D NULL; - } - ret =3D vu_gpio_realize_connect(gpio, errp); - } while (ret < 0 && retries--); - - if (ret < 0) { - do_vhost_user_cleanup(vdev, gpio); - } - - return; -} - -static void vu_gpio_device_unrealize(DeviceState *dev) -{ - VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); - VHostUserGPIO *gpio =3D VHOST_USER_GPIO(dev); - - vu_gpio_set_status(vdev, 0); - qemu_chr_fe_set_handlers(&gpio->chardev, NULL, NULL, NULL, NULL, NULL,= NULL, - false); - vhost_dev_cleanup(&gpio->vhost_dev); - do_vhost_user_cleanup(vdev, gpio); -} +#include "standard-headers/linux/virtio_gpio.h" =20 static const VMStateDescription vu_gpio_vmstate =3D { .name =3D "vhost-user-gpio", .unmigratable =3D 1, }; =20 -static Property vu_gpio_properties[] =3D { - DEFINE_PROP_CHR("chardev", VHostUserGPIO, chardev), - DEFINE_PROP_END_OF_LIST(), -}; - static void vu_gpio_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); - VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_CLASS(klass); + ObjectProperty *op; =20 - device_class_set_props(dc, vu_gpio_properties); dc->vmsd =3D &vu_gpio_vmstate; set_bit(DEVICE_CATEGORY_INPUT, dc->categories); - vdc->realize =3D vu_gpio_device_realize; - vdc->unrealize =3D vu_gpio_device_unrealize; - vdc->get_features =3D vu_gpio_get_features; - vdc->get_config =3D vu_gpio_get_config; - vdc->set_status =3D vu_gpio_set_status; - vdc->guest_notifier_mask =3D vu_gpio_guest_notifier_mask; + + op =3D object_class_property_find(klass, "virtio-id"); + g_assert(op); + object_property_fix_default_uint(op, VIRTIO_ID_GPIO); + + op =3D object_class_property_find(klass, "num-vqs"); + g_assert(op); + object_property_fix_default_uint(op, 2); + + op =3D object_class_property_find(klass, "config_size"); + g_assert(op); + object_property_fix_default_uint(op, sizeof(struct virtio_gpio_config)= ); } =20 static const TypeInfo vu_gpio_info =3D { .name =3D TYPE_VHOST_USER_GPIO, - .parent =3D TYPE_VIRTIO_DEVICE, + .parent =3D TYPE_VHOST_USER_DEVICE, .instance_size =3D sizeof(VHostUserGPIO), .class_init =3D vu_gpio_class_init, }; --=20 2.39.2 From nobody Tue Feb 10 20:47:41 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1681488425; cv=none; d=zohomail.com; s=zohoarc; b=Cnr6XscFBRzkXLVAenotX6hf97wz0w7mPJsFxBlq25ckv+qrQH/q+a3fvgcpdBygYYq5I1OAsEKFHcIQOMSyn+oh2oHOw0hvZn86G9U3IpaKMVYOuk1nA+Ddg8aMPXhptoiEav4VEDv9KnvkK+6h+sZ2gTsYskzcziGpIBuZKxc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681488425; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+fMbxBkambXkAbitMf0yYS02jxY28hzasoKde2tZwkQ=; b=XlLV9RtTZenOK3ZazYQnnbwZHm9X24HJitF0uaUzZpWVtx+2rWgwx8glfICJfbMgdnhWWhVwlmAAhi/TsqcF1sMGAeDId6siMLW3nqvTjbg5TGMlgpuQO5Gne8hwuUmnWPWl/viUJjVktnSjf2Lu6eycWxpzP3MEFUvDCB26t/4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1681488425445536.8785049275455; Fri, 14 Apr 2023 09:07:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pnLvC-00071p-WE; Fri, 14 Apr 2023 12:05:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnLum-0006SI-8D for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:49 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pnLuj-00080C-Lb for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:43 -0400 Received: by mail-wr1-x434.google.com with SMTP id e7so7952801wrc.12 for ; Fri, 14 Apr 2023 09:04:41 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id f4-20020adff584000000b002f008477522sm3851238wro.24.2023.04.14.09.04.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 09:04:39 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 359F31FFBB; Fri, 14 Apr 2023 17:04:35 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681488280; x=1684080280; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+fMbxBkambXkAbitMf0yYS02jxY28hzasoKde2tZwkQ=; b=JzT83oWwmcqo5vxYHf7Q0VBydrgskgxPELCHECrV8WCxaWUzoW+ygyTWrZO1KT6jaV WhZ4NSBP07w2197lRXsJQ/8mxpxuLIb24HPgVVVwz59lobN+NRy4wIk2k5EnZZFqE0BC 1xUkBZUJ4m2bNzbp076SC7zV8B2HJRczuz1oMjJA7SijSMrCgIaJIGDuYqGi2u8QDozp Hp6i59+cRulDDQFMx+wto/9mHA0SP+dS4exQksC9TuiugH7FYigmhYPhmvuJCJV4guUG p60oVzJu0PnkfRDBuA7mpEZx0KZ8769JGl+4wTwSab/LZ3axpFysAcTF/DgnWD2BVeRm 3IzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681488280; x=1684080280; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+fMbxBkambXkAbitMf0yYS02jxY28hzasoKde2tZwkQ=; b=SeAmTFvk3Y+Qn89S6brg6wqLhV8XPVPI1RZ8OzUBTMjgwK+tQPtjdkSy+uMnFznHB1 eGsyT6QtJ9q6xaSPG/qiNSZOhprs8P/5INrM6uyzoFNRFbrOoOa4VyJzQ2aJ8182wU5x xHy8dY30u7YIjbC/CxwIqS3KKtXCUb6UUPSeKZWqAr6K555vVG/KjMkz1m77WeJN1xP7 LFZn3YvdqBr8niuGa9vAcuWZwG3P3h+2WR0JJvSKW2uCyLKqkV1Vj2BzyMxQ1JHmnC4l P25Q0dki/nGMtz8HaayemyfXLL0C6PbBOjlUF/RI4lCUfgviRhD8MP7S89rwHNQGAwbq yBnA== X-Gm-Message-State: AAQBX9doEba6k1mYJ/80nudeaoJNaid6zu1Yigzn1YVmQ2FDyGFipZg1 AoQMIR3IbrnFepVcIFQEdZxfag== X-Google-Smtp-Source: AKy350byvSBB2nd99ikFvAzb/05d/dEOGIv4BHQ7P+zT1kYpslfH1PxE2zCr8qYHknWI4FcTaMx8Cg== X-Received: by 2002:adf:f312:0:b0:2f8:2d4:74ef with SMTP id i18-20020adff312000000b002f802d474efmr177006wro.43.1681488280161; Fri, 14 Apr 2023 09:04:40 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Paolo Bonzini , "Michael S. Tsirkin" , virtio-fs@redhat.com, Erik Schilling , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Eduardo Habkost , Stefan Hajnoczi , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Jason Wang , Viresh Kumar , Mathieu Poirier , Gerd Hoffmann , Markus Armbruster Subject: [PATCH 12/12] docs/system: add a basic enumeration of vhost-user devices Date: Fri, 14 Apr 2023 17:04:33 +0100 Message-Id: <20230414160433.2096866-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414160433.2096866-1-alex.bennee@linaro.org> References: <20230414160433.2096866-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1681488427689100004 Signed-off-by: Alex Benn=C3=A9e --- docs/system/devices/vhost-user-rng.rst | 2 ++ docs/system/devices/vhost-user.rst | 41 ++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/docs/system/devices/vhost-user-rng.rst b/docs/system/devices/v= host-user-rng.rst index a145d4105c..ead1405326 100644 --- a/docs/system/devices/vhost-user-rng.rst +++ b/docs/system/devices/vhost-user-rng.rst @@ -1,3 +1,5 @@ +.. _vhost_user_rng: + QEMU vhost-user-rng - RNG emulation =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 diff --git a/docs/system/devices/vhost-user.rst b/docs/system/devices/vhost= -user.rst index 86128114fa..99b352823e 100644 --- a/docs/system/devices/vhost-user.rst +++ b/docs/system/devices/vhost-user.rst @@ -15,6 +15,47 @@ to the guest. The code is mostly boilerplate although ea= ch device has a ``chardev`` option which specifies the ID of the ``--chardev`` device that connects via a socket to the vhost-user *daemon*. =20 +Each device will have an virtio-mmio and virtio-pci variant. See your +platform details for what sort of virtio bus to use. + +.. list-table:: vhost-user devices + :widths: 20 20 60 + :header-rows: 1 + + * - Device + - Type + - Notes + * - vhost-user-device + - Generic + - You must manually specify ``virtio-id`` and the correct ``num_vqs`` + * - vhost-user-blk + - Block storage + - + * - vhost-user-fs + - File based storage driver + - See https://gitlab.com/virtio-fs/virtiofsd + * - vhost-user-scsi + - SCSI based storage + - See contrib/vhost-user/scsi + * - vhost-user-gpio + - Proxy gpio pins to host + - See https://github.com/rust-vmm/vhost-device + * - vhost-user-i2c + - Proxy i2c devices to host + - See https://github.com/rust-vmm/vhost-device + * - vhost-user-input + - Generic input driver + - See contrib/vhost-user-input + * - vhost-user-rng + - Entropy driver + - :ref:`vhost_user_rng` + * - vhost-user-gpu + - GPU driver + - + * - vhost-user-vsock + - Socket based communication + - See https://github.com/rust-vmm/vhost-device + vhost-user daemon =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 --=20 2.39.2