提交 9bcd47cd 编写于 作者: D Daniel P. Berrangé

lxc: replace VIR_FREE with g_autofree / g_free

Reviewed-by: NLaine Stump <laine@redhat.com>
Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 a5a297f3
......@@ -387,16 +387,16 @@ virCgroupPtr virLXCCgroupCreate(virDomainDefPtr def,
int *nicindexes)
{
virCgroupPtr cgroup = NULL;
char *machineName = virLXCDomainGetMachineName(def, 0);
g_autofree char *machineName = virLXCDomainGetMachineName(def, 0);
if (!machineName)
goto cleanup;
return NULL;
if (def->resource->partition[0] != '/') {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Resource partition '%s' must start with '/'"),
def->resource->partition);
goto cleanup;
return NULL;
}
if (virCgroupNewMachine(machineName,
......@@ -410,7 +410,7 @@ virCgroupPtr virLXCCgroupCreate(virDomainDefPtr def,
-1,
0,
&cgroup) < 0)
goto cleanup;
return NULL;
/* setup control group permissions for user namespace */
if (def->idmap.uidmap) {
......@@ -419,14 +419,10 @@ virCgroupPtr virLXCCgroupCreate(virDomainDefPtr def,
def->idmap.gidmap[0].target,
(1 << VIR_CGROUP_CONTROLLER_SYSTEMD)) < 0) {
virCgroupFree(&cgroup);
cgroup = NULL;
goto cleanup;
return NULL;
}
}
cleanup:
VIR_FREE(machineName);
return cgroup;
}
......
......@@ -62,7 +62,7 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver)
virCapsPtr caps;
virCapsGuestPtr guest;
virArch altArch;
char *lxc_path = NULL;
g_autofree char *lxc_path = NULL;
if ((caps = virCapabilitiesNew(virArchFromHost(),
false, false)) == NULL)
......@@ -135,8 +135,6 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver)
goto error;
}
VIR_FREE(lxc_path);
if (driver) {
/* Security driver data */
const char *doi, *model, *label, *type;
......@@ -167,7 +165,6 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver)
return caps;
error:
VIR_FREE(lxc_path);
virObjectUnref(caps);
return NULL;
}
......@@ -290,9 +287,9 @@ virLXCDriverConfigDispose(void *obj)
{
virLXCDriverConfigPtr cfg = obj;
VIR_FREE(cfg->configDir);
VIR_FREE(cfg->autostartDir);
VIR_FREE(cfg->stateDir);
VIR_FREE(cfg->logDir);
VIR_FREE(cfg->securityDriverName);
g_free(cfg->configDir);
g_free(cfg->autostartDir);
g_free(cfg->stateDir);
g_free(cfg->logDir);
g_free(cfg->securityDriverName);
}
此差异已折叠。
......@@ -191,7 +191,7 @@ static virLXCControllerPtr virLXCControllerNew(const char *name)
{
virLXCControllerPtr ctrl = NULL;
virLXCDriverPtr driver = NULL;
char *configFile = NULL;
g_autofree char *configFile = NULL;
if (VIR_ALLOC(ctrl) < 0)
goto error;
......@@ -220,7 +220,6 @@ static virLXCControllerPtr virLXCControllerNew(const char *name)
goto error;
cleanup:
VIR_FREE(configFile);
virLXCControllerDriverFree(driver);
return ctrl;
......@@ -288,22 +287,22 @@ static void virLXCControllerFree(virLXCControllerPtr ctrl)
virObjectUnref(ctrl->securityManager);
for (i = 0; i < ctrl->nveths; i++)
VIR_FREE(ctrl->veths[i]);
VIR_FREE(ctrl->veths);
VIR_FREE(ctrl->nicindexes);
g_free(ctrl->veths[i]);
g_free(ctrl->veths);
g_free(ctrl->nicindexes);
for (i = 0; i < ctrl->npassFDs; i++)
VIR_FORCE_CLOSE(ctrl->passFDs[i]);
VIR_FREE(ctrl->passFDs);
g_free(ctrl->passFDs);
for (i = 0; i < ctrl->nconsoles; i++)
virLXCControllerConsoleClose(&(ctrl->consoles[i]));
VIR_FREE(ctrl->consoles);
g_free(ctrl->consoles);
VIR_FREE(ctrl->devptmx);
g_free(ctrl->devptmx);
virDomainObjEndAPI(&ctrl->vm);
VIR_FREE(ctrl->name);
g_free(ctrl->name);
if (ctrl->timerShutdown != -1)
virEventRemoveTimeout(ctrl->timerShutdown);
......@@ -311,14 +310,14 @@ static void virLXCControllerFree(virLXCControllerPtr ctrl)
virObjectUnref(ctrl->daemon);
virLXCControllerFreeFuse(ctrl);
VIR_FREE(ctrl->nbdpids);
g_free(ctrl->nbdpids);
VIR_FREE(ctrl->nsFDs);
g_free(ctrl->nsFDs);
virCgroupFree(&ctrl->cgroup);
/* This must always be the last thing to be closed */
VIR_FORCE_CLOSE(ctrl->handshakeFd);
VIR_FREE(ctrl);
g_free(ctrl);
}
......@@ -469,7 +468,7 @@ static int virLXCControllerSetupLoopDeviceFS(virDomainFSDefPtr fs)
* the rest of container setup 'just works'
*/
fs->type = VIR_DOMAIN_FS_TYPE_BLOCK;
VIR_FREE(fs->src->path);
g_free(fs->src->path);
fs->src->path = loname;
loname = NULL;
......@@ -480,7 +479,7 @@ static int virLXCControllerSetupLoopDeviceFS(virDomainFSDefPtr fs)
static int virLXCControllerSetupLoopDeviceDisk(virDomainDiskDefPtr disk)
{
int lofd;
char *loname = NULL;
g_autofree char *loname = NULL;
const char *src = virDomainDiskGetSource(disk);
int ret = -1;
......@@ -501,7 +500,6 @@ static int virLXCControllerSetupLoopDeviceDisk(virDomainDiskDefPtr disk)
ret = 0;
cleanup:
VIR_FREE(loname);
if (ret < 0)
VIR_FORCE_CLOSE(lofd);
......@@ -533,7 +531,7 @@ static int virLXCControllerSetupNBDDeviceFS(virDomainFSDefPtr fs)
* the rest of container setup 'just works'
*/
fs->type = VIR_DOMAIN_FS_TYPE_BLOCK;
VIR_FREE(fs->src->path);
g_free(fs->src->path);
fs->src->path = dev;
return 0;
......@@ -542,7 +540,7 @@ static int virLXCControllerSetupNBDDeviceFS(virDomainFSDefPtr fs)
static int virLXCControllerSetupNBDDeviceDisk(virDomainDiskDefPtr disk)
{
char *dev;
g_autofree char *dev = NULL;
const char *src = virDomainDiskGetSource(disk);
int format = virDomainDiskGetFormat(disk);
......@@ -565,11 +563,8 @@ static int virLXCControllerSetupNBDDeviceDisk(virDomainDiskDefPtr disk)
* the rest of container setup 'just works'
*/
virDomainDiskSetType(disk, VIR_STORAGE_TYPE_BLOCK);
if (virDomainDiskSetSource(disk, dev) < 0) {
VIR_FREE(dev);
if (virDomainDiskSetSource(disk, dev) < 0)
return -1;
}
VIR_FREE(dev);
return 0;
}
......@@ -577,16 +572,15 @@ static int virLXCControllerSetupNBDDeviceDisk(virDomainDiskDefPtr disk)
static int virLXCControllerAppendNBDPids(virLXCControllerPtr ctrl,
const char *dev)
{
char *pidpath = NULL;
pid_t *pids = NULL;
g_autofree char *pidpath = NULL;
g_autofree pid_t *pids = NULL;
size_t npids = 0;
size_t i;
int ret = -1;
size_t loops = 0;
pid_t pid;
if (!STRPREFIX(dev, "/dev/"))
goto cleanup;
return -1;
pidpath = g_strdup_printf("/sys/devices/virtual/block/%s/pid", dev + 5);
......@@ -600,27 +594,22 @@ static int virLXCControllerAppendNBDPids(virLXCControllerPtr ctrl,
virReportSystemError(errno,
_("Cannot check NBD device %s pid"),
dev + 5);
goto cleanup;
return -1;
}
}
if (virPidFileReadPath(pidpath, &pid) < 0)
goto cleanup;
return -1;
if (virProcessGetPids(pid, &npids, &pids) < 0)
goto cleanup;
return -1;
for (i = 0; i < npids; i++) {
if (VIR_APPEND_ELEMENT(ctrl->nbdpids, ctrl->nnbdpids, pids[i]) < 0)
goto cleanup;
return -1;
}
ret = 0;
cleanup:
VIR_FREE(pids);
VIR_FREE(pidpath);
return ret;
return 0;
}
static int virLXCControllerSetupLoopDevices(virLXCControllerPtr ctrl)
......@@ -957,7 +946,7 @@ static int virLXCControllerSetupServer(virLXCControllerPtr ctrl)
{
virNetServerPtr srv = NULL;
virNetServerServicePtr svc = NULL;
char *sockpath;
g_autofree char *sockpath = NULL;
sockpath = g_strdup_printf("%s/%s.sock", LXC_STATE_DIR, ctrl->name);
......@@ -1002,11 +991,9 @@ static int virLXCControllerSetupServer(virLXCControllerPtr ctrl)
goto error;
virNetDaemonUpdateServices(ctrl->daemon, true);
VIR_FREE(sockpath);
return 0;
error:
VIR_FREE(sockpath);
virObjectUnref(srv);
virObjectUnref(ctrl->daemon);
ctrl->daemon = NULL;
......@@ -1606,11 +1593,10 @@ virLXCControllerSetupHostdevSubsysUSB(virDomainDefPtr vmDef,
virDomainHostdevDefPtr def,
virSecurityManagerPtr securityDriver)
{
int ret = -1;
char *src = NULL;
char *dstdir = NULL;
char *dstfile = NULL;
char *vroot = NULL;
g_autofree char *src = NULL;
g_autofree char *dstdir = NULL;
g_autofree char *dstfile = NULL;
g_autofree char *vroot = NULL;
struct stat sb;
mode_t mode;
virDomainHostdevSubsysUSBPtr usbsrc = &def->source.subsys.u.usb;
......@@ -1626,14 +1612,14 @@ virLXCControllerSetupHostdevSubsysUSB(virDomainDefPtr vmDef,
if (stat(src, &sb) < 0) {
virReportSystemError(errno,
_("Unable to access %s"), src);
goto cleanup;
return -1;
}
if (!S_ISCHR(sb.st_mode)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("USB source %s was not a character device"),
src);
goto cleanup;
return -1;
}
mode = 0700 | S_IFCHR;
......@@ -1641,7 +1627,7 @@ virLXCControllerSetupHostdevSubsysUSB(virDomainDefPtr vmDef,
if (virFileMakePath(dstdir) < 0) {
virReportSystemError(errno,
_("Unable to create %s"), dstdir);
goto cleanup;
return -1;
}
VIR_DEBUG("Creating dev %s (%d,%d)",
......@@ -1650,24 +1636,17 @@ virLXCControllerSetupHostdevSubsysUSB(virDomainDefPtr vmDef,
virReportSystemError(errno,
_("Unable to create device %s"),
dstfile);
goto cleanup;
return -1;
}
if (lxcContainerChown(vmDef, dstfile) < 0)
goto cleanup;
return -1;
if (virSecurityManagerSetHostdevLabel(securityDriver,
vmDef, def, vroot) < 0)
goto cleanup;
ret = 0;
return -1;
cleanup:
VIR_FREE(src);
VIR_FREE(dstfile);
VIR_FREE(dstdir);
VIR_FREE(vroot);
return ret;
return 0;
}
......@@ -1676,8 +1655,8 @@ virLXCControllerSetupHostdevCapsStorage(virDomainDefPtr vmDef,
virDomainHostdevDefPtr def,
virSecurityManagerPtr securityDriver)
{
char *dst = NULL;
char *path = NULL;
g_autofree char *dst = NULL;
g_autofree char *path = NULL;
int len = 0;
int ret = -1;
struct stat sb;
......@@ -1741,8 +1720,6 @@ virLXCControllerSetupHostdevCapsStorage(virDomainDefPtr vmDef,
cleanup:
def->source.caps.u.storage.block = dev;
VIR_FREE(dst);
VIR_FREE(path);
return ret;
}
......@@ -1752,8 +1729,8 @@ virLXCControllerSetupHostdevCapsMisc(virDomainDefPtr vmDef,
virDomainHostdevDefPtr def,
virSecurityManagerPtr securityDriver)
{
char *dst = NULL;
char *path = NULL;
g_autofree char *dst = NULL;
g_autofree char *path = NULL;
int len = 0;
int ret = -1;
struct stat sb;
......@@ -1817,8 +1794,6 @@ virLXCControllerSetupHostdevCapsMisc(virDomainDefPtr vmDef,
cleanup:
def->source.caps.u.misc.chardev = dev;
VIR_FREE(dst);
VIR_FREE(path);
return ret;
}
......@@ -1910,7 +1885,7 @@ static int virLXCControllerSetupDisk(virLXCControllerPtr ctrl,
virDomainDiskDefPtr def,
virSecurityManagerPtr securityDriver)
{
char *dst = NULL;
g_autofree char *dst = NULL;
int ret = -1;
struct stat sb;
mode_t mode;
......@@ -1979,7 +1954,6 @@ static int virLXCControllerSetupDisk(virLXCControllerPtr ctrl,
cleanup:
def->src->path = tmpsrc;
VIR_FREE(dst);
return ret;
}
......@@ -2125,7 +2099,8 @@ lxcCreateTty(virLXCControllerPtr ctrl, int *ttymaster,
cleanup:
if (ret != 0) {
VIR_FORCE_CLOSE(*ttymaster);
VIR_FREE(*ttyName);
g_free(*ttyName);
*ttyName = NULL;
}
return ret;
......@@ -2233,9 +2208,10 @@ virLXCControllerSetupConsoles(virLXCControllerPtr ctrl,
char **containerTTYPaths)
{
size_t i;
g_autofree char *ttyHostPath = NULL;
for (i = 0; i < ctrl->nconsoles; i++) {
g_autofree char *ttyHostPath = NULL;
VIR_DEBUG("Opening tty on private %s", ctrl->devptmx);
if (lxcCreateTty(ctrl,
&ctrl->consoles[i].contFd,
......@@ -2248,8 +2224,6 @@ virLXCControllerSetupConsoles(virLXCControllerPtr ctrl,
/* Change the owner of tty device to the root user of container */
if (lxcContainerChown(ctrl->def, ttyHostPath) < 0)
return -1;
VIR_FREE(ttyHostPath);
}
return 0;
......@@ -2484,8 +2458,8 @@ virLXCControllerRun(virLXCControllerPtr ctrl)
VIR_FORCE_CLOSE(containerhandshake[1]);
for (i = 0; i < ctrl->nconsoles; i++)
VIR_FREE(containerTTYPaths[i]);
VIR_FREE(containerTTYPaths);
g_free(containerTTYPaths[i]);
g_free(containerTTYPaths);
virLXCControllerStopInit(ctrl);
......@@ -2517,9 +2491,9 @@ int main(int argc, char *argv[])
{ "help", 0, NULL, 'h' },
{ 0, 0, 0, 0 },
};
int *ttyFDs = NULL;
g_autofree int *ttyFDs = NULL;
size_t nttyFDs = 0;
int *passFDs = NULL;
g_autofree int *passFDs = NULL;
size_t npassFDs = 0;
virLXCControllerPtr ctrl = NULL;
size_t i;
......@@ -2760,10 +2734,8 @@ int main(int argc, char *argv[])
virLXCControllerDeleteInterfaces(ctrl);
for (i = 0; i < nttyFDs; i++)
VIR_FORCE_CLOSE(ttyFDs[i]);
VIR_FREE(ttyFDs);
for (i = 0; i < npassFDs; i++)
VIR_FORCE_CLOSE(passFDs[i]);
VIR_FREE(passFDs);
virLXCControllerFree(ctrl);
......
......@@ -159,7 +159,7 @@ virLXCDomainObjPrivateAlloc(void *opaque G_GNUC_UNUSED)
return NULL;
if (virLXCDomainObjInitJob(priv) < 0) {
VIR_FREE(priv);
g_free(priv);
return NULL;
}
......@@ -174,7 +174,7 @@ virLXCDomainObjPrivateFree(void *data)
virCgroupFree(&priv->cgroup);
virLXCDomainObjFreeJob(priv);
VIR_FREE(priv);
g_free(priv);
}
......@@ -200,8 +200,8 @@ lxcDomainDefNamespaceFree(void *nsdata)
size_t i;
lxcDomainDefPtr lxcDef = nsdata;
for (i = 0; i < VIR_LXC_DOMAIN_NAMESPACE_LAST; i++)
VIR_FREE(lxcDef->ns_val[i]);
VIR_FREE(nsdata);
g_free(lxcDef->ns_val[i]);
g_free(nsdata);
}
static int
......@@ -209,12 +209,11 @@ lxcDomainDefNamespaceParse(xmlXPathContextPtr ctxt,
void **data)
{
lxcDomainDefPtr lxcDef = NULL;
xmlNodePtr *nodes = NULL;
g_autofree xmlNodePtr *nodes = NULL;
bool uses_lxc_ns = false;
xmlNodePtr node;
int feature;
int n;
char *tmp = NULL;
size_t i;
if (VIR_ALLOC(lxcDef) < 0)
......@@ -226,6 +225,7 @@ lxcDomainDefNamespaceParse(xmlXPathContextPtr ctxt,
uses_lxc_ns |= n > 0;
for (i = 0; i < n; i++) {
g_autofree char *tmp = NULL;
if ((feature = virLXCDomainNamespaceTypeFromString(
(const char *)nodes[i]->name)) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
......@@ -246,10 +246,8 @@ lxcDomainDefNamespaceParse(xmlXPathContextPtr ctxt,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unknown LXC namespace source '%s'"),
tmp);
VIR_FREE(tmp);
goto error;
}
VIR_FREE(tmp);
if (!(lxcDef->ns_val[feature] =
virXMLPropString(nodes[i], "value"))) {
......@@ -258,15 +256,13 @@ lxcDomainDefNamespaceParse(xmlXPathContextPtr ctxt,
goto error;
}
}
VIR_FREE(nodes);
ctxt->node = node;
if (uses_lxc_ns)
*data = lxcDef;
else
VIR_FREE(lxcDef);
g_free(lxcDef);
return 0;
error:
VIR_FREE(nodes);
lxcDomainDefNamespaceFree(lxcDef);
return -1;
}
......@@ -496,7 +492,9 @@ virLXCDomainSetRunlevel(virDomainObjPtr vm,
lxcDomainInitctlCallback,
&data);
cleanup:
VIR_FREE(data.st);
VIR_FREE(data.st_valid);
g_free(data.st);
data.st = NULL;
g_free(data.st_valid);
data.st_valid = NULL;
return ret;
}
......@@ -1496,7 +1496,8 @@ static int lxcStateInitialize(bool privileged,
return VIR_DRV_STATE_INIT_ERROR;
lxc_driver->lockFD = -1;
if (virMutexInit(&lxc_driver->lock) < 0) {
VIR_FREE(lxc_driver);
g_free(lxc_driver);
lxc_driver = NULL;
return VIR_DRV_STATE_INIT_ERROR;
}
......@@ -1633,7 +1634,8 @@ static int lxcStateCleanup(void)
virObjectUnref(lxc_driver->config);
virMutexDestroy(&lxc_driver->lock);
VIR_FREE(lxc_driver);
g_free(lxc_driver);
lxc_driver = NULL;
return 0;
}
......@@ -2473,7 +2475,8 @@ static int lxcDomainSetAutostart(virDomainPtr dom,
{
virLXCDriverPtr driver = dom->conn->privateData;
virDomainObjPtr vm;
char *configFile = NULL, *autostartLink = NULL;
g_autofree char *configFile = NULL;
g_autofree char *autostartLink = NULL;
int ret = -1;
virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
......@@ -2538,8 +2541,6 @@ static int lxcDomainSetAutostart(virDomainPtr dom,
virLXCDomainObjEndJob(driver, vm);
cleanup:
VIR_FREE(configFile);
VIR_FREE(autostartLink);
virDomainObjEndAPI(&vm);
virObjectUnref(cfg);
return ret;
......@@ -2551,8 +2552,7 @@ static int lxcFreezeContainer(virDomainObjPtr vm)
int check_interval = 1; /* In milliseconds */
int exp = 10;
int waited_time = 0;
int ret = -1;
char *state = NULL;
g_autofree char *state = NULL;
virLXCDomainObjPrivatePtr priv = vm->privateData;
while (waited_time < timeout) {
......@@ -2599,10 +2599,8 @@ static int lxcFreezeContainer(virDomainObjPtr vm)
}
VIR_DEBUG("Read freezer.state: %s", state);
if (STREQ(state, "FROZEN")) {
ret = 0;
goto cleanup;
}
if (STREQ(state, "FROZEN"))
return 0;
waited_time += check_interval;
/*
......@@ -2614,7 +2612,6 @@ static int lxcFreezeContainer(virDomainObjPtr vm)
* In that case, eager polling will just waste CPU time.
*/
check_interval *= exp;
VIR_FREE(state);
}
VIR_DEBUG("lxcFreezeContainer timeout");
error:
......@@ -2624,11 +2621,7 @@ static int lxcFreezeContainer(virDomainObjPtr vm)
* This is likely to fall the group back again gracefully.
*/
virCgroupSetFreezerState(priv->cgroup, "THAWED");
ret = -1;
cleanup:
VIR_FREE(state);
return ret;
return -1;
}
static int lxcDomainSuspend(virDomainPtr dom)
......@@ -3345,7 +3338,7 @@ lxcDomainAttachDeviceDiskLive(virLXCDriverPtr driver,
virDomainDiskDefPtr def = dev->data.disk;
int ret = -1;
struct stat sb;
char *file = NULL;
g_autofree char *file = NULL;
int perms;
const char *src = NULL;
......@@ -3433,7 +3426,6 @@ lxcDomainAttachDeviceDiskLive(virLXCDriverPtr driver,
cleanup:
if (src)
virDomainAuditDisk(vm, NULL, def->src, "attach", ret == 0);
VIR_FREE(file);
return ret;
}
......@@ -3584,7 +3576,7 @@ lxcDomainAttachDeviceHostdevSubsysUSBLive(virLXCDriverPtr driver,
virLXCDomainObjPrivatePtr priv = vm->privateData;
virDomainHostdevDefPtr def = dev->data.hostdev;
int ret = -1;
char *src = NULL;
g_autofree char *src = NULL;
struct stat sb;
virUSBDevicePtr usb = NULL;
virDomainHostdevSubsysUSBPtr usbsrc;
......@@ -3643,7 +3635,6 @@ lxcDomainAttachDeviceHostdevSubsysUSBLive(virLXCDriverPtr driver,
cleanup:
virDomainAuditHostdev(vm, def, "attach", ret == 0);
virUSBDeviceFree(usb);
VIR_FREE(src);
return ret;
}
......@@ -3910,14 +3901,14 @@ lxcDomainDetachDeviceDiskLive(virDomainObjPtr vm,
{
virLXCDomainObjPrivatePtr priv = vm->privateData;
virDomainDiskDefPtr def = NULL;
int idx, ret = -1;
char *dst = NULL;
int idx;
g_autofree char *dst = NULL;
const char *src;
if (!priv->initpid) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("Cannot attach disk until init PID is known"));
goto cleanup;
return -1;
}
if ((idx = virDomainDiskIndexByName(vm->def,
......@@ -3925,7 +3916,7 @@ lxcDomainDetachDeviceDiskLive(virDomainObjPtr vm,
false)) < 0) {
virReportError(VIR_ERR_OPERATION_FAILED,
_("disk %s not found"), dev->data.disk->dst);
goto cleanup;
return -1;
}
def = vm->def->disks[idx];
......@@ -3936,12 +3927,12 @@ lxcDomainDetachDeviceDiskLive(virDomainObjPtr vm,
if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_DEVICES)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("devices cgroup isn't mounted"));
goto cleanup;
return -1;
}
if (lxcDomainAttachDeviceUnlink(vm, dst) < 0) {
virDomainAuditDisk(vm, def->src, NULL, "detach", false);
goto cleanup;
return -1;
}
virDomainAuditDisk(vm, def->src, NULL, "detach", true);
......@@ -3953,11 +3944,7 @@ lxcDomainDetachDeviceDiskLive(virDomainObjPtr vm,
virDomainDiskRemove(vm->def, idx);
virDomainDiskDefFree(def);
ret = 0;
cleanup:
VIR_FREE(dst);
return ret;
return 0;
}
......@@ -4055,7 +4042,7 @@ lxcDomainDetachDeviceHostdevUSBLive(virLXCDriverPtr driver,
virLXCDomainObjPrivatePtr priv = vm->privateData;
virDomainHostdevDefPtr def = NULL;
int idx, ret = -1;
char *dst = NULL;
g_autofree char *dst = NULL;
virUSBDevicePtr usb = NULL;
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
virDomainHostdevSubsysUSBPtr usbsrc;
......@@ -4103,7 +4090,6 @@ lxcDomainDetachDeviceHostdevUSBLive(virLXCDriverPtr driver,
cleanup:
virUSBDeviceFree(usb);
VIR_FREE(dst);
return ret;
}
......@@ -4948,8 +4934,6 @@ lxcDomainGetHostname(virDomainPtr dom,
virDomainObjPtr vm = NULL;
char macaddr[VIR_MAC_STRING_BUFLEN];
g_autoptr(virConnect) conn = NULL;
virNetworkDHCPLeasePtr *leases = NULL;
int n_leases;
size_t i, j;
char *hostname = NULL;
......@@ -4973,6 +4957,8 @@ lxcDomainGetHostname(virDomainPtr dom,
for (i = 0; i < vm->def->nnets; i++) {
g_autoptr(virNetwork) network = NULL;
virDomainNetDefPtr net = vm->def->nets[i];
g_autofree virNetworkDHCPLeasePtr *leases = NULL;
int n_leases;
if (net->type != VIR_DOMAIN_NET_TYPE_NETWORK)
continue;
......@@ -4996,8 +4982,6 @@ lxcDomainGetHostname(virDomainPtr dom,
virNetworkDHCPLeaseFree(lease);
}
VIR_FREE(leases);
if (hostname)
goto endjob;
}
......
......@@ -326,10 +326,10 @@ int lxcSetupFuse(virLXCFusePtr *f, virDomainDefPtr def)
*f = fuse;
return ret;
cleanup1:
VIR_FREE(fuse->mountpoint);
g_free(fuse->mountpoint);
virMutexDestroy(&fuse->lock);
cleanup2:
VIR_FREE(fuse);
g_free(fuse);
goto cleanup;
}
......@@ -356,8 +356,8 @@ void lxcFreeFuse(virLXCFusePtr *f)
fuse_exit(fuse->fuse);
virMutexUnlock(&fuse->lock);
VIR_FREE(fuse->mountpoint);
VIR_FREE(*f);
g_free(fuse->mountpoint);
g_free(*f);
}
}
#else
......
......@@ -143,7 +143,7 @@ virLXCMonitorPtr virLXCMonitorNew(virDomainObjPtr vm,
virLXCMonitorCallbacksPtr cb)
{
virLXCMonitorPtr mon;
char *sockpath = NULL;
g_autofree char *sockpath = NULL;
if (virLXCMonitorInitialize() < 0)
return NULL;
......@@ -180,14 +180,11 @@ virLXCMonitorPtr virLXCMonitorNew(virDomainObjPtr vm,
mon->vm = virObjectRef(vm);
memcpy(&mon->cb, cb, sizeof(mon->cb));
cleanup:
VIR_FREE(sockpath);
return mon;
error:
virObjectUnref(mon);
mon = NULL;
goto cleanup;
return NULL;
}
......
......@@ -93,11 +93,11 @@ lxcFstabFree(lxcFstabPtr fstab)
lxcFstabPtr next = NULL;
next = fstab->next;
VIR_FREE(fstab->src);
VIR_FREE(fstab->dst);
VIR_FREE(fstab->type);
VIR_FREE(fstab->options);
VIR_FREE(fstab);
g_free(fstab->src);
g_free(fstab->dst);
g_free(fstab->type);
g_free(fstab->options);
g_free(fstab);
fstab = next;
}
......@@ -105,7 +105,7 @@ lxcFstabFree(lxcFstabPtr fstab)
static char ** lxcStringSplit(const char *string)
{
char *tmp;
g_autofree char *tmp = NULL;
size_t i;
size_t ntokens = 0;
char **parts;
......@@ -136,12 +136,10 @@ static char ** lxcStringSplit(const char *string)
result[ntokens - 2] = g_strdup(parts[i]);
}
VIR_FREE(tmp);
virStringListFree(parts);
return result;
error:
VIR_FREE(tmp);
virStringListFree(parts);
virStringListFree(result);
return NULL;
......@@ -257,7 +255,7 @@ static int
lxcAddFstabLine(virDomainDefPtr def, lxcFstabPtr fstab)
{
const char *src = NULL;
char *dst = NULL;
g_autofree char *dst = NULL;
char **options = virStringSplit(fstab->options, ",", 0);
bool readonly;
int type = VIR_DOMAIN_FS_TYPE_MOUNT;
......@@ -313,7 +311,6 @@ lxcAddFstabLine(virDomainDefPtr def, lxcFstabPtr fstab)
ret = 1;
cleanup:
VIR_FREE(dst);
virStringListFree(options);
return ret;
}
......@@ -444,8 +441,8 @@ lxcAddNetworkRouteDefinition(const char *address,
size_t *nroutes)
{
virNetDevIPRoutePtr route = NULL;
char *familyStr = NULL;
char *zero = NULL;
g_autofree char *familyStr = NULL;
g_autofree char *zero = NULL;
zero = g_strdup(family == AF_INET ? VIR_SOCKET_ADDR_IPV4_ALL : VIR_SOCKET_ADDR_IPV6_ALL);
......@@ -459,14 +456,9 @@ lxcAddNetworkRouteDefinition(const char *address,
if (VIR_APPEND_ELEMENT(*routes, *nroutes, route) < 0)
goto error;
VIR_FREE(familyStr);
VIR_FREE(zero);
return 0;
error:
VIR_FREE(familyStr);
VIR_FREE(zero);
virNetDevIPRouteFree(route);
return -1;
}
......@@ -499,7 +491,7 @@ lxcAddNetworkDefinition(virDomainDefPtr def, lxcNetworkParseData *data)
/* This still requires the user to manually setup the vlan interface
* on the host */
if (isVlan && data->vlanid) {
VIR_FREE(hostdev->source.caps.u.net.ifname);
g_free(hostdev->source.caps.u.net.ifname);
hostdev->source.caps.u.net.ifname = g_strdup_printf("%s.%s",
data->link,
data->vlanid);
......@@ -553,8 +545,9 @@ lxcAddNetworkDefinition(virDomainDefPtr def, lxcNetworkParseData *data)
error:
for (i = 0; i < data->nips; i++)
VIR_FREE(data->ips[i]);
VIR_FREE(data->ips);
g_free(data->ips[i]);
g_free(data->ips);
data->ips = NULL;
virDomainNetDefFree(net);
virDomainHostdevDefFree(hostdev);
return -1;
......@@ -568,7 +561,7 @@ lxcNetworkParseDataIPs(const char *name,
{
int family = AF_INET;
char **ipparts = NULL;
virNetDevIPAddrPtr ip = NULL;
g_autofree virNetDevIPAddrPtr ip = NULL;
if (VIR_ALLOC(ip) < 0)
return -1;
......@@ -585,16 +578,13 @@ lxcNetworkParseDataIPs(const char *name,
_("Invalid CIDR address: '%s'"), value->str);
virStringListFree(ipparts);
VIR_FREE(ip);
return -1;
}
virStringListFree(ipparts);
if (VIR_APPEND_ELEMENT(parseData->ips, parseData->nips, ip) < 0) {
VIR_FREE(ip);
if (VIR_APPEND_ELEMENT(parseData->ips, parseData->nips, ip) < 0)
return -1;
}
return 0;
}
......@@ -792,16 +782,18 @@ lxcConvertNetworkSettings(virDomainDefPtr def, virConfPtr properties)
cleanup:
for (i = 0; i < networks.ndata; i++)
VIR_FREE(networks.parseData[i]);
VIR_FREE(networks.parseData);
g_free(networks.parseData[i]);
g_free(networks.parseData);
networks.parseData = NULL;
return ret;
error:
for (i = 0; i < networks.ndata; i++) {
lxcNetworkParseDataPtr data = networks.parseData[i];
for (j = 0; j < data->nips; j++)
VIR_FREE(data->ips[j]);
VIR_FREE(data->ips);
g_free(data->ips[j]);
g_free(data->ips);
data->ips = NULL;
}
goto cleanup;
}
......@@ -905,7 +897,8 @@ lxcSetMemTune(virDomainDefPtr def, virConfPtr properties)
size = size / 1024;
virDomainDefSetMemoryTotal(def, size);
def->mem.hard_limit = virMemoryLimitTruncate(size);
VIR_FREE(value);
g_free(value);
value = NULL;
}
if (virConfGetValueString(properties,
......@@ -914,7 +907,8 @@ lxcSetMemTune(virDomainDefPtr def, virConfPtr properties)
if (lxcConvertSize(value, &size) < 0)
return -1;
def->mem.soft_limit = virMemoryLimitTruncate(size / 1024);
VIR_FREE(value);
g_free(value);
value = NULL;
}
if (virConfGetValueString(properties,
......@@ -937,14 +931,16 @@ lxcSetCpuTune(virDomainDefPtr def, virConfPtr properties)
if (virStrToLong_ull(value, NULL, 10, &def->cputune.shares) < 0)
goto error;
def->cputune.sharesSpecified = true;
VIR_FREE(value);
g_free(value);
value = NULL;
}
if (virConfGetValueString(properties, "lxc.cgroup.cpu.cfs_quota_us",
&value) > 0) {
if (virStrToLong_ll(value, NULL, 10, &def->cputune.quota) < 0)
goto error;
VIR_FREE(value);
g_free(value);
value = NULL;
}
if (virConfGetValueString(properties, "lxc.cgroup.cpu.cfs_period_us",
......@@ -972,7 +968,8 @@ lxcSetCpusetTune(virDomainDefPtr def, virConfPtr properties)
if (virBitmapParse(value, &def->cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0)
return -1;
def->placement_mode = VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC;
VIR_FREE(value);
g_free(value);
value = NULL;
}
if (virConfGetValueString(properties, "lxc.cgroup.cpuset.mems",
......@@ -1001,7 +998,7 @@ lxcBlkioDeviceWalkCallback(const char *name, virConfValuePtr value, void *data)
virBlkioDevicePtr device = NULL;
virDomainDefPtr def = data;
size_t i = 0;
char *path = NULL;
g_autofree char *path = NULL;
int ret = -1;
if (!STRPREFIX(name, "lxc.cgroup.blkio.") ||
......@@ -1077,8 +1074,6 @@ lxcBlkioDeviceWalkCallback(const char *name, virConfValuePtr value, void *data)
cleanup:
virStringListFree(parts);
VIR_FREE(path);
return ret;
}
......@@ -1172,7 +1167,8 @@ lxcParseConfigString(const char *config,
else if (arch == VIR_ARCH_NONE && STREQ(value, "amd64"))
arch = VIR_ARCH_X86_64;
vmdef->os.arch = arch;
VIR_FREE(value);
g_free(value);
value = NULL;
}
vmdef->os.init = g_strdup("/sbin/init");
......
......@@ -135,14 +135,13 @@ static void
lxcProcessRemoveDomainStatus(virLXCDriverConfigPtr cfg,
virDomainObjPtr vm)
{
char *file = NULL;
file = g_strdup_printf("%s/%s.xml", cfg->stateDir, vm->def->name);
g_autofree char *file = g_strdup_printf("%s/%s.xml",
cfg->stateDir,
vm->def->name);
if (unlink(file) < 0 && errno != ENOENT && errno != ENOTDIR)
VIR_WARN("Failed to remove domain XML for %s: %s",
vm->def->name, g_strerror(errno));
VIR_FREE(file);
}
......@@ -170,13 +169,12 @@ static void virLXCProcessCleanup(virLXCDriverPtr driver,
/* now that we know it's stopped call the hook if present */
if (virHookPresent(VIR_HOOK_DRIVER_LXC)) {
char *xml = virDomainDefFormat(vm->def, driver->xmlopt, 0);
g_autofree char *xml = virDomainDefFormat(vm->def, driver->xmlopt, 0);
/* we can't stop the operation even if the script raised an error */
virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name,
VIR_HOOK_LXC_OP_STOPPED, VIR_HOOK_SUBOP_END,
NULL, xml, NULL);
VIR_FREE(xml);
}
virSecurityManagerRestoreAllLabel(driver->securityManager,
......@@ -185,9 +183,12 @@ static void virLXCProcessCleanup(virLXCDriverPtr driver,
/* Clear out dynamically assigned labels */
if (vm->def->nseclabels &&
vm->def->seclabels[0]->type == VIR_DOMAIN_SECLABEL_DYNAMIC) {
VIR_FREE(vm->def->seclabels[0]->model);
VIR_FREE(vm->def->seclabels[0]->label);
VIR_FREE(vm->def->seclabels[0]->imagelabel);
g_free(vm->def->seclabels[0]->model);
g_free(vm->def->seclabels[0]->label);
g_free(vm->def->seclabels[0]->imagelabel);
vm->def->seclabels[0]->model = NULL;
vm->def->seclabels[0]->label = NULL;
vm->def->seclabels[0]->imagelabel = NULL;
}
/* Stop autodestroy in case guest is restarted */
......@@ -243,17 +244,17 @@ static void virLXCProcessCleanup(virLXCDriverPtr driver,
* the bug we are working around here.
*/
virCgroupTerminateMachine(priv->machineName);
VIR_FREE(priv->machineName);
g_free(priv->machineName);
priv->machineName = NULL;
/* The "release" hook cleans up additional resources */
if (virHookPresent(VIR_HOOK_DRIVER_LXC)) {
char *xml = virDomainDefFormat(vm->def, driver->xmlopt, 0);
g_autofree char *xml = virDomainDefFormat(vm->def, driver->xmlopt, 0);
/* we can't stop the operation even if the script raised an error */
virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name,
VIR_HOOK_LXC_OP_RELEASE, VIR_HOOK_SUBOP_END,
NULL, xml, NULL);
VIR_FREE(xml);
}
virDomainObjRemoveTransientDef(vm);
......@@ -442,12 +443,9 @@ static int virLXCProcessSetupNamespaceName(virLXCDriverPtr driver,
static int virLXCProcessSetupNamespacePID(int ns_type, const char *name)
{
int fd;
char *path;
path = g_strdup_printf("/proc/%s/ns/%s", name, nsInfoLocal[ns_type]);
fd = open(path, O_RDONLY);
VIR_FREE(path);
g_autofree char *path = g_strdup_printf("/proc/%s/ns/%s",
name, nsInfoLocal[ns_type]);
int fd = open(path, O_RDONLY);
if (fd < 0) {
virReportSystemError(errno,
_("failed to open ns %s"),
......@@ -460,7 +458,7 @@ static int virLXCProcessSetupNamespacePID(int ns_type, const char *name)
static int virLXCProcessSetupNamespaceNet(int ns_type, const char *name)
{
char *path;
g_autofree char *path = NULL;
int fd;
if (ns_type != VIR_LXC_DOMAIN_NAMESPACE_SHARENET) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
......@@ -471,7 +469,6 @@ static int virLXCProcessSetupNamespaceNet(int ns_type, const char *name)
path = g_strdup_printf("%s/netns/%s", RUNSTATEDIR, name);
fd = open(path, O_RDONLY);
VIR_FREE(path);
if (fd < 0) {
virReportSystemError(errno,
_("failed to open netns %s"), name);
......@@ -669,7 +666,8 @@ virLXCProcessCleanInterfaces(virDomainDefPtr def)
size_t i;
for (i = 0; i < def->nnets; i++) {
VIR_FREE(def->nets[i]->ifname_guest_actual);
g_free(def->nets[i]->ifname_guest_actual);
def->nets[i]->ifname_guest_actual = NULL;
VIR_DEBUG("Cleared net names: %s", def->nets[i]->ifname_guest);
}
}
......@@ -757,24 +755,20 @@ virLXCProcessGetNsInode(pid_t pid,
const char *nsname,
ino_t *inode)
{
char *path = NULL;
g_autofree char *path = NULL;
struct stat sb;
int ret = -1;
path = g_strdup_printf("/proc/%lld/ns/%s", (long long)pid, nsname);
if (stat(path, &sb) < 0) {
virReportSystemError(errno,
_("Unable to stat %s"), path);
goto cleanup;
return -1;
}
*inode = sb.st_ino;
ret = 0;
cleanup:
VIR_FREE(path);
return ret;
return 0;
}
......@@ -929,8 +923,8 @@ virLXCProcessBuildControllerCmd(virLXCDriverPtr driver,
const char *pidfile)
{
size_t i;
char *filterstr;
char *outputstr;
g_autofree char *filterstr = NULL;
g_autofree char *outputstr = NULL;
virCommandPtr cmd;
virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
......@@ -950,7 +944,6 @@ virLXCProcessBuildControllerCmd(virLXCDriverPtr driver,
}
virCommandAddEnvPair(cmd, "LIBVIRT_LOG_FILTERS", filterstr);
VIR_FREE(filterstr);
}
if (cfg->log_libvirtd) {
......@@ -962,7 +955,6 @@ virLXCProcessBuildControllerCmd(virLXCDriverPtr driver,
}
virCommandAddEnvPair(cmd, "LIBVIRT_LOG_OUTPUTS", outputstr);
VIR_FREE(outputstr);
}
} else {
virCommandAddEnvFormat(cmd,
......@@ -985,12 +977,11 @@ virLXCProcessBuildControllerCmd(virLXCDriverPtr driver,
for (i = 0; i < VIR_LXC_DOMAIN_NAMESPACE_LAST; i++) {
if (nsInheritFDs[i] > 0) {
char *tmp = NULL;
tmp = g_strdup_printf("--share-%s", nsInfoLocal[i]);
g_autofree char *tmp = g_strdup_printf("--share-%s",
nsInfoLocal[i]);
virCommandAddArg(cmd, tmp);
virCommandAddArgFormat(cmd, "%d", nsInheritFDs[i]);
virCommandPassFD(cmd, nsInheritFDs[i], 0);
VIR_FREE(tmp);
}
}
......@@ -1188,15 +1179,15 @@ int virLXCProcessStart(virConnectPtr conn,
{
int rc = -1, r;
size_t nttyFDs = 0;
int *ttyFDs = NULL;
g_autofree int *ttyFDs = NULL;
size_t i;
char *logfile = NULL;
g_autofree char *logfile = NULL;
int logfd = -1;
VIR_AUTOSTRINGLIST veths = NULL;
int handshakefds[2] = { -1, -1 };
off_t pos = -1;
char ebuf[1024];
char *timestamp;
g_autofree char *timestamp = NULL;
int nsInheritFDs[VIR_LXC_DOMAIN_NAMESPACE_LAST];
virCommandPtr cmd = NULL;
virLXCDomainObjPrivatePtr priv = vm->privateData;
......@@ -1205,7 +1196,7 @@ int virLXCProcessStart(virConnectPtr conn,
virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
virCgroupPtr selfcgroup;
int status;
char *pidfile = NULL;
g_autofree char *pidfile = NULL;
if (virCgroupNewSelf(&selfcgroup) < 0)
return -1;
......@@ -1283,18 +1274,14 @@ int virLXCProcessStart(virConnectPtr conn,
/* Run an early hook to set-up missing devices */
if (virHookPresent(VIR_HOOK_DRIVER_LXC)) {
char *xml = virDomainDefFormat(vm->def, driver->xmlopt, 0);
int hookret;
hookret = virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name,
VIR_HOOK_LXC_OP_PREPARE, VIR_HOOK_SUBOP_BEGIN,
NULL, xml, NULL);
VIR_FREE(xml);
g_autofree char *xml = virDomainDefFormat(vm->def, driver->xmlopt, 0);
/*
* If the script raised an error abort the launch
*/
if (hookret < 0)
if (virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name,
VIR_HOOK_LXC_OP_PREPARE, VIR_HOOK_SUBOP_BEGIN,
NULL, xml, NULL) < 0)
goto cleanup;
}
......@@ -1348,10 +1335,10 @@ int virLXCProcessStart(virConnectPtr conn,
goto cleanup;
}
VIR_FREE(vm->def->consoles[i]->source->data.file.path);
g_free(vm->def->consoles[i]->source->data.file.path);
vm->def->consoles[i]->source->data.file.path = ttyPath;
VIR_FREE(vm->def->consoles[i]->info.alias);
g_free(vm->def->consoles[i]->info.alias);
vm->def->consoles[i]->info.alias = g_strdup_printf("console%zu", i);
}
......@@ -1388,18 +1375,14 @@ int virLXCProcessStart(virConnectPtr conn,
/* now that we know it is about to start call the hook if present */
if (virHookPresent(VIR_HOOK_DRIVER_LXC)) {
char *xml = virDomainDefFormat(vm->def, driver->xmlopt, 0);
int hookret;
hookret = virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name,
VIR_HOOK_LXC_OP_START, VIR_HOOK_SUBOP_BEGIN,
NULL, xml, NULL);
VIR_FREE(xml);
g_autofree char *xml = virDomainDefFormat(vm->def, driver->xmlopt, 0);
/*
* If the script raised an error abort the launch
*/
if (hookret < 0)
if (virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name,
VIR_HOOK_LXC_OP_START, VIR_HOOK_SUBOP_BEGIN,
NULL, xml, NULL) < 0)
goto cleanup;
}
......@@ -1411,7 +1394,6 @@ int virLXCProcessStart(virConnectPtr conn,
VIR_WARN("Unable to write timestamp to logfile: %s",
g_strerror(errno));
}
VIR_FREE(timestamp);
/* Log generated command line */
virCommandWriteArgLog(cmd, logfd);
......@@ -1530,18 +1512,14 @@ int virLXCProcessStart(virConnectPtr conn,
/* finally we can call the 'started' hook script if any */
if (virHookPresent(VIR_HOOK_DRIVER_LXC)) {
char *xml = virDomainDefFormat(vm->def, driver->xmlopt, 0);
int hookret;
hookret = virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name,
VIR_HOOK_LXC_OP_STARTED, VIR_HOOK_SUBOP_BEGIN,
NULL, xml, NULL);
VIR_FREE(xml);
g_autofree char *xml = virDomainDefFormat(vm->def, driver->xmlopt, 0);
/*
* If the script raised an error abort the launch
*/
if (hookret < 0)
if (virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name,
VIR_HOOK_LXC_OP_STARTED, VIR_HOOK_SUBOP_BEGIN,
NULL, xml, NULL) < 0)
goto cleanup;
}
......@@ -1559,11 +1537,8 @@ int virLXCProcessStart(virConnectPtr conn,
virCommandFree(cmd);
for (i = 0; i < nttyFDs; i++)
VIR_FORCE_CLOSE(ttyFDs[i]);
VIR_FREE(ttyFDs);
VIR_FORCE_CLOSE(handshakefds[0]);
VIR_FORCE_CLOSE(handshakefds[1]);
VIR_FREE(pidfile);
VIR_FREE(logfile);
virObjectUnref(cfg);
virObjectUnref(caps);
......@@ -1710,15 +1685,12 @@ virLXCProcessReconnectDomain(virDomainObjPtr vm,
/* now that we know it's reconnected call the hook if present */
if (virHookPresent(VIR_HOOK_DRIVER_LXC)) {
char *xml = virDomainDefFormat(vm->def, driver->xmlopt, 0);
int hookret;
g_autofree char *xml = virDomainDefFormat(vm->def, driver->xmlopt, 0);
/* we can't stop the operation even if the script raised an error */
hookret = virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name,
VIR_HOOK_LXC_OP_RECONNECT, VIR_HOOK_SUBOP_BEGIN,
NULL, xml, NULL);
VIR_FREE(xml);
if (hookret < 0)
if (virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name,
VIR_HOOK_LXC_OP_RECONNECT, VIR_HOOK_SUBOP_BEGIN,
NULL, xml, NULL) < 0)
goto error;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册