From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: "Michael S . Tsirkin" <mst@redhat.com>,
Thomas Huth <thuth@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
Eric Blake <eblake@redhat.com>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
qemu-devel@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>
Subject: [Qemu-devel] [RFC PATCH 1/2] libqtest: add qtest_accel() to avoid warnings when kvm is not available
Date: Tue, 15 Aug 2017 13:39:58 -0300 [thread overview]
Message-ID: <20170815163959.6632-2-f4bug@amsat.org> (raw)
In-Reply-To: <20170815163959.6632-1-f4bug@amsat.org>
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é <f4bug@amsat.org>
---
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));
+/**
+ * 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 = true;
+
+ if (strlen(accel) <= 4 || strncmp(accel, "kvm:", 4)) {
+ return accel; /* no match */
+ }
+
+ if (!kvm_accessible || !access("/dev/kvm", W_OK)) {
+ accel += 4; /* skip "kvm:" */
+ if (kvm_accessible) {
+ kvm_accessible = false; /* warn once */
+ g_printerr("kvm not accessible, using %s\n", accel);
+ }
+ }
+ return accel;
+}
--
2.14.1
next prev parent reply other threads:[~2017-08-15 16:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-15 16:39 [Qemu-devel] [RFC PATCH 0/2] tests: avoid kvm accel when it is not accessible Philippe Mathieu-Daudé
2017-08-15 16:39 ` Philippe Mathieu-Daudé [this message]
2017-08-15 18:13 ` [Qemu-devel] [RFC PATCH 1/2] libqtest: add qtest_accel() to avoid warnings when kvm is not available Eric Blake
2017-08-15 18:27 ` Philippe Mathieu-Daudé
2017-08-15 18:39 ` Peter Maydell
2017-08-15 19:10 ` Philippe Mathieu-Daudé
2017-08-15 18:40 ` Eric Blake
2017-08-15 18:51 ` Eric Blake
2017-08-15 19:08 ` Philippe Mathieu-Daudé
2017-08-15 16:39 ` [Qemu-devel] [PATCH 2/2] tests: use qtest_accel() Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170815163959.6632-2-f4bug@amsat.org \
--to=f4bug@amsat.org \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).