[libvirt] [PATCH v2 04/14] virsh: Create macro for common "persistent" option

John Ferlan jferlan at redhat.com
Fri Dec 18 15:45:41 UTC 2015


Rather than continually cut-n-paste the strings into each command,
create a common macro to be used generically.  Note that not all
'{.name = "persistent",' entries are replaced, just those that have the
common .help string of "make live change persistent".

Non replaced instances are unique to the command.

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 tools/virsh-domain.c | 41 +++++++++++++----------------------------
 1 file changed, 13 insertions(+), 28 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 916c754..f12973b 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -63,6 +63,12 @@
 # define SA_SIGINFO 0
 #endif
 
+#define VIRSH_DOMAIN_PERSISTENT_OPT_COMMON             \
+    {.name = "persistent",                             \
+     .type = VSH_OT_BOOL,                              \
+     .help = N_("make live change persistent")         \
+    }                                                  \
+
 static virDomainPtr
 virshLookupDomainInternal(vshControl *ctl,
                           const char *cmdname,
@@ -211,10 +217,7 @@ static const vshCmdOptDef opts_attach_device[] = {
      .flags = VSH_OFLAG_REQ,
      .help = N_("XML file")
     },
-    {.name = "persistent",
-     .type = VSH_OT_BOOL,
-     .help = N_("make live change persistent")
-    },
+    VIRSH_DOMAIN_PERSISTENT_OPT_COMMON,
     {.name = "config",
      .type = VSH_OT_BOOL,
      .help = N_("affect next boot")
@@ -374,10 +377,7 @@ static const vshCmdOptDef opts_attach_disk[] = {
      .type = VSH_OT_BOOL,
      .help = N_("print XML document rather than attach the disk")
     },
-    {.name = "persistent",
-     .type = VSH_OT_BOOL,
-     .help = N_("make live change persistent")
-    },
+    VIRSH_DOMAIN_PERSISTENT_OPT_COMMON,
     {.name = "config",
      .type = VSH_OT_BOOL,
      .help = N_("affect next boot")
@@ -834,10 +834,7 @@ static const vshCmdOptDef opts_attach_interface[] = {
      .type = VSH_OT_STRING,
      .help = N_("control domain's outgoing traffics")
     },
-    {.name = "persistent",
-     .type = VSH_OT_BOOL,
-     .help = N_("make live change persistent")
-    },
+    VIRSH_DOMAIN_PERSISTENT_OPT_COMMON,
     {.name = "config",
      .type = VSH_OT_BOOL,
      .help = N_("affect next boot")
@@ -10830,10 +10827,7 @@ static const vshCmdOptDef opts_detach_device[] = {
      .flags = VSH_OFLAG_REQ,
      .help = N_("XML file")
     },
-    {.name = "persistent",
-     .type = VSH_OT_BOOL,
-     .help = N_("make live change persistent")
-    },
+    VIRSH_DOMAIN_PERSISTENT_OPT_COMMON,
     {.name = "config",
      .type = VSH_OT_BOOL,
      .help = N_("affect next boot")
@@ -10927,10 +10921,7 @@ static const vshCmdOptDef opts_update_device[] = {
      .flags = VSH_OFLAG_REQ,
      .help = N_("XML file")
     },
-    {.name = "persistent",
-     .type = VSH_OT_BOOL,
-     .help = N_("make live change persistent")
-    },
+    VIRSH_DOMAIN_PERSISTENT_OPT_COMMON,
     {.name = "config",
      .type = VSH_OT_BOOL,
      .help = N_("affect next boot")
@@ -11029,10 +11020,7 @@ static const vshCmdOptDef opts_detach_interface[] = {
      .type = VSH_OT_STRING,
      .help = N_("MAC address")
     },
-    {.name = "persistent",
-     .type = VSH_OT_BOOL,
-     .help = N_("make live change persistent")
-    },
+    VIRSH_DOMAIN_PERSISTENT_OPT_COMMON,
     {.name = "config",
      .type = VSH_OT_BOOL,
      .help = N_("affect next boot")
@@ -11441,10 +11429,7 @@ static const vshCmdOptDef opts_detach_disk[] = {
      .flags = VSH_OFLAG_REQ,
      .help = N_("target of disk device")
     },
-    {.name = "persistent",
-     .type = VSH_OT_BOOL,
-     .help = N_("make live change persistent")
-    },
+    VIRSH_DOMAIN_PERSISTENT_OPT_COMMON,
     {.name = "config",
      .type = VSH_OT_BOOL,
      .help = N_("affect next boot")
-- 
2.5.0




More information about the libvir-list mailing list