From: John Ferlan Date: Sat, 9 Jan 2016 13:36:29 +0000 (-0500) Subject: virsh: Create macro for common "file" option X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=febf69b5e9fa5cff1baea8ed2c6da13d5cb32722;p=libvirt.git virsh: Create macro for common "file" option Rather than continually cut-n-paste the strings into each command, create a common macro to be used generically. The macro will take a single argument _helpstr for the less common help string for each command option. Note that only file options using "OT_DATA" and "OFLAG_REQ" will be replace - others are left as is. Signed-off-by: John Ferlan --- diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 456e5969bc..d239ba82a3 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -224,11 +224,7 @@ static const vshCmdInfo info_attach_device[] = { static const vshCmdOptDef opts_attach_device[] = { VIRSH_COMMON_OPT_DOMAIN_FULL, - {.name = "file", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("XML file") - }, + VIRSH_COMMON_OPT_FILE(N_("XML file")), VIRSH_COMMON_OPT_DOMAIN_PERSISTENT, VIRSH_COMMON_OPT_DOMAIN_CONFIG, VIRSH_COMMON_OPT_DOMAIN_LIVE, @@ -4133,11 +4129,7 @@ static const vshCmdInfo info_save[] = { static const vshCmdOptDef opts_save[] = { VIRSH_COMMON_OPT_DOMAIN_FULL, - {.name = "file", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("where to save the data") - }, + VIRSH_COMMON_OPT_FILE(N_("where to save the data")), {.name = "bypass-cache", .type = VSH_OT_BOOL, .help = N_("avoid file system cache when saving") @@ -4394,11 +4386,7 @@ static const vshCmdInfo info_save_image_dumpxml[] = { }; static const vshCmdOptDef opts_save_image_dumpxml[] = { - {.name = "file", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("saved state file to read") - }, + VIRSH_COMMON_OPT_FILE(N_("saved state file to read")), {.name = "security-info", .type = VSH_OT_BOOL, .help = N_("include security sensitive information in XML dump") @@ -4447,11 +4435,7 @@ static const vshCmdInfo info_save_image_define[] = { }; static const vshCmdOptDef opts_save_image_define[] = { - {.name = "file", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("saved state file to modify") - }, + VIRSH_COMMON_OPT_FILE(N_("saved state file to modify")), {.name = "xml", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -4519,11 +4503,7 @@ static const vshCmdInfo info_save_image_edit[] = { }; static const vshCmdOptDef opts_save_image_edit[] = { - {.name = "file", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("saved state file to edit") - }, + VIRSH_COMMON_OPT_FILE(N_("saved state file to edit")), {.name = "running", .type = VSH_OT_BOOL, .help = N_("set domain to be running on restore") @@ -5008,11 +4988,7 @@ static const vshCmdInfo info_restore[] = { }; static const vshCmdOptDef opts_restore[] = { - {.name = "file", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("the state to restore") - }, + VIRSH_COMMON_OPT_FILE(N_("the state to restore")), {.name = "bypass-cache", .type = VSH_OT_BOOL, .help = N_("avoid file system cache when restoring") @@ -5089,11 +5065,7 @@ static const vshCmdInfo info_dump[] = { static const vshCmdOptDef opts_dump[] = { VIRSH_COMMON_OPT_DOMAIN_FULL, - {.name = "file", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("where to dump the core") - }, + VIRSH_COMMON_OPT_FILE(N_("where to dump the core")), VIRSH_COMMON_OPT_LIVE(N_("perform a live core dump if supported")), {.name = "crash", .type = VSH_OT_BOOL, @@ -7038,11 +7010,7 @@ static const vshCmdInfo info_cpu_compare[] = { }; static const vshCmdOptDef opts_cpu_compare[] = { - {.name = "file", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("file containing an XML CPU description") - }, + VIRSH_COMMON_OPT_FILE(N_("file containing an XML CPU description")), {.name = "error", .type = VSH_OT_BOOL, .help = N_("report error if CPUs are incompatible") @@ -7140,11 +7108,7 @@ static const vshCmdInfo info_cpu_baseline[] = { }; static const vshCmdOptDef opts_cpu_baseline[] = { - {.name = "file", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("file containing XML CPU descriptions") - }, + VIRSH_COMMON_OPT_FILE(N_("file containing XML CPU descriptions")), {.name = "features", .type = VSH_OT_BOOL, .help = N_("Show features that are part of the CPU model type") @@ -7442,11 +7406,7 @@ static const vshCmdInfo info_create[] = { }; static const vshCmdOptDef opts_create[] = { - {.name = "file", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("file containing an XML domain description") - }, + VIRSH_COMMON_OPT_FILE(N_("file containing an XML domain description")), #ifndef WIN32 {.name = "console", .type = VSH_OT_BOOL, @@ -7542,11 +7502,7 @@ static const vshCmdInfo info_define[] = { }; static const vshCmdOptDef opts_define[] = { - {.name = "file", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("file containing an XML domain description") - }, + VIRSH_COMMON_OPT_FILE(N_("file containing an XML domain description")), {.name = "validate", .type = VSH_OT_BOOL, .help = N_("validate the XML against the schema") @@ -10666,11 +10622,7 @@ static const vshCmdInfo info_detach_device[] = { static const vshCmdOptDef opts_detach_device[] = { VIRSH_COMMON_OPT_DOMAIN_FULL, - {.name = "file", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("XML file") - }, + VIRSH_COMMON_OPT_FILE(N_("XML file")), VIRSH_COMMON_OPT_DOMAIN_PERSISTENT, VIRSH_COMMON_OPT_DOMAIN_CONFIG, VIRSH_COMMON_OPT_DOMAIN_LIVE, @@ -10751,11 +10703,7 @@ static const vshCmdInfo info_update_device[] = { static const vshCmdOptDef opts_update_device[] = { VIRSH_COMMON_OPT_DOMAIN_FULL, - {.name = "file", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("XML file") - }, + VIRSH_COMMON_OPT_FILE(N_("XML file")), VIRSH_COMMON_OPT_DOMAIN_PERSISTENT, VIRSH_COMMON_OPT_DOMAIN_CONFIG, VIRSH_COMMON_OPT_DOMAIN_LIVE, diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c index b69c685860..c36b92d2c6 100644 --- a/tools/virsh-interface.c +++ b/tools/virsh-interface.c @@ -1,7 +1,7 @@ /* * virsh-interface.c: Commands to manage host interface * - * Copyright (C) 2005, 2007-2015 Red Hat, Inc. + * Copyright (C) 2005, 2007-2016 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -518,11 +518,7 @@ static const vshCmdInfo info_interface_define[] = { }; static const vshCmdOptDef opts_interface_define[] = { - {.name = "file", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("file containing an XML interface description") - }, + VIRSH_COMMON_OPT_FILE(N_("file containing an XML interface description")), {.name = NULL} }; diff --git a/tools/virsh-network.c b/tools/virsh-network.c index 24e80490c6..153947a0f1 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -142,11 +142,7 @@ static const vshCmdInfo info_network_create[] = { }; static const vshCmdOptDef opts_network_create[] = { - {.name = "file", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("file containing an XML network description") - }, + VIRSH_COMMON_OPT_FILE(N_("file containing an XML network description")), {.name = NULL} }; @@ -194,11 +190,7 @@ static const vshCmdInfo info_network_define[] = { }; static const vshCmdOptDef opts_network_define[] = { - {.name = "file", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("file containing an XML network description") - }, + VIRSH_COMMON_OPT_FILE(N_("file containing an XML network description")), {.name = NULL} }; diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index bfe507ed60..a715b611e7 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -1,7 +1,7 @@ /* * virsh-nodedev.c: Commands in node device group * - * Copyright (C) 2005, 2007-2013 Red Hat, Inc. + * Copyright (C) 2005, 2007-2016 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -50,11 +50,8 @@ static const vshCmdInfo info_node_device_create[] = { }; static const vshCmdOptDef opts_node_device_create[] = { - {.name = "file", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("file containing an XML description of the device") - }, + VIRSH_COMMON_OPT_FILE(N_("file containing an XML description " + "of the device")), {.name = NULL} }; diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c index 7732da8f99..6e6582d4d8 100644 --- a/tools/virsh-nwfilter.c +++ b/tools/virsh-nwfilter.c @@ -1,7 +1,7 @@ /* * virsh-nwfilter.c: Commands to manage network filters * - * Copyright (C) 2005, 2007-2015 Red Hat, Inc. + * Copyright (C) 2005, 2007-2016 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -85,11 +85,8 @@ static const vshCmdInfo info_nwfilter_define[] = { }; static const vshCmdOptDef opts_nwfilter_define[] = { - {.name = "file", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("file containing an XML network filter description") - }, + VIRSH_COMMON_OPT_FILE(N_("file containing an XML network " + "filter description")), {.name = NULL} }; diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index 5e7dbcd07f..f9299e21f0 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -36,13 +36,6 @@ #define VIRSH_COMMON_OPT_POOL_FULL \ VIRSH_COMMON_OPT_POOL(N_("pool name or uuid")) \ -#define VIRSH_COMMON_OPT_POOL_FILE \ - {.name = "file", \ - .type = VSH_OT_DATA, \ - .flags = VSH_OFLAG_REQ, \ - .help = N_("file containing an XML pool description") \ - } \ - #define VIRSH_COMMON_OPT_POOL_BUILD \ {.name = "build", \ .type = VSH_OT_BOOL, \ @@ -237,7 +230,7 @@ static const vshCmdInfo info_pool_create[] = { }; static const vshCmdOptDef opts_pool_create[] = { - VIRSH_COMMON_OPT_POOL_FILE, + VIRSH_COMMON_OPT_FILE(N_("file containing an XML pool description")), VIRSH_COMMON_OPT_POOL_BUILD, VIRSH_COMMON_OPT_POOL_NO_OVERWRITE, VIRSH_COMMON_OPT_POOL_OVERWRITE, @@ -480,7 +473,7 @@ static const vshCmdInfo info_pool_define[] = { }; static const vshCmdOptDef opts_pool_define[] = { - VIRSH_COMMON_OPT_POOL_FILE, + VIRSH_COMMON_OPT_FILE(N_("file containing an XML pool description")), {.name = NULL} }; diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c index db900c0ce3..087c2ed23a 100644 --- a/tools/virsh-secret.c +++ b/tools/virsh-secret.c @@ -1,7 +1,7 @@ /* * virsh-secret.c: Commands to manage secret * - * Copyright (C) 2005, 2007-2015 Red Hat, Inc. + * Copyright (C) 2005, 2007-2016 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -73,11 +73,7 @@ static const vshCmdInfo info_secret_define[] = { }; static const vshCmdOptDef opts_secret_define[] = { - {.name = "file", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("file containing secret attributes in XML") - }, + VIRSH_COMMON_OPT_FILE(N_("file containing secret attributes in XML")), {.name = NULL} }; diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index 42862ee4b1..a1bf19a984 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -1,7 +1,7 @@ /* * virsh-volume.c: Commands to manage storage volume * - * Copyright (C) 2005, 2007-2014 Red Hat, Inc. + * Copyright (C) 2005, 2007-2016 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -362,11 +362,7 @@ static const vshCmdInfo info_vol_create[] = { static const vshCmdOptDef opts_vol_create[] = { VIRSH_COMMON_OPT_POOL_NAME, - {.name = "file", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("file containing an XML vol description") - }, + VIRSH_COMMON_OPT_FILE(N_("file containing an XML vol description")), {.name = "prealloc-metadata", .type = VSH_OT_BOOL, .help = N_("preallocate metadata (for qcow2 instead of full allocation)") @@ -428,11 +424,7 @@ static const vshCmdInfo info_vol_create_from[] = { static const vshCmdOptDef opts_vol_create_from[] = { VIRSH_COMMON_OPT_POOL_FULL, - {.name = "file", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("file containing an XML vol description") - }, + VIRSH_COMMON_OPT_FILE(N_("file containing an XML vol description")), {.name = "vol", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -653,11 +645,7 @@ static const vshCmdOptDef opts_vol_upload[] = { .flags = VSH_OFLAG_REQ, .help = N_("vol name, key or path") }, - {.name = "file", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("file") - }, + VIRSH_COMMON_OPT_FILE(N_("file")), VIRSH_COMMON_OPT_POOL_OPTIONAL, {.name = "offset", .type = VSH_OT_INT, @@ -764,11 +752,7 @@ static const vshCmdOptDef opts_vol_download[] = { .flags = VSH_OFLAG_REQ, .help = N_("vol name, key or path") }, - {.name = "file", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("file") - }, + VIRSH_COMMON_OPT_FILE(N_("file")), VIRSH_COMMON_OPT_POOL_OPTIONAL, {.name = "offset", .type = VSH_OT_INT, diff --git a/tools/virsh.h b/tools/virsh.h index ba7e31457c..94d012aa36 100644 --- a/tools/virsh.h +++ b/tools/virsh.h @@ -94,6 +94,13 @@ .help = _helpstr \ } \ +# define VIRSH_COMMON_OPT_FILE(_helpstr) \ + {.name = "file", \ + .type = VSH_OT_DATA, \ + .flags = VSH_OFLAG_REQ, \ + .help = _helpstr \ + } \ + typedef struct _virshControl virshControl; typedef virshControl *virshControlPtr;