From nobody Wed Nov 27 04:51:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1700321175; cv=none; d=zohomail.com; s=zohoarc; b=VxkxfD6t4Qy01Z6RyekBudzRHPt3/HCFE8o3ke6rrObbDj/6DlxZcz23IY7pmHF912StNi6KPkHGccaTq4yNwKr41vyfO6laGC8Ni44Wu+olvMezZPhdosJ9oCvj9GNIcB4nlfiv6gbrcWg04YwYWQ+XSsQXaZzbzkLyCaeNodU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700321175; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SgZStl6cQ0hFCfxIDbFZBOxl4qkddCAwhz0OMlhMXNU=; b=FVvGcfLG1j0k8r1i7AT+9ZQq6/JvMeEBBj7spM6LYkegmWk0jsF15vCEbqXuL3/AztUJ8yUN2pRALxC+jqobrXlS5L+3ljagKVsXVHBTqbaFrNzzLLUrPEj5PyjQ97mp/EyhqPYUz3T5ljDu6yxojKUm0oaRdVI8F1IkocNRfU4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700321175738450.8746112013389; Sat, 18 Nov 2023 07:26:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r4NCN-0003NV-P0; Sat, 18 Nov 2023 10:25:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r4NC5-0003KM-2n for qemu-devel@nongnu.org; Sat, 18 Nov 2023 10:25:13 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r4NC3-0007no-9y for qemu-devel@nongnu.org; Sat, 18 Nov 2023 10:25:12 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1cc68c1fac2so26706495ad.0 for ; Sat, 18 Nov 2023 07:23:10 -0800 (PST) Received: from localhost.localdomain ([125.71.94.124]) by smtp.gmail.com with ESMTPSA id f2-20020a170902ce8200b001bbb25dd3a7sm3120884plg.187.2023.11.18.07.23.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 07:23:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smartx-com.20230601.gappssmtp.com; s=20230601; t=1700320989; x=1700925789; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SgZStl6cQ0hFCfxIDbFZBOxl4qkddCAwhz0OMlhMXNU=; b=lK2U76w7tcPWrRrugslXYlXIm7fIhZvBoAqSUDHuwOIvf+F/dZkdWlk9lRg1/BVAN0 HebCGejhaDIQFIsWT54RpiMEk9HW1kme+48IIagoH7O72wBCiEnENhUx+fr60cjAYUgx ZCm4u6xq3nP2W+fazUWnsA49W5Ua/tMTAt+g1VsVoamPBOCZYG/+rLBGvuC3ZKUzOXxi 7Qbck5PmNyl5lY4yNpggENATq9nfYcFKTT53JRlJWzL9bCw+peftY+srteJdEfURSo7u JbNHS0VBcMH4vhyVr8vuG2EnhYD1nvlDIbqQ7zRggr7l1BDX/H4Lgf/bMoRHSQaUDMwL AeFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700320989; x=1700925789; 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=SgZStl6cQ0hFCfxIDbFZBOxl4qkddCAwhz0OMlhMXNU=; b=NexmJqMcukk/Jxr5fs1dsn+9hiW/5gP6xILrHU21dPyAi1P6EMiKB0r4k06JzGe0eL NdpSRr+sRrOP4WLmgKkCdqazhnW5wA64TTWMa8MupnebPYGybNKVK3IGP4juhc2K4yQD xHUHgn0vJxbr3mmlbcB2l6gyrzSEDqpBwRxVmv8GZrrF2daReCjgUGJEjakmGmDt4gZZ 6ilLnGtmQJrKsXv8F8K9oAiERurploYdhO8SAVMUy0d75sjznE6BIygZUTJdOoQZYttq DoFZLSsMevjvihszLD6GMO9iwXfA5P8sMCT01CVCZucpbL2/5vsACr8eGGLKjQLPD7L0 mjTA== X-Gm-Message-State: AOJu0YyY3AJaoZZ3PktlCJuPcSor6ALC02tzZmk40Fio/0tqRrcSzBQJ 2VpRstnR6su3lkoz8x+VuOEFZfKJFsmbHg0nrHASCw== X-Google-Smtp-Source: AGHT+IGqTmfDBbqqwxiI+7QbzG3uvSzgK3isc+v28wtXSsQRLfG8YD3iMtP45w0hLeuBH+2wdr4GvQ== X-Received: by 2002:a17:902:ec02:b0:1cc:4467:a563 with SMTP id l2-20020a170902ec0200b001cc4467a563mr3083938pld.3.1700320989230; Sat, 18 Nov 2023 07:23:09 -0800 (PST) From: Hyman Huang To: qemu-devel@nongnu.org Cc: "Michael S . Tsirkin" , Eric Blake , Markus Armbruster , Thomas Huth , Laurent Vivier , Paolo Bonzini , Hyman Huang Subject: [v2 1/2] qapi/virtio: Add feature and status bits for x-query-virtio-status Date: Sat, 18 Nov 2023 23:22:49 +0800 Message-Id: <3c7161a47b141af04b1f8272e8e24c5faa46ddb2.1700319559.git.yong.huang@smartx.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::631; envelope-from=yong.huang@smartx.com; helo=mail-pl1-x631.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @smartx-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1700321176618100002 Content-Type: text/plain; charset="utf-8" This patch allows to display feature and status bits in virtio-status. Applications could find it helpful to compare status and features that are numeric encoded. For example, an upper application could use the features (encoded as a number) in the output of "ovs-vsctl list interface" and the feature bits fields in the output of QMP command "x-query-virtio-status" to compare directly when attempting to ensure the correctness of the virtio negotiation between guest, QEMU, and OVS-DPDK. Not applying any more encoding. This patch also serves as a preparation for the next one, which implements a vhost-user test case about acked features of vhost-user protocol. Note that since the matching HMP command is typically used for human, leave it unchanged. Signed-off-by: Hyman Huang --- hw/virtio/virtio-qmp.c | 8 ++++++++ qapi/virtio.json | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/hw/virtio/virtio-qmp.c b/hw/virtio/virtio-qmp.c index 1dd96ed20f..13ba1e926e 100644 --- a/hw/virtio/virtio-qmp.c +++ b/hw/virtio/virtio-qmp.c @@ -733,6 +733,9 @@ VirtioStatus *qmp_x_query_virtio_status(const char *pat= h, Error **errp) status->name =3D g_strdup(vdev->name); status->device_id =3D vdev->device_id; status->vhost_started =3D vdev->vhost_started; + status->guest_features_bits =3D vdev->guest_features; + status->host_features_bits =3D vdev->host_features; + status->backend_features_bits =3D vdev->backend_features; status->guest_features =3D qmp_decode_features(vdev->device_id, vdev->guest_features); status->host_features =3D qmp_decode_features(vdev->device_id, @@ -753,6 +756,7 @@ VirtioStatus *qmp_x_query_virtio_status(const char *pat= h, Error **errp) } =20 status->num_vqs =3D virtio_get_num_queues(vdev); + status->status_bits =3D vdev->status; status->status =3D qmp_decode_status(vdev->status); status->isr =3D vdev->isr; status->queue_sel =3D vdev->queue_sel; @@ -775,6 +779,10 @@ VirtioStatus *qmp_x_query_virtio_status(const char *pa= th, Error **errp) status->vhost_dev->n_tmp_sections =3D hdev->n_tmp_sections; status->vhost_dev->nvqs =3D hdev->nvqs; status->vhost_dev->vq_index =3D hdev->vq_index; + status->vhost_dev->features_bits =3D hdev->features; + status->vhost_dev->acked_features_bits =3D hdev->acked_features; + status->vhost_dev->backend_features_bits =3D hdev->backend_feature= s; + status->vhost_dev->protocol_features_bits =3D hdev->protocol_featu= res; status->vhost_dev->features =3D qmp_decode_features(vdev->device_id, hdev->features); status->vhost_dev->acked_features =3D diff --git a/qapi/virtio.json b/qapi/virtio.json index e6dcee7b83..6f1b5e3710 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -79,12 +79,20 @@ # # @vq-index: vhost_dev vq_index # +# @features-bits: vhost_dev features encoded as a number +# # @features: vhost_dev features # +# @acked-features-bits: vhost_dev acked_features encoded as a number +# # @acked-features: vhost_dev acked_features # +# @backend-features-bits: vhost_dev backend_features encoded as a number +# # @backend-features: vhost_dev backend_features # +# @protocol-features-bits: vhost_dev protocol_features encoded as a number +# # @protocol-features: vhost_dev protocol_features # # @max-queues: vhost_dev max_queues @@ -102,9 +110,13 @@ 'n-tmp-sections': 'int', 'nvqs': 'uint32', 'vq-index': 'int', + 'features-bits': 'uint64', 'features': 'VirtioDeviceFeatures', + 'acked-features-bits': 'uint64', 'acked-features': 'VirtioDeviceFeatures', + 'backend-features-bits': 'uint64', 'backend-features': 'VirtioDeviceFeatures', + 'protocol-features-bits': 'uint64', 'protocol-features': 'VhostDeviceProtocols', 'max-queues': 'uint64', 'backend-cap': 'uint64', @@ -124,10 +136,16 @@ # # @vhost-started: VirtIODevice vhost_started flag # +# @guest-features-bits: VirtIODevice guest_features encoded as a number +# # @guest-features: VirtIODevice guest_features # +# @host-features-bits: VirtIODevice host_features encoded as a number +# # @host-features: VirtIODevice host_features # +# @backend-features-bits: VirtIODevice backend_features encoded as a number +# # @backend-features: VirtIODevice backend_features # # @device-endian: VirtIODevice device_endian @@ -135,6 +153,9 @@ # @num-vqs: VirtIODevice virtqueue count. This is the number of # active virtqueues being used by the VirtIODevice. # +# @status-bits: VirtIODevice configuration status encoded as a number +# (VirtioDeviceStatus) +# # @status: VirtIODevice configuration status (VirtioDeviceStatus) # # @isr: VirtIODevice ISR @@ -170,10 +191,14 @@ 'device-id': 'uint16', 'vhost-started': 'bool', 'device-endian': 'str', + 'guest-features-bits': 'uint64', 'guest-features': 'VirtioDeviceFeatures', + 'host-features-bits': 'uint64', 'host-features': 'VirtioDeviceFeatures', + 'backend-features-bits': 'uint64', 'backend-features': 'VirtioDeviceFeatures', 'num-vqs': 'int', + 'status-bits': 'uint8', 'status': 'VirtioDeviceStatus', 'isr': 'uint8', 'queue-sel': 'uint16', @@ -216,6 +241,7 @@ # "disable-legacy-check": false, # "name": "virtio-crypto", # "started": true, +# "guest-features-bits": 5100273664, # "device-id": 20, # "backend-features": { # "transports": [], @@ -241,6 +267,7 @@ # "VIRTIO_F_VERSION_1: Device compliant for v1 spec (lega= cy)" # ] # }, +# "host-features-bits": 6325010432, # "host-features": { # "unknown-dev-features": 1073741824, # "dev-features": [], @@ -252,9 +279,11 @@ # "VIRTIO_F_NOTIFY_ON_EMPTY: Notify when device runs out = of avail. descs. on VQ" # ] # }, +# "backend-features-bits": 0, # "use-guest-notifier-mask": true, # "vm-running": true, # "queue-sel": 1, +# "status-bits": 15, # "disabled": false, # "vhost-started": false, # "use-started": true @@ -272,11 +301,13 @@ # "disabled-legacy-check": false, # "name": "virtio-net", # "started": true, +# "guest-features-bits": 5111807911, # "device-id": 1, # "vhost-dev": { # "n-tmp-sections": 4, # "n-mem-sections": 4, # "max-queues": 1, +# "features-bits": 13908344832 # "backend-cap": 2, # "log-size": 0, # "backend-features": { @@ -284,6 +315,8 @@ # "transports": [] # }, # "nvqs": 2, +# "acked-features-bits": 5100306432, +# "backend-features-bits": 0, # "protocol-features": { # "protocols": [] # }, @@ -299,6 +332,7 @@ # "VIRTIO_F_VERSION_1: Device compliant for v1 spec (= legacy)" # ] # }, +# "protocol-features-bits": 0, # "features": { # "dev-features": [ # "VHOST_F_LOG_ALL: Logging write descriptors support= ed", @@ -387,6 +421,7 @@ # "VIRTIO_F_VERSION_1: Device compliant for v1 spec (lega= cy)" # ] # }, +# "host-features-bits": 6337593319, # "host-features": { # "dev-features": [ # "VHOST_USER_F_PROTOCOL_FEATURES: Vhost-user protocol fe= atures negotiation supported", @@ -420,9 +455,11 @@ # "VIRTIO_F_NOTIFY_ON_EMPTY: Notify when device runs out = of avail. descs. on VQ" # ] # }, +# "backend-features-bits": 6337593319, # "use-guest-notifier-mask": true, # "vm-running": true, # "queue-sel": 2, +# "status-bits": 15, # "disabled": false, # "vhost-started": true, # "use-started": true --=20 2.39.1 From nobody Wed Nov 27 04:51:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1700321176; cv=none; d=zohomail.com; s=zohoarc; b=BTOKxv4RMOGKYRzzB+eoStl54t4VS8kf7w7ijgx+LINPjL11ya5Dg4wl828OYZVsPDL52q/aDb1bd0oSwkB3PXReIIIVOxHjCPn6K0CuaHgLms3q1+vj9b8n5nBgF3wO18gb2a2jgPGMQMAc2HSKmJ/362eRtnWgacapK5Jj28M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700321176; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Bo6ow+3THX/vVzTTSSoq8Ep2dpKhj9o6TyQslkfrchI=; b=fJNwS7tdJMZ40G6g257CuooNz2XvKm4TXogHRcdWAsO7Q8Ggilbj7xawufDIHlz3swmRk1poj5pjo7nfuvnm9hs/mhMSXi2s5hhu2IG6xLeqQwKV3Ax210kAsT0pR52V37SwmrronsGFOaUS1BDMJvG6K6H11cU5isdOJmv1d3g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170032117582616.969080667340904; Sat, 18 Nov 2023 07:26:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r4NCT-0003OS-FF; Sat, 18 Nov 2023 10:25:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r4NCA-0003Kp-Nb for qemu-devel@nongnu.org; Sat, 18 Nov 2023 10:25:20 -0500 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r4NC8-0007o1-Ly for qemu-devel@nongnu.org; Sat, 18 Nov 2023 10:25:18 -0500 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1ce5e65ba37so11038595ad.1 for ; Sat, 18 Nov 2023 07:23:16 -0800 (PST) Received: from localhost.localdomain ([125.71.94.124]) by smtp.gmail.com with ESMTPSA id f2-20020a170902ce8200b001bbb25dd3a7sm3120884plg.187.2023.11.18.07.23.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 07:23:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smartx-com.20230601.gappssmtp.com; s=20230601; t=1700320994; x=1700925794; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Bo6ow+3THX/vVzTTSSoq8Ep2dpKhj9o6TyQslkfrchI=; b=LaGkdL77JmYb36/cpV3pCYPfFGjvDH79xllnmJhkfwChQg/yHF3WKIKZGT68X2AFho iVHpTb40kYY/VQMtyR9l2layeMv6k/mISgZUFhzGfBbkU56HSFQgDUSFljaGb6656DAa CZv4RG5M0/vtcwXclnCJRVCC27VafCjOBa8em9qrQCxcUfGt5irUk64T5IdIMH/23u/k b5TBt9by9/HkAXlIS9flqrE5cmvA5sLjhOyHrrj79wpRSkiPot27/OJI4nerDGF+c+M7 +fuZexN8ei3sv+2dfun851VR5lOUROKzZy/YrlRxUSaI8eFyR+4ZhGCQ2EmiU9DjT7kK Cu4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700320994; x=1700925794; 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=Bo6ow+3THX/vVzTTSSoq8Ep2dpKhj9o6TyQslkfrchI=; b=Ams6Z3yP3E3xscCRZyCxL9lQA3OgP25KBAweNQoUqk++Hf1l7FYl3Y94v1yYgb5YZD 3t+ZVpvG9vuknf68qi+tVLEdmMa5Mz/ugLQYTMKYkIrIBWatR3rZQfwrrI9OOCi1AItj V/N/otYzqbw5ifg2ZvGpwc6k4YPZ405Q0UuqpKEqbt4P5WDwybE+wJG0pAhYpJb1px4W c0r6VL0WXw4ILBkKhzwysWJ07vCDWAK3v2r26IJjpS+iS1WWb9ZytNW3K9QzGCaIf6i5 rLoK0M0qxveONp8cB1SUQb4whkYiWKwTHTu5Sm48MksOSfCpwtgt0TtPXO/ApPnKDEU9 ILCg== X-Gm-Message-State: AOJu0YxapjxVI21QcJzW+NaCd9BuxoRCW+7i6pHPJ4LQO4LDj9XMW1Pj BAjrpWYvGb/dXvOQY4sKPDT9Y97rOsD94BmtrT1sCw== X-Google-Smtp-Source: AGHT+IGtaZaQaMM178M9zlrFUDCLg+6u4l+N5C53yZbRvuwVCzdPr5G84qYmF3tfL4NR+FOO/GgzAg== X-Received: by 2002:a17:902:d50f:b0:1bc:edd:e891 with SMTP id b15-20020a170902d50f00b001bc0edde891mr12359403plg.1.1700320993846; Sat, 18 Nov 2023 07:23:13 -0800 (PST) From: Hyman Huang To: qemu-devel@nongnu.org Cc: "Michael S . Tsirkin" , Eric Blake , Markus Armbruster , Thomas Huth , Laurent Vivier , Paolo Bonzini , Hyman Huang Subject: [v2 2/2] vhost-user-test: Add negotiated features check Date: Sat, 18 Nov 2023 23:22:50 +0800 Message-Id: X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::633; envelope-from=yong.huang@smartx.com; helo=mail-pl1-x633.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @smartx-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1700321176603100001 Content-Type: text/plain; charset="utf-8" When a vhost-user network device is restored from an unexpected failure, the acked_features could be used as input for the VHOST_USER_SET_FEATURES command because QEMU internally backups the final features as acked_features after the guest acknowledges features during virtio-net driver initialization. The negotiated features check verifies whether the features in the Vhost slave device and the acked_features in QEMU are identical. Through the usage of the vhost-user protocol, the test case seeks to verify that the vhost-user network device is correctly negotiating. Signed-off-by: Hyman Huang --- tests/qtest/vhost-user-test.c | 100 ++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index d4e437265f..4f98ee2560 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -13,6 +13,7 @@ #include "libqtest-single.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" +#include "qapi/qmp/qlist.h" #include "qemu/config-file.h" #include "qemu/option.h" #include "qemu/range.h" @@ -169,6 +170,7 @@ typedef struct TestServer { int test_flags; int queues; struct vhost_user_ops *vu_ops; + uint64_t features; } TestServer; =20 struct vhost_user_ops { @@ -1020,6 +1022,100 @@ static void test_multiqueue(void *obj, void *arg, Q= GuestAllocator *alloc) } =20 =20 +static QDict *query_virtio(QTestState *who) +{ + QDict *rsp; + + rsp =3D qtest_qmp(who, "{ 'execute': 'x-query-virtio'}"); + g_assert(!qdict_haskey(rsp, "error")); + g_assert(qdict_haskey(rsp, "return")); + + return rsp; +} + +static QDict *query_virtio_status(QTestState *who, const char *path) +{ + QDict *rsp; + + rsp =3D qtest_qmp(who, "{ 'execute': 'x-query-virtio-status', " + "'arguments': { 'path': %s} }", path); + + g_assert(!qdict_haskey(rsp, "error")); + g_assert(qdict_haskey(rsp, "return")); + + return rsp; +} + +static uint64_t get_acked_features(QTestState *who) +{ + QDict *rsp_return, *status, *vhost_info, *dev; + QList *dev_list; + const QListEntry *entry; + const char *name; + char *path; + uint64_t acked_features; + + /* query the virtio devices */ + rsp_return =3D query_virtio(who); + g_assert(rsp_return); + + dev_list =3D qdict_get_qlist(rsp_return, "return"); + g_assert(dev_list && !qlist_empty(dev_list)); + + /* fetch the first and the sole device */ + entry =3D qlist_first(dev_list); + g_assert(entry); + + dev =3D qobject_to(QDict, qlist_entry_obj(entry)); + g_assert(dev); + + name =3D qdict_get_try_str(dev, "name"); + g_assert_cmpstr(name, =3D=3D, "virtio-net"); + + path =3D g_strdup(qdict_get_try_str(dev, "path")); + g_assert(path); + qobject_unref(rsp_return); + rsp_return =3D NULL; + + /* fetch the status of the virtio-net device by QOM path */ + rsp_return =3D query_virtio_status(who, path); + g_assert(rsp_return); + + status =3D qdict_get_qdict(rsp_return, "return"); + g_assert(status); + + vhost_info =3D qdict_get_qdict(status, "vhost-dev"); + g_assert(vhost_info); + + acked_features =3D qdict_get_try_int(vhost_info, "acked-features-bits"= , 0); + + qobject_unref(rsp_return); + g_free(path); + + return acked_features; +} + +static void acked_features_check(QTestState *qts, TestServer *s) +{ + uint64_t acked_features; + + acked_features =3D get_acked_features(qts); + g_assert_cmpint(acked_features, =3D=3D, s->features); +} + +static void test_acked_features(void *obj, + void *arg, + QGuestAllocator *alloc) +{ + TestServer *server =3D arg; + + if (!wait_for_fds(server)) { + return; + } + + acked_features_check(global_qtest, server); +} + static uint64_t vu_net_get_features(TestServer *s) { uint64_t features =3D 0x1ULL << VHOST_F_LOG_ALL | @@ -1040,6 +1136,7 @@ static void vu_net_set_features(TestServer *s, CharBa= ckend *chr, qemu_chr_fe_disconnect(chr); s->test_flags =3D TEST_FLAGS_BAD; } + s->features =3D msg->payload.u64; } =20 static void vu_net_get_protocol_features(TestServer *s, CharBackend *chr, @@ -1109,6 +1206,9 @@ static void register_vhost_user_test(void) qos_add_test("vhost-user/multiqueue", "virtio-net", test_multiqueue, &opts); + qos_add_test("vhost-user/read_acked_features", + "virtio-net", + test_acked_features, &opts); } libqos_init(register_vhost_user_test); =20 --=20 2.39.1