[libvirt] [PATCH v2 06/14] virsh: Create macro for common "live" option

John Ferlan jferlan at redhat.com
Fri Dec 18 15:45:43 UTC 2015


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

Non replaced instances are unique to the command.

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 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 dc3b07c..c6e9979 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -75,6 +75,12 @@
     .help = N_("affect next boot")                     \
     }                                                  \
 
+#define VIRSH_DOMAIN_LIVE_OPT_COMMON                   \
+    {.name = "live",                                   \
+     .type = VSH_OT_BOOL,                              \
+     .help = N_("affect running domain")               \
+    }                                                  \
+
 static virDomainPtr
 virshLookupDomainInternal(vshControl *ctl,
                           const char *cmdname,
@@ -225,10 +231,7 @@ static const vshCmdOptDef opts_attach_device[] = {
     },
     VIRSH_DOMAIN_PERSISTENT_OPT_COMMON,
     VIRSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -382,10 +385,7 @@ static const vshCmdOptDef opts_attach_disk[] = {
     },
     VIRSH_DOMAIN_PERSISTENT_OPT_COMMON,
     VIRSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -836,10 +836,7 @@ static const vshCmdOptDef opts_attach_interface[] = {
     },
     VIRSH_DOMAIN_PERSISTENT_OPT_COMMON,
     VIRSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -1279,10 +1276,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
      .help = N_("I/O size in bytes")
     },
     VIRSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -1530,10 +1524,7 @@ static const vshCmdOptDef opts_blkiotune[] = {
      .help = N_("per-device bytes wrote per second, in the form of /path/to/device,write_bytes_sec,...")
     },
     VIRSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -3216,10 +3207,7 @@ static const vshCmdOptDef opts_domiftune[] = {
      .help = N_("control domain's outgoing traffics")
     },
     VIRSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -6401,10 +6389,7 @@ static const vshCmdOptDef opts_vcpupin[] = {
      .help = N_("host cpu number(s) to set, or omit option to query")
     },
     VIRSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -6602,10 +6587,7 @@ static const vshCmdOptDef opts_emulatorpin[] = {
      .help = N_("host cpu number(s) to set, or omit option to query")
     },
     VIRSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -6716,10 +6698,7 @@ static const vshCmdOptDef opts_setvcpus[] = {
      .help = N_("set maximum limit on next boot")
     },
     VIRSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -6801,10 +6780,7 @@ static const vshCmdInfo info_iothreadinfo[] = {
 static const vshCmdOptDef opts_iothreadinfo[] = {
     VIRSH_DOMAIN_OPT_COMMON,
     VIRSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -6893,10 +6869,7 @@ static const vshCmdOptDef opts_iothreadpin[] = {
      .help = N_("host cpu number(s) to set")
     },
     VIRSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -6976,10 +6949,7 @@ static const vshCmdOptDef opts_iothreadadd[] = {
      .help = N_("iothread for the new IOThread")
     },
     VIRSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -7047,10 +7017,7 @@ static const vshCmdOptDef opts_iothreaddel[] = {
      .help = N_("iothread_id for the IOThread to delete")
     },
     VIRSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -8306,10 +8273,7 @@ static const vshCmdOptDef opts_setmem[] = {
      .help = N_("new memory size, as scaled integer (default KiB)")
     },
     VIRSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -8393,10 +8357,7 @@ static const vshCmdOptDef opts_setmaxmem[] = {
      .help = N_("new maximum memory size, as scaled integer (default KiB)")
     },
     VIRSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -8494,10 +8455,7 @@ static const vshCmdOptDef opts_memtune[] = {
      .help = N_("Min guaranteed memory, as scaled integer (default KiB)")
     },
     VIRSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -8670,10 +8628,7 @@ static const vshCmdOptDef opts_numatune[] = {
      .help = N_("NUMA node selections to set")
     },
     VIRSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -10781,10 +10736,7 @@ static const vshCmdOptDef opts_detach_device[] = {
     },
     VIRSH_DOMAIN_PERSISTENT_OPT_COMMON,
     VIRSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -10872,10 +10824,7 @@ static const vshCmdOptDef opts_update_device[] = {
     },
     VIRSH_DOMAIN_PERSISTENT_OPT_COMMON,
     VIRSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -10968,10 +10917,7 @@ static const vshCmdOptDef opts_detach_interface[] = {
     },
     VIRSH_DOMAIN_PERSISTENT_OPT_COMMON,
     VIRSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -11374,10 +11320,7 @@ static const vshCmdOptDef opts_detach_disk[] = {
     },
     VIRSH_DOMAIN_PERSISTENT_OPT_COMMON,
     VIRSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
-- 
2.5.0




More information about the libvir-list mailing list