]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: Create macro for common "live" option
authorJohn Ferlan <jferlan@redhat.com>
Sat, 9 Jan 2016 13:36:27 +0000 (08:36 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 11 Jan 2016 23:14:00 +0000 (18:14 -0500)
Rather than continually cut-n-paste the strings into each command,
create a common macro to be used generically. The macro will take a
single argument _helpstr which for many options in virsh-domain.c
is simply "affect running domain". So, create a second macro within that
file in order to define the more common use as a revector to the
common macro with the common _helpstr.

Signed-off-by: John Ferlan <jferlan@redhat.com>
tools/virsh-domain-monitor.c
tools/virsh-domain.c
tools/virsh-network.c
tools/virsh-snapshot.c
tools/virsh.h

index 4ac10e5bc59daf981b2d0c9349d492a90c8ac4a9..cd8a0da353e4e3b4ae95f3095b9fc20f0fae0f0c 100644 (file)
@@ -291,10 +291,7 @@ static const vshCmdOptDef opts_dommemstat[] = {
      .help = N_("period in seconds to set collection")
     },
     VIRSH_COMMON_OPT_CONFIG(N_("affect next boot")),
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running domain")
-    },
+    VIRSH_COMMON_OPT_LIVE(N_("affect running domain")),
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
index 5f4361f7fbe2f2d3207ca6f23397e7bb2769c285..807647503773802ae6bc78b0f1065f32f34b1032 100644 (file)
@@ -75,6 +75,9 @@
 #define VIRSH_COMMON_OPT_DOMAIN_CONFIG                 \
     VIRSH_COMMON_OPT_CONFIG(N_("affect next boot"))    \
 
+#define VIRSH_COMMON_OPT_DOMAIN_LIVE                   \
+    VIRSH_COMMON_OPT_LIVE(N_("affect running domain")) \
+
 static virDomainPtr
 virshLookupDomainInternal(vshControl *ctl,
                           const char *cmdname,
@@ -225,10 +228,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 +382,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 +833,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 +1273,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 +1521,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 +3204,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")
@@ -4819,10 +4804,7 @@ static const vshCmdOptDef opts_schedinfo[] = {
      .help = N_("get/set current scheduler info")
     },
     VIRSH_COMMON_OPT_CONFIG(N_("get/set value to be used on next boot")),
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("get/set value from running domain")
-    },
+    VIRSH_COMMON_OPT_LIVE(N_("get/set value from running domain")),
     {.name = "set",
      .type = VSH_OT_ARGV,
      .flags = VSH_OFLAG_NONE,
@@ -5130,10 +5112,7 @@ static const vshCmdOptDef opts_dump[] = {
      .flags = VSH_OFLAG_REQ,
      .help = N_("where to dump the core")
     },
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("perform a live core dump if supported")
-    },
+    VIRSH_COMMON_OPT_LIVE(N_("perform a live core dump if supported")),
     {.name = "crash",
      .type = VSH_OT_BOOL,
      .help = N_("crash the domain after core dump")
@@ -6094,10 +6073,7 @@ static const vshCmdOptDef opts_vcpucount[] = {
      .type = VSH_OT_BOOL,
      .help = N_("get number of currently active vcpus")
     },
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("get value from running domain")
-    },
+    VIRSH_COMMON_OPT_LIVE(N_("get value from running domain")),
     VIRSH_COMMON_OPT_CONFIG(N_("get value to be used on next boot")),
     {.name = "current",
      .type = VSH_OT_BOOL,
@@ -6415,10 +6391,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")
@@ -6616,10 +6589,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")
@@ -6730,10 +6700,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")
@@ -6815,10 +6782,7 @@ static const vshCmdInfo info_iothreadinfo[] = {
 static const vshCmdOptDef opts_iothreadinfo[] = {
     VIRSH_COMMON_OPT_DOMAIN_FULL,
     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")
@@ -6907,10 +6871,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")
@@ -6990,10 +6951,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")
@@ -7061,10 +7019,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")
@@ -7745,10 +7700,7 @@ static const vshCmdInfo info_desc[] = {
 
 static const vshCmdOptDef opts_desc[] = {
     VIRSH_COMMON_OPT_DOMAIN_FULL,
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("modify/get running state")
-    },
+    VIRSH_COMMON_OPT_LIVE(N_("modify/get running state")),
     VIRSH_COMMON_OPT_CONFIG(N_("modify/get persistent configuration")),
     {.name = "current",
      .type = VSH_OT_BOOL,
@@ -7922,10 +7874,7 @@ static const vshCmdOptDef opts_metadata[] = {
      .flags = VSH_OFLAG_REQ,
      .help = N_("URI of the namespace")
     },
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("modify/get running state")
-    },
+    VIRSH_COMMON_OPT_LIVE(N_("modify/get running state")),
     VIRSH_COMMON_OPT_CONFIG(N_("modify/get persistent configuration")),
     {.name = "current",
      .type = VSH_OT_BOOL,
@@ -8314,10 +8263,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")
@@ -8401,10 +8347,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")
@@ -8502,10 +8445,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")
@@ -8678,10 +8618,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")
@@ -9721,10 +9658,7 @@ static const vshCmdOptDef opts_migrate[] = {
      .flags = VSH_OFLAG_REQ,
      .help = N_("connection URI of the destination host as seen from the client(normal migration) or source(p2p migration)")
     },
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("live migration")
-    },
+    VIRSH_COMMON_OPT_LIVE(N_("live migration")),
     {.name = "offline",
      .type = VSH_OT_BOOL,
      .help = N_("offline migration")
@@ -10799,10 +10733,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")
@@ -10890,10 +10821,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")
@@ -10986,10 +10914,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")
@@ -11392,10 +11317,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")
@@ -12366,10 +12288,7 @@ static const vshCmdOptDef opts_change_media[] = {
      .help = N_("can be either or both of --live and --config, "
                 "depends on implementation of hypervisor driver")
     },
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("alter live configuration of running domain")
-    },
+    VIRSH_COMMON_OPT_LIVE(N_("alter live configuration of running domain")),
     VIRSH_COMMON_OPT_CONFIG(N_("alter persistent configuration, effect "
                                "observed on next boot")),
     {.name = "force",
index 0568b144a2ff454c1661be3b37696ef82334c38c..90d4c8b589164b8d56b6678b5160c1be59e57293 100644 (file)
@@ -907,10 +907,7 @@ static const vshCmdOptDef opts_network_update[] = {
      .help = N_("which parent object to search through")
     },
     VIRSH_COMMON_OPT_CONFIG(N_("affect next network startup")),
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect running network")
-    },
+    VIRSH_COMMON_OPT_LIVE(N_("affect running network")),
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("affect current state of network")
index 13ad7e59e9ff9fbbb3ff3f13e6c772e24b8345b9..f4b2350b845a8a3f836408126ffdf477873f4d21 100644 (file)
@@ -163,10 +163,7 @@ static const vshCmdOptDef opts_snapshot_create[] = {
      .type = VSH_OT_BOOL,
      .help = N_("require atomic operation")
     },
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("take a live snapshot")
-    },
+    VIRSH_COMMON_OPT_LIVE(N_("take a live snapshot")),
     {.name = NULL}
 };
 
@@ -364,10 +361,7 @@ static const vshCmdOptDef opts_snapshot_create_as[] = {
      .type = VSH_OT_BOOL,
      .help = N_("require atomic operation")
     },
-    {.name = "live",
-     .type = VSH_OT_BOOL,
-     .help = N_("take a live snapshot")
-    },
+    VIRSH_COMMON_OPT_LIVE(N_("take a live snapshot")),
     {.name = "memspec",
      .type = VSH_OT_STRING,
      .flags = VSH_OFLAG_REQ_OPT,
index c6414aec6ac574e29845f61c6cb631bb2baf422a..e731964634da95258974697a91690deed3f2d76e 100644 (file)
     .help = _helpstr                                              \
     }                                                             \
 
+# define VIRSH_COMMON_OPT_LIVE(_helpstr)                          \
+    {.name = "live",                                              \
+     .type = VSH_OT_BOOL,                                         \
+     .help = _helpstr                                             \
+    }                                                             \
+
 typedef struct _virshControl virshControl;
 typedef virshControl *virshControlPtr;