提交 43a1f54e 编写于 作者: N Nikolay Shirokovskiy 提交者: Jiri Denemark

virsh: support up to 64 migration options for command

Upcoming compression options for migration command patch
series hits current limit of 32 possible options for a command.
Lets take one step further and support 64 possible options.

And all it takes is moving from 32 bit integers to 64 bit ones.
The only less then trivial change i found is moving from
'ffs' to 'ffsl'.
Signed-off-by: NNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
上级 fb6ec0ed
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
#include <limits.h> #include <limits.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <inttypes.h> #include <inttypes.h>
#include <strings.h>
#include <signal.h> #include <signal.h>
#if WITH_READLINE #if WITH_READLINE
...@@ -329,8 +328,8 @@ vshCmddefGetInfo(const vshCmdDef * cmd, const char *name) ...@@ -329,8 +328,8 @@ vshCmddefGetInfo(const vshCmdDef * cmd, const char *name)
/* Validate that the options associated with cmd can be parsed. */ /* Validate that the options associated with cmd can be parsed. */
static int static int
vshCmddefOptParse(const vshCmdDef *cmd, uint32_t *opts_need_arg, vshCmddefOptParse(const vshCmdDef *cmd, uint64_t *opts_need_arg,
uint32_t *opts_required) uint64_t *opts_required)
{ {
size_t i; size_t i;
bool optional = false; bool optional = false;
...@@ -344,7 +343,7 @@ vshCmddefOptParse(const vshCmdDef *cmd, uint32_t *opts_need_arg, ...@@ -344,7 +343,7 @@ vshCmddefOptParse(const vshCmdDef *cmd, uint32_t *opts_need_arg,
for (i = 0; cmd->opts[i].name; i++) { for (i = 0; cmd->opts[i].name; i++) {
const vshCmdOptDef *opt = &cmd->opts[i]; const vshCmdOptDef *opt = &cmd->opts[i];
if (i > 31) if (i > 63)
return -1; /* too many options */ return -1; /* too many options */
if (opt->type == VSH_OT_BOOL) { if (opt->type == VSH_OT_BOOL) {
optional = true; optional = true;
...@@ -407,7 +406,7 @@ static vshCmdOptDef helpopt = { ...@@ -407,7 +406,7 @@ static vshCmdOptDef helpopt = {
}; };
static const vshCmdOptDef * static const vshCmdOptDef *
vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char *name, vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char *name,
uint32_t *opts_seen, int *opt_index, char **optstr) uint64_t *opts_seen, int *opt_index, char **optstr)
{ {
size_t i; size_t i;
const vshCmdOptDef *ret = NULL; const vshCmdOptDef *ret = NULL;
...@@ -464,8 +463,8 @@ vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char *name, ...@@ -464,8 +463,8 @@ vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char *name,
} }
static const vshCmdOptDef * static const vshCmdOptDef *
vshCmddefGetData(const vshCmdDef *cmd, uint32_t *opts_need_arg, vshCmddefGetData(const vshCmdDef *cmd, uint64_t *opts_need_arg,
uint32_t *opts_seen) uint64_t *opts_seen)
{ {
size_t i; size_t i;
const vshCmdOptDef *opt; const vshCmdOptDef *opt;
...@@ -474,7 +473,7 @@ vshCmddefGetData(const vshCmdDef *cmd, uint32_t *opts_need_arg, ...@@ -474,7 +473,7 @@ vshCmddefGetData(const vshCmdDef *cmd, uint32_t *opts_need_arg,
return NULL; return NULL;
/* Grab least-significant set bit */ /* Grab least-significant set bit */
i = ffs(*opts_need_arg) - 1; i = ffsl(*opts_need_arg) - 1;
opt = &cmd->opts[i]; opt = &cmd->opts[i];
if (opt->type != VSH_OT_ARGV) if (opt->type != VSH_OT_ARGV)
*opts_need_arg &= ~(1 << i); *opts_need_arg &= ~(1 << i);
...@@ -486,8 +485,8 @@ vshCmddefGetData(const vshCmdDef *cmd, uint32_t *opts_need_arg, ...@@ -486,8 +485,8 @@ vshCmddefGetData(const vshCmdDef *cmd, uint32_t *opts_need_arg,
* Checks for required options * Checks for required options
*/ */
static int static int
vshCommandCheckOpts(vshControl *ctl, const vshCmd *cmd, uint32_t opts_required, vshCommandCheckOpts(vshControl *ctl, const vshCmd *cmd, uint64_t opts_required,
uint32_t opts_seen) uint64_t opts_seen)
{ {
const vshCmdDef *def = cmd->def; const vshCmdDef *def = cmd->def;
size_t i; size_t i;
...@@ -598,8 +597,8 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname) ...@@ -598,8 +597,8 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname)
const char *desc = vshCmddefGetInfo(def, "desc"); const char *desc = vshCmddefGetInfo(def, "desc");
const char *help = _(vshCmddefGetInfo(def, "help")); const char *help = _(vshCmddefGetInfo(def, "help"));
char buf[256]; char buf[256];
uint32_t opts_need_arg; uint64_t opts_need_arg;
uint32_t opts_required; uint64_t opts_required;
bool shortopt = false; /* true if 'arg' works instead of '--opt arg' */ bool shortopt = false; /* true if 'arg' works instead of '--opt arg' */
if (vshCmddefOptParse(def, &opts_need_arg, &opts_required)) { if (vshCmddefOptParse(def, &opts_need_arg, &opts_required)) {
...@@ -1350,9 +1349,9 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser) ...@@ -1350,9 +1349,9 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser)
const vshCmdDef *cmd = NULL; const vshCmdDef *cmd = NULL;
vshCommandToken tk; vshCommandToken tk;
bool data_only = false; bool data_only = false;
uint32_t opts_need_arg = 0; uint64_t opts_need_arg = 0;
uint32_t opts_required = 0; uint64_t opts_required = 0;
uint32_t opts_seen = 0; uint64_t opts_seen = 0;
first = NULL; first = NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册