From patchwork Tue Apr 18 16:21:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 674517 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp58660wrs; Tue, 18 Apr 2023 09:22:58 -0700 (PDT) X-Google-Smtp-Source: AKy350bd4VDvTZB3V69gMRBWWampRuzrWQZlAVNDKjZ0AjUHeR44yDbi84qX7oUfs7wNjJ1eDddt X-Received: by 2002:ac8:574c:0:b0:3ef:3b04:b8dc with SMTP id 12-20020ac8574c000000b003ef3b04b8dcmr781197qtx.0.1681834977918; Tue, 18 Apr 2023 09:22:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681834977; cv=none; d=google.com; s=arc-20160816; b=HW2LBZvA7tI5B8AKU9q51TDUtC2yMjGaI/iNgnHNCcbf6ObmXTfsGOHUpZeNlqO/p7 qvQMps6LPNzrFVX6mKuPoxABtFNUooU1nBfjE0K/iI/+f+2uUxw9vp3F9ruqQK3wJfP/ /5pfen789j1cFjaGPvhIVzxKPp0db2TVKgAkK6ofDEyyzv58Q4g9eppd3XJ+C3KotGQ1 Kkuz32hGhl6F0Cyo5XblMvn8mSO/N2Vj4/6ZDlcX5qPHpx4n/MkCaLfLiiDb/h2g6oIg hsZywFuE2ofbe2nvcmQrtB01dBddRKxMVnI1dqWwmtlWBDVKpDFuTBHAuXo5M/Yq/Fig bS+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nVPcgNqV4+yTyF7JyxZthOMz/9y/APO3HAlemN7QWn4=; b=NgOgv+VfGr3ZR/pJNoBkqXo7xnPhKFD+kGkFAt/XSRsLT+oW92nvb9GyX+5O20rjuS 3nA9HcRuU29wZ1dEwCI1N9eRXA/QnxWKuEuCwlC/Z/IVKNQ2Rt9u90xuyYmI9iM0LXua n4UNONScAgyEZLzyRpPu/81PJcQx+MLDR3NbPHUCyKPjhrC3UWYrwCoNqz8yI01wKnpC Jhan9FfGeA09ZUek1zQ+HGzbVPhkPbsmrdMqdf8wIPqnJs5S882XQdz4wX1hN7yQwwNw ol0yMKmJm/og1PR6LGRoOoRtBYggY2ci4UfZzCOridUUkq9DjdWIFD8n+Im/4HXUA07H 9PZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lh3DoEsc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t8-20020a37ea08000000b00746b5597206si7443621qkj.114.2023.04.18.09.22.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Apr 2023 09:22:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lh3DoEsc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Daniel_?= =?utf-8?q?P=2E_Berrang=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-And?= =?utf-8?q?r=C3=A9_Lureau?= , 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org I'm still not sure how I achieve by use case of the parent class defining the following properties: static Property vud_properties[] = { 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[] = { 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ée --- 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 *dev); +/** + * 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); /** From patchwork Tue Apr 18 16:21:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 674519 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp58831wrs; Tue, 18 Apr 2023 09:23:18 -0700 (PDT) X-Google-Smtp-Source: AKy350awOLhYehOxU/o1RYe32Gp1fOicU/+gXzqzyGi/hY3XX1TeXg2Tc1N6gTDC+55RRSIbkbt+ X-Received: by 2002:a05:6214:246f:b0:5ea:2575:dccb with SMTP id im15-20020a056214246f00b005ea2575dccbmr20034238qvb.46.1681834998128; Tue, 18 Apr 2023 09:23:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681834998; cv=none; d=google.com; s=arc-20160816; b=Dn1Svp3y7odRMaPMwLpAgmyjibR4f2GoOx0FoAWwYVCpESA+J/nq4176bT1Rmg/0jp 2XMCV2GMEwRwiGfzI/EL69C2+kQUt16+KhilimPJIYgP0GkNgkhifMfbL+N7kvPsLDuf NPyZ6kYvaYQq6JQ9PljsfGpb1qO8v7tRbjaPK3hnsnD6t26nJvxln3pXVCXd3yogMC2s TkW3Sp5XRYUXV3o+Zu48bTXZybXSkl4s/5FAZ8m7x3m54alQrTo2d4oPRXIhqteu6t9z tuBrom3Y8hzl8NYQQ05S3PlHRmf/ytFsayW1snbxUrKmkOzqP65U+bQrfnIbPhYkNw0f P5Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2d/kTabziFWz81diPGPd2lcq9eXntPtMnKyAEA11+CY=; b=gL/CMlIJbHVxNVZJBPxGmEt4LKbPkK29meuHiu24cW/yboN5E4U3pBvmqoSGKCcS6/ 4kXWr/q5cMT0EFVJP2rz//+F2IGIeWFJ32Zj7phpZeIiLaSjYrgILjkmEXlm2kUo8wK0 ixPRTAK6H7ojBCv6SJ/EI3Aku4hwLXYsdmn4gtcUIKdkduemmAu9iKkczvTaegEhF5VO lLnRqxxPDqYaI63jVqh7rsiR2fJn2Egy9PPJ8Xchwmk7ea5OV/xU3n0w8fylJEJ7KCir ySymkEDTolMhncWkocnpUT9YBe8YdRdqwfcQYwq432jYfahbRC+PAz36IN8BQ6Wsl9Yl vIhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VBIl2DDI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 4-20020a0562140d0400b005e7fc559b08si7448842qvh.147.2023.04.18.09.23.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Apr 2023 09:23:18 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VBIl2DDI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Daniel_?= =?utf-8?q?P=2E_Berrang=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-And?= =?utf-8?q?r=C3=A9_Lureau?= , 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org These are useful functions for when you want proper inheritance of functionality across realize/unrealize calls. Signed-off-by: Alex Bennée --- 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); From patchwork Tue Apr 18 16:21:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 674521 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp58888wrs; Tue, 18 Apr 2023 09:23:25 -0700 (PDT) X-Google-Smtp-Source: AKy350ZUTsxjXz3KILA/GcxLNvv4yPPJQ6eKrM13v50ISGfJhn6Y+9vMcWN8iwFgpyvfjHVcaHRd X-Received: by 2002:ad4:5ce4:0:b0:5e8:e227:983d with SMTP id iv4-20020ad45ce4000000b005e8e227983dmr25330936qvb.45.1681835005719; Tue, 18 Apr 2023 09:23:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681835005; cv=none; d=google.com; s=arc-20160816; b=bNgp2keIIp8QbJbsWZikoXhPVgVBhKlNq+Ncp+yQkygBJQmIp8WX2FLaUeRINiK7Ys yuJUsh1CElC9bOB/NiRiNQYTxmbjXDaXp6/gb+9C17x9eMETeHvDIVHrEYc3YfwxS+kc DF4bWmM+qIS6FbR/eLzGV/n7fSX/s5KklsQtRgd/QV6RcQ+Bp5hYcBxHyeihKQADO6Fp RaOVQtgQNZBSfl+HIgowC/cQODS6Gi8NnjZkWCPvhowveEqal2fQ6dFcsS+CxecNj4+m tUmm2wZMdo08kEnn4NPa3chCXUlhgK1S0GWna1wWxIY3yR7YTfDGMdEBLPRFNquKKYsW eWBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ac6OXeQsb/93HLbnF+qlx0Y/JMMvx4eaZHVLLhBGMnw=; b=DPi2lA3dPGxYVR/VhKErzv+pa4LOBzaD7ERgwivkm4G6IJPXQ4Da26zCSTKFIWW8kr VHKia4PBycncLmR7qypYJ8IK9erTZQsZDBGR658bMa9KgAiiuII3uc4PIMNHmrDpgUbQ l5znZDZRzjmdLDyTy5VAgbfg+5KFHEB70/APw7lOGSgm9dV3ughxqYWQL5csFkYPBkvk 7Zkx6NEmSdVFRcDVbxHpdhvkkW8m6FxCwLul9u5qLUya29gcnYIuv00w8Ae06K35XqyT pIqBwdNCID96U7Q0oak5EFUXJ6sy+2ZOzkUb2pC/XU/mgbOT4FonWLpJBMZKRTW/ssMj XAIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fEqXtv0u; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m5-20020ad45dc5000000b0056eb2269008si7411157qvh.498.2023.04.18.09.23.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Apr 2023 09:23:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fEqXtv0u; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Daniel_?= =?utf-8?q?P=2E_Berrang=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-And?= =?utf-8?q?r=C3=A9_Lureau?= , 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Fixes: 544f0278af (virtio: introduce macro VIRTIO_CONFIG_IRQ_IDX) Signed-off-by: Alex Bennée 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 *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 */ @@ -506,7 +506,7 @@ vhost_user_gpu_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask) /* * 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 */ 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(VirtIODevice *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 */ @@ -3391,7 +3391,7 @@ static void virtio_net_guest_notifier_mask(VirtIODevice *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 */ 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, /* * 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 */ @@ -177,7 +177,7 @@ static bool vuf_guest_notifier_pending(VirtIODevice *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 */ 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 *vdev, int idx, bool mask) /* * 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 */ 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(VirtIODevice *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 */ @@ -146,7 +146,7 @@ static bool vhost_vsock_common_guest_notifier_pending(VirtIODevice *vdev, /* * 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 */ 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(VirtIODevice *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 */ @@ -1227,7 +1227,7 @@ static bool virtio_crypto_guest_notifier_pending(VirtIODevice *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 */ From patchwork Tue Apr 18 16:21:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 674516 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp58591wrs; Tue, 18 Apr 2023 09:22:48 -0700 (PDT) X-Google-Smtp-Source: AKy350anu9NC4R9aRzv8aSA+5dv1+ivRLjRE/fddj6yIUibVAOKcqIjRY2kxsGQ1vR+8c3JSfbZO X-Received: by 2002:a05:6214:27e6:b0:5ef:5049:f49a with SMTP id jt6-20020a05621427e600b005ef5049f49amr25966152qvb.32.1681834968332; Tue, 18 Apr 2023 09:22:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681834968; cv=none; d=google.com; s=arc-20160816; b=iYrSf7flPaxqHCm3SIkzW8cjJZokn8gnF9XNLxK9l1LcfHi3JNrU3lKYrVgwiP4aLf tqDPLhCmA+5+cvwMfdxinFR6T3Sbnz7ejKqn/LXU+h6jjJO3DQ8smmuxpt3ExGtvjPg+ eJ9Npj1uilYWR/b1ARteogghyuxlKSSyfuPWZjIwe/WNmpwkwYmdrMGkLbqvT4sLzFYu u1aef8OdHSNUWE+D3xULr1yalzOCTCe6T5Zxw7oUpkS4FtTurPazUnQxevKjci6Rfscp TL5Rds3t/vzzAjF+zyunaZWeKQ8RZMyi53e8PksJqfs/GceqgrASR6MCUf6wMvs+FlIY pSqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KH5LwiCrOTvBSCuNpYnxQcsypFz8wThrZQsAnqkj0KQ=; b=IqTuNLIGEpDMXCVD2eJzrlo1DY9NLJiWX0TaJmmCeVw5WRc5dcIkZ8ngGJxNB3UpUO msZyEohAKhpSIEdG3QTXMibD0M4lLpvZAT6ZfeMy6R4MENAzvRLBgT6Q3X4n+JJAkUOh eGAltPH1rNF+7xd4JBdS7OD/2QJaDS45f5MWHPQiRZ4SV/qt0p+nV51XWUBhMTLVsv1R d6tdxkYfn17qywZWANmvaQKAEQLguKAMXyU6++X2bQLC8HfKMVb/ew6/6yqkYmarUjgv hyl01pNPb8Yha0mr37mpbN6GzawrZRYRUVVt/I3gTIQ3EKkRYWlDrJGdndPTEk4GXdEv KiQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XyBsieux; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id hf1-20020a0562140e8100b0058dd32b99a2si7577308qvb.301.2023.04.18.09.22.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Apr 2023 09:22:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XyBsieux; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Daniel_?= =?utf-8?q?P=2E_Berrang=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-And?= =?utf-8?q?r=C3=A9_Lureau?= , 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Alex Bennée 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; int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id); +/** + * 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); bool virtio_queue_get_notification(VirtQueue *vq); From patchwork Tue Apr 18 16:21:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 674523 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp59131wrs; Tue, 18 Apr 2023 09:24:00 -0700 (PDT) X-Google-Smtp-Source: AKy350YWcXwOvWk88bX90oMK3OrJy2AcP9wm8/l+4AKKpAHO6aKz7TR+TL9DN2FNbQZMU7QSa9AU X-Received: by 2002:ad4:5bcb:0:b0:5a9:609d:e23c with SMTP id t11-20020ad45bcb000000b005a9609de23cmr25222648qvt.34.1681835040097; Tue, 18 Apr 2023 09:24:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681835040; cv=none; d=google.com; s=arc-20160816; b=0DitEH4P0xOQjtDCv3kfDhSjkzwAEpd0rMqPHpXuG+uIEyYa4kiBH/UmQ/gQkEkEbS 5dCFvZRGsYntC7hvgvPEgqoCCYGt1dqhjYAFI0zILt30/uX3rmr47XkW5++UF7FpFFbx iQ8f4Y4nLm+wKxjAHtnzbzYNx9Gwgrp7pxX2pLGVcOwclMf4Aj6pcODNCSPdv4c3A5H1 8PTOS9m6+lxdYALyKIVJkpm2mqQmtB1DWxk4J9vOQ0h8RMxBwJO77mjXjdhG3QUg9PY5 lU/2GN1Xgeqmi7xogJSOG5OTKKK6nHwUxXgwQ6UyuRrpXOSmGMBYJ0D1s5aXKtkaKyUO MghQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9tB5/chm/xr33XCg/P0FBnvaCeSkgyIRzyFrSzsSo0k=; b=Zru9qJOBaFPfePMRR0PeXGkoxCyrovlLENWUd7BIrjwiHoDLBAsBt8NSg3DMnIx2CK EC+AxjQ/yi7DPvzaq6PbXLfw66B/4lcy5yzIDbNlY+0r95/3koqAsDPRFPSE0llyI/+X koq0ux2Gv8YnMxbkrSuehvO2eC/5EkxmFZkn9YWlcCh6PkiIdNRA7uE8tC39HiE283mt A0niSZIyNXAPw8Fotu68hcT6Nz32AFEB0pCKDmRDIpwbzf5CKEFvASUmvLGwKo/ZNZ7/ 8exeVI1C7cr6at6VYCjKZU9otkA+wzG8+IPzDbWtWZKcnoY/8S6K7bbHKg/N9NSJpcDH 8bpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="uxF/LM8P"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t10-20020ad45bca000000b0056ef275d752si7398883qvt.481.2023.04.18.09.23.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Apr 2023 09:24:00 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="uxF/LM8P"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Daniel_?= =?utf-8?q?P=2E_Berrang=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-And?= =?utf-8?q?r=C3=A9_Lureau?= , 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Alex Bennée 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); +/** + * 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_size); void virtio_cleanup(VirtIODevice *vdev); From patchwork Tue Apr 18 16:21:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 674520 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp58865wrs; Tue, 18 Apr 2023 09:23:22 -0700 (PDT) X-Google-Smtp-Source: AKy350aXR7o8YOUx7B6YECQI+2GMqiILSby0x9tuu5z/nhj3S4pvzCFD7caIgYHZT+6lTG+VECsP X-Received: by 2002:a05:622a:50:b0:3e6:499c:6849 with SMTP id y16-20020a05622a005000b003e6499c6849mr612603qtw.10.1681835002265; Tue, 18 Apr 2023 09:23:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681835002; cv=none; d=google.com; s=arc-20160816; b=aj4RYF14ixCyPi/3D66kucEkfjwvirq/nGYbF3v3rHjwCNgdoqPdVQXnEVOjRjiHg7 fYSOLazPKNBQSpGX+Nc1WT4P6EKe2g1HpfLPoU7/9m93OhvhAvujMPv0R86szPsx0QWg ydHFXhe9JZTETuVCLBn4ZitXBEGW+ThEM4PRGmXPIBFW9q3FnmXROozIVQHnwXT1kqyU 0SOxrTTWYklcWLZ7oGYfw/TJATNO1A3G1o+Z0b4hDnvg1+6bZIHgIakU401IcRGbsL+J OL21an8/GAqBmJzmcY9AltjMY0aRqC+duizSjaGsmO6IKffmA1ASpPW03Q/FD84d2UuS k+KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uMkpUFkutd+rkxciDVz0OwgC4E2pyiYQdv8Xz2UBqBQ=; b=vEG0CSHZeTjssnu+4FEjBczhDLYHCTHHyBuMlP5rtzBPffyW2wBmt+eL63rENOBOso XhkQgIpU7OP3emB1HjPzoxaBGYMmqZweIzOBcglLH4lZHpOAvcA+cI3E5XZTt2xU/7kd IwHut7vv7xxpVo24409KV/Qnp0LuZYJdqcRQAlTuuv0KcpIIxWdlDBPp152q4+x9MoWo 1e5uD7Ljuh9CCxFHM6aVQf5IxmmC3U0AlmT1cUEqtFCr0PjZReUi1YuCeqqnrkXPv5lI sfJk/SD4D+KHjQtqA+swhl43COg68LznnMF3QpedIOiv3memYAu2c+3MqRVgmz5tRdfU hTbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="pYO2bM/H"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y19-20020a05620a25d300b0074ac130d169si7817148qko.745.2023.04.18.09.23.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Apr 2023 09:23:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="pYO2bM/H"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Daniel_?= =?utf-8?q?P=2E_Berrang=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-And?= =?utf-8?q?r=C3=A9_Lureau?= , 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Lets document some more of the core VirtIODevice structure. Signed-off-by: Alex Bennée 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() callback. + * 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; }; From patchwork Tue Apr 18 16:21:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 674525 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp59266wrs; Tue, 18 Apr 2023 09:24:15 -0700 (PDT) X-Google-Smtp-Source: AKy350aSId0N9/tu/l28PuN4FHdxZEuZDVdcOJMZKGe43wsG/IyUGwsLm82aLbPj5amz5gpiJb+C X-Received: by 2002:ac8:5bc6:0:b0:3bf:cea5:7004 with SMTP id b6-20020ac85bc6000000b003bfcea57004mr447015qtb.51.1681835055256; Tue, 18 Apr 2023 09:24:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681835055; cv=none; d=google.com; s=arc-20160816; b=Ea2l5A8JGzXXnrcWtWR833wOqW+kicF73w4+Z1AtXUhQ1n9TujwWz9/Dhr5r6XJZTa XXAnrex2WwEemSWUA6WyijnBnTOPLLIwbxJBO4OsrSiqgM2/ffy0YyWPBfA+Gq8a1JJr StM+vZO2jzLaJ31x+T/9wHo91YCcJLSwgsmHAqi5liaRA2RZputoNIk9XJTIkKWcAp2b Kxqc9QDwT+N44ETWQ+gfzHETxhMXAs8TloOZT6WHNeB3F3Wi2uGDWGcH1ZZNpRn/AvM0 WQYsVa9nUzgdNTQICuV+RwapX4jpN4PtTjJiFJXrS166C69zZ3x9FWYLDzDVNZrj+n6U CxCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1A+5QxSTbXGCo55UOJ3nazzxUb4+UhfLG866jSa6yr4=; b=WxXyK6O9oG3IR2EHvvpVZOsN2wJs6yszgtSEEpca3H7wnwWeGcOzkBNJYU/carx0Ro Y0fX4BO9NggIQNDBxi+6pq9r32PYbB+Y+ACRayrPQ1qK+1kHnnJnqXqUn3skJD1zgw6i Byhem6I2ZY2tQciPgyNaONDoOvF3OGyv6G0TxZYAxLYYrBLKMHJa8jI453xyOE6E+RQT /UeEemBwBx7kRfZLwLJt4xDhyW307qo/FazbTf87pAHBGun/c4FNLoV9iMROt+ZZeWtb 2RajixTecIfwcbvaxIWFBG7Uu2LSCig4ui2OhrguqkiJWeUEsyn2Aeby3tnNusZYw5mf bgdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f1mgtZ69; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n62-20020a37bd41000000b0074a4fab58basi7221526qkf.3.2023.04.18.09.24.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Apr 2023 09:24:15 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f1mgtZ69; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Daniel_?= =?utf-8?q?P=2E_Berrang=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-And?= =?utf-8?q?r=C3=A9_Lureau?= , 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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ée --- 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/vhost-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ée + * + * 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 = BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); + VHostUserBase *vub = VHOST_USER_BASE(vdev); + int ret, i; + + if (!k->set_guest_notifiers) { + error_report("binding does not support guest notifiers"); + return; + } + + ret = vhost_dev_enable_notifiers(&vub->vhost_dev, vdev); + if (ret < 0) { + error_report("Error enabling host notifiers: %d", -ret); + return; + } + + ret = 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 = vdev->guest_features; + + ret = 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 = 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 = VHOST_USER_BASE(vdev); + BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); + int ret; + + if (!k->set_guest_notifiers) { + return; + } + + vhost_dev_stop(&vub->vhost_dev, vdev, true); + + ret = k->set_guest_notifiers(qbus->parent, vub->vhost_dev.nvqs, false); + 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 = VHOST_USER_BASE(vdev); + bool should_start = virtio_device_should_start(vdev, status); + + if (vhost_dev_is_started(&vub->vhost_dev) == 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 = 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_FEATURES); +} + +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 = 0; i < vub->num_vqs; i++) { + VirtQueue *vq = g_ptr_array_index(vub->vqs, i); + virtio_delete_queue(vq); + } + + virtio_cleanup(vdev); +} + +static int vub_connect(DeviceState *dev) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserBase *vub = VHOST_USER_BASE(vdev); + + if (vub->connected) { + return 0; + } + vub->connected = true; + + /* restore vhost state */ + if (virtio_device_started(vdev, vdev->status)) { + vub_start(vdev); + } + + return 0; +} + +static void vub_disconnect(DeviceState *dev) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserBase *vub = VHOST_USER_BASE(vdev); + + if (!vub->connected) { + return; + } + vub->connected = false; + + if (vhost_dev_is_started(&vub->vhost_dev)) { + vub_stop(vdev); + } +} + +static void vub_event(void *opaque, QEMUChrEvent event) +{ + DeviceState *dev = opaque; + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserBase *vub = 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 = VIRTIO_DEVICE(dev); + VHostUserBase *vub = 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 = 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 the + * asynchronous vhost-user socket. + */ + vdev->use_guest_notifier_mask = false; + + /* Allocate queues */ + vub->vqs = g_ptr_array_sized_new(vub->num_vqs); + for (int i = 0; i < vub->num_vqs; i++) { + g_ptr_array_add(vub->vqs, + virtio_add_queue(vdev, 4, vub_handle_output)); + } + + vub->vhost_dev.nvqs = vub->num_vqs; + vub->vhost_dev.vqs = g_new0(struct vhost_virtqueue, vub->vhost_dev.nvqs); + + /* connect to backend */ + ret = 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 = VIRTIO_DEVICE(dev); + VHostUserBase *vub = VHOST_USER_BASE(dev); + struct vhost_virtqueue *vhost_vqs = 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 = VIRTIO_DEVICE_CLASS(klass); + + vdc->realize = vub_device_realize; + vdc->unrealize = vub_device_unrealize; + vdc->get_features = vub_get_features; + vdc->set_status = vub_set_status; +} + +static const TypeInfo vub_info = { + .name = TYPE_VHOST_USER_BASE, + .parent = TYPE_VIRTIO_DEVICE, + .instance_size = sizeof(VHostUserBase), + .class_init = vub_class_init, + .class_size = sizeof(VHostUserBaseClass), + .abstract = 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 = { + .name = "vhost-user-device", + .unmigratable = 1, +}; + +static Property vud_properties[] = { + 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 = DEVICE_CLASS(klass); + + device_class_set_props(dc, vud_properties); + dc->vmsd = &vud_vmstate; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); +} + +static const TypeInfo vud_info = { + .name = TYPE_VHOST_USER_DEVICE, + .parent = TYPE_VHOST_USER_BASE, + .instance_size = sizeof(VHostUserBase), + .class_init = vud_class_init, + .class_size = 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', 'virtio-qmp.c')) if have_vhost specific_virtio_ss.add(files('vhost.c', 'vhost-backend.c', 'vhost-iova-tree.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')) From patchwork Tue Apr 18 16:21:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 674515 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp58574wrs; Tue, 18 Apr 2023 09:22:46 -0700 (PDT) X-Google-Smtp-Source: AKy350bFinRAKPdYG2X6YuW10efGxt0qjXP8TZaPKuu96+KHEZbsVId9EEcHATarRHjtEa/p4IiA X-Received: by 2002:ac8:5e4d:0:b0:3ed:164c:6834 with SMTP id i13-20020ac85e4d000000b003ed164c6834mr612773qtx.27.1681834966262; Tue, 18 Apr 2023 09:22:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681834966; cv=none; d=google.com; s=arc-20160816; b=kGxFrsLPoSm7/CMsRl1g5+Fkv5plJF6KzybOHkwFmb9sth/7CAWX0VRnyHG2NGSfL4 zV649VO2kKm8PikgfcXu/cfL/iuBEHf1BqS3TzwSDUhnXw1K/KhISjulR7dYrvZmqEWc A6PUGwfb0XWXqu8BKyfIXhiZkADnQNYfO2mC7+YE8Jl/XgmO5BOU/rDvDrE7MyrLZHNR MefHe6ZeXOyxG0w1J/TYg23RZeR+zOmOjmvuzXzZn48pWAYq8mI3jCGvZuTudxLrqf6C dEx9FBRM1t8PAxVaK6JWOh0Dl3tslwygSuL/DpBakTUMBR0CcpdDe8W+X4SN0rlbVerd ymOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=eC5A3sVizk95geXn4I1Vdcti4PHMTBsSCbklkuaCJpg=; b=Nf2lEohp+xn7uJS4wtA9FMDcDijbpL09WwI5r5ZmLsiUssfTkptLPCVdh8ANpH2+o5 0WHmLQwQCmeIZr9fkO917ns/eeiJyrKpOelbh2eb6FwC9Z1bvS2HJdepQPnirer9A4yK axzoCWV/3dFBawEv6vGst1GBRhI8JauNuqV/XO8ikUCgjKcnAU+sIMrU2AFKDdpGlvaP vJGzu8Ls8D/30guU/18E45b2l0vHKNnt3S+nPPKGXKZ3ZJO/lgpKyPjv+oxjVlQuU0xw YAVDTL1bqzbWaVGnxKRzQvijJLmCRQ7vxICQQKxZC60CoUiq9R4HWQblui3v8msm1HPo G2Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xX9KuWOR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k11-20020a05620a0b8b00b0074ae357dfd8si3059113qkh.603.2023.04.18.09.22.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Apr 2023 09:22:46 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xX9KuWOR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Daniel_?= =?utf-8?q?P=2E_Berrang=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-And?= =?utf-8?q?r=C3=A9_Lureau?= , 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This is all pretty much boilerplate. Signed-off-by: Alex Bennée 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-device-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ée + * + * 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 = VHOST_USER_DEVICE_PCI(vpci_dev); + DeviceState *vdev = DEVICE(&dev->vub); + + vpci_dev->nvectors = 1; + qdev_realize(vdev, BUS(&vpci_dev->bus), errp); +} + +static void vhost_user_device_pci_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass); + PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass); + k->realize = vhost_user_device_pci_realize; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); + pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET; + pcidev_k->device_id = 0; /* Set by virtio-pci based on virtio id */ + pcidev_k->revision = 0x00; + pcidev_k->class_id = PCI_CLASS_COMMUNICATION_OTHER; +} + +static void vhost_user_device_pci_instance_init(Object *obj) +{ + VHostUserDevicePCI *dev = 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 = { + .base_name = TYPE_VHOST_USER_DEVICE_PCI, + .non_transitional_name = "vhost-user-device-pci", + .instance_size = sizeof(VHostUserDevicePCI), + .instance_init = vhost_user_device_pci_instance_init, + .class_init = 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')) From patchwork Tue Apr 18 16:21:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 674526 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp59285wrs; Tue, 18 Apr 2023 09:24:16 -0700 (PDT) X-Google-Smtp-Source: AKy350ZuXxfhw+LufYdxMTqh545u/Wmnzzm4/1znfMCpkRm5IIbAz5Eut1NgAGUK/dbwb1I3gTVF X-Received: by 2002:ac8:5a45:0:b0:3ef:2199:1a79 with SMTP id o5-20020ac85a45000000b003ef21991a79mr796448qta.5.1681835056537; Tue, 18 Apr 2023 09:24:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681835056; cv=none; d=google.com; s=arc-20160816; b=q44+F0ysmkWRIWU2ESEetvSb38L3Mn1Ruq98s+KboJpAX1Nr5QPVEHZfw87xyraByC S4ZROhA62J8RnPFcFfkJpqWgPqrWwl8gl6O870H3A/3NbqbEXCmRRF7IATNg+TBy4Cma cP0U7cuEda3KZTMg4UJJVvbZg5vJ2TBGmVdKlt4IacNL9/boCfm3dBurtWorXLEviBQI hPGWuZUlWzh9RgIvbRahHvolCR0QAbAkUNWPTYv8dT21BELuDMDJPQUfTb1ApW4HBIQD GdjP4fSFKtKxXCODxB1Kx3ErjxloHiQwB8PC4lfdC/lTeoeXVV7E0deXbX7+QH5ZG8wg 1ERw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RHdGm7j8I+C9yYQqKwhoXKBTWIBzPYm6rSCDYdpEQFY=; b=LK55xZujxjS/SzHPlr+aR24warMLBe9+8ry0WZA14RrRlsFcr2hdJ8ZL/XPsXSkoFh AfRTtVOnbpLJ9OFd4zCdm72LVzSxMoG0DbZuXyM/N6ZBss61i8Mz5oGcTPYu9Kl8OAXN LX1nxNTv0ylAcEBVVJH/F4wIaYhfgrdK8D5BNdic8yloXss1Oi/PJgbqh3z+XPTRjqZc z3PL0iNf9aUhfEW5vToZljm4XsBemHxtr5XYtZOje9mPvWtMh8C9jYDftEI1J5oXPjG4 b0Ofvb0unMCDgkZ2t+hhtTjmzX/+wJwpes3zg7TKIVN7vszS/VOIUZ1UzZYW1ZjA9eah 20uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=deuGwp5r; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 13-20020a370a0d000000b0074ced3e0003si3471584qkk.26.2023.04.18.09.24.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Apr 2023 09:24:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=deuGwp5r; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Daniel_?= =?utf-8?q?P=2E_Berrang=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-And?= =?utf-8?q?r=C3=A9_Lureau?= , 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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ée 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-user-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" #define TYPE_VHOST_USER_RNG "vhost-user-rng" OBJECT_DECLARE_SIMPLE_TYPE(VHostUserRNG, VHOST_USER_RNG) 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 >*/ }; 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" -static const int feature_bits[] = { - VIRTIO_F_RING_RESET, - VHOST_INVALID_FEATURE_BIT -}; - -static void vu_rng_start(VirtIODevice *vdev) -{ - VHostUserRNG *rng = VHOST_USER_RNG(vdev); - BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); - VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); - int ret; - int i; - - if (!k->set_guest_notifiers) { - error_report("binding does not support guest notifiers"); - return; - } - - ret = vhost_dev_enable_notifiers(&rng->vhost_dev, vdev); - if (ret < 0) { - error_report("Error enabling host notifiers: %d", -ret); - return; - } - - ret = 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 = vdev->guest_features; - ret = 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 = 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 = VHOST_USER_RNG(vdev); - BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); - VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); - int ret; - - if (!k->set_guest_notifiers) { - return; - } - - vhost_dev_stop(&rng->vhost_dev, vdev, true); - - ret = k->set_guest_notifiers(qbus->parent, rng->vhost_dev.nvqs, false); - 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 = VHOST_USER_RNG(vdev); - bool should_start = virtio_device_should_start(vdev, status); - - if (vhost_dev_is_started(&rng->vhost_dev) == 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 **errp) -{ - VHostUserRNG *rng = 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 mask) -{ - VHostUserRNG *rng = 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 = VHOST_USER_RNG(vdev); - - return vhost_virtqueue_pending(&rng->vhost_dev, idx); -} - -static void vu_rng_connect(DeviceState *dev) -{ - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserRNG *rng = VHOST_USER_RNG(vdev); - - if (rng->connected) { - return; - } - - rng->connected = true; - - /* restore vhost state */ - if (virtio_device_started(vdev, vdev->status)) { - vu_rng_start(vdev); - } -} - -static void vu_rng_disconnect(DeviceState *dev) -{ - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserRNG *rng = VHOST_USER_RNG(vdev); - - if (!rng->connected) { - return; - } - - rng->connected = false; - - if (vhost_dev_is_started(&rng->vhost_dev)) { - vu_rng_stop(vdev); - } -} - -static void vu_rng_event(void *opaque, QEMUChrEvent event) -{ - DeviceState *dev = 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 = VIRTIO_DEVICE(dev); - VHostUserRNG *rng = 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 = 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 = 1; - rng->vhost_dev.vqs = g_new0(struct vhost_virtqueue, rng->vhost_dev.nvqs); - ret = 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 = VIRTIO_DEVICE(dev); - VHostUserRNG *rng = VHOST_USER_RNG(dev); - struct vhost_virtqueue *vhost_vqs = 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 = VHOST_USER_RNG(vdev); - return &rng->vhost_dev; -} - static const VMStateDescription vu_rng_vmstate = { .name = "vhost-user-rng", .unmigratable = 1, }; -static Property vu_rng_properties[] = { - DEFINE_PROP_CHR("chardev", VHostUserRNG, chardev), +static Property vrng_properties[] = { + DEFINE_PROP_CHR("chardev", VHostUserBase, chardev), DEFINE_PROP_END_OF_LIST(), }; +static void vu_rng_base_realize(DeviceState *dev, Error **errp) +{ + VHostUserBase *vub = VHOST_USER_BASE(dev); + VHostUserBaseClass *vubs = VHOST_USER_BASE_GET_CLASS(dev); + + /* Fixed for RNG */ + vub->virtio_id = VIRTIO_ID_RNG; + vub->num_vqs = 1; + + vubs->parent_realize(dev, errp); +} + static void vu_rng_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); + VHostUserBaseClass *vubc = VHOST_USER_BASE_CLASS(klass); - device_class_set_props(dc, vu_rng_properties); dc->vmsd = &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); - vdc->realize = vu_rng_device_realize; - vdc->unrealize = vu_rng_device_unrealize; - vdc->get_features = vu_rng_get_features; - vdc->set_status = vu_rng_set_status; - vdc->guest_notifier_mask = vu_rng_guest_notifier_mask; - vdc->guest_notifier_pending = vu_rng_guest_notifier_pending; - vdc->get_vhost = vu_rng_get_vhost; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); } static const TypeInfo vu_rng_info = { .name = TYPE_VHOST_USER_RNG, - .parent = TYPE_VIRTIO_DEVICE, + .parent = TYPE_VHOST_USER_BASE, .instance_size = sizeof(VHostUserRNG), .class_init = 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-pci.c')) softmmu_virtio_ss.add(when: 'CONFIG_VIRTIO_MMIO', if_true: files('virtio-mmio.c')) +# 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 = 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-mem.c')) specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c.c')) -specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c')) specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-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_true: files('vhost-user-vs virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-user-blk-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_INPUT', if_true: files('vhost-user-input-pci.c')) -virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_SCSI', if_true: files('vhost-user-scsi-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_SCSI', if_true: files('vhost-scsi-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_FS', if_true: files('vhost-user-fs-pci.c')) From patchwork Tue Apr 18 16:21:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 674514 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp58497wrs; Tue, 18 Apr 2023 09:22:38 -0700 (PDT) X-Google-Smtp-Source: AKy350b99U27+gslFl0TTQmNHANnx8az58T2jUR+xWH7wbXc9O9yb+nze2lvoWJGYYkClWk97bi2 X-Received: by 2002:ac8:5a0a:0:b0:3bf:d9d2:4871 with SMTP id n10-20020ac85a0a000000b003bfd9d24871mr687014qta.12.1681834957847; Tue, 18 Apr 2023 09:22:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681834957; cv=none; d=google.com; s=arc-20160816; b=AKw820cQI2yXDQKrbAlznURyOIVdaH7WOZZF4/i396vM+zC2+szzbuciACzZRmdErH r+oRXyutt915+w3Ix9W2d64e4uOvb3QpAafA3LBafIry09Azq4gSMOgLYoflMAh5cdxR 8jmvbySKy90aaQyDFxMOO7kxIzuvx+DcorD/kWWdXbUGFkcfoiQhiXWspruh6ITzDAME euj6LEDliLMawp9LZ16H6Wnrt3G494VOWsGPCkXzz2XjUmcxs39X0EuNIpuTsdVe+mfH c6fQ3y4ZZY1UBVyLAfAJpSvuamYgDcNuEv5byk+0C7IKmbe45V1WaKAy2GeV3UUZvfkK CxZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uTkEU0oqDGeWEiEFn49DE5kPkeQF20sGslhQri+i2Js=; b=gaLEaoYGlFKkgOfgUdHMPZIZ8kPWt9mLoSVFKxvy6X1PCQ9dzdcRkSb4iFAPxtgOFY KmFwuIK0NcetkjnG0RIpiljilUumVcIueXuTF12u7wX0DYzlGCJn2V83w4+vWOjtJbv9 /Bdb3tasadnGeu1Hd/yFgAQR2SAWG0seUFTtU1TyBr35ZAeut53P/FXKcstZRgMzR2fn VgD1vlQ+9lc/E9MGRQ/5wvXLHBTgMuADUULCS97g96aDgUxDt4+He8ukoQss2dKckg7T +gfxyb7j1dQcrU+JksSywmWYt7LvpMnNc43fmx7U0/oWs5Ap2u2ZLo8n5Ct3nl4yHzws SoFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qx4KdgdP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e10-20020ac8598a000000b003e3348193f9si7535402qte.635.2023.04.18.09.22.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Apr 2023 09:22:37 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qx4KdgdP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Daniel_?= =?utf-8?q?P=2E_Berrang=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-And?= =?utf-8?q?r=C3=A9_Lureau?= , 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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=41,num_vqs=2,config_size=8 is equivalent to: -device vhost-user-gpio-pci Signed-off-by: Alex Bennée --- 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/vhost-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_FEATURES); } +/* + * 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 = VHOST_USER_BASE(vdev); + Error *local_err = 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 == true); + + 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 = { + .vhost_dev_config_notifier = vub_config_notifier, +}; + static void vub_handle_output(VirtIODevice *vdev, VirtQueue *vq) { /* @@ -141,12 +177,21 @@ static int vub_connect(DeviceState *dev) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); VHostUserBase *vub = VHOST_USER_BASE(vdev); + struct vhost_dev *vhost_dev = &vub->vhost_dev; if (vub->connected) { return 0; } vub->connected = true; + /* + * 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, Error **errp) vub->num_vqs = 1; /* reasonable default? */ } + /* + * 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 = true; + } + if (!vhost_user_init(&vub->vhost_user, &vub->chardev, errp)) { return; } - virtio_init(vdev, vub->virtio_id, 0); + virtio_init(vdev, vub->virtio_id, vub->config_size); /* * Disable guest notifiers, by default all notifications will be via the @@ -268,6 +322,7 @@ static void vub_class_init(ObjectClass *klass, void *data) vdc->realize = vub_device_realize; vdc->unrealize = vub_device_unrealize; vdc->get_features = vub_get_features; + vdc->get_config = vub_get_config; vdc->set_status = vub_set_status; } @@ -295,6 +350,7 @@ static Property vud_properties[] = { 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(), }; From patchwork Tue Apr 18 16:21:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 674524 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp59271wrs; Tue, 18 Apr 2023 09:24:15 -0700 (PDT) X-Google-Smtp-Source: AKy350acdZUXR5QAVj/JOUpAwf7td5Lu7UPSPpldag02Vro1lExwy3PEa1VbWfLno9ZEFYfU74G7 X-Received: by 2002:a05:622a:130c:b0:3e8:e986:b20a with SMTP id v12-20020a05622a130c00b003e8e986b20amr767926qtk.16.1681835055666; Tue, 18 Apr 2023 09:24:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681835055; cv=none; d=google.com; s=arc-20160816; b=RaTh3WHU0psxfW941GajWDBLxL43bufyvyowvilLIOgpdgMO+MQQ0hU+36RbeMs012 p2ciw3dmWZhbcpB0lJrvPy88iaj9ok3bGbe50SzMIirbUCzQlOVdQSyLyRJXb7TmRYck 6pEODmYxD7IWauWDb/sS2O2eIDNM9bpPD7acARE75VQS++GtP03ojOzz+10KeLt7uUo6 20Jp0eEZosEDR/SuXL2w8SDiJK8cM41E8csRCsuOr/S8psCQC1ff+q4M3B3pZ5PYzQOS nx+tEr5E16FQ6TjpidzVMR78oPbXUIigmlakwCJRTgRX5K4KS8bKH7FL4P0MA/5Jji8h k9nQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Y6Sf2OjNrNXUb0GYO7bZcBDDP3EdkmkeAoJBhG/jVsc=; b=lqg1yhiWNLAkOFVBYcNNIm5DlmiCtyorxyPmFYP1t2bUSI391VCDYrIZsC8/MmVhtS db0X8QUgiWoJCHZO2h97bHaBgHGlehBFY7enwoEqNVfQnv8wf7MlJbdzj0TCZogRcxNg NGh7HDCKHM41oLOKlCHqLLvc/hl6gN+jBkZnpLLXmeOY1ZcwhQl89ClhOMO/Q6mK5JaA gKIV/tsxAT75eKTVvz7MIXPNo+HFaGo6Q3kFj9yqhY86gKYLT+Yj7bal+Di7e64rgznL pQXPFKvGxHdt6C1DWsfA6ZZ5ibI/X21bC0FQKx3gZbTNFKT0HhINpTN3RTLe4PMonmpy z1pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GJoh6vae; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q195-20020a3743cc000000b007426e52504dsi7395229qka.601.2023.04.18.09.24.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Apr 2023 09:24:15 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GJoh6vae; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Daniel_?= =?utf-8?q?P=2E_Berrang=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-And?= =?utf-8?q?r=C3=A9_Lureau?= , 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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ée 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" #define TYPE_VHOST_USER_GPIO "vhost-user-gpio-device" OBJECT_DECLARE_SIMPLE_TYPE(VHostUserGPIO, VHOST_USER_GPIO); struct VHostUserGPIO { /*< private >*/ - VirtIODevice parent_obj; - CharBackend chardev; - struct virtio_gpio_config config; - struct vhost_virtqueue *vhost_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 >*/ }; 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" -#define REALIZE_CONNECTION_RETRIES 3 -#define VHOST_NVQS 2 - -/* Features required from VirtIO */ -static const int feature_bits[] = { - VIRTIO_F_VERSION_1, - VIRTIO_F_NOTIFY_ON_EMPTY, - VIRTIO_RING_F_INDIRECT_DESC, - VIRTIO_RING_F_EVENT_IDX, - VIRTIO_GPIO_F_IRQ, - VIRTIO_F_RING_RESET, - VHOST_INVALID_FEATURE_BIT -}; - -static void vu_gpio_get_config(VirtIODevice *vdev, uint8_t *config) -{ - VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); - - memcpy(config, &gpio->config, sizeof(gpio->config)); -} - -static int vu_gpio_config_notifier(struct vhost_dev *dev) -{ - VHostUserGPIO *gpio = VHOST_USER_GPIO(dev->vdev); - - memcpy(dev->vdev->config, &gpio->config, sizeof(gpio->config)); - virtio_notify_config(dev->vdev); - - return 0; -} - -const VhostDevConfigOps gpio_ops = { - .vhost_dev_config_notifier = vu_gpio_config_notifier, +static Property vgpio_properties[] = { + DEFINE_PROP_CHR("chardev", VHostUserBase, chardev), + DEFINE_PROP_END_OF_LIST(), }; -static int vu_gpio_start(VirtIODevice *vdev) +static void vgpio_realize(DeviceState *dev, Error **errp) { - BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); - VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); - VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); - struct vhost_dev *vhost_dev = &gpio->vhost_dev; - int ret, i; + VHostUserBase *vub = VHOST_USER_BASE(dev); + VHostUserBaseClass *vubc = VHOST_USER_BASE_GET_CLASS(dev); - if (!k->set_guest_notifiers) { - error_report("binding does not support guest notifiers"); - return -ENOSYS; - } + /* Fixed for GPIO */ + vub->virtio_id = VIRTIO_ID_GPIO; + vub->num_vqs = 2; + vub->config_size = sizeof(struct virtio_gpio_config); - ret = vhost_dev_enable_notifiers(vhost_dev, vdev); - if (ret < 0) { - error_report("Error enabling host notifiers: %d", ret); - return ret; - } - - ret = k->set_guest_notifiers(qbus->parent, vhost_dev->nvqs, true); - if (ret < 0) { - error_report("Error binding guest notifier: %d", ret); - goto err_host_notifiers; - } - - /* - * Before we start up we need to ensure we have the final feature - * set needed for the vhost configuration. The backend may also - * apply backend_features when the feature set is sent. - */ - vhost_ack_features(&gpio->vhost_dev, feature_bits, vdev->guest_features); - - ret = vhost_dev_start(&gpio->vhost_dev, vdev, false); - if (ret < 0) { - error_report("Error starting vhost-user-gpio: %d", ret); - goto err_guest_notifiers; - } - gpio->started_vu = 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 = 0; i < gpio->vhost_dev.nvqs; i++) { - vhost_virtqueue_mask(&gpio->vhost_dev, vdev, i, false); - } - - /* - * As we must have VHOST_USER_F_PROTOCOL_FEATURES (because - * VHOST_USER_GET_CONFIG requires it) we need to explicitly enable - * the vrings. - */ - g_assert(vhost_dev->vhost_ops && - vhost_dev->vhost_ops->vhost_set_vring_enable); - ret = vhost_dev->vhost_ops->vhost_set_vring_enable(vhost_dev, true); - if (ret == 0) { - return 0; - } - - error_report("Failed to start vrings for vhost-user-gpio: %d", ret); - -err_guest_notifiers: - k->set_guest_notifiers(qbus->parent, gpio->vhost_dev.nvqs, false); -err_host_notifiers: - vhost_dev_disable_notifiers(&gpio->vhost_dev, vdev); - - return ret; -} - -static void vu_gpio_stop(VirtIODevice *vdev) -{ - VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); - BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); - VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); - struct vhost_dev *vhost_dev = &gpio->vhost_dev; - int ret; - - if (!gpio->started_vu) { - return; - } - gpio->started_vu = false; - - if (!k->set_guest_notifiers) { - return; - } - - vhost_dev_stop(vhost_dev, vdev, false); - - ret = k->set_guest_notifiers(qbus->parent, vhost_dev->nvqs, false); - if (ret < 0) { - error_report("vhost guest notifier cleanup failed: %d", ret); - return; - } - - vhost_dev_disable_notifiers(vhost_dev, vdev); -} - -static void vu_gpio_set_status(VirtIODevice *vdev, uint8_t status) -{ - VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); - bool should_start = virtio_device_should_start(vdev, status); - - trace_virtio_gpio_set_status(status); - - if (!gpio->connected) { - return; - } - - if (vhost_dev_is_started(&gpio->vhost_dev) == should_start) { - return; - } - - if (should_start) { - if (vu_gpio_start(vdev)) { - qemu_chr_fe_disconnect(&gpio->chardev); - } - } else { - vu_gpio_stop(vdev); - } -} - -static uint64_t vu_gpio_get_features(VirtIODevice *vdev, uint64_t features, - Error **errp) -{ - VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); - - return vhost_get_features(&gpio->vhost_dev, feature_bits, features); -} - -static void vu_gpio_handle_output(VirtIODevice *vdev, VirtQueue *vq) -{ - /* - * Not normally called; it's the daemon that handles the queue; - * however virtio's cleanup path can call this. - */ -} - -static void vu_gpio_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask) -{ - VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); - - /* - * 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 == 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 = VIRTIO_DEVICE(dev); - VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); - struct vhost_dev *vhost_dev = &gpio->vhost_dev; - int ret; - - if (gpio->connected) { - return 0; - } - gpio->connected = true; - - vhost_dev_set_config_notifier(vhost_dev, &gpio_ops); - gpio->vhost_user.supports_config = true; - - gpio->vhost_dev.nvqs = VHOST_NVQS; - gpio->vhost_dev.vqs = gpio->vhost_vqs; - - ret = vhost_dev_init(vhost_dev, &gpio->vhost_user, - VHOST_BACKEND_TYPE_USER, 0, errp); - if (ret < 0) { - return ret; - } - - /* restore vhost state */ - if (virtio_device_started(vdev, vdev->status)) { - vu_gpio_start(vdev); - } - - return 0; -} - -static void vu_gpio_event(void *opaque, QEMUChrEvent event); - -static void vu_gpio_disconnect(DeviceState *dev) -{ - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); - - if (!gpio->connected) { - return; - } - gpio->connected = false; - - vu_gpio_stop(vdev); - vhost_dev_cleanup(&gpio->vhost_dev); - - /* 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 = opaque; - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); - Error *local_err = NULL; - - switch (event) { - case CHR_EVENT_OPENED: - if (vu_gpio_connect(dev, &local_err) < 0) { - qemu_chr_fe_disconnect(&gpio->chardev); - return; - } - break; - case CHR_EVENT_CLOSED: - /* 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 = &gpio->parent_obj; - DeviceState *dev = &vdev->parent_obj; - struct vhost_dev *vhost_dev = &gpio->vhost_dev; - int ret; - - ret = qemu_chr_fe_wait_connected(&gpio->chardev, errp); - if (ret < 0) { - return ret; - } - - /* - * vu_gpio_connect() may have already connected (via the event - * callback) in which case it will just report success. - */ - ret = vu_gpio_connect(dev, errp); - if (ret < 0) { - qemu_chr_fe_disconnect(&gpio->chardev); - return ret; - } - g_assert(gpio->connected); - - ret = vhost_dev_get_config(vhost_dev, (uint8_t *)&gpio->config, - sizeof(gpio->config), errp); - - if (ret < 0) { - error_report("vhost-user-gpio: get config failed"); - - qemu_chr_fe_disconnect(&gpio->chardev); - vhost_dev_cleanup(vhost_dev); - return ret; - } - - return 0; -} - -static void vu_gpio_device_realize(DeviceState *dev, Error **errp) -{ - ERRP_GUARD(); - - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserGPIO *gpio = VHOST_USER_GPIO(dev); - int retries, ret; - - if (!gpio->chardev.chr) { - error_setg(errp, "vhost-user-gpio: chardev is mandatory"); - return; - } - - if (!vhost_user_init(&gpio->vhost_user, &gpio->chardev, errp)) { - return; - } - - virtio_init(vdev, VIRTIO_ID_GPIO, sizeof(gpio->config)); - - gpio->command_vq = virtio_add_queue(vdev, 256, vu_gpio_handle_output); - gpio->interrupt_vq = virtio_add_queue(vdev, 256, vu_gpio_handle_output); - gpio->vhost_vqs = g_new0(struct vhost_virtqueue, VHOST_NVQS); - - gpio->connected = false; - - qemu_chr_fe_set_handlers(&gpio->chardev, NULL, NULL, vu_gpio_event, NULL, - dev, NULL, true); - - retries = REALIZE_CONNECTION_RETRIES; - g_assert(!*errp); - do { - if (*errp) { - error_prepend(errp, "Reconnecting after error: "); - error_report_err(*errp); - *errp = NULL; - } - ret = vu_gpio_realize_connect(gpio, errp); - } while (ret < 0 && retries--); - - if (ret < 0) { - do_vhost_user_cleanup(vdev, gpio); - } - - return; -} - -static void vu_gpio_device_unrealize(DeviceState *dev) -{ - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserGPIO *gpio = VHOST_USER_GPIO(dev); - - vu_gpio_set_status(vdev, 0); - qemu_chr_fe_set_handlers(&gpio->chardev, NULL, NULL, NULL, NULL, NULL, NULL, - false); - vhost_dev_cleanup(&gpio->vhost_dev); - do_vhost_user_cleanup(vdev, gpio); + vubc->parent_realize(dev, errp); } static const VMStateDescription vu_gpio_vmstate = { @@ -394,30 +37,21 @@ static const VMStateDescription vu_gpio_vmstate = { .unmigratable = 1, }; -static Property vu_gpio_properties[] = { - DEFINE_PROP_CHR("chardev", VHostUserGPIO, chardev), - DEFINE_PROP_END_OF_LIST(), -}; - static void vu_gpio_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); + VHostUserBaseClass *vubc = VHOST_USER_BASE_CLASS(klass); - device_class_set_props(dc, vu_gpio_properties); dc->vmsd = &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 = vu_gpio_device_realize; - vdc->unrealize = vu_gpio_device_unrealize; - vdc->get_features = vu_gpio_get_features; - vdc->get_config = vu_gpio_get_config; - vdc->set_status = vu_gpio_set_status; - vdc->guest_notifier_mask = vu_gpio_guest_notifier_mask; } static const TypeInfo vu_gpio_info = { .name = TYPE_VHOST_USER_GPIO, - .parent = TYPE_VIRTIO_DEVICE, + .parent = TYPE_VHOST_USER_BASE, .instance_size = sizeof(VHostUserGPIO), .class_init = 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('vhost-user-gpio.c')) +softmmu_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_GPIO'], + if_true: files('vhost-user-gpio-pci.c')) specific_virtio_ss = 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-mem.c')) specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c.c')) -specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-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')) virtio_pci_ss = ss.source_set() From patchwork Tue Apr 18 16:21:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 674522 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp59011wrs; Tue, 18 Apr 2023 09:23:44 -0700 (PDT) X-Google-Smtp-Source: AKy350bJyWietSM6E6gDZpRyXKl6+UcdkgaVlrPzvQ/lgXwQsQc/PVYKGZkEjeCEePZ0b0UQ650n X-Received: by 2002:a05:6214:c8a:b0:5ef:519:b21 with SMTP id r10-20020a0562140c8a00b005ef05190b21mr16927384qvr.26.1681835024154; Tue, 18 Apr 2023 09:23:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681835024; cv=none; d=google.com; s=arc-20160816; b=vYLW2PLeh0ezcHeG1JZxDgWtNIfe0rrRE8fha83/boLo9nB9/wYGF+rlAp9Jon73fs 8Nt32E0sLOwX9qOq89cxjRCIDg8tr8JeWEWH09tv+meFHXsSPn0qYw5gk9kJffqp+vLl ROUshFVq+os2zoN4klgBqqssTu7rYTPzDDzDDvmYTupymsNGWCqQ3S+7Ze/t4QUTXGet 5qZ4WSyp2QC1OYN+mUWVvSyQSs42YhxvBPSJIJXgPR8Yd5yz+kktMTQQc+wpmetlodrl Q3rEgz3tC+ChD4pyXdLVsHJMCfI+ocp4yQPbAhqUuZhPkZzNP3gWzJWFxXnHc+t3xw86 8TaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=x87bue2xLVWQrfVBSyRRYhA/dy43njxINkH3kP9vb3k=; b=nK+fjJ3k2c4cqGDphndw3AbRbwLfs1GPuYvDIxEnTIAMDJz5FXRBueFEv0vOhnJY42 evOSXgwj4UW8aqBn1uYogw8kTD0UC++vAb1zdojjKRMOK6J3BwKHC28dCRpBzbKCG3Rs xLTK0b1Ue/dDL9oCfb4xxSQh0zEfn+x52MjEm0BS+8cy69EJyMz465eNdQQpV8ffSkdI sihnGOnPDc2xzt/R2KHKjqYsfYIOJb+JbaxpSRUGgeGv58wdLUIdoEOlnDAKUOORj47v nl51Dv120BACkRqNvQ4LVDwYvoANzsccuOPfhI8unZK68iyGDXHkSSTY4M9FijBgMJ+g uDRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EHRQv7Ju; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 69-20020a370848000000b0074abf2e72edsi3645520qki.189.2023.04.18.09.23.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Apr 2023 09:23:44 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EHRQv7Ju; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Daniel_?= =?utf-8?q?P=2E_Berrang=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-And?= =?utf-8?q?r=C3=A9_Lureau?= , 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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ée 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-user-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" +#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) 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 >*/ }; -/* 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" -static const int feature_bits[] = { - VIRTIO_I2C_F_ZERO_LENGTH_REQUEST, - VIRTIO_F_RING_RESET, - VHOST_INVALID_FEATURE_BIT +static Property vi2c_properties[] = { + DEFINE_PROP_CHR("chardev", VHostUserBase, chardev), + DEFINE_PROP_END_OF_LIST(), }; -static void vu_i2c_start(VirtIODevice *vdev) -{ - BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); - VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); - VHostUserI2C *i2c = VHOST_USER_I2C(vdev); - int ret, i; - - if (!k->set_guest_notifiers) { - error_report("binding does not support guest notifiers"); - return; - } - - ret = vhost_dev_enable_notifiers(&i2c->vhost_dev, vdev); - if (ret < 0) { - error_report("Error enabling host notifiers: %d", -ret); - return; - } - - ret = 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 = vdev->guest_features; - - ret = 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 = 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 = VHOST_USER_I2C(vdev); - BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); - VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); - int ret; - - if (!k->set_guest_notifiers) { - return; - } - - vhost_dev_stop(&i2c->vhost_dev, vdev, true); - - ret = k->set_guest_notifiers(qbus->parent, i2c->vhost_dev.nvqs, false); - 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 = VHOST_USER_I2C(vdev); - bool should_start = virtio_device_should_start(vdev, status); - - if (vhost_dev_is_started(&i2c->vhost_dev) == 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 **errp) -{ - VHostUserI2C *i2c = VHOST_USER_I2C(vdev); - - virtio_add_feature(&requested_features, VIRTIO_I2C_F_ZERO_LENGTH_REQUEST); - return vhost_get_features(&i2c->vhost_dev, feature_bits, requested_features); -} - -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 mask) -{ - VHostUserI2C *i2c = 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 = 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 = VIRTIO_DEVICE(dev); - VHostUserI2C *i2c = VHOST_USER_I2C(vdev); - - if (i2c->connected) { - return 0; - } - i2c->connected = 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 = VIRTIO_DEVICE(dev); - VHostUserI2C *i2c = VHOST_USER_I2C(vdev); - - if (!i2c->connected) { - return; - } - i2c->connected = 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 = opaque; - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserI2C *i2c = 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 = VIRTIO_DEVICE(dev); - VHostUserI2C *i2c = 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 = VHOST_USER_BASE(dev); + VHostUserBaseClass *vubc = VHOST_USER_BASE_GET_CLASS(dev); - i2c->vhost_dev.nvqs = 1; - i2c->vq = virtio_add_queue(vdev, 4, vu_i2c_handle_output); - i2c->vhost_dev.vqs = g_new0(struct vhost_virtqueue, i2c->vhost_dev.nvqs); + /* Fixed for I2C */ + vub->virtio_id = VIRTIO_ID_I2C_ADAPTER; + vub->num_vqs = 1; - ret = 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 = VIRTIO_DEVICE(dev); - VHostUserI2C *i2c = VHOST_USER_I2C(dev); - struct vhost_virtqueue *vhost_vqs = 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); } static const VMStateDescription vu_i2c_vmstate = { @@ -252,30 +36,21 @@ static const VMStateDescription vu_i2c_vmstate = { .unmigratable = 1, }; -static Property vu_i2c_properties[] = { - DEFINE_PROP_CHR("chardev", VHostUserI2C, chardev), - DEFINE_PROP_END_OF_LIST(), -}; - static void vu_i2c_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); + VHostUserBaseClass *vubc = VHOST_USER_BASE_CLASS(klass); - device_class_set_props(dc, vu_i2c_properties); dc->vmsd = &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 = vu_i2c_device_realize; - vdc->unrealize = vu_i2c_device_unrealize; - vdc->get_features = vu_i2c_get_features; - vdc->set_status = vu_i2c_set_status; - vdc->guest_notifier_mask = vu_i2c_guest_notifier_mask; - vdc->guest_notifier_pending = vu_i2c_guest_notifier_pending; } static const TypeInfo vu_i2c_info = { .name = TYPE_VHOST_USER_I2C, - .parent = TYPE_VIRTIO_DEVICE, + .parent = TYPE_VHOST_USER_BASE, .instance_size = sizeof(VHostUserI2C), .class_init = 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('vhost-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')) specific_virtio_ss = 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-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-mem.c')) -specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c.c')) specific_virtio_ss.add(when: 'CONFIG_VHOST_VDPA_DEV', if_true: files('vdpa-dev.c')) virtio_pci_ss = 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-user-vsock-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-user-blk-pci.c')) -virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_INPUT', if_true: files('vhost-user-input-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_SCSI', if_true: files('vhost-user-scsi-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_SCSI', if_true: files('vhost-scsi-pci.c')) From patchwork Tue Apr 18 16:21:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 674527 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp61883wrs; Tue, 18 Apr 2023 09:29:37 -0700 (PDT) X-Google-Smtp-Source: AKy350ZMDvBeYRi+JtL+/YW7BytX+hnFpMstMO6Tn4arVSnyFjY9t4dCEWjJpX+kQ6+r2AKdueNj X-Received: by 2002:a05:622a:50:b0:3e6:499c:6849 with SMTP id y16-20020a05622a005000b003e6499c6849mr646479qtw.10.1681835377087; Tue, 18 Apr 2023 09:29:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681835377; cv=none; d=google.com; s=arc-20160816; b=0GwG8xYJCtBxSphDSZzHBy7tK3j/Zc0MxpyUBEHc+6TsVAckY96bM5ciyr4HnH50Qu TmksnCRw5jMz/cf1YqHtuRbUUxSSNsCbrQUqFm5DIYvuRSsIzOuSMmu2DW9hDSb47zrN CPOMcGPoekE2Xc2UBGheAvXOZx4EjAf5+7uhfuAPUQR874tDb3q8u1cnFsx8DVany0AE HaqxIpGdol0cDtPR5C7BrdEYMuT6ZCSb5K72pjBNSR9Fv38hOA70as+YYRwDa59t8Sli WRu280MLXfQFBEiho9+NQJ8VRb4alNn58tk3WTGoRbHP5LL9Miu3aaN/BkbqbyXJpAet b/Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=QuJZaLubT8BhFuE9ylcD4Gy9hPKTq8TPugnpWu/KBiw=; b=XrAJccStYVnrC5Q6NDrmrBICBmdIFcHdKxYBj55nFoaJzviH72OKciRrJOWBZSyuo3 SFPWI21YKT5TQg5EdBojTcOtyzR5LA2vflijDz8JWxZ/xgyoSP1H5HtlSr5/s+Gmx3W0 Ef9Z8u6wDPVkLxtZBcaz7quvF7p6XmU2qLB0NifNBA6BjfA81gwySxrnc13v31GpZwZh D2rP5MAKY9uD8n+MVI80BIA6y7Qg5kwFY/jEC4WN4dW1m+afEklBSx+n91puW/8llMJ5 EadSephwukU2epL6TeXz1eMUcSmptSU9cziAx1y0tDUtnHwrXI1O78txS5RS83NqtDly M8TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t3HCEI06; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z5-20020a05622a028500b003e631a7a89bsi7385326qtw.718.2023.04.18.09.29.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Apr 2023 09:29:37 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t3HCEI06; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Daniel_?= =?utf-8?q?P=2E_Berrang=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-And?= =?utf-8?q?r=C3=A9_Lureau?= , 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Make it clear the vhost-user-device is intended for expert use only. Signed-off-by: Alex Bennée --- 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/vhost-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 =================================== 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 each device has a ``chardev`` option which specifies the ID of the ``--chardev`` device that connects via a socket to the vhost-user *daemon*. +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 =================