rescue: If attach-method is 'libvirt', force it to be 'appliance'.

The libvirt backend currently doesn't support direct mode.  We should
make that work in future.  As a workaround, force the attach-method to
be 'appliance' in this case.
This commit is contained in:
Richard W.M. Jones
2012-09-04 12:04:31 +01:00
parent 6fdf1f40fa
commit 2e36adf83c

View File

@@ -139,6 +139,7 @@ main (int argc, char *argv[])
int memsize = 0;
int smp = 0;
int suggest = 0;
char *attach_method;
g = guestfs_create ();
if (g == NULL) {
@@ -313,6 +314,21 @@ main (int argc, char *argv[])
/* Setting "direct mode" is required for the rescue appliance. */
guestfs_set_direct (g, 1);
/* The libvirt backend doesn't support direct mode. As a temporary
* workaround, force the appliance backend, but warn about it.
*/
attach_method = guestfs_get_attach_method (g);
if (attach_method) {
if (STREQ (attach_method, "libvirt") ||
STRPREFIX (attach_method, "libvirt:")) {
fprintf (stderr, _("%s: warning: virt-rescue doesn't work with the libvirt backend\n"
"at the moment. As a workaround, forcing attach-method = 'appliance'.\n"),
program_name);
guestfs_set_attach_method (g, "appliance");
}
free (attach_method);
}
/* Set other features. */
if (memsize > 0)
guestfs_set_memsize (g, memsize);