diff --git a/lib/guestfs-internal.h b/lib/guestfs-internal.h index 290d1f948..0f2a38845 100644 --- a/lib/guestfs-internal.h +++ b/lib/guestfs-internal.h @@ -793,7 +793,6 @@ void guestfs_int_init_libvirt_backend (void) __attribute__((constructor)); /* qemu.c */ struct qemu_data; extern struct qemu_data *guestfs_int_test_qemu (guestfs_h *g); -extern struct version guestfs_int_qemu_version (guestfs_h *g, struct qemu_data *); extern int guestfs_int_qemu_supports_device (guestfs_h *g, const struct qemu_data *, const char *device_name); extern bool guestfs_int_platform_has_kvm (guestfs_h *g, const struct qemu_data *data); extern char *guestfs_int_drive_source_qemu_param (guestfs_h *g, const struct drive_source *src); diff --git a/lib/launch-direct.c b/lib/launch-direct.c index 090f50024..e94d4e7f2 100644 --- a/lib/launch-direct.c +++ b/lib/launch-direct.c @@ -61,6 +61,13 @@ struct backend_direct_data { char guestfsd_sock[UNIX_PATH_MAX]; /* Path to daemon socket. */ }; +/* Helper that sends all output from a command to debug. */ +static void +debug_lines (guestfs_h *g, void *retv, const char *buf, size_t len) +{ + debug (g, "qemu: %s", buf); +} + static char * create_cow_overlay_direct (guestfs_h *g, void *datav, struct drive *drv) { @@ -479,16 +486,21 @@ launch_direct (guestfs_h *g, void *datav, const char *arg) debug (g, "begin testing qemu features"); - /* Get qemu help text and version. */ - if (data->qemu_data == NULL) { - struct version qemu_version; + /* If debugging, print the qemu version. */ + if (g->verbose) { + CLEANUP_CMD_CLOSE struct command *cmd = guestfs_int_new_command (g); + guestfs_int_cmd_add_arg (cmd, g->hv); + guestfs_int_cmd_add_arg (cmd, "-version"); + guestfs_int_cmd_set_stdout_callback (cmd, debug_lines, NULL, 0); + guestfs_int_cmd_run (cmd); + } + + /* Get qemu help text. */ + if (data->qemu_data == NULL) { data->qemu_data = guestfs_int_test_qemu (g); if (data->qemu_data == NULL) goto cleanup0; - qemu_version = guestfs_int_qemu_version (g, data->qemu_data); - debug (g, "qemu version: %d.%d", - qemu_version.v_major, qemu_version.v_minor); } /* Work out if KVM is supported or if the user wants to force TCG. */ diff --git a/lib/qemu.c b/lib/qemu.c index c96d66bda..748780610 100644 --- a/lib/qemu.c +++ b/lib/qemu.c @@ -65,7 +65,6 @@ struct qemu_data { char *query_kvm; /* Output of QMP query-kvm. */ /* The following fields are derived from the fields above. */ - struct version qemu_version; /* Parsed qemu version number. */ bool has_kvm; /* If KVM is available. */ }; @@ -81,7 +80,6 @@ static int read_cache_query_kvm (guestfs_h *g, struct qemu_data *data, const cha static int write_cache_query_kvm (guestfs_h *g, const struct qemu_data *data, const char *filename); static int read_cache_qemu_stat (guestfs_h *g, struct qemu_data *data, const char *filename); static int write_cache_qemu_stat (guestfs_h *g, const struct qemu_data *data, const char *filename); -static void parse_qemu_version (guestfs_h *g, const char *, struct version *qemu_version); static void parse_has_kvm (guestfs_h *g, const char *, bool *); static void read_all (guestfs_h *g, void *retv, const char *buf, size_t len); static int generic_read_cache (guestfs_h *g, const char *filename, char **strp); @@ -218,7 +216,6 @@ guestfs_int_test_qemu (guestfs_h *g) out: /* Derived fields. */ - parse_qemu_version (g, data->qemu_help, &data->qemu_version); parse_has_kvm (g, data->query_kvm, &data->has_kvm); return data; @@ -392,23 +389,6 @@ write_cache_qemu_stat (guestfs_h *g, const struct qemu_data *data, return 0; } -/** - * Parse the first line of C into the major and minor - * version of qemu, but don't fail if parsing is not possible. - */ -static void -parse_qemu_version (guestfs_h *g, const char *qemu_help, - struct version *qemu_version) -{ - version_init_null (qemu_version); - - if (guestfs_int_version_from_x_y (g, qemu_version, qemu_help) < 1) { - debug (g, "%s: failed to parse qemu version string from the first line of the output of '%s -help'. When reporting this bug please include the -help output.", - __func__, g->hv); - return; - } -} - /** * Parse the json output from QMP query-kvm to find out if KVM is * enabled on this machine. Don't fail if parsing is not possible, @@ -579,15 +559,6 @@ read_all (guestfs_h *g, void *retv, const char *buf, size_t len) *ret = safe_strndup (g, buf, len); } -/** - * Return the parsed version of qemu. - */ -struct version -guestfs_int_qemu_version (guestfs_h *g, struct qemu_data *data) -{ - return data->qemu_version; -} - /** * Test if device is supported by qemu (currently just greps the * C output).