qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 23/23] qemu-img: inline list of supported commands, remove qemu-i


From: Michael Tokarev
Subject: [PATCH 23/23] qemu-img: inline list of supported commands, remove qemu-img-cmds.h include
Date: Sat, 10 Feb 2024 00:22:44 +0300

also add short description to each command and use it in --help

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 qemu-img.c | 42 +++++++++++++++++++++++++++++++++++-------
 1 file changed, 35 insertions(+), 7 deletions(-)

diff --git a/qemu-img.c b/qemu-img.c
index d9c5c6078b..e57076738e 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -61,6 +61,7 @@
 typedef struct img_cmd_t {
     const char *name;
     int (*handler)(const struct img_cmd_t *ccmd, int argc, char **argv);
+    const char *description;
 } img_cmd_t;
 
 enum {
@@ -130,11 +131,12 @@ static G_NORETURN
 void cmd_help(const img_cmd_t *ccmd,
               const char *syntax, const char *arguments)
 {
-    printf("qemu-img %s %s"
+    printf("qemu-img %s: %s.  Usage:\n"
+           "qemu-img %s %s"
            "Arguments:\n"
            " -h|--help - print this help and exit\n"
            "%s",
-           ccmd->name, syntax, arguments);
+           ccmd->name, ccmd->description, ccmd->name, syntax, arguments);
     exit(EXIT_SUCCESS);
 }
 
@@ -5746,10 +5748,36 @@ out:
 }
 
 static const img_cmd_t img_cmds[] = {
-#define DEF(option, callback, arg_string)        \
-    { option, callback },
-#include "qemu-img-cmds.h"
-#undef DEF
+    { "amend", img_amend,
+      "Update format-specific options of the image" },
+    { "bench", img_bench,
+      "Run simple image benchmark" },
+    { "bitmap", img_bitmap,
+      "Perform modifications of the persistent bitmap in the image" },
+    { "check", img_check,
+      "Check basic image integrity" },
+    { "commit", img_commit,
+      "Commit image to its backing file" },
+    { "compare", img_compare,
+      "Check if two images have the same contents" },
+    { "convert", img_convert,
+      "Copy one image to another with optional format conversion" },
+    { "create", img_create,
+      "Create and format new image file" },
+    { "dd", img_dd,
+      "Copy input to output with optional format conversion" },
+    { "info", img_info,
+      "Display information about image" },
+    { "map", img_map,
+      "Dump image metadata" },
+    { "measure", img_measure,
+      "Calculate file size requred for a new image" },
+    { "rebase", img_rebase,
+      "Change backing file of the image" },
+    { "resize", img_resize,
+      "Resize the image to the new size" },
+    { "snapshot", img_snapshot,
+      "List or manipulate snapshots within image" },
     { NULL, NULL, },
 };
 
@@ -5813,7 +5841,7 @@ QEMU_IMG_VERSION
 "   [[enable=]<pattern>][,events=<file>][,file=<file>]\n"
 "Recognized commands (run qemu-img command --help for command-specific 
help):\n");
             for (cmd = img_cmds; cmd->name != NULL; cmd++) {
-                printf("  %s\n", cmd->name);
+                printf("  %s - %s\n", cmd->name, cmd->description);
             }
             c = printf("Supported image formats:");
             bdrv_iterate_format(format_print, &c, false);
-- 
2.39.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]