ndata = virJSONValueArraySize(data);
- if (VIR_ALLOC_N(*info, ndata) < 0)
- goto cleanup;
+ *info = g_new0(qemuAgentCPUInfo, ndata);
for (i = 0; i < ndata; i++) {
virJSONValuePtr entry = virJSONValueArrayGet(data, i);
if (VIR_EXPAND_N(ifaces_ret, ifaces_count, 1) < 0)
goto error;
- if (VIR_ALLOC(ifaces_ret[ifaces_count - 1]) < 0)
- goto error;
+ ifaces_ret[ifaces_count - 1] = g_new0(virDomainInterface, 1);
if (virHashAddEntry(ifaces_store, ifname_s,
ifaces_ret[ifaces_count - 1]) < 0)
}
}
- if (VIR_ALLOC(data) < 0)
- return -1;
+ data = g_new0(qemuBlockNodeNameBackingChainData, 1);
data->nodeformat = g_strdup(nodename);
data->nodestorage = g_strdup(parentnodename);
return NULL;
}
- if (VIR_ALLOC(uri) < 0)
- return NULL;
+ uri = g_new0(virURI, 1);
if (src->hosts->transport == VIR_STORAGE_NET_HOST_TRANS_TCP) {
uri->port = src->hosts->port;
if (autoreadonly)
backendpropsflags |= QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_AUTO_READONLY;
- if (VIR_ALLOC(data) < 0)
- return NULL;
+ data = g_new0(qemuBlockStorageSourceAttachData, 1);
if (!(data->formatProps = qemuBlockStorageSourceGetBlockdevProps(src,
backingStore)) ||
g_autoptr(qemuBlockStorageSourceChainData) data = NULL;
virStorageSourcePtr n;
- if (VIR_ALLOC(data) < 0)
- return NULL;
+ data = g_new0(qemuBlockStorageSourceChainData, 1);
for (n = src; virStorageSourceIsBacking(n); n = n->backingStore) {
if (!(backend = qemuBlockStorageSourceDetachPrepare(n, NULL)))
g_autoptr(qemuBlockStorageSourceAttachData) backend = NULL;
g_autoptr(qemuBlockStorageSourceChainData) data = NULL;
- if (VIR_ALLOC(data) < 0)
- return NULL;
+ data = g_new0(qemuBlockStorageSourceChainData, 1);
if (!(backend = qemuBlockStorageSourceDetachPrepare(src, driveAlias)))
return NULL;
if (!vm->def->resource) {
virDomainResourceDefPtr res;
- if (VIR_ALLOC(res) < 0)
- return -1;
+ res = g_new0(virDomainResourceDef, 1);
res->partition = g_strdup("/machine");
if (!(all_nodes_str = virBitmapFormat(all_nodes)))
goto cleanup;
- if (VIR_ALLOC(data) < 0)
- goto cleanup;
+ data = g_new0(qemuCgroupEmulatorAllNodesData, 1);
if (virCgroupNewThread(cgroup, VIR_CGROUP_THREAD_EMULATOR, 0,
false, &data->emulatorCgroup) < 0)
VIR_FREE(cfg->hugetlbfs);
cfg->nhugetlbfs = virStringListLength((const char *const *)hugetlbfs);
- if (hugetlbfs[0] &&
- VIR_ALLOC_N(cfg->hugetlbfs, cfg->nhugetlbfs) < 0)
- return -1;
+ if (hugetlbfs[0])
+ cfg->hugetlbfs = g_new0(virHugeTLBFS, cfg->nhugetlbfs);
for (i = 0; hugetlbfs[i] != NULL; i++) {
if (virQEMUDriverConfigHugeTLBFSInit(&cfg->hugetlbfs[i],
}
cfg->nfirmwares = virStringListLength((const char *const *)nvram);
- if (nvram[0] && VIR_ALLOC_N(cfg->firmwares, cfg->nfirmwares) < 0)
- return -1;
+ if (nvram[0])
+ cfg->firmwares = g_new0(virFirmwarePtr, cfg->nfirmwares);
for (i = 0; nvram[i] != NULL; i++) {
- if (VIR_ALLOC(cfg->firmwares[i]) < 0)
- return -1;
+ cfg->firmwares[i] = g_new0(virFirmware, 1);
if (virFirmwareParse(nvram[i], cfg->firmwares[i]) < 0)
return -1;
}
;
caps->host.nsecModels = i;
- if (VIR_ALLOC_N(caps->host.secModels, caps->host.nsecModels) < 0)
- return NULL;
+ caps->host.secModels = g_new0(virCapsHostSecModel, caps->host.nsecModels);
for (i = 0; sec_managers[i]; i++) {
virCapsHostSecModelPtr sm = &caps->host.secModels[i];
entry->domains[entry->ref - 1] = g_strdup(name);
}
} else {
- if (VIR_ALLOC(entry) < 0 ||
- VIR_ALLOC_N(entry->domains, 1) < 0)
- goto error;
+ entry = g_new0(qemuSharedDeviceEntry, 1);
+ entry->domains = g_new0(char *, 1);
entry->domains[0] = g_strdup(name);
data.count, available_ports, hubs_needed);
for (i = 0; i < hubs_needed; i++) {
- if (VIR_ALLOC(hub) < 0)
- return -1;
+ hub = g_new0(virDomainHubDef, 1);
hub->type = VIR_DOMAIN_HUB_TYPE_USB;
if (VIR_APPEND_ELEMENT(def->hubs, def->nhubs, hub) < 0)
/* No SCSI controller present, for backward compatibility we
* now hotplug a controller */
- if (VIR_ALLOC(cont) < 0)
- return NULL;
+ cont = g_new0(virDomainControllerDef, 1);
cont->type = VIR_DOMAIN_CONTROLLER_TYPE_SCSI;
cont->idx = controller;
if (model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT)
if (!tapfdSize)
tapfdSize = vhostfdSize = 1;
queueSize = tapfdSize;
- if (VIR_ALLOC_N(tapfd, tapfdSize) < 0)
- goto cleanup;
+ tapfd = g_new0(int, tapfdSize);
memset(tapfd, -1, sizeof(*tapfd) * tapfdSize);
- if (VIR_ALLOC_N(vhostfd, vhostfdSize) < 0)
- goto cleanup;
+ vhostfd = g_new0(int, vhostfdSize);
memset(vhostfd, -1, sizeof(*vhostfd) * vhostfdSize);
if (qemuInterfaceBridgeConnect(vm->def, driver, net,
tapfd, &tapfdSize) < 0)
if (!tapfdSize)
tapfdSize = vhostfdSize = 1;
queueSize = tapfdSize;
- if (VIR_ALLOC_N(tapfd, tapfdSize) < 0)
- goto cleanup;
+ tapfd = g_new0(int, tapfdSize);
memset(tapfd, -1, sizeof(*tapfd) * tapfdSize);
- if (VIR_ALLOC_N(vhostfd, vhostfdSize) < 0)
- goto cleanup;
+ vhostfd = g_new0(int, vhostfdSize);
memset(vhostfd, -1, sizeof(*vhostfd) * vhostfdSize);
if (qemuInterfaceDirectConnect(vm->def, driver, net,
tapfd, tapfdSize,
if (!tapfdSize)
tapfdSize = vhostfdSize = 1;
queueSize = tapfdSize;
- if (VIR_ALLOC_N(tapfd, tapfdSize) < 0)
- goto cleanup;
+ tapfd = g_new0(int, tapfdSize);
memset(tapfd, -1, sizeof(*tapfd) * tapfdSize);
- if (VIR_ALLOC_N(vhostfd, vhostfdSize) < 0)
+ vhostfd = g_new0(int, vhostfdSize);
goto cleanup;
memset(vhostfd, -1, sizeof(*vhostfd) * vhostfdSize);
if (qemuInterfaceEthernetConnect(vm->def, driver, net,
goto cleanup;
}
- if (VIR_ALLOC_N(tapfdName, tapfdSize) < 0 ||
- VIR_ALLOC_N(vhostfdName, vhostfdSize) < 0)
- goto cleanup;
+ tapfdName = g_new0(char *, tapfdSize);
+ vhostfdName = g_new0(char *, vhostfdSize);
for (i = 0; i < tapfdSize; i++)
tapfdName[i] = g_strdup_printf("fd-%s%zu", net->info.alias, i);
*/
if (vmdef->nserials == 0 && vmdef->nconsoles == 0 &&
chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL) {
- if (!vmdef->consoles && VIR_ALLOC(vmdef->consoles) < 0)
- return -1;
+ if (!vmdef->consoles)
+ vmdef->consoles = g_new0(virDomainChrDefPtr, 1);
/* We'll be dealing with serials[0] directly, so NULL is fine here. */
if (!(vmdef->consoles[0] = virDomainChrDefNew(NULL))) {
VIR_DEBUG("Running migration tunnel; stream=%p, sock=%d",
data->st, data->sock);
- if (VIR_ALLOC_N(buffer, TUNNEL_SEND_BUF_SIZE) < 0)
- goto abrt;
+ buffer = g_new0(char, TUNNEL_SEND_BUF_SIZE);
fds[0].fd = data->sock;
fds[1].fd = data->wakeupRecvFD;
if (virPipe(wakeupFD) < 0)
goto error;
- if (VIR_ALLOC(io) < 0)
- goto error;
+ io = g_new0(qemuMigrationIOThread, 1);
io->st = st;
io->sock = sock;
QEMU_CHECK_MONITOR(mon);
- if (VIR_ALLOC_N(info, maxvcpus) < 0)
- return -1;
+ info = g_new0(qemuMonitorCPUInfo, maxvcpus);
/* initialize a few non-zero defaults */
qemuMonitorCPUInfoClear(info, maxvcpus);
qemuMonitorCPUModelInfoPtr copy;
size_t i;
- if (VIR_ALLOC(copy) < 0)
- goto error;
+ copy = g_new0(qemuMonitorCPUModelInfo, 1);
- if (VIR_ALLOC_N(copy->props, orig->nprops) < 0)
- goto error;
+ copy->props = g_new0(qemuMonitorCPUProperty, orig->nprops);
copy->name = g_strdup(orig->name);
}
return copy;
-
- error:
- qemuMonitorCPUModelInfoFree(copy);
- return NULL;
}
}
}
- if (VIR_ALLOC_N(paths, nmounts) < 0)
- goto error;
+ paths = g_new0(char *, nmounts);
for (i = 0; i < nmounts; i++) {
if (!(paths[i] = qemuDomainGetPreservedMountPath(cfg, vm, mounts[i])))
virQEMUSaveDataPtr data = NULL;
virQEMUSaveHeaderPtr header;
- if (VIR_ALLOC(data) < 0)
- return NULL;
+ data = g_new0(virQEMUSaveData, 1);
data->xml = g_steal_pointer(&domXML);
return NULL;
}
- if (VIR_ALLOC(vu) < 0)
- return NULL;
+ vu = g_new0(qemuVhostUser, 1);
if (qemuVhostUserTypeParse(path, doc, vu) < 0)
return NULL;
npaths = virStringListLength((const char **)paths);
- if (VIR_ALLOC_N(vus, npaths) < 0)
- return -1;
+ vus = g_new0(qemuVhostUserPtr, npaths);
for (i = 0; i < npaths; i++) {
if (!(vus[i] = qemuVhostUserParse(paths[i])))
}
nfeatures = virJSONValueArraySize(featuresJSON);
- if (VIR_ALLOC_N(features, nfeatures) < 0)
- return -1;
+ features = g_new0(qemuVhostUserGPUFeature, nfeatures);
for (i = 0; i < nfeatures; i++) {
virJSONValuePtr item = virJSONValueArrayGet(featuresJSON, i);
continue;
}
- if (!video->driver && VIR_ALLOC(video->driver) < 0)
- goto end;
+ if (!video->driver)
+ video->driver = g_new0(virDomainVideoDriverDef, 1);
VIR_FREE(video->driver->vhost_user_binary);
video->driver->vhost_user_binary = g_strdup(vu->binary);
goto end;
}
- if (!video->accel && VIR_ALLOC(video->accel) < 0)
- goto end;
+ if (!video->accel)
+ video->accel = g_new0(virDomainVideoAccelDef, 1);
if (!video->accel->rendernode &&
qemuVhostUserGPUHasFeature(&vu->capabilities.gpu,