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 <jferlan@redhat.com>
This commit is contained in:
John Ferlan 2016-01-09 08:36:29 -05:00
parent 5b42dbed98
commit febf69b5e9
9 changed files with 39 additions and 129 deletions

View File

@ -224,11 +224,7 @@ static const vshCmdInfo info_attach_device[] = {
static const vshCmdOptDef opts_attach_device[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL,
{.name = "file",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("XML file")
},
VIRSH_COMMON_OPT_FILE(N_("XML file")),
VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
VIRSH_COMMON_OPT_DOMAIN_CONFIG,
VIRSH_COMMON_OPT_DOMAIN_LIVE,
@ -4133,11 +4129,7 @@ static const vshCmdInfo info_save[] = {
static const vshCmdOptDef opts_save[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL,
{.name = "file",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("where to save the data")
},
VIRSH_COMMON_OPT_FILE(N_("where to save the data")),
{.name = "bypass-cache",
.type = VSH_OT_BOOL,
.help = N_("avoid file system cache when saving")
@ -4394,11 +4386,7 @@ static const vshCmdInfo info_save_image_dumpxml[] = {
};
static const vshCmdOptDef opts_save_image_dumpxml[] = {
{.name = "file",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("saved state file to read")
},
VIRSH_COMMON_OPT_FILE(N_("saved state file to read")),
{.name = "security-info",
.type = VSH_OT_BOOL,
.help = N_("include security sensitive information in XML dump")
@ -4447,11 +4435,7 @@ static const vshCmdInfo info_save_image_define[] = {
};
static const vshCmdOptDef opts_save_image_define[] = {
{.name = "file",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("saved state file to modify")
},
VIRSH_COMMON_OPT_FILE(N_("saved state file to modify")),
{.name = "xml",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
@ -4519,11 +4503,7 @@ static const vshCmdInfo info_save_image_edit[] = {
};
static const vshCmdOptDef opts_save_image_edit[] = {
{.name = "file",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("saved state file to edit")
},
VIRSH_COMMON_OPT_FILE(N_("saved state file to edit")),
{.name = "running",
.type = VSH_OT_BOOL,
.help = N_("set domain to be running on restore")
@ -5008,11 +4988,7 @@ static const vshCmdInfo info_restore[] = {
};
static const vshCmdOptDef opts_restore[] = {
{.name = "file",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("the state to restore")
},
VIRSH_COMMON_OPT_FILE(N_("the state to restore")),
{.name = "bypass-cache",
.type = VSH_OT_BOOL,
.help = N_("avoid file system cache when restoring")
@ -5089,11 +5065,7 @@ static const vshCmdInfo info_dump[] = {
static const vshCmdOptDef opts_dump[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL,
{.name = "file",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("where to dump the core")
},
VIRSH_COMMON_OPT_FILE(N_("where to dump the core")),
VIRSH_COMMON_OPT_LIVE(N_("perform a live core dump if supported")),
{.name = "crash",
.type = VSH_OT_BOOL,
@ -7038,11 +7010,7 @@ static const vshCmdInfo info_cpu_compare[] = {
};
static const vshCmdOptDef opts_cpu_compare[] = {
{.name = "file",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("file containing an XML CPU description")
},
VIRSH_COMMON_OPT_FILE(N_("file containing an XML CPU description")),
{.name = "error",
.type = VSH_OT_BOOL,
.help = N_("report error if CPUs are incompatible")
@ -7140,11 +7108,7 @@ static const vshCmdInfo info_cpu_baseline[] = {
};
static const vshCmdOptDef opts_cpu_baseline[] = {
{.name = "file",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("file containing XML CPU descriptions")
},
VIRSH_COMMON_OPT_FILE(N_("file containing XML CPU descriptions")),
{.name = "features",
.type = VSH_OT_BOOL,
.help = N_("Show features that are part of the CPU model type")
@ -7442,11 +7406,7 @@ static const vshCmdInfo info_create[] = {
};
static const vshCmdOptDef opts_create[] = {
{.name = "file",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("file containing an XML domain description")
},
VIRSH_COMMON_OPT_FILE(N_("file containing an XML domain description")),
#ifndef WIN32
{.name = "console",
.type = VSH_OT_BOOL,
@ -7542,11 +7502,7 @@ static const vshCmdInfo info_define[] = {
};
static const vshCmdOptDef opts_define[] = {
{.name = "file",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("file containing an XML domain description")
},
VIRSH_COMMON_OPT_FILE(N_("file containing an XML domain description")),
{.name = "validate",
.type = VSH_OT_BOOL,
.help = N_("validate the XML against the schema")
@ -10666,11 +10622,7 @@ static const vshCmdInfo info_detach_device[] = {
static const vshCmdOptDef opts_detach_device[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL,
{.name = "file",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("XML file")
},
VIRSH_COMMON_OPT_FILE(N_("XML file")),
VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
VIRSH_COMMON_OPT_DOMAIN_CONFIG,
VIRSH_COMMON_OPT_DOMAIN_LIVE,
@ -10751,11 +10703,7 @@ static const vshCmdInfo info_update_device[] = {
static const vshCmdOptDef opts_update_device[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL,
{.name = "file",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("XML file")
},
VIRSH_COMMON_OPT_FILE(N_("XML file")),
VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
VIRSH_COMMON_OPT_DOMAIN_CONFIG,
VIRSH_COMMON_OPT_DOMAIN_LIVE,

View File

@ -1,7 +1,7 @@
/*
* virsh-interface.c: Commands to manage host interface
*
* Copyright (C) 2005, 2007-2015 Red Hat, Inc.
* Copyright (C) 2005, 2007-2016 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -518,11 +518,7 @@ static const vshCmdInfo info_interface_define[] = {
};
static const vshCmdOptDef opts_interface_define[] = {
{.name = "file",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("file containing an XML interface description")
},
VIRSH_COMMON_OPT_FILE(N_("file containing an XML interface description")),
{.name = NULL}
};

View File

@ -142,11 +142,7 @@ static const vshCmdInfo info_network_create[] = {
};
static const vshCmdOptDef opts_network_create[] = {
{.name = "file",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("file containing an XML network description")
},
VIRSH_COMMON_OPT_FILE(N_("file containing an XML network description")),
{.name = NULL}
};
@ -194,11 +190,7 @@ static const vshCmdInfo info_network_define[] = {
};
static const vshCmdOptDef opts_network_define[] = {
{.name = "file",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("file containing an XML network description")
},
VIRSH_COMMON_OPT_FILE(N_("file containing an XML network description")),
{.name = NULL}
};

View File

@ -1,7 +1,7 @@
/*
* virsh-nodedev.c: Commands in node device group
*
* Copyright (C) 2005, 2007-2013 Red Hat, Inc.
* Copyright (C) 2005, 2007-2016 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -50,11 +50,8 @@ static const vshCmdInfo info_node_device_create[] = {
};
static const vshCmdOptDef opts_node_device_create[] = {
{.name = "file",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("file containing an XML description of the device")
},
VIRSH_COMMON_OPT_FILE(N_("file containing an XML description "
"of the device")),
{.name = NULL}
};

View File

@ -1,7 +1,7 @@
/*
* virsh-nwfilter.c: Commands to manage network filters
*
* Copyright (C) 2005, 2007-2015 Red Hat, Inc.
* Copyright (C) 2005, 2007-2016 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -85,11 +85,8 @@ static const vshCmdInfo info_nwfilter_define[] = {
};
static const vshCmdOptDef opts_nwfilter_define[] = {
{.name = "file",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("file containing an XML network filter description")
},
VIRSH_COMMON_OPT_FILE(N_("file containing an XML network "
"filter description")),
{.name = NULL}
};

View File

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

View File

@ -1,7 +1,7 @@
/*
* virsh-secret.c: Commands to manage secret
*
* Copyright (C) 2005, 2007-2015 Red Hat, Inc.
* Copyright (C) 2005, 2007-2016 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -73,11 +73,7 @@ static const vshCmdInfo info_secret_define[] = {
};
static const vshCmdOptDef opts_secret_define[] = {
{.name = "file",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("file containing secret attributes in XML")
},
VIRSH_COMMON_OPT_FILE(N_("file containing secret attributes in XML")),
{.name = NULL}
};

View File

@ -1,7 +1,7 @@
/*
* virsh-volume.c: Commands to manage storage volume
*
* Copyright (C) 2005, 2007-2014 Red Hat, Inc.
* Copyright (C) 2005, 2007-2016 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -362,11 +362,7 @@ static const vshCmdInfo info_vol_create[] = {
static const vshCmdOptDef opts_vol_create[] = {
VIRSH_COMMON_OPT_POOL_NAME,
{.name = "file",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("file containing an XML vol description")
},
VIRSH_COMMON_OPT_FILE(N_("file containing an XML vol description")),
{.name = "prealloc-metadata",
.type = VSH_OT_BOOL,
.help = N_("preallocate metadata (for qcow2 instead of full allocation)")
@ -428,11 +424,7 @@ static const vshCmdInfo info_vol_create_from[] = {
static const vshCmdOptDef opts_vol_create_from[] = {
VIRSH_COMMON_OPT_POOL_FULL,
{.name = "file",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("file containing an XML vol description")
},
VIRSH_COMMON_OPT_FILE(N_("file containing an XML vol description")),
{.name = "vol",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
@ -653,11 +645,7 @@ static const vshCmdOptDef opts_vol_upload[] = {
.flags = VSH_OFLAG_REQ,
.help = N_("vol name, key or path")
},
{.name = "file",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("file")
},
VIRSH_COMMON_OPT_FILE(N_("file")),
VIRSH_COMMON_OPT_POOL_OPTIONAL,
{.name = "offset",
.type = VSH_OT_INT,
@ -764,11 +752,7 @@ static const vshCmdOptDef opts_vol_download[] = {
.flags = VSH_OFLAG_REQ,
.help = N_("vol name, key or path")
},
{.name = "file",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("file")
},
VIRSH_COMMON_OPT_FILE(N_("file")),
VIRSH_COMMON_OPT_POOL_OPTIONAL,
{.name = "offset",
.type = VSH_OT_INT,

View File

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