X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=fish%2Fcmds.c;h=527091284e13bde1c62f80a58be4f2f02fba89e0;hb=42a8baf3c9abc6f742671f37e9e24b607e5f9857;hp=c197ecea86ded8310ea91f2a79952cb332866d78;hpb=1765330e07a48dc6f7bdef7007f69ebe606fa731;p=libguestfs.git diff --git a/fish/cmds.c b/fish/cmds.c index c197ece..5270912 100644 --- a/fish/cmds.c +++ b/fish/cmds.c @@ -66,9 +66,14 @@ void list_commands (void) printf ("%-20s %s\n", "file", "determine file type"); printf ("%-20s %s\n", "get-autosync", "get autosync mode"); printf ("%-20s %s\n", "get-path", "get the search path"); + printf ("%-20s %s\n", "get-state", "get the current state"); printf ("%-20s %s\n", "get-verbose", "get verbose mode"); + printf ("%-20s %s\n", "is-busy", "is busy processing a command"); + printf ("%-20s %s\n", "is-config", "is in configuration state"); printf ("%-20s %s\n", "is-dir", "test if file exists"); printf ("%-20s %s\n", "is-file", "test if file exists"); + printf ("%-20s %s\n", "is-launching", "is launching subprocess"); + printf ("%-20s %s\n", "is-ready", "is ready to accept commands"); printf ("%-20s %s\n", "kill-subprocess", "kill the qemu subprocess"); printf ("%-20s %s\n", "launch", "launch the qemu subprocess"); printf ("%-20s %s\n", "list-devices", "list the block devices"); @@ -145,6 +150,21 @@ void display_command (const char *cmd) if (strcasecmp (cmd, "get_verbose") == 0 || strcasecmp (cmd, "get-verbose") == 0) pod2text ("get-verbose - get verbose mode", " get-verbose\n\nThis returns the verbose messages flag."); else + if (strcasecmp (cmd, "is_ready") == 0 || strcasecmp (cmd, "is-ready") == 0) + pod2text ("is-ready - is ready to accept commands", " is-ready\n\nThis returns true iff this handle is ready to accept commands\n(in the C state).\n\nFor more information on states, see L."); + else + if (strcasecmp (cmd, "is_config") == 0 || strcasecmp (cmd, "is-config") == 0) + pod2text ("is-config - is in configuration state", " is-config\n\nThis returns true iff this handle is being configured\n(in the C state).\n\nFor more information on states, see L."); + else + if (strcasecmp (cmd, "is_launching") == 0 || strcasecmp (cmd, "is-launching") == 0) + pod2text ("is-launching - is launching subprocess", " is-launching\n\nThis returns true iff this handle is launching the subprocess\n(in the C state).\n\nFor more information on states, see L."); + else + if (strcasecmp (cmd, "is_busy") == 0 || strcasecmp (cmd, "is-busy") == 0) + pod2text ("is-busy - is busy processing a command", " is-busy\n\nThis returns true iff this handle is busy processing a command\n(in the C state).\n\nFor more information on states, see L."); + else + if (strcasecmp (cmd, "get_state") == 0 || strcasecmp (cmd, "get-state") == 0) + pod2text ("get-state - get the current state", " get-state\n\nThis returns the current state as an opaque integer. This is\nonly useful for printing debug and internal error messages.\n\nFor more information on states, see L."); + else if (strcasecmp (cmd, "mount") == 0) pod2text ("mount - mount a guest disk at a position in the filesystem", " mount \n\nMount a guest disk at a position in the filesystem. Block devices\nare named C, C and so on, as they were added to\nthe guest. If those block devices contain partitions, they will have\nthe usual names (eg. C). Also LVM C-style\nnames can be used.\n\nThe rules are the same as for L: A filesystem must\nfirst be mounted on C before others can be mounted. Other\nfilesystems can only be mounted on directories which already\nexist.\n\nThe mounted filesystem is writable, if we have sufficient permissions\non the underlying device.\n\nThe filesystem options C and C are set with this\ncall, in order to improve reliability."); else @@ -629,6 +649,76 @@ static int run_get_verbose (const char *cmd, int argc, char *argv[]) return 0; } +static int run_is_ready (const char *cmd, int argc, char *argv[]) +{ + int r; + if (argc != 0) { + fprintf (stderr, "%s should have 0 parameter(s)\n", cmd); + fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd); + return -1; + } + r = guestfs_is_ready (g); + if (r == -1) return -1; + if (r) printf ("true\n"); else printf ("false\n"); + return 0; +} + +static int run_is_config (const char *cmd, int argc, char *argv[]) +{ + int r; + if (argc != 0) { + fprintf (stderr, "%s should have 0 parameter(s)\n", cmd); + fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd); + return -1; + } + r = guestfs_is_config (g); + if (r == -1) return -1; + if (r) printf ("true\n"); else printf ("false\n"); + return 0; +} + +static int run_is_launching (const char *cmd, int argc, char *argv[]) +{ + int r; + if (argc != 0) { + fprintf (stderr, "%s should have 0 parameter(s)\n", cmd); + fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd); + return -1; + } + r = guestfs_is_launching (g); + if (r == -1) return -1; + if (r) printf ("true\n"); else printf ("false\n"); + return 0; +} + +static int run_is_busy (const char *cmd, int argc, char *argv[]) +{ + int r; + if (argc != 0) { + fprintf (stderr, "%s should have 0 parameter(s)\n", cmd); + fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd); + return -1; + } + r = guestfs_is_busy (g); + if (r == -1) return -1; + if (r) printf ("true\n"); else printf ("false\n"); + return 0; +} + +static int run_get_state (const char *cmd, int argc, char *argv[]) +{ + int r; + if (argc != 0) { + fprintf (stderr, "%s should have 0 parameter(s)\n", cmd); + fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd); + return -1; + } + r = guestfs_get_state (g); + if (r == -1) return -1; + printf ("%d\n", r); + return 0; +} + static int run_mount (const char *cmd, int argc, char *argv[]) { int r; @@ -1683,6 +1773,21 @@ int run_action (const char *cmd, int argc, char *argv[]) if (strcasecmp (cmd, "get_verbose") == 0 || strcasecmp (cmd, "get-verbose") == 0) return run_get_verbose (cmd, argc, argv); else + if (strcasecmp (cmd, "is_ready") == 0 || strcasecmp (cmd, "is-ready") == 0) + return run_is_ready (cmd, argc, argv); + else + if (strcasecmp (cmd, "is_config") == 0 || strcasecmp (cmd, "is-config") == 0) + return run_is_config (cmd, argc, argv); + else + if (strcasecmp (cmd, "is_launching") == 0 || strcasecmp (cmd, "is-launching") == 0) + return run_is_launching (cmd, argc, argv); + else + if (strcasecmp (cmd, "is_busy") == 0 || strcasecmp (cmd, "is-busy") == 0) + return run_is_busy (cmd, argc, argv); + else + if (strcasecmp (cmd, "get_state") == 0 || strcasecmp (cmd, "get-state") == 0) + return run_get_state (cmd, argc, argv); + else if (strcasecmp (cmd, "mount") == 0) return run_mount (cmd, argc, argv); else