]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: Create macro for common "file" option
authorJohn Ferlan <jferlan@redhat.com>
Sat, 9 Jan 2016 13:36:29 +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 for the less common help string for each
command option.  Note that only file options using "OT_DATA" and
"OFLAG_REQ" will be replace - others are left as is.

Signed-off-by: John Ferlan <jferlan@redhat.com>
tools/virsh-domain.c
tools/virsh-interface.c
tools/virsh-network.c
tools/virsh-nodedev.c
tools/virsh-nwfilter.c
tools/virsh-pool.c
tools/virsh-secret.c
tools/virsh-volume.c
tools/virsh.h

index 456e5969bc7511682920a683773b06e2319d2979..d239ba82a3095e0a887fd74e707b3326ca595fde 100644 (file)
@@ -224,11 +224,7 @@ static const vshCmdInfo info_attach_device[] = {
 
 static const vshCmdOptDef opts_attach_device[] = {
     VIRSH_COMMON_OPT_DOMAIN_FULL,
-    {.name = "file",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("XML file")
-    },
+    VIRSH_COMMON_OPT_FILE(N_("XML file")),
     VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     VIRSH_COMMON_OPT_DOMAIN_LIVE,
@@ -4133,11 +4129,7 @@ static const vshCmdInfo info_save[] = {
 
 static const vshCmdOptDef opts_save[] = {
     VIRSH_COMMON_OPT_DOMAIN_FULL,
-    {.name = "file",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("where to save the data")
-    },
+    VIRSH_COMMON_OPT_FILE(N_("where to save the data")),
     {.name = "bypass-cache",
      .type = VSH_OT_BOOL,
      .help = N_("avoid file system cache when saving")
@@ -4394,11 +4386,7 @@ static const vshCmdInfo info_save_image_dumpxml[] = {
 };
 
 static const vshCmdOptDef opts_save_image_dumpxml[] = {
-    {.name = "file",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("saved state file to read")
-    },
+    VIRSH_COMMON_OPT_FILE(N_("saved state file to read")),
     {.name = "security-info",
      .type = VSH_OT_BOOL,
      .help = N_("include security sensitive information in XML dump")
@@ -4447,11 +4435,7 @@ static const vshCmdInfo info_save_image_define[] = {
 };
 
 static const vshCmdOptDef opts_save_image_define[] = {
-    {.name = "file",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("saved state file to modify")
-    },
+    VIRSH_COMMON_OPT_FILE(N_("saved state file to modify")),
     {.name = "xml",
      .type = VSH_OT_DATA,
      .flags = VSH_OFLAG_REQ,
@@ -4519,11 +4503,7 @@ static const vshCmdInfo info_save_image_edit[] = {
 };
 
 static const vshCmdOptDef opts_save_image_edit[] = {
-    {.name = "file",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("saved state file to edit")
-    },
+    VIRSH_COMMON_OPT_FILE(N_("saved state file to edit")),
     {.name = "running",
      .type = VSH_OT_BOOL,
      .help = N_("set domain to be running on restore")
@@ -5008,11 +4988,7 @@ static const vshCmdInfo info_restore[] = {
 };
 
 static const vshCmdOptDef opts_restore[] = {
-    {.name = "file",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("the state to restore")
-    },
+    VIRSH_COMMON_OPT_FILE(N_("the state to restore")),
     {.name = "bypass-cache",
      .type = VSH_OT_BOOL,
      .help = N_("avoid file system cache when restoring")
@@ -5089,11 +5065,7 @@ static const vshCmdInfo info_dump[] = {
 
 static const vshCmdOptDef opts_dump[] = {
     VIRSH_COMMON_OPT_DOMAIN_FULL,
-    {.name = "file",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("where to dump the core")
-    },
+    VIRSH_COMMON_OPT_FILE(N_("where to dump the core")),
     VIRSH_COMMON_OPT_LIVE(N_("perform a live core dump if supported")),
     {.name = "crash",
      .type = VSH_OT_BOOL,
@@ -7038,11 +7010,7 @@ static const vshCmdInfo info_cpu_compare[] = {
 };
 
 static const vshCmdOptDef opts_cpu_compare[] = {
-    {.name = "file",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("file containing an XML CPU description")
-    },
+    VIRSH_COMMON_OPT_FILE(N_("file containing an XML CPU description")),
     {.name = "error",
      .type = VSH_OT_BOOL,
      .help = N_("report error if CPUs are incompatible")
@@ -7140,11 +7108,7 @@ static const vshCmdInfo info_cpu_baseline[] = {
 };
 
 static const vshCmdOptDef opts_cpu_baseline[] = {
-    {.name = "file",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("file containing XML CPU descriptions")
-    },
+    VIRSH_COMMON_OPT_FILE(N_("file containing XML CPU descriptions")),
     {.name = "features",
      .type = VSH_OT_BOOL,
      .help = N_("Show features that are part of the CPU model type")
@@ -7442,11 +7406,7 @@ static const vshCmdInfo info_create[] = {
 };
 
 static const vshCmdOptDef opts_create[] = {
-    {.name = "file",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("file containing an XML domain description")
-    },
+    VIRSH_COMMON_OPT_FILE(N_("file containing an XML domain description")),
 #ifndef WIN32
     {.name = "console",
      .type = VSH_OT_BOOL,
@@ -7542,11 +7502,7 @@ static const vshCmdInfo info_define[] = {
 };
 
 static const vshCmdOptDef opts_define[] = {
-    {.name = "file",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("file containing an XML domain description")
-    },
+    VIRSH_COMMON_OPT_FILE(N_("file containing an XML domain description")),
     {.name = "validate",
      .type = VSH_OT_BOOL,
      .help = N_("validate the XML against the schema")
@@ -10666,11 +10622,7 @@ static const vshCmdInfo info_detach_device[] = {
 
 static const vshCmdOptDef opts_detach_device[] = {
     VIRSH_COMMON_OPT_DOMAIN_FULL,
-    {.name = "file",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("XML file")
-    },
+    VIRSH_COMMON_OPT_FILE(N_("XML file")),
     VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     VIRSH_COMMON_OPT_DOMAIN_LIVE,
@@ -10751,11 +10703,7 @@ static const vshCmdInfo info_update_device[] = {
 
 static const vshCmdOptDef opts_update_device[] = {
     VIRSH_COMMON_OPT_DOMAIN_FULL,
-    {.name = "file",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("XML file")
-    },
+    VIRSH_COMMON_OPT_FILE(N_("XML file")),
     VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     VIRSH_COMMON_OPT_DOMAIN_LIVE,
index b69c685860dce02d20a09f414ebad2bff53e7a41..c36b92d2c67b37b0e04a9cffeee1ebce4019250a 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * virsh-interface.c: Commands to manage host interface
  *
- * 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
@@ -518,11 +518,7 @@ static const vshCmdInfo info_interface_define[] = {
 };
 
 static const vshCmdOptDef opts_interface_define[] = {
-    {.name = "file",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("file containing an XML interface description")
-    },
+    VIRSH_COMMON_OPT_FILE(N_("file containing an XML interface description")),
     {.name = NULL}
 };
 
index 24e80490c6033057a0110af69320b4a4eca5bdec..153947a0f11b197a8b3fe9ee1b8ef29814f818c5 100644 (file)
@@ -142,11 +142,7 @@ static const vshCmdInfo info_network_create[] = {
 };
 
 static const vshCmdOptDef opts_network_create[] = {
-    {.name = "file",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("file containing an XML network description")
-    },
+    VIRSH_COMMON_OPT_FILE(N_("file containing an XML network description")),
     {.name = NULL}
 };
 
@@ -194,11 +190,7 @@ static const vshCmdInfo info_network_define[] = {
 };
 
 static const vshCmdOptDef opts_network_define[] = {
-    {.name = "file",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("file containing an XML network description")
-    },
+    VIRSH_COMMON_OPT_FILE(N_("file containing an XML network description")),
     {.name = NULL}
 };
 
index bfe507ed609754f2c4fd2ca8ae045ab642761183..a715b611e7481374a2aecaded6c00d1fac882e08 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * virsh-nodedev.c: Commands in node device group
  *
- * Copyright (C) 2005, 2007-2013 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
@@ -50,11 +50,8 @@ static const vshCmdInfo info_node_device_create[] = {
 };
 
 static const vshCmdOptDef opts_node_device_create[] = {
-    {.name = "file",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("file containing an XML description of the device")
-    },
+    VIRSH_COMMON_OPT_FILE(N_("file containing an XML description "
+                             "of the device")),
     {.name = NULL}
 };
 
index 7732da8f99243f05edbc6cb817d956de20acdbbb..6e6582d4d87edac72debee6c24b208ce62fb9949 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * virsh-nwfilter.c: Commands to manage network filters
  *
- * 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
@@ -85,11 +85,8 @@ static const vshCmdInfo info_nwfilter_define[] = {
 };
 
 static const vshCmdOptDef opts_nwfilter_define[] = {
-    {.name = "file",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("file containing an XML network filter description")
-    },
+    VIRSH_COMMON_OPT_FILE(N_("file containing an XML network "
+                             "filter description")),
     {.name = NULL}
 };
 
index 5e7dbcd07fae28f1be666010dedbdc07b2618ab8..f9299e21f005e659e19ddb39121330599939a69b 100644 (file)
 #define VIRSH_COMMON_OPT_POOL_FULL                            \
     VIRSH_COMMON_OPT_POOL(N_("pool name or uuid"))            \
 
-#define VIRSH_COMMON_OPT_POOL_FILE                            \
-    {.name = "file",                                          \
-     .type = VSH_OT_DATA,                                     \
-     .flags = VSH_OFLAG_REQ,                                  \
-     .help = N_("file containing an XML pool description")    \
-    }                                                         \
-
 #define VIRSH_COMMON_OPT_POOL_BUILD                           \
     {.name = "build",                                         \
      .type = VSH_OT_BOOL,                                     \
@@ -237,7 +230,7 @@ static const vshCmdInfo info_pool_create[] = {
 };
 
 static const vshCmdOptDef opts_pool_create[] = {
-    VIRSH_COMMON_OPT_POOL_FILE,
+    VIRSH_COMMON_OPT_FILE(N_("file containing an XML pool description")),
     VIRSH_COMMON_OPT_POOL_BUILD,
     VIRSH_COMMON_OPT_POOL_NO_OVERWRITE,
     VIRSH_COMMON_OPT_POOL_OVERWRITE,
@@ -480,7 +473,7 @@ static const vshCmdInfo info_pool_define[] = {
 };
 
 static const vshCmdOptDef opts_pool_define[] = {
-    VIRSH_COMMON_OPT_POOL_FILE,
+    VIRSH_COMMON_OPT_FILE(N_("file containing an XML pool description")),
 
     {.name = NULL}
 };
index db900c0ce3008d67f68ada31b6f8ba92af557752..087c2ed23a966f12badf50e9e7b4b3ee3993a4be 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * virsh-secret.c: Commands to manage secret
  *
- * 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
@@ -73,11 +73,7 @@ static const vshCmdInfo info_secret_define[] = {
 };
 
 static const vshCmdOptDef opts_secret_define[] = {
-    {.name = "file",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("file containing secret attributes in XML")
-    },
+    VIRSH_COMMON_OPT_FILE(N_("file containing secret attributes in XML")),
     {.name = NULL}
 };
 
index 42862ee4b1e418f17abe21c2a036d3d22f96eb50..a1bf19a9840e92ae1abc2b79b19f29d683ea6309 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * virsh-volume.c: Commands to manage storage volume
  *
- * Copyright (C) 2005, 2007-2014 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
@@ -362,11 +362,7 @@ static const vshCmdInfo info_vol_create[] = {
 
 static const vshCmdOptDef opts_vol_create[] = {
     VIRSH_COMMON_OPT_POOL_NAME,
-    {.name = "file",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("file containing an XML vol description")
-    },
+    VIRSH_COMMON_OPT_FILE(N_("file containing an XML vol description")),
     {.name = "prealloc-metadata",
      .type = VSH_OT_BOOL,
      .help = N_("preallocate metadata (for qcow2 instead of full allocation)")
@@ -428,11 +424,7 @@ static const vshCmdInfo info_vol_create_from[] = {
 
 static const vshCmdOptDef opts_vol_create_from[] = {
     VIRSH_COMMON_OPT_POOL_FULL,
-    {.name = "file",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("file containing an XML vol description")
-    },
+    VIRSH_COMMON_OPT_FILE(N_("file containing an XML vol description")),
     {.name = "vol",
      .type = VSH_OT_DATA,
      .flags = VSH_OFLAG_REQ,
@@ -653,11 +645,7 @@ static const vshCmdOptDef opts_vol_upload[] = {
      .flags = VSH_OFLAG_REQ,
      .help = N_("vol name, key or path")
     },
-    {.name = "file",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("file")
-    },
+    VIRSH_COMMON_OPT_FILE(N_("file")),
     VIRSH_COMMON_OPT_POOL_OPTIONAL,
     {.name = "offset",
      .type = VSH_OT_INT,
@@ -764,11 +752,7 @@ static const vshCmdOptDef opts_vol_download[] = {
      .flags = VSH_OFLAG_REQ,
      .help = N_("vol name, key or path")
     },
-    {.name = "file",
-     .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
-     .help = N_("file")
-    },
+    VIRSH_COMMON_OPT_FILE(N_("file")),
     VIRSH_COMMON_OPT_POOL_OPTIONAL,
     {.name = "offset",
      .type = VSH_OT_INT,
index ba7e31457c30596c6628712ede91be4bf794dbd0..94d012aa367e288bff7d1427f1299ca9c15b73ee 100644 (file)
      .help = _helpstr                                             \
     }                                                             \
 
+# define VIRSH_COMMON_OPT_FILE(_helpstr)                          \
+    {.name = "file",                                              \
+     .type = VSH_OT_DATA,                                         \
+     .flags = VSH_OFLAG_REQ,                                      \
+     .help = _helpstr                                             \
+    }                                                             \
+
 typedef struct _virshControl virshControl;
 typedef virshControl *virshControlPtr;