From patchwork Fri Apr 14 16:04:21 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: 673130 Delivered-To: patch@linaro.org Received: by 2002:adf:fcce:0:0:0:0:0 with SMTP id f14csp262045wrs; Fri, 14 Apr 2023 09:05:14 -0700 (PDT) X-Google-Smtp-Source: AKy350ayeMr07W6yXvw1mpep5JLQTXv2QdOjfjzLFshmvshFT+aDIaQTRS+syj2CFlp39T8AN4Ji X-Received: by 2002:a05:6214:246f:b0:5ef:56f6:64ad with SMTP id im15-20020a056214246f00b005ef56f664admr4155067qvb.3.1681488313964; Fri, 14 Apr 2023 09:05:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681488313; cv=none; d=google.com; s=arc-20160816; b=QmMw4lk6uD7Mux9HEqQCB6UDzuJIHISKorHoCFkzCMLB2+Qgl7zWkjqWmeKJeOMsKX vtoFbNdqQkH/b8kdkUuEaPZ7TR52fmofMfIfH3gUU6BTb9fUSLURNc8MbCbn/AEhOP4S 7+e09A6Vg1j9FaMXQCyqY8pRoc5E1dyNSF3LfyeT/1nWpZGY9L5hD3ZIOkXjDs4N0Ic5 m2/n8Rwk4LC0L7FWDsXyh/LYd/arvcfKHPQ7QiM6YLKb8mwQy5yB7fGUd5zJkfg8/SPU xjcwSHXxBDvXJRjzhP7gbkEw+yZ4Q3/zqlpoLQPYyo4YNc6Ss8v0ul20L2qdpwUCWRT/ 5t7g== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=upwamrFOWbXpB0LRg3OycRh6xKp0neSg/Tq8ON+G04o=; b=Hz+zaVP/qM2Go+tKplN6GcLWbRAGpCyaCoP67UAl1C38LeU9jOpRU26/Uq2mHeI0s7 hl/T00vsCiw5psAunEa089okujGJCC6sEKB9NQzJCMVkDBXbKyDN7WcD4Ulsvcw2hS/3 NsZhh1R42qDw8IADROpm/tMOJ1O3bWtqZ2obJhn4Gb4MhkkKStGqO5YKTpZ6L1S74w/A 8nOPY+gDsAMLDGUyLpSGBmGGghUTtMTKq0nmTyXibIVOfYReVjTEAGi9M/sgnGLhrdo9 rJvuGBc29iIYmVbjmqQrDaZYC7J3wnmHqa12oTGT1oYGTjkeaOCU+MfdkwPe2fo1diRb fk/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HnHCUASr; 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 pt13-20020a056214048d00b0056ea051a8f2si2825165qvb.330.2023.04.14.09.05.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Apr 2023 09:05:13 -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=HnHCUASr; 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 1pnLvA-0006p5-Ib; Fri, 14 Apr 2023 12:05:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnLuh-0006Rh-Ue for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:45 -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 1pnLue-0007yM-7d for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:38 -0400 Received: by mail-wm1-x330.google.com with SMTP id d8-20020a05600c3ac800b003ee6e324b19so10052941wms.1 for ; Fri, 14 Apr 2023 09:04:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681488274; x=1684080274; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=upwamrFOWbXpB0LRg3OycRh6xKp0neSg/Tq8ON+G04o=; b=HnHCUASrDHmRpFdQnH/kC4fg1J2tS2b3xMJEHXFblVbTy9J5pJ55BSNL882fCPJ8gY e/CTewZXgr7dzO7+Rsr9zF+wnuI1yzLrflv6zkz/2owUK+69L8FH/mJKXQFCALXVsSgS XnA4FGy8ciRF5Kdy6gdtpkukRGhhdhKJCKZgdMY2zgMlcSPrYf0JhKukHSFKd2UTmn+o vNBaykoigtEb1bCLlIn6Jdg1rG2qV1WxfgUxtZaNkwqEvYvTDy3vzyF0vwJWbUfj88D6 ixTlxutXKhEb44W4Oo30xKEegTtiLJ+eEX09AvfeLJeTs9zCqvYNVOej8ufg61m6miOn Mm1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681488274; x=1684080274; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=upwamrFOWbXpB0LRg3OycRh6xKp0neSg/Tq8ON+G04o=; b=Kfh/05/DDHFNEeWrf5+dy6QHg71yl5jeViwXy0bLAI1C76zyWeNIcZlzBYTO6RRdn1 lfR/h9zowazy0il3+ebiOVCb9Wa9Yn9pe9T1YNmilT4STc4IDhJ+MspZgBzi6jYxQKaW t7XA0+6TeMLM+rBfjvyAw7xDhWOzkC6V21+j8pdAxY10LwOSKfLtv8B/BTphjXHQPOAN q6KsZ8v7adIgOFczNYJSQGhzRBaInwkXEY2ixxDUbrm6j4tt/kqzAPor1RfPxILCGQ96 PefLC3o73353rEGzkiJwrOPysQy2BAMMr5s6x4koGmoSE7QLL3tiO4B9tOBKDOS+d8bf QouA== X-Gm-Message-State: AAQBX9e1ykDkb/4rdEY9xwu57XJbqEqM79AM62nrez428LwBiacTvn/h Un/pGBEcCbosfrUTRB68mr6Bgg== X-Received: by 2002:a7b:c7d6:0:b0:3f0:a9dc:a369 with SMTP id z22-20020a7bc7d6000000b003f0a9dca369mr4481439wmk.19.1681488274531; Fri, 14 Apr 2023 09:04:34 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id l2-20020a1c7902000000b003edd1c44b57sm4639009wme.27.2023.04.14.09.04.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 09:04:34 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id CB7691FFB7; Fri, 14 Apr 2023 17:04:33 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Paolo Bonzini , "Michael S. Tsirkin" , virtio-fs@redhat.com, Erik Schilling , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Eduardo Habkost , Stefan Hajnoczi , Eric Blake , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Jason Wang , Viresh Kumar , Mathieu Poirier , Gerd Hoffmann , Markus Armbruster Subject: [PATCH 00/12] virtio: add vhost-user-generic and reduce copy and paste Date: Fri, 14 Apr 2023 17:04:21 +0100 Message-Id: <20230414160433.2096866-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 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 A lot of our vhost-user stubs are large chunks of boilerplate that do (mostly) the same thing. This series attempts to fix that by defining a new base class for vhost-user devices and then converting the rng and gpio devices to be based off them. You can even use vhost-user-device directly if you supply it with the right magic numbers (which is helpful for development). However the final patch runs into the weeds because I don't yet have a clean way to represent in QOM the fixing of certain properties for the specialised classes. The series is a net reduction in code and an increase in documentation but obviously needs to iron out a few more warts. I'm open to suggestions on the best way to tweak the QOM stuff. Alex. Alex Bennée (12): hw/virtio: fix typo in VIRTIO_CONFIG_IRQ_IDX comments include/hw/virtio: document virtio_notify_config include/hw/virtio: add kerneldoc for virtio_init include/hw/virtio: document some more usage of notifiers virtio: add generic vhost-user-device virtio: add PCI stub for vhost-user-device include: attempt to document device_class_set_props qom: allow for properties to become "fixed" hw/virtio: derive vhost-user-rng from vhost-user-device hw/virtio: add config support to vhost-user-device hw/virtio: derive vhost-user-gpio from vhost-user-device (!BROKEN) docs/system: add a basic enumeration of vhost-user devices docs/system/devices/vhost-user-rng.rst | 2 + docs/system/devices/vhost-user.rst | 41 +++ qapi/qom.json | 2 + include/hw/qdev-core.h | 9 + include/hw/virtio/vhost-user-device.h | 33 ++ include/hw/virtio/vhost-user-gpio.h | 23 +- include/hw/virtio/vhost-user-rng.h | 11 +- include/hw/virtio/virtio.h | 21 ++ include/qom/object.h | 16 +- hw/display/vhost-user-gpu.c | 4 +- hw/net/virtio-net.c | 4 +- hw/virtio/vhost-user-device-pci.c | 71 +++++ hw/virtio/vhost-user-device.c | 359 ++++++++++++++++++++++ hw/virtio/vhost-user-fs.c | 4 +- hw/virtio/vhost-user-gpio.c | 405 +------------------------ hw/virtio/vhost-user-rng.c | 264 +--------------- hw/virtio/vhost-vsock-common.c | 4 +- hw/virtio/virtio-crypto.c | 4 +- qom/object.c | 14 + qom/object_interfaces.c | 9 +- qom/qom-qmp-cmds.c | 1 + softmmu/qdev-monitor.c | 1 + hw/virtio/meson.build | 3 + 23 files changed, 613 insertions(+), 692 deletions(-) create mode 100644 include/hw/virtio/vhost-user-device.h create mode 100644 hw/virtio/vhost-user-device-pci.c create mode 100644 hw/virtio/vhost-user-device.c