提交 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 * 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 * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
...@@ -40,6 +40,9 @@ ...@@ -40,6 +40,9 @@
#include "virxml.h" #include "virxml.h"
#include "virstring.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_DECL(virshDomainIOError)
VIR_ENUM_IMPL(virshDomainIOError, VIR_ENUM_IMPL(virshDomainIOError,
VIR_DOMAIN_DISK_ERROR_LAST, VIR_DOMAIN_DISK_ERROR_LAST,
...@@ -281,11 +284,7 @@ static const vshCmdInfo info_dommemstat[] = { ...@@ -281,11 +284,7 @@ static const vshCmdInfo info_dommemstat[] = {
}; };
static const vshCmdOptDef opts_dommemstat[] = { static const vshCmdOptDef opts_dommemstat[] = {
{.name = "domain", VIRSH_COMMON_OPT_DOMAIN_FULL,
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("domain name, id or uuid")
},
{.name = "period", {.name = "period",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.flags = VSH_OFLAG_REQ_OPT, .flags = VSH_OFLAG_REQ_OPT,
...@@ -402,11 +401,7 @@ static const vshCmdInfo info_domblkinfo[] = { ...@@ -402,11 +401,7 @@ static const vshCmdInfo info_domblkinfo[] = {
}; };
static const vshCmdOptDef opts_domblkinfo[] = { static const vshCmdOptDef opts_domblkinfo[] = {
{.name = "domain", VIRSH_COMMON_OPT_DOMAIN_FULL,
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("domain name, id or uuid")
},
{.name = "device", {.name = "device",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
...@@ -457,11 +452,7 @@ static const vshCmdInfo info_domblklist[] = { ...@@ -457,11 +452,7 @@ static const vshCmdInfo info_domblklist[] = {
}; };
static const vshCmdOptDef opts_domblklist[] = { static const vshCmdOptDef opts_domblklist[] = {
{.name = "domain", VIRSH_COMMON_OPT_DOMAIN_FULL,
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("domain name, id or uuid")
},
{.name = "inactive", {.name = "inactive",
.type = VSH_OT_BOOL, .type = VSH_OT_BOOL,
.help = N_("get inactive rather than running configuration") .help = N_("get inactive rather than running configuration")
...@@ -579,11 +570,7 @@ static const vshCmdInfo info_domiflist[] = { ...@@ -579,11 +570,7 @@ static const vshCmdInfo info_domiflist[] = {
}; };
static const vshCmdOptDef opts_domiflist[] = { static const vshCmdOptDef opts_domiflist[] = {
{.name = "domain", VIRSH_COMMON_OPT_DOMAIN_FULL,
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("domain name, id or uuid")
},
{.name = "inactive", {.name = "inactive",
.type = VSH_OT_BOOL, .type = VSH_OT_BOOL,
.help = N_("get inactive rather than running configuration") .help = N_("get inactive rather than running configuration")
...@@ -684,11 +671,7 @@ static const vshCmdInfo info_domif_getlink[] = { ...@@ -684,11 +671,7 @@ static const vshCmdInfo info_domif_getlink[] = {
}; };
static const vshCmdOptDef opts_domif_getlink[] = { static const vshCmdOptDef opts_domif_getlink[] = {
{.name = "domain", VIRSH_COMMON_OPT_DOMAIN_FULL,
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("domain name, id or uuid")
},
{.name = "interface", {.name = "interface",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
...@@ -799,11 +782,7 @@ static const vshCmdInfo info_domcontrol[] = { ...@@ -799,11 +782,7 @@ static const vshCmdInfo info_domcontrol[] = {
}; };
static const vshCmdOptDef opts_domcontrol[] = { static const vshCmdOptDef opts_domcontrol[] = {
{.name = "domain", VIRSH_COMMON_OPT_DOMAIN_FULL,
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("domain name, id or uuid")
},
{.name = NULL} {.name = NULL}
}; };
...@@ -856,11 +835,7 @@ static const vshCmdInfo info_domblkstat[] = { ...@@ -856,11 +835,7 @@ static const vshCmdInfo info_domblkstat[] = {
}; };
static const vshCmdOptDef opts_domblkstat[] = { static const vshCmdOptDef opts_domblkstat[] = {
{.name = "domain", VIRSH_COMMON_OPT_DOMAIN_FULL,
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("domain name, id or uuid")
},
{.name = "device", {.name = "device",
.type = VSH_OT_STRING, .type = VSH_OT_STRING,
.flags = VSH_OFLAG_EMPTY_OK, .flags = VSH_OFLAG_EMPTY_OK,
...@@ -1046,11 +1021,7 @@ static const vshCmdInfo info_domifstat[] = { ...@@ -1046,11 +1021,7 @@ static const vshCmdInfo info_domifstat[] = {
}; };
static const vshCmdOptDef opts_domifstat[] = { static const vshCmdOptDef opts_domifstat[] = {
{.name = "domain", VIRSH_COMMON_OPT_DOMAIN_FULL,
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("domain name, id or uuid")
},
{.name = "interface", {.name = "interface",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
...@@ -1123,11 +1094,7 @@ static const vshCmdInfo info_domblkerror[] = { ...@@ -1123,11 +1094,7 @@ static const vshCmdInfo info_domblkerror[] = {
}; };
static const vshCmdOptDef opts_domblkerror[] = { static const vshCmdOptDef opts_domblkerror[] = {
{.name = "domain", VIRSH_COMMON_OPT_DOMAIN_FULL,
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("domain name, id, or uuid")
},
{.name = NULL} {.name = NULL}
}; };
...@@ -1188,11 +1155,7 @@ static const vshCmdInfo info_dominfo[] = { ...@@ -1188,11 +1155,7 @@ static const vshCmdInfo info_dominfo[] = {
}; };
static const vshCmdOptDef opts_dominfo[] = { static const vshCmdOptDef opts_dominfo[] = {
{.name = "domain", VIRSH_COMMON_OPT_DOMAIN_FULL,
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("domain name, id or uuid")
},
{.name = NULL} {.name = NULL}
}; };
...@@ -1331,11 +1294,7 @@ static const vshCmdInfo info_domstate[] = { ...@@ -1331,11 +1294,7 @@ static const vshCmdInfo info_domstate[] = {
}; };
static const vshCmdOptDef opts_domstate[] = { static const vshCmdOptDef opts_domstate[] = {
{.name = "domain", VIRSH_COMMON_OPT_DOMAIN_FULL,
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("domain name, id or uuid")
},
{.name = "reason", {.name = "reason",
.type = VSH_OT_BOOL, .type = VSH_OT_BOOL,
.help = N_("also print reason for the state") .help = N_("also print reason for the state")
...@@ -1387,11 +1346,7 @@ static const vshCmdInfo info_domtime[] = { ...@@ -1387,11 +1346,7 @@ static const vshCmdInfo info_domtime[] = {
}; };
static const vshCmdOptDef opts_domtime[] = { static const vshCmdOptDef opts_domtime[] = {
{.name = "domain", VIRSH_COMMON_OPT_DOMAIN_FULL,
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("domain name, id or uuid")
},
{.name = "now", {.name = "now",
.type = VSH_OT_BOOL, .type = VSH_OT_BOOL,
.help = N_("set to the time of the host running virsh") .help = N_("set to the time of the host running virsh")
...@@ -2208,10 +2163,7 @@ static const vshCmdInfo info_domifaddr[] = { ...@@ -2208,10 +2163,7 @@ static const vshCmdInfo info_domifaddr[] = {
}; };
static const vshCmdOptDef opts_domifaddr[] = { static const vshCmdOptDef opts_domifaddr[] = {
{.name = "domain", VIRSH_COMMON_OPT_DOMAIN_FULL,
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("domain name, id or uuid")},
{.name = "interface", {.name = "interface",
.type = VSH_OT_STRING, .type = VSH_OT_STRING,
.flags = VSH_OFLAG_NONE, .flags = VSH_OFLAG_NONE,
......
此差异已折叠。
/* /*
* virsh-snapshot.c: Commands to manage domain snapshot * 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 * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
...@@ -42,6 +42,9 @@ ...@@ -42,6 +42,9 @@
#include "virxml.h" #include "virxml.h"
#include "conf/snapshot_conf.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 */ /* Helper for snapshot-create and snapshot-create-as */
static bool static bool
virshSnapshotCreate(vshControl *ctl, virDomainPtr dom, const char *buffer, virshSnapshotCreate(vshControl *ctl, virDomainPtr dom, const char *buffer,
...@@ -123,11 +126,7 @@ static const vshCmdInfo info_snapshot_create[] = { ...@@ -123,11 +126,7 @@ static const vshCmdInfo info_snapshot_create[] = {
}; };
static const vshCmdOptDef opts_snapshot_create[] = { static const vshCmdOptDef opts_snapshot_create[] = {
{.name = "domain", VIRSH_COMMON_OPT_DOMAIN_FULL,
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("domain name, id or uuid")
},
{.name = "xmlfile", {.name = "xmlfile",
.type = VSH_OT_STRING, .type = VSH_OT_STRING,
.help = N_("domain snapshot XML") .help = N_("domain snapshot XML")
...@@ -328,11 +327,7 @@ static const vshCmdInfo info_snapshot_create_as[] = { ...@@ -328,11 +327,7 @@ static const vshCmdInfo info_snapshot_create_as[] = {
}; };
static const vshCmdOptDef opts_snapshot_create_as[] = { static const vshCmdOptDef opts_snapshot_create_as[] = {
{.name = "domain", VIRSH_COMMON_OPT_DOMAIN_FULL,
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("domain name, id or uuid")
},
{.name = "name", {.name = "name",
.type = VSH_OT_STRING, .type = VSH_OT_STRING,
.help = N_("name of snapshot") .help = N_("name of snapshot")
...@@ -524,11 +519,7 @@ static const vshCmdInfo info_snapshot_edit[] = { ...@@ -524,11 +519,7 @@ static const vshCmdInfo info_snapshot_edit[] = {
}; };
static const vshCmdOptDef opts_snapshot_edit[] = { static const vshCmdOptDef opts_snapshot_edit[] = {
{.name = "domain", VIRSH_COMMON_OPT_DOMAIN_FULL,
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("domain name, id or uuid")
},
{.name = "snapshotname", {.name = "snapshotname",
.type = VSH_OT_STRING, .type = VSH_OT_STRING,
.help = N_("snapshot name") .help = N_("snapshot name")
...@@ -645,11 +636,7 @@ static const vshCmdInfo info_snapshot_current[] = { ...@@ -645,11 +636,7 @@ static const vshCmdInfo info_snapshot_current[] = {
}; };
static const vshCmdOptDef opts_snapshot_current[] = { static const vshCmdOptDef opts_snapshot_current[] = {
{.name = "domain", VIRSH_COMMON_OPT_DOMAIN_FULL,
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("domain name, id or uuid")
},
{.name = "name", {.name = "name",
.type = VSH_OT_BOOL, .type = VSH_OT_BOOL,
.help = N_("list the name, rather than the full xml") .help = N_("list the name, rather than the full xml")
...@@ -882,11 +869,7 @@ static const vshCmdInfo info_snapshot_info[] = { ...@@ -882,11 +869,7 @@ static const vshCmdInfo info_snapshot_info[] = {
}; };
static const vshCmdOptDef opts_snapshot_info[] = { static const vshCmdOptDef opts_snapshot_info[] = {
{.name = "domain", VIRSH_COMMON_OPT_DOMAIN_FULL,
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("domain name, id or uuid")
},
{.name = "snapshotname", {.name = "snapshotname",
.type = VSH_OT_STRING, .type = VSH_OT_STRING,
.help = N_("snapshot name") .help = N_("snapshot name")
...@@ -1441,11 +1424,7 @@ static const vshCmdInfo info_snapshot_list[] = { ...@@ -1441,11 +1424,7 @@ static const vshCmdInfo info_snapshot_list[] = {
}; };
static const vshCmdOptDef opts_snapshot_list[] = { static const vshCmdOptDef opts_snapshot_list[] = {
{.name = "domain", VIRSH_COMMON_OPT_DOMAIN_FULL,
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("domain name, id or uuid")
},
{.name = "parent", {.name = "parent",
.type = VSH_OT_BOOL, .type = VSH_OT_BOOL,
.help = N_("add a column showing parent snapshot") .help = N_("add a column showing parent snapshot")
...@@ -1705,11 +1684,7 @@ static const vshCmdInfo info_snapshot_dumpxml[] = { ...@@ -1705,11 +1684,7 @@ static const vshCmdInfo info_snapshot_dumpxml[] = {
}; };
static const vshCmdOptDef opts_snapshot_dumpxml[] = { static const vshCmdOptDef opts_snapshot_dumpxml[] = {
{.name = "domain", VIRSH_COMMON_OPT_DOMAIN_FULL,
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("domain name, id or uuid")
},
{.name = "snapshotname", {.name = "snapshotname",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
...@@ -1773,11 +1748,7 @@ static const vshCmdInfo info_snapshot_parent[] = { ...@@ -1773,11 +1748,7 @@ static const vshCmdInfo info_snapshot_parent[] = {
}; };
static const vshCmdOptDef opts_snapshot_parent[] = { static const vshCmdOptDef opts_snapshot_parent[] = {
{.name = "domain", VIRSH_COMMON_OPT_DOMAIN_FULL,
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("domain name, id or uuid")
},
{.name = "snapshotname", {.name = "snapshotname",
.type = VSH_OT_STRING, .type = VSH_OT_STRING,
.help = N_("find parent of snapshot name") .help = N_("find parent of snapshot name")
...@@ -1841,11 +1812,7 @@ static const vshCmdInfo info_snapshot_revert[] = { ...@@ -1841,11 +1812,7 @@ static const vshCmdInfo info_snapshot_revert[] = {
}; };
static const vshCmdOptDef opts_snapshot_revert[] = { static const vshCmdOptDef opts_snapshot_revert[] = {
{.name = "domain", VIRSH_COMMON_OPT_DOMAIN_FULL,
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("domain name, id or uuid")
},
{.name = "snapshotname", {.name = "snapshotname",
.type = VSH_OT_STRING, .type = VSH_OT_STRING,
.help = N_("snapshot name") .help = N_("snapshot name")
...@@ -1934,11 +1901,7 @@ static const vshCmdInfo info_snapshot_delete[] = { ...@@ -1934,11 +1901,7 @@ static const vshCmdInfo info_snapshot_delete[] = {
}; };
static const vshCmdOptDef opts_snapshot_delete[] = { static const vshCmdOptDef opts_snapshot_delete[] = {
{.name = "domain", VIRSH_COMMON_OPT_DOMAIN_FULL,
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("domain name, id or uuid")
},
{.name = "snapshotname", {.name = "snapshotname",
.type = VSH_OT_STRING, .type = VSH_OT_STRING,
.help = N_("snapshot name") .help = N_("snapshot name")
......
...@@ -69,6 +69,13 @@ ...@@ -69,6 +69,13 @@
.help = _helpstr \ .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 struct _virshControl virshControl;
typedef virshControl *virshControlPtr; typedef virshControl *virshControlPtr;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册