[libvirt] [PATCH 2/6] virsh: Create macro for "pool" option

John Ferlan jferlan at redhat.com
Wed Nov 25 19:11:04 UTC 2015


Rather than continually cut/paste the "pool" option for pool command
option structures, generate a macro which will commonly define it for
any command.  Then of course use that macro.

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 tools/virsh-pool.c | 91 +++++++++++++++++++-----------------------------------
 1 file changed, 31 insertions(+), 60 deletions(-)

diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c
index cf5a8f3..6922ad5 100644
--- a/tools/virsh-pool.c
+++ b/tools/virsh-pool.c
@@ -33,6 +33,13 @@
 #include "conf/storage_conf.h"
 #include "virstring.h"
 
+#define OPT_POOL_COMMON                                       \
+    {.name = "pool",                                          \
+     .type = VSH_OT_DATA,                                     \
+     .flags = VSH_OFLAG_REQ,                                  \
+     .help = N_("pool name or uuid")                          \
+    },                                                        \
+
 virStoragePoolPtr
 virshCommandOptPoolBy(vshControl *ctl, const vshCmd *cmd, const char *optname,
                       const char **name, unsigned int flags)
@@ -85,11 +92,8 @@ static const vshCmdInfo info_pool_autostart[] = {
 };
 
 static const vshCmdOptDef opts_pool_autostart[] = {
-    {.name = "pool",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("pool name or uuid")
-    },
+    OPT_POOL_COMMON
+
     {.name = "disable",
      .type = VSH_OT_BOOL,
      .help = N_("disable autostarting")
@@ -500,11 +504,8 @@ static const vshCmdInfo info_pool_build[] = {
 };
 
 static const vshCmdOptDef opts_pool_build[] = {
-    {.name = "pool",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("pool name or uuid")
-    },
+    OPT_POOL_COMMON
+
     {.name = "no-overwrite",
      .type = VSH_OT_BOOL,
      .help = N_("do not overwrite an existing pool of this type")
@@ -559,11 +560,8 @@ static const vshCmdInfo info_pool_destroy[] = {
 };
 
 static const vshCmdOptDef opts_pool_destroy[] = {
-    {.name = "pool",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("pool name or uuid")
-    },
+    OPT_POOL_COMMON
+
     {.name = NULL}
 };
 
@@ -602,11 +600,8 @@ static const vshCmdInfo info_pool_delete[] = {
 };
 
 static const vshCmdOptDef opts_pool_delete[] = {
-    {.name = "pool",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("pool name or uuid")
-    },
+    OPT_POOL_COMMON
+
     {.name = NULL}
 };
 
@@ -645,11 +640,8 @@ static const vshCmdInfo info_pool_refresh[] = {
 };
 
 static const vshCmdOptDef opts_pool_refresh[] = {
-    {.name = "pool",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("pool name or uuid")
-    },
+    OPT_POOL_COMMON
+
     {.name = NULL}
 };
 
@@ -688,11 +680,8 @@ static const vshCmdInfo info_pool_dumpxml[] = {
 };
 
 static const vshCmdOptDef opts_pool_dumpxml[] = {
-    {.name = "pool",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("pool name or uuid")
-    },
+    OPT_POOL_COMMON
+
     {.name = "inactive",
      .type = VSH_OT_BOOL,
      .help = N_("show inactive defined XML")
@@ -1542,11 +1531,8 @@ static const vshCmdInfo info_pool_info[] = {
 };
 
 static const vshCmdOptDef opts_pool_info[] = {
-    {.name = "pool",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("pool name or uuid")
-    },
+    OPT_POOL_COMMON
+
     {.name = NULL}
 };
 
@@ -1622,11 +1608,8 @@ static const vshCmdInfo info_pool_name[] = {
 };
 
 static const vshCmdOptDef opts_pool_name[] = {
-    {.name = "pool",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("pool uuid")
-    },
+    OPT_POOL_COMMON
+
     {.name = NULL}
 };
 
@@ -1657,11 +1640,8 @@ static const vshCmdInfo info_pool_start[] = {
 };
 
 static const vshCmdOptDef opts_pool_start[] = {
-    {.name = "pool",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("name or uuid of the inactive pool")
-    },
+    OPT_POOL_COMMON
+
     {.name = NULL}
 };
 
@@ -1700,11 +1680,8 @@ static const vshCmdInfo info_pool_undefine[] = {
 };
 
 static const vshCmdOptDef opts_pool_undefine[] = {
-    {.name = "pool",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("pool name or uuid")
-    },
+    OPT_POOL_COMMON
+
     {.name = NULL}
 };
 
@@ -1743,11 +1720,8 @@ static const vshCmdInfo info_pool_uuid[] = {
 };
 
 static const vshCmdOptDef opts_pool_uuid[] = {
-    {.name = "pool",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("pool name")
-    },
+    OPT_POOL_COMMON
+
     {.name = NULL}
 };
 
@@ -1783,11 +1757,8 @@ static const vshCmdInfo info_pool_edit[] = {
 };
 
 static const vshCmdOptDef opts_pool_edit[] = {
-    {.name = "pool",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("pool name or uuid")
-    },
+    OPT_POOL_COMMON
+
     {.name = NULL}
 };
 
-- 
2.5.0




More information about the libvir-list mailing list