#include "virfile.h"
#include "virerror.h"
#include "virlog.h"
-#include "viralloc.h"
#include "virstring.h"
#include "virsystemd.h"
#include "virutil.h"
#include "lxc_domain.h"
#include "virerror.h"
#include "virconf.h"
-#include "viralloc.h"
#include "virlog.h"
#include "viruuid.h"
#include "configmake.h"
VIR_DOMAIN_VIRT_LXC);
type = virDomainVirtTypeToString(VIR_DOMAIN_VIRT_LXC);
/* Allocate the primary security driver for LXC. */
- if (VIR_ALLOC(caps->host.secModels) < 0)
- goto error;
+ caps->host.secModels = g_new0(virCapsHostSecModel, 1);
caps->host.nsecModels = 1;
caps->host.secModels[0].model = g_strdup(model);
caps->host.secModels[0].doi = g_strdup(doi);
}
cmd = v ? LINUX_REBOOT_CMD_CAD_ON : LINUX_REBOOT_CMD_CAD_OFF;
- if (VIR_ALLOC_N(stack, stacksize) < 0)
- return -1;
+ stack = g_new0(char, stacksize);
childStack = stack + stacksize;
};
/* allocate a stack for the container */
- if (VIR_ALLOC_N(stack, stacksize) < 0)
- return -1;
+ stack = g_new0(char, stacksize);
stacktop = stack + stacksize;
static virLXCControllerPtr virLXCControllerNew(const char *name)
{
- virLXCControllerPtr ctrl = NULL;
+ virLXCControllerPtr ctrl = g_new0(virLXCController, 1);
virLXCDriverPtr driver = NULL;
g_autofree char *configFile = NULL;
- if (VIR_ALLOC(ctrl) < 0)
- goto error;
-
ctrl->timerShutdown = -1;
ctrl->firstClient = true;
int rc = -1;
int control[2] = { -1, -1};
int containerhandshake[2] = { -1, -1 };
- char **containerTTYPaths = NULL;
+ char **containerTTYPaths = g_new0(char *, ctrl->nconsoles);
size_t i;
- if (VIR_ALLOC_N(containerTTYPaths, ctrl->nconsoles) < 0)
- goto cleanup;
-
if (socketpair(PF_UNIX, SOCK_STREAM, 0, control) < 0) {
virReportSystemError(errno, "%s",
_("sockpair failed"));
break;
case 'v':
- if (VIR_REALLOC_N(veths, nveths+1) < 0)
- goto cleanup;
+ veths = g_renew(char *, veths, nveths+1);
veths[nveths++] = g_strdup(optarg);
break;
case 'c':
- if (VIR_REALLOC_N(ttyFDs, nttyFDs + 1) < 0)
- goto cleanup;
+ ttyFDs = g_renew(int, ttyFDs, nttyFDs + 1);
if (virStrToLong_i(optarg, NULL, 10, &ttyFDs[nttyFDs++]) < 0) {
fprintf(stderr, "malformed --console argument '%s'", optarg);
goto cleanup;
break;
case 'p':
- if (VIR_REALLOC_N(passFDs, npassFDs + 1) < 0)
- goto cleanup;
+ passFDs = g_renew(int, passFDs, npassFDs + 1);
if (virStrToLong_i(optarg, NULL, 10, &passFDs[npassFDs++]) < 0) {
fprintf(stderr, "malformed --passfd argument '%s'", optarg);
goto cleanup;
if (ns_fd[i] != -1) {
if (!ctrl->nsFDs) {/*allocate only once */
size_t j = 0;
- if (VIR_ALLOC_N(ctrl->nsFDs, VIR_LXC_DOMAIN_NAMESPACE_LAST) < 0)
- goto cleanup;
+ ctrl->nsFDs = g_new0(int, VIR_LXC_DOMAIN_NAMESPACE_LAST);
for (j = 0; j < VIR_LXC_DOMAIN_NAMESPACE_LAST; j++)
ctrl->nsFDs[j] = -1;
}
#include "lxc_domain.h"
-#include "viralloc.h"
#include "virlog.h"
#include "virerror.h"
#include "virstring.h"
static void *
virLXCDomainObjPrivateAlloc(void *opaque G_GNUC_UNUSED)
{
- virLXCDomainObjPrivatePtr priv;
-
- if (VIR_ALLOC(priv) < 0)
- return NULL;
+ virLXCDomainObjPrivatePtr priv = g_new0(virLXCDomainObjPrivate, 1);
if (virLXCDomainObjInitJob(priv) < 0) {
g_free(priv);
lxcDomainDefNamespaceParse(xmlXPathContextPtr ctxt,
void **data)
{
- lxcDomainDefPtr lxcDef = NULL;
+ lxcDomainDefPtr lxcDef = g_new0(lxcDomainDef, 1);
g_autofree xmlNodePtr *nodes = NULL;
bool uses_lxc_ns = false;
xmlNodePtr node;
int n;
size_t i;
- if (VIR_ALLOC(lxcDef) < 0)
- return -1;
-
node = ctxt->node;
if ((n = virXPathNodeSet("./lxc:namespace/*", ctxt, &nodes)) < 0)
goto error;
for (nfifos = 0; virInitctlFifos[nfifos]; nfifos++)
;
- if (VIR_ALLOC_N(data.st, nfifos) < 0 ||
- VIR_ALLOC_N(data.st_valid, nfifos) < 0)
- goto cleanup;
+ data.st = g_new0(struct stat, nfifos);
+ data.st_valid = g_new0(bool, nfifos);
for (i = 0; virInitctlFifos[i]; i++) {
const char *fifo = virInitctlFifos[i];
#include "lxc_driver.h"
#include "lxc_native.h"
#include "lxc_process.h"
-#include "viralloc.h"
#include "virnetdevbridge.h"
#include "virnetdevveth.h"
#include "virnetdevopenvswitch.h"
return VIR_DRV_STATE_INIT_SKIPPED;
}
- if (VIR_ALLOC(lxc_driver) < 0)
- return VIR_DRV_STATE_INIT_ERROR;
+ lxc_driver = g_new0(virLXCDriver, 1);
lxc_driver->lockFD = -1;
if (virMutexInit(&lxc_driver->lock) < 0) {
g_free(lxc_driver);
perms) < 0)
goto cleanup;
- if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks + 1) < 0)
- goto cleanup;
+ vm->def->disks = g_renew(virDomainDiskDefPtr,
+ vm->def->disks,
+ vm->def->ndisks + 1);
file = g_strdup_printf("/dev/%s", def->dst);
return -1;
/* preallocate new slot for device */
- if (VIR_REALLOC_N(vm->def->nets, vm->def->nnets+1) < 0)
- return -1;
+ vm->def->nets = g_renew(virDomainNetDefPtr,
+ vm->def->nets,
+ vm->def->nnets + 1);
/* If appropriate, grab a physical device from the configured
* network's pool of devices, or resolve bridge device name
goto cleanup;
}
- if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0)
- goto cleanup;
+ vm->def->hostdevs = g_renew(virDomainHostdevDefPtr,
+ vm->def->hostdevs,
+ vm->def->nhostdevs + 1);
if (virUSBDeviceFileIterate(usb,
virLXCSetupHostUSBDeviceCgroup,
goto cleanup;
}
- if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs+1) < 0)
- goto cleanup;
+ vm->def->hostdevs = g_renew(virDomainHostdevDefPtr,
+ vm->def->hostdevs,
+ vm->def->nhostdevs + 1);
if (virCgroupAllowDevice(priv->cgroup,
'b',
VIR_CGROUP_DEVICE_RWM) < 0)
goto cleanup;
- if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs+1) < 0)
- goto cleanup;
+ vm->def->hostdevs = g_renew(virDomainHostdevDefPtr,
+ vm->def->hostdevs,
+ vm->def->nhostdevs + 1);
if (lxcDomainAttachDeviceMknod(driver,
0700 | S_IFBLK,
#include "virfile.h"
#include "virbuffer.h"
#include "virstring.h"
-#include "viralloc.h"
#include "virutil.h"
#define VIR_FROM_THIS VIR_FROM_LXC
{
int ret = -1;
struct fuse_args args = FUSE_ARGS_INIT(0, NULL);
- virLXCFusePtr fuse = NULL;
-
- if (VIR_ALLOC(fuse) < 0)
- goto cleanup;
+ virLXCFusePtr fuse = g_new0(virLXCFuse, 1);
fuse->def = def;
struct fuse_chan *ch;
virMutex lock;
};
+typedef struct virLXCFuse virLXCFuse;
typedef struct virLXCFuse *virLXCFusePtr;
int lxcSetupFuse(virLXCFusePtr *f, virDomainDefPtr def);
#include <config.h>
#include "lxc_hostdev.h"
-#include "viralloc.h"
#include "virlog.h"
#include "virerror.h"
#include "virhostdev.h"
#include "lxc_conf.h"
#include "lxc_monitor_dispatch.h"
-#include "viralloc.h"
-
#include "virerror.h"
#include "virlog.h"
#include "virthread.h"
lxcFstabPtr fstab = NULL;
char **parts;
- if (!fstabLine || VIR_ALLOC(fstab) < 0)
+ if (!fstabLine)
return NULL;
+ fstab = g_new0(lxcFstab, 1);
if (!(parts = lxcStringSplit(fstabLine)))
goto error;
{
int family = AF_INET;
char **ipparts = NULL;
- g_autofree virNetDevIPAddrPtr ip = NULL;
-
- if (VIR_ALLOC(ip) < 0)
- return -1;
+ g_autofree virNetDevIPAddrPtr ip = g_new0(virNetDevIPAddr, 1);
if (STREQ(name, "ipv6") || STREQ(name, "ipv6.address"))
family = AF_INET6;
return -1;
}
- if (VIR_ALLOC_N(def->consoles, nbttys) < 0)
- return -1;
+ def->consoles = g_new0(virDomainChrDefPtr, nbttys);
def->nconsoles = nbttys;
for (i = 0; i < nbttys; i++) {
virConnectPtr netconn = NULL;
virErrorPtr save_err = NULL;
- if (VIR_ALLOC_N(*veths, def->nnets + 1) < 0)
- return -1;
+ *veths = g_new0(char *, def->nnets + 1);
for (i = 0; i < def->nnets; i++) {
char *veth = NULL;
}
if (!vm->def->resource) {
- virDomainResourceDefPtr res;
-
- if (VIR_ALLOC(res) < 0)
- goto cleanup;
+ virDomainResourceDefPtr res = g_new0(virDomainResourceDef, 1);
res->partition = g_strdup("/machine");
* and forward I/O between them.
*/
nttyFDs = vm->def->nconsoles;
- if (VIR_ALLOC_N(ttyFDs, nttyFDs) < 0)
- goto cleanup;
+ ttyFDs = g_new0(int, nttyFDs);
for (i = 0; i < vm->def->nconsoles; i++)
ttyFDs[i] = -1;