static bool
cmdAttachDevice(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
const char *from = NULL;
char *buffer;
int rv;
ret = true;
cleanup:
- virshDomainFree(dom);
return ret;
}
static bool
cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
const char *mac = NULL, *target = NULL, *script = NULL,
*type = NULL, *source = NULL, *model = NULL,
*inboundStr = NULL, *outboundStr = NULL, *alias = NULL;
cleanup:
VIR_FREE(xml);
- virshDomainFree(dom);
return functionReturn;
}
static bool
cmdAutostart(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
const char *name;
int autostart;
vshError(ctl, _("Failed to mark domain '%s' as autostarted"), name);
else
vshError(ctl, _("Failed to unmark domain '%s' as autostarted"), name);
- virshDomainFree(dom);
return false;
}
else
vshPrintExtra(ctl, _("Domain '%s' unmarked as autostarted\n"), name);
- virshDomainFree(dom);
return true;
}
static bool
cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
const char *name, *disk;
const char *group_name = NULL;
unsigned long long value;
cleanup:
virTypedParamsFree(params, nparams);
- virshDomainFree(dom);
return ret;
save_error:
static bool
cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
const char *device_weight = NULL;
const char *device_riops = NULL;
const char *device_wiops = NULL;
cleanup:
virTypedParamsFree(params, nparams);
- virshDomainFree(dom);
return ret;
save_error:
static bool
cmdBlockcommit(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = false;
bool verbose = vshCommandOptBool(cmd, "verbose");
bool pivot = vshCommandOptBool(cmd, "pivot");
ret = true;
cleanup:
- virshDomainFree(dom);
virshBlockJobWaitFree(bjWait);
return ret;
}
static bool
cmdBlockcopy(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
const char *dest = NULL;
const char *format = NULL;
unsigned long bandwidth = 0;
cleanup:
VIR_FREE(xmlstr);
virTypedParamsFree(params, nparams);
- virshDomainFree(dom);
virshBlockJobWaitFree(bjWait);
return ret;
}
bool async = vshCommandOptBool(cmd, "async");
bool info = vshCommandOptBool(cmd, "info");
bool bandwidth = vshCommandOptBool(cmd, "bandwidth");
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
const char *path;
VSH_EXCLUSIVE_OPTIONS("raw", "abort");
ret = virshBlockJobInfo(ctl, dom, path, raw, bytes);
cleanup:
- virshDomainFree(dom);
return ret;
}
static bool
cmdBlockpull(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = false;
bool blocking = vshCommandOptBool(cmd, "wait");
bool verbose = vshCommandOptBool(cmd, "verbose");
ret = true;
cleanup:
- virshDomainFree(dom);
virshBlockJobWaitFree(bjWait);
return ret;
}
static bool
cmdBlockresize(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
const char *path = NULL;
unsigned long long size = 0;
unsigned int flags = 0;
ret = true;
}
- virshDomainFree(dom);
return ret;
}
static bool
cmdConsole(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = false;
bool force = vshCommandOptBool(cmd, "force");
bool safe = vshCommandOptBool(cmd, "safe");
ret = cmdRunConsole(ctl, dom, name, flags);
cleanup:
- virshDomainFree(dom);
return ret;
}
#endif /* WIN32 */
static bool
cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
const char *iface;
const char *state;
char *value;
xmlXPathFreeContext(ctxt);
xmlFreeDoc(xml);
VIR_FREE(xml_buf);
- virshDomainFree(dom);
return ret;
}
static bool
cmdDomIftune(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
const char *name = NULL, *device = NULL,
*inboundStr = NULL, *outboundStr = NULL;
unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
cleanup:
virTypedParamsFree(params, nparams);
- virshDomainFree(dom);
return ret;
save_error:
static bool
cmdSuspend(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
const char *name;
bool ret = true;
ret = false;
}
- virshDomainFree(dom);
return ret;
}
static bool
cmdDomPMSuspend(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
const char *name;
bool ret = false;
const char *target = NULL;
ret = true;
cleanup:
- virshDomainFree(dom);
return ret;
}
static bool
cmdDomPMWakeup(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
const char *name;
bool ret = false;
unsigned int flags = 0;
ret = true;
cleanup:
- virshDomainFree(dom);
return ret;
}
static bool
cmdUndefine(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = false;
const char *name = NULL;
/* Flags to attempt. */
VIR_FREE(vol_nodes);
xmlFreeDoc(doc);
xmlXPathFreeContext(ctxt);
- virshDomainFree(dom);
return ret;
error:
static bool
cmdStart(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = false;
#ifndef WIN32
bool console = vshCommandOptBool(cmd, "console");
ret = true;
cleanup:
- virshDomainFree(dom);
VIR_FREE(fds);
return ret;
}
virshCtrlData *data = opaque;
vshControl *ctl = data->ctl;
const vshCmd *cmd = data->cmd;
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
const char *name = NULL;
const char *to = NULL;
unsigned int flags = 0;
pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL);
out_sig:
#endif /* !WIN32 */
- virshDomainFree(dom);
VIR_FREE(xml);
g_main_loop_quit(data->eventLoop);
}
static bool
cmdSave(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
virThread workerThread;
bool verbose = false;
const char *to = NULL;
vshPrintExtra(ctl, _("\nDomain '%s' saved to %s\n"), name, to);
cleanup:
- virshDomainFree(dom);
return !data.ret;
}
virshCtrlData *data = opaque;
vshControl *ctl = data->ctl;
const vshCmd *cmd = data->cmd;
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
const char *name;
unsigned int flags = 0;
#ifndef WIN32
pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL);
out_sig:
#endif /* !WIN32 */
- virshDomainFree(dom);
g_main_loop_quit(data->eventLoop);
}
static bool
cmdManagedSave(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
bool verbose = false;
const char *name = NULL;
virThread workerThread;
vshPrintExtra(ctl, _("\nDomain '%s' state saved by libvirt\n"), name);
cleanup:
- virshDomainFree(dom);
return !data.ret;
}
static bool
cmdManagedSaveRemove(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
const char *name;
bool ret = false;
int hassave;
ret = true;
cleanup:
- virshDomainFree(dom);
return ret;
}
cmdManagedSaveEdit(vshControl *ctl, const vshCmd *cmd)
{
bool ret = false;
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
unsigned int getxml_flags = VIR_DOMAIN_XML_SECURE;
unsigned int define_flags = 0;
ret = true;
cleanup:
- virshDomainFree(dom);
return ret;
}
cmdManagedSaveDumpxml(vshControl *ctl, const vshCmd *cmd)
{
bool ret = false;
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
unsigned int flags = 0;
char *xml = NULL;
ret = true;
cleanup:
- virshDomainFree(dom);
VIR_FREE(xml);
return ret;
}
cmdManagedSaveDefine(vshControl *ctl, const vshCmd *cmd)
{
bool ret = false;
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
const char *xmlfile = NULL;
char *xml = NULL;
unsigned int flags = 0;
ret = true;
cleanup:
- virshDomainFree(dom);
VIR_FREE(xml);
return ret;
}
cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
{
char *schedulertype;
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
virTypedParameterPtr params = NULL;
virTypedParameterPtr updates = NULL;
int nparams = 0;
cleanup:
virTypedParamsFree(params, nparams);
virTypedParamsFree(updates, nupdates);
- virshDomainFree(dom);
return ret_val;
}
virshCtrlData *data = opaque;
vshControl *ctl = data->ctl;
const vshCmd *cmd = data->cmd;
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
const char *name = NULL;
const char *to = NULL;
unsigned int flags = 0;
pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL);
out_sig:
#endif /* !WIN32 */
- virshDomainFree(dom);
g_main_loop_quit(data->eventLoop);
}
static bool
cmdDump(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
bool verbose = false;
const char *name = NULL;
const char *to = NULL;
vshPrintExtra(ctl, _("\nDomain '%s' dumped to %s\n"), name, to);
cleanup:
- virshDomainFree(dom);
return !data.ret;
}
static bool
cmdScreenshot(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
const char *name = NULL;
char *file = NULL;
int fd = -1;
unlink(file);
if (generated)
VIR_FREE(file);
- virshDomainFree(dom);
if (st)
virStreamFree(st);
VIR_FORCE_CLOSE(fd);
static bool
cmdSetLifecycleAction(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = true;
bool config = vshCommandOptBool(cmd, "config");
bool live = vshCommandOptBool(cmd, "live");
ret = false;
}
- virshDomainFree(dom);
return ret;
}
static bool
cmdSetUserPassword(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
const char *name;
const char *password = NULL;
const char *user = NULL;
ret = true;
cleanup:
- virshDomainFree(dom);
return ret;
}
/*
static bool
cmdResume(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = true;
const char *name;
ret = false;
}
- virshDomainFree(dom);
return ret;
}
static bool
cmdShutdown(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = false;
const char *name;
const char *mode = NULL;
ret = true;
cleanup:
- virshDomainFree(dom);
g_strfreev(modes);
return ret;
}
static bool
cmdReboot(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = false;
const char *name;
const char *mode = NULL;
ret = true;
cleanup:
- virshDomainFree(dom);
g_strfreev(modes);
return ret;
}
static bool
cmdReset(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = true;
const char *name;
ret = false;
}
- virshDomainFree(dom);
return ret;
}
cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
{
virDomainJobInfo info;
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = false;
const char *unit;
double val;
ret = true;
cleanup:
- virshDomainFree(dom);
virTypedParamsFree(params, nparams);
return ret;
static bool
cmdDomjobabort(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = true;
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
if (virDomainAbortJob(dom) < 0)
ret = false;
- virshDomainFree(dom);
return ret;
}
static bool
cmdVcpucount(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = false;
bool maximum = vshCommandOptBool(cmd, "maximum");
bool active = vshCommandOptBool(cmd, "active");
ret = true;
cleanup:
- virshDomainFree(dom);
return ret;
}
static bool
cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
unsigned int vcpu = 0;
const char *cpulist = NULL;
bool ret = false;
cleanup:
VIR_FREE(cpumap);
- virshDomainFree(dom);
return ret;
}
static bool
cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
const char *cpulist = NULL;
bool ret = false;
unsigned char *cpumap = NULL;
return false;
if (vshCommandOptStringReq(ctl, cmd, "cpulist", &cpulist) < 0) {
- virshDomainFree(dom);
return false;
}
query = !cpulist;
if ((maxcpu = virshNodeGetCPUCount(priv->conn)) < 0) {
- virshDomainFree(dom);
return false;
}
ret = true;
cleanup:
VIR_FREE(cpumap);
- virshDomainFree(dom);
return ret;
}
static bool
cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
unsigned int count = 0;
bool ret = false;
bool maximum = vshCommandOptBool(cmd, "maximum");
ret = true;
cleanup:
- virshDomainFree(dom);
return ret;
}
static bool
cmdGuestvcpus(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
bool enable = vshCommandOptBool(cmd, "enable");
bool disable = vshCommandOptBool(cmd, "disable");
virTypedParameterPtr params = NULL;
cleanup:
virTypedParamsFree(params, nparams);
- virshDomainFree(dom);
return ret;
}
static bool
cmdSetvcpu(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
bool enable = vshCommandOptBool(cmd, "enable");
bool disable = vshCommandOptBool(cmd, "disable");
bool config = vshCommandOptBool(cmd, "config");
ret = true;
cleanup:
- virshDomainFree(dom);
return ret;
}
{
unsigned long long threshold;
const char *dev = NULL;
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = false;
if (vshCommandOptStringReq(ctl, cmd, "dev", &dev))
ret = true;
cleanup:
- virshDomainFree(dom);
return ret;
}
static bool
cmdIOThreadInfo(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
bool config = vshCommandOptBool(cmd, "config");
bool live = vshCommandOptBool(cmd, "live");
bool current = vshCommandOptBool(cmd, "current");
virDomainIOThreadInfoFree(info[i]);
VIR_FREE(info);
vshTableFree(table);
- virshDomainFree(dom);
return ret;
}
static bool
cmdIOThreadPin(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
const char *cpulist = NULL;
bool config = vshCommandOptBool(cmd, "config");
bool live = vshCommandOptBool(cmd, "live");
cleanup:
VIR_FREE(cpumap);
- virshDomainFree(dom);
return ret;
}
static bool
cmdIOThreadAdd(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
int iothread_id = 0;
bool ret = false;
bool config = vshCommandOptBool(cmd, "config");
ret = true;
cleanup:
- virshDomainFree(dom);
return ret;
}
static bool
cmdIOThreadSet(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
int id = 0;
bool ret = false;
bool live = vshCommandOptBool(cmd, "live");
cleanup:
virTypedParamsFree(params, nparams);
- virshDomainFree(dom);
return ret;
save_error:
static bool
cmdIOThreadDel(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
int iothread_id = 0;
bool ret = false;
bool config = vshCommandOptBool(cmd, "config");
ret = true;
cleanup:
- virshDomainFree(dom);
return ret;
}
static bool
cmdCPUStats(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
virTypedParameterPtr params = NULL;
int max_id, cpu = 0, show_count = -1, nparams = 0, stats_per_cpu;
size_t i, j;
cleanup:
virTypedParamsFree(params, nparams);
- virshDomainFree(dom);
return ret;
failed_stats:
static bool
cmdCreate(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
const char *from = NULL;
bool ret = false;
char *buffer;
if (console)
cmdRunConsole(ctl, dom, NULL, 0);
#endif
- virshDomainFree(dom);
ret = true;
cleanup:
static bool
cmdDefine(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
const char *from = NULL;
bool ret = true;
char *buffer;
if (dom != NULL) {
vshPrintExtra(ctl, _("Domain '%s' defined from %s\n"),
virDomainGetName(dom), from);
- virshDomainFree(dom);
} else {
vshError(ctl, _("Failed to define domain from %s"), from);
ret = false;
static bool
cmdDestroy(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = true;
const char *name;
unsigned int flags = 0;
ret = false;
}
- virshDomainFree(dom);
return ret;
}
static bool
cmdDesc(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
bool config = vshCommandOptBool(cmd, "config");
bool live = vshCommandOptBool(cmd, "live");
bool current = vshCommandOptBool(cmd, "current");
unlink(tmp);
VIR_FREE(tmp);
}
- virshDomainFree(dom);
return ret;
}
static bool
cmdMetadata(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
bool config = vshCommandOptBool(cmd, "config");
bool live = vshCommandOptBool(cmd, "live");
bool current = vshCommandOptBool(cmd, "current");
ret = true;
cleanup:
- virshDomainFree(dom);
return ret;
}
static bool
cmdSendKey(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = false;
const char *codeset_option;
int codeset;
ret = true;
cleanup:
- virshDomainFree(dom);
return ret;
}
static bool
cmdSetmem(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
unsigned long long bytes = 0;
unsigned long long max;
unsigned long kibibytes = 0;
ret = true;
cleanup:
- virshDomainFree(dom);
return ret;
}
static bool
cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
unsigned long long bytes = 0;
unsigned long long max;
unsigned long kibibytes = 0;
ret = true;
cleanup:
- virshDomainFree(dom);
return ret;
}
static bool
cmdMemtune(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
long long tmpVal;
int nparams = 0;
int maxparams = 0;
cleanup:
virTypedParamsFree(params, nparams);
- virshDomainFree(dom);
return ret;
save_error:
static bool
cmdPerf(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
int nparams = 0;
int maxparams = 0;
virTypedParameterPtr params = NULL;
ret = true;
cleanup:
virTypedParamsFree(params, nparams);
- virshDomainFree(dom);
return ret;
}
static bool
cmdNumatune(vshControl * ctl, const vshCmd * cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
int nparams = 0;
int maxparams = 0;
size_t i;
cleanup:
virTypedParamsFree(params, nparams);
- virshDomainFree(dom);
return ret;
save_error:
static bool
cmdQemuMonitorEvent(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = false;
unsigned int flags = 0;
int eventId = -1;
if (eventId >= 0 &&
virConnectDomainQemuMonitorEventDeregister(priv->conn, eventId) < 0)
ret = false;
- virshDomainFree(dom);
return ret;
}
static bool
cmdQemuAttach(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
unsigned int flags = 0;
unsigned int pid_value; /* API uses unsigned int, not pid_t */
virshControl *priv = ctl->privData;
vshPrintExtra(ctl, _("Domain '%s' attached to pid %u\n"),
virDomainGetName(dom), pid_value);
- virshDomainFree(dom);
return true;
}
static bool
cmdQemuAgentCommand(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = false;
char *guest_agent_cmd = NULL;
char *result = NULL;
cleanup:
VIR_FREE(result);
VIR_FREE(guest_agent_cmd);
- virshDomainFree(dom);
return ret;
}
static bool
cmdLxcEnterNamespace(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = false;
const vshCmdOpt *opt = NULL;
char **cmdargv = NULL;
cleanup:
VIR_FREE(seclabel);
VIR_FREE(secmodel);
- virshDomainFree(dom);
VIR_FREE(cmdargv);
return ret;
}
static bool
cmdDumpXML(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = true;
char *dump;
unsigned int flags = 0;
ret = false;
}
- virshDomainFree(dom);
return ret;
}
char *xmlData = NULL;
unsigned int flags = 0;
virshControl *priv = ctl->privData;
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
if (vshCommandOptStringReq(ctl, cmd, "format", &format) < 0 ||
vshCommandOptStringReq(ctl, cmd, "xml", &xmlFile) < 0)
}
cleanup:
- virshDomainFree(dom);
VIR_FREE(xmlData);
VIR_FREE(configData);
return ret;
static bool
cmdDomname(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
if (!(dom = virshCommandOptDomainBy(ctl, cmd, NULL,
VIRSH_BYID|VIRSH_BYUUID)))
return false;
vshPrint(ctl, "%s\n", virDomainGetName(dom));
- virshDomainFree(dom);
return true;
}
static bool
cmdDomrename(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
const char *new_name = NULL;
bool ret = false;
ret = true;
cleanup:
- virshDomainFree(dom);
return ret;
}
static bool
cmdDomid(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
unsigned int id;
if (!(dom = virshCommandOptDomainBy(ctl, cmd, NULL,
vshPrint(ctl, "%s\n", "-");
else
vshPrint(ctl, "%d\n", id);
- virshDomainFree(dom);
return true;
}
static bool
cmdDomuuid(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
char uuid[VIR_UUID_STRING_BUFLEN];
if (!(dom = virshCommandOptDomainBy(ctl, cmd, NULL,
else
vshError(ctl, "%s", _("failed to get domain UUID"));
- virshDomainFree(dom);
return true;
}
static void
doMigrate(void *opaque)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
const char *desturi = NULL;
const char *opt = NULL;
unsigned int flags = 0;
data->ret = 0;
} else {
/* For traditional live migration, connect to the destination host directly. */
- virDomainPtr ddom = NULL;
+ g_autoptr(virshDomain) ddom = NULL;
if ((ddom = virDomainMigrate3(dom, dconn, params, nparams, flags))) {
- virshDomainFree(ddom);
data->ret = 0;
}
}
out_sig:
#endif /* !WIN32 */
virTypedParamsFree(params, nparams);
- virshDomainFree(dom);
g_main_loop_quit(data->eventLoop);
return;
static bool
cmdMigrate(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
virThread workerThread;
bool verbose = false;
unsigned int timeout = 0;
virConnectClose(data.dconn);
if (iterEvent != -1)
virConnectDomainEventDeregisterAny(priv->conn, iterEvent);
- virshDomainFree(dom);
return !data.ret;
}
static bool
cmdMigrateSetMaxDowntime(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
unsigned long long downtime = 0;
bool ret = false;
ret = true;
done:
- virshDomainFree(dom);
return ret;
}
static bool
cmdMigrateGetMaxDowntime(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
unsigned long long downtime;
bool ret = false;
ret = true;
done:
- virshDomainFree(dom);
return ret;
}
static bool
cmdMigrateCompCache(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
unsigned long long size = 0;
bool ret = false;
const char *unit;
ret = true;
cleanup:
- virshDomainFree(dom);
return ret;
}
static bool
cmdMigrateSetMaxSpeed(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
unsigned long bandwidth = 0;
unsigned int flags = 0;
bool ret = false;
ret = true;
done:
- virshDomainFree(dom);
return ret;
}
static bool
cmdMigrateGetMaxSpeed(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
unsigned long bandwidth;
unsigned int flags = 0;
bool ret = false;
ret = true;
done:
- virshDomainFree(dom);
return ret;
}
static bool
cmdMigratePostCopy(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = false;
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
ret = true;
cleanup:
- virshDomainFree(dom);
return ret;
}
{
xmlDocPtr xml = NULL;
xmlXPathContextPtr ctxt = NULL;
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
bool ret = false;
char *xpath = NULL;
VIR_FREE(output);
xmlXPathFreeContext(ctxt);
xmlFreeDoc(xml);
- virshDomainFree(dom);
return ret;
}
{
xmlDocPtr xml = NULL;
xmlXPathContextPtr ctxt = NULL;
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = false;
int port = 0;
char *listen_addr = NULL;
VIR_FREE(listen_addr);
xmlXPathFreeContext(ctxt);
xmlFreeDoc(xml);
- virshDomainFree(dom);
return ret;
}
static bool
cmdDetachDeviceAlias(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
const char *alias = NULL;
bool current = vshCommandOptBool(cmd, "current");
bool config = vshCommandOptBool(cmd, "config");
ret = true;
cleanup:
- virshDomainFree(dom);
return ret;
}
static bool
cmdUpdateDevice(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
const char *from = NULL;
char *buffer = NULL;
bool ret = false;
cleanup:
VIR_FREE(buffer);
- virshDomainFree(dom);
return ret;
}
static bool
cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
char *doc_live = NULL, *doc_config = NULL;
const char *mac = NULL, *type = NULL;
int flags = 0;
}
VIR_FREE(doc_live);
VIR_FREE(doc_config);
- virshDomainFree(dom);
return ret;
}
cmdDetachDisk(vshControl *ctl, const vshCmd *cmd)
{
char *disk_xml = NULL;
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
const char *target = NULL;
char *doc = NULL;
int ret;
xmlFreeNode(disk_node);
VIR_FREE(disk_xml);
VIR_FREE(doc);
- virshDomainFree(dom);
return functionReturn;
}
cmdEdit(vshControl *ctl, const vshCmd *cmd)
{
bool ret = false;
- virDomainPtr dom = NULL;
- virDomainPtr dom_edited = NULL;
+ g_autoptr(virshDomain) dom = NULL;
+ g_autoptr(virshDomain) dom_edited = NULL;
unsigned int query_flags = VIR_DOMAIN_XML_SECURE | VIR_DOMAIN_XML_INACTIVE;
unsigned int define_flags = VIR_DOMAIN_DEFINE_VALIDATE;
virshControl *priv = ctl->privData;
ret = true;
cleanup:
- virshDomainFree(dom);
- virshDomainFree(dom_edited);
return ret;
}
static bool
cmdEvent(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = false;
int timeout = 0;
virshDomEventData *data = NULL;
}
VIR_FREE(data);
}
- virshDomainFree(dom);
return ret;
}
static bool
cmdChangeMedia(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
const char *source = NULL;
const char *path = NULL;
char *doc = NULL;
VIR_FREE(doc);
xmlFreeNode(disk_node);
VIR_FREE(disk_xml);
- virshDomainFree(dom);
return ret;
}
static bool
cmdDomFSTrim(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = false;
unsigned long long minimum = 0;
const char *mountPoint = NULL;
ret = true;
cleanup:
- virshDomainFree(dom);
return ret;
}
static bool
cmdDomFSFreeze(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
int ret = -1;
const vshCmdOpt *opt = NULL;
const char **mountpoints = NULL;
cleanup:
VIR_FREE(mountpoints);
- virshDomainFree(dom);
return ret >= 0;
}
static bool
cmdDomFSThaw(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
int ret = -1;
const vshCmdOpt *opt = NULL;
const char **mountpoints = NULL;
cleanup:
VIR_FREE(mountpoints);
- virshDomainFree(dom);
return ret >= 0;
}
static bool
cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
int rc = -1;
size_t i, j;
virDomainFSInfoPtr *info = NULL;
VIR_FREE(info);
}
vshTableFree(table);
- virshDomainFree(dom);
return ret;
}
static bool
cmdGuestAgentTimeout(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
int timeout = VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK;
const unsigned int flags = 0;
bool ret = false;
ret = true;
cleanup:
- virshDomainFree(dom);
return ret;
}
static bool
cmdGuestInfo(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = false;
virTypedParameterPtr params = NULL;
int nparams = 0;
cleanup:
virTypedParamsFree(params, nparams);
- virshDomainFree(dom);
return ret;
}
static bool
cmdGetUserSSHKeys(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
const char *user;
g_auto(GStrv) keys = NULL;
int nkeys = 0;
ret = true;
cleanup:
- virshDomainFree(dom);
return ret;
}
static bool
cmdSetUserSSHKeys(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
const char *user;
const char *from;
g_autofree char *buffer = NULL;
ret = true;
cleanup:
- virshDomainFree(dom);
return ret;
}
static bool
cmdDomDirtyRateCalc(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
int seconds = 1; /* the default value is 1 */
bool ret = false;
ret = true;
cleanup:
- virshDomainFree(dom);
return ret;
}