static char *progname;
-#ifndef TRUE
-# define TRUE 1
-# define FALSE 0
-#endif
-
#define VIRSH_MAX_XML_FILE 10*1024*1024
#define VSH_PROMPT_RW "virsh # "
*/
typedef struct {
const char *name;
- int (*handler) (vshControl *, const vshCmd *); /* command handler */
+ bool (*handler) (vshControl *, const vshCmd *); /* command handler */
const vshCmdOptDef *opts; /* definition of command options */
const vshCmdInfo *info; /* details about command */
} vshCmdDef;
virConnectPtr conn; /* connection to hypervisor (MAY BE NULL) */
vshCmd *cmd; /* the current command */
char *cmdstr; /* string with command */
- int imode; /* interactive mode? */
- int quiet; /* quiet mode */
+ bool imode; /* interactive mode? */
+ bool quiet; /* quiet mode */
int debug; /* print debug messages? */
- int timing; /* print timing info? */
- int readonly; /* connect readonly (first time only, not
+ bool timing; /* print timing info? */
+ bool readonly; /* connect readonly (first time only, not
* during explicit connect command)
*/
char *logfile; /* log file name */
static void vshError(vshControl *ctl, const char *format, ...)
ATTRIBUTE_FMT_PRINTF(2, 3);
-static int vshInit(vshControl *ctl);
-static int vshDeinit(vshControl *ctl);
+static bool vshInit(vshControl *ctl);
+static bool vshDeinit(vshControl *ctl);
static void vshUsage(void);
static void vshOpenLogFile(vshControl *ctl);
static void vshOutputLogFile(vshControl *ctl, int log_level, const char *format, va_list ap)
ATTRIBUTE_FMT_PRINTF(3, 0);
static void vshCloseLogFile(vshControl *ctl);
-static int vshParseArgv(vshControl *ctl, int argc, char **argv);
+static bool vshParseArgv(vshControl *ctl, int argc, char **argv);
static const char *vshCmddefGetInfo(const vshCmdDef *cmd, const char *info);
static const vshCmdDef *vshCmddefSearch(const char *cmdname);
-static int vshCmddefHelp(vshControl *ctl, const char *name);
+static bool vshCmddefHelp(vshControl *ctl, const char *name);
static const vshCmdGrp *vshCmdGrpSearch(const char *grpname);
-static int vshCmdGrpHelp(vshControl *ctl, const char *name);
+static bool vshCmdGrpHelp(vshControl *ctl, const char *name);
static vshCmdOpt *vshCommandOpt(const vshCmd *cmd, const char *name);
static int vshCommandOptInt(const vshCmd *cmd, const char *name, int *value)
static int vshCommandOptULongLong(const vshCmd *cmd, const char *name,
unsigned long long *value)
ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK;
-static int vshCommandOptBool(const vshCmd *cmd, const char *name);
+static bool vshCommandOptBool(const vshCmd *cmd, const char *name);
static char *vshCommandOptArgv(const vshCmd *cmd, int count);
#define VSH_BYID (1 << 1)
static const char *vshDomainStateToString(int state);
static const char *vshDomainVcpuStateToString(int state);
-static int vshConnectionUsability(vshControl *ctl, virConnectPtr conn);
+static bool vshConnectionUsability(vshControl *ctl, virConnectPtr conn);
static char *editWriteToTempFile (vshControl *ctl, const char *doc);
static int editFile (vshControl *ctl, const char *filename);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdHelp(vshControl *ctl, const vshCmd *cmd)
{
const char *name = NULL;
vshPrint(ctl, "\n");
}
- return TRUE;
+ return true;
}
if (vshCmddefSearch(name)) {
return vshCmdGrpHelp(ctl, name);
} else {
vshError(ctl, _("command or command group '%s' doesn't exist"), name);
- return FALSE;
+ return false;
}
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdAutostart(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
int autostart;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
autostart = !vshCommandOptBool(cmd, "disable");
else
vshError(ctl, _("Failed to unmark domain %s as autostarted"), name);
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (autostart)
vshPrint(ctl, _("Domain %s unmarked as autostarted\n"), name);
virDomainFree(dom);
- return TRUE;
+ return true;
}
/*
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdConnect(vshControl *ctl, const vshCmd *cmd)
{
- int ro = vshCommandOptBool(cmd, "readonly");
+ bool ro = vshCommandOptBool(cmd, "readonly");
const char *name = NULL;
if (ctl->conn) {
int ret;
if ((ret = virConnectClose(ctl->conn)) != 0) {
vshError(ctl, _("Failed to disconnect from the hypervisor, %d leaked reference(s)"), ret);
- return FALSE;
+ return false;
}
ctl->conn = NULL;
}
VIR_FREE(ctl->name);
if (vshCommandOptString(cmd, "name", &name) < 0) {
vshError(ctl, "%s", _("Please specify valid connection URI"));
- return FALSE;
+ return false;
}
ctl->name = vshStrdup(ctl, name);
- if (!ro) {
- ctl->readonly = 0;
- } else {
- ctl->readonly = 1;
- }
+ ctl->readonly = ro;
ctl->conn = virConnectOpenAuth(ctl->name, virConnectAuthPtrDefault,
ctl->readonly ? VIR_CONNECT_RO : 0);
if (!ctl->conn)
vshError(ctl, "%s", _("Failed to connect to the hypervisor"));
- return ctl->conn ? TRUE : FALSE;
+ return !!ctl->conn;
}
#ifndef WIN32
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdRunConsole(vshControl *ctl, virDomainPtr dom, const char *name)
{
- int ret = FALSE;
+ bool ret = false;
virDomainInfo dominfo;
if (virDomainGetInfo(dom, &dominfo) < 0) {
vshPrintExtra(ctl, _("Connected to domain %s\n"), virDomainGetName(dom));
vshPrintExtra(ctl, "%s", _("Escape character is ^]\n"));
if (vshRunConsole(dom, name) == 0)
- ret = TRUE;
+ ret = true;
cleanup:
return ret;
}
-static int
+static bool
cmdConsole(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = FALSE;
+ bool ret = false;
const char *name = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "devname", &name) < 0) {
vshError(ctl, "%s", _("Invalid devname"));
};
-static int
+static bool
cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
int inactive = vshCommandOptBool(cmd, "inactive");
inactive |= all;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (active) {
maxid = virConnectNumOfDomains(ctl->conn);
if (maxid < 0) {
vshError(ctl, "%s", _("Failed to list active domains"));
- return FALSE;
+ return false;
}
if (maxid) {
ids = vshMalloc(ctl, sizeof(int) * maxid);
if ((maxid = virConnectListDomains(ctl->conn, &ids[0], maxid)) < 0) {
vshError(ctl, "%s", _("Failed to list active domains"));
VIR_FREE(ids);
- return FALSE;
+ return false;
}
qsort(&ids[0], maxid, sizeof(int), idsorter);
if (maxname < 0) {
vshError(ctl, "%s", _("Failed to list inactive domains"));
VIR_FREE(ids);
- return FALSE;
+ return false;
}
if (maxname) {
names = vshMalloc(ctl, sizeof(char *) * maxname);
vshError(ctl, "%s", _("Failed to list inactive domains"));
VIR_FREE(ids);
VIR_FREE(names);
- return FALSE;
+ return false;
}
qsort(&names[0], maxname, sizeof(char*), namesorter);
}
VIR_FREE(ids);
VIR_FREE(names);
- return TRUE;
+ return true;
}
/*
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomstate(vshControl *ctl, const vshCmd *cmd)
{
virDomainInfo info;
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (virDomainGetInfo(dom, &info) == 0)
vshPrint(ctl, "%s\n",
_(vshDomainStateToString(info.state)));
else
- ret = FALSE;
+ ret = false;
virDomainFree(dom);
return ret;
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomblkstat (vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
struct _virDomainBlockStats stats;
if (!vshConnectionUsability (ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain (ctl, cmd, &name)))
- return FALSE;
+ return false;
if (vshCommandOptString (cmd, "device", &device) <= 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virDomainBlockStats (dom, device, &stats, sizeof stats) == -1) {
vshError(ctl, _("Failed to get block stats %s %s"), name, device);
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (stats.rd_req >= 0)
vshPrint (ctl, "%s errs %lld\n", device, stats.errs);
virDomainFree(dom);
- return TRUE;
+ return true;
}
/* "domifstat" command
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomIfstat (vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
struct _virDomainInterfaceStats stats;
if (!vshConnectionUsability (ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain (ctl, cmd, &name)))
- return FALSE;
+ return false;
if (vshCommandOptString (cmd, "interface", &device) <= 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virDomainInterfaceStats (dom, device, &stats, sizeof stats) == -1) {
vshError(ctl, _("Failed to get interface stats %s %s"), name, device);
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (stats.rx_bytes >= 0)
vshPrint (ctl, "%s tx_drop %lld\n", device, stats.tx_drop);
virDomainFree(dom);
- return TRUE;
+ return true;
}
/*
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomMemStat(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
unsigned int nr_stats, i;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
nr_stats = virDomainMemoryStats (dom, stats, VIR_DOMAIN_MEMORY_STAT_NR, 0);
if (nr_stats == -1) {
vshError(ctl, _("Failed to get memory statistics for domain %s"), name);
virDomainFree(dom);
- return FALSE;
+ return false;
}
for (i = 0; i < nr_stats; i++) {
}
virDomainFree(dom);
- return TRUE;
+ return true;
}
/*
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd)
{
virDomainBlockInfo info;
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
const char *device = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptString (cmd, "device", &device) <= 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virDomainGetBlockInfo(dom, device, &info, 0) < 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
vshPrint(ctl, "%-15s %llu\n", _("Capacity:"), info.capacity);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSuspend(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *name;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virDomainSuspend(dom) == 0) {
vshPrint(ctl, _("Domain %s suspended\n"), name);
} else {
vshError(ctl, _("Failed to suspend domain %s"), name);
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdCreate(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
#ifndef WIN32
int console = vshCommandOptBool(cmd, "console");
unsigned int flags = VIR_DOMAIN_NONE;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
if (vshCommandOptBool(cmd, "paused"))
flags |= VIR_DOMAIN_START_PAUSED;
virDomainFree(dom);
} else {
vshError(ctl, _("Failed to create domain from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDefine(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
dom = virDomainDefineXML(ctl->conn, buffer);
VIR_FREE(buffer);
virDomainFree(dom);
} else {
vshError(ctl, _("Failed to define domain from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdUndefine(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
const char *name = NULL;
int id;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "domain", &name) <= 0)
- return FALSE;
+ return false;
if (name && virStrToLong_i(name, NULL, 10, &id) == 0
&& id >= 0 && (dom = virDomainLookupByID(ctl->conn, id))) {
" using its name or UUID"),
name);
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (!(dom = vshCommandOptDomainBy(ctl, cmd, &name,
VSH_BYNAME|VSH_BYUUID)))
- return FALSE;
+ return false;
if (virDomainUndefine(dom) == 0) {
vshPrint(ctl, _("Domain %s has been undefined\n"), name);
} else {
vshError(ctl, _("Failed to undefine domain %s"), name);
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdStart(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
#ifndef WIN32
int console = vshCommandOptBool(cmd, "console");
#endif
unsigned int flags = VIR_DOMAIN_NONE;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomainBy(ctl, cmd, NULL,
VSH_BYNAME | VSH_BYUUID)))
- return FALSE;
+ return false;
if (virDomainGetID(dom) != (unsigned int)-1) {
vshError(ctl, "%s", _("Domain is already active"));
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (vshCommandOptBool(cmd, "paused"))
#endif
} else {
vshError(ctl, _("Failed to start domain %s"), virDomainGetName(dom));
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
return ret;
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSave(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *name = NULL;
const char *to = NULL;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &to) <= 0)
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virDomainSave(dom, to) == 0) {
vshPrint(ctl, _("Domain %s saved to %s\n"), name, to);
} else {
vshError(ctl, _("Failed to save domain %s to %s"), name, to);
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdManagedSave(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *name;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virDomainManagedSave(dom, 0) == 0) {
vshPrint(ctl, _("Domain %s state saved by libvirt\n"), name);
} else {
vshError(ctl, _("Failed to save domain %s state"), name);
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdManagedSaveRemove(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *name;
- int ret = FALSE;
+ bool ret = false;
int hassave;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
hassave = virDomainHasManagedSaveImage(dom, 0);
if (hassave < 0) {
vshPrint(ctl, _("Domain %s has no manage save image; removal skipped"),
name);
- ret = TRUE;
+ ret = true;
cleanup:
virDomainFree(dom);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSchedInfoUpdate(vshControl *ctl, const vshCmd *cmd,
virSchedParameterPtr param)
{
}
-static int
+static bool
cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
{
char *schedulertype;
int nparams = 0;
int update = 0;
int i, ret;
- int ret_val = FALSE;
+ int ret_val = false;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
/* Print SchedulerType */
schedulertype = virDomainGetSchedulerType(dom, &nparams);
}
}
- ret_val = TRUE;
+ ret_val = true;
for (i = 0; i < nparams; i++){
switch (params[i].type) {
case VIR_DOMAIN_SCHED_FIELD_INT:
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdRestore(vshControl *ctl, const vshCmd *cmd)
{
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virDomainRestore(ctl->conn, from) == 0) {
vshPrint(ctl, _("Domain restored from %s\n"), from);
} else {
vshError(ctl, _("Failed to restore domain from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDump(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *name = NULL;
const char *to = NULL;
- int ret = TRUE;
+ bool ret = true;
int flags = 0;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &to) <= 0)
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (vshCommandOptBool (cmd, "live"))
flags |= VIR_DUMP_LIVE;
vshPrint(ctl, _("Domain %s dumped to %s\n"), name, to);
} else {
vshError(ctl, _("Failed to core dump domain %s to %s"), name, to);
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdResume(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virDomainResume(dom) == 0) {
vshPrint(ctl, _("Domain %s resumed\n"), name);
} else {
vshError(ctl, _("Failed to resume domain %s"), name);
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdShutdown(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virDomainShutdown(dom) == 0) {
vshPrint(ctl, _("Domain %s is being shutdown\n"), name);
} else {
vshError(ctl, _("Failed to shutdown domain %s"), name);
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdReboot(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virDomainReboot(dom, 0) == 0) {
vshPrint(ctl, _("Domain %s is being rebooted\n"), name);
} else {
vshError(ctl, _("Failed to reboot domain %s"), name);
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDestroy(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virDomainDestroy(dom) == 0) {
vshPrint(ctl, _("Domain %s destroyed\n"), name);
} else {
vshError(ctl, _("Failed to destroy domain %s"), name);
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDominfo(vshControl *ctl, const vshCmd *cmd)
{
virDomainInfo info;
virSecurityModel secmodel;
virSecurityLabelPtr seclabel;
int persistent = 0;
- int ret = TRUE, autostart;
+ bool ret = true;
+ int autostart;
unsigned int id;
char *str, uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
id = virDomainGetID(dom);
if (id == ((unsigned int)-1))
info.memory);
} else {
- ret = FALSE;
+ ret = false;
}
/* Check and display whether the domain is persistent or not */
if (virNodeGetSecurityModel(ctl->conn, &secmodel) == -1) {
if (last_error->code != VIR_ERR_NO_SUPPORT) {
virDomainFree(dom);
- return FALSE;
+ return false;
} else {
virFreeError(last_error);
last_error = NULL;
/* Security labels are only valid for active domains */
if (VIR_ALLOC(seclabel) < 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virDomainGetSecurityLabel(dom, seclabel) == -1) {
virDomainFree(dom);
VIR_FREE(seclabel);
- return FALSE;
+ return false;
} else {
if (seclabel->label[0] != '\0')
vshPrint(ctl, "%-15s %s (%s)\n", _("Security label:"),
};
-static int
+static bool
cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
{
virDomainJobInfo info;
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (virDomainGetJobInfo(dom, &info) == 0) {
const char *unit;
vshPrint(ctl, "%-17s %-.3lf %s\n", _("File total:"), val, unit);
}
} else {
- ret = FALSE;
+ ret = false;
}
cleanup:
virDomainFree(dom);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomjobabort(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (virDomainAbortJob(dom) < 0)
- ret = FALSE;
+ ret = false;
virDomainFree(dom);
return ret;
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdFreecell(vshControl *ctl, const vshCmd *cmd)
{
- int func_ret = FALSE;
+ int func_ret = false;
int ret;
int cell = -1, cell_given;
unsigned long long memory;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if ( (cell_given = vshCommandOptInt(cmd, "cellno", &cell)) < 0) {
vshError(ctl, "%s", _("cell number has to be a number"));
vshPrint(ctl, "%d: %llu kB\n", cell, (memory/1024));
}
- func_ret = TRUE;
+ func_ret = true;
cleanup:
xmlXPathFreeContext(ctxt);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd)
{
const char *type = NULL;
if (vshCommandOptString(cmd, "type", &type) < 0) {
vshError(ctl, "%s", _("Invalid type"));
- return FALSE;
+ return false;
}
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
vcpus = virConnectGetMaxVcpus(ctl->conn, type);
if (vcpus < 0)
- return FALSE;
+ return false;
vshPrint(ctl, "%d\n", vcpus);
- return TRUE;
+ return true;
}
/*
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVcpucount(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
int maximum = vshCommandOptBool(cmd, "maximum");
int current = vshCommandOptBool(cmd, "current");
int config = vshCommandOptBool(cmd, "config");
if (maximum && current) {
vshError(ctl, "%s",
_("--maximum and --current cannot both be specified"));
- return FALSE;
+ return false;
}
if (config && live) {
vshError(ctl, "%s",
_("--config and --live cannot both be specified"));
- return FALSE;
+ return false;
}
/* We want one of each pair of mutually exclusive options; that
* is, use of flags requires exactly two options. */
: config ? "config" : "live"),
maximum + current ? "config" : "maximum",
maximum + current ? "live" : "current");
- return FALSE;
+ return false;
}
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
/* In all cases, try the new API first; if it fails because we are
* talking to an older client, try a fallback API before giving
if (count < 0) {
virshReportError(ctl);
- ret = FALSE;
+ ret = false;
} else if (all) {
vshPrint(ctl, "%-12s %-12s %3d\n", _("maximum"), _("config"),
count);
if (count < 0) {
virshReportError(ctl);
- ret = FALSE;
+ ret = false;
} else if (all) {
vshPrint(ctl, "%-12s %-12s %3d\n", _("maximum"), _("live"),
count);
if (count < 0) {
virshReportError(ctl);
- ret = FALSE;
+ ret = false;
} else if (all) {
vshPrint(ctl, "%-12s %-12s %3d\n", _("current"), _("config"),
count);
if (count < 0) {
virshReportError(ctl);
- ret = FALSE;
+ ret = false;
} else if (all) {
vshPrint(ctl, "%-12s %-12s %3d\n", _("current"), _("live"),
count);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd)
{
virDomainInfo info;
unsigned char *cpumap;
int ncpus;
size_t cpumaplen;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (virNodeGetInfo(ctl->conn, &nodeinfo) != 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virDomainGetInfo(dom, &info) != 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
cpuinfo = vshMalloc(ctl, sizeof(virVcpuInfo)*info.nrVirtCpu);
vshError(ctl, "%s",
_("Domain shut off, virtual CPUs not present."));
}
- ret = FALSE;
+ ret = false;
}
VIR_FREE(cpumap);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVcpupin(vshControl *ctl, const vshCmd *cmd)
{
virDomainInfo info;
virNodeInfo nodeinfo;
int vcpu;
const char *cpulist = NULL;
- int ret = TRUE;
+ bool ret = true;
unsigned char *cpumap;
int cpumaplen;
int i;
enum { expect_num, expect_num_or_comma } state;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptInt(cmd, "vcpu", &vcpu) <= 0) {
vshError(ctl, "%s", _("vcpupin: Invalid or missing vCPU number."));
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (vshCommandOptString(cmd, "cpulist", &cpulist) <= 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virNodeGetInfo(ctl->conn, &nodeinfo) != 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virDomainGetInfo(dom, &info) != 0) {
vshError(ctl, "%s", _("vcpupin: failed to get domain informations."));
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (vcpu >= info.nrVirtCpu) {
vshError(ctl, "%s", _("vcpupin: Invalid vCPU number."));
virDomainFree(dom);
- return FALSE;
+ return false;
}
/* Check that the cpulist parameter is a comma-separated list of
if (cpulist[0] == '\0') {
vshError(ctl, "%s", _("cpulist: Invalid format. Empty string."));
virDomainFree (dom);
- return FALSE;
+ return false;
}
state = expect_num;
"digit at position %d (near '%c')."),
cpulist, i, cpulist[i]);
virDomainFree (dom);
- return FALSE;
+ return false;
}
state = expect_num_or_comma;
break;
"digit or comma at position %d (near '%c')."),
cpulist, i, cpulist[i]);
virDomainFree (dom);
- return FALSE;
+ return false;
}
}
}
"at position %d."),
cpulist, i);
virDomainFree (dom);
- return FALSE;
+ return false;
}
cpumaplen = VIR_CPU_MAPLEN(VIR_NODEINFO_MAXCPUS(nodeinfo));
vshError(ctl, _("Physical CPU %d doesn't exist."), cpu);
VIR_FREE(cpumap);
virDomainFree(dom);
- return FALSE;
+ return false;
}
cpulist = strchr(cpulist, ',');
if (cpulist)
} while (cpulist);
if (virDomainPinVcpu(dom, vcpu, cpumap, cpumaplen) != 0) {
- ret = FALSE;
+ ret = false;
}
VIR_FREE(cpumap);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
int count;
- int ret = TRUE;
+ bool ret = true;
int maximum = vshCommandOptBool(cmd, "maximum");
int config = vshCommandOptBool(cmd, "config");
int live = vshCommandOptBool(cmd, "live");
(live ? VIR_DOMAIN_VCPU_LIVE : 0));
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptInt(cmd, "count", &count) < 0) {
vshError(ctl, "%s", _("Invalid number of virtual CPUs"));
if (!flags) {
if (virDomainSetVcpus(dom, count) != 0) {
- ret = FALSE;
+ ret = false;
}
} else {
/* If the --maximum flag was given, we need to ensure only the
/* Warn the user about the invalid flag combination */
vshError(ctl, _("--maximum must be used with --config only"));
- ret = FALSE;
+ ret = false;
goto cleanup;
}
}
/* Apply the virtual cpu changes */
if (virDomainSetVcpusFlags(dom, count, flags) < 0) {
- ret = FALSE;
+ ret = false;
}
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSetmem(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
virDomainInfo info;
unsigned long kilobytes = 0;
- int ret = TRUE;
+ bool ret = true;
int config = vshCommandOptBool(cmd, "config");
int live = vshCommandOptBool(cmd, "live");
int current = vshCommandOptBool(cmd, "current");
if (current) {
if (live || config) {
vshError(ctl, "%s", _("--current must be specified exclusively"));
- return FALSE;
+ return false;
}
flags = VIR_DOMAIN_MEM_CURRENT;
} else {
}
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptUL(cmd, "kilobytes", &kilobytes) < 0) {
vshError(ctl, "%s", _("memory size has to be a number"));
- return FALSE;
+ return false;
}
if (kilobytes <= 0) {
virDomainFree(dom);
vshError(ctl, _("Invalid value of %lu for memory size"), kilobytes);
- return FALSE;
+ return false;
}
if (virDomainGetInfo(dom, &info) != 0) {
virDomainFree(dom);
vshError(ctl, "%s", _("Unable to verify MaxMemorySize"));
- return FALSE;
+ return false;
}
if (kilobytes > info.maxMem) {
virDomainFree(dom);
vshError(ctl, _("Requested memory size %lu kb is larger than maximum of %lu kb"),
kilobytes, info.maxMem);
- return FALSE;
+ return false;
}
if (flags == -1) {
if (virDomainSetMemory(dom, kilobytes) != 0) {
- ret = FALSE;
+ ret = false;
}
} else {
if (virDomainSetMemoryFlags(dom, kilobytes, flags) < 0) {
- ret = FALSE;
+ ret = false;
}
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
virDomainInfo info;
int kilobytes = 0;
- int ret = TRUE;
+ bool ret = true;
int config = vshCommandOptBool(cmd, "config");
int live = vshCommandOptBool(cmd, "live");
int current = vshCommandOptBool(cmd, "current");
if (current) {
if (live || config) {
vshError(ctl, "%s", _("--current must be specified exclusively"));
- return FALSE;
+ return false;
}
} else {
if (config)
}
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptInt(cmd, "kilobytes", &kilobytes) < 0) {
vshError(ctl, "%s", _("memory size has to be a number"));
- return FALSE;
+ return false;
}
if (kilobytes <= 0) {
virDomainFree(dom);
vshError(ctl, _("Invalid value of %d for memory size"), kilobytes);
- return FALSE;
+ return false;
}
if (virDomainGetInfo(dom, &info) != 0) {
virDomainFree(dom);
vshError(ctl, "%s", _("Unable to verify current MemorySize"));
- return FALSE;
+ return false;
}
if (flags == -1) {
if (virDomainSetMaxMemory(dom, kilobytes) != 0) {
vshError(ctl, "%s", _("Unable to change MaxMemorySize"));
- ret = FALSE;
+ ret = false;
}
} else {
if (virDomainSetMemoryFlags(dom, kilobytes, flags) < 0) {
vshError(ctl, "%s", _("Unable to change MaxMemorySize"));
- ret = FALSE;
+ ret = false;
}
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
{
virDomainPtr dom;
int nparams = 0;
unsigned int i = 0;
virBlkioParameterPtr params = NULL, temp = NULL;
- int ret = FALSE;
+ bool ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptInt(cmd, "weight", &weight) < 0) {
vshError(ctl, "%s",
if (nparams == 0) {
/* nothing to output */
- ret = TRUE;
+ ret = true;
goto cleanup;
}
}
}
- ret = TRUE;
+ ret = true;
} else {
/* set the blkio parameters */
params = vshCalloc(ctl, nparams, sizeof(*params));
if (virDomainSetBlkioParameters(dom, params, nparams, 0) != 0)
vshError(ctl, "%s", _("Unable to change blkio parameters"));
else
- ret = TRUE;
+ ret = true;
}
cleanup:
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdMemtune(vshControl * ctl, const vshCmd * cmd)
{
virDomainPtr dom;
int nparams = 0;
unsigned int i = 0;
virMemoryParameterPtr params = NULL, temp = NULL;
- int ret = FALSE;
+ bool ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptLongLong(cmd, "hard-limit", &hard_limit) < 0 ||
vshCommandOptLongLong(cmd, "soft-limit", &soft_limit) < 0 ||
if (nparams == 0) {
/* nothing to output */
- ret = TRUE;
+ ret = true;
goto cleanup;
}
}
}
- ret = TRUE;
+ ret = true;
} else {
/* set the memory parameters */
params = vshCalloc(ctl, nparams, sizeof(*params));
if (virDomainSetMemoryParameters(dom, params, nparams, 0) != 0)
vshError(ctl, "%s", _("Unable to change memory parameters"));
else
- ret = TRUE;
+ ret = true;
}
cleanup:
{NULL, NULL}
};
-static int
+static bool
cmdNodeinfo(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
virNodeInfo info;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (virNodeGetInfo(ctl->conn, &info) < 0) {
vshError(ctl, "%s", _("failed to get node information"));
- return FALSE;
+ return false;
}
vshPrint(ctl, "%-20s %s\n", _("CPU model:"), info.model);
vshPrint(ctl, "%-20s %d\n", _("CPU(s):"), info.cpus);
vshPrint(ctl, "%-20s %d\n", _("NUMA cell(s):"), info.nodes);
vshPrint(ctl, "%-20s %lu kB\n", _("Memory size:"), info.memory);
- return TRUE;
+ return true;
}
/*
{NULL, NULL}
};
-static int
+static bool
cmdCapabilities (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
char *caps;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if ((caps = virConnectGetCapabilities (ctl->conn)) == NULL) {
vshError(ctl, "%s", _("failed to get capabilities"));
- return FALSE;
+ return false;
}
vshPrint (ctl, "%s\n", caps);
VIR_FREE(caps);
- return TRUE;
+ return true;
}
/*
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDumpXML(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
char *dump;
int flags = 0;
int inactive = vshCommandOptBool(cmd, "inactive");
flags |= VIR_DOMAIN_XML_UPDATE_CPU;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
dump = virDomainGetXMLDesc(dom, flags);
if (dump != NULL) {
vshPrint(ctl, "%s", dump);
VIR_FREE(dump);
} else {
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomXMLFromNative(vshControl *ctl, const vshCmd *cmd)
{
- int ret = TRUE;
+ bool ret = true;
const char *format = NULL;
const char *configFile = NULL;
char *configData;
int flags = 0;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "format", &format) < 0 ||
vshCommandOptString(cmd, "config", &configFile) < 0)
- return FALSE;
+ return false;
if (virFileReadAll(configFile, 1024*1024, &configData) < 0)
- return FALSE;
+ return false;
xmlData = virConnectDomainXMLFromNative(ctl->conn, format, configData, flags);
if (xmlData != NULL) {
vshPrint(ctl, "%s", xmlData);
VIR_FREE(xmlData);
} else {
- ret = FALSE;
+ ret = false;
}
return ret;
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomXMLToNative(vshControl *ctl, const vshCmd *cmd)
{
- int ret = TRUE;
+ bool ret = true;
const char *format = NULL;
const char *xmlFile = NULL;
char *configData;
int flags = 0;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "format", &format) < 0
|| vshCommandOptString(cmd, "xml", &xmlFile) < 0)
- return FALSE;
+ return false;
if (virFileReadAll(xmlFile, 1024*1024, &xmlData) < 0)
- return FALSE;
+ return false;
configData = virConnectDomainXMLToNative(ctl->conn, format, xmlData, flags);
if (configData != NULL) {
vshPrint(ctl, "%s", configData);
VIR_FREE(configData);
} else {
- ret = FALSE;
+ ret = false;
}
return ret;
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomname(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomainBy(ctl, cmd, NULL,
VSH_BYID|VSH_BYUUID)))
- return FALSE;
+ return false;
vshPrint(ctl, "%s\n", virDomainGetName(dom));
virDomainFree(dom);
- return TRUE;
+ return true;
}
/*
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomid(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
unsigned int id;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomainBy(ctl, cmd, NULL,
VSH_BYNAME|VSH_BYUUID)))
- return FALSE;
+ return false;
id = virDomainGetID(dom);
if (id == ((unsigned int)-1))
else
vshPrint(ctl, "%d\n", id);
virDomainFree(dom);
- return TRUE;
+ return true;
}
/*
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomuuid(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
char uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomainBy(ctl, cmd, NULL,
VSH_BYNAME|VSH_BYID)))
- return FALSE;
+ return false;
if (virDomainGetUUIDString(dom, uuid) != -1)
vshPrint(ctl, "%s\n", uuid);
vshError(ctl, "%s", _("failed to get domain UUID"));
virDomainFree(dom);
- return TRUE;
+ return true;
}
/*
fprintf(stderr, "\rMigration: [%3d %%]", progress);
}
-static int
+static bool
cmdMigrate (vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
#endif
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptBool (cmd, "verbose"))
verbose = true;
if (vshCommandOptBool (cmd, "live"))
- live_flag = TRUE;
+ live_flag = true;
if (vshCommandOptInt(cmd, "timeout", &timeout) > 0) {
if (! live_flag) {
vshError(ctl, "%s", _("migrate: Unexpected timeout for offline migration"));
if (ret > 0) {
if (saferead(p[0], &retchar, sizeof(retchar)) > 0) {
if (retchar == '0') {
- ret = TRUE;
+ ret = true;
if (verbose) {
/* print [100 %] */
print_job_progress(0, 1);
}
} else
- ret = FALSE;
+ ret = false;
} else
- ret = FALSE;
+ ret = false;
break;
}
if (errno == EINTR) {
if (intCaught) {
virDomainAbortJob(dom);
- ret = FALSE;
+ ret = false;
intCaught = 0;
} else
goto repoll;
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdMigrateSetMaxDowntime(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
long long downtime = 0;
- int ret = FALSE;
+ bool ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptLongLong(cmd, "downtime", &downtime) < 0 ||
downtime < 1) {
if (virDomainMigrateSetMaxDowntime(dom, downtime, 0))
goto done;
- ret = TRUE;
+ ret = true;
done:
virDomainFree(dom);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkAutostart(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
int autostart;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(network = vshCommandOptNetwork(ctl, cmd, &name)))
- return FALSE;
+ return false;
autostart = !vshCommandOptBool(cmd, "disable");
else
vshError(ctl, _("failed to unmark network %s as autostarted"), name);
virNetworkFree(network);
- return FALSE;
+ return false;
}
if (autostart)
vshPrint(ctl, _("Network %s unmarked as autostarted\n"), name);
virNetworkFree(network);
- return TRUE;
+ return true;
}
/*
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkCreate(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
network = virNetworkCreateXML(ctl->conn, buffer);
VIR_FREE(buffer);
virNetworkFree(network);
} else {
vshError(ctl, _("Failed to create network from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkDefine(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
network = virNetworkDefineXML(ctl->conn, buffer);
VIR_FREE(buffer);
virNetworkFree(network);
} else {
vshError(ctl, _("Failed to define network from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkDestroy(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(network = vshCommandOptNetwork(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virNetworkDestroy(network) == 0) {
vshPrint(ctl, _("Network %s destroyed\n"), name);
} else {
vshError(ctl, _("Failed to destroy network %s"), name);
- ret = FALSE;
+ ret = false;
}
virNetworkFree(network);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkDumpXML(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
- int ret = TRUE;
+ bool ret = true;
char *dump;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(network = vshCommandOptNetwork(ctl, cmd, NULL)))
- return FALSE;
+ return false;
dump = virNetworkGetXMLDesc(network, 0);
if (dump != NULL) {
vshPrint(ctl, "%s", dump);
VIR_FREE(dump);
} else {
- ret = FALSE;
+ ret = false;
}
virNetworkFree(network);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkInfo(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
char *bridge = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(network = vshCommandOptNetworkBy(ctl, cmd, NULL,
VSH_BYNAME)))
- return FALSE;
+ return false;
vshPrint(ctl, "%-15s %s\n", _("Name"), virNetworkGetName(network));
vshPrint(ctl, "%-15s %s\n", _("Bridge:"), bridge);
virNetworkFree(network);
- return TRUE;
+ return true;
}
/*
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdInterfaceEdit (vshControl *ctl, const vshCmd *cmd)
{
- int ret = FALSE;
+ bool ret = false;
virInterfacePtr iface = NULL;
char *tmp = NULL;
char *doc = NULL;
if (STREQ (doc, doc_edited)) {
vshPrint (ctl, _("Interface %s XML configuration not changed.\n"),
virInterfaceGetName (iface));
- ret = TRUE;
+ ret = true;
goto cleanup;
}
vshPrint (ctl, _("Interface %s XML configuration edited.\n"),
virInterfaceGetName(iface));
- ret = TRUE;
+ ret = true;
cleanup:
if (iface)
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
int inactive = vshCommandOptBool(cmd, "inactive");
inactive |= all;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (active) {
maxactive = virConnectNumOfNetworks(ctl->conn);
if (maxactive < 0) {
vshError(ctl, "%s", _("Failed to list active networks"));
- return FALSE;
+ return false;
}
if (maxactive) {
activeNames = vshMalloc(ctl, sizeof(char *) * maxactive);
maxactive)) < 0) {
vshError(ctl, "%s", _("Failed to list active networks"));
VIR_FREE(activeNames);
- return FALSE;
+ return false;
}
qsort(&activeNames[0], maxactive, sizeof(char *), namesorter);
if (maxinactive < 0) {
vshError(ctl, "%s", _("Failed to list inactive networks"));
VIR_FREE(activeNames);
- return FALSE;
+ return false;
}
if (maxinactive) {
inactiveNames = vshMalloc(ctl, sizeof(char *) * maxinactive);
vshError(ctl, "%s", _("Failed to list inactive networks"));
VIR_FREE(activeNames);
VIR_FREE(inactiveNames);
- return FALSE;
+ return false;
}
qsort(&inactiveNames[0], maxinactive, sizeof(char*), namesorter);
}
VIR_FREE(activeNames);
VIR_FREE(inactiveNames);
- return TRUE;
+ return true;
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkName(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(network = vshCommandOptNetworkBy(ctl, cmd, NULL,
VSH_BYUUID)))
- return FALSE;
+ return false;
vshPrint(ctl, "%s\n", virNetworkGetName(network));
virNetworkFree(network);
- return TRUE;
+ return true;
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkStart(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(network = vshCommandOptNetworkBy(ctl, cmd, NULL, VSH_BYNAME)))
- return FALSE;
+ return false;
if (virNetworkCreate(network) == 0) {
vshPrint(ctl, _("Network %s started\n"),
} else {
vshError(ctl, _("Failed to start network %s"),
virNetworkGetName(network));
- ret = FALSE;
+ ret = false;
}
virNetworkFree(network);
return ret;
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkUndefine(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(network = vshCommandOptNetwork(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virNetworkUndefine(network) == 0) {
vshPrint(ctl, _("Network %s has been undefined\n"), name);
} else {
vshError(ctl, _("Failed to undefine network %s"), name);
- ret = FALSE;
+ ret = false;
}
virNetworkFree(network);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkUuid(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
char uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(network = vshCommandOptNetworkBy(ctl, cmd, NULL,
VSH_BYNAME)))
- return FALSE;
+ return false;
if (virNetworkGetUUIDString(network, uuid) != -1)
vshPrint(ctl, "%s\n", uuid);
vshError(ctl, "%s", _("failed to get network UUID"));
virNetworkFree(network);
- return TRUE;
+ return true;
}
{"all", VSH_OT_BOOL, 0, N_("list inactive & active interfaces")},
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdInterfaceList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
int inactive = vshCommandOptBool(cmd, "inactive");
inactive |= all;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (active) {
maxactive = virConnectNumOfInterfaces(ctl->conn);
if (maxactive < 0) {
vshError(ctl, "%s", _("Failed to list active interfaces"));
- return FALSE;
+ return false;
}
if (maxactive) {
activeNames = vshMalloc(ctl, sizeof(char *) * maxactive);
maxactive)) < 0) {
vshError(ctl, "%s", _("Failed to list active interfaces"));
VIR_FREE(activeNames);
- return FALSE;
+ return false;
}
qsort(&activeNames[0], maxactive, sizeof(char *), namesorter);
if (maxinactive < 0) {
vshError(ctl, "%s", _("Failed to list inactive interfaces"));
VIR_FREE(activeNames);
- return FALSE;
+ return false;
}
if (maxinactive) {
inactiveNames = vshMalloc(ctl, sizeof(char *) * maxinactive);
vshError(ctl, "%s", _("Failed to list inactive interfaces"));
VIR_FREE(activeNames);
VIR_FREE(inactiveNames);
- return FALSE;
+ return false;
}
qsort(&inactiveNames[0], maxinactive, sizeof(char*), namesorter);
}
VIR_FREE(activeNames);
VIR_FREE(inactiveNames);
- return TRUE;
+ return true;
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdInterfaceName(vshControl *ctl, const vshCmd *cmd)
{
virInterfacePtr iface;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(iface = vshCommandOptInterfaceBy(ctl, cmd, NULL,
VSH_BYMAC)))
- return FALSE;
+ return false;
vshPrint(ctl, "%s\n", virInterfaceGetName(iface));
virInterfaceFree(iface);
- return TRUE;
+ return true;
}
/*
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdInterfaceMAC(vshControl *ctl, const vshCmd *cmd)
{
virInterfacePtr iface;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(iface = vshCommandOptInterfaceBy(ctl, cmd, NULL,
VSH_BYNAME)))
- return FALSE;
+ return false;
vshPrint(ctl, "%s\n", virInterfaceGetMACString(iface));
virInterfaceFree(iface);
- return TRUE;
+ return true;
}
/*
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdInterfaceDumpXML(vshControl *ctl, const vshCmd *cmd)
{
virInterfacePtr iface;
- int ret = TRUE;
+ bool ret = true;
char *dump;
int flags = 0;
int inactive = vshCommandOptBool(cmd, "inactive");
flags |= VIR_INTERFACE_XML_INACTIVE;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(iface = vshCommandOptInterface(ctl, cmd, NULL)))
- return FALSE;
+ return false;
dump = virInterfaceGetXMLDesc(iface, flags);
if (dump != NULL) {
vshPrint(ctl, "%s", dump);
VIR_FREE(dump);
} else {
- ret = FALSE;
+ ret = false;
}
virInterfaceFree(iface);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdInterfaceDefine(vshControl *ctl, const vshCmd *cmd)
{
virInterfacePtr iface;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
iface = virInterfaceDefineXML(ctl->conn, buffer, 0);
VIR_FREE(buffer);
virInterfaceFree (iface);
} else {
vshError(ctl, _("Failed to define interface from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdInterfaceUndefine(vshControl *ctl, const vshCmd *cmd)
{
virInterfacePtr iface;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(iface = vshCommandOptInterface(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virInterfaceUndefine(iface) == 0) {
vshPrint(ctl, _("Interface %s undefined\n"), name);
} else {
vshError(ctl, _("Failed to undefine interface %s"), name);
- ret = FALSE;
+ ret = false;
}
virInterfaceFree(iface);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdInterfaceStart(vshControl *ctl, const vshCmd *cmd)
{
virInterfacePtr iface;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(iface = vshCommandOptInterface(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virInterfaceCreate(iface, 0) == 0) {
vshPrint(ctl, _("Interface %s started\n"), name);
} else {
vshError(ctl, _("Failed to start interface %s"), name);
- ret = FALSE;
+ ret = false;
}
virInterfaceFree(iface);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdInterfaceDestroy(vshControl *ctl, const vshCmd *cmd)
{
virInterfacePtr iface;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(iface = vshCommandOptInterface(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virInterfaceDestroy(iface, 0) == 0) {
vshPrint(ctl, _("Interface %s destroyed\n"), name);
} else {
vshError(ctl, _("Failed to destroy interface %s"), name);
- ret = FALSE;
+ ret = false;
}
virInterfaceFree(iface);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNWFilterDefine(vshControl *ctl, const vshCmd *cmd)
{
virNWFilterPtr nwfilter;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
nwfilter = virNWFilterDefineXML(ctl->conn, buffer);
VIR_FREE(buffer);
virNWFilterFree(nwfilter);
} else {
vshError(ctl, _("Failed to define network filter from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNWFilterUndefine(vshControl *ctl, const vshCmd *cmd)
{
virNWFilterPtr nwfilter;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(nwfilter = vshCommandOptNWFilter(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virNWFilterUndefine(nwfilter) == 0) {
vshPrint(ctl, _("Network filter %s undefined\n"), name);
} else {
vshError(ctl, _("Failed to undefine network filter %s"), name);
- ret = FALSE;
+ ret = false;
}
virNWFilterFree(nwfilter);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNWFilterDumpXML(vshControl *ctl, const vshCmd *cmd)
{
virNWFilterPtr nwfilter;
- int ret = TRUE;
+ bool ret = true;
char *dump;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(nwfilter = vshCommandOptNWFilter(ctl, cmd, NULL)))
- return FALSE;
+ return false;
dump = virNWFilterGetXMLDesc(nwfilter, 0);
if (dump != NULL) {
vshPrint(ctl, "%s", dump);
VIR_FREE(dump);
} else {
- ret = FALSE;
+ ret = false;
}
virNWFilterFree(nwfilter);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNWFilterList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
int numfilters, i;
char uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
numfilters = virConnectNumOfNWFilters(ctl->conn);
if (numfilters < 0) {
vshError(ctl, "%s", _("Failed to list network filters"));
- return FALSE;
+ return false;
}
names = vshMalloc(ctl, sizeof(char *) * numfilters);
numfilters)) < 0) {
vshError(ctl, "%s", _("Failed to list network filters"));
VIR_FREE(names);
- return FALSE;
+ return false;
}
qsort(&names[0], numfilters, sizeof(char *), namesorter);
}
VIR_FREE(names);
- return TRUE;
+ return true;
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNWFilterEdit (vshControl *ctl, const vshCmd *cmd)
{
- int ret = FALSE;
+ bool ret = false;
virNWFilterPtr nwfilter = NULL;
char *tmp = NULL;
char *doc = NULL;
if (STREQ (doc, doc_edited)) {
vshPrint (ctl, _("Network filter %s XML configuration not changed.\n"),
virNWFilterGetName (nwfilter));
- ret = TRUE;
+ ret = true;
goto cleanup;
}
vshPrint (ctl, _("Network filter %s XML configuration edited.\n"),
virNWFilterGetName(nwfilter));
- ret = TRUE;
+ ret = true;
cleanup:
if (nwfilter)
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolAutostart(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
int autostart;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
- return FALSE;
+ return false;
autostart = !vshCommandOptBool(cmd, "disable");
else
vshError(ctl, _("failed to unmark pool %s as autostarted"), name);
virStoragePoolFree(pool);
- return FALSE;
+ return false;
}
if (autostart)
vshPrint(ctl, _("Pool %s unmarked as autostarted\n"), name);
virStoragePoolFree(pool);
- return TRUE;
+ return true;
}
/*
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolCreate(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
pool = virStoragePoolCreateXML(ctl->conn, buffer, 0);
VIR_FREE(buffer);
virStoragePoolFree(pool);
} else {
vshError(ctl, _("Failed to create pool from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNodeDeviceCreate(vshControl *ctl, const vshCmd *cmd)
{
virNodeDevicePtr dev = NULL;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
dev = virNodeDeviceCreateXML(ctl->conn, buffer, 0);
VIR_FREE(buffer);
virNodeDeviceFree(dev);
} else {
vshError(ctl, _("Failed to create node device from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNodeDeviceDestroy(vshControl *ctl, const vshCmd *cmd)
{
virNodeDevicePtr dev = NULL;
- int ret = TRUE;
+ bool ret = true;
const char *name = NULL;
if (!vshConnectionUsability(ctl, ctl->conn)) {
- return FALSE;
+ return false;
}
if (vshCommandOptString(cmd, "name", &name) <= 0)
- return FALSE;
+ return false;
dev = virNodeDeviceLookupByName(ctl->conn, name);
vshPrint(ctl, _("Destroyed node device '%s'\n"), name);
} else {
vshError(ctl, _("Failed to destroy node device '%s'"), name);
- ret = FALSE;
+ ret = false;
}
virNodeDeviceFree(dev);
if (virBufferError(&buf)) {
vshPrint(ctl, "%s", _("Failed to allocate XML buffer"));
- return FALSE;
+ return false;
}
*xml = virBufferContentAndReset(&buf);
*retname = name;
- return TRUE;
+ return true;
cleanup:
virBufferFreeAndReset(&buf);
- return FALSE;
+ return false;
}
/*
{NULL, NULL}
};
-static int
+static bool
cmdPoolCreateAs(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
int printXML = vshCommandOptBool(cmd, "print-xml");
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!buildPoolXML(cmd, &name, &xml))
- return FALSE;
+ return false;
if (printXML) {
vshPrint(ctl, "%s", xml);
virStoragePoolFree(pool);
} else {
vshError(ctl, _("Failed to create pool %s"), name);
- return FALSE;
+ return false;
}
}
- return TRUE;
+ return true;
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolDefine(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
pool = virStoragePoolDefineXML(ctl->conn, buffer, 0);
VIR_FREE(buffer);
virStoragePoolFree(pool);
} else {
vshError(ctl, _("Failed to define pool from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
{NULL, NULL}
};
-static int
+static bool
cmdPoolDefineAs(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
int printXML = vshCommandOptBool(cmd, "print-xml");
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!buildPoolXML(cmd, &name, &xml))
- return FALSE;
+ return false;
if (printXML) {
vshPrint(ctl, "%s", xml);
virStoragePoolFree(pool);
} else {
vshError(ctl, _("Failed to define pool %s"), name);
- return FALSE;
+ return false;
}
}
- return TRUE;
+ return true;
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolBuild(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
- return FALSE;
+ return false;
if (virStoragePoolBuild(pool, 0) == 0) {
vshPrint(ctl, _("Pool %s built\n"), name);
} else {
vshError(ctl, _("Failed to build pool %s"), name);
- ret = FALSE;
+ ret = false;
}
virStoragePoolFree(pool);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolDestroy(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
- return FALSE;
+ return false;
if (virStoragePoolDestroy(pool) == 0) {
vshPrint(ctl, _("Pool %s destroyed\n"), name);
} else {
vshError(ctl, _("Failed to destroy pool %s"), name);
- ret = FALSE;
+ ret = false;
}
virStoragePoolFree(pool);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolDelete(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
- return FALSE;
+ return false;
if (virStoragePoolDelete(pool, 0) == 0) {
vshPrint(ctl, _("Pool %s deleted\n"), name);
} else {
vshError(ctl, _("Failed to delete pool %s"), name);
- ret = FALSE;
+ ret = false;
}
virStoragePoolFree(pool);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolRefresh(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
- return FALSE;
+ return false;
if (virStoragePoolRefresh(pool, 0) == 0) {
vshPrint(ctl, _("Pool %s refreshed\n"), name);
} else {
vshError(ctl, _("Failed to refresh pool %s"), name);
- ret = FALSE;
+ ret = false;
}
virStoragePoolFree(pool);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolDumpXML(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
- int ret = TRUE;
+ bool ret = true;
char *dump;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
- return FALSE;
+ return false;
dump = virStoragePoolGetXMLDesc(pool, 0);
if (dump != NULL) {
vshPrint(ctl, "%s", dump);
VIR_FREE(dump);
} else {
- ret = FALSE;
+ ret = false;
}
virStoragePoolFree(pool);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
virStoragePoolInfo info;
/* Check the connection to libvirtd daemon is still working */
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
/* Retrieve the number of active storage pools */
if (active) {
numActivePools = virConnectNumOfStoragePools(ctl->conn);
if (numActivePools < 0) {
vshError(ctl, "%s", _("Failed to list active pools"));
- return FALSE;
+ return false;
}
}
numInactivePools = virConnectNumOfDefinedStoragePools(ctl->conn);
if (numInactivePools < 0) {
vshError(ctl, "%s", _("Failed to list inactive pools"));
- return FALSE;
+ return false;
}
}
vshError(ctl, "%s", _("Failed to list active pools"));
VIR_FREE(poolInfoTexts);
VIR_FREE(poolNames);
- return FALSE;
+ return false;
}
}
vshError(ctl, "%s", _("Failed to list inactive pools"));
VIR_FREE(poolInfoTexts);
VIR_FREE(poolNames);
- return FALSE;
+ return false;
}
}
}
/* Cleanup and return */
- functionReturn = TRUE;
+ functionReturn = true;
goto cleanup;
}
}
/* Cleanup and return */
- functionReturn = TRUE;
+ functionReturn = true;
goto cleanup;
asprintf_failure:
/* Some other error */
vshError(ctl, _("virAsprintf failed (errno %d)"), errno);
}
- functionReturn = FALSE;
+ functionReturn = false;
cleanup:
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolDiscoverSourcesAs(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED)
{
const char *type = NULL, *host = NULL;
vshCommandOptString(cmd, "host", &host) < 0 ||
vshCommandOptString(cmd, "initiator", &initiator) < 0) {
vshError(ctl,"%s", _("missing argument"));
- return FALSE;
+ return false;
}
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (host) {
const char *port = NULL;
if (vshCommandOptString(cmd, "port", &port) < 0) {
vshError(ctl, "%s", _("missing argument"));
virBufferFreeAndReset(&buf);
- return FALSE;
+ return false;
}
virBufferAddLit(&buf, "<source>\n");
virBufferVSprintf(&buf, " <host name='%s'", host);
virBufferAddLit(&buf, "</source>\n");
if (virBufferError(&buf)) {
vshError(ctl, "%s", _("Out of memory"));
- return FALSE;
+ return false;
}
srcSpec = virBufferContentAndReset(&buf);
}
VIR_FREE(srcSpec);
if (srcList == NULL) {
vshError(ctl, _("Failed to find any %s pool sources"), type);
- return FALSE;
+ return false;
}
vshPrint(ctl, "%s", srcList);
VIR_FREE(srcList);
- return TRUE;
+ return true;
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolDiscoverSources(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED)
{
const char *type = NULL, *srcSpecFile = NULL;
char *srcSpec = NULL, *srcList;
if (vshCommandOptString(cmd, "type", &type) <= 0)
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "srcSpec", &srcSpecFile) < 0) {
vshError(ctl, "%s", _("missing option"));
- return FALSE;
+ return false;
}
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (srcSpecFile && virFileReadAll(srcSpecFile, VIRSH_MAX_XML_FILE, &srcSpec) < 0)
- return FALSE;
+ return false;
srcList = virConnectFindStoragePoolSources(ctl->conn, type, srcSpec, 0);
VIR_FREE(srcSpec);
if (srcList == NULL) {
vshError(ctl, _("Failed to find any %s pool sources"), type);
- return FALSE;
+ return false;
}
vshPrint(ctl, "%s", srcList);
VIR_FREE(srcList);
- return TRUE;
+ return true;
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolInfo(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolInfo info;
virStoragePoolPtr pool;
int autostart = 0;
int persistent = 0;
- int ret = TRUE;
+ bool ret = true;
char uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
- return FALSE;
+ return false;
vshPrint(ctl, "%-15s %s\n", _("Name:"), virStoragePoolGetName(pool));
vshPrint(ctl, "%-15s %2.2lf %s\n", _("Available:"), val, unit);
}
} else {
- ret = FALSE;
+ ret = false;
}
virStoragePoolFree(pool);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolName(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL,
VSH_BYUUID)))
- return FALSE;
+ return false;
vshPrint(ctl, "%s\n", virStoragePoolGetName(pool));
virStoragePoolFree(pool);
- return TRUE;
+ return true;
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolStart(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL, VSH_BYNAME)))
- return FALSE;
+ return false;
if (virStoragePoolCreate(pool, 0) == 0) {
vshPrint(ctl, _("Pool %s started\n"),
virStoragePoolGetName(pool));
} else {
vshError(ctl, _("Failed to start pool %s"), virStoragePoolGetName(pool));
- ret = FALSE;
+ ret = false;
}
virStoragePoolFree(pool);
return 0;
}
-static int
+static bool
cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
virBuffer buf = VIR_BUFFER_INITIALIZER;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL,
VSH_BYNAME)))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "name", &name) <= 0)
goto cleanup;
}
if (snapVol == NULL) {
vshError(ctl, _("failed to get vol '%s'"), snapshotStrVol);
- return FALSE;
+ return false;
}
char *snapshotStrVolPath;
if ((snapshotStrVolPath = virStorageVolGetPath(snapVol)) == NULL) {
virStorageVolFree(snapVol);
- return FALSE;
+ return false;
}
/* Create XML for the backing store */
if (virBufferError(&buf)) {
vshPrint(ctl, "%s", _("Failed to allocate XML buffer"));
- return FALSE;
+ return false;
}
xml = virBufferContentAndReset(&buf);
vol = virStorageVolCreateXML(pool, xml, 0);
if (vol != NULL) {
vshPrint(ctl, _("Vol %s created\n"), name);
virStorageVolFree(vol);
- return TRUE;
+ return true;
} else {
vshError(ctl, _("Failed to create vol %s"), name);
- return FALSE;
+ return false;
}
cleanup:
virBufferFreeAndReset(&buf);
virStoragePoolFree(pool);
- return FALSE;
+ return false;
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolUndefine(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
- return FALSE;
+ return false;
if (virStoragePoolUndefine(pool) == 0) {
vshPrint(ctl, _("Pool %s has been undefined\n"), name);
} else {
vshError(ctl, _("Failed to undefine pool %s"), name);
- ret = FALSE;
+ ret = false;
}
virStoragePoolFree(pool);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolUuid(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
char uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL,
VSH_BYNAME)))
- return FALSE;
+ return false;
if (virStoragePoolGetUUIDString(pool, uuid) != -1)
vshPrint(ctl, "%s\n", uuid);
vshError(ctl, "%s", _("failed to get pool UUID"));
virStoragePoolFree(pool);
- return TRUE;
+ return true;
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolCreate(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
virStorageVolPtr vol;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL,
VSH_BYNAME)))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0) {
virStoragePoolFree(pool);
- return FALSE;
+ return false;
}
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {
virshReportError(ctl);
virStoragePoolFree(pool);
- return FALSE;
+ return false;
}
vol = virStorageVolCreateXML(pool, buffer, 0);
virStorageVolFree(vol);
} else {
vshError(ctl, _("Failed to create vol from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool = NULL;
virStorageVolPtr newvol = NULL, inputvol = NULL;
const char *from = NULL;
- int ret = FALSE;
+ bool ret = false;
char *buffer = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
}
- ret = TRUE;
+ ret = true;
cleanup:
VIR_FREE(buffer);
if (pool)
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolClone(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr origpool = NULL;
const char *name = NULL;
char *origxml = NULL;
xmlChar *newxml = NULL;
- int ret = FALSE;
+ bool ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
goto cleanup;
}
- ret = TRUE;
+ ret = true;
cleanup:
VIR_FREE(origxml);
return saferead(*fd, bytes, nbytes);
}
-static int
+static bool
cmdVolUpload (vshControl *ctl, const vshCmd *cmd)
{
const char *file = NULL;
virStorageVolPtr vol = NULL;
- int ret = FALSE;
+ bool ret = false;
int fd = -1;
virStreamPtr st = NULL;
const char *name = NULL;
if (vshCommandOptULongLong(cmd, "offset", &offset) < 0) {
vshError(ctl, _("Unable to parse integer"));
- return FALSE;
+ return false;
}
if (vshCommandOptULongLong(cmd, "length", &length) < 0) {
vshError(ctl, _("Unable to parse integer"));
- return FALSE;
+ return false;
}
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) {
- return FALSE;
+ return false;
}
if (vshCommandOptString(cmd, "file", &file) < 0) {
goto cleanup;
}
- ret = TRUE;
+ ret = true;
cleanup:
if (vol)
return safewrite(*fd, bytes, nbytes);
}
-static int
+static bool
cmdVolDownload (vshControl *ctl, const vshCmd *cmd)
{
const char *file = NULL;
virStorageVolPtr vol = NULL;
- int ret = FALSE;
+ bool ret = false;
int fd = -1;
virStreamPtr st = NULL;
const char *name = NULL;
if (vshCommandOptULongLong(cmd, "offset", &offset) < 0) {
vshError(ctl, _("Unable to parse integer"));
- return FALSE;
+ return false;
}
if (vshCommandOptULongLong(cmd, "length", &length) < 0) {
vshError(ctl, _("Unable to parse integer"));
- return FALSE;
+ return false;
}
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &file) < 0) {
vshError(ctl, _("file must not be empty"));
goto cleanup;
}
- ret = TRUE;
+ ret = true;
cleanup:
- if (ret == FALSE && created)
+ if (ret == false && created)
unlink(file);
if (vol)
virStorageVolFree(vol);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolDelete(vshControl *ctl, const vshCmd *cmd)
{
virStorageVolPtr vol;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) {
- return FALSE;
+ return false;
}
if (virStorageVolDelete(vol, 0) == 0) {
vshPrint(ctl, _("Vol %s deleted\n"), name);
} else {
vshError(ctl, _("Failed to delete vol %s"), name);
- ret = FALSE;
+ ret = false;
}
virStorageVolFree(vol);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolWipe(vshControl *ctl, const vshCmd *cmd)
{
virStorageVolPtr vol;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) {
- return FALSE;
+ return false;
}
if (virStorageVolWipe(vol, 0) == 0) {
vshPrint(ctl, _("Vol %s wiped\n"), name);
} else {
vshError(ctl, _("Failed to wipe vol %s"), name);
- ret = FALSE;
+ ret = false;
}
virStorageVolFree(vol);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolInfo(vshControl *ctl, const vshCmd *cmd)
{
virStorageVolInfo info;
virStorageVolPtr vol;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
- return FALSE;
+ return false;
vshPrint(ctl, "%-15s %s\n", _("Name:"), virStorageVolGetName(vol));
val = prettyCapacity(info.allocation, &unit);
vshPrint(ctl, "%-15s %2.2lf %s\n", _("Allocation:"), val, unit);
} else {
- ret = FALSE;
+ ret = false;
}
virStorageVolFree(vol);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolDumpXML(vshControl *ctl, const vshCmd *cmd)
{
virStorageVolPtr vol;
- int ret = TRUE;
+ bool ret = true;
char *dump;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
- return FALSE;
+ return false;
dump = virStorageVolGetXMLDesc(vol, 0);
if (dump != NULL) {
vshPrint(ctl, "%s", dump);
VIR_FREE(dump);
} else {
- ret = FALSE;
+ ret = false;
}
virStorageVolFree(vol);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
virStorageVolInfo volumeInfo;
/* Check the connection to libvirtd daemon is still working */
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
/* Look up the pool information given to us by the user */
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
- return FALSE;
+ return false;
/* Determine the number of volumes in the pool */
numVolumes = virStoragePoolNumOfVolumes(pool);
if (numVolumes < 0) {
vshError(ctl, "%s", _("Failed to list storage volumes"));
virStoragePoolFree(pool);
- return FALSE;
+ return false;
}
/* Retrieve the list of volume names in the pool */
vshError(ctl, "%s", _("Failed to list active vols"));
VIR_FREE(activeNames);
virStoragePoolFree(pool);
- return FALSE;
+ return false;
}
/* Sort the volume names */
}
/* Cleanup and return */
- functionReturn = TRUE;
+ functionReturn = true;
goto cleanup;
}
}
/* Cleanup and return */
- functionReturn = TRUE;
+ functionReturn = true;
goto cleanup;
asprintf_failure:
/* Some other error */
vshError(ctl, _("virAsprintf failed (errno %d)"), errno);
}
- functionReturn = FALSE;
+ functionReturn = false;
cleanup:
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolName(vshControl *ctl, const vshCmd *cmd)
{
virStorageVolPtr vol;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(vol = vshCommandOptVolBy(ctl, cmd, "vol", "pool", NULL,
VSH_BYUUID)))
- return FALSE;
+ return false;
vshPrint(ctl, "%s\n", virStorageVolGetName(vol));
virStorageVolFree(vol);
- return TRUE;
+ return true;
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolPool(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
/* Check the connection to libvirtd daemon is still working */
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
/* Use the supplied string to locate the volume */
if (!(vol = vshCommandOptVolBy(ctl, cmd, "vol", "pool", NULL,
VSH_BYUUID))) {
- return FALSE;
+ return false;
}
/* Look up the parent storage pool for the volume */
if (pool == NULL) {
vshError(ctl, "%s", _("failed to get parent pool"));
virStorageVolFree(vol);
- return FALSE;
+ return false;
}
/* Return the requested details of the parent storage pool */
/* Cleanup */
virStorageVolFree(vol);
virStoragePoolFree(pool);
- return TRUE;
+ return true;
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolKey(vshControl *ctl, const vshCmd *cmd)
{
virStorageVolPtr vol;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
- return FALSE;
+ return false;
vshPrint(ctl, "%s\n", virStorageVolGetKey(vol));
virStorageVolFree(vol);
- return TRUE;
+ return true;
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolPath(vshControl *ctl, const vshCmd *cmd)
{
virStorageVolPtr vol;
const char *name = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) {
- return FALSE;
+ return false;
}
vshPrint(ctl, "%s\n", virStorageVolGetPath(vol));
virStorageVolFree(vol);
- return TRUE;
+ return true;
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSecretDefine(vshControl *ctl, const vshCmd *cmd)
{
const char *from = NULL;
char uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
res = virSecretDefineXML(ctl->conn, buffer, 0);
VIR_FREE(buffer);
if (res == NULL) {
vshError(ctl, _("Failed to set attributes from %s"), from);
- return FALSE;
+ return false;
}
if (virSecretGetUUIDString(res, &(uuid[0])) < 0) {
vshError(ctl, "%s", _("Failed to get UUID of created secret"));
virSecretFree(res);
- return FALSE;
+ return false;
}
vshPrint(ctl, _("Secret %s created\n"), uuid);
virSecretFree(res);
- return TRUE;
+ return true;
}
/*
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSecretDumpXML(vshControl *ctl, const vshCmd *cmd)
{
virSecretPtr secret;
- int ret = FALSE;
+ bool ret = false;
char *xml;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
secret = vshCommandOptSecret(ctl, cmd, NULL);
if (secret == NULL)
- return FALSE;
+ return false;
xml = virSecretGetXMLDesc(secret, 0);
if (xml == NULL)
goto cleanup;
vshPrint(ctl, "%s", xml);
VIR_FREE(xml);
- ret = TRUE;
+ ret = true;
cleanup:
virSecretFree(secret);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd)
{
virSecretPtr secret;
size_t value_size;
const char *base64 = NULL;
char *value;
- int res, ret = FALSE;
+ int res;
+ bool ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
secret = vshCommandOptSecret(ctl, cmd, NULL);
if (secret == NULL)
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "base64", &base64) <= 0)
goto cleanup;
}
if (value == NULL) {
vshError(ctl, "%s", _("Failed to allocate memory"));
- return FALSE;
+ return false;
}
res = virSecretSetValue(secret, (unsigned char *)value, value_size, 0);
goto cleanup;
}
vshPrint(ctl, "%s", _("Secret value set\n"));
- ret = TRUE;
+ ret = true;
cleanup:
virSecretFree(secret);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSecretGetValue(vshControl *ctl, const vshCmd *cmd)
{
virSecretPtr secret;
char *base64;
unsigned char *value;
size_t value_size;
- int ret = FALSE;
+ bool ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
secret = vshCommandOptSecret(ctl, cmd, NULL);
if (secret == NULL)
- return FALSE;
+ return false;
value = virSecretGetValue(secret, &value_size, 0);
if (value == NULL)
vshPrint(ctl, "%s", base64);
memset(base64, 0, strlen(base64));
VIR_FREE(base64);
- ret = TRUE;
+ ret = true;
cleanup:
virSecretFree(secret);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSecretUndefine(vshControl *ctl, const vshCmd *cmd)
{
virSecretPtr secret;
- int ret = FALSE;
+ bool ret = false;
const char *uuid;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
secret = vshCommandOptSecret(ctl, cmd, &uuid);
if (secret == NULL)
- return FALSE;
+ return false;
if (virSecretUndefine(secret) < 0) {
vshError(ctl, _("Failed to delete secret %s"), uuid);
goto cleanup;
}
vshPrint(ctl, _("Secret %s deleted\n"), uuid);
- ret = TRUE;
+ ret = true;
cleanup:
virSecretFree(secret);
{NULL, NULL}
};
-static int
+static bool
cmdSecretList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
int maxuuids = 0, i;
char **uuids = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
maxuuids = virConnectNumOfSecrets(ctl->conn);
if (maxuuids < 0) {
vshError(ctl, "%s", _("Failed to list secrets"));
- return FALSE;
+ return false;
}
uuids = vshMalloc(ctl, sizeof(*uuids) * maxuuids);
if (maxuuids < 0) {
vshError(ctl, "%s", _("Failed to list secrets"));
VIR_FREE(uuids);
- return FALSE;
+ return false;
}
qsort(uuids, maxuuids, sizeof(char *), namesorter);
VIR_FREE(uuids[i]);
}
VIR_FREE(uuids);
- return TRUE;
+ return true;
}
};
-static int
+static bool
cmdVersion(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
unsigned long hvVersion;
unsigned int rel;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
hvType = virConnectGetType(ctl->conn);
if (hvType == NULL) {
vshError(ctl, "%s", _("failed to get hypervisor type"));
- return FALSE;
+ return false;
}
includeVersion = LIBVIR_VERSION_NUMBER;
ret = virGetVersion(&libVersion, hvType, &apiVersion);
if (ret < 0) {
vshError(ctl, "%s", _("failed to get the library version"));
- return FALSE;
+ return false;
}
major = libVersion / 1000000;
libVersion %= 1000000;
ret = virConnectGetVersion(ctl->conn, &hvVersion);
if (ret < 0) {
vshError(ctl, "%s", _("failed to get the hypervisor version"));
- return FALSE;
+ return false;
}
if (hvVersion == 0) {
vshPrint(ctl,
vshPrint(ctl, _("Running hypervisor: %s %d.%d.%d\n"),
hvType, major, minor, rel);
}
- return TRUE;
+ return true;
}
/*
}
}
-static int
+static bool
cmdNodeListDevices (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
const char *cap = NULL;
int tree = vshCommandOptBool(cmd, "tree");
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "cap", &cap) <= 0)
cap = NULL;
num_devices = virNodeNumOfDevices(ctl->conn, cap, 0);
if (num_devices < 0) {
vshError(ctl, "%s", _("Failed to count node devices"));
- return FALSE;
+ return false;
} else if (num_devices == 0) {
- return TRUE;
+ return true;
}
devices = vshMalloc(ctl, sizeof(char *) * num_devices);
if (num_devices < 0) {
vshError(ctl, "%s", _("Failed to list node devices"));
VIR_FREE(devices);
- return FALSE;
+ return false;
}
qsort(&devices[0], num_devices, sizeof(char*), namesorter);
if (tree) {
}
}
VIR_FREE(devices);
- return TRUE;
+ return true;
}
/*
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNodeDeviceDumpXML (vshControl *ctl, const vshCmd *cmd)
{
const char *name = NULL;
char *xml;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "device", &name) <= 0)
- return FALSE;
+ return false;
if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) {
vshError(ctl, "%s '%s'", _("Could not find matching device"), name);
- return FALSE;
+ return false;
}
xml = virNodeDeviceGetXMLDesc(device, 0);
if (!xml) {
virNodeDeviceFree(device);
- return FALSE;
+ return false;
}
vshPrint(ctl, "%s\n", xml);
VIR_FREE(xml);
virNodeDeviceFree(device);
- return TRUE;
+ return true;
}
/*
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNodeDeviceDettach (vshControl *ctl, const vshCmd *cmd)
{
const char *name = NULL;
virNodeDevicePtr device;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "device", &name) <= 0)
- return FALSE;
+ return false;
if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) {
vshError(ctl, "%s '%s'", _("Could not find matching device"), name);
- return FALSE;
+ return false;
}
if (virNodeDeviceDettach(device) == 0) {
vshPrint(ctl, _("Device %s dettached\n"), name);
} else {
vshError(ctl, _("Failed to dettach device %s"), name);
- ret = FALSE;
+ ret = false;
}
virNodeDeviceFree(device);
return ret;
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNodeDeviceReAttach (vshControl *ctl, const vshCmd *cmd)
{
const char *name = NULL;
virNodeDevicePtr device;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "device", &name) <= 0)
- return FALSE;
+ return false;
if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) {
vshError(ctl, "%s '%s'", _("Could not find matching device"), name);
- return FALSE;
+ return false;
}
if (virNodeDeviceReAttach(device) == 0) {
vshPrint(ctl, _("Device %s re-attached\n"), name);
} else {
vshError(ctl, _("Failed to re-attach device %s"), name);
- ret = FALSE;
+ ret = false;
}
virNodeDeviceFree(device);
return ret;
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNodeDeviceReset (vshControl *ctl, const vshCmd *cmd)
{
const char *name = NULL;
virNodeDevicePtr device;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "device", &name) <= 0)
- return FALSE;
+ return false;
if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) {
vshError(ctl, "%s '%s'", _("Could not find matching device"), name);
- return FALSE;
+ return false;
}
if (virNodeDeviceReset(device) == 0) {
vshPrint(ctl, _("Device %s reset\n"), name);
} else {
vshError(ctl, _("Failed to reset device %s"), name);
- ret = FALSE;
+ ret = false;
}
virNodeDeviceFree(device);
return ret;
{NULL, NULL}
};
-static int
+static bool
cmdHostname (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
char *hostname;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
hostname = virConnectGetHostname (ctl->conn);
if (hostname == NULL) {
vshError(ctl, "%s", _("failed to get hostname"));
- return FALSE;
+ return false;
}
vshPrint (ctl, "%s\n", hostname);
VIR_FREE(hostname);
- return TRUE;
+ return true;
}
/*
{NULL, NULL}
};
-static int
+static bool
cmdURI (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
char *uri;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
uri = virConnectGetURI (ctl->conn);
if (uri == NULL) {
vshError(ctl, "%s", _("failed to get URI"));
- return FALSE;
+ return false;
}
vshPrint (ctl, "%s\n", uri);
VIR_FREE(uri);
- return TRUE;
+ return true;
}
/*
{NULL, NULL}
};
-static int
+static bool
cmdSysinfo (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
char *sysinfo;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
sysinfo = virConnectGetSysinfo (ctl->conn, 0);
if (sysinfo == NULL) {
vshError(ctl, "%s", _("failed to get sysinfo"));
- return FALSE;
+ return false;
}
vshPrint (ctl, "%s", sysinfo);
VIR_FREE(sysinfo);
- return TRUE;
+ return true;
}
/*
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd)
{
xmlDocPtr xml = NULL;
xmlXPathObjectPtr obj = NULL;
xmlXPathContextPtr ctxt = NULL;
virDomainPtr dom;
- int ret = FALSE;
+ bool ret = false;
int port = 0;
char *doc;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
doc = virDomainGetXMLDesc(dom, 0);
if (!doc)
}
xmlXPathFreeObject(obj);
obj = NULL;
- ret = TRUE;
+ ret = true;
cleanup:
xmlXPathFreeObject(obj);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdTTYConsole(vshControl *ctl, const vshCmd *cmd)
{
xmlDocPtr xml = NULL;
xmlXPathObjectPtr obj = NULL;
xmlXPathContextPtr ctxt = NULL;
virDomainPtr dom;
- int ret = FALSE;
+ bool ret = false;
char *doc;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
doc = virDomainGetXMLDesc(dom, 0);
if (!doc)
goto cleanup;
}
vshPrint(ctl, "%s\n", (const char *)obj->stringval);
- ret = TRUE;
+ ret = true;
cleanup:
xmlXPathFreeObject(obj);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdAttachDevice(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *from = NULL;
char *buffer;
- int ret = TRUE;
+ bool ret = true;
unsigned int flags;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {
virshReportError(ctl);
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (vshCommandOptBool(cmd, "persistent")) {
if (ret < 0) {
vshError(ctl, _("Failed to attach device from %s"), from);
virDomainFree(dom);
- return FALSE;
+ return false;
} else {
vshPrint(ctl, "%s", _("Device attached successfully\n"));
}
virDomainFree(dom);
- return TRUE;
+ return true;
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDetachDevice(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *from = NULL;
char *buffer;
- int ret = TRUE;
+ bool ret = true;
unsigned int flags;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {
virshReportError(ctl);
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (vshCommandOptBool(cmd, "persistent")) {
if (ret < 0) {
vshError(ctl, _("Failed to detach device from %s"), from);
virDomainFree(dom);
- return FALSE;
+ return false;
} else {
vshPrint(ctl, "%s", _("Device detached successfully\n"));
}
virDomainFree(dom);
- return TRUE;
+ return true;
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdUpdateDevice(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *from = NULL;
char *buffer;
- int ret = TRUE;
+ bool ret = true;
unsigned int flags;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {
virshReportError(ctl);
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (vshCommandOptBool(cmd, "persistent")) {
if (ret < 0) {
vshError(ctl, _("Failed to update device from %s"), from);
virDomainFree(dom);
- return FALSE;
+ return false;
} else {
vshPrint(ctl, "%s", _("Device updated successfully\n"));
}
virDomainFree(dom);
- return TRUE;
+ return true;
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
const char *mac = NULL, *target = NULL, *script = NULL,
*type = NULL, *source = NULL, *model = NULL;
- int typ, ret = FALSE;
+ int typ;
+ bool ret = false;
unsigned int flags;
virBuffer buf = VIR_BUFFER_INITIALIZER;
char *xml;
if (virBufferError(&buf)) {
vshPrint(ctl, "%s", _("Failed to allocate XML buffer"));
- return FALSE;
+ return false;
}
xml = virBufferContentAndReset(&buf);
if (ret != 0) {
vshError(ctl, "%s", _("Failed to attach interface"));
- ret = FALSE;
+ ret = false;
} else {
vshPrint(ctl, "%s", _("Interface attached successfully\n"));
- ret = TRUE;
+ ret = true;
}
cleanup:
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
const char *mac =NULL, *type = NULL;
char *doc;
char buf[64];
- int i = 0, diff_mac, ret = FALSE;
+ int i = 0, diff_mac;
+ bool ret = false;
unsigned int flags;
if (!vshConnectionUsability(ctl, ctl->conn))
if (ret != 0) {
vshError(ctl, "%s", _("Failed to detach interface"));
- ret = FALSE;
+ ret = false;
} else {
vshPrint(ctl, "%s", _("Interface detached successfully\n"));
- ret = TRUE;
+ ret = true;
}
cleanup:
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
const char *source = NULL, *target = NULL, *driver = NULL,
*subdriver = NULL, *type = NULL, *mode = NULL;
- int isFile = 0, ret = FALSE;
+ bool isFile = false, ret = false;
unsigned int flags;
const char *stype = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
if (!stype) {
if (driver && (STREQ(driver, "file") || STREQ(driver, "tap")))
- isFile = 1;
+ isFile = true;
} else if (STREQ(stype, "file")) {
- isFile = 1;
+ isFile = true;
} else if (STRNEQ(stype, "block")) {
vshError(ctl, _("Unknown source type: '%s'"), stype);
goto cleanup;
if (virBufferError(&buf)) {
vshPrint(ctl, "%s", _("Failed to allocate XML buffer"));
- return FALSE;
+ return false;
}
xml = virBufferContentAndReset(&buf);
if (ret != 0) {
vshError(ctl, "%s", _("Failed to attach disk"));
- ret = FALSE;
+ ret = false;
} else {
vshPrint(ctl, "%s", _("Disk attached successfully\n"));
- ret = TRUE;
+ ret = true;
}
cleanup:
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDetachDisk(vshControl *ctl, const vshCmd *cmd)
{
xmlDocPtr xml = NULL;
virDomainPtr dom = NULL;
const char *target = NULL;
char *doc;
- int i = 0, diff_tgt, ret = FALSE;
+ int i = 0, diff_tgt;
+ bool ret = false;
unsigned int flags;
if (!vshConnectionUsability(ctl, ctl->conn))
if (ret != 0) {
vshError(ctl, "%s", _("Failed to detach disk"));
- ret = FALSE;
+ ret = false;
} else {
vshPrint(ctl, "%s", _("Disk detached successfully\n"));
- ret = TRUE;
+ ret = true;
}
cleanup:
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdCPUCompare(vshControl *ctl, const vshCmd *cmd)
{
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
int result;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
result = virConnectCompareCPU(ctl->conn, buffer, 0);
VIR_FREE(buffer);
case VIR_CPU_COMPARE_INCOMPATIBLE:
vshPrint(ctl, _("CPU described in %s is incompatible with host CPU\n"),
from);
- ret = FALSE;
+ ret = false;
break;
case VIR_CPU_COMPARE_IDENTICAL:
vshPrint(ctl, _("CPU described in %s is identical to host CPU\n"),
from);
- ret = TRUE;
+ ret = true;
break;
case VIR_CPU_COMPARE_SUPERSET:
vshPrint(ctl, _("Host CPU is a superset of CPU described in %s\n"),
from);
- ret = TRUE;
+ ret = true;
break;
case VIR_CPU_COMPARE_ERROR:
default:
vshError(ctl, _("Failed to compare host CPU with %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd)
{
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
char *result = NULL;
const char **list = NULL;
int res, i;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
doc = xmlNewDoc(NULL);
if (doc == NULL)
(const xmlChar *)buffer, &node_list);
if (res != 0) {
vshError(ctl, _("Failed to parse XML fragment %s"), from);
- ret = FALSE;
+ ret = false;
goto cleanup;
}
if (count == 0) {
vshError(ctl, _("No host CPU specified in '%s'"), from);
- ret = FALSE;
+ ret = false;
goto cleanup;
}
if (result)
vshPrint(ctl, "%s", result);
else
- ret = FALSE;
+ ret = false;
cleanup:
xmlXPathFreeObject(obj);
no_memory:
vshError(ctl, "%s", _("Out of memory"));
- ret = FALSE;
+ ret = false;
goto cleanup;
}
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdCd(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
const char *dir = NULL;
char *dir_malloced = NULL;
- int ret = TRUE;
+ bool ret = true;
if (!ctl->imode) {
vshError(ctl, "%s", _("cd: command valid only in interactive mode"));
- return FALSE;
+ return false;
}
if (vshCommandOptString(cmd, "dir", &dir) <= 0) {
if (chdir(dir) == -1) {
vshError(ctl, _("cd: %s: %s"), strerror(errno), dir);
- ret = FALSE;
+ ret = false;
}
VIR_FREE(dir_malloced);
{NULL, NULL}
};
-static int
+static bool
cmdPwd(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
char *cwd;
size_t path_max;
- int err = TRUE;
+ bool err = true;
path_max = (size_t) PATH_MAX + 2;
cwd = vshMalloc (ctl, path_max);
/* Exists mainly for debugging virsh, but also handy for adding back
* quotes for later evaluation.
*/
-static int
+static bool
cmdEcho (vshControl *ctl ATTRIBUTE_UNUSED, const vshCmd *cmd)
{
bool shell = false;
if (virBufferError(&buf)) {
vshPrint(ctl, "%s", _("Failed to allocate XML buffer"));
- return FALSE;
+ return false;
}
arg = virBufferContentAndReset(&buf);
if (arg)
vshPrint(ctl, "%s", arg);
VIR_FREE(arg);
- return TRUE;
+ return true;
}
/*
/* This function also acts as a template to generate cmdNetworkEdit
* and cmdPoolEdit functions (below) using a sed script in the Makefile.
*/
-static int
+static bool
cmdEdit (vshControl *ctl, const vshCmd *cmd)
{
- int ret = FALSE;
+ bool ret = false;
virDomainPtr dom = NULL;
char *tmp = NULL;
char *doc = NULL;
if (STREQ (doc, doc_edited)) {
vshPrint (ctl, _("Domain %s XML configuration not changed.\n"),
virDomainGetName (dom));
- ret = TRUE;
+ ret = true;
goto cleanup;
}
vshPrint (ctl, _("Domain %s XML configuration edited.\n"),
virDomainGetName(dom));
- ret = TRUE;
+ ret = true;
cleanup:
if (dom)
{NULL, NULL}
};
-static int
+static bool
cmdQuit(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
- ctl->imode = FALSE;
- return TRUE;
+ ctl->imode = false;
+ return true;
}
/*
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSnapshotCreate(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
- int ret = FALSE;
+ bool ret = false;
const char *from = NULL;
char *buffer = NULL;
virDomainSnapshotPtr snapshot = NULL;
vshPrint(ctl, _(" from '%s'"), from);
vshPrint(ctl, "\n");
- ret = TRUE;
+ ret = true;
cleanup:
VIR_FREE(name);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
- int ret = FALSE;
+ bool ret = false;
int current;
virDomainSnapshotPtr snapshot = NULL;
VIR_FREE(xml);
}
- ret = TRUE;
+ ret = true;
cleanup:
if (snapshot)
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
- int ret = FALSE;
+ bool ret = false;
int numsnaps;
char **names = NULL;
int actual = 0;
}
}
- ret = TRUE;
+ ret = true;
cleanup:
/* this frees up memory from the last iteration of the loop */
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSnapshotDumpXML(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
- int ret = FALSE;
+ bool ret = false;
const char *name = NULL;
virDomainSnapshotPtr snapshot = NULL;
char *xml = NULL;
vshPrint(ctl, "%s", xml);
- ret = TRUE;
+ ret = true;
cleanup:
VIR_FREE(xml);
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomainSnapshotRevert(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
- int ret = FALSE;
+ bool ret = false;
const char *name = NULL;
virDomainSnapshotPtr snapshot = NULL;
if (virDomainRevertToSnapshot(snapshot, 0) < 0)
goto cleanup;
- ret = TRUE;
+ ret = true;
cleanup:
if (snapshot)
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSnapshotDelete(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
- int ret = FALSE;
+ bool ret = false;
const char *name = NULL;
virDomainSnapshotPtr snapshot = NULL;
unsigned int flags = 0;
if (virDomainSnapshotDelete(snapshot, flags) < 0)
goto cleanup;
- ret = TRUE;
+ ret = true;
cleanup:
if (snapshot)
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
- int ret = FALSE;
+ bool ret = false;
const char *monitor_cmd = NULL;
char *result = NULL;
unsigned int flags = 0;
printf("%s\n", result);
- ret = TRUE;
+ ret = true;
cleanup:
VIR_FREE(result);
return NULL;
}
-static int
+static bool
vshCmdGrpHelp(vshControl *ctl, const char *grpname)
{
const vshCmdGrp *grp = vshCmdGrpSearch(grpname);
if (!grp) {
vshError(ctl, _("command group '%s' doesn't exist"), grpname);
- return FALSE;
+ return false;
} else {
vshPrint(ctl, _(" %s (help keyword '%s'):\n"), grp->name,
grp->keyword);
}
}
- return TRUE;
+ return true;
}
-static int
+static bool
vshCmddefHelp(vshControl *ctl, const char *cmdname)
{
const vshCmdDef *def = vshCmddefSearch(cmdname);
if (!def) {
vshError(ctl, _("command '%s' doesn't exist"), cmdname);
- return FALSE;
+ return false;
} else {
const char *desc = _(vshCmddefGetInfo(def, "desc"));
const char *help = _(vshCmddefGetInfo(def, "help"));
if (vshCmddefOptParse(def, &opts_need_arg, &opts_required)) {
vshError(ctl, _("internal error: bad options in command: '%s'"),
def->name);
- return FALSE;
+ return false;
}
fputs(_(" NAME\n"), stdout);
}
fputc('\n', stdout);
}
- return TRUE;
+ return true;
}
/* ---------------
/*
- * Returns TRUE/FALSE if the option exists
+ * Returns true/false if the option exists
*/
-static int
+static bool
vshCommandOptBool(const vshCmd *cmd, const char *name)
{
- return vshCommandOpt(cmd, name) ? TRUE : FALSE;
+ return vshCommandOpt(cmd, name) != NULL;
}
/*
/*
* Executes command(s) and returns return code from last command
*/
-static int
+static bool
vshCommandRun(vshControl *ctl, const vshCmd *cmd)
{
- int ret = TRUE;
+ bool ret = true;
while (cmd) {
struct timeval before, after;
if (enable_timing)
GETTIMEOFDAY(&after);
- if (ret == FALSE)
+ if (ret == false)
virshReportError(ctl);
/* try to automatically catch disconnections */
- if ((ret == FALSE) &&
+ if ((ret == false) &&
((disconnected != 0) ||
((last_error != NULL) &&
(((last_error->code == VIR_ERR_SYSTEM_ERROR) &&
char **arg_end;
} vshCommandParser;
-static int
+static bool
vshCommandParse(vshControl *ctl, vshCommandParser *parser)
{
char *tkdata = NULL;
break;
}
- return TRUE;
+ return true;
syntaxError:
if (ctl->cmd) {
if (first)
vshCommandOptFree(first);
VIR_FREE(tkdata);
- return FALSE;
+ return false;
}
/* --------------------
return VSH_TK_ARG;
}
-static int vshCommandArgvParse(vshControl *ctl, int nargs, char **argv)
+static bool
+vshCommandArgvParse(vshControl *ctl, int nargs, char **argv)
{
vshCommandParser parser;
if (nargs <= 0)
- return FALSE;
+ return false;
parser.arg_pos = argv;
parser.arg_end = argv + nargs;
return VSH_TK_ARG;
}
-static int vshCommandStringParse(vshControl *ctl, char *cmdstr)
+static bool
+vshCommandStringParse(vshControl *ctl, char *cmdstr)
{
vshCommandParser parser;
if (cmdstr == NULL || *cmdstr == '\0')
- return FALSE;
+ return false;
parser.pos = cmdstr;
parser.getNextArg = vshCommandStringGetArg;
return N_("no state");
}
-static int
+static bool
vshConnectionUsability(vshControl *ctl, virConnectPtr conn)
{
/* TODO: use something like virConnectionState() to
*/
if (!conn) {
vshError(ctl, "%s", _("no valid connection"));
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
static void
va_list ap;
char *str;
- if (ctl && ctl->quiet == TRUE)
+ if (ctl && ctl->quiet == true)
return;
va_start(ap, format);
/*
* Initialize connection.
*/
-static int
+static bool
vshInit(vshControl *ctl)
{
if (ctl->conn)
- return FALSE;
+ return false;
vshOpenLogFile(ctl);
vshSetupSignals();
if (virEventRegisterDefaultImpl() < 0)
- return FALSE;
+ return false;
ctl->conn = virConnectOpenAuth(ctl->name,
virConnectAuthPtrDefault,
if (!ctl->conn) {
virshReportError(ctl);
vshError(ctl, "%s", _("failed to connect to the hypervisor"));
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
#define LOGFILE_FLAGS (O_WRONLY | O_APPEND | O_CREAT | O_SYNC)
/*
* Deinitialize virsh
*/
-static int
+static bool
vshDeinit(vshControl *ctl)
{
vshReadlineDeinit(ctl);
}
virResetLastError();
- return TRUE;
+ return true;
}
/*
* argv[]: virsh [options] [command]
*
*/
-static int
+static bool
vshParseArgv(vshControl *ctl, int argc, char **argv)
{
bool help = false;
help = true;
break;
case 'q':
- ctl->quiet = TRUE;
+ ctl->quiet = true;
break;
case 't':
- ctl->timing = TRUE;
+ ctl->timing = true;
break;
case 'c':
ctl->name = vshStrdup(ctl, optarg);
vshShowVersion(ctl);
exit(EXIT_SUCCESS);
case 'r':
- ctl->readonly = TRUE;
+ ctl->readonly = true;
break;
case 'l':
ctl->logfile = vshStrdup(ctl, optarg);
if (argc > optind) {
/* parse command */
- ctl->imode = FALSE;
+ ctl->imode = false;
if (argc - optind == 1) {
vshDebug(ctl, 2, "commands: \"%s\"\n", argv[optind]);
return vshCommandStringParse(ctl, argv[optind]);
return vshCommandArgvParse(ctl, argc - optind, argv + optind);
}
}
- return TRUE;
+ return true;
}
int
{
vshControl _ctl, *ctl = &_ctl;
char *defaultConn;
- int ret = TRUE;
+ bool ret = true;
if (!setlocale(LC_ALL, "")) {
perror("setlocale");
progname++;
memset(ctl, 0, sizeof(vshControl));
- ctl->imode = TRUE; /* default is interactive mode */
+ ctl->imode = true; /* default is interactive mode */
ctl->log_fd = -1; /* Initialize log file descriptor */
if ((defaultConn = getenv("VIRSH_DEFAULT_CONNECT_URI"))) {