From nobody Tue Feb 10 19:09:25 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=1681859290; cv=none; d=zohomail.com; s=zohoarc; b=LPxlEYRfVqVBd80DHyi9J1ekWZDFuTBJMH8QBLPDh00XL9RSyAQRzkuQ1tRbrIO13fX7eK+sKLaQ/XyrdrTDjzquT7JUFPHSG/NF1wXu8aT0ZhxKcu1rs5rVMVe7vp1c3EO7SRSbDN7pj9STCF3ruQHjCJ0FnN0YuZk/Q5yjSdA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681859290; 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=BKJTgsFYiMO/1lWukUp+Mmbmw8UBRy8xhqlac9Wn2RqB7lR2UN6khbr0fDanp8YN6MpCSP9poEjGLBs71TnjbsSED8aF4IdOzznBNgenb2SPuHxg7rktJsLkM5/EarOtAai2q+dSwp4p9CDr6BxjJSQ29t53EEc2foPJA/VZKfI= 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 1681859290689766.0060494466892; Tue, 18 Apr 2023 16:08:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1poo5R-0006kE-Dj; Tue, 18 Apr 2023 12:21:45 -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 1poo5P-0006jd-TS for qemu-devel@nongnu.org; Tue, 18 Apr 2023 12:21:43 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1poo5O-00019i-EB for qemu-devel@nongnu.org; Tue, 18 Apr 2023 12:21:43 -0400 Received: by mail-wm1-x32c.google.com with SMTP id q5so15808824wmo.4 for ; Tue, 18 Apr 2023 09:21:42 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id l6-20020adfe586000000b002fe065da369sm1371456wrm.69.2023.04.18.09.21.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 09:21:40 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 3FA401FFB8; Tue, 18 Apr 2023 17:21:40 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681834901; x=1684426901; 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=lh3DoEscXnSGZYVJilsLz7CrDv9jETtkrvXu+/jcvnYRChkSlFa0gMBrojRPrqfezm zcULKjJGS8RaT8aZhvGHhlkLwhnBEgfqiccMtVwvOrVhOM8VUDce9BEqe817a3fV++AF b8Fzoasw4jnYQEpCZZQA9Whf7zjpTx8k1hoMSuYQLXpB5O6aW94aX+BsxZcaWgcCtWFj GwHTSAjzwlWw0WxXnQ3Epi7KoMVB7gmS06TJ8BAcwtRpChb0T6/HFiPc7icqh5IbhDwx 7PWEGuQupe02XWKsNW52Us+WswQre3G1SkNN+/T+GlTiENr8BfRHfqOR7a+nTr1QLoOg vyUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681834901; x=1684426901; 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=FsWOXap0Z83qNrAiaKBL3jHS9tTYli2qP5pmS7ecG5FSKZXFAqM6wDHDWqMuTGdNVV YalLdpRi++uD/32+PCZmPd0syKmXyxfACuVh4f+m3JIVuQ7s3FF9ZKOo2r+1RcdGNcnO jqkry/n0K2/g+Z8h1YbLPpkuRJezvkwx3pzcI2gIn0vIssFOBy0EyYgxSRcIMWUoNIt+ YCy9FBNe/Uk+tXk4Plg+Cq3ml7TDJqR7W95TUCllP3UQ3Ej2FR4HBP+KHNSMnuq92eTS jspaJL4DWI4jRbJnzvgzp8D/IGwuJiu6tHWlYUr1SK9Lidzf39jeE1rLmEgtKkJE9acB 6rKQ== X-Gm-Message-State: AAQBX9fBuG34QdinNWrjmhrY8YpZbyzfEBGS/THtO6pQmnxdYccQmWem M+h/YIyGx9g1kGmTXJ9P5Nky9A== X-Google-Smtp-Source: AKy350ZcQ56yJ0x/zonSWGEhuBget+lCP6JrVToqoYGc/8XdNZEzwdisSW77ddxh0cMQaxaSl5wJIg== X-Received: by 2002:a7b:cd8c:0:b0:3f1:7440:f21d with SMTP id y12-20020a7bcd8c000000b003f17440f21dmr5088103wmj.33.1681834900875; Tue, 18 Apr 2023 09:21:40 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Viresh Kumar , Mathieu Poirier , "Gonglei (Arei)" , Markus Armbruster , Erik Schilling , Jason Wang , Mark Cave-Ayland , Gerd Hoffmann , virtio-fs@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake Subject: [PATCH v2 01/13] include: attempt to document device_class_set_props Date: Tue, 18 Apr 2023 17:21:28 +0100 Message-Id: <20230418162140.373219-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230418162140.373219-1-alex.bennee@linaro.org> References: <20230418162140.373219-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::32c; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32c.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: 1681859292824100003 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 19:09:25 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=1681853782; cv=none; d=zohomail.com; s=zohoarc; b=a35HztZNH/HW1fXLT//MAb6HWfaHKVg742c+Y+hp5hdxzHY7uvtmD8qDAXhQd3sWUCHIKkiS6kDLvC70DpQdPMkvTW81/9+GOL4RTVSb7TeuhQ1zTEomIpUhAJZw1cHc+3eh1BmCiYOeS69ctgti8zeGkKAY/M6pmAvQRvAxXZ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681853782; 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=2d/kTabziFWz81diPGPd2lcq9eXntPtMnKyAEA11+CY=; b=QYyuf5ntDzG3E8AzUvbCGKK2cK7bxaCfJKV8+gUeOyJ8UdxHYpMwbvXULOOLgXYc1gcjzmF5YID6cj6Y94HPdPRRybLHad6Aj2Fqn2A8TTuxvRc6Crj1u8K8mBTCyBqH+/1zWdZ0+5bd9a8IHls8xant0VfA+5lardeBtnpmKq8= 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 1681853782516768.7147221753057; Tue, 18 Apr 2023 14:36:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1poo5S-0006lH-Kr; Tue, 18 Apr 2023 12:21:46 -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 1poo5R-0006k9-B3 for qemu-devel@nongnu.org; Tue, 18 Apr 2023 12:21:45 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1poo5P-00019u-Hr for qemu-devel@nongnu.org; Tue, 18 Apr 2023 12:21:45 -0400 Received: by mail-wm1-x32f.google.com with SMTP id ay3-20020a05600c1e0300b003f17289710aso131506wmb.5 for ; Tue, 18 Apr 2023 09:21:43 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id z16-20020adff750000000b002fb6a79dea0sm3963944wrp.7.2023.04.18.09.21.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 09:21:40 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 57F9D1FFBA; Tue, 18 Apr 2023 17:21:40 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681834902; x=1684426902; 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=2d/kTabziFWz81diPGPd2lcq9eXntPtMnKyAEA11+CY=; b=VBIl2DDITwHYzCBWk8T/c3PSW1X/2UIjoMDfUr0uzjO1UAEp9twCZm7Pu6X01Vb4TS MDDcY8sUPQvlfFBou1xMdSZ8oMBcyY6dAh7h/8HGUxYrlDuQpOYVKBdGUOEBs8g2oNF3 hNzuNZHkf87fQTu/BlnAJKfu6mD4W6HV3DyZ7bElssGj2fsRDQsrLfOea90OVg7uuxST qICsIFBVYL9wzNoV0qnAMT7M1CnOdEBK+FF62kykL9Vm0ghchrwt9xpmxF2Z6mQYFGBY sIFy2WBte33dS4OPTCmE+njA9hediQv9SIC+QyHCjaymAv93BCJ0P0f+WGjfb6A/2xaC 88og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681834902; x=1684426902; 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=2d/kTabziFWz81diPGPd2lcq9eXntPtMnKyAEA11+CY=; b=BwhhAVdjOJhbW6AZLsbd4eYv1MnjBdIbZFrWrU9yGxiM36EXKsCnC261fGvLfPvutM Uziu6uevZVIAUN2mcM7t1TUMnsLQ39Tvwmorig44WiDbm8cU9X7YhvushNITOQ91bVHs VwHx6pnqh5ajaWxfjtMD86m21WkYNGDLyUjf/TewA6Lnro48n7IERgjhdyBl0+PSEydu D5SXpOP/sINLmcSOyPgMhea5iTFME6CTBalVBtCHBarqJv3C+qta0AkQPkqvAQGrvTo1 lvyVjUj/tPf+wYjVBIEcLAUYQyP0hnPxDQxsEvU26YgRxVzXUMb0oV6WN/dj2gNDrsx2 OfiQ== X-Gm-Message-State: AAQBX9cFhjaRjEvYQsY3KLZcnOE9RLHduNmdkUgSMOHeLzluI6j7Ka+4 OEXRj1qVBAWy1/evUu3Ud+9Sag== X-Google-Smtp-Source: AKy350YtD6bBJft2RRV38a3ORIWN/9fGZgfO3eHwzCTzevswU1L/ErwgMViK2taC//TGcSrBeiduOQ== X-Received: by 2002:a05:600c:21c4:b0:3f1:6ef6:c9d6 with SMTP id x4-20020a05600c21c400b003f16ef6c9d6mr8330381wmj.32.1681834902140; Tue, 18 Apr 2023 09:21:42 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Viresh Kumar , Mathieu Poirier , "Gonglei (Arei)" , Markus Armbruster , Erik Schilling , Jason Wang , Mark Cave-Ayland , Gerd Hoffmann , virtio-fs@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake Subject: [PATCH v2 02/13] include/hw: document the device_class_set_parent_* fns Date: Tue, 18 Apr 2023 17:21:29 +0100 Message-Id: <20230418162140.373219-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230418162140.373219-1-alex.bennee@linaro.org> References: <20230418162140.373219-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::32f; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32f.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: 1681853784585100005 These are useful functions for when you want proper inheritance of functionality across realize/unrealize calls. Signed-off-by: Alex Benn=C3=A9e --- include/hw/qdev-core.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index d4bbc30c92..b1d194b561 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -795,9 +795,36 @@ void device_class_set_props(DeviceClass *dc, Property = *props); void device_class_set_parent_reset(DeviceClass *dc, DeviceReset dev_reset, DeviceReset *parent_reset); + +/** + * device_class_set_parent_realize(): set up for chaining realize fns + * @dc: The device class + * @dev_realize: the device realize function + * @parent_realize: somewhere to save the parents realize function + * + * This is intended to be used when the new realize function will + * eventually call its parent realization function during creation. + * This requires storing the function call somewhere (usually in the + * instance structure) so you can eventually call: + * my_dev->parent_realize(dev, errp); + */ void device_class_set_parent_realize(DeviceClass *dc, DeviceRealize dev_realize, DeviceRealize *parent_realize); + + +/** + * device_class_set_parent_unrealize(): set up for chaining unrealize fns + * @dc: The device class + * @dev_unrealize: the device realize function + * @parent_unrealize: somewhere to save the parents unrealize function + * + * This is intended to be used when the new unrealize function will + * eventually call its parent unrealization function during the + * unrealize phase. This requires storing the function call somewhere + * (usually in the instance structure) so you can eventually call: + * my_dev->parent_unrealize(dev); + */ void device_class_set_parent_unrealize(DeviceClass *dc, DeviceUnrealize dev_unrealize, DeviceUnrealize *parent_unrealize); --=20 2.39.2 From nobody Tue Feb 10 19:09:25 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=1681853780; cv=none; d=zohomail.com; s=zohoarc; b=ZoaV3OQXcXVeViSnipE2TvgOlXOPipMa6vUVZaSfskGFWHB8J2lerhVxLiggXTaxJlLqO5cqsMWmGbjnQ1zgpLLGjhvUeGgb6CHjyZWIU3zP56OH2Lq3TeMCVEDSEABtODHg9dDO6GupXB7xDxZ9OKY8bzmx3FltS5cKov0IXHM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681853780; 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=L0syDM+jQQc9onGm+YmzLX+8aRG3csdtLCuT4T5fRR04p3HRhqOYJZXd9BvlbL+miDRXOVWjZFy0qjIlGC7VBdjBb2zUpEduY5oEbjuT6yqaawtJFuLHbIye+SDANt9T3U902pU7FxRlgeqRuFhLr0a7BxPio2u35vGgMWWgDvw= 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 1681853780771251.73373796469195; Tue, 18 Apr 2023 14:36:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1poo5S-0006lU-Qu; Tue, 18 Apr 2023 12:21:46 -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 1poo5R-0006ka-Hp for qemu-devel@nongnu.org; Tue, 18 Apr 2023 12:21:45 -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 1poo5P-0001A0-Mx for qemu-devel@nongnu.org; Tue, 18 Apr 2023 12:21:45 -0400 Received: by mail-wm1-x331.google.com with SMTP id a8-20020a05600c348800b003f17ddb04e3so78227wmq.2 for ; Tue, 18 Apr 2023 09:21:43 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id p22-20020a05600c205600b003f16f362ae7sm9532247wmg.21.2023.04.18.09.21.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 09:21:41 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 7C6F91FFBB; Tue, 18 Apr 2023 17:21:40 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681834902; x=1684426902; 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=fEqXtv0uMEXZkBdY+0HDek1T3/aGFwcZVkqACLkTTbnaQ0rm7ttZ8wyaGHOv1rzHMo xgJtRu/Nq14Z/uXXT7ndh5mClejqNkwMOvVA8VuRlIuumaCOO68/tZErEDYEPH/4fT92 IG0c/65CaD0dOOL8Okka7ejeTsZrYsolAkAyFwLHwID6M4EtfCxnyPBTmGQuTDj/eYgp WCDf3PSm6Tb24LFMwphWBna3znh5ZMqHWQoEuDYiPLwylKQ+y8Qz16KXUOS4r4NZWgdC +B719FRzD8DdzcTNbGs9Rw2UyOjiK+DaRiuowc4fcJkYLa9x49EYw7AVXs38zN6L+YnX 3IwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681834902; x=1684426902; 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=R2KvdWuEn+3kG4TmT0QKSYujCxN9/mDXOvno9QWygrsFyQYQ07VWDT4qdwZvuHnyBo nSiiYzt6EBPSWrHzXF+NScx9twKJTWcH8kF7MPQUR3RltZ032O8FWABWJQQJzXyewf9Y 6OHeu6o0ZtES0/uTE0hejVjj5RH3o+Gs/ykzyiGxDPcrkpiqMGi6auaxzTtgTtlV8Of1 jef/qmITw+eZLsSUIrpAN9dAfRdrvTab8GKw7BNjGgwt6fQJ5343c5mGoNzo9UqawcFx a71y1WuGvfWLzhJKLCj/rVKdSPwDMGY/l6gV2aLbmX3dOQ2HovLv8ovcHudwYrvf0Zeq depw== X-Gm-Message-State: AAQBX9enIcTSsaB3n+WKc1LjH6Mn+0gF0Lily/jrXkrANCTr9ssa12uK Hu7WwQt3KkVownPelCO9lS9E+w== X-Google-Smtp-Source: AKy350aWm7ea2OEEHSzz99/n9o6fCfz+9/NN/Khetgre6ye6Y0jdWayirqWugg563d24NeFNMQK3YA== X-Received: by 2002:a05:600c:ac4:b0:3f1:6ead:34fe with SMTP id c4-20020a05600c0ac400b003f16ead34femr8681728wmr.26.1681834902395; Tue, 18 Apr 2023 09:21:42 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Viresh Kumar , Mathieu Poirier , "Gonglei (Arei)" , Markus Armbruster , Erik Schilling , Jason Wang , Mark Cave-Ayland , Gerd Hoffmann , virtio-fs@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake Subject: [PATCH v2 03/13] hw/virtio: fix typo in VIRTIO_CONFIG_IRQ_IDX comments Date: Tue, 18 Apr 2023 17:21:30 +0100 Message-Id: <20230418162140.373219-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230418162140.373219-1-alex.bennee@linaro.org> References: <20230418162140.373219-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: 1681853782590100001 Fixes: 544f0278af (virtio: introduce macro VIRTIO_CONFIG_IRQ_IDX) Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Mark Cave-Ayland Reviewed-by: Stefan Hajnoczi --- 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 19:09:25 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=1681857538; cv=none; d=zohomail.com; s=zohoarc; b=U0iH8e1ZqH2GLUSNXAYOE0s1o0iYQxZe4BZAExlQC2eU2RbSseIlzxDflsWbf3r+xKcKGroeBaGh7/Mduz2kL7fm0RJnetMxzel24jnAnXsUgQNRVbD2EtHRWOXTOetsLNrkobSrSS+Q8nX+UxIDQ0BduFsmcoB/+FqwgpoVYuc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681857538; 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=ZmxwT+ikTk6kXxZZ5fqjdQ+UNBzlv8cGFWRxMspIgX8sWEsH7+RFkgTDV+ndrN9gpN/ZbaCgjuF5JQYsxsUTp8xXh+5ZOeetKF9Kq7SJfSamB4J0agicc28zGc4ovlx+UDzxABSXtNZtHliPvS2Xk+X9zcQIDDl3YvFckOMYDBQ= 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 1681857538815130.59412186129111; Tue, 18 Apr 2023 15:38:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1poo5U-0006mL-8F; Tue, 18 Apr 2023 12:21:48 -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 1poo5S-0006ku-5v for qemu-devel@nongnu.org; Tue, 18 Apr 2023 12:21:46 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1poo5Q-0001AG-Ku for qemu-devel@nongnu.org; Tue, 18 Apr 2023 12:21:45 -0400 Received: by mail-wm1-x32f.google.com with SMTP id bi21-20020a05600c3d9500b003f17a8eaedbso147604wmb.1 for ; Tue, 18 Apr 2023 09:21:44 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id c22-20020a05600c0ad600b003f16fc33fbesm9095950wmr.17.2023.04.18.09.21.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 09:21:42 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 956B61FFBC; Tue, 18 Apr 2023 17:21:40 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681834903; x=1684426903; 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=XyBsieux2yV2IhpLu6LipUTherdcEmwmOtkCXSVxv6547QiZd/H7LzT/Lsa08V0kNr DpeP09zRP5qEJwpmyoYKqjV+zaoikE48DCCYH5W/XC7GuQTKoj8l0ecOV7Y66A8vlGQJ ogPOIcz6atx6ZQqW0SCMGMzRdFZh+rIEnCiNAf5tPo80IDMIBMkSLwKKnBuhq3oK1/ER illWpRqxPTZjET+nssfUxDZVnRVO4wgcfbDDff1ZRDwdtiw20K2X78Z6bZ4OzVMZgllh hi6fClMr9hsqUFbgItsCKU4+kSFoVpQVJATOM0PHQb7FLEusH+GUkwMsZcoKHSot5bll z8Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681834903; x=1684426903; 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=S6mde5NLa8W75eZs1C9nLzr1ZVBNdQUOapikcKY+ZKEMYNLWh+aMohyOsymV13+DeZ bTsE4den59sgLcGlRCrbT9EGu4qYEz1tAYNLjQTKCMa/e05yesK7hpDHVe6ttMWc7QmH 8uP9IUJWAh3hmbo/Q+ovIW1zpKKxvaTKeszSkK2noGZv1QYKlOVm978DWAihmkpwkFp3 qWEjaD/bcgcL3tTB9ErbNw59f17H7UvkMxd7yHDeBUh6kLltVscWuII6+bl//1eO+TKU WoX6X/2WOMobCWEeVQxgfQJXkkS6siu9tch/MmfuLubcICZgrm+wNmqaQ8eeReIghx0x tVaw== X-Gm-Message-State: AAQBX9ddyrAxOUWLcieot8EtzC++7uwQBVwToLMJCp48KFacSs6TCh3E MERjWvSfODiTb26swKUtA9KBZA== X-Google-Smtp-Source: AKy350anlnUhsgsP7QB17wMYoSFv17IlCyVd6QbuBZpQbXKZ01evzfLqXprPBkdH8alnAIa1WI5mgQ== X-Received: by 2002:a7b:cd85:0:b0:3f0:9d1a:223b with SMTP id y5-20020a7bcd85000000b003f09d1a223bmr13183192wmj.16.1681834903464; Tue, 18 Apr 2023 09:21:43 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Viresh Kumar , Mathieu Poirier , "Gonglei (Arei)" , Markus Armbruster , Erik Schilling , Jason Wang , Mark Cave-Ayland , Gerd Hoffmann , virtio-fs@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake Subject: [PATCH v2 04/13] include/hw/virtio: document virtio_notify_config Date: Tue, 18 Apr 2023 17:21:31 +0100 Message-Id: <20230418162140.373219-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230418162140.373219-1-alex.bennee@linaro.org> References: <20230418162140.373219-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::32f; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32f.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: 1681857540259100001 Signed-off-by: Alex Benn=C3=A9e Acked-by: Mark Cave-Ayland --- 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 19:09:25 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=1681857632; cv=none; d=zohomail.com; s=zohoarc; b=SbEuGJTo3RLBVBB6CakJKRq7ZE0NDBr/j4H0WXZqskUNyurowXWQ0F4QI9edv7TZ1xmq66nvzE3ZAfeoxKlXvJuFQT7FhY3esDFG0Xp5x4qF/QZbdUSa3whsLLCVve3um3MU11gGrJv73o5D8mIqbqCWrn4VR39sz8Pzwju6EbM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681857632; 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=ddlT5aQyp4+Nrvl80k1ftE7GzvzTI4g4QaJwVgejOpMwApCvCH3aVf4FgEJgegnCY3xJX+erRLgBWzOcvXnfOSmiGPD/JwpPh4JvL6NLajs7NGd3MVYXOF58EPR1q5ySekZR+u6YFdDxYbbFmYjhXvCRuQWhwtznVasiwf4LLvE= 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 1681857632929641.1037968819379; Tue, 18 Apr 2023 15:40:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1poo5V-0006ms-Fj; Tue, 18 Apr 2023 12:21:49 -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 1poo5S-0006lE-I4 for qemu-devel@nongnu.org; Tue, 18 Apr 2023 12:21:46 -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 1poo5R-0001AV-1S for qemu-devel@nongnu.org; Tue, 18 Apr 2023 12:21:46 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-2efbaad9d76so2355641f8f.0 for ; Tue, 18 Apr 2023 09:21:44 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id x11-20020adff0cb000000b002f9ff443184sm6499966wro.24.2023.04.18.09.21.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 09:21:42 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id AD4911FFBD; Tue, 18 Apr 2023 17:21:40 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681834903; x=1684426903; 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=uxF/LM8P9SZYpCizN3Zui8qVlBYHD8UmnmrC1P4/cPHgzoMR+6tpEocqtb4OTObdFu MkKKQLOd1q0sqZlccxyH79EF8Db7LqSH5t0w6Kz6I1XZaW+wf3uDOiFWRaXBNVT+Sosk 1fdAurJNSm2ochL9YoawEwmvEVBOBOR73UBembnnlJRi35X+u2AHAbjvX25jWfbtoM7o l0tjtL1FEYufZXHPZxvC2aBfP/FDGzY09bo3q6ZCjvzCp0GRuxM/va62LMOY0UN8C2SG Clwy3iaEr3rEXPYtcaBYs2rBsHDMhCblSAqmqIGWohtaZZnUJzou1hJ3TDc36wjPmCnl K75g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681834903; x=1684426903; 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=RW3YyFijaP8QK5f+W1g7PBHkK3YCERPuFjRfhLiwUTNQjraZtV2RXInXW7YrBYX5AU 6zlUiS+W27FbeRe2pTvs0imACMg+TXdrFlBPBnScWL6B7u3Yj6qZ0gw7exGHdZjY52kG PHdCdkFeFqu34VIbjIWJYnNObKvQZyVVIuF/utQeHofP1DwD5z72i/YAgJsFVXyEE0js UWDz8ZVI3aO//0yRDtU/sbR8gNYCduzvghx9uPpqLd04pGG5oy+0X1B2DQptwzOkHcS7 z26Non4YuiGbyBvob2rrveIFWyk21q47GMDZHt8FLHjPeA2sQ6WW2DbUK1eV3ktaOvCL 9TPg== X-Gm-Message-State: AAQBX9f4REPFKQql0e7G5unliSJ+DVxlKmQsa8wiZw/vllWS+CmgLLf+ +E+urzk189ZfMpPUE5fOJ/y8CQ== X-Google-Smtp-Source: AKy350ZSbDhPNukuBQYrJAwopH8Us33Dgb44bESVXGoJen8nL+g1bwkAPFnFp56YcBgIWrO3epaPkA== X-Received: by 2002:adf:ef8b:0:b0:2ef:8c85:771b with SMTP id d11-20020adfef8b000000b002ef8c85771bmr2392857wro.51.1681834903650; Tue, 18 Apr 2023 09:21:43 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Viresh Kumar , Mathieu Poirier , "Gonglei (Arei)" , Markus Armbruster , Erik Schilling , Jason Wang , Mark Cave-Ayland , Gerd Hoffmann , virtio-fs@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake Subject: [PATCH v2 05/13] include/hw/virtio: add kerneldoc for virtio_init Date: Tue, 18 Apr 2023 17:21:32 +0100 Message-Id: <20230418162140.373219-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230418162140.373219-1-alex.bennee@linaro.org> References: <20230418162140.373219-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: 1681857634230100001 Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Mark Cave-Ayland Reviewed-by: Stefan Hajnoczi --- 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 19:09:25 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=1681857630; cv=none; d=zohomail.com; s=zohoarc; b=ifZjugHAHf+HtSD3SedHeJKl7JFY8YkjiH5E33yMdSYDMm15Qhsn0cX6snxc9bzlEbXubosnzK4x0E+lQk6FocAJRI0ueMvkJT2Axbvh/KZx+fVhj2DYO4vc3rtsxg9YBxEG5KgfP7ydIgHTpZGOB4TQCYBfx2cqybywPn7GKxI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681857630; 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=JuK9ND9Cxi7NDVy5/7z099D2Rqfgfe62W3HlSNWnZ7a3c+BUixm94kLmSoCTuhP2j7Qy/01CY4UNwrdkcYr3F4dv+JKPVAAPpNOkUvNaLFGDNZ3hOsR3mzCSEFiaOOOFFNEe8TE1Bdhjp8Ag/mcpY627CgqzTTwGkQ3Wq/UB2Jg= 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 1681857630588168.01828852138408; Tue, 18 Apr 2023 15:40:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1poo5V-0006mw-Uj; Tue, 18 Apr 2023 12:21:49 -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 1poo5U-0006mI-N6 for qemu-devel@nongnu.org; Tue, 18 Apr 2023 12:21:48 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1poo5S-0001B0-8B for qemu-devel@nongnu.org; Tue, 18 Apr 2023 12:21:47 -0400 Received: by mail-wm1-x32e.google.com with SMTP id d8-20020a05600c3ac800b003ee6e324b19so143172wms.1 for ; Tue, 18 Apr 2023 09:21:45 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id g23-20020a7bc4d7000000b003f17300c7dcsm7279114wmk.48.2023.04.18.09.21.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 09:21:42 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C471B1FFBE; Tue, 18 Apr 2023 17:21:40 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681834904; x=1684426904; 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=pYO2bM/HxOUrYC2DCsCRsjUUil5wQCYuoiMIhEF3v/4pvUZw5SxTR7GpxY2ZJ++QAw oPlH6J74QUxKDX2bcgL2k2W5n1rnYaLSnBCD0xpyAqUaM5DGpkcwL5fBqFZ0IoK97QN/ biv1o3AT+5wDuC2L2ewl1wv8Vt9YsNUgAko0HRw7QGGBTb7e23NClAdTMtFSKZQRJtWV 1BYFEkSJ0axr1mLY/wzHlubuAh8kWI6w9616SLVuGb+wPGZqWk5r1AQMAaPdWcajJuY5 3zWODqYBwvT6bKsIuZG/Yf4UQtzHE514S8e7WxxiQP/Yz+tMbDb35wWY/5IM4a2+HhmU AK2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681834904; x=1684426904; 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=KXwVvvcViEq+AQcF0gXfdSE4gDH0ufnoiy8vv80mGnP/AfJ+y+Q6ByhXdSjGIE+ERg x9Cp5ODCd3h/sdk5GgBE0cNtdu6HtyRE7VpQB5PT53dBO5U6GvDseMoCIPEP/s3pA1Fs S1pMp6bcXqoPmDHAW5kSUsrfq7KiT7YiBweJblnSGT1uRV0wiJmEpnQ3W0JtLNC54vJc bi2Hqzp2GH1UFYov0IUTs+5xxezQHirZ4/xRt33vz3qsTRFiYO8JJ0Rk8tIblFVXoYow K4XbF2MmQ0iQzXIbWNnQCDIcS86s0aOSGvHA/Dd4Lh+rQ0LGUABz87Qzb/beQgUkfR73 LTJQ== X-Gm-Message-State: AAQBX9cRaKQ6cgOv1g0FfTuw8IUQzhhbzJJBpgDBTrF/Fe3sSLNtX5Iy GE7b2GnsaE/kK4WYIyF5T7g4MQ== X-Google-Smtp-Source: AKy350bDS4bb3FKP9JBfG3bThVNVL8AMCipdT5rIhxJKNe3LIcUPgdwDBqKq50TJkiaHsmeRC2TRcA== X-Received: by 2002:a7b:c4d3:0:b0:3f1:76d4:d43f with SMTP id g19-20020a7bc4d3000000b003f176d4d43fmr3771383wmk.8.1681834904592; Tue, 18 Apr 2023 09:21:44 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Viresh Kumar , Mathieu Poirier , "Gonglei (Arei)" , Markus Armbruster , Erik Schilling , Jason Wang , Mark Cave-Ayland , Gerd Hoffmann , virtio-fs@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake Subject: [PATCH v2 06/13] include/hw/virtio: document some more usage of notifiers Date: Tue, 18 Apr 2023 17:21:33 +0100 Message-Id: <20230418162140.373219-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230418162140.373219-1-alex.bennee@linaro.org> References: <20230418162140.373219-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::32e; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32e.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: 1681857631808100001 Lets document some more of the core VirtIODevice structure. Signed-off-by: Alex Benn=C3=A9e Acked-by: Mark Cave-Ayland --- 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 19:09:25 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=1681857592; cv=none; d=zohomail.com; s=zohoarc; b=M5nF1rQDz4OnZiKDrU53iRSQTBp6Hi5rDk+2H9jmI77vRyEKs/4QPVpb3IO4WkY47TtWBBYj/uFVlCwl+sogDEJ4k6pzTTxeIsGzOdGYKk3jJrtAc6vj2N29uOJP7jetWLapkpJRsBz/ILA2RWyah48EGU3Vnx66v6Co87BESHU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681857592; 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=1A+5QxSTbXGCo55UOJ3nazzxUb4+UhfLG866jSa6yr4=; b=JDPAPX3T1ZIXaUIe18PRpgkAIlJVqcgBP/0RrVJZf3Pf8Otf1T9Vz6cARrn+OxM1/lM9Bqbk7O4sB1GeewVzg9wweFm3D0QS9UQERtuP0irWYTcTNEN3d0erTq92XaHJlmu9IDPv0gsNGI9ERt/ZSEGjVv0gLBJ5Trau17AVtVc= 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 1681857592051628.1752216317852; Tue, 18 Apr 2023 15:39:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1poo5W-0006n3-2q; Tue, 18 Apr 2023 12:21:50 -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 1poo5U-0006ma-IA for qemu-devel@nongnu.org; Tue, 18 Apr 2023 12:21:48 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1poo5S-0001Av-8H for qemu-devel@nongnu.org; Tue, 18 Apr 2023 12:21:48 -0400 Received: by mail-wm1-x32b.google.com with SMTP id l31-20020a05600c1d1f00b003f1718d89b2so168513wms.0 for ; Tue, 18 Apr 2023 09:21:45 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id t15-20020a05600c198f00b003f173956a82sm6563522wmq.21.2023.04.18.09.21.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 09:21:42 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E41061FFBF; Tue, 18 Apr 2023 17:21:40 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681834904; x=1684426904; 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=1A+5QxSTbXGCo55UOJ3nazzxUb4+UhfLG866jSa6yr4=; b=f1mgtZ69k7Kj4ijAMctLgIExd27VV0GYl8ZoJeqILw5TcDiA6VMDGnpLmzyPnBWUHW f56feqkULdz6T5g838ckwfrD2TDGMvol2vfZzqb30tBheX1yBcz5mqU+UU1pYtqxjpvC b6aCgaP8/bIZlKUp1kGL3126f9Eu9qH83/sgyndWcMiFT715RhaRoUFUFfpDdYsTV3HC 5GvfarJtUDIUfvbVa8f1ZQ+NHuhQBMQQaxoXrATs4+8Ez3Eqn8ZhFlh3g0RRPrnqKuMT qGOX8UsgyU1ika6PwVKKBJQnOLhPU6jTy36jRWdJm/+lk4AzUhAebndGsrqMGIObcCec s6Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681834904; x=1684426904; 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=1A+5QxSTbXGCo55UOJ3nazzxUb4+UhfLG866jSa6yr4=; b=D66YBpmodvb57xMrK9215YYO38TeIYMWxjD2XLMbSoawG1OseF+sy5SLOMmYb+Hznb OufR1BVDNSsvqNpaqh+IcYUEqblEnwU7kRFKSVpoD1haP+HGPZqE83rCLWgA89ezf551 tmbuUyhtom036crUg0TjE6nEGNb4h1pME2BpDhxzfn47MiHyI0ZyvGUpA4+YBsZqeBNi IlfwEQhkV8g/Jpd6fLlr5xDYMX7Ofy4Qs59W+ed1rsLo1pvWDx5sbT5qXZx6IakPW/fv YzZ5oO5a3mBoW2NhPRKKyQEimOhxB4uuw8NiYULhegteNPWq9cWgViTWomgGNvMpc/Jo m2NQ== X-Gm-Message-State: AAQBX9fhu2wnMuqN4KOj3ARqvjm+MC/TGTnyrOOmVhujqlgpqPcfwCB4 PdHsfQUZm1LBdUs/1SfagxI4cA== X-Google-Smtp-Source: AKy350YP1fbjOOYXG2WOh2XmVrQZoe2HuR6jQr4P8L9Cve/cadsxyV3oO9MzBdDK1TMAVJalQLnR2A== X-Received: by 2002:a05:600c:228b:b0:3f1:718d:a21c with SMTP id 11-20020a05600c228b00b003f1718da21cmr6200468wmf.31.1681834904383; Tue, 18 Apr 2023 09:21:44 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Viresh Kumar , Mathieu Poirier , "Gonglei (Arei)" , Markus Armbruster , Erik Schilling , Jason Wang , Mark Cave-Ayland , Gerd Hoffmann , virtio-fs@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake Subject: [PATCH v2 07/13] virtio: add vhost-user-base and a generic vhost-user-device Date: Tue, 18 Apr 2023 17:21:34 +0100 Message-Id: <20230418162140.373219-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230418162140.373219-1-alex.bennee@linaro.org> References: <20230418162140.373219-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::32b; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32b.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: 1681857592656100001 In theory we shouldn't need to repeat so much boilerplate to support vhost-user backends. This provides a generic vhost-user-base QOM object and a derived 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 --- v2 - split into vub and vud --- include/hw/virtio/vhost-user-device.h | 45 ++++ hw/virtio/vhost-user-device.c | 324 ++++++++++++++++++++++++++ hw/virtio/meson.build | 2 + 3 files changed, 371 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..9105011e25 --- /dev/null +++ b/include/hw/virtio/vhost-user-device.h @@ -0,0 +1,45 @@ +/* + * 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_BASE "vhost-user-base" + +OBJECT_DECLARE_TYPE(VHostUserBase, VHostUserBaseClass, VHOST_USER_BASE) + +struct VHostUserBase { + 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; +}; + + /* needed so we can use the base realize after specialisation + tweaks */ +struct VHostUserBaseClass { + /*< private >*/ + VirtioDeviceClass parent_class; + /*< public >*/ + DeviceRealize parent_realize; +}; + +/* shared for the benefit of the derived pci class */ +#define TYPE_VHOST_USER_DEVICE "vhost-user-device" + +#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..b0239fa033 --- /dev/null +++ b/hw/virtio/vhost-user-device.c @@ -0,0 +1,324 @@ +/* + * 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 vub_start(VirtIODevice *vdev) +{ + BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); + VHostUserBase *vub =3D VHOST_USER_BASE(vdev); + int ret, i; + + if (!k->set_guest_notifiers) { + error_report("binding does not support guest notifiers"); + return; + } + + ret =3D vhost_dev_enable_notifiers(&vub->vhost_dev, vdev); + if (ret < 0) { + error_report("Error enabling host notifiers: %d", -ret); + return; + } + + ret =3D k->set_guest_notifiers(qbus->parent, vub->vhost_dev.nvqs, true= ); + if (ret < 0) { + error_report("Error binding guest notifier: %d", -ret); + goto err_host_notifiers; + } + + vub->vhost_dev.acked_features =3D vdev->guest_features; + + ret =3D vhost_dev_start(&vub->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 < vub->vhost_dev.nvqs; i++) { + vhost_virtqueue_mask(&vub->vhost_dev, vdev, i, false); + } + + return; + +err_guest_notifiers: + k->set_guest_notifiers(qbus->parent, vub->vhost_dev.nvqs, false); +err_host_notifiers: + vhost_dev_disable_notifiers(&vub->vhost_dev, vdev); +} + +static void vub_stop(VirtIODevice *vdev) +{ + VHostUserBase *vub =3D VHOST_USER_BASE(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(&vub->vhost_dev, vdev, true); + + ret =3D k->set_guest_notifiers(qbus->parent, vub->vhost_dev.nvqs, fals= e); + if (ret < 0) { + error_report("vhost guest notifier cleanup failed: %d", ret); + return; + } + + vhost_dev_disable_notifiers(&vub->vhost_dev, vdev); +} + +static void vub_set_status(VirtIODevice *vdev, uint8_t status) +{ + VHostUserBase *vub =3D VHOST_USER_BASE(vdev); + bool should_start =3D virtio_device_should_start(vdev, status); + + if (vhost_dev_is_started(&vub->vhost_dev) =3D=3D should_start) { + return; + } + + if (should_start) { + vub_start(vdev); + } else { + vub_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 vub_get_features(VirtIODevice *vdev, + uint64_t requested_features, Error **errp) +{ + VHostUserBase *vub =3D VHOST_USER_BASE(vdev); + /* This should be set when the vhost connection initialises */ + g_assert(vub->vhost_dev.features); + return vub->vhost_dev.features & ~(1ULL << VHOST_USER_F_PROTOCOL_FEATU= RES); +} + +static void vub_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, VHostUserBase *vub) +{ + vhost_user_cleanup(&vub->vhost_user); + + for (int i =3D 0; i < vub->num_vqs; i++) { + VirtQueue *vq =3D g_ptr_array_index(vub->vqs, i); + virtio_delete_queue(vq); + } + + virtio_cleanup(vdev); +} + +static int vub_connect(DeviceState *dev) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserBase *vub =3D VHOST_USER_BASE(vdev); + + if (vub->connected) { + return 0; + } + vub->connected =3D true; + + /* restore vhost state */ + if (virtio_device_started(vdev, vdev->status)) { + vub_start(vdev); + } + + return 0; +} + +static void vub_disconnect(DeviceState *dev) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserBase *vub =3D VHOST_USER_BASE(vdev); + + if (!vub->connected) { + return; + } + vub->connected =3D false; + + if (vhost_dev_is_started(&vub->vhost_dev)) { + vub_stop(vdev); + } +} + +static void vub_event(void *opaque, QEMUChrEvent event) +{ + DeviceState *dev =3D opaque; + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserBase *vub =3D VHOST_USER_BASE(vdev); + + switch (event) { + case CHR_EVENT_OPENED: + if (vub_connect(dev) < 0) { + qemu_chr_fe_disconnect(&vub->chardev); + return; + } + break; + case CHR_EVENT_CLOSED: + vub_disconnect(dev); + break; + case CHR_EVENT_BREAK: + case CHR_EVENT_MUX_IN: + case CHR_EVENT_MUX_OUT: + /* Ignore */ + break; + } +} + +static void vub_device_realize(DeviceState *dev, Error **errp) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserBase *vub =3D VHOST_USER_BASE(dev); + int ret; + + if (!vub->chardev.chr) { + error_setg(errp, "vhost-user-device: missing chardev"); + return; + } + + if (!vub->virtio_id) { + error_setg(errp, "vhost-user-device: need to define device id"); + return; + } + + if (!vub->num_vqs) { + vub->num_vqs =3D 1; /* reasonable default? */ + } + + if (!vhost_user_init(&vub->vhost_user, &vub->chardev, errp)) { + return; + } + + virtio_init(vdev, vub->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 */ + vub->vqs =3D g_ptr_array_sized_new(vub->num_vqs); + for (int i =3D 0; i < vub->num_vqs; i++) { + g_ptr_array_add(vub->vqs, + virtio_add_queue(vdev, 4, vub_handle_output)); + } + + vub->vhost_dev.nvqs =3D vub->num_vqs; + vub->vhost_dev.vqs =3D g_new0(struct vhost_virtqueue, vub->vhost_dev.n= vqs); + + /* connect to backend */ + ret =3D vhost_dev_init(&vub->vhost_dev, &vub->vhost_user, + VHOST_BACKEND_TYPE_USER, 0, errp); + + if (ret < 0) { + do_vhost_user_cleanup(vdev, vub); + } + + qemu_chr_fe_set_handlers(&vub->chardev, NULL, NULL, vub_event, NULL, + dev, NULL, true); +} + +static void vub_device_unrealize(DeviceState *dev) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserBase *vub =3D VHOST_USER_BASE(dev); + struct vhost_virtqueue *vhost_vqs =3D vub->vhost_dev.vqs; + + /* This will stop vhost backend if appropriate. */ + vub_set_status(vdev, 0); + vhost_dev_cleanup(&vub->vhost_dev); + g_free(vhost_vqs); + do_vhost_user_cleanup(vdev, vub); +} + +static void vub_class_init(ObjectClass *klass, void *data) +{ + VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_CLASS(klass); + + vdc->realize =3D vub_device_realize; + vdc->unrealize =3D vub_device_unrealize; + vdc->get_features =3D vub_get_features; + vdc->set_status =3D vub_set_status; +} + +static const TypeInfo vub_info =3D { + .name =3D TYPE_VHOST_USER_BASE, + .parent =3D TYPE_VIRTIO_DEVICE, + .instance_size =3D sizeof(VHostUserBase), + .class_init =3D vub_class_init, + .class_size =3D sizeof(VHostUserBaseClass), + .abstract =3D true +}; + + +/* + * The following is a concrete implementation of the base class which + * allows the user to define the key parameters via the command line. + */ + +static const VMStateDescription vud_vmstate =3D { + .name =3D "vhost-user-device", + .unmigratable =3D 1, +}; + +static Property vud_properties[] =3D { + DEFINE_PROP_CHR("chardev", VHostUserBase, chardev), + DEFINE_PROP_UINT16("virtio-id", VHostUserBase, virtio_id, 0), + DEFINE_PROP_UINT32("num_vqs", VHostUserBase, num_vqs, 1), + DEFINE_PROP_END_OF_LIST(), +}; + +static void vud_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + device_class_set_props(dc, vud_properties); + dc->vmsd =3D &vud_vmstate; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); +} + +static const TypeInfo vud_info =3D { + .name =3D TYPE_VHOST_USER_DEVICE, + .parent =3D TYPE_VHOST_USER_BASE, + .instance_size =3D sizeof(VHostUserBase), + .class_init =3D vud_class_init, + .class_size =3D sizeof(VHostUserBaseClass), +}; + +static void vu_register_types(void) +{ + type_register_static(&vub_info); + type_register_static(&vud_info); +} + +type_init(vu_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 19:09:25 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=1681857560; cv=none; d=zohomail.com; s=zohoarc; b=JBtEk82Qnzr1Hck7I9YjY2m4Btly76T884IfkQVfCOmvV/OgpbkfjFe30vOfeTmpdfUvXAMBgOILDJrefT/ExpRwd8LHgH6+12GR77/WH0WfXj6qxnMeSbPDWw2Kf8Qk0Gqijcr1wPPuWG1lApabov5ef8DsQ62+ochusjtZkik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681857560; 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=eC5A3sVizk95geXn4I1Vdcti4PHMTBsSCbklkuaCJpg=; b=JGhi+ZuYomK2cyfk7D+DhVmP9sjrkgRrwstqmDqcrbOiNwlJ6EVe/AKtR2L6YE5xFsWxI3b15r7UQ6vLxwB4q1Dwo/sBa0KsMwfRi2Lj66yWPTh3avl+Ux+D/QVpF+sdRxMmwH7jLEfTEDy9mBje0uT7LJslmnBZq78sQZt+atI= 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 168185756065481.08909815843344; Tue, 18 Apr 2023 15:39:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1poo5b-0006pQ-47; Tue, 18 Apr 2023 12:21:55 -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 1poo5a-0006pE-37 for qemu-devel@nongnu.org; Tue, 18 Apr 2023 12:21:54 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1poo5S-0001BU-T6 for qemu-devel@nongnu.org; Tue, 18 Apr 2023 12:21:53 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3f178da21b2so8517035e9.1 for ; Tue, 18 Apr 2023 09:21:46 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id e2-20020a5d65c2000000b002ceacff44c7sm13404133wrw.83.2023.04.18.09.21.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 09:21:43 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 09CE81FFB8; Tue, 18 Apr 2023 17:21:41 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681834905; x=1684426905; 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=eC5A3sVizk95geXn4I1Vdcti4PHMTBsSCbklkuaCJpg=; b=xX9KuWORBVoBfQaDp//Zj0pCE5vi9R8pcHOLPKEJQIUMXddEwHNwZq084NqimIeyhB HuFcJaY/AtdyL1kOOyxH198nMH9K/P/HP+qmddQwx85LZzJujl3jUeF9M2i01toKnPT8 paS0v4aJQ/co9mcaY2FT4MJPfGtPthzwnL17/d/BXS1xRsDrnexwQ0n48m4ZZWKatO63 AduMP3Hpmv2mrlGVvfagKIKaM995d/8qGx7v4PeV9l5dgCktjjW0W78lYWdCS+kcRWPu cqJ/synPvQ2RAMUPgUELdkVLjjoM+T3VuKmdANkLxsUcqdV7e2cASOlr47p1Tu5O0oXd 110w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681834905; x=1684426905; 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=eC5A3sVizk95geXn4I1Vdcti4PHMTBsSCbklkuaCJpg=; b=jWK8vEjXZXGv8OgO51PvJH3MUYAOVxT6NgROVmHc3FfVkgNixnbdS6wFmQfFdx4Twn AztN/HQ4GMXFYrXC9uRU3x95t5gwmgAooUIr9kvBHqZ79dz3NPZfDqcdr1z5uIXV1lLe 3K4PhVj66eGsz0Go+/0G8Hyuvn5IYfa9+Uy2JRb9d0/q2sTYgbeZmPdV2sZxmaoqcbtm E1FIpKWQGxUkf5vpuMN3XRRK3BU9Gv8sJVnip5fxF5SjmmKSTzw7nXKeRH3r/trAa/ET n2X0YNrwiUGmlLGtT/wOwm6RGE34ZkKXEVqyTLAy+OSaze73+6i31QJFTDj/vtJj/5Kw LbHw== X-Gm-Message-State: AAQBX9dj4UC+lUsdx5FBWdK/N0YHv2j2Bck+2x9ajZtZr+Aodd6Go6Y6 TMqbOSPXmNr4Zt4Crek2SxLi6g== X-Google-Smtp-Source: AKy350Y3EkGcFH4MgJreFztMUeROhPvCrndmp97Mj0E9HSXHOgeUS78r6WLfkzhOMeNnwf76Si/XvQ== X-Received: by 2002:adf:d0c2:0:b0:2f2:86cd:3e11 with SMTP id z2-20020adfd0c2000000b002f286cd3e11mr2405489wrh.36.1681834905522; Tue, 18 Apr 2023 09:21:45 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Viresh Kumar , Mathieu Poirier , "Gonglei (Arei)" , Markus Armbruster , Erik Schilling , Jason Wang , Mark Cave-Ayland , Gerd Hoffmann , virtio-fs@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake Subject: [PATCH v2 08/13] virtio: add PCI stub for vhost-user-device Date: Tue, 18 Apr 2023 17:21:35 +0100 Message-Id: <20230418162140.373219-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230418162140.373219-1-alex.bennee@linaro.org> References: <20230418162140.373219-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::32a; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1681857564449100001 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..41f9b7905b --- /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; + VHostUserBase vub; +}; + +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->vub); + + 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->vub, sizeof(dev->vub), + 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 19:09:25 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=1681857612; cv=none; d=zohomail.com; s=zohoarc; b=htVVkLJHBh8RZrwBGFItizuZ/czMgC1ObiyB4gU1DFp1DG/77A4hlnsmpS4lHAycRcX4wjNxRSd2b/E+/sBMXvaIIhweh4nBNKsXF08GPEBLhSZohB1yFrRG4uT7PBZsJBOCXIPAs3wn+uT6iLzpgE4qd2wOguZARpwpzS1yctw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681857612; 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=RHdGm7j8I+C9yYQqKwhoXKBTWIBzPYm6rSCDYdpEQFY=; b=VD3oQfkY1vRk3bYJPPtYOX7Ip4ji7r2I+D1ByAqPQkrnXDZ1UX5lZDakQfbv1BLi8u90uy/tg/XE8PkDodfUEQDcI/RQJ6YkGdlIXDFsAtQxvckIFGcKnO0px04RGKyvMTlJMP/mqLlls0y23l+NmQsI9QiVrBxajtFSDOAUuQI= 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 16818576127631002.1723611500058; Tue, 18 Apr 2023 15:40:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1poo5a-0006pD-0G; Tue, 18 Apr 2023 12:21:54 -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 1poo5X-0006nE-Fx for qemu-devel@nongnu.org; Tue, 18 Apr 2023 12:21:51 -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 1poo5U-0001CJ-7b for qemu-devel@nongnu.org; Tue, 18 Apr 2023 12:21:51 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-2f9b9aa9d75so1291904f8f.0 for ; Tue, 18 Apr 2023 09:21:47 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id m4-20020a5d6a04000000b002f0442a2d3asm13456035wru.48.2023.04.18.09.21.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 09:21:44 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 2DFCC1FFC0; Tue, 18 Apr 2023 17:21:41 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681834907; x=1684426907; 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=RHdGm7j8I+C9yYQqKwhoXKBTWIBzPYm6rSCDYdpEQFY=; b=deuGwp5rAZYC5syALPZhWioCmWGRvpOYvx58ZCYZ7WjLW70hU8BaMdUoPk3XWoGQeG A6EDNB9tLeYj2TPgVYAilqzopjWPzRvzX7LWho4R+0QEayd8YwLf5hh72gxHI7S8E+I7 mOHK2IIZRHZnOW7l7VteuVBMRl8c850wahOQhPZF/OF2hlGepIQQNJLV6uwuTKOOFVIi GMcgApm9FJNX+dHqzEHLPZ4CU02mO5i2qc8dyFaB3wFIpN+kRub7s41uG9ghK9bjPuev y6Yr36GzV+UTjHbPxUOHBD2nq84ACoQ+7L0ruxwSOIHjTn7OGM5gCgBO7UCXvRepD6bk U+vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681834907; x=1684426907; 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=RHdGm7j8I+C9yYQqKwhoXKBTWIBzPYm6rSCDYdpEQFY=; b=VCY6LVisK+VDvbDezb09B7h38hBOqBg4QFBOVIn9oVv1guxZpnH/DqKRRC5KjpPhUR 9N9EOYUpeGcpBUJ5UNfw/crrdDNdurYPzmr8n3EvWqg6IDDGEAX+c0A/I9GoAyb4yZfJ poAQgawcAZz4W4959rl7c9uFDbV9+9V44hVYIeTArl2KoJWBbprhqtrXfuTje4gBxJs0 YdUFrqGY12CyezlD5OJYrjY0UfMQVMj/6w5RcCKcMu5qUnnbBTunGu22l0cp+rmMKiYG ++BoBI/g66kTBL68BcsDVwZL/Z3HWOshBsRveaxwljPIiYMRNEcuvZd9B54zYF7WQg3c 9+rg== X-Gm-Message-State: AAQBX9eTmCCBBMrRSfG9TwOpsYDbPEzyUA0Slk0nYS2o/LS+iScCGvRE M5k8XoqNbCx7tHk0QfqU7l4DLQ== X-Google-Smtp-Source: AKy350Zb5AauL2zQhqybeAXfysAOaKnZeezRPxsJpG7/SdUYPYR7MAcKLVbS/5enUJxh3nWXCoVx+Q== X-Received: by 2002:adf:fe4c:0:b0:2d5:39d:514f with SMTP id m12-20020adffe4c000000b002d5039d514fmr2439055wrs.65.1681834906801; Tue, 18 Apr 2023 09:21:46 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Viresh Kumar , Mathieu Poirier , "Gonglei (Arei)" , Markus Armbruster , Erik Schilling , Jason Wang , Mark Cave-Ayland , Gerd Hoffmann , virtio-fs@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake Subject: [PATCH v2 09/13] hw/virtio: derive vhost-user-rng from vhost-user-device Date: Tue, 18 Apr 2023 17:21:36 +0100 Message-Id: <20230418162140.373219-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230418162140.373219-1-alex.bennee@linaro.org> References: <20230418162140.373219-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: 1681857614729100006 Now we can take advantage of our new base class and make vhost-user-rng a much simpler boilerplate wrapper. Also as this doesn't require any target specific hacks we only need to build the stubs once. Signed-off-by: Alex Benn=C3=A9e Acked-by: Mark Cave-Ayland --- v2 - new derivation layout - move directly to softmmu_virtio_ss --- include/hw/virtio/vhost-user-rng.h | 11 +- hw/virtio/vhost-user-rng.c | 277 +++-------------------------- hw/virtio/meson.build | 7 +- 3 files changed, 28 insertions(+), 267 deletions(-) diff --git a/include/hw/virtio/vhost-user-rng.h b/include/hw/virtio/vhost-u= ser-rng.h index ddd9f01eea..13139c0d9d 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; - + VHostUserBase parent; /*< public >*/ }; =20 diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c index efc54cd3fb..71d3991f93 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,46 @@ #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), +static Property vrng_properties[] =3D { + DEFINE_PROP_CHR("chardev", VHostUserBase, chardev), DEFINE_PROP_END_OF_LIST(), }; =20 +static void vu_rng_base_realize(DeviceState *dev, Error **errp) +{ + VHostUserBase *vub =3D VHOST_USER_BASE(dev); + VHostUserBaseClass *vubs =3D VHOST_USER_BASE_GET_CLASS(dev); + + /* Fixed for RNG */ + vub->virtio_id =3D VIRTIO_ID_RNG; + vub->num_vqs =3D 1; + + vubs->parent_realize(dev, errp); +} + static void vu_rng_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); - VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_CLASS(klass); + VHostUserBaseClass *vubc =3D VHOST_USER_BASE_CLASS(klass); =20 - device_class_set_props(dc, vu_rng_properties); dc->vmsd =3D &vu_rng_vmstate; - set_bit(DEVICE_CATEGORY_INPUT, dc->categories); + device_class_set_props(dc, vrng_properties); + device_class_set_parent_realize(dc, vu_rng_base_realize, + &vubc->parent_realize); =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; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); } =20 static const TypeInfo vu_rng_info =3D { .name =3D TYPE_VHOST_USER_RNG, - .parent =3D TYPE_VIRTIO_DEVICE, + .parent =3D TYPE_VHOST_USER_BASE, .instance_size =3D sizeof(VHostUserRNG), .class_init =3D vu_rng_class_init, }; diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index c0a86b94ae..de442dcb96 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -3,6 +3,11 @@ softmmu_virtio_ss.add(files('virtio-bus.c')) softmmu_virtio_ss.add(when: 'CONFIG_VIRTIO_PCI', if_true: files('virtio-pc= i.c')) softmmu_virtio_ss.add(when: 'CONFIG_VIRTIO_MMIO', if_true: files('virtio-m= mio.c')) =20 +# VirtIO stubs which don't need building per-guest +softmmu_virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost= -user-rng.c')) +softmmu_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_RNG'], + if_true: files('vhost-user-rng-pci.c')) + specific_virtio_ss =3D ss.source_set() specific_virtio_ss.add(files('virtio.c')) specific_virtio_ss.add(files('virtio-config-io.c', 'virtio-qmp.c')) @@ -32,7 +37,6 @@ specific_virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true= : files('virtio-rng.c') specific_virtio_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files('virtio= -iommu.c')) specific_virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-m= em.c')) specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhos= t-user-i2c.c')) -specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhos= t-user-rng.c')) specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vho= st-user-gpio.c')) specific_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_GPIO= '], if_true: files('vhost-user-gpio-pci.c')) specific_virtio_ss.add(when: 'CONFIG_VHOST_VDPA_DEV', if_true: files('vdpa= -dev.c')) @@ -43,7 +47,6 @@ virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_tru= e: files('vhost-user-vs virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-use= r-blk-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-use= r-i2c-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_INPUT', if_true: files('vhost-u= ser-input-pci.c')) -virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-use= r-rng-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_SCSI', if_true: files('vhost-us= er-scsi-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_SCSI', if_true: files('vhost-scsi-pc= i.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_FS', if_true: files('vhost-user= -fs-pci.c')) --=20 2.39.2 From nobody Tue Feb 10 19:09:25 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=1681857700; cv=none; d=zohomail.com; s=zohoarc; b=P+xKNqfoZN7mS8wZrWv4JIRUsJNx+Dc5sMZSNXmaqwsdhE9GeXLM4Wv4f/VicjUmAkmOZLs0O+hcqk+1btaBEa2SPEQANzxkaN1yJQPEmIm4Duh5z5KP40F1ce7Xqa25T/uW7n3x/oAg/otRxGpIf0lavad7dT2am7yxIVc8Oy0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681857700; 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=uTkEU0oqDGeWEiEFn49DE5kPkeQF20sGslhQri+i2Js=; b=O5LLMm8y+UEvP32lNCqR3Efz1ytutDKh8IcnbVwG2GKx2KzSwuPziH3u5nUnc7AzGvZIKNuPuo3JVunqBrr33vK5PX2Sy4XCIj/Y4D6ZbGcKdopOSIhlZr5DcOX8hmyubIjUmL61HOt/G5zbvTSwkAehiH+3VmN/aFFkjOAEejs= 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 1681857700403561.2920176288701; Tue, 18 Apr 2023 15:41:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1poo5X-0006nD-82; Tue, 18 Apr 2023 12:21:51 -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 1poo5V-0006mv-TB for qemu-devel@nongnu.org; Tue, 18 Apr 2023 12:21:49 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1poo5T-0001Bh-9D for qemu-devel@nongnu.org; Tue, 18 Apr 2023 12:21:49 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3f16b99b936so15376115e9.3 for ; Tue, 18 Apr 2023 09:21:46 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id y11-20020a056000108b00b002f013fb708fsm13560795wrw.4.2023.04.18.09.21.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 09:21:44 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 4C4391FFB7; Tue, 18 Apr 2023 17:21:41 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681834906; x=1684426906; 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=uTkEU0oqDGeWEiEFn49DE5kPkeQF20sGslhQri+i2Js=; b=Qx4KdgdPZjW3qENTPMJcMl8Ulf9v7o9rH1J8gU/pwRgUKgk7FciB6j07A4w9Y4PmeP eSx8DfuLJc262S8OMkXsepujdQ8PVmihiXGn15NkgfJPxKWJKjvto91EBAzWQ8TUSf6C 7piiG2N2DugFTjQx+FykbO5SaBYW5NF7FoqsWPRNSdwmsYM/dIleNZrGqNUrDXlyB4fl k7MHLz4Sy0SiCgqS3rYa1p7sGh0MLaIOxO1jYjPr7CeFO1e8bFbxTgyteR2J6jOPfNlX cfPUGK++kx3ZVxJexecLX/54ut58loJbBsBqibRW2YaEIZfirKgnfmdrHMYAYNjnels6 pxCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681834906; x=1684426906; 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=uTkEU0oqDGeWEiEFn49DE5kPkeQF20sGslhQri+i2Js=; b=lS5QfEWY18q2Xs3UYpE9JiM3i9I7bXPG7q7JQBBVxtTeiDCtzcHzYcyKY/UTxBeszR HvzYZiKyYUVpp3K2gVMqUh1unvjSYjAHXikomsZj74SMrxxgxUmmDD9gA5gjmgu0PQhj pTAOUlv1nwLYBsu2mGl5Ige1mMzsulSKYoZNBt/FBs8ym3YCbQZvELQ6vNM1QIv/UOLO lnoDm/07VRuxVaSeeU2X+rtfghj2lnSp0wtN7hdrkLGtBFhFDletbh5KgeQJp55gKDXC o/93yRIU98ahTF7xUa3JjOj88459A/9OtjqvjiTJtd9Nf1+3HTm1vtPBNaP7+G5bXBaj wW9g== X-Gm-Message-State: AAQBX9diFb+u3/Ox1jWAlt6ge97asrG2cCOnGSP9G9Vt9/LXWeNSydvr 3vUn8y5kNVPO636XlQjZ+Vx6dw== X-Google-Smtp-Source: AKy350bIir60SeU7Ft6Xz35nCUgfgJsSOyRInz5vr4Q61YC0UkSWJW3F4VpZAAbLUaM6JKjTKslsjA== X-Received: by 2002:adf:f8d0:0:b0:2c5:3cd2:b8e with SMTP id f16-20020adff8d0000000b002c53cd20b8emr2406488wrq.1.1681834905766; Tue, 18 Apr 2023 09:21:45 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Viresh Kumar , Mathieu Poirier , "Gonglei (Arei)" , Markus Armbruster , Erik Schilling , Jason Wang , Mark Cave-Ayland , Gerd Hoffmann , virtio-fs@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake Subject: [PATCH v2 10/13] hw/virtio: add config support to vhost-user-device Date: Tue, 18 Apr 2023 17:21:37 +0100 Message-Id: <20230418162140.373219-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230418162140.373219-1-alex.bennee@linaro.org> References: <20230418162140.373219-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::32a; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1681857702325100009 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 9105011e25..3ddf88a146 100644 --- a/include/hw/virtio/vhost-user-device.h +++ b/include/hw/virtio/vhost-user-device.h @@ -22,6 +22,7 @@ struct VHostUserBase { 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 b0239fa033..2b028cae08 100644 --- a/hw/virtio/vhost-user-device.c +++ b/hw/virtio/vhost-user-device.c @@ -117,6 +117,42 @@ static uint64_t vub_get_features(VirtIODevice *vdev, return vub->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 vub_get_config(VirtIODevice *vdev, uint8_t *config) +{ + VHostUserBase *vub =3D VHOST_USER_BASE(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(vub->config_size && vub->vhost_user.supports_config =3D=3D tr= ue); + + if (vhost_dev_get_config(&vub->vhost_dev, config, + vub->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 vub_config_notifier(struct vhost_dev *dev) +{ + virtio_notify_config(dev->vdev); + return 0; +} + +const VhostDevConfigOps vub_config_ops =3D { + .vhost_dev_config_notifier =3D vub_config_notifier, +}; + static void vub_handle_output(VirtIODevice *vdev, VirtQueue *vq) { /* @@ -141,12 +177,21 @@ static int vub_connect(DeviceState *dev) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VHostUserBase *vub =3D VHOST_USER_BASE(vdev); + struct vhost_dev *vhost_dev =3D &vub->vhost_dev; =20 if (vub->connected) { return 0; } vub->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 (vub->vhost_user.supports_config) { + vhost_dev_set_config_notifier(vhost_dev, &vub_config_ops); + } + /* restore vhost state */ if (virtio_device_started(vdev, vdev->status)) { vub_start(vdev); @@ -214,11 +259,20 @@ static void vub_device_realize(DeviceState *dev, Erro= r **errp) vub->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 (vub->config_size) { + vub->vhost_user.supports_config =3D true; + } + if (!vhost_user_init(&vub->vhost_user, &vub->chardev, errp)) { return; } =20 - virtio_init(vdev, vub->virtio_id, 0); + virtio_init(vdev, vub->virtio_id, vub->config_size); =20 /* * Disable guest notifiers, by default all notifications will be via t= he @@ -268,6 +322,7 @@ static void vub_class_init(ObjectClass *klass, void *da= ta) vdc->realize =3D vub_device_realize; vdc->unrealize =3D vub_device_unrealize; vdc->get_features =3D vub_get_features; + vdc->get_config =3D vub_get_config; vdc->set_status =3D vub_set_status; } =20 @@ -295,6 +350,7 @@ static Property vud_properties[] =3D { DEFINE_PROP_CHR("chardev", VHostUserBase, chardev), DEFINE_PROP_UINT16("virtio-id", VHostUserBase, virtio_id, 0), DEFINE_PROP_UINT32("num_vqs", VHostUserBase, num_vqs, 1), + DEFINE_PROP_UINT32("config_size", VHostUserBase, config_size, 0), DEFINE_PROP_END_OF_LIST(), }; =20 --=20 2.39.2 From nobody Tue Feb 10 19:09:25 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=1681857610; cv=none; d=zohomail.com; s=zohoarc; b=LXB8HaGz9om/X1Vflr1vNix7dDhcFfDORyXs89sswfzQnPe2fpqsByGVfNe7wWlFJIUfmLFPDaxAcMX+JZodMZwS4FeBkD/PHmX4c9NRud2zv23nyr2GyoM3slGVpLDUBSqPkigBTHV2ArBPiFU9jom0bU9K3FXR/YbR6OzMeP4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681857610; 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=Y6Sf2OjNrNXUb0GYO7bZcBDDP3EdkmkeAoJBhG/jVsc=; b=ZxoGR81ZMYW1NkqIS84Nu0f2mVjkuXASZy70GOKoRg+0QsOy0aiGq0hCGzOKnqv9JtAHSr2J00mfB+Dc9WGSLLZw32v8zHbHp3iEqsnM3s+ZOlphbLJKHNPbBzpDEvWnK6dlvcD/RdsMzRVYIuGQIPLMSUGXSNyZpvjxOJ27q8E= 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 1681857610154387.1607197853182; Tue, 18 Apr 2023 15:40:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1poo5a-0006pM-Id; Tue, 18 Apr 2023 12:21:54 -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 1poo5X-0006nl-V3 for qemu-devel@nongnu.org; Tue, 18 Apr 2023 12:21:51 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1poo5U-0001CR-RD for qemu-devel@nongnu.org; Tue, 18 Apr 2023 12:21:51 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3f09b9ac51dso72297345e9.0 for ; Tue, 18 Apr 2023 09:21:48 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id k18-20020a5d6e92000000b002cea8e3bd54sm13407081wrz.53.2023.04.18.09.21.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 09:21:44 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 6C5841FFC1; Tue, 18 Apr 2023 17:21:41 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681834907; x=1684426907; 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=Y6Sf2OjNrNXUb0GYO7bZcBDDP3EdkmkeAoJBhG/jVsc=; b=GJoh6vae1cNq/amigSNov9XmZECq9Ugyyk8UWCpylMDEbFNuBE2G4RDy19TopKYuzT v9o5E0nRnwQ1+lgo6HIfGj8Lo3rnXF1Pq81Pjg+xZ485bTsCKW5MtpuiWGPVp0Gw08EN Bv72q4TrnAocCkeDPlD4fL4ydXn4FZCoKD057Ia/S4NX8ZW+i+v7MSF0XXLUeIAtypUy 8hOrWqokHXQ53LBHr4ERxzvL9sxmNUpwjPbNSBGduMmz1qd0qkgodgX4NBnw3Vb3BJKn vBSV6NkmvszFqAWRrUnHfkuvQ7lbpgGMX2Y0NS0wgrOV92pgXZqYXkCNKHntTXIN1rgt OwCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681834907; x=1684426907; 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=Y6Sf2OjNrNXUb0GYO7bZcBDDP3EdkmkeAoJBhG/jVsc=; b=TPMbwsCcur62044v6zWuzFHmcerxqusUU6aYUaSdAOJGaI0N5BmpdAElDGSAWx1M0/ HkjLXwb11mtf5b8WwXYWdTGeiZYm8nTAktA1HY2t05HGKBBuq1TLYn4RZC13XD05fJ0D mUbyVyF9YR96UprnA3WXUVF+F3xsjI4oh6R4ZLalVBhNyo1kYHn1TtNpK433pqYe+qbL xYoZbAbHJzlwUBQW60Ne37ozs70pz//RkiGGZA7SUL4z2RasvaZMl3ldf/lm5FMjRenl q6qlMgv2uRnlusy8gjF+uvInrJ1ioyU9c7N4UUxqC/K0B/Y/Ewj79pPE8PYMacFIw7ci LjFQ== X-Gm-Message-State: AAQBX9fQnH/LBYSxCiSAq/LxzGv+tGUGSZ2zluN/DGBQcny+EKiN0OWG 8t7Jw+AkQF2A2eQRrjDk/L77Gg== X-Google-Smtp-Source: AKy350YsrT2KZ1o1bZcHn7nuc7Smb239hzaSeDBCbVW1fwhviQ+ZGJ/d65e57qKBIJnKXwxP38yTOw== X-Received: by 2002:adf:f787:0:b0:2f2:79aa:c8b9 with SMTP id q7-20020adff787000000b002f279aac8b9mr2299511wrp.35.1681834907171; Tue, 18 Apr 2023 09:21:47 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Viresh Kumar , Mathieu Poirier , "Gonglei (Arei)" , Markus Armbruster , Erik Schilling , Jason Wang , Mark Cave-Ayland , Gerd Hoffmann , virtio-fs@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake Subject: [PATCH v2 11/13] hw/virtio: derive vhost-user-gpio from vhost-user-device Date: Tue, 18 Apr 2023 17:21:38 +0100 Message-Id: <20230418162140.373219-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230418162140.373219-1-alex.bennee@linaro.org> References: <20230418162140.373219-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::336; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x336.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: 1681857610834100003 Now the new base class supports config handling we can take advantage and make vhost-user-gpio a much simpler boilerplate wrapper. Also as this doesn't require any target specific hacks we only need to build the stubs once. Signed-off-by: Alex Benn=C3=A9e Acked-by: Mark Cave-Ayland --- v2 - use new vhost-user-base - move build to common code --- include/hw/virtio/vhost-user-gpio.h | 23 +- hw/virtio/vhost-user-gpio.c | 400 ++-------------------------- hw/virtio/meson.build | 5 +- 3 files changed, 22 insertions(+), 406 deletions(-) diff --git a/include/hw/virtio/vhost-user-gpio.h b/include/hw/virtio/vhost-= user-gpio.h index a9d3f9b049..0948654dec 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; + VHostUserBase parent; /*< public >*/ }; =20 diff --git a/hw/virtio/vhost-user-gpio.c b/hw/virtio/vhost-user-gpio.c index 3b013f2d0f..9f37c25415 100644 --- a/hw/virtio/vhost-user-gpio.c +++ b/hw/virtio/vhost-user-gpio.c @@ -11,382 +11,25 @@ #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" +#include "standard-headers/linux/virtio_gpio.h" =20 -#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 Property vgpio_properties[] =3D { + DEFINE_PROP_CHR("chardev", VHostUserBase, chardev), + DEFINE_PROP_END_OF_LIST(), }; =20 -static int vu_gpio_start(VirtIODevice *vdev) +static void vgpio_realize(DeviceState *dev, Error **errp) { - 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; + VHostUserBase *vub =3D VHOST_USER_BASE(dev); + VHostUserBaseClass *vubc =3D VHOST_USER_BASE_GET_CLASS(dev); =20 - if (!k->set_guest_notifiers) { - error_report("binding does not support guest notifiers"); - return -ENOSYS; - } + /* Fixed for GPIO */ + vub->virtio_id =3D VIRTIO_ID_GPIO; + vub->num_vqs =3D 2; + vub->config_size =3D sizeof(struct virtio_gpio_config); =20 - 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); + vubc->parent_realize(dev, errp); } =20 static const VMStateDescription vu_gpio_vmstate =3D { @@ -394,30 +37,21 @@ static const VMStateDescription vu_gpio_vmstate =3D { .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); + VHostUserBaseClass *vubc =3D VHOST_USER_BASE_CLASS(klass); =20 - device_class_set_props(dc, vu_gpio_properties); dc->vmsd =3D &vu_gpio_vmstate; + device_class_set_props(dc, vgpio_properties); + device_class_set_parent_realize(dc, vgpio_realize, + &vubc->parent_realize); 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; } =20 static const TypeInfo vu_gpio_info =3D { .name =3D TYPE_VHOST_USER_GPIO, - .parent =3D TYPE_VIRTIO_DEVICE, + .parent =3D TYPE_VHOST_USER_BASE, .instance_size =3D sizeof(VHostUserGPIO), .class_init =3D vu_gpio_class_init, }; diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index de442dcb96..8c6cb2143d 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -7,6 +7,9 @@ softmmu_virtio_ss.add(when: 'CONFIG_VIRTIO_MMIO', if_true: = files('virtio-mmio.c' softmmu_virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost= -user-rng.c')) softmmu_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_RNG'], if_true: files('vhost-user-rng-pci.c')) +softmmu_virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhos= t-user-gpio.c')) +softmmu_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_GPIO'= ], + if_true: files('vhost-user-gpio-pci.c')) =20 specific_virtio_ss =3D ss.source_set() specific_virtio_ss.add(files('virtio.c')) @@ -37,8 +40,6 @@ specific_virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true= : files('virtio-rng.c') specific_virtio_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files('virtio= -iommu.c')) specific_virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-m= em.c')) specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhos= t-user-i2c.c')) -specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vho= st-user-gpio.c')) -specific_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_GPIO= '], if_true: files('vhost-user-gpio-pci.c')) specific_virtio_ss.add(when: 'CONFIG_VHOST_VDPA_DEV', if_true: files('vdpa= -dev.c')) =20 virtio_pci_ss =3D ss.source_set() --=20 2.39.2 From nobody Tue Feb 10 19:09:25 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=1681857697; cv=none; d=zohomail.com; s=zohoarc; b=M3i8L39flpRsmh46qqYP9JZ+Mmj+f3bZWKSfaWlyEL4IJgAs5RmhxmKNUCKO0CxU63iLCQxhIddc6y5PrQABAs/Bfxx8ofJlRlnu/hwa6Z1Ba9AdBEmDBasMHxQ86ecgLgU8m6PyHK514dqnQZXgAjbgl+HbtikKxnvIPD+pLkE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681857697; 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=x87bue2xLVWQrfVBSyRRYhA/dy43njxINkH3kP9vb3k=; b=DhYnY5GTA+wI8zrFRHso9bUdAmMw0tMKr4Y/tZpGC2DRkbmyaobF/KINDj/gmPVrPQRAc0fTBgmgJWeML6e0WlPraq9Re0W/m44I0OamLbdxYC0lHIhAfasyw4F0SQeZR5KfnF9dXxif42s2yslrYnIM7qGs5VlcyxMiJkslTzQ= 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 1681857697645929.7146733261944; Tue, 18 Apr 2023 15:41:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1poo5X-0006nQ-QK; Tue, 18 Apr 2023 12:21:51 -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 1poo5V-0006mt-P1 for qemu-devel@nongnu.org; Tue, 18 Apr 2023 12:21:49 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1poo5S-00019l-O1 for qemu-devel@nongnu.org; Tue, 18 Apr 2023 12:21:49 -0400 Received: by mail-wm1-x330.google.com with SMTP id a8-20020a05600c348800b003f17ddb04e3so78316wmq.2 for ; Tue, 18 Apr 2023 09:21:46 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id f16-20020a05600c4e9000b003f0a6a1f969sm15864549wmq.46.2023.04.18.09.21.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 09:21:44 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 8C7AB1FFC2; Tue, 18 Apr 2023 17:21:41 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681834906; x=1684426906; 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=x87bue2xLVWQrfVBSyRRYhA/dy43njxINkH3kP9vb3k=; b=EHRQv7Ju6LENPKauwKEtqNkE2betd0pLn4ZbmX+uOKT0XmzMfyuK0xuf6q4uvaGaK4 YXj0rT8dWBkUUyO8KAgEktHYo2iAeQsqAmDgY8xsC1LbPTYwNA7AYCcjzJQbMKZPQyMh CRGHIQY22jpFqROaBjWVzmt6hBYVikpGQ4K7DO+i7WcyK7C/J7a1alSViAn3Y9DpAoU4 5mvNPW0I2BmAjh/IlO6nrcF8fuYD94TpYrWCDwvSaLe5tL7GVq/mu/p72K32I5+SXQO3 vxQbc36zjkpYBJYoxvInbLzcak00sf3qRwXyiURyR97COHHFf9Ti/dpfJl4BmFCtrwPb Wp6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681834906; x=1684426906; 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=x87bue2xLVWQrfVBSyRRYhA/dy43njxINkH3kP9vb3k=; b=XqvCx/bYNbgnoGnTSrgtXl4hNYxMFtnERdf4M2g1LUlKT++Y39/uyK37mDx6J7kYWG PVG547tE+Q7uz5v6gwXejAQn40bfpCrb2M4L/wAB1KTJDLK0KcVEcAIuo83u2eq8pN2x Zr9u24lrg5hlgjjlpVEOlQw8cetRE3Kw2IUyagHzUqoKc5oPBhgBG37V0FJQyMmFChHb n9DgRcrlTTWdfe4XDhfBYHg3QkqafUao/Xj2l/WBNHWzy4GN6Vu/kuc7EmrfUEPWW3qS 084mlSXf9WE3aDm/H4pRasVqMQpckNlAKBOoOv1hYzGs+9DS9IdHkzmDXMYQkhcBsDFe dJBw== X-Gm-Message-State: AAQBX9c+QRoe2cM+BmM4E2TDs7Iinx9Wwd7KlNlLuOmL7cW/oihsJMtQ /OiOtlVzMe3idUjymXsh7H292Q== X-Google-Smtp-Source: AKy350YwiQpNucZPLFmYH31nXKCEmFnTPwJ530gji2rhw14K8Gja6BcKS2eDLrg0WTH99+06Q0AYfg== X-Received: by 2002:a05:600c:22c7:b0:3f0:3ab2:a7e5 with SMTP id 7-20020a05600c22c700b003f03ab2a7e5mr14988699wmg.34.1681834905967; Tue, 18 Apr 2023 09:21:45 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Viresh Kumar , Mathieu Poirier , "Gonglei (Arei)" , Markus Armbruster , Erik Schilling , Jason Wang , Mark Cave-Ayland , Gerd Hoffmann , virtio-fs@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake Subject: [PATCH v2 12/13] hw/virtio: derive vhost-user-i2c from vhost-user-base Date: Tue, 18 Apr 2023 17:21:39 +0100 Message-Id: <20230418162140.373219-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230418162140.373219-1-alex.bennee@linaro.org> References: <20230418162140.373219-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::330; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x330.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: 1681857698862100001 Now we can take advantage of the new base class and make vhost-user-i2c a much simpler boilerplate wrapper. Also as this doesn't require any target specific hacks we only need to build the stubs once. Signed-off-by: Alex Benn=C3=A9e Acked-by: Mark Cave-Ayland --- v2 - update to new inheritance scheme - move build to common code --- include/hw/virtio/vhost-user-i2c.h | 18 +- hw/virtio/vhost-user-i2c.c | 255 ++--------------------------- hw/virtio/meson.build | 5 +- 3 files changed, 26 insertions(+), 252 deletions(-) diff --git a/include/hw/virtio/vhost-user-i2c.h b/include/hw/virtio/vhost-u= ser-i2c.h index 0f7acd40e3..47153782d1 100644 --- a/include/hw/virtio/vhost-user-i2c.h +++ b/include/hw/virtio/vhost-user-i2c.h @@ -12,20 +12,18 @@ #include "hw/virtio/vhost.h" #include "hw/virtio/vhost-user.h" =20 +#include "hw/virtio/virtio.h" +#include "hw/virtio/vhost.h" +#include "hw/virtio/vhost-user.h" +#include "hw/virtio/vhost-user-device.h" + #define TYPE_VHOST_USER_I2C "vhost-user-i2c-device" OBJECT_DECLARE_SIMPLE_TYPE(VHostUserI2C, VHOST_USER_I2C) =20 struct VHostUserI2C { - VirtIODevice parent; - CharBackend chardev; - struct vhost_virtqueue *vhost_vq; - struct vhost_dev vhost_dev; - VhostUserState vhost_user; - VirtQueue *vq; - bool connected; + /*< private >*/ + VHostUserBase parent; + /*< public >*/ }; =20 -/* Virtio Feature bits */ -#define VIRTIO_I2C_F_ZERO_LENGTH_REQUEST 0 - #endif /* QEMU_VHOST_USER_I2C_H */ diff --git a/hw/virtio/vhost-user-i2c.c b/hw/virtio/vhost-user-i2c.c index 60eaf0d95b..4a1f644a87 100644 --- a/hw/virtio/vhost-user-i2c.c +++ b/hw/virtio/vhost-user-i2c.c @@ -14,237 +14,21 @@ #include "qemu/error-report.h" #include "standard-headers/linux/virtio_ids.h" =20 -static const int feature_bits[] =3D { - VIRTIO_I2C_F_ZERO_LENGTH_REQUEST, - VIRTIO_F_RING_RESET, - VHOST_INVALID_FEATURE_BIT +static Property vi2c_properties[] =3D { + DEFINE_PROP_CHR("chardev", VHostUserBase, chardev), + DEFINE_PROP_END_OF_LIST(), }; =20 -static void vu_i2c_start(VirtIODevice *vdev) -{ - BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); - VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); - VHostUserI2C *i2c =3D VHOST_USER_I2C(vdev); - int ret, i; - - if (!k->set_guest_notifiers) { - error_report("binding does not support guest notifiers"); - return; - } - - ret =3D vhost_dev_enable_notifiers(&i2c->vhost_dev, vdev); - if (ret < 0) { - error_report("Error enabling host notifiers: %d", -ret); - return; - } - - ret =3D k->set_guest_notifiers(qbus->parent, i2c->vhost_dev.nvqs, true= ); - if (ret < 0) { - error_report("Error binding guest notifier: %d", -ret); - goto err_host_notifiers; - } - - i2c->vhost_dev.acked_features =3D vdev->guest_features; - - ret =3D vhost_dev_start(&i2c->vhost_dev, vdev, true); - if (ret < 0) { - error_report("Error starting vhost-user-i2c: %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 < i2c->vhost_dev.nvqs; i++) { - vhost_virtqueue_mask(&i2c->vhost_dev, vdev, i, false); - } - - return; - -err_guest_notifiers: - k->set_guest_notifiers(qbus->parent, i2c->vhost_dev.nvqs, false); -err_host_notifiers: - vhost_dev_disable_notifiers(&i2c->vhost_dev, vdev); -} - -static void vu_i2c_stop(VirtIODevice *vdev) -{ - VHostUserI2C *i2c =3D VHOST_USER_I2C(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(&i2c->vhost_dev, vdev, true); - - ret =3D k->set_guest_notifiers(qbus->parent, i2c->vhost_dev.nvqs, fals= e); - if (ret < 0) { - error_report("vhost guest notifier cleanup failed: %d", ret); - return; - } - - vhost_dev_disable_notifiers(&i2c->vhost_dev, vdev); -} - -static void vu_i2c_set_status(VirtIODevice *vdev, uint8_t status) -{ - VHostUserI2C *i2c =3D VHOST_USER_I2C(vdev); - bool should_start =3D virtio_device_should_start(vdev, status); - - if (vhost_dev_is_started(&i2c->vhost_dev) =3D=3D should_start) { - return; - } - - if (should_start) { - vu_i2c_start(vdev); - } else { - vu_i2c_stop(vdev); - } -} - -static uint64_t vu_i2c_get_features(VirtIODevice *vdev, - uint64_t requested_features, Error **e= rrp) -{ - VHostUserI2C *i2c =3D VHOST_USER_I2C(vdev); - - virtio_add_feature(&requested_features, VIRTIO_I2C_F_ZERO_LENGTH_REQUE= ST); - return vhost_get_features(&i2c->vhost_dev, feature_bits, requested_fea= tures); -} - -static void vu_i2c_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_i2c_guest_notifier_mask(VirtIODevice *vdev, int idx, bool m= ask) -{ - VHostUserI2C *i2c =3D VHOST_USER_I2C(vdev); - - vhost_virtqueue_mask(&i2c->vhost_dev, vdev, idx, mask); -} - -static bool vu_i2c_guest_notifier_pending(VirtIODevice *vdev, int idx) -{ - VHostUserI2C *i2c =3D VHOST_USER_I2C(vdev); - - return vhost_virtqueue_pending(&i2c->vhost_dev, idx); -} - -static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserI2C *i2c) -{ - vhost_user_cleanup(&i2c->vhost_user); - virtio_delete_queue(i2c->vq); - virtio_cleanup(vdev); -} - -static int vu_i2c_connect(DeviceState *dev) -{ - VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); - VHostUserI2C *i2c =3D VHOST_USER_I2C(vdev); - - if (i2c->connected) { - return 0; - } - i2c->connected =3D true; - - /* restore vhost state */ - if (virtio_device_started(vdev, vdev->status)) { - vu_i2c_start(vdev); - } - - return 0; -} - -static void vu_i2c_disconnect(DeviceState *dev) -{ - VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); - VHostUserI2C *i2c =3D VHOST_USER_I2C(vdev); - - if (!i2c->connected) { - return; - } - i2c->connected =3D false; - - if (vhost_dev_is_started(&i2c->vhost_dev)) { - vu_i2c_stop(vdev); - } -} - -static void vu_i2c_event(void *opaque, QEMUChrEvent event) +static void vi2c_realize(DeviceState *dev, Error **errp) { - DeviceState *dev =3D opaque; - VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); - VHostUserI2C *i2c =3D VHOST_USER_I2C(vdev); - - switch (event) { - case CHR_EVENT_OPENED: - if (vu_i2c_connect(dev) < 0) { - qemu_chr_fe_disconnect(&i2c->chardev); - return; - } - break; - case CHR_EVENT_CLOSED: - vu_i2c_disconnect(dev); - break; - case CHR_EVENT_BREAK: - case CHR_EVENT_MUX_IN: - case CHR_EVENT_MUX_OUT: - /* Ignore */ - break; - } -} - -static void vu_i2c_device_realize(DeviceState *dev, Error **errp) -{ - VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); - VHostUserI2C *i2c =3D VHOST_USER_I2C(dev); - int ret; - - if (!i2c->chardev.chr) { - error_setg(errp, "vhost-user-i2c: missing chardev"); - return; - } - - if (!vhost_user_init(&i2c->vhost_user, &i2c->chardev, errp)) { - return; - } - - virtio_init(vdev, VIRTIO_ID_I2C_ADAPTER, 0); + VHostUserBase *vub =3D VHOST_USER_BASE(dev); + VHostUserBaseClass *vubc =3D VHOST_USER_BASE_GET_CLASS(dev); =20 - i2c->vhost_dev.nvqs =3D 1; - i2c->vq =3D virtio_add_queue(vdev, 4, vu_i2c_handle_output); - i2c->vhost_dev.vqs =3D g_new0(struct vhost_virtqueue, i2c->vhost_dev.n= vqs); + /* Fixed for I2C */ + vub->virtio_id =3D VIRTIO_ID_I2C_ADAPTER; + vub->num_vqs =3D 1; =20 - ret =3D vhost_dev_init(&i2c->vhost_dev, &i2c->vhost_user, - VHOST_BACKEND_TYPE_USER, 0, errp); - if (ret < 0) { - g_free(i2c->vhost_dev.vqs); - do_vhost_user_cleanup(vdev, i2c); - } - - qemu_chr_fe_set_handlers(&i2c->chardev, NULL, NULL, vu_i2c_event, NULL, - dev, NULL, true); -} - -static void vu_i2c_device_unrealize(DeviceState *dev) -{ - VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); - VHostUserI2C *i2c =3D VHOST_USER_I2C(dev); - struct vhost_virtqueue *vhost_vqs =3D i2c->vhost_dev.vqs; - - /* This will stop vhost backend if appropriate. */ - vu_i2c_set_status(vdev, 0); - vhost_dev_cleanup(&i2c->vhost_dev); - g_free(vhost_vqs); - do_vhost_user_cleanup(vdev, i2c); + vubc->parent_realize(dev, errp); } =20 static const VMStateDescription vu_i2c_vmstate =3D { @@ -252,30 +36,21 @@ static const VMStateDescription vu_i2c_vmstate =3D { .unmigratable =3D 1, }; =20 -static Property vu_i2c_properties[] =3D { - DEFINE_PROP_CHR("chardev", VHostUserI2C, chardev), - DEFINE_PROP_END_OF_LIST(), -}; - static void vu_i2c_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); - VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_CLASS(klass); + VHostUserBaseClass *vubc =3D VHOST_USER_BASE_CLASS(klass); =20 - device_class_set_props(dc, vu_i2c_properties); dc->vmsd =3D &vu_i2c_vmstate; + device_class_set_props(dc, vi2c_properties); + device_class_set_parent_realize(dc, vi2c_realize, + &vubc->parent_realize); set_bit(DEVICE_CATEGORY_INPUT, dc->categories); - vdc->realize =3D vu_i2c_device_realize; - vdc->unrealize =3D vu_i2c_device_unrealize; - vdc->get_features =3D vu_i2c_get_features; - vdc->set_status =3D vu_i2c_set_status; - vdc->guest_notifier_mask =3D vu_i2c_guest_notifier_mask; - vdc->guest_notifier_pending =3D vu_i2c_guest_notifier_pending; } =20 static const TypeInfo vu_i2c_info =3D { .name =3D TYPE_VHOST_USER_I2C, - .parent =3D TYPE_VIRTIO_DEVICE, + .parent =3D TYPE_VHOST_USER_BASE, .instance_size =3D sizeof(VHostUserI2C), .class_init =3D vu_i2c_class_init, }; diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index 8c6cb2143d..31c0406f05 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -10,6 +10,9 @@ softmmu_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG= _VHOST_USER_RNG'], softmmu_virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhos= t-user-gpio.c')) softmmu_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_GPIO'= ], if_true: files('vhost-user-gpio-pci.c')) +softmmu_virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost= -user-i2c.c')) +softmmu_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_I2C'], + if_true: files('vhost-user-i2c-pci.c')) =20 specific_virtio_ss =3D ss.source_set() specific_virtio_ss.add(files('virtio.c')) @@ -39,14 +42,12 @@ specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_VSOCK',= if_true: files('vhost-us specific_virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true: files('virtio-r= ng.c')) specific_virtio_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files('virtio= -iommu.c')) specific_virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-m= em.c')) -specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhos= t-user-i2c.c')) specific_virtio_ss.add(when: 'CONFIG_VHOST_VDPA_DEV', if_true: files('vdpa= -dev.c')) =20 virtio_pci_ss =3D ss.source_set() virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-= pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: files('vhost-u= ser-vsock-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-use= r-blk-pci.c')) -virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-use= r-i2c-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_INPUT', if_true: files('vhost-u= ser-input-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_SCSI', if_true: files('vhost-us= er-scsi-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_SCSI', if_true: files('vhost-scsi-pc= i.c')) --=20 2.39.2 From nobody Tue Feb 10 19:09:25 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=1681857532; cv=none; d=zohomail.com; s=zohoarc; b=QJ8SiKZJYlkr37p2322l98XLdf5dp3tOC6maNDSxGTofs2nYeNArmovF0zf0YTCdOBj9lJMuLhp+uy3NWKUclLMFJhrEOLRDJHO7blKOFdy9U+WojLZm/5eeeJVVflziybNqt7IoTyfAqsCdf/4ddJT9QI4EMlTNS54FosG+XZM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681857532; 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=QuJZaLubT8BhFuE9ylcD4Gy9hPKTq8TPugnpWu/KBiw=; b=O6EqNIrVies6Byic3l+yYJyvRzqglOkb5F+2sndo3GPH0L+9XAIDAEVvQSZrTmLNIxwFj1f9svchIOf0IPtCv5Y/5VrOnZg13n3gLoI/jp8iad/CSQB51mEpyriVy7jHm/2MaLqqEykpthpF3hqgoeuQWydU09DgkvvbAu3htcc= 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 1681857532691268.9065384527768; Tue, 18 Apr 2023 15:38:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pooCs-0008D8-P2; Tue, 18 Apr 2023 12:29:26 -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 1pooCq-0008Cz-Je for qemu-devel@nongnu.org; Tue, 18 Apr 2023 12:29:24 -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 1pooCo-0002jo-MF for qemu-devel@nongnu.org; Tue, 18 Apr 2023 12:29:24 -0400 Received: by mail-wm1-x334.google.com with SMTP id ay3-20020a05600c1e0300b003f17289710aso143776wmb.5 for ; Tue, 18 Apr 2023 09:29:21 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id g15-20020a05600c4ecf00b003edc4788fa0sm19486588wmq.2.2023.04.18.09.29.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 09:29:20 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A65D31FFC3; Tue, 18 Apr 2023 17:21:41 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681835360; x=1684427360; 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=QuJZaLubT8BhFuE9ylcD4Gy9hPKTq8TPugnpWu/KBiw=; b=t3HCEI064XFBRsR+tvVoJjytqVHXY8E+Nut66xpWqyIdLmbKR9S8pt8L1SFUjT+mPJ 3a5FjtnWl0y7ilDrcPUhfSa/4jIctYVL/GGYLdkAi/zWxb57VkBphyc8IzLt3QGYFInz NdRy9drlJF+0E7pNxveRiUsUr0NBlbBGF9D/E2n73mepPZvF86mN9Q+OrmOicQPVND72 4lWs+C87PwoNPKz3TShgfK1zRu7LiuZaRzAZRUIfBQ+prohi0R1gRLTT3T0JKEbKdUqp HKDBK1NlL8ZtRu6kdKrcqdBJz7wKFcHmAoxrHS/z+VGRwUbJxliSNzUj03ApLuh5Fu59 hY3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681835360; x=1684427360; 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=QuJZaLubT8BhFuE9ylcD4Gy9hPKTq8TPugnpWu/KBiw=; b=LMehk8iT+fkxg6aplnWrn2jsf8vXcpuGJaqDNUuxMlMqMKBctMQXnf7wDQvEHOMC1b 7IBpRFnYdiU5NPet3GHYlf0Z0A4xCMT3io7hCb3oU8Uz4DIauCIO1KDd9fLaS/acvmL/ 8jf4lwSfZ9TiUpXhTiT+soJF4YTu+wc5/JSXRBC5Dp16cO++FUrrAgRQXtAq1rz5LHL+ H+UdeEi1fLO6AUAt/KDdb54OeAI0Z3Qfgzi+ZMt92tfYPDxskfax69G/4NZcMVoJeP/0 A+5cOjst0Anr67jRp2J1FqeWczTcDdusaQZa83+3cC7TO0tnDfWf0RdV7binYgjU8cuw Bjkw== X-Gm-Message-State: AAQBX9fsfrZ6h2odnfu7aWImATrY/SzA5T2HHI6HjraXvGUYWXMrO3r/ 2O8S0wnrtqJp+OCNHlg6++3AlQ== X-Google-Smtp-Source: AKy350YNQudDN1NTLOM25n8TgBgWHR9vzbn3Rjecdg9LkJw6UYFwVelNmSewsm3wkCCCeAaX2jg1yg== X-Received: by 2002:a7b:c01a:0:b0:3ed:b56c:9496 with SMTP id c26-20020a7bc01a000000b003edb56c9496mr13031205wmb.31.1681835360679; Tue, 18 Apr 2023 09:29:20 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Viresh Kumar , Mathieu Poirier , "Gonglei (Arei)" , Markus Armbruster , Erik Schilling , Jason Wang , Mark Cave-Ayland , Gerd Hoffmann , virtio-fs@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake Subject: [PATCH v2 13/13] docs/system: add a basic enumeration of vhost-user devices Date: Tue, 18 Apr 2023 17:21:40 +0100 Message-Id: <20230418162140.373219-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230418162140.373219-1-alex.bennee@linaro.org> References: <20230418162140.373219-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: 1681857534343100002 Make it clear the vhost-user-device is intended for expert use only. Signed-off-by: Alex Benn=C3=A9e --- v2 - make clear vhost-user-device for expert use --- 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..7038cece3e 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 Development Device + - You must manually specify ``virtio-id`` and the correct ``num_vqs``.= Intended for expert use. + * - 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