Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
launch: direct: Add force_tcg backend setting.
By using:

  export LIBGUESTFS_BACKEND=direct
  export LIBGUESTFS_BACKEND_SETTINGS=force_tcg

you can force the direct backend to use TCG (software emulation)
instead of KVM (hardware accelerated virtualization).

This is sometimes useful, especially if you are trying to use
nested KVM on Intel.
  • Loading branch information
rwmjones committed Jan 18, 2014
1 parent 1e46638 commit 11ac9f7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/guestfs.pod
Expand Up @@ -1490,6 +1490,13 @@ either call L</guestfs_set_backend_settings> with a list of strings,
or set the C<LIBGUESTFS_BACKEND_SETTINGS> environment variable to a
colon-separated list of strings (before creating the handle).

Currently the only backend setting is:

export LIBGUESTFS_BACKEND_SETTINGS=force_tcg

which will force the direct backend to use TCG (software emulation)
instead of KVM (hardware accelerated virtualization).

=head2 ATTACHING TO RUNNING DAEMONS

I<Note (1):> This is B<highly experimental> and has a tendency to eat
Expand Down
13 changes: 10 additions & 3 deletions src/launch-direct.c
Expand Up @@ -290,6 +290,7 @@ launch_direct (guestfs_h *g, void *datav, const char *arg)
int virtio_scsi;
struct hv_param *hp;
bool has_kvm;
bool force_tcg;

/* At present you must add drives before starting the appliance. In
* future when we enable hotplugging you won't need to do this.
Expand All @@ -299,7 +300,10 @@ launch_direct (guestfs_h *g, void *datav, const char *arg)
return -1;
}

debian_kvm_warning (g);
force_tcg = guestfs___get_backend_setting_bool (g, "force_tcg");

if (!force_tcg)
debian_kvm_warning (g);

guestfs___launch_send_progress (g, 0);

Expand Down Expand Up @@ -446,7 +450,10 @@ launch_direct (guestfs_h *g, void *datav, const char *arg)
*/
if (qemu_supports (g, data, "-machine")) {
ADD_CMDLINE ("-machine");
ADD_CMDLINE ("accel=kvm:tcg");
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
Expand All @@ -456,7 +463,7 @@ launch_direct (guestfs_h *g, void *datav, const char *arg)
* available will cause qemu to fail. A giant clusterfuck with
* the qemu command line, again.
*/
if (qemu_supports (g, data, "-enable-kvm") && has_kvm)
if (has_kvm && !force_tcg && qemu_supports (g, data, "-enable-kvm"))
ADD_CMDLINE ("-enable-kvm");
}

Expand Down

0 comments on commit 11ac9f7

Please sign in to comment.