}
}
- if (VIR_ALLOC_N(cpus, nr_nodes) < 0)
- goto cleanup;
+ cpus = g_new0(virCapsHostNUMACellCPUPtr, nr_nodes);
- if (VIR_ALLOC_N(nr_cpus_node, nr_nodes) < 0)
- goto cleanup;
+ nr_cpus_node = g_new0(int, nr_nodes);
/* For each node, prepare a list of CPUs belonging to that node */
for (i = 0; i < nr_cpus; i++) {
nr_cpus_node[node]++;
if (nr_cpus_node[node] == 1) {
- if (VIR_ALLOC(cpus[node]) < 0)
+ cpus[node] = g_new0(virCapsHostNUMACellCPU, 1);
goto cleanup;
} else {
if (VIR_REALLOC_N(cpus[node], nr_cpus_node[node]) < 0)
if (nr_siblings) {
size_t j;
- if (VIR_ALLOC_N(siblings, nr_siblings) < 0)
+ siblings = g_new0(virCapsHostNUMACellSiblingInfo, nr_siblings);
goto cleanup;
for (j = 0; j < nr_siblings; j++) {
return 0;
capsLoader->supported = VIR_TRISTATE_BOOL_YES;
- if (VIR_ALLOC_N(capsLoader->values.values, nfirmwares) < 0)
- return -1;
+ capsLoader->values.values = g_new0(char *, nfirmwares);
for (i = 0; i < nfirmwares; i++) {
capsLoader->values.values[capsLoader->values.nvalues] = g_strdup(firmwares[i]->name);
return -1;
} else {
#ifdef LIBXL_HAVE_BUILDINFO_SERIAL_LIST
- if (VIR_ALLOC_N(b_info->u.hvm.serial_list, def->nserials + 1) <
- 0)
- return -1;
+ b_info->u.hvm.serial_list = *g_new0(libxl_string_list, def->nserials + 1);
for (i = 0; i < def->nserials; i++) {
if (libxlMakeChrdevStr(def->serials[i],
&b_info->u.hvm.serial_list[i]) < 0)
/*
* allocate the vnuma_nodes for assignment under b_info.
*/
- if (VIR_ALLOC_N(vnuma_nodes, num_vnuma) < 0)
- return -1;
+ vnuma_nodes = g_new0(libxl_vnode_info, num_vnuma);
/*
* parse the vnuma vnodes data.
libxl_bitmap_dispose(&vcpu_bitmap);
/* vdistances */
- if (VIR_ALLOC_N(p->distances, num_vnuma) < 0)
- goto cleanup;
+ p->distances = g_new0(uint32_t, num_vnuma);
p->num_distances = num_vnuma;
for (j = 0; j < num_vnuma; j++)
libxl_device_disk *x_disks;
size_t i;
- if (VIR_ALLOC_N(x_disks, ndisks) < 0)
- return -1;
+ x_disks = g_new0(libxl_device_disk, ndisks);
for (i = 0; i < ndisks; i++) {
if (libxlMakeDisk(l_disks[i], &x_disks[i]) < 0)
libxl_device_nic *x_nics;
size_t i, nvnics = 0;
- if (VIR_ALLOC_N(x_nics, nnics) < 0)
- return -1;
+ x_nics = g_new0(libxl_device_nic, nnics);
for (i = 0; i < nnics; i++) {
if (virDomainNetGetActualType(l_nics[i]) == VIR_DOMAIN_NET_TYPE_HOSTDEV)
if (nvfbs == 0)
return 0;
- if (VIR_ALLOC_N(x_vfbs, nvfbs) < 0)
- return -1;
- if (VIR_ALLOC_N(x_vkbs, nvfbs) < 0) {
- VIR_FREE(x_vfbs);
- return -1;
- }
+ x_vfbs = g_new0(libxl_device_vfb, nvfbs);
+ x_vkbs = g_new0(libxl_device_vkb, nvfbs);
for (i = 0; i < nvfbs; i++) {
libxl_device_vkb_init(&x_vkbs[i]);
goto error;
#else
- if (VIR_ALLOC_N(cfg->firmwares, 1) < 0)
- goto error;
+ cfg->firmwares = g_new0(virFirmwarePtr, 1);
cfg->nfirmwares = 1;
- if (VIR_ALLOC(cfg->firmwares[0]) < 0)
- goto error;
+ cfg->firmwares[0] = g_new0(virFirmware, 1);
cfg->firmwares[0]->name = g_strdup(LIBXL_FIRMWARE_DIR "/ovmf.bin");
#endif
if (VIR_REALLOC_N(cfg->firmwares, cfg->nfirmwares + 1) < 0)
goto error;
cfg->nfirmwares++;
- if (VIR_ALLOC(cfg->firmwares[cfg->nfirmwares - 1]) < 0)
- goto error;
+ cfg->firmwares[cfg->nfirmwares - 1] = g_new0(virFirmware, 1);
cfg->firmwares[cfg->nfirmwares - 1]->name = g_strdup(LIBXL_FIRMWARE_DIR "/hvmloader");
/* defaults for keepalive messages */
libxl_device_channel *x_channels;
size_t i, nvchannels = 0;
- if (VIR_ALLOC_N(x_channels, nchannels) < 0)
- return -1;
+ x_channels = g_new0(libxl_device_channel, nchannels);
for (i = 0; i < nchannels; i++) {
if (l_channels[i]->deviceType != VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL)
/* Create USB controllers with 8 ports */
ncontrollers = VIR_DIV_UP(nusbdevs, 8);
- if (VIR_ALLOC_N(x_controllers, ncontrollers) < 0)
- return -1;
+ x_controllers = g_new0(libxl_device_usbctrl, ncontrollers);
for (i = 0; i < ncontrollers; i++) {
if (!(l_controller = virDomainControllerDefNew(VIR_DOMAIN_CONTROLLER_TYPE_USB)))
if (nusbctrls == 0)
return libxlMakeDefaultUSBControllers(def, d_config);
- if (VIR_ALLOC_N(x_usbctrls, nusbctrls) < 0)
- return -1;
+ x_usbctrls = g_new0(libxl_device_usbctrl, nusbctrls);
for (i = 0, j = 0; i < ncontrollers && j < nusbctrls; i++) {
if (l_controllers[i]->type != VIR_DOMAIN_CONTROLLER_TYPE_USB)
if (nhostdevs == 0)
return 0;
- if (VIR_ALLOC_N(x_usbdevs, nhostdevs) < 0)
- return -1;
+ x_usbdevs = g_new0(libxl_device_usbdev, nhostdevs);
for (i = 0, j = 0; i < nhostdevs; i++) {
if (l_hostdevs[i]->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
if (nhostdevs == 0)
return 0;
- if (VIR_ALLOC_N(x_pcidevs, nhostdevs) < 0)
- return -1;
+ x_pcidevs = g_new0(libxl_device_pci, nhostdevs);
for (i = 0, j = 0; i < nhostdevs; i++) {
if (l_hostdevs[i]->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
if (virCondInit(&priv->job.cond) < 0)
return -1;
- if (VIR_ALLOC(priv->job.current) < 0)
- return -1;
+ priv->job.current = g_new0(virDomainJobInfo, 1);
return 0;
}
chrdef->target.port = 0;
chrdef->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
- if (VIR_ALLOC_N(def->consoles, 1) < 0) {
- virDomainChrDefFree(chrdef);
- return -1;
- }
-
+ def->consoles = g_new0(virDomainChrDefPtr, 1);
def->nconsoles = 1;
def->consoles[0] = chrdef;
}
/* add implicit balloon device */
if (def->memballoon == NULL) {
virDomainMemballoonDefPtr memballoon;
- if (VIR_ALLOC(memballoon) < 0)
- return -1;
+ memballoon = g_new0(virDomainMemballoonDef,
+ 1);
memballoon->model = VIR_DOMAIN_MEMBALLOON_MODEL_XEN;
def->memballoon = memballoon;
* Start a thread to handle shutdown. We don't want to be tying up
* libxl's event machinery by doing a potentially lengthy shutdown.
*/
- if (VIR_ALLOC(shutdown_info) < 0)
- goto error;
+ shutdown_info = g_new0(struct libxlShutdownThreadInfo, 1);
shutdown_info->driver = driver;
shutdown_info->event = (libxl_event *)event;
goto error;
}
- if (VIR_ALLOC_N(xml, hdr.xmlLen) < 0)
- goto error;
+ xml = g_new0(char, hdr.xmlLen);
if (saferead(fd, xml, hdr.xmlLen) != hdr.xmlLen) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("failed to read XML"));
int vir_events = VIR_EVENT_HANDLE_ERROR;
libxlOSEventHookInfoPtr info;
- if (VIR_ALLOC(info) < 0)
- return -1;
+ info = g_new0(libxlOSEventHookInfo, 1);
info->ctx = priv;
info->xl_priv = xl_priv;
gint64 res_ms;
int timeout;
- if (VIR_ALLOC(info) < 0)
- return -1;
+ info = g_new0(libxlOSEventHookInfo, 1);
info->ctx = priv;
info->xl_priv = xl_priv;
if (!libxlDriverShouldLoad(privileged))
return VIR_DRV_STATE_INIT_SKIPPED;
- if (VIR_ALLOC(libxl_driver) < 0)
- return VIR_DRV_STATE_INIT_ERROR;
+ libxl_driver = g_new0(libxlDriverPrivate, 1);
libxl_driver->lockFD = -1;
if (virMutexInit(&libxl_driver->lock) < 0) {
goto endjob;
maplen = VIR_CPU_MAPLEN(nvcpus);
- if (VIR_ALLOC_N(bitmask, maplen) < 0)
- goto endjob;
+ bitmask = g_new0(uint8_t, maplen);
for (i = 0; i < nvcpus; ++i) {
pos = i / 8;
goto cleanup;
}
- if (VIR_ALLOC_N(ret, len) < 0)
+ ret = g_new0(char, len);
goto cleanup;
if (virConfWriteMem(ret, &len, conf) < 0) {
goto error;
if (n_leases) {
- ifaces_ret = g_renew(typeof(*ifaces_ret), ifaces_ret, ifaces_count + 1);
- ifaces_ret[ifaces_count] = g_new0(typeof(**ifaces_ret), 1);
+ ifaces_ret = g_renew(virDomainInterfacePtr, ifaces_ret, ifaces_count + 1);
+ ifaces_ret[ifaces_count] = g_new0(virDomainInterface, 1);
iface = ifaces_ret[ifaces_count];
ifaces_count++;
/* Assuming each lease corresponds to a separate IP */
iface->naddrs = n_leases;
- iface->addrs = g_new0(typeof(*iface->addrs), iface->naddrs);
+ iface->addrs = g_new0(virDomainIPAddress, iface->naddrs);
iface->name = g_strdup(vm->def->nets[i]->ifname);
iface->hwaddr = g_strdup(macaddr);
}
{
libxlMigrationCookiePtr mig = NULL;
- if (VIR_ALLOC(mig) < 0)
- goto error;
+ mig = g_new0(libxlMigrationCookie, 1);
mig->name = g_strdup(dom->def->name);
* specify a stream version.
*/
if (!cookiein || !cookieinlen) {
- if (VIR_ALLOC(mig) < 0)
- return -1;
+ mig = g_new0(libxlMigrationCookie, 1);
mig->xenMigStreamVer = 1;
*migout = mig;
VIR_DEBUG("cookielen=%d cookie='%s'", cookieinlen, NULLSTR(cookiein));
- if (VIR_ALLOC(mig) < 0)
- return -1;
+ mig = g_new0(libxlMigrationCookie, 1);
if (!(doc = virXMLParseStringCtxt(cookiein,
_("(libxl_migration_cookie)"),
*/
args->recvfd = recvfd;
VIR_FREE(priv->migrationDstReceiveThr);
- if (VIR_ALLOC(priv->migrationDstReceiveThr) < 0)
- goto fail;
+ priv->migrationDstReceiveThr = g_new0(virThread, 1);
name = g_strdup_printf("mig-%s", args->vm->def->name);
if (virThreadCreateFull(priv->migrationDstReceiveThr, true,
mig = NULL;
VIR_FREE(priv->migrationDstReceiveThr);
- if (VIR_ALLOC(priv->migrationDstReceiveThr) < 0)
- goto error;
+ priv->migrationDstReceiveThr = g_new0(virThread, 1);
name = g_strdup_printf("mig-%s", args->vm->def->name);
if (virThreadCreateFull(priv->migrationDstReceiveThr, true,
libxlDoMigrateDstReceive,
struct pollfd fds[1];
int timeout = -1;
- if (VIR_ALLOC_N(buffer, TUNNEL_SEND_BUF_SIZE) < 0)
- return;
+ buffer = g_new0(char, TUNNEL_SEND_BUF_SIZE);
fds[0].fd = data->srcFD;
for (;;) {
int ret = -1;
g_autofree char *name = NULL;
- if (VIR_ALLOC(tc) < 0)
- goto out;
+ tc = g_new0(struct libxlTunnelControl, 1);
*tnl = tc;
tc->dataFD[0] = -1;
l, setting);
return -1;
}
- if (VIR_ALLOC(value) < 0)
- return -1;
+ value = g_new0(virConfValue, 1);
value->type = VIR_CONF_LLONG;
value->next = NULL;
{
virConfValuePtr value = NULL;
- if (VIR_ALLOC(value) < 0)
- return -1;
+ value = g_new0(virConfValue, 1);
value->type = VIR_CONF_STRING;
value->next = NULL;
return -1;
if (strval) {
- if (VIR_EXPAND_N(def->clock.timers, def->clock.ntimers, 1) < 0 ||
- VIR_ALLOC(timer) < 0)
+ if (VIR_EXPAND_N(def->clock.timers, def->clock.ntimers, 1) < 0)
return -1;
+ timer = g_new0(virDomainTimerDef, 1);
timer->name = VIR_DOMAIN_TIMER_NAME_TSC;
timer->present = 1;
timer->tickpolicy = -1;
return -1;
if (val != -1) {
- if (VIR_EXPAND_N(def->clock.timers, def->clock.ntimers, 1) < 0 ||
- VIR_ALLOC(timer) < 0)
+ if (VIR_EXPAND_N(def->clock.timers, def->clock.ntimers, 1) < 0)
return -1;
+ timer = g_new0(virDomainTimerDef, 1);
timer->name = VIR_DOMAIN_TIMER_NAME_HPET;
timer->present = val;
timer->tickpolicy = -1;
if (xenConfigGetBool(conf, "vnc", &val, 0) < 0)
goto cleanup;
if (val) {
- if (VIR_ALLOC(graphics) < 0)
- goto cleanup;
+ graphics = g_new0(virDomainGraphicsDef, 1);
graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_VNC;
if (xenConfigGetBool(conf, "vncunused", &val, 1) < 0)
goto cleanup;
goto cleanup;
if (xenConfigCopyStringOpt(conf, "keymap", &graphics->data.vnc.keymap) < 0)
goto cleanup;
- if (VIR_ALLOC_N(def->graphics, 1) < 0)
- goto cleanup;
+ def->graphics = g_new0(virDomainGraphicsDefPtr, 1);
def->graphics[0] = graphics;
def->ngraphics = 1;
graphics = NULL;
if (xenConfigGetBool(conf, "sdl", &val, 0) < 0)
goto cleanup;
if (val) {
- if (VIR_ALLOC(graphics) < 0)
- goto cleanup;
+ graphics = g_new0(virDomainGraphicsDef, 1);
graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_SDL;
if (xenConfigCopyStringOpt(conf, "display", &graphics->data.sdl.display) < 0)
goto cleanup;
if (xenConfigCopyStringOpt(conf, "xauthority", &graphics->data.sdl.xauth) < 0)
goto cleanup;
- if (VIR_ALLOC_N(def->graphics, 1) < 0)
- goto cleanup;
+ def->graphics = g_new0(virDomainGraphicsDefPtr, 1);
def->graphics[0] = graphics;
def->ngraphics = 1;
graphics = NULL;
goto cleanup;
}
- if (VIR_ALLOC(graphics) < 0)
- goto cleanup;
+ graphics = g_new0(virDomainGraphicsDef, 1);
if (strstr(key, "type=sdl"))
graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_SDL;
else
goto cleanup;
VIR_FREE(listenAddr);
}
- if (VIR_ALLOC_N(def->graphics, 1) < 0)
- goto cleanup;
+ def->graphics = g_new0(virDomainGraphicsDefPtr, 1);
def->graphics[0] = graphics;
def->ngraphics = 1;
graphics = NULL;
!(chr = xenParseSxprChar(parallel, NULL)))
goto cleanup;
if (chr) {
- if (VIR_ALLOC_N(def->parallels, 1) < 0)
- goto cleanup;
+ def->parallels = g_new0(virDomainChrDefPtr, 1);
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL;
chr->target.port = 0;
!(chr = xenParseSxprChar(serial, NULL)))
goto cleanup;
if (chr) {
- if (VIR_ALLOC_N(def->serials, 1) < 0)
- goto cleanup;
+ def->serials = g_new0(virDomainChrDefPtr, 1);
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
chr->target.port = 0;
def->serials[0] = chr;
}
}
} else {
- if (VIR_ALLOC_N(def->consoles, 1) < 0)
- goto cleanup;
+ def->consoles = g_new0(virDomainChrDefPtr, 1);
def->nconsoles = 1;
if (!(def->consoles[0] = xenParseSxprChar("pty", NULL)))
goto cleanup;
if (virStrToLong_ui(vlanstr, NULL, 10, &tag) < 0)
return -1;
- if (VIR_ALLOC_N(net->vlan.tag, 1) < 0)
- return -1;
-
+ net->vlan.tag = g_new0(unsigned int, 1);
net->vlan.tag[0] = tag;
net->vlan.nTags = 1;
- if (VIR_ALLOC(net->virtPortProfile) < 0)
- return -1;
-
+ net->virtPortProfile = g_new0(virNetDevVPortProfile, 1);
net->virtPortProfile->virtPortType = VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH;
return 0;
} else if ((vlanstr = strchr(bridge, ':'))) {
for (i = 1; vlanstr_list[i]; i++)
nvlans++;
- if (VIR_ALLOC_N(net->vlan.tag, nvlans) < 0) {
- g_strfreev(vlanstr_list);
- return -1;
- }
+ net->vlan.tag = g_new0(unsigned int, nvlans);
for (i = 1; i <= nvlans; i++) {
if (virStrToLong_ui(vlanstr_list[i], NULL, 10, &tag) < 0) {
net->vlan.trunk = true;
g_strfreev(vlanstr_list);
- if (VIR_ALLOC(net->virtPortProfile) < 0)
- return -1;
-
+ net->virtPortProfile = g_new0(virNetDevVPortProfile, 1);
net->virtPortProfile->virtPortType = VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH;
return 0;
} else {
if (xenParseSxprVifRate(rate, &kbytes_per_sec) < 0)
goto cleanup;
- if (VIR_ALLOC(bandwidth) < 0)
- goto cleanup;
-
- if (VIR_ALLOC(bandwidth->out) < 0) {
- VIR_FREE(bandwidth);
- goto cleanup;
- }
-
+ bandwidth = g_new0(virNetDevBandwidth, 1);
+ bandwidth->out = g_new0(virNetDevBandwidthRate, 1);
bandwidth->out->average = kbytes_per_sec;
net->bandwidth = bandwidth;
}
* Hence use of MODEL_ES1370 + 1, instead of MODEL_LAST
*/
- if (VIR_ALLOC_N(def->sounds,
- VIR_DOMAIN_SOUND_MODEL_ES1370 + 1) < 0)
- return -1;
-
+ def->sounds = g_new0(virDomainSoundDefPtr,
+ VIR_DOMAIN_SOUND_MODEL_ES1370 + 1);
for (i = 0; i < (VIR_DOMAIN_SOUND_MODEL_ES1370 + 1); i++) {
- virDomainSoundDefPtr sound;
- if (VIR_ALLOC(sound) < 0)
- return -1;
+ virDomainSoundDefPtr sound = g_new0(virDomainSoundDef, 1);
sound->model = i;
def->sounds[def->nsounds++] = sound;
}
return -1;
}
- if (VIR_ALLOC(sound) < 0)
- return -1;
+ sound = g_new0(virDomainSoundDef, 1);
if ((sound->model = virDomainSoundModelTypeFromString(model)) < 0) {
VIR_FREE(sound);
virBufferAddLit(&buf, "none");
}
- if (VIR_ALLOC(val) < 0)
- return -1;
+ val = g_new0(virConfValue, 1);
val->type = VIR_CONF_STRING;
val->str = virBufferContentAndReset(&buf);
char **address_array;
char *ret = NULL;
- if (VIR_ALLOC_N(address_array, guestIP->nips + 1) < 0)
- return NULL;
+ address_array = g_new0(char *, guestIP->nips + 1);
for (i = 0; i < guestIP->nips; i++) {
address_array[i] = virSocketAddrFormat(&guestIP->ips[i]->address);
if (net->bandwidth && net->bandwidth->out && net->bandwidth->out->average)
virBufferAsprintf(&buf, ",rate=%lluKB/s", net->bandwidth->out->average);
- if (VIR_ALLOC(val) < 0)
- return -1;
-
+ val = g_new0(virConfValue, 1);
val->type = VIR_CONF_STRING;
val->str = virBufferContentAndReset(&buf);
tmp = list->list;
if (!hasPCI)
return 0;
- if (VIR_ALLOC(pciVal) < 0)
- return -1;
+ pciVal = g_new0(virConfValue, 1);
pciVal->type = VIR_CONF_LIST;
pciVal->list = NULL;
permissive_str);
- if (VIR_ALLOC(val) < 0) {
- VIR_FREE(buf);
- goto error;
- }
+ val = g_new0(virConfValue, 1);
val->type = VIR_CONF_STRING;
val->str = buf;
tmp = pciVal->list;
VIR_FREE(pciVal);
return 0;
-
- error:
- virConfFreeValue(pciVal);
- return -1;
}
return -1;
}
- if (VIR_ALLOC(serialVal) < 0)
- return -1;
-
+ serialVal = g_new0(virConfValue, 1);
serialVal->type = VIR_CONF_LIST;
serialVal->list = NULL;
vfbstr = virBufferContentAndReset(&buf);
- if (VIR_ALLOC(vfb) < 0) {
- VIR_FREE(vfbstr);
- return -1;
- }
-
- if (VIR_ALLOC(disp) < 0) {
- VIR_FREE(vfb);
- VIR_FREE(vfbstr);
- return -1;
- }
+ vfb = g_new0(virConfValue, 1);
+ disp = g_new0(virConfValue, 1);
vfb->type = VIR_CONF_LIST;
vfb->list = disp;
size_t i;
int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM;
- if (VIR_ALLOC(netVal) < 0)
- goto cleanup;
+ netVal = g_new0(virConfValue, 1);
netVal->type = VIR_CONF_LIST;
netVal->list = NULL;
return -1;
if (bios && STREQ(bios, "ovmf")) {
- if (VIR_ALLOC(def->os.loader) < 0)
- return -1;
-
+ def->os.loader = g_new0(virDomainLoaderDef, 1);
def->os.loader->type = VIR_DOMAIN_LOADER_TYPE_PFLASH;
def->os.loader->readonly = VIR_TRISTATE_BOOL_YES;
for (i = 0; i < caps->nguests; i++) {
if (caps->guests[i]->ostype == VIR_DOMAIN_OSTYPE_HVM &&
caps->guests[i]->arch.id == def->os.arch) {
- if (VIR_ALLOC(def->os.loader) < 0)
- return -1;
+ def->os.loader = g_new0(virDomainLoaderDef, 1);
def->os.loader->path = g_strdup(caps->guests[i]->arch.defaultInfo.loader);
}
}
return -1;
if (val) {
- if (VIR_ALLOC(graphics) < 0)
- return -1;
-
+ graphics = g_new0(virDomainGraphicsDef, 1);
graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_SPICE;
if (xenConfigCopyStringOpt(conf, "spicehost", &listenAddr) < 0)
goto cleanup;
else
graphics->data.spice.copypaste = VIR_TRISTATE_BOOL_NO;
- if (VIR_ALLOC_N(def->graphics, 1) < 0)
- goto cleanup;
+ def->graphics = g_new0(virDomainGraphicsDefPtr, 1);
def->graphics[0] = graphics;
def->ngraphics = 1;
}
libxl_device_disk *libxldisk;
virDomainDiskDefPtr disk = NULL;
- if (VIR_ALLOC(libxldisk) < 0)
- return -1;
+ libxldisk = g_new0(libxl_device_disk, 1);
if (!(xluconf = xlu_cfg_init(stderr, "command line")))
goto cleanup;
STREQ(str, "mouse") ||
STREQ(str, "keyboard"))) {
virDomainInputDefPtr input;
- if (VIR_ALLOC(input) < 0)
- return -1;
+ input = g_new0(virDomainInputDef,
+ 1);
input->bus = VIR_DOMAIN_INPUT_BUS_USB;
if (STREQ(str, "mouse"))
}
/* "host" + all features + NULL */
- if (VIR_ALLOC_N(cpuid_pairs, def->cpu->nfeatures + 2) < 0)
- return -1;
+ cpuid_pairs = g_new0(char *, def->cpu->nfeatures + 2);
cpuid_pairs[0] = g_strdup("host");
{
virConfValuePtr numaPnode, tmp;
- if (VIR_ALLOC(numaPnode) < 0)
- return -1;
+ numaPnode = g_new0(virConfValue, 1);
/* Place VNODE directive */
numaPnode->type = VIR_CONF_STRING;
size_t nodeSize = virDomainNumaGetNodeMemorySize(numa, node) / 1024;
g_autofree char *nodeVcpus = NULL;
- if (!cpumask ||
- VIR_ALLOC(numaVnode) < 0)
- goto cleanup;
+ if (!cpumask)
+ return -1;
+ numaVnode = g_new0(virConfValue, 1);
numaVnode->type = VIR_CONF_LIST;
numaVnode->list = NULL;
list->list = numaVnode;
ret = 0;
- cleanup:
VIR_FREE(nodeVcpus);
return ret;
}
if (numa == NULL)
return -1;
- if (VIR_ALLOC(vnumaVal) < 0)
- return -1;
+ vnumaVal = g_new0(virConfValue, 1);
vnumaVal->type = VIR_CONF_LIST;
vnumaVal->list = NULL;
if (target)
virBufferAsprintf(&buf, ",target=%s", target);
- if (VIR_ALLOC(val) < 0)
- goto cleanup;
+ val = g_new0(virConfValue, 1);
val->type = VIR_CONF_STRING;
val->str = virBufferContentAndReset(&buf);
virConfValuePtr diskVal;
size_t i;
- if (VIR_ALLOC(diskVal) < 0)
- return -1;
+ diskVal = g_new0(virConfValue, 1);
diskVal->type = VIR_CONF_LIST;
diskVal->list = NULL;
virConfValuePtr usbdevices = NULL, lastdev;
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
- if (VIR_ALLOC(usbdevices) < 0)
- goto error;
-
+ usbdevices = g_new0(virConfValue, 1);
usbdevices->type = VIR_CONF_LIST;
usbdevices->list = NULL;
lastdev = NULL;
}
if (lastdev == NULL) {
- if (VIR_ALLOC(lastdev) < 0)
- goto error;
+ lastdev = g_new0(virConfValue, 1);
usbdevices->list = lastdev;
} else {
- if (VIR_ALLOC(lastdev->next) < 0)
- goto error;
+ lastdev->next = g_new0(virConfValue, 1);
lastdev = lastdev->next;
}
lastdev->type = VIR_CONF_STRING;
if (!hasUSBCtrl)
return 0;
- if (VIR_ALLOC(usbctrlVal) < 0)
- return -1;
+ usbctrlVal = g_new0(virConfValue, 1);
usbctrlVal->type = VIR_CONF_LIST;
usbctrlVal->list = NULL;
virBufferAsprintf(&buf, "ports=%x",
def->controllers[i]->opts.usbopts.ports);
- if (VIR_ALLOC(val) < 0)
- goto error;
-
+ val = g_new0(virConfValue, 1);
val->type = VIR_CONF_STRING;
val->str = virBufferContentAndReset(&buf);
tmp = usbctrlVal->list;
if (!hasUSB)
return 0;
- if (VIR_ALLOC(usbVal) < 0)
- return -1;
+ usbVal = g_new0(virConfValue, 1);
usbVal->type = VIR_CONF_LIST;
usbVal->list = NULL;
def->hostdevs[i]->source.subsys.u.usb.bus,
def->hostdevs[i]->source.subsys.u.usb.device);
- if (VIR_ALLOC(val) < 0) {
- VIR_FREE(buf);
- goto error;
- }
+ val = g_new0(virConfValue, 1);
val->type = VIR_CONF_STRING;
val->str = buf;
tmp = usbVal->list;
VIR_FREE(usbVal);
return 0;
-
- error:
- virConfFreeValue(usbVal);
- return -1;
}
static int
/* name */
virBufferAsprintf(&buf, "name=%s", channel->target.name);
- if (VIR_ALLOC(val) < 0)
- return -1;
-
+ val = g_new0(virConfValue, 1);
val->type = VIR_CONF_STRING;
val->str = virBufferContentAndReset(&buf);
tmp = list->list;
virConfValuePtr channelVal = NULL;
size_t i;
- if (VIR_ALLOC(channelVal) < 0)
- goto cleanup;
+ channelVal = g_new0(virConfValue, 1);
channelVal->type = VIR_CONF_LIST;
channelVal->list = NULL;
if (nsdata->num_args == 0)
return 0;
- if (VIR_ALLOC(args) < 0)
- return -1;
+ args = g_new0(virConfValue, 1);
args->type = VIR_CONF_LIST;
args->list = NULL;
for (i = 0; i < nsdata->num_args; i++) {
virConfValuePtr val, tmp;
- if (VIR_ALLOC(val) < 0)
- goto error;
+ val = g_new0(virConfValue, 1);
val->type = VIR_CONF_STRING;
val->str = g_strdup(nsdata->args[i]);
if (!(offset = strchr(head, ',')))
goto error;
- if (VIR_ALLOC_N(disk->dst, (offset - head) + 1) < 0)
- goto error;
+ disk->dst = g_new0(char, (offset - head) + 1);
if (virStrncpy(disk->dst, head, offset - head,
(offset - head) + 1) < 0) {
virConfValuePtr diskVal = NULL;
size_t i = 0;
- if (VIR_ALLOC(diskVal) < 0)
- goto cleanup;
+ diskVal = g_new0(virConfValue, 1);
diskVal->type = VIR_CONF_LIST;
diskVal->list = NULL;
STREQ(str, "mouse") ||
STREQ(str, "keyboard"))) {
virDomainInputDefPtr input;
- if (VIR_ALLOC(input) < 0)
- return -1;
+ input = g_new0(virDomainInputDef, 1);
input->bus = VIR_DOMAIN_INPUT_BUS_USB;
if (STREQ(str, "mouse"))