g_autoptr(xmlDoc) xmldoc = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
int ndisks;
- xmlNodePtr *disks = NULL;
+ g_autofree xmlNodePtr *disks = NULL;
size_t i;
bool details = false;
g_autoptr(vshTable) table = NULL;
ret = true;
cleanup:
- VIR_FREE(disks);
return ret;
}
g_autoptr(xmlDoc) xmldoc = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
int ninterfaces;
- xmlNodePtr *interfaces = NULL;
+ g_autofree xmlNodePtr *interfaces = NULL;
size_t i;
g_autoptr(vshTable) table = NULL;
ret = true;
cleanup:
- VIR_FREE(interfaces);
return ret;
}
cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd)
{
const char *iface = NULL;
- char *state = NULL;
- char *xpath = NULL;
+ g_autofree char *state = NULL;
+ g_autofree char *xpath = NULL;
virMacAddr macaddr;
char macstr[VIR_MAC_STRING_BUFLEN] = "";
g_autoptr(xmlDoc) xml = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
- xmlNodePtr *interfaces = NULL;
+ g_autofree xmlNodePtr *interfaces = NULL;
int ninterfaces;
unsigned int flags = 0;
bool ret = false;
ret = true;
cleanup:
- VIR_FREE(state);
- VIR_FREE(interfaces);
- VIR_FREE(xpath);
return ret;
}
g_autoptr(virshDomain) dom = NULL;
const char *name = NULL, *device = NULL;
virDomainBlockStatsStruct stats;
- virTypedParameterPtr params = NULL;
+ g_autofree virTypedParameterPtr params = NULL;
virTypedParameterPtr par = NULL;
const char *field = NULL;
int rc, nparams = 0;
ret = true;
cleanup:
- VIR_FREE(params);
return ret;
}
#undef DOMBLKSTAT_LEGACY_PRINT
int ret;
bool functionReturn = false;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
- char *xml = NULL;
+ g_autofree char *xml = NULL;
unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
bool current = vshCommandOptBool(cmd, "current");
bool config = vshCommandOptBool(cmd, "config");
}
cleanup:
- VIR_FREE(xml);
return functionReturn;
}
}
for (i = 0; i < nparams; i++) {
- char *str = vshGetTypedParamValue(ctl, ¶ms[i]);
+ g_autofree char *str = vshGetTypedParamValue(ctl, ¶ms[i]);
vshPrint(ctl, "%-15s: %s\n", params[i].field, str);
- VIR_FREE(str);
}
} else {
if (virDomainSetBlockIoTune(dom, disk, params, nparams, flags) < 0)
}
for (i = 0; i < nparams; i++) {
- char *str = vshGetTypedParamValue(ctl, ¶ms[i]);
+ g_autofree char *str = vshGetTypedParamValue(ctl, ¶ms[i]);
vshPrint(ctl, "%-15s: %s\n", params[i].field, str);
- VIR_FREE(str);
}
} else {
/* set the blkio parameters */
g_autoptr(xmlXPathContext) ctxt = NULL;
g_autoptr(xmlXPathObject) obj = NULL;
xmlNodePtr cur = NULL;
- char *xml_buf = NULL;
+ g_autofree char *xml_buf = NULL;
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
return false;
}
cleanup:
- VIR_FREE(xml_buf);
return ret;
}
}
for (i = 0; i < nparams; i++) {
- char *str = vshGetTypedParamValue(ctl, ¶ms[i]);
+ g_autofree char *str = vshGetTypedParamValue(ctl, ¶ms[i]);
vshPrint(ctl, "%-15s: %s\n", params[i].field, str);
- VIR_FREE(str);
}
} else {
if (virDomainSetInterfaceParameters(dom, device, params,
unsigned int flags = VIR_DOMAIN_NONE;
int rc;
size_t nfds = 0;
- int *fds = NULL;
+ g_autofree int *fds = NULL;
if (!(dom = virshCommandOptDomainBy(ctl, cmd, NULL,
VIRSH_BYNAME | VIRSH_BYUUID)))
ret = true;
cleanup:
- VIR_FREE(fds);
return ret;
}
const char *to = NULL;
unsigned int flags = 0;
const char *xmlfile = NULL;
- char *xml = NULL;
+ g_autofree char *xml = NULL;
#ifndef WIN32
sigset_t sigmask, oldsigmask;
pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL);
out_sig:
#endif /* !WIN32 */
- VIR_FREE(xml);
g_main_loop_quit(data->eventLoop);
}
const char *file = NULL;
bool ret = false;
unsigned int flags = 0;
- char *xml = NULL;
+ g_autofree char *xml = NULL;
virshControl *priv = ctl->privData;
if (vshCommandOptBool(cmd, "security-info"))
ret = true;
cleanup:
- VIR_FREE(xml);
return ret;
}
const char *file = NULL;
bool ret = false;
const char *xmlfile = NULL;
- char *xml = NULL;
+ g_autofree char *xml = NULL;
unsigned int flags = 0;
virshControl *priv = ctl->privData;
ret = true;
cleanup:
- VIR_FREE(xml);
return ret;
}
bool ret = false;
g_autoptr(virshDomain) dom = NULL;
unsigned int flags = 0;
- char *xml = NULL;
+ g_autofree char *xml = NULL;
if (vshCommandOptBool(cmd, "security-info"))
flags |= VIR_DOMAIN_XML_SECURE;
ret = true;
cleanup:
- VIR_FREE(xml);
return ret;
}
bool ret = false;
g_autoptr(virshDomain) dom = NULL;
const char *xmlfile = NULL;
- char *xml = NULL;
+ g_autofree char *xml = NULL;
unsigned int flags = 0;
if (vshCommandOptBool(cmd, "running"))
ret = true;
cleanup:
- VIR_FREE(xml);
return ret;
}
bool ret = false;
unsigned int flags = 0;
const char *xmlfile = NULL;
- char *xml = NULL;
+ g_autofree char *xml = NULL;
virshControl *priv = ctl->privData;
if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
ret = true;
cleanup:
- VIR_FREE(xml);
return ret;
}
int maxcpu,
bool pretty)
{
- char *str = NULL;
+ g_autofree char *str = NULL;
size_t i;
int ret = -1;
ret = 0;
cleanup:
- VIR_FREE(str);
return ret;
}
virBitmap *ret = NULL;
g_autoptr(xmlDoc) xml = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
- xmlNodePtr *nodes = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
int nnodes;
size_t i;
unsigned int curvcpus = 0;
}
cleanup:
- VIR_FREE(nodes);
return ret;
}
unsigned char *cpumap,
size_t cpumaplen)
{
- char *str = NULL;
+ g_autofree char *str = NULL;
if (!(str = virBitmapDataFormat(cpumap, cpumaplen)))
return false;
vshPrint(ctl, "%s", str);
- VIR_FREE(str);
return true;
}
int maxcpu,
unsigned int flags)
{
- unsigned char *cpumap = NULL;
+ g_autofree unsigned char *cpumap = NULL;
unsigned int countFlags = flags | VIR_DOMAIN_VCPU_MAXIMUM;
int cpumaplen;
size_t i;
ret = true;
cleanup:
- VIR_FREE(cpumap);
return ret;
}
unsigned int vcpu = 0;
const char *cpulist = NULL;
bool ret = false;
- unsigned char *cpumap = NULL;
+ g_autofree unsigned char *cpumap = NULL;
int cpumaplen;
int maxcpu;
bool config = vshCommandOptBool(cmd, "config");
ret = true;
cleanup:
- VIR_FREE(cpumap);
return ret;
}
g_autoptr(virshDomain) dom = NULL;
const char *cpulist = NULL;
bool ret = false;
- unsigned char *cpumap = NULL;
+ g_autofree unsigned char *cpumap = NULL;
int cpumaplen;
int maxcpu;
bool config = vshCommandOptBool(cmd, "config");
ret = true;
cleanup:
- VIR_FREE(cpumap);
return ret;
}
unsigned int iothread_id = 0;
int maxcpu;
bool ret = false;
- unsigned char *cpumap = NULL;
+ g_autofree unsigned char *cpumap = NULL;
int cpumaplen;
unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
virshControl *priv = ctl->privData;
ret = true;
cleanup:
- VIR_FREE(cpumap);
return ret;
}
param->value.ul / 1000000000,
param->value.ul % 1000000000);
} else {
- char *s = vshGetTypedParamValue(ctl, param);
+ g_autofree char *s = vshGetTypedParamValue(ctl, param);
vshPrint(ctl, "%s\n", s);
- VIR_FREE(s);
}
}
g_autoptr(virshDomain) dom = NULL;
const char *from = NULL;
bool ret = false;
- char *buffer;
+ g_autofree char *buffer = NULL;
#ifndef WIN32
bool console = vshCommandOptBool(cmd, "console");
#endif
unsigned int flags = 0;
size_t nfds = 0;
- int *fds = NULL;
+ g_autofree int *fds = NULL;
virshControl *priv = ctl->privData;
if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
ret = true;
cleanup:
- VIR_FREE(buffer);
- VIR_FREE(fds);
return ret;
}
vshPrintExtra(ctl, "%s\n", _("Metadata modified"));
} else {
- char *data;
+ g_autofree char *data = NULL;
/* get */
if (!(data = virDomainGetMetadata(dom, VIR_DOMAIN_METADATA_ELEMENT,
uri, flags)))
goto cleanup;
vshPrint(ctl, "%s\n", data);
- VIR_FREE(data);
}
ret = true;
params[i].value.ul == VIR_DOMAIN_MEMORY_PARAM_UNLIMITED) {
vshPrint(ctl, "%-15s: %s\n", params[i].field, _("unlimited"));
} else {
- char *str = vshGetTypedParamValue(ctl, ¶ms[i]);
+ g_autofree char *str = vshGetTypedParamValue(ctl, ¶ms[i]);
vshPrint(ctl, "%-15s: %s\n", params[i].field, str);
- VIR_FREE(str);
}
}
} else {
vshPrint(ctl, "%-15s: %s\n", params[i].field,
virDomainNumatuneMemModeTypeToString(params[i].value.i));
} else {
- char *str = vshGetTypedParamValue(ctl, ¶ms[i]);
+ g_autofree char *str = vshGetTypedParamValue(ctl, ¶ms[i]);
vshPrint(ctl, "%-15s: %s\n", params[i].field, str);
- VIR_FREE(str);
}
}
} else {
{
virshQemuEventData *data = opaque;
virJSONValue *pretty = NULL;
- char *str = NULL;
+ g_autofree char *str = NULL;
if (!data->loop && data->count)
return;
data->count++;
if (!data->loop)
vshEventDone(data->ctl);
-
- VIR_FREE(str);
}
static const vshCmdInfo info_qemu_monitor_event[] = {
g_autoptr(virshDomain) dom = NULL;
bool ret = false;
const vshCmdOpt *opt = NULL;
- char **cmdargv = NULL;
+ g_autofree char **cmdargv = NULL;
size_t ncmdargv = 0;
pid_t pid;
int nfdlist;
int *fdlist;
size_t i;
bool setlabel = true;
- virSecurityModelPtr secmodel = NULL;
- virSecurityLabelPtr seclabel = NULL;
+ g_autofree virSecurityModelPtr secmodel = NULL;
+ g_autofree virSecurityLabelPtr seclabel = NULL;
virshControl *priv = ctl->privData;
dom = virshCommandOptDomain(ctl, cmd, NULL);
ret = true;
cleanup:
- VIR_FREE(seclabel);
- VIR_FREE(secmodel);
- VIR_FREE(cmdargv);
return ret;
}
{
g_autoptr(virshDomain) dom = NULL;
bool ret = true;
- char *dump;
+ g_autofree char *dump = NULL;
unsigned int flags = 0;
bool inactive = vshCommandOptBool(cmd, "inactive");
bool secure = vshCommandOptBool(cmd, "security-info");
dump = virDomainGetXMLDesc(dom, flags);
if (dump != NULL) {
vshPrint(ctl, "%s", dump);
- VIR_FREE(dump);
} else {
ret = false;
}
bool ret = true;
const char *format = NULL;
const char *configFile = NULL;
- char *configData;
- char *xmlData;
+ g_autofree char *configData = NULL;
+ g_autofree char *xmlData = NULL;
unsigned int flags = 0;
virshControl *priv = ctl->privData;
xmlData = virConnectDomainXMLFromNative(priv->conn, format, configData, flags);
if (xmlData != NULL) {
vshPrint(ctl, "%s", xmlData);
- VIR_FREE(xmlData);
} else {
ret = false;
}
- VIR_FREE(configData);
return ret;
}
bool ret = false;
const char *format = NULL;
const char *xmlFile = NULL;
- char *configData = NULL;
- char *xmlData = NULL;
+ g_autofree char *configData = NULL;
+ g_autofree char *xmlData = NULL;
unsigned int flags = 0;
virshControl *priv = ctl->privData;
g_autoptr(virshDomain) dom = NULL;
}
cleanup:
- VIR_FREE(xmlData);
- VIR_FREE(configData);
return ret;
}
g_autoptr(virshDomain) dom = NULL;
bool ret = false;
int port = 0;
- char *listen_addr = NULL;
+ g_autofree char *listen_addr = NULL;
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
return false;
ret = true;
cleanup:
- VIR_FREE(listen_addr);
return ret;
}
g_autoptr(xmlDoc) xml = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
bool ret = false;
- char *tty = NULL;
+ g_autofree char *tty = NULL;
if (virshDomainGetXML(ctl, cmd, 0, &xml, &ctxt) < 0)
return false;
ret = true;
cleanup:
- VIR_FREE(tty);
return ret;
}
{
g_autoptr(virshDomain) dom = NULL;
const char *from = NULL;
- char *buffer = NULL;
+ g_autofree char *buffer = NULL;
bool ret = false;
unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
bool current = vshCommandOptBool(cmd, "current");
ret = true;
cleanup:
- VIR_FREE(buffer);
return ret;
}
g_autoptr(xmlXPathObject) obj = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
xmlNodePtr cur = NULL, matchNode = NULL;
- char *detach_xml = NULL;
+ g_autofree char *detach_xml = NULL;
char buf[64];
int diff_mac, ret = -1;
size_t i;
while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE &&
virXMLNodeNameEqual(cur, "mac")) {
- char *tmp_mac = virXMLPropString(cur, "address");
+ g_autofree char *tmp_mac = virXMLPropString(cur, "address");
diff_mac = virMacAddrCompare(tmp_mac, mac);
- VIR_FREE(tmp_mac);
if (!diff_mac) {
if (matchNode) {
/* this is the 2nd match, so it's ambiguous */
ret = virDomainDetachDevice(dom, detach_xml);
cleanup:
- VIR_FREE(detach_xml);
return ret == 0;
}
cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
{
g_autoptr(virshDomain) dom = NULL;
- char *doc_live = NULL, *doc_config = NULL;
+ g_autofree char *doc_live = NULL;
+ g_autofree char *doc_config = NULL;
const char *mac = NULL, *type = NULL;
int flags = 0;
bool ret = false, affect_config, affect_live;
} else {
vshPrintExtra(ctl, "%s", _("Interface detached successfully\n"));
}
- VIR_FREE(doc_live);
- VIR_FREE(doc_config);
return ret;
}
/* Check if the disk is CDROM or floppy disk */
if (virXMLNodeNameEqual(n, "disk")) {
- char *device_value = virXMLPropString(n, "device");
+ g_autofree char *device_value = virXMLPropString(n, "device");
if (STREQ(device_value, "cdrom") ||
STREQ(device_value, "floppy"))
is_supported = true;
-
- VIR_FREE(device_value);
}
if (!is_supported)
cur = obj->nodesetval->nodeTab[i]->children;
while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE) {
- char *tmp = NULL;
+ g_autofree char *tmp = NULL;
if (virXMLNodeNameEqual(cur, "source")) {
if ((tmp = virXMLPropString(cur, "file")) ||
ret = xmlCopyNode(obj->nodesetval->nodeTab[i], 1);
/* drop backing store since they are not needed here */
virshDiskDropBackingStore(ret);
- VIR_FREE(tmp);
goto cleanup;
}
- VIR_FREE(tmp);
}
cur = cur->next;
}
xmlNodePtr source = NULL;
xmlNodePtr target_node = NULL;
xmlNodePtr text_node = NULL;
- char *device_type = NULL;
+ g_autofree char *device_type = NULL;
char *ret = NULL;
- char *startupPolicy = NULL;
- char *source_path = NULL;
+ g_autofree char *startupPolicy = NULL;
+ g_autofree char *source_path = NULL;
if (!disk_node)
return NULL;
}
cleanup:
- VIR_FREE(device_type);
- VIR_FREE(startupPolicy);
- VIR_FREE(source_path);
return ret;
}
static bool
cmdDetachDisk(vshControl *ctl, const vshCmd *cmd)
{
- char *disk_xml = NULL;
+ g_autofree char *disk_xml = NULL;
g_autoptr(virshDomain) dom = NULL;
const char *target = NULL;
- char *doc = NULL;
+ g_autofree char *doc = NULL;
int ret;
bool functionReturn = false;
xmlNodePtr disk_node = NULL;
cleanup:
xmlFreeNode(disk_node);
- VIR_FREE(disk_xml);
- VIR_FREE(doc);
return functionReturn;
}
{
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
size_t i;
- char *value;
virBufferAsprintf(&buf, _("event 'job-completed' for domain '%s':\n"),
virDomainGetName(dom));
for (i = 0; i < nparams; i++) {
- value = virTypedParameterToString(¶ms[i]);
- if (value) {
+ g_autofree char *value = virTypedParameterToString(¶ms[i]);
+ if (value)
virBufferAsprintf(&buf, "\t%s: %s\n", params[i].field, value);
- VIR_FREE(value);
- }
}
virshEventPrint(opaque, &buf);
}
g_autoptr(virshDomain) dom = NULL;
const char *source = NULL;
const char *path = NULL;
- char *doc = NULL;
+ g_autofree char *doc = NULL;
xmlNodePtr disk_node = NULL;
- char *disk_xml = NULL;
+ g_autofree char *disk_xml = NULL;
bool ret = false;
virshUpdateDiskXMLType update_type;
const char *action = NULL;
ret = true;
cleanup:
- VIR_FREE(doc);
xmlFreeNode(disk_node);
- VIR_FREE(disk_xml);
return ret;
}
g_autoptr(virshDomain) dom = NULL;
int ret = -1;
const vshCmdOpt *opt = NULL;
- const char **mountpoints = NULL;
+ g_autofree const char **mountpoints = NULL;
size_t nmountpoints = 0;
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
vshPrintExtra(ctl, _("Froze %d filesystem(s)\n"), ret);
cleanup:
- VIR_FREE(mountpoints);
return ret >= 0;
}
g_autoptr(virshDomain) dom = NULL;
int ret = -1;
const vshCmdOpt *opt = NULL;
- const char **mountpoints = NULL;
+ g_autofree const char **mountpoints = NULL;
size_t nmountpoints = 0;
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
vshPrintExtra(ctl, _("Thawed %d filesystem(s)\n"), ret);
cleanup:
- VIR_FREE(mountpoints);
return ret >= 0;
}
goto cleanup;
for (i = 0; i < nparams; i++) {
- char *str = vshGetTypedParamValue(ctl, ¶ms[i]);
+ g_autofree char *str = vshGetTypedParamValue(ctl, ¶ms[i]);
vshPrint(ctl, "%-20s: %s\n", params[i].field, str);
- VIR_FREE(str);
}
ret = true;
static bool
cmdCapabilities(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
{
- char *caps;
+ g_autofree char *caps = NULL;
virshControl *priv = ctl->privData;
if ((caps = virConnectGetCapabilities(priv->conn)) == NULL) {
return false;
}
vshPrint(ctl, "%s\n", caps);
- VIR_FREE(caps);
return true;
}
cmdDomCapabilities(vshControl *ctl, const vshCmd *cmd)
{
bool ret = false;
- char *caps = NULL;
+ g_autofree char *caps = NULL;
const char *virttype = NULL;
const char *emulatorbin = NULL;
const char *arch = NULL;
vshPrint(ctl, "%s\n", caps);
ret = true;
cleanup:
- VIR_FREE(caps);
return ret;
}
bool ret = false;
int cell = -1;
unsigned long long memory = 0;
- xmlNodePtr *nodes = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
unsigned long nodes_cnt;
- unsigned long *nodes_id = NULL;
- unsigned long long *nodes_free = NULL;
+ g_autofree unsigned long *nodes_id = NULL;
+ g_autofree unsigned long long *nodes_free = NULL;
bool all = vshCommandOptBool(cmd, "all");
bool cellno = vshCommandOptBool(cmd, "cellno");
size_t i;
- char *cap_xml = NULL;
+ g_autofree char *cap_xml = NULL;
g_autoptr(xmlDoc) xml = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
virshControl *priv = ctl->privData;
for (i = 0; i < nodes_cnt; i++) {
unsigned long id;
- char *val = virXMLPropString(nodes[i], "id");
+ g_autofree char *val = virXMLPropString(nodes[i], "id");
if (virStrToLong_ulp(val, NULL, 10, &id)) {
vshError(ctl, "%s", _("conversion from string failed"));
- VIR_FREE(val);
goto cleanup;
}
- VIR_FREE(val);
nodes_id[i] = id;
if (virNodeGetCellsFreeMemory(priv->conn, &(nodes_free[i]),
id, 1) != 1) {
ret = true;
cleanup:
- VIR_FREE(nodes);
- VIR_FREE(nodes_free);
- VIR_FREE(nodes_id);
- VIR_FREE(cap_xml);
return ret;
}
{
bool ret = false;
unsigned int npages;
- unsigned int *pagesize = NULL;
+ g_autofree unsigned int *pagesize = NULL;
unsigned long long bytes = 0;
unsigned int kibibytes = 0;
int cell;
- unsigned long long *counts = NULL;
+ g_autofree unsigned long long *counts = NULL;
size_t i, j;
xmlNodePtr *nodes = NULL;
int nodes_cnt;
- char *cap_xml = NULL;
+ g_autofree char *cap_xml = NULL;
g_autoptr(xmlDoc) doc = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
bool all = vshCommandOptBool(cmd, "all");
pagesize = g_new0(unsigned int, nodes_cnt);
for (i = 0; i < nodes_cnt; i++) {
- char *val = virXMLPropString(nodes[i], "size");
+ g_autofree char *val = virXMLPropString(nodes[i], "size");
if (virStrToLong_uip(val, NULL, 10, &pagesize[i]) < 0) {
vshError(ctl, _("unable to parse page size: %s"), val);
- VIR_FREE(val);
goto cleanup;
}
-
- VIR_FREE(val);
}
/* Here, if we've done the trick few lines above,
nodes_cnt = virXPathNodeSet("/capabilities/host/topology/cells/cell",
ctxt, &nodes);
for (i = 0; i < nodes_cnt; i++) {
- char *val = virXMLPropString(nodes[i], "id");
+ g_autofree char *val = virXMLPropString(nodes[i], "id");
if (virStrToLong_i(val, NULL, 10, &cell) < 0) {
vshError(ctl, _("unable to parse numa node id: %s"), val);
- VIR_FREE(val);
goto cleanup;
}
- VIR_FREE(val);
if (virNodeGetFreePages(priv->conn, npages, pagesize,
cell, 1, counts, 0) < 0)
ret = true;
cleanup:
- VIR_FREE(cap_xml);
VIR_FREE(nodes);
- VIR_FREE(counts);
- VIR_FREE(pagesize);
return ret;
}
unsigned int pageSizes[1];
unsigned long long pageCounts[1], tmp;
unsigned int flags = 0;
- char *cap_xml = NULL;
+ g_autofree char *cap_xml = NULL;
g_autoptr(xmlDoc) xml = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
- xmlNodePtr *nodes = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
virshControl *priv = ctl->privData;
VSH_EXCLUSIVE_OPTIONS_VAR(all, cellno);
for (i = 0; i < nodes_cnt; i++) {
unsigned long id;
- char *val = virXMLPropString(nodes[i], "id");
+ g_autofree char *val = virXMLPropString(nodes[i], "id");
if (virStrToLong_ulp(val, NULL, 10, &id)) {
vshError(ctl, "%s", _("conversion from string failed"));
- VIR_FREE(val);
goto cleanup;
}
- VIR_FREE(val);
if (virNodeAllocPages(priv->conn, 1, pageSizes,
pageCounts, id, 1, flags) < 0)
ret = true;
cleanup:
- VIR_FREE(nodes);
- VIR_FREE(cap_xml);
return ret;
}
{
const char *type = NULL;
int vcpus = -1;
- char *caps = NULL;
+ g_autofree char *caps = NULL;
g_autoptr(xmlDoc) xml = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
virshControl *priv = ctl->privData;
ret = true;
cleanup:
- VIR_FREE(caps);
return ret;
}
cmdNodeCpuMap(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
{
int cpu, cpunum;
- unsigned char *cpumap = NULL;
+ g_autofree unsigned char *cpumap = NULL;
unsigned int online;
bool pretty = vshCommandOptBool(cmd, "pretty");
bool ret = false;
vshPrint(ctl, "%-15s ", _("CPU map:"));
if (pretty) {
- char *str = virBitmapDataFormat(cpumap, VIR_CPU_MAPLEN(cpunum));
+ g_autofree char *str = virBitmapDataFormat(cpumap, VIR_CPU_MAPLEN(cpunum));
if (!str)
goto cleanup;
vshPrint(ctl, "%s", str);
- VIR_FREE(str);
} else {
for (cpu = 0; cpu < cpunum; cpu++)
vshPrint(ctl, "%c", VIR_CPU_USED(cpumap, cpu) ? 'y' : '-');
ret = true;
cleanup:
- VIR_FREE(cpumap);
return ret;
}
size_t i, j;
bool flag_percent = vshCommandOptBool(cmd, "percent");
int cpuNum = VIR_NODE_CPU_STATS_ALL_CPUS;
- virNodeCPUStatsPtr params;
+ g_autofree virNodeCPUStatsPtr params = NULL;
int nparams = 0;
bool ret = false;
unsigned long long cpu_stats[VIRSH_CPU_LAST] = { 0 };
ret = true;
cleanup:
- VIR_FREE(params);
return ret;
}
int nparams = 0;
size_t i;
int cellNum = VIR_NODE_MEMORY_STATS_ALL_CELLS;
- virNodeMemoryStatsPtr params = NULL;
+ g_autofree virNodeMemoryStatsPtr params = NULL;
bool ret = false;
virshControl *priv = ctl->privData;
ret = true;
cleanup:
- VIR_FREE(params);
return ret;
}
static bool
cmdSysinfo(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
{
- char *sysinfo;
+ g_autofree char *sysinfo = NULL;
virshControl *priv = ctl->privData;
sysinfo = virConnectGetSysinfo(priv->conn, 0);
}
vshPrint(ctl, "%s", sysinfo);
- VIR_FREE(sysinfo);
return true;
}
static bool
cmdHostname(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
{
- char *hostname;
+ g_autofree char *hostname = NULL;
virshControl *priv = ctl->privData;
hostname = virConnectGetHostname(priv->conn);
}
vshPrint(ctl, "%s\n", hostname);
- VIR_FREE(hostname);
return true;
}
static bool
cmdURI(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
{
- char *uri;
+ g_autofree char *uri = NULL;
virshControl *priv = ctl->privData;
uri = virConnectGetURI(priv->conn);
}
vshPrint(ctl, "%s\n", uri);
- VIR_FREE(uri);
return true;
}
const char *xmlFile)
{
char **cpus = NULL;
- char *buffer = NULL;
- char *xmlStr = NULL;
+ g_autofree char *buffer = NULL;
+ g_autofree char *xmlStr = NULL;
g_autoptr(xmlDoc) xml = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
- xmlNodePtr *nodes = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
char *doc;
size_t i;
int n;
}
cleanup:
- VIR_FREE(buffer);
- VIR_FREE(xmlStr);
- VIR_FREE(nodes);
return cpus;
error:
{
const char *from = NULL;
bool ret = false;
- char *result = NULL;
+ g_autofree char *result = NULL;
g_auto(GStrv) list = NULL;
unsigned int flags = 0;
virshControl *priv = ctl->privData;
ret = true;
}
- VIR_FREE(result);
return ret;
}
*/
vshPrint(ctl, _("Shared memory:\n"));
for (i = 0; i < nparams; i++) {
- char *str = vshGetTypedParamValue(ctl, ¶ms[i]);
+ g_autofree char *str = vshGetTypedParamValue(ctl, ¶ms[i]);
vshPrint(ctl, "\t%-15s %s\n", params[i].field, str);
- VIR_FREE(str);
}
} else {
if (virNodeSetMemoryParameters(priv->conn, params, nparams, flags) != 0)
const char *arch = NULL;
const char *machine = NULL;
bool ret = false;
- char *result = NULL;
+ g_autofree char *result = NULL;
char **list = NULL;
unsigned int flags = 0;
virshControl *priv = ctl->privData;
ret = true;
}
- VIR_FREE(result);
g_strfreev(list);
return ret;
}
{
virInterfacePtr iface;
bool ret = true;
- char *dump;
+ g_autofree char *dump = NULL;
unsigned int flags = 0;
bool inactive = vshCommandOptBool(cmd, "inactive");
dump = virInterfaceGetXMLDesc(iface, flags);
if (dump != NULL) {
vshPrint(ctl, "%s", dump);
- VIR_FREE(dump);
} else {
ret = false;
}
virInterfacePtr iface;
const char *from = NULL;
bool ret = true;
- char *buffer;
+ g_autofree char *buffer = NULL;
virshControl *priv = ctl->privData;
if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
return false;
iface = virInterfaceDefineXML(priv->conn, buffer, 0);
- VIR_FREE(buffer);
if (iface != NULL) {
vshPrintExtra(ctl, _("Interface %s defined from %s\n"),
virNetworkPtr network;
const char *from = NULL;
bool ret = true;
- char *buffer;
+ g_autofree char *buffer = NULL;
virshControl *priv = ctl->privData;
if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
return false;
network = virNetworkCreateXML(priv->conn, buffer);
- VIR_FREE(buffer);
if (network != NULL) {
vshPrintExtra(ctl, _("Network %s created from %s\n"),
virNetworkPtr network;
const char *from = NULL;
bool ret = true;
- char *buffer;
+ g_autofree char *buffer = NULL;
virshControl *priv = ctl->privData;
if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
return false;
network = virNetworkDefineXML(priv->conn, buffer);
- VIR_FREE(buffer);
if (network != NULL) {
vshPrintExtra(ctl, _("Network %s defined from %s\n"),
{
virNetworkPtr network;
bool ret = true;
- char *dump;
+ g_autofree char *dump = NULL;
unsigned int flags = 0;
int inactive;
if (dump != NULL) {
vshPrint(ctl, "%s", dump);
- VIR_FREE(dump);
} else {
ret = false;
}
const char *sectionStr = NULL;
int command, section, parentIndex = -1;
const char *xml = NULL;
- char *xmlFromFile = NULL;
+ g_autofree char *xmlFromFile = NULL;
bool config = vshCommandOptBool(cmd, "config");
bool live = vshCommandOptBool(cmd, "live");
unsigned int flags = VIR_NETWORK_UPDATE_AFFECT_CURRENT;
cleanup:
vshReportError(ctl);
virNetworkFree(network);
- VIR_FREE(xmlFromFile);
return ret;
}
virNetworkPtr network;
virNetworkPortPtr port = NULL;
bool ret = true;
- char *dump;
+ g_autofree char *dump = NULL;
unsigned int flags = 0;
if (!(network = virshCommandOptNetwork(ctl, cmd, NULL)))
if (dump != NULL) {
vshPrint(ctl, "%s", dump);
- VIR_FREE(dump);
} else {
ret = false;
}
virNodeDevicePtr dev = NULL;
const char *from = NULL;
bool ret = true;
- char *buffer;
+ g_autofree char *buffer = NULL;
virshControl *priv = ctl->privData;
if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
return false;
dev = virNodeDeviceCreateXML(priv->conn, buffer, 0);
- VIR_FREE(buffer);
if (dev != NULL) {
vshPrintExtra(ctl, _("Node device %s created from %s\n"),
/* filter the list if the list was acquired by fallback means */
for (i = 0; i < list->ndevices; i++) {
- char **caps = NULL;
+ g_autofree char **caps = NULL;
int ncaps = 0;
bool match = false;
size_t j, k;
if ((ncaps = virNodeDeviceListCaps(device, caps, ncaps)) < 0) {
vshError(ctl, "%s", _("Failed to get capability names of the device"));
- VIR_FREE(caps);
goto cleanup;
}
}
}
- VIR_FREE(caps);
-
if (!match)
goto remove_entry;
cmdNodeDeviceDumpXML(vshControl *ctl, const vshCmd *cmd)
{
virNodeDevicePtr device = NULL;
- char *xml = NULL;
+ g_autofree char *xml = NULL;
const char *device_value = NULL;
bool ret = false;
ret = true;
cleanup:
- VIR_FREE(xml);
if (device)
virNodeDeviceFree(device);
return ret;
virNodeDevice *dev = NULL;
const char *from = NULL;
bool ret = true;
- char *buffer;
+ g_autofree char *buffer = NULL;
virshControl *priv = ctl->privData;
if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
return false;
dev = virNodeDeviceDefineXML(priv->conn, buffer, 0);
- VIR_FREE(buffer);
if (dev != NULL) {
vshPrintExtra(ctl, _("Node device '%s' defined from '%s'\n"),
virNWFilterPtr nwfilter;
const char *from = NULL;
bool ret = true;
- char *buffer;
+ g_autofree char *buffer = NULL;
virshControl *priv = ctl->privData;
if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
return false;
nwfilter = virNWFilterDefineXML(priv->conn, buffer);
- VIR_FREE(buffer);
if (nwfilter != NULL) {
vshPrintExtra(ctl, _("Network filter %s defined from %s\n"),
{
virNWFilterPtr nwfilter;
bool ret = true;
- char *dump;
+ g_autofree char *dump = NULL;
if (!(nwfilter = virshCommandOptNWFilter(ctl, cmd, NULL)))
return false;
dump = virNWFilterGetXMLDesc(nwfilter, 0);
if (dump != NULL) {
vshPrint(ctl, "%s", dump);
- VIR_FREE(dump);
} else {
ret = false;
}
{
virNWFilterBindingPtr binding;
bool ret = true;
- char *dump;
+ g_autofree char *dump = NULL;
if (!(binding = virshCommandOptNWFilterBinding(ctl, cmd, NULL)))
return false;
dump = virNWFilterBindingGetXMLDesc(binding, 0);
if (dump != NULL) {
vshPrint(ctl, "%s", dump);
- VIR_FREE(dump);
} else {
ret = false;
}
virStoragePoolPtr pool;
const char *from = NULL;
bool ret = true;
- char *buffer;
+ g_autofree char *buffer = NULL;
bool build;
bool overwrite;
bool no_overwrite;
return false;
pool = virStoragePoolCreateXML(priv->conn, buffer, flags);
- VIR_FREE(buffer);
if (pool != NULL) {
vshPrintExtra(ctl, _("Pool %s created from %s\n"),
{
virStoragePoolPtr pool;
const char *name;
- char *xml;
+ g_autofree char *xml = NULL;
bool printXML = vshCommandOptBool(cmd, "print-xml");
bool build;
bool overwrite;
if (printXML) {
vshPrint(ctl, "%s", xml);
- VIR_FREE(xml);
} else {
pool = virStoragePoolCreateXML(priv->conn, xml, flags);
- VIR_FREE(xml);
if (pool != NULL) {
vshPrintExtra(ctl, _("Pool %s created\n"), name);
virStoragePoolPtr pool;
const char *from = NULL;
bool ret = true;
- char *buffer;
+ g_autofree char *buffer = NULL;
virshControl *priv = ctl->privData;
if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
return false;
pool = virStoragePoolDefineXML(priv->conn, buffer, 0);
- VIR_FREE(buffer);
if (pool != NULL) {
vshPrintExtra(ctl, _("Pool %s defined from %s\n"),
{
virStoragePoolPtr pool;
const char *name;
- char *xml;
+ g_autofree char *xml = NULL;
bool printXML = vshCommandOptBool(cmd, "print-xml");
virshControl *priv = ctl->privData;
if (printXML) {
vshPrint(ctl, "%s", xml);
- VIR_FREE(xml);
} else {
pool = virStoragePoolDefineXML(priv->conn, xml, 0);
- VIR_FREE(xml);
if (pool != NULL) {
vshPrintExtra(ctl, _("Pool %s defined\n"), name);
bool ret = true;
bool inactive = vshCommandOptBool(cmd, "inactive");
unsigned int flags = 0;
- char *dump;
+ g_autofree char *dump = NULL;
if (inactive)
flags |= VIR_STORAGE_XML_INACTIVE;
dump = virStoragePoolGetXMLDesc(pool, flags);
if (dump != NULL) {
vshPrint(ctl, "%s", dump);
- VIR_FREE(dump);
} else {
ret = false;
}
cmdPoolDiscoverSourcesAs(vshControl * ctl, const vshCmd * cmd G_GNUC_UNUSED)
{
const char *type = NULL, *host = NULL;
- char *srcSpec = NULL;
- char *srcList;
+ g_autofree char *srcSpec = NULL;
+ g_autofree char *srcList = NULL;
const char *initiator = NULL;
virshControl *priv = ctl->privData;
}
srcList = virConnectFindStoragePoolSources(priv->conn, type, srcSpec, 0);
- VIR_FREE(srcSpec);
if (srcList == NULL) {
vshError(ctl, _("Failed to find any %s pool sources"), type);
return false;
}
vshPrint(ctl, "%s", srcList);
- VIR_FREE(srcList);
return true;
}
virStoragePoolPtr pool = NULL;
virStoragePoolPtr pool_edited = NULL;
unsigned int flags = VIR_STORAGE_XML_INACTIVE;
- char *tmp_desc = NULL;
+ g_autofree char *tmp_desc = NULL;
virshControl *priv = ctl->privData;
pool = virshCommandOptPool(ctl, cmd, "pool", NULL);
} else {
goto cleanup;
}
- } else {
- VIR_FREE(tmp_desc);
}
#define EDIT_GET_XML virStoragePoolGetXMLDesc(pool, flags)
cmdSecretDefine(vshControl *ctl, const vshCmd *cmd)
{
const char *from = NULL;
- char *buffer;
+ g_autofree char *buffer = NULL;
virSecretPtr res;
char uuid[VIR_UUID_STRING_BUFLEN];
bool ret = false;
ret = true;
cleanup:
- VIR_FREE(buffer);
virshSecretFree(res);
return ret;
}
{
virSecretPtr secret;
bool ret = false;
- char *xml;
+ g_autofree char *xml = NULL;
secret = virshCommandOptSecret(ctl, cmd, NULL);
if (secret == NULL)
if (xml == NULL)
goto cleanup;
vshPrint(ctl, "%s", xml);
- VIR_FREE(xml);
ret = true;
cleanup:
xmlDocPtr *xml,
xmlXPathContextPtr *ctxt)
{
- char *desc = NULL;
+ g_autofree char *desc = NULL;
if (!(desc = virDomainGetXMLDesc(dom, flags))) {
vshError(ctl, _("Failed to get domain description xml"));
}
*xml = virXMLParseStringCtxt(desc, _("(domain_definition)"), ctxt);
- VIR_FREE(desc);
if (!(*xml)) {
vshError(ctl, _("Failed to parse domain description xml"));
{
virStoragePoolPtr pool;
virStorageVolPtr vol = NULL;
- char *xml = NULL;
+ g_autofree char *xml = NULL;
bool printXML = vshCommandOptBool(cmd, "print-xml");
const char *name, *capacityStr = NULL, *allocationStr = NULL, *format = NULL;
const char *snapshotStrVol = NULL, *snapshotStrFormat = NULL;
/* Convert the snapshot parameters into backingStore XML */
if (snapshotStrVol) {
virStorageVolPtr snapVol;
- char *snapshotStrVolPath;
+ g_autofree char *snapshotStrVolPath = NULL;
/* Lookup snapshot backing volume. Try the backing-vol
* parameter as a name */
vshDebug(ctl, VSH_ERR_DEBUG,
virBufferAddLit(&buf, "</backingStore>\n");
/* Cleanup snapshot allocations */
- VIR_FREE(snapshotStrVolPath);
virStorageVolFree(snapVol);
}
if (vol)
virStorageVolFree(vol);
virStoragePoolFree(pool);
- VIR_FREE(xml);
return ret;
}
const char *from = NULL;
bool ret = false;
unsigned int flags = 0;
- char *buffer = NULL;
+ g_autofree char *buffer = NULL;
if (vshCommandOptBool(cmd, "prealloc-metadata"))
flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
}
cleanup:
- VIR_FREE(buffer);
virStoragePoolFree(pool);
return ret;
}
virStorageVolPtr newvol = NULL, inputvol = NULL;
const char *from = NULL;
bool ret = false;
- char *buffer = NULL;
+ g_autofree char *buffer = NULL;
unsigned int flags = 0;
if (!(pool = virshCommandOptPool(ctl, cmd, "pool", NULL)))
ret = true;
cleanup:
- VIR_FREE(buffer);
if (pool)
virStoragePoolFree(pool);
if (inputvol)
virStoragePoolPtr origpool = NULL;
virStorageVolPtr origvol = NULL, newvol = NULL;
const char *name = NULL;
- char *origxml = NULL;
+ g_autofree char *origxml = NULL;
xmlChar *newxml = NULL;
bool ret = false;
unsigned int flags = 0;
ret = true;
cleanup:
- VIR_FREE(origxml);
xmlFree(newxml);
if (origvol)
virStorageVolFree(origvol);
cmdVolPath(vshControl *ctl, const vshCmd *cmd)
{
virStorageVolPtr vol;
- char * StorageVolPath;
+ g_autofree char *StorageVolPath = NULL;
if (!(vol = virshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
return false;
}
vshPrint(ctl, "%s\n", StorageVolPath);
- VIR_FREE(StorageVolPath);
virStorageVolFree(vol);
return true;
}
vshControl *ctl = opaque;
const char *str = "unknown reason";
virErrorPtr error;
- char *uri;
+ g_autofree char *uri = NULL;
virErrorPreserveLast(&error);
uri = virConnectGetURI(conn);
break;
}
vshError(ctl, _(str), NULLSTR(uri));
- VIR_FREE(uri);
virErrorRestore(&error);
disconnected++;