From nobody Tue Feb 10 04:29:42 2026 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1677618990; cv=none; d=zohomail.com; s=zohoarc; b=CyBZBefhyZ6vIL1iG+csLOvEm7ikw2/YdccU73aoz9QXmyboLqupdwXYCvaCgM/SenAyD/DaTUbj64kBZDHGTEX6EtD98nL7DL9DwRWCqjcHJOJurtIFrW1yTXWc40wd7OngMxJKJM2kctG/vD0BwZVoAdRFRmNZQPbiRsErnYQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677618990; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=91xrWNrIFc5KJYlLZr/qQHRa5CP3dakRgPr1I+HWECc=; b=V5Id7HRCHbj6EunXXAUZusjvuOsx8DQwGMbViu/l11wv8287TxKJLhTH+iS0Ic17LU9FtQMZyd4nFRucPwqi1KdbhvfZ4e3BDVuGUpvuGNqEZYJAhItSG3/57cBT4/3Ew5oDhsbqYgWq7RziGcn9gYOgM4X7pCWzbNwa4+/qy7k= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167761899055254.71382857303706; Tue, 28 Feb 2023 13:16:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pX7KE-0004PD-Uv; Tue, 28 Feb 2023 16:15:54 -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 1pX7K9-0004OB-TL for qemu-devel@nongnu.org; Tue, 28 Feb 2023 16:15:53 -0500 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 1pX7K8-0004LH-4y for qemu-devel@nongnu.org; Tue, 28 Feb 2023 16:15:49 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-512-5y6mXw66OOSIvewGsAE1lg-1; Tue, 28 Feb 2023 16:15:43 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E0AE91C04191; Tue, 28 Feb 2023 21:15:42 +0000 (UTC) Received: from thuth.com (unknown [10.39.192.105]) by smtp.corp.redhat.com (Postfix) with ESMTP id F066040C6EC4; Tue, 28 Feb 2023 21:15:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677618947; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=91xrWNrIFc5KJYlLZr/qQHRa5CP3dakRgPr1I+HWECc=; b=RC6kmTYt+aby5fQH5Ms0dDCA7TZ0ctUdJ3uNxinYob3tof3OkpZmTuCUNO7h1HjHfM5592 UeMLJsStp2RT86gmvHWjuF1+tWOa6rPscJtIao1wUsoPWqB1pc5Ki47hBvfONr0IjrrUW6 fTV/iD9mJv2gcGXJaCqZWpsYGdZnMws= X-MC-Unique: 5y6mXw66OOSIvewGsAE1lg-1 From: Thomas Huth To: Paolo Bonzini , qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier Subject: [PATCH 1/6] tests/qtest/readconfig: Rework test_object_rng_resp into a generic function Date: Tue, 28 Feb 2023 22:15:28 +0100 Message-Id: <20230228211533.201837-2-thuth@redhat.com> In-Reply-To: <20230228211533.201837-1-thuth@redhat.com> References: <20230228211533.201837-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 @redhat.com) X-ZM-MESSAGEID: 1677618992035100003 Content-Type: text/plain; charset="utf-8" test_object_rng_resp() can be reworked quite easily to allow testing for arbitrary objects in the qom-list response. Signed-off-by: Thomas Huth --- tests/qtest/readconfig-test.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/qtest/readconfig-test.c b/tests/qtest/readconfig-test.c index 9ef870643d..26d79b5e4b 100644 --- a/tests/qtest/readconfig-test.c +++ b/tests/qtest/readconfig-test.c @@ -124,13 +124,15 @@ static void test_spice(void) } #endif =20 -static void test_object_rng_resp(QObject *res) +static void test_object_available(QObject *res, const char *name, + const char *type) { Visitor *v; g_autoptr(ObjectPropertyInfoList) objs =3D NULL; ObjectPropertyInfoList *tmp; ObjectPropertyInfo *obj; - bool seen_rng =3D false; + bool object_available =3D false; + g_autofree char *childtype =3D g_strdup_printf("child<%s>", type); =20 g_assert(res); v =3D qobject_input_visitor_new(res); @@ -142,16 +144,15 @@ static void test_object_rng_resp(QObject *res) g_assert(tmp->value); =20 obj =3D tmp->value; - if (g_str_equal(obj->name, "rng0") && - g_str_equal(obj->type, "child")) { - seen_rng =3D true; + if (g_str_equal(obj->name, name) && g_str_equal(obj->type, childty= pe)) { + object_available =3D true; break; } =20 tmp =3D tmp->next; } =20 - g_assert(seen_rng); + g_assert(object_available); =20 visit_free(v); } @@ -170,7 +171,7 @@ static void test_object_rng(void) resp =3D qtest_qmp(qts, "{ 'execute': 'qom-list'," " 'arguments': {'path': '/objects' }}"); - test_object_rng_resp(qdict_get(resp, "return")); + test_object_available(qdict_get(resp, "return"), "rng0", "rng-builtin"= ); qobject_unref(resp); =20 qtest_quit(qts); --=20 2.31.1 From nobody Tue Feb 10 04:29:42 2026 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1677619099; cv=none; d=zohomail.com; s=zohoarc; b=KdAHY83MnybYwFWBtwqO3QHIhrRmNdIr9lIycZpYFbgB8ksomKkACJkijK7Pw1u2glG22wGjzi/9IPFa76Z7n5Ha90UwSgZ8wi8B3333LSN+LfiWCm/+00PBHgNzCquvmEoS+3FTHahxwk0/GO2QYJ7Zj3pM+5qZYzKkQhY8jg8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677619099; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ap120i6BZ6AChi8u7XZe0nrIJdZJLwjXQyMn66atFlg=; b=C+hIePZhMzjcRDc+Mx8vvxM/9dvkhvAel9Yvr0GNgwZZo3lRVk09ty7+CjDFVNisL9+SNGgZEpK1IsIXs5c8J6PAOsNpEP7ZKVizybHLtEuZKa6QlPisf7IC2s4vhcDn5MaHRYZhNiLSo+NxLrHEt8jy1wxP4Xvpbkm/i3HRRAU= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167761909966868.72085714232344; Tue, 28 Feb 2023 13:18:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pX7Kl-0004Zh-BZ; Tue, 28 Feb 2023 16:16:27 -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 1pX7Ki-0004ZM-Of for qemu-devel@nongnu.org; Tue, 28 Feb 2023 16:16:24 -0500 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 1pX7Kh-0004QR-AD for qemu-devel@nongnu.org; Tue, 28 Feb 2023 16:16:24 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-554-bFuvmBDOPIWxriQ0j046lA-1; Tue, 28 Feb 2023 16:15:56 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6B368811E9C; Tue, 28 Feb 2023 21:15:44 +0000 (UTC) Received: from thuth.com (unknown [10.39.192.105]) by smtp.corp.redhat.com (Postfix) with ESMTP id 60F2340C6EC4; Tue, 28 Feb 2023 21:15:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677618981; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ap120i6BZ6AChi8u7XZe0nrIJdZJLwjXQyMn66atFlg=; b=cDtFwBhK8R3lV2XevRUzkG2DuFY4C1zVuafpPBLg/tgoE2ypncfqfRIU21M9WuCYpEDGUa zuNTsVIoPeRuc7vLGrou5AD+AhCXemW28XYFq2VmGWMIvae/AopDl/ilUvq/teoSzO9+DY HOVR25coq0hzoN6v1Q2rV6U4TwpcDfw= X-MC-Unique: bFuvmBDOPIWxriQ0j046lA-1 From: Thomas Huth To: Paolo Bonzini , qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier Subject: [PATCH 2/6] tests/qtest/readconfig: Test docs/config/ich9-ehci-uhci.cfg Date: Tue, 28 Feb 2023 22:15:29 +0100 Message-Id: <20230228211533.201837-3-thuth@redhat.com> In-Reply-To: <20230228211533.201837-1-thuth@redhat.com> References: <20230228211533.201837-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 @redhat.com) X-ZM-MESSAGEID: 1677619100409100005 Content-Type: text/plain; charset="utf-8" We've got some sample config files in docs/config/ but no means of regression checking them. Thus let's test them in our readconfig qtest, starting with ich9-ehci-uhci.cfg. Note: To enable the test to read the config files from the build folder, we have to install a symlink for docs/config in the build directory. Signed-off-by: Thomas Huth --- configure | 1 + tests/qtest/readconfig-test.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/configure b/configure index dccb5d4f96..4331fead78 100755 --- a/configure +++ b/configure @@ -2215,6 +2215,7 @@ fi # tests might fail. Prefer to keep the relevant files in their own # directory and symlink the directory instead. LINKS=3D"Makefile" +LINKS=3D"$LINKS docs/config" LINKS=3D"$LINKS pc-bios/optionrom/Makefile" LINKS=3D"$LINKS pc-bios/s390-ccw/Makefile" LINKS=3D"$LINKS pc-bios/vof/Makefile" diff --git a/tests/qtest/readconfig-test.c b/tests/qtest/readconfig-test.c index 26d79b5e4b..2160603880 100644 --- a/tests/qtest/readconfig-test.c +++ b/tests/qtest/readconfig-test.c @@ -177,6 +177,26 @@ static void test_object_rng(void) qtest_quit(qts); } =20 +static void test_docs_config_ich9(void) +{ + QTestState *qts; + QDict *resp; + QObject *qobj; + + qts =3D qtest_initf("-nodefaults -readconfig docs/config/ich9-ehci-uhc= i.cfg"); + + resp =3D qtest_qmp(qts, "{ 'execute': 'qom-list'," + " 'arguments': {'path': '/machine/peripheral' }= }"); + qobj =3D qdict_get(resp, "return"); + test_object_available(qobj, "ehci", "ich9-usb-ehci1"); + test_object_available(qobj, "uhci-1", "ich9-usb-uhci1"); + test_object_available(qobj, "uhci-2", "ich9-usb-uhci2"); + test_object_available(qobj, "uhci-3", "ich9-usb-uhci3"); + qobject_unref(resp); + + qtest_quit(qts); +} + int main(int argc, char *argv[]) { const char *arch; @@ -187,6 +207,7 @@ int main(int argc, char *argv[]) if (g_str_equal(arch, "i386") || g_str_equal(arch, "x86_64")) { qtest_add_func("readconfig/x86/memdev", test_x86_memdev); + qtest_add_func("readconfig/x86/ich9-ehci-uhci", test_docs_config_i= ch9); } #ifdef CONFIG_SPICE qtest_add_func("readconfig/spice", test_spice); --=20 2.31.1 From nobody Tue Feb 10 04:29:42 2026 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1677619021; cv=none; d=zohomail.com; s=zohoarc; b=P6/6cv9cxKxy96W6HdPiPgupGzkiylSe5w6mZ4aTZXb9lzd8lsmRAplD7EY70Z+Pi4EQs4pUUAPqfa6dg4gQlNaIpG07Pe6elVRBgyCnFE70Qxzt9VwrVm7qnA7QNFXEvgY0JGKXAvXkWmgN+wWXmrM6TBEYy2o4mAsTdibI3xs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677619021; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ty0CpmuPbm7lxdYiWy2xbMLW7aVn2k8hXr8E+HzIdhM=; b=BZmKwrE86BElkg+RTVmAl9pjRo/kd9HMOGLXt5CBpd5JrbjoL/RthQN1fbRjhohKT0wJQVb/BizsvrGYJd18t87MQR0wRu6Y46LELHxXiqKpGr+GsC/uB2ilWCR+1xpPjFf9tRMkZpWYcUGA3j/2BUwWd4Vy04Fxr4BjgCXAQLc= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677619021979246.57062497365382; Tue, 28 Feb 2023 13:17:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pX7KG-0004Rb-MW; Tue, 28 Feb 2023 16:15:56 -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 1pX7KB-0004OH-Gv for qemu-devel@nongnu.org; Tue, 28 Feb 2023 16:15:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pX7KA-0004Lc-0c for qemu-devel@nongnu.org; Tue, 28 Feb 2023 16:15:51 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-395-JRRx7JQPPe2DhUNIBv2VNQ-1; Tue, 28 Feb 2023 16:15:46 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B4FC98828C1; Tue, 28 Feb 2023 21:15:45 +0000 (UTC) Received: from thuth.com (unknown [10.39.192.105]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF48940C6EC4; Tue, 28 Feb 2023 21:15:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677618949; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ty0CpmuPbm7lxdYiWy2xbMLW7aVn2k8hXr8E+HzIdhM=; b=KmGMKIPBDGn1MLUM86pxrkzXU6xPM616FtxAjL0L0a1shP0dWIf+aDq4MudfX2HmVbV5RO PnICG38QGyFtgS9zPQR2rnnxeGoJ0r7t2YbZFE6DSmVzjD/7T0RDhvEdoUaNmhncTFP2Ex U4ilFBmM+edFXJgvQNaZ/kgBe7sYfz4= X-MC-Unique: JRRx7JQPPe2DhUNIBv2VNQ-1 From: Thomas Huth To: Paolo Bonzini , qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier Subject: [PATCH 3/6] docs/config: Set the "kvm" accelerator via "[accel]" section Date: Tue, 28 Feb 2023 22:15:30 +0100 Message-Id: <20230228211533.201837-4-thuth@redhat.com> In-Reply-To: <20230228211533.201837-1-thuth@redhat.com> References: <20230228211533.201837-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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=170.10.129.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 @redhat.com) X-ZM-MESSAGEID: 1677619023913100003 Content-Type: text/plain; charset="utf-8" Configuring the accelerator should nowadays be done via the "-accel" command line parameter, and thus via the "[accel]" section in config files. We also need this change for the upcoming qtests that will use these config files, since the qtests are already using "-accel" for setting the "qtest" accelerator and QEMU does not like mixing "-accel ..." and "-machine accel=3D...". Signed-off-by: Thomas Huth --- docs/config/mach-virt-graphical.cfg | 4 +++- docs/config/mach-virt-serial.cfg | 4 +++- docs/config/q35-emulated.cfg | 2 ++ docs/config/q35-virtio-graphical.cfg | 2 ++ docs/config/q35-virtio-serial.cfg | 2 ++ 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/config/mach-virt-graphical.cfg b/docs/config/mach-virt-gr= aphical.cfg index d6d31b17f5..eba76eb198 100644 --- a/docs/config/mach-virt-graphical.cfg +++ b/docs/config/mach-virt-graphical.cfg @@ -56,9 +56,11 @@ =20 [machine] type =3D "virt" - accel =3D "kvm" gic-version =3D "host" =20 +[accel] + accel =3D "kvm" + [memory] size =3D "1024" =20 diff --git a/docs/config/mach-virt-serial.cfg b/docs/config/mach-virt-seria= l.cfg index 18a7c83731..324b0542ff 100644 --- a/docs/config/mach-virt-serial.cfg +++ b/docs/config/mach-virt-serial.cfg @@ -62,9 +62,11 @@ =20 [machine] type =3D "virt" - accel =3D "kvm" gic-version =3D "host" =20 +[accel] + accel =3D "kvm" + [memory] size =3D "1024" =20 diff --git a/docs/config/q35-emulated.cfg b/docs/config/q35-emulated.cfg index 99ac918e78..c8806e6d36 100644 --- a/docs/config/q35-emulated.cfg +++ b/docs/config/q35-emulated.cfg @@ -61,6 +61,8 @@ =20 [machine] type =3D "q35" + +[accel] accel =3D "kvm" =20 [memory] diff --git a/docs/config/q35-virtio-graphical.cfg b/docs/config/q35-virtio-= graphical.cfg index 4207f11e4f..148b5d2c5e 100644 --- a/docs/config/q35-virtio-graphical.cfg +++ b/docs/config/q35-virtio-graphical.cfg @@ -55,6 +55,8 @@ =20 [machine] type =3D "q35" + +[accel] accel =3D "kvm" =20 [memory] diff --git a/docs/config/q35-virtio-serial.cfg b/docs/config/q35-virtio-ser= ial.cfg index d2830aec5e..023291390e 100644 --- a/docs/config/q35-virtio-serial.cfg +++ b/docs/config/q35-virtio-serial.cfg @@ -60,6 +60,8 @@ =20 [machine] type =3D "q35" + +[accel] accel =3D "kvm" =20 [memory] --=20 2.31.1 From nobody Tue Feb 10 04:29:42 2026 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1677618991; cv=none; d=zohomail.com; s=zohoarc; b=UrWi8KghnyK4X+R2uivLwFYiFaPa5piAO0wboWKluZ1Sw8F4BiU9cAf0u8W/Nl0ZoRpDiCFENOq+49lfe8tmA+X2wf5xDD3IVGi7AYmjma7uQyEzG8qaKVB4FOViXx7F0s1DKaW1U0La+nnUgKGrWA2FmiJOA8TIpgIAjwLSjU4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677618991; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XnnWKKTt/Jd/lhXQoVvXu5e26trL+RnjsW3fkNmubwk=; b=VnhI+CXTSL6ueKan2QClhJquDWGxox5Fa91iPgskRQAraqhJ/B5B5UYiEsl08Vg2gB9rdkdhjA1uX2XUAGd3pBwmZGesGxaSiAEQoyBUoTniaa6gRMvTFVxlWG8dPlUUhzdvpiPhirwxX4Z+v+9ShSfnU7T3LpwY/WM4pThSfrI= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677618991347270.43443463906124; Tue, 28 Feb 2023 13:16:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pX7KE-0004P3-N6; Tue, 28 Feb 2023 16:15:54 -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 1pX7KD-0004OS-6U for qemu-devel@nongnu.org; Tue, 28 Feb 2023 16:15:53 -0500 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 1pX7KB-0004Lv-QT for qemu-devel@nongnu.org; Tue, 28 Feb 2023 16:15:52 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-516-Y0I8oD_HMs-5sHDkANj9MQ-1; Tue, 28 Feb 2023 16:15:47 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3216980D0F1; Tue, 28 Feb 2023 21:15:47 +0000 (UTC) Received: from thuth.com (unknown [10.39.192.105]) by smtp.corp.redhat.com (Postfix) with ESMTP id 089A840C6EC4; Tue, 28 Feb 2023 21:15:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677618950; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XnnWKKTt/Jd/lhXQoVvXu5e26trL+RnjsW3fkNmubwk=; b=ZnG92HC1wnnJHnVzLPZ2ykHza1j1jRXyP5xjRserCF2nCt89SesCv+FzehCoFUDoBNivcp BPPGBXJVeD612+uQ/mTNfTBwJDgufDA6ktIExGH/MAeEpBMkO5dyXZQLJxLAkpWIDdLii0 xQYkP/c7WT3bwRn0PmkXwcBitiBweNM= X-MC-Unique: Y0I8oD_HMs-5sHDkANj9MQ-1 From: Thomas Huth To: Paolo Bonzini , qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier Subject: [PATCH 4/6] tests/qtest/readconfig-test: Allow testing for arbitrary memory sizes Date: Tue, 28 Feb 2023 22:15:31 +0100 Message-Id: <20230228211533.201837-5-thuth@redhat.com> In-Reply-To: <20230228211533.201837-1-thuth@redhat.com> References: <20230228211533.201837-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 @redhat.com) X-ZM-MESSAGEID: 1677618992027100001 Content-Type: text/plain; charset="utf-8" Make test_x86_memdev_resp() more flexible by allowing arbitrary memory sizes as parameter here. Signed-off-by: Thomas Huth --- tests/qtest/readconfig-test.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/qtest/readconfig-test.c b/tests/qtest/readconfig-test.c index 2160603880..533623f638 100644 --- a/tests/qtest/readconfig-test.c +++ b/tests/qtest/readconfig-test.c @@ -48,7 +48,7 @@ static QTestState *qtest_init_with_config(const char *cfg= data) return qts; } =20 -static void test_x86_memdev_resp(QObject *res) +static void test_x86_memdev_resp(QObject *res, const char *mem_id, int siz= e) { Visitor *v; g_autoptr(MemdevList) memdevs =3D NULL; @@ -63,8 +63,8 @@ static void test_x86_memdev_resp(QObject *res) g_assert(!memdevs->next); =20 memdev =3D memdevs->value; - g_assert_cmpstr(memdev->id, =3D=3D, "ram"); - g_assert_cmpint(memdev->size, =3D=3D, 200 * MiB); + g_assert_cmpstr(memdev->id, =3D=3D, mem_id); + g_assert_cmpint(memdev->size, =3D=3D, size * MiB); =20 visit_free(v); } @@ -80,7 +80,7 @@ static void test_x86_memdev(void) qts =3D qtest_init_with_config(cfgdata); /* Test valid command */ resp =3D qtest_qmp(qts, "{ 'execute': 'query-memdev' }"); - test_x86_memdev_resp(qdict_get(resp, "return")); + test_x86_memdev_resp(qdict_get(resp, "return"), "ram", 200); qobject_unref(resp); =20 qtest_quit(qts); --=20 2.31.1 From nobody Tue Feb 10 04:29:42 2026 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1677619097; cv=none; d=zohomail.com; s=zohoarc; b=XKBQCBUmcAwlBIawex/XvdpcOb0mwz4NcMYNadaaqgZCvVpCgKcJiBMk9apYkiDBBRKXpuC6In3x6YIsenDLUchkgu2QyBikDrExDAVWu4ey/Endy21rlZSLR2f5t5khYWFHWpshr59KhL0NSbHITw6TYRB7Mz1S6whCZjqtcwE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677619097; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=q+gwPRJXtooA7IGENp28yohWK+NnJYMeT1VJMQNczR0=; b=Wh9nWCeShc31uqIGzA0cerSPB0K4ysc5fBrevKi4ThYtAlmO4LjnXhWEgHZXDHc4MLXUzO7ZGjd5/3I+EuyK4uugxdCmiCS0RGiaiUoqqZzSwINELJk0X50OzLV488Zpr/xNdEki052vCBOePv0rIgWH/Yy3eLJ/xM9k9+4lwAY= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677619097584220.70321093506152; Tue, 28 Feb 2023 13:18:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pX7KF-0004Q6-Q6; Tue, 28 Feb 2023 16:15:55 -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 1pX7KE-0004P2-Ij for qemu-devel@nongnu.org; Tue, 28 Feb 2023 16:15:54 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pX7KC-0004MA-Nw for qemu-devel@nongnu.org; Tue, 28 Feb 2023 16:15:54 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-157-Y4aYiF12NhKl5omKoQEc4A-1; Tue, 28 Feb 2023 16:15:48 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8817A185A794; Tue, 28 Feb 2023 21:15:48 +0000 (UTC) Received: from thuth.com (unknown [10.39.192.105]) by smtp.corp.redhat.com (Postfix) with ESMTP id 93BC040C6EC4; Tue, 28 Feb 2023 21:15:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677618952; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q+gwPRJXtooA7IGENp28yohWK+NnJYMeT1VJMQNczR0=; b=PeN+R8cUTM0vn5nDMfluDwYVANUU4zVV6iKSqY3wJegbIweN42Q3RRmCVeSfrm+hUC/hfq uUh++EfZVkLMobfM8MbE0/4funVrJE0dxnkedjxPb1tV1NkmHuJdxD34ivIYH+FUPq6wmg ZKDxKgp7AqJv18sVPFGUzlNiU74Tmdk= X-MC-Unique: Y4aYiF12NhKl5omKoQEc4A-1 From: Thomas Huth To: Paolo Bonzini , qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier Subject: [PATCH 5/6] tests/qtest: Move mkimg() and have_qemu_img() from libqos to libqtest Date: Tue, 28 Feb 2023 22:15:32 +0100 Message-Id: <20230228211533.201837-6-thuth@redhat.com> In-Reply-To: <20230228211533.201837-1-thuth@redhat.com> References: <20230228211533.201837-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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=170.10.129.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 @redhat.com) X-ZM-MESSAGEID: 1677619098317100001 Content-Type: text/plain; charset="utf-8" These two functions can be useful for other qtests beside the qos-test, too, so move them to libqtest instead. Signed-off-by: Thomas Huth --- tests/qtest/libqos/libqos.h | 2 -- tests/qtest/libqtest.h | 21 +++++++++++++++ tests/qtest/libqos/libqos.c | 49 +--------------------------------- tests/qtest/libqtest.c | 52 +++++++++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 50 deletions(-) diff --git a/tests/qtest/libqos/libqos.h b/tests/qtest/libqos/libqos.h index 12d05b2365..c04950e2b1 100644 --- a/tests/qtest/libqos/libqos.h +++ b/tests/qtest/libqos/libqos.h @@ -27,8 +27,6 @@ QOSState *qtest_boot(QOSOps *ops, const char *cmdline_fmt= , ...) G_GNUC_PRINTF(2, 3); void qtest_common_shutdown(QOSState *qs); void qtest_shutdown(QOSState *qs); -bool have_qemu_img(void); -void mkimg(const char *file, const char *fmt, unsigned size_mb); void mkqcow2(const char *file, unsigned size_mb); void migrate(QOSState *from, QOSState *to, const char *uri); void prepare_blkdebug_script(const char *debug_fn, const char *event); diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h index fcf1c3c3b3..3380cc1f54 100644 --- a/tests/qtest/libqtest.h +++ b/tests/qtest/libqtest.h @@ -832,4 +832,25 @@ void qtest_qom_set_bool(QTestState *s, const char *pat= h, const char *property, * Returns: Value retrieved from property. */ bool qtest_qom_get_bool(QTestState *s, const char *path, const char *prope= rty); + +/** + * have_qemu_img: + * + * Returns: true if "qemu-img" is available. + */ +bool have_qemu_img(void); + +/** + * mkimg: + * @file: File name of the image that should be created + * @fmt: Format, e.g. "qcow2" or "raw" + * @size_mb: Size of the image in megabytes + * + * Create a disk image with qemu-img. Note that the QTEST_QEMU_IMG + * environment variable must point to the qemu-img file. + * + * Returns: true if the image has been created successfully. + */ +bool mkimg(const char *file, const char *fmt, unsigned size_mb); + #endif diff --git a/tests/qtest/libqos/libqos.c b/tests/qtest/libqos/libqos.c index 5ffda080ec..5c0fa1f7c5 100644 --- a/tests/qtest/libqos/libqos.c +++ b/tests/qtest/libqos/libqos.c @@ -137,56 +137,9 @@ void migrate(QOSState *from, QOSState *to, const char = *uri) migrate_allocator(&from->alloc, &to->alloc); } =20 -bool have_qemu_img(void) -{ - char *rpath; - const char *path =3D getenv("QTEST_QEMU_IMG"); - if (!path) { - return false; - } - - rpath =3D realpath(path, NULL); - if (!rpath) { - return false; - } else { - free(rpath); - return true; - } -} - -void mkimg(const char *file, const char *fmt, unsigned size_mb) -{ - gchar *cli; - bool ret; - int rc; - GError *err =3D NULL; - char *qemu_img_path; - gchar *out, *out2; - char *qemu_img_abs_path; - - qemu_img_path =3D getenv("QTEST_QEMU_IMG"); - g_assert(qemu_img_path); - qemu_img_abs_path =3D realpath(qemu_img_path, NULL); - g_assert(qemu_img_abs_path); - - cli =3D g_strdup_printf("%s create -f %s %s %uM", qemu_img_abs_path, - fmt, file, size_mb); - ret =3D g_spawn_command_line_sync(cli, &out, &out2, &rc, &err); - if (err || !g_spawn_check_exit_status(rc, &err)) { - fprintf(stderr, "%s\n", err->message); - g_error_free(err); - } - g_assert(ret && !err); - - g_free(out); - g_free(out2); - g_free(cli); - free(qemu_img_abs_path); -} - void mkqcow2(const char *file, unsigned size_mb) { - return mkimg(file, "qcow2", size_mb); + g_assert_true(mkimg(file, "qcow2", size_mb)); } =20 void prepare_blkdebug_script(const char *debug_fn, const char *event) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 2bfd460531..eaa1e8185f 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -1625,3 +1625,55 @@ bool qtest_qom_get_bool(QTestState *s, const char *p= ath, const char *property) =20 return b; } + +bool have_qemu_img(void) +{ + char *rpath; + const char *path =3D getenv("QTEST_QEMU_IMG"); + if (!path) { + return false; + } + + rpath =3D realpath(path, NULL); + if (!rpath) { + return false; + } else { + free(rpath); + return true; + } +} + +bool mkimg(const char *file, const char *fmt, unsigned size_mb) +{ + gchar *cli; + bool ret; + int rc; + GError *err =3D NULL; + char *qemu_img_path; + gchar *out, *out2; + char *qemu_img_abs_path; + + qemu_img_path =3D getenv("QTEST_QEMU_IMG"); + if (!qemu_img_path) { + return false; + } + qemu_img_abs_path =3D realpath(qemu_img_path, NULL); + if (!qemu_img_abs_path) { + return false; + } + + cli =3D g_strdup_printf("%s create -f %s %s %uM", qemu_img_abs_path, + fmt, file, size_mb); + ret =3D g_spawn_command_line_sync(cli, &out, &out2, &rc, &err); + if (err || !g_spawn_check_exit_status(rc, &err)) { + fprintf(stderr, "%s\n", err->message); + g_error_free(err); + } + + g_free(out); + g_free(out2); + g_free(cli); + free(qemu_img_abs_path); + + return ret && !err; +} --=20 2.31.1 From nobody Tue Feb 10 04:29:42 2026 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1677619103; cv=none; d=zohomail.com; s=zohoarc; b=TvM6+IDZQCdG8zZxX5g0Vv6ce7YX/G4IyHP4Hd3SnXjFUX8CK+iA0NnkdaXEgR+WbRXatPGNGGKx3U8nrjRAwLthBRRx6H4Kybd/p3M/cmJYtsYsoGJM1iWPUvepVpI1ry5Z43KTQKUqek1hMEUk+Zg9j4wA8CMEwFDxYVZEE5g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677619103; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZIbcHz+TqTCGXfu8pkkTMH6d/mSSOrmJ/pUC5dcPpkc=; b=P6CGAows+GP2ONuLd+dUGk3DQDQbWqKvVfnSum+5/c8s2D1KZoAO3DQXNOnsVdWe36ZraubNSsng3PQvWRlx30n9cEJ5p49iUeOZxdaMCqi+yZOAfKsV/xV8I5FPZWuQHUHy43/URQpOlGrsF52wiClp6DxqHHT4WVIuCukOuUI= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677619103641323.9070610930223; Tue, 28 Feb 2023 13:18:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pX7KH-0004Rd-6o; Tue, 28 Feb 2023 16:15:57 -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 1pX7KF-0004RE-VH for qemu-devel@nongnu.org; Tue, 28 Feb 2023 16:15:55 -0500 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 1pX7KE-0004MS-1e for qemu-devel@nongnu.org; Tue, 28 Feb 2023 16:15:55 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-54-OXeyYjkkO0O4OlCDZa7iDg-1; Tue, 28 Feb 2023 16:15:50 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CEA411C04193; Tue, 28 Feb 2023 21:15:49 +0000 (UTC) Received: from thuth.com (unknown [10.39.192.105]) by smtp.corp.redhat.com (Postfix) with ESMTP id D3B9D40C945A; Tue, 28 Feb 2023 21:15:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677618953; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZIbcHz+TqTCGXfu8pkkTMH6d/mSSOrmJ/pUC5dcPpkc=; b=dabrctEi7kN4WXqCMklkRHZoq8JMPalrN7S4K+HwnTtx5vQZXs0aU4kGHdlQrtGHaH4YeR ApHdzuTlGzQeJNiWEvGjG6A5kRkvrSFTWR1/aHj7mpcLq5IBu473or4mZIeE3QlIeL+IrO JeSg0N0Fn6tV8wSj2bLkznVo+tlW6p0= X-MC-Unique: OXeyYjkkO0O4OlCDZa7iDg-1 From: Thomas Huth To: Paolo Bonzini , qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier Subject: [PATCH 6/6] tests/qtest/readconfig: Test docs/config/q35-emulated.cfg Date: Tue, 28 Feb 2023 22:15:33 +0100 Message-Id: <20230228211533.201837-7-thuth@redhat.com> In-Reply-To: <20230228211533.201837-1-thuth@redhat.com> References: <20230228211533.201837-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 @redhat.com) X-ZM-MESSAGEID: 1677619104317100001 Content-Type: text/plain; charset="utf-8" This config file uses accel =3D "kvm", so it can only work on Linux. It also uses two hard-coded image names which we have to replace with unique temporary files to avoid race conditions. So after creating the temporary image files, we also have to create a copy of the config file where we replaced the hard-coded image names. Once everything is in place, we can start QEMU with this config file and check that everything is available in QEMU. Signed-off-by: Thomas Huth --- tests/qtest/readconfig-test.c | 131 ++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) diff --git a/tests/qtest/readconfig-test.c b/tests/qtest/readconfig-test.c index 533623f638..fe64376e85 100644 --- a/tests/qtest/readconfig-test.c +++ b/tests/qtest/readconfig-test.c @@ -197,6 +197,132 @@ static void test_docs_config_ich9(void) qtest_quit(qts); } =20 +#ifdef CONFIG_LINUX + +static char *make_temp_img(const char *template, const char *format, int s= ize) +{ + GError *error =3D NULL; + char *temp_name; + int fd; + + /* Create a temporary image names */ + fd =3D g_file_open_tmp(template, &temp_name, &error); + if (fd =3D=3D -1) { + fprintf(stderr, "unable to create file: %s\n", error->message); + g_error_free(error); + return NULL; + } + close(fd); + + if (!mkimg(temp_name, format, size)) { + fprintf(stderr, "qemu-img failed to create %s\n", temp_name); + g_free(temp_name); + return NULL; + } + + return temp_name; +} + +static void test_docs_q35_emulated(void) +{ + QTestState *qts; + QDict *resp; + QObject *qobj; + int ret, i; + g_autofree char *cfg_file =3D NULL, *sedcmd =3D NULL; + g_autofree char *hd_file =3D NULL, *cd_file =3D NULL; + + struct { + const char *name; + const char *type; + } devices[] =3D { + { "ich9-pcie-port-1", "ioh3420" }, + { "ich9-pcie-port-2", "ioh3420" }, + { "ich9-pcie-port-3", "ioh3420" }, + { "ich9-pcie-port-4", "ioh3420" }, + { "ich9-pci-bridge", "i82801b11-bridge" }, + { "ich9-ehci-1", "ich9-usb-ehci1" }, + { "ich9-ehci-2", "ich9-usb-ehci2" }, + { "ich9-uhci-1", "ich9-usb-uhci1" }, + { "ich9-uhci-2", "ich9-usb-uhci2" }, + { "ich9-uhci-3", "ich9-usb-uhci3" }, + { "ich9-uhci-4", "ich9-usb-uhci4" }, + { "ich9-uhci-5", "ich9-usb-uhci5" }, + { "ich9-uhci-6", "ich9-usb-uhci6" }, + { "sata-disk", "ide-hd" }, + { "sata-optical-disk", "ide-cd" }, + { "net", "e1000" }, + { "video", "VGA" }, + { "ich9-hda-audio", "ich9-intel-hda" }, + { "ich9-hda-duplex", "hda-duplex" }, + }; + + /* Check that all the devices are available in the QEMU binary */ + for (i =3D 0; i < ARRAY_SIZE(devices); i++) { + if (!qtest_has_device(devices[i].type)) { + g_test_skip("one of the required devices is not available"); + return; + } + } + + hd_file =3D make_temp_img("qtest_disk_XXXXXX.qcow2", "qcow2", 1); + cd_file =3D make_temp_img("qtest_cdrom_XXXXXX.iso", "raw", 1); + if (!hd_file || !cd_file) { + g_test_skip("could not create disk images"); + goto cleanup; + } + + /* Create a temporary config file where we replace the disk image name= s */ + ret =3D g_file_open_tmp("q35-emulated-XXXXXX.cfg", &cfg_file, NULL); + if (ret =3D=3D -1) { + g_test_skip("could not create temporary config file"); + goto cleanup; + } + close(ret); + + sedcmd =3D g_strdup_printf("sed -e 's,guest.qcow2,%s,' -e 's,install.i= so,%s,'" + " docs/config/q35-emulated.cfg > '%s'", + hd_file, cd_file, cfg_file); + ret =3D system(sedcmd); + if (ret) { + g_test_skip("could not modify temporary config file"); + goto cleanup; + } + + qts =3D qtest_initf("-machine none -nodefaults -readconfig %s", cfg_fi= le); + + /* Check memory size */ + resp =3D qtest_qmp(qts, "{ 'execute': 'query-memdev' }"); + test_x86_memdev_resp(qdict_get(resp, "return"), "pc.ram", 1024); + qobject_unref(resp); + + resp =3D qtest_qmp(qts, "{ 'execute': 'qom-list'," + " 'arguments': {'path': '/machine/peripheral' }= }"); + qobj =3D qdict_get(resp, "return"); + + /* Check that all the devices have been created */ + for (i =3D 0; i < ARRAY_SIZE(devices); i++) { + test_object_available(qobj, devices[i].name, devices[i].type); + } + + qobject_unref(resp); + + qtest_quit(qts); + +cleanup: + if (hd_file) { + unlink(hd_file); + } + if (cd_file) { + unlink(cd_file); + } + if (cfg_file) { + unlink(cfg_file); + } +} + +#endif /* CONFIG_LINUX */ + int main(int argc, char *argv[]) { const char *arch; @@ -208,6 +334,11 @@ int main(int argc, char *argv[]) g_str_equal(arch, "x86_64")) { qtest_add_func("readconfig/x86/memdev", test_x86_memdev); qtest_add_func("readconfig/x86/ich9-ehci-uhci", test_docs_config_i= ch9); +#ifdef CONFIG_LINUX + if (qtest_has_accel("kvm")) { + qtest_add_func("readconfig/x86/q35-emulated", test_docs_q35_em= ulated); + } +#endif } #ifdef CONFIG_SPICE qtest_add_func("readconfig/spice", test_spice); --=20 2.31.1