[libvirt] [PATCH 4/8] virsh: Create macro for common "live" option

John Ferlan jferlan at redhat.com
Thu Dec 17 16:55:44 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 6a34688..c9e8475 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -82,6 +82,12 @@
     .help = N_("affect next boot")                     \
     }                                                  \
 
+#define VSH_DOMAIN_LIVE_OPT_COMMON                     \
+    {.name = "live",                                   \
+     .type = VSH_OT_BOOL,                              \
+     .help = N_("affect running domain")               \
+    }                                                  \
+
 static virDomainPtr
 virshLookupDomainInternal(vshControl *ctl,
                           const char *cmdname,
@@ -232,10 +238,7 @@ static const vshCmdOptDef opts_attach_device[] = {
     },
     VSH_DOMAIN_PERSISTENT_OPT_COMMON,
     VSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -389,10 +392,7 @@ static const vshCmdOptDef opts_attach_disk[] = {
     },
     VSH_DOMAIN_PERSISTENT_OPT_COMMON,
     VSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -843,10 +843,7 @@ static const vshCmdOptDef opts_attach_interface[] = {
     },
     VSH_DOMAIN_PERSISTENT_OPT_COMMON,
     VSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -1286,10 +1283,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
      .help = N_("I/O size in bytes")
     },
     VSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -1537,10 +1531,7 @@ static const vshCmdOptDef opts_blkiotune[] = {
      .help = N_("per-device bytes wrote per second, in the form of /path/to/device,write_bytes_sec,...")
     },
     VSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -3223,10 +3214,7 @@ static const vshCmdOptDef opts_domiftune[] = {
      .help = N_("control domain's outgoing traffics")
     },
     VSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -6408,10 +6396,7 @@ static const vshCmdOptDef opts_vcpupin[] = {
      .help = N_("host cpu number(s) to set, or omit option to query")
     },
     VSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -6609,10 +6594,7 @@ static const vshCmdOptDef opts_emulatorpin[] = {
      .help = N_("host cpu number(s) to set, or omit option to query")
     },
     VSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -6723,10 +6705,7 @@ static const vshCmdOptDef opts_setvcpus[] = {
      .help = N_("set maximum limit on next boot")
     },
     VSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -6808,10 +6787,7 @@ static const vshCmdInfo info_iothreadinfo[] = {
 static const vshCmdOptDef opts_iothreadinfo[] = {
     VSH_DOMAIN_OPT_COMMON,
     VSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -6900,10 +6876,7 @@ static const vshCmdOptDef opts_iothreadpin[] = {
      .help = N_("host cpu number(s) to set")
     },
     VSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -6983,10 +6956,7 @@ static const vshCmdOptDef opts_iothreadadd[] = {
      .help = N_("iothread for the new IOThread")
     },
     VSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -7054,10 +7024,7 @@ static const vshCmdOptDef opts_iothreaddel[] = {
      .help = N_("iothread_id for the IOThread to delete")
     },
     VSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -8313,10 +8280,7 @@ static const vshCmdOptDef opts_setmem[] = {
      .help = N_("new memory size, as scaled integer (default KiB)")
     },
     VSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -8400,10 +8364,7 @@ static const vshCmdOptDef opts_setmaxmem[] = {
      .help = N_("new maximum memory size, as scaled integer (default KiB)")
     },
     VSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -8501,10 +8462,7 @@ static const vshCmdOptDef opts_memtune[] = {
      .help = N_("Min guaranteed memory, as scaled integer (default KiB)")
     },
     VSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -8677,10 +8635,7 @@ static const vshCmdOptDef opts_numatune[] = {
      .help = N_("NUMA node selections to set")
     },
     VSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -10788,10 +10743,7 @@ static const vshCmdOptDef opts_detach_device[] = {
     },
     VSH_DOMAIN_PERSISTENT_OPT_COMMON,
     VSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -10879,10 +10831,7 @@ static const vshCmdOptDef opts_update_device[] = {
     },
     VSH_DOMAIN_PERSISTENT_OPT_COMMON,
     VSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -10975,10 +10924,7 @@ static const vshCmdOptDef opts_detach_interface[] = {
     },
     VSH_DOMAIN_PERSISTENT_OPT_COMMON,
     VSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VSH_DOMAIN_LIVE_OPT_COMMON,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -11381,10 +11327,7 @@ static const vshCmdOptDef opts_detach_disk[] = {
     },
     VSH_DOMAIN_PERSISTENT_OPT_COMMON,
     VSH_DOMAIN_CONFIG_OPT_COMMON,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VSH_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