Richard W.M. Jones
2015-Oct-02 14:22 UTC
[Libguestfs] [PATCH 1/2] launch: direct: Use a single -machine [type, ]accel=... option.
Previously we used (on arm): -M virt -machine accel=... After this change, we use: -machine virt,accel=... On x86 there is no change. The -M option is an abbreviation for -machine, and we can combine the two options together. (Qemu combines the two options internally, but it's more predictable if we do it ourselves). Upstream qemu has supported the -machine option for over 5 years, and in fact we implicitly relied on it (despite what the comment in the code said). --- src/launch-direct.c | 52 +++++++++++++++++++--------------------------------- 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/src/launch-direct.c b/src/launch-direct.c index 44ae9d0..2ffbff1 100644 --- a/src/launch-direct.c +++ b/src/launch-direct.c @@ -376,11 +376,6 @@ launch_direct (guestfs_h *g, void *datav, const char *arg) ADD_CMDLINE ("-display"); ADD_CMDLINE ("none"); -#ifdef MACHINE_TYPE - ADD_CMDLINE ("-M"); - ADD_CMDLINE (MACHINE_TYPE); -#endif - /* See guestfs.pod / gdb */ if (guestfs_int_get_backend_setting_bool (g, "gdb") > 0) { ADD_CMDLINE ("-S"); @@ -388,35 +383,26 @@ launch_direct (guestfs_h *g, void *datav, const char *arg) warning (g, "qemu debugging is enabled, connect gdb to tcp::1234 to begin"); } + ADD_CMDLINE ("-machine"); + if (!force_tcg) + ADD_CMDLINE ( +#ifdef MACHINE_TYPE + MACHINE_TYPE "," +#endif + "accel=kvm:tcg"); + else + ADD_CMDLINE ( +#ifdef MACHINE_TYPE + MACHINE_TYPE "," +#endif + "accel=tcg"); + cpu_model = guestfs_int_get_cpu_model (has_kvm && !force_tcg); if (cpu_model) { ADD_CMDLINE ("-cpu"); ADD_CMDLINE (cpu_model); } - /* The qemu -machine option (added 2010-12) is a bit more sane - * since it falls back through various different acceleration - * modes, so try that first (thanks Markus Armbruster). - */ - if (qemu_supports (g, data, "-machine")) { - ADD_CMDLINE ("-machine"); - if (!force_tcg) - ADD_CMDLINE ("accel=kvm:tcg"); - else - ADD_CMDLINE ("accel=tcg"); - } else { - /* qemu sometimes needs this option to enable hardware - * virtualization, but some versions of 'qemu-kvm' will use KVM - * regardless (even where this option appears in the help text). - * It is rumoured that there are versions of qemu where - * supplying this option when hardware virtualization is not - * available will cause qemu to fail. A giant clusterfuck with - * the qemu command line, again. - */ - if (has_kvm && !force_tcg && qemu_supports (g, data, "-enable-kvm")) - ADD_CMDLINE ("-enable-kvm"); - } - if (g->smp > 1) { ADD_CMDLINE ("-smp"); ADD_CMDLINE_PRINTF ("%d", g->smp); @@ -997,12 +983,12 @@ test_qemu (guestfs_h *g, struct backend_direct_data *data) guestfs_int_cmd_add_arg (cmd3, g->hv); guestfs_int_cmd_add_arg (cmd3, "-display"); guestfs_int_cmd_add_arg (cmd3, "none"); -#ifdef MACHINE_TYPE - guestfs_int_cmd_add_arg (cmd3, "-M"); - guestfs_int_cmd_add_arg (cmd3, MACHINE_TYPE); -#endif guestfs_int_cmd_add_arg (cmd3, "-machine"); - guestfs_int_cmd_add_arg (cmd3, "accel=kvm:tcg"); + guestfs_int_cmd_add_arg (cmd3, +#ifdef MACHINE_TYPE + MACHINE_TYPE "," +#endif + "accel=kvm:tcg"); guestfs_int_cmd_add_arg (cmd3, "-device"); guestfs_int_cmd_add_arg (cmd3, "?"); guestfs_int_cmd_clear_capture_errors (cmd3); -- 2.5.2
Making -machine configurable would be a really bad idea. --- src/guestfs-internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index 7f1e572..113705d 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -133,7 +133,7 @@ #define VIRTIO_NET "virtio-net-device" #endif /* ARM */ -/* Machine types. XXX Make these configurable. */ +/* Machine types. */ #ifdef __arm__ #define MACHINE_TYPE "virt" #endif -- 2.5.2
Apparently Analagous Threads
- [PATCH] launch: direct: Add DAX root filesystem support.
- [PATCH v3 07/11] launch: direct: Don't run qemu -version.
- [PATCH] launch: switch from -nographic to -display none
- [PATCH] aarch64: launch: Only pass gic-version=host when KVM is likely to be enabled.
- Adventures in building libguestfs on non-x86 architectures for Debian