提交 70c6e677 编写于 作者: J John Ferlan

virsh: Adjustments for the VIRSH_COMMON_OPT_POOL

The macro is slightly adjusted to add an argument "_helpstr". This
will be passed as a translation macro string since other uses of the
option may not have the same exact help string (such as is the case
when the uuid is not suppliable for create commands).

In virsh-pool.c - we'll create a singular VIRSH_COMMON_OPT_POOL_FULL
in order to pass along the 'N_("pool name or uuid")'

In virsh-volume.c there will be a VIRSH_COMMON_OPT_POOL_FULL and a
VIRSH_COMMON_OPT_POOL_NAME, which passes 'N_("pool name")' for
the commands that can only pass a name. There will also be a
VIRSH_COMMON_OPT_POOL_OPTIONAL which is used for the command
options which use OT_STRING and don't require the --pool argument.
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 f688b808
......@@ -33,12 +33,8 @@
#include "conf/storage_conf.h"
#include "virstring.h"
#define VIRSH_COMMON_OPT_POOL \
{.name = "pool", \
.type = VSH_OT_DATA, \
.flags = VSH_OFLAG_REQ, \
.help = N_("pool name or uuid") \
} \
#define VIRSH_COMMON_OPT_POOL_FULL \
VIRSH_COMMON_OPT_POOL(N_("pool name or uuid")) \
#define VIRSH_COMMON_OPT_POOL_FILE \
{.name = "file", \
......@@ -188,7 +184,7 @@ static const vshCmdInfo info_pool_autostart[] = {
};
static const vshCmdOptDef opts_pool_autostart[] = {
VIRSH_COMMON_OPT_POOL,
VIRSH_COMMON_OPT_POOL_FULL,
{.name = "disable",
.type = VSH_OT_BOOL,
......@@ -575,7 +571,7 @@ static const vshCmdInfo info_pool_build[] = {
};
static const vshCmdOptDef opts_pool_build[] = {
VIRSH_COMMON_OPT_POOL,
VIRSH_COMMON_OPT_POOL_FULL,
VIRSH_COMMON_OPT_POOL_NO_OVERWRITE,
VIRSH_COMMON_OPT_POOL_OVERWRITE,
......@@ -625,7 +621,7 @@ static const vshCmdInfo info_pool_destroy[] = {
};
static const vshCmdOptDef opts_pool_destroy[] = {
VIRSH_COMMON_OPT_POOL,
VIRSH_COMMON_OPT_POOL_FULL,
{.name = NULL}
};
......@@ -665,7 +661,7 @@ static const vshCmdInfo info_pool_delete[] = {
};
static const vshCmdOptDef opts_pool_delete[] = {
VIRSH_COMMON_OPT_POOL,
VIRSH_COMMON_OPT_POOL_FULL,
{.name = NULL}
};
......@@ -705,7 +701,7 @@ static const vshCmdInfo info_pool_refresh[] = {
};
static const vshCmdOptDef opts_pool_refresh[] = {
VIRSH_COMMON_OPT_POOL,
VIRSH_COMMON_OPT_POOL_FULL,
{.name = NULL}
};
......@@ -745,7 +741,7 @@ static const vshCmdInfo info_pool_dumpxml[] = {
};
static const vshCmdOptDef opts_pool_dumpxml[] = {
VIRSH_COMMON_OPT_POOL,
VIRSH_COMMON_OPT_POOL_FULL,
{.name = "inactive",
.type = VSH_OT_BOOL,
......@@ -1596,7 +1592,7 @@ static const vshCmdInfo info_pool_info[] = {
};
static const vshCmdOptDef opts_pool_info[] = {
VIRSH_COMMON_OPT_POOL,
VIRSH_COMMON_OPT_POOL_FULL,
{.name = NULL}
};
......@@ -1673,7 +1669,7 @@ static const vshCmdInfo info_pool_name[] = {
};
static const vshCmdOptDef opts_pool_name[] = {
VIRSH_COMMON_OPT_POOL,
VIRSH_COMMON_OPT_POOL_FULL,
{.name = NULL}
};
......@@ -1705,7 +1701,7 @@ static const vshCmdInfo info_pool_start[] = {
};
static const vshCmdOptDef opts_pool_start[] = {
VIRSH_COMMON_OPT_POOL,
VIRSH_COMMON_OPT_POOL_FULL,
VIRSH_COMMON_OPT_POOL_BUILD,
VIRSH_COMMON_OPT_POOL_NO_OVERWRITE,
VIRSH_COMMON_OPT_POOL_OVERWRITE,
......@@ -1766,7 +1762,7 @@ static const vshCmdInfo info_pool_undefine[] = {
};
static const vshCmdOptDef opts_pool_undefine[] = {
VIRSH_COMMON_OPT_POOL,
VIRSH_COMMON_OPT_POOL_FULL,
{.name = NULL}
};
......@@ -1806,7 +1802,7 @@ static const vshCmdInfo info_pool_uuid[] = {
};
static const vshCmdOptDef opts_pool_uuid[] = {
VIRSH_COMMON_OPT_POOL,
VIRSH_COMMON_OPT_POOL_FULL,
{.name = NULL}
};
......@@ -1843,7 +1839,7 @@ static const vshCmdInfo info_pool_edit[] = {
};
static const vshCmdOptDef opts_pool_edit[] = {
VIRSH_COMMON_OPT_POOL,
VIRSH_COMMON_OPT_POOL_FULL,
{.name = NULL}
};
......
......@@ -42,6 +42,18 @@
#include "virxml.h"
#include "virstring.h"
#define VIRSH_COMMON_OPT_POOL_FULL \
VIRSH_COMMON_OPT_POOL(N_("pool name or uuid")) \
#define VIRSH_COMMON_OPT_POOL_NAME \
VIRSH_COMMON_OPT_POOL(N_("pool name")) \
#define VIRSH_COMMON_OPT_POOL_OPTIONAL \
{.name = "pool", \
.type = VSH_OT_STRING, \
.help = N_("pool name or uuid") \
} \
virStorageVolPtr
virshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd,
const char *optname,
......@@ -145,11 +157,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_COMMON_OPT_POOL_NAME,
{.name = "name",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
......@@ -353,11 +361,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_COMMON_OPT_POOL_NAME,
{.name = "file",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
......@@ -423,11 +427,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_COMMON_OPT_POOL_FULL,
{.name = "file",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
......@@ -558,10 +558,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_COMMON_OPT_POOL_OPTIONAL,
{.name = "prealloc-metadata",
.type = VSH_OT_BOOL,
.help = N_("preallocate metadata (for qcow2 instead of full allocation)")
......@@ -661,10 +658,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_COMMON_OPT_POOL_OPTIONAL,
{.name = "offset",
.type = VSH_OT_INT,
.help = N_("volume offset to upload to")
......@@ -775,10 +769,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_COMMON_OPT_POOL_OPTIONAL,
{.name = "offset",
.type = VSH_OT_INT,
.help = N_("volume offset to download from")
......@@ -883,10 +874,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_COMMON_OPT_POOL_OPTIONAL,
{.name = "delete-snapshots",
.type = VSH_OT_BOOL,
.help = N_("delete snapshots associated with volume (must be "
......@@ -940,10 +928,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_COMMON_OPT_POOL_OPTIONAL,
{.name = "algorithm",
.type = VSH_OT_STRING,
.help = N_("perform selected wiping algorithm")
......@@ -1033,10 +1018,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_COMMON_OPT_POOL_OPTIONAL,
{.name = NULL}
};
......@@ -1096,10 +1078,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_COMMON_OPT_POOL_OPTIONAL,
{.name = "allocate",
.type = VSH_OT_BOOL,
.help = N_("allocate the new capacity, rather than leaving it sparse")
......@@ -1195,10 +1174,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_COMMON_OPT_POOL_OPTIONAL,
{.name = NULL}
};
......@@ -1364,11 +1340,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_COMMON_OPT_POOL_FULL,
{.name = "details",
.type = VSH_OT_BOOL,
.help = N_("display extended details for volumes")
......@@ -1710,10 +1682,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_COMMON_OPT_POOL_OPTIONAL,
{.name = NULL}
};
......@@ -1749,10 +1718,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_COMMON_OPT_POOL_OPTIONAL,
{.name = NULL}
};
......
/*
* virsh.h: a shell to exercise the libvirt API
*
* 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
......@@ -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_COMMON_OPT_POOL(_helpstr) \
{.name = "pool", \
.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.
先完成此消息的编辑!
想要评论请 注册