From patchwork Wed Jun 12 13:01:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefano Garzarella X-Patchwork-Id: 13694963 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B8D45C27C77 for ; Wed, 12 Jun 2024 13:11:20 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sHNeQ-0001af-Jj; Wed, 12 Jun 2024 09:04:30 -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 1sHNeP-0001ZW-40 for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:04:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sHNeM-0008Nh-Lh for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:04:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718197465; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CNfNqVgiPACxEos23z/KKmFGM3slQs8eIq4L2oKEPI8=; b=Gh07k2mtdYco7sYT1ea34wJHSQY83NpCI3KQ9SPoahXGgyvQIdxRnuSEbTOoyB9Dtnbuu5 BgeELFk20plS3g8AQUH8BoMCW/b1wXOMz0QkGXxro1H7GEsS9EWXY69vDXIWVRJQFNdVbP +PvstDRGhu354Ytgfn7/9AHrb5uIaVQ= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-568-jfPk6O73Ote8RQq93H_QrA-1; Wed, 12 Jun 2024 09:04:24 -0400 X-MC-Unique: jfPk6O73Ote8RQq93H_QrA-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-79557d418e0so131003685a.1 for ; Wed, 12 Jun 2024 06:04:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718197464; x=1718802264; 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=CNfNqVgiPACxEos23z/KKmFGM3slQs8eIq4L2oKEPI8=; b=L0EYmE39n7iOvj1HMgB/dxZ/Pc9Jzpx+wVab/DpxToK/A6+JO0ISWYT92Lo9P9CIWA dOsM2BzD9zc1rEBKxSBzU51wgmGPud4MRt8VVclggOS2Eq9VCWIYEvd4PWKuklbBYU65 pFcOuqypFmsW7Nb7QAlNxXjOFX2bdVduG9Gt+1WWTthPbwAXg552Kum8x8iNsAxYaypf q3FwgMjsjQt7YqbxIZ2VpfMsKWnxEgj/4IVWiEEkAo5tHU8pTb6S4QQGzr4CmgkNFK/j YT2G0RRx1VtnajMzk9renFJLvcSEDR6U0kGFGR0SF4Eab1sB4HJ8ZD1FHxtL/MaErsLw nunw== X-Forwarded-Encrypted: i=1; AJvYcCVeAEG53k2YOK4aUPAV1KcwYXZ2tDbUeJ9vLX/2cHoYy8917PTes9ZFenv3ETsx1wKvyyMYewUrPPPEBwxwv5eOpVAhf+4= X-Gm-Message-State: AOJu0YxIU2TS9jJ7uu5dxXujoJjK6UNh0Zk61mLh40S0qxu7FER572wU 606HcYAXsrwaISFAPloraSBebVsn9P5uag69OxvIcncE5dfe65QnlaCG3gPX7UF9ks4swH2tJwr ITtA10mnrnpz7YCKDj4melFbHvwr7peMtp8sVZrL/7BN410x2x+O3 X-Received: by 2002:a05:620a:248f:b0:796:de79:f577 with SMTP id af79cd13be357-797f4db46a5mr305670185a.7.1718197463884; Wed, 12 Jun 2024 06:04:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IES+eNDH7l0fcQFSgjZd9Cgd67bs3haFZfc6vWAj9INn10tsrsp40myO8ciHKmvP6uZ+4jnYQ== X-Received: by 2002:a05:620a:248f:b0:796:de79:f577 with SMTP id af79cd13be357-797f4db46a5mr305663385a.7.1718197463336; Wed, 12 Jun 2024 06:04:23 -0700 (PDT) Received: from step1.redhat.com ([193.207.132.52]) by smtp.gmail.com with ESMTPSA id af79cd13be357-797e8f4906bsm122685485a.80.2024.06.12.06.04.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 06:04:21 -0700 (PDT) From: Stefano Garzarella To: mst@redhat.com, qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Hanna Reitz , Brad Smith , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Marc?= =?utf-8?q?-Andr=C3=A9_Lureau?= , Laurent Vivier , gmaglione@redhat.com, stefanha@redhat.com, Coiby Xu , Gerd Hoffmann , slp@redhat.com, Igor Mammedov , Raphael Norwitz , Thomas Huth , Eduardo Habkost , David Hildenbrand , Kevin Wolf , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jason Wang , Markus Armbruster , Eric Blake , Stefano Garzarella Subject: [PATCH RESEND v7 12/12] tests/qtest/vhost-user-test: add a test case for memory-backend-shm Date: Wed, 12 Jun 2024 15:01:40 +0200 Message-ID: <20240612130140.63004-13-sgarzare@redhat.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240612130140.63004-1-sgarzare@redhat.com> References: <20240612130140.63004-1-sgarzare@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=sgarzare@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org `memory-backend-shm` can be used with vhost-user devices, so let's add a new test case for it. Acked-by: Thomas Huth Acked-by: Stefan Hajnoczi Reviewed-by: David Hildenbrand Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Stefano Garzarella --- tests/qtest/vhost-user-test.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index d4e437265f..8c1d903b2a 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -44,6 +44,8 @@ "mem-path=%s,share=on -numa node,memdev=mem" #define QEMU_CMD_MEMFD " -m %d -object memory-backend-memfd,id=mem,size=%dM," \ " -numa node,memdev=mem" +#define QEMU_CMD_SHM " -m %d -object memory-backend-shm,id=mem,size=%dM," \ + " -numa node,memdev=mem" #define QEMU_CMD_CHR " -chardev socket,id=%s,path=%s%s" #define QEMU_CMD_NETDEV " -netdev vhost-user,id=hs0,chardev=%s,vhostforce=on" @@ -195,6 +197,7 @@ enum test_memfd { TEST_MEMFD_AUTO, TEST_MEMFD_YES, TEST_MEMFD_NO, + TEST_MEMFD_SHM, }; static void append_vhost_net_opts(TestServer *s, GString *cmd_line, @@ -228,6 +231,8 @@ static void append_mem_opts(TestServer *server, GString *cmd_line, if (memfd == TEST_MEMFD_YES) { g_string_append_printf(cmd_line, QEMU_CMD_MEMFD, size, size); + } else if (memfd == TEST_MEMFD_SHM) { + g_string_append_printf(cmd_line, QEMU_CMD_SHM, size, size); } else { const char *root = init_hugepagefs() ? : server->tmpfs; @@ -788,6 +793,19 @@ static void *vhost_user_test_setup_memfd(GString *cmd_line, void *arg) return server; } +static void *vhost_user_test_setup_shm(GString *cmd_line, void *arg) +{ + TestServer *server = test_server_new("vhost-user-test", arg); + test_server_listen(server); + + append_mem_opts(server, cmd_line, 256, TEST_MEMFD_SHM); + server->vu_ops->append_opts(server, cmd_line, ""); + + g_test_queue_destroy(vhost_user_test_cleanup, server); + + return server; +} + static void test_read_guest_mem(void *obj, void *arg, QGuestAllocator *alloc) { TestServer *server = arg; @@ -1081,6 +1099,11 @@ static void register_vhost_user_test(void) "virtio-net", test_read_guest_mem, &opts); + opts.before = vhost_user_test_setup_shm; + qos_add_test("vhost-user/read-guest-mem/shm", + "virtio-net", + test_read_guest_mem, &opts); + if (qemu_memfd_check(MFD_ALLOW_SEALING)) { opts.before = vhost_user_test_setup_memfd; qos_add_test("vhost-user/read-guest-mem/memfd",