From patchwork Mon Nov 13 01:16:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 743443 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp1403879wrw; Sun, 12 Nov 2023 17:18:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IE5EdUyWM9IAhUXqm2fREjVDVZHkq6tSnyxSxzoIuTiwgV2HoJSob7PvjkTvkw9gXVvRVAZ X-Received: by 2002:a05:6102:1481:b0:45d:9cb0:28fc with SMTP id d1-20020a056102148100b0045d9cb028fcmr6662890vsv.9.1699838291224; Sun, 12 Nov 2023 17:18:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699838291; cv=none; d=google.com; s=arc-20160816; b=vWXNR1LPjgnMZstvoaA03CbIAzPz4tOw/QgEu5nXfykkmzR/N0ex4fByM30jUdjW9/ C3UbeeNJOeHl8Mc1YmDpeF2IEz+txU6fmbkIjT0xFJ/yOvagzpMJhsnLfMRLW3T97TtY 8NOgXTXUmPIXzC1lW1R8L4rQIUkA9pNLuOC1g8oCYyGDgMMqmLqdlRpPIaf6jGSif6oG fFBVARWabKFZMTC5jxmhkSkeZ+xpfqtJMf8oB9UUjJtlQSxRTVONYBVkv1GOdcnAYzWT dTn3nCLE2xgDGVGsgEM2LLXEW+F1qLioCYrcjwI+K5g2Fnm3grGzwZ+iPkXqlc4cmXUk 2AtQ== 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=T9oQMwnfds7gwheh540NHUto9x6gbHU1X9JBynkAdpY=; fh=wuGuGNzRUBT5nBQhy+zJrmr0MipRLMv40xtKcfwYGIM=; b=dlHy+DhGjJ22iqGMOidm0030VhxtfJDGtypMm6lggEeBYLi8X7Zo1zmnGTcU3DSXQr fHIdh2PfmpqKNnrQiJwv351mnXKEwb08VYCSw9O+I6bV7sLPuwQk7BJAIH2xve14FHWY 2tY64nN4tpbpKkX74UyL17iFndnoNURlgQEcLF2Tf3M85rA/Ox9SYeXHlOKWiYFsmR3G Vol4UJdeocZUZLQo2OjccvEg+Qk1F2atz+bLqrqMQ0f5g0Z8gRRGv0gGUFVsxkQwkT3r o8ZlberczMOYHseuXrFmXVvHgY25Xgra1olnBLlJjsBn2/y4YYGVoyCwmhYO2OZwG67Y BOVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ev7Aoz0R; 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 de37-20020a05620a372500b0077583599c4esi3647395qkb.239.2023.11.12.17.18.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 12 Nov 2023 17:18:11 -0800 (PST) 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=ev7Aoz0R; 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 1r2LZt-0000Wh-7X; Sun, 12 Nov 2023 20:17:25 -0500 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 1r2LZs-0000WY-35 for qemu-devel@nongnu.org; Sun, 12 Nov 2023 20:17:24 -0500 Received: from mail-il1-x12a.google.com ([2607:f8b0:4864:20::12a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r2LZq-0003oA-Gk for qemu-devel@nongnu.org; Sun, 12 Nov 2023 20:17:23 -0500 Received: by mail-il1-x12a.google.com with SMTP id e9e14a558f8ab-35961c61ffaso14541415ab.3 for ; Sun, 12 Nov 2023 17:17:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699838241; x=1700443041; darn=nongnu.org; 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=T9oQMwnfds7gwheh540NHUto9x6gbHU1X9JBynkAdpY=; b=ev7Aoz0RQQXg4pPjoOFp2SwBvsQxtqYpYRSnGfXD+GiusY4A41crdiqodOZCI/biCh 4ya+743tVbSlPZYRz3oShYY3odmWeOaenhWJyrjfq0SfiQh/A4UAyvtvvKsw8csb79in +a4agFyPaRmAT3Ss34kclFTPwK6HzV9cD3grjKoDRc03ZF2oIC1AEWZWJnAaBFa7eT1J KQlXJYYnZmwXHj9eYbkkYBYB2rVfIFOTKoLu/jHe1SsAQIBaqNUHeVEqc/yJ2jRRWYCT +JblokgVih09wfKy1KvU/ZyR1dlr6AJ2cw9d/O6a7uvJEShs0joYVfX751+fszSKyfDi V2UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699838241; x=1700443041; 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=T9oQMwnfds7gwheh540NHUto9x6gbHU1X9JBynkAdpY=; b=JZARux/8IIh0UPer9tiLR0pTjve6pWlwK3E3gi1WbJE6U9EsU3nrUWBLev6H9Nuw1W 7KkBK4vA8dhmIcMTSvOMfi7FcuK/95t0WcOE3/Zh+uk+X696KL3FNI1koN0p0c8T0p2J OjWUkDi9UVhRDAMSnLehD6+/MEqqRQLpUFluZ0e/CAuL6KPGXKFqqYUjhmvAQ4c1cNYT Y8MZkfDEKEgHZ0Cvl5nE1glAJfpOmdFn6gV7MFZEoRIu9hYZgelnSGL5UPbEEcbwJtaq 5hmiQM9HFVlqfpzmbDTn43lIWDSeZLgbIBnoOINgS7iCUszwBBd/hplVq9CHcqyUz3yA 1Jcw== X-Gm-Message-State: AOJu0Ywclfs3jrW9cvK+RiBDEfccK6kwEGn/hsyaXRzhfyauqsDgecNg 49N+LhRFXdQVLsfqNOJgNzaq+8OJIXX85tPOy2qFQBS33iw= X-Received: by 2002:a05:6e02:1a65:b0:359:d425:618c with SMTP id w5-20020a056e021a6500b00359d425618cmr7979912ilv.19.1699838241202; Sun, 12 Nov 2023 17:17:21 -0800 (PST) Received: from localhost.localdomain ([128.1.74.235]) by smtp.gmail.com with ESMTPSA id r6-20020aa78b86000000b0064f76992905sm2918511pfd.202.2023.11.12.17.17.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Nov 2023 17:17:20 -0800 (PST) From: Leo Yan To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , "Michael S . Tsirkin" , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Manos Pitsidianakis , Leo Yan Subject: [PATCH v1 1/4] hw/virtio: Support set_config() callback in vhost-user-base Date: Mon, 13 Nov 2023 09:16:39 +0800 Message-Id: <20231113011642.48176-2-leo.yan@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231113011642.48176-1-leo.yan@linaro.org> References: <20231113011642.48176-1-leo.yan@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::12a; envelope-from=leo.yan@linaro.org; helo=mail-il1-x12a.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 The Virtio input device invokes set_config() callback for retrieving the event configuration info, but the callback is not supported in vhost-user-base. This patch adds support set_config() callback in vhost-user-base. Signed-off-by: Leo Yan --- hw/virtio/vhost-user-base.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hw/virtio/vhost-user-base.c b/hw/virtio/vhost-user-base.c index 78cfa9a5bb..a83167191e 100644 --- a/hw/virtio/vhost-user-base.c +++ b/hw/virtio/vhost-user-base.c @@ -140,6 +140,22 @@ static void vub_get_config(VirtIODevice *vdev, uint8_t *config) } } +static void vub_set_config(VirtIODevice *vdev, const uint8_t *config_data) +{ + VHostUserBase *vub = VHOST_USER_BASE(vdev); + int ret; + + g_assert(vub->config_size && vub->vhost_user.supports_config == true); + + ret = vhost_dev_set_config(&vub->vhost_dev, config_data, + 0, vub->config_size, + VHOST_SET_CONFIG_TYPE_FRONTEND); + if (ret) { + error_report("vhost guest set device config space failed: %d", ret); + return; + } +} + /* * 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. @@ -337,6 +353,7 @@ static void vub_class_init(ObjectClass *klass, void *data) vdc->unrealize = vub_device_unrealize; vdc->get_features = vub_get_features; vdc->get_config = vub_get_config; + vdc->set_config = vub_set_config; vdc->set_status = vub_set_status; } From patchwork Mon Nov 13 01:16:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 743441 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp1403824wrw; Sun, 12 Nov 2023 17:18:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IFQ83ls+eGp8/AV2kFGBF8d7OlGmkpDR7hVDn1WWz1ELuvGHEhNsMvUYYQ2eWLURhDXy8L9 X-Received: by 2002:ac8:57d0:0:b0:41c:dd14:c32e with SMTP id w16-20020ac857d0000000b0041cdd14c32emr7207148qta.48.1699838283537; Sun, 12 Nov 2023 17:18:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699838283; cv=none; d=google.com; s=arc-20160816; b=TAHKE3Amc300x5HcXyFI+X2ozFK+9eK4TcimRhwNpvIt8P378bR+aaRgkfhf8PxMSg Ks4+EL8nTWo+q3k4gr5hMRMuqcj2FsM8yMOaveFpORI7zaPc6GX2Sz9hd0rU4wSYpQPU ifczK3EYa6jvP5Q+/govz3Wa7JgnnLG3ce1DaA4KqLrDZW/rYcZnUZmZSq0e2OK4hrYz pVTKOXZcSa+LnOavoXENcixbyz/krvFketX81EVzMUPZM6AfMRi/cWrla0avepFgYzLj JE5DIH+hpfyNL8lNglH9cFTAhuB1PDLZ/FHGmGkM4F4VB6iP494+VZwDgT7dqczB/f2C j7Sw== 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=z7vncVI87o92pRpzeuD48ta62u1QTVk6AgDWcVuOTqQ=; fh=wuGuGNzRUBT5nBQhy+zJrmr0MipRLMv40xtKcfwYGIM=; b=fJ0l3S7YjX7xyFRr6dLJwfdl59ZalwYwyTCtf882Imkyq7yigxrh4ZVXOOkn+ywVjk gOxc8DyvfXZ6KpJM7+7GgBO0NccOxn0auQ6gGEWn2gOJrT5jfktahrsbZQt0yOl4BOJ6 X2TejVLF5lgoYheu0BNApDeUDDx6Txn2nGbxhlFw0NyPD9/n41K2mEDsWxkoYeHlb5/G 2FxVV8I4eNaFZwDdUA9IuXxPGEgxJni/bAGod3Yw7XDspJKQIxW/KCKv3aweXJjpBPDO pQinc9nC+12Iq6vyYiBzBmvRaCUYBXGwiTda5GGFG5Os0ryeqJRKw8cmiodJtr0fGnIN kHiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EU4wuJco; 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 y7-20020a05622a004700b00417b2074a0esi3671313qtw.457.2023.11.12.17.18.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 12 Nov 2023 17:18:03 -0800 (PST) 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=EU4wuJco; 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 1r2La3-0000ZN-R0; Sun, 12 Nov 2023 20:17:35 -0500 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 1r2La2-0000Z8-IA for qemu-devel@nongnu.org; Sun, 12 Nov 2023 20:17:34 -0500 Received: from mail-ot1-x344.google.com ([2607:f8b0:4864:20::344]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r2La0-0003os-SU for qemu-devel@nongnu.org; Sun, 12 Nov 2023 20:17:34 -0500 Received: by mail-ot1-x344.google.com with SMTP id 46e09a7af769-6d2fedd836fso2477266a34.1 for ; Sun, 12 Nov 2023 17:17:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699838251; x=1700443051; darn=nongnu.org; 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=z7vncVI87o92pRpzeuD48ta62u1QTVk6AgDWcVuOTqQ=; b=EU4wuJcoINLWVEy0HKYI5JUZFoeHb0r1BN9gttdCXGsBUpMna1ZI1IHBfp4H6WIxM3 VJtJg6FEIniyQmOzqn7fR98mdAMCVsa0z275srr9p6f/zKCIlqY1n5EYXQPw/s8jXAzX 8jkU2wt2P2zcMu+DjTcDB8sPD/3hC8zT8qOoH1GWDVWO+nUMX6LJ2lfq9oM6q6kVpWma c6+G4+SXGrWe2rnxeRiRa0Ski4hv+1Wve2gGFFD0gZlAYAihzl5l5YSXxia5QrnJ0GGn 4qWmv74I+U8BSmfgUDDKza9ct7CGLGSrHeJiHaIP27B4cQhJ4zv+RO53XCNrQeXtzp9K 7oEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699838251; x=1700443051; 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=z7vncVI87o92pRpzeuD48ta62u1QTVk6AgDWcVuOTqQ=; b=B5c9zb7TIkTGOQVUgfGKEnVWCYzKijtVoKkG+yb4ic4KAbLmvX6W1p4pJTsdYvCbit wxUNr+EW2uBAl/3KbbR9ypV/3VjWxOLukNSaghmlPUgd0k+X0WZXfYc1Vc4hA/7UgsEK aIuOLVy6fOuIbPaHL+ay58MMBVJJP/MwpqQwx94opgDvAMqmz5XoCjcev+DUInqDyMW5 dbDWn49cWFtRSwwiHUzqgHqmKxXlXayh98Lmb2lrb/mcIgKBT2R84yWRTpS5T0+fLXH/ SYwg7F0Rt/UiEFKTQ6r+wrzFnkMTwqnwnhP4qhdsp20Burf88IVJI+6SCHDOiPDfUYo/ AT7Q== X-Gm-Message-State: AOJu0Yzf/3La0H7dXyKW5UcuZPAHhuH+OuYDGuqGIS2CVYNFnpXluaEM TXicXOpl0GICi0e1TjiQokb5ZfH6Z4gQqJzQmNPL+IIn3Cg2bw== X-Received: by 2002:a05:6870:6b89:b0:1e9:919d:83ec with SMTP id ms9-20020a0568706b8900b001e9919d83ecmr8386683oab.28.1699838251367; Sun, 12 Nov 2023 17:17:31 -0800 (PST) Received: from localhost.localdomain ([128.1.74.235]) by smtp.gmail.com with ESMTPSA id r6-20020aa78b86000000b0064f76992905sm2918511pfd.202.2023.11.12.17.17.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Nov 2023 17:17:31 -0800 (PST) From: Leo Yan To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , "Michael S . Tsirkin" , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Manos Pitsidianakis , Leo Yan Subject: [PATCH v1 2/4] docs/system: Add vhost-user-input documentation Date: Mon, 13 Nov 2023 09:16:40 +0800 Message-Id: <20231113011642.48176-3-leo.yan@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231113011642.48176-1-leo.yan@linaro.org> References: <20231113011642.48176-1-leo.yan@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::344; envelope-from=leo.yan@linaro.org; helo=mail-ot1-x344.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 adds basic documentation for vhost-user-input. Signed-off-by: Leo Yan --- docs/system/devices/vhost-user-input.rst | 44 ++++++++++++++++++++++++ docs/system/devices/vhost-user.rst | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 docs/system/devices/vhost-user-input.rst diff --git a/docs/system/devices/vhost-user-input.rst b/docs/system/devices/vhost-user-input.rst new file mode 100644 index 0000000000..601282e658 --- /dev/null +++ b/docs/system/devices/vhost-user-input.rst @@ -0,0 +1,44 @@ +.. _vhost_user_rng: + +QEMU vhost-user-input - Input emulation +======================================= + +This document describes the setup and usage of the Virtio input device. +The Virtio input device is a paravirtualized device for input events. + +Description +----------- + +The vhost-user-input device implementation was designed to work with a daemon +polling on input devices and passes input events to the guest. + +QEMU provides a backend implementation in contrib/vhost-user-input. + +Linux kernel support +-------------------- + +Virtio input requires a guest Linux kernel built with the +``CONFIG_VIRTIO_INPUT`` option. + +Examples +-------- + +The backend daemon should be started first: + +:: + + host# vhost-user-input --socket-path=input.sock \ + --evdev-path=/dev/input/event17 + +The QEMU invocation needs to create a chardev socket to communicate with the +backend daemon and share memory with the guest over a memfd. + +:: + + host# qemu-system \ + -chardev socket,path=/tmp/input.sock,id=mouse0 \ + -device vhost-user-input-pci,chardev=mouse0 \ + -m 4096 \ + -object memory-backend-file,id=mem,size=4G,mem-path=/dev/shm,share=on \ + -numa node,memdev=mem \ + ... diff --git a/docs/system/devices/vhost-user.rst b/docs/system/devices/vhost-user.rst index c6afc4836f..75b40f08c6 100644 --- a/docs/system/devices/vhost-user.rst +++ b/docs/system/devices/vhost-user.rst @@ -42,7 +42,7 @@ platform details for what sort of virtio bus to use. - See https://github.com/rust-vmm/vhost-device * - vhost-user-input - Generic input driver - - See contrib/vhost-user-input + - :ref:`vhost_user_input` * - vhost-user-rng - Entropy driver - :ref:`vhost_user_rng` From patchwork Mon Nov 13 01:16:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 743444 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp1403976wrw; Sun, 12 Nov 2023 17:18:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IGUiKdnmTOnyAJ/RUb4Y5r/cB+cAVj2l5xkFAMu80o2EFitXlyYx4L8GvU2IerhifXDQeig X-Received: by 2002:a05:622a:1991:b0:410:9089:6b74 with SMTP id u17-20020a05622a199100b0041090896b74mr6135925qtc.15.1699838309639; Sun, 12 Nov 2023 17:18:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699838309; cv=none; d=google.com; s=arc-20160816; b=onOpDoZLix5dX3n71/CZG/0VndexdRXETHWgP7Z+lAyDdGKV2TzMdeL2AmazQramMm ULpu5GWnvhYC3K9gKbeRqoNaQhbX/6QUa3auWhzDNM6jspungro8UKmwu+nFwCDCtwth OT1yN1Qc83tXkg201qY/fFOAwMJ5cV6yDoTRNJyI//lUCE99BT7fAMWCgQtNGYBItkVb Cw6UFKt7vUXpKNshEgGNuQY5KIjojA4H87oI5TSr1ZPgXZK8p2PxQzYkR9UvJhLQZZAv oOPZd+XsUfFP/NK5c6OHt+hRuWQylXLmTrhpSLcTvShVyEM9u/SB/Rb1gjqSCdy/zMTg +DoA== 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=CnIjF81Iq4zeaKROB6E3ZJNVF7enVvjwzbGJ8K3b0k4=; fh=wuGuGNzRUBT5nBQhy+zJrmr0MipRLMv40xtKcfwYGIM=; b=fdG+deScZsJPoB3ZU9wUJE8NbrUy3DC/gSfzZLvKiHzXGoiIM7dVtlCLJAVYaDqUN+ PIXwiP5JFw7JaNBhm8vsDp6cgg2eOm8VAnoqM/JiDgAezcJguICXoZOsrFH1EWRj75nm U1EcTTWL86pj9vnnzyrdsBg5qhyJBoJBJ8hvpltwGB74M6pmB0MEze5dkCOv/U1SGq+d 5fM/xa4eM85uU+MrOzEmpID/z78GfcSfR1D+ejuUB2LEc8+BScR3HKc0vQTOmUiWyuLM w2BA15gcRTZ7clYV1MOjPPigEzCapD9H+1G/PqNMOyAiaN2qfVXh8IMkjRCo7KlJuq/B EJTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="vh/lrjJd"; 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 w14-20020ac87e8e000000b0041cc1bc8ed8si3832024qtj.23.2023.11.12.17.18.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 12 Nov 2023 17:18:29 -0800 (PST) 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="vh/lrjJd"; 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 1r2LaD-0000c0-PD; Sun, 12 Nov 2023 20:17:45 -0500 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 1r2LaC-0000b5-HY for qemu-devel@nongnu.org; Sun, 12 Nov 2023 20:17:44 -0500 Received: from mail-oa1-x31.google.com ([2001:4860:4864:20::31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r2LaA-0003pc-RH for qemu-devel@nongnu.org; Sun, 12 Nov 2023 20:17:44 -0500 Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-1efb9571b13so2517301fac.2 for ; Sun, 12 Nov 2023 17:17:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699838261; x=1700443061; darn=nongnu.org; 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=CnIjF81Iq4zeaKROB6E3ZJNVF7enVvjwzbGJ8K3b0k4=; b=vh/lrjJdDVrKdfaX8qtd+/sx9fYI67hcfUQc5Ajjw0O+84wTrxKZJaafo84rFaqv8A qoXC2uQeInLABUYih9t45P/EIMd3jcz59OE0MUPmS0YK+MGyefMqNBwCdIefrQN69Z7y VRllSywr9zvoCvveaL3ySVBkVVOq8n17LU+Os21r1BiaQ6Gzh5zKJk5ucY1rEjB/oblY BeRNplnvcjipDI+iQpvl9yu06h5elJBon1tkfGyffoGhrh0Nz2QUwxaXhSuxY7oxSjYZ TVRvO/XPZmQkdZ46sHLjw5ctR1KqWpcWYDwWLpuk/eIQVo0rbjE2NptILewHrrbXcv1l lYnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699838261; x=1700443061; 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=CnIjF81Iq4zeaKROB6E3ZJNVF7enVvjwzbGJ8K3b0k4=; b=L1FC5chkFeQTHXfy4sA0S1sdOwyX2lmk2MF1IwLXnctuv9Na5vWSHOmLVav9UbHueu O3aNmfQ37E17hGjnjAc1bG7UbFF6T6KCBVF/YasYPohJ2UiT8DuEx1WeG3j/gE+IknEh h+tjZ8UNm8JkA75Dtew/3PP9lsesa1WodV1GJPnuZLf8Ms9lFXBwMZ5sOZuwnsg4BdwT 3VA/LrFK8pREOXH9cfUYNoKlUQzFmaW/oCpa5ZumEBD1gt5rM7kjpWJzGpi4GVS5F6ii DXc2aNulUJVon+m7R8sw4TSwhS4St6o136JjuLucqmUbuhqMPXsbBg7HaEDljELPE1BX 0WjQ== X-Gm-Message-State: AOJu0YxCB9aZ0cyPmCppAEgpae7bMGFndW7zl4/rx2DTKlBxekrDhIuU o4c0+q7u9N1Cz3A6zL3sKevO7uIVXT0Ck8tjfxXqDcTSE5Q= X-Received: by 2002:a05:6870:887:b0:1ea:6a7b:e40a with SMTP id fx7-20020a056870088700b001ea6a7be40amr7142194oab.59.1699838261335; Sun, 12 Nov 2023 17:17:41 -0800 (PST) Received: from localhost.localdomain ([128.1.74.235]) by smtp.gmail.com with ESMTPSA id r6-20020aa78b86000000b0064f76992905sm2918511pfd.202.2023.11.12.17.17.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Nov 2023 17:17:40 -0800 (PST) From: Leo Yan To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , "Michael S . Tsirkin" , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Manos Pitsidianakis , Leo Yan Subject: [PATCH v1 3/4] hw/virtio: Move vhost-user-input into virtio folder Date: Mon, 13 Nov 2023 09:16:41 +0800 Message-Id: <20231113011642.48176-4-leo.yan@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231113011642.48176-1-leo.yan@linaro.org> References: <20231113011642.48176-1-leo.yan@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::31; envelope-from=leo.yan@linaro.org; helo=mail-oa1-x31.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 vhost-user-input is in the input folder. On the other hand, the folder 'hw/virtio' maintains other virtio stubs (e.g. I2C, RNG, GPIO, etc). This patch moves vhost-user-input into the virtio folder for better code organization. No functionality change. Signed-off-by: Leo Yan --- hw/input/meson.build | 1 - hw/virtio/meson.build | 4 +++- hw/{input => virtio}/vhost-user-input.c | 0 3 files changed, 3 insertions(+), 2 deletions(-) rename hw/{input => virtio}/vhost-user-input.c (100%) diff --git a/hw/input/meson.build b/hw/input/meson.build index 640556bbbc..3cc8ab85f0 100644 --- a/hw/input/meson.build +++ b/hw/input/meson.build @@ -11,7 +11,6 @@ system_ss.add(when: 'CONFIG_TSC2005', if_true: files('tsc2005.c')) system_ss.add(when: 'CONFIG_VIRTIO_INPUT', if_true: files('virtio-input.c')) system_ss.add(when: 'CONFIG_VIRTIO_INPUT', if_true: files('virtio-input-hid.c')) system_ss.add(when: 'CONFIG_VIRTIO_INPUT_HOST', if_true: files('virtio-input-host.c')) -system_ss.add(when: 'CONFIG_VHOST_USER_INPUT', if_true: files('vhost-user-input.c')) system_ss.add(when: 'CONFIG_PXA2XX', if_true: files('pxa2xx_keypad.c')) system_ss.add(when: 'CONFIG_TSC210X', if_true: files('tsc210x.c')) diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index 118d4d4da7..c924afcafc 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -25,6 +25,7 @@ if have_vhost system_virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c.c')) system_virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c')) system_virtio_ss.add(when: 'CONFIG_VHOST_USER_SND', if_true: files('vhost-user-snd.c')) + system_virtio_ss.add(when: 'CONFIG_VHOST_USER_INPUT', if_true: files('vhost-user-input.c')) # PCI Stubs system_virtio_ss.add(when: 'CONFIG_VIRTIO_PCI', if_true: files('vhost-user-device-pci.c')) @@ -36,6 +37,8 @@ if have_vhost if_true: files('vhost-user-rng-pci.c')) system_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_SND'], if_true: files('vhost-user-snd-pci.c')) + system_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_INPUT'], + if_true: files('vhost-user-input-pci.c')) endif if have_vhost_vdpa system_virtio_ss.add(files('vhost-vdpa.c')) @@ -59,7 +62,6 @@ 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_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')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_FS', if_true: files('vhost-user-fs-pci.c')) diff --git a/hw/input/vhost-user-input.c b/hw/virtio/vhost-user-input.c similarity index 100% rename from hw/input/vhost-user-input.c rename to hw/virtio/vhost-user-input.c From patchwork Mon Nov 13 01:16:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 743445 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp1404002wrw; Sun, 12 Nov 2023 17:18:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IGEi8540lih9nivriC13X7m/a0Dy2mlTVN5Z0kNrQlfuClZqTu9gWpyS//Yi2mpz91ID8ma X-Received: by 2002:a05:6214:1934:b0:66f:afe3:1ef7 with SMTP id es20-20020a056214193400b0066fafe31ef7mr6123057qvb.12.1699838313990; Sun, 12 Nov 2023 17:18:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699838313; cv=none; d=google.com; s=arc-20160816; b=QiZu+aHOOKMtk0jDOGq7EMhWkIjPDEjqa8cx+Z7uY5b8JIQZRBNSjObsOo8a7W3MpM fLcwYRglnG13J4pScik8WMjsSjMCG7nBMuQa9Ivrw+V8OUbytd3gvobsOZCCg6ObHPdR FT7pLkwndlPP3BfH5UrBM+u9YpZoDYYXboYNGQSIPIlu94u0xVktHlrJd3Kwzmzuu7Is ySCK6zb1irib8wPLjh9dA9ywgRXcnhmIKKRoG01mdIQ+HRcd6fR/fBNF9psdLn/eucGp in3SVRJEq+i3C5tTnjqZ0sbSbHYiIzgoZg92u6SFmwWwR0boigNdVkQ0Mn2YQVn8FQt+ e7Lw== 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=LwfL1MMbcUd8gBQwuRg85QiTdLCeCUniVkLUUu4iwTE=; fh=wuGuGNzRUBT5nBQhy+zJrmr0MipRLMv40xtKcfwYGIM=; b=arkALuEDostiN4gyE78LTLqAftpZi/ES+xT1WheXixhMYXIFVB+e0Gc9VCyXrRfcs+ cnKI087wplP0Q3zf6vupZj6O+jHQzyLAuNPWcCx0U2lszHWAzM1vVujnulcbdC/mlgR/ CxFL7Lb9PKszdq6BPmriaiKUOLoWtfA6XMoLhCopURhV4BJIILifQM4/6JmmZNUoHYbe VlmPiZLQz6T9vsi1qFlJ+bTtGDGnIIekLElWUx9xHbRPpw+UE8PPcpw4YkYlulLMIsa0 2/rxgvQXv2UjCTbhPbEHFNtRaEM7i8Jw5amHNCiiwz0Ih06vDv6Q+4NOAmZhDVn+YtIT HxXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qHKKDihW; 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 bd19-20020ad45693000000b0065b2e14c1c3si3862365qvb.463.2023.11.12.17.18.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 12 Nov 2023 17:18:33 -0800 (PST) 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=qHKKDihW; 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 1r2LaO-0000hp-Ok; Sun, 12 Nov 2023 20:17:56 -0500 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 1r2LaM-0000h1-HY for qemu-devel@nongnu.org; Sun, 12 Nov 2023 20:17:54 -0500 Received: from mail-oi1-x233.google.com ([2607:f8b0:4864:20::233]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r2LaK-0003qX-Nh for qemu-devel@nongnu.org; Sun, 12 Nov 2023 20:17:54 -0500 Received: by mail-oi1-x233.google.com with SMTP id 5614622812f47-3b2e330033fso2488303b6e.3 for ; Sun, 12 Nov 2023 17:17:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699838271; x=1700443071; darn=nongnu.org; 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=LwfL1MMbcUd8gBQwuRg85QiTdLCeCUniVkLUUu4iwTE=; b=qHKKDihWxzKW9q7Yk9pU0zCNdrAXyPvU4xsmJpm8d5i3Au7d+HbGGEC16yGttqfsSY otICbSRVjouTlRdCitz8W481L6rvtrp9nN9atnXF1oU1VG0CeB76g6bXkGBd7Bck6ayF ptbbGzy3kIqy1zJHQ9xB6hmUFoX5HCTupnAEGVENo4jMsWeC+EMbtnARtlBinKlQ2MM7 NVtPOP5YOK69P/vsoHqONPgG1PMQ8d82rOW7tL3OadOtKjPkdwgdapYo1ezvl0na6wX3 r380df+8/HpTi3VWAUsqy/E6NS0Pir/sd3MbuGFm4Dwtua+o5bu6HJOFzBA3/0xXx4Hf +thQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699838271; x=1700443071; 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=LwfL1MMbcUd8gBQwuRg85QiTdLCeCUniVkLUUu4iwTE=; b=BvUdmSGwm/3TkZW5fS+06AhinRFyeCla8x0yBqqv6qneHHUDlUGRVn+WLG0Mh9H90b yuiamp87GP8ENReOGZErAkDtCdYNAV8WCLO6NA7HbPcDIcbhgV7fJfbdXCSjD7aDQB9F h6uz4DHPOovAfNE6wdJAqF2L6McsNJbwWqrqv5NU3gnBfRUj19hJICwDAeKz4EvayUaF oOkrw6rh7pUQzNRCEZhQZzkk6fkuWBSClk3NRXodfuCkXConS2l4Qr0w+7jZ3HH6p6LK R0Q+aiC597+9DCCFxqABrsoHiqNDYJawAvRUmpyK/X3YcluVQSjhcRdNkqQKNzxcY1/G WxVw== X-Gm-Message-State: AOJu0YxXcyQF5hZT89Y2Mq2ZdxWlT1tEVellvIEzKESDtw39q2OsQwHt ymrdPUrfjip+jykyH60e58Zw4raSoKubwpzFgCSpxBCelH0= X-Received: by 2002:a05:6808:200e:b0:3b6:dc6f:2713 with SMTP id q14-20020a056808200e00b003b6dc6f2713mr6558112oiw.31.1699838271489; Sun, 12 Nov 2023 17:17:51 -0800 (PST) Received: from localhost.localdomain ([128.1.74.235]) by smtp.gmail.com with ESMTPSA id r6-20020aa78b86000000b0064f76992905sm2918511pfd.202.2023.11.12.17.17.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Nov 2023 17:17:51 -0800 (PST) From: Leo Yan To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , "Michael S . Tsirkin" , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Manos Pitsidianakis , Leo Yan Subject: [PATCH v1 4/4] hw/virtio: derive vhost-user-input from vhost-user-base Date: Mon, 13 Nov 2023 09:16:42 +0800 Message-Id: <20231113011642.48176-5-leo.yan@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231113011642.48176-1-leo.yan@linaro.org> References: <20231113011642.48176-1-leo.yan@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::233; envelope-from=leo.yan@linaro.org; helo=mail-oi1-x233.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 patch derives vhost-user-input from vhost-user-base class, so make the input stub as a simpler boilerplate wrapper. With the refactoring, vhost-user-input adds the property 'chardev', this leads to conflict with the vhost-user-input-pci adds the same property. To resolve the error, remove the duplicate property from vhost-user-input-pci. Signed-off-by: Leo Yan --- hw/virtio/vhost-user-input-pci.c | 3 - hw/virtio/vhost-user-input.c | 114 +++++-------------------------- include/hw/virtio/virtio-input.h | 6 +- 3 files changed, 21 insertions(+), 102 deletions(-) diff --git a/hw/virtio/vhost-user-input-pci.c b/hw/virtio/vhost-user-input-pci.c index b858898a36..3f4761ce88 100644 --- a/hw/virtio/vhost-user-input-pci.c +++ b/hw/virtio/vhost-user-input-pci.c @@ -30,9 +30,6 @@ static void vhost_user_input_pci_instance_init(Object *obj) virtio_instance_init_common(obj, &dev->vhi, sizeof(dev->vhi), TYPE_VHOST_USER_INPUT); - - object_property_add_alias(obj, "chardev", - OBJECT(&dev->vhi), "chardev"); } static const VirtioPCIDeviceTypeInfo vhost_user_input_pci_info = { diff --git a/hw/virtio/vhost-user-input.c b/hw/virtio/vhost-user-input.c index 4ee3542106..bedec0468c 100644 --- a/hw/virtio/vhost-user-input.c +++ b/hw/virtio/vhost-user-input.c @@ -5,83 +5,25 @@ */ #include "qemu/osdep.h" -#include "qemu/error-report.h" -#include "qapi/error.h" - #include "hw/virtio/virtio-input.h" -static int vhost_input_config_change(struct vhost_dev *dev) -{ - error_report("vhost-user-input: unhandled backend config change"); - return -1; -} - -static const VhostDevConfigOps config_ops = { - .vhost_dev_config_notifier = vhost_input_config_change, +static Property vinput_properties[] = { + DEFINE_PROP_CHR("chardev", VHostUserBase, chardev), + DEFINE_PROP_END_OF_LIST(), }; -static void vhost_input_realize(DeviceState *dev, Error **errp) +static void vinput_realize(DeviceState *dev, Error **errp) { - VHostUserInput *vhi = VHOST_USER_INPUT(dev); - VirtIOInput *vinput = VIRTIO_INPUT(dev); - VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserBase *vub = VHOST_USER_BASE(dev); + VHostUserBaseClass *vubc = VHOST_USER_BASE_GET_CLASS(dev); - vhost_dev_set_config_notifier(&vhi->vhost->dev, &config_ops); - vinput->cfg_size = sizeof_field(virtio_input_config, u); - if (vhost_user_backend_dev_init(vhi->vhost, vdev, 2, errp) == -1) { - return; - } -} + /* Fixed for input device */ + vub->virtio_id = VIRTIO_ID_INPUT; + vub->num_vqs = 2; + vub->vq_size = 4; + vub->config_size = sizeof(virtio_input_config); -static void vhost_input_change_active(VirtIOInput *vinput) -{ - VHostUserInput *vhi = VHOST_USER_INPUT(vinput); - - if (vinput->active) { - vhost_user_backend_start(vhi->vhost); - } else { - vhost_user_backend_stop(vhi->vhost); - } -} - -static void vhost_input_get_config(VirtIODevice *vdev, uint8_t *config_data) -{ - VirtIOInput *vinput = VIRTIO_INPUT(vdev); - VHostUserInput *vhi = VHOST_USER_INPUT(vdev); - Error *local_err = NULL; - int ret; - - memset(config_data, 0, vinput->cfg_size); - - ret = vhost_dev_get_config(&vhi->vhost->dev, config_data, vinput->cfg_size, - &local_err); - if (ret) { - error_report_err(local_err); - return; - } -} - -static void vhost_input_set_config(VirtIODevice *vdev, - const uint8_t *config_data) -{ - VHostUserInput *vhi = VHOST_USER_INPUT(vdev); - int ret; - - ret = vhost_dev_set_config(&vhi->vhost->dev, config_data, - 0, sizeof(virtio_input_config), - VHOST_SET_CONFIG_TYPE_FRONTEND); - if (ret) { - error_report("vhost-user-input: set device config space failed"); - return; - } - - virtio_notify_config(vdev); -} - -static struct vhost_dev *vhost_input_get_vhost(VirtIODevice *vdev) -{ - VHostUserInput *vhi = VHOST_USER_INPUT(vdev); - return &vhi->vhost->dev; + vubc->parent_realize(dev, errp); } static const VMStateDescription vmstate_vhost_input = { @@ -91,40 +33,20 @@ static const VMStateDescription vmstate_vhost_input = { static void vhost_input_class_init(ObjectClass *klass, void *data) { - VirtIOInputClass *vic = VIRTIO_INPUT_CLASS(klass); - VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); + VHostUserBaseClass *vubc = VHOST_USER_BASE_CLASS(klass); DeviceClass *dc = DEVICE_CLASS(klass); dc->vmsd = &vmstate_vhost_input; - vdc->get_config = vhost_input_get_config; - vdc->set_config = vhost_input_set_config; - vdc->get_vhost = vhost_input_get_vhost; - vic->realize = vhost_input_realize; - vic->change_active = vhost_input_change_active; -} - -static void vhost_input_init(Object *obj) -{ - VHostUserInput *vhi = VHOST_USER_INPUT(obj); - - vhi->vhost = VHOST_USER_BACKEND(object_new(TYPE_VHOST_USER_BACKEND)); - object_property_add_alias(obj, "chardev", - OBJECT(vhi->vhost), "chardev"); -} - -static void vhost_input_finalize(Object *obj) -{ - VHostUserInput *vhi = VHOST_USER_INPUT(obj); - - object_unref(OBJECT(vhi->vhost)); + device_class_set_props(dc, vinput_properties); + device_class_set_parent_realize(dc, vinput_realize, + &vubc->parent_realize); + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); } static const TypeInfo vhost_input_info = { .name = TYPE_VHOST_USER_INPUT, - .parent = TYPE_VIRTIO_INPUT, + .parent = TYPE_VHOST_USER_BASE, .instance_size = sizeof(VHostUserInput), - .instance_init = vhost_input_init, - .instance_finalize = vhost_input_finalize, .class_init = vhost_input_class_init, }; diff --git a/include/hw/virtio/virtio-input.h b/include/hw/virtio/virtio-input.h index a6c9703644..e69c0aeca3 100644 --- a/include/hw/virtio/virtio-input.h +++ b/include/hw/virtio/virtio-input.h @@ -1,6 +1,8 @@ #ifndef QEMU_VIRTIO_INPUT_H #define QEMU_VIRTIO_INPUT_H +#include "hw/virtio/vhost-user.h" +#include "hw/virtio/vhost-user-base.h" #include "ui/input.h" #include "sysemu/vhost-user-backend.h" @@ -97,9 +99,7 @@ struct VirtIOInputHost { }; struct VHostUserInput { - VirtIOInput parent_obj; - - VhostUserBackend *vhost; + VHostUserBase parent_obj; }; void virtio_input_send(VirtIOInput *vinput, virtio_input_event *event);