[PATCH 5/8] virsh: Create macro for common "current" option

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

 



Rather than continually cut-n-paste the strings into each command,
create a common macro to be used generically.  Note that not all
'{.name = "current",' entries are replaced, just those that have the
common .help string of "affect current domain".

Non replaced instances are unique to the command.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 tools/virsh-domain.c | 111 +++++++++++++--------------------------------------
 1 file changed, 27 insertions(+), 84 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index c9e8475..3387625 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -88,6 +88,12 @@
      .help = N_("affect running domain")               \
     }                                                  \
 
+#define VSH_DOMAIN_CURRENT_OPT_COMMON                  \
+    {.name = "current",                                \
+     .type = VSH_OT_BOOL,                              \
+     .help = N_("affect current domain")               \
+    }                                                  \
+
 static virDomainPtr
 virshLookupDomainInternal(vshControl *ctl,
                           const char *cmdname,
@@ -239,10 +245,7 @@ static const vshCmdOptDef opts_attach_device[] = {
     VSH_DOMAIN_PERSISTENT_OPT_COMMON,
     VSH_DOMAIN_CONFIG_OPT_COMMON,
     VSH_DOMAIN_LIVE_OPT_COMMON,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VSH_DOMAIN_CURRENT_OPT_COMMON,
     {.name = NULL}
 };
 
@@ -393,10 +396,7 @@ static const vshCmdOptDef opts_attach_disk[] = {
     VSH_DOMAIN_PERSISTENT_OPT_COMMON,
     VSH_DOMAIN_CONFIG_OPT_COMMON,
     VSH_DOMAIN_LIVE_OPT_COMMON,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VSH_DOMAIN_CURRENT_OPT_COMMON,
     {.name = NULL}
 };
 
@@ -844,10 +844,7 @@ static const vshCmdOptDef opts_attach_interface[] = {
     VSH_DOMAIN_PERSISTENT_OPT_COMMON,
     VSH_DOMAIN_CONFIG_OPT_COMMON,
     VSH_DOMAIN_LIVE_OPT_COMMON,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VSH_DOMAIN_CURRENT_OPT_COMMON,
     {.name = "print-xml",
      .type = VSH_OT_BOOL,
      .help = N_("print XML document rather than attach the interface")
@@ -1284,10 +1281,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
     },
     VSH_DOMAIN_CONFIG_OPT_COMMON,
     VSH_DOMAIN_LIVE_OPT_COMMON,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VSH_DOMAIN_CURRENT_OPT_COMMON,
     {.name = NULL}
 };
 
@@ -1532,10 +1526,7 @@ static const vshCmdOptDef opts_blkiotune[] = {
     },
     VSH_DOMAIN_CONFIG_OPT_COMMON,
     VSH_DOMAIN_LIVE_OPT_COMMON,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VSH_DOMAIN_CURRENT_OPT_COMMON,
     {.name = NULL}
 };
 
@@ -3215,10 +3206,7 @@ static const vshCmdOptDef opts_domiftune[] = {
     },
     VSH_DOMAIN_CONFIG_OPT_COMMON,
     VSH_DOMAIN_LIVE_OPT_COMMON,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VSH_DOMAIN_CURRENT_OPT_COMMON,
     {.name = NULL}
 };
 
@@ -6397,10 +6385,7 @@ static const vshCmdOptDef opts_vcpupin[] = {
     },
     VSH_DOMAIN_CONFIG_OPT_COMMON,
     VSH_DOMAIN_LIVE_OPT_COMMON,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VSH_DOMAIN_CURRENT_OPT_COMMON,
     {.name = NULL}
 };
 
@@ -6595,10 +6580,7 @@ static const vshCmdOptDef opts_emulatorpin[] = {
     },
     VSH_DOMAIN_CONFIG_OPT_COMMON,
     VSH_DOMAIN_LIVE_OPT_COMMON,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VSH_DOMAIN_CURRENT_OPT_COMMON,
     {.name = NULL}
 };
 
@@ -6706,10 +6688,7 @@ static const vshCmdOptDef opts_setvcpus[] = {
     },
     VSH_DOMAIN_CONFIG_OPT_COMMON,
     VSH_DOMAIN_LIVE_OPT_COMMON,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VSH_DOMAIN_CURRENT_OPT_COMMON,
     {.name = "guest",
      .type = VSH_OT_BOOL,
      .help = N_("modify cpu state in the guest")
@@ -6788,10 +6767,7 @@ static const vshCmdOptDef opts_iothreadinfo[] = {
     VSH_DOMAIN_OPT_COMMON,
     VSH_DOMAIN_CONFIG_OPT_COMMON,
     VSH_DOMAIN_LIVE_OPT_COMMON,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VSH_DOMAIN_CURRENT_OPT_COMMON,
     {.name = NULL}
 };
 
@@ -6877,10 +6853,7 @@ static const vshCmdOptDef opts_iothreadpin[] = {
     },
     VSH_DOMAIN_CONFIG_OPT_COMMON,
     VSH_DOMAIN_LIVE_OPT_COMMON,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VSH_DOMAIN_CURRENT_OPT_COMMON,
     {.name = NULL}
 };
 
@@ -6957,10 +6930,7 @@ static const vshCmdOptDef opts_iothreadadd[] = {
     },
     VSH_DOMAIN_CONFIG_OPT_COMMON,
     VSH_DOMAIN_LIVE_OPT_COMMON,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VSH_DOMAIN_CURRENT_OPT_COMMON,
     {.name = NULL}
 };
 
@@ -7025,10 +6995,7 @@ static const vshCmdOptDef opts_iothreaddel[] = {
     },
     VSH_DOMAIN_CONFIG_OPT_COMMON,
     VSH_DOMAIN_LIVE_OPT_COMMON,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VSH_DOMAIN_CURRENT_OPT_COMMON,
     {.name = NULL}
 };
 
@@ -8281,10 +8248,7 @@ static const vshCmdOptDef opts_setmem[] = {
     },
     VSH_DOMAIN_CONFIG_OPT_COMMON,
     VSH_DOMAIN_LIVE_OPT_COMMON,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VSH_DOMAIN_CURRENT_OPT_COMMON,
     {.name = NULL}
 };
 
@@ -8365,10 +8329,7 @@ static const vshCmdOptDef opts_setmaxmem[] = {
     },
     VSH_DOMAIN_CONFIG_OPT_COMMON,
     VSH_DOMAIN_LIVE_OPT_COMMON,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VSH_DOMAIN_CURRENT_OPT_COMMON,
     {.name = NULL}
 };
 
@@ -8463,10 +8424,7 @@ static const vshCmdOptDef opts_memtune[] = {
     },
     VSH_DOMAIN_CONFIG_OPT_COMMON,
     VSH_DOMAIN_LIVE_OPT_COMMON,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VSH_DOMAIN_CURRENT_OPT_COMMON,
     {.name = NULL}
 };
 
@@ -8636,10 +8594,7 @@ static const vshCmdOptDef opts_numatune[] = {
     },
     VSH_DOMAIN_CONFIG_OPT_COMMON,
     VSH_DOMAIN_LIVE_OPT_COMMON,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VSH_DOMAIN_CURRENT_OPT_COMMON,
     {.name = NULL}
 };
 
@@ -10744,10 +10699,7 @@ static const vshCmdOptDef opts_detach_device[] = {
     VSH_DOMAIN_PERSISTENT_OPT_COMMON,
     VSH_DOMAIN_CONFIG_OPT_COMMON,
     VSH_DOMAIN_LIVE_OPT_COMMON,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VSH_DOMAIN_CURRENT_OPT_COMMON,
     {.name = NULL}
 };
 
@@ -10832,10 +10784,7 @@ static const vshCmdOptDef opts_update_device[] = {
     VSH_DOMAIN_PERSISTENT_OPT_COMMON,
     VSH_DOMAIN_CONFIG_OPT_COMMON,
     VSH_DOMAIN_LIVE_OPT_COMMON,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VSH_DOMAIN_CURRENT_OPT_COMMON,
     {.name = "force",
      .type = VSH_OT_BOOL,
      .help = N_("force device update")
@@ -10925,10 +10874,7 @@ static const vshCmdOptDef opts_detach_interface[] = {
     VSH_DOMAIN_PERSISTENT_OPT_COMMON,
     VSH_DOMAIN_CONFIG_OPT_COMMON,
     VSH_DOMAIN_LIVE_OPT_COMMON,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VSH_DOMAIN_CURRENT_OPT_COMMON,
     {.name = NULL}
 };
 
@@ -11328,10 +11274,7 @@ static const vshCmdOptDef opts_detach_disk[] = {
     VSH_DOMAIN_PERSISTENT_OPT_COMMON,
     VSH_DOMAIN_CONFIG_OPT_COMMON,
     VSH_DOMAIN_LIVE_OPT_COMMON,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VSH_DOMAIN_CURRENT_OPT_COMMON,
     {.name = NULL}
 };
 
-- 
2.5.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]