static const vshCmdDef commands[];
-static void vshError(vshControl *ctl, int doexit, const char *format, ...)
- ATTRIBUTE_FMT_PRINTF(3, 4);
+static void vshError(vshControl *ctl, const char *format, ...)
+ ATTRIBUTE_FMT_PRINTF(2, 3);
static int vshInit(vshControl *ctl);
static int vshDeinit(vshControl *ctl);
static void vshUsage(void);
return;
if (last_error->code == VIR_ERR_OK) {
- vshError(ctl, FALSE, "%s", _("unknown error"));
+ vshError(ctl, "%s", _("unknown error"));
goto out;
}
- vshError(ctl, FALSE, "%s", last_error->message);
+ vshError(ctl, "%s", last_error->message);
out:
virFreeError(last_error);
if (virDomainSetAutostart(dom, autostart) < 0) {
if (autostart)
- vshError(ctl, FALSE, _("Failed to mark domain %s as autostarted"),
- name);
+ vshError(ctl, _("Failed to mark domain %s as autostarted"), name);
else
- vshError(ctl, FALSE, _("Failed to unmark domain %s as autostarted"),
- name);
+ vshError(ctl, _("Failed to unmark domain %s as autostarted"), name);
virDomainFree(dom);
return FALSE;
}
if (ctl->conn) {
if (virConnectClose(ctl->conn) != 0) {
- vshError(ctl, FALSE, "%s",
- _("Failed to disconnect from the hypervisor"));
+ vshError(ctl, "%s", _("Failed to disconnect from the hypervisor"));
return FALSE;
}
ctl->conn = NULL;
ctl->readonly ? VIR_CONNECT_RO : 0);
if (!ctl->conn)
- vshError(ctl, FALSE, "%s", _("Failed to connect to the hypervisor"));
+ vshError(ctl, "%s", _("Failed to connect to the hypervisor"));
return ctl->conn ? TRUE : FALSE;
}
char *thisHost = NULL;
if (!(thisHost = virGetHostname())) {
- vshError(ctl, FALSE, "%s", _("Failed to get local hostname"));
+ vshError(ctl, "%s", _("Failed to get local hostname"));
goto cleanup;
}
if (!(thatHost = virConnectGetHostname(ctl->conn))) {
- vshError(ctl, FALSE, "%s", _("Failed to get connection hostname"));
+ vshError(ctl, "%s", _("Failed to get connection hostname"));
goto cleanup;
}
if (STRNEQ(thisHost, thatHost)) {
- vshError(ctl, FALSE, "%s", _("Cannot connect to a remote console device"));
+ vshError(ctl, "%s", _("Cannot connect to a remote console device"));
goto cleanup;
}
if (active) {
maxid = virConnectNumOfDomains(ctl->conn);
if (maxid < 0) {
- vshError(ctl, FALSE, "%s", _("Failed to list active domains"));
+ vshError(ctl, "%s", _("Failed to list active domains"));
return FALSE;
}
if (maxid) {
ids = vshMalloc(ctl, sizeof(int) * maxid);
if ((maxid = virConnectListDomains(ctl->conn, &ids[0], maxid)) < 0) {
- vshError(ctl, FALSE, "%s", _("Failed to list active domains"));
+ vshError(ctl, "%s", _("Failed to list active domains"));
free(ids);
return FALSE;
}
if (inactive) {
maxname = virConnectNumOfDefinedDomains(ctl->conn);
if (maxname < 0) {
- vshError(ctl, FALSE, "%s", _("Failed to list inactive domains"));
+ vshError(ctl, "%s", _("Failed to list inactive domains"));
free(ids);
return FALSE;
}
names = vshMalloc(ctl, sizeof(char *) * maxname);
if ((maxname = virConnectListDefinedDomains(ctl->conn, names, maxname)) < 0) {
- vshError(ctl, FALSE, "%s", _("Failed to list inactive domains"));
+ vshError(ctl, "%s", _("Failed to list inactive domains"));
free(ids);
free(names);
return FALSE;
}
if (virDomainBlockStats (dom, device, &stats, sizeof stats) == -1) {
- vshError (ctl, FALSE, _("Failed to get block stats %s %s"),
- name, device);
+ vshError(ctl, _("Failed to get block stats %s %s"), name, device);
virDomainFree(dom);
return FALSE;
}
}
if (virDomainInterfaceStats (dom, device, &stats, sizeof stats) == -1) {
- vshError (ctl, FALSE, _("Failed to get interface stats %s %s"),
- name, device);
+ vshError(ctl, _("Failed to get interface stats %s %s"), name, device);
virDomainFree(dom);
return FALSE;
}
if (virDomainSuspend(dom) == 0) {
vshPrint(ctl, _("Domain %s suspended\n"), name);
} else {
- vshError(ctl, FALSE, _("Failed to suspend domain %s"), name);
+ vshError(ctl, _("Failed to suspend domain %s"), name);
ret = FALSE;
}
#endif
virDomainFree(dom);
} else {
- vshError(ctl, FALSE, _("Failed to create domain from %s"), from);
+ vshError(ctl, _("Failed to create domain from %s"), from);
ret = FALSE;
}
return ret;
virDomainGetName(dom), from);
virDomainFree(dom);
} else {
- vshError(ctl, FALSE, _("Failed to define domain from %s"), from);
+ vshError(ctl, _("Failed to define domain from %s"), from);
ret = FALSE;
}
return ret;
if (name && virStrToLong_i(name, NULL, 10, &id) == 0
&& id >= 0 && (dom = virDomainLookupByID(ctl->conn, id))) {
- vshError(ctl, FALSE, _("a running domain like %s cannot be undefined;\n"
- "to undefine, first shutdown then undefine"
- " using its name or UUID"), name);
+ vshError(ctl,
+ _("a running domain like %s cannot be undefined;\n"
+ "to undefine, first shutdown then undefine"
+ " using its name or UUID"),
+ name);
virDomainFree(dom);
return FALSE;
}
if (virDomainUndefine(dom) == 0) {
vshPrint(ctl, _("Domain %s has been undefined\n"), name);
} else {
- vshError(ctl, FALSE, _("Failed to undefine domain %s"), name);
+ vshError(ctl, _("Failed to undefine domain %s"), name);
ret = FALSE;
}
return FALSE;
if (virDomainGetID(dom) != (unsigned int)-1) {
- vshError(ctl, FALSE, "%s", _("Domain is already active"));
+ vshError(ctl, "%s", _("Domain is already active"));
virDomainFree(dom);
return FALSE;
}
cmdRunConsole(ctl, dom);
#endif
} else {
- vshError(ctl, FALSE, _("Failed to start domain %s"),
- virDomainGetName(dom));
+ vshError(ctl, _("Failed to start domain %s"), virDomainGetName(dom));
ret = FALSE;
}
virDomainFree(dom);
if (virDomainSave(dom, to) == 0) {
vshPrint(ctl, _("Domain %s saved to %s\n"), name, to);
} else {
- vshError(ctl, FALSE, _("Failed to save domain %s to %s"), name, to);
+ vshError(ctl, _("Failed to save domain %s to %s"), name, to);
ret = FALSE;
}
int val;
val = vshCommandOptInt(cmd, "weight", &found);
if (!found) {
- vshError(ctl, FALSE, "%s", _("Invalid value of weight"));
+ vshError(ctl, "%s", _("Invalid value of weight"));
return -1;
} else {
param->value.ui = val;
int val;
val = vshCommandOptInt(cmd, "cap", &found);
if (!found) {
- vshError(ctl, FALSE, "%s", _("Invalid value of cap"));
+ vshError(ctl, "%s", _("Invalid value of cap"));
return -1;
} else {
param->value.ui = val;
char *val = strchr(data, '=');
int match = 0;
if (!val) {
- vshError(ctl, FALSE, "%s", _("Invalid syntax for --set, expecting name=value"));
+ vshError(ctl, "%s", _("Invalid syntax for --set, expecting name=value"));
return -1;
}
*val = '\0';
switch (param->type) {
case VIR_DOMAIN_SCHED_FIELD_INT:
if (virStrToLong_i(val, NULL, 10, ¶m->value.i) < 0) {
- vshError(ctl, FALSE, "%s",
+ vshError(ctl, "%s",
_("Invalid value for parameter, expecting an int"));
return -1;
}
break;
case VIR_DOMAIN_SCHED_FIELD_UINT:
if (virStrToLong_ui(val, NULL, 10, ¶m->value.ui) < 0) {
- vshError(ctl, FALSE, "%s",
+ vshError(ctl, "%s",
_("Invalid value for parameter, expecting an unsigned int"));
return -1;
}
break;
case VIR_DOMAIN_SCHED_FIELD_LLONG:
if (virStrToLong_ll(val, NULL, 10, ¶m->value.l) < 0) {
- vshError(ctl, FALSE, "%s",
+ vshError(ctl, "%s",
_("Invalid value for parameter, expecting an long long"));
return -1;
}
break;
case VIR_DOMAIN_SCHED_FIELD_ULLONG:
if (virStrToLong_ull(val, NULL, 10, ¶m->value.ul) < 0) {
- vshError(ctl, FALSE, "%s",
+ vshError(ctl, "%s",
_("Invalid value for parameter, expecting an unsigned long long"));
return -1;
}
break;
case VIR_DOMAIN_SCHED_FIELD_DOUBLE:
if (virStrToDouble(val, NULL, ¶m->value.d) < 0) {
- vshError(ctl, FALSE, "%s", _("Invalid value for parameter, expecting a double"));
+ vshError(ctl, "%s", _("Invalid value for parameter, expecting a double"));
return -1;
}
break;
if (virDomainRestore(ctl->conn, from) == 0) {
vshPrint(ctl, _("Domain restored from %s\n"), from);
} else {
- vshError(ctl, FALSE, _("Failed to restore domain from %s"), from);
+ vshError(ctl, _("Failed to restore domain from %s"), from);
ret = FALSE;
}
return ret;
if (virDomainCoreDump(dom, to, 0) == 0) {
vshPrint(ctl, _("Domain %s dumped to %s\n"), name, to);
} else {
- vshError(ctl, FALSE, _("Failed to core dump domain %s to %s"),
- name, to);
+ vshError(ctl, _("Failed to core dump domain %s to %s"), name, to);
ret = FALSE;
}
if (virDomainResume(dom) == 0) {
vshPrint(ctl, _("Domain %s resumed\n"), name);
} else {
- vshError(ctl, FALSE, _("Failed to resume domain %s"), name);
+ vshError(ctl, _("Failed to resume domain %s"), name);
ret = FALSE;
}
if (virDomainShutdown(dom) == 0) {
vshPrint(ctl, _("Domain %s is being shutdown\n"), name);
} else {
- vshError(ctl, FALSE, _("Failed to shutdown domain %s"), name);
+ vshError(ctl, _("Failed to shutdown domain %s"), name);
ret = FALSE;
}
if (virDomainReboot(dom, 0) == 0) {
vshPrint(ctl, _("Domain %s is being rebooted\n"), name);
} else {
- vshError(ctl, FALSE, _("Failed to reboot domain %s"), name);
+ vshError(ctl, _("Failed to reboot domain %s"), name);
ret = FALSE;
}
if (virDomainDestroy(dom) == 0) {
vshPrint(ctl, _("Domain %s destroyed\n"), name);
} else {
- vshError(ctl, FALSE, _("Failed to destroy domain %s"), name);
+ vshError(ctl, _("Failed to destroy domain %s"), name);
ret = FALSE;
}
}
} else {
if (info.state == VIR_DOMAIN_SHUTOFF) {
- vshError(ctl, FALSE, "%s",
- _("Domain shut off, virtual CPUs not present."));
+ vshError(ctl, "%s",
+ _("Domain shut off, virtual CPUs not present."));
}
ret = FALSE;
}
vcpu = vshCommandOptInt(cmd, "vcpu", &vcpufound);
if (!vcpufound) {
- vshError(ctl, FALSE, "%s",
- _("vcpupin: Invalid or missing vCPU number."));
+ vshError(ctl, "%s", _("vcpupin: Invalid or missing vCPU number."));
virDomainFree(dom);
return FALSE;
}
if (!(cpulist = vshCommandOptString(cmd, "cpulist", NULL))) {
- vshError(ctl, FALSE, "%s", _("vcpupin: Missing cpulist"));
+ vshError(ctl, "%s", _("vcpupin: Missing cpulist"));
virDomainFree(dom);
return FALSE;
}
}
if (virDomainGetInfo(dom, &info) != 0) {
- vshError(ctl, FALSE, "%s",
- _("vcpupin: failed to get domain informations."));
+ vshError(ctl, "%s", _("vcpupin: failed to get domain informations."));
virDomainFree(dom);
return FALSE;
}
if (vcpu >= info.nrVirtCpu) {
- vshError(ctl, FALSE, "%s", _("vcpupin: Invalid vCPU number."));
+ vshError(ctl, "%s", _("vcpupin: Invalid vCPU number."));
virDomainFree(dom);
return FALSE;
}
* numbers and give an intelligent error message if not.
*/
if (cpulist[0] == '\0') {
- vshError(ctl, FALSE, "%s", _("cpulist: Invalid format. Empty string."));
+ vshError(ctl, "%s", _("cpulist: Invalid format. Empty string."));
virDomainFree (dom);
return FALSE;
}
switch (state) {
case expect_num:
if (!c_isdigit (cpulist[i])) {
- vshError( ctl, FALSE, _("cpulist: %s: Invalid format. Expecting digit at position %d (near '%c')."), cpulist, i, cpulist[i]);
+ vshError(ctl, _("cpulist: %s: Invalid format. Expecting "
+ "digit at position %d (near '%c')."),
+ cpulist, i, cpulist[i]);
virDomainFree (dom);
return FALSE;
}
if (cpulist[i] == ',')
state = expect_num;
else if (!c_isdigit (cpulist[i])) {
- vshError(ctl, FALSE, _("cpulist: %s: Invalid format. Expecting digit or comma at position %d (near '%c')."), cpulist, i, cpulist[i]);
+ vshError(ctl, _("cpulist: %s: Invalid format. Expecting "
+ "digit or comma at position %d (near '%c')."),
+ cpulist, i, cpulist[i]);
virDomainFree (dom);
return FALSE;
}
}
}
if (state == expect_num) {
- vshError(ctl, FALSE, _("cpulist: %s: Invalid format. Trailing comma at position %d."), cpulist, i);
+ vshError(ctl, _("cpulist: %s: Invalid format. Trailing comma "
+ "at position %d."),
+ cpulist, i);
virDomainFree (dom);
return FALSE;
}
if (cpu < VIR_NODEINFO_MAXCPUS(nodeinfo)) {
VIR_USE_CPU(cpumap, cpu);
} else {
- vshError(ctl, FALSE, _("Physical CPU %d doesn't exist."), cpu);
+ vshError(ctl, _("Physical CPU %d doesn't exist."), cpu);
free(cpumap);
virDomainFree(dom);
return FALSE;
count = vshCommandOptInt(cmd, "count", &count);
if (count <= 0) {
- vshError(ctl, FALSE, "%s", _("Invalid number of virtual CPUs."));
+ vshError(ctl, "%s", _("Invalid number of virtual CPUs."));
virDomainFree(dom);
return FALSE;
}
}
if (count > maxcpu) {
- vshError(ctl, FALSE, "%s", _("Too many virtual CPUs."));
+ vshError(ctl, "%s", _("Too many virtual CPUs."));
virDomainFree(dom);
return FALSE;
}
kilobytes = vshCommandOptInt(cmd, "kilobytes", &kilobytes);
if (kilobytes <= 0) {
virDomainFree(dom);
- vshError(ctl, FALSE, _("Invalid value of %d for memory size"), kilobytes);
+ vshError(ctl, _("Invalid value of %d for memory size"), kilobytes);
return FALSE;
}
if (virDomainGetInfo(dom, &info) != 0) {
virDomainFree(dom);
- vshError(ctl, FALSE, "%s", _("Unable to verify MaxMemorySize"));
+ vshError(ctl, "%s", _("Unable to verify MaxMemorySize"));
return FALSE;
}
if (kilobytes > info.maxMem) {
virDomainFree(dom);
- vshError(ctl, FALSE, _("Invalid value of %d for memory size"), kilobytes);
+ vshError(ctl, _("Invalid value of %d for memory size"), kilobytes);
return FALSE;
}
kilobytes = vshCommandOptInt(cmd, "kilobytes", &kilobytes);
if (kilobytes <= 0) {
virDomainFree(dom);
- vshError(ctl, FALSE, _("Invalid value of %d for memory size"), kilobytes);
+ vshError(ctl, _("Invalid value of %d for memory size"), kilobytes);
return FALSE;
}
if (virDomainGetInfo(dom, &info) != 0) {
virDomainFree(dom);
- vshError(ctl, FALSE, "%s", _("Unable to verify current MemorySize"));
+ vshError(ctl, "%s", _("Unable to verify current MemorySize"));
return FALSE;
}
if (kilobytes < info.memory) {
if (virDomainSetMemory(dom, kilobytes) != 0) {
virDomainFree(dom);
- vshError(ctl, FALSE, "%s", _("Unable to shrink current MemorySize"));
+ vshError(ctl, "%s", _("Unable to shrink current MemorySize"));
return FALSE;
}
}
if (virDomainSetMaxMemory(dom, kilobytes) != 0) {
- vshError(ctl, FALSE, "%s", _("Unable to change MaxMemorySize"));
+ vshError(ctl, "%s", _("Unable to change MaxMemorySize"));
ret = FALSE;
}
return FALSE;
if (virNodeGetInfo(ctl->conn, &info) < 0) {
- vshError(ctl, FALSE, "%s", _("failed to get node information"));
+ vshError(ctl, "%s", _("failed to get node information"));
return FALSE;
}
vshPrint(ctl, "%-20s %s\n", _("CPU model:"), info.model);
return FALSE;
if ((caps = virConnectGetCapabilities (ctl->conn)) == NULL) {
- vshError(ctl, FALSE, "%s", _("failed to get capabilities"));
+ vshError(ctl, "%s", _("failed to get capabilities"));
return FALSE;
}
vshPrint (ctl, "%s\n", caps);
if (virDomainGetUUIDString(dom, uuid) != -1)
vshPrint(ctl, "%s\n", uuid);
else
- vshError(ctl, FALSE, "%s", _("failed to get domain UUID"));
+ vshError(ctl, "%s", _("failed to get domain UUID"));
virDomainFree(dom);
return TRUE;
desturi = vshCommandOptString (cmd, "desturi", &found);
if (!found) {
- vshError (ctl, FALSE, "%s", _("migrate: Missing desturi"));
+ vshError(ctl, "%s", _("migrate: Missing desturi"));
goto done;
}
if (virNetworkSetAutostart(network, autostart) < 0) {
if (autostart)
- vshError(ctl, FALSE, _("failed to mark network %s as autostarted"),
- name);
+ vshError(ctl, _("failed to mark network %s as autostarted"), name);
else
- vshError(ctl, FALSE,_("failed to unmark network %s as autostarted"),
- name);
+ vshError(ctl, _("failed to unmark network %s as autostarted"), name);
virNetworkFree(network);
return FALSE;
}
virNetworkGetName(network), from);
virNetworkFree(network);
} else {
- vshError(ctl, FALSE, _("Failed to create network from %s"), from);
+ vshError(ctl, _("Failed to create network from %s"), from);
ret = FALSE;
}
return ret;
virNetworkGetName(network), from);
virNetworkFree(network);
} else {
- vshError(ctl, FALSE, _("Failed to define network from %s"), from);
+ vshError(ctl, _("Failed to define network from %s"), from);
ret = FALSE;
}
return ret;
if (virNetworkDestroy(network) == 0) {
vshPrint(ctl, _("Network %s destroyed\n"), name);
} else {
- vshError(ctl, FALSE, _("Failed to destroy network %s"), name);
+ vshError(ctl, _("Failed to destroy network %s"), name);
ret = FALSE;
}
goto cleanup;
if (STRNEQ (doc, doc_reread)) {
- vshError (ctl, FALSE, "%s",
- _("ERROR: the XML configuration was changed by another user"));
+ vshError(ctl, "%s",
+ _("ERROR: the XML configuration was changed by another user"));
goto cleanup;
}
if (active) {
maxactive = virConnectNumOfNetworks(ctl->conn);
if (maxactive < 0) {
- vshError(ctl, FALSE, "%s", _("Failed to list active networks"));
+ vshError(ctl, "%s", _("Failed to list active networks"));
return FALSE;
}
if (maxactive) {
if ((maxactive = virConnectListNetworks(ctl->conn, activeNames,
maxactive)) < 0) {
- vshError(ctl, FALSE, "%s", _("Failed to list active networks"));
+ vshError(ctl, "%s", _("Failed to list active networks"));
free(activeNames);
return FALSE;
}
if (inactive) {
maxinactive = virConnectNumOfDefinedNetworks(ctl->conn);
if (maxinactive < 0) {
- vshError(ctl, FALSE, "%s", _("Failed to list inactive networks"));
+ vshError(ctl, "%s", _("Failed to list inactive networks"));
free(activeNames);
return FALSE;
}
if ((maxinactive =
virConnectListDefinedNetworks(ctl->conn, inactiveNames,
maxinactive)) < 0) {
- vshError(ctl, FALSE, "%s",
- _("Failed to list inactive networks"));
+ vshError(ctl, "%s", _("Failed to list inactive networks"));
free(activeNames);
free(inactiveNames);
return FALSE;
vshPrint(ctl, _("Network %s started\n"),
virNetworkGetName(network));
} else {
- vshError(ctl, FALSE, _("Failed to start network %s"),
+ vshError(ctl, _("Failed to start network %s"),
virNetworkGetName(network));
ret = FALSE;
}
if (virNetworkUndefine(network) == 0) {
vshPrint(ctl, _("Network %s has been undefined\n"), name);
} else {
- vshError(ctl, FALSE, _("Failed to undefine network %s"), name);
+ vshError(ctl, _("Failed to undefine network %s"), name);
ret = FALSE;
}
if (virNetworkGetUUIDString(network, uuid) != -1)
vshPrint(ctl, "%s\n", uuid);
else
- vshError(ctl, FALSE, "%s", _("failed to get network UUID"));
+ vshError(ctl, "%s", _("failed to get network UUID"));
virNetworkFree(network);
return TRUE;
if (active) {
maxactive = virConnectNumOfInterfaces(ctl->conn);
if (maxactive < 0) {
- vshError(ctl, FALSE, "%s", _("Failed to list active interfaces"));
+ vshError(ctl, "%s", _("Failed to list active interfaces"));
return FALSE;
}
if (maxactive) {
if ((maxactive = virConnectListInterfaces(ctl->conn, activeNames,
maxactive)) < 0) {
- vshError(ctl, FALSE, "%s",
- _("Failed to list active interfaces"));
+ vshError(ctl, "%s", _("Failed to list active interfaces"));
free(activeNames);
return FALSE;
}
if (inactive) {
maxinactive = virConnectNumOfDefinedInterfaces(ctl->conn);
if (maxinactive < 0) {
- vshError(ctl, FALSE, "%s",
- _("Failed to list inactive interfaces"));
+ vshError(ctl, "%s", _("Failed to list inactive interfaces"));
free(activeNames);
return FALSE;
}
if ((maxinactive =
virConnectListDefinedInterfaces(ctl->conn, inactiveNames,
maxinactive)) < 0) {
- vshError(ctl, FALSE, "%s",
- _("Failed to list inactive interfaces"));
+ vshError(ctl, "%s", _("Failed to list inactive interfaces"));
free(activeNames);
free(inactiveNames);
return FALSE;
virInterfaceGetName(iface), from);
virInterfaceFree (iface);
} else {
- vshError(ctl, FALSE, _("Failed to define interface from %s"), from);
+ vshError(ctl, _("Failed to define interface from %s"), from);
ret = FALSE;
}
return ret;
if (virInterfaceUndefine(iface) == 0) {
vshPrint(ctl, _("Interface %s undefined\n"), name);
} else {
- vshError(ctl, FALSE, _("Failed to undefine interface %s"), name);
+ vshError(ctl, _("Failed to undefine interface %s"), name);
ret = FALSE;
}
if (virInterfaceCreate(iface, 0) == 0) {
vshPrint(ctl, _("Interface %s started\n"), name);
} else {
- vshError(ctl, FALSE, _("Failed to start interface %s"), name);
+ vshError(ctl, _("Failed to start interface %s"), name);
ret = FALSE;
}
if (virInterfaceDestroy(iface, 0) == 0) {
vshPrint(ctl, _("Interface %s destroyed\n"), name);
} else {
- vshError(ctl, FALSE, _("Failed to destroy interface %s"), name);
+ vshError(ctl, _("Failed to destroy interface %s"), name);
ret = FALSE;
}
if (virStoragePoolSetAutostart(pool, autostart) < 0) {
if (autostart)
- vshError(ctl, FALSE, _("failed to mark pool %s as autostarted"),
- name);
+ vshError(ctl, _("failed to mark pool %s as autostarted"), name);
else
- vshError(ctl, FALSE,_("failed to unmark pool %s as autostarted"),
- name);
+ vshError(ctl, _("failed to unmark pool %s as autostarted"), name);
virStoragePoolFree(pool);
return FALSE;
}
virStoragePoolGetName(pool), from);
virStoragePoolFree(pool);
} else {
- vshError(ctl, FALSE, _("Failed to create pool from %s"), from);
+ vshError(ctl, _("Failed to create pool from %s"), from);
ret = FALSE;
}
return ret;
virNodeDeviceGetName(dev), from);
virNodeDeviceFree(dev);
} else {
- vshError(ctl, FALSE, _("Failed to create node device from %s"), from);
+ vshError(ctl, _("Failed to create node device from %s"), from);
ret = FALSE;
}
if (virNodeDeviceDestroy(dev) == 0) {
vshPrint(ctl, _("Destroyed node device '%s'\n"), name);
} else {
- vshError(ctl, FALSE, _("Failed to destroy node device '%s'"), name);
+ vshError(ctl, _("Failed to destroy node device '%s'"), name);
ret = FALSE;
}
vshPrint(ctl, _("Pool %s created\n"), name);
virStoragePoolFree(pool);
} else {
- vshError(ctl, FALSE, _("Failed to create pool %s"), name);
+ vshError(ctl, _("Failed to create pool %s"), name);
return FALSE;
}
}
virStoragePoolGetName(pool), from);
virStoragePoolFree(pool);
} else {
- vshError(ctl, FALSE, _("Failed to define pool from %s"), from);
+ vshError(ctl, _("Failed to define pool from %s"), from);
ret = FALSE;
}
return ret;
vshPrint(ctl, _("Pool %s defined\n"), name);
virStoragePoolFree(pool);
} else {
- vshError(ctl, FALSE, _("Failed to define pool %s"), name);
+ vshError(ctl, _("Failed to define pool %s"), name);
return FALSE;
}
}
if (virStoragePoolBuild(pool, 0) == 0) {
vshPrint(ctl, _("Pool %s built\n"), name);
} else {
- vshError(ctl, FALSE, _("Failed to build pool %s"), name);
+ vshError(ctl, _("Failed to build pool %s"), name);
ret = FALSE;
virStoragePoolFree(pool);
}
if (virStoragePoolDestroy(pool) == 0) {
vshPrint(ctl, _("Pool %s destroyed\n"), name);
} else {
- vshError(ctl, FALSE, _("Failed to destroy pool %s"), name);
+ vshError(ctl, _("Failed to destroy pool %s"), name);
ret = FALSE;
}
if (virStoragePoolDelete(pool, 0) == 0) {
vshPrint(ctl, _("Pool %s deleted\n"), name);
} else {
- vshError(ctl, FALSE, _("Failed to delete pool %s"), name);
+ vshError(ctl, _("Failed to delete pool %s"), name);
ret = FALSE;
}
if (virStoragePoolRefresh(pool, 0) == 0) {
vshPrint(ctl, _("Pool %s refreshed\n"), name);
} else {
- vshError(ctl, FALSE, _("Failed to refresh pool %s"), name);
+ vshError(ctl, _("Failed to refresh pool %s"), name);
ret = FALSE;
}
virStoragePoolFree(pool);
if (active) {
maxactive = virConnectNumOfStoragePools(ctl->conn);
if (maxactive < 0) {
- vshError(ctl, FALSE, "%s", _("Failed to list active pools"));
+ vshError(ctl, "%s", _("Failed to list active pools"));
return FALSE;
}
if (maxactive) {
if ((maxactive = virConnectListStoragePools(ctl->conn, activeNames,
maxactive)) < 0) {
- vshError(ctl, FALSE, "%s", _("Failed to list active pools"));
+ vshError(ctl, "%s", _("Failed to list active pools"));
free(activeNames);
return FALSE;
}
if (inactive) {
maxinactive = virConnectNumOfDefinedStoragePools(ctl->conn);
if (maxinactive < 0) {
- vshError(ctl, FALSE, "%s", _("Failed to list inactive pools"));
+ vshError(ctl, "%s", _("Failed to list inactive pools"));
free(activeNames);
return FALSE;
}
inactiveNames = vshMalloc(ctl, sizeof(char *) * maxinactive);
if ((maxinactive = virConnectListDefinedStoragePools(ctl->conn, inactiveNames, maxinactive)) < 0) {
- vshError(ctl, FALSE, "%s", _("Failed to list inactive pools"));
+ vshError(ctl, "%s", _("Failed to list inactive pools"));
free(activeNames);
free(inactiveNames);
return FALSE;
if (ret < 0) {
switch (errno) {
case ENOMEM:
- vshError(ctl, FALSE, "%s", _("Out of memory"));
+ vshError(ctl, "%s", _("Out of memory"));
break;
default:
- vshError(ctl, FALSE, _("virAsprintf failed (errno %d)"), errno);
+ vshError(ctl, _("virAsprintf failed (errno %d)"), errno);
}
return FALSE;
}
srcList = virConnectFindStoragePoolSources(ctl->conn, type, srcSpec, 0);
free(srcSpec);
if (srcList == NULL) {
- vshError(ctl, FALSE, _("Failed to find any %s pool sources"), type);
+ vshError(ctl, _("Failed to find any %s pool sources"), type);
return FALSE;
}
vshPrint(ctl, "%s", srcList);
srcList = virConnectFindStoragePoolSources(ctl->conn, type, srcSpec, 0);
free(srcSpec);
if (srcList == NULL) {
- vshError(ctl, FALSE, _("Failed to find any %s pool sources"), type);
+ vshError(ctl, _("Failed to find any %s pool sources"), type);
return FALSE;
}
vshPrint(ctl, "%s", srcList);
vshPrint(ctl, _("Pool %s started\n"),
virStoragePoolGetName(pool));
} else {
- vshError(ctl, FALSE, _("Failed to start pool %s"),
- virStoragePoolGetName(pool));
+ vshError(ctl, _("Failed to start pool %s"), virStoragePoolGetName(pool));
ret = FALSE;
}
if (!found)
goto cleanup;
if (cmdVolSize(capacityStr, &capacity) < 0)
- vshError(ctl, FALSE, _("Malformed size %s"), capacityStr);
+ vshError(ctl, _("Malformed size %s"), capacityStr);
allocationStr = vshCommandOptString(cmd, "allocation", &found);
if (allocationStr &&
cmdVolSize(allocationStr, &allocation) < 0)
- vshError(ctl, FALSE, _("Malformed size %s"), allocationStr);
+ vshError(ctl, _("Malformed size %s"), allocationStr);
format = vshCommandOptString(cmd, "format", &found);
virStorageVolFree(vol);
return TRUE;
} else {
- vshError(ctl, FALSE, _("Failed to create vol %s"), name);
+ vshError(ctl, _("Failed to create vol %s"), name);
return FALSE;
}
if (virStoragePoolUndefine(pool) == 0) {
vshPrint(ctl, _("Pool %s has been undefined\n"), name);
} else {
- vshError(ctl, FALSE, _("Failed to undefine pool %s"), name);
+ vshError(ctl, _("Failed to undefine pool %s"), name);
ret = FALSE;
}
if (virStoragePoolGetUUIDString(pool, uuid) != -1)
vshPrint(ctl, "%s\n", uuid);
else
- vshError(ctl, FALSE, "%s", _("failed to get pool UUID"));
+ vshError(ctl, "%s", _("failed to get pool UUID"));
virStoragePoolFree(pool);
return TRUE;
virStorageVolGetName(vol), from);
virStorageVolFree(vol);
} else {
- vshError(ctl, FALSE, _("Failed to create vol from %s"), from);
+ vshError(ctl, _("Failed to create vol from %s"), from);
ret = FALSE;
}
return ret;
vshPrint(ctl, _("Vol %s created from input vol %s\n"),
virStorageVolGetName(newvol), virStorageVolGetName(inputvol));
} else {
- vshError(ctl, FALSE, _("Failed to create vol from %s"), from);
+ vshError(ctl, _("Failed to create vol from %s"), from);
goto cleanup;
}
origpool = virStoragePoolLookupByVolume(origvol);
if (!origpool) {
- vshError(ctl, FALSE, "%s", _("failed to get parent pool"));
+ vshError(ctl, "%s", _("failed to get parent pool"));
goto cleanup;
}
vshPrint(ctl, _("Vol %s cloned from %s\n"),
virStorageVolGetName(newvol), virStorageVolGetName(origvol));
} else {
- vshError(ctl, FALSE, _("Failed to clone vol from %s"),
+ vshError(ctl, _("Failed to clone vol from %s"),
virStorageVolGetName(origvol));
goto cleanup;
}
if (virStorageVolDelete(vol, 0) == 0) {
vshPrint(ctl, _("Vol %s deleted\n"), name);
} else {
- vshError(ctl, FALSE, _("Failed to delete vol %s"), name);
+ vshError(ctl, _("Failed to delete vol %s"), name);
ret = FALSE;
}
maxactive = virStoragePoolNumOfVolumes(pool);
if (maxactive < 0) {
virStoragePoolFree(pool);
- vshError(ctl, FALSE, "%s", _("Failed to list active vols"));
+ vshError(ctl, "%s", _("Failed to list active vols"));
return FALSE;
}
if (maxactive) {
if ((maxactive = virStoragePoolListVolumes(pool, activeNames,
maxactive)) < 0) {
- vshError(ctl, FALSE, "%s", _("Failed to list active vols"));
+ vshError(ctl, "%s", _("Failed to list active vols"));
free(activeNames);
virStoragePoolFree(pool);
return FALSE;
free (buffer);
if (res == NULL) {
- vshError(ctl, FALSE, _("Failed to set attributes from %s"), from);
+ vshError(ctl, _("Failed to set attributes from %s"), from);
return FALSE;
}
if (virSecretGetUUIDString(res, &(uuid[0])) < 0) {
- vshError(ctl, FALSE, "%s",
- _("Failed to get UUID of created secret"));
+ vshError(ctl, "%s", _("Failed to get UUID of created secret"));
virSecretFree(res);
return FALSE;
}
goto cleanup;
if (!base64_decode_alloc(base64, strlen(base64), &value, &value_size)) {
- vshError(ctl, FALSE, _("Invalid base64 data"));
+ vshError(ctl, _("Invalid base64 data"));
goto cleanup;
}
if (value == NULL) {
- vshError(ctl, FALSE, "%s", _("Failed to allocate memory"));
+ vshError(ctl, "%s", _("Failed to allocate memory"));
return FALSE;
}
free (value);
if (res != 0) {
- vshError(ctl, FALSE, "%s", _("Failed to set secret value"));
+ vshError(ctl, "%s", _("Failed to set secret value"));
goto cleanup;
}
vshPrint(ctl, "%s", _("Secret value set\n"));
free(value);
if (base64 == NULL) {
- vshError(ctl, FALSE, "%s", _("Failed to allocate memory"));
+ vshError(ctl, "%s", _("Failed to allocate memory"));
goto cleanup;
}
printf("%s", base64);
return FALSE;
if (virSecretUndefine(secret) < 0) {
- vshError(ctl, FALSE, _("Failed to delete secret %s"), uuid);
+ vshError(ctl, _("Failed to delete secret %s"), uuid);
goto cleanup;
}
vshPrint(ctl, _("Secret %s deleted\n"), uuid);
maxuuids = virConnectNumOfSecrets(ctl->conn);
if (maxuuids < 0) {
- vshError(ctl, FALSE, "%s", _("Failed to list secrets"));
+ vshError(ctl, "%s", _("Failed to list secrets"));
return FALSE;
}
uuids = vshMalloc(ctl, sizeof(*uuids) * maxuuids);
maxuuids = virConnectListSecrets(ctl->conn, uuids, maxuuids);
if (maxuuids < 0) {
- vshError(ctl, FALSE, "%s", _("Failed to list secrets"));
+ vshError(ctl, "%s", _("Failed to list secrets"));
free(uuids);
return FALSE;
}
hvType = virConnectGetType(ctl->conn);
if (hvType == NULL) {
- vshError(ctl, FALSE, "%s", _("failed to get hypervisor type"));
+ vshError(ctl, "%s", _("failed to get hypervisor type"));
return FALSE;
}
ret = virGetVersion(&libVersion, hvType, &apiVersion);
if (ret < 0) {
- vshError(ctl, FALSE, "%s", _("failed to get the library version"));
+ vshError(ctl, "%s", _("failed to get the library version"));
return FALSE;
}
major = libVersion / 1000000;
ret = virConnectGetVersion(ctl->conn, &hvVersion);
if (ret < 0) {
- vshError(ctl, FALSE, "%s", _("failed to get the hypervisor version"));
+ vshError(ctl, "%s", _("failed to get the hypervisor version"));
return FALSE;
}
if (hvVersion == 0) {
num_devices = virNodeNumOfDevices(ctl->conn, cap, 0);
if (num_devices < 0) {
- vshError(ctl, FALSE, "%s", _("Failed to count node devices"));
+ vshError(ctl, "%s", _("Failed to count node devices"));
return FALSE;
} else if (num_devices == 0) {
return TRUE;
num_devices =
virNodeListDevices(ctl->conn, cap, devices, num_devices, 0);
if (num_devices < 0) {
- vshError(ctl, FALSE, "%s", _("Failed to list node devices"));
+ vshError(ctl, "%s", _("Failed to list node devices"));
free(devices);
return FALSE;
}
if (!(name = vshCommandOptString(cmd, "device", NULL)))
return FALSE;
if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) {
- vshError(ctl, FALSE, "%s '%s'", _("Could not find matching device"), name);
+ vshError(ctl, "%s '%s'", _("Could not find matching device"), name);
return FALSE;
}
if (!(name = vshCommandOptString(cmd, "device", NULL)))
return FALSE;
if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) {
- vshError(ctl, FALSE, "%s '%s'", _("Could not find matching device"), name);
+ vshError(ctl, "%s '%s'", _("Could not find matching device"), name);
return FALSE;
}
if (virNodeDeviceDettach(device) == 0) {
vshPrint(ctl, _("Device %s dettached\n"), name);
} else {
- vshError(ctl, FALSE, _("Failed to dettach device %s"), name);
+ vshError(ctl, _("Failed to dettach device %s"), name);
ret = FALSE;
}
virNodeDeviceFree(device);
if (!(name = vshCommandOptString(cmd, "device", NULL)))
return FALSE;
if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) {
- vshError(ctl, FALSE, "%s '%s'", _("Could not find matching device"), name);
+ vshError(ctl, "%s '%s'", _("Could not find matching device"), name);
return FALSE;
}
if (virNodeDeviceReAttach(device) == 0) {
vshPrint(ctl, _("Device %s re-attached\n"), name);
} else {
- vshError(ctl, FALSE, _("Failed to re-attach device %s"), name);
+ vshError(ctl, _("Failed to re-attach device %s"), name);
ret = FALSE;
}
virNodeDeviceFree(device);
if (!(name = vshCommandOptString(cmd, "device", NULL)))
return FALSE;
if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) {
- vshError(ctl, FALSE, "%s '%s'", _("Could not find matching device"), name);
+ vshError(ctl, "%s '%s'", _("Could not find matching device"), name);
return FALSE;
}
if (virNodeDeviceReset(device) == 0) {
vshPrint(ctl, _("Device %s reset\n"), name);
} else {
- vshError(ctl, FALSE, _("Failed to reset device %s"), name);
+ vshError(ctl, _("Failed to reset device %s"), name);
ret = FALSE;
}
virNodeDeviceFree(device);
hostname = virConnectGetHostname (ctl->conn);
if (hostname == NULL) {
- vshError(ctl, FALSE, "%s", _("failed to get hostname"));
+ vshError(ctl, "%s", _("failed to get hostname"));
return FALSE;
}
uri = virConnectGetURI (ctl->conn);
if (uri == NULL) {
- vshError(ctl, FALSE, "%s", _("failed to get URI"));
+ vshError(ctl, "%s", _("failed to get URI"));
return FALSE;
}
from = vshCommandOptString(cmd, "file", &found);
if (!found) {
- vshError(ctl, FALSE, "%s", _("attach-device: Missing <file> option"));
+ vshError(ctl, "%s", _("attach-device: Missing <file> option"));
virDomainFree(dom);
return FALSE;
}
free (buffer);
if (ret < 0) {
- vshError(ctl, FALSE, _("Failed to attach device from %s"), from);
+ vshError(ctl, _("Failed to attach device from %s"), from);
virDomainFree(dom);
return FALSE;
} else {
from = vshCommandOptString(cmd, "file", &found);
if (!found) {
- vshError(ctl, FALSE, "%s", _("detach-device: Missing <file> option"));
+ vshError(ctl, "%s", _("detach-device: Missing <file> option"));
virDomainFree(dom);
return FALSE;
}
free (buffer);
if (ret < 0) {
- vshError(ctl, FALSE, _("Failed to detach device from %s"), from);
+ vshError(ctl, _("Failed to detach device from %s"), from);
virDomainFree(dom);
return FALSE;
} else {
} else if (STREQ(type, "bridge")) {
typ = 2;
} else {
- vshError(ctl, FALSE, _("No support %s in command 'attach-interface'"), type);
+ vshError(ctl, _("No support %s in command 'attach-interface'"), type);
goto cleanup;
}
XML_PARSE_NOWARNING);
free(doc);
if (!xml) {
- vshError(ctl, FALSE, "%s", _("Failed to get interface information"));
+ vshError(ctl, "%s", _("Failed to get interface information"));
goto cleanup;
}
ctxt = xmlXPathNewContext(xml);
if (!ctxt) {
- vshError(ctl, FALSE, "%s", _("Failed to get interface information"));
+ vshError(ctl, "%s", _("Failed to get interface information"));
goto cleanup;
}
obj = xmlXPathEval(BAD_CAST buf, ctxt);
if ((obj == NULL) || (obj->type != XPATH_NODESET) ||
(obj->nodesetval == NULL) || (obj->nodesetval->nodeNr == 0)) {
- vshError(ctl, FALSE, _("No found interface whose type is %s"), type);
+ vshError(ctl, _("No found interface whose type is %s"), type);
goto cleanup;
}
cur = cur->next;
}
}
- vshError(ctl, FALSE, _("No found interface whose MAC address is %s"), mac);
+ vshError(ctl, _("No found interface whose MAC address is %s"), mac);
goto cleanup;
hit:
xml_buf = xmlBufferCreate();
if (!xml_buf) {
- vshError(ctl, FALSE, "%s", _("Failed to allocate memory"));
+ vshError(ctl, "%s", _("Failed to allocate memory"));
goto cleanup;
}
if(xmlNodeDump(xml_buf, xml, obj->nodesetval->nodeTab[i], 0, 0) < 0){
- vshError(ctl, FALSE, "%s", _("Failed to create XML"));
+ vshError(ctl, "%s", _("Failed to create XML"));
goto cleanup;
}
if (STREQ(driver, "file") || STREQ(driver, "tap")) {
isFile = 1;
} else if (STRNEQ(driver, "phy")) {
- vshError(ctl, FALSE, _("No support %s in command 'attach-disk'"), driver);
+ vshError(ctl, _("No support %s in command 'attach-disk'"), driver);
goto cleanup;
}
}
if (mode) {
if (STRNEQ(mode, "readonly") && STRNEQ(mode, "shareable")) {
- vshError(ctl, FALSE, _("No support %s in command 'attach-disk'"), mode);
+ vshError(ctl, _("No support %s in command 'attach-disk'"), mode);
goto cleanup;
}
}
XML_PARSE_NOWARNING);
free(doc);
if (!xml) {
- vshError(ctl, FALSE, "%s", _("Failed to get disk information"));
+ vshError(ctl, "%s", _("Failed to get disk information"));
goto cleanup;
}
ctxt = xmlXPathNewContext(xml);
if (!ctxt) {
- vshError(ctl, FALSE, "%s", _("Failed to get disk information"));
+ vshError(ctl, "%s", _("Failed to get disk information"));
goto cleanup;
}
obj = xmlXPathEval(BAD_CAST "/domain/devices/disk", ctxt);
if ((obj == NULL) || (obj->type != XPATH_NODESET) ||
(obj->nodesetval == NULL) || (obj->nodesetval->nodeNr == 0)) {
- vshError(ctl, FALSE, "%s", _("Failed to get disk information"));
+ vshError(ctl, "%s", _("Failed to get disk information"));
goto cleanup;
}
cur = cur->next;
}
}
- vshError(ctl, FALSE, _("No found disk whose target is %s"), target);
+ vshError(ctl, _("No found disk whose target is %s"), target);
goto cleanup;
hit:
xml_buf = xmlBufferCreate();
if (!xml_buf) {
- vshError(ctl, FALSE, "%s", _("Failed to allocate memory"));
+ vshError(ctl, "%s", _("Failed to allocate memory"));
goto cleanup;
}
if(xmlNodeDump(xml_buf, xml, obj->nodesetval->nodeTab[i], 0, 0) < 0){
- vshError(ctl, FALSE, "%s", _("Failed to create XML"));
+ vshError(ctl, "%s", _("Failed to create XML"));
goto cleanup;
}
ret = malloc (PATH_MAX);
if (!ret) {
- vshError(ctl, FALSE,
- _("malloc: failed to allocate temporary file name: %s"),
- strerror (errno));
+ vshError(ctl, _("malloc: failed to allocate temporary file name: %s"),
+ strerror(errno));
return NULL;
}
snprintf (ret, PATH_MAX, "%s/virshXXXXXX", tmpdir);
fd = mkstemp (ret);
if (fd == -1) {
- vshError(ctl, FALSE,
- _("mkstemp: failed to create temporary file: %s"),
- strerror (errno));
+ vshError(ctl, _("mkstemp: failed to create temporary file: %s"),
+ strerror(errno));
return NULL;
}
if (safewrite (fd, doc, strlen (doc)) == -1) {
- vshError(ctl, FALSE,
- _("write: %s: failed to write to temporary file: %s"),
- ret, strerror (errno));
+ vshError(ctl, _("write: %s: failed to write to temporary file: %s"),
+ ret, strerror(errno));
close (fd);
unlink (ret);
free (ret);
return NULL;
}
if (close (fd) == -1) {
- vshError(ctl, FALSE,
- _("close: %s: failed to write or close temporary file: %s"),
- ret, strerror (errno));
+ vshError(ctl, _("close: %s: failed to write or close temporary file: %s"),
+ ret, strerror(errno));
unlink (ret);
free (ret);
return NULL;
* it does, refuse to run.
*/
if (strspn (editor, ACCEPTED_CHARS) != strlen (editor)) {
- vshError(ctl, FALSE,
- _("%s: $EDITOR environment variable contains shell meta or other unacceptable characters"),
+ vshError(ctl,
+ _("%s: $EDITOR environment variable contains shell meta or "
+ "other unacceptable characters"),
editor);
return -1;
}
/* Same for the filename. */
if (strspn (filename, ACCEPTED_CHARS) != strlen (filename)) {
- vshError(ctl, FALSE,
- _("%s: temporary filename contains shell meta or other unacceptable characters (is $TMPDIR wrong?)"),
+ vshError(ctl,
+ _("%s: temporary filename contains shell meta or other "
+ "unacceptable characters (is $TMPDIR wrong?)"),
filename);
return -1;
}
if (virAsprintf(&command, "%s %s", editor, filename) == -1) {
- vshError(ctl, FALSE,
+ vshError(ctl,
_("virAsprintf: could not create editing command: %s"),
- strerror (errno));
+ strerror(errno));
return -1;
}
command_ret = system (command);
if (command_ret == -1) {
- vshError(ctl, FALSE,
- _("%s: edit command failed: %s"), command, strerror (errno));
+ vshError(ctl,
+ _("%s: edit command failed: %s"), command, strerror(errno));
free (command);
return -1;
}
if (command_ret != WEXITSTATUS (0)) {
- vshError(ctl, FALSE,
+ vshError(ctl,
_("%s: command exited with non-zero status"), command);
free (command);
return -1;
char *ret;
if (virFileReadAll (filename, VIRSH_MAX_XML_FILE, &ret) == -1) {
- vshError(ctl, FALSE,
+ vshError(ctl,
_("%s: failed to read temporary file: %s"),
- filename, strerror (errno));
+ filename, strerror(errno));
return NULL;
}
return ret;
int found;
if (!ctl->imode) {
- vshError(ctl, FALSE, "%s",
- _("cd: command valid only in interactive mode"));
+ vshError(ctl, "%s", _("cd: command valid only in interactive mode"));
return -1;
}
dir = "/";
if (chdir (dir) == -1) {
- vshError(ctl, FALSE, _("cd: %s: %s"), strerror (errno), dir);
+ vshError(ctl, _("cd: %s: %s"), strerror(errno), dir);
return -1;
}
}
if (err)
- vshError(ctl, FALSE, _("pwd: cannot get current directory: %s"), strerror (errno));
+ vshError(ctl, _("pwd: cannot get current directory: %s"),
+ strerror(errno));
else
vshPrint (ctl, _("%s\n"), cwd);
goto cleanup;
if (STRNEQ (doc, doc_reread)) {
- vshError (ctl, FALSE,
- "%s", _("ERROR: the XML configuration was changed by another user"));
+ vshError(ctl,
+ "%s", _("ERROR: the XML configuration was changed by another user"));
goto cleanup;
}
o = o->next;
}
if (!ok) {
- vshError(ctl, FALSE,
+ vshError(ctl,
d->type == VSH_OT_DATA ?
_("command '%s' requires <%s> option") :
_("command '%s' requires --%s option"),
const vshCmdDef *def = vshCmddefSearch(cmdname);
if (!def) {
- vshError(ctl, FALSE, _("command '%s' doesn't exist"), cmdname);
+ vshError(ctl, _("command '%s' doesn't exist"), cmdname);
return FALSE;
} else {
const char *desc = N_(vshCmddefGetInfo(def, "desc"));
}
if (!found)
- vshError(ctl, FALSE,
- _("internal error: virsh %s: no %s VSH_OT_DATA option"),
+ vshError(ctl, _("internal error: virsh %s: no %s VSH_OT_DATA option"),
cmd->def->name, optname);
return found;
}
return NULL;
if (!(n = vshCommandOptString(cmd, optname, NULL))) {
- vshError(ctl, FALSE, "%s", _("undefined domain name or id"));
+ vshError(ctl, "%s", _("undefined domain name or id"));
return NULL;
}
}
if (!dom)
- vshError(ctl, FALSE, _("failed to get domain '%s'"), n);
+ vshError(ctl, _("failed to get domain '%s'"), n);
return dom;
}
return NULL;
if (!(n = vshCommandOptString(cmd, optname, NULL))) {
- vshError(ctl, FALSE, "%s", _("undefined network name"));
+ vshError(ctl, "%s", _("undefined network name"));
return NULL;
}
}
if (!network)
- vshError(ctl, FALSE, _("failed to get network '%s'"), n);
+ vshError(ctl, _("failed to get network '%s'"), n);
return network;
}
return NULL;
if (!(n = vshCommandOptString(cmd, optname, NULL))) {
- vshError(ctl, FALSE, "%s", _("undefined interface identifier"));
+ vshError(ctl, "%s", _("undefined interface identifier"));
return NULL;
}
}
if (!iface)
- vshError(ctl, FALSE, _("failed to get interface '%s'"), n);
+ vshError(ctl, _("failed to get interface '%s'"), n);
return iface;
}
char *n;
if (!(n = vshCommandOptString(cmd, optname, NULL))) {
- vshError(ctl, FALSE, "%s", _("undefined pool name"));
+ vshError(ctl, "%s", _("undefined pool name"));
return NULL;
}
}
if (!pool)
- vshError(ctl, FALSE, _("failed to get pool '%s'"), n);
+ vshError(ctl, _("failed to get pool '%s'"), n);
return pool;
}
int found;
if (!(n = vshCommandOptString(cmd, optname, NULL))) {
- vshError(ctl, FALSE, "%s", _("undefined vol name"));
+ vshError(ctl, "%s", _("undefined vol name"));
return NULL;
}
if (!(p = vshCommandOptString(cmd, pooloptname, &found)) && found) {
- vshError(ctl, FALSE, "%s", _("undefined pool name"));
+ vshError(ctl, "%s", _("undefined pool name"));
return NULL;
}
}
if (!vol)
- vshError(ctl, FALSE, _("failed to get vol '%s'"), n);
+ vshError(ctl, _("failed to get vol '%s'"), n);
if (pool)
virStoragePoolFree(pool);
n = vshCommandOptString(cmd, optname, NULL);
if (n == NULL) {
- vshError(ctl, FALSE, "%s", _("undefined secret UUID"));
+ vshError(ctl, "%s", _("undefined secret UUID"));
return NULL;
}
secret = virSecretLookupByUUIDString(ctl->conn, n);
if (secret == NULL)
- vshError(ctl, FALSE, _("failed to get secret '%s'"), n);
+ vshError(ctl, _("failed to get secret '%s'"), n);
return secret;
}
sz++;
}
if (quote) {
- vshError(ctl, FALSE, "%s", _("missing \""));
+ vshError(ctl, "%s", _("missing \""));
return VSH_TK_ERROR;
}
if (tkstr == NULL || *tkstr == '\0' || p == NULL)
if (cmd == NULL) {
/* first token must be command name */
if (tk != VSH_TK_DATA) {
- vshError(ctl, FALSE,
+ vshError(ctl,
_("unexpected token (command name): '%s'"),
tkdata);
goto syntaxError;
}
if (!(cmd = vshCmddefSearch(tkdata))) {
- vshError(ctl, FALSE, _("unknown command: '%s'"), tkdata);
+ vshError(ctl, _("unknown command: '%s'"), tkdata);
goto syntaxError; /* ... or ignore this command only? */
}
free(tkdata);
} else if (tk == VSH_TK_OPTION) {
if (!(opt = vshCmddefGetOption(cmd, tkdata))) {
- vshError(ctl, FALSE,
+ vshError(ctl,
_("command '%s' doesn't support option --%s"),
cmd->name, tkdata);
goto syntaxError;
if (tk == VSH_TK_ERROR)
goto syntaxError;
if (tk != VSH_TK_DATA) {
- vshError(ctl, FALSE,
+ vshError(ctl,
_("expected syntax: --%s <%s>"),
opt->name,
opt->type ==
}
} else if (tk == VSH_TK_DATA) {
if (!(opt = vshCmddefGetData(cmd, data_ct++))) {
- vshError(ctl, FALSE, _("unexpected data '%s'"), tkdata);
+ vshError(ctl, _("unexpected data '%s'"), tkdata);
goto syntaxError;
}
}
*/
if (!conn) {
if (showerror)
- vshError(ctl, FALSE, "%s", _("no valid connection"));
+ vshError(ctl, "%s", _("no valid connection"));
return FALSE;
}
return TRUE;
static void
-vshError(vshControl *ctl, int doexit, const char *format, ...)
+vshError(vshControl *ctl, const char *format, ...)
{
va_list ap;
vshOutputLogFile(ctl, VSH_ERR_ERROR, format, ap);
va_end(ap);
- if (doexit)
- fprintf(stderr, _("%s: error: "), progname);
- else
- fputs(_("error: "), stderr);
+ fputs(_("error: "), stderr);
va_start(ap, format);
vfprintf(stderr, format, ap);
va_end(ap);
fputc('\n', stderr);
-
- if (doexit) {
- if (ctl)
- vshDeinit(ctl);
- exit(EXIT_FAILURE);
- }
}
static void *
if ((x = malloc(size)))
return x;
- vshError(ctl, TRUE, _("%s: %d: failed to allocate %d bytes"),
+ vshError(ctl, _("%s: %d: failed to allocate %d bytes"),
filename, line, (int) size);
- return NULL;
+ exit(EXIT_FAILURE);
}
static void *
if ((x = calloc(nmemb, size)))
return x;
- vshError(ctl, TRUE, _("%s: %d: failed to allocate %d bytes"),
+ vshError(ctl, _("%s: %d: failed to allocate %d bytes"),
filename, line, (int) (size*nmemb));
- return NULL;
+ exit(EXIT_FAILURE);
}
static void *
if ((x = realloc(ptr, size)))
return x;
free(ptr);
- vshError(ctl, TRUE, _("%s: %d: failed to allocate %d bytes"),
+ vshError(ctl, _("%s: %d: failed to allocate %d bytes"),
filename, line, (int) size);
- return NULL;
+ exit(EXIT_FAILURE);
}
static char *
return(NULL);
if ((x = strdup(s)))
return x;
- vshError(ctl, TRUE, _("%s: %d: failed to allocate %lu bytes"),
+ vshError(ctl, _("%s: %d: failed to allocate %lu bytes"),
filename, line, (unsigned long)strlen(s));
- return NULL;
+ exit(EXIT_FAILURE);
}
/*
*/
if (!ctl->conn) {
virshReportError(ctl);
- vshError(ctl, FALSE, "%s", _("failed to connect to the hypervisor"));
+ vshError(ctl, "%s", _("failed to connect to the hypervisor"));
return FALSE;
}
case ENOENT:
break;
default:
- vshError(ctl, TRUE, "%s",
+ vshError(ctl, "%s",
_("failed to get the log file information"));
- break;
+ exit(EXIT_FAILURE);
}
} else {
if (!S_ISREG(st.st_mode)) {
- vshError(ctl, TRUE, "%s", _("the log path is not a file"));
+ vshError(ctl, "%s", _("the log path is not a file"));
+ exit(EXIT_FAILURE);
}
}
/* log file open */
if ((ctl->log_fd = open(ctl->logfile, LOGFILE_FLAGS, FILE_MODE)) < 0) {
- vshError(ctl, TRUE, "%s",
+ vshError(ctl, "%s",
_("failed to open the log file. check the log file path"));
+ exit(EXIT_FAILURE);
}
}
/* write log */
if (safewrite(ctl->log_fd, msg_buf, strlen(msg_buf)) < 0) {
vshCloseLogFile(ctl);
- vshError(ctl, FALSE, "%s", _("failed to write the log file"));
+ vshError(ctl, "%s", _("failed to write the log file"));
}
}
/* log file close */
if (ctl->log_fd >= 0) {
if (close(ctl->log_fd) < 0)
- vshError(ctl, FALSE, _("%s: failed to write log file: %s"),
+ vshError(ctl, _("%s: failed to write log file: %s"),
ctl->logfile ? ctl->logfile : "?", strerror (errno));
ctl->log_fd = -1;
}
free(ctl->name);
if (ctl->conn) {
if (virConnectClose(ctl->conn) != 0) {
- ctl->conn = NULL; /* prevent recursive call from vshError() */
- vshError(ctl, TRUE, "%s",
- _("failed to disconnect from the hypervisor"));
+ vshError(ctl, "%s", _("failed to disconnect from the hypervisor"));
}
}
virResetLastError();
ctl->logfile = vshStrdup(ctl, optarg);
break;
default:
- vshError(ctl, TRUE,
- _("unsupported option '-%c'. See --help."), arg);
- break;
+ vshError(ctl, _("unsupported option '-%c'. See --help."), arg);
+ exit(EXIT_FAILURE);
}
}
if (help) {
- if (end < argc)
- vshError(ctl, TRUE,
- _("extra argument '%s'. See --help."), argv[end]);
+ if (end < argc) {
+ vshError(ctl, _("extra argument '%s'. See --help."), argv[end]);
+ exit(EXIT_FAILURE);
+ }
/* list all command */
vshUsage();