From nobody Tue Feb 10 23:01:24 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