From a20e5c00c35490fa29668630113a01240a69b701 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 28 Jan 2011 19:25:02 +0000 Subject: [PATCH] fish: Add guestfish --live, guestmount --live options. The other programs have the variable, but the flag is not enabled either because it doesn't make sense or because the implications are not well understood. --- cat/virt-cat.c | 2 ++ cat/virt-filesystems.c | 2 ++ cat/virt-ls.c | 2 ++ df/main.c | 2 ++ fish/fish.c | 5 +++++ fish/guestfish.pod | 5 +++++ fish/inspect.c | 6 ++++++ fish/options.h | 1 + fish/virt.c | 4 ++++ fuse/guestmount.c | 5 +++++ fuse/guestmount.pod | 5 +++++ inspector/virt-inspector.c | 2 ++ rescue/virt-rescue.c | 2 ++ 13 files changed, 43 insertions(+) diff --git a/cat/virt-cat.c b/cat/virt-cat.c index 470c70c..834d490 100644 --- a/cat/virt-cat.c +++ b/cat/virt-cat.c @@ -34,6 +34,7 @@ guestfs_h *g; int read_only = 1; +int live = 0; int verbose = 0; int keys_from_stdin = 0; int echo_keys = 0; @@ -213,6 +214,7 @@ main (int argc, char *argv[]) */ assert (read_only == 1); assert (inspector == 1); + assert (live == 0); /* User must specify at least one filename on the command line. */ if (optind >= argc || argc - optind < 1) diff --git a/cat/virt-filesystems.c b/cat/virt-filesystems.c index cd991e8..7eca9eb 100644 --- a/cat/virt-filesystems.c +++ b/cat/virt-filesystems.c @@ -46,6 +46,7 @@ guestfs_h *g; int read_only = 1; +int live = 0; int verbose = 0; int keys_from_stdin = 0; int echo_keys = 0; @@ -301,6 +302,7 @@ main (int argc, char *argv[]) */ assert (read_only == 1); assert (inspector == 0); + assert (live == 0); /* Must be no extra arguments on the command line. */ if (optind != argc) diff --git a/cat/virt-ls.c b/cat/virt-ls.c index 64bae46..315fb1f 100644 --- a/cat/virt-ls.c +++ b/cat/virt-ls.c @@ -35,6 +35,7 @@ guestfs_h *g; int read_only = 1; +int live = 0; int verbose = 0; int keys_from_stdin = 0; int echo_keys = 0; @@ -227,6 +228,7 @@ main (int argc, char *argv[]) */ assert (read_only == 1); assert (inspector == 1); + assert (live == 0); /* User must specify at least one directory name on the command line. */ if (optind >= argc || argc - optind < 1) diff --git a/df/main.c b/df/main.c index 7ac5a6c..174692f 100644 --- a/df/main.c +++ b/df/main.c @@ -41,6 +41,7 @@ guestfs_h *g; int read_only = 1; +int live = 0; int verbose = 0; int keys_from_stdin = 0; int echo_keys = 0; @@ -238,6 +239,7 @@ main (int argc, char *argv[]) */ assert (read_only == 1); assert (inspector == 0); + assert (live == 0); /* Must be no extra arguments on the command line. */ if (optind != argc) diff --git a/fish/fish.c b/fish/fish.c index eb7c8fe..b62c098 100644 --- a/fish/fish.c +++ b/fish/fish.c @@ -74,6 +74,7 @@ static int override_progress_bars = -1; guestfs_h *g; int read_only = 0; +int live = 0; int quit = 0; int verbose = 0; int remote_control_listen = 0; @@ -124,6 +125,7 @@ usage (int status) " -i|--inspector Automatically mount filesystems\n" " --keys-from-stdin Read passphrases from stdin\n" " --listen Listen for remote commands\n" + " --live Connect to a live virtual machine\n" " -m|--mount dev[:mnt] Mount dev on mnt (if omitted, /)\n" " -n|--no-sync Don't autosync\n" " -N|--new type Create prepared disk (test1.img, ...)\n" @@ -173,6 +175,7 @@ main (int argc, char *argv[]) { "inspector", 0, 0, 'i' }, { "keys-from-stdin", 0, 0, 0 }, { "listen", 0, 0, 0 }, + { "live", 0, 0, 0 }, { "mount", 1, 0, 'm' }, { "new", 1, 0, 'N' }, { "no-dest-paths", 0, 0, 'D' }, @@ -277,6 +280,8 @@ main (int argc, char *argv[]) format = optarg; } else if (STREQ (long_options[option_index].name, "csh")) { remote_control_csh = 1; + } else if (STREQ (long_options[option_index].name, "live")) { + live = 1; } else { fprintf (stderr, _("%s: unknown long option: %s (%d)\n"), program_name, long_options[option_index].name, option_index); diff --git a/fish/guestfish.pod b/fish/guestfish.pod index 0f318f0..abf6d7a 100644 --- a/fish/guestfish.pod +++ b/fish/guestfish.pod @@ -294,6 +294,11 @@ to try to read passphrases from the user by opening C. Fork into the background and listen for remote commands. See section L below. +=item B<--live> + +Connect to a live virtual machine. +(Experimental, see L). + =item B<-m dev[:mountpoint]> =item B<--mount dev[:mountpoint]> diff --git a/fish/inspect.c b/fish/inspect.c index 713501e..5e1948c 100644 --- a/fish/inspect.c +++ b/fish/inspect.c @@ -73,6 +73,12 @@ compare_keys (const void *p1, const void *p2) void inspect_mount (void) { + if (live) { + fprintf (stderr, _("%s: don't use --live and -i options together\n"), + program_name); + exit (EXIT_FAILURE); + } + inspect_do_decrypt (); char **roots = guestfs_inspect_os (g); diff --git a/fish/options.h b/fish/options.h index 728df04..b755d90 100644 --- a/fish/options.h +++ b/fish/options.h @@ -67,6 +67,7 @@ /* Provided by guestfish or guestmount. */ extern guestfs_h *g; extern int read_only; +extern int live; extern int verbose; extern int inspector; extern int keys_from_stdin; diff --git a/fish/virt.c b/fish/virt.c index 13a6d12..b14cee2 100644 --- a/fish/virt.c +++ b/fish/virt.c @@ -43,6 +43,10 @@ add_libvirt_drives (const char *guest) optargs.bitmask |= GUESTFS_ADD_DOMAIN_READONLY_BITMASK; optargs.readonly = 1; } + if (live) { + optargs.bitmask |= GUESTFS_ADD_DOMAIN_LIVE_BITMASK; + optargs.live = 1; + } return guestfs_add_domain_argv (g, guest, &optargs); } diff --git a/fuse/guestmount.c b/fuse/guestmount.c index 3d3da39..6adf140 100644 --- a/fuse/guestmount.c +++ b/fuse/guestmount.c @@ -59,6 +59,7 @@ guestfs_h *g = NULL; int read_only = 0; +int live = 0; int verbose = 0; int inspector = 0; int keys_from_stdin = 0; @@ -879,6 +880,7 @@ usage (int status) " -i|--inspector Automatically mount filesystems\n" " --help Display help message and exit\n" " --keys-from-stdin Read passphrases from stdin\n" + " --live Connect to a live virtual machine\n" " -m|--mount dev[:mnt] Mount dev on mnt (if omitted, /)\n" " -n|--no-sync Don't autosync\n" " -o|--option opt Pass extra option to FUSE\n" @@ -917,6 +919,7 @@ main (int argc, char *argv[]) { "help", 0, 0, HELP_OPTION }, { "inspector", 0, 0, 'i' }, { "keys-from-stdin", 0, 0, 0 }, + { "live", 0, 0, 0 }, { "mount", 1, 0, 'm' }, { "no-sync", 0, 0, 'n' }, { "option", 1, 0, 'o' }, @@ -1017,6 +1020,8 @@ main (int argc, char *argv[]) keys_from_stdin = 1; } else if (STREQ (long_options[option_index].name, "echo-keys")) { echo_keys = 1; + } else if (STREQ (long_options[option_index].name, "live")) { + live = 1; } else { fprintf (stderr, _("%s: unknown long option: %s (%d)\n"), program_name, long_options[option_index].name, option_index); diff --git a/fuse/guestmount.pod b/fuse/guestmount.pod index 567a270..338af97 100644 --- a/fuse/guestmount.pod +++ b/fuse/guestmount.pod @@ -143,6 +143,11 @@ mounted on the real virtual machine. Read key or passphrase parameters from stdin. The default is to try to read passphrases from the user by opening C. +=item B<--live> + +Connect to a live virtual machine. +(Experimental, see L). + =item B<-m dev[:mnt]> | B<--mount dev[:mnt]> Mount the named partition or logical volume on the given mountpoint diff --git a/inspector/virt-inspector.c b/inspector/virt-inspector.c index 68f8b46..fda9787 100644 --- a/inspector/virt-inspector.c +++ b/inspector/virt-inspector.c @@ -38,6 +38,7 @@ guestfs_h *g; int read_only = 1; +int live = 0; int verbose = 0; int keys_from_stdin = 0; int echo_keys = 0; @@ -226,6 +227,7 @@ main (int argc, char *argv[]) */ assert (read_only == 1); assert (inspector == 1); + assert (live == 0); /* Must be no extra arguments on the command line. */ if (optind != argc) diff --git a/rescue/virt-rescue.c b/rescue/virt-rescue.c index 6224ad7..58be96b 100644 --- a/rescue/virt-rescue.c +++ b/rescue/virt-rescue.c @@ -36,6 +36,7 @@ guestfs_h *g; int read_only = 0; +int live = 0; int verbose = 0; int keys_from_stdin = 0; int echo_keys = 0; @@ -239,6 +240,7 @@ main (int argc, char *argv[]) assert (inspector == 0); assert (keys_from_stdin == 0); assert (echo_keys == 0); + assert (live == 0); /* Must be no extra arguments on the command line. */ if (optind != argc) -- 1.8.3.1