[PATCH v3 06/14] virsh: Create macro for common "live" 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 = "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@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 ba6ba7f..50d8225 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -75,6 +75,12 @@
     .help = N_("affect next boot")                     \
     }                                                  \
 
+#define VIRSH_COMMON_OPT_DOMAIN_LIVE                   \
+    {.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_COMMON_OPT_DOMAIN_PERSISTENT,
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_LIVE,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -382,10 +385,7 @@ static const vshCmdOptDef opts_attach_disk[] = {
     },
     VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_LIVE,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -836,10 +836,7 @@ static const vshCmdOptDef opts_attach_interface[] = {
     },
     VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_LIVE,
     {.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_COMMON_OPT_DOMAIN_CONFIG,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_LIVE,
     {.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_COMMON_OPT_DOMAIN_CONFIG,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_LIVE,
     {.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_COMMON_OPT_DOMAIN_CONFIG,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_LIVE,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -6429,10 +6417,7 @@ static const vshCmdOptDef opts_vcpupin[] = {
      .help = N_("host cpu number(s) to set, or omit option to query")
     },
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_LIVE,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -6630,10 +6615,7 @@ static const vshCmdOptDef opts_emulatorpin[] = {
      .help = N_("host cpu number(s) to set, or omit option to query")
     },
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_LIVE,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -6744,10 +6726,7 @@ static const vshCmdOptDef opts_setvcpus[] = {
      .help = N_("set maximum limit on next boot")
     },
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_LIVE,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -6829,10 +6808,7 @@ static const vshCmdInfo info_iothreadinfo[] = {
 static const vshCmdOptDef opts_iothreadinfo[] = {
     VIRSH_COMMON_OPT_DOMAIN,
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_LIVE,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -6921,10 +6897,7 @@ static const vshCmdOptDef opts_iothreadpin[] = {
      .help = N_("host cpu number(s) to set")
     },
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_LIVE,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -7004,10 +6977,7 @@ static const vshCmdOptDef opts_iothreadadd[] = {
      .help = N_("iothread for the new IOThread")
     },
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_LIVE,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -7075,10 +7045,7 @@ static const vshCmdOptDef opts_iothreaddel[] = {
      .help = N_("iothread_id for the IOThread to delete")
     },
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_LIVE,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -8334,10 +8301,7 @@ static const vshCmdOptDef opts_setmem[] = {
      .help = N_("new memory size, as scaled integer (default KiB)")
     },
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_LIVE,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -8421,10 +8385,7 @@ static const vshCmdOptDef opts_setmaxmem[] = {
      .help = N_("new maximum memory size, as scaled integer (default KiB)")
     },
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_LIVE,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -8522,10 +8483,7 @@ static const vshCmdOptDef opts_memtune[] = {
      .help = N_("Min guaranteed memory, as scaled integer (default KiB)")
     },
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_LIVE,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -8698,10 +8656,7 @@ static const vshCmdOptDef opts_numatune[] = {
      .help = N_("NUMA node selections to set")
     },
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_LIVE,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -10813,10 +10768,7 @@ static const vshCmdOptDef opts_detach_device[] = {
     },
     VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_LIVE,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -10904,10 +10856,7 @@ static const vshCmdOptDef opts_update_device[] = {
     },
     VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_LIVE,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -11000,10 +10949,7 @@ static const vshCmdOptDef opts_detach_interface[] = {
     },
     VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_LIVE,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
@@ -11406,10 +11352,7 @@ static const vshCmdOptDef opts_detach_disk[] = {
     },
     VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_LIVE,
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
-- 
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]