diff --git a/tools/virsh-backup.c b/tools/virsh-backup.c index 9a1e89760f..27777eea74 100644 --- a/tools/virsh-backup.c +++ b/tools/virsh-backup.c @@ -68,7 +68,7 @@ cmdBackupBegin(vshControl *ctl, if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "backupxml", &backup_from) < 0) + if (vshCommandOptString(ctl, cmd, "backupxml", &backup_from) < 0) return false; if (!backup_from) { @@ -80,7 +80,7 @@ cmdBackupBegin(vshControl *ctl, } } - if (vshCommandOptStringReq(ctl, cmd, "checkpointxml", &check_from) < 0) + if (vshCommandOptString(ctl, cmd, "checkpointxml", &check_from) < 0) return false; if (check_from) { if (virFileReadAll(check_from, VSH_MAX_XML_FILE, &check_buffer) < 0) { diff --git a/tools/virsh-checkpoint.c b/tools/virsh-checkpoint.c index e3fd6b2df2..fea6b4fb4b 100644 --- a/tools/virsh-checkpoint.c +++ b/tools/virsh-checkpoint.c @@ -121,7 +121,7 @@ cmdCheckpointCreate(vshControl *ctl, if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "xmlfile", &from) < 0) + if (vshCommandOptString(ctl, cmd, "xmlfile", &from) < 0) return false; if (!from) { buffer = g_strdup(""); @@ -234,8 +234,8 @@ cmdCheckpointCreateAs(vshControl *ctl, if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0 || - vshCommandOptStringReq(ctl, cmd, "description", &desc) < 0) + if (vshCommandOptString(ctl, cmd, "name", &name) < 0 || + vshCommandOptString(ctl, cmd, "description", &desc) < 0) return false; virBufferAddLit(&buf, "\n"); @@ -281,7 +281,7 @@ virshLookupCheckpoint(vshControl *ctl, { const char *chkname = NULL; - if (vshCommandOptStringReq(ctl, cmd, arg, &chkname) < 0) + if (vshCommandOptString(ctl, cmd, arg, &chkname) < 0) return -1; if (!(*chk = virDomainCheckpointLookupByName(dom, chkname, 0))) diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index 2891d1399c..61362224a3 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -381,7 +381,7 @@ virshDomainInterfaceStateCompleter(vshControl *ctl, if (virshDomainGetXML(ctl, cmd, flags, &xml, &ctxt) < 0) return NULL; - if (vshCommandOptStringReq(ctl, cmd, "interface", &iface) < 0) + if (vshCommandOptString(ctl, cmd, "interface", &iface) < 0) return NULL; /* normalize the mac addr */ diff --git a/tools/virsh-completer-host.c b/tools/virsh-completer-host.c index 93b633eb64..78d2236f97 100644 --- a/tools/virsh-completer-host.c +++ b/tools/virsh-completer-host.c @@ -227,10 +227,10 @@ virshCPUModelCompleter(vshControl *ctl, virCheckFlags(0, NULL); - if (vshCommandOptStringReq(ctl, cmd, "virttype", &virttype) < 0 || - vshCommandOptStringReq(ctl, cmd, "emulator", &emulator) < 0 || - vshCommandOptStringReq(ctl, cmd, "arch", &arch) < 0 || - vshCommandOptStringReq(ctl, cmd, "machine", &machine) < 0) + if (vshCommandOptString(ctl, cmd, "virttype", &virttype) < 0 || + vshCommandOptString(ctl, cmd, "emulator", &emulator) < 0 || + vshCommandOptString(ctl, cmd, "arch", &arch) < 0 || + vshCommandOptString(ctl, cmd, "machine", &machine) < 0) return NULL; if (!priv->conn || virConnectIsAlive(priv->conn) <= 0) diff --git a/tools/virsh-domain-event.c b/tools/virsh-domain-event.c index 8bf57ade7a..cd33d4d938 100644 --- a/tools/virsh-domain-event.c +++ b/tools/virsh-domain-event.c @@ -927,7 +927,7 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd) return true; } - if (vshCommandOptStringReq(ctl, cmd, "event", &eventName) < 0) + if (vshCommandOptString(ctl, cmd, "event", &eventName) < 0) return false; if (!eventName && !all) { diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 599ae71e7a..700f3ae094 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -765,7 +765,7 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd) int ninterfaces; unsigned int flags = 0; - if (vshCommandOptStringReq(ctl, cmd, "interface", &iface) < 0) + if (vshCommandOptString(ctl, cmd, "interface", &iface) < 0) return false; if (vshCommandOptBool(cmd, "config")) @@ -934,7 +934,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd) string to denote 'all devices'. A NULL device arg would violate API contract. */ - if (vshCommandOptStringReq(ctl, cmd, "device", &device) < 0) + if (vshCommandOptString(ctl, cmd, "device", &device) < 0) return false; if (!device) @@ -1058,7 +1058,7 @@ cmdDomIfstat(vshControl *ctl, const vshCmd *cmd) if (!(dom = virshCommandOptDomain(ctl, cmd, &name))) return false; - if (vshCommandOptStringReq(ctl, cmd, "interface", &device) < 0) + if (vshCommandOptString(ctl, cmd, "interface", &device) < 0) return false; if (virDomainInterfaceStats(dom, device, &stats, sizeof(stats)) == -1) { @@ -2254,9 +2254,9 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd) const char *sourcestr = NULL; int source = VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE; - if (vshCommandOptStringReq(ctl, cmd, "interface", &ifacestr) < 0) + if (vshCommandOptString(ctl, cmd, "interface", &ifacestr) < 0) return false; - if (vshCommandOptStringReq(ctl, cmd, "source", &sourcestr) < 0) + if (vshCommandOptString(ctl, cmd, "source", &sourcestr) < 0) return false; if (sourcestr && diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 3d9c48629a..28d90377a1 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -382,7 +382,7 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd) if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) + if (vshCommandOptString(ctl, cmd, "file", &from) < 0) return false; if (persistent && @@ -647,25 +647,25 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) if (live) flags |= VIR_DOMAIN_AFFECT_LIVE; - if (vshCommandOptStringReq(ctl, cmd, "source", &source) < 0 || - vshCommandOptStringReq(ctl, cmd, "target", &target) < 0 || - vshCommandOptStringReq(ctl, cmd, "driver", &driver) < 0 || - vshCommandOptStringReq(ctl, cmd, "subdriver", &subdriver) < 0 || - vshCommandOptStringReq(ctl, cmd, "type", &device) < 0 || - vshCommandOptStringReq(ctl, cmd, "mode", &mode) < 0 || - vshCommandOptStringReq(ctl, cmd, "iothread", &iothread) < 0 || - vshCommandOptStringReq(ctl, cmd, "cache", &cache) < 0 || - vshCommandOptStringReq(ctl, cmd, "io", &io) < 0 || - vshCommandOptStringReq(ctl, cmd, "serial", &serial) < 0 || - vshCommandOptStringReq(ctl, cmd, "wwn", &wwn) < 0 || - vshCommandOptStringReq(ctl, cmd, "address", &straddr) < 0 || - vshCommandOptStringReq(ctl, cmd, "targetbus", &targetbus) < 0 || - vshCommandOptStringReq(ctl, cmd, "alias", &alias) < 0 || - vshCommandOptStringReq(ctl, cmd, "sourcetype", &stype) < 0 || - vshCommandOptStringReq(ctl, cmd, "source-protocol", &source_protocol) < 0 || - vshCommandOptStringReq(ctl, cmd, "source-host-name", &host_name) < 0 || - vshCommandOptStringReq(ctl, cmd, "source-host-transport", &host_transport) < 0 || - vshCommandOptStringReq(ctl, cmd, "source-host-socket", &host_socket) < 0) + if (vshCommandOptString(ctl, cmd, "source", &source) < 0 || + vshCommandOptString(ctl, cmd, "target", &target) < 0 || + vshCommandOptString(ctl, cmd, "driver", &driver) < 0 || + vshCommandOptString(ctl, cmd, "subdriver", &subdriver) < 0 || + vshCommandOptString(ctl, cmd, "type", &device) < 0 || + vshCommandOptString(ctl, cmd, "mode", &mode) < 0 || + vshCommandOptString(ctl, cmd, "iothread", &iothread) < 0 || + vshCommandOptString(ctl, cmd, "cache", &cache) < 0 || + vshCommandOptString(ctl, cmd, "io", &io) < 0 || + vshCommandOptString(ctl, cmd, "serial", &serial) < 0 || + vshCommandOptString(ctl, cmd, "wwn", &wwn) < 0 || + vshCommandOptString(ctl, cmd, "address", &straddr) < 0 || + vshCommandOptString(ctl, cmd, "targetbus", &targetbus) < 0 || + vshCommandOptString(ctl, cmd, "alias", &alias) < 0 || + vshCommandOptString(ctl, cmd, "sourcetype", &stype) < 0 || + vshCommandOptString(ctl, cmd, "source-protocol", &source_protocol) < 0 || + vshCommandOptString(ctl, cmd, "source-host-name", &host_name) < 0 || + vshCommandOptString(ctl, cmd, "source-host-transport", &host_transport) < 0 || + vshCommandOptString(ctl, cmd, "source-host-socket", &host_socket) < 0) return false; if (stype && @@ -963,16 +963,16 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) if (live) flags |= VIR_DOMAIN_AFFECT_LIVE; - if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0 || - vshCommandOptStringReq(ctl, cmd, "source", &source) < 0 || - vshCommandOptStringReq(ctl, cmd, "target", &target) < 0 || - vshCommandOptStringReq(ctl, cmd, "mac", &mac) < 0 || - vshCommandOptStringReq(ctl, cmd, "script", &script) < 0 || - vshCommandOptStringReq(ctl, cmd, "model", &model) < 0 || - vshCommandOptStringReq(ctl, cmd, "alias", &alias) < 0 || - vshCommandOptStringReq(ctl, cmd, "inbound", &inboundStr) < 0 || - vshCommandOptStringReq(ctl, cmd, "outbound", &outboundStr) < 0 || - vshCommandOptStringReq(ctl, cmd, "source-mode", &sourceModeStr) < 0) + if (vshCommandOptString(ctl, cmd, "type", &type) < 0 || + vshCommandOptString(ctl, cmd, "source", &source) < 0 || + vshCommandOptString(ctl, cmd, "target", &target) < 0 || + vshCommandOptString(ctl, cmd, "mac", &mac) < 0 || + vshCommandOptString(ctl, cmd, "script", &script) < 0 || + vshCommandOptString(ctl, cmd, "model", &model) < 0 || + vshCommandOptString(ctl, cmd, "alias", &alias) < 0 || + vshCommandOptString(ctl, cmd, "inbound", &inboundStr) < 0 || + vshCommandOptString(ctl, cmd, "outbound", &outboundStr) < 0 || + vshCommandOptString(ctl, cmd, "source-mode", &sourceModeStr) < 0) return false; /* check interface type */ @@ -1402,7 +1402,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd) if (!(dom = virshCommandOptDomain(ctl, cmd, &name))) goto cleanup; - if (vshCommandOptStringReq(ctl, cmd, "device", &disk) < 0) + if (vshCommandOptString(ctl, cmd, "device", &disk) < 0) goto cleanup; #define VSH_ADD_IOTUNE_SCALED(PARAM, CONST) \ @@ -1450,7 +1450,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd) VSH_ADD_IOTUNE(write-iops-sec-max-length, WRITE_IOPS_SEC_MAX_LENGTH); #undef VSH_ADD_IOTUNE - if (vshCommandOptStringReq(ctl, cmd, "group-name", &group_name) < 0) { + if (vshCommandOptString(ctl, cmd, "group-name", &group_name) < 0) { vshError(ctl, "%s", _("Unable to parse group-name parameter")); goto cleanup; } @@ -2095,13 +2095,13 @@ cmdBlockcommit(vshControl *ctl, const vshCmd *cmd) VSH_EXCLUSIVE_OPTIONS("pivot", "keep-overlay"); - if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0) + if (vshCommandOptString(ctl, cmd, "path", &path) < 0) return false; - if (vshCommandOptStringReq(ctl, cmd, "base", &base) < 0) + if (vshCommandOptString(ctl, cmd, "base", &base) < 0) return false; - if (vshCommandOptStringReq(ctl, cmd, "top", &top) < 0) + if (vshCommandOptString(ctl, cmd, "top", &top) < 0) return false; if (vshBlockJobOptionBandwidth(ctl, cmd, bytes, &bandwidth) < 0) @@ -2352,13 +2352,13 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd) virshBlockJobWaitData *bjWait = NULL; int nparams = 0; - if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0) + if (vshCommandOptString(ctl, cmd, "path", &path) < 0) return false; - if (vshCommandOptStringReq(ctl, cmd, "dest", &dest) < 0) + if (vshCommandOptString(ctl, cmd, "dest", &dest) < 0) return false; - if (vshCommandOptStringReq(ctl, cmd, "xml", &xml) < 0) + if (vshCommandOptString(ctl, cmd, "xml", &xml) < 0) return false; - if (vshCommandOptStringReq(ctl, cmd, "format", &format) < 0) + if (vshCommandOptString(ctl, cmd, "format", &format) < 0) return false; if (vshBlockJobOptionBandwidth(ctl, cmd, bytes, &bandwidth) < 0) return false; @@ -2755,7 +2755,7 @@ cmdBlockjob(vshControl *ctl, const vshCmd *cmd) return false; /* XXX Allow path to be optional to list info on all devices at once */ - if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0) + if (vshCommandOptString(ctl, cmd, "path", &path) < 0) return false; if (bandwidth) @@ -2840,10 +2840,10 @@ cmdBlockpull(vshControl *ctl, const vshCmd *cmd) VSH_REQUIRE_OPTION("verbose", "wait"); VSH_REQUIRE_OPTION("async", "wait"); - if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0) + if (vshCommandOptString(ctl, cmd, "path", &path) < 0) return false; - if (vshCommandOptStringReq(ctl, cmd, "base", &base) < 0) + if (vshCommandOptString(ctl, cmd, "base", &base) < 0) return false; if (vshBlockJobOptionBandwidth(ctl, cmd, bytes, &bandwidth) < 0) @@ -2950,7 +2950,7 @@ cmdBlockresize(vshControl *ctl, const vshCmd *cmd) VSH_ALTERNATIVE_OPTIONS("size", "capacity"); - if (vshCommandOptStringReq(ctl, cmd, "path", (const char **) &path) < 0) + if (vshCommandOptString(ctl, cmd, "path", (const char **) &path) < 0) return false; if (vshCommandOptScaledInt(ctl, cmd, "size", &size, 1024, ULLONG_MAX) < 0) @@ -3052,7 +3052,7 @@ cmdConsole(vshControl *ctl, const vshCmd *cmd) if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "devname", &name) < 0) /* sc_prohibit_devname */ + if (vshCommandOptString(ctl, cmd, "devname", &name) < 0) /* sc_prohibit_devname */ return false; if (force) @@ -3121,8 +3121,8 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd) if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "interface", &iface) < 0 || - vshCommandOptStringReq(ctl, cmd, "state", &state) < 0) + if (vshCommandOptString(ctl, cmd, "interface", &iface) < 0 || + vshCommandOptString(ctl, cmd, "state", &state) < 0) return false; if (STRNEQ(state, "up") && STRNEQ(state, "down")) { @@ -3276,11 +3276,11 @@ cmdDomIftune(vshControl *ctl, const vshCmd *cmd) if (!(dom = virshCommandOptDomain(ctl, cmd, &name))) return false; - if (vshCommandOptStringReq(ctl, cmd, "interface", &device) < 0) + if (vshCommandOptString(ctl, cmd, "interface", &device) < 0) goto cleanup; - if (vshCommandOptStringReq(ctl, cmd, "inbound", &inboundStr) < 0 || - vshCommandOptStringReq(ctl, cmd, "outbound", &outboundStr) < 0) + if (vshCommandOptString(ctl, cmd, "inbound", &inboundStr) < 0 || + vshCommandOptString(ctl, cmd, "outbound", &outboundStr) < 0) goto cleanup; if (inboundStr) { @@ -3481,7 +3481,7 @@ cmdDomPMSuspend(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptULongLong(ctl, cmd, "duration", &duration) < 0) return false; - if (vshCommandOptStringReq(ctl, cmd, "target", &target) < 0) + if (vshCommandOptString(ctl, cmd, "target", &target) < 0) return false; if ((suspendTarget = virshNodeSuspendTargetTypeFromString(target)) < 0) { @@ -4188,7 +4188,7 @@ doSave(void *opaque) goto out_sig; #endif /* !WIN32 */ - if (vshCommandOptStringReq(ctl, cmd, "file", &to) < 0) + if (vshCommandOptString(ctl, cmd, "file", &to) < 0) goto out; if (vshCommandOptBool(cmd, "bypass-cache")) @@ -4198,7 +4198,7 @@ doSave(void *opaque) if (vshCommandOptBool(cmd, "paused")) flags |= VIR_DOMAIN_SAVE_PAUSED; - if (vshCommandOptStringReq(ctl, cmd, "xml", &xmlfile) < 0) + if (vshCommandOptString(ctl, cmd, "xml", &xmlfile) < 0) goto out; if (!(dom = virshCommandOptDomain(ctl, cmd, &name))) @@ -4454,7 +4454,7 @@ cmdSave(vshControl *ctl, const vshCmd *cmd) if (!(dom = virshCommandOptDomain(ctl, cmd, &name))) return false; - if (vshCommandOptStringReq(ctl, cmd, "file", &to) < 0) + if (vshCommandOptString(ctl, cmd, "file", &to) < 0) return false; if (vshCommandOptBool(cmd, "verbose")) @@ -4521,7 +4521,7 @@ cmdSaveImageDumpxml(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "security-info")) flags |= VIR_DOMAIN_XML_SECURE; - if (vshCommandOptStringReq(ctl, cmd, "file", &file) < 0) + if (vshCommandOptString(ctl, cmd, "file", &file) < 0) return false; if (vshCommandOptStringQuiet(ctl, cmd, "xpath", &xpath) < 0) @@ -4581,10 +4581,10 @@ cmdSaveImageDefine(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "paused")) flags |= VIR_DOMAIN_SAVE_PAUSED; - if (vshCommandOptStringReq(ctl, cmd, "file", &file) < 0) + if (vshCommandOptString(ctl, cmd, "file", &file) < 0) return false; - if (vshCommandOptStringReq(ctl, cmd, "xml", &xmlfile) < 0) + if (vshCommandOptString(ctl, cmd, "xml", &xmlfile) < 0) return false; if (virFileReadAll(xmlfile, VSH_MAX_XML_FILE, &xml) < 0) @@ -4645,7 +4645,7 @@ cmdSaveImageEdit(vshControl *ctl, const vshCmd *cmd) * flags, so we reject it up front to avoid looping. */ VSH_EXCLUSIVE_OPTIONS("running", "paused"); - if (vshCommandOptStringReq(ctl, cmd, "file", &file) < 0) + if (vshCommandOptString(ctl, cmd, "file", &file) < 0) return false; #define EDIT_GET_XML \ @@ -4980,7 +4980,7 @@ cmdManagedSaveDefine(vshControl *ctl, const vshCmd *cmd) VSH_EXCLUSIVE_OPTIONS("running", "paused"); - if (vshCommandOptStringReq(ctl, cmd, "xml", &xmlfile) < 0) + if (vshCommandOptString(ctl, cmd, "xml", &xmlfile) < 0) return false; if (virFileReadAll(xmlfile, VSH_MAX_XML_FILE, &xml) < 0) @@ -5089,7 +5089,7 @@ cmdSchedInfoUpdate(vshControl *ctl, const vshCmd *cmd, goto cleanup; } - rv = vshCommandOptStringReq(ctl, cmd, "cap", &val); + rv = vshCommandOptString(ctl, cmd, "cap", &val); if (rv < 0 || (val && cmdSchedInfoUpdateOne(ctl, src_params, nsrc_params, @@ -5097,7 +5097,7 @@ cmdSchedInfoUpdate(vshControl *ctl, const vshCmd *cmd, "cap", val) < 0)) goto cleanup; - rv = vshCommandOptStringReq(ctl, cmd, "weight", &val); + rv = vshCommandOptString(ctl, cmd, "weight", &val); if (rv < 0 || (val && cmdSchedInfoUpdateOne(ctl, src_params, nsrc_params, @@ -5263,7 +5263,7 @@ cmdRestore(vshControl *ctl, const vshCmd *cmd) virshControl *priv = ctl->privData; int rc; - if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) + if (vshCommandOptString(ctl, cmd, "file", &from) < 0) return false; if (vshCommandOptBool(cmd, "bypass-cache")) @@ -5275,7 +5275,7 @@ cmdRestore(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "reset-nvram")) flags |= VIR_DOMAIN_SAVE_RESET_NVRAM; - if (vshCommandOptStringReq(ctl, cmd, "xml", &xmlfile) < 0) + if (vshCommandOptString(ctl, cmd, "xml", &xmlfile) < 0) return false; if (xmlfile && @@ -5372,7 +5372,7 @@ doDump(void *opaque) goto out_sig; #endif /* !WIN32 */ - if (vshCommandOptStringReq(ctl, cmd, "file", &to) < 0) + if (vshCommandOptString(ctl, cmd, "file", &to) < 0) goto out; if (!(dom = virshCommandOptDomain(ctl, cmd, &name))) @@ -5445,7 +5445,7 @@ cmdDump(vshControl *ctl, const vshCmd *cmd) if (!(dom = virshCommandOptDomain(ctl, cmd, &name))) return false; - if (vshCommandOptStringReq(ctl, cmd, "file", &to) < 0) + if (vshCommandOptString(ctl, cmd, "file", &to) < 0) return false; if (vshCommandOptBool(cmd, "verbose")) @@ -5536,7 +5536,7 @@ cmdScreenshot(vshControl *ctl, const vshCmd *cmd) virshControl *priv = ctl->privData; virshStreamCallbackData cbdata; - if (vshCommandOptStringReq(ctl, cmd, "file", (const char **) &file) < 0) + if (vshCommandOptString(ctl, cmd, "file", (const char **) &file) < 0) return false; if (vshCommandOptUInt(ctl, cmd, "screen", &screen) < 0) @@ -5666,8 +5666,8 @@ cmdSetLifecycleAction(vshControl *ctl, const vshCmd *cmd) if (live) flags |= VIR_DOMAIN_AFFECT_LIVE; - if (vshCommandOptStringReq(ctl, cmd, "type", &typeStr) < 0 || - vshCommandOptStringReq(ctl, cmd, "action", &actionStr) < 0) { + if (vshCommandOptString(ctl, cmd, "type", &typeStr) < 0 || + vshCommandOptString(ctl, cmd, "action", &actionStr) < 0) { return false; } @@ -5735,10 +5735,10 @@ cmdSetUserPassword(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "encrypted")) flags = VIR_DOMAIN_PASSWORD_ENCRYPTED; - if (vshCommandOptStringReq(ctl, cmd, "user", &user) < 0) + if (vshCommandOptString(ctl, cmd, "user", &user) < 0) return false; - if (vshCommandOptStringReq(ctl, cmd, "password", &password) < 0) + if (vshCommandOptString(ctl, cmd, "password", &password) < 0) return false; if (!(dom = virshCommandOptDomain(ctl, cmd, &name))) @@ -5811,7 +5811,7 @@ cmdShutdown(vshControl *ctl, const vshCmd *cmd) g_auto(GStrv) modes = NULL; char **tmp; - if (vshCommandOptStringReq(ctl, cmd, "mode", &mode) < 0) + if (vshCommandOptString(ctl, cmd, "mode", &mode) < 0) return false; if (mode && !(modes = g_strsplit(mode, ",", 0))) { @@ -5886,7 +5886,7 @@ cmdReboot(vshControl *ctl, const vshCmd *cmd) g_auto(GStrv) modes = NULL; char **tmp; - if (vshCommandOptStringReq(ctl, cmd, "mode", &mode) < 0) + if (vshCommandOptString(ctl, cmd, "mode", &mode) < 0) return false; if (mode && !(modes = g_strsplit(mode, ",", 0))) { @@ -6982,7 +6982,7 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd) if (live) flags |= VIR_DOMAIN_AFFECT_LIVE; - if (vshCommandOptStringReq(ctl, cmd, "cpulist", &cpulist) < 0) + if (vshCommandOptString(ctl, cmd, "cpulist", &cpulist) < 0) return false; if (!cpulist) @@ -7076,7 +7076,7 @@ cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd) if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "cpulist", &cpulist) < 0) { + if (vshCommandOptString(ctl, cmd, "cpulist", &cpulist) < 0) { return false; } query = !cpulist; @@ -7253,7 +7253,7 @@ cmdGuestvcpus(vshControl *ctl, const vshCmd *cmd) VSH_REQUIRE_OPTION("enable", "cpulist"); VSH_REQUIRE_OPTION("disable", "cpulist"); - if (vshCommandOptStringReq(ctl, cmd, "cpulist", &cpulist)) + if (vshCommandOptString(ctl, cmd, "cpulist", &cpulist)) return false; if (cpulist && !(enable || disable)) { @@ -7346,7 +7346,7 @@ cmdSetvcpu(vshControl *ctl, const vshCmd *cmd) return false; } - if (vshCommandOptStringReq(ctl, cmd, "vcpulist", &vcpulist)) + if (vshCommandOptString(ctl, cmd, "vcpulist", &vcpulist)) return false; if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) @@ -7396,7 +7396,7 @@ cmdDomblkthreshold(vshControl *ctl, const vshCmd *cmd) const char *dev = NULL; g_autoptr(virshDomain) dom = NULL; - if (vshCommandOptStringReq(ctl, cmd, "dev", &dev)) + if (vshCommandOptString(ctl, cmd, "dev", &dev)) return false; if (vshCommandOptScaledInt(ctl, cmd, "threshold", @@ -7552,7 +7552,7 @@ cmdIOThreadPin(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptUInt(ctl, cmd, "iothread", &iothread_id) < 0) return false; - if (vshCommandOptStringReq(ctl, cmd, "cpulist", &cpulist) < 0) + if (vshCommandOptString(ctl, cmd, "cpulist", &cpulist) < 0) return false; if ((maxcpu = virshNodeGetCPUCount(priv->conn)) < 0) @@ -8052,7 +8052,7 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd) g_autofree int *fds = NULL; virshControl *priv = ctl->privData; - if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) + if (vshCommandOptString(ctl, cmd, "file", &from) < 0) return false; if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) @@ -8129,7 +8129,7 @@ cmdDefine(vshControl *ctl, const vshCmd *cmd) unsigned int flags = 0; virshControl *priv = ctl->privData; - if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) + if (vshCommandOptString(ctl, cmd, "file", &from) < 0) return false; if (vshCommandOptBool(cmd, "validate")) @@ -8432,9 +8432,9 @@ cmdMetadata(vshControl *ctl, const vshCmd *cmd) if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "uri", &uri) < 0 || - vshCommandOptStringReq(ctl, cmd, "key", &key) < 0 || - vshCommandOptStringReq(ctl, cmd, "set", &set) < 0) + if (vshCommandOptString(ctl, cmd, "uri", &uri) < 0 || + vshCommandOptString(ctl, cmd, "key", &key) < 0 || + vshCommandOptString(ctl, cmd, "set", &set) < 0) return false; if ((set || edit) && !key) { @@ -8684,7 +8684,7 @@ cmdSendProcessSignal(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptLongLong(ctl, cmd, "pid", &pid_value) < 0) return false; - if (vshCommandOptStringReq(ctl, cmd, "signame", &signame) < 0) + if (vshCommandOptString(ctl, cmd, "signame", &signame) < 0) return false; if ((signum = getSignalNumber(signame)) < 0) { @@ -8896,7 +8896,7 @@ virshGetUpdatedMemoryXML(char **updatedMemoryXML, return -1; nodeOpt = vshCommandOptBool(cmd, "node"); - if (vshCommandOptStringReq(ctl, cmd, "alias", &alias) < 0 || + if (vshCommandOptString(ctl, cmd, "alias", &alias) < 0 || vshCommandOptUInt(ctl, cmd, "node", &node) < 0) { return -1; } @@ -9248,8 +9248,8 @@ cmdPerf(vshControl *ctl, const vshCmd *cmd) if (live) flags |= VIR_DOMAIN_AFFECT_LIVE; - if (vshCommandOptStringReq(ctl, cmd, "enable", &enable) < 0 || - vshCommandOptStringReq(ctl, cmd, "disable", &disable) < 0) + if (vshCommandOptString(ctl, cmd, "enable", &enable) < 0 || + vshCommandOptString(ctl, cmd, "disable", &disable) < 0) return false; if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) @@ -9340,7 +9340,7 @@ cmdNumatune(vshControl * ctl, const vshCmd * cmd) if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "nodeset", &nodeset) < 0) + if (vshCommandOptString(ctl, cmd, "nodeset", &nodeset) < 0) goto cleanup; if (nodeset && @@ -9348,7 +9348,7 @@ cmdNumatune(vshControl * ctl, const vshCmd * cmd) VIR_DOMAIN_NUMA_NODESET, nodeset) < 0) goto save_error; - if (vshCommandOptStringReq(ctl, cmd, "mode", &mode) < 0) + if (vshCommandOptString(ctl, cmd, "mode", &mode) < 0) goto cleanup; if (mode) { @@ -9502,10 +9502,10 @@ cmdDomSetLaunchSecState(vshControl * ctl, const vshCmd * cmd) if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "secrethdr", &sechdrfile) < 0) + if (vshCommandOptString(ctl, cmd, "secrethdr", &sechdrfile) < 0) return false; - if (vshCommandOptStringReq(ctl, cmd, "secret", &secfile) < 0) + if (vshCommandOptString(ctl, cmd, "secret", &secfile) < 0) return false; if (sechdrfile == NULL || secfile == NULL) { @@ -9609,7 +9609,7 @@ cmdDomFdAssociate(vshControl *ctl, const vshCmd *cmd) if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0) + if (vshCommandOptString(ctl, cmd, "name", &name) < 0) return false; if (virshFetchPassFdsList(ctl, cmd, &nfds, &fds) < 0) @@ -9941,7 +9941,7 @@ cmdQemuMonitorEvent(vshControl *ctl, const vshCmd *cmd) data.count = 0; if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0) return false; - if (vshCommandOptStringReq(ctl, cmd, "event", &event) < 0) + if (vshCommandOptString(ctl, cmd, "event", &event) < 0) return false; if (vshCommandOptBool(cmd, "domain")) @@ -10350,8 +10350,8 @@ cmdDomXMLFromNative(vshControl *ctl, const vshCmd *cmd) unsigned int flags = 0; virshControl *priv = ctl->privData; - if (vshCommandOptStringReq(ctl, cmd, "format", &format) < 0 || - vshCommandOptStringReq(ctl, cmd, "config", &configFile) < 0) + if (vshCommandOptString(ctl, cmd, "format", &format) < 0 || + vshCommandOptString(ctl, cmd, "config", &configFile) < 0) return false; if (virFileReadAll(configFile, VSH_MAX_XML_FILE, &configData) < 0) @@ -10405,8 +10405,8 @@ cmdDomXMLToNative(vshControl *ctl, const vshCmd *cmd) virshControl *priv = ctl->privData; g_autoptr(virshDomain) dom = NULL; - if (vshCommandOptStringReq(ctl, cmd, "format", &format) < 0 || - vshCommandOptStringReq(ctl, cmd, "xml", &xmlFile) < 0) + if (vshCommandOptString(ctl, cmd, "format", &format) < 0 || + vshCommandOptString(ctl, cmd, "xml", &xmlFile) < 0) return false; VSH_EXCLUSIVE_OPTIONS("domain", "xml"); @@ -10500,7 +10500,7 @@ cmdDomrename(vshControl *ctl, const vshCmd *cmd) if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "new-name", &new_name) < 0) + if (vshCommandOptString(ctl, cmd, "new-name", &new_name) < 0) return false; if (virDomainRename(dom, new_name, 0) < 0) @@ -10881,24 +10881,24 @@ doMigrate(void *opaque) if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) goto out; - if (vshCommandOptStringReq(ctl, cmd, "desturi", &desturi) < 0) + if (vshCommandOptString(ctl, cmd, "desturi", &desturi) < 0) goto out; - if (vshCommandOptStringReq(ctl, cmd, "migrateuri", &opt) < 0) + if (vshCommandOptString(ctl, cmd, "migrateuri", &opt) < 0) goto out; if (opt && virTypedParamsAddString(¶ms, &nparams, &maxparams, VIR_MIGRATE_PARAM_URI, opt) < 0) goto save_error; - if (vshCommandOptStringReq(ctl, cmd, "graphicsuri", &opt) < 0) + if (vshCommandOptString(ctl, cmd, "graphicsuri", &opt) < 0) goto out; if (opt && virTypedParamsAddString(¶ms, &nparams, &maxparams, VIR_MIGRATE_PARAM_GRAPHICS_URI, opt) < 0) goto save_error; - if (vshCommandOptStringReq(ctl, cmd, "listen-address", &opt) < 0) + if (vshCommandOptString(ctl, cmd, "listen-address", &opt) < 0) goto out; if (opt && virTypedParamsAddString(¶ms, &nparams, &maxparams, @@ -10912,7 +10912,7 @@ doMigrate(void *opaque) VIR_MIGRATE_PARAM_DISKS_PORT, intOpt) < 0) goto save_error; - if (vshCommandOptStringReq(ctl, cmd, "disks-uri", &opt) < 0) + if (vshCommandOptString(ctl, cmd, "disks-uri", &opt) < 0) goto out; if (opt && virTypedParamsAddString(¶ms, &nparams, &maxparams, @@ -10920,14 +10920,14 @@ doMigrate(void *opaque) opt) < 0) goto save_error; - if (vshCommandOptStringReq(ctl, cmd, "dname", &opt) < 0) + if (vshCommandOptString(ctl, cmd, "dname", &opt) < 0) goto out; if (opt && virTypedParamsAddString(¶ms, &nparams, &maxparams, VIR_MIGRATE_PARAM_DEST_NAME, opt) < 0) goto save_error; - if (vshCommandOptStringReq(ctl, cmd, "migrate-disks", &opt) < 0) + if (vshCommandOptString(ctl, cmd, "migrate-disks", &opt) < 0) goto out; if (opt) { g_autofree char **val = NULL; @@ -10948,7 +10948,7 @@ doMigrate(void *opaque) } } - if (vshCommandOptStringReq(ctl, cmd, "comp-methods", &opt) < 0) + if (vshCommandOptString(ctl, cmd, "comp-methods", &opt) < 0) goto out; if (opt) { g_autofree char **val = g_strsplit(opt, ",", 0); @@ -10998,7 +10998,7 @@ doMigrate(void *opaque) goto save_error; } - if (vshCommandOptStringReq(ctl, cmd, "xml", &opt) < 0) + if (vshCommandOptString(ctl, cmd, "xml", &opt) < 0) goto out; if (opt) { g_autofree char *xml = NULL; @@ -11014,7 +11014,7 @@ doMigrate(void *opaque) } } - if (vshCommandOptStringReq(ctl, cmd, "persistent-xml", &opt) < 0) + if (vshCommandOptString(ctl, cmd, "persistent-xml", &opt) < 0) goto out; if (opt) { g_autofree char *xml = NULL; @@ -11093,7 +11093,7 @@ doMigrate(void *opaque) goto save_error; } - if (vshCommandOptStringReq(ctl, cmd, "tls-destination", &opt) < 0) + if (vshCommandOptString(ctl, cmd, "tls-destination", &opt) < 0) goto out; if (opt && virTypedParamsAddString(¶ms, &nparams, &maxparams, @@ -11250,7 +11250,7 @@ cmdMigrate(vshControl *ctl, const vshCmd *cmd) virConnectPtr dconn = NULL; const char *desturi = NULL; - if (vshCommandOptStringReq(ctl, cmd, "desturi", &desturi) < 0) + if (vshCommandOptString(ctl, cmd, "desturi", &desturi) < 0) goto cleanup; dconn = virshConnect(ctl, desturi, false); @@ -11722,7 +11722,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "include-password")) flags |= VIR_DOMAIN_XML_SECURE; - if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0) + if (vshCommandOptString(ctl, cmd, "type", &type) < 0) return false; if (virshDomainGetXMLFromDom(ctl, dom, flags, &xml, &ctxt) < 0) @@ -11885,7 +11885,7 @@ cmdDomHostname(vshControl *ctl, const vshCmd *cmd) if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "source", &sourcestr) < 0) + if (vshCommandOptString(ctl, cmd, "source", &sourcestr) < 0) return false; if (sourcestr) { @@ -11966,7 +11966,7 @@ cmdDetachDevice(vshControl *ctl, const vshCmd *cmd) virDomainIsActive(dom) == 1) flags |= VIR_DOMAIN_AFFECT_LIVE; - if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) + if (vshCommandOptString(ctl, cmd, "file", &from) < 0) return false; if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) { @@ -12033,7 +12033,7 @@ cmdDetachDeviceAlias(vshControl *ctl, const vshCmd *cmd) if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "alias", &alias) < 0) + if (vshCommandOptString(ctl, cmd, "alias", &alias) < 0) return false; if (virDomainDetachDeviceAlias(dom, alias, flags) < 0) { @@ -12093,7 +12093,7 @@ cmdUpdateDevice(vshControl *ctl, const vshCmd *cmd) if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) + if (vshCommandOptString(ctl, cmd, "file", &from) < 0) return false; if (persistent && @@ -12255,10 +12255,10 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd) if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0) + if (vshCommandOptString(ctl, cmd, "type", &type) < 0) goto cleanup; - if (vshCommandOptStringReq(ctl, cmd, "mac", &mac) < 0) + if (vshCommandOptString(ctl, cmd, "mac", &mac) < 0) goto cleanup; affect_config = (config || persistent); @@ -12548,7 +12548,7 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd) if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "target", &target) < 0) + if (vshCommandOptString(ctl, cmd, "target", &target) < 0) return false; if (flags == VIR_DOMAIN_AFFECT_CONFIG) @@ -12736,7 +12736,7 @@ cmdChangeMedia(vshControl *ctl, const vshCmd *cmd) VSH_EXCLUSIVE_OPTIONS_VAR(eject, block); - if (vshCommandOptStringReq(ctl, cmd, "source", &source) < 0) + if (vshCommandOptString(ctl, cmd, "source", &source) < 0) return false; /* Docs state that update without source is eject */ @@ -12776,7 +12776,7 @@ cmdChangeMedia(vshControl *ctl, const vshCmd *cmd) if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0) + if (vshCommandOptString(ctl, cmd, "path", &path) < 0) return false; if (flags & VIR_DOMAIN_AFFECT_CONFIG) @@ -12842,7 +12842,7 @@ cmdDomFSTrim(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptULongLong(ctl, cmd, "minimum", &minimum) < 0) return false; - if (vshCommandOptStringReq(ctl, cmd, "mountpoint", &mountPoint) < 0) + if (vshCommandOptString(ctl, cmd, "mountpoint", &mountPoint) < 0) return false; if (virDomainFSTrim(dom, mountPoint, minimum, flags) < 0) { @@ -13164,7 +13164,7 @@ cmdGetUserSSHKeys(vshControl *ctl, const vshCmd *cmd) if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "user", &user) < 0) + if (vshCommandOptString(ctl, cmd, "user", &user) < 0) return false; nkeys = virDomainAuthorizedSSHKeysGet(dom, user, &keys, flags); @@ -13230,10 +13230,10 @@ cmdSetUserSSHKeys(vshControl *ctl, const vshCmd *cmd) if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "user", &user) < 0) + if (vshCommandOptString(ctl, cmd, "user", &user) < 0) return false; - if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) + if (vshCommandOptString(ctl, cmd, "file", &from) < 0) return false; if (vshCommandOptBool(cmd, "remove")) { @@ -13323,7 +13323,7 @@ cmdDomDirtyRateCalc(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptInt(ctl, cmd, "seconds", &seconds) < 0) return false; - if (vshCommandOptStringReq(ctl, cmd, "mode", &modestr) < 0) + if (vshCommandOptString(ctl, cmd, "mode", &modestr) < 0) return false; if (modestr) { diff --git a/tools/virsh-host.c b/tools/virsh-host.c index c338b5cd85..2fe64e415f 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -130,10 +130,10 @@ cmdDomCapabilities(vshControl *ctl, const vshCmd *cmd) bool wrap = vshCommandOptBool(cmd, "wrap"); virshControl *priv = ctl->privData; - if (vshCommandOptStringReq(ctl, cmd, "virttype", &virttype) < 0 || - vshCommandOptStringReq(ctl, cmd, "emulatorbin", &emulatorbin) < 0 || - vshCommandOptStringReq(ctl, cmd, "arch", &arch) < 0 || - vshCommandOptStringReq(ctl, cmd, "machine", &machine) < 0 || + if (vshCommandOptString(ctl, cmd, "virttype", &virttype) < 0 || + vshCommandOptString(ctl, cmd, "emulatorbin", &emulatorbin) < 0 || + vshCommandOptString(ctl, cmd, "arch", &arch) < 0 || + vshCommandOptString(ctl, cmd, "machine", &machine) < 0 || vshCommandOptStringQuiet(ctl, cmd, "xpath", &xpath) < 0) return false; @@ -605,7 +605,7 @@ cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd) g_autoptr(xmlXPathContext) ctxt = NULL; virshControl *priv = ctl->privData; - if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0) + if (vshCommandOptString(ctl, cmd, "type", &type) < 0) return false; if ((caps = virConnectGetDomainCapabilities(priv->conn, NULL, NULL, NULL, @@ -977,7 +977,7 @@ cmdNodeSuspend(vshControl *ctl, const vshCmd *cmd) long long duration; virshControl *priv = ctl->privData; - if (vshCommandOptStringReq(ctl, cmd, "target", &target) < 0) + if (vshCommandOptString(ctl, cmd, "target", &target) < 0) return false; if (vshCommandOptLongLong(ctl, cmd, "duration", &duration) < 0) @@ -1189,7 +1189,7 @@ cmdCPUCompare(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "validate")) flags |= VIR_CONNECT_COMPARE_CPU_VALIDATE_XML; - if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) + if (vshCommandOptString(ctl, cmd, "file", &from) < 0) return false; if (!(cpus = vshExtractCPUDefXMLs(ctl, from))) @@ -1258,7 +1258,7 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "migratable")) flags |= VIR_CONNECT_BASELINE_CPU_MIGRATABLE; - if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) + if (vshCommandOptString(ctl, cmd, "file", &from) < 0) return false; if (!(list = vshExtractCPUDefXMLs(ctl, from))) @@ -1300,7 +1300,7 @@ cmdCPUModelNames(vshControl *ctl, const vshCmd *cmd) const char *arch = NULL; virshControl *priv = ctl->privData; - if (vshCommandOptStringReq(ctl, cmd, "arch", &arch) < 0) + if (vshCommandOptString(ctl, cmd, "arch", &arch) < 0) return false; nmodels = virConnectGetCPUModelNames(priv->conn, arch, &models, 0); @@ -1598,11 +1598,11 @@ cmdHypervisorCPUCompare(vshControl *ctl, if (vshCommandOptBool(cmd, "validate")) flags |= VIR_CONNECT_COMPARE_CPU_VALIDATE_XML; - if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0 || - vshCommandOptStringReq(ctl, cmd, "virttype", &virttype) < 0 || - vshCommandOptStringReq(ctl, cmd, "emulator", &emulator) < 0 || - vshCommandOptStringReq(ctl, cmd, "arch", &arch) < 0 || - vshCommandOptStringReq(ctl, cmd, "machine", &machine) < 0) + if (vshCommandOptString(ctl, cmd, "file", &from) < 0 || + vshCommandOptString(ctl, cmd, "virttype", &virttype) < 0 || + vshCommandOptString(ctl, cmd, "emulator", &emulator) < 0 || + vshCommandOptString(ctl, cmd, "arch", &arch) < 0 || + vshCommandOptString(ctl, cmd, "machine", &machine) < 0) return false; if (!(cpus = vshExtractCPUDefXMLs(ctl, from))) @@ -1718,12 +1718,12 @@ cmdHypervisorCPUBaseline(vshControl *ctl, if (vshCommandOptBool(cmd, "migratable")) flags |= VIR_CONNECT_BASELINE_CPU_MIGRATABLE; - if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0 || - vshCommandOptStringReq(ctl, cmd, "virttype", &virttype) < 0 || - vshCommandOptStringReq(ctl, cmd, "emulator", &emulator) < 0 || - vshCommandOptStringReq(ctl, cmd, "arch", &arch) < 0 || - vshCommandOptStringReq(ctl, cmd, "machine", &machine) < 0 || - vshCommandOptStringReq(ctl, cmd, "model", &model) < 0) + if (vshCommandOptString(ctl, cmd, "file", &from) < 0 || + vshCommandOptString(ctl, cmd, "virttype", &virttype) < 0 || + vshCommandOptString(ctl, cmd, "emulator", &emulator) < 0 || + vshCommandOptString(ctl, cmd, "arch", &arch) < 0 || + vshCommandOptString(ctl, cmd, "machine", &machine) < 0 || + vshCommandOptString(ctl, cmd, "model", &model) < 0) return false; VSH_ALTERNATIVE_OPTIONS_EXPR("file", from, "model", model); diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c index 755c0d6455..fda6d55158 100644 --- a/tools/virsh-interface.c +++ b/tools/virsh-interface.c @@ -58,7 +58,7 @@ virshCommandOptInterfaceBy(vshControl *ctl, const vshCmd *cmd, if (!optname) optname = "interface"; - if (vshCommandOptStringReq(ctl, cmd, optname, &n) < 0) + if (vshCommandOptString(ctl, cmd, optname, &n) < 0) return NULL; vshDebug(ctl, VSH_ERR_INFO, "%s: found option <%s>: %s\n", @@ -515,7 +515,7 @@ cmdInterfaceDefine(vshControl *ctl, const vshCmd *cmd) unsigned int flags = 0; virshControl *priv = ctl->privData; - if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) + if (vshCommandOptString(ctl, cmd, "file", &from) < 0) return false; if (vshCommandOptBool(cmd, "validate")) @@ -770,7 +770,7 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd) } /* Name for new bridge device */ - if (vshCommandOptStringReq(ctl, cmd, "bridge", &br_name) < 0) + if (vshCommandOptString(ctl, cmd, "bridge", &br_name) < 0) goto cleanup; /* make sure "new" device doesn't already exist */ diff --git a/tools/virsh-network.c b/tools/virsh-network.c index e6552cbe57..24049a66f3 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -65,7 +65,7 @@ virshCommandOptNetworkBy(vshControl *ctl, const vshCmd *cmd, virCheckFlags(VIRSH_BYUUID | VIRSH_BYNAME, NULL); - if (vshCommandOptStringReq(ctl, cmd, optname, &n) < 0) + if (vshCommandOptString(ctl, cmd, optname, &n) < 0) return NULL; vshDebug(ctl, VSH_ERR_INFO, "%s: found option <%s>: %s\n", @@ -103,7 +103,7 @@ virshCommandOptNetworkPort(vshControl *ctl, const vshCmd *cmd, const char *n = NULL; const char *optname = "port"; - if (vshCommandOptStringReq(ctl, cmd, optname, &n) < 0) + if (vshCommandOptString(ctl, cmd, optname, &n) < 0) return NULL; vshDebug(ctl, VSH_ERR_INFO, "%s: found option <%s>: %s\n", @@ -193,7 +193,7 @@ cmdNetworkCreate(vshControl *ctl, const vshCmd *cmd) unsigned int flags = 0; virshControl *priv = ctl->privData; - if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) + if (vshCommandOptString(ctl, cmd, "file", &from) < 0) return false; if (vshCommandOptBool(cmd, "validate")) @@ -244,7 +244,7 @@ cmdNetworkDefine(vshControl *ctl, const vshCmd *cmd) unsigned int flags = 0; virshControl *priv = ctl->privData; - if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) + if (vshCommandOptString(ctl, cmd, "file", &from) < 0) return false; if (vshCommandOptBool(cmd, "validate")) @@ -570,9 +570,9 @@ cmdNetworkMetadata(vshControl *ctl, const vshCmd *cmd) if (!(net = virshCommandOptNetwork(ctl, cmd, NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "uri", &uri) < 0 || - vshCommandOptStringReq(ctl, cmd, "key", &key) < 0 || - vshCommandOptStringReq(ctl, cmd, "set", &set) < 0) + if (vshCommandOptString(ctl, cmd, "uri", &uri) < 0 || + vshCommandOptString(ctl, cmd, "key", &key) < 0 || + vshCommandOptString(ctl, cmd, "set", &set) < 0) return false; if ((set || edit) && !key) { @@ -1281,7 +1281,7 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd) if (!(network = virshCommandOptNetwork(ctl, cmd, NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "command", &commandStr) < 0) + if (vshCommandOptString(ctl, cmd, "command", &commandStr) < 0) goto cleanup; if (STREQ(commandStr, "add")) { @@ -1295,7 +1295,7 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd) } } - if (vshCommandOptStringReq(ctl, cmd, "section", §ionStr) < 0) + if (vshCommandOptString(ctl, cmd, "section", §ionStr) < 0) goto cleanup; section = virshNetworkSectionTypeFromString(sectionStr); @@ -1314,7 +1314,7 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd) * the desired xml. */ - if (vshCommandOptStringReq(ctl, cmd, "xml", &xml) < 0) + if (vshCommandOptString(ctl, cmd, "xml", &xml) < 0) goto cleanup; if (*xml != '<') { @@ -1631,7 +1631,7 @@ cmdNetworkEvent(vshControl *ctl, const vshCmd *cmd) return true; } - if (vshCommandOptStringReq(ctl, cmd, "event", &eventName) < 0) + if (vshCommandOptString(ctl, cmd, "event", &eventName) < 0) return false; if (!eventName) { vshError(ctl, "%s", _("either --list or --event is required")); @@ -1736,7 +1736,7 @@ cmdNetworkDHCPLeases(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshNetwork) network = NULL; g_autoptr(vshTable) table = NULL; - if (vshCommandOptStringReq(ctl, cmd, "mac", &mac) < 0) + if (vshCommandOptString(ctl, cmd, "mac", &mac) < 0) return false; if (!(network = virshCommandOptNetwork(ctl, cmd, &name))) @@ -1829,7 +1829,7 @@ cmdNetworkPortCreate(vshControl *ctl, const vshCmd *cmd) if (network == NULL) goto cleanup; - if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) + if (vshCommandOptString(ctl, cmd, "file", &from) < 0) goto cleanup; if (vshCommandOptBool(cmd, "validate")) diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index b0563395f0..910eaefc9e 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -61,7 +61,7 @@ cmdNodeDeviceCreate(vshControl *ctl, const vshCmd *cmd) virshControl *priv = ctl->privData; unsigned int flags = 0; - if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) + if (vshCommandOptString(ctl, cmd, "file", &from) < 0) return false; if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) @@ -142,7 +142,7 @@ cmdNodeDeviceDestroy(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshNodeDevice) dev = NULL; const char *device_value = NULL; - if (vshCommandOptStringReq(ctl, cmd, "device", &device_value) < 0) + if (vshCommandOptString(ctl, cmd, "device", &device_value) < 0) return false; dev = vshFindNodeDevice(ctl, device_value); @@ -604,7 +604,7 @@ cmdNodeDeviceDumpXML(vshControl *ctl, const vshCmd *cmd) bool wrap = vshCommandOptBool(cmd, "wrap"); const char *xpath = NULL; - if (vshCommandOptStringReq(ctl, cmd, "device", &device_value) < 0) + if (vshCommandOptString(ctl, cmd, "device", &device_value) < 0) return false; if (vshCommandOptStringQuiet(ctl, cmd, "xpath", &xpath) < 0) @@ -659,7 +659,7 @@ cmdNodeDeviceDetach(vshControl *ctl, const vshCmd *cmd) bool ret = true; virshControl *priv = ctl->privData; - if (vshCommandOptStringReq(ctl, cmd, "device", &name) < 0) + if (vshCommandOptString(ctl, cmd, "device", &name) < 0) return false; ignore_value(vshCommandOptStringQuiet(ctl, cmd, "driver", &driverName)); @@ -716,7 +716,7 @@ cmdNodeDeviceReAttach(vshControl *ctl, const vshCmd *cmd) bool ret = true; virshControl *priv = ctl->privData; - if (vshCommandOptStringReq(ctl, cmd, "device", &name) < 0) + if (vshCommandOptString(ctl, cmd, "device", &name) < 0) return false; if (!(device = virNodeDeviceLookupByName(priv->conn, name))) { @@ -762,7 +762,7 @@ cmdNodeDeviceReset(vshControl *ctl, const vshCmd *cmd) bool ret = true; virshControl *priv = ctl->privData; - if (vshCommandOptStringReq(ctl, cmd, "device", &name) < 0) + if (vshCommandOptString(ctl, cmd, "device", &name) < 0) return false; if (!(device = virNodeDeviceLookupByName(priv->conn, name))) { @@ -936,7 +936,7 @@ cmdNodeDeviceEvent(vshControl *ctl, const vshCmd *cmd) return true; } - if (vshCommandOptStringReq(ctl, cmd, "event", &eventName) < 0) + if (vshCommandOptString(ctl, cmd, "event", &eventName) < 0) return false; if (!eventName) { vshError(ctl, "%s", _("either --list or --event is required")); @@ -958,7 +958,7 @@ cmdNodeDeviceEvent(vshControl *ctl, const vshCmd *cmd) data.cb = &virshNodeDeviceEventCallbacks[event]; if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0) return false; - if (vshCommandOptStringReq(ctl, cmd, "device", &device_value) < 0) + if (vshCommandOptString(ctl, cmd, "device", &device_value) < 0) return false; if (device_value) { @@ -1025,7 +1025,7 @@ cmdNodeDeviceUndefine(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED) g_autoptr(virshNodeDevice) dev = NULL; const char *device_value = NULL; - if (vshCommandOptStringReq(ctl, cmd, "device", &device_value) < 0) + if (vshCommandOptString(ctl, cmd, "device", &device_value) < 0) return false; dev = vshFindNodeDevice(ctl, device_value); @@ -1072,7 +1072,7 @@ cmdNodeDeviceDefine(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED) virshControl *priv = ctl->privData; unsigned int flags = 0; - if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) + if (vshCommandOptString(ctl, cmd, "file", &from) < 0) return false; if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) @@ -1119,7 +1119,7 @@ cmdNodeDeviceStart(vshControl *ctl, const vshCmd *cmd) bool ret = true; virshControl *priv = ctl->privData; - if (vshCommandOptStringReq(ctl, cmd, "device", &name) < 0) + if (vshCommandOptString(ctl, cmd, "device", &name) < 0) return false; if (!(device = virNodeDeviceLookupByName(priv->conn, name))) { @@ -1168,7 +1168,7 @@ cmdNodeDeviceAutostart(vshControl *ctl, const vshCmd *cmd) const char *name = NULL; int autostart; - if (vshCommandOptStringReq(ctl, cmd, "device", &name) < 0) + if (vshCommandOptString(ctl, cmd, "device", &name) < 0) return false; dev = vshFindNodeDevice(ctl, name); @@ -1223,7 +1223,7 @@ cmdNodeDeviceInfo(vshControl *ctl, const vshCmd *cmd) int autostart; const char *parent = NULL; - if (vshCommandOptStringReq(ctl, cmd, "device", &device_value) < 0) + if (vshCommandOptString(ctl, cmd, "device", &device_value) < 0) return false; device = vshFindNodeDevice(ctl, device_value); @@ -1286,7 +1286,7 @@ cmdNodeDeviceUpdate(vshControl *ctl, const vshCmd *cmd) VSH_EXCLUSIVE_OPTIONS("current", "live"); VSH_EXCLUSIVE_OPTIONS("current", "config"); - if (vshCommandOptStringReq(ctl, cmd, "device", &device_value) < 0) + if (vshCommandOptString(ctl, cmd, "device", &device_value) < 0) return false; device = vshFindNodeDevice(ctl, device_value); @@ -1294,7 +1294,7 @@ cmdNodeDeviceUpdate(vshControl *ctl, const vshCmd *cmd) if (!device) return false; - if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) + if (vshCommandOptString(ctl, cmd, "file", &from) < 0) goto cleanup; if (virFileReadAll(from, VSH_MAX_XML_FILE, &xml) < 0) diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c index 69473b4935..56133d6566 100644 --- a/tools/virsh-nwfilter.c +++ b/tools/virsh-nwfilter.c @@ -38,7 +38,7 @@ virshCommandOptNWFilterBy(vshControl *ctl, const vshCmd *cmd, virCheckFlags(VIRSH_BYUUID | VIRSH_BYNAME, NULL); - if (vshCommandOptStringReq(ctl, cmd, optname, &n) < 0) + if (vshCommandOptString(ctl, cmd, optname, &n) < 0) return NULL; vshDebug(ctl, VSH_ERR_INFO, "%s: found option <%s>: %s\n", @@ -94,7 +94,7 @@ cmdNWFilterDefine(vshControl *ctl, const vshCmd *cmd) unsigned int flags = 0; virshControl *priv = ctl->privData; - if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) + if (vshCommandOptString(ctl, cmd, "file", &from) < 0) return false; if (vshCommandOptBool(cmd, "validate")) @@ -447,7 +447,7 @@ virshCommandOptNWFilterBindingBy(vshControl *ctl, virCheckFlags(0, NULL); - if (vshCommandOptStringReq(ctl, cmd, optname, &n) < 0) + if (vshCommandOptString(ctl, cmd, optname, &n) < 0) return NULL; vshDebug(ctl, VSH_ERR_INFO, "%s: found option <%s>: %s\n", @@ -494,7 +494,7 @@ cmdNWFilterBindingCreate(vshControl *ctl, const vshCmd *cmd) unsigned int flags = 0; virshControl *priv = ctl->privData; - if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) + if (vshCommandOptString(ctl, cmd, "file", &from) < 0) return false; if (vshCommandOptBool(cmd, "validate")) diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index 24e7bb9bf5..f9aad8ded0 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -180,7 +180,7 @@ virshCommandOptPoolBy(vshControl *ctl, const vshCmd *cmd, const char *optname, virCheckFlags(VIRSH_BYUUID | VIRSH_BYNAME, NULL); - if (vshCommandOptStringReq(ctl, cmd, optname, &n) < 0) + if (vshCommandOptString(ctl, cmd, optname, &n) < 0) return NULL; if (cmd->skipChecks && !n) @@ -286,7 +286,7 @@ cmdPoolCreate(vshControl *ctl, const vshCmd *cmd) unsigned int flags = 0; virshControl *priv = ctl->privData; - if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) + if (vshCommandOptString(ctl, cmd, "file", &from) < 0) return false; build = vshCommandOptBool(cmd, "build"); @@ -340,31 +340,31 @@ virshBuildPoolXML(vshControl *ctl, VSH_EXCLUSIVE_OPTIONS("secret-usage", "secret-uuid"); - if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0) + if (vshCommandOptString(ctl, cmd, "name", &name) < 0) return false; - if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0) + if (vshCommandOptString(ctl, cmd, "type", &type) < 0) return false; - if (vshCommandOptStringReq(ctl, cmd, "source-host", &srcHost) < 0 || - vshCommandOptStringReq(ctl, cmd, "source-path", &srcPath) < 0 || - vshCommandOptStringReq(ctl, cmd, "source-dev", &srcDev) < 0 || - vshCommandOptStringReq(ctl, cmd, "source-name", &srcName) < 0 || - vshCommandOptStringReq(ctl, cmd, "source-format", &srcFormat) < 0 || - vshCommandOptStringReq(ctl, cmd, "target", &target) < 0 || - vshCommandOptStringReq(ctl, cmd, "auth-type", &authType) < 0 || - vshCommandOptStringReq(ctl, cmd, "auth-username", &authUsername) < 0 || - vshCommandOptStringReq(ctl, cmd, "secret-usage", &secretUsage) < 0 || - vshCommandOptStringReq(ctl, cmd, "secret-uuid", &secretUUID) < 0 || - vshCommandOptStringReq(ctl, cmd, "adapter-name", &adapterName) < 0 || - vshCommandOptStringReq(ctl, cmd, "adapter-wwnn", &adapterWwnn) < 0 || - vshCommandOptStringReq(ctl, cmd, "adapter-wwpn", &adapterWwpn) < 0 || - vshCommandOptStringReq(ctl, cmd, "adapter-parent", &adapterParent) < 0 || - vshCommandOptStringReq(ctl, cmd, "adapter-parent-wwnn", &adapterParentWwnn) < 0 || - vshCommandOptStringReq(ctl, cmd, "adapter-parent-wwpn", &adapterParentWwpn) < 0 || - vshCommandOptStringReq(ctl, cmd, "adapter-parent-fabric-wwn", &adapterParentFabricWwn) < 0 || - vshCommandOptStringReq(ctl, cmd, "source-protocol-ver", &protoVer) < 0 || - vshCommandOptStringReq(ctl, cmd, "source-initiator", &srcInitiator) < 0) { + if (vshCommandOptString(ctl, cmd, "source-host", &srcHost) < 0 || + vshCommandOptString(ctl, cmd, "source-path", &srcPath) < 0 || + vshCommandOptString(ctl, cmd, "source-dev", &srcDev) < 0 || + vshCommandOptString(ctl, cmd, "source-name", &srcName) < 0 || + vshCommandOptString(ctl, cmd, "source-format", &srcFormat) < 0 || + vshCommandOptString(ctl, cmd, "target", &target) < 0 || + vshCommandOptString(ctl, cmd, "auth-type", &authType) < 0 || + vshCommandOptString(ctl, cmd, "auth-username", &authUsername) < 0 || + vshCommandOptString(ctl, cmd, "secret-usage", &secretUsage) < 0 || + vshCommandOptString(ctl, cmd, "secret-uuid", &secretUUID) < 0 || + vshCommandOptString(ctl, cmd, "adapter-name", &adapterName) < 0 || + vshCommandOptString(ctl, cmd, "adapter-wwnn", &adapterWwnn) < 0 || + vshCommandOptString(ctl, cmd, "adapter-wwpn", &adapterWwpn) < 0 || + vshCommandOptString(ctl, cmd, "adapter-parent", &adapterParent) < 0 || + vshCommandOptString(ctl, cmd, "adapter-parent-wwnn", &adapterParentWwnn) < 0 || + vshCommandOptString(ctl, cmd, "adapter-parent-wwpn", &adapterParentWwpn) < 0 || + vshCommandOptString(ctl, cmd, "adapter-parent-fabric-wwn", &adapterParentFabricWwn) < 0 || + vshCommandOptString(ctl, cmd, "source-protocol-ver", &protoVer) < 0 || + vshCommandOptString(ctl, cmd, "source-initiator", &srcInitiator) < 0) { return false; } @@ -530,7 +530,7 @@ cmdPoolDefine(vshControl *ctl, const vshCmd *cmd) unsigned int flags = 0; virshControl *priv = ctl->privData; - if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) + if (vshCommandOptString(ctl, cmd, "file", &from) < 0) return false; if (vshCommandOptBool(cmd, "validate")) @@ -1124,7 +1124,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED) if (vshCommandOptBool(cmd, "name")) name = true; - if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0) + if (vshCommandOptString(ctl, cmd, "type", &type) < 0) return false; VSH_EXCLUSIVE_OPTIONS("details", "uuid"); @@ -1407,16 +1407,16 @@ cmdPoolDiscoverSourcesAs(vshControl * ctl, const vshCmd * cmd G_GNUC_UNUSED) const char *initiator = NULL; virshControl *priv = ctl->privData; - if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0 || - vshCommandOptStringReq(ctl, cmd, "host", &host) < 0 || - vshCommandOptStringReq(ctl, cmd, "initiator", &initiator) < 0) + if (vshCommandOptString(ctl, cmd, "type", &type) < 0 || + vshCommandOptString(ctl, cmd, "host", &host) < 0 || + vshCommandOptString(ctl, cmd, "initiator", &initiator) < 0) return false; if (host) { const char *port = NULL; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - if (vshCommandOptStringReq(ctl, cmd, "port", &port) < 0) { + if (vshCommandOptString(ctl, cmd, "port", &port) < 0) { vshError(ctl, "%s", _("missing argument")); return false; } @@ -1480,10 +1480,10 @@ cmdPoolDiscoverSources(vshControl * ctl, const vshCmd * cmd G_GNUC_UNUSED) char *srcSpec = NULL, *srcList; virshControl *priv = ctl->privData; - if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0) + if (vshCommandOptString(ctl, cmd, "type", &type) < 0) return false; - if (vshCommandOptStringReq(ctl, cmd, "srcSpec", &srcSpecFile) < 0) + if (vshCommandOptString(ctl, cmd, "srcSpec", &srcSpecFile) < 0) return false; if (srcSpecFile && virFileReadAll(srcSpecFile, VSH_MAX_XML_FILE, @@ -1952,7 +1952,7 @@ cmdPoolEvent(vshControl *ctl, const vshCmd *cmd) return true; } - if (vshCommandOptStringReq(ctl, cmd, "event", &eventName) < 0) + if (vshCommandOptString(ctl, cmd, "event", &eventName) < 0) return false; if (!eventName) { vshError(ctl, "%s", _("either --list or --event is required")); diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c index 5653451862..d9435e4357 100644 --- a/tools/virsh-secret.c +++ b/tools/virsh-secret.c @@ -41,7 +41,7 @@ virshCommandOptSecret(vshControl *ctl, const vshCmd *cmd, const char **name) const char *optname = "secret"; virshControl *priv = ctl->privData; - if (vshCommandOptStringReq(ctl, cmd, optname, &n) < 0) + if (vshCommandOptString(ctl, cmd, optname, &n) < 0) return NULL; vshDebug(ctl, VSH_ERR_DEBUG, @@ -86,7 +86,7 @@ cmdSecretDefine(vshControl *ctl, const vshCmd *cmd) unsigned int flags = 0; virshControl *priv = ctl->privData; - if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) + if (vshCommandOptString(ctl, cmd, "file", &from) < 0) return false; if (vshCommandOptBool(cmd, "validate")) @@ -227,10 +227,10 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd) if (!(secret = virshCommandOptSecret(ctl, cmd, NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "base64", &base64) < 0) + if (vshCommandOptString(ctl, cmd, "base64", &base64) < 0) return false; - if (vshCommandOptStringReq(ctl, cmd, "file", &filename) < 0) + if (vshCommandOptString(ctl, cmd, "file", &filename) < 0) return false; if (base64) { @@ -763,7 +763,7 @@ cmdSecretEvent(vshControl *ctl, const vshCmd *cmd) return true; } - if (vshCommandOptStringReq(ctl, cmd, "event", &eventName) < 0) + if (vshCommandOptString(ctl, cmd, "event", &eventName) < 0) return false; if (!eventName) { vshError(ctl, "%s", _("either --list or --event is required")); diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index 80448ca08d..415a390786 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -182,7 +182,7 @@ cmdSnapshotCreate(vshControl *ctl, const vshCmd *cmd) if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "xmlfile", &from) < 0) + if (vshCommandOptString(ctl, cmd, "xmlfile", &from) < 0) return false; if (!from) { buffer = g_strdup(""); @@ -401,8 +401,8 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd) if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0 || - vshCommandOptStringReq(ctl, cmd, "description", &desc) < 0) + if (vshCommandOptString(ctl, cmd, "name", &name) < 0 || + vshCommandOptString(ctl, cmd, "description", &desc) < 0) return false; virBufferAddLit(&buf, "\n"); @@ -410,7 +410,7 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd) virBufferEscapeString(&buf, "%s\n", name); virBufferEscapeString(&buf, "%s\n", desc); - if (vshCommandOptStringReq(ctl, cmd, "memspec", &memspec) < 0) + if (vshCommandOptString(ctl, cmd, "memspec", &memspec) < 0) return false; if (memspec && virshParseSnapshotMemspec(ctl, &buf, memspec) < 0) @@ -451,7 +451,7 @@ virshLookupSnapshot(vshControl *ctl, const vshCmd *cmd, bool current = vshCommandOptBool(cmd, "current"); const char *snapname = NULL; - if (vshCommandOptStringReq(ctl, cmd, arg, &snapname) < 0) + if (vshCommandOptString(ctl, cmd, arg, &snapname) < 0) return -1; if (exclusive && current && snapname) { @@ -629,7 +629,7 @@ cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd) if (!(dom = virshCommandOptDomain(ctl, cmd, &domname))) return false; - if (vshCommandOptStringReq(ctl, cmd, "snapshotname", &snapshotname) < 0) + if (vshCommandOptString(ctl, cmd, "snapshotname", &snapshotname) < 0) goto cleanup; if (snapshotname) { @@ -1616,7 +1616,7 @@ cmdSnapshotDumpXML(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "security-info")) flags |= VIR_DOMAIN_XML_SECURE; - if (vshCommandOptStringReq(ctl, cmd, "snapshotname", &name) < 0) + if (vshCommandOptString(ctl, cmd, "snapshotname", &name) < 0) return false; if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) diff --git a/tools/virsh-util.c b/tools/virsh-util.c index a6026eed53..ab350f0326 100644 --- a/tools/virsh-util.c +++ b/tools/virsh-util.c @@ -87,7 +87,7 @@ virshCommandOptDomainBy(vshControl *ctl, const char *n = NULL; const char *optname = "domain"; - if (vshCommandOptStringReq(ctl, cmd, optname, &n) < 0) + if (vshCommandOptString(ctl, cmd, optname, &n) < 0) return NULL; vshDebug(ctl, VSH_ERR_INFO, "%s: found option <%s>: %s\n", diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index 67a6f2eda0..8805b8c06b 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -92,11 +92,11 @@ virshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd, virCheckFlags(VIRSH_BYUUID | VIRSH_BYNAME, NULL); - if (vshCommandOptStringReq(ctl, cmd, optname, &n) < 0) + if (vshCommandOptString(ctl, cmd, optname, &n) < 0) return NULL; if (pooloptname != NULL && - vshCommandOptStringReq(ctl, cmd, pooloptname, &p) < 0) + vshCommandOptString(ctl, cmd, pooloptname, &p) < 0) return NULL; if (p) { @@ -249,10 +249,10 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd) if (!(pool = virshCommandOptPool(ctl, cmd, "pool", NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0) + if (vshCommandOptString(ctl, cmd, "name", &name) < 0) return false; - if (vshCommandOptStringReq(ctl, cmd, "capacity", &capacityStr) < 0) + if (vshCommandOptString(ctl, cmd, "capacity", &capacityStr) < 0) return false; if (virshVolSize(capacityStr, &capacity) < 0) { @@ -266,10 +266,9 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd) return false; } - if (vshCommandOptStringReq(ctl, cmd, "format", &format) < 0 || - vshCommandOptStringReq(ctl, cmd, "backing-vol", &snapshotStrVol) < 0 || - vshCommandOptStringReq(ctl, cmd, "backing-vol-format", - &snapshotStrFormat) < 0) + if (vshCommandOptString(ctl, cmd, "format", &format) < 0 || + vshCommandOptString(ctl, cmd, "backing-vol", &snapshotStrVol) < 0 || + vshCommandOptString(ctl, cmd, "backing-vol-format", &snapshotStrFormat) < 0) return false; virBufferAddLit(&buf, "\n"); @@ -404,7 +403,7 @@ cmdVolCreate(vshControl *ctl, const vshCmd *cmd) if (!(pool = virshCommandOptPool(ctl, cmd, "pool", NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) + if (vshCommandOptString(ctl, cmd, "file", &from) < 0) return false; if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) { @@ -477,7 +476,7 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "validate")) flags |= VIR_STORAGE_VOL_CREATE_VALIDATE; - if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) + if (vshCommandOptString(ctl, cmd, "file", &from) < 0) return false; if (!(inputvol = virshCommandOptVol(ctl, cmd, "vol", "inputpool", NULL))) @@ -577,7 +576,7 @@ cmdVolClone(vshControl *ctl, const vshCmd *cmd) return false; } - if (vshCommandOptStringReq(ctl, cmd, "newname", &name) < 0) + if (vshCommandOptString(ctl, cmd, "newname", &name) < 0) return false; if (!(origxml = virStorageVolGetXMLDesc(origvol, 0))) @@ -656,7 +655,7 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd) if (!(vol = virshCommandOptVol(ctl, cmd, "vol", "pool", &name))) return false; - if (vshCommandOptStringReq(ctl, cmd, "file", &file) < 0) + if (vshCommandOptString(ctl, cmd, "file", &file) < 0) return false; if ((fd = open(file, O_RDONLY)) < 0) { @@ -768,7 +767,7 @@ cmdVolDownload(vshControl *ctl, const vshCmd *cmd) if (!(vol = virshCommandOptVol(ctl, cmd, "vol", "pool", &name))) return false; - if (vshCommandOptStringReq(ctl, cmd, "file", &file) < 0) + if (vshCommandOptString(ctl, cmd, "file", &file) < 0) goto cleanup; if (vshCommandOptBool(cmd, "sparse")) @@ -908,7 +907,7 @@ cmdVolWipe(vshControl *ctl, const vshCmd *cmd) if (!(vol = virshCommandOptVol(ctl, cmd, "vol", "pool", &name))) return false; - if (vshCommandOptStringReq(ctl, cmd, "algorithm", &algorithm_str) < 0) + if (vshCommandOptString(ctl, cmd, "algorithm", &algorithm_str) < 0) return false; if (algorithm_str && @@ -1078,7 +1077,7 @@ cmdVolResize(vshControl *ctl, const vshCmd *cmd) if (!(vol = virshCommandOptVol(ctl, cmd, "vol", "pool", NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "capacity", &capacityStr) < 0) + if (vshCommandOptString(ctl, cmd, "capacity", &capacityStr) < 0) return false; virSkipSpaces(&capacityStr); if (*capacityStr == '-') { diff --git a/tools/virsh.c b/tools/virsh.c index 0a586fd639..58ebb493fc 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -269,7 +269,7 @@ cmdConnect(vshControl *ctl, const vshCmd *cmd) bool ro = vshCommandOptBool(cmd, "readonly"); const char *name = NULL; - if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0) + if (vshCommandOptString(ctl, cmd, "name", &name) < 0) return false; if (virshReconnect(ctl, name, ro, true) < 0) diff --git a/tools/virt-admin.c b/tools/virt-admin.c index 9a10a4eb45..a996923094 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -273,7 +273,7 @@ cmdConnect(vshControl *ctl, const vshCmd *cmd) vshAdmControl *priv = ctl->privData; bool connected = priv->conn; - if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0) + if (vshCommandOptString(ctl, cmd, "name", &name) < 0) return false; if (name) { @@ -379,7 +379,7 @@ cmdSrvThreadpoolInfo(vshControl *ctl, const vshCmd *cmd) virAdmServerPtr srv = NULL; vshAdmControl *priv = ctl->privData; - if (vshCommandOptStringReq(ctl, cmd, "server", &srvname) < 0) + if (vshCommandOptString(ctl, cmd, "server", &srvname) < 0) return false; if (!(srv = virAdmConnectLookupServer(priv->conn, srvname, 0))) @@ -454,7 +454,7 @@ cmdSrvThreadpoolSet(vshControl *ctl, const vshCmd *cmd) virAdmServerPtr srv = NULL; vshAdmControl *priv = ctl->privData; - if (vshCommandOptStringReq(ctl, cmd, "server", &srvname) < 0) + if (vshCommandOptString(ctl, cmd, "server", &srvname) < 0) return false; #define PARSE_CMD_TYPED_PARAM(NAME, FIELD) \ @@ -545,7 +545,7 @@ cmdSrvClientsList(vshControl *ctl, const vshCmd *cmd) vshAdmControl *priv = ctl->privData; g_autoptr(vshTable) table = NULL; - if (vshCommandOptStringReq(ctl, cmd, "server", &srvname) < 0) + if (vshCommandOptString(ctl, cmd, "server", &srvname) < 0) return false; if (!(srv = virAdmConnectLookupServer(priv->conn, srvname, 0))) @@ -638,7 +638,7 @@ cmdClientInfo(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptULongLong(ctl, cmd, "client", &id) < 0) return false; - if (vshCommandOptStringReq(ctl, cmd, "server", &srvname) < 0) + if (vshCommandOptString(ctl, cmd, "server", &srvname) < 0) return false; if (!(srv = virAdmConnectLookupServer(priv->conn, srvname, 0)) || @@ -714,7 +714,7 @@ cmdClientDisconnect(vshControl *ctl, const vshCmd *cmd) virAdmClientPtr client = NULL; vshAdmControl *priv = ctl->privData; - if (vshCommandOptStringReq(ctl, cmd, "server", &srvname) < 0) + if (vshCommandOptString(ctl, cmd, "server", &srvname) < 0) return false; if (vshCommandOptULongLongWrap(ctl, cmd, "client", &id) < 0) @@ -772,7 +772,7 @@ cmdSrvClientsInfo(vshControl *ctl, const vshCmd *cmd) virAdmServerPtr srv = NULL; vshAdmControl *priv = ctl->privData; - if (vshCommandOptStringReq(ctl, cmd, "server", &srvname) < 0) + if (vshCommandOptString(ctl, cmd, "server", &srvname) < 0) return false; if (!(srv = virAdmConnectLookupServer(priv->conn, srvname, 0))) @@ -841,7 +841,7 @@ cmdSrvClientsSet(vshControl *ctl, const vshCmd *cmd) virTypedParameterPtr params = NULL; vshAdmControl *priv = ctl->privData; - if (vshCommandOptStringReq(ctl, cmd, "server", &srvname) < 0) + if (vshCommandOptString(ctl, cmd, "server", &srvname) < 0) return false; #define PARSE_CMD_TYPED_PARAM(NAME, FIELD) \ @@ -925,7 +925,7 @@ cmdSrvUpdateTlsFiles(vshControl *ctl, const vshCmd *cmd) virAdmServerPtr srv = NULL; vshAdmControl *priv = ctl->privData; - if (vshCommandOptStringReq(ctl, cmd, "server", &srvname) < 0) + if (vshCommandOptString(ctl, cmd, "server", &srvname) < 0) return false; if (!(srv = virAdmConnectLookupServer(priv->conn, srvname, 0))) @@ -973,7 +973,7 @@ cmdDaemonLogFilters(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "filters")) { const char *filters = NULL; - if ((vshCommandOptStringReq(ctl, cmd, "filters", &filters) < 0 || + if ((vshCommandOptString(ctl, cmd, "filters", &filters) < 0 || virAdmConnectSetLoggingFilters(priv->conn, filters, 0) < 0)) { vshError(ctl, _("Unable to change daemon logging settings")); return false; @@ -1056,7 +1056,7 @@ cmdDaemonLogOutputs(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "outputs")) { const char *outputs = NULL; - if ((vshCommandOptStringReq(ctl, cmd, "outputs", &outputs) < 0 || + if ((vshCommandOptString(ctl, cmd, "outputs", &outputs) < 0 || virAdmConnectSetLoggingOutputs(priv->conn, outputs, 0) < 0)) { vshError(ctl, _("Unable to change daemon logging settings")); return false; diff --git a/tools/vsh.c b/tools/vsh.c index f954f7af77..3fd567c1bf 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -1036,7 +1036,7 @@ vshCommandOptStringQuiet(vshControl *ctl G_GNUC_UNUSED, const vshCmd *cmd, } /** - * vshCommandOptStringReq: + * vshCommandOptString: * @ctl virtshell control structure * @cmd command structure * @name option name @@ -1049,10 +1049,10 @@ vshCommandOptStringQuiet(vshControl *ctl G_GNUC_UNUSED, const vshCmd *cmd, * returned and error message printed. */ int -vshCommandOptStringReq(vshControl *ctl, - const vshCmd *cmd, - const char *name, - const char **value) +vshCommandOptString(vshControl *ctl, + const vshCmd *cmd, + const char *name, + const char **value) { vshCmdOpt *arg; int ret; diff --git a/tools/vsh.h b/tools/vsh.h index eeba1d4b3c..38a9b7e39b 100644 --- a/tools/vsh.h +++ b/tools/vsh.h @@ -265,8 +265,8 @@ int vshCommandOptULWrap(vshControl *ctl, const vshCmd *cmd, int vshCommandOptStringQuiet(vshControl *ctl, const vshCmd *cmd, const char *name, const char **value) ATTRIBUTE_NONNULL(4) G_GNUC_WARN_UNUSED_RESULT; -int vshCommandOptStringReq(vshControl *ctl, const vshCmd *cmd, - const char *name, const char **value) +int vshCommandOptString(vshControl *ctl, const vshCmd *cmd, + const char *name, const char **value) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4) G_GNUC_WARN_UNUSED_RESULT; int vshCommandOptLongLong(vshControl *ctl, const vshCmd *cmd,