[PATCH v2 13/14] virsh: Create macro for common "network" 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 = "network",' entries are replaced, just those that have the
common .help string of "network name or uuid".

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 tools/virsh-network.c | 61 ++++++++++++++-------------------------------------
 1 file changed, 16 insertions(+), 45 deletions(-)

diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index bd89c11..26db6b6 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -33,6 +33,13 @@
 #include "virstring.h"
 #include "conf/network_conf.h"
 
+#define VIRSH_NETWORK_OPT_COMMON                              \
+    {.name = "network",                                       \
+     .type = VSH_OT_DATA,                                     \
+     .flags = VSH_OFLAG_REQ,                                  \
+     .help = N_("network name or uuid")                       \
+    }                                                         \
+
 virNetworkPtr
 virshCommandOptNetworkBy(vshControl *ctl, const vshCmd *cmd,
                          const char **name, unsigned int flags)
@@ -85,11 +92,7 @@ static const vshCmdInfo info_network_autostart[] = {
 };
 
 static const vshCmdOptDef opts_network_autostart[] = {
-    {.name = "network",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("network name or uuid")
-    },
+    VIRSH_NETWORK_OPT_COMMON,
     {.name = "disable",
      .type = VSH_OT_BOOL,
      .help = N_("disable autostarting")
@@ -244,11 +247,7 @@ static const vshCmdInfo info_network_destroy[] = {
 };
 
 static const vshCmdOptDef opts_network_destroy[] = {
-    {.name = "network",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("network name or uuid")
-    },
+    VIRSH_NETWORK_OPT_COMMON,
     {.name = NULL}
 };
 
@@ -287,11 +286,7 @@ static const vshCmdInfo info_network_dumpxml[] = {
 };
 
 static const vshCmdOptDef opts_network_dumpxml[] = {
-    {.name = "network",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("network name or uuid")
-    },
+    VIRSH_NETWORK_OPT_COMMON,
     {.name = "inactive",
      .type = VSH_OT_BOOL,
      .help = N_("network information of an inactive domain")
@@ -342,11 +337,7 @@ static const vshCmdInfo info_network_info[] = {
 };
 
 static const vshCmdOptDef opts_network_info[] = {
-    {.name = "network",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("network name or uuid")
-    },
+    VIRSH_NETWORK_OPT_COMMON,
     {.name = NULL}
 };
 
@@ -795,11 +786,7 @@ static const vshCmdInfo info_network_start[] = {
 };
 
 static const vshCmdOptDef opts_network_start[] = {
-    {.name = "network",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("network name or uuid")
-    },
+    VIRSH_NETWORK_OPT_COMMON,
     {.name = NULL}
 };
 
@@ -837,11 +824,7 @@ static const vshCmdInfo info_network_undefine[] = {
 };
 
 static const vshCmdOptDef opts_network_undefine[] = {
-    {.name = "network",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("network name or uuid")
-    },
+    VIRSH_NETWORK_OPT_COMMON,
     {.name = NULL}
 };
 
@@ -880,11 +863,7 @@ static const vshCmdInfo info_network_update[] = {
 };
 
 static const vshCmdOptDef opts_network_update[] = {
-    {.name = "network",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("network name or uuid")
-    },
+    VIRSH_NETWORK_OPT_COMMON,
     {.name = "command",
      .type = VSH_OT_DATA,
      .flags = VSH_OFLAG_REQ,
@@ -1097,11 +1076,7 @@ static const vshCmdInfo info_network_edit[] = {
 };
 
 static const vshCmdOptDef opts_network_edit[] = {
-    {.name = "network",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("network name or uuid")
-    },
+    VIRSH_NETWORK_OPT_COMMON,
     {.name = NULL}
 };
 
@@ -1329,11 +1304,7 @@ static const vshCmdInfo info_network_dhcp_leases[] = {
 };
 
 static const vshCmdOptDef opts_network_dhcp_leases[] = {
-    {.name = "network",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("network name or uuid")
-    },
+    VIRSH_NETWORK_OPT_COMMON,
     {.name = "mac",
      .type = VSH_OT_STRING,
      .flags = VSH_OFLAG_NONE,
-- 
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]