From patchwork Mon Nov 20 04:37:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 745349 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1100170wrt; Sun, 19 Nov 2023 20:38:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IHcoVQ5jQajOyUjwstQw6pdORxMgauXy4pWFAYQ3CgR6iSLZwzz8lCBUv2C63/R3Hj5mjQg X-Received: by 2002:a05:6214:2a:b0:66d:66cd:a351 with SMTP id b10-20020a056214002a00b0066d66cda351mr17320480qvr.18.1700455120153; Sun, 19 Nov 2023 20:38:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700455120; cv=none; d=google.com; s=arc-20160816; b=SciQkyQMDIGZZ5rS21c9NvVQV8y6v54g3rQzMlG7ncTEud69rgqwXq67l4rC2RhuxW XSG9QG7Y/SrG93lq9CfmpPPzctwyU6r03ebLus4LbrT6dD3b/jLvxM0+1UvkfM6NrVV3 VslCG8aV5gNgewkLrtnYGD3w1J0JMGsd2UOE6mqR2CYD2l6PvII8ouR7Zywk3p2DSGtE AFmXm9QgVFNQGvuNELDUFAt4E+W9onmDe9ePdVMH7uA6/KJYT2nnL3Y7/pTSshY/Q5a3 mKAVJKf4WEzheCpBm9FdHcwR1yQ5jMrl4kPY1E5ftuYWjivsPy/itXCoju4zrVaUCqDP v3WA== 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=WBpKSrlAkKXf6rultbFnaIQsV4HRFQIvdhScRurtvXE=; fh=j5N4gOp3ka1Xsisgn/3FSSHjf2kwoyjMvxSEx5jWFCk=; b=XLIKixUgb+AOE7izvZ9RiPFJx9HTWzRaEaZX+cPHDWv9xDjLi/bM1vOzcN78/e1Hkr nXWY3jHCTscSuFVrolKiyhlTGF7I+6Ial6X5uTimFnWFIOapqtVgxgLfIi5klbbLcyVN Dgm+/ii4RI92NMAZ2GuX4JwjbcdDZWwQ07jEyHhvUeMw4R4pDc+PVVHfHfcv4HejFtIQ /KM6FDcWvdT8YeWuBzwKqwIIqeOJiAPQ+lLV3pxOvvOLfhspsu+zw2OFMnfGxYNPdrGX 39dEt7huGY381YnZfycFRlALRQeEs101ixnoMbjse7YY0WwXgPAcZat1iqOFlxMquYsZ BRmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tG+peU1g; 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 z17-20020ad44151000000b0066d15c73fc0si6634601qvp.120.2023.11.19.20.38.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 19 Nov 2023 20:38:40 -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=tG+peU1g; 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 1r4w2V-0000Ce-KL; Sun, 19 Nov 2023 23:37:39 -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 1r4w2U-0000CP-26 for qemu-devel@nongnu.org; Sun, 19 Nov 2023 23:37:38 -0500 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r4w2S-00039U-Gj for qemu-devel@nongnu.org; Sun, 19 Nov 2023 23:37:37 -0500 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-6bf03b98b9bso3538354b3a.1 for ; Sun, 19 Nov 2023 20:37:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700455055; x=1701059855; 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=WBpKSrlAkKXf6rultbFnaIQsV4HRFQIvdhScRurtvXE=; b=tG+peU1gAYKohDfr3AczmxcmznhUpxaBzDn0UkBYwW6uh6VJdyEIEqIwyCzg2ot3XS fJF3LxeBx01fHFhrHchH3xlTaroii/z3pBrda9JRpXePMpG/jKTihjWlFZXtscfPbeZj 7grZFBLVxfh13nU5Vpt/x1plRYbzqBS1Upis6sKE91bOH3AG8b2+nRoinf4xd8MBar9Q fVP9PxZBG9C27ubbdB5iJ3nTWiMGnBc2fkkbJovVL4vGnI1D6NH85YkuihyNY1PAtWAW Kzop/jWav0KrFMPP8XVFYy5hUbfNojDUcItSoxJpsaNfpP45D6o3WICS2L7mvok+Cv0U FX+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700455055; x=1701059855; 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=WBpKSrlAkKXf6rultbFnaIQsV4HRFQIvdhScRurtvXE=; b=XJvLEwC/Kn23l11KyRJzTTQuGu+KN+xIw3QHynbTXiGV7RQP/YL8+ql60ktInSFlFO V8ejFT//tPjLBTqSGnR/wb86k/ooizDKj+kK3TvElHDym1J7ESn6apgvTJQUkP/2HyE/ nFPD53Cgr2PTDmBjq1AnzLPlwQmFdI5Fk5nwHCPDlBoDy7BCYP0YfP1WCTjuEo8sm3Cu 02SuHWD2GOdz6kHXk3NXNBpKIihyKPCXcpu+tDico8h94n+0/CFbn6eBHrRH5BkRprAX bC6qKhxFWKSroj4CJ2NT4kCZyUh9LbVFuxhiSJ3UGu+3RPKZUREPsMnHRfOdELwwrvnu omiQ== X-Gm-Message-State: AOJu0YzSPm7WvWzLYFAmJg10Ou+TQbqwMcoPnfSYLXI0ayUubsn/fyf2 HeXoDLKR8pfKIqSSzF3LzUu7T8L8OMtBPMrW3EgXfeApW62IdQ== X-Received: by 2002:a05:6a20:938e:b0:15d:b407:b0a0 with SMTP id x14-20020a056a20938e00b0015db407b0a0mr8477856pzh.26.1700455055031; Sun, 19 Nov 2023 20:37:35 -0800 (PST) Received: from leoy-yangtze.lan (211-75-219-202.hinet-ip.hinet.net. [211.75.219.202]) by smtp.gmail.com with ESMTPSA id s41-20020a056a0017a900b006926d199fdcsm5035991pfg.190.2023.11.19.20.37.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 20:37:34 -0800 (PST) From: Leo Yan To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Gerd Hoffmann , "Michael S . Tsirkin" , Manos Pitsidianakis , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Leo Yan Subject: [PATCH v3 1/4] hw/virtio: Support set_config() callback in vhost-user-base Date: Mon, 20 Nov 2023 12:37:18 +0800 Message-Id: <20231120043721.50555-2-leo.yan@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231120043721.50555-1-leo.yan@linaro.org> References: <20231120043721.50555-1-leo.yan@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=leo.yan@linaro.org; helo=mail-pf1-x430.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 Reviewed-by: Marc-André Lureau --- 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 20 04:37:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 745350 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1100198wrt; Sun, 19 Nov 2023 20:38:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IEXoJU1KmAQszxQE3z4EvI6vY/wJMqLLZLHpOzHPnlxNWMHQl9Mq6KaAR08aD0n4L/TSGy5 X-Received: by 2002:a05:622a:44e:b0:417:b55d:dfa0 with SMTP id o14-20020a05622a044e00b00417b55ddfa0mr8241444qtx.0.1700455124863; Sun, 19 Nov 2023 20:38:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700455124; cv=none; d=google.com; s=arc-20160816; b=U3kZnH1mjA2PhlS0T0/VQlQQxK7GRqRa74paJkb5j9EdrRX+hQzBEt/sVY98qRxV59 V5ux15htjY7LsD/1G/2FVTvofu+ZqKNUFG8X/Ht6XQUpGHLGUbwAyM2Ww18e3YWy1Qon nB4aOcwhb5xEmTPA5R6HKr82CAe1M3Qe8KZBSlNu0YdBOCKjbGefBcXhddCzagIf+LJJ C5ocJhCYwe0CMVlmTqKDfijHUT586sJzPSIXtCfHcthc5QAiA5G20WrFJno4Ads+5QkO GNcNCb4K4+Aansf+mfUoApxyT8f4qVNX09R/gBBNznzl3hlbXZYlaKG5jRVpWl2L1HOV xArw== 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=nfEdFC/D9UpE1gEhOw+eN4wVWhKF64mX7MUD3h35eU0=; fh=j5N4gOp3ka1Xsisgn/3FSSHjf2kwoyjMvxSEx5jWFCk=; b=FVOGasjRFlcVUHVyeuyWzbpbxUpBEIMKIdb/OpcuA6wcZoWNbrxRMw737fZQun8Aw6 Rb0XXRUAQcF7bjAADiQvui4kV+yj0XC6c4UlvJJaR1qC4gt7iNC2PdVs1BWI1XCgNvvn p/8V+XYXQ8amUqvCmti4NEisIUJzzWqhKcdzqsN3yyzLl8Jr6iXeyVcuLNubq3Y3Htbz MNBSrgFVLHN71hwkqxDKGcFJX7uotRedadEEMid+iCaUHulufk0At2FX9jJHS0SfpTyv FP9BfvziKHOt/UnfsmvuB6AqVWY1mDct5+4O+SuDcc7IU6t+qs2oEtnLGyP5WWDL6M8l dmfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lrRVlJti; 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 u21-20020a05622a011500b0041e47735605si6717895qtw.366.2023.11.19.20.38.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 19 Nov 2023 20:38:44 -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=lrRVlJti; 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 1r4w2Z-0000Da-Fh; Sun, 19 Nov 2023 23:37:43 -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 1r4w2X-0000Cx-GV for qemu-devel@nongnu.org; Sun, 19 Nov 2023 23:37:41 -0500 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r4w2V-00039r-LB for qemu-devel@nongnu.org; Sun, 19 Nov 2023 23:37:41 -0500 Received: by mail-pf1-x442.google.com with SMTP id d2e1a72fcca58-6c34e87b571so3140015b3a.3 for ; Sun, 19 Nov 2023 20:37:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700455058; x=1701059858; 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=nfEdFC/D9UpE1gEhOw+eN4wVWhKF64mX7MUD3h35eU0=; b=lrRVlJtiPQGOuP2pV9hlpQodpEUclZ9s79BmQJSDZ0K2tSeJN+8o9hEzRdyjs7OQac aeUByCwojTRWqNgHqYmQfBHLEOBJQsESw88e6biWbKPkKARuFx+grYEWbEfqUJ/vUtJj enOtrpw1OXvhIj4Bf7EBDCaH2EBTMrWiJEbcyyO98OdasUwzyrO/A9knBCAMIri54+ok L938oHZhHhM6p6gJWNxndaq5tTjMQMbLkBg20emIvW6qLW4peBjoN58jNBNaZPACwWp4 KlRQvbOD2zsC81ayEQIE5YCgBi0ItJLXjjXydYPHibZ9AwTstXTOrQGOZWK8y6GsmrYP V9zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700455058; x=1701059858; 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=nfEdFC/D9UpE1gEhOw+eN4wVWhKF64mX7MUD3h35eU0=; b=kA4orRgVneQzBef4EmBLpBtCrKPiqoudCQy/Vn0m7Ncf9Xgkvwms/2UOfLbWgvZfvH uD1KRAUS1rWj8CSaPlMRFMVuAGI17P/dj8rfZnCt6OQ9lkS6OpDA0X9he+42WnifpTBJ ZbsIDc8g1+pqeAvTVvkyRFq9rDJsq82nvu51mJnJ+snf8hWwMTCXLf2xyuzYgwRe4E6Y i9TfQE5yoyFcIzat6Gim9GR1gO5ojxcma7XnOZNTaamGKXdasqNCNUAskcYrHnmWpncM oWCGqMxNkUA017H1sXTPoRyCJNJ6nXIfn3jDUMOABuReKP5IpWsQ5WURgVXb7hzNz+C7 n+0A== X-Gm-Message-State: AOJu0YxUA3RkLHTdfQBJZixS9NW+lUC5eHiZnqxvSni93WzwnGUILLA5 aPUx9aa2Md+94ro2W6+CbV0JWGiq8gi5QOqjGUo77SMpwC7fAguX X-Received: by 2002:a05:6a00:a88:b0:6c3:1b7d:dac9 with SMTP id b8-20020a056a000a8800b006c31b7ddac9mr4822781pfl.34.1700455057737; Sun, 19 Nov 2023 20:37:37 -0800 (PST) Received: from leoy-yangtze.lan (211-75-219-202.hinet-ip.hinet.net. [211.75.219.202]) by smtp.gmail.com with ESMTPSA id s41-20020a056a0017a900b006926d199fdcsm5035991pfg.190.2023.11.19.20.37.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 20:37:37 -0800 (PST) From: Leo Yan To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Gerd Hoffmann , "Michael S . Tsirkin" , Manos Pitsidianakis , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Leo Yan Subject: [PATCH v3 2/4] docs/system: Add vhost-user-input documentation Date: Mon, 20 Nov 2023 12:37:19 +0800 Message-Id: <20231120043721.50555-3-leo.yan@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231120043721.50555-1-leo.yan@linaro.org> References: <20231120043721.50555-1-leo.yan@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::442; envelope-from=leo.yan@linaro.org; helo=mail-pf1-x442.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 --- MAINTAINERS | 1 + docs/system/device-emulation.rst | 1 + docs/system/devices/vhost-user-input.rst | 45 ++++++++++++++++++++++++ docs/system/devices/vhost-user.rst | 4 ++- 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 docs/system/devices/vhost-user-input.rst diff --git a/MAINTAINERS b/MAINTAINERS index 0624d67932..8a26fe9493 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2262,6 +2262,7 @@ L: virtio-fs@lists.linux.dev virtio-input M: Gerd Hoffmann S: Odd Fixes +F: docs/system/devices/vhost-user-input.rst F: hw/input/vhost-user-input.c F: hw/input/virtio-input*.c F: include/hw/virtio/virtio-input.h diff --git a/docs/system/device-emulation.rst b/docs/system/device-emulation.rst index d1f3277cb0..f19777411c 100644 --- a/docs/system/device-emulation.rst +++ b/docs/system/device-emulation.rst @@ -94,6 +94,7 @@ Emulated Devices devices/virtio-gpu.rst devices/virtio-pmem.rst devices/virtio-snd.rst + devices/vhost-user-input.rst devices/vhost-user-rng.rst devices/canokey.rst devices/usb-u2f.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..118eb78101 --- /dev/null +++ b/docs/system/devices/vhost-user-input.rst @@ -0,0 +1,45 @@ +.. _vhost_user_input: + +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 access the VirtIO queues with the guest over the +:ref:`shared memory `. + +:: + + 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..9b2da106ce 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` @@ -91,6 +91,8 @@ following the :ref:`vhost_user_proto`. There are a number of daemons that can be built when enabled by the project although any daemon that meets the specification for a given device can be used. +.. _shared_memory_object: + Shared memory object ==================== From patchwork Mon Nov 20 04:37:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 745347 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1100169wrt; Sun, 19 Nov 2023 20:38:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IECGAEO8WRExyFYzgwQzIIayMjY54pV+bFm5lE5LdmGS6oPCFgf6naNKeaiGF3jSuZJP6uf X-Received: by 2002:a05:620a:8f07:b0:77b:d668:dfa7 with SMTP id rh7-20020a05620a8f0700b0077bd668dfa7mr4468653qkn.70.1700455120005; Sun, 19 Nov 2023 20:38:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700455119; cv=none; d=google.com; s=arc-20160816; b=qzhmQvPt9bdxuHRwzrCVE+mDUrEb6TXN52k7x+oGdq2IlnCVUgSwOBhYz9hnIfRRW2 TZHk4cdJGOqp71xZUNtFrm29Zax0ow1NJFbrOSiTXJDiTPGTZSINkKKrP0LiZjeVsAif MywvNa/tDNXT2A6OPfcFIhd3kDBQ7ubBgoBr5KGlcNE9tvQMl1VIQFtUlGoAKZg8ODL0 ZgjgS1iEhA2LM0UMG0GrUHiKzu1e9Ae0J3rcFCttuNlsF2qX/74f7K+6d6jNV+kkCmF7 0067WRIwbk7GMWxj9QT8sxjc6KXEShq/HjdF60g9CyGe2/hVay2dSD3Idwi18MMyApYo cf1A== 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=3NIG2F7HCiQQLDnxtUKaAqaCC4f9JUC5QSsNOyMPV/o=; fh=j5N4gOp3ka1Xsisgn/3FSSHjf2kwoyjMvxSEx5jWFCk=; b=Ki5HDyyBKswhNjLkZJyff3h7hp4PprvOF39qodte+yGG0E3ipsUsbFNNIaPnDAXwMu Itzs3PNohiSBLK3qJO/eM6OTTOzsptaymAa59uuKKRs9ZwG/8/RfN7nmuWKKeyJo8i57 e9yVg+GQUmq7YT6JelCryrKdPoRZ4OSo+T6xfDk8KaFihuQYJ/UXKEyfYM7+CoUWUI/S 2ILf2Nh0NkcW9Dmvh2HrUHEwB9IFmV3glKYfk9uY3IxWGJ1K36PwCzxyIM8lUtshIZcC r8oPn0Y9Nm63/wlW1gILpJW0BDs0jGb6VnnmIgVN2HFAy8o61oQVDqyqEBzhI/woaRax 7//A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ACtBTCyq; 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 pq9-20020a05620a84c900b007672ef90bd6si6639166qkn.556.2023.11.19.20.38.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 19 Nov 2023 20:38:39 -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=ACtBTCyq; 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 1r4w2b-0000Dp-2R; Sun, 19 Nov 2023 23:37: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 1r4w2Z-0000Db-Fk for qemu-devel@nongnu.org; Sun, 19 Nov 2023 23:37:43 -0500 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r4w2X-0003AG-TI for qemu-devel@nongnu.org; Sun, 19 Nov 2023 23:37:43 -0500 Received: by mail-oi1-x236.google.com with SMTP id 5614622812f47-3b2f507c03cso2347951b6e.2 for ; Sun, 19 Nov 2023 20:37:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700455060; x=1701059860; 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=3NIG2F7HCiQQLDnxtUKaAqaCC4f9JUC5QSsNOyMPV/o=; b=ACtBTCyqT7viacRCkjeSuvVcYksAeCyMX5V9eU1Xp872tDiLyK7oeR78bIRI107ywO Tg4uOke5RRVHXtjxK1XogGVb7JthMgtobjJUQzDDAAcngJYt6ADbPCapeMjvtABi70xn nzarz8qZAGRU1vQFwSSjrEstPnAZJl3oJL0ZJ3SRlzgYschJ1Yz20AUrD7sePUQkPEcU DnpDqvdE5efCAaWsC2PLWG+e+ndrZi0ODBI6QXdrUrzL4QM8VG7TdZx7ij6KxSUST5Xf 3eSrarwC/tpmm9ArxD+rujoXNg2+6voPRRhlxWsqyJDOOJ//irI2a9yljusZhVd7zcv4 inlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700455060; x=1701059860; 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=3NIG2F7HCiQQLDnxtUKaAqaCC4f9JUC5QSsNOyMPV/o=; b=jjkFYSQk7thurDtMWx6H8PzHtEbjCinICISlJJ9RCq/rRVu+sjQU/Oy74TFm8qqyjN sygVMCxZE5tOCErcTMooW7eWYYJtWUvvFz37pMzThgKqjggZeg98e7eTeatJqfxntdhi pipUSfJhmp3Rr2AKsgA7w/1qG26g5OWq199f52C30Y1Wm+HePcxfWf5hxunZCURduT9q SiYfwvyR51X8U6lpeV2epP7Us/QrjrkxX1ggWeVTQd4OvYdMRJJDBxp78FTX08mDzv4S 9+fdgA7vtSzxQX/6ln7LRBkGmJmrZ2sopMBsGuSFMHxEdN/Ps27xTPh4tiphHMVbXeGF kLDQ== X-Gm-Message-State: AOJu0YxEUErKPgJcNYpEnmShDwwUDFii76xd6uLs6F+0fizk1vD4IwGT JExm/fOPnnKxHgJB17OMlGoYNRJIp4cYW8XptgZVX3EBGFC+Wg== X-Received: by 2002:a54:4e81:0:b0:3b2:e577:7344 with SMTP id c1-20020a544e81000000b003b2e5777344mr6714633oiy.38.1700455060551; Sun, 19 Nov 2023 20:37:40 -0800 (PST) Received: from leoy-yangtze.lan (211-75-219-202.hinet-ip.hinet.net. [211.75.219.202]) by smtp.gmail.com with ESMTPSA id s41-20020a056a0017a900b006926d199fdcsm5035991pfg.190.2023.11.19.20.37.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 20:37:40 -0800 (PST) From: Leo Yan To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Gerd Hoffmann , "Michael S . Tsirkin" , Manos Pitsidianakis , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Leo Yan Subject: [PATCH v3 3/4] hw/virtio: Move vhost-user-input into virtio folder Date: Mon, 20 Nov 2023 12:37:20 +0800 Message-Id: <20231120043721.50555-4-leo.yan@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231120043721.50555-1-leo.yan@linaro.org> References: <20231120043721.50555-1-leo.yan@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::236; envelope-from=leo.yan@linaro.org; helo=mail-oi1-x236.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 Reviewed-by: Manos Pitsidianakis --- MAINTAINERS | 2 +- hw/input/meson.build | 1 - hw/virtio/meson.build | 4 +++- hw/{input => virtio}/vhost-user-input.c | 0 4 files changed, 4 insertions(+), 3 deletions(-) rename hw/{input => virtio}/vhost-user-input.c (100%) diff --git a/MAINTAINERS b/MAINTAINERS index 8a26fe9493..fdc3edc6cb 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2263,8 +2263,8 @@ virtio-input M: Gerd Hoffmann S: Odd Fixes F: docs/system/devices/vhost-user-input.rst -F: hw/input/vhost-user-input.c F: hw/input/virtio-input*.c +F: hw/virtio/vhost-user-input.c F: include/hw/virtio/virtio-input.h F: contrib/vhost-user-input/* 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 20 04:37:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 745348 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1100166wrt; Sun, 19 Nov 2023 20:38:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IEC1IIX2/D5wRhoCogED/apEOZ2pPnW/VtjY/JYXe9CsWC6hYZRDRyMv19amq/nScU78adk X-Received: by 2002:a05:622a:353:b0:418:1059:dfbc with SMTP id r19-20020a05622a035300b004181059dfbcmr8307644qtw.45.1700455119905; Sun, 19 Nov 2023 20:38:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700455119; cv=none; d=google.com; s=arc-20160816; b=iw2ub4lDA+l2jCSe1dzwUO41G9hpNSz8hI1DmOoNx1w38qWsHRvZasSQbAMY0ZXtij /yH977iL8CGc9pqgGtyaLTcVSSUUhmmc347SLPZd2AQDQzFyHvX5iyZNJ4jy0o/IRfmH NxCaZnyXL2bkHO/rYFUSgJXidkFAawjlG8uB8N4lqke0WIAgdqLuAuTtAVsIpw8pKQdA +s7ZkQ2AEjuoTukGDJjIaxBkUmWgHTzrE+DP4VqLs4uiNLMtn6qNFZDBe2oB2EOW8qGP ePwj5jdJjr6N9HJgTH8nUQsCB7Axn63bQ+Q9w4c8V8ukAa/4mcoaPHixOfdeBFNW5DbF Nxwg== 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=6J3RP6xz4scGjmPj01RG5aacRVJuHKa6R4XaJ4bEqpM=; fh=j5N4gOp3ka1Xsisgn/3FSSHjf2kwoyjMvxSEx5jWFCk=; b=FUewWXhqQPO75mvd6WHXgIpjXnP42nSJFUXDrfpj2LknODuGkShU0vtNnWDc7AfYrx N0RecHM142t8Ta/TxjXd9mGxy4vD0/XGSWRHIZXcTbS3UPeEZyZlxEB3HxW1r0WI0M17 P4RZ5KluQMSjrmv0DGG9C1Et/U8qWMgprNodS2MRfL1TPPIzcap7qHp2EY/Q2g5qGHf+ BFDhi2S7TfDHdPLVpM+5zlXoarmoqLqFPlhlgAkytrHjWIUZIvzfKbgLLu3BRWwIc7qP joaal2OErjYYpUjNOSXfoQJ7a5YyIxFHWnxmfbXjQGl76KfN7e8LZzyr1axOnJKmYdFO Cdcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=db7aJCQA; 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 c7-20020a05622a024700b0041e7729836esi6740680qtx.69.2023.11.19.20.38.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 19 Nov 2023 20:38:39 -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=db7aJCQA; 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 1r4w2e-0000EJ-Sa; Sun, 19 Nov 2023 23:37:48 -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 1r4w2d-0000E8-4S for qemu-devel@nongnu.org; Sun, 19 Nov 2023 23:37:47 -0500 Received: from mail-oa1-x2e.google.com ([2001:4860:4864:20::2e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r4w2b-0003Ak-Ak for qemu-devel@nongnu.org; Sun, 19 Nov 2023 23:37:46 -0500 Received: by mail-oa1-x2e.google.com with SMTP id 586e51a60fabf-1f5bd86ceb3so1458023fac.2 for ; Sun, 19 Nov 2023 20:37:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700455063; x=1701059863; 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=6J3RP6xz4scGjmPj01RG5aacRVJuHKa6R4XaJ4bEqpM=; b=db7aJCQA0Hu3fhq+r62QV5Os3ghpEPDlEgjrHBJ5QmKS0oFc1hzu2pLhaXRrcx6m19 ZPbNkcNDf1BK0rVNIqcdYwnIwhI/fAdnaZHHZDfeZnzTIDodk0+7AH+aRMg0d5mnK4MM S65wyh9VHck1u31ySSYogy/iFPEQk1DLGGlcQF8q+Q+VR54+oYedv2ArJueSXsK62zd7 Lxg3dlfjLDN+5ozYIz4rs/A3GgWup/QjLWgTYqWojlIYxLOf6iVM9QwRsXIGP6DXsh0D JFt3EvOCB2KytFrtwMKiXMK3hjXV7dG4XrUOyUHcieUe9fJm40UzNAjZOSpIaeWXGQtK 7Rwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700455063; x=1701059863; 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=6J3RP6xz4scGjmPj01RG5aacRVJuHKa6R4XaJ4bEqpM=; b=hvHWCzsxsnhoW7i4Y34+JML6QmnENgLWmUJ3k04GOkr53057/Do/TZCd1aGgV4NwRD +zsrKUBB+ue0zS9ia9fkl70p19RiMxZ9G99F7I7S/tLZrI4IZeulRZvmAMY5CFGz7zX6 A3bzlQtn8rdorL8viXNyY6Z3/Ze7ofJpwnf4VZ9xDvqwz2Ykgq+dAlRAbJYI27XrfyLc cmFG4GWatLDFluE4ZBM8dVGzyVvszoWD2M0383m6Q3d78eIcryMeyFDaYP0NKDfQOuuE zLZaIOY0+yAuALsQlnblEJBbzDRGFzWzYSdFOggZaDVKAcGg0zuJPKMBsjKUwDW+Kg9I y2pw== X-Gm-Message-State: AOJu0YyGvTusa47BpxPECq4ljfhQy+aNR25mtQ8hB+fDF2bac4BCUuqC yUx+IL7+iPzrFrW2so3tuURu/u0wkuej6AYLNIm7ZPB7K+ygEA== X-Received: by 2002:a05:6871:79a2:b0:1e9:9742:7dfd with SMTP id pb34-20020a05687179a200b001e997427dfdmr8381279oac.31.1700455063504; Sun, 19 Nov 2023 20:37:43 -0800 (PST) Received: from leoy-yangtze.lan (211-75-219-202.hinet-ip.hinet.net. [211.75.219.202]) by smtp.gmail.com with ESMTPSA id s41-20020a056a0017a900b006926d199fdcsm5035991pfg.190.2023.11.19.20.37.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 20:37:42 -0800 (PST) From: Leo Yan To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Gerd Hoffmann , "Michael S . Tsirkin" , Manos Pitsidianakis , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Leo Yan Subject: [PATCH v3 4/4] hw/virtio: derive vhost-user-input from vhost-user-base Date: Mon, 20 Nov 2023 12:37:21 +0800 Message-Id: <20231120043721.50555-5-leo.yan@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231120043721.50555-1-leo.yan@linaro.org> References: <20231120043721.50555-1-leo.yan@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::2e; envelope-from=leo.yan@linaro.org; helo=mail-oa1-x2e.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 Reviewed-by: Manos Pitsidianakis --- 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) -{ - VHostUserInput *vhi = VHOST_USER_INPUT(dev); - VirtIOInput *vinput = VIRTIO_INPUT(dev); - VirtIODevice *vdev = VIRTIO_DEVICE(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; - } -} - -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) +static void vinput_realize(DeviceState *dev, Error **errp) { - VHostUserInput *vhi = VHOST_USER_INPUT(vdev); - int ret; + VHostUserBase *vub = VHOST_USER_BASE(dev); + VHostUserBaseClass *vubc = VHOST_USER_BASE_GET_CLASS(dev); - 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; - } + /* 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); - 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);