X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=src%2Flaunch.c;h=0b15ce98d79fac55032a7e93788f62d0011e8c34;hp=a60ef7b3a36a4af4d8202652a286ccac878b261a;hb=64841fe8957f798df12a38bd81843c7011f2c278;hpb=371eabfae3790588ed97c0017d2882799c7ea871;ds=sidebyside diff --git a/src/launch.c b/src/launch.c index a60ef7b..0b15ce9 100644 --- a/src/launch.c +++ b/src/launch.c @@ -104,20 +104,20 @@ add_cmdline (guestfs_h *g, const char *str) return 0; } -int +size_t guestfs___checkpoint_cmdline (guestfs_h *g) { return g->cmdline_size; } void -guestfs___rollback_cmdline (guestfs_h *g, int pos) +guestfs___rollback_cmdline (guestfs_h *g, size_t pos) { - int i; + size_t i; assert (g->cmdline_size >= pos); - for (i = g->cmdline_size - 1; i >= pos; --i) + for (i = pos; i < g->cmdline_size; ++i) free (g->cmdline[i]); g->cmdline_size = pos; @@ -127,7 +127,7 @@ guestfs___rollback_cmdline (guestfs_h *g, int pos) char ** guestfs__debug_cmdline (guestfs_h *g) { - int i; + size_t i; char **r; if (g->cmdline == NULL) { @@ -487,21 +487,30 @@ launch_appliance (guestfs_h *g) if (qemu_supports (g, "-nodefconfig")) add_cmdline (g, "-nodefconfig"); - /* 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, so we we have to check at least that - * /dev/kvm is openable. That's not reliable, since /dev/kvm - * might be openable by qemu but not by us (think: SELinux) in - * which case the user would not get hardware virtualization, - * although at least shouldn't fail. A giant clusterfuck with the - * qemu command line, again. + /* 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, "-enable-kvm") && - is_openable (g, "/dev/kvm", O_RDWR)) - add_cmdline (g, "-enable-kvm"); + if (qemu_supports (g, "-machine")) { + add_cmdline (g, "-machine"); + add_cmdline (g, "accel=kvm: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, so we we have to check at least that + * /dev/kvm is openable. That's not reliable, since /dev/kvm + * might be openable by qemu but not by us (think: SELinux) in + * which case the user would not get hardware virtualization, + * although at least shouldn't fail. A giant clusterfuck with the + * qemu command line, again. + */ + if (qemu_supports (g, "-enable-kvm") && + is_openable (g, "/dev/kvm", O_RDWR)) + add_cmdline (g, "-enable-kvm"); + } /* Newer versions of qemu (from around 2009/12) changed the * behaviour of monitors so that an implicit '-monitor stdio' is