From: "Richard W.M. Jones" <rjones(a)redhat.com>
This allows us to find out what qemu devices are supported
at runtime.
---
configure.ac | 8 ++++++++
src/guestfs-internal.h | 1 +
src/guestfs.c | 1 +
src/launch.c | 9 +++++++++
4 files changed, 19 insertions(+)
diff --git a/configure.ac b/configure.ac
index ca0f9f1..9eae5a0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -589,6 +589,14 @@ working.
AC_MSG_FAILURE([$QEMU version must be >= 1.0.])
fi
+ AC_MSG_CHECKING([that $QEMU -machine accel=kvm:tcg -device ? works])
+ if $QEMU -machine accel=kvm:tcg -device \? >&AS_MESSAGE_LOG_FD 2>&1;
then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ AC_MSG_FAILURE([$QEMU -machine accel=kvm:tcg -device ? doesn't work.])
+ fi
+
AC_MSG_CHECKING([for virtio-serial support in $QEMU])
if $QEMU $QEMU_OPTIONS -machine accel=kvm:tcg -device \? 2>&1 | grep -sq
virtio-serial; then
AC_MSG_RESULT([yes])
diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h
index 4e82966..fb4868c 100644
--- a/src/guestfs-internal.h
+++ b/src/guestfs-internal.h
@@ -187,6 +187,7 @@ struct guestfs_h
char *tmpdir; /* Temporary directory containing socket. */
char *qemu_help, *qemu_version; /* Output of qemu -help, qemu -version. */
+ char *qemu_devices; /* Output of qemu -device ? */
char **cmdline; /* Qemu command line. */
size_t cmdline_size;
diff --git a/src/guestfs.c b/src/guestfs.c
index f296a0c..561fab4 100644
--- a/src/guestfs.c
+++ b/src/guestfs.c
@@ -270,6 +270,7 @@ guestfs_close (guestfs_h *g)
free (g->append);
free (g->qemu_help);
free (g->qemu_version);
+ free (g->qemu_devices);
free (g);
}
diff --git a/src/launch.c b/src/launch.c
index e175dd9..3db2443 100644
--- a/src/launch.c
+++ b/src/launch.c
@@ -1319,6 +1319,8 @@ test_qemu (guestfs_h *g)
g->qemu_help = NULL;
free (g->qemu_version);
g->qemu_version = NULL;
+ free (g->qemu_devices);
+ g->qemu_devices = NULL;
snprintf (cmd, sizeof cmd, "LC_ALL=C '%s' -nographic -help",
g->qemu);
@@ -1338,6 +1340,13 @@ test_qemu (guestfs_h *g)
if (test_qemu_cmd (g, cmd, &g->qemu_version) == -1)
goto qemu_error;
+ snprintf (cmd, sizeof cmd,
+ "LC_ALL=C '%s' -nographic -machine accel=kvm:tcg -device ?
2>&1",
+ g->qemu);
+
+ if (test_qemu_cmd (g, cmd, &g->qemu_devices) == -1)
+ goto qemu_error;
+
return 0;
}
--
1.7.10.1