From patchwork Mon Nov 13 19:02:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 743484 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp1793172wrw; Mon, 13 Nov 2023 11:03:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IEBVXRjF2JgqPMbLPYmLP0+1uqJqnOmbPX90pUZJFYV60OJzosPVLwyn49MtP97/QmQcv/6 X-Received: by 2002:a05:6122:1689:b0:4ac:593b:e9f4 with SMTP id 9-20020a056122168900b004ac593be9f4mr7493591vkl.9.1699902191435; Mon, 13 Nov 2023 11:03:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699902191; cv=none; d=google.com; s=arc-20160816; b=WM9bW8J1FQrt10xKQ+4SmPwE0MQa/Qsm3kbdHvOrxT0K1AMxiiG3DurmvN1VLP6lj3 h813/XlTTiZy+fuYdyxp52AylSI74v+/i2YGDPeLH2ExyhcUiYH+Zq2AURQgTYhTOPTa Au/aGooVCGWKAfbN0bjqRYoY1IxOkNZ75+NQ/dVBjiI175j55N5qmw2I8NIKYA6gheFW XDfMhdVs459Ri3iW3GQX4IEX8m4HQCEnxiD2FK1TqsR3vwZdmjMAQMVgyqE1rlfOhKtb U2PJ4RNDfnaSLHNlgnpqvi5oLWECKO+5g3AhrljDkSiv95iza+Samer3PHHOnDiV+/mE Q/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=T9oQMwnfds7gwheh540NHUto9x6gbHU1X9JBynkAdpY=; fh=j5N4gOp3ka1Xsisgn/3FSSHjf2kwoyjMvxSEx5jWFCk=; b=znKXbNxmIlX4jPKKr1bS6KJULZ2L41sc033LqJElxK8dEI+wV4YdCIhB4yZbkYrIN/ 8AXY+P+hZKWSmgbwMrOXCzyl+jJb1iq5j3hxXOf+98sQRoA47eEb1QMAt7eSgZzeq+C6 yrixDTTEPu/YQb9ZVjhojAt4ikEmvo8grr50Shwb/U+bcPGn8VAGWWuKIgrXyq3Mgb/y aJ+n2x7VGazmvpg5Pk2bkzGksuYC8K43PuRtUmdZthDGFoG6cX34YGdP85vaCTmXJgYr awCnghSKP3zPxh8+7xm3gWxa76Zba++ETrMoxyIFj8o7Za4tHKtKJGccnreq1VuoG4cM 9wNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M2ajJyqk; 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 k25-20020a05612212f900b0049d0f89a36asi648793vkp.226.2023.11.13.11.03.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 Nov 2023 11:03: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=M2ajJyqk; 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 1r2cCi-0002dL-LV; Mon, 13 Nov 2023 14:02:37 -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 1r2cCf-0002d4-Ut for qemu-devel@nongnu.org; Mon, 13 Nov 2023 14:02:34 -0500 Received: from mail-qt1-x82e.google.com ([2607:f8b0:4864:20::82e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r2cCd-0000Ki-5K for qemu-devel@nongnu.org; Mon, 13 Nov 2023 14:02:32 -0500 Received: by mail-qt1-x82e.google.com with SMTP id d75a77b69052e-41b7ec4cceeso27832551cf.1 for ; Mon, 13 Nov 2023 11:02:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699902150; x=1700506950; 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=M2ajJyqkCwRwWifWXQDJKrticpN6AaK1rVJmE7ZLew2NefgoQr7IjqMMmhSBfp/8+H aCkQaB+x+5jIHF4FjjYFluMN/bxdeOuUuGRkxDagCGekar7RZRuvYrq5DQbF2C86nnkJ +iF7FF6rPmmOXbi6oo+3nD2lcsr1ihsYSRIuqbIugPh+WnTRe3NehfDU7T0csdx/2RLO mwMi2HvsxmhUQBUBF8AsQy2CbNBCOF83m13HkSe6wrP4xnVXH5Rg+77nR4Jw2sVOZSkV R8wbr3jPjY4meLunUspjaV+WInbxrasRVbc1xXlRfr+KQIJqxyt0keMpHlAwwgPVdoJs dAZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699902150; x=1700506950; 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=kbDYjoPTwTgR8SHyfqGxKHNHilCWHODM0jfgO9610ZtnmmYh0+fN+PpQBqhBfA3G+r 7JfEOUJ0mYivxZFzZiC4oKe//9ksRYkYUk8MrfgP8t3BdILSSgV5DT0O0IBr781PLV0b cji40AEepKrrsblTKrb+5evgQ3Yv8FwzSLunEGXslMjsKt+RJcydCTdoL1CGZyaxm8s+ c1d52pGmwsyUGjd9JWlcZ96PF1PpcsoY7sEZDwassNMc3oklLsK1g7xiazk5rVyFGkdN +DlvzjOtn8HSODpCci3ksuP0nZe613cyy5/P9UVQkqOPlGoIAyQPgqT1Iwg+iuJL9YfI yfWw== X-Gm-Message-State: AOJu0YxWvRyqgJn99Y22Hedtr/jTfARDV2KYNXti5Kdg7VU7oXoarW9J EFooQjdwfT9DTYaAdrzYTw0wdQt+Vsh2R/5JqzbJ8GyfwBA= X-Received: by 2002:ac8:5a83:0:b0:418:194a:f9fe with SMTP id c3-20020ac85a83000000b00418194af9femr9009254qtc.62.1699902149795; Mon, 13 Nov 2023 11:02:29 -0800 (PST) Received: from localhost.localdomain ([12.186.190.1]) by smtp.gmail.com with ESMTPSA id kq4-20020ac86184000000b004181c32dcc3sm2124834qtb.16.2023.11.13.11.02.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 11:02:29 -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 v2 1/4] hw/virtio: Support set_config() callback in vhost-user-base Date: Tue, 14 Nov 2023 03:02:08 +0800 Message-Id: <20231113190211.92412-2-leo.yan@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231113190211.92412-1-leo.yan@linaro.org> References: <20231113190211.92412-1-leo.yan@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::82e; envelope-from=leo.yan@linaro.org; helo=mail-qt1-x82e.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 13 19:02:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 743485 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp1793171wrw; Mon, 13 Nov 2023 11:03:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IFaJI5xK7ZAguDGiVsdZuvijD0FN9cItqicCbTzd9icuyC/lvAcqxcyQzdBIgIQgRfB3ylF X-Received: by 2002:a05:6214:768:b0:66d:6311:f91f with SMTP id f8-20020a056214076800b0066d6311f91fmr125431qvz.45.1699902191433; Mon, 13 Nov 2023 11:03:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699902191; cv=none; d=google.com; s=arc-20160816; b=nUaDzx9ufjMAk3yXhd5yUda9rD3Qck/mZ4TAphH1s4bmYVBe5wQ7TcrCUxCrrQxO+B x0hLoA4VvZs63ATzERIJDVdwyHjwKRB6/blhrimd8Kp6vVzz9bxD7g/8LMZoGQ0jCRWE osKA9tRlZojW8nMxqxeRHHIQEkOh+DC1ubLFrhesowA/9Jym1z5zzuYGWeQtuRH0cNVQ 6Khwmy/xC4/0WxRwWE6UaT/aqXKMVHK06rv1UIMAS+tzBq8+6A1PCiXtvbKAMHYk9E8K KDvVr3/f3/V6MrARktaRzz4njXJ/8XHA3szvAqTJr4s2tbiKSf62nrxShssv14K4AKQR zxcA== 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=FYSYSgbV/GuLcMBTYGrmXS1BeLIkylU92XcqQA40kIg=; fh=j5N4gOp3ka1Xsisgn/3FSSHjf2kwoyjMvxSEx5jWFCk=; b=WcIrho15DG6pUSVLgLwtbvFCRIw05yiImzA9slDr6RGGHJhVuL2HP76ShEtj56+GQh 7BuMByJ1vC1auaH2KlW4Q8CRARED0D8xxppniVao16G7pQ8gkLyHpdg1uK91k60F7GAj 5nNfVyXEVYrxleL7z166YfulwdT+HObL0DGP8XXFxhp2P15/QVR0s99ijAuMBv72nqRX CThN86rZOtv3OchIGAoo5FfAxyR1i4ZbPqa51gGBP3GmmMHQAx7goTcZb02h0ynMKuGM B+VESoCTJAQKIXfE1tlluDmSIGI/7BD+yc/ndhudbOTtlzvnU/3CcYYXv98hDprQ0EBs 3BvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="A/l2x5bX"; 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 a13-20020ad441cd000000b0065b20aeaec8si5102248qvq.194.2023.11.13.11.03.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 Nov 2023 11:03: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="A/l2x5bX"; 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 1r2cCl-0002dj-9n; Mon, 13 Nov 2023 14:02: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 1r2cCj-0002db-N0 for qemu-devel@nongnu.org; Mon, 13 Nov 2023 14:02:38 -0500 Received: from mail-qt1-x82c.google.com ([2607:f8b0:4864:20::82c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r2cCh-0000L5-7L for qemu-devel@nongnu.org; Mon, 13 Nov 2023 14:02:37 -0500 Received: by mail-qt1-x82c.google.com with SMTP id d75a77b69052e-421bcd0b532so16892841cf.2 for ; Mon, 13 Nov 2023 11:02:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699902154; x=1700506954; 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=FYSYSgbV/GuLcMBTYGrmXS1BeLIkylU92XcqQA40kIg=; b=A/l2x5bXQoQRjKcmWHve+gCwW40StMbs8HD3VCH2dNZ5LS3Mwp7hxp7lQ0VwXneaIR s9mWzQ+K81EKH6RuJmsSkY6XMBX9NzwsMLvcYuAvaZRkfIKLZ9aDDGQPj4hfOIFzaFoZ G3qF1LR1VyaqtyHbegLuPxZNfszmtwLxBCe8Ye69rBqombAsA5qDvYVxejqkqMla9ZQS nmhsNkr7q1P50EIXCpauyAW2Rhaapp98gKIxPlr12BRiRdRffLWLbQVklK84tZvuNHB0 0h1yZwmWTQ0PVC60PFdc44Yz2Uw+Bd6mPF/YVzLLd3JOqTEBcPED7uuQLreaMACGFfUG LNXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699902154; x=1700506954; 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=FYSYSgbV/GuLcMBTYGrmXS1BeLIkylU92XcqQA40kIg=; b=DRCEp12Vo26oHW5+w/rdmAVVz7lgTRgrc7bttalI7m/6efzy3h6Tml99t38IBdMKTL uNh+DUW1BJ/CzcN7RWK1LKkZUnfsNI56uOBWA4WDxYYuZ69JS9ZayE5bIm+7mFk/LixQ aETYcziV3fWLsZiialES0q5h82knvs57OH4MrEBvBeDVxMZC9QrhgaPKHnAfDjfn84Tl chCSw8IbrU5/FlUzfYrM5gY5KRbrsnyPaakspjpFTxxVVZkrf6glDxMYC6PT5CvuO+ig CCdX0gNKUPZjnwn0U3Nw/3kBEd5ZPbL2t5+UYuhZMMbtbzYOg9cOnuMd+tAtBQwXIlyX Q7+A== X-Gm-Message-State: AOJu0Yy9CLljcgjoOBxqj/Bo3Go3wbZe4CRdX6olYK5c+o7YkJt+dGEv wyiZrxLRq7fSXlTZ6Hp3QhN45FYlTKIvdQqEgCEKgoSHd5k= X-Received: by 2002:ac8:7fd3:0:b0:413:bd3:cda5 with SMTP id b19-20020ac87fd3000000b004130bd3cda5mr9226970qtk.49.1699902154250; Mon, 13 Nov 2023 11:02:34 -0800 (PST) Received: from localhost.localdomain ([12.186.190.1]) by smtp.gmail.com with ESMTPSA id kq4-20020ac86184000000b004181c32dcc3sm2124834qtb.16.2023.11.13.11.02.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 11:02:31 -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 v2 2/4] docs/system: Add vhost-user-input documentation Date: Tue, 14 Nov 2023 03:02:09 +0800 Message-Id: <20231113190211.92412-3-leo.yan@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231113190211.92412-1-leo.yan@linaro.org> References: <20231113190211.92412-1-leo.yan@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::82c; envelope-from=leo.yan@linaro.org; helo=mail-qt1-x82c.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/devices/vhost-user-input.rst | 44 ++++++++++++++++++++++++ docs/system/devices/vhost-user.rst | 2 +- 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 docs/system/devices/vhost-user-input.rst diff --git a/MAINTAINERS b/MAINTAINERS index 86c649784e..ef72c6d512 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2233,6 +2233,7 @@ L: virtio-fs@redhat.com 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/devices/vhost-user-input.rst b/docs/system/devices/vhost-user-input.rst new file mode 100644 index 0000000000..4ff9dd4b27 --- /dev/null +++ b/docs/system/devices/vhost-user-input.rst @@ -0,0 +1,44 @@ +.. _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 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 19:02:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 743486 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp1793538wrw; Mon, 13 Nov 2023 11:03:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IHgtpsYKZQVLNkqQ8fxdUTTGePNFMUxCRxtMCLJg4GXy/TasAk/ribjAStuMkzEwTJ+0uBM X-Received: by 2002:a05:620a:4006:b0:77a:25bd:e616 with SMTP id h6-20020a05620a400600b0077a25bde616mr63542qko.42.1699902229507; Mon, 13 Nov 2023 11:03:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699902229; cv=none; d=google.com; s=arc-20160816; b=a5YcV+kVbCxfA2sCWHo4XkEFkAtRJo1nPY5V/QcqHiOAvVeiI/v93t0ltFYdrRpjdI gsA08xUuB3spLk2EOfVnpNrHqowjX4iUuRfiE0p1fL32Kd6YbPAxk3cm6XTEfUJynl/T my+l9tHLMsifPArNXgp/ufnKtpaewg1JZd0Z9EpzmAonayRShGrp8ZbCZzp7Bn313zxr UgNciBNmX9Kxjw+kzXwTELeg6hjaoQ3ShIEcSXwNM4d8sQgV7fJcPOWlOvRW+MN9hv8D YuvQfdfongIdXiOeV1Pps2nwHintCvLZuX5HQvpz3ss9hMgeD+9o0xfQb7Qsty8TgI2w FtbA== 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=pKs2iaNGcckU3ni81u+5apbwGwozAkz/WW7uZAFdepY=; fh=j5N4gOp3ka1Xsisgn/3FSSHjf2kwoyjMvxSEx5jWFCk=; b=vhDOJVdqpI+uceSQxRC/aFkE/N57r/ah0ebVFPd6pq3iZNFca29Iq9sZUgfrZtZltB n+Iv4zW3mBGg3u3zs2C6M0+c7e29bFn4OX+yyeGVLul1qjzwZ9eDVNl7jGtIl62g8i/H IZG04y0M2P23ILEcCw/N6ErkNiZJcMYBGXfSl8oNrxwucYSsBxAee9GoaA3Xpujvav59 CbIGWPiKbkkTeHCS4ZSbE6Ca5eDUhvJ6AAR3BOR2p2mPEJb9fUe+5/GQRJIiC9c2xdWn qVKnsfu619U1Mv0p6H0lZKFFYvakn0wQNXkAI8xE/hssZ1cApcG4oUNHYzKAB70dJm2i bB+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ma+SD+Fa; 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 bj18-20020a05620a191200b0077411b34546si5055388qkb.243.2023.11.13.11.03.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 Nov 2023 11:03:49 -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=Ma+SD+Fa; 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 1r2cCq-0002eV-8x; Mon, 13 Nov 2023 14:02:44 -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 1r2cCn-0002e6-Ge for qemu-devel@nongnu.org; Mon, 13 Nov 2023 14:02:41 -0500 Received: from mail-qt1-x82d.google.com ([2607:f8b0:4864:20::82d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r2cCj-0000LF-LR for qemu-devel@nongnu.org; Mon, 13 Nov 2023 14:02:39 -0500 Received: by mail-qt1-x82d.google.com with SMTP id d75a77b69052e-41eae4ebf61so31158171cf.2 for ; Mon, 13 Nov 2023 11:02:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699902156; x=1700506956; 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=pKs2iaNGcckU3ni81u+5apbwGwozAkz/WW7uZAFdepY=; b=Ma+SD+FaeB0XJSF0amKQLnzM2tzC2BIbBoRKBdG+dWKMFo93phgu4+/kU6Knjt+88M GxtuIVNXHd01Q7nSZY1f5OjK5wu5o7RqEu7NlHalZ6w/h1IXooi3opARjI+aaGt/S++6 J42afjuuItxD0KvKg+RfB8R0moMpAd63ox1QIxzTE4i9n74ci/0NKN9vN4WM1lIhWGbo bxQYl4I+MIt/Q7HZpoe2psREp+/QUV32GNhEF081AIKCqOQIPXBYbe8y6WlvgDO6TpPZ rBxFoSgWq0X7usemjaO+3ljL/W9bUK4Mu8jcNk5vn3Gto84oHjD9jYq4USZDvZCOk89H LeiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699902156; x=1700506956; 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=pKs2iaNGcckU3ni81u+5apbwGwozAkz/WW7uZAFdepY=; b=iB9L6OOK3XjS4j3XYDzzW4nRlQ79iSh+2gJkh9ZG6TvXOevOqU1wVd0QOnFdOHxifq VSykEwmTK0PmZufoa0hmM4JNTsohNZ1/Oedohr8KzorL0QvVIEluOngFmvvY/MZ/NAzE CdnVcSD+Po/9CtPREHi5iO0zfj48RNcxD2vMaVsoV5slU2DqpRyF6hXmW1OVFONcgMUh uYa7ooI9CovfxUNv5og3pDruA6Q4z3aHo8gEsDciDsR/GcErZTW9pmYZ6uXEbHqGiqWI 3OVgZK2VS4fZrMMzPuGkdeyDMtadE1K1GW3BDvc6jlKhDHkGWRSQNMqhhH+DEedCs+Ld 8wMg== X-Gm-Message-State: AOJu0YxaXJQplpbm4zTqBKFAbXXsNsSB1LIx3Jf1lw3z8gDzGzz1RJAh ltvwjbHGiRAVi/SOKpxV+GE0guq0rq2n2wzMLeaGhvr0ovY= X-Received: by 2002:ac8:4e83:0:b0:41c:c34a:84af with SMTP id 3-20020ac84e83000000b0041cc34a84afmr17686qtp.6.1699902156181; Mon, 13 Nov 2023 11:02:36 -0800 (PST) Received: from localhost.localdomain ([12.186.190.1]) by smtp.gmail.com with ESMTPSA id kq4-20020ac86184000000b004181c32dcc3sm2124834qtb.16.2023.11.13.11.02.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 11:02: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 v2 3/4] hw/virtio: Move vhost-user-input into virtio folder Date: Tue, 14 Nov 2023 03:02:10 +0800 Message-Id: <20231113190211.92412-4-leo.yan@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231113190211.92412-1-leo.yan@linaro.org> References: <20231113190211.92412-1-leo.yan@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::82d; envelope-from=leo.yan@linaro.org; helo=mail-qt1-x82d.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 --- 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 ef72c6d512..b0b6db38c7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2234,8 +2234,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 13 19:02:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 743487 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp1793687wrw; Mon, 13 Nov 2023 11:04:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IE58UMxFJrg0xv5TdmWsUGc6xeMyJ6X1A1brxApv0eRWv3IW0wJ7lARPJNGDb+QOkt9Q9nk X-Received: by 2002:ac8:5892:0:b0:41c:c2db:217e with SMTP id t18-20020ac85892000000b0041cc2db217emr9293899qta.46.1699902244437; Mon, 13 Nov 2023 11:04:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699902244; cv=none; d=google.com; s=arc-20160816; b=apRm1vtKF8jn6qgKcmmlZ/RIMFXmJ7jUtFw4kaiyMTTch0M+Ng7aK7eCVCRY2bRkHC 4DdutWIrPxnt7VpQzNIUZVrUSsw4akGBhui6jHb8C6OUhuUYMzkc+wmtu/cKy7Evjwdn Si57uaUI5LcJWW7ViXNyLbhCZbJI+7K8Bf480dYsBRH35dB8eYW5Wkaw6pZHJV7aoYAw KdS0fijQYbJPLtwkHoP1uI/gMk0W6IezdTKvK2dKD9+w2wjZ7Cr8F+yhpa90uR8RRiZ1 lrlcdFo9nQPD0JeEhHEcip91RhoZequEZeVlTmHe3iF+DVqrGy7MeBQI811GICpCK998 /EpA== 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=j5N4gOp3ka1Xsisgn/3FSSHjf2kwoyjMvxSEx5jWFCk=; b=Xyc4hqqAJqagd9gEqTlcVZo2ZxChnMNmeyYig/ZHJyqcxF68KcNwvXBjek2MdjrS2m Ky5Dm96JFmpIChyodPTCKOO1wNJIzorBgxNeKiiCCg1zNG9rLMY96/1u2RetLcyiuFtC RwPsob1ZfOu0WZ0zpgnpbKPkcDrnyuQ8NRE9I7URORau5mzfvRQfo8HyO7UocO75zPyR ZPNM70ZDUBGOPuWU9TyxSN4h757aDoqEbMFjc6kyvtnKkRvIK9z+Wy2xgXgfwK3SW0rJ PchRUWZGlk110Eoc/iVEmCdze6queMIJ2OWXUdciP91kTQplvmIV8AS0Ie01AiVRAoyt ZHWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kGKjfWRf; 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 w10-20020a05622a190a00b00419797673cbsi4781402qtc.800.2023.11.13.11.04.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 Nov 2023 11:04:04 -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=kGKjfWRf; 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 1r2cCu-0002el-4y; Mon, 13 Nov 2023 14:02:49 -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 1r2cCp-0002eU-VF for qemu-devel@nongnu.org; Mon, 13 Nov 2023 14:02:44 -0500 Received: from mail-qt1-x830.google.com ([2607:f8b0:4864:20::830]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r2cCl-0000LT-2x for qemu-devel@nongnu.org; Mon, 13 Nov 2023 14:02:43 -0500 Received: by mail-qt1-x830.google.com with SMTP id d75a77b69052e-41cb615c6fbso30100991cf.1 for ; Mon, 13 Nov 2023 11:02:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699902158; x=1700506958; 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=kGKjfWRfkUYZatdcGS5Jv91JIqdZvcfAg4CJH2mOl3N0XR/Ehy6pNYTsyQzYPSjCD8 gi+4Ohsd3VNXCPa1lTtwyWnTedbqPit6PyoZQzCHZr5541u+nuVaCCmghQ7L5aOjoPQB 8IS7s7EX8zAaQXax7Xcc74ZtD417Bt88Od9Rj/TG8U3oITlHZbjA/7LLYFQ1BeQLlDzn usCz/rIQLZkfaL1zRD1zeG1E05ZGzoka2133Qd2qCMWKOMyrrjL+uL4YOWa7eicMWUf2 E0n81fwQgXt0SG+ocACAdS69c7JE2c4kGtSweSdVz3EHJU/hvbAnPrV5UqPb4fISsSPY P/og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699902158; x=1700506958; 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=H9MfHF+51VpTcB6pJlcjmEjNiv+3bPFeGKrYohhLRh5Md4LdpxnvM8mhAeYhqqcZWx g0zDLaTbutICmuER0rt0ONh7snDiCKnN4h7I2ZT0BmuQ0Qx8hQmnkSLjUV3w1DJ8rT11 6388E14FdTv/Z7kAd/KPudAC4+xP74KIepUVbgfYwNVsfp2uX1gH3gtUK8gDNxTOqN+J Mf+9G0zj2N3FGhpGatEcOrsfDElWEBmvVcVEGCPLD+jFbU5PiE77DQ74KVAdGOIbIKak J5R4p9ovmSLoFyPIAl+VI2PaELbxTYYyZ33iPbG2nbqQdImrvl+ZIvDeqPmjp9VahDyk LNaQ== X-Gm-Message-State: AOJu0YykiUZr3qQn2lw66RqhkN6qD2a+4OrQ/iJeG0YJ+kAWYPl8R/wR KIuFiLALCOTGox6yfDymFqrCYYwWB2s1TZf0f50fuz60RZQ= X-Received: by 2002:ac8:5bc2:0:b0:41c:dd22:e7c0 with SMTP id b2-20020ac85bc2000000b0041cdd22e7c0mr11728863qtb.29.1699902157983; Mon, 13 Nov 2023 11:02:37 -0800 (PST) Received: from localhost.localdomain ([12.186.190.1]) by smtp.gmail.com with ESMTPSA id kq4-20020ac86184000000b004181c32dcc3sm2124834qtb.16.2023.11.13.11.02.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 11:02:36 -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 v2 4/4] hw/virtio: derive vhost-user-input from vhost-user-base Date: Tue, 14 Nov 2023 03:02:11 +0800 Message-Id: <20231113190211.92412-5-leo.yan@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231113190211.92412-1-leo.yan@linaro.org> References: <20231113190211.92412-1-leo.yan@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::830; envelope-from=leo.yan@linaro.org; helo=mail-qt1-x830.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);