[libvirt] [PATCH v2 00/14] Use macros for more common virsh command options

v1: http://www.redhat.com/archives/libvir-list/2015-December/msg00731.html Changes over v1: 1. Insert patch 1 to convert already pushed VSH_POOL into VIRSH_POOL since that was the review comment from this patch series 2. Insert patch 2 to move the POOL_OPT_COMMON to virsh.h for later patch reuse. 3. Use VIRSH_* instead of VSH_* for patches 1-8 (now 3-10) 4. Add usage of common domain for virsh-domain-monitor.c and virsh-snapshot.c (patches 11-12) 5. Add common macros for "network" and "interface" (patches 13-14). NOTE: I figure to let this perculate for a bit as I'll assume there may be varying opinions on this... Also, the next couple of weeks heavy on people perhaps paying not paying close attention to the list. John Ferlan (14): virsh: Covert VSH_POOL_ macro to VIRSH_POOL_ virsh: Move VIRSH_POOL_OPT_COMMON to virsh.h virsh: Create macro for common "domain" option virsh: Create macro for common "persistent" option virsh: Create macro for common "config" option virsh: Create macro for common "live" option virsh: Create macro for common "current" option virsh: Create macro for common "file" option virsh: Create macros for common "pool" options virsh: Create macros for common "vol" options virsh: Have domain-monitor use common "domain" option virsh: have snapshot use common "domain" option virsh: Create macro for common "network" option virsh: Create macro for common "interface" option po/POTFILES.in | 1 + tools/virsh-domain-monitor.c | 77 +--- tools/virsh-domain.c | 911 +++++++++---------------------------------- tools/virsh-interface.c | 37 +- tools/virsh-network.c | 61 +-- tools/virsh-pool.c | 71 ++-- tools/virsh-snapshot.c | 60 +-- tools/virsh-volume.c | 148 ++----- tools/virsh.h | 17 + 9 files changed, 334 insertions(+), 1049 deletions(-) -- 2.5.0

Commit id's 'cf793b00', 'e178688f', 'f9a6110f', '5372d49', and 'e193735' added new VSH_POOL_ macros; however, it was pointed out after push that commit id '834c5720' preferred use of VIRSH_ for the prefix over VSH_. So this patch just changes the VSH_ to VIRSH_ Signed-off-by: John Ferlan <jferlan@redhat.com> --- tools/virsh-pool.c | 66 +++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index f2f25da..b8b37e4 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -33,42 +33,42 @@ #include "conf/storage_conf.h" #include "virstring.h" -#define VSH_POOL_OPT_COMMON \ +#define VIRSH_POOL_OPT_COMMON \ {.name = "pool", \ .type = VSH_OT_DATA, \ .flags = VSH_OFLAG_REQ, \ .help = N_("pool name or uuid") \ } \ -#define VSH_POOL_FILE_OPT_COMMON \ +#define VIRSH_POOL_FILE_OPT_COMMON \ {.name = "file", \ .type = VSH_OT_DATA, \ .flags = VSH_OFLAG_REQ, \ .help = N_("file containing an XML pool description") \ } \ -#define VSH_POOL_BUILD_OPT_COMMON \ +#define VIRSH_POOL_BUILD_OPT_COMMON \ {.name = "build", \ .type = VSH_OT_BOOL, \ .flags = 0, \ .help = N_("build the pool as normal") \ } \ -#define VSH_POOL_NO_OVERWRITE_OPT_COMMON \ +#define VIRSH_POOL_NO_OVERWRITE_OPT_COMMON \ {.name = "no-overwrite", \ .type = VSH_OT_BOOL, \ .flags = 0, \ .help = N_("do not overwrite an existing pool of this type") \ } \ -#define VSH_POOL_OVERWRITE_OPT_COMMON \ +#define VIRSH_POOL_OVERWRITE_OPT_COMMON \ {.name = "overwrite", \ .type = VSH_OT_BOOL, \ .flags = 0, \ .help = N_("overwrite any existing data") \ } \ -#define VSH_POOL_X_AS_OPT_COMMON \ +#define VIRSH_POOL_X_AS_OPT_COMMON \ {.name = "name", \ .type = VSH_OT_DATA, \ .flags = VSH_OFLAG_REQ, \ @@ -188,7 +188,7 @@ static const vshCmdInfo info_pool_autostart[] = { }; static const vshCmdOptDef opts_pool_autostart[] = { - VSH_POOL_OPT_COMMON, + VIRSH_POOL_OPT_COMMON, {.name = "disable", .type = VSH_OT_BOOL, @@ -241,10 +241,10 @@ static const vshCmdInfo info_pool_create[] = { }; static const vshCmdOptDef opts_pool_create[] = { - VSH_POOL_FILE_OPT_COMMON, - VSH_POOL_BUILD_OPT_COMMON, - VSH_POOL_NO_OVERWRITE_OPT_COMMON, - VSH_POOL_OVERWRITE_OPT_COMMON, + VIRSH_POOL_FILE_OPT_COMMON, + VIRSH_POOL_BUILD_OPT_COMMON, + VIRSH_POOL_NO_OVERWRITE_OPT_COMMON, + VIRSH_POOL_OVERWRITE_OPT_COMMON, {.name = NULL} }; @@ -297,7 +297,7 @@ cmdPoolCreate(vshControl *ctl, const vshCmd *cmd) } static const vshCmdOptDef opts_pool_define_as[] = { - VSH_POOL_X_AS_OPT_COMMON, + VIRSH_POOL_X_AS_OPT_COMMON, {.name = NULL} }; @@ -413,10 +413,10 @@ static const vshCmdInfo info_pool_create_as[] = { }; static const vshCmdOptDef opts_pool_create_as[] = { - VSH_POOL_X_AS_OPT_COMMON, - VSH_POOL_BUILD_OPT_COMMON, - VSH_POOL_NO_OVERWRITE_OPT_COMMON, - VSH_POOL_OVERWRITE_OPT_COMMON, + VIRSH_POOL_X_AS_OPT_COMMON, + VIRSH_POOL_BUILD_OPT_COMMON, + VIRSH_POOL_NO_OVERWRITE_OPT_COMMON, + VIRSH_POOL_OVERWRITE_OPT_COMMON, {.name = NULL} }; @@ -484,7 +484,7 @@ static const vshCmdInfo info_pool_define[] = { }; static const vshCmdOptDef opts_pool_define[] = { - VSH_POOL_FILE_OPT_COMMON, + VIRSH_POOL_FILE_OPT_COMMON, {.name = NULL} }; @@ -575,9 +575,9 @@ static const vshCmdInfo info_pool_build[] = { }; static const vshCmdOptDef opts_pool_build[] = { - VSH_POOL_OPT_COMMON, - VSH_POOL_NO_OVERWRITE_OPT_COMMON, - VSH_POOL_OVERWRITE_OPT_COMMON, + VIRSH_POOL_OPT_COMMON, + VIRSH_POOL_NO_OVERWRITE_OPT_COMMON, + VIRSH_POOL_OVERWRITE_OPT_COMMON, {.name = NULL} }; @@ -625,7 +625,7 @@ static const vshCmdInfo info_pool_destroy[] = { }; static const vshCmdOptDef opts_pool_destroy[] = { - VSH_POOL_OPT_COMMON, + VIRSH_POOL_OPT_COMMON, {.name = NULL} }; @@ -665,7 +665,7 @@ static const vshCmdInfo info_pool_delete[] = { }; static const vshCmdOptDef opts_pool_delete[] = { - VSH_POOL_OPT_COMMON, + VIRSH_POOL_OPT_COMMON, {.name = NULL} }; @@ -705,7 +705,7 @@ static const vshCmdInfo info_pool_refresh[] = { }; static const vshCmdOptDef opts_pool_refresh[] = { - VSH_POOL_OPT_COMMON, + VIRSH_POOL_OPT_COMMON, {.name = NULL} }; @@ -745,7 +745,7 @@ static const vshCmdInfo info_pool_dumpxml[] = { }; static const vshCmdOptDef opts_pool_dumpxml[] = { - VSH_POOL_OPT_COMMON, + VIRSH_POOL_OPT_COMMON, {.name = "inactive", .type = VSH_OT_BOOL, @@ -1596,7 +1596,7 @@ static const vshCmdInfo info_pool_info[] = { }; static const vshCmdOptDef opts_pool_info[] = { - VSH_POOL_OPT_COMMON, + VIRSH_POOL_OPT_COMMON, {.name = NULL} }; @@ -1673,7 +1673,7 @@ static const vshCmdInfo info_pool_name[] = { }; static const vshCmdOptDef opts_pool_name[] = { - VSH_POOL_OPT_COMMON, + VIRSH_POOL_OPT_COMMON, {.name = NULL} }; @@ -1705,10 +1705,10 @@ static const vshCmdInfo info_pool_start[] = { }; static const vshCmdOptDef opts_pool_start[] = { - VSH_POOL_OPT_COMMON, - VSH_POOL_BUILD_OPT_COMMON, - VSH_POOL_NO_OVERWRITE_OPT_COMMON, - VSH_POOL_OVERWRITE_OPT_COMMON, + VIRSH_POOL_OPT_COMMON, + VIRSH_POOL_BUILD_OPT_COMMON, + VIRSH_POOL_NO_OVERWRITE_OPT_COMMON, + VIRSH_POOL_OVERWRITE_OPT_COMMON, {.name = NULL} }; @@ -1766,7 +1766,7 @@ static const vshCmdInfo info_pool_undefine[] = { }; static const vshCmdOptDef opts_pool_undefine[] = { - VSH_POOL_OPT_COMMON, + VIRSH_POOL_OPT_COMMON, {.name = NULL} }; @@ -1806,7 +1806,7 @@ static const vshCmdInfo info_pool_uuid[] = { }; static const vshCmdOptDef opts_pool_uuid[] = { - VSH_POOL_OPT_COMMON, + VIRSH_POOL_OPT_COMMON, {.name = NULL} }; @@ -1843,7 +1843,7 @@ static const vshCmdInfo info_pool_edit[] = { }; static const vshCmdOptDef opts_pool_edit[] = { - VSH_POOL_OPT_COMMON, + VIRSH_POOL_OPT_COMMON, {.name = NULL} }; -- 2.5.0

Since it can be used by other virsh*.c modules, move the macro to virsh.h and add virsh.h to POTFILES.in (since there are translatable strings). Signed-off-by: John Ferlan <jferlan@redhat.com> --- po/POTFILES.in | 1 + tools/virsh-pool.c | 7 ------- tools/virsh.h | 10 ++++++++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index 82e8d3e..46d3940 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -265,6 +265,7 @@ src/xenconfig/xen_xm.c tests/virpolkittest.c tools/libvirt-guests.sh.in tools/virsh.c +tools/virsh.h tools/virsh-console.c tools/virsh-domain-monitor.c tools/virsh-domain.c diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index b8b37e4..1a71cb7 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -33,13 +33,6 @@ #include "conf/storage_conf.h" #include "virstring.h" -#define VIRSH_POOL_OPT_COMMON \ - {.name = "pool", \ - .type = VSH_OT_DATA, \ - .flags = VSH_OFLAG_REQ, \ - .help = N_("pool name or uuid") \ - } \ - #define VIRSH_POOL_FILE_OPT_COMMON \ {.name = "file", \ .type = VSH_OT_DATA, \ diff --git a/tools/virsh.h b/tools/virsh.h index 1845b0e..c1a1866 100644 --- a/tools/virsh.h +++ b/tools/virsh.h @@ -59,6 +59,16 @@ # define VIRSH_CMD_GRP_HOST_AND_HV "Host and Hypervisor" # define VIRSH_CMD_GRP_VIRSH "Virsh itself" +/* + * Common command options + */ +# define VIRSH_POOL_OPT_COMMON \ + {.name = "pool", \ + .type = VSH_OT_DATA, \ + .flags = VSH_OFLAG_REQ, \ + .help = N_("pool name or uuid") \ + } \ + typedef struct _virshControl virshControl; typedef virshControl *virshControlPtr; -- 2.5.0

Rather than continually cut-n-paste the strings into each command, create a common macro to be used generically. Note that not all '{.name = "domain",' entries are replaced, just those that have the common .help string of "domain name, id or uuid" and those that are required. Other instances won't take all 3 options, but some subset of those options as directed by the virshCommandOptDomainBy flags argument or in some instances where the domain is not a required option. Signed-off-by: John Ferlan <jferlan@redhat.com> --- tools/virsh-domain.c | 445 +++++++++------------------------------------------ tools/virsh.h | 7 + 2 files changed, 81 insertions(+), 371 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 7650535..916c754 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -63,7 +63,6 @@ # define SA_SIGINFO 0 #endif - static virDomainPtr virshLookupDomainInternal(vshControl *ctl, const char *cmdname, @@ -206,11 +205,7 @@ static const vshCmdInfo info_attach_device[] = { }; static const vshCmdOptDef opts_attach_device[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "file", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -308,11 +303,7 @@ static const vshCmdInfo info_attach_disk[] = { }; static const vshCmdOptDef opts_attach_disk[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "source", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ | VSH_OFLAG_EMPTY_OK, @@ -808,11 +799,7 @@ static const vshCmdInfo info_attach_interface[] = { }; static const vshCmdOptDef opts_attach_interface[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "type", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -1135,11 +1122,7 @@ static const vshCmdInfo info_autostart[] = { }; static const vshCmdOptDef opts_autostart[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "disable", .type = VSH_OT_BOOL, .help = N_("disable autostarting") @@ -1191,11 +1174,7 @@ static const vshCmdInfo info_blkdeviotune[] = { }; static const vshCmdOptDef opts_blkdeviotune[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "device", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -1534,11 +1513,7 @@ static const vshCmdInfo info_blkiotune[] = { }; static const vshCmdOptDef opts_blkiotune[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "weight", .type = VSH_OT_INT, .help = N_("IO Weight") @@ -2007,11 +1982,7 @@ static const vshCmdInfo info_block_commit[] = { }; static const vshCmdOptDef opts_block_commit[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "path", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -2227,11 +2198,7 @@ static const vshCmdInfo info_block_copy[] = { }; static const vshCmdOptDef opts_block_copy[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "path", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -2532,11 +2499,7 @@ static const vshCmdInfo info_block_job[] = { }; static const vshCmdOptDef opts_block_job[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "path", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -2777,11 +2740,7 @@ static const vshCmdInfo info_block_pull[] = { }; static const vshCmdOptDef opts_block_pull[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "path", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -2916,11 +2875,7 @@ static const vshCmdInfo info_block_resize[] = { }; static const vshCmdOptDef opts_block_resize[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "path", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -2984,11 +2939,7 @@ static const vshCmdInfo info_console[] = { }; static const vshCmdOptDef opts_console[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "devname", /* sc_prohibit_devname */ .type = VSH_OT_STRING, .help = N_("character device name") @@ -3082,11 +3033,7 @@ static const vshCmdInfo info_domif_setlink[] = { }; static const vshCmdOptDef opts_domif_setlink[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "interface", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -3269,11 +3216,7 @@ static const vshCmdInfo info_domiftune[] = { }; static const vshCmdOptDef opts_domiftune[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "interface", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -3479,11 +3422,7 @@ static const vshCmdInfo info_suspend[] = { }; static const vshCmdOptDef opts_suspend[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = NULL} }; @@ -3525,11 +3464,7 @@ static const vshCmdInfo info_dom_pm_suspend[] = { }; static const vshCmdOptDef opts_dom_pm_suspend[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "target", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -3607,11 +3542,7 @@ static const vshCmdInfo info_dom_pm_wakeup[] = { }; static const vshCmdOptDef opts_dom_pm_wakeup[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = NULL} }; @@ -4245,11 +4176,7 @@ static const vshCmdInfo info_save[] = { }; static const vshCmdOptDef opts_save[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "file", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -4715,11 +4642,7 @@ static const vshCmdInfo info_managedsave[] = { }; static const vshCmdOptDef opts_managedsave[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "bypass-cache", .type = VSH_OT_BOOL, .help = N_("avoid file system cache when saving") @@ -4839,11 +4762,7 @@ static const vshCmdInfo info_managedsaveremove[] = { }; static const vshCmdOptDef opts_managedsaveremove[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = NULL} }; @@ -4898,11 +4817,7 @@ static const vshCmdInfo info_schedinfo[] = { }; static const vshCmdOptDef opts_schedinfo[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "weight", .type = VSH_OT_INT, .flags = VSH_OFLAG_REQ_OPT, @@ -5226,11 +5141,7 @@ static const vshCmdInfo info_dump[] = { }; static const vshCmdOptDef opts_dump[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "file", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -5409,11 +5320,7 @@ static const vshCmdInfo info_screenshot[] = { }; static const vshCmdOptDef opts_screenshot[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "file", .type = VSH_OT_STRING, .help = N_("where to store the screenshot") @@ -5556,11 +5463,7 @@ static const vshCmdInfo info_set_user_password[] = { }; static const vshCmdOptDef opts_set_user_password[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "user", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -5624,11 +5527,7 @@ static const vshCmdInfo info_resume[] = { }; static const vshCmdOptDef opts_resume[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = NULL} }; @@ -5667,11 +5566,7 @@ static const vshCmdInfo info_shutdown[] = { }; static const vshCmdOptDef opts_shutdown[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "mode", .type = VSH_OT_STRING, .help = N_("shutdown mode: acpi|agent|initctl|signal|paravirt") @@ -5756,11 +5651,7 @@ static const vshCmdInfo info_reboot[] = { }; static const vshCmdOptDef opts_reboot[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "mode", .type = VSH_OT_STRING, .help = N_("shutdown mode: acpi|agent|initctl|signal|paravirt") @@ -5840,11 +5731,7 @@ static const vshCmdInfo info_reset[] = { }; static const vshCmdOptDef opts_reset[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = NULL} }; @@ -5883,11 +5770,7 @@ static const vshCmdInfo info_domjobinfo[] = { }; static const vshCmdOptDef opts_domjobinfo[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "completed", .type = VSH_OT_BOOL, .help = N_("return statistics of a recently completed job") @@ -6169,11 +6052,7 @@ static const vshCmdInfo info_domjobabort[] = { }; static const vshCmdOptDef opts_domjobabort[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = NULL} }; @@ -6207,11 +6086,7 @@ static const vshCmdInfo info_vcpucount[] = { }; static const vshCmdOptDef opts_vcpucount[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "maximum", .type = VSH_OT_BOOL, .help = N_("get maximum count of vcpus") @@ -6422,11 +6297,7 @@ static const vshCmdInfo info_vcpuinfo[] = { }; static const vshCmdOptDef opts_vcpuinfo[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "pretty", .type = VSH_OT_BOOL, .help = N_("return human readable output") @@ -6537,11 +6408,7 @@ static const vshCmdInfo info_vcpupin[] = { }; static const vshCmdOptDef opts_vcpupin[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "vcpu", .type = VSH_OT_INT, .help = N_("vcpu number") @@ -6749,11 +6616,7 @@ static const vshCmdInfo info_emulatorpin[] = { }; static const vshCmdOptDef opts_emulatorpin[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "cpulist", .type = VSH_OT_STRING, .flags = VSH_OFLAG_EMPTY_OK, @@ -6866,11 +6729,7 @@ static const vshCmdInfo info_setvcpus[] = { }; static const vshCmdOptDef opts_setvcpus[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "count", .type = VSH_OT_INT, .flags = VSH_OFLAG_REQ, @@ -6967,11 +6826,7 @@ static const vshCmdInfo info_iothreadinfo[] = { {.name = NULL} }; static const vshCmdOptDef opts_iothreadinfo[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "config", .type = VSH_OT_BOOL, .help = N_("affect next boot") @@ -7056,11 +6911,7 @@ static const vshCmdInfo info_iothreadpin[] = { }; static const vshCmdOptDef opts_iothreadpin[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "iothread", .type = VSH_OT_INT, .flags = VSH_OFLAG_REQ, @@ -7151,11 +7002,7 @@ static const vshCmdInfo info_iothreadadd[] = { }; static const vshCmdOptDef opts_iothreadadd[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "id", .type = VSH_OT_INT, .flags = VSH_OFLAG_REQ, @@ -7229,11 +7076,7 @@ static const vshCmdInfo info_iothreaddel[] = { }; static const vshCmdOptDef opts_iothreaddel[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "id", .type = VSH_OT_INT, .flags = VSH_OFLAG_REQ, @@ -7526,11 +7369,7 @@ static const vshCmdInfo info_cpu_stats[] = { }; static const vshCmdOptDef opts_cpu_stats[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "total", .type = VSH_OT_BOOL, .help = N_("Show total statistics only") @@ -7877,11 +7716,7 @@ static const vshCmdInfo info_destroy[] = { }; static const vshCmdOptDef opts_destroy[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "graceful", .type = VSH_OT_BOOL, .help = N_("terminate gracefully") @@ -7934,11 +7769,7 @@ static const vshCmdInfo info_desc[] = { }; static const vshCmdOptDef opts_desc[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "live", .type = VSH_OT_BOOL, .help = N_("modify/get running state") @@ -8113,11 +7944,7 @@ static const vshCmdInfo info_metadata[] = { }; static const vshCmdOptDef opts_metadata[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "uri", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -8272,11 +8099,7 @@ static const vshCmdInfo info_inject_nmi[] = { }; static const vshCmdOptDef opts_inject_nmi[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = NULL} }; @@ -8310,11 +8133,7 @@ static const vshCmdInfo info_send_key[] = { }; static const vshCmdOptDef opts_send_key[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "codeset", .type = VSH_OT_STRING, .flags = VSH_OFLAG_REQ_OPT, @@ -8410,11 +8229,7 @@ static const vshCmdInfo info_send_process_signal[] = { }; static const vshCmdOptDef opts_send_process_signal[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "pid", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -8519,11 +8334,7 @@ static const vshCmdInfo info_setmem[] = { }; static const vshCmdOptDef opts_setmem[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "kilobytes", .type = VSH_OT_ALIAS, .help = "size" @@ -8613,11 +8424,7 @@ static const vshCmdInfo info_setmaxmem[] = { }; static const vshCmdOptDef opts_setmaxmem[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "kilobytes", .type = VSH_OT_ALIAS, .help = "size" @@ -8714,11 +8521,7 @@ static const vshCmdInfo info_memtune[] = { }; static const vshCmdOptDef opts_memtune[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "hard-limit", .type = VSH_OT_INT, .help = N_("Max memory, as scaled integer (default KiB)") @@ -8904,11 +8707,7 @@ static const vshCmdInfo info_numatune[] = { }; static const vshCmdOptDef opts_numatune[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "mode", .type = VSH_OT_STRING, .help = N_("NUMA mode, one of strict, preferred and interleave \n" @@ -9052,11 +8851,7 @@ static const vshCmdInfo info_qemu_monitor_command[] = { }; static const vshCmdOptDef opts_qemu_monitor_command[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "hmp", .type = VSH_OT_BOOL, .help = N_("command is in human monitor protocol") @@ -9342,11 +9137,7 @@ static const vshCmdInfo info_qemu_agent_command[] = { }; static const vshCmdOptDef opts_qemu_agent_command[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "timeout", .type = VSH_OT_INT, .flags = VSH_OFLAG_REQ_OPT, @@ -9469,11 +9260,7 @@ static const vshCmdInfo info_lxc_enter_namespace[] = { }; static const vshCmdOptDef opts_lxc_enter_namespace[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "noseclabel", .type = VSH_OT_BOOL, .help = N_("Do not change process security label") @@ -9612,11 +9399,7 @@ static const vshCmdInfo info_dumpxml[] = { }; static const vshCmdOptDef opts_dumpxml[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "inactive", .type = VSH_OT_BOOL, .help = N_("show inactive defined XML") @@ -9836,11 +9619,7 @@ static const vshCmdInfo info_domrename[] = { }; static const vshCmdOptDef opts_domrename[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "new-name", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -9969,11 +9748,7 @@ static const vshCmdInfo info_migrate[] = { }; static const vshCmdOptDef opts_migrate[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "desturi", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -10339,11 +10114,7 @@ static const vshCmdInfo info_migrate_setmaxdowntime[] = { }; static const vshCmdOptDef opts_migrate_setmaxdowntime[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "downtime", .type = VSH_OT_INT, .flags = VSH_OFLAG_REQ, @@ -10394,11 +10165,7 @@ static const vshCmdInfo info_migrate_compcache[] = { }; static const vshCmdOptDef opts_migrate_compcache[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "size", .type = VSH_OT_INT, .flags = VSH_OFLAG_REQ_OPT, @@ -10455,11 +10222,7 @@ static const vshCmdInfo info_migrate_setspeed[] = { }; static const vshCmdOptDef opts_migrate_setspeed[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "bandwidth", .type = VSH_OT_INT, .flags = VSH_OFLAG_REQ, @@ -10505,11 +10268,7 @@ static const vshCmdInfo info_migrate_getspeed[] = { }; static const vshCmdOptDef opts_migrate_getspeed[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = NULL} }; @@ -10550,11 +10309,7 @@ static const vshCmdInfo info_domdisplay[] = { }; static const vshCmdOptDef opts_domdisplay[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "include-password", .type = VSH_OT_BOOL, .help = N_("includes the password into the connection URI if available") @@ -10773,11 +10528,7 @@ static const vshCmdInfo info_vncdisplay[] = { }; static const vshCmdOptDef opts_vncdisplay[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = NULL} }; @@ -10858,11 +10609,7 @@ static const vshCmdInfo info_ttyconsole[] = { }; static const vshCmdOptDef opts_ttyconsole[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = NULL} }; @@ -10918,11 +10665,7 @@ static const vshCmdInfo info_domhostname[] = { }; static const vshCmdOptDef opts_domhostname[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = NULL} }; @@ -11081,11 +10824,7 @@ static const vshCmdInfo info_detach_device[] = { }; static const vshCmdOptDef opts_detach_device[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "file", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -11182,11 +10921,7 @@ static const vshCmdInfo info_update_device[] = { }; static const vshCmdOptDef opts_update_device[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "file", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -11284,11 +11019,7 @@ static const vshCmdInfo info_detach_interface[] = { }; static const vshCmdOptDef opts_detach_interface[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "type", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -11704,11 +11435,7 @@ static const vshCmdInfo info_detach_disk[] = { }; static const vshCmdOptDef opts_detach_disk[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "target", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -11820,11 +11547,7 @@ static const vshCmdInfo info_edit[] = { }; static const vshCmdOptDef opts_edit[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "skip-validate", .type = VSH_OT_BOOL, .help = N_("skip validation of the XML against the schema") @@ -12671,11 +12394,7 @@ static const vshCmdInfo info_change_media[] = { }; static const vshCmdOptDef opts_change_media[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "path", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -12843,11 +12562,7 @@ static const vshCmdInfo info_domfstrim[] = { }; static const vshCmdOptDef opts_domfstrim[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "minimum", .type = VSH_OT_INT, .help = N_("Just a hint to ignore contiguous " @@ -12900,11 +12615,7 @@ static const vshCmdInfo info_domfsfreeze[] = { }; static const vshCmdOptDef opts_domfsfreeze[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "mountpoint", .type = VSH_OT_ARGV, .help = N_("mountpoint path to be frozen") @@ -12957,11 +12668,7 @@ static const vshCmdInfo info_domfsthaw[] = { }; static const vshCmdOptDef opts_domfsthaw[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "mountpoint", .type = VSH_OT_ARGV, .help = N_("mountpoint path to be thawed") @@ -13014,11 +12721,7 @@ static const vshCmdInfo info_domfsinfo[] = { }; static const vshCmdOptDef opts_domfsinfo[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = NULL} }; diff --git a/tools/virsh.h b/tools/virsh.h index c1a1866..a77a2d6 100644 --- a/tools/virsh.h +++ b/tools/virsh.h @@ -69,6 +69,13 @@ .help = N_("pool name or uuid") \ } \ +# define VIRSH_DOMAIN_OPT_COMMON \ + {.name = "domain", \ + .type = VSH_OT_DATA, \ + .flags = VSH_OFLAG_REQ, \ + .help = N_("domain name, id or uuid") \ + } \ + typedef struct _virshControl virshControl; typedef virshControl *virshControlPtr; -- 2.5.0

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@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

Rather than continually cut-n-paste the strings into each command, create a common macro to be used generically. Note that not all '{.name = "config",' entries are replaced, just those that have the common .help string of "affect next boot". Non replaced instances are unique to the command. Signed-off-by: John Ferlan <jferlan@redhat.com> --- tools/virsh-domain.c | 116 +++++++++++++-------------------------------------- 1 file changed, 28 insertions(+), 88 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index f12973b..dc3b07c 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -69,6 +69,12 @@ .help = N_("make live change persistent") \ } \ +#define VIRSH_DOMAIN_CONFIG_OPT_COMMON \ + {.name = "config", \ + .type = VSH_OT_BOOL, \ + .help = N_("affect next boot") \ + } \ + static virDomainPtr virshLookupDomainInternal(vshControl *ctl, const char *cmdname, @@ -218,10 +224,7 @@ static const vshCmdOptDef opts_attach_device[] = { .help = N_("XML file") }, VIRSH_DOMAIN_PERSISTENT_OPT_COMMON, - {.name = "config", - .type = VSH_OT_BOOL, - .help = N_("affect next boot") - }, + VIRSH_DOMAIN_CONFIG_OPT_COMMON, {.name = "live", .type = VSH_OT_BOOL, .help = N_("affect running domain") @@ -378,10 +381,7 @@ static const vshCmdOptDef opts_attach_disk[] = { .help = N_("print XML document rather than attach the disk") }, VIRSH_DOMAIN_PERSISTENT_OPT_COMMON, - {.name = "config", - .type = VSH_OT_BOOL, - .help = N_("affect next boot") - }, + VIRSH_DOMAIN_CONFIG_OPT_COMMON, {.name = "live", .type = VSH_OT_BOOL, .help = N_("affect running domain") @@ -835,10 +835,7 @@ static const vshCmdOptDef opts_attach_interface[] = { .help = N_("control domain's outgoing traffics") }, VIRSH_DOMAIN_PERSISTENT_OPT_COMMON, - {.name = "config", - .type = VSH_OT_BOOL, - .help = N_("affect next boot") - }, + VIRSH_DOMAIN_CONFIG_OPT_COMMON, {.name = "live", .type = VSH_OT_BOOL, .help = N_("affect running domain") @@ -1281,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_DOMAIN_CONFIG_OPT_COMMON, {.name = "live", .type = VSH_OT_BOOL, .help = N_("affect running domain") @@ -1535,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_DOMAIN_CONFIG_OPT_COMMON, {.name = "live", .type = VSH_OT_BOOL, .help = N_("affect running domain") @@ -3045,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_DOMAIN_CONFIG_OPT_COMMON, {.name = NULL} }; @@ -3227,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_DOMAIN_CONFIG_OPT_COMMON, {.name = "live", .type = VSH_OT_BOOL, .help = N_("affect running domain") @@ -6415,10 +6400,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_DOMAIN_CONFIG_OPT_COMMON, {.name = "live", .type = VSH_OT_BOOL, .help = N_("affect running domain") @@ -6619,10 +6601,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_DOMAIN_CONFIG_OPT_COMMON, {.name = "live", .type = VSH_OT_BOOL, .help = N_("affect running domain") @@ -6736,10 +6715,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_DOMAIN_CONFIG_OPT_COMMON, {.name = "live", .type = VSH_OT_BOOL, .help = N_("affect running domain") @@ -6824,10 +6800,7 @@ static const vshCmdInfo info_iothreadinfo[] = { }; static const vshCmdOptDef opts_iothreadinfo[] = { VIRSH_DOMAIN_OPT_COMMON, - {.name = "config", - .type = VSH_OT_BOOL, - .help = N_("affect next boot") - }, + VIRSH_DOMAIN_CONFIG_OPT_COMMON, {.name = "live", .type = VSH_OT_BOOL, .help = N_("affect running domain") @@ -6919,10 +6892,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_DOMAIN_CONFIG_OPT_COMMON, {.name = "live", .type = VSH_OT_BOOL, .help = N_("affect running domain") @@ -7005,10 +6975,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_DOMAIN_CONFIG_OPT_COMMON, {.name = "live", .type = VSH_OT_BOOL, .help = N_("affect running domain") @@ -7079,10 +7046,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_DOMAIN_CONFIG_OPT_COMMON, {.name = "live", .type = VSH_OT_BOOL, .help = N_("affect running domain") @@ -8341,10 +8305,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_DOMAIN_CONFIG_OPT_COMMON, {.name = "live", .type = VSH_OT_BOOL, .help = N_("affect running domain") @@ -8431,10 +8392,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_DOMAIN_CONFIG_OPT_COMMON, {.name = "live", .type = VSH_OT_BOOL, .help = N_("affect running domain") @@ -8535,10 +8493,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_DOMAIN_CONFIG_OPT_COMMON, {.name = "live", .type = VSH_OT_BOOL, .help = N_("affect running domain") @@ -8714,10 +8669,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_DOMAIN_CONFIG_OPT_COMMON, {.name = "live", .type = VSH_OT_BOOL, .help = N_("affect running domain") @@ -10828,10 +10780,7 @@ static const vshCmdOptDef opts_detach_device[] = { .help = N_("XML file") }, VIRSH_DOMAIN_PERSISTENT_OPT_COMMON, - {.name = "config", - .type = VSH_OT_BOOL, - .help = N_("affect next boot") - }, + VIRSH_DOMAIN_CONFIG_OPT_COMMON, {.name = "live", .type = VSH_OT_BOOL, .help = N_("affect running domain") @@ -10922,10 +10871,7 @@ static const vshCmdOptDef opts_update_device[] = { .help = N_("XML file") }, VIRSH_DOMAIN_PERSISTENT_OPT_COMMON, - {.name = "config", - .type = VSH_OT_BOOL, - .help = N_("affect next boot") - }, + VIRSH_DOMAIN_CONFIG_OPT_COMMON, {.name = "live", .type = VSH_OT_BOOL, .help = N_("affect running domain") @@ -11021,10 +10967,7 @@ static const vshCmdOptDef opts_detach_interface[] = { .help = N_("MAC address") }, VIRSH_DOMAIN_PERSISTENT_OPT_COMMON, - {.name = "config", - .type = VSH_OT_BOOL, - .help = N_("affect next boot") - }, + VIRSH_DOMAIN_CONFIG_OPT_COMMON, {.name = "live", .type = VSH_OT_BOOL, .help = N_("affect running domain") @@ -11430,10 +11373,7 @@ static const vshCmdOptDef opts_detach_disk[] = { .help = N_("target of disk device") }, VIRSH_DOMAIN_PERSISTENT_OPT_COMMON, - {.name = "config", - .type = VSH_OT_BOOL, - .help = N_("affect next boot") - }, + VIRSH_DOMAIN_CONFIG_OPT_COMMON, {.name = "live", .type = VSH_OT_BOOL, .help = N_("affect running domain") -- 2.5.0

Rather than continually cut-n-paste the strings into each command, create a common macro to be used generically. Note that not all '{.name = "live",' entries are replaced, just those that have the common .help string of "affect running domain". Non replaced instances are unique to the command. Signed-off-by: John Ferlan <jferlan@redhat.com> --- tools/virsh-domain.c | 111 +++++++++++++-------------------------------------- 1 file changed, 27 insertions(+), 84 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index dc3b07c..c6e9979 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -75,6 +75,12 @@ .help = N_("affect next boot") \ } \ +#define VIRSH_DOMAIN_LIVE_OPT_COMMON \ + {.name = "live", \ + .type = VSH_OT_BOOL, \ + .help = N_("affect running domain") \ + } \ + static virDomainPtr virshLookupDomainInternal(vshControl *ctl, const char *cmdname, @@ -225,10 +231,7 @@ static const vshCmdOptDef opts_attach_device[] = { }, VIRSH_DOMAIN_PERSISTENT_OPT_COMMON, VIRSH_DOMAIN_CONFIG_OPT_COMMON, - {.name = "live", - .type = VSH_OT_BOOL, - .help = N_("affect running domain") - }, + VIRSH_DOMAIN_LIVE_OPT_COMMON, {.name = "current", .type = VSH_OT_BOOL, .help = N_("affect current domain") @@ -382,10 +385,7 @@ static const vshCmdOptDef opts_attach_disk[] = { }, VIRSH_DOMAIN_PERSISTENT_OPT_COMMON, VIRSH_DOMAIN_CONFIG_OPT_COMMON, - {.name = "live", - .type = VSH_OT_BOOL, - .help = N_("affect running domain") - }, + VIRSH_DOMAIN_LIVE_OPT_COMMON, {.name = "current", .type = VSH_OT_BOOL, .help = N_("affect current domain") @@ -836,10 +836,7 @@ static const vshCmdOptDef opts_attach_interface[] = { }, VIRSH_DOMAIN_PERSISTENT_OPT_COMMON, VIRSH_DOMAIN_CONFIG_OPT_COMMON, - {.name = "live", - .type = VSH_OT_BOOL, - .help = N_("affect running domain") - }, + VIRSH_DOMAIN_LIVE_OPT_COMMON, {.name = "current", .type = VSH_OT_BOOL, .help = N_("affect current domain") @@ -1279,10 +1276,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = { .help = N_("I/O size in bytes") }, VIRSH_DOMAIN_CONFIG_OPT_COMMON, - {.name = "live", - .type = VSH_OT_BOOL, - .help = N_("affect running domain") - }, + VIRSH_DOMAIN_LIVE_OPT_COMMON, {.name = "current", .type = VSH_OT_BOOL, .help = N_("affect current domain") @@ -1530,10 +1524,7 @@ static const vshCmdOptDef opts_blkiotune[] = { .help = N_("per-device bytes wrote per second, in the form of /path/to/device,write_bytes_sec,...") }, VIRSH_DOMAIN_CONFIG_OPT_COMMON, - {.name = "live", - .type = VSH_OT_BOOL, - .help = N_("affect running domain") - }, + VIRSH_DOMAIN_LIVE_OPT_COMMON, {.name = "current", .type = VSH_OT_BOOL, .help = N_("affect current domain") @@ -3216,10 +3207,7 @@ static const vshCmdOptDef opts_domiftune[] = { .help = N_("control domain's outgoing traffics") }, VIRSH_DOMAIN_CONFIG_OPT_COMMON, - {.name = "live", - .type = VSH_OT_BOOL, - .help = N_("affect running domain") - }, + VIRSH_DOMAIN_LIVE_OPT_COMMON, {.name = "current", .type = VSH_OT_BOOL, .help = N_("affect current domain") @@ -6401,10 +6389,7 @@ static const vshCmdOptDef opts_vcpupin[] = { .help = N_("host cpu number(s) to set, or omit option to query") }, VIRSH_DOMAIN_CONFIG_OPT_COMMON, - {.name = "live", - .type = VSH_OT_BOOL, - .help = N_("affect running domain") - }, + VIRSH_DOMAIN_LIVE_OPT_COMMON, {.name = "current", .type = VSH_OT_BOOL, .help = N_("affect current domain") @@ -6602,10 +6587,7 @@ static const vshCmdOptDef opts_emulatorpin[] = { .help = N_("host cpu number(s) to set, or omit option to query") }, VIRSH_DOMAIN_CONFIG_OPT_COMMON, - {.name = "live", - .type = VSH_OT_BOOL, - .help = N_("affect running domain") - }, + VIRSH_DOMAIN_LIVE_OPT_COMMON, {.name = "current", .type = VSH_OT_BOOL, .help = N_("affect current domain") @@ -6716,10 +6698,7 @@ static const vshCmdOptDef opts_setvcpus[] = { .help = N_("set maximum limit on next boot") }, VIRSH_DOMAIN_CONFIG_OPT_COMMON, - {.name = "live", - .type = VSH_OT_BOOL, - .help = N_("affect running domain") - }, + VIRSH_DOMAIN_LIVE_OPT_COMMON, {.name = "current", .type = VSH_OT_BOOL, .help = N_("affect current domain") @@ -6801,10 +6780,7 @@ static const vshCmdInfo info_iothreadinfo[] = { static const vshCmdOptDef opts_iothreadinfo[] = { VIRSH_DOMAIN_OPT_COMMON, VIRSH_DOMAIN_CONFIG_OPT_COMMON, - {.name = "live", - .type = VSH_OT_BOOL, - .help = N_("affect running domain") - }, + VIRSH_DOMAIN_LIVE_OPT_COMMON, {.name = "current", .type = VSH_OT_BOOL, .help = N_("affect current domain") @@ -6893,10 +6869,7 @@ static const vshCmdOptDef opts_iothreadpin[] = { .help = N_("host cpu number(s) to set") }, VIRSH_DOMAIN_CONFIG_OPT_COMMON, - {.name = "live", - .type = VSH_OT_BOOL, - .help = N_("affect running domain") - }, + VIRSH_DOMAIN_LIVE_OPT_COMMON, {.name = "current", .type = VSH_OT_BOOL, .help = N_("affect current domain") @@ -6976,10 +6949,7 @@ static const vshCmdOptDef opts_iothreadadd[] = { .help = N_("iothread for the new IOThread") }, VIRSH_DOMAIN_CONFIG_OPT_COMMON, - {.name = "live", - .type = VSH_OT_BOOL, - .help = N_("affect running domain") - }, + VIRSH_DOMAIN_LIVE_OPT_COMMON, {.name = "current", .type = VSH_OT_BOOL, .help = N_("affect current domain") @@ -7047,10 +7017,7 @@ static const vshCmdOptDef opts_iothreaddel[] = { .help = N_("iothread_id for the IOThread to delete") }, VIRSH_DOMAIN_CONFIG_OPT_COMMON, - {.name = "live", - .type = VSH_OT_BOOL, - .help = N_("affect running domain") - }, + VIRSH_DOMAIN_LIVE_OPT_COMMON, {.name = "current", .type = VSH_OT_BOOL, .help = N_("affect current domain") @@ -8306,10 +8273,7 @@ static const vshCmdOptDef opts_setmem[] = { .help = N_("new memory size, as scaled integer (default KiB)") }, VIRSH_DOMAIN_CONFIG_OPT_COMMON, - {.name = "live", - .type = VSH_OT_BOOL, - .help = N_("affect running domain") - }, + VIRSH_DOMAIN_LIVE_OPT_COMMON, {.name = "current", .type = VSH_OT_BOOL, .help = N_("affect current domain") @@ -8393,10 +8357,7 @@ static const vshCmdOptDef opts_setmaxmem[] = { .help = N_("new maximum memory size, as scaled integer (default KiB)") }, VIRSH_DOMAIN_CONFIG_OPT_COMMON, - {.name = "live", - .type = VSH_OT_BOOL, - .help = N_("affect running domain") - }, + VIRSH_DOMAIN_LIVE_OPT_COMMON, {.name = "current", .type = VSH_OT_BOOL, .help = N_("affect current domain") @@ -8494,10 +8455,7 @@ static const vshCmdOptDef opts_memtune[] = { .help = N_("Min guaranteed memory, as scaled integer (default KiB)") }, VIRSH_DOMAIN_CONFIG_OPT_COMMON, - {.name = "live", - .type = VSH_OT_BOOL, - .help = N_("affect running domain") - }, + VIRSH_DOMAIN_LIVE_OPT_COMMON, {.name = "current", .type = VSH_OT_BOOL, .help = N_("affect current domain") @@ -8670,10 +8628,7 @@ static const vshCmdOptDef opts_numatune[] = { .help = N_("NUMA node selections to set") }, VIRSH_DOMAIN_CONFIG_OPT_COMMON, - {.name = "live", - .type = VSH_OT_BOOL, - .help = N_("affect running domain") - }, + VIRSH_DOMAIN_LIVE_OPT_COMMON, {.name = "current", .type = VSH_OT_BOOL, .help = N_("affect current domain") @@ -10781,10 +10736,7 @@ static const vshCmdOptDef opts_detach_device[] = { }, VIRSH_DOMAIN_PERSISTENT_OPT_COMMON, VIRSH_DOMAIN_CONFIG_OPT_COMMON, - {.name = "live", - .type = VSH_OT_BOOL, - .help = N_("affect running domain") - }, + VIRSH_DOMAIN_LIVE_OPT_COMMON, {.name = "current", .type = VSH_OT_BOOL, .help = N_("affect current domain") @@ -10872,10 +10824,7 @@ static const vshCmdOptDef opts_update_device[] = { }, VIRSH_DOMAIN_PERSISTENT_OPT_COMMON, VIRSH_DOMAIN_CONFIG_OPT_COMMON, - {.name = "live", - .type = VSH_OT_BOOL, - .help = N_("affect running domain") - }, + VIRSH_DOMAIN_LIVE_OPT_COMMON, {.name = "current", .type = VSH_OT_BOOL, .help = N_("affect current domain") @@ -10968,10 +10917,7 @@ static const vshCmdOptDef opts_detach_interface[] = { }, VIRSH_DOMAIN_PERSISTENT_OPT_COMMON, VIRSH_DOMAIN_CONFIG_OPT_COMMON, - {.name = "live", - .type = VSH_OT_BOOL, - .help = N_("affect running domain") - }, + VIRSH_DOMAIN_LIVE_OPT_COMMON, {.name = "current", .type = VSH_OT_BOOL, .help = N_("affect current domain") @@ -11374,10 +11320,7 @@ static const vshCmdOptDef opts_detach_disk[] = { }, VIRSH_DOMAIN_PERSISTENT_OPT_COMMON, VIRSH_DOMAIN_CONFIG_OPT_COMMON, - {.name = "live", - .type = VSH_OT_BOOL, - .help = N_("affect running domain") - }, + VIRSH_DOMAIN_LIVE_OPT_COMMON, {.name = "current", .type = VSH_OT_BOOL, .help = N_("affect current domain") -- 2.5.0

Rather than continually cut-n-paste the strings into each command, create a common macro to be used generically. Note that not all '{.name = "current",' entries are replaced, just those that have the common .help string of "affect current domain". Non replaced instances are unique to the command. Signed-off-by: John Ferlan <jferlan@redhat.com> --- tools/virsh-domain.c | 111 +++++++++++++-------------------------------------- 1 file changed, 27 insertions(+), 84 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index c6e9979..20627e9 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -81,6 +81,12 @@ .help = N_("affect running domain") \ } \ +#define VIRSH_DOMAIN_CURRENT_OPT_COMMON \ + {.name = "current", \ + .type = VSH_OT_BOOL, \ + .help = N_("affect current domain") \ + } \ + static virDomainPtr virshLookupDomainInternal(vshControl *ctl, const char *cmdname, @@ -232,10 +238,7 @@ static const vshCmdOptDef opts_attach_device[] = { VIRSH_DOMAIN_PERSISTENT_OPT_COMMON, VIRSH_DOMAIN_CONFIG_OPT_COMMON, VIRSH_DOMAIN_LIVE_OPT_COMMON, - {.name = "current", - .type = VSH_OT_BOOL, - .help = N_("affect current domain") - }, + VIRSH_DOMAIN_CURRENT_OPT_COMMON, {.name = NULL} }; @@ -386,10 +389,7 @@ static const vshCmdOptDef opts_attach_disk[] = { VIRSH_DOMAIN_PERSISTENT_OPT_COMMON, VIRSH_DOMAIN_CONFIG_OPT_COMMON, VIRSH_DOMAIN_LIVE_OPT_COMMON, - {.name = "current", - .type = VSH_OT_BOOL, - .help = N_("affect current domain") - }, + VIRSH_DOMAIN_CURRENT_OPT_COMMON, {.name = NULL} }; @@ -837,10 +837,7 @@ static const vshCmdOptDef opts_attach_interface[] = { VIRSH_DOMAIN_PERSISTENT_OPT_COMMON, VIRSH_DOMAIN_CONFIG_OPT_COMMON, VIRSH_DOMAIN_LIVE_OPT_COMMON, - {.name = "current", - .type = VSH_OT_BOOL, - .help = N_("affect current domain") - }, + VIRSH_DOMAIN_CURRENT_OPT_COMMON, {.name = "print-xml", .type = VSH_OT_BOOL, .help = N_("print XML document rather than attach the interface") @@ -1277,10 +1274,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = { }, VIRSH_DOMAIN_CONFIG_OPT_COMMON, VIRSH_DOMAIN_LIVE_OPT_COMMON, - {.name = "current", - .type = VSH_OT_BOOL, - .help = N_("affect current domain") - }, + VIRSH_DOMAIN_CURRENT_OPT_COMMON, {.name = NULL} }; @@ -1525,10 +1519,7 @@ static const vshCmdOptDef opts_blkiotune[] = { }, VIRSH_DOMAIN_CONFIG_OPT_COMMON, VIRSH_DOMAIN_LIVE_OPT_COMMON, - {.name = "current", - .type = VSH_OT_BOOL, - .help = N_("affect current domain") - }, + VIRSH_DOMAIN_CURRENT_OPT_COMMON, {.name = NULL} }; @@ -3208,10 +3199,7 @@ static const vshCmdOptDef opts_domiftune[] = { }, VIRSH_DOMAIN_CONFIG_OPT_COMMON, VIRSH_DOMAIN_LIVE_OPT_COMMON, - {.name = "current", - .type = VSH_OT_BOOL, - .help = N_("affect current domain") - }, + VIRSH_DOMAIN_CURRENT_OPT_COMMON, {.name = NULL} }; @@ -6390,10 +6378,7 @@ static const vshCmdOptDef opts_vcpupin[] = { }, VIRSH_DOMAIN_CONFIG_OPT_COMMON, VIRSH_DOMAIN_LIVE_OPT_COMMON, - {.name = "current", - .type = VSH_OT_BOOL, - .help = N_("affect current domain") - }, + VIRSH_DOMAIN_CURRENT_OPT_COMMON, {.name = NULL} }; @@ -6588,10 +6573,7 @@ static const vshCmdOptDef opts_emulatorpin[] = { }, VIRSH_DOMAIN_CONFIG_OPT_COMMON, VIRSH_DOMAIN_LIVE_OPT_COMMON, - {.name = "current", - .type = VSH_OT_BOOL, - .help = N_("affect current domain") - }, + VIRSH_DOMAIN_CURRENT_OPT_COMMON, {.name = NULL} }; @@ -6699,10 +6681,7 @@ static const vshCmdOptDef opts_setvcpus[] = { }, VIRSH_DOMAIN_CONFIG_OPT_COMMON, VIRSH_DOMAIN_LIVE_OPT_COMMON, - {.name = "current", - .type = VSH_OT_BOOL, - .help = N_("affect current domain") - }, + VIRSH_DOMAIN_CURRENT_OPT_COMMON, {.name = "guest", .type = VSH_OT_BOOL, .help = N_("modify cpu state in the guest") @@ -6781,10 +6760,7 @@ static const vshCmdOptDef opts_iothreadinfo[] = { VIRSH_DOMAIN_OPT_COMMON, VIRSH_DOMAIN_CONFIG_OPT_COMMON, VIRSH_DOMAIN_LIVE_OPT_COMMON, - {.name = "current", - .type = VSH_OT_BOOL, - .help = N_("affect current domain") - }, + VIRSH_DOMAIN_CURRENT_OPT_COMMON, {.name = NULL} }; @@ -6870,10 +6846,7 @@ static const vshCmdOptDef opts_iothreadpin[] = { }, VIRSH_DOMAIN_CONFIG_OPT_COMMON, VIRSH_DOMAIN_LIVE_OPT_COMMON, - {.name = "current", - .type = VSH_OT_BOOL, - .help = N_("affect current domain") - }, + VIRSH_DOMAIN_CURRENT_OPT_COMMON, {.name = NULL} }; @@ -6950,10 +6923,7 @@ static const vshCmdOptDef opts_iothreadadd[] = { }, VIRSH_DOMAIN_CONFIG_OPT_COMMON, VIRSH_DOMAIN_LIVE_OPT_COMMON, - {.name = "current", - .type = VSH_OT_BOOL, - .help = N_("affect current domain") - }, + VIRSH_DOMAIN_CURRENT_OPT_COMMON, {.name = NULL} }; @@ -7018,10 +6988,7 @@ static const vshCmdOptDef opts_iothreaddel[] = { }, VIRSH_DOMAIN_CONFIG_OPT_COMMON, VIRSH_DOMAIN_LIVE_OPT_COMMON, - {.name = "current", - .type = VSH_OT_BOOL, - .help = N_("affect current domain") - }, + VIRSH_DOMAIN_CURRENT_OPT_COMMON, {.name = NULL} }; @@ -8274,10 +8241,7 @@ static const vshCmdOptDef opts_setmem[] = { }, VIRSH_DOMAIN_CONFIG_OPT_COMMON, VIRSH_DOMAIN_LIVE_OPT_COMMON, - {.name = "current", - .type = VSH_OT_BOOL, - .help = N_("affect current domain") - }, + VIRSH_DOMAIN_CURRENT_OPT_COMMON, {.name = NULL} }; @@ -8358,10 +8322,7 @@ static const vshCmdOptDef opts_setmaxmem[] = { }, VIRSH_DOMAIN_CONFIG_OPT_COMMON, VIRSH_DOMAIN_LIVE_OPT_COMMON, - {.name = "current", - .type = VSH_OT_BOOL, - .help = N_("affect current domain") - }, + VIRSH_DOMAIN_CURRENT_OPT_COMMON, {.name = NULL} }; @@ -8456,10 +8417,7 @@ static const vshCmdOptDef opts_memtune[] = { }, VIRSH_DOMAIN_CONFIG_OPT_COMMON, VIRSH_DOMAIN_LIVE_OPT_COMMON, - {.name = "current", - .type = VSH_OT_BOOL, - .help = N_("affect current domain") - }, + VIRSH_DOMAIN_CURRENT_OPT_COMMON, {.name = NULL} }; @@ -8629,10 +8587,7 @@ static const vshCmdOptDef opts_numatune[] = { }, VIRSH_DOMAIN_CONFIG_OPT_COMMON, VIRSH_DOMAIN_LIVE_OPT_COMMON, - {.name = "current", - .type = VSH_OT_BOOL, - .help = N_("affect current domain") - }, + VIRSH_DOMAIN_CURRENT_OPT_COMMON, {.name = NULL} }; @@ -10737,10 +10692,7 @@ static const vshCmdOptDef opts_detach_device[] = { VIRSH_DOMAIN_PERSISTENT_OPT_COMMON, VIRSH_DOMAIN_CONFIG_OPT_COMMON, VIRSH_DOMAIN_LIVE_OPT_COMMON, - {.name = "current", - .type = VSH_OT_BOOL, - .help = N_("affect current domain") - }, + VIRSH_DOMAIN_CURRENT_OPT_COMMON, {.name = NULL} }; @@ -10825,10 +10777,7 @@ static const vshCmdOptDef opts_update_device[] = { VIRSH_DOMAIN_PERSISTENT_OPT_COMMON, VIRSH_DOMAIN_CONFIG_OPT_COMMON, VIRSH_DOMAIN_LIVE_OPT_COMMON, - {.name = "current", - .type = VSH_OT_BOOL, - .help = N_("affect current domain") - }, + VIRSH_DOMAIN_CURRENT_OPT_COMMON, {.name = "force", .type = VSH_OT_BOOL, .help = N_("force device update") @@ -10918,10 +10867,7 @@ static const vshCmdOptDef opts_detach_interface[] = { VIRSH_DOMAIN_PERSISTENT_OPT_COMMON, VIRSH_DOMAIN_CONFIG_OPT_COMMON, VIRSH_DOMAIN_LIVE_OPT_COMMON, - {.name = "current", - .type = VSH_OT_BOOL, - .help = N_("affect current domain") - }, + VIRSH_DOMAIN_CURRENT_OPT_COMMON, {.name = NULL} }; @@ -11321,10 +11267,7 @@ static const vshCmdOptDef opts_detach_disk[] = { VIRSH_DOMAIN_PERSISTENT_OPT_COMMON, VIRSH_DOMAIN_CONFIG_OPT_COMMON, VIRSH_DOMAIN_LIVE_OPT_COMMON, - {.name = "current", - .type = VSH_OT_BOOL, - .help = N_("affect current domain") - }, + VIRSH_DOMAIN_CURRENT_OPT_COMMON, {.name = NULL} }; -- 2.5.0

Rather than continually cut-n-paste the strings into each command, create a common macro to be used generically. Note that not all '{.name = "file",' entries are replaced, just those that use VSH_OT_DATA and VSH_OFLAG_REQ. Replacement of this option is a bit trickier, since the .helpstr changes from command to command. Also because if the N_() I18N for each, it's also not possible to just copy the string. So, replace the enter right side of the .helpstr = with the _helpstr macro argument. Signed-off-by: John Ferlan <jferlan@redhat.com> --- tools/virsh-domain.c | 85 +++++++++++++--------------------------------------- 1 file changed, 20 insertions(+), 65 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 20627e9..8e28bb3 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -87,6 +87,13 @@ .help = N_("affect current domain") \ } \ +#define VIRSH_DOMAIN_FILE_OPT_COMMON(_helpstr) \ + {.name = "file", \ + .type = VSH_OT_DATA, \ + .flags = VSH_OFLAG_REQ, \ + .help = _helpstr \ + } \ + static virDomainPtr virshLookupDomainInternal(vshControl *ctl, const char *cmdname, @@ -230,11 +237,7 @@ static const vshCmdInfo info_attach_device[] = { static const vshCmdOptDef opts_attach_device[] = { VIRSH_DOMAIN_OPT_COMMON, - {.name = "file", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("XML file") - }, + VIRSH_DOMAIN_FILE_OPT_COMMON(N_("XML file")), VIRSH_DOMAIN_PERSISTENT_OPT_COMMON, VIRSH_DOMAIN_CONFIG_OPT_COMMON, VIRSH_DOMAIN_LIVE_OPT_COMMON, @@ -4135,11 +4138,7 @@ static const vshCmdInfo info_save[] = { static const vshCmdOptDef opts_save[] = { VIRSH_DOMAIN_OPT_COMMON, - {.name = "file", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("where to save the data") - }, + VIRSH_DOMAIN_FILE_OPT_COMMON(N_("where to save the data")), {.name = "bypass-cache", .type = VSH_OT_BOOL, .help = N_("avoid file system cache when saving") @@ -4396,11 +4395,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_DOMAIN_FILE_OPT_COMMON(N_("saved state file to read")), {.name = "security-info", .type = VSH_OT_BOOL, .help = N_("include security sensitive information in XML dump") @@ -4449,11 +4444,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_DOMAIN_FILE_OPT_COMMON(N_("saved state file to modify")), {.name = "xml", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -4521,11 +4512,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_DOMAIN_FILE_OPT_COMMON(N_("saved state file to edit")), {.name = "running", .type = VSH_OT_BOOL, .help = N_("set domain to be running on restore") @@ -5019,11 +5006,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_DOMAIN_FILE_OPT_COMMON(N_("the state to restore")), {.name = "bypass-cache", .type = VSH_OT_BOOL, .help = N_("avoid file system cache when restoring") @@ -5100,11 +5083,7 @@ static const vshCmdInfo info_dump[] = { static const vshCmdOptDef opts_dump[] = { VIRSH_DOMAIN_OPT_COMMON, - {.name = "file", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("where to dump the core") - }, + VIRSH_DOMAIN_FILE_OPT_COMMON(N_("where to dump the core")), {.name = "live", .type = VSH_OT_BOOL, .help = N_("perform a live core dump if supported") @@ -7045,11 +7024,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_DOMAIN_FILE_OPT_COMMON(N_("file containing an XML CPU description")), {.name = "error", .type = VSH_OT_BOOL, .help = N_("report error if CPUs are incompatible") @@ -7147,11 +7122,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_DOMAIN_FILE_OPT_COMMON(N_("file containing XML CPU descriptions")), {.name = "features", .type = VSH_OT_BOOL, .help = N_("Show features that are part of the CPU model type") @@ -7449,11 +7420,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_DOMAIN_FILE_OPT_COMMON(N_("file containing an XML domain description")), #ifndef WIN32 {.name = "console", .type = VSH_OT_BOOL, @@ -7549,11 +7516,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_DOMAIN_FILE_OPT_COMMON(N_("file containing an XML domain description")), {.name = "validate", .type = VSH_OT_BOOL, .help = N_("validate the XML against the schema") @@ -10684,11 +10647,7 @@ static const vshCmdInfo info_detach_device[] = { static const vshCmdOptDef opts_detach_device[] = { VIRSH_DOMAIN_OPT_COMMON, - {.name = "file", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("XML file") - }, + VIRSH_DOMAIN_FILE_OPT_COMMON(N_("XML file")), VIRSH_DOMAIN_PERSISTENT_OPT_COMMON, VIRSH_DOMAIN_CONFIG_OPT_COMMON, VIRSH_DOMAIN_LIVE_OPT_COMMON, @@ -10769,11 +10728,7 @@ static const vshCmdInfo info_update_device[] = { static const vshCmdOptDef opts_update_device[] = { VIRSH_DOMAIN_OPT_COMMON, - {.name = "file", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("XML file") - }, + VIRSH_DOMAIN_FILE_OPT_COMMON(N_("XML file")), VIRSH_DOMAIN_PERSISTENT_OPT_COMMON, VIRSH_DOMAIN_CONFIG_OPT_COMMON, VIRSH_DOMAIN_LIVE_OPT_COMMON, -- 2.5.0

Rather than continually cut-n-paste the strings into each command, create common macros to be used generically. For virsh-volume, there are 3 different types of "pool" options - 2 for create, 2 required for the command, and 10 for string type options. Create 2 new macros for the create and string type options, but use the virsh.h common macro for the required for command option. Signed-off-by: John Ferlan <jferlan@redhat.com> --- tools/virsh-volume.c | 87 ++++++++++++++++------------------------------------ 1 file changed, 27 insertions(+), 60 deletions(-) diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index 3408bee..cb350ee 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -42,6 +42,19 @@ #include "virxml.h" #include "virstring.h" +#define VIRSH_VOLUME_POOL_CREATE_OPT_COMMON \ + {.name = "pool", \ + .type = VSH_OT_DATA, \ + .flags = VSH_OFLAG_REQ, \ + .help = N_("pool name") \ + } \ + +#define VIRSH_VOLUME_POOL_STRING_OPT_COMMON \ + {.name = "pool", \ + .type = VSH_OT_STRING, \ + .help = N_("pool name or uuid") \ + } \ + virStorageVolPtr virshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd, const char *optname, @@ -145,11 +158,7 @@ static const vshCmdInfo info_vol_create_as[] = { }; static const vshCmdOptDef opts_vol_create_as[] = { - {.name = "pool", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("pool name") - }, + VIRSH_VOLUME_POOL_CREATE_OPT_COMMON, {.name = "name", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -353,11 +362,7 @@ static const vshCmdInfo info_vol_create[] = { }; static const vshCmdOptDef opts_vol_create[] = { - {.name = "pool", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("pool name") - }, + VIRSH_VOLUME_POOL_CREATE_OPT_COMMON, {.name = "file", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -423,11 +428,7 @@ static const vshCmdInfo info_vol_create_from[] = { }; static const vshCmdOptDef opts_vol_create_from[] = { - {.name = "pool", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("pool name or uuid") - }, + VIRSH_POOL_OPT_COMMON, {.name = "file", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -558,10 +559,7 @@ static const vshCmdOptDef opts_vol_clone[] = { .flags = VSH_OFLAG_REQ, .help = N_("clone name") }, - {.name = "pool", - .type = VSH_OT_STRING, - .help = N_("pool name or uuid") - }, + VIRSH_VOLUME_POOL_STRING_OPT_COMMON, {.name = "prealloc-metadata", .type = VSH_OT_BOOL, .help = N_("preallocate metadata (for qcow2 instead of full allocation)") @@ -661,10 +659,7 @@ static const vshCmdOptDef opts_vol_upload[] = { .flags = VSH_OFLAG_REQ, .help = N_("file") }, - {.name = "pool", - .type = VSH_OT_STRING, - .help = N_("pool name or uuid") - }, + VIRSH_VOLUME_POOL_STRING_OPT_COMMON, {.name = "offset", .type = VSH_OT_INT, .help = N_("volume offset to upload to") @@ -775,10 +770,7 @@ static const vshCmdOptDef opts_vol_download[] = { .flags = VSH_OFLAG_REQ, .help = N_("file") }, - {.name = "pool", - .type = VSH_OT_STRING, - .help = N_("pool name or uuid") - }, + VIRSH_VOLUME_POOL_STRING_OPT_COMMON, {.name = "offset", .type = VSH_OT_INT, .help = N_("volume offset to download from") @@ -883,10 +875,7 @@ static const vshCmdOptDef opts_vol_delete[] = { .flags = VSH_OFLAG_REQ, .help = N_("vol name, key or path") }, - {.name = "pool", - .type = VSH_OT_STRING, - .help = N_("pool name or uuid") - }, + VIRSH_VOLUME_POOL_STRING_OPT_COMMON, {.name = NULL} }; @@ -930,10 +919,7 @@ static const vshCmdOptDef opts_vol_wipe[] = { .flags = VSH_OFLAG_REQ, .help = N_("vol name, key or path") }, - {.name = "pool", - .type = VSH_OT_STRING, - .help = N_("pool name or uuid") - }, + VIRSH_VOLUME_POOL_STRING_OPT_COMMON, {.name = "algorithm", .type = VSH_OT_STRING, .help = N_("perform selected wiping algorithm") @@ -1023,10 +1009,7 @@ static const vshCmdOptDef opts_vol_info[] = { .flags = VSH_OFLAG_REQ, .help = N_("vol name, key or path") }, - {.name = "pool", - .type = VSH_OT_STRING, - .help = N_("pool name or uuid") - }, + VIRSH_VOLUME_POOL_STRING_OPT_COMMON, {.name = NULL} }; @@ -1086,10 +1069,7 @@ static const vshCmdOptDef opts_vol_resize[] = { .flags = VSH_OFLAG_REQ, .help = N_("new capacity for the vol, as scaled integer (default bytes)") }, - {.name = "pool", - .type = VSH_OT_STRING, - .help = N_("pool name or uuid") - }, + VIRSH_VOLUME_POOL_STRING_OPT_COMMON, {.name = "allocate", .type = VSH_OT_BOOL, .help = N_("allocate the new capacity, rather than leaving it sparse") @@ -1185,10 +1165,7 @@ static const vshCmdOptDef opts_vol_dumpxml[] = { .flags = VSH_OFLAG_REQ, .help = N_("vol name, key or path") }, - {.name = "pool", - .type = VSH_OT_STRING, - .help = N_("pool name or uuid") - }, + VIRSH_VOLUME_POOL_STRING_OPT_COMMON, {.name = NULL} }; @@ -1354,11 +1331,7 @@ static const vshCmdInfo info_vol_list[] = { }; static const vshCmdOptDef opts_vol_list[] = { - {.name = "pool", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("pool name or uuid") - }, + VIRSH_POOL_OPT_COMMON, {.name = "details", .type = VSH_OT_BOOL, .help = N_("display extended details for volumes") @@ -1700,10 +1673,7 @@ static const vshCmdOptDef opts_vol_key[] = { .flags = VSH_OFLAG_REQ, .help = N_("volume name or path") }, - {.name = "pool", - .type = VSH_OT_STRING, - .help = N_("pool name or uuid") - }, + VIRSH_VOLUME_POOL_STRING_OPT_COMMON, {.name = NULL} }; @@ -1739,10 +1709,7 @@ static const vshCmdOptDef opts_vol_path[] = { .flags = VSH_OFLAG_REQ, .help = N_("volume name or key") }, - {.name = "pool", - .type = VSH_OT_STRING, - .help = N_("pool name or uuid") - }, + VIRSH_VOLUME_POOL_STRING_OPT_COMMON, {.name = NULL} }; -- 2.5.0

Rather than continually cut-n-paste the strings into each command, create common macros to be used generically. Replace the more commonly used "vol" option with a macro. This also adjusts 2 commands that didn't have the correct helpstr - 'vol-create-from' and 'vol-clone'. Both are described in the man page as taking vol, path, or key and the code uses the virshCommandOptVol instead of virshCommandOptVolBy. Signed-off-by: John Ferlan <jferlan@redhat.com> --- tools/virsh-volume.c | 61 ++++++++++++++-------------------------------------- 1 file changed, 16 insertions(+), 45 deletions(-) diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index cb350ee..2ddab80 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -55,6 +55,13 @@ .help = N_("pool name or uuid") \ } \ +#define VIRSH_VOLUME_VOL_OPT_COMMON \ + {.name = "vol", \ + .type = VSH_OT_DATA, \ + .flags = VSH_OFLAG_REQ, \ + .help = N_("vol name, key or path") \ + } \ + virStorageVolPtr virshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd, const char *optname, @@ -434,11 +441,7 @@ static const vshCmdOptDef opts_vol_create_from[] = { .flags = VSH_OFLAG_REQ, .help = N_("file containing an XML vol description") }, - {.name = "vol", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("input vol name or key") - }, + VIRSH_VOLUME_VOL_OPT_COMMON, {.name = "inputpool", .type = VSH_OT_STRING, .help = N_("pool name or uuid of the input volume's pool") @@ -549,11 +552,7 @@ static const vshCmdInfo info_vol_clone[] = { }; static const vshCmdOptDef opts_vol_clone[] = { - {.name = "vol", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("orig vol name or key") - }, + VIRSH_VOLUME_VOL_OPT_COMMON, {.name = "newname", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -649,11 +648,7 @@ static const vshCmdInfo info_vol_upload[] = { }; static const vshCmdOptDef opts_vol_upload[] = { - {.name = "vol", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("vol name, key or path") - }, + VIRSH_VOLUME_VOL_OPT_COMMON, {.name = "file", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -760,11 +755,7 @@ static const vshCmdInfo info_vol_download[] = { }; static const vshCmdOptDef opts_vol_download[] = { - {.name = "vol", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("vol name, key or path") - }, + VIRSH_VOLUME_VOL_OPT_COMMON, {.name = "file", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -870,11 +861,7 @@ static const vshCmdInfo info_vol_delete[] = { }; static const vshCmdOptDef opts_vol_delete[] = { - {.name = "vol", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("vol name, key or path") - }, + VIRSH_VOLUME_POOL_STRING_OPT_COMMON, VIRSH_VOLUME_POOL_STRING_OPT_COMMON, {.name = NULL} }; @@ -914,11 +901,7 @@ static const vshCmdInfo info_vol_wipe[] = { }; static const vshCmdOptDef opts_vol_wipe[] = { - {.name = "vol", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("vol name, key or path") - }, + VIRSH_VOLUME_POOL_STRING_OPT_COMMON, VIRSH_VOLUME_POOL_STRING_OPT_COMMON, {.name = "algorithm", .type = VSH_OT_STRING, @@ -1004,11 +987,7 @@ static const vshCmdInfo info_vol_info[] = { }; static const vshCmdOptDef opts_vol_info[] = { - {.name = "vol", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("vol name, key or path") - }, + VIRSH_VOLUME_POOL_STRING_OPT_COMMON, VIRSH_VOLUME_POOL_STRING_OPT_COMMON, {.name = NULL} }; @@ -1059,11 +1038,7 @@ static const vshCmdInfo info_vol_resize[] = { }; static const vshCmdOptDef opts_vol_resize[] = { - {.name = "vol", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("vol name, key or path") - }, + VIRSH_VOLUME_VOL_OPT_COMMON, {.name = "capacity", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -1160,11 +1135,7 @@ static const vshCmdInfo info_vol_dumpxml[] = { }; static const vshCmdOptDef opts_vol_dumpxml[] = { - {.name = "vol", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("vol name, key or path") - }, + VIRSH_VOLUME_POOL_STRING_OPT_COMMON, VIRSH_VOLUME_POOL_STRING_OPT_COMMON, {.name = NULL} }; -- 2.5.0

Make use of the common VIRSH_DOMAIN_OPT_COMMON macro for each of the matching '.name = "domain"' command options. Signed-off-by: John Ferlan <jferlan@redhat.com> --- tools/virsh-domain-monitor.c | 77 ++++++++------------------------------------ 1 file changed, 13 insertions(+), 64 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 7dcf833..53ed4de 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -281,11 +281,7 @@ static const vshCmdInfo info_dommemstat[] = { }; static const vshCmdOptDef opts_dommemstat[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "period", .type = VSH_OT_INT, .flags = VSH_OFLAG_REQ_OPT, @@ -402,11 +398,7 @@ static const vshCmdInfo info_domblkinfo[] = { }; static const vshCmdOptDef opts_domblkinfo[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "device", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -457,11 +449,7 @@ static const vshCmdInfo info_domblklist[] = { }; static const vshCmdOptDef opts_domblklist[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "inactive", .type = VSH_OT_BOOL, .help = N_("get inactive rather than running configuration") @@ -579,11 +567,7 @@ static const vshCmdInfo info_domiflist[] = { }; static const vshCmdOptDef opts_domiflist[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "inactive", .type = VSH_OT_BOOL, .help = N_("get inactive rather than running configuration") @@ -684,11 +668,7 @@ static const vshCmdInfo info_domif_getlink[] = { }; static const vshCmdOptDef opts_domif_getlink[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "interface", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -799,11 +779,7 @@ static const vshCmdInfo info_domcontrol[] = { }; static const vshCmdOptDef opts_domcontrol[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = NULL} }; @@ -856,11 +832,7 @@ static const vshCmdInfo info_domblkstat[] = { }; static const vshCmdOptDef opts_domblkstat[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "device", .type = VSH_OT_STRING, .flags = VSH_OFLAG_EMPTY_OK, @@ -1046,11 +1018,7 @@ static const vshCmdInfo info_domifstat[] = { }; static const vshCmdOptDef opts_domifstat[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "interface", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -1123,11 +1091,7 @@ static const vshCmdInfo info_domblkerror[] = { }; static const vshCmdOptDef opts_domblkerror[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id, or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = NULL} }; @@ -1188,11 +1152,7 @@ static const vshCmdInfo info_dominfo[] = { }; static const vshCmdOptDef opts_dominfo[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = NULL} }; @@ -1331,11 +1291,7 @@ static const vshCmdInfo info_domstate[] = { }; static const vshCmdOptDef opts_domstate[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "reason", .type = VSH_OT_BOOL, .help = N_("also print reason for the state") @@ -1387,11 +1343,7 @@ static const vshCmdInfo info_domtime[] = { }; static const vshCmdOptDef opts_domtime[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "now", .type = VSH_OT_BOOL, .help = N_("set to the time of the host running virsh") @@ -2208,10 +2160,7 @@ static const vshCmdInfo info_domifaddr[] = { }; static const vshCmdOptDef opts_domifaddr[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid")}, + VIRSH_DOMAIN_OPT_COMMON, {.name = "interface", .type = VSH_OT_STRING, .flags = VSH_OFLAG_NONE, -- 2.5.0

Make use of the common VIRSH_DOMAIN_OPT_COMMON macro for each of the matching '.name = "domain"' command options. Signed-off-by: John Ferlan <jferlan@redhat.com> --- tools/virsh-snapshot.c | 60 +++++++++----------------------------------------- 1 file changed, 10 insertions(+), 50 deletions(-) diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index 3ab2104..071ecd0 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -123,11 +123,7 @@ static const vshCmdInfo info_snapshot_create[] = { }; static const vshCmdOptDef opts_snapshot_create[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "xmlfile", .type = VSH_OT_STRING, .help = N_("domain snapshot XML") @@ -328,11 +324,7 @@ static const vshCmdInfo info_snapshot_create_as[] = { }; static const vshCmdOptDef opts_snapshot_create_as[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "name", .type = VSH_OT_STRING, .help = N_("name of snapshot") @@ -524,11 +516,7 @@ static const vshCmdInfo info_snapshot_edit[] = { }; static const vshCmdOptDef opts_snapshot_edit[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "snapshotname", .type = VSH_OT_STRING, .help = N_("snapshot name") @@ -645,11 +633,7 @@ static const vshCmdInfo info_snapshot_current[] = { }; static const vshCmdOptDef opts_snapshot_current[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "name", .type = VSH_OT_BOOL, .help = N_("list the name, rather than the full xml") @@ -882,11 +866,7 @@ static const vshCmdInfo info_snapshot_info[] = { }; static const vshCmdOptDef opts_snapshot_info[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "snapshotname", .type = VSH_OT_STRING, .help = N_("snapshot name") @@ -1441,11 +1421,7 @@ static const vshCmdInfo info_snapshot_list[] = { }; static const vshCmdOptDef opts_snapshot_list[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "parent", .type = VSH_OT_BOOL, .help = N_("add a column showing parent snapshot") @@ -1705,11 +1681,7 @@ static const vshCmdInfo info_snapshot_dumpxml[] = { }; static const vshCmdOptDef opts_snapshot_dumpxml[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "snapshotname", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -1773,11 +1745,7 @@ static const vshCmdInfo info_snapshot_parent[] = { }; static const vshCmdOptDef opts_snapshot_parent[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "snapshotname", .type = VSH_OT_STRING, .help = N_("find parent of snapshot name") @@ -1841,11 +1809,7 @@ static const vshCmdInfo info_snapshot_revert[] = { }; static const vshCmdOptDef opts_snapshot_revert[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "snapshotname", .type = VSH_OT_STRING, .help = N_("snapshot name") @@ -1934,11 +1898,7 @@ static const vshCmdInfo info_snapshot_delete[] = { }; static const vshCmdOptDef opts_snapshot_delete[] = { - {.name = "domain", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("domain name, id or uuid") - }, + VIRSH_DOMAIN_OPT_COMMON, {.name = "snapshotname", .type = VSH_OT_STRING, .help = N_("snapshot name") -- 2.5.0

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@redhat.com> --- 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

Rather than continually cut-n-paste the strings into each command, create a common macro to be used generically. Note that not all '{.name = "interface",' entries are replaced, just those that have the common .help string of "interface name or MAC address". Signed-off-by: John Ferlan <jferlan@redhat.com> --- tools/virsh-interface.c | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c index b69c685..b98b002 100644 --- a/tools/virsh-interface.c +++ b/tools/virsh-interface.c @@ -23,6 +23,13 @@ * */ +#define VIRSH_INTERFACE_OPT_COMMON \ + {.name = "interface", \ + .type = VSH_OT_DATA, \ + .flags = VSH_OFLAG_REQ, \ + .help = N_("interface name or MAC address") \ + } \ + #include <config.h> #include "virsh-interface.h" @@ -100,11 +107,7 @@ static const vshCmdInfo info_interface_edit[] = { }; static const vshCmdOptDef opts_interface_edit[] = { - {.name = "interface", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("interface name or MAC address") - }, + VIRSH_INTERFACE_OPT_COMMON, {.name = NULL} }; @@ -464,11 +467,7 @@ static const vshCmdInfo info_interface_dumpxml[] = { }; static const vshCmdOptDef opts_interface_dumpxml[] = { - {.name = "interface", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("interface name or MAC address") - }, + VIRSH_INTERFACE_OPT_COMMON, {.name = "inactive", .type = VSH_OT_BOOL, .help = N_("show inactive defined XML") @@ -569,11 +568,7 @@ static const vshCmdInfo info_interface_undefine[] = { }; static const vshCmdOptDef opts_interface_undefine[] = { - {.name = "interface", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("interface name or MAC address") - }, + VIRSH_INTERFACE_OPT_COMMON, {.name = NULL} }; @@ -612,11 +607,7 @@ static const vshCmdInfo info_interface_start[] = { }; static const vshCmdOptDef opts_interface_start[] = { - {.name = "interface", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("interface name or MAC address") - }, + VIRSH_INTERFACE_OPT_COMMON, {.name = NULL} }; @@ -655,11 +646,7 @@ static const vshCmdInfo info_interface_destroy[] = { }; static const vshCmdOptDef opts_interface_destroy[] = { - {.name = "interface", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("interface name or MAC address") - }, + VIRSH_INTERFACE_OPT_COMMON, {.name = NULL} }; -- 2.5.0

On 12/18/2015 10:45 AM, John Ferlan wrote:
v1: http://www.redhat.com/archives/libvir-list/2015-December/msg00731.html
Changes over v1:
1. Insert patch 1 to convert already pushed VSH_POOL into VIRSH_POOL since that was the review comment from this patch series
2. Insert patch 2 to move the POOL_OPT_COMMON to virsh.h for later patch reuse.
3. Use VIRSH_* instead of VSH_* for patches 1-8 (now 3-10)
4. Add usage of common domain for virsh-domain-monitor.c and virsh-snapshot.c (patches 11-12)
5. Add common macros for "network" and "interface" (patches 13-14).
NOTE: I figure to let this perculate for a bit as I'll assume there may be varying opinions on this... Also, the next couple of weeks heavy on people perhaps paying not paying close attention to the list.
I'm a bit conflicted. On one hand, it makes for less bulk in the code and assures consistency when the same option is used by multiple commands. On the other hand, as Peter said in a response to the original patch, it obscures things behind macros which can lead to confusion (and extra time backtracking). If you're looking for a final "vote" from me, I guess I'd give it +1 (brevity wins this time), with these comments: 1) I assume that make check and make syntax-check have been run for each patch. :-) 2) I agree with using "VIRSH_..." instead of "VSH_..." (I dislike the shortening of virsh to vsh - doing that just for 2 characters? What is this, twitter? :-P) 3) I haven't looked at how is meshes with consistency of other macro names in virsh*, but it would make more sense to me if these were named VIRSH_COMMON_OPT_BLAH instead of VIRSH_BLAH_OPT_COMMON It reads better, and sticks the difference out at the end where it is more easily separated from the "common common" part.
John Ferlan (14): virsh: Covert VSH_POOL_ macro to VIRSH_POOL_ virsh: Move VIRSH_POOL_OPT_COMMON to virsh.h virsh: Create macro for common "domain" option virsh: Create macro for common "persistent" option virsh: Create macro for common "config" option virsh: Create macro for common "live" option virsh: Create macro for common "current" option virsh: Create macro for common "file" option virsh: Create macros for common "pool" options virsh: Create macros for common "vol" options virsh: Have domain-monitor use common "domain" option virsh: have snapshot use common "domain" option virsh: Create macro for common "network" option virsh: Create macro for common "interface" option
po/POTFILES.in | 1 + tools/virsh-domain-monitor.c | 77 +--- tools/virsh-domain.c | 911 +++++++++---------------------------------- tools/virsh-interface.c | 37 +- tools/virsh-network.c | 61 +-- tools/virsh-pool.c | 71 ++-- tools/virsh-snapshot.c | 60 +-- tools/virsh-volume.c | 148 ++----- tools/virsh.h | 17 + 9 files changed, 334 insertions(+), 1049 deletions(-)

On 01/06/2016 01:58 PM, Laine Stump wrote:
On 12/18/2015 10:45 AM, John Ferlan wrote:
v1: http://www.redhat.com/archives/libvir-list/2015-December/msg00731.html
Changes over v1:
1. Insert patch 1 to convert already pushed VSH_POOL into VIRSH_POOL since that was the review comment from this patch series
2. Insert patch 2 to move the POOL_OPT_COMMON to virsh.h for later patch reuse.
3. Use VIRSH_* instead of VSH_* for patches 1-8 (now 3-10)
4. Add usage of common domain for virsh-domain-monitor.c and virsh-snapshot.c (patches 11-12)
5. Add common macros for "network" and "interface" (patches 13-14).
NOTE: I figure to let this perculate for a bit as I'll assume there may be varying opinions on this... Also, the next couple of weeks heavy on people perhaps paying not paying close attention to the list.
I'm a bit conflicted. On one hand, it makes for less bulk in the code and assures consistency when the same option is used by multiple commands. On the other hand, as Peter said in a response to the original patch, it obscures things behind macros which can lead to confusion (and extra time backtracking).
Understood; however, at least they're more or less easily found especially if you use cscope. There are certainly some macros in the source code which are far more obfuscated!
If you're looking for a final "vote" from me, I guess I'd give it +1 (brevity wins this time), with these comments:
1) I assume that make check and make syntax-check have been run for each patch. :-)
yes, painfully ;-)
2) I agree with using "VIRSH_..." instead of "VSH_..." (I dislike the shortening of virsh to vsh - doing that just for 2 characters? What is this, twitter? :-P)
Newsflash - twitter is apparently expanding to allow 10000 characters. Maybe now I'll be able to start tweeting (yeah, right, not!)
3) I haven't looked at how is meshes with consistency of other macro names in virsh*, but it would make more sense to me if these were named
VIRSH_COMMON_OPT_BLAH
instead of
VIRSH_BLAH_OPT_COMMON
It reads better, and sticks the difference out at the end where it is more easily separated from the "common common" part.
I was following Peter's suggested naming: http://www.redhat.com/archives/libvir-list/2015-December/msg00675.html but I have no favorite... If others chime in and agree, then I'm fine with switching. thanks for the comments - John
John Ferlan (14): virsh: Covert VSH_POOL_ macro to VIRSH_POOL_ virsh: Move VIRSH_POOL_OPT_COMMON to virsh.h virsh: Create macro for common "domain" option virsh: Create macro for common "persistent" option virsh: Create macro for common "config" option virsh: Create macro for common "live" option virsh: Create macro for common "current" option virsh: Create macro for common "file" option virsh: Create macros for common "pool" options virsh: Create macros for common "vol" options virsh: Have domain-monitor use common "domain" option virsh: have snapshot use common "domain" option virsh: Create macro for common "network" option virsh: Create macro for common "interface" option
po/POTFILES.in | 1 + tools/virsh-domain-monitor.c | 77 +--- tools/virsh-domain.c | 911 +++++++++---------------------------------- tools/virsh-interface.c | 37 +- tools/virsh-network.c | 61 +-- tools/virsh-pool.c | 71 ++-- tools/virsh-snapshot.c | 60 +-- tools/virsh-volume.c | 148 ++----- tools/virsh.h | 17 + 9 files changed, 334 insertions(+), 1049 deletions(-)

On Thu, 2016-01-07 at 08:51 -0500, John Ferlan wrote:
3) I haven't looked at how is meshes with consistency of other macro names in virsh*, but it would make more sense to me if these were named VIRSH_COMMON_OPT_BLAH instead of VIRSH_BLAH_OPT_COMMON It reads better, and sticks the difference out at the end where it is more easily separated from the "common common" part. I was following Peter's suggested naming: http://www.redhat.com/archives/libvir-list/2015-December/msg00675.html but I have no favorite... If others chime in and agree, then I'm fine with switching.
I think Peter was merely suggesting that the macros should have a suitable prefix. VIRSH_COMMON_OPT_FOO makes the most sense to me, so +1 to Laine's proposal. On the other hand, we already have some VSH_POOL_*_OPT_COMMON in master, so changing the naming now would clash with what's already been committed. On the *other* other hand, however, I think the VSH_ prefix is not appropriate for those macros, since they are virsh specific and as such should be using the VIRSH_ prefix, so the best course of action IMHO would be to first fix what's already in master to use the VIRSH_COMMON_OPT_ prefix and then follow up with this series, making sure to adhere to the same naming convention. This is prime bikeshedding material, isn't it? :) Cheers. -- Andrea Bolognani Software Engineer - Virtualization Team
participants (3)
-
Andrea Bolognani
-
John Ferlan
-
Laine Stump