X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=rescue%2Fvirt-rescue.c;h=7ad39b5b65a96e347e57ffeae875f0887a13d98c;hb=62909197d120c01cc86095518aacca9d4ad268dd;hp=6224ad7bb1ff47a3530910af6e5664cdbe13a6b0;hpb=d72815578f7b8fea9702902d8562430e8a007a46;p=libguestfs.git diff --git a/rescue/virt-rescue.c b/rescue/virt-rescue.c index 6224ad7..7ad39b5 100644 --- a/rescue/virt-rescue.c +++ b/rescue/virt-rescue.c @@ -1,5 +1,5 @@ /* virt-rescue - * Copyright (C) 2010 Red Hat Inc. + * Copyright (C) 2010-2011 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,12 +20,16 @@ #include #include +#include #include #include #include #include +#include #include +#include +#include "ignore-value.h" #include "progname.h" #include "xvasprintf.h" @@ -36,6 +40,7 @@ guestfs_h *g; int read_only = 0; +int live = 0; int verbose = 0; int keys_from_stdin = 0; int echo_keys = 0; @@ -72,8 +77,10 @@ usage (int status) " --network Enable network\n" " -r|--ro Access read-only\n" " --selinux Enable SELinux\n" + " --smp N Enable SMP with N >= 2 virtual CPUs\n" " -v|--verbose Verbose messages\n" " -V|--version Display version and exit\n" + " -w|--rw Mount read-write\n" " -x Trace libguestfs API calls\n" "For more information, see the manpage %s(1).\n"), program_name, program_name, program_name, @@ -92,6 +99,8 @@ main (int argc, char *argv[]) bindtextdomain (PACKAGE, LOCALEBASEDIR); textdomain (PACKAGE); + parse_config (); + enum { HELP_OPTION = CHAR_MAX + 1 }; static const char *options = "a:c:d:m:rvVx"; @@ -105,7 +114,9 @@ main (int argc, char *argv[]) { "memsize", 1, 0, 'm' }, { "network", 0, 0, 0 }, { "ro", 0, 0, 'r' }, + { "rw", 0, 0, 'w' }, { "selinux", 0, 0, 0 }, + { "smp", 1, 0, 0 }, { "verbose", 0, 0, 'v' }, { "version", 0, 0, 'V' }, { 0, 0, 0, 0 } @@ -119,6 +130,7 @@ main (int argc, char *argv[]) const char *append = NULL; char *append_full; int memsize = 0; + int smp = 0; g = guestfs_create (); if (g == NULL) { @@ -145,6 +157,17 @@ main (int argc, char *argv[]) format = NULL; else format = optarg; + } else if (STREQ (long_options[option_index].name, "smp")) { + if (sscanf (optarg, "%u", &smp) != 1) { + fprintf (stderr, _("%s: could not parse --smp parameter '%s'\n"), + program_name, optarg); + exit (EXIT_FAILURE); + } + if (smp < 1) { + fprintf (stderr, _("%s: --smp parameter '%s' should be >= 1\n"), + program_name, optarg); + exit (EXIT_FAILURE); + } } else { fprintf (stderr, _("%s: unknown long option: %s (%d)\n"), program_name, long_options[option_index].name, option_index); @@ -187,6 +210,10 @@ main (int argc, char *argv[]) OPTION_V; break; + case 'w': + OPTION_w; + break; + case 'x': OPTION_x; break; @@ -239,6 +266,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) @@ -256,6 +284,8 @@ main (int argc, char *argv[]) guestfs_set_memsize (g, memsize); if (network) guestfs_set_network (g, 1); + if (smp >= 1) + guestfs_set_smp (g, smp); /* Kernel command line must include guestfs_rescue=1 (see * appliance/init) as well as other options. @@ -276,17 +306,9 @@ main (int argc, char *argv[]) * appliance. */ guestfs_set_error_handler (g, NULL, NULL); - guestfs_launch (g); - /* launch() expects guestfsd to start. However, virt-rescue doesn't - * run guestfsd, so this will always fail with ECHILD when the - * appliance exits unexpectedly. - */ - if (errno != ECHILD) { - fprintf (stderr, "%s: %s\n", program_name, guestfs_last_error (g)); - guestfs_close (g); - exit (EXIT_FAILURE); - } + /* We expect launch to fail, so ignore the return value. */ + ignore_value (guestfs_launch (g)); guestfs_close (g);