unsigned int flags, const char *from)
{
bool ret = false;
- virDomainSnapshotPtr snapshot;
+ g_autoptr(virshDomainSnapshot) snapshot = NULL;
bool halt = false;
const char *name = NULL;
ret = true;
cleanup:
- virshDomainSnapshotFree(snapshot);
return ret;
}
static bool
cmdSnapshotCreate(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = false;
const char *from = NULL;
- char *buffer = NULL;
+ g_autofree char *buffer = NULL;
unsigned int flags = 0;
if (vshCommandOptBool(cmd, "redefine"))
ret = virshSnapshotCreate(ctl, dom, buffer, flags, from);
cleanup:
- VIR_FREE(buffer);
- virshDomainFree(dom);
-
return ret;
}
int ret = -1;
const char *snapshot = NULL;
const char *file = NULL;
- char **array = NULL;
+ g_auto(GStrv) array = NULL;
int narray;
size_t i;
cleanup:
if (ret < 0)
vshError(ctl, _("unable to parse memspec: %s"), str);
- g_strfreev(array);
return ret;
}
const char *driver = NULL;
const char *stype = NULL;
const char *file = NULL;
- char **array = NULL;
+ g_auto(GStrv) array = NULL;
int narray;
size_t i;
bool isFile = true;
cleanup:
if (ret < 0)
vshError(ctl, _("unable to parse diskspec: %s"), str);
- g_strfreev(array);
return ret;
}
static bool
cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = false;
- char *buffer = NULL;
+ g_autofree char *buffer = NULL;
const char *name = NULL;
const char *desc = NULL;
const char *memspec = NULL;
ret = virshSnapshotCreate(ctl, dom, buffer, flags, NULL);
cleanup:
- VIR_FREE(buffer);
- virshDomainFree(dom);
-
return ret;
}
static bool
cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
- virDomainSnapshotPtr snapshot = NULL;
- virDomainSnapshotPtr edited = NULL;
+ g_autoptr(virshDomain) dom = NULL;
+ g_autoptr(virshDomainSnapshot) snapshot = NULL;
+ g_autoptr(virshDomainSnapshot) edited = NULL;
const char *name = NULL;
const char *edited_name;
bool ret = false;
cleanup:
if (!ret && name)
vshError(ctl, _("Failed to update %s"), name);
- virshDomainSnapshotFree(edited);
- virshDomainSnapshotFree(snapshot);
- virshDomainFree(dom);
return ret;
}
static bool
cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = false;
int current;
- virDomainSnapshotPtr snapshot = NULL;
- char *xml = NULL;
+ g_autoptr(virshDomainSnapshot) snapshot = NULL;
+ g_autofree char *xml = NULL;
const char *snapshotname = NULL;
unsigned int flags = 0;
const char *domname;
goto cleanup;
if (snapshotname) {
- virDomainSnapshotPtr snapshot2 = NULL;
+ g_autoptr(virshDomainSnapshot) snapshot2 = NULL;
flags = (VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE |
VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT);
if (!(snapshot2 = virDomainSnapshotCreateXML(dom, xml, flags)))
goto cleanup;
- virshDomainSnapshotFree(snapshot2);
vshPrintExtra(ctl, _("Snapshot %s set as current"), snapshotname);
ret = true;
goto cleanup;
cleanup:
if (!ret)
vshReportError(ctl);
- VIR_FREE(xml);
- virshDomainSnapshotFree(snapshot);
- virshDomainFree(dom);
-
return ret;
}
virshGetSnapshotParent(vshControl *ctl, virDomainSnapshotPtr snapshot,
char **parent_name)
{
- virDomainSnapshotPtr parent = NULL;
- char *xml = NULL;
- xmlDocPtr xmldoc = NULL;
- xmlXPathContextPtr ctxt = NULL;
+ g_autoptr(virshDomainSnapshot) parent = NULL;
+ g_autofree char *xml = NULL;
+ g_autoptr(xmlDoc) xmldoc = NULL;
+ g_autoptr(xmlXPathContext) ctxt = NULL;
int ret = -1;
virshControl *priv = ctl->privData;
} else {
vshResetLibvirtError();
}
- virshDomainSnapshotFree(parent);
- xmlXPathFreeContext(ctxt);
- xmlFreeDoc(xmldoc);
- VIR_FREE(xml);
return ret;
}
virshSnapshotFilter(vshControl *ctl, virDomainSnapshotPtr snapshot,
unsigned int flags)
{
- char *xml = NULL;
- xmlDocPtr xmldoc = NULL;
- xmlXPathContextPtr ctxt = NULL;
+ g_autofree char *xml = NULL;
+ g_autoptr(xmlDoc) xmldoc = NULL;
+ g_autoptr(xmlXPathContext) ctxt = NULL;
int ret = -1;
- char *state = NULL;
+ g_autofree char *state = NULL;
if (!snapshot)
return 1;
}
cleanup:
- VIR_FREE(state);
- xmlXPathFreeContext(ctxt);
- xmlFreeDoc(xmldoc);
- VIR_FREE(xml);
return ret;
}
static bool
cmdSnapshotInfo(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom;
- virDomainSnapshotPtr snapshot = NULL;
+ g_autoptr(virshDomain) dom = NULL;
+ g_autoptr(virshDomainSnapshot) snapshot = NULL;
const char *name;
- char *doc = NULL;
- xmlDocPtr xmldoc = NULL;
- xmlXPathContextPtr ctxt = NULL;
- char *state = NULL;
+ g_autofree char *doc = NULL;
+ g_autoptr(xmlDoc) xmldoc = NULL;
+ g_autoptr(xmlXPathContext) ctxt = NULL;
+ g_autofree char *state = NULL;
int external;
- char *parent = NULL;
+ g_autofree char *parent = NULL;
bool ret = false;
int count;
unsigned int flags;
* attempt a fallback. */
current = virDomainSnapshotIsCurrent(snapshot, 0);
if (current < 0) {
- virDomainSnapshotPtr other = virDomainSnapshotCurrent(dom, 0);
+ g_autoptr(virshDomainSnapshot) other = NULL;
vshResetLibvirtError();
current = 0;
if (other) {
if (STREQ(name, virDomainSnapshotGetName(other)))
current = 1;
- virshDomainSnapshotFree(other);
}
}
vshPrint(ctl, "%-15s %s\n", _("Current:"),
ret = true;
cleanup:
- VIR_FREE(state);
- xmlXPathFreeContext(ctxt);
- xmlFreeDoc(xmldoc);
- VIR_FREE(doc);
- VIR_FREE(parent);
- virshDomainSnapshotFree(snapshot);
- virshDomainFree(dom);
return ret;
}
static bool
cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = false;
unsigned int flags = 0;
size_t i;
bool roots = vshCommandOptBool(cmd, "roots");
bool current = vshCommandOptBool(cmd, "current");
const char *from_snap = NULL;
- virDomainSnapshotPtr start = NULL;
+ g_autoptr(virshDomainSnapshot) start = NULL;
struct virshSnapshotList *snaplist = NULL;
- vshTable *table = NULL;
+ g_autoptr(vshTable) table = NULL;
VSH_EXCLUSIVE_OPTIONS_VAR(tree, name);
VSH_EXCLUSIVE_OPTIONS_VAR(parent, roots);
cleanup:
virshSnapshotListFree(snaplist);
- virshDomainSnapshotFree(start);
- virshDomainFree(dom);
- vshTableFree(table);
-
return ret;
}
static bool
cmdSnapshotDumpXML(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = false;
const char *name = NULL;
- virDomainSnapshotPtr snapshot = NULL;
- char *xml = NULL;
+ g_autoptr(virshDomainSnapshot) snapshot = NULL;
+ g_autofree char *xml = NULL;
unsigned int flags = 0;
if (vshCommandOptBool(cmd, "security-info"))
ret = true;
cleanup:
- VIR_FREE(xml);
- virshDomainSnapshotFree(snapshot);
- virshDomainFree(dom);
-
return ret;
}
static bool
cmdSnapshotParent(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = false;
const char *name = NULL;
- virDomainSnapshotPtr snapshot = NULL;
- char *parent = NULL;
+ g_autoptr(virshDomainSnapshot) snapshot = NULL;
+ g_autofree char *parent = NULL;
dom = virshCommandOptDomain(ctl, cmd, NULL);
if (dom == NULL)
ret = true;
cleanup:
- VIR_FREE(parent);
- virshDomainSnapshotFree(snapshot);
- virshDomainFree(dom);
-
return ret;
}
static bool
cmdDomainSnapshotRevert(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = false;
const char *name = NULL;
- virDomainSnapshotPtr snapshot = NULL;
+ g_autoptr(virshDomainSnapshot) snapshot = NULL;
unsigned int flags = 0;
bool force = false;
int result;
ret = true;
cleanup:
- virshDomainSnapshotFree(snapshot);
- virshDomainFree(dom);
return ret;
}
static bool
cmdSnapshotDelete(vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
+ g_autoptr(virshDomain) dom = NULL;
bool ret = false;
const char *name = NULL;
- virDomainSnapshotPtr snapshot = NULL;
+ g_autoptr(virshDomainSnapshot) snapshot = NULL;
unsigned int flags = 0;
dom = virshCommandOptDomain(ctl, cmd, NULL);
ret = true;
cleanup:
- virshDomainSnapshotFree(snapshot);
- virshDomainFree(dom);
return ret;
}