From patchwork Fri Apr 14 16:04:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 673139 Delivered-To: patch@linaro.org Received: by 2002:adf:fcce:0:0:0:0:0 with SMTP id f14csp263227wrs; Fri, 14 Apr 2023 09:07:05 -0700 (PDT) X-Google-Smtp-Source: AKy350Z1GhKb4NMsmBAhr9rddgNiIU19RMLedEClp6tRJAaadLRStsD/fLz0eZZFy+dFke4LhztT X-Received: by 2002:a25:1c04:0:b0:b8f:54f9:46e6 with SMTP id c4-20020a251c04000000b00b8f54f946e6mr6370772ybc.41.1681488425228; Fri, 14 Apr 2023 09:07:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681488425; cv=none; d=google.com; s=arc-20160816; b=xxLmSXMbgTHbnAqabUEUBGpaRK2dihDAiA9iDlVwOoVcV76qfe8qmpvNxl/sbV1yfF lXvcuw/Aa+OUFD+DDdM3Aq17pRii83Jirut4iZRs/7CCtT5ZBfZcYr7YKmeMQ3HYTuIR ctSUgNrJIOoGEcOW2BRLwaG9ZWbN36xwZCopJCx/CXqiUnTm4cn1STrx5aF9b3mEhesE rZ8YD2HOIlI7+Bjb2gBeQGFHYYXqlzQ1ksSc0Y4hHr/RJBw8eUt5lhMUtRpzVtj5AKiH GsJO5+I4/PgtxBQFW8fkvDJPNzmofApnSrhQKKJyimkVz6Dp8SKBnTQBsVgVg7Gxk4TM hJXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ac6OXeQsb/93HLbnF+qlx0Y/JMMvx4eaZHVLLhBGMnw=; b=dQAf5+Y7opA9ZlXkEsp7T/cGL518n6l6YTKeJjMAp514YgNBE0kaJ6X5KFUhlFZ953 C4KfRD7ijV7JNEvMZYmM/ohaRSmkXq6D+Qk1wf3e0zrpyI6GUB2rxx7mO4M1LaCa7f1Y TN/G6mI3wijAinbFHEKaewnzIJZx6oyLLShdMCuUzBNqf7Y5v75aW+MgoUuuKV3NN2Nr p9RFJYu2echCSyG2RdD7qmiBdJDYdmv8nsXu50A7zBzw0Uir2rGUZ/wfkgj4rp9WdtT4 6A/l9UYHXT+tCJVCVqzH2XG1/CdB1RvHQ4gDgtBfWcr7ZLqT0/moHSJ4EAJH/gpY9yNf GWpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RdaJOdn8; 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 o20-20020a05620a22d400b007457ca3616esi2412933qki.694.2023.04.14.09.07.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Apr 2023 09:07:05 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RdaJOdn8; 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 1pnLv7-0006mz-KE; Fri, 14 Apr 2023 12:05:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnLui-0006Rj-LH for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:47 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pnLue-0007yP-8E for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:39 -0400 Received: by mail-wm1-x332.google.com with SMTP id bi22-20020a05600c3d9600b003f0ad935166so2710937wmb.4 for ; Fri, 14 Apr 2023 09:04:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681488275; x=1684080275; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ac6OXeQsb/93HLbnF+qlx0Y/JMMvx4eaZHVLLhBGMnw=; b=RdaJOdn8FisdymopEgb4lrpOBYUrGosSgLoD8zlv0WiTwZFjeV8KjQmJ76VQFwJA7j MDcVYXVpkZXue1Tq0rsvBLC9raEUoAlAUhbpjKkLMCBQn7mnklvRuzxxFW2S37S4ddgx XqpsDd9xoSlltwSsw2qc03KPJzkl9hlM4EbqVPHY8BcE9C3X1kBgdZdlhJq3ImU/POl0 oBc24Tcrlx9iZc65cFw9J/AQ6IgK16TtyIEsKQp5kP9WOx/PWw84d8n3vHyIoqF7h1uV YVLsdc2AmQo1rgTB8dt+gsNrkFj49EhwJJQsHLq4JgrIZzcfWBmtoJl/cmCvrxlg6MpJ UcRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681488275; x=1684080275; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ac6OXeQsb/93HLbnF+qlx0Y/JMMvx4eaZHVLLhBGMnw=; b=VxucAbtAgDJR79N02sXIAIb6md16QYSBvdeIBnx0YcHegZBIR6f9Q6FRUwaudra+zz G3+46xO9WAsUu0JgCl+3T1TglDz9IkmjTJAZyOB5CSL/nOJ9RfDjGBcPsCeXlmB0oaSu q53cObcXbstXdKlGheF/vKfCTAXnF7MXqjNrjjgN4fLtNh7IbIdkxqiBtnjyr9bcHxO4 nUJnA5bq+unjdK06WlfG3dUWNQlpBTfSdLgFcIteckOw5qsj9X9rxcOQaghZxl3Efe0S DasE9T0rNRb7qUDWrVeEGwMWIjLx+ywveJoblX67ZzPrfQEMQje9Zadj054oRqK+HHz7 EJ0g== X-Gm-Message-State: AAQBX9fvASyxJTSrv3VU/x6/4fu1DmZ+2dN8HA0zANvMic7oCWk0xah7 jO0uutefv5kAdmFRCA3lqjLYvaaHIaXw/wYUD2k= X-Received: by 2002:a05:600c:b49:b0:3ed:5d41:f998 with SMTP id k9-20020a05600c0b4900b003ed5d41f998mr4799643wmr.15.1681488274819; Fri, 14 Apr 2023 09:04:34 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a1-20020a05600c224100b003f072b22dbbsm4557999wmm.16.2023.04.14.09.04.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 09:04:34 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id F07C51FFB8; Fri, 14 Apr 2023 17:04:33 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Paolo Bonzini , "Michael S. Tsirkin" , virtio-fs@redhat.com, Erik Schilling , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Eduardo Habkost , Stefan Hajnoczi , Eric Blake , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Jason Wang , Viresh Kumar , Mathieu Poirier , Gerd Hoffmann , Markus Armbruster Subject: [PATCH 01/12] hw/virtio: fix typo in VIRTIO_CONFIG_IRQ_IDX comments Date: Fri, 14 Apr 2023 17:04:22 +0100 Message-Id: <20230414160433.2096866-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414160433.2096866-1-alex.bennee@linaro.org> References: <20230414160433.2096866-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x332.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Fixes: 544f0278af (virtio: introduce macro VIRTIO_CONFIG_IRQ_IDX) Signed-off-by: Alex Bennée --- hw/display/vhost-user-gpu.c | 4 ++-- hw/net/virtio-net.c | 4 ++-- hw/virtio/vhost-user-fs.c | 4 ++-- hw/virtio/vhost-user-gpio.c | 2 +- hw/virtio/vhost-vsock-common.c | 4 ++-- hw/virtio/virtio-crypto.c | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index 71dfd956b8..7c61a7c3ac 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -489,7 +489,7 @@ vhost_user_gpu_guest_notifier_pending(VirtIODevice *vdev, int idx) /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ @@ -506,7 +506,7 @@ vhost_user_gpu_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask) /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 53e1c32643..c53616a080 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3359,7 +3359,7 @@ static bool virtio_net_guest_notifier_pending(VirtIODevice *vdev, int idx) } /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return false */ @@ -3391,7 +3391,7 @@ static void virtio_net_guest_notifier_mask(VirtIODevice *vdev, int idx, } /* *Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index 83fc20e49e..49d699ffc2 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -161,7 +161,7 @@ static void vuf_guest_notifier_mask(VirtIODevice *vdev, int idx, /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ @@ -177,7 +177,7 @@ static bool vuf_guest_notifier_pending(VirtIODevice *vdev, int idx) /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ diff --git a/hw/virtio/vhost-user-gpio.c b/hw/virtio/vhost-user-gpio.c index d6927b610a..3b013f2d0f 100644 --- a/hw/virtio/vhost-user-gpio.c +++ b/hw/virtio/vhost-user-gpio.c @@ -194,7 +194,7 @@ static void vu_gpio_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask) /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index d2b5519d5a..623bdf91cc 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -129,7 +129,7 @@ static void vhost_vsock_common_guest_notifier_mask(VirtIODevice *vdev, int idx, /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ @@ -146,7 +146,7 @@ static bool vhost_vsock_common_guest_notifier_pending(VirtIODevice *vdev, /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index 802e1b9659..6b3e607329 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -1208,7 +1208,7 @@ static void virtio_crypto_guest_notifier_mask(VirtIODevice *vdev, int idx, /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ @@ -1227,7 +1227,7 @@ static bool virtio_crypto_guest_notifier_pending(VirtIODevice *vdev, int idx) /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ From patchwork Fri Apr 14 16:04:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 673142 Delivered-To: patch@linaro.org Received: by 2002:adf:fcce:0:0:0:0:0 with SMTP id f14csp263841wrs; Fri, 14 Apr 2023 09:08:03 -0700 (PDT) X-Google-Smtp-Source: AKy350ZC+za76Vqg2mSRxi4mtyB9T2ag9uZcMMAjJ5JstC2tv6oEm0o7dbXPBMdxVxrrF3RhZekz X-Received: by 2002:a05:6214:412:b0:5ef:56e4:f614 with SMTP id z18-20020a056214041200b005ef56e4f614mr4950715qvx.34.1681488483514; Fri, 14 Apr 2023 09:08:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681488483; cv=none; d=google.com; s=arc-20160816; b=W3dfVExax+4eSnU7dWzgaajisl4YHfRokbUL4xUq56CieAxcAjxEA68q5da+PjxqC1 OsbWFg3H8OgrTg18tb3BEioSsA/Lbj/lmR9Rw6+sx+0ohz/CcLE+BfdRQxXFi1bbzHLc 99IC+VAfbU/flel41sjr6rCGJ7g/OUVKGV0FrhAcyzmleP4If1Luw7bwUYjDj12GBNf4 mtom3wo3GktlMnqebdMRkHZD3tkop7mdAYnIB2Wa8cpnYxK8KT4TEMFvSFeydmDr3waF 1tQw9mVe9MEGw7tgVRlGll3e4wJwuc+twZwkqgWlnVrTBNSzUMDzUrgzNAXWyJ6lHd2/ Kpzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KH5LwiCrOTvBSCuNpYnxQcsypFz8wThrZQsAnqkj0KQ=; b=ETVMZzwtKsJWKxnBNT5tyqU83n7QcOw8Um/WDeNpuRMTHPuT3NhqtSWAYSbRMbzSHw GoEU0lV9Phunr8r8vtr7uOpZQnZPc3WpDM2MdxReIQzd1J3CmchkCRbnaxa9sBv5mQtv 5/ex3ObpxLkkakyJSMzucCOFYxh9vl/DOkQ0hBevHTBQ+jg5gIkNFK9X8aPFhVXLHzXX cvcSNmfM4NK2Ure/DesA2bLG2+7uSvZyIh9abGH148YGnfI7hKHg8mYjsQKoFLO3Y74R tSWBFY+qa1EVLCg9m0hDDmhTMz7nxGK4LVnOieGceKv1MgcC+PEbfWrRRMDG7mxV57PL 83mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Sdj8gbiD; 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 br6-20020a05620a460600b0074a29c9d8basi2962860qkb.443.2023.04.14.09.08.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Apr 2023 09:08:03 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Sdj8gbiD; 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 1pnLvH-0007MB-Dj; Fri, 14 Apr 2023 12:05:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnLuk-0006S1-8A for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:47 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pnLui-0007yo-Ct for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:41 -0400 Received: by mail-wr1-x436.google.com with SMTP id l18so17963466wrb.9 for ; Fri, 14 Apr 2023 09:04:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681488276; x=1684080276; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KH5LwiCrOTvBSCuNpYnxQcsypFz8wThrZQsAnqkj0KQ=; b=Sdj8gbiDPb4tzbA4IYEDhfIDNGgL1BAPjP2dI1RtO2mEIx2afuqR93ODe/ARptkGMc OgrYZvwPP6KoAwSs5SjkutYwzuhrQlzjuuxr0G+o2LSvwb6Y1kvL6uIBJstB8P+wqtoe ZTeSWcIx1YWMUCxRL9wvz/X3q8WBD0U2tbl6amzaot3mxH6pnjcWbbuS5HFkfxiL+Bpy R53uVYPdY7iEmXSAU/7QL4cxkwptnm0QpBRPx3945N/rbB1S0votndKpLEDWbPuhOuy8 eyFgy61kF0I/tJipXdrdET3GXQ1o/RNL/WXgJfybuXLoV4+RUH/4OIyfpAieu92Jjpgs ueLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681488276; x=1684080276; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KH5LwiCrOTvBSCuNpYnxQcsypFz8wThrZQsAnqkj0KQ=; b=IvbW8syc2xUijUBtXHvA/Wau8DK/MSjoXmxi0S/qvnzpJWmcZEg/jN5Ke6BHeVj8oT TqS+qQeZ7jH5qNcxgww0wGtSYbyU5ZTEFiq5vMfAb83oAQpwQZTBv6P6y811Ed9ukcLh GAT/2ptNQhEt7ArzpyVgii2Sr64mAq+3Eg7lLV5qfyytka5p3oqTi1qZKgNDj9QlDUsL co6G2I8LsD1CfiX/fDaYIZSMiLGp7I3jycz68HDeC4afWGJEQvQeBLD7PaakG2B7tsAX OIrlRmLtnWu1Zfg9vWhuFzwe6zRznNWYqqyj2pGD7x/Wh+vF0yAwc3KhESGY+Xh59V8M Z8BQ== X-Gm-Message-State: AAQBX9fFnV4uDSwFRShnr3BJFU/NhIegutcjdIoByZndq9vNwB47o6kP 5ey2PZOLyKfiSks7rNsWVCQaDw== X-Received: by 2002:adf:ee83:0:b0:2f5:39a2:fd99 with SMTP id b3-20020adfee83000000b002f539a2fd99mr4380381wro.71.1681488276102; Fri, 14 Apr 2023 09:04:36 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id f17-20020adff8d1000000b002ef222822d5sm3855281wrq.74.2023.04.14.09.04.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 09:04:34 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 14A1B1FFBA; Fri, 14 Apr 2023 17:04:34 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Paolo Bonzini , "Michael S. Tsirkin" , virtio-fs@redhat.com, Erik Schilling , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Eduardo Habkost , Stefan Hajnoczi , Eric Blake , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Jason Wang , Viresh Kumar , Mathieu Poirier , Gerd Hoffmann , Markus Armbruster Subject: [PATCH 02/12] include/hw/virtio: document virtio_notify_config Date: Fri, 14 Apr 2023 17:04:23 +0100 Message-Id: <20230414160433.2096866-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414160433.2096866-1-alex.bennee@linaro.org> References: <20230414160433.2096866-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Alex Bennée --- include/hw/virtio/virtio.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index f236e94ca6..22ec098462 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -274,6 +274,13 @@ extern const VMStateInfo virtio_vmstate_info; int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id); +/** + * virtio_notify_config() - signal a change to device config + * @vdev: the virtio device + * + * Assuming the virtio device is up (VIRTIO_CONFIG_S_DRIVER_OK) this + * will trigger a guest interrupt and update the config version. + */ void virtio_notify_config(VirtIODevice *vdev); bool virtio_queue_get_notification(VirtQueue *vq); From patchwork Fri Apr 14 16:04:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 673141 Delivered-To: patch@linaro.org Received: by 2002:adf:fcce:0:0:0:0:0 with SMTP id f14csp263411wrs; Fri, 14 Apr 2023 09:07:22 -0700 (PDT) X-Google-Smtp-Source: AKy350YXPOV2zbAKUU1QgGflFiAITYRjz1cWB24u+BT7s0HT5T+K/Wn6LRVbd9H4XPkrwkkuTgns X-Received: by 2002:a05:622a:1755:b0:3d5:cf4e:bd0 with SMTP id l21-20020a05622a175500b003d5cf4e0bd0mr10108561qtk.63.1681488442729; Fri, 14 Apr 2023 09:07:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681488442; cv=none; d=google.com; s=arc-20160816; b=yPGG/miHLD2xUn/J0yjTSnZLep7DCIoo/xfisSBRN8EA3wzsDjs/BKx7X1aj7P1oCI yGfGvTDPEW/4Qqltl4lN27k5VHuwiDkJNrcvJQyUt5JqhL0DzdcKEAo9YI51TsVuUwsW tEVCq2QLEARDpVEI06aLRw94c3RwGdpUqQew+burFyXwWPeKOqgy5W/cmqtQWOHSCKwF 4fQrvFV1gUGfhP6UPnG8fT1614ZzR9YSjCU4Co/M0LIuE25bLGtEkK53XsPNjm/+FSz0 rgJeZaRst/TwA+Ko8tUwumRrM0edHttnltHpqcBrbNOAwIzcVPZYxdH4qJ7Ozur5FAL8 T+sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9tB5/chm/xr33XCg/P0FBnvaCeSkgyIRzyFrSzsSo0k=; b=Alkdne1gdGLNmpm/uXDnoEoZFuV4jISPxDqkRkq6jyytJiqrWIKowlogT6V/NsqnUe L5lq8AcJ0qTIG+wOTwP9a6NcxOgYdT+dQ3JAZxwngrcr4fnT18TDyyi6UN7t1dpZ5LuU Vc2EVi16e30GJhXrpBZ56j16C0nxQiGqx3BSAhIEZEuLOMhmIlQmeFXgy+DVd/zZ54cJ HmnGVzHQ1siDmP36ilhlaHLE961AEsBu2If0aHVzJsfuV5ZeNvR+ivFipYkQ9RII50bF z/H1GawB65NRbFXTLE1Bw6OrTRROQzmiu3ThEcSTZDVD8xCQBG9MrdfDnboeKB7vWv4s EZug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nfBBBpcy; 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 t21-20020a37ea15000000b0074594f290d5si2724990qkj.724.2023.04.14.09.07.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Apr 2023 09:07:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nfBBBpcy; 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 1pnLvD-00072H-1W; Fri, 14 Apr 2023 12:05:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnLui-0006Ri-LF for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:45 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pnLue-0007yT-Ka for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:39 -0400 Received: by mail-wm1-x334.google.com with SMTP id o6-20020a05600c4fc600b003ef6e6754c5so8378903wmq.5 for ; Fri, 14 Apr 2023 09:04:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681488275; x=1684080275; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9tB5/chm/xr33XCg/P0FBnvaCeSkgyIRzyFrSzsSo0k=; b=nfBBBpcykoTEqquKkMJXT0yVy3hlK6944jFPb+9q/eLqYGwR6OqL1NKSzrzDZu4z5V aDTXWqxVpV6+PU1xcb26oAR56WQCQBD8X9IHbnAGfTGAvflVAZffs+BqKjdkaU8W0PCZ SOLzokotez54WLEyTiP8xIshpQDcPfgfVPWnEDoqCU/xZae902SRbgKJPNabP9k4sle9 d9MpjhkbOO5OchlXX/gtLJx0/DenVWuyB4C+olBQd9dKiLUB6kim93kCQlEQAoWlJtT3 g0k43sMM4yK4Od+sWIGf4FsN/Bz85625AhyE+dnsQsZPzIei7PpsvwgfRdUo5PS7kiFA pkKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681488275; x=1684080275; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9tB5/chm/xr33XCg/P0FBnvaCeSkgyIRzyFrSzsSo0k=; b=Hv8gIOqsBxoIxIeVt+SFo24y0HXqUXwXd+VJ1Q2NMIPCxYYeoW+jGf12l4P/J9djN4 oPQOe82UeL2X1w2bBS3KOeGP1edtd7qgQpc/bNxoInWfUthc45LSRnHdnV0sOAEghebX Gazf/GsE7GNn6bIkPuvzeSP18IKn1i07+v+zZzXM/VYrcP4tNgQIeIdFPZ8TPeDTsfL5 3lFY2+bprmmdB65/p9VCc6z9Q5USWMaoU9RgwmqoIDyYapuoLyJtClVGON938iWZqbRO f1mozvewWfWjHoMr1PASoD65WW9sJ2xfGKIs9PT9pTBMJAe8VxqBUlJ/jeBobDUnLhTG aFCA== X-Gm-Message-State: AAQBX9fZYpW5To9pm7bUussjW+K44EfOlU4RCFlhSmVJuTRsmp1k1qCD knQwXexLD/doISJ1YCt4heTlWQ== X-Received: by 2002:a7b:ca4d:0:b0:3f0:6ada:f445 with SMTP id m13-20020a7bca4d000000b003f06adaf445mr4631903wml.33.1681488275019; Fri, 14 Apr 2023 09:04:35 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id n16-20020a05600c3b9000b003dd1bd0b915sm8349256wms.22.2023.04.14.09.04.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 09:04:34 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 2C5471FFBB; Fri, 14 Apr 2023 17:04:34 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Paolo Bonzini , "Michael S. Tsirkin" , virtio-fs@redhat.com, Erik Schilling , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Eduardo Habkost , Stefan Hajnoczi , Eric Blake , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Jason Wang , Viresh Kumar , Mathieu Poirier , Gerd Hoffmann , Markus Armbruster Subject: [PATCH 03/12] include/hw/virtio: add kerneldoc for virtio_init Date: Fri, 14 Apr 2023 17:04:24 +0100 Message-Id: <20230414160433.2096866-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414160433.2096866-1-alex.bennee@linaro.org> References: <20230414160433.2096866-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Alex Bennée --- include/hw/virtio/virtio.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 22ec098462..1ba7a9dd74 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -217,6 +217,12 @@ struct VirtioDeviceClass { void virtio_instance_init_common(Object *proxy_obj, void *data, size_t vdev_size, const char *vdev_name); +/** + * virtio_init() - initialise the common VirtIODevice structure + * @vdev: pointer to VirtIODevice + * @device_id: the VirtIO device ID (see virtio_ids.h) + * @config_size: size of the config space + */ void virtio_init(VirtIODevice *vdev, uint16_t device_id, size_t config_size); void virtio_cleanup(VirtIODevice *vdev); From patchwork Fri Apr 14 16:04:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 673136 Delivered-To: patch@linaro.org Received: by 2002:adf:fcce:0:0:0:0:0 with SMTP id f14csp262612wrs; Fri, 14 Apr 2023 09:06:03 -0700 (PDT) X-Google-Smtp-Source: AKy350ZeLpljA2dmSjt0WpQ1fyWKjh5H2inA9OVdU+2CS9LAAZGa/DjrUFBeGUTEiAayridQ+JUU X-Received: by 2002:a05:6214:2463:b0:5ef:5060:436c with SMTP id im3-20020a056214246300b005ef5060436cmr4352682qvb.17.1681488363361; Fri, 14 Apr 2023 09:06:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681488363; cv=none; d=google.com; s=arc-20160816; b=Ybt+LCWB1Z9rLPhL+kubs8EMqkdovao/VUrAh/MnqX/CMOVmutprbblB6ga8eFqYF8 OLWKRrbLfRuEtER7VuxvYbOwOFKmR0Wimo9p5v3wEwlX2U1cAUnCsD2JnbrGcvGIIvnE TNlTohHV5NyIB7zrGUDAzSp9AFrQ2YMBn6iNstP2agkx+HoTqDEvLW1HV4pHnq2dZb52 F08gDBLbxaL7LL2BbBTUaq47h/0X5Qr0dKCyd8c0HRkQP/yGI8ecAUSIgEMeN96XMCNZ l8X8dFU5p/YG/Jm6vL3ZGrpHYvxGpvDb4r/FAUyb91/Vjgxfs+VdNE88pYNkQKDqhrlF abYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uMkpUFkutd+rkxciDVz0OwgC4E2pyiYQdv8Xz2UBqBQ=; b=JH4BoT80Erj09kzLvqYhfhrGvWgE1LmiRMq0MBtqU9QfuQ2cpwhuiqKogwlRlRygez ulmcH19Hi93eSX5yVnEFtuPgx5ulsOsi0porh1OiZaMYAjHeAS2wId9FjATah2UQi7Pz Umd0BWOhfA7Sf3rXiUh6q/gvjzCgYWS26sqxkyN2JYFf2XPaU0IVfudcBKMRMzTM4oQu JzU2HhlXeNfQUAwKYAfXyBCt36VYZH8Ljivm9CPSqFjzXEfHIK7FOhHV0GrjpNM8I4fi vMzkzKgKL5WUQOpUoNzncDGIL+caTGHViZw6wehQXJu/9WZF5PE12TwpqmOnoqm4Rvs/ bjjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZDAQ4JDh; 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 bs35-20020a05620a472300b00746102fc951si2919433qkb.362.2023.04.14.09.06.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Apr 2023 09:06:03 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZDAQ4JDh; 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 1pnLvQ-0007zf-LG; Fri, 14 Apr 2023 12:05:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnLuj-0006Rv-9g for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:47 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pnLuh-0007uB-7E for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:40 -0400 Received: by mail-wm1-x331.google.com with SMTP id r15so1090400wmo.1 for ; Fri, 14 Apr 2023 09:04:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681488276; x=1684080276; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uMkpUFkutd+rkxciDVz0OwgC4E2pyiYQdv8Xz2UBqBQ=; b=ZDAQ4JDh77Z7nJTcc8Cyx2jNOtWdsdacBdEdLIskqZUBEJfISElHBRSNzucK5uIiom JLRB60GJHXNOJ70N5CXbtcxRu4KOiC5nZox3p4vMKUlDqMuHVeZoOmpG0fShBCKVXGse 8cjmUrEGkYhg45X0aBgkaxewoggWVhif7cYCESRCGaChFtW8N3Fn0q8nfxbcMFhNN9H2 8CPJu5Fx0qe+wIAWxJdg1tDPhEfvDzRTq7fddkWTkG/hDp/4aOQboduTYg3EnQT/fP9S v5N50Pxhcuo0JKZAfk1IVH6WY721yJDsb2oyBWqpoqYV0J9w3biurcufZt6UtStI0Guw LKtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681488276; x=1684080276; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uMkpUFkutd+rkxciDVz0OwgC4E2pyiYQdv8Xz2UBqBQ=; b=WDI1b+7JRsJZn69RVgpmIWCEDTcQNNSP167lgCzyZ5Lic9CuKt812CYk0uXoVEoTTA CDt1OdDmiMAmUWpwTqMX/F8R3CO2RDW2KrFwkB3bJuCMPHgXp6/HswXQFE6MSJgO0xpP lGK+pW5BQpuKXHNmgHxBWNBjIPwVQEi5YJttbsMCx/+doLiLux4CHDGcKNMnKOWl8XPG mN1O/xTcajLauBJpYCN39M3u1IaMfb7bYAGXVHR8B9C6AnigEt3I5Le0ZFrm2vLZlqgl GpBfPi7oDv2xu59mJmD49AseyckTFJOhPhB16JYXTq0MdGlP+qh4w1lKkjtNh08EQRY9 SbxA== X-Gm-Message-State: AAQBX9egJ9oLusml62CmX0L34sQAbfDriX64k5nmy1dDM1xYYILhhzXg nUQGy5lpkAqJ2Z3+bESKwqw7ow== X-Received: by 2002:a7b:c419:0:b0:3ee:672d:caa5 with SMTP id k25-20020a7bc419000000b003ee672dcaa5mr4433072wmi.17.1681488276405; Fri, 14 Apr 2023 09:04:36 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id e2-20020a5d65c2000000b002ceacff44c7sm3807575wrw.83.2023.04.14.09.04.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 09:04:35 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 4416B1FFBC; Fri, 14 Apr 2023 17:04:34 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Paolo Bonzini , "Michael S. Tsirkin" , virtio-fs@redhat.com, Erik Schilling , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Eduardo Habkost , Stefan Hajnoczi , Eric Blake , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Jason Wang , Viresh Kumar , Mathieu Poirier , Gerd Hoffmann , Markus Armbruster Subject: [PATCH 04/12] include/hw/virtio: document some more usage of notifiers Date: Fri, 14 Apr 2023 17:04:25 +0100 Message-Id: <20230414160433.2096866-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414160433.2096866-1-alex.bennee@linaro.org> References: <20230414160433.2096866-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Lets document some more of the core VirtIODevice structure. Signed-off-by: Alex Bennée --- include/hw/virtio/virtio.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 1ba7a9dd74..ef77e9ef0e 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -150,10 +150,18 @@ struct VirtIODevice VMChangeStateEntry *vmstate; char *bus_name; uint8_t device_endian; + /** + * @user_guest_notifier_mask: gate usage of ->guest_notifier_mask() callback. + * This is used to suppress the masking of guest updates for + * vhost-user devices which are asynchronous by design. + */ bool use_guest_notifier_mask; AddressSpace *dma_as; QLIST_HEAD(, VirtQueue) *vector_queues; QTAILQ_ENTRY(VirtIODevice) next; + /** + * @config_notifier: the event notifier that handles config events + */ EventNotifier config_notifier; }; From patchwork Fri Apr 14 16:04:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 673137 Delivered-To: patch@linaro.org Received: by 2002:adf:fcce:0:0:0:0:0 with SMTP id f14csp262611wrs; Fri, 14 Apr 2023 09:06:03 -0700 (PDT) X-Google-Smtp-Source: AKy350Y1LzK10PfOWse/RAZprmHOkzwCBQPuN/cY3XRCGB+60laFemxqqJczB1exjugw3SomH8ta X-Received: by 2002:a05:6214:4008:b0:5a9:c0a1:d31a with SMTP id kd8-20020a056214400800b005a9c0a1d31amr3182947qvb.49.1681488363310; Fri, 14 Apr 2023 09:06:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681488363; cv=none; d=google.com; s=arc-20160816; b=ziSJSoKpLcStA7O3SefTDqwVjEqcNQW+N8nU/UuWgca+WKPWCQYjsoBaS/2FNx1IIY wXNs14m5e+xrRzFht6uS1UDoK3l6XW+wZJbE7zsWkW/e1rc/6MfalE/2KzOE2fuS8PoE zSFBnhtG3A7h9AxIA7DtjMeMoTX4iqmKB35YSk5MVcfDFAKnPneVRCF3jsOD2HEpmIuH NtR1XY0BI9MQUqKMcNnkcp4n5+n+NqK8ibOO+aYCBTL3mEr+vlLjflLzvPWjSzPt9fz8 lZrb20sVY3Z5ZJzvDSFLEMrdM69k6vWAMp4yKlI+eIaibFg/Ta9+M9JKiU0UqSCyiOo7 iSAw== 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=dVJ8qhMaIj4CRymWVGCYn/io0gCtL6so6/34qr3Q4IM=; b=qgf7hgsoQbzbnwwLMIFoU1taak3B8lBG5p3GuRaEWFhcGWwomiOGThjrNNZ3zFom1e oU0JfZGQAp9WFkdqgI2LQtM6/HeZbCv0Xq5Wzx36zkg/fh6bxt4idvWu38XRcKXGn6Ps W2ua2BhB4yPXTawA+wAVPduT/KlXJjd2Ac7ukNVLxwm4THZZOEd1wS5imUmacMs10aix 3MVmkDOEBnu0uvpnJTYzdLmG20aKdto7/SbdFyrXIMI6e6GIQz52NiLLUpM/mCudckTZ JXoWUJyrMDaoqPGQ//ap/Q5Pi7qwI5K6662exPvbcgpFwvi/R6rgeMXfiSkaJMv3Y4X1 5OQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bds7Ecdw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e10-20020a0562141d0a00b0056c23bb1597si2979616qvd.88.2023.04.14.09.06.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Apr 2023 09:06:03 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bds7Ecdw; 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 1pnLvH-0007M8-DX; Fri, 14 Apr 2023 12:05:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnLuk-0006S2-NB for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:47 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pnLuh-0007z1-NN for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:42 -0400 Received: by mail-wm1-x332.google.com with SMTP id q5so10625592wmo.4 for ; Fri, 14 Apr 2023 09:04:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681488277; x=1684080277; 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=dVJ8qhMaIj4CRymWVGCYn/io0gCtL6so6/34qr3Q4IM=; b=bds7EcdwVG3YzeinJ+j7Szh+sqm53B0ml1f/OflSsJMdq9zOhhRTZJsNTjzOBEtJdI 0wsKOP0OVooCTu07qsCjhk4qSqxCDvtPql2byUWGmX2NVwfnQZwAzKgIJX1ocqag5itW zKtlM9IR/rTFBue/1y3T9oPWTFr5NE3tsJ273gZPaiziwmsOpKX2K6O4vABTRFiMP0JA HfhBfyDsC97varWdJgcBymzSK6E99l8ouHZasn5jn7Y/UmB0GJ00i5QFOpQPv7a3JS38 tlSfeEzBMEtWep/AeEzXWiEAUJSrfXs1vAC2GyTiFyZ3cjKAfPfybVXPaCQmkbliLdX/ KMZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681488277; x=1684080277; 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=dVJ8qhMaIj4CRymWVGCYn/io0gCtL6so6/34qr3Q4IM=; b=X02/0v7SMQ3K1vZIZv3/Ajs+KOcLll5vMlJOocf2fItUci7i1LFMzfsDR67fZsgj9v LCQ614PcifAUfq7Kvw1hH3qEQ5taOL4pB8Rh+Kuh6e68zPB/hXgeMjqre6QiZhRB52iC d6KqlrOIVyJZAMjFFM3Tf7/zNJNRREa+ghPiosBmoSeIW+vMCLhXmg5PvsHyLtqg9/hF O78/tQLNsfVBZ2CxqKbdH/6q9AjCh73QilmYvh7vDOkd++NqxU4fwva9NofJbTVgalDU Y48mRmxIkWqvNWc/+L4y3XENNyoucpV4YToWYiVn+Ew9tpX1Ha98y/MhI0wxGjzm/TsA zerQ== X-Gm-Message-State: AAQBX9fc1q+Ejj69jFBm2iujLzL0LCyQLD427XXKFfUHjDwmxMc97QQ+ qkaBGJo/mh+S3FFeBlWU2oSRuA== X-Received: by 2002:a1c:e903:0:b0:3f0:a023:2614 with SMTP id q3-20020a1ce903000000b003f0a0232614mr4592475wmc.6.1681488277344; Fri, 14 Apr 2023 09:04:37 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id iv8-20020a05600c548800b003f09e294d5esm8088548wmb.6.2023.04.14.09.04.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 09:04:36 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 628E21FFBD; Fri, 14 Apr 2023 17:04:34 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Paolo Bonzini , "Michael S. Tsirkin" , virtio-fs@redhat.com, Erik Schilling , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Eduardo Habkost , Stefan Hajnoczi , Eric Blake , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Jason Wang , Viresh Kumar , Mathieu Poirier , Gerd Hoffmann , Markus Armbruster Subject: [PATCH 05/12] virtio: add generic vhost-user-device Date: Fri, 14 Apr 2023 17:04:26 +0100 Message-Id: <20230414160433.2096866-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414160433.2096866-1-alex.bennee@linaro.org> References: <20230414160433.2096866-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x332.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org In theory we shouldn't need to repeat so much boilerplate to support vhost-user backends. This provides a generic vhost-user-device for which the user needs to provide the few bits of information that aren't currently provided by the vhost-user protocol. This should provide a baseline implementation from which the other vhost-user stub can specialise. Signed-off-by: Alex Bennée --- include/hw/virtio/vhost-user-device.h | 32 +++ hw/virtio/vhost-user-device.c | 303 ++++++++++++++++++++++++++ hw/virtio/meson.build | 2 + 3 files changed, 337 insertions(+) create mode 100644 include/hw/virtio/vhost-user-device.h create mode 100644 hw/virtio/vhost-user-device.c diff --git a/include/hw/virtio/vhost-user-device.h b/include/hw/virtio/vhost-user-device.h new file mode 100644 index 0000000000..8d77f06721 --- /dev/null +++ b/include/hw/virtio/vhost-user-device.h @@ -0,0 +1,32 @@ +/* + * Vhost-user generic virtio device + * + * Copyright (c) 2023 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef QEMU_VHOST_USER_DEVICE_H +#define QEMU_VHOST_USER_DEVICE_H + +#include "hw/virtio/vhost.h" +#include "hw/virtio/vhost-user.h" + +#define TYPE_VHOST_USER_DEVICE "vhost-user-device" +OBJECT_DECLARE_SIMPLE_TYPE(VHostUserDevice, VHOST_USER_DEVICE) + +struct VHostUserDevice { + VirtIODevice parent; + /* Properties */ + CharBackend chardev; + uint16_t virtio_id; + uint32_t num_vqs; + /* State tracking */ + VhostUserState vhost_user; + struct vhost_virtqueue *vhost_vq; + struct vhost_dev vhost_dev; + GPtrArray *vqs; + bool connected; +}; + +#endif /* QEMU_VHOST_USER_DEVICE_H */ diff --git a/hw/virtio/vhost-user-device.c b/hw/virtio/vhost-user-device.c new file mode 100644 index 0000000000..bfbf3b29cb --- /dev/null +++ b/hw/virtio/vhost-user-device.c @@ -0,0 +1,303 @@ +/* + * Generic vhost-user stub. This can be used to connect to any + * vhost-user backend. All configuration details must be handled by + * the vhost-user daemon itself + * + * Copyright (c) 2023 Linaro Ltd + * Author: Alex Bennée + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/qdev-properties.h" +#include "hw/virtio/virtio-bus.h" +#include "hw/virtio/vhost-user-device.h" +#include "qemu/error-report.h" + +static void vud_start(VirtIODevice *vdev) +{ + BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); + VHostUserDevice *vud = VHOST_USER_DEVICE(vdev); + int ret, i; + + if (!k->set_guest_notifiers) { + error_report("binding does not support guest notifiers"); + return; + } + + ret = vhost_dev_enable_notifiers(&vud->vhost_dev, vdev); + if (ret < 0) { + error_report("Error enabling host notifiers: %d", -ret); + return; + } + + ret = k->set_guest_notifiers(qbus->parent, vud->vhost_dev.nvqs, true); + if (ret < 0) { + error_report("Error binding guest notifier: %d", -ret); + goto err_host_notifiers; + } + + vud->vhost_dev.acked_features = vdev->guest_features; + + ret = vhost_dev_start(&vud->vhost_dev, vdev, true); + if (ret < 0) { + error_report("Error starting vhost-user-device: %d", -ret); + goto err_guest_notifiers; + } + + /* + * guest_notifier_mask/pending not used yet, so just unmask + * everything here. virtio-pci will do the right thing by + * enabling/disabling irqfd. + */ + for (i = 0; i < vud->vhost_dev.nvqs; i++) { + vhost_virtqueue_mask(&vud->vhost_dev, vdev, i, false); + } + + return; + +err_guest_notifiers: + k->set_guest_notifiers(qbus->parent, vud->vhost_dev.nvqs, false); +err_host_notifiers: + vhost_dev_disable_notifiers(&vud->vhost_dev, vdev); +} + +static void vud_stop(VirtIODevice *vdev) +{ + VHostUserDevice *vud = VHOST_USER_DEVICE(vdev); + BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); + int ret; + + if (!k->set_guest_notifiers) { + return; + } + + vhost_dev_stop(&vud->vhost_dev, vdev, true); + + ret = k->set_guest_notifiers(qbus->parent, vud->vhost_dev.nvqs, false); + if (ret < 0) { + error_report("vhost guest notifier cleanup failed: %d", ret); + return; + } + + vhost_dev_disable_notifiers(&vud->vhost_dev, vdev); +} + +static void vud_set_status(VirtIODevice *vdev, uint8_t status) +{ + VHostUserDevice *vud = VHOST_USER_DEVICE(vdev); + bool should_start = virtio_device_should_start(vdev, status); + + if (vhost_dev_is_started(&vud->vhost_dev) == should_start) { + return; + } + + if (should_start) { + vud_start(vdev); + } else { + vud_stop(vdev); + } +} + +/* + * For an implementation where everything is delegated to the backend + * we don't do anything other than return the full feature set offered + * by the daemon (module the reserved feature bit). + */ +static uint64_t vud_get_features(VirtIODevice *vdev, + uint64_t requested_features, Error **errp) +{ + VHostUserDevice *vud = VHOST_USER_DEVICE(vdev); + /* This should be set when the vhost connection initialises */ + g_assert(vud->vhost_dev.features); + return vud->vhost_dev.features & ~(1ULL << VHOST_USER_F_PROTOCOL_FEATURES); +} + +static void vud_handle_output(VirtIODevice *vdev, VirtQueue *vq) +{ + /* + * Not normally called; it's the daemon that handles the queue; + * however virtio's cleanup path can call this. + */ +} + +static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserDevice *vud) +{ + vhost_user_cleanup(&vud->vhost_user); + + for (int i = 0; i < vud->num_vqs; i++) { + VirtQueue *vq = g_ptr_array_index(vud->vqs, i); + virtio_delete_queue(vq); + } + + virtio_cleanup(vdev); +} + +static int vud_connect(DeviceState *dev) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserDevice *vud = VHOST_USER_DEVICE(vdev); + + if (vud->connected) { + return 0; + } + vud->connected = true; + + /* restore vhost state */ + if (virtio_device_started(vdev, vdev->status)) { + vud_start(vdev); + } + + return 0; +} + +static void vud_disconnect(DeviceState *dev) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserDevice *vud = VHOST_USER_DEVICE(vdev); + + if (!vud->connected) { + return; + } + vud->connected = false; + + if (vhost_dev_is_started(&vud->vhost_dev)) { + vud_stop(vdev); + } +} + +static void vud_event(void *opaque, QEMUChrEvent event) +{ + DeviceState *dev = opaque; + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserDevice *vud = VHOST_USER_DEVICE(vdev); + + switch (event) { + case CHR_EVENT_OPENED: + if (vud_connect(dev) < 0) { + qemu_chr_fe_disconnect(&vud->chardev); + return; + } + break; + case CHR_EVENT_CLOSED: + vud_disconnect(dev); + break; + case CHR_EVENT_BREAK: + case CHR_EVENT_MUX_IN: + case CHR_EVENT_MUX_OUT: + /* Ignore */ + break; + } +} + +static void vud_device_realize(DeviceState *dev, Error **errp) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserDevice *vud = VHOST_USER_DEVICE(dev); + int ret; + + if (!vud->chardev.chr) { + error_setg(errp, "vhost-user-device: missing chardev"); + return; + } + + if (!vud->virtio_id) { + error_setg(errp, "vhost-user-device: need to define device id"); + return; + } + + if (!vud->num_vqs) { + vud->num_vqs = 1; /* reasonable default? */ + } + + if (!vhost_user_init(&vud->vhost_user, &vud->chardev, errp)) { + return; + } + + virtio_init(vdev, vud->virtio_id, 0); + + /* + * Disable guest notifiers, by default all notifications will be via the + * asynchronous vhost-user socket. + */ + vdev->use_guest_notifier_mask = false; + + /* Allocate queues */ + vud->vqs = g_ptr_array_sized_new(vud->num_vqs); + for (int i = 0; i < vud->num_vqs; i++) { + g_ptr_array_add(vud->vqs, + virtio_add_queue(vdev, 4, vud_handle_output)); + } + + vud->vhost_dev.nvqs = vud->num_vqs; + vud->vhost_dev.vqs = g_new0(struct vhost_virtqueue, vud->vhost_dev.nvqs); + + /* connect to backend */ + fprintf(stderr, "%s: doing vhost_dev_init()\n", __func__); + ret = vhost_dev_init(&vud->vhost_dev, &vud->vhost_user, + VHOST_BACKEND_TYPE_USER, 0, errp); + + if (ret < 0) { + do_vhost_user_cleanup(vdev, vud); + } + + qemu_chr_fe_set_handlers(&vud->chardev, NULL, NULL, vud_event, NULL, + dev, NULL, true); +} + +static void vud_device_unrealize(DeviceState *dev) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserDevice *vud = VHOST_USER_DEVICE(dev); + struct vhost_virtqueue *vhost_vqs = vud->vhost_dev.vqs; + + /* This will stop vhost backend if appropriate. */ + vud_set_status(vdev, 0); + vhost_dev_cleanup(&vud->vhost_dev); + g_free(vhost_vqs); + do_vhost_user_cleanup(vdev, vud); +} + +static const VMStateDescription vud_vmstate = { + .name = "vhost-user-device", + .unmigratable = 1, +}; + +static Property vud_properties[] = { + DEFINE_PROP_CHR("chardev", VHostUserDevice, chardev), + DEFINE_PROP_UINT16("virtio-id", VHostUserDevice, virtio_id, 0), + DEFINE_PROP_UINT32("num_vqs", VHostUserDevice, num_vqs, 1), + DEFINE_PROP_END_OF_LIST(), +}; + +static void vud_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); + + device_class_set_props(dc, vud_properties); + dc->vmsd = &vud_vmstate; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); + vdc->realize = vud_device_realize; + vdc->unrealize = vud_device_unrealize; + vdc->get_features = vud_get_features; + vdc->set_status = vud_set_status; +} + +static const TypeInfo vud_info = { + .name = TYPE_VHOST_USER_DEVICE, + .parent = TYPE_VIRTIO_DEVICE, + .instance_size = sizeof(VHostUserDevice), + .class_init = vud_class_init, +}; + +static void vud_register_types(void) +{ + type_register_static(&vud_info); +} + +type_init(vud_register_types) diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index bdec78bfc6..43e5fa3f7d 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -10,7 +10,9 @@ specific_virtio_ss.add(files('virtio-config-io.c', 'virtio-qmp.c')) if have_vhost specific_virtio_ss.add(files('vhost.c', 'vhost-backend.c', 'vhost-iova-tree.c')) if have_vhost_user + # fixme - this really should be generic specific_virtio_ss.add(files('vhost-user.c')) + softmmu_virtio_ss.add(files('vhost-user-device.c')) endif if have_vhost_vdpa specific_virtio_ss.add(files('vhost-vdpa.c', 'vhost-shadow-virtqueue.c')) From patchwork Fri Apr 14 16:04:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 673133 Delivered-To: patch@linaro.org Received: by 2002:adf:fcce:0:0:0:0:0 with SMTP id f14csp262339wrs; Fri, 14 Apr 2023 09:05:41 -0700 (PDT) X-Google-Smtp-Source: AKy350b3EpPtIy5M09oxgO4a7xQ/aZxmp9c16ER1KNgXUFGJ3HjmUgF4WAqJ1fXWKGJPBIc7ITdB X-Received: by 2002:a05:6214:e49:b0:56c:37a:58b2 with SMTP id o9-20020a0562140e4900b0056c037a58b2mr3905460qvc.15.1681488341368; Fri, 14 Apr 2023 09:05:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681488341; cv=none; d=google.com; s=arc-20160816; b=sq8hJw9uvGwdrcjdamSC7x/xtpVSO86Qwce2i8twNs95KMQ3vrXCljcQlzFtdsMHTM yUXaqsxcNhaMO4WEyfFoPbBgTu1h9C98lIrKjWygGT89OXT8VfGE+eo7SVpwA7oqiWZC 8qcFIuVXvcue845UbEoBgorVqDdgSFo5K571Hne9DN+uFqHWM2fGEXz55saYVmzlvX2n /l7HlcgReRx7nBgCZcgN1Fo5YtNfdZQm1Fr27fYujmTCeR98AFVhsJlaTpPTt6F8J+vr Q+OEbnWKOx9CIjyqMZcgz+UZ5vAEE/HWfuqZzGVBn30rsvSbVDisWD6PwX8bwG8kAs7v wh6Q== 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=qzkS2+7HizjSf39YyqA8Cq2rMvvTCIuBSsfqveXGmXY=; b=AAhtxdVqEcD70GglwOiiFQWrFyQDQAH8CtTnQx1U6NmH4Cb7g5RlARPzPF3Y/OB71o aZ0nWsOKiXFjZLxN0UoRzNd5kB7KnF7N4wOYGSzSd8qHlFeCvLEer5Uw7aePcNUg+9Yt mkfUriTxOpYIjWlpEG8tUjlJWkrDqKPq53BoLjUTW3QCUstTSNGuvaYUGMBGz4BrDD9V GHAhplasZ+2vDaqjUFWwF5J7/3Yd3X0D/r9yo2mSz2QuXZN1L8l3tMeyPZ07XxVNEqVo vQDJPrYClfe9qQqAnitXhYa/5sjwpiYJUCgp9sIFGtNKYY+Vp0O+4n5mhVIuaPYsTOxy 4Waw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oQki8JcC; 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 t22-20020a05620a451600b00745657d6a58si3048649qkp.37.2023.04.14.09.05.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Apr 2023 09:05:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oQki8JcC; 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 1pnLv2-0006h4-Jn; Fri, 14 Apr 2023 12:05:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnLul-0006SG-Ah for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:47 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pnLui-0007zV-L1 for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:43 -0400 Received: by mail-wr1-x435.google.com with SMTP id v6so18017484wrv.8 for ; Fri, 14 Apr 2023 09:04:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681488279; x=1684080279; 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=qzkS2+7HizjSf39YyqA8Cq2rMvvTCIuBSsfqveXGmXY=; b=oQki8JcCOBUDtxvcJydmEBkY0xGHK9Li0fWLu09OdcGLn/8/v105xW8W85N/lzoP7e aERWlwhD6ZoSOONni39zElEg3RM8o1w2rB8xzsYSGulSfCwSlJeACwdvvMHZURW6fF29 qzxcOOyPgNbLR2AELKGqAyDdL39d7FRgV8WBznDT7njOrlBu6vsFkUVPrfoeMp4fnTCk 9mij9WAJEFdNjNkV+/gO/ahfI/SSVohQtBZUuUY0kDg1jLxlpiwF57M52OYnY9eAXv40 Hy0/DbP0tLZ6/vHfilDyGeSEXqmgsn8hEU7mxV+TXVkNxlxO0+rSL35Zrt3NsKHQxgTb 0JrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681488279; x=1684080279; 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=qzkS2+7HizjSf39YyqA8Cq2rMvvTCIuBSsfqveXGmXY=; b=Ihprbsh7NiyHdMIIaFtxWpUyD9eUQyfPGRVdb8T7S/yZBWH/5nhbzKVRXiHS8xp/Xt UpSKcUn2rl0JAaRZ9X8l2DY6+i6pGV0j+JttP5lIBxwVc2bX3UYZlCoYfoVJlub4x5W5 EoOf22aRdN4TJTcZWfVMGIhfj5wH3roOHbQ2zK2agV08NNdiLkut0l646AKuhYiRIsWu 2/venQ1A7Y3wgeDt1R71vgj43F0LE7f4p88i4Mbgt34qL48tiGkL9vCvzB2e6Ks8gnfk bGb/gH6ac49Et7Q69mq/B15fSij5kwlOyR/cv8uhtS3KF4WX4QKyBZ5jWubgyWfLaF/T vl2Q== X-Gm-Message-State: AAQBX9dj5Ii/wtw8HVimCQhPAjHGGgw4ME/rECk/JP7f3y8KXYkg/iDs 7cFsdjMp9loVkpwWS2E3LT732w== X-Received: by 2002:a05:6000:1818:b0:2f5:4b0b:a323 with SMTP id m24-20020a056000181800b002f54b0ba323mr4631230wrh.7.1681488278774; Fri, 14 Apr 2023 09:04:38 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id y18-20020adff6d2000000b002daf0b52598sm3865268wrp.18.2023.04.14.09.04.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 09:04:36 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 7DC7E1FFBE; Fri, 14 Apr 2023 17:04:34 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Paolo Bonzini , "Michael S. Tsirkin" , virtio-fs@redhat.com, Erik Schilling , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Eduardo Habkost , Stefan Hajnoczi , Eric Blake , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Jason Wang , Viresh Kumar , Mathieu Poirier , Gerd Hoffmann , Markus Armbruster Subject: [PATCH 06/12] virtio: add PCI stub for vhost-user-device Date: Fri, 14 Apr 2023 17:04:27 +0100 Message-Id: <20230414160433.2096866-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414160433.2096866-1-alex.bennee@linaro.org> References: <20230414160433.2096866-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This is all pretty much boilerplate. Signed-off-by: Alex Bennée Tested-by: Erik Schilling --- hw/virtio/vhost-user-device-pci.c | 71 +++++++++++++++++++++++++++++++ hw/virtio/meson.build | 1 + 2 files changed, 72 insertions(+) create mode 100644 hw/virtio/vhost-user-device-pci.c diff --git a/hw/virtio/vhost-user-device-pci.c b/hw/virtio/vhost-user-device-pci.c new file mode 100644 index 0000000000..96bf99d5fd --- /dev/null +++ b/hw/virtio/vhost-user-device-pci.c @@ -0,0 +1,71 @@ +/* + * Vhost-user generic virtio device PCI glue + * + * Copyright (c) 2023 Linaro Ltd + * Author: Alex Bennée + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "hw/qdev-properties.h" +#include "hw/virtio/vhost-user-device.h" +#include "hw/virtio/virtio-pci.h" + +struct VHostUserDevicePCI { + VirtIOPCIProxy parent_obj; + VHostUserDevice vdev; +}; + +typedef struct VHostUserDevicePCI VHostUserDevicePCI; + +#define TYPE_VHOST_USER_DEVICE_PCI "vhost-user-device-pci-base" + +DECLARE_INSTANCE_CHECKER(VHostUserDevicePCI, + VHOST_USER_DEVICE_PCI, + TYPE_VHOST_USER_DEVICE_PCI) + +static void vhost_user_device_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) +{ + VHostUserDevicePCI *dev = VHOST_USER_DEVICE_PCI(vpci_dev); + DeviceState *vdev = DEVICE(&dev->vdev); + + vpci_dev->nvectors = 1; + qdev_realize(vdev, BUS(&vpci_dev->bus), errp); +} + +static void vhost_user_device_pci_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass); + PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass); + k->realize = vhost_user_device_pci_realize; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); + pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET; + pcidev_k->device_id = 0; /* Set by virtio-pci based on virtio id */ + pcidev_k->revision = 0x00; + pcidev_k->class_id = PCI_CLASS_COMMUNICATION_OTHER; +} + +static void vhost_user_device_pci_instance_init(Object *obj) +{ + VHostUserDevicePCI *dev = VHOST_USER_DEVICE_PCI(obj); + + virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), + TYPE_VHOST_USER_DEVICE); +} + +static const VirtioPCIDeviceTypeInfo vhost_user_device_pci_info = { + .base_name = TYPE_VHOST_USER_DEVICE_PCI, + .non_transitional_name = "vhost-user-device-pci", + .instance_size = sizeof(VHostUserDevicePCI), + .instance_init = vhost_user_device_pci_instance_init, + .class_init = vhost_user_device_pci_class_init, +}; + +static void vhost_user_device_pci_register(void) +{ + virtio_pci_types_register(&vhost_user_device_pci_info); +} + +type_init(vhost_user_device_pci_register); diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index 43e5fa3f7d..c0a86b94ae 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -13,6 +13,7 @@ if have_vhost # fixme - this really should be generic specific_virtio_ss.add(files('vhost-user.c')) softmmu_virtio_ss.add(files('vhost-user-device.c')) + softmmu_virtio_ss.add(when: 'CONFIG_VIRTIO_PCI', if_true: files('vhost-user-device-pci.c')) endif if have_vhost_vdpa specific_virtio_ss.add(files('vhost-vdpa.c', 'vhost-shadow-virtqueue.c')) From patchwork Fri Apr 14 16:04:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 673144 Delivered-To: patch@linaro.org Received: by 2002:adf:fcce:0:0:0:0:0 with SMTP id f14csp264015wrs; Fri, 14 Apr 2023 09:08:20 -0700 (PDT) X-Google-Smtp-Source: AKy350bT7Vmi1WM3STZ/6PD5V19i72DD/RTYtQBNvy06wk13EnFZ0BUrvQqPoTXsUVDDdtYzeW+7 X-Received: by 2002:a05:6214:19ec:b0:5ea:9fc5:fca2 with SMTP id q12-20020a05621419ec00b005ea9fc5fca2mr4924413qvc.45.1681488500362; Fri, 14 Apr 2023 09:08:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681488500; cv=none; d=google.com; s=arc-20160816; b=vDwak50UsdqgNCCZHq4nLC0V9TlWBwYZvgk+pr5OLoNjBkfQOqvGS3D9oGrd5nCdQt zFsYGMpfh00x8uv2p3U/qmhHiZk4BkElUwKmWvhyr89ROLHyDTwX6HceV6Hovg6qOx9G ljaXyjLKjD8AvPHJWcT9FRgTpYyQNyBB5xIpdRSi10DPJuuy5HB6xP8vQSfqL19qmfeW L0ffDGbbazNQyzWvsRULeG+1VxiNGpVGEJT33VU6orLpjJYTomewBPqUT6XUmYWEI9TO RN6MztpdrGngA0KxEKAw91dgNTDhDEmgKcQ6ijO4MgKcE0F2vhFHpFIo5ErBaUMQKvZa FOCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nVPcgNqV4+yTyF7JyxZthOMz/9y/APO3HAlemN7QWn4=; b=iymhE/wHXL36OGk6vTjs2bovAseAlvB5aK6a7N7llUJ60TFXicf713TWgGLDQ4vPPU 6JGkGswujo6XPzuUI8J3uqa8osAOoz6iGwI+dX7vFGQWhEwDyw2f+c+x4mrb3NFNfK5l rGPvDouYvbBeM+A3xarE7ZV3dWkHy+IoJ7pUFHQgeHCoktx4V9x0kFZM5YZivKV8Df8w Sf1jyQII1AWfiMupLOuWDxL+t2PwQFWlKMD7B1bip1HCVg6uJm30r5bcKF7RP2+LTj2E KkuFX2osXE4zP1i9vmCyktvDuwujxMuKdkUO8vBGy5TSCb9BX5JmCvfZ9daBeAsgLD3I TnVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Km+2PWcc; 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 2-20020a0562140dc200b005a927154b59si2900932qvt.354.2023.04.14.09.08.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Apr 2023 09:08:20 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Km+2PWcc; 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 1pnLvN-0007sG-70; Fri, 14 Apr 2023 12:05:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnLuk-0006S0-79 for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:47 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pnLuh-0007zC-In for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:41 -0400 Received: by mail-wr1-x42b.google.com with SMTP id l18so17963535wrb.9 for ; Fri, 14 Apr 2023 09:04:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681488277; x=1684080277; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nVPcgNqV4+yTyF7JyxZthOMz/9y/APO3HAlemN7QWn4=; b=Km+2PWccfqrAl6iXS+0QxP9ByJ0556FYve9PXciZyQzU1CJJ8I8scFfQK8XXBmXy5v kxCP5k0lOtBtlyhcAQ6Ik/03qQ6RmDQ6uS/fJhi6djAoAwMq8iy9MjYzmVFdJPZwQIYs Bj+0/RjbcQyU3webm69fVm/HEFtLNKhM4/Tnrdw3QUNmsG/9SS6iGWE55Aa7SiqLAoqh 90DyjEPjRGMgXevBbAaVDpLPWg2yNa9I2RZRk3nqI6VTAuqjMVHRZqx4TD0ZJXVph8Am Jq1XAUITDjnI/vmRKZJwwha5MCRh7FIWCZ9u/LW5ZdTsL27nmqk208OjB6hTVp15RfWV ZSzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681488277; x=1684080277; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nVPcgNqV4+yTyF7JyxZthOMz/9y/APO3HAlemN7QWn4=; b=F7nJUW9Q52nuaZjp2tL+/3heWuzYlmRnsm2hi435ExjlC9fTOXnV2FVbOpMtuEx5l6 VD4ILVi7kvsGuBhAHN5XuLItNavQT4PGq0urN5bddtlP90uxhUdsR98c7Fv8tK29ni2e L9I+JgFoEf+n5d4rE0FlUJefI+j8hkAwCzuWRz3uXjB9wxH0A4pJW8IsvlDv5WXu4KVU +y0TMw5xwRdoaG0zIIrIGD570Rxbw+ikV1S3bHlDXsUlIbyOnGBlX9XPUfw8PBtzG4jf bG4gUUDsQ7yjYyN0JqP3FQRVqdXbKjGCIDV2t99u48xNX7C59zvokHSlQb990fa4uyM2 XopA== X-Gm-Message-State: AAQBX9epdK6Is+ZgaCF2Tw/rpjPOQzOd/wKG3zEaSEq245meOlBkESae z0oRt3jFbfFQd6AahxhC6Hd+yw== X-Received: by 2002:adf:e407:0:b0:2f4:cf53:c961 with SMTP id g7-20020adfe407000000b002f4cf53c961mr4436312wrm.54.1681488277718; Fri, 14 Apr 2023 09:04:37 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id q13-20020adfcd8d000000b002e51195a3e2sm3832381wrj.79.2023.04.14.09.04.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 09:04:36 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 94B431FFBF; Fri, 14 Apr 2023 17:04:34 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Paolo Bonzini , "Michael S. Tsirkin" , virtio-fs@redhat.com, Erik Schilling , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Eduardo Habkost , Stefan Hajnoczi , Eric Blake , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Jason Wang , Viresh Kumar , Mathieu Poirier , Gerd Hoffmann , Markus Armbruster Subject: [PATCH 07/12] include: attempt to document device_class_set_props Date: Fri, 14 Apr 2023 17:04:28 +0100 Message-Id: <20230414160433.2096866-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414160433.2096866-1-alex.bennee@linaro.org> References: <20230414160433.2096866-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org I'm still not sure how I achieve by use case of the parent class defining the following properties: static Property vud_properties[] = { DEFINE_PROP_CHR("chardev", VHostUserDevice, chardev), DEFINE_PROP_UINT16("id", VHostUserDevice, id, 0), DEFINE_PROP_UINT32("num_vqs", VHostUserDevice, num_vqs, 1), DEFINE_PROP_END_OF_LIST(), }; But for the specialisation of the class I want the id to default to the actual device id, e.g.: static Property vu_rng_properties[] = { DEFINE_PROP_UINT16("id", VHostUserDevice, id, VIRTIO_ID_RNG), DEFINE_PROP_UINT32("num_vqs", VHostUserDevice, num_vqs, 1), DEFINE_PROP_END_OF_LIST(), }; And so far the API for doing that isn't super clear. Signed-off-by: Alex Bennée --- include/hw/qdev-core.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index bd50ad5ee1..d4bbc30c92 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -776,6 +776,15 @@ BusState *sysbus_get_default(void); char *qdev_get_fw_dev_path(DeviceState *dev); char *qdev_get_own_fw_dev_path_from_handler(BusState *bus, DeviceState *dev); +/** + * device_class_set_props(): add a set of properties to an device + * @dc: the parent DeviceClass all devices inherit + * @props: an array of properties, terminate by DEFINE_PROP_END_OF_LIST() + * + * This will add a set of properties to the object. It will fault if + * you attempt to add an existing property defined by a parent class. + * To modify an inherited property you need to use???? + */ void device_class_set_props(DeviceClass *dc, Property *props); /** From patchwork Fri Apr 14 16:04:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 673134 Delivered-To: patch@linaro.org Received: by 2002:adf:fcce:0:0:0:0:0 with SMTP id f14csp262497wrs; Fri, 14 Apr 2023 09:05:54 -0700 (PDT) X-Google-Smtp-Source: AKy350ZH3zsu3GH/wvZqbFx6KV6SUicEHuhMxYL0mbbHlC6G/pdcOlOEiBGWp1udSYNKVVlKmK7W X-Received: by 2002:a05:622a:1a1a:b0:3bd:140c:91ed with SMTP id f26-20020a05622a1a1a00b003bd140c91edmr9521614qtb.52.1681488354198; Fri, 14 Apr 2023 09:05:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681488354; cv=none; d=google.com; s=arc-20160816; b=c3XKpzhTXiXO3mSPyLC1lTyfohvCw+fS0QMkUrT2jrbVajS0QK6yH2tpwW4yRGCu/2 4pzZLyWPptQ479CtsUsDT+oWoLG8XExWtMcj4tLW0DXNKwdUhNoLy4lptdX28WRIk/Gc 68iTtquzUgNb90IJA8Hh/g95qGvQVezv1u+8ODl5AQqiTxqr61OtXZN8Wz2bq9zuOYuQ sWDEyzVwM07EAVHtNjeJC4p8vmwYJkOnVDmv/szhXd9Xw1ksCzV62u8c+Bvod8opusKO DYGjuxO3lJE0Ew7snqMH53zpYcGdVh5U7dK+uneqBCAIk0I8JGj93aahgZ7nY6LGmzAr Bb/Q== 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=87Eys71a5bFDwpsmcqiXjalsGOMTQZkXpUaxljHCLjI=; b=ji3QMuJ/LJ7RbGmKIf/dKmsHDEYzZDEHjfV2++2IK73PYKERhWTbxXQGA6Qfyho0y+ 0ha1EBQhto3jgCCFDL7XSqXfymw2Z9qyKZV66kDrdodbVHKUp30WZF4Gg73iuS4adUTG tQXdpAolAUjdqw6S4iIwNWneXZ/H72a54LQeeOba7T/IoP32n9yw+07uNBYaIncBYI5v Of1Tzqxz1gKKJ0CcFu0fOvAzZXvT+NcgIfX3KsS4YlbBxUl09o0Td/axZSpNyJT3mhU6 IU4+I2mEzUn+mETk5ywLBmk93TnPsQ+Z1iluXja15GuJozDnNEe0xJJVyohanmcu7Hv9 SoNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Lkv7hQWd; 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 s7-20020a05620a29c700b00746a5623849si3067569qkp.463.2023.04.14.09.05.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Apr 2023 09:05:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Lkv7hQWd; 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 1pnLvB-0006qo-Fw; Fri, 14 Apr 2023 12:05:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnLuk-0006S3-Q2 for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:47 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pnLui-0007z7-Du for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:42 -0400 Received: by mail-wr1-x431.google.com with SMTP id r20so2227606wra.5 for ; Fri, 14 Apr 2023 09:04:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681488277; x=1684080277; 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=87Eys71a5bFDwpsmcqiXjalsGOMTQZkXpUaxljHCLjI=; b=Lkv7hQWdIlA2sElrxSUtHPNg4UUF+/pMmmAB5iBfBiSP6hz/+L1/iAytdkjdaALLr8 F1GVjHMQ99qOBDE23t2pXSpoFe0kUvHQBbNg7jPSYR/BVBtOo3hRjuhRfNcd88/luB9N rBpCIzB1Y9tY+p72b+QRHqRtXGJC+4USvPU9TqNQZbbwJEfMPD0ivv8p/sNwonnMdH76 2IrAaCqe7w7YVX8cHy543Q2idXIgyZZDDDlg6pxvpUQMMzbCmVhfle3Clmw7mYNcKfE5 ANOQFG9xHDCz5+tkO6hd9ozTrgmcX9boEez6MwSvCZt4YwKcXBMe3PgChfnO+LdSdwG/ YmMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681488277; x=1684080277; 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=87Eys71a5bFDwpsmcqiXjalsGOMTQZkXpUaxljHCLjI=; b=jpuUgpW3ZUSxFT5vC180nYckjg9G47WAOOQpsBsHvmGsyyP7Kndge6PXYLTkuO/nTC ZNQzULQww3/v7H3rghuz7AUUmYaSXXUOspcxj5A3ndI/Ld5A8G9JmsucMm7uygsa1sin HOyFXJbWejy7qa2IZP85FXjNAGM5V+6x6z/l1H/AzINLlByL6lnqAZI/xwaOCw2vH6f2 3jPqrXyg449rNVABSO6pxYi4JV9EzCXD6q4l8hVb2fSy3T+nCtZ7vgt5s52HmhpbExyf o7MQ+dGxfJhqJtdKhiqcxlJmVAq8WxLT7tX+RrVELSKviYG1kMAJQFYGiTqy/pHuUw2Z dfZA== X-Gm-Message-State: AAQBX9dSzAIMR/YfsiBCRWJ+K5JWkKxHth9Ytvm4NVWyU9PQsDKbOX0+ xqafG9bx+ayVgq+ALl65GVH9vA== X-Received: by 2002:a5d:6587:0:b0:2ce:a6f6:edca with SMTP id q7-20020a5d6587000000b002cea6f6edcamr4865810wru.55.1681488277527; Fri, 14 Apr 2023 09:04:37 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id g4-20020a5d5404000000b002efb121b75fsm3830886wrv.58.2023.04.14.09.04.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 09:04:36 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id BBB191FFB7; Fri, 14 Apr 2023 17:04:34 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Paolo Bonzini , "Michael S. Tsirkin" , virtio-fs@redhat.com, Erik Schilling , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Eduardo Habkost , Stefan Hajnoczi , Eric Blake , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Jason Wang , Viresh Kumar , Mathieu Poirier , Gerd Hoffmann , Markus Armbruster Subject: [PATCH 08/12] qom: allow for properties to become "fixed" Date: Fri, 14 Apr 2023 17:04:29 +0100 Message-Id: <20230414160433.2096866-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414160433.2096866-1-alex.bennee@linaro.org> References: <20230414160433.2096866-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x431.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 When specialising general purpose objects it is sometimes useful to "fix" some of the properties that were configurable by the base classes. We will use this facility when specialising vhost-user-device. Signed-off-by: Alex Bennée --- qapi/qom.json | 2 ++ include/qom/object.h | 16 +++++++++++++++- qom/object.c | 14 ++++++++++++++ qom/object_interfaces.c | 9 ++++++--- qom/qom-qmp-cmds.c | 1 + softmmu/qdev-monitor.c | 1 + 6 files changed, 39 insertions(+), 4 deletions(-) diff --git a/qapi/qom.json b/qapi/qom.json index a877b879b9..4cda191f00 100644 --- a/qapi/qom.json +++ b/qapi/qom.json @@ -33,12 +33,14 @@ # @description: if specified, the description of the property. # # @default-value: the default value, if any (since 5.0) +# @fixed: if specified if value has been fixed (since 8.1) # # Since: 1.2 ## { 'struct': 'ObjectPropertyInfo', 'data': { 'name': 'str', 'type': 'str', + 'fixed': 'bool', '*description': 'str', '*default-value': 'any' } } diff --git a/include/qom/object.h b/include/qom/object.h index ef7258a5e1..f18d1a8254 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -97,6 +97,8 @@ struct ObjectProperty ObjectPropertyInit *init; void *opaque; QObject *defval; + /** @fixed: if the property has been fixed at its default */ + bool fixed; }; /** @@ -1111,6 +1113,17 @@ void object_property_set_default_int(ObjectProperty *prop, int64_t value); */ void object_property_set_default_uint(ObjectProperty *prop, uint64_t value); +/** + * object_property_fix_default_uint: + * @prop: the property to be fixed + * @value: the fixed value to be written to the property + * + * When specialising an object it may make send to fix some values and + * not allow them to be changed. This can only be applied to + * properties that previously had a default and now cannot be changed. + */ +void object_property_fix_default_uint(ObjectProperty *prop, uint64_t value); + /** * object_property_find: * @obj: the object @@ -1961,13 +1974,14 @@ size_t object_type_get_instance_size(const char *typename); * object_property_help: * @name: the name of the property * @type: the type of the property + * @fixed: has the value been fixed * @defval: the default value * @description: description of the property * * Returns: a user-friendly formatted string describing the property * for help purposes. */ -char *object_property_help(const char *name, const char *type, +char *object_property_help(const char *name, const char *type, bool fixed, QObject *defval, const char *description); G_DEFINE_AUTOPTR_CLEANUP_FUNC(Object, object_unref) diff --git a/qom/object.c b/qom/object.c index e25f1e96db..b5aba3ffc8 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1584,6 +1584,20 @@ void object_property_set_default_uint(ObjectProperty *prop, uint64_t value) object_property_set_default(prop, QOBJECT(qnum_from_uint(value))); } +static void object_property_fix_default(ObjectProperty *prop, QObject *defval) +{ + g_assert(prop->init == object_property_init_defval); + g_assert(!prop->fixed); + + prop->defval = defval; + prop->fixed = true; +} + +void object_property_fix_default_uint(ObjectProperty *prop, uint64_t value) +{ + object_property_fix_default(prop, QOBJECT(qnum_from_uint(value))); +} + bool object_property_set_uint(Object *obj, const char *name, uint64_t value, Error **errp) { diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index 7d31589b04..e351938f8f 100644 --- a/qom/object_interfaces.c +++ b/qom/object_interfaces.c @@ -161,7 +161,7 @@ void user_creatable_add_qapi(ObjectOptions *options, Error **errp) visit_free(v); } -char *object_property_help(const char *name, const char *type, +char *object_property_help(const char *name, const char *type, bool fixed, QObject *defval, const char *description) { GString *str = g_string_new(NULL); @@ -179,7 +179,9 @@ char *object_property_help(const char *name, const char *type, if (defval) { g_autofree char *def_json = g_string_free(qobject_to_json(defval), false); - g_string_append_printf(str, " (default: %s)", def_json); + g_string_append_printf(str, " (%s: %s)", + fixed ? "fixed" : "default", + def_json); } return g_string_free(str, false); @@ -220,7 +222,8 @@ bool type_print_class_properties(const char *type) g_ptr_array_add(array, object_property_help(prop->name, prop->type, - prop->defval, prop->description)); + prop->fixed, prop->defval, + prop->description)); } g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0); if (array->len > 0) { diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c index 7c087299de..f4cdf4ddde 100644 --- a/qom/qom-qmp-cmds.c +++ b/qom/qom-qmp-cmds.c @@ -55,6 +55,7 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp) value->name = g_strdup(prop->name); value->type = g_strdup(prop->type); + value->fixed = prop->fixed; } return props; diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index b8d2c4dadd..b56b2af2f2 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -315,6 +315,7 @@ int qdev_device_help(QemuOpts *opts) g_ptr_array_add(array, object_property_help(prop->value->name, prop->value->type, + prop->value->fixed, prop->value->default_value, prop->value->description)); } From patchwork Fri Apr 14 16:04:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 673138 Delivered-To: patch@linaro.org Received: by 2002:adf:fcce:0:0:0:0:0 with SMTP id f14csp262731wrs; Fri, 14 Apr 2023 09:06:19 -0700 (PDT) X-Google-Smtp-Source: AKy350YSh7UQhCiMVtIcZD4RlK5zDrA2waJWNParCq0JR9GnXy4TCq/G/js57zA4KwyRX3EsNNC4 X-Received: by 2002:ad4:5969:0:b0:56e:a96b:a3a1 with SMTP id eq9-20020ad45969000000b0056ea96ba3a1mr4369801qvb.7.1681488379254; Fri, 14 Apr 2023 09:06:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681488379; cv=none; d=google.com; s=arc-20160816; b=xJO8rz8UT2AcLSeXSIu83Nk6faibx3Ps2zGsG/ZQeUon8Q+SaWxiGacS52+0BoustN KYb4FXennbHCOVToA/ePPaT9HyvSTkG8irgA5Vs5174sdv7M67XrgqtSDKpgDSfisFbR 6gQIHWOtYxrAqZ/qll56zQ9hsnh5IPw0Ey7imCqIVvvwMSBwvLUTW817g6hdkGZ2HSdw hwExJUjsdTYCGi+ERwDcgaMPFUEPpQpU9sBF/A4WBzn464KqOlNq1SqPksC9kknXl+M9 7jjhppqxZV6T1zFWUy09Ktpm9DemQZnb+rLIli0wuzQ8sT8zhIgpvvsi7XUivfNdu16C 5L/w== 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=ksXUcYDNEGnzuSF+MT7+XzXqFq6Xy1BiJwdlLWdbrp4=; b=CQWV6HQOJTf0ctyfFCa7Ugk3f2UKBf+G5fnWDqwWK/9IfDhZTHWoyHw96X+C/zfy30 e0+ry1B6SKuhuZhZqDh+DlPiG7JMihkp8R5t9A6Xno30Rt9JPc7hxeJFTTRhlpNRuhID cfJUnunvRtVHh7anZYWz9W8tPfmwJo4TyFFDopTvpRld57aEWW6jcAMpNnncrrL+LavT LBzbNeRVXlqTo4XNFE/kxxFgPPfNsfvpvc60ta81ZDRONE4jVLTXHJzJB3cmYLb+zlZR bpIGsS9blYZ4PW5MLBhfGLfy5DRTBVd0e4QpTxCLK6h6gginOADPp2UxKBVd4g3eVRU1 mp5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t6YSyIEz; 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 t15-20020a05622a01cf00b003e90a859914si2944607qtw.317.2023.04.14.09.06.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Apr 2023 09:06:19 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t6YSyIEz; 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 1pnLvJ-0007V6-GJ; Fri, 14 Apr 2023 12:05:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnLun-0006SM-Dw for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:49 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pnLuj-0007zd-2W for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:45 -0400 Received: by mail-wr1-x429.google.com with SMTP id j12so1775896wrd.2 for ; Fri, 14 Apr 2023 09:04:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681488279; x=1684080279; 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=ksXUcYDNEGnzuSF+MT7+XzXqFq6Xy1BiJwdlLWdbrp4=; b=t6YSyIEz8GhdIInpixE+F4RTmVYvtpLeHol0HJKKor/T4fR7NwHddwuhUsq8OhCVHu ZkrFHt4EQKXCRtMqeT5/tBSrwGyI5CZzq094NwOQHMokVtnxNQFaCwxFnmuMMTKJgpk3 A7tYghPUwjWOWFWkp8N723ys7rMJuWyDJiQX35rOrnEdvQTyC+WHES6/IZa159zcqnmr JYy0mE4HyjSEgqqMrjipe46gVp4qW/BVQzpsV+jSkHsbyKNwevcJEp0EsbF6OEuDwJxs BTVyy3T8U3FJzx7t8pK0eq7NOHfGFLtQbU7nFcOeyaQTK8v4iU6LD/eMnVbmJA7asAmc Jqlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681488279; x=1684080279; 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=ksXUcYDNEGnzuSF+MT7+XzXqFq6Xy1BiJwdlLWdbrp4=; b=XUwxFw5qR7PFDW2SsDntmiXU/uw2RLtIZCB8WkQ2ykoSY/kJ7GNZl0r57Vic2WJIYF u1O5j+cLpwrJ6jLUGyrQ8F9S7l27wxY+Hhd6bITN81gMsZ5Jj9SeALk5RQwWDhgubQhv M3mQiN3Fmi8GkRjSZ4Mmi3EbiWEKyk7iMKFpHTkB1jKk8/xl86zfKG5MfRNJKdIvrLp0 f7eORg3pvND6LRsqZuvIIZ+0QYJyjuYJK0OK49coTOAlwvIcDOp+W69r2ILJfgBwfbPI rO1HD5zTcuWv6rm7FZlOTxHsoBPcMhGqIbn/tdK0FlQpgGqYFp8luwJJiZ+z5wmIhhFN IOmw== X-Gm-Message-State: AAQBX9dGTQ3cuVE02W7RGNGIbgp/mFnt6PQaaNjKbnrlPzxAWRX4gScB cT9C3EQc2SQ1E2+gEGf0ahJJ7g== X-Received: by 2002:a5d:5908:0:b0:2f2:ad19:bddd with SMTP id v8-20020a5d5908000000b002f2ad19bdddmr4235792wrd.20.1681488279234; Fri, 14 Apr 2023 09:04:39 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id r17-20020a5d4e51000000b002f01e181c4asm3886389wrt.5.2023.04.14.09.04.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 09:04:36 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D7E941FFC0; Fri, 14 Apr 2023 17:04:34 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Paolo Bonzini , "Michael S. Tsirkin" , virtio-fs@redhat.com, Erik Schilling , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Eduardo Habkost , Stefan Hajnoczi , Eric Blake , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Jason Wang , Viresh Kumar , Mathieu Poirier , Gerd Hoffmann , Markus Armbruster Subject: [PATCH 09/12] hw/virtio: derive vhost-user-rng from vhost-user-device Date: Fri, 14 Apr 2023 17:04:30 +0100 Message-Id: <20230414160433.2096866-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414160433.2096866-1-alex.bennee@linaro.org> References: <20230414160433.2096866-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Now we can take advantage of our new base class and make vhost-user-rng a much simpler boilerplate wrapper. Signed-off-by: Alex Bennée --- include/hw/virtio/vhost-user-rng.h | 11 +- hw/virtio/vhost-user-rng.c | 264 +---------------------------- 2 files changed, 8 insertions(+), 267 deletions(-) diff --git a/include/hw/virtio/vhost-user-rng.h b/include/hw/virtio/vhost-user-rng.h index ddd9f01eea..5be2999498 100644 --- a/include/hw/virtio/vhost-user-rng.h +++ b/include/hw/virtio/vhost-user-rng.h @@ -12,21 +12,14 @@ #include "hw/virtio/virtio.h" #include "hw/virtio/vhost.h" #include "hw/virtio/vhost-user.h" -#include "chardev/char-fe.h" +#include "hw/virtio/vhost-user-device.h" #define TYPE_VHOST_USER_RNG "vhost-user-rng" OBJECT_DECLARE_SIMPLE_TYPE(VHostUserRNG, VHOST_USER_RNG) struct VHostUserRNG { /*< private >*/ - VirtIODevice parent; - CharBackend chardev; - struct vhost_virtqueue *vhost_vq; - struct vhost_dev vhost_dev; - VhostUserState vhost_user; - VirtQueue *req_vq; - bool connected; - + VHostUserDevice parent; /*< public >*/ }; diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c index efc54cd3fb..1f23442b81 100644 --- a/hw/virtio/vhost-user-rng.c +++ b/hw/virtio/vhost-user-rng.c @@ -3,7 +3,7 @@ * * Copyright (c) 2021 Mathieu Poirier * - * Implementation seriously tailored on vhost-user-i2c.c + * Simple wrapper of the generic vhost-user-device. * * SPDX-License-Identifier: GPL-2.0-or-later */ @@ -13,281 +13,29 @@ #include "hw/qdev-properties.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/vhost-user-rng.h" -#include "qemu/error-report.h" #include "standard-headers/linux/virtio_ids.h" -static const int feature_bits[] = { - VIRTIO_F_RING_RESET, - VHOST_INVALID_FEATURE_BIT -}; - -static void vu_rng_start(VirtIODevice *vdev) -{ - VHostUserRNG *rng = VHOST_USER_RNG(vdev); - BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); - VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); - int ret; - int i; - - if (!k->set_guest_notifiers) { - error_report("binding does not support guest notifiers"); - return; - } - - ret = vhost_dev_enable_notifiers(&rng->vhost_dev, vdev); - if (ret < 0) { - error_report("Error enabling host notifiers: %d", -ret); - return; - } - - ret = k->set_guest_notifiers(qbus->parent, rng->vhost_dev.nvqs, true); - if (ret < 0) { - error_report("Error binding guest notifier: %d", -ret); - goto err_host_notifiers; - } - - rng->vhost_dev.acked_features = vdev->guest_features; - ret = vhost_dev_start(&rng->vhost_dev, vdev, true); - if (ret < 0) { - error_report("Error starting vhost-user-rng: %d", -ret); - goto err_guest_notifiers; - } - - /* - * guest_notifier_mask/pending not used yet, so just unmask - * everything here. virtio-pci will do the right thing by - * enabling/disabling irqfd. - */ - for (i = 0; i < rng->vhost_dev.nvqs; i++) { - vhost_virtqueue_mask(&rng->vhost_dev, vdev, i, false); - } - - return; - -err_guest_notifiers: - k->set_guest_notifiers(qbus->parent, rng->vhost_dev.nvqs, false); -err_host_notifiers: - vhost_dev_disable_notifiers(&rng->vhost_dev, vdev); -} - -static void vu_rng_stop(VirtIODevice *vdev) -{ - VHostUserRNG *rng = VHOST_USER_RNG(vdev); - BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); - VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); - int ret; - - if (!k->set_guest_notifiers) { - return; - } - - vhost_dev_stop(&rng->vhost_dev, vdev, true); - - ret = k->set_guest_notifiers(qbus->parent, rng->vhost_dev.nvqs, false); - if (ret < 0) { - error_report("vhost guest notifier cleanup failed: %d", ret); - return; - } - - vhost_dev_disable_notifiers(&rng->vhost_dev, vdev); -} - -static void vu_rng_set_status(VirtIODevice *vdev, uint8_t status) -{ - VHostUserRNG *rng = VHOST_USER_RNG(vdev); - bool should_start = virtio_device_should_start(vdev, status); - - if (vhost_dev_is_started(&rng->vhost_dev) == should_start) { - return; - } - - if (should_start) { - vu_rng_start(vdev); - } else { - vu_rng_stop(vdev); - } -} - -static uint64_t vu_rng_get_features(VirtIODevice *vdev, - uint64_t requested_features, Error **errp) -{ - VHostUserRNG *rng = VHOST_USER_RNG(vdev); - - return vhost_get_features(&rng->vhost_dev, feature_bits, - requested_features); -} - -static void vu_rng_handle_output(VirtIODevice *vdev, VirtQueue *vq) -{ - /* - * Not normally called; it's the daemon that handles the queue; - * however virtio's cleanup path can call this. - */ -} - -static void vu_rng_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask) -{ - VHostUserRNG *rng = VHOST_USER_RNG(vdev); - - vhost_virtqueue_mask(&rng->vhost_dev, vdev, idx, mask); -} - -static bool vu_rng_guest_notifier_pending(VirtIODevice *vdev, int idx) -{ - VHostUserRNG *rng = VHOST_USER_RNG(vdev); - - return vhost_virtqueue_pending(&rng->vhost_dev, idx); -} - -static void vu_rng_connect(DeviceState *dev) -{ - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserRNG *rng = VHOST_USER_RNG(vdev); - - if (rng->connected) { - return; - } - - rng->connected = true; - - /* restore vhost state */ - if (virtio_device_started(vdev, vdev->status)) { - vu_rng_start(vdev); - } -} - -static void vu_rng_disconnect(DeviceState *dev) -{ - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserRNG *rng = VHOST_USER_RNG(vdev); - - if (!rng->connected) { - return; - } - - rng->connected = false; - - if (vhost_dev_is_started(&rng->vhost_dev)) { - vu_rng_stop(vdev); - } -} - -static void vu_rng_event(void *opaque, QEMUChrEvent event) -{ - DeviceState *dev = opaque; - - switch (event) { - case CHR_EVENT_OPENED: - vu_rng_connect(dev); - break; - case CHR_EVENT_CLOSED: - vu_rng_disconnect(dev); - break; - case CHR_EVENT_BREAK: - case CHR_EVENT_MUX_IN: - case CHR_EVENT_MUX_OUT: - /* Ignore */ - break; - } -} - -static void vu_rng_device_realize(DeviceState *dev, Error **errp) -{ - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserRNG *rng = VHOST_USER_RNG(dev); - int ret; - - if (!rng->chardev.chr) { - error_setg(errp, "missing chardev"); - return; - } - - if (!vhost_user_init(&rng->vhost_user, &rng->chardev, errp)) { - return; - } - - virtio_init(vdev, VIRTIO_ID_RNG, 0); - - rng->req_vq = virtio_add_queue(vdev, 4, vu_rng_handle_output); - if (!rng->req_vq) { - error_setg_errno(errp, -1, "virtio_add_queue() failed"); - goto virtio_add_queue_failed; - } - - rng->vhost_dev.nvqs = 1; - rng->vhost_dev.vqs = g_new0(struct vhost_virtqueue, rng->vhost_dev.nvqs); - ret = vhost_dev_init(&rng->vhost_dev, &rng->vhost_user, - VHOST_BACKEND_TYPE_USER, 0, errp); - if (ret < 0) { - error_setg_errno(errp, -ret, "vhost_dev_init() failed"); - goto vhost_dev_init_failed; - } - - qemu_chr_fe_set_handlers(&rng->chardev, NULL, NULL, vu_rng_event, NULL, - dev, NULL, true); - - return; - -vhost_dev_init_failed: - g_free(rng->vhost_dev.vqs); - virtio_delete_queue(rng->req_vq); -virtio_add_queue_failed: - virtio_cleanup(vdev); - vhost_user_cleanup(&rng->vhost_user); -} - -static void vu_rng_device_unrealize(DeviceState *dev) -{ - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserRNG *rng = VHOST_USER_RNG(dev); - struct vhost_virtqueue *vhost_vqs = rng->vhost_dev.vqs; - - vu_rng_set_status(vdev, 0); - - vhost_dev_cleanup(&rng->vhost_dev); - g_free(vhost_vqs); - virtio_delete_queue(rng->req_vq); - virtio_cleanup(vdev); - vhost_user_cleanup(&rng->vhost_user); -} - -static struct vhost_dev *vu_rng_get_vhost(VirtIODevice *vdev) -{ - VHostUserRNG *rng = VHOST_USER_RNG(vdev); - return &rng->vhost_dev; -} - static const VMStateDescription vu_rng_vmstate = { .name = "vhost-user-rng", .unmigratable = 1, }; -static Property vu_rng_properties[] = { - DEFINE_PROP_CHR("chardev", VHostUserRNG, chardev), - DEFINE_PROP_END_OF_LIST(), -}; - static void vu_rng_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); + ObjectProperty *op; - device_class_set_props(dc, vu_rng_properties); dc->vmsd = &vu_rng_vmstate; set_bit(DEVICE_CATEGORY_INPUT, dc->categories); - vdc->realize = vu_rng_device_realize; - vdc->unrealize = vu_rng_device_unrealize; - vdc->get_features = vu_rng_get_features; - vdc->set_status = vu_rng_set_status; - vdc->guest_notifier_mask = vu_rng_guest_notifier_mask; - vdc->guest_notifier_pending = vu_rng_guest_notifier_pending; - vdc->get_vhost = vu_rng_get_vhost; + op = object_class_property_find(klass, "virtio-id"); + g_assert(op); + object_property_fix_default_uint(op, VIRTIO_ID_RNG); } static const TypeInfo vu_rng_info = { .name = TYPE_VHOST_USER_RNG, - .parent = TYPE_VIRTIO_DEVICE, + .parent = TYPE_VHOST_USER_DEVICE, .instance_size = sizeof(VHostUserRNG), .class_init = vu_rng_class_init, }; From patchwork Fri Apr 14 16:04:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 673143 Delivered-To: patch@linaro.org Received: by 2002:adf:fcce:0:0:0:0:0 with SMTP id f14csp264007wrs; Fri, 14 Apr 2023 09:08:20 -0700 (PDT) X-Google-Smtp-Source: AKy350aQ0fJ5vH4+HvObPjeddXPRvjyYNx7Em7vgmocbaxzm6pDdoEOYuTMO4b64VyMPY9it8g3C X-Received: by 2002:a05:6214:408:b0:5e9:5602:3af0 with SMTP id z8-20020a056214040800b005e956023af0mr4879433qvx.46.1681488499912; Fri, 14 Apr 2023 09:08:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681488499; cv=none; d=google.com; s=arc-20160816; b=Bdpcbik2C+TPcZw1ZoPke4Jh1srk7hXzzOJidMY/pes1x6Jxp32BX7IN0/EYz+Aamv Zc0cZiLfz3RhHiyGuLJK8O/7D4FbFP5PszdunORoJzjzBEScjfLvZLssPc/zM65vlOKK n0ePhqByWvPoXfqJG23uIiBL/pIRKfOFZekaTBmzmO+Msgm5YDuto/xC157m22wkB6rc lJBdRKkSIU6C/fVsOR+S4vU2awbBBoGD26B1HpN3NTsC3UtC0XGpPJe1W/SfRtNxH4eE x2irkWolvctH0/mxwbAq1mCqo0Bm9tb2nCcnOqmgC1GppVqm7mdQTR5MPJJfi1aj/hzh AUtA== 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=8LanDirQaSq5LBuEyiFieoGUbbdGI81Zqz66tepS9FQ=; b=a906R08DQkxx6LpbkC55kymQHtnVWwPNzljJLakcABhgewOd82Wt/PPR6flHZkYgxX oAIPL1U4Z2cZZuMG2d5UgJwx1CJOMjRBFX+ooiMgWYQ/Lqp2DpHud8/2izujvOA8UJRq qz7PNV2hl0ebfANMFVUbFwjLtTyW9SzRB24Va9TOpwJfaf0ogrnSB6phF65nqLv1dW/N O7fD1p/Cl6OmGs8hCl5lh4P5/OZdb8L94txUNfeFrHj5BmIrtnxttF5WjEFiv/6QrIQ4 ECfIkr9pi7rv2Q9B8ScgVkZ+FssF7tMKGhwaUdVuOWuazi8hL/oITNEqd0lL/3YDARRa sWyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U+LgH173; 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 jk2-20020ad45d42000000b0056eb019cf92si2958527qvb.118.2023.04.14.09.08.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Apr 2023 09:08:19 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U+LgH173; 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 1pnLvN-0007sF-6r; Fri, 14 Apr 2023 12:05:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnLul-0006SH-K9 for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:47 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pnLui-0007zc-Ln for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:43 -0400 Received: by mail-wm1-x329.google.com with SMTP id k27-20020a05600c1c9b00b003f0a9f022beso2257194wms.1 for ; Fri, 14 Apr 2023 09:04:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681488279; x=1684080279; 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=8LanDirQaSq5LBuEyiFieoGUbbdGI81Zqz66tepS9FQ=; b=U+LgH173VoEnClmk7N0zz0J0Rbd4X7uGJOV6cb1+Vm9EpXFm77MJQJOHdsXWn5tQa6 RzHZyoSBqWlab3YUwF42OKbMZ/hcISl09QhqYXX8+OOT4TdzQ8y7lFnLeFfU3SXSG07S sqxYetcbQknkip75ZkqNrPqtOvFUuhBxn+4PxmAaUOw1nx53VG+QKQN6RfkqLzIHFXDN mlRm5NAOoa8fFcM9ttDD0kw2hI/W9+qpw7hNvTM+JCOVjw0iyawvPgAYTqATjS4LvGNB x2aJ0o20sJKrycdLO5aMw1PP2PgN+ypmh5D2RAdDudGPHMbBYtvnHBCk0pF3mL4Z0wwB 8T+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681488279; x=1684080279; 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=8LanDirQaSq5LBuEyiFieoGUbbdGI81Zqz66tepS9FQ=; b=Kh46m9qiJ/ObR6gOyxN5RjU+YakMRimROd1TL3x/ivmOdegI2wMKPf6TJHT5s/aZXk nBxsgez3JEjZEzHylnwxbG6SQXVuPHtdJ8eTQRyBrKsEWqxt1oaEaNuH1ooTMZIFCCFu bBGbZNmmPMxhAugF33UH87DO7ide/eCOqY9ld8fNfMgUs+V+mFbs92Yzzd3DnSFsAgHX iIc55k+CHay+zXWXfncK8WcC6PGvo3cEYY54AkA1BlRVvfS5z8PJUfRnl0rOlbsEX7pO /pO8XzrMNfvChueVxwo3+IzE/JvvBgm2vAfn9pM99derQbRofPfEtWsi0LmXt6eM9aUz 20mA== X-Gm-Message-State: AAQBX9cI2iP1JFi2N4Fs7PrXvEZR6YKjjncNNM5NxgY4rQXKA2GqFl5R pkWx4C/flC2rjCvwFWyAOpbOUw== X-Received: by 2002:a1c:4c1a:0:b0:3f0:a9e5:3ae with SMTP id z26-20020a1c4c1a000000b003f0a9e503aemr4732344wmf.24.1681488279014; Fri, 14 Apr 2023 09:04:39 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id x2-20020a05600c21c200b003f149715cb6sm1067151wmj.10.2023.04.14.09.04.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 09:04:36 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id F2B881FFB8; Fri, 14 Apr 2023 17:04:34 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Paolo Bonzini , "Michael S. Tsirkin" , virtio-fs@redhat.com, Erik Schilling , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Eduardo Habkost , Stefan Hajnoczi , Eric Blake , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Jason Wang , Viresh Kumar , Mathieu Poirier , Gerd Hoffmann , Markus Armbruster Subject: [PATCH 10/12] hw/virtio: add config support to vhost-user-device Date: Fri, 14 Apr 2023 17:04:31 +0100 Message-Id: <20230414160433.2096866-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414160433.2096866-1-alex.bennee@linaro.org> References: <20230414160433.2096866-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org To use the generic device the user will need to provide the config region size via the command line. We also add a notifier so the guest can be pinged if the remote daemon updates the config. With these changes: -device vhost-user-device-pci,virtio-id=41,num_vqs=2,config_size=8 is equivalent to: -device vhost-user-gpio-pci Signed-off-by: Alex Bennée --- include/hw/virtio/vhost-user-device.h | 1 + hw/virtio/vhost-user-device.c | 58 ++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/include/hw/virtio/vhost-user-device.h b/include/hw/virtio/vhost-user-device.h index 8d77f06721..cb98e0dcaa 100644 --- a/include/hw/virtio/vhost-user-device.h +++ b/include/hw/virtio/vhost-user-device.h @@ -21,6 +21,7 @@ struct VHostUserDevice { CharBackend chardev; uint16_t virtio_id; uint32_t num_vqs; + uint32_t config_size; /* State tracking */ VhostUserState vhost_user; struct vhost_virtqueue *vhost_vq; diff --git a/hw/virtio/vhost-user-device.c b/hw/virtio/vhost-user-device.c index bfbf3b29cb..977cfed247 100644 --- a/hw/virtio/vhost-user-device.c +++ b/hw/virtio/vhost-user-device.c @@ -117,6 +117,42 @@ static uint64_t vud_get_features(VirtIODevice *vdev, return vud->vhost_dev.features & ~(1ULL << VHOST_USER_F_PROTOCOL_FEATURES); } +/* + * To handle VirtIO config we need to know the size of the config + * space. We don't cache the config but re-fetch it from the guest + * every time in case something has changed. + */ +static void vud_get_config(VirtIODevice *vdev, uint8_t *config) +{ + VHostUserDevice *vud = VHOST_USER_DEVICE(vdev); + Error *local_err = NULL; + + /* + * There will have been a warning during vhost_dev_init, but lets + * assert here as nothing will go right now. + */ + g_assert(vud->config_size && vud->vhost_user.supports_config == true); + + if (vhost_dev_get_config(&vud->vhost_dev, config, + vud->config_size, &local_err)) { + error_report_err(local_err); + } +} + +/* + * When the daemon signals an update to the config we just need to + * signal the guest as we re-read the config on demand above. + */ +static int vud_config_notifier(struct vhost_dev *dev) +{ + virtio_notify_config(dev->vdev); + return 0; +} + +const VhostDevConfigOps vud_config_ops = { + .vhost_dev_config_notifier = vud_config_notifier, +}; + static void vud_handle_output(VirtIODevice *vdev, VirtQueue *vq) { /* @@ -141,12 +177,21 @@ static int vud_connect(DeviceState *dev) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); VHostUserDevice *vud = VHOST_USER_DEVICE(vdev); + struct vhost_dev *vhost_dev = &vud->vhost_dev; if (vud->connected) { return 0; } vud->connected = true; + /* + * If we support VHOST_USER_GET_CONFIG we must enable the notifier + * so we can ping the guest when it updates. + */ + if (vud->vhost_user.supports_config) { + vhost_dev_set_config_notifier(vhost_dev, &vud_config_ops); + } + /* restore vhost state */ if (virtio_device_started(vdev, vdev->status)) { vud_start(vdev); @@ -214,11 +259,20 @@ static void vud_device_realize(DeviceState *dev, Error **errp) vud->num_vqs = 1; /* reasonable default? */ } + /* + * We can't handle config requests unless we know the size of the + * config region, specialisations of the vhost-user-device will be + * able to set this. + */ + if (vud->config_size) { + vud->vhost_user.supports_config = true; + } + if (!vhost_user_init(&vud->vhost_user, &vud->chardev, errp)) { return; } - virtio_init(vdev, vud->virtio_id, 0); + virtio_init(vdev, vud->virtio_id, vud->config_size); /* * Disable guest notifiers, by default all notifications will be via the @@ -271,6 +325,7 @@ static Property vud_properties[] = { DEFINE_PROP_CHR("chardev", VHostUserDevice, chardev), DEFINE_PROP_UINT16("virtio-id", VHostUserDevice, virtio_id, 0), DEFINE_PROP_UINT32("num_vqs", VHostUserDevice, num_vqs, 1), + DEFINE_PROP_UINT32("config_size", VHostUserDevice, config_size, 0), DEFINE_PROP_END_OF_LIST(), }; @@ -285,6 +340,7 @@ static void vud_class_init(ObjectClass *klass, void *data) vdc->realize = vud_device_realize; vdc->unrealize = vud_device_unrealize; vdc->get_features = vud_get_features; + vdc->get_config = vud_get_config; vdc->set_status = vud_set_status; } From patchwork Fri Apr 14 16:04:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 673135 Delivered-To: patch@linaro.org Received: by 2002:adf:fcce:0:0:0:0:0 with SMTP id f14csp262603wrs; Fri, 14 Apr 2023 09:06:02 -0700 (PDT) X-Google-Smtp-Source: AKy350Z24fcL1ZhxzHBZJgWssPArNz/twj7/BHpmf0PXAXSoC5NTZDK2GJJlG9FrgfqoBLtb3Acw X-Received: by 2002:a05:6214:2685:b0:5b4:ccc0:4f60 with SMTP id gm5-20020a056214268500b005b4ccc04f60mr4647662qvb.37.1681488362654; Fri, 14 Apr 2023 09:06:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681488362; cv=none; d=google.com; s=arc-20160816; b=TQ3s1anOgdXnV9J9+ofs6kRH4901s8h+L1DBRCRCAIhcl0eRQ6WyUomPjKJqBy1vGu 3c56XZN7liMoZ8DIDDj5xCpD1Ih8AjzonvxpwTuU25S0f0s9vIObvBBduXoVCGppWB/g JtD6G7Uh1Xw0AHOr+ClSOQbDxTRF/DV7oSxpRGfAxLglpmG98ZSz3MffqxbrhZXJMV2L uXTgtYKaOfHTb+Zbk8yy3Eu+RJqMRNkDJUdBg16qbeqN60pCFyckxAv0mBpxNZ9PX4Gx cWhn29+qa3SgphtdksanXRdKgzPpdLKo9slye9dOpUY4xnZhneiwKeoBtLi8gR2wW2ZQ 2udA== 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=4Ryfe6WB+la5kXKs32EYl/Vciz9ABPkj0uG+7/D/vdw=; b=K+3JdgoS2gRK0LrAULsvP0FhFtcnKiYIe4FeNJ7aJHjDwTz7l0FcWGdv56HYyaGeNl fkFDtc5lSw/uDSsZF8AB5tP97UOIwBef/XJRhdXDDKhjB2xyXw3z3IFxcsri0ut/tUHo O5tFsbHyNFdR1Ay/kF1Hl0oR36ZTh2atFaD1O+2rOss0ONVXq+gz/YcClcauUEjH6NOo zz+8CIRhnc4fqRE0pUc2BUQDm/UdIuPXwwlQqwcUSbRw3mVpVs5kfjttLVRna2lMhAa5 OXM5JFyMYYYW2PlbulODM2AFqvXAqQgaOde/wM3hweX4zmihmi5L3Zymeic2o1/G6rCZ 0xOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cIlExdGR; 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 g10-20020a0562141cca00b005eee9ede7e0si2714535qvd.95.2023.04.14.09.06.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Apr 2023 09:06:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cIlExdGR; 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 1pnLvJ-0007V5-G5; Fri, 14 Apr 2023 12:05:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnLun-0006Sk-KV for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:49 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pnLuj-00080K-VP for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:45 -0400 Received: by mail-wr1-x431.google.com with SMTP id s2so14759625wra.7 for ; Fri, 14 Apr 2023 09:04:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681488280; x=1684080280; 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=4Ryfe6WB+la5kXKs32EYl/Vciz9ABPkj0uG+7/D/vdw=; b=cIlExdGROySEk88B2tfqCGjQ/TsXCmyeL+AI5l+xTV5zYgHcP18HD77bdsFlJws1Z5 /1y+oaZGVgHfr0Pob9gIg0yzrYFc4JLbOxfFbNqm2ud9fQui7ldGQMwp20+w+tUojymX n6lrOg21PHSNxQA7SCuHnjBwfewvg4T2wwuiVoTD75TWh5d5jZUXsns2vB92gXcDYEWD E7zeQA7ridQlZcnhcTD1gCLSGYlko6YXVaWVB6YDvcZcbzz0tcrO/CK15BX68qvr/tKK IBQbPE1uV1mELnQlhhmsteGTCV4x9reuALpA3ioVT61EfZa1asPtdQC+zyzp48bAXLOR PIxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681488280; x=1684080280; 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=4Ryfe6WB+la5kXKs32EYl/Vciz9ABPkj0uG+7/D/vdw=; b=GdlZBWH9T9dmYs0sTlO8ooPMI+KClCtycC93bfG0nt6ExpzKC0ZwD8NsgMoj9NasZr 2tFLCJt88wS33zUHRHOGaieKYwo1TM67YIvB9TmzK+rO+OfBbb5YcNDVljHTeq4ZP7Dz g20w4uwFPX73ZtNHIiYPkU3xLBausUr6V03BW58gPx4D3UawFW3k+0ZZXI3+fsV1lGmu VrAY45oRe6iS5fYiFRMaPM/RNbZNxpvN135U/aXh9KiDZacvkQ0xP8xByNqbbTc1DERo KlSOt1RvujjDPSR6SJN1XVeRf6wOfA6tPYGUNKin3NLlWkVv7RJj+vRcXsjZaIOz/8BJ Pr3A== X-Gm-Message-State: AAQBX9eI356LBuvxd1T9HD886EnGwBUNoh3726cIblHS0tdVPeeox+/o THBXsdJgKiW+pNmNB8GDgPubEg== X-Received: by 2002:a05:6000:18cd:b0:2f7:2b68:1fbe with SMTP id w13-20020a05600018cd00b002f72b681fbemr1969217wrq.6.1681488280336; Fri, 14 Apr 2023 09:04:40 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id t1-20020a1c7701000000b003ede06f3178sm4579281wmi.31.2023.04.14.09.04.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 09:04:39 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 1B7011FFC1; Fri, 14 Apr 2023 17:04:35 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Paolo Bonzini , "Michael S. Tsirkin" , virtio-fs@redhat.com, Erik Schilling , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Eduardo Habkost , Stefan Hajnoczi , Eric Blake , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Jason Wang , Viresh Kumar , Mathieu Poirier , Gerd Hoffmann , Markus Armbruster Subject: [PATCH 11/12] hw/virtio: derive vhost-user-gpio from vhost-user-device (!BROKEN) Date: Fri, 14 Apr 2023 17:04:32 +0100 Message-Id: <20230414160433.2096866-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414160433.2096866-1-alex.bennee@linaro.org> References: <20230414160433.2096866-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Now we can take advantage of our new base class and make vhost-user-gpio a much simpler boilerplate wrapper. [AJB - and this breaks because of the class init propery hack leading to the config getting overriden and firing the assert. I need a clean QOM way to do this derived class] Signed-off-by: Alex Bennée --- include/hw/virtio/vhost-user-gpio.h | 23 +- hw/virtio/vhost-user-gpio.c | 405 ++-------------------------- 2 files changed, 17 insertions(+), 411 deletions(-) diff --git a/include/hw/virtio/vhost-user-gpio.h b/include/hw/virtio/vhost-user-gpio.h index a9d3f9b049..82a2e36c21 100644 --- a/include/hw/virtio/vhost-user-gpio.h +++ b/include/hw/virtio/vhost-user-gpio.h @@ -12,33 +12,14 @@ #include "hw/virtio/virtio.h" #include "hw/virtio/vhost.h" #include "hw/virtio/vhost-user.h" -#include "standard-headers/linux/virtio_gpio.h" -#include "chardev/char-fe.h" +#include "hw/virtio/vhost-user-device.h" #define TYPE_VHOST_USER_GPIO "vhost-user-gpio-device" OBJECT_DECLARE_SIMPLE_TYPE(VHostUserGPIO, VHOST_USER_GPIO); struct VHostUserGPIO { /*< private >*/ - VirtIODevice parent_obj; - CharBackend chardev; - struct virtio_gpio_config config; - struct vhost_virtqueue *vhost_vqs; - struct vhost_dev vhost_dev; - VhostUserState vhost_user; - VirtQueue *command_vq; - VirtQueue *interrupt_vq; - /** - * There are at least two steps of initialization of the - * vhost-user device. The first is a "connect" step and - * second is a "start" step. Make a separation between - * those initialization phases by using two fields. - * - * @connected: see vu_gpio_connect()/vu_gpio_disconnect() - * @started_vu: see vu_gpio_start()/vu_gpio_stop() - */ - bool connected; - bool started_vu; + VHostUserDevice parent; /*< public >*/ }; diff --git a/hw/virtio/vhost-user-gpio.c b/hw/virtio/vhost-user-gpio.c index 3b013f2d0f..c76af1fc69 100644 --- a/hw/virtio/vhost-user-gpio.c +++ b/hw/virtio/vhost-user-gpio.c @@ -11,413 +11,38 @@ #include "hw/qdev-properties.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/vhost-user-gpio.h" -#include "qemu/error-report.h" #include "standard-headers/linux/virtio_ids.h" -#include "trace.h" - -#define REALIZE_CONNECTION_RETRIES 3 -#define VHOST_NVQS 2 - -/* Features required from VirtIO */ -static const int feature_bits[] = { - VIRTIO_F_VERSION_1, - VIRTIO_F_NOTIFY_ON_EMPTY, - VIRTIO_RING_F_INDIRECT_DESC, - VIRTIO_RING_F_EVENT_IDX, - VIRTIO_GPIO_F_IRQ, - VIRTIO_F_RING_RESET, - VHOST_INVALID_FEATURE_BIT -}; - -static void vu_gpio_get_config(VirtIODevice *vdev, uint8_t *config) -{ - VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); - - memcpy(config, &gpio->config, sizeof(gpio->config)); -} - -static int vu_gpio_config_notifier(struct vhost_dev *dev) -{ - VHostUserGPIO *gpio = VHOST_USER_GPIO(dev->vdev); - - memcpy(dev->vdev->config, &gpio->config, sizeof(gpio->config)); - virtio_notify_config(dev->vdev); - - return 0; -} - -const VhostDevConfigOps gpio_ops = { - .vhost_dev_config_notifier = vu_gpio_config_notifier, -}; - -static int vu_gpio_start(VirtIODevice *vdev) -{ - BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); - VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); - VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); - struct vhost_dev *vhost_dev = &gpio->vhost_dev; - int ret, i; - - if (!k->set_guest_notifiers) { - error_report("binding does not support guest notifiers"); - return -ENOSYS; - } - - ret = vhost_dev_enable_notifiers(vhost_dev, vdev); - if (ret < 0) { - error_report("Error enabling host notifiers: %d", ret); - return ret; - } - - ret = k->set_guest_notifiers(qbus->parent, vhost_dev->nvqs, true); - if (ret < 0) { - error_report("Error binding guest notifier: %d", ret); - goto err_host_notifiers; - } - - /* - * Before we start up we need to ensure we have the final feature - * set needed for the vhost configuration. The backend may also - * apply backend_features when the feature set is sent. - */ - vhost_ack_features(&gpio->vhost_dev, feature_bits, vdev->guest_features); - - ret = vhost_dev_start(&gpio->vhost_dev, vdev, false); - if (ret < 0) { - error_report("Error starting vhost-user-gpio: %d", ret); - goto err_guest_notifiers; - } - gpio->started_vu = true; - - /* - * guest_notifier_mask/pending not used yet, so just unmask - * everything here. virtio-pci will do the right thing by - * enabling/disabling irqfd. - */ - for (i = 0; i < gpio->vhost_dev.nvqs; i++) { - vhost_virtqueue_mask(&gpio->vhost_dev, vdev, i, false); - } - - /* - * As we must have VHOST_USER_F_PROTOCOL_FEATURES (because - * VHOST_USER_GET_CONFIG requires it) we need to explicitly enable - * the vrings. - */ - g_assert(vhost_dev->vhost_ops && - vhost_dev->vhost_ops->vhost_set_vring_enable); - ret = vhost_dev->vhost_ops->vhost_set_vring_enable(vhost_dev, true); - if (ret == 0) { - return 0; - } - - error_report("Failed to start vrings for vhost-user-gpio: %d", ret); - -err_guest_notifiers: - k->set_guest_notifiers(qbus->parent, gpio->vhost_dev.nvqs, false); -err_host_notifiers: - vhost_dev_disable_notifiers(&gpio->vhost_dev, vdev); - - return ret; -} - -static void vu_gpio_stop(VirtIODevice *vdev) -{ - VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); - BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); - VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); - struct vhost_dev *vhost_dev = &gpio->vhost_dev; - int ret; - - if (!gpio->started_vu) { - return; - } - gpio->started_vu = false; - - if (!k->set_guest_notifiers) { - return; - } - - vhost_dev_stop(vhost_dev, vdev, false); - - ret = k->set_guest_notifiers(qbus->parent, vhost_dev->nvqs, false); - if (ret < 0) { - error_report("vhost guest notifier cleanup failed: %d", ret); - return; - } - - vhost_dev_disable_notifiers(vhost_dev, vdev); -} - -static void vu_gpio_set_status(VirtIODevice *vdev, uint8_t status) -{ - VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); - bool should_start = virtio_device_should_start(vdev, status); - - trace_virtio_gpio_set_status(status); - - if (!gpio->connected) { - return; - } - - if (vhost_dev_is_started(&gpio->vhost_dev) == should_start) { - return; - } - - if (should_start) { - if (vu_gpio_start(vdev)) { - qemu_chr_fe_disconnect(&gpio->chardev); - } - } else { - vu_gpio_stop(vdev); - } -} - -static uint64_t vu_gpio_get_features(VirtIODevice *vdev, uint64_t features, - Error **errp) -{ - VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); - - return vhost_get_features(&gpio->vhost_dev, feature_bits, features); -} - -static void vu_gpio_handle_output(VirtIODevice *vdev, VirtQueue *vq) -{ - /* - * Not normally called; it's the daemon that handles the queue; - * however virtio's cleanup path can call this. - */ -} - -static void vu_gpio_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask) -{ - VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); - - /* - * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the macro of configure interrupt's IDX, If this driver does not - * support, the function will return - */ - - if (idx == VIRTIO_CONFIG_IRQ_IDX) { - return; - } - - vhost_virtqueue_mask(&gpio->vhost_dev, vdev, idx, mask); -} - -static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserGPIO *gpio) -{ - virtio_delete_queue(gpio->command_vq); - virtio_delete_queue(gpio->interrupt_vq); - g_free(gpio->vhost_vqs); - virtio_cleanup(vdev); - vhost_user_cleanup(&gpio->vhost_user); -} - -static int vu_gpio_connect(DeviceState *dev, Error **errp) -{ - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); - struct vhost_dev *vhost_dev = &gpio->vhost_dev; - int ret; - - if (gpio->connected) { - return 0; - } - gpio->connected = true; - - vhost_dev_set_config_notifier(vhost_dev, &gpio_ops); - gpio->vhost_user.supports_config = true; - - gpio->vhost_dev.nvqs = VHOST_NVQS; - gpio->vhost_dev.vqs = gpio->vhost_vqs; - - ret = vhost_dev_init(vhost_dev, &gpio->vhost_user, - VHOST_BACKEND_TYPE_USER, 0, errp); - if (ret < 0) { - return ret; - } - - /* restore vhost state */ - if (virtio_device_started(vdev, vdev->status)) { - vu_gpio_start(vdev); - } - - return 0; -} - -static void vu_gpio_event(void *opaque, QEMUChrEvent event); - -static void vu_gpio_disconnect(DeviceState *dev) -{ - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); - - if (!gpio->connected) { - return; - } - gpio->connected = false; - - vu_gpio_stop(vdev); - vhost_dev_cleanup(&gpio->vhost_dev); - - /* Re-instate the event handler for new connections */ - qemu_chr_fe_set_handlers(&gpio->chardev, - NULL, NULL, vu_gpio_event, - NULL, dev, NULL, true); -} - -static void vu_gpio_event(void *opaque, QEMUChrEvent event) -{ - DeviceState *dev = opaque; - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); - Error *local_err = NULL; - - switch (event) { - case CHR_EVENT_OPENED: - if (vu_gpio_connect(dev, &local_err) < 0) { - qemu_chr_fe_disconnect(&gpio->chardev); - return; - } - break; - case CHR_EVENT_CLOSED: - /* defer close until later to avoid circular close */ - vhost_user_async_close(dev, &gpio->chardev, &gpio->vhost_dev, - vu_gpio_disconnect); - break; - case CHR_EVENT_BREAK: - case CHR_EVENT_MUX_IN: - case CHR_EVENT_MUX_OUT: - /* Ignore */ - break; - } -} - -static int vu_gpio_realize_connect(VHostUserGPIO *gpio, Error **errp) -{ - VirtIODevice *vdev = &gpio->parent_obj; - DeviceState *dev = &vdev->parent_obj; - struct vhost_dev *vhost_dev = &gpio->vhost_dev; - int ret; - - ret = qemu_chr_fe_wait_connected(&gpio->chardev, errp); - if (ret < 0) { - return ret; - } - - /* - * vu_gpio_connect() may have already connected (via the event - * callback) in which case it will just report success. - */ - ret = vu_gpio_connect(dev, errp); - if (ret < 0) { - qemu_chr_fe_disconnect(&gpio->chardev); - return ret; - } - g_assert(gpio->connected); - - ret = vhost_dev_get_config(vhost_dev, (uint8_t *)&gpio->config, - sizeof(gpio->config), errp); - - if (ret < 0) { - error_report("vhost-user-gpio: get config failed"); - - qemu_chr_fe_disconnect(&gpio->chardev); - vhost_dev_cleanup(vhost_dev); - return ret; - } - - return 0; -} - -static void vu_gpio_device_realize(DeviceState *dev, Error **errp) -{ - ERRP_GUARD(); - - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserGPIO *gpio = VHOST_USER_GPIO(dev); - int retries, ret; - - if (!gpio->chardev.chr) { - error_setg(errp, "vhost-user-gpio: chardev is mandatory"); - return; - } - - if (!vhost_user_init(&gpio->vhost_user, &gpio->chardev, errp)) { - return; - } - - virtio_init(vdev, VIRTIO_ID_GPIO, sizeof(gpio->config)); - - gpio->command_vq = virtio_add_queue(vdev, 256, vu_gpio_handle_output); - gpio->interrupt_vq = virtio_add_queue(vdev, 256, vu_gpio_handle_output); - gpio->vhost_vqs = g_new0(struct vhost_virtqueue, VHOST_NVQS); - - gpio->connected = false; - - qemu_chr_fe_set_handlers(&gpio->chardev, NULL, NULL, vu_gpio_event, NULL, - dev, NULL, true); - - retries = REALIZE_CONNECTION_RETRIES; - g_assert(!*errp); - do { - if (*errp) { - error_prepend(errp, "Reconnecting after error: "); - error_report_err(*errp); - *errp = NULL; - } - ret = vu_gpio_realize_connect(gpio, errp); - } while (ret < 0 && retries--); - - if (ret < 0) { - do_vhost_user_cleanup(vdev, gpio); - } - - return; -} - -static void vu_gpio_device_unrealize(DeviceState *dev) -{ - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserGPIO *gpio = VHOST_USER_GPIO(dev); - - vu_gpio_set_status(vdev, 0); - qemu_chr_fe_set_handlers(&gpio->chardev, NULL, NULL, NULL, NULL, NULL, NULL, - false); - vhost_dev_cleanup(&gpio->vhost_dev); - do_vhost_user_cleanup(vdev, gpio); -} +#include "standard-headers/linux/virtio_gpio.h" static const VMStateDescription vu_gpio_vmstate = { .name = "vhost-user-gpio", .unmigratable = 1, }; -static Property vu_gpio_properties[] = { - DEFINE_PROP_CHR("chardev", VHostUserGPIO, chardev), - DEFINE_PROP_END_OF_LIST(), -}; - static void vu_gpio_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); + ObjectProperty *op; - device_class_set_props(dc, vu_gpio_properties); dc->vmsd = &vu_gpio_vmstate; set_bit(DEVICE_CATEGORY_INPUT, dc->categories); - vdc->realize = vu_gpio_device_realize; - vdc->unrealize = vu_gpio_device_unrealize; - vdc->get_features = vu_gpio_get_features; - vdc->get_config = vu_gpio_get_config; - vdc->set_status = vu_gpio_set_status; - vdc->guest_notifier_mask = vu_gpio_guest_notifier_mask; + + op = object_class_property_find(klass, "virtio-id"); + g_assert(op); + object_property_fix_default_uint(op, VIRTIO_ID_GPIO); + + op = object_class_property_find(klass, "num-vqs"); + g_assert(op); + object_property_fix_default_uint(op, 2); + + op = object_class_property_find(klass, "config_size"); + g_assert(op); + object_property_fix_default_uint(op, sizeof(struct virtio_gpio_config)); } static const TypeInfo vu_gpio_info = { .name = TYPE_VHOST_USER_GPIO, - .parent = TYPE_VIRTIO_DEVICE, + .parent = TYPE_VHOST_USER_DEVICE, .instance_size = sizeof(VHostUserGPIO), .class_init = vu_gpio_class_init, }; From patchwork Fri Apr 14 16:04:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 673140 Delivered-To: patch@linaro.org Received: by 2002:adf:fcce:0:0:0:0:0 with SMTP id f14csp263236wrs; Fri, 14 Apr 2023 09:07:05 -0700 (PDT) X-Google-Smtp-Source: AKy350YAj1SZdY00/7iEeW5J+Cyevw0nmrESQWW2NsSDG3nMjcV4d9/Evh6P4wRYNs64sLC75AIV X-Received: by 2002:a05:6214:4106:b0:5ac:fb9a:67a1 with SMTP id kc6-20020a056214410600b005acfb9a67a1mr4204359qvb.47.1681488425036; Fri, 14 Apr 2023 09:07:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681488425; cv=none; d=google.com; s=arc-20160816; b=cqVBjyOBAaxube5TQWKMLwP82Q4frxll1ZoZJhGlUbMVuXj0iO3WkQcB1/xTYdmKi3 bOQ1R3jLvPAFuCKYcdyp/lafZk1vfbw9COY5umMy232aaIkO/HAbW5CNENgkbO2ytGpb CNWYzYHNlPI1MFvf/0U85wXHoDZUj17hRhuZ6vL3GNOCdGOGi+U7yotnFhhD9HVKvQXY QYrAyZa/jHdThOHuOcnPgRuChRaEtOeHO/AMmmNwHRA2W2iqfTsEQCBMB7eqg9DLoaG2 m6EW8WGMraQBNIvU6pNxV7om/0o/GaL6uYqWrJoJT1A5ks2dY9GWVCv6ayaPuLVnmkun v5sw== 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=+fMbxBkambXkAbitMf0yYS02jxY28hzasoKde2tZwkQ=; b=LOBpMwO6e8A1CkSSgonvc1Gufrs+n0cVUbqcDelhSyLUljMefQofXtnjpT/V0olNOi 5eLOuHhvRPWLTyge48/+ICR8ldNbQ0eysqJJZYVB2e0pyU6MYGJE9BIShm9fidBc65z7 08C1AvQcTxQfQqIjerKRlcg2nT7HFfPQ4U4BFxI7ZqZXKvLp0ilqQJuSWrVGENfxmzxq TzeuEs6LXcYYt1siKwdlaElejLKcFlHUd8glWKOZayjJ8eAvjuWSLGXmxqS2EvBSM6ma 1wpPG2k2kGhmCjTtjhAbGUP6aWuoe6VfPHoDmKYmaB9icOAVdlxu9v1TJikDs2mEggyh PXtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JzT83oWw; 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 u14-20020ad45aae000000b0056cbb225837si2739430qvg.274.2023.04.14.09.07.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Apr 2023 09:07:05 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JzT83oWw; 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 1pnLvC-00071p-WE; Fri, 14 Apr 2023 12:05:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnLum-0006SI-8D for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:49 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pnLuj-00080C-Lb for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:43 -0400 Received: by mail-wr1-x434.google.com with SMTP id e7so7952801wrc.12 for ; Fri, 14 Apr 2023 09:04:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681488280; x=1684080280; 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=+fMbxBkambXkAbitMf0yYS02jxY28hzasoKde2tZwkQ=; b=JzT83oWwmcqo5vxYHf7Q0VBydrgskgxPELCHECrV8WCxaWUzoW+ygyTWrZO1KT6jaV WhZ4NSBP07w2197lRXsJQ/8mxpxuLIb24HPgVVVwz59lobN+NRy4wIk2k5EnZZFqE0BC 1xUkBZUJ4m2bNzbp076SC7zV8B2HJRczuz1oMjJA7SijSMrCgIaJIGDuYqGi2u8QDozp Hp6i59+cRulDDQFMx+wto/9mHA0SP+dS4exQksC9TuiugH7FYigmhYPhmvuJCJV4guUG p60oVzJu0PnkfRDBuA7mpEZx0KZ8769JGl+4wTwSab/LZ3axpFysAcTF/DgnWD2BVeRm 3IzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681488280; x=1684080280; 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=+fMbxBkambXkAbitMf0yYS02jxY28hzasoKde2tZwkQ=; b=SeAmTFvk3Y+Qn89S6brg6wqLhV8XPVPI1RZ8OzUBTMjgwK+tQPtjdkSy+uMnFznHB1 eGsyT6QtJ9q6xaSPG/qiNSZOhprs8P/5INrM6uyzoFNRFbrOoOa4VyJzQ2aJ8182wU5x xHy8dY30u7YIjbC/CxwIqS3KKtXCUb6UUPSeKZWqAr6K555vVG/KjMkz1m77WeJN1xP7 LFZn3YvdqBr8niuGa9vAcuWZwG3P3h+2WR0JJvSKW2uCyLKqkV1Vj2BzyMxQ1JHmnC4l P25Q0dki/nGMtz8HaayemyfXLL0C6PbBOjlUF/RI4lCUfgviRhD8MP7S89rwHNQGAwbq yBnA== X-Gm-Message-State: AAQBX9doEba6k1mYJ/80nudeaoJNaid6zu1Yigzn1YVmQ2FDyGFipZg1 AoQMIR3IbrnFepVcIFQEdZxfag== X-Received: by 2002:adf:f312:0:b0:2f8:2d4:74ef with SMTP id i18-20020adff312000000b002f802d474efmr177006wro.43.1681488280161; Fri, 14 Apr 2023 09:04:40 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id f4-20020adff584000000b002f008477522sm3851238wro.24.2023.04.14.09.04.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 09:04:39 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 359F31FFBB; Fri, 14 Apr 2023 17:04:35 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Paolo Bonzini , "Michael S. Tsirkin" , virtio-fs@redhat.com, Erik Schilling , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Eduardo Habkost , Stefan Hajnoczi , Eric Blake , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Jason Wang , Viresh Kumar , Mathieu Poirier , Gerd Hoffmann , Markus Armbruster Subject: [PATCH 12/12] docs/system: add a basic enumeration of vhost-user devices Date: Fri, 14 Apr 2023 17:04:33 +0100 Message-Id: <20230414160433.2096866-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414160433.2096866-1-alex.bennee@linaro.org> References: <20230414160433.2096866-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Alex Bennée --- docs/system/devices/vhost-user-rng.rst | 2 ++ docs/system/devices/vhost-user.rst | 41 ++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/docs/system/devices/vhost-user-rng.rst b/docs/system/devices/vhost-user-rng.rst index a145d4105c..ead1405326 100644 --- a/docs/system/devices/vhost-user-rng.rst +++ b/docs/system/devices/vhost-user-rng.rst @@ -1,3 +1,5 @@ +.. _vhost_user_rng: + QEMU vhost-user-rng - RNG emulation =================================== diff --git a/docs/system/devices/vhost-user.rst b/docs/system/devices/vhost-user.rst index 86128114fa..99b352823e 100644 --- a/docs/system/devices/vhost-user.rst +++ b/docs/system/devices/vhost-user.rst @@ -15,6 +15,47 @@ to the guest. The code is mostly boilerplate although each device has a ``chardev`` option which specifies the ID of the ``--chardev`` device that connects via a socket to the vhost-user *daemon*. +Each device will have an virtio-mmio and virtio-pci variant. See your +platform details for what sort of virtio bus to use. + +.. list-table:: vhost-user devices + :widths: 20 20 60 + :header-rows: 1 + + * - Device + - Type + - Notes + * - vhost-user-device + - Generic + - You must manually specify ``virtio-id`` and the correct ``num_vqs`` + * - vhost-user-blk + - Block storage + - + * - vhost-user-fs + - File based storage driver + - See https://gitlab.com/virtio-fs/virtiofsd + * - vhost-user-scsi + - SCSI based storage + - See contrib/vhost-user/scsi + * - vhost-user-gpio + - Proxy gpio pins to host + - See https://github.com/rust-vmm/vhost-device + * - vhost-user-i2c + - Proxy i2c devices to host + - See https://github.com/rust-vmm/vhost-device + * - vhost-user-input + - Generic input driver + - See contrib/vhost-user-input + * - vhost-user-rng + - Entropy driver + - :ref:`vhost_user_rng` + * - vhost-user-gpu + - GPU driver + - + * - vhost-user-vsock + - Socket based communication + - See https://github.com/rust-vmm/vhost-device + vhost-user daemon =================