提交 ea723c48 编写于 作者: J Ján Tomko

virsh: rename vshCommandOptString to vshCommandOptStringQuiet

This function does not set an error. Make it obvious in its name
to discourage its usage without reporting an error in the caller.
上级 bfc29df3
...@@ -1622,7 +1622,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd) ...@@ -1622,7 +1622,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
goto save_error; goto save_error;
} }
rv = vshCommandOptString(ctl, cmd, "device-weights", &device_weight); rv = vshCommandOptStringQuiet(ctl, cmd, "device-weights", &device_weight);
if (rv < 0) { if (rv < 0) {
vshError(ctl, "%s", _("Unable to parse string parameter")); vshError(ctl, "%s", _("Unable to parse string parameter"));
goto cleanup; goto cleanup;
...@@ -1633,7 +1633,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd) ...@@ -1633,7 +1633,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
goto save_error; goto save_error;
} }
rv = vshCommandOptString(ctl, cmd, "device-read-iops-sec", &device_riops); rv = vshCommandOptStringQuiet(ctl, cmd, "device-read-iops-sec", &device_riops);
if (rv < 0) { if (rv < 0) {
vshError(ctl, "%s", _("Unable to parse string parameter")); vshError(ctl, "%s", _("Unable to parse string parameter"));
goto cleanup; goto cleanup;
...@@ -1644,7 +1644,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd) ...@@ -1644,7 +1644,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
goto save_error; goto save_error;
} }
rv = vshCommandOptString(ctl, cmd, "device-write-iops-sec", &device_wiops); rv = vshCommandOptStringQuiet(ctl, cmd, "device-write-iops-sec", &device_wiops);
if (rv < 0) { if (rv < 0) {
vshError(ctl, "%s", _("Unable to parse string parameter")); vshError(ctl, "%s", _("Unable to parse string parameter"));
goto cleanup; goto cleanup;
...@@ -1655,7 +1655,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd) ...@@ -1655,7 +1655,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
goto save_error; goto save_error;
} }
rv = vshCommandOptString(ctl, cmd, "device-read-bytes-sec", &device_rbps); rv = vshCommandOptStringQuiet(ctl, cmd, "device-read-bytes-sec", &device_rbps);
if (rv < 0) { if (rv < 0) {
vshError(ctl, "%s", _("Unable to parse string parameter")); vshError(ctl, "%s", _("Unable to parse string parameter"));
goto cleanup; goto cleanup;
...@@ -1666,7 +1666,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd) ...@@ -1666,7 +1666,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
goto save_error; goto save_error;
} }
rv = vshCommandOptString(ctl, cmd, "device-write-bytes-sec", &device_wbps); rv = vshCommandOptStringQuiet(ctl, cmd, "device-write-bytes-sec", &device_wbps);
if (rv < 0) { if (rv < 0) {
vshError(ctl, "%s", _("Unable to parse string parameter")); vshError(ctl, "%s", _("Unable to parse string parameter"));
goto cleanup; goto cleanup;
...@@ -3736,7 +3736,7 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd) ...@@ -3736,7 +3736,7 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
size_t j; size_t j;
virshControlPtr priv = ctl->privData; virshControlPtr priv = ctl->privData;
ignore_value(vshCommandOptString(ctl, cmd, "storage", &vol_string)); ignore_value(vshCommandOptStringQuiet(ctl, cmd, "storage", &vol_string));
if (!(vol_string || remove_all_storage) && wipe_storage) { if (!(vol_string || remove_all_storage) && wipe_storage) {
vshError(ctl, vshError(ctl,
...@@ -4115,7 +4115,7 @@ cmdStartGetFDs(vshControl *ctl, ...@@ -4115,7 +4115,7 @@ cmdStartGetFDs(vshControl *ctl,
*nfdsret = 0; *nfdsret = 0;
*fdsret = NULL; *fdsret = NULL;
if (vshCommandOptString(ctl, cmd, "pass-fds", &fdopt) <= 0) if (vshCommandOptStringQuiet(ctl, cmd, "pass-fds", &fdopt) <= 0)
return 0; return 0;
if (!(fdlist = virStringSplit(fdopt, ",", -1))) { if (!(fdlist = virStringSplit(fdopt, ",", -1))) {
...@@ -5310,7 +5310,7 @@ doDump(void *opaque) ...@@ -5310,7 +5310,7 @@ doDump(void *opaque)
goto out; goto out;
} }
if (vshCommandOptString(ctl, cmd, "format", &format) > 0) { if (vshCommandOptStringQuiet(ctl, cmd, "format", &format) > 0) {
if (STREQ(format, "kdump-zlib")) { if (STREQ(format, "kdump-zlib")) {
dumpformat = VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_ZLIB; dumpformat = VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_ZLIB;
} else if (STREQ(format, "kdump-lzo")) { } else if (STREQ(format, "kdump-lzo")) {
...@@ -8359,7 +8359,7 @@ cmdSendKey(vshControl *ctl, const vshCmd *cmd) ...@@ -8359,7 +8359,7 @@ cmdSendKey(vshControl *ctl, const vshCmd *cmd)
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
if (vshCommandOptString(ctl, cmd, "codeset", &codeset_option) <= 0) if (vshCommandOptStringQuiet(ctl, cmd, "codeset", &codeset_option) <= 0)
codeset_option = "linux"; codeset_option = "linux";
if (vshCommandOptUInt(ctl, cmd, "holdtime", &holdtime) < 0) if (vshCommandOptUInt(ctl, cmd, "holdtime", &holdtime) < 0)
...@@ -8775,7 +8775,7 @@ virshMemtuneGetSize(vshControl *ctl, const vshCmd *cmd, ...@@ -8775,7 +8775,7 @@ virshMemtuneGetSize(vshControl *ctl, const vshCmd *cmd,
const char *str; const char *str;
char *end; char *end;
ret = vshCommandOptString(ctl, cmd, name, &str); ret = vshCommandOptStringQuiet(ctl, cmd, name, &str);
if (ret <= 0) if (ret <= 0)
return ret; return ret;
if (virStrToLong_ll(str, &end, 10, value) < 0) if (virStrToLong_ll(str, &end, 10, value) < 0)
......
...@@ -398,7 +398,7 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) ...@@ -398,7 +398,7 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
virshNodeDeviceListPtr list = NULL; virshNodeDeviceListPtr list = NULL;
int cap_type = -1; int cap_type = -1;
ignore_value(vshCommandOptString(ctl, cmd, "cap", &cap_str)); ignore_value(vshCommandOptStringQuiet(ctl, cmd, "cap", &cap_str));
if (cap_str) { if (cap_str) {
if (tree) { if (tree) {
...@@ -615,7 +615,7 @@ cmdNodeDeviceDetach(vshControl *ctl, const vshCmd *cmd) ...@@ -615,7 +615,7 @@ cmdNodeDeviceDetach(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptStringReq(ctl, cmd, "device", &name) < 0) if (vshCommandOptStringReq(ctl, cmd, "device", &name) < 0)
return false; return false;
ignore_value(vshCommandOptString(ctl, cmd, "driver", &driverName)); ignore_value(vshCommandOptStringQuiet(ctl, cmd, "driver", &driverName));
if (!(device = virNodeDeviceLookupByName(priv->conn, name))) { if (!(device = virNodeDeviceLookupByName(priv->conn, name))) {
vshError(ctl, _("Could not find matching device '%s'"), name); vshError(ctl, _("Could not find matching device '%s'"), name);
......
...@@ -222,7 +222,7 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd) ...@@ -222,7 +222,7 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
goto cleanup; goto cleanup;
} }
if (vshCommandOptString(ctl, cmd, "allocation", &allocationStr) > 0 && if (vshCommandOptStringQuiet(ctl, cmd, "allocation", &allocationStr) > 0 &&
virshVolSize(allocationStr, &allocation) < 0) { virshVolSize(allocationStr, &allocation) < 0) {
vshError(ctl, _("Malformed size %s"), allocationStr); vshError(ctl, _("Malformed size %s"), allocationStr);
goto cleanup; goto cleanup;
......
...@@ -944,20 +944,20 @@ vshCommandOptULWrap(vshControl *ctl, const vshCmd *cmd, ...@@ -944,20 +944,20 @@ vshCommandOptULWrap(vshControl *ctl, const vshCmd *cmd,
} }
/** /**
* vshCommandOptString: * vshCommandOptStringQuiet:
* @ctl virtshell control structure * @ctl virtshell control structure
* @cmd command reference * @cmd command reference
* @name option name * @name option name
* @value result * @value result
* *
* Returns option as STRING * Returns option as STRING. On error -1 is returned but no error is set.
* Return value: * Return value:
* >0 if option found and valid (@value updated) * >0 if option found and valid (@value updated)
* 0 if option not found and not required (@value untouched) * 0 if option not found and not required (@value untouched)
* <0 in all other cases (@value untouched) * <0 in all other cases (@value untouched)
*/ */
int int
vshCommandOptString(vshControl *ctl ATTRIBUTE_UNUSED, const vshCmd *cmd, vshCommandOptStringQuiet(vshControl *ctl ATTRIBUTE_UNUSED, const vshCmd *cmd,
const char *name, const char **value) const char *name, const char **value)
{ {
vshCmdOpt *arg; vshCmdOpt *arg;
...@@ -2793,7 +2793,7 @@ cmdHelp(vshControl *ctl, const vshCmd *cmd) ...@@ -2793,7 +2793,7 @@ cmdHelp(vshControl *ctl, const vshCmd *cmd)
{ {
const char *name = NULL; const char *name = NULL;
if (vshCommandOptString(ctl, cmd, "command", &name) <= 0) { if (vshCommandOptStringQuiet(ctl, cmd, "command", &name) <= 0) {
const vshCmdGrp *grp; const vshCmdGrp *grp;
const vshCmdDef *def; const vshCmdDef *def;
...@@ -2857,7 +2857,7 @@ cmdCd(vshControl *ctl, const vshCmd *cmd) ...@@ -2857,7 +2857,7 @@ cmdCd(vshControl *ctl, const vshCmd *cmd)
return false; return false;
} }
if (vshCommandOptString(ctl, cmd, "dir", &dir) <= 0) if (vshCommandOptStringQuiet(ctl, cmd, "dir", &dir) <= 0)
dir = dir_malloced = virGetUserDirectory(); dir = dir_malloced = virGetUserDirectory();
if (!dir) if (!dir)
dir = "/"; dir = "/";
......
...@@ -270,7 +270,7 @@ int vshCommandOptUL(vshControl *ctl, const vshCmd *cmd, ...@@ -270,7 +270,7 @@ int vshCommandOptUL(vshControl *ctl, const vshCmd *cmd,
int vshCommandOptULWrap(vshControl *ctl, const vshCmd *cmd, int vshCommandOptULWrap(vshControl *ctl, const vshCmd *cmd,
const char *name, unsigned long *value) const char *name, unsigned long *value)
ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK; ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
int vshCommandOptString(vshControl *ctl, const vshCmd *cmd, int vshCommandOptStringQuiet(vshControl *ctl, const vshCmd *cmd,
const char *name, const char **value) const char *name, const char **value)
ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK; ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
int vshCommandOptStringReq(vshControl *ctl, const vshCmd *cmd, int vshCommandOptStringReq(vshControl *ctl, const vshCmd *cmd,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册