提交 b6fb1e24 编写于 作者: J John Ferlan

virsh: Create macro for common "domain" 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 which will be used to pass the translatable
helpstr since not all domain options can take the same string.

The majority of the options take 'N_("domain name, id or uuid")', so
create a separate macro with a _FULL suffix while those that do not
take the same string will use the VIRSH_COMMON_OPT_DOMAIN macro.
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 70c6e677
/*
* virsh-domain-monitor.c: Commands to monitor domain status
*
* 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
......@@ -40,6 +40,9 @@
#include "virxml.h"
#include "virstring.h"
#define VIRSH_COMMON_OPT_DOMAIN_FULL \
VIRSH_COMMON_OPT_DOMAIN(N_("domain name, id or uuid")) \
VIR_ENUM_DECL(virshDomainIOError)
VIR_ENUM_IMPL(virshDomainIOError,
VIR_DOMAIN_DISK_ERROR_LAST,
......@@ -281,11 +284,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_COMMON_OPT_DOMAIN_FULL,
{.name = "period",
.type = VSH_OT_INT,
.flags = VSH_OFLAG_REQ_OPT,
......@@ -402,11 +401,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_COMMON_OPT_DOMAIN_FULL,
{.name = "device",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
......@@ -457,11 +452,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_COMMON_OPT_DOMAIN_FULL,
{.name = "inactive",
.type = VSH_OT_BOOL,
.help = N_("get inactive rather than running configuration")
......@@ -579,11 +570,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_COMMON_OPT_DOMAIN_FULL,
{.name = "inactive",
.type = VSH_OT_BOOL,
.help = N_("get inactive rather than running configuration")
......@@ -684,11 +671,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_COMMON_OPT_DOMAIN_FULL,
{.name = "interface",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
......@@ -799,11 +782,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_COMMON_OPT_DOMAIN_FULL,
{.name = NULL}
};
......@@ -856,11 +835,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_COMMON_OPT_DOMAIN_FULL,
{.name = "device",
.type = VSH_OT_STRING,
.flags = VSH_OFLAG_EMPTY_OK,
......@@ -1046,11 +1021,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_COMMON_OPT_DOMAIN_FULL,
{.name = "interface",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
......@@ -1123,11 +1094,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_COMMON_OPT_DOMAIN_FULL,
{.name = NULL}
};
......@@ -1188,11 +1155,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_COMMON_OPT_DOMAIN_FULL,
{.name = NULL}
};
......@@ -1331,11 +1294,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_COMMON_OPT_DOMAIN_FULL,
{.name = "reason",
.type = VSH_OT_BOOL,
.help = N_("also print reason for the state")
......@@ -1387,11 +1346,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_COMMON_OPT_DOMAIN_FULL,
{.name = "now",
.type = VSH_OT_BOOL,
.help = N_("set to the time of the host running virsh")
......@@ -2208,10 +2163,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_COMMON_OPT_DOMAIN_FULL,
{.name = "interface",
.type = VSH_OT_STRING,
.flags = VSH_OFLAG_NONE,
......
此差异已折叠。
/*
* virsh-snapshot.c: Commands to manage domain snapshot
*
* 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
......@@ -42,6 +42,9 @@
#include "virxml.h"
#include "conf/snapshot_conf.h"
#define VIRSH_COMMON_OPT_DOMAIN_FULL \
VIRSH_COMMON_OPT_DOMAIN(N_("domain name, id or uuid")) \
/* Helper for snapshot-create and snapshot-create-as */
static bool
virshSnapshotCreate(vshControl *ctl, virDomainPtr dom, const char *buffer,
......@@ -123,11 +126,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_COMMON_OPT_DOMAIN_FULL,
{.name = "xmlfile",
.type = VSH_OT_STRING,
.help = N_("domain snapshot XML")
......@@ -328,11 +327,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_COMMON_OPT_DOMAIN_FULL,
{.name = "name",
.type = VSH_OT_STRING,
.help = N_("name of snapshot")
......@@ -524,11 +519,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_COMMON_OPT_DOMAIN_FULL,
{.name = "snapshotname",
.type = VSH_OT_STRING,
.help = N_("snapshot name")
......@@ -645,11 +636,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_COMMON_OPT_DOMAIN_FULL,
{.name = "name",
.type = VSH_OT_BOOL,
.help = N_("list the name, rather than the full xml")
......@@ -882,11 +869,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_COMMON_OPT_DOMAIN_FULL,
{.name = "snapshotname",
.type = VSH_OT_STRING,
.help = N_("snapshot name")
......@@ -1441,11 +1424,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_COMMON_OPT_DOMAIN_FULL,
{.name = "parent",
.type = VSH_OT_BOOL,
.help = N_("add a column showing parent snapshot")
......@@ -1705,11 +1684,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_COMMON_OPT_DOMAIN_FULL,
{.name = "snapshotname",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
......@@ -1773,11 +1748,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_COMMON_OPT_DOMAIN_FULL,
{.name = "snapshotname",
.type = VSH_OT_STRING,
.help = N_("find parent of snapshot name")
......@@ -1841,11 +1812,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_COMMON_OPT_DOMAIN_FULL,
{.name = "snapshotname",
.type = VSH_OT_STRING,
.help = N_("snapshot name")
......@@ -1934,11 +1901,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_COMMON_OPT_DOMAIN_FULL,
{.name = "snapshotname",
.type = VSH_OT_STRING,
.help = N_("snapshot name")
......
......@@ -69,6 +69,13 @@
.help = _helpstr \
} \
# define VIRSH_COMMON_OPT_DOMAIN(_helpstr) \
{.name = "domain", \
.type = VSH_OT_DATA, \
.flags = VSH_OFLAG_REQ, \
.help = _helpstr \
} \
typedef struct _virshControl virshControl;
typedef virshControl *virshControlPtr;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册