From nobody Sat Apr 27 08:21:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150281530668842.24185294208053; Tue, 15 Aug 2017 09:41:46 -0700 (PDT) Received: from localhost ([::1]:46902 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dheuX-00014q-FU for importer@patchew.org; Tue, 15 Aug 2017 12:41:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39306) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhetD-0000JF-VG for qemu-devel@nongnu.org; Tue, 15 Aug 2017 12:40:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dhetD-0003D3-2A for qemu-devel@nongnu.org; Tue, 15 Aug 2017 12:40:23 -0400 Received: from mail-qk0-x243.google.com ([2607:f8b0:400d:c09::243]:35823) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dhetC-0003CE-Tz for qemu-devel@nongnu.org; Tue, 15 Aug 2017 12:40:22 -0400 Received: by mail-qk0-x243.google.com with SMTP id a77so1168161qkb.2 for ; Tue, 15 Aug 2017 09:40:22 -0700 (PDT) Received: from yoga.offpageads.com ([170.51.28.254]) by smtp.gmail.com with ESMTPSA id c50sm7375814qte.55.2017.08.15.09.40.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Aug 2017 09:40:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wHxp9s1RQW9396oAMjkleZbe9ZMP4XDWwiZcRTmIcXA=; b=Bbo6BnHLE4mtevi2vvxTJqNsAIP8Xk8STUBOTqbArj067pmiAoLVUip/9fkGRz3PzM wUaujOhNYAhNQu1/3n7lFVDFWx1kzga3qttSUiuuwuu/qsife1/VhCm5CfLy0qTkf4Qx OOiVqL7stVOI+7AybxwdsyDJTeF7/TGU+hkecY9uBjjjgjaeDEzc1bqiQjaiL2wTo5iB 7LrEoimufGvWOn1PTN8C9CPcMHsgfE3w8O/ZnMedQAU/C0DGgfQc5Z3GTzP4tmTC6HG9 oSt3lAKRKYg+1fBTBDfN02syn0EpTL10ugf3X1yh3+jijt4x5hjc5UMw6IUJzZfNdAOI eURw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=wHxp9s1RQW9396oAMjkleZbe9ZMP4XDWwiZcRTmIcXA=; b=V8j7c7kStsOELvIbUHVVkw2t0i52uIVs1Y6V7EC8IMwqhiBEM/YUnKbegTciznVRGV 4B/8EDjZXu4uHWHBZJVBgxLHWZkK8kgFmCygsYFAqKOcLhrVmbKmIKa56Z/t577k9GuE LaXdQjjCOkXx4YRTlko30/eeyQ6d0DQTRMIVfgpaDsgG0kcLAqes27jdGXRqMtcjdK9y Vcg0UDf+6VpUAv4yzBlIQSHR/9gNKhi7hZFaIMSMArleYatklY51QoXGomnKcCg+1XZy QzHDV4c64en51E6TfSO8DrlyxJoWtyKvZLJv3VJVMkM83yEsS4NkXCeGZoKkS5Ifc8/B bH1Q== X-Gm-Message-State: AHYfb5idWlWspm0nQCFawXykwIWo38q8oV08GwvzcnmcItkMiYk8bzIW PPYyAO4J6HB+oQ== X-Received: by 10.55.160.15 with SMTP id j15mr37853142qke.324.1502815222365; Tue, 15 Aug 2017 09:40:22 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: "Michael S . Tsirkin" , Thomas Huth , Markus Armbruster , Eric Blake Date: Tue, 15 Aug 2017 13:39:58 -0300 Message-Id: <20170815163959.6632-2-f4bug@amsat.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170815163959.6632-1-f4bug@amsat.org> References: <20170815163959.6632-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::243 Subject: [Qemu-devel] [RFC PATCH 1/2] libqtest: add qtest_accel() to avoid warnings when kvm is not available X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 only warn once about it. - kernel without kvm: # make check-qtest-x86_64 GTESTER check-qtest-x86_64 Could not access KVM kernel module: No such device qemu-system-x86_64: failed to initialize KVM: No such device qemu-system-x86_64: Back to tcg accelerator - tests ran as user: $ make check-qtest-x86_64 GTESTER check-qtest-x86_64 Could not access KVM kernel module: Permission denied qemu-system-x86_64: failed to initialize KVM: Permission denied qemu-system-x86_64: Back to tcg accelerator Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tests/libqtest.h | 8 ++++++++ tests/libqtest.c | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/tests/libqtest.h b/tests/libqtest.h index 38bc1e9953..24e03148eb 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -927,4 +927,12 @@ QDict *qmp_fd(int fd, const char *fmt, ...); */ void qtest_cb_for_every_machine(void (*cb)(const char *machine)); =20 +/** + * qtest_accel: + * @accel: List of accelerators + * + * Filter accelerators accessible on the host. + */ +const char *qtest_accel(const char *accel); + #endif diff --git a/tests/libqtest.c b/tests/libqtest.c index b9a1f180e1..d2dfca35a3 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -987,3 +987,21 @@ void qtest_cb_for_every_machine(void (*cb)(const char = *machine)) qtest_end(); QDECREF(response); } + +const char *qtest_accel(const char *accel) +{ + static bool kvm_accessible =3D true; + + if (strlen(accel) <=3D 4 || strncmp(accel, "kvm:", 4)) { + return accel; /* no match */ + } + + if (!kvm_accessible || !access("/dev/kvm", W_OK)) { + accel +=3D 4; /* skip "kvm:" */ + if (kvm_accessible) { + kvm_accessible =3D false; /* warn once */ + g_printerr("kvm not accessible, using %s\n", accel); + } + } + return accel; +} --=20 2.14.1 From nobody Sat Apr 27 08:21:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502815406904121.21045139683144; Tue, 15 Aug 2017 09:43:26 -0700 (PDT) Received: from localhost ([::1]:47007 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhew9-0002EK-Mz for importer@patchew.org; Tue, 15 Aug 2017 12:43:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39331) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhetH-0000Lf-Uh for qemu-devel@nongnu.org; Tue, 15 Aug 2017 12:40:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dhetG-0003Mm-Ry for qemu-devel@nongnu.org; Tue, 15 Aug 2017 12:40:27 -0400 Received: from mail-qt0-x241.google.com ([2607:f8b0:400d:c0d::241]:35256) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dhetG-0003M1-Mi for qemu-devel@nongnu.org; Tue, 15 Aug 2017 12:40:26 -0400 Received: by mail-qt0-x241.google.com with SMTP id t37so1208463qtg.2 for ; Tue, 15 Aug 2017 09:40:26 -0700 (PDT) Received: from yoga.offpageads.com ([170.51.28.254]) by smtp.gmail.com with ESMTPSA id c50sm7375814qte.55.2017.08.15.09.40.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Aug 2017 09:40:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=35qNb3CMxtbPBzA9JJuaBs161Vl2etKIWQBuy1vgHKA=; b=hN0txgFaoBDcvJEp5oXnRV19qsbDUjf9X72xxC89mt7GfDvQnxPUl3ewsG2dA/xASO 7+/hqmHiKtyI0b4cTjvTAUvE1S4NG/zGfdoFbaUNnMyqstl5+qGAdbbG+YSQhyOpJmR7 a1ryy/o35cSXpfOOmNphYZ51bs8JjPM7nUVC5GP7AFH4/rkMz4RLwZc2x80KMxjsntWx AE96gdADeVN49gF5c4D5LpF5QyQIeV7z63I0VKN+XkDEOoeX5TaEw2Q7eYX4szUGrgGs Vu5xPxEz4jYxut75xgdwdqGqrG32NwHMxev0bh3zMFUZgPHO0J2ygMIsVbS8Y3u/8VC/ j2vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=35qNb3CMxtbPBzA9JJuaBs161Vl2etKIWQBuy1vgHKA=; b=dCAwwKjo1h1G7F8ybTBztCBfYmUAnAah0w3+JnMZq9ShxEUEzPQ94g3nq76RN1lggY sob9LgRu1vDp0schN3x5ULx7zvmVUnu9CU4/Xr9tc5gUVpT6vN3V1hJ9VDTXMxlI1dNC 8mlvcv0RxZcTpppJ8CAeATaZpBc+BVWeJ/ibjgMfHtr4O9UGQUGewMlLEyY5cS+EYPeE jNiKHXUgZ0YB/CxzPbtNSyA/P9ncrTqpP5yTa3/kaVTKtvNpprqub3/Dnb6JfQmlcGRY Xg7TxywGzPHB95OjVaWDil0AwUeT0tvokz7QLh9VNcOLH6WQUsgsMNkn2Ywa7bnKLHkf i4Bg== X-Gm-Message-State: AHYfb5iChfeaPTXrDdBDDw5FO0n4Cxj49FC+6cejxgWkdBEhpvE8pWZp KtOMdtkr93z5crYJZ9BaVA== X-Received: by 10.200.46.195 with SMTP id i3mr36377174qta.219.1502815226079; Tue, 15 Aug 2017 09:40:26 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: "Michael S . Tsirkin" , Thomas Huth , Markus Armbruster , Eric Blake Date: Tue, 15 Aug 2017 13:39:59 -0300 Message-Id: <20170815163959.6632-3-f4bug@amsat.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170815163959.6632-1-f4bug@amsat.org> References: <20170815163959.6632-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::241 Subject: [Qemu-devel] [PATCH 2/2] tests: use qtest_accel() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tests/bios-tables-test.c | 2 +- tests/boot-serial-test.c | 5 +++-- tests/postcopy-test.c | 10 ++++++---- tests/pxe-test.c | 5 +++-- tests/vmgenid-test.c | 4 ++-- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c index 564da45f65..621bd8d95d 100644 --- a/tests/bios-tables-test.c +++ b/tests/bios-tables-test.c @@ -627,7 +627,7 @@ static void test_acpi_one(const char *params, test_data= *data) "-net none -display none %s " "-drive id=3Dhd0,if=3Dnone,file=3D%s,format=3Dr= aw " "-device ide-hd,drive=3Dhd0 ", - data->machine, "kvm:tcg", + data->machine, qtest_accel("kvm:tcg"), params ? params : "", disk); =20 qtest_start(args); diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c index a8ca877168..f986ea51b5 100644 --- a/tests/boot-serial-test.c +++ b/tests/boot-serial-test.c @@ -78,10 +78,11 @@ static void test_machine(const void *data) fd =3D mkstemp(tmpname); g_assert(fd !=3D -1); =20 - args =3D g_strdup_printf("-M %s,accel=3Dkvm:tcg " + args =3D g_strdup_printf("-M %s,accel=3D%s " "-chardev file,id=3Dserial0,path=3D%s " "-no-shutdown -serial chardev:serial0 %s", - test->machine, tmpname, test->extra); + test->machine, qtest_accel("kvm:tcg"), + tmpname, test->extra); =20 qtest_start(args); unlink(tmpname); diff --git a/tests/postcopy-test.c b/tests/postcopy-test.c index 8142f2ab90..781b955a59 100644 --- a/tests/postcopy-test.c +++ b/tests/postcopy-test.c @@ -367,18 +367,20 @@ static void test_migrate(void) got_stop =3D false; =20 if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { + const char *accel =3D qtest_accel("kvm:tcg"); + init_bootfile_x86(bootpath); - cmd_src =3D g_strdup_printf("-machine accel=3Dkvm:tcg -m 150M" + cmd_src =3D g_strdup_printf("-machine accel=3D%s -m 150M" " -name pcsource,debug-threads=3Don" " -serial file:%s/src_serial" " -drive file=3D%s,format=3Draw", - tmpfs, bootpath); - cmd_dst =3D g_strdup_printf("-machine accel=3Dkvm:tcg -m 150M" + accel, tmpfs, bootpath); + cmd_dst =3D g_strdup_printf("-machine accel=3D%s -m 150M" " -name pcdest,debug-threads=3Don" " -serial file:%s/dest_serial" " -drive file=3D%s,format=3Draw" " -incoming %s", - tmpfs, bootpath, uri); + accel, tmpfs, bootpath, uri); } else if (strcmp(arch, "ppc64") =3D=3D 0) { const char *accel; =20 diff --git a/tests/pxe-test.c b/tests/pxe-test.c index cf6e225330..531e0d5506 100644 --- a/tests/pxe-test.c +++ b/tests/pxe-test.c @@ -25,9 +25,10 @@ static void test_pxe_one(const char *params, bool ipv6) { char *args; =20 - args =3D g_strdup_printf("-machine accel=3Dkvm:tcg -nodefaults -boot o= rder=3Dn " + args =3D g_strdup_printf("-machine accel=3D%s -nodefaults -boot order= =3Dn " "-netdev user,id=3D" NETNAME ",tftp=3D./,bootfi= le=3D%s," - "ipv4=3D%s,ipv6=3D%s %s", disk, ipv6 ? "off" : = "on", + "ipv4=3D%s,ipv6=3D%s %s", qtest_accel("kvm:tcg"= ), + disk, ipv6 ? "off" : "on", ipv6 ? "on" : "off", params); =20 qtest_start(args); diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c index 3d5c1c3615..82b52aa44c 100644 --- a/tests/vmgenid-test.c +++ b/tests/vmgenid-test.c @@ -132,11 +132,11 @@ static char disk[] =3D "tests/vmgenid-test-disk-XXXXX= X"; =20 static char *guid_cmd_strdup(const char *guid) { - return g_strdup_printf("-machine accel=3Dkvm:tcg " + return g_strdup_printf("-machine accel=3D%s " "-device vmgenid,id=3Dtestvgid,guid=3D%s " "-drive id=3Dhd0,if=3Dnone,file=3D%s,format=3Dr= aw " "-device ide-hd,drive=3Dhd0 ", - guid, disk); + qtest_accel("kvm:tcg"), guid, disk); } =20 =20 --=20 2.14.1