cmdConnect(vshControl *ctl, const vshCmd *cmd)
{
int ro = vshCommandOptBool(cmd, "readonly");
+ char *name;
if (ctl->conn) {
if (virConnectClose(ctl->conn) != 0) {
}
VIR_FREE(ctl->name);
- ctl->name = vshStrdup(ctl, vshCommandOptString(cmd, "name", NULL));
+ name = vshCommandOptString(cmd, "name", NULL);
+ if (!name)
+ return FALSE;
+ ctl->name = vshStrdup(ctl, name);
if (!ro) {
ctl->readonly = 0;
}
if (!(cpulist = vshCommandOptString(cmd, "cpulist", NULL))) {
- vshError(ctl, "%s", _("vcpupin: Missing cpulist"));
virDomainFree(dom);
return FALSE;
}
return FALSE;
desturi = vshCommandOptString (cmd, "desturi", &found);
- if (!found) {
- vshError(ctl, "%s", _("migrate: Missing desturi"));
+ if (!found)
goto done;
- }
migrateuri = vshCommandOptString (cmd, "migrateuri", NULL);
from = vshCommandOptString(cmd, "file", &found);
if (!found) {
- vshError(ctl, "%s", _("attach-device: Missing <file> option"));
virDomainFree(dom);
return FALSE;
}
from = vshCommandOptString(cmd, "file", &found);
if (!found) {
- vshError(ctl, "%s", _("detach-device: Missing <file> option"));
virDomainFree(dom);
return FALSE;
}
from = vshCommandOptString(cmd, "file", &found);
if (!found) {
- vshError(ctl, "%s", _("update-device: Missing <file> option"));
virDomainFree(dom);
return FALSE;
}
goto cleanup;
name = vshCommandOptString(cmd, "snapshotname", NULL);
- if (name == NULL) {
- vshError(ctl, "%s", _("missing snapshotname"));
+ if (name == NULL)
goto cleanup;
- }
snapshot = virDomainSnapshotLookupByName(dom, name, 0);
if (snapshot == NULL)
goto cleanup;
name = vshCommandOptString(cmd, "snapshotname", NULL);
- if (name == NULL) {
- vshError(ctl, "%s", _("missing snapshotname"));
+ if (name == NULL)
goto cleanup;
- }
snapshot = virDomainSnapshotLookupByName(dom, name, 0);
if (snapshot == NULL)
goto cleanup;
name = vshCommandOptString(cmd, "snapshotname", NULL);
- if (name == NULL) {
- vshError(ctl, "%s", _("missing snapshotname"));
+ if (name == NULL)
goto cleanup;
- }
if (vshCommandOptBool(cmd, "children"))
flags |= VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN;
if (found)
*found = arg ? TRUE : FALSE;
- return arg && arg->data && *arg->data ? arg->data : NULL;
+ if (arg && arg->data && *arg->data)
+ return arg->data;
+
+ if ((arg->def->flag) & VSH_OFLAG_REQ)
+ vshError(NULL, _("Missing required option '%s'"), name);
+
+ return NULL;
}
/*
if (!cmd_has_option (ctl, cmd, optname))
return NULL;
- if (!(n = vshCommandOptString(cmd, optname, NULL))) {
- vshError(ctl, "%s", _("undefined domain name or id"));
+ if (!(n = vshCommandOptString(cmd, optname, NULL)))
return NULL;
- }
vshDebug(ctl, 5, "%s: found option <%s>: %s\n",
cmd->def->name, optname, n);
if (!cmd_has_option (ctl, cmd, optname))
return NULL;
- if (!(n = vshCommandOptString(cmd, optname, NULL))) {
- vshError(ctl, "%s", _("undefined network name"));
+ if (!(n = vshCommandOptString(cmd, optname, NULL)))
return NULL;
- }
vshDebug(ctl, 5, "%s: found option <%s>: %s\n",
cmd->def->name, optname, n);
if (!cmd_has_option (ctl, cmd, optname))
return NULL;
- if (!(n = vshCommandOptString(cmd, optname, NULL))) {
- vshError(ctl, "%s", _("undefined nwfilter name"));
+ if (!(n = vshCommandOptString(cmd, optname, NULL)))
return NULL;
- }
vshDebug(ctl, 5, "%s: found option <%s>: %s\n",
cmd->def->name, optname, n);
if (!cmd_has_option (ctl, cmd, optname))
return NULL;
- if (!(n = vshCommandOptString(cmd, optname, NULL))) {
- vshError(ctl, "%s", _("undefined interface identifier"));
+ if (!(n = vshCommandOptString(cmd, optname, NULL)))
return NULL;
- }
vshDebug(ctl, 5, "%s: found option <%s>: %s\n",
cmd->def->name, optname, n);
virStoragePoolPtr pool = NULL;
char *n;
- if (!(n = vshCommandOptString(cmd, optname, NULL))) {
- vshError(ctl, "%s", _("undefined pool name"));
+ if (!(n = vshCommandOptString(cmd, optname, NULL)))
return NULL;
- }
vshDebug(ctl, 5, "%s: found option <%s>: %s\n",
cmd->def->name, optname, n);
char *n, *p;
int found;
- if (!(n = vshCommandOptString(cmd, optname, NULL))) {
- vshError(ctl, "%s", _("undefined vol name"));
+ if (!(n = vshCommandOptString(cmd, optname, NULL)))
return NULL;
- }
- if (!(p = vshCommandOptString(cmd, pooloptname, &found)) && found) {
- vshError(ctl, "%s", _("undefined pool name"));
+ if (!(p = vshCommandOptString(cmd, pooloptname, &found)) && found)
return NULL;
- }
if (p)
pool = vshCommandOptPoolBy(ctl, cmd, pooloptname, name, flag);
return NULL;
n = vshCommandOptString(cmd, optname, NULL);
- if (n == NULL) {
- vshError(ctl, "%s", _("undefined secret UUID"));
+ if (n == NULL)
return NULL;
- }
vshDebug(ctl, 5, "%s: found option <%s>: %s\n", cmd->def->name, optname, n);