]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: Create macro for common "config" option
authorJohn Ferlan <jferlan@redhat.com>
Sat, 9 Jan 2016 13:36:26 +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 next boot". 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.h

index 043221b1ec68010147e3519adc73286d0db08338..4ac10e5bc59daf981b2d0c9349d492a90c8ac4a9 100644 (file)
@@ -290,10 +290,7 @@ static const vshCmdOptDef opts_dommemstat[] = {
      .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("period in seconds to set collection")
     },
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect next boot")
-    },
+    VIRSH_COMMON_OPT_CONFIG(N_("affect next boot")),
     {.name = "live",
      .type = VSH_OT_BOOL,
      .help = N_("affect running domain")
@@ -681,10 +678,7 @@ static const vshCmdOptDef opts_domif_getlink[] = {
      .type = VSH_OT_ALIAS,
      .help = "config"
     },
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("Get persistent interface state")
-    },
+    VIRSH_COMMON_OPT_CONFIG(N_("Get persistent interface state")),
     {.name = NULL}
 };
 
index f59c3eda3541f58d8e727a4c7c94ad0d9ed82bb3..5f4361f7fbe2f2d3207ca6f23397e7bb2769c285 100644 (file)
@@ -72,6 +72,9 @@
      .help = N_("make live change persistent")         \
     }                                                  \
 
+#define VIRSH_COMMON_OPT_DOMAIN_CONFIG                 \
+    VIRSH_COMMON_OPT_CONFIG(N_("affect next boot"))    \
+
 static virDomainPtr
 virshLookupDomainInternal(vshControl *ctl,
                           const char *cmdname,
@@ -221,10 +224,7 @@ static const vshCmdOptDef opts_attach_device[] = {
      .help = N_("XML file")
     },
     VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect next boot")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     {.name = "live",
      .type = VSH_OT_BOOL,
      .help = N_("affect running domain")
@@ -381,10 +381,7 @@ static const vshCmdOptDef opts_attach_disk[] = {
      .help = N_("print XML document rather than attach the disk")
     },
     VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect next boot")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     {.name = "live",
      .type = VSH_OT_BOOL,
      .help = N_("affect running domain")
@@ -838,10 +835,7 @@ static const vshCmdOptDef opts_attach_interface[] = {
      .help = N_("control domain's outgoing traffics")
     },
     VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect next boot")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     {.name = "live",
      .type = VSH_OT_BOOL,
      .help = N_("affect running domain")
@@ -1284,10 +1278,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
      .type = VSH_OT_INT,
      .help = N_("I/O size in bytes")
     },
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect next boot")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     {.name = "live",
      .type = VSH_OT_BOOL,
      .help = N_("affect running domain")
@@ -1538,10 +1529,7 @@ static const vshCmdOptDef opts_blkiotune[] = {
      .type = VSH_OT_STRING,
      .help = N_("per-device bytes wrote per second, in the form of /path/to/device,write_bytes_sec,...")
     },
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect next boot")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     {.name = "live",
      .type = VSH_OT_BOOL,
      .help = N_("affect running domain")
@@ -3048,10 +3036,7 @@ static const vshCmdOptDef opts_domif_setlink[] = {
      .type = VSH_OT_ALIAS,
      .help = "config"
     },
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect next boot")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     {.name = NULL}
 };
 
@@ -3230,10 +3215,7 @@ static const vshCmdOptDef opts_domiftune[] = {
      .type = VSH_OT_STRING,
      .help = N_("control domain's outgoing traffics")
     },
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect next boot")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     {.name = "live",
      .type = VSH_OT_BOOL,
      .help = N_("affect running domain")
@@ -4836,10 +4818,7 @@ static const vshCmdOptDef opts_schedinfo[] = {
      .type = VSH_OT_BOOL,
      .help = N_("get/set current scheduler info")
     },
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("get/set value to be used on next boot")
-    },
+    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")
@@ -6119,10 +6098,7 @@ static const vshCmdOptDef opts_vcpucount[] = {
      .type = VSH_OT_BOOL,
      .help = N_("get value from running domain")
     },
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("get value to be used on next boot")
-    },
+    VIRSH_COMMON_OPT_CONFIG(N_("get value to be used on next boot")),
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("get value according to current domain state")
@@ -6438,10 +6414,7 @@ static const vshCmdOptDef opts_vcpupin[] = {
      .flags = VSH_OFLAG_EMPTY_OK,
      .help = N_("host cpu number(s) to set, or omit option to query")
     },
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect next boot")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     {.name = "live",
      .type = VSH_OT_BOOL,
      .help = N_("affect running domain")
@@ -6642,10 +6615,7 @@ static const vshCmdOptDef opts_emulatorpin[] = {
      .flags = VSH_OFLAG_EMPTY_OK,
      .help = N_("host cpu number(s) to set, or omit option to query")
     },
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect next boot")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     {.name = "live",
      .type = VSH_OT_BOOL,
      .help = N_("affect running domain")
@@ -6759,10 +6729,7 @@ static const vshCmdOptDef opts_setvcpus[] = {
      .type = VSH_OT_BOOL,
      .help = N_("set maximum limit on next boot")
     },
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect next boot")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     {.name = "live",
      .type = VSH_OT_BOOL,
      .help = N_("affect running domain")
@@ -6847,10 +6814,7 @@ static const vshCmdInfo info_iothreadinfo[] = {
 };
 static const vshCmdOptDef opts_iothreadinfo[] = {
     VIRSH_COMMON_OPT_DOMAIN_FULL,
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect next boot")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     {.name = "live",
      .type = VSH_OT_BOOL,
      .help = N_("affect running domain")
@@ -6942,10 +6906,7 @@ static const vshCmdOptDef opts_iothreadpin[] = {
      .flags = VSH_OFLAG_REQ,
      .help = N_("host cpu number(s) to set")
     },
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect next boot")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     {.name = "live",
      .type = VSH_OT_BOOL,
      .help = N_("affect running domain")
@@ -7028,10 +6989,7 @@ static const vshCmdOptDef opts_iothreadadd[] = {
      .flags = VSH_OFLAG_REQ,
      .help = N_("iothread for the new IOThread")
     },
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect next boot")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     {.name = "live",
      .type = VSH_OT_BOOL,
      .help = N_("affect running domain")
@@ -7102,10 +7060,7 @@ static const vshCmdOptDef opts_iothreaddel[] = {
      .flags = VSH_OFLAG_REQ,
      .help = N_("iothread_id for the IOThread to delete")
     },
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect next boot")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     {.name = "live",
      .type = VSH_OT_BOOL,
      .help = N_("affect running domain")
@@ -7794,10 +7749,7 @@ static const vshCmdOptDef opts_desc[] = {
      .type = VSH_OT_BOOL,
      .help = N_("modify/get running state")
     },
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("modify/get persistent configuration")
-    },
+    VIRSH_COMMON_OPT_CONFIG(N_("modify/get persistent configuration")),
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("modify/get current state configuration")
@@ -7974,10 +7926,7 @@ static const vshCmdOptDef opts_metadata[] = {
      .type = VSH_OT_BOOL,
      .help = N_("modify/get running state")
     },
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("modify/get persistent configuration")
-    },
+    VIRSH_COMMON_OPT_CONFIG(N_("modify/get persistent configuration")),
     {.name = "current",
      .type = VSH_OT_BOOL,
      .help = N_("modify/get current state configuration")
@@ -8364,10 +8313,7 @@ static const vshCmdOptDef opts_setmem[] = {
      .flags = VSH_OFLAG_REQ,
      .help = N_("new memory size, as scaled integer (default KiB)")
     },
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect next boot")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     {.name = "live",
      .type = VSH_OT_BOOL,
      .help = N_("affect running domain")
@@ -8454,10 +8400,7 @@ static const vshCmdOptDef opts_setmaxmem[] = {
      .flags = VSH_OFLAG_REQ,
      .help = N_("new maximum memory size, as scaled integer (default KiB)")
     },
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect next boot")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     {.name = "live",
      .type = VSH_OT_BOOL,
      .help = N_("affect running domain")
@@ -8558,10 +8501,7 @@ static const vshCmdOptDef opts_memtune[] = {
      .type = VSH_OT_INT,
      .help = N_("Min guaranteed memory, as scaled integer (default KiB)")
     },
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect next boot")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     {.name = "live",
      .type = VSH_OT_BOOL,
      .help = N_("affect running domain")
@@ -8737,10 +8677,7 @@ static const vshCmdOptDef opts_numatune[] = {
      .type = VSH_OT_STRING,
      .help = N_("NUMA node selections to set")
     },
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect next boot")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     {.name = "live",
      .type = VSH_OT_BOOL,
      .help = N_("affect running domain")
@@ -10861,10 +10798,7 @@ static const vshCmdOptDef opts_detach_device[] = {
      .help = N_("XML file")
     },
     VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect next boot")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     {.name = "live",
      .type = VSH_OT_BOOL,
      .help = N_("affect running domain")
@@ -10955,10 +10889,7 @@ static const vshCmdOptDef opts_update_device[] = {
      .help = N_("XML file")
     },
     VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect next boot")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     {.name = "live",
      .type = VSH_OT_BOOL,
      .help = N_("affect running domain")
@@ -11054,10 +10985,7 @@ static const vshCmdOptDef opts_detach_interface[] = {
      .help = N_("MAC address")
     },
     VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect next boot")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     {.name = "live",
      .type = VSH_OT_BOOL,
      .help = N_("affect running domain")
@@ -11463,10 +11391,7 @@ static const vshCmdOptDef opts_detach_disk[] = {
      .help = N_("target of disk device")
     },
     VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect next boot")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     {.name = "live",
      .type = VSH_OT_BOOL,
      .help = N_("affect running domain")
@@ -12445,10 +12370,8 @@ static const vshCmdOptDef opts_change_media[] = {
      .type = VSH_OT_BOOL,
      .help = N_("alter live configuration of running domain")
     },
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("alter persistent configuration, effect observed on next boot")
-    },
+    VIRSH_COMMON_OPT_CONFIG(N_("alter persistent configuration, effect "
+                               "observed on next boot")),
     {.name = "force",
      .type = VSH_OT_BOOL,
      .help = N_("force media changing")
index 3eb1160078c0f6b18c68c4d23cc65849e363b314..0568b144a2ff454c1661be3b37696ef82334c38c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * virsh-network.c: Commands to manage network
  *
- * Copyright (C) 2005, 2007-2015 Red Hat, Inc.
+ * Copyright (C) 2005, 2007-2016 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -906,10 +906,7 @@ static const vshCmdOptDef opts_network_update[] = {
      .type = VSH_OT_INT,
      .help = N_("which parent object to search through")
     },
-    {.name = "config",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect next network startup")
-    },
+    VIRSH_COMMON_OPT_CONFIG(N_("affect next network startup")),
     {.name = "live",
      .type = VSH_OT_BOOL,
      .help = N_("affect running network")
index 6fa5290f816358de9a81924cc38b91ac46615193..c6414aec6ac574e29845f61c6cb631bb2baf422a 100644 (file)
      .help = _helpstr                                             \
     }                                                             \
 
+# define VIRSH_COMMON_OPT_CONFIG(_helpstr)                        \
+    {.name = "config",                                            \
+    .type = VSH_OT_BOOL,                                          \
+    .help = _helpstr                                              \
+    }                                                             \
+
 typedef struct _virshControl virshControl;
 typedef virshControl *virshControlPtr;