]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: Create macro for common "current" option
authorJohn Ferlan <jferlan@redhat.com>
Sat, 9 Jan 2016 13:36:28 +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 current 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 cd8a0da353e4e3b4ae95f3095b9fc20f0fae0f0c..7eb387d17e8b530b8578da12870dccfb936a84f8 100644 (file)
@@ -292,10 +292,7 @@ static const vshCmdOptDef opts_dommemstat[] = {
     },
     VIRSH_COMMON_OPT_CONFIG(N_("affect next boot")),
     VIRSH_COMMON_OPT_LIVE(N_("affect running domain")),
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VIRSH_COMMON_OPT_CURRENT(N_("affect current domain")),
     {.name = NULL}
 };
 
index 807647503773802ae6bc78b0f1065f32f34b1032..456e5969bc7511682920a683773b06e2319d2979 100644 (file)
@@ -78,6 +78,9 @@
 #define VIRSH_COMMON_OPT_DOMAIN_LIVE                   \
     VIRSH_COMMON_OPT_LIVE(N_("affect running domain")) \
 
+#define VIRSH_COMMON_OPT_DOMAIN_CURRENT                   \
+    VIRSH_COMMON_OPT_CURRENT(N_("affect current domain")) \
+
 static virDomainPtr
 virshLookupDomainInternal(vshControl *ctl,
                           const char *cmdname,
@@ -229,10 +232,7 @@ static const vshCmdOptDef opts_attach_device[] = {
     VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     VIRSH_COMMON_OPT_DOMAIN_LIVE,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CURRENT,
     {.name = NULL}
 };
 
@@ -383,10 +383,7 @@ static const vshCmdOptDef opts_attach_disk[] = {
     VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     VIRSH_COMMON_OPT_DOMAIN_LIVE,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CURRENT,
     {.name = NULL}
 };
 
@@ -834,10 +831,7 @@ static const vshCmdOptDef opts_attach_interface[] = {
     VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     VIRSH_COMMON_OPT_DOMAIN_LIVE,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CURRENT,
     {.name = "print-xml",
      .type = VSH_OT_BOOL,
      .help = N_("print XML document rather than attach the interface")
@@ -1274,10 +1268,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
     },
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     VIRSH_COMMON_OPT_DOMAIN_LIVE,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CURRENT,
     {.name = NULL}
 };
 
@@ -1522,10 +1513,7 @@ static const vshCmdOptDef opts_blkiotune[] = {
     },
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     VIRSH_COMMON_OPT_DOMAIN_LIVE,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CURRENT,
     {.name = NULL}
 };
 
@@ -3205,10 +3193,7 @@ static const vshCmdOptDef opts_domiftune[] = {
     },
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     VIRSH_COMMON_OPT_DOMAIN_LIVE,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CURRENT,
     {.name = NULL}
 };
 
@@ -4799,10 +4784,7 @@ static const vshCmdOptDef opts_schedinfo[] = {
      .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("cap for XEN_CREDIT")
     },
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("get/set current scheduler info")
-    },
+    VIRSH_COMMON_OPT_CURRENT(N_("get/set current scheduler info")),
     VIRSH_COMMON_OPT_CONFIG(N_("get/set value to be used on next boot")),
     VIRSH_COMMON_OPT_LIVE(N_("get/set value from running domain")),
     {.name = "set",
@@ -6075,10 +6057,7 @@ static const vshCmdOptDef opts_vcpucount[] = {
     },
     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,
-     .help = N_("get value according to current domain state")
-    },
+    VIRSH_COMMON_OPT_CURRENT(N_("get value according to current domain state")),
     {.name = "guest",
      .type = VSH_OT_BOOL,
      .help = N_("retrieve vcpu count from the guest instead of the hypervisor")
@@ -6392,10 +6371,7 @@ static const vshCmdOptDef opts_vcpupin[] = {
     },
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     VIRSH_COMMON_OPT_DOMAIN_LIVE,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CURRENT,
     {.name = NULL}
 };
 
@@ -6590,10 +6566,7 @@ static const vshCmdOptDef opts_emulatorpin[] = {
     },
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     VIRSH_COMMON_OPT_DOMAIN_LIVE,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CURRENT,
     {.name = NULL}
 };
 
@@ -6701,10 +6674,7 @@ static const vshCmdOptDef opts_setvcpus[] = {
     },
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     VIRSH_COMMON_OPT_DOMAIN_LIVE,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CURRENT,
     {.name = "guest",
      .type = VSH_OT_BOOL,
      .help = N_("modify cpu state in the guest")
@@ -6783,10 +6753,7 @@ static const vshCmdOptDef opts_iothreadinfo[] = {
     VIRSH_COMMON_OPT_DOMAIN_FULL,
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     VIRSH_COMMON_OPT_DOMAIN_LIVE,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CURRENT,
     {.name = NULL}
 };
 
@@ -6872,10 +6839,7 @@ static const vshCmdOptDef opts_iothreadpin[] = {
     },
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     VIRSH_COMMON_OPT_DOMAIN_LIVE,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CURRENT,
     {.name = NULL}
 };
 
@@ -6952,10 +6916,7 @@ static const vshCmdOptDef opts_iothreadadd[] = {
     },
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     VIRSH_COMMON_OPT_DOMAIN_LIVE,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CURRENT,
     {.name = NULL}
 };
 
@@ -7020,10 +6981,7 @@ static const vshCmdOptDef opts_iothreaddel[] = {
     },
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     VIRSH_COMMON_OPT_DOMAIN_LIVE,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CURRENT,
     {.name = NULL}
 };
 
@@ -7702,10 +7660,7 @@ static const vshCmdOptDef opts_desc[] = {
     VIRSH_COMMON_OPT_DOMAIN_FULL,
     VIRSH_COMMON_OPT_LIVE(N_("modify/get running state")),
     VIRSH_COMMON_OPT_CONFIG(N_("modify/get persistent configuration")),
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("modify/get current state configuration")
-    },
+    VIRSH_COMMON_OPT_CURRENT(N_("modify/get current state configuration")),
     {.name = "title",
      .type = VSH_OT_BOOL,
      .help = N_("modify/get the title instead of description")
@@ -7876,10 +7831,7 @@ static const vshCmdOptDef opts_metadata[] = {
     },
     VIRSH_COMMON_OPT_LIVE(N_("modify/get running state")),
     VIRSH_COMMON_OPT_CONFIG(N_("modify/get persistent configuration")),
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("modify/get current state configuration")
-    },
+    VIRSH_COMMON_OPT_CURRENT(N_("modify/get current state configuration")),
     {.name = "edit",
      .type = VSH_OT_BOOL,
      .help = N_("use an editor to change the metadata")
@@ -8264,10 +8216,7 @@ static const vshCmdOptDef opts_setmem[] = {
     },
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     VIRSH_COMMON_OPT_DOMAIN_LIVE,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CURRENT,
     {.name = NULL}
 };
 
@@ -8348,10 +8297,7 @@ static const vshCmdOptDef opts_setmaxmem[] = {
     },
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     VIRSH_COMMON_OPT_DOMAIN_LIVE,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CURRENT,
     {.name = NULL}
 };
 
@@ -8446,10 +8392,7 @@ static const vshCmdOptDef opts_memtune[] = {
     },
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     VIRSH_COMMON_OPT_DOMAIN_LIVE,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CURRENT,
     {.name = NULL}
 };
 
@@ -8619,10 +8562,7 @@ static const vshCmdOptDef opts_numatune[] = {
     },
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     VIRSH_COMMON_OPT_DOMAIN_LIVE,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CURRENT,
     {.name = NULL}
 };
 
@@ -10734,10 +10674,7 @@ static const vshCmdOptDef opts_detach_device[] = {
     VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     VIRSH_COMMON_OPT_DOMAIN_LIVE,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CURRENT,
     {.name = NULL}
 };
 
@@ -10822,10 +10759,7 @@ static const vshCmdOptDef opts_update_device[] = {
     VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     VIRSH_COMMON_OPT_DOMAIN_LIVE,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CURRENT,
     {.name = "force",
      .type = VSH_OT_BOOL,
      .help = N_("force device update")
@@ -10915,10 +10849,7 @@ static const vshCmdOptDef opts_detach_interface[] = {
     VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     VIRSH_COMMON_OPT_DOMAIN_LIVE,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CURRENT,
     {.name = NULL}
 };
 
@@ -11318,10 +11249,7 @@ static const vshCmdOptDef opts_detach_disk[] = {
     VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     VIRSH_COMMON_OPT_DOMAIN_LIVE,
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current domain")
-    },
+    VIRSH_COMMON_OPT_DOMAIN_CURRENT,
     {.name = NULL}
 };
 
@@ -12283,11 +12211,9 @@ static const vshCmdOptDef opts_change_media[] = {
      .type = VSH_OT_BOOL,
      .help = N_("Update the media")
     },
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("can be either or both of --live and --config, "
-                "depends on implementation of hypervisor driver")
-    },
+    VIRSH_COMMON_OPT_CURRENT(N_("can be either or both of --live and "
+                                "--config, depends on implementation "
+                                "hypervisor driver")),
     VIRSH_COMMON_OPT_LIVE(N_("alter live configuration of running domain")),
     VIRSH_COMMON_OPT_CONFIG(N_("alter persistent configuration, effect "
                                "observed on next boot")),
index 90d4c8b589164b8d56b6678b5160c1be59e57293..24e80490c6033057a0110af69320b4a4eca5bdec 100644 (file)
@@ -908,10 +908,7 @@ static const vshCmdOptDef opts_network_update[] = {
     },
     VIRSH_COMMON_OPT_CONFIG(N_("affect next network startup")),
     VIRSH_COMMON_OPT_LIVE(N_("affect running network")),
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("affect current state of network")
-    },
+    VIRSH_COMMON_OPT_CURRENT(N_("affect current state of network")),
     {.name = NULL}
 };
 
index f4b2350b845a8a3f836408126ffdf477873f4d21..f879e7aec4708de948942a49cda8392ddd7b6ad2 100644 (file)
@@ -135,10 +135,7 @@ static const vshCmdOptDef opts_snapshot_create[] = {
      .type = VSH_OT_BOOL,
      .help = N_("redefine metadata for existing snapshot")
     },
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("with redefine, set current snapshot")
-    },
+    VIRSH_COMMON_OPT_CURRENT(N_("with redefine, set current snapshot")),
     {.name = "no-metadata",
      .type = VSH_OT_BOOL,
      .help = N_("take snapshot but create no metadata")
@@ -518,10 +515,7 @@ static const vshCmdOptDef opts_snapshot_edit[] = {
      .type = VSH_OT_STRING,
      .help = N_("snapshot name")
     },
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("also set edited snapshot as current")
-    },
+    VIRSH_COMMON_OPT_CURRENT(N_("also set edited snapshot as current")),
     {.name = "rename",
      .type = VSH_OT_BOOL,
      .help = N_("allow renaming an existing snapshot")
@@ -868,10 +862,7 @@ static const vshCmdOptDef opts_snapshot_info[] = {
      .type = VSH_OT_STRING,
      .help = N_("snapshot name")
     },
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("info on current snapshot")
-    },
+    VIRSH_COMMON_OPT_CURRENT(N_("info on current snapshot")),
     {.name = NULL}
 };
 
@@ -1471,10 +1462,7 @@ static const vshCmdOptDef opts_snapshot_list[] = {
      .type = VSH_OT_STRING,
      .help = N_("limit list to children of given snapshot")
     },
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("limit list to children of current snapshot")
-    },
+    VIRSH_COMMON_OPT_CURRENT(N_("limit list to children of current snapshot")),
     {.name = "descendants",
      .type = VSH_OT_BOOL,
      .help = N_("with --from, list all descendants")
@@ -1747,10 +1735,7 @@ static const vshCmdOptDef opts_snapshot_parent[] = {
      .type = VSH_OT_STRING,
      .help = N_("find parent of snapshot name")
     },
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("find parent of current snapshot")
-    },
+    VIRSH_COMMON_OPT_CURRENT(N_("find parent of current snapshot")),
     {.name = NULL}
 };
 
@@ -1811,10 +1796,7 @@ static const vshCmdOptDef opts_snapshot_revert[] = {
      .type = VSH_OT_STRING,
      .help = N_("snapshot name")
     },
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("revert to current snapshot")
-    },
+    VIRSH_COMMON_OPT_CURRENT(N_("revert to current snapshot")),
     {.name = "running",
      .type = VSH_OT_BOOL,
      .help = N_("after reverting, change state to running")
@@ -1900,10 +1882,7 @@ static const vshCmdOptDef opts_snapshot_delete[] = {
      .type = VSH_OT_STRING,
      .help = N_("snapshot name")
     },
-    {.name = "current",
-     .type = VSH_OT_BOOL,
-     .help = N_("delete current snapshot")
-    },
+    VIRSH_COMMON_OPT_CURRENT(N_("delete current snapshot")),
     {.name = "children",
      .type = VSH_OT_BOOL,
      .help = N_("delete snapshot and all children")
index e731964634da95258974697a91690deed3f2d76e..ba7e31457c30596c6628712ede91be4bf794dbd0 100644 (file)
      .help = _helpstr                                             \
     }                                                             \
 
+# define VIRSH_COMMON_OPT_CURRENT(_helpstr)                       \
+    {.name = "current",                                           \
+     .type = VSH_OT_BOOL,                                         \
+     .help = _helpstr                                             \
+    }                                                             \
+
 typedef struct _virshControl virshControl;
 typedef virshControl *virshControlPtr;