提交 4e31e733 编写于 作者: P Peter Krempa

virsh-network: Update network commands to use vshCommandOptStringReq

上级 edbdc45b
...@@ -50,7 +50,7 @@ vshCommandOptNetworkBy(vshControl *ctl, const vshCmd *cmd, ...@@ -50,7 +50,7 @@ vshCommandOptNetworkBy(vshControl *ctl, const vshCmd *cmd,
if (!vshCmdHasOption(ctl, cmd, optname)) if (!vshCmdHasOption(ctl, cmd, optname))
return NULL; return NULL;
if (vshCommandOptString(cmd, optname, &n) <= 0) if (vshCommandOptStringReq(ctl, cmd, optname, &n) < 0)
return NULL; return NULL;
vshDebug(ctl, VSH_ERR_INFO, "%s: found option <%s>: %s\n", vshDebug(ctl, VSH_ERR_INFO, "%s: found option <%s>: %s\n",
...@@ -158,7 +158,7 @@ cmdNetworkCreate(vshControl *ctl, const vshCmd *cmd) ...@@ -158,7 +158,7 @@ cmdNetworkCreate(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
char *buffer; char *buffer;
if (vshCommandOptString(cmd, "file", &from) <= 0) if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
return false; return false;
if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
...@@ -204,7 +204,7 @@ cmdNetworkDefine(vshControl *ctl, const vshCmd *cmd) ...@@ -204,7 +204,7 @@ cmdNetworkDefine(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
char *buffer; char *buffer;
if (vshCommandOptString(cmd, "file", &from) <= 0) if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
return false; return false;
if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
...@@ -889,10 +889,8 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd) ...@@ -889,10 +889,8 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd)
if (!(network = vshCommandOptNetwork(ctl, cmd, NULL))) if (!(network = vshCommandOptNetwork(ctl, cmd, NULL)))
goto cleanup; goto cleanup;
if (vshCommandOptString(cmd, "command", &commandStr) < 0) { if (vshCommandOptStringReq(ctl, cmd, "command", &commandStr) < 0)
vshError(ctl, "%s", _("missing or malformed command argument"));
goto cleanup; goto cleanup;
}
if (STREQ(commandStr, "add")) { if (STREQ(commandStr, "add")) {
/* "add" is a synonym for "add-last" */ /* "add" is a synonym for "add-last" */
...@@ -905,10 +903,9 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd) ...@@ -905,10 +903,9 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd)
} }
} }
if (vshCommandOptString(cmd, "section", &sectionStr) < 0) { if (vshCommandOptStringReq(ctl, cmd, "section", &sectionStr) < 0)
vshError(ctl, "%s", _("missing or malformed section argument"));
goto cleanup; goto cleanup;
}
section = virNetworkSectionTypeFromString(sectionStr); section = virNetworkSectionTypeFromString(sectionStr);
if (section <= 0 || section >= VIR_NETWORK_SECTION_LAST) { if (section <= 0 || section >= VIR_NETWORK_SECTION_LAST) {
vshError(ctl, _("unrecognized section name '%s'"), sectionStr); vshError(ctl, _("unrecognized section name '%s'"), sectionStr);
...@@ -927,10 +924,8 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd) ...@@ -927,10 +924,8 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd)
* the desired xml. * the desired xml.
*/ */
if (vshCommandOptString(cmd, "xml", &xml) < 0) { if (vshCommandOptStringReq(ctl, cmd, "xml", &xml) < 0)
vshError(ctl, "%s", _("malformed or missing xml argument"));
goto cleanup; goto cleanup;
}
if (*xml != '<') { if (*xml != '<') {
/* contents of xmldata is actually the name of a file that /* contents of xmldata is actually the name of a file that
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册