From nobody Thu May 16 05:32:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1596537695; cv=none; d=zohomail.com; s=zohoarc; b=UramaJbZ5X7E3MlB3/gZRs4Kbkq0Ize4aoHAuA8Wgvk2BVD/eZWw266lv9Pk6dZPrnJpxhsqygCyDfR90m3PRlcS8UKLFNMEeu/91dba2OEBafRumTvGPrnAXeyN2bI6AQIJ7NV2eigr+itQILlYwRrvb7/GAK0M53WQ2UQ5TDE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596537695; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=byWalZzlV6Kc9WQLv0XUfukdkc8FtZimav1r3Wx+JfY=; b=Uvt/Y3+rA3w/kELgVVNqW22nhuWbFsNwSdrCxrjRjCzop7v72Z68DfNbInoWSsT056xra+GlCAPc+0OWAlbqGX3hhKMNpZgaFArV45urAWOjZORbrEFhZEB1AqTGd9vML1PtwYlqIiYOLl5mWhCUoLSNHlKrQVeYNbOtDY93Xx0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596537695963316.7374546567461; Tue, 4 Aug 2020 03:41:35 -0700 (PDT) Received: from localhost ([::1]:45128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k2uNy-0005yz-MG for importer@patchew.org; Tue, 04 Aug 2020 06:41:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41014) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2uKL-0000wb-Na; Tue, 04 Aug 2020 06:37:49 -0400 Received: from forwardcorp1j.mail.yandex.net ([5.45.199.163]:48142) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2uKF-0002KQ-7W; Tue, 04 Aug 2020 06:37:48 -0400 Received: from iva8-d077482f1536.qloud-c.yandex.net (iva8-d077482f1536.qloud-c.yandex.net [IPv6:2a02:6b8:c0c:2f26:0:640:d077:482f]) by forwardcorp1j.mail.yandex.net (Yandex) with ESMTP id 87DC92E1651; Tue, 4 Aug 2020 13:37:35 +0300 (MSK) Received: from iva8-88b7aa9dc799.qloud-c.yandex.net (iva8-88b7aa9dc799.qloud-c.yandex.net [2a02:6b8:c0c:77a0:0:640:88b7:aa9d]) by iva8-d077482f1536.qloud-c.yandex.net (mxbackcorp/Yandex) with ESMTP id Ote9oNWC2p-bUtu0maj; Tue, 04 Aug 2020 13:37:35 +0300 Received: from dynamic-vpn.dhcp.yndx.net (dynamic-vpn.dhcp.yndx.net [2a02:6b8:b081:2::1:a]) by iva8-88b7aa9dc799.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id ZZLKBSFEhl-bUiW9ggY; Tue, 04 Aug 2020 13:37:30 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) Precedence: bulk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1596537455; bh=byWalZzlV6Kc9WQLv0XUfukdkc8FtZimav1r3Wx+JfY=; h=In-Reply-To:In-Reply-To:Message-Id:References:References:Date: Subject:To:From:Cc; b=TmmHyScBiFdXsCttXeMDslB+26hTyyxoyPV7xU/hsaS0qt4S2+YZkU1j0iei4poHD Zty7zEpwM+tUFr8hrwKCHibudKsnn2Ej6hnnrr2UIZkpcLs/1AzRVQUGeRys0zSrhB KjVJP6ru+0TD97x4RkM7sWYZ22+tUy7Xr/ctcufY= Authentication-Results: iva8-d077482f1536.qloud-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Dima Stepanov To: qemu-devel@nongnu.org Subject: [PATCH v1 1/7] vhost: recheck dev state in the vhost_migration_log routine Date: Tue, 4 Aug 2020 13:36:46 +0300 Message-Id: <723bde710a16a24f4d684d05abf4e61e1ee4138c.1596536559.git.dimastep@yandex-team.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: 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: pass client-ip=5.45.199.163; envelope-from=dimastep@yandex-team.ru; helo=forwardcorp1j.mail.yandex.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/04 06:37:36 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, lvivier@redhat.com, thuth@redhat.com, qemu-block@nongnu.org, mst@redhat.com, jasowang@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, fengli@smartx.com, yc-core@yandex-team.ru, pbonzini@redhat.com, raphael.norwitz@nutanix.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" vhost-user devices can get a disconnect in the middle of the VHOST-USER handshake on the migration start. If disconnect event happened right before sending next VHOST-USER command, then the vhost_dev_set_log() call in the vhost_migration_log() function will return error. This error will lead to the assert() and close the QEMU migration source process. For the vhost-user devices the disconnect event should not break the migration process, because: - the device will be in the stopped state, so it will not be changed during migration - if reconnect will be made the migration log will be reinitialized as part of reconnect/init process: #0 vhost_log_global_start (listener=3D0x563989cf7be0) at hw/virtio/vhost.c:920 #1 0x000056398603d8bc in listener_add_address_space (listener=3D0x5639= 89cf7be0, as=3D0x563986ea4340 ) at softmmu/memory.c:2664 #2 0x000056398603dd30 in memory_listener_register (listener=3D0x563989= cf7be0, as=3D0x563986ea4340 ) at softmmu/memory.c:2740 #3 0x0000563985fd6956 in vhost_dev_init (hdev=3D0x563989cf7bd8, opaque=3D0x563989cf7e30, backend_type=3DVHOST_BACKEND_TYPE_USER, busyloop_timeout=3D0) at hw/virtio/vhost.c:1385 #4 0x0000563985f7d0b8 in vhost_user_blk_connect (dev=3D0x563989cf7990) at hw/block/vhost-user-blk.c:315 #5 0x0000563985f7d3f6 in vhost_user_blk_event (opaque=3D0x563989cf7990, event=3DCHR_EVENT_OPENED) at hw/block/vhost-user-blk.c:379 Update the vhost-user-blk device with the internal started field which will be used for initialization and clean up. The disconnect event will set the overall VHOST device to the stopped state, so it can be used by the vhost_migration_log routine. Such approach could be propogated to the other vhost-user devices, but better idea is just to make the same connect/disconnect code for all the vhost-user devices. This migration issue was slightly discussed earlier: - https://lists.gnu.org/archive/html/qemu-devel/2020-05/msg01509.html - https://lists.gnu.org/archive/html/qemu-devel/2020-05/msg05241.html Signed-off-by: Dima Stepanov --- hw/block/vhost-user-blk.c | 13 ++++++++++++- hw/virtio/vhost.c | 27 ++++++++++++++++++++++++--- include/hw/virtio/vhost-user-blk.h | 1 + 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index a00b854..9da08ec 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -150,6 +150,7 @@ static int vhost_user_blk_start(VirtIODevice *vdev) error_report("Error starting vhost: %d", -ret); goto err_guest_notifiers; } + s->started =3D true; =20 /* guest_notifier_mask/pending not used yet, so just unmask * everything here. virtio-pci will do the right thing by @@ -341,8 +342,9 @@ static void vhost_user_blk_disconnect(DeviceState *dev) } s->connected =3D false; =20 - if (s->dev.started) { + if (s->started) { vhost_user_blk_stop(vdev); + s->started =3D false; } =20 vhost_dev_cleanup(&s->dev); @@ -399,6 +401,15 @@ static void vhost_user_blk_event(void *opaque, QEMUChr= Event event) NULL, NULL, false); aio_bh_schedule_oneshot(ctx, vhost_user_blk_chr_closed_bh, opa= que); } + + /* + * Move vhost device to the stopped state. The vhost-user device + * will be clean up and disconnected in BH. This can be useful in + * the vhost migration code. If disconnect was caught there is an + * option for the general vhost code to get the dev state without + * knowing its type (in this case vhost-user). + */ + s->dev.started =3D false; break; case CHR_EVENT_BREAK: case CHR_EVENT_MUX_IN: diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 1a1384e..ffef7ab 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -861,21 +861,42 @@ static int vhost_migration_log(MemoryListener *listen= er, bool enable) dev->log_enabled =3D enable; return 0; } + + r =3D 0; if (!enable) { r =3D vhost_dev_set_log(dev, false); if (r < 0) { - return r; + goto check_dev_state; } vhost_log_put(dev, false); } else { vhost_dev_log_resize(dev, vhost_get_log_size(dev)); r =3D vhost_dev_set_log(dev, true); if (r < 0) { - return r; + goto check_dev_state; } } + +check_dev_state: dev->log_enabled =3D enable; - return 0; + /* + * vhost-user-* devices could change their state during log + * initialization due to disconnect. So check dev state after + * vhost communication. + */ + if (!dev->started) { + /* + * Since device is in the stopped state, it is okay for + * migration. Return success. + */ + r =3D 0; + } + if (r) { + /* An error is occured. */ + dev->log_enabled =3D false; + } + + return r; } =20 static void vhost_log_global_start(MemoryListener *listener) diff --git a/include/hw/virtio/vhost-user-blk.h b/include/hw/virtio/vhost-u= ser-blk.h index 34ad6f0..2112a48 100644 --- a/include/hw/virtio/vhost-user-blk.h +++ b/include/hw/virtio/vhost-user-blk.h @@ -39,6 +39,7 @@ typedef struct VHostUserBlk { struct vhost_virtqueue *vhost_vqs; VirtQueue **virtqs; bool connected; + bool started; } VHostUserBlk; =20 #endif --=20 2.7.4 From nobody Thu May 16 05:32:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1596537575; cv=none; d=zohomail.com; s=zohoarc; b=XIV4I6JHRWuTUOlFbPpBJo1l3p8VtIz0dxxZSdbMvjXEcjyeexuH9mTvyYojdvbQYPqKmhzpoY/IsOvgOnkp1l9QIV0hl30SLo4OMTNkJvCUOUEj79RfoMq7n1nkD+msPPNZBZRhiZp1PCJaffFPPacuKLnjaaQXOp5177KDafY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596537575; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=w4HAjC+uPauCS+4y5UQZrU0FI/SIeVh9OnDJmAmUQsg=; b=T8W5ZsqKs1UBXqPl57KQjHXl4wQpLIfosLbJJdv/qujC+HmOhoZDwYyhuNdAMQWLCo3awVzT5ZCk24l/aZe8B5EFNqhZiGQ323N6Mui+JEYIQBMYzcL8Ofqg0DU/wNDoO4wXlXnSz5KPtPkaGtCSqJ1sb1CepLqxKWN10ysT4FE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596537575785698.7240492250928; Tue, 4 Aug 2020 03:39:35 -0700 (PDT) Received: from localhost ([::1]:37562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k2uM2-0002oS-CQ for importer@patchew.org; Tue, 04 Aug 2020 06:39:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41040) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2uKN-0000ww-H3; Tue, 04 Aug 2020 06:37:51 -0400 Received: from forwardcorp1j.mail.yandex.net ([2a02:6b8:0:1619::183]:36446) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2uKL-0002L8-80; Tue, 04 Aug 2020 06:37:51 -0400 Received: from iva8-d077482f1536.qloud-c.yandex.net (iva8-d077482f1536.qloud-c.yandex.net [IPv6:2a02:6b8:c0c:2f26:0:640:d077:482f]) by forwardcorp1j.mail.yandex.net (Yandex) with ESMTP id 11D242E1637; Tue, 4 Aug 2020 13:37:45 +0300 (MSK) Received: from iva8-88b7aa9dc799.qloud-c.yandex.net (iva8-88b7aa9dc799.qloud-c.yandex.net [2a02:6b8:c0c:77a0:0:640:88b7:aa9d]) by iva8-d077482f1536.qloud-c.yandex.net (mxbackcorp/Yandex) with ESMTP id zQBziKgDuh-bgtuGKno; Tue, 04 Aug 2020 13:37:45 +0300 Received: from dynamic-vpn.dhcp.yndx.net (dynamic-vpn.dhcp.yndx.net [2a02:6b8:b081:2::1:a]) by iva8-88b7aa9dc799.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id ZZLKBSFEhl-bfiWw1ux; Tue, 04 Aug 2020 13:37:42 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) Precedence: bulk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1596537464; bh=w4HAjC+uPauCS+4y5UQZrU0FI/SIeVh9OnDJmAmUQsg=; h=In-Reply-To:In-Reply-To:Message-Id:References:References:Date: Subject:To:From:Cc; b=FIBM6gcfK4+uCgYIDSX/DPUIumXleoS+Afw7F/RaEaw7WjvqgjszIwDJt3C9/G3+y txxe94V+rq/R/YLDkLE0be/JiNfNA00zb8D7WkB8N3ByQekOUTkmqmDNQjjXBBNEHv 2XYn8vesEbVqSTr0lLQK/ay2R6l5E6FcrUMrcLmQ= Authentication-Results: iva8-d077482f1536.qloud-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Dima Stepanov To: qemu-devel@nongnu.org Subject: [PATCH v1 2/7] vhost: check queue state in the vhost_dev_set_log routine Date: Tue, 4 Aug 2020 13:36:47 +0300 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: 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: pass client-ip=2a02:6b8:0:1619::183; envelope-from=dimastep@yandex-team.ru; helo=forwardcorp1j.mail.yandex.net X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, lvivier@redhat.com, thuth@redhat.com, qemu-block@nongnu.org, mst@redhat.com, jasowang@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, fengli@smartx.com, yc-core@yandex-team.ru, pbonzini@redhat.com, raphael.norwitz@nutanix.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If the vhost-user-blk daemon provides only one virtqueue, but device was added with several queues, then QEMU will send more VHOST-USER command than expected by daemon side. The vhost_virtqueue_start() routine handles such case by checking the return value from the virtio_queue_get_desc_addr() function call. Add the same check to the vhost_dev_set_log() routine. Signed-off-by: Dima Stepanov --- hw/virtio/vhost.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index ffef7ab..a33ffd4 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -825,12 +825,24 @@ static int vhost_dev_set_features(struct vhost_dev *d= ev, static int vhost_dev_set_log(struct vhost_dev *dev, bool enable_log) { int r, i, idx; + hwaddr addr; + r =3D vhost_dev_set_features(dev, enable_log); if (r < 0) { goto err_features; } for (i =3D 0; i < dev->nvqs; ++i) { idx =3D dev->vhost_ops->vhost_get_vq_index(dev, dev->vq_index + i); + addr =3D virtio_queue_get_desc_addr(dev->vdev, idx); + if (!addr) { + /* + * The queue might not be ready for start. If this + * is the case there is no reason to continue the process. + * The similar logic is used by the vhost_virtqueue_start() + * routine. + */ + break; + } r =3D vhost_virtqueue_set_addr(dev, dev->vqs + i, idx, enable_log); if (r < 0) { --=20 2.7.4 From nobody Thu May 16 05:32:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1596537583; cv=none; d=zohomail.com; s=zohoarc; b=L71RFqVEkafkQ07HUCb6Dh0Mtlj20fE2WL4XVZXjECPnvDttrm3kcBNb9njAQhhto2MGu4orzZQTULBTOdh/ZRDRmnI4/QBpYNGpS4+ZcGOK2J+UaH+1AyT5NdTCvKdnV9utWUOPZhAvj3KhFAD44ndZxsz0MO8nJZo/fpydlj4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596537583; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=gDOPq1RV3CLuGyPljyeYmAP4zg0EO7xHieFeyJevpn0=; b=ETOoV2i6zitSuP6Z925k4rH4XLrwYhYyXEZ6wCMh9SCwTF/AnSsKeoI//zl2nwQXmFA6FV4xzWURrnka0m1QnRizQACVLRqJ6A5kIqdNQJ0o1LoAF8oiVA12T5gwfStfWESCmSEBun/x8oPza6ZA4MW4ux6nNe9QOAmsXZBLxsM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596537583020555.1569737199343; Tue, 4 Aug 2020 03:39:43 -0700 (PDT) Received: from localhost ([::1]:37850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k2uM9-0002vq-Hd for importer@patchew.org; Tue, 04 Aug 2020 06:39:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2uKP-0000xU-HS; Tue, 04 Aug 2020 06:37:53 -0400 Received: from forwardcorp1o.mail.yandex.net ([95.108.205.193]:54330) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2uKM-0002LP-G4; Tue, 04 Aug 2020 06:37:53 -0400 Received: from iva8-d077482f1536.qloud-c.yandex.net (iva8-d077482f1536.qloud-c.yandex.net [IPv6:2a02:6b8:c0c:2f26:0:640:d077:482f]) by forwardcorp1o.mail.yandex.net (Yandex) with ESMTP id 1E78F2E1902; Tue, 4 Aug 2020 13:37:48 +0300 (MSK) Received: from iva8-88b7aa9dc799.qloud-c.yandex.net (iva8-88b7aa9dc799.qloud-c.yandex.net [2a02:6b8:c0c:77a0:0:640:88b7:aa9d]) by iva8-d077482f1536.qloud-c.yandex.net (mxbackcorp/Yandex) with ESMTP id CwlcxYsVO7-bktu9HBS; Tue, 04 Aug 2020 13:37:48 +0300 Received: from dynamic-vpn.dhcp.yndx.net (dynamic-vpn.dhcp.yndx.net [2a02:6b8:b081:2::1:a]) by iva8-88b7aa9dc799.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id ZZLKBSFEhl-bkiW6Imp; Tue, 04 Aug 2020 13:37:46 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) Precedence: bulk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1596537468; bh=gDOPq1RV3CLuGyPljyeYmAP4zg0EO7xHieFeyJevpn0=; h=In-Reply-To:In-Reply-To:Message-Id:References:References:Date: Subject:To:From:Cc; b=OSysRTPN4osU1/Y0OHPltaalA5GqyvSlXHATZwKNQ8Q+nRrKFXy1mOC0LWwUAgHsG kCvLcOTqaRYrFzpqMrev4d5PPWFZO+2+AvJQzq177q276sWNyuKjIwiQ+eF22/qdX9 mhi+O55C4C8pn8yPERL4wsoZNP5/22NuHFDUsfS4= Authentication-Results: iva8-d077482f1536.qloud-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Dima Stepanov To: qemu-devel@nongnu.org Subject: [PATCH v1 3/7] tests/qtest/vhost-user-test: prepare the tests for adding new dev class Date: Tue, 4 Aug 2020 13:36:48 +0300 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: 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: pass client-ip=95.108.205.193; envelope-from=dimastep@yandex-team.ru; helo=forwardcorp1o.mail.yandex.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/04 06:37:25 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, lvivier@redhat.com, thuth@redhat.com, qemu-block@nongnu.org, mst@redhat.com, jasowang@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, fengli@smartx.com, yc-core@yandex-team.ru, pbonzini@redhat.com, raphael.norwitz@nutanix.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" For now only vhost-user-net device is supported by the test. Other vhost-user devices are not tested. As a first step make source code refactoring so new devices can reuse the same test routines. To make this provide a new vhost_user_ops structure with the methods to initialize device, its command line or make a proper vhost-user responses. Signed-off-by: Dima Stepanov --- tests/qtest/vhost-user-test.c | 105 ++++++++++++++++++++++++++++++--------= ---- 1 file changed, 76 insertions(+), 29 deletions(-) diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index 9ee0f1e..3df5322 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -135,6 +135,10 @@ enum { TEST_FLAGS_END, }; =20 +enum { + VHOST_USER_NET, +}; + typedef struct TestServer { gchar *socket_path; gchar *mig_path; @@ -154,10 +158,25 @@ typedef struct TestServer { bool test_fail; int test_flags; int queues; + struct vhost_user_ops *vu_ops; } TestServer; =20 +struct vhost_user_ops { + /* Device types. */ + int type; + void (*append_opts)(TestServer *s, GString *cmd_line, + const char *chr_opts); + + /* VHOST-USER commands. */ + void (*set_features)(TestServer *s, CharBackend *chr, + VhostUserMsg *msg); + void (*get_protocol_features)(TestServer *s, + CharBackend *chr, VhostUserMsg *msg); +}; + static const char *init_hugepagefs(void); -static TestServer *test_server_new(const gchar *name); +static TestServer *test_server_new(const gchar *name, + struct vhost_user_ops *ops); static void test_server_free(TestServer *server); static void test_server_listen(TestServer *server); =20 @@ -167,7 +186,7 @@ enum test_memfd { TEST_MEMFD_NO, }; =20 -static void append_vhost_opts(TestServer *s, GString *cmd_line, +static void append_vhost_net_opts(TestServer *s, GString *cmd_line, const char *chr_opts) { g_string_append_printf(cmd_line, QEMU_CMD_CHR QEMU_CMD_NETDEV, @@ -332,25 +351,15 @@ static void chr_read(void *opaque, const uint8_t *buf= , int size) break; =20 case VHOST_USER_SET_FEATURES: - g_assert_cmpint(msg.payload.u64 & (0x1ULL << VHOST_USER_F_PROTOCOL= _FEATURES), - !=3D, 0ULL); - if (s->test_flags =3D=3D TEST_FLAGS_DISCONNECT) { - qemu_chr_fe_disconnect(chr); - s->test_flags =3D TEST_FLAGS_BAD; + if (s->vu_ops->set_features) { + s->vu_ops->set_features(s, chr, &msg); } break; =20 case VHOST_USER_GET_PROTOCOL_FEATURES: - /* send back features to qemu */ - msg.flags |=3D VHOST_USER_REPLY_MASK; - msg.size =3D sizeof(m.payload.u64); - msg.payload.u64 =3D 1 << VHOST_USER_PROTOCOL_F_LOG_SHMFD; - msg.payload.u64 |=3D 1 << VHOST_USER_PROTOCOL_F_CROSS_ENDIAN; - if (s->queues > 1) { - msg.payload.u64 |=3D 1 << VHOST_USER_PROTOCOL_F_MQ; + if (s->vu_ops->get_protocol_features) { + s->vu_ops->get_protocol_features(s, chr, &msg); } - p =3D (uint8_t *) &msg; - qemu_chr_fe_write_all(chr, p, VHOST_USER_HDR_SIZE + msg.size); break; =20 case VHOST_USER_GET_VRING_BASE: @@ -467,7 +476,8 @@ static const char *init_hugepagefs(void) #endif } =20 -static TestServer *test_server_new(const gchar *name) +static TestServer *test_server_new(const gchar *name, + struct vhost_user_ops *ops) { TestServer *server =3D g_new0(TestServer, 1); char template[] =3D "/tmp/vhost-test-XXXXXX"; @@ -495,6 +505,7 @@ static TestServer *test_server_new(const gchar *name) =20 server->log_fd =3D -1; server->queues =3D 1; + server->vu_ops =3D ops; =20 return server; } @@ -669,11 +680,11 @@ static void vhost_user_test_cleanup(void *s) =20 static void *vhost_user_test_setup(GString *cmd_line, void *arg) { - TestServer *server =3D test_server_new("vhost-user-test"); + TestServer *server =3D test_server_new("vhost-user-test", arg); test_server_listen(server); =20 append_mem_opts(server, cmd_line, 256, TEST_MEMFD_AUTO); - append_vhost_opts(server, cmd_line, ""); + server->vu_ops->append_opts(server, cmd_line, ""); =20 g_test_queue_destroy(vhost_user_test_cleanup, server); =20 @@ -682,11 +693,11 @@ static void *vhost_user_test_setup(GString *cmd_line,= void *arg) =20 static void *vhost_user_test_setup_memfd(GString *cmd_line, void *arg) { - TestServer *server =3D test_server_new("vhost-user-test"); + TestServer *server =3D test_server_new("vhost-user-test", arg); test_server_listen(server); =20 append_mem_opts(server, cmd_line, 256, TEST_MEMFD_YES); - append_vhost_opts(server, cmd_line, ""); + server->vu_ops->append_opts(server, cmd_line, ""); =20 g_test_queue_destroy(vhost_user_test_cleanup, server); =20 @@ -720,7 +731,7 @@ static void test_migrate(void *obj, void *arg, QGuestAl= locator *alloc) return; } =20 - dest =3D test_server_new("dest"); + dest =3D test_server_new("dest", s->vu_ops); dest_cmdline =3D g_string_new(qos_get_current_command_line()); uri =3D g_strdup_printf("%s%s", "unix:", dest->mig_path); =20 @@ -730,7 +741,7 @@ static void test_migrate(void *obj, void *arg, QGuestAl= locator *alloc) test_server_listen(dest); g_string_append_printf(dest_cmdline, " -incoming %s", uri); append_mem_opts(dest, dest_cmdline, 256, TEST_MEMFD_AUTO); - append_vhost_opts(dest, dest_cmdline, ""); + dest->vu_ops->append_opts(dest, dest_cmdline, ""); to =3D qtest_init(dest_cmdline->str); =20 /* This would be where you call qos_allocate_objects(to, NULL), if you= want @@ -831,11 +842,11 @@ connect_thread(gpointer data) =20 static void *vhost_user_test_setup_reconnect(GString *cmd_line, void *arg) { - TestServer *s =3D test_server_new("reconnect"); + TestServer *s =3D test_server_new("reconnect", arg); =20 g_thread_new("connect", connect_thread, s); append_mem_opts(s, cmd_line, 256, TEST_MEMFD_AUTO); - append_vhost_opts(s, cmd_line, ",server"); + s->vu_ops->append_opts(s, cmd_line, ",server"); =20 g_test_queue_destroy(vhost_user_test_cleanup, s); =20 @@ -866,13 +877,13 @@ static void test_reconnect(void *obj, void *arg, QGue= stAllocator *alloc) =20 static void *vhost_user_test_setup_connect_fail(GString *cmd_line, void *a= rg) { - TestServer *s =3D test_server_new("connect-fail"); + TestServer *s =3D test_server_new("connect-fail", arg); =20 s->test_fail =3D true; =20 g_thread_new("connect", connect_thread, s); append_mem_opts(s, cmd_line, 256, TEST_MEMFD_AUTO); - append_vhost_opts(s, cmd_line, ",server"); + s->vu_ops->append_opts(s, cmd_line, ",server"); =20 g_test_queue_destroy(vhost_user_test_cleanup, s); =20 @@ -881,13 +892,13 @@ static void *vhost_user_test_setup_connect_fail(GStri= ng *cmd_line, void *arg) =20 static void *vhost_user_test_setup_flags_mismatch(GString *cmd_line, void = *arg) { - TestServer *s =3D test_server_new("flags-mismatch"); + TestServer *s =3D test_server_new("flags-mismatch", arg); =20 s->test_flags =3D TEST_FLAGS_DISCONNECT; =20 g_thread_new("connect", connect_thread, s); append_mem_opts(s, cmd_line, 256, TEST_MEMFD_AUTO); - append_vhost_opts(s, cmd_line, ",server"); + s->vu_ops->append_opts(s, cmd_line, ",server"); =20 g_test_queue_destroy(vhost_user_test_cleanup, s); =20 @@ -924,11 +935,47 @@ static void test_multiqueue(void *obj, void *arg, QGu= estAllocator *alloc) wait_for_rings_started(s, s->queues * 2); } =20 +static void vu_net_set_features(TestServer *s, CharBackend *chr, + VhostUserMsg *msg) +{ + g_assert_cmpint(msg->payload.u64 & + (0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES), !=3D, 0ULL); + if (s->test_flags =3D=3D TEST_FLAGS_DISCONNECT) { + qemu_chr_fe_disconnect(chr); + s->test_flags =3D TEST_FLAGS_BAD; + } +} + +static void vu_net_get_protocol_features(TestServer *s, CharBackend *chr, + VhostUserMsg *msg) +{ + /* send back features to qemu */ + msg->flags |=3D VHOST_USER_REPLY_MASK; + msg->size =3D sizeof(m.payload.u64); + msg->payload.u64 =3D 1 << VHOST_USER_PROTOCOL_F_LOG_SHMFD; + msg->payload.u64 |=3D 1 << VHOST_USER_PROTOCOL_F_CROSS_ENDIAN; + if (s->queues > 1) { + msg->payload.u64 |=3D 1 << VHOST_USER_PROTOCOL_F_MQ; + } + qemu_chr_fe_write_all(chr, (uint8_t *)msg, VHOST_USER_HDR_SIZE + msg->= size); +} + +/* Each VHOST-USER device should have its ops structure defined. */ +static struct vhost_user_ops g_vu_net_ops =3D { + .type =3D VHOST_USER_NET, + + .append_opts =3D append_vhost_net_opts, + + .set_features =3D vu_net_set_features, + .get_protocol_features =3D vu_net_get_protocol_features, +}; + static void register_vhost_user_test(void) { QOSGraphTestOptions opts =3D { .before =3D vhost_user_test_setup, .subprocess =3D true, + .arg =3D &g_vu_net_ops, }; =20 qemu_add_opts(&qemu_chardev_opts); --=20 2.7.4 From nobody Thu May 16 05:32:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1596537711; cv=none; d=zohomail.com; s=zohoarc; b=YWo0yf1hvSQoBRp0WERAzrqLbMJ4i3ECx9S7SqnIvT5nGB9XN4nQHOqqCS+A4pdW/LhiJL5KTtE1SzsGT3No+gVZVbyrCEOnHYJGrh7iSMa8tQF3+9c1OwRO6eAhnLkCJ1GJiLFbk/TA82NDqgMMAVohjM5ETjPD+ZlQNwqBVOE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596537711; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=c/7bjDqXoTdmIaZ98Ptc2nYCrapOqdlvaj6uHWPyZyA=; b=lma0/5Kg8afX/2lKl3EP3i0zU/m3YNvI1qvv9rdTit7Yc03CZPCKOmApSPz6yDbonjS44uDkxhJpBVQ+449kEQkrXemTBPi3yztAmh9oEuKORuKVhMQy5GpS5kphyDvuIVxtwPq/mAHDm6bZ+QgY2Qzu/OjLg9Ip5yuT3iREtkE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596537711863102.41938636004556; Tue, 4 Aug 2020 03:41:51 -0700 (PDT) Received: from localhost ([::1]:46382 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k2uOE-0006V5-Ii for importer@patchew.org; Tue, 04 Aug 2020 06:41:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41118) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2uKW-0001EX-Hv; Tue, 04 Aug 2020 06:38:00 -0400 Received: from forwardcorp1o.mail.yandex.net ([2a02:6b8:0:1a2d::193]:40470) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2uKT-0002MC-UP; Tue, 04 Aug 2020 06:38:00 -0400 Received: from iva8-d077482f1536.qloud-c.yandex.net (iva8-d077482f1536.qloud-c.yandex.net [IPv6:2a02:6b8:c0c:2f26:0:640:d077:482f]) by forwardcorp1o.mail.yandex.net (Yandex) with ESMTP id D633B2E1903; Tue, 4 Aug 2020 13:37:53 +0300 (MSK) Received: from iva8-88b7aa9dc799.qloud-c.yandex.net (iva8-88b7aa9dc799.qloud-c.yandex.net [2a02:6b8:c0c:77a0:0:640:88b7:aa9d]) by iva8-d077482f1536.qloud-c.yandex.net (mxbackcorp/Yandex) with ESMTP id zwHeim9UNi-bntiGDkm; Tue, 04 Aug 2020 13:37:53 +0300 Received: from dynamic-vpn.dhcp.yndx.net (dynamic-vpn.dhcp.yndx.net [2a02:6b8:b081:2::1:a]) by iva8-88b7aa9dc799.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id ZZLKBSFEhl-bniWpFgL; Tue, 04 Aug 2020 13:37:49 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) Precedence: bulk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1596537473; bh=c/7bjDqXoTdmIaZ98Ptc2nYCrapOqdlvaj6uHWPyZyA=; h=In-Reply-To:In-Reply-To:Message-Id:References:References:Date: Subject:To:From:Cc; b=zd1ASJ/16c+NbyN8EEWkjUDG+eVQCmxlXvmKKX6zasCXazfRsDdkYrqIcDZU32NBW Dwzp6r+iVr+xIEAhyJURBG0RN3LKbLDNtAdIW32AH1OlrVa62xqkbYDCxVRlv5IGoB 86r/rNoAm/FTCOpn6/Rzhky4RKHZshUR5eXibu3M= Authentication-Results: iva8-d077482f1536.qloud-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Dima Stepanov To: qemu-devel@nongnu.org Subject: [PATCH v1 4/7] tests/qtest/libqos/virtio-blk: add support for vhost-user-blk Date: Tue, 4 Aug 2020 13:36:49 +0300 Message-Id: <2e724d955caa1ab65d41ecac2600a54f5cda5cb0.1596536559.git.dimastep@yandex-team.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: 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: pass client-ip=2a02:6b8:0:1a2d::193; envelope-from=dimastep@yandex-team.ru; helo=forwardcorp1o.mail.yandex.net X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, lvivier@redhat.com, thuth@redhat.com, qemu-block@nongnu.org, mst@redhat.com, jasowang@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, fengli@smartx.com, yc-core@yandex-team.ru, pbonzini@redhat.com, raphael.norwitz@nutanix.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add support for the vhost-user-blk-pci device. This node can be used by the vhost-user-blk tests. Tests for the vhost-user-blk device are added in the following patches. Signed-off-by: Dima Stepanov --- tests/qtest/libqos/virtio-blk.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/qtest/libqos/virtio-blk.c b/tests/qtest/libqos/virtio-bl= k.c index 5fc6940..c7878ab 100644 --- a/tests/qtest/libqos/virtio-blk.c +++ b/tests/qtest/libqos/virtio-blk.c @@ -36,6 +36,9 @@ static void *qvirtio_blk_get_driver(QVirtioBlk *v_blk, if (!g_strcmp0(interface, "virtio")) { return v_blk->vdev; } + if (!g_strcmp0(interface, "vhost-user-blk")) { + return v_blk; + } =20 fprintf(stderr, "%s not present in virtio-blk-device\n", interface); g_assert_not_reached(); @@ -120,6 +123,17 @@ static void virtio_blk_register_nodes(void) qos_node_produces("virtio-blk-pci", "virtio-blk"); =20 g_free(arg); + + /* vhost-user-blk-pci */ + arg =3D g_strdup_printf("id=3Ddrv0,chardev=3Dchdev0,addr=3D%x.%x", + PCI_SLOT, PCI_FN); + opts.extra_device_opts =3D arg; + add_qpci_address(&opts, &addr); + qos_node_create_driver("vhost-user-blk-pci", virtio_blk_pci_create); + qos_node_consumes("vhost-user-blk-pci", "pci-bus", &opts); + qos_node_produces("vhost-user-blk-pci", "vhost-user-blk"); + + g_free(arg); } =20 libqos_init(virtio_blk_register_nodes); --=20 2.7.4 From nobody Thu May 16 05:32:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1596537703; cv=none; d=zohomail.com; s=zohoarc; b=UXmqUccLp2wQy/BTE1+I22ekZuRCYo084A1AQ3jaS7Hv8jSibnlUyF+czcctHBMtIiLGwyoAeh7E2ZwJcMyBOirAozVFaSrul/d+qq5+k9QF0451KgBq3fjuM7Pw/p9u32jVdqBLAEBK6pdTnjbRM0F9tN1g73OaBDV0SezDDKw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596537703; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=0YiyaXGCteV6eAUx85YKD/nISwnScCEnn+mIKN9OdOg=; b=NDEE7dzBUeqyVmgBHLT409EGbaqTbARdShRy+Mp2c8hn2i/fK15nTfUuuB5JFC7KxHFym62HGA1p7Gbqel0AYpt8inisNc0tqbb3aHqlxT3WGhP/hvv1VzdOOHKBNGvpBvHNSYJHmx0HZweSazJ0U+2Bcv1lYuhWMHs4X7Dmj94= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159653770379257.09272070042664; Tue, 4 Aug 2020 03:41:43 -0700 (PDT) Received: from localhost ([::1]:45684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k2uO6-0006Cg-Bn for importer@patchew.org; Tue, 04 Aug 2020 06:41:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41170) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2uKa-0001O6-DT; Tue, 04 Aug 2020 06:38:04 -0400 Received: from forwardcorp1p.mail.yandex.net ([2a02:6b8:0:1472:2741:0:8b6:217]:44534) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2uKX-0002Mu-Kh; Tue, 04 Aug 2020 06:38:04 -0400 Received: from iva8-d077482f1536.qloud-c.yandex.net (iva8-d077482f1536.qloud-c.yandex.net [IPv6:2a02:6b8:c0c:2f26:0:640:d077:482f]) by forwardcorp1p.mail.yandex.net (Yandex) with ESMTP id 3840F2E1438; Tue, 4 Aug 2020 13:37:58 +0300 (MSK) Received: from iva8-88b7aa9dc799.qloud-c.yandex.net (iva8-88b7aa9dc799.qloud-c.yandex.net [2a02:6b8:c0c:77a0:0:640:88b7:aa9d]) by iva8-d077482f1536.qloud-c.yandex.net (mxbackcorp/Yandex) with ESMTP id QDCZp2P7ml-bttWPd76; Tue, 04 Aug 2020 13:37:58 +0300 Received: from dynamic-vpn.dhcp.yndx.net (dynamic-vpn.dhcp.yndx.net [2a02:6b8:b081:2::1:a]) by iva8-88b7aa9dc799.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id ZZLKBSFEhl-bsiW9XFf; Tue, 04 Aug 2020 13:37:55 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) Precedence: bulk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1596537478; bh=0YiyaXGCteV6eAUx85YKD/nISwnScCEnn+mIKN9OdOg=; h=In-Reply-To:In-Reply-To:Message-Id:References:References:Date: Subject:To:From:Cc; b=hhWXX6/VHztgM26I6jTlyViMXuQhrLCdmAEem2yL3YK9JOgbQSULb5QjUEF65DWOv 4wQskPLZ/55txBIjdG7pBMWbyg8DJDVQ5gTI6KTiu62nHaFduB23QDUyoihLliPoTl v6b0FQJRQ4buq6kDxBswwdO3F9Wl0LZcQCdwekqo= Authentication-Results: iva8-d077482f1536.qloud-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Dima Stepanov To: qemu-devel@nongnu.org Subject: [PATCH v1 5/7] tests/qtest/vhost-user-test: add support for the vhost-user-blk device Date: Tue, 4 Aug 2020 13:36:50 +0300 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: 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: pass client-ip=2a02:6b8:0:1472:2741:0:8b6:217; envelope-from=dimastep@yandex-team.ru; helo=forwardcorp1p.mail.yandex.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/04 06:37:58 X-ACL-Warn: Detected OS = ??? 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, lvivier@redhat.com, thuth@redhat.com, qemu-block@nongnu.org, mst@redhat.com, jasowang@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, fengli@smartx.com, yc-core@yandex-team.ru, pbonzini@redhat.com, raphael.norwitz@nutanix.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add vhost_user_ops structure for the vhost-user-blk device class. Add the test_reconnect and test_migrate tests for this device. Signed-off-by: Dima Stepanov --- tests/qtest/vhost-user-test.c | 140 ++++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 138 insertions(+), 2 deletions(-) diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index 3df5322..9b6e202 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -24,6 +24,7 @@ #include "libqos/libqos.h" #include "libqos/pci-pc.h" #include "libqos/virtio-pci.h" +#include "libqos/virtio-blk.h" =20 #include "libqos/malloc-pc.h" #include "hw/virtio/virtio-net.h" @@ -31,6 +32,7 @@ #include "standard-headers/linux/vhost_types.h" #include "standard-headers/linux/virtio_ids.h" #include "standard-headers/linux/virtio_net.h" +#include "standard-headers/linux/virtio_blk.h" =20 #ifdef CONFIG_LINUX #include @@ -43,6 +45,7 @@ " -numa node,memdev=3Dmem" #define QEMU_CMD_CHR " -chardev socket,id=3D%s,path=3D%s%s" #define QEMU_CMD_NETDEV " -netdev vhost-user,id=3Dhs0,chardev=3D%s,vhostfo= rce" +#define QEMU_CMD_BLKCHR " -chardev socket,id=3Dchdev0,path=3D%s%s" =20 #define HUGETLBFS_MAGIC 0x958458f6 =20 @@ -55,6 +58,7 @@ #define VHOST_USER_PROTOCOL_F_MQ 0 #define VHOST_USER_PROTOCOL_F_LOG_SHMFD 1 #define VHOST_USER_PROTOCOL_F_CROSS_ENDIAN 6 +#define VHOST_USER_PROTOCOL_F_CONFIG 9 =20 #define VHOST_LOG_PAGE 0x1000 =20 @@ -78,6 +82,8 @@ typedef enum VhostUserRequest { VHOST_USER_SET_PROTOCOL_FEATURES =3D 16, VHOST_USER_GET_QUEUE_NUM =3D 17, VHOST_USER_SET_VRING_ENABLE =3D 18, + VHOST_USER_GET_CONFIG =3D 24, + VHOST_USER_SET_CONFIG =3D 25, VHOST_USER_MAX } VhostUserRequest; =20 @@ -99,6 +105,14 @@ typedef struct VhostUserLog { uint64_t mmap_offset; } VhostUserLog; =20 +#define VHOST_USER_MAX_CONFIG_SIZE 256 +typedef struct VhostUserConfig { + uint32_t offset; + uint32_t size; + uint32_t flags; + uint8_t region[VHOST_USER_MAX_CONFIG_SIZE]; +} VhostUserConfig; + typedef struct VhostUserMsg { VhostUserRequest request; =20 @@ -114,6 +128,7 @@ typedef struct VhostUserMsg { struct vhost_vring_addr addr; VhostUserMemory memory; VhostUserLog log; + VhostUserConfig config; } payload; } QEMU_PACKED VhostUserMsg; =20 @@ -137,6 +152,7 @@ enum { =20 enum { VHOST_USER_NET, + VHOST_USER_BLK, }; =20 typedef struct TestServer { @@ -166,12 +182,15 @@ struct vhost_user_ops { int type; void (*append_opts)(TestServer *s, GString *cmd_line, const char *chr_opts); + void (*driver_init)(void *obj, QGuestAllocator *alloc); =20 /* VHOST-USER commands. */ void (*set_features)(TestServer *s, CharBackend *chr, VhostUserMsg *msg); void (*get_protocol_features)(TestServer *s, CharBackend *chr, VhostUserMsg *msg); + void (*get_config)(TestServer *s, CharBackend *chr, + VhostUserMsg *msg); }; =20 static const char *init_hugepagefs(void); @@ -194,6 +213,14 @@ static void append_vhost_net_opts(TestServer *s, GStri= ng *cmd_line, chr_opts, s->chr_name); } =20 +static void append_vhost_blk_opts(TestServer *s, GString *cmd_line, + const char *chr_opts) +{ + g_string_append_printf(cmd_line, QEMU_CMD_BLKCHR, + s->socket_path, + chr_opts); +} + static void append_mem_opts(TestServer *server, GString *cmd_line, int size, enum test_memfd memfd) { @@ -425,6 +452,12 @@ static void chr_read(void *opaque, const uint8_t *buf,= int size) qemu_chr_fe_write_all(chr, p, VHOST_USER_HDR_SIZE + msg.size); break; =20 + case VHOST_USER_GET_CONFIG: + if (s->vu_ops->get_config) { + s->vu_ops->get_config(s, chr, &msg); + } + break; + default: break; } @@ -727,6 +760,9 @@ static void test_migrate(void *obj, void *arg, QGuestAl= locator *alloc) guint8 *log; guint64 size; =20 + if (s->vu_ops->driver_init) { + s->vu_ops->driver_init(obj, alloc); + } if (!wait_for_fds(s)) { return; } @@ -796,6 +832,24 @@ static void test_migrate(void *obj, void *arg, QGuestA= llocator *alloc) g_string_free(dest_cmdline, true); } =20 +static void vu_blk_driver_init(void *obj, QGuestAllocator *alloc) +{ + QVirtioBlk *blk_if; + QVirtioDevice *dev; + QVirtQueue *vq; + uint64_t features; + + blk_if =3D obj; + dev =3D blk_if->vdev; + features =3D qvirtio_get_features(dev); + qvirtio_set_features(dev, features); + + vq =3D qvirtqueue_setup(dev, alloc, 0); + g_assert(vq); + + qvirtio_set_driver_ok(dev); +} + static void wait_for_rings_started(TestServer *s, size_t count) { gint64 end_time; @@ -857,12 +911,22 @@ static void test_reconnect(void *obj, void *arg, QGue= stAllocator *alloc) { TestServer *s =3D arg; GSource *src; + int nq; =20 + if (s->vu_ops->driver_init) { + s->vu_ops->driver_init(obj, alloc); + } if (!wait_for_fds(s)) { return; } =20 - wait_for_rings_started(s, 2); + if (s->vu_ops->type =3D=3D VHOST_USER_NET) { + /* tx and rx queues */ + nq =3D 2; + } else if (s->vu_ops->type =3D=3D VHOST_USER_BLK) { + nq =3D 1; + } + wait_for_rings_started(s, nq); =20 /* reconnect */ s->fds_num =3D 0; @@ -872,7 +936,7 @@ static void test_reconnect(void *obj, void *arg, QGuest= Allocator *alloc) g_source_attach(src, s->context); g_source_unref(src); g_assert(wait_for_fds(s)); - wait_for_rings_started(s, 2); + wait_for_rings_started(s, nq); } =20 static void *vhost_user_test_setup_connect_fail(GString *cmd_line, void *a= rg) @@ -960,6 +1024,56 @@ static void vu_net_get_protocol_features(TestServer *= s, CharBackend *chr, qemu_chr_fe_write_all(chr, (uint8_t *)msg, VHOST_USER_HDR_SIZE + msg->= size); } =20 +static void vu_blk_set_features(TestServer *s, CharBackend *chr, + VhostUserMsg *msg) +{ + if (s->test_flags =3D=3D TEST_FLAGS_DISCONNECT) { + qemu_chr_fe_disconnect(chr); + s->test_flags =3D TEST_FLAGS_BAD; + } +} + +static void vu_blk_get_protocol_features(TestServer *s, + CharBackend *chr, VhostUserMsg *msg) +{ + /* send back features to qemu */ + msg->flags |=3D VHOST_USER_REPLY_MASK; + msg->size =3D sizeof(m.payload.u64); + msg->payload.u64 =3D 1 << VHOST_USER_PROTOCOL_F_LOG_SHMFD; + msg->payload.u64 |=3D 1 << VHOST_USER_PROTOCOL_F_CONFIG; + if (s->queues > 1) { + msg->payload.u64 |=3D 1 << VHOST_USER_PROTOCOL_F_MQ; + } + qemu_chr_fe_write_all(chr, (uint8_t *)msg, VHOST_USER_HDR_SIZE + msg->= size); +} + +static void vu_blk_get_config(TestServer *s, CharBackend *chr, + VhostUserMsg *msg) +{ + VhostUserConfig *config; + struct virtio_blk_config *blk_config; + + config =3D &msg->payload.config; + memset(config, 0, sizeof(*config)); + config->size =3D sizeof(*blk_config); + + blk_config =3D (struct virtio_blk_config *)&config->region; + /* + * Represent 128Mb test disk, with no real backend, just + * to test vhost-user functionality. + */ + blk_config->capacity =3D 262144; + blk_config->size_max =3D 0x20000; + blk_config->seg_max =3D 0x7e; + blk_config->blk_size =3D 512; + blk_config->min_io_size =3D 0x1; + blk_config->num_queues =3D 0x1; + + msg->size =3D sizeof(*config) - sizeof(config->region) + config->size; + msg->flags |=3D VHOST_USER_REPLY_MASK; + qemu_chr_fe_write_all(chr, (uint8_t *)msg, VHOST_USER_HDR_SIZE + msg->= size); +} + /* Each VHOST-USER device should have its ops structure defined. */ static struct vhost_user_ops g_vu_net_ops =3D { .type =3D VHOST_USER_NET, @@ -970,6 +1084,17 @@ static struct vhost_user_ops g_vu_net_ops =3D { .get_protocol_features =3D vu_net_get_protocol_features, }; =20 +static struct vhost_user_ops g_vu_blk_ops =3D { + .type =3D VHOST_USER_BLK, + + .append_opts =3D append_vhost_blk_opts, + .driver_init =3D vu_blk_driver_init, + + .set_features =3D vu_blk_set_features, + .get_protocol_features =3D vu_blk_get_protocol_features, + .get_config =3D vu_blk_get_config, +}; + static void register_vhost_user_test(void) { QOSGraphTestOptions opts =3D { @@ -1015,5 +1140,16 @@ static void register_vhost_user_test(void) qos_add_test("vhost-user/multiqueue", "virtio-net", test_multiqueue, &opts); + opts.edge.extra_device_opts =3D NULL; + + /* vhost-user-blk tests */ + opts.arg =3D &g_vu_blk_ops; + opts.before =3D vhost_user_test_setup_reconnect; + qos_add_test("reconnect", "vhost-user-blk", + test_reconnect, &opts); + + opts.before =3D vhost_user_test_setup_memfd; + qos_add_test("migrate", "vhost-user-blk", + test_migrate, &opts); } libqos_init(register_vhost_user_test); --=20 2.7.4 From nobody Thu May 16 05:32:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1596537769; cv=none; d=zohomail.com; s=zohoarc; b=FpCYOli4moUBD1q3b68xDeHA9mhUXcVeHdAB3IMLWVg5Rdstf395GEiKjcMNGA8jOffepWWgucdUvbP0WMuBYq/FfIdI5odnfxvXsLWn8vOt1X5F3cY7s20mfQQBObBV8/SLRXfknXzv2rtrivrLeqG85RM52lraa2hBMM3xp30= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596537769; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=q0+U/QfA4vXjDbbbTSlxDOvBDrzv7zTyuZdj9kiei3s=; b=M19s2A32oD818DRVw8rkZ/enjWQP2G3dSMhwB4VAmeneNK9t3HKnqNduE7efJY/rWI7KMFblK8OWwNzJ319+0dIi5wKiiNiN6+t8K7dgVJOzZvYeaF44YD0Spa/aqT6sFQfaK+YQcE4JISjwuFlSJPLz484GPMswbg6FVQFMvJc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596537769935502.10112689779; Tue, 4 Aug 2020 03:42:49 -0700 (PDT) Received: from localhost ([::1]:50686 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k2uPA-0008Eu-Km for importer@patchew.org; Tue, 04 Aug 2020 06:42:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41232) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2uKj-0001io-Hq; Tue, 04 Aug 2020 06:38:13 -0400 Received: from forwardcorp1o.mail.yandex.net ([95.108.205.193]:54922) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2uKg-0002O9-NN; Tue, 04 Aug 2020 06:38:13 -0400 Received: from iva8-d077482f1536.qloud-c.yandex.net (iva8-d077482f1536.qloud-c.yandex.net [IPv6:2a02:6b8:c0c:2f26:0:640:d077:482f]) by forwardcorp1o.mail.yandex.net (Yandex) with ESMTP id DD22B2E1907; Tue, 4 Aug 2020 13:38:08 +0300 (MSK) Received: from iva8-88b7aa9dc799.qloud-c.yandex.net (iva8-88b7aa9dc799.qloud-c.yandex.net [2a02:6b8:c0c:77a0:0:640:88b7:aa9d]) by iva8-d077482f1536.qloud-c.yandex.net (mxbackcorp/Yandex) with ESMTP id 3HIdyhBNPn-c3tKRGYZ; Tue, 04 Aug 2020 13:38:08 +0300 Received: from dynamic-vpn.dhcp.yndx.net (dynamic-vpn.dhcp.yndx.net [2a02:6b8:b081:2::1:a]) by iva8-88b7aa9dc799.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id ZZLKBSFEhl-bxiWDAkJ; Tue, 04 Aug 2020 13:37:59 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) Precedence: bulk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1596537488; bh=q0+U/QfA4vXjDbbbTSlxDOvBDrzv7zTyuZdj9kiei3s=; h=In-Reply-To:In-Reply-To:Message-Id:References:References:Date: Subject:To:From:Cc; b=1uYlIH+Ixu7KKSd474L3quV6smv1Pm9SqWsudowdSnEH41/Hork76Lh/Dzkxn27oy HgzUaQ8SYbeZBwwGkDLlofDS/yPXGbJQor+HXgiWwdvhLRUhe2H8vIkQZem179ZkRn xwNttXC5zPgPGYYh9Ms79ypXtvPoJb4BpbQeXS0U= Authentication-Results: iva8-d077482f1536.qloud-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Dima Stepanov To: qemu-devel@nongnu.org Subject: [PATCH v1 6/7] tests/qtest/vhost-user-test: add migrate_reconnect test Date: Tue, 4 Aug 2020 13:36:51 +0300 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: 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: pass client-ip=95.108.205.193; envelope-from=dimastep@yandex-team.ru; helo=forwardcorp1o.mail.yandex.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/04 06:37:25 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, lvivier@redhat.com, thuth@redhat.com, qemu-block@nongnu.org, mst@redhat.com, jasowang@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, fengli@smartx.com, yc-core@yandex-team.ru, pbonzini@redhat.com, raphael.norwitz@nutanix.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add new migrate_reconnect test for the vhost-user-blk device. Perform a disconnect after sending response for the VHOST_USER_SET_LOG_BASE command. Signed-off-by: Dima Stepanov --- tests/qtest/vhost-user-test.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index 9b6e202..6b4c147 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -146,6 +146,7 @@ static VhostUserMsg m __attribute__ ((unused)); enum { TEST_FLAGS_OK, TEST_FLAGS_DISCONNECT, + TEST_FLAGS_MIGRATE_DISCONNECT, TEST_FLAGS_BAD, TEST_FLAGS_END, }; @@ -436,6 +437,15 @@ static void chr_read(void *opaque, const uint8_t *buf,= int size) qemu_chr_fe_write_all(chr, p, VHOST_USER_HDR_SIZE); =20 g_cond_broadcast(&s->data_cond); + /* + * Perform disconnect after sending a response. In this + * case the next write command on the QEMU side (for now + * it is SET_FEATURES will return -1, because of disconnect. + */ + if (s->test_flags =3D=3D TEST_FLAGS_MIGRATE_DISCONNECT) { + qemu_chr_fe_disconnect(chr); + s->test_flags =3D TEST_FLAGS_BAD; + } break; =20 case VHOST_USER_SET_VRING_BASE: @@ -737,6 +747,17 @@ static void *vhost_user_test_setup_memfd(GString *cmd_= line, void *arg) return server; } =20 +static void *vhost_user_test_setup_migrate_reconnect(GString *cmd_line, + void *arg) +{ + TestServer *server; + + server =3D vhost_user_test_setup_memfd(cmd_line, arg); + server->test_flags =3D TEST_FLAGS_MIGRATE_DISCONNECT; + + return server; +} + static void test_read_guest_mem(void *obj, void *arg, QGuestAllocator *all= oc) { TestServer *server =3D arg; @@ -1151,5 +1172,9 @@ static void register_vhost_user_test(void) opts.before =3D vhost_user_test_setup_memfd; qos_add_test("migrate", "vhost-user-blk", test_migrate, &opts); + + opts.before =3D vhost_user_test_setup_migrate_reconnect; + qos_add_test("migrate_reconnect", "vhost-user-blk", + test_migrate, &opts); } libqos_init(register_vhost_user_test); --=20 2.7.4 From nobody Thu May 16 05:32:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1596537621; cv=none; d=zohomail.com; s=zohoarc; b=hHiPXmGYcMsO2syNUqsPAJRykCGRKESE2Vsd9n8OuoVPmgVGsCO3RonE8g1HSoC63amYn2mN1eu7PifdaI+eRdyeS3v5sHo3REnZt0Y3cdNE+p5vUsBwhHDg4bOmfO7pTvjl0yvV0iliE23HOt+lroqPeSGi0v18w9wtnrLKhbc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596537621; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=qZtCbGhJqHabu/WbWL7vzAIYFZMpA47m/YOq18cRKO0=; b=YnOWx7qOd9uopTq3mP4Ij+SwT7/k96ghbXfQnOfmH8spiJFVfflCB/fJD35v3HEusI8Mi2QaNXHThTK8d3LcpHgz5f0hOu4gbkCKF9lcsxscsUWBEGn+3iTdmVsCHJBccf33loF9PnUhVp8n2dmm/0lj8NlMcWCBWtZw7SFR8us= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596537621515318.76392401594546; Tue, 4 Aug 2020 03:40:21 -0700 (PDT) Received: from localhost ([::1]:39808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k2uMm-0003jg-7y for importer@patchew.org; Tue, 04 Aug 2020 06:40:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2uKn-0001rw-Po; Tue, 04 Aug 2020 06:38:17 -0400 Received: from forwardcorp1o.mail.yandex.net ([2a02:6b8:0:1a2d::193]:41102) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2uKl-0002P8-Pm; Tue, 04 Aug 2020 06:38:17 -0400 Received: from iva8-d077482f1536.qloud-c.yandex.net (iva8-d077482f1536.qloud-c.yandex.net [IPv6:2a02:6b8:c0c:2f26:0:640:d077:482f]) by forwardcorp1o.mail.yandex.net (Yandex) with ESMTP id BAF2F2E1906; Tue, 4 Aug 2020 13:38:13 +0300 (MSK) Received: from iva8-88b7aa9dc799.qloud-c.yandex.net (iva8-88b7aa9dc799.qloud-c.yandex.net [2a02:6b8:c0c:77a0:0:640:88b7:aa9d]) by iva8-d077482f1536.qloud-c.yandex.net (mxbackcorp/Yandex) with ESMTP id 3bysB47OtS-cAt8lAti; Tue, 04 Aug 2020 13:38:13 +0300 Received: from dynamic-vpn.dhcp.yndx.net (dynamic-vpn.dhcp.yndx.net [2a02:6b8:b081:2::1:a]) by iva8-88b7aa9dc799.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id ZZLKBSFEhl-cAiWYiYN; Tue, 04 Aug 2020 13:38:10 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) Precedence: bulk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1596537493; bh=qZtCbGhJqHabu/WbWL7vzAIYFZMpA47m/YOq18cRKO0=; h=In-Reply-To:In-Reply-To:Message-Id:References:References:Date: Subject:To:From:Cc; b=WmYYb+XSWgtKiFZN8qTFnk4rsYHmtWp4191KFYhYJtgJEGuGqIeiSRNjmVzYpPIRV nRaTqtleA7PJx1HYRWNGU/nP/2pUPtgdO7EQ1TU2JJ4q2iVS4ZXfkj7aqnSigelhVX lC74Yx+ePy+K5EjcbZbFJQWlxaxP7yz4I+tXkO/Y= Authentication-Results: iva8-d077482f1536.qloud-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Dima Stepanov To: qemu-devel@nongnu.org Subject: [PATCH v1 7/7] tests/qtest/vhost-user-test: enable the reconnect tests Date: Tue, 4 Aug 2020 13:36:52 +0300 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: 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: pass client-ip=2a02:6b8:0:1a2d::193; envelope-from=dimastep@yandex-team.ru; helo=forwardcorp1o.mail.yandex.net X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, lvivier@redhat.com, thuth@redhat.com, qemu-block@nongnu.org, mst@redhat.com, jasowang@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, fengli@smartx.com, yc-core@yandex-team.ru, pbonzini@redhat.com, raphael.norwitz@nutanix.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" For now a QTEST_VHOST_USER_FIXME environment variable is used to separate reconnect tests for the vhost-user-net device. Looks like the reconnect functionality is pretty stable, so this separation is deprecated. Remove it and enable these tests for the default run. Signed-off-by: Dima Stepanov --- tests/qtest/vhost-user-test.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index 6b4c147..5fbfa02 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -1141,20 +1141,17 @@ static void register_vhost_user_test(void) "virtio-net", test_migrate, &opts); =20 - /* keeps failing on build-system since Aug 15 2017 */ - if (getenv("QTEST_VHOST_USER_FIXME")) { - opts.before =3D vhost_user_test_setup_reconnect; - qos_add_test("vhost-user/reconnect", "virtio-net", - test_reconnect, &opts); - - opts.before =3D vhost_user_test_setup_connect_fail; - qos_add_test("vhost-user/connect-fail", "virtio-net", - test_vhost_user_started, &opts); - - opts.before =3D vhost_user_test_setup_flags_mismatch; - qos_add_test("vhost-user/flags-mismatch", "virtio-net", - test_vhost_user_started, &opts); - } + opts.before =3D vhost_user_test_setup_reconnect; + qos_add_test("vhost-user/reconnect", "virtio-net", + test_reconnect, &opts); + + opts.before =3D vhost_user_test_setup_connect_fail; + qos_add_test("vhost-user/connect-fail", "virtio-net", + test_vhost_user_started, &opts); + + opts.before =3D vhost_user_test_setup_flags_mismatch; + qos_add_test("vhost-user/flags-mismatch", "virtio-net", + test_vhost_user_started, &opts); =20 opts.before =3D vhost_user_test_setup_multiqueue; opts.edge.extra_device_opts =3D "mq=3Don"; --=20 2.7.4