if ((n = virXPathNodeSet("./keywrap/cipher", ctxt, &nodes)) < 0)
return n;
- if (VIR_ALLOC(keywrap) < 0)
- return -1;
+ keywrap = g_new0(virDomainKeyWrapDef, 1);
for (i = 0; i < n; i++) {
if (virDomainKeyWrapCipherDefParseXML(keywrap, nodes[i]) < 0)
if (*virtio || !driver)
return 0;
- if (VIR_ALLOC(*virtio) < 0)
- return -1;
+ *virtio = g_new0(virDomainVirtioOptions, 1);
res = *virtio;
!(priv = xmlopt->privateData.vcpuNew()))
return NULL;
- if (VIR_ALLOC(ret) < 0)
- return NULL;
+ ret = g_new0(virDomainVcpuDef, 1);
ret->privateData = g_steal_pointer(&priv);
{
virDomainDiskDefPtr ret;
- if (VIR_ALLOC(ret) < 0)
- return NULL;
+ ret = g_new0(virDomainDiskDef, 1);
ret->src = virStorageSourceNew();
{
virDomainControllerDefPtr def;
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ def = g_new0(virDomainControllerDef, 1);
def->type = type;
{
virDomainFSDefPtr ret;
- if (VIR_ALLOC(ret) < 0)
- return NULL;
+ ret = g_new0(virDomainFSDef, 1);
ret->src = virStorageSourceNew();
virDomainVsockDefPtr ret = NULL;
virDomainVsockDefPtr vsock;
- if (VIR_ALLOC(vsock) < 0)
- return NULL;
+ vsock = g_new0(virDomainVsockDef, 1);
if (xmlopt &&
xmlopt->privateData.vsockNew &&
{
virDomainVideoDefPtr def;
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ def = g_new0(virDomainVideoDef, 1);
if (xmlopt && xmlopt->privateData.videoNew &&
!(def->privateData = xmlopt->privateData.videoNew())) {
{
virDomainHostdevDefPtr def;
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ def = g_new0(virDomainHostdevDef, 1);
- if (VIR_ALLOC(def->info) < 0)
- goto error;
+ def->info = g_new0(virDomainDeviceInfo, 1);
return def;
-
- error:
- VIR_FREE(def->info);
- VIR_FREE(def);
- return NULL;
}
_("failed to populate iothreadids"));
return -1;
}
- if (VIR_ALLOC(iothrid) < 0)
- return -1;
+ iothrid = g_new0(virDomainIOThreadIDDef, 1);
iothrid->iothread_id = nxt;
iothrid->autofill = true;
def->iothreadids[def->niothreadids++] = iothrid;
{
virDomainDefPtr ret;
- if (VIR_ALLOC(ret) < 0)
- return NULL;
+ ret = g_new0(virDomainDef, 1);
if (!(ret->numa = virDomainNumaNew()))
goto error;
else
family = virSocketAddrNumericFamily(address);
- if (VIR_ALLOC(ip) < 0)
- return NULL;
+ ip = g_new0(virNetDevIPAddr, 1);
if (virSocketAddrParse(&ip->address, address, family) < 0) {
virReportError(VIR_ERR_XML_ERROR,
if (!str)
return NULL;
- if (VIR_ALLOC(ret) < 0)
- return NULL;
+ ret = g_new0(virNetDevCoalesce, 1);
if (virStrToLong_ullp(str, NULL, 10, &tmp) < 0) {
virReportError(VIR_ERR_XML_DETAIL,
if (n == 0)
return 0;
- if (VIR_ALLOC_N(def->seclabels, n) < 0)
- goto error;
+ def->seclabels = g_new0(virSecurityLabelDefPtr, n);
/* Parse each "seclabel" tag */
for (i = 0; i < n; i++) {
if (n == 0)
return 0;
- if (VIR_ALLOC_N(seclabels, n) < 0)
- goto error;
+ seclabels = g_new0(virSecurityDeviceLabelDefPtr, n);
nseclabels = n;
- for (i = 0; i < n; i++) {
- if (VIR_ALLOC(seclabels[i]) < 0)
- goto error;
- }
+ for (i = 0; i < n; i++)
+ seclabels[i] = g_new0(virSecurityDeviceLabelDef, 1);
for (i = 0; i < n; i++) {
/* get model associated to this override */
g_autofree char *path = NULL;
g_autofree char *offset = NULL;
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ def = g_new0(virDomainLeaseDef, 1);
cur = node->children;
while (cur != NULL) {
*srcpool = NULL;
- if (VIR_ALLOC(source) < 0)
- return -1;
+ source = g_new0(virStorageSourcePoolDef, 1);
source->pool = virXMLPropString(node, "pool");
source->volume = virXMLPropString(node, "volume");
g_autofree char *trustGuestRxFilters = NULL;
g_autofree char *macTableManager = NULL;
- if (VIR_ALLOC(actual) < 0)
- return -1;
+ actual = g_new0(virDomainActualNetDef, 1);
ctxt->node = node;
unsigned int prefix)
{
virNetDevIPAddrPtr ipDef = NULL;
- if (VIR_ALLOC(ipDef) < 0)
- return -1;
+ ipDef = g_new0(virNetDevIPAddr, 1);
if (virSocketAddrParse(&ipDef->address, address, family) < 0)
goto error;
addrStr = virXMLPropString(cur, "address");
portStr = virXMLPropString(cur, "port");
- if (VIR_ALLOC(def->target.addr) < 0)
- return -1;
+ def->target.addr = g_new0(virSocketAddr, 1);
if (addrStr == NULL) {
virReportError(VIR_ERR_XML_ERROR, "%s",
{
virDomainChrDefPtr def = NULL;
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ def = g_new0(virDomainChrDef, 1);
def->target.port = -1;
g_autofree char *mode = NULL;
g_autofree char *type = NULL;
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ def = g_new0(virDomainSmartcardDef, 1);
mode = virXMLPropString(node, "mode");
if (mode == NULL) {
g_autofree char *secretuuid = NULL;
g_autofree xmlNodePtr *backends = NULL;
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ def = g_new0(virDomainTPMDef, 1);
model = virXMLPropString(node, "model");
if (model != NULL &&
virDomainPanicDefPtr panic;
g_autofree char *model = NULL;
- if (VIR_ALLOC(panic) < 0)
- return NULL;
+ panic = g_new0(virDomainPanicDef, 1);
if (virDomainDeviceInfoParseXML(xmlopt, node,
&panic->info, flags) < 0)
g_autofree char *bus = NULL;
g_autofree char *model = NULL;
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ def = g_new0(virDomainInputDef, 1);
ctxt->node = node;
virDomainHubDefPtr def;
g_autofree char *type = NULL;
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ def = g_new0(virDomainHubDef, 1);
type = virXMLPropString(node, "type");
g_autofree char *track = NULL;
g_autofree char *mode = NULL;
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ def = g_new0(virDomainTimerDef, 1);
ctxt->node = node;
if (nListens > 0) {
size_t i;
- if (VIR_ALLOC_N(def->listens, nListens) < 0)
- goto cleanup;
+ def->listens = g_new0(virDomainGraphicsListenDef, nListens);
for (i = 0; i < nListens; i++) {
if (virDomainGraphicsListenDefParseXML(&def->listens[i], def,
{
virDomainGraphicsDefPtr def = NULL;
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ def = g_new0(virDomainGraphicsDef, 1);
if (xmlopt && xmlopt->privateData.graphicsNew &&
!(def->privateData = xmlopt->privateData.graphicsNew())) {
{
virDomainNetDefPtr def = NULL;
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ def = g_new0(virDomainNetDef, 1);
if (xmlopt && xmlopt->privateData.networkNew &&
!(def->privateData = xmlopt->privateData.networkNew())) {
virDomainSoundCodecDefPtr def;
g_autofree char *type = NULL;
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ def = g_new0(virDomainSoundCodecDef, 1);
type = virXMLPropString(node, "type");
if ((def->type = virDomainSoundCodecTypeFromString(type)) < 0) {
g_autofree char *model = NULL;
xmlNodePtr audioNode;
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ def = g_new0(virDomainSoundDef, 1);
ctxt->node = node;
model = virXMLPropString(node, "model");
if (ncodecs > 0) {
size_t i;
- if (VIR_ALLOC_N(def->codecs, ncodecs) < 0)
- goto error;
+ def->codecs = g_new0(virDomainSoundCodecDefPtr, ncodecs);
for (i = 0; i < ncodecs; i++) {
virDomainSoundCodecDefPtr codec = virDomainSoundCodecDefParseXML(codecNodes[i]);
g_autofree char *tmp = NULL;
g_autofree char *type = NULL;
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ def = g_new0(virDomainAudioDef, 1);
ctxt->node = node;
type = virXMLPropString(node, "type");
g_autofree char *model = NULL;
g_autofree char *action = NULL;
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ def = g_new0(virDomainWatchdogDef, 1);
model = virXMLPropString(node, "model");
if (model == NULL) {
g_autofree char *backend = NULL;
g_autofree char *type = NULL;
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ def = g_new0(virDomainRNGDef, 1);
if (!(model = virXMLPropString(node, "model"))) {
virReportError(VIR_ERR_XML_ERROR, "%s", _("missing RNG device model"));
g_autofree char *model = NULL;
g_autofree char *deflate = NULL;
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ def = g_new0(virDomainMemballoonDef, 1);
model = virXMLPropString(node, "model");
if (model == NULL) {
{
virDomainNVRAMDefPtr def;
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ def = g_new0(virDomainNVRAMDef, 1);
if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0)
goto error;
xmlNodePtr server = NULL;
g_autofree char *tmp = NULL;
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ def = g_new0(virDomainShmemDef, 1);
ctxt->node = node;
return ret;
}
- if (VIR_ALLOC(def) < 0)
- goto cleanup;
+ def = g_new0(virSysinfoBIOSDef, 1);
def->vendor = virXPathString("string(entry[@name='vendor'])", ctxt);
def->version = virXPathString("string(entry[@name='version'])", ctxt);
return ret;
}
- if (VIR_ALLOC(def) < 0)
- goto cleanup;
+ def = g_new0(virSysinfoSystemDef, 1);
def->manufacturer =
virXPathString("string(entry[@name='manufacturer'])", ctxt);
if ((n = virXPathNodeSet("./baseBoard", ctxt, &nodes)) < 0)
return -1;
- if (n && VIR_ALLOC_N(boards, n) < 0)
- return -1;
+ if (n)
+ boards = g_new0(virSysinfoBaseBoardDef, n);
for (i = 0; i < n; i++) {
virSysinfoBaseBoardDefPtr def = boards + nboards;
if (nstrings == 0)
return 0;
- if (VIR_ALLOC(def) < 0)
- goto cleanup;
+ def = g_new0(virSysinfoOEMStringsDef, 1);
- if (VIR_ALLOC_N(def->values, nstrings) < 0)
- goto cleanup;
+ def->values = g_new0(char *, nstrings);
def->nvalues = nstrings;
for (i = 0; i < nstrings; i++) {
return ret;
}
- if (VIR_ALLOC(def) < 0)
- goto cleanup;
+ def = g_new0(virSysinfoChassisDef, 1);
def->manufacturer =
virXPathString("string(entry[@name='manufacturer'])", ctxt);
*chassisdef = g_steal_pointer(&def);
ret = 0;
- cleanup:
virSysinfoChassisDefFree(def);
return ret;
}
return NULL;
}
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ def = g_new0(virSysinfoDef, 1);
typeStr = virXMLPropString(node, "type");
if (typeStr == NULL) {
if (!vgaconf)
return NULL;
- if (VIR_ALLOC(def) < 0)
- return def;
+ def = g_new0(virDomainVideoDriverDef, 1);
if ((val = virDomainVideoVGAConfTypeFromString(vgaconf)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
g_autofree char *bus = NULL;
g_autofree char *type = NULL;
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ def = g_new0(virDomainRedirdevDef, 1);
if (!(def->source = virDomainChrSourceDefNew(xmlopt)))
goto error;
g_autofree char *version = NULL;
g_autofree char *allow = NULL;
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ def = g_new0(virDomainRedirFilterUSBDevDef, 1);
class = virXMLPropString(node, "class");
if (class) {
virDomainRedirFilterDefPtr def = NULL;
g_autofree xmlNodePtr *nodes = NULL;
- if (VIR_ALLOC(def) < 0)
- goto error;
+ def = g_new0(virDomainRedirFilterDef, 1);
ctxt->node = node;
if ((n = virXPathNodeSet("./usbdev", ctxt, &nodes)) < 0)
goto error;
- if (n && VIR_ALLOC_N(def->usbdevs, n) < 0)
- goto error;
+ if (n)
+ def->usbdevs = g_new0(virDomainRedirFilterUSBDevDefPtr, n);
for (i = 0; i < n; i++) {
virDomainRedirFilterUSBDevDefPtr usbdev =
unsigned long policy;
g_autofree char *type = NULL;
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ def = g_new0(virDomainSEVDef, 1);
ctxt->node = sevNode;
int val;
g_autofree char *tmp = NULL;
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ def = g_new0(virDomainMemoryDef, 1);
ctxt->node = memdevNode;
ctxt->node = node;
- if (VIR_ALLOC(iommu) < 0)
- return NULL;
+ iommu = g_new0(virDomainIOMMUDef, 1);
if (!(tmp = virXMLPropString(node, "model"))) {
virReportError(VIR_ERR_XML_ERROR, "%s",
node = ctxt->node;
- if (VIR_ALLOC(dev) < 0)
- return NULL;
+ dev = g_new0(virDomainDeviceDef, 1);
if ((dev->type = virDomainDeviceTypeFromString((const char *) node->name)) < 0) {
/* Some crazy mapping of serial, parallel, console and channel to
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(def->nets[i]->ifname);
iface->hwaddr = g_strdup(macaddr);
}
virArpTableEntry entry = table->t[j];
if (STREQ(entry.mac, macaddr)) {
- if (VIR_ALLOC(iface) < 0)
- goto cleanup;
+ iface = g_new0(virDomainInterface, 1);
iface->name = g_strdup(def->nets[i]->ifname);
iface->hwaddr = g_strdup(macaddr);
- if (VIR_ALLOC(iface->addrs) < 0)
- goto cleanup;
+ iface->addrs = g_new0(virDomainIPAddress, 1);
iface->naddrs = 1;
iface->addrs->addr = g_strdup(entry.ipaddr);
virDomainIdMapEntryPtr idmap = NULL;
VIR_XPATH_NODE_AUTORESTORE(ctxt)
- if (VIR_ALLOC_N(idmap, num) < 0)
- return idmap;
+ idmap = g_new0(virDomainIdMapEntry, num);
for (i = 0; i < num; i++) {
ctxt->node = node[i];
virDomainIOThreadIDDefPtr iothrid;
g_autofree char *tmp = NULL;
- if (VIR_ALLOC(iothrid) < 0)
- return NULL;
+ iothrid = g_new0(virDomainIOThreadIDDef, 1);
if (!(tmp = virXMLPropString(node, "id"))) {
virReportError(VIR_ERR_XML_ERROR, "%s",
if (n > iothreads)
iothreads = n;
- if (n && VIR_ALLOC_N(def->iothreadids, n) < 0)
- return -1;
+ if (n)
+ def->iothreadids = g_new0(virDomainIOThreadIDDefPtr, n);
for (i = 0; i < n; i++) {
virDomainIOThreadIDDefPtr iothrid = NULL;
return 0;
}
- if (VIR_ALLOC(input) < 0)
- return -1;
+ input = g_new0(virDomainInputDef, 1);
input->type = type;
input->bus = bus;
ctxt->node = node;
- if (VIR_ALLOC(def) < 0)
- goto error;
+ def = g_new0(virDomainResourceDef, 1);
/* Find out what type of virtualization to use */
if (!(def->partition = virXPathString("string(./partition)", ctxt))) {
{
g_autofree virDomainThreadSchedParamPtr sched = NULL;
- if (VIR_ALLOC(sched) < 0)
- return -1;
+ sched = g_new0(virDomainThreadSchedParam, 1);
if (virDomainSchedulerParseCommonAttrs(node,
&sched->policy,
if ((n = virXPathNodeSet("./os/initarg", ctxt, &nodes)) < 0)
return -1;
- if (VIR_ALLOC_N(def->os.initargv, n+1) < 0)
- return -1;
+ def->os.initargv = g_new0(char *, n+1);
for (i = 0; i < n; i++) {
if (!nodes[i]->children ||
!nodes[i]->children->content) {
if ((n = virXPathNodeSet("./os/initenv", ctxt, &nodes)) < 0)
return -1;
- if (VIR_ALLOC_N(def->os.initenv, n+1) < 0)
- return -1;
+ def->os.initenv = g_new0(virDomainOSEnvPtr, n+1);
for (i = 0; i < n; i++) {
if (!(name = virXMLPropString(nodes[i], "name"))) {
virReportError(VIR_ERR_XML_ERROR, "%s",
return -1;
}
- if (VIR_ALLOC(def->os.initenv[i]) < 0)
- return -1;
-
+ def->os.initenv[i] = g_new0(virDomainOSEnv, 1);
def->os.initenv[i]->name = name;
def->os.initenv[i]->value = g_strdup((const char *)nodes[i]->children->content);
}
if ((loader_node = virXPathNode("./os/loader[1]", ctxt))) {
const bool fwAutoSelect = def->os.firmware != VIR_DOMAIN_OS_DEF_FIRMWARE_NONE;
- if (VIR_ALLOC(def->os.loader) < 0)
- return -1;
+ def->os.loader = g_new0(virDomainLoaderDef, 1);
if (virDomainLoaderDefParseXML(loader_node,
def->os.loader,
}
for (i = 0; i < n; i++) {
- if (VIR_ALLOC(domresmon) < 0)
- goto cleanup;
+ domresmon = g_new0(virDomainResctrlMonDef, 1);
domresmon->tag = tag;
}
if (n) {
- if (VIR_ALLOC_N(def->mem.hugepages, n) < 0)
- goto error;
+ def->mem.hugepages = g_new0(virDomainHugePage, n);
for (i = 0; i < n; i++) {
if (virDomainHugepagesParseXML(nodes[i], ctxt,
VIR_FREE(nodes);
} else {
/* no hugepage pages */
- if (VIR_ALLOC(def->mem.hugepages) < 0)
- goto error;
-
+ def->mem.hugepages = g_new0(virDomainHugePage, 1);
def->mem.nhugepages = 1;
}
}
"%s", _("cannot extract blkiotune nodes"));
goto error;
}
- if (n && VIR_ALLOC_N(def->blkio.devices, n) < 0)
- goto error;
+ if (n)
+ def->blkio.devices = g_new0(virBlkioDevice, n);
for (i = 0; i < n; i++) {
if (virDomainBlkioDeviceParseXML(nodes[i],
if ((n = virXPathNodeSet("./clock/timer", ctxt, &nodes)) < 0)
goto error;
- if (n && VIR_ALLOC_N(def->clock.timers, n) < 0)
- goto error;
+ if (n)
+ def->clock.timers = g_new0(virDomainTimerDefPtr, n);
for (i = 0; i < n; i++) {
virDomainTimerDefPtr timer = virDomainTimerDefParseXML(nodes[i],
if ((n = virXPathNodeSet("./devices/controller", ctxt, &nodes)) < 0)
goto error;
- if (n && VIR_ALLOC_N(def->controllers, n) < 0)
- goto error;
+ if (n)
+ def->controllers = g_new0(virDomainControllerDefPtr, n);
for (i = 0; i < n; i++) {
virDomainControllerDefPtr controller = virDomainControllerDefParseXML(xmlopt,
if ((n = virXPathNodeSet("./devices/disk", ctxt, &nodes)) < 0)
goto error;
- if (n && VIR_ALLOC_N(def->disks, n) < 0)
- goto error;
+ if (n)
+ def->disks = g_new0(virDomainDiskDefPtr, n);
for (i = 0; i < n; i++) {
virDomainDiskDefPtr disk = virDomainDiskDefParseXML(xmlopt,
"%s", _("cannot extract device leases"));
goto error;
}
- if (n && VIR_ALLOC_N(def->leases, n) < 0)
- goto error;
+ if (n)
+ def->leases = g_new0(virDomainLeaseDefPtr, n);
for (i = 0; i < n; i++) {
virDomainLeaseDefPtr lease = virDomainLeaseDefParseXML(nodes[i]);
if (!lease)
/* analysis of the filesystems */
if ((n = virXPathNodeSet("./devices/filesystem", ctxt, &nodes)) < 0)
goto error;
- if (n && VIR_ALLOC_N(def->fss, n) < 0)
- goto error;
+ if (n)
+ def->fss = g_new0(virDomainFSDefPtr, n);
for (i = 0; i < n; i++) {
virDomainFSDefPtr fs = virDomainFSDefParseXML(xmlopt,
nodes[i],
/* analysis of the network devices */
if ((n = virXPathNodeSet("./devices/interface", ctxt, &nodes)) < 0)
goto error;
- if (n && VIR_ALLOC_N(def->nets, n) < 0)
- goto error;
+ if (n)
+ def->nets = g_new0(virDomainNetDefPtr, n);
for (i = 0; i < n; i++) {
virDomainNetDefPtr net = virDomainNetDefParseXML(xmlopt,
nodes[i],
/* analysis of the smartcard devices */
if ((n = virXPathNodeSet("./devices/smartcard", ctxt, &nodes)) < 0)
goto error;
- if (n && VIR_ALLOC_N(def->smartcards, n) < 0)
- goto error;
+ if (n)
+ def->smartcards = g_new0(virDomainSmartcardDefPtr, n);
for (i = 0; i < n; i++) {
virDomainSmartcardDefPtr card = virDomainSmartcardDefParseXML(xmlopt,
/* analysis of the character devices */
if ((n = virXPathNodeSet("./devices/parallel", ctxt, &nodes)) < 0)
goto error;
- if (n && VIR_ALLOC_N(def->parallels, n) < 0)
- goto error;
+ if (n)
+ def->parallels = g_new0(virDomainChrDefPtr, n);
for (i = 0; i < n; i++) {
virDomainChrDefPtr chr = virDomainChrDefParseXML(xmlopt,
if ((n = virXPathNodeSet("./devices/serial", ctxt, &nodes)) < 0)
goto error;
- if (n && VIR_ALLOC_N(def->serials, n) < 0)
- goto error;
+ if (n)
+ def->serials = g_new0(virDomainChrDefPtr, n);
for (i = 0; i < n; i++) {
virDomainChrDefPtr chr = virDomainChrDefParseXML(xmlopt,
"%s", _("cannot extract console devices"));
goto error;
}
- if (n && VIR_ALLOC_N(def->consoles, n) < 0)
- goto error;
+ if (n)
+ def->consoles = g_new0(virDomainChrDefPtr, n);
for (i = 0; i < n; i++) {
virDomainChrDefPtr chr = virDomainChrDefParseXML(xmlopt,
if ((n = virXPathNodeSet("./devices/channel", ctxt, &nodes)) < 0)
goto error;
- if (n && VIR_ALLOC_N(def->channels, n) < 0)
- goto error;
+ if (n)
+ def->channels = g_new0(virDomainChrDefPtr, n);
for (i = 0; i < n; i++) {
virDomainChrDefPtr chr = virDomainChrDefParseXML(xmlopt,
/* analysis of the input devices */
if ((n = virXPathNodeSet("./devices/input", ctxt, &nodes)) < 0)
goto error;
- if (n && VIR_ALLOC_N(def->inputs, n) < 0)
- goto error;
+ if (n)
+ def->inputs = g_new0(virDomainInputDefPtr, n);
for (i = 0; i < n; i++) {
virDomainInputDefPtr input = virDomainInputDefParseXML(xmlopt,
/* analysis of the graphics devices */
if ((n = virXPathNodeSet("./devices/graphics", ctxt, &nodes)) < 0)
goto error;
- if (n && VIR_ALLOC_N(def->graphics, n) < 0)
- goto error;
+ if (n)
+ def->graphics = g_new0(virDomainGraphicsDefPtr, n);
for (i = 0; i < n; i++) {
virDomainGraphicsDefPtr graphics = virDomainGraphicsDefParseXML(xmlopt,
nodes[i],
/* analysis of the sound devices */
if ((n = virXPathNodeSet("./devices/sound", ctxt, &nodes)) < 0)
goto error;
- if (n && VIR_ALLOC_N(def->sounds, n) < 0)
- goto error;
+ if (n)
+ def->sounds = g_new0(virDomainSoundDefPtr, n);
for (i = 0; i < n; i++) {
virDomainSoundDefPtr sound = virDomainSoundDefParseXML(xmlopt,
nodes[i],
/* analysis of the audio devices */
if ((n = virXPathNodeSet("./devices/audio", ctxt, &nodes)) < 0)
goto error;
- if (n && VIR_ALLOC_N(def->audios, n) < 0)
- goto error;
+ if (n)
+ def->audios = g_new0(virDomainAudioDefPtr, n);
for (i = 0; i < n; i++) {
virDomainAudioDefPtr audio = virDomainAudioDefParseXML(xmlopt,
nodes[i],
/* analysis of the video devices */
if ((n = virXPathNodeSet("./devices/video", ctxt, &nodes)) < 0)
goto error;
- if (n && VIR_ALLOC_N(def->videos, n) < 0)
- goto error;
+ if (n)
+ def->videos = g_new0(virDomainVideoDefPtr, n);
for (i = 0; i < n; i++) {
virDomainVideoDefPtr video;
ssize_t insertAt = -1;
/* Parse the RNG devices */
if ((n = virXPathNodeSet("./devices/rng", ctxt, &nodes)) < 0)
goto error;
- if (n && VIR_ALLOC_N(def->rngs, n) < 0)
- goto error;
+ if (n)
+ def->rngs = g_new0(virDomainRNGDefPtr, n);
for (i = 0; i < n; i++) {
virDomainRNGDefPtr rng = virDomainRNGDefParseXML(xmlopt, nodes[i],
ctxt, flags);
goto error;
}
- if (n && VIR_ALLOC_N(def->tpms, n) < 0)
- goto error;
+ if (n)
+ def->tpms = g_new0(virDomainTPMDefPtr, n);
for (i = 0; i < n; i++) {
virDomainTPMDefPtr tpm = virDomainTPMDefParseXML(xmlopt, nodes[i],
/* analysis of the hub devices */
if ((n = virXPathNodeSet("./devices/hub", ctxt, &nodes)) < 0)
goto error;
- if (n && VIR_ALLOC_N(def->hubs, n) < 0)
- goto error;
+ if (n)
+ def->hubs = g_new0(virDomainHubDefPtr, n);
for (i = 0; i < n; i++) {
virDomainHubDefPtr hub;
/* analysis of the redirected devices */
if ((n = virXPathNodeSet("./devices/redirdev", ctxt, &nodes)) < 0)
goto error;
- if (n && VIR_ALLOC_N(def->redirdevs, n) < 0)
- goto error;
+ if (n)
+ def->redirdevs = g_new0(virDomainRedirdevDefPtr, n);
for (i = 0; i < n; i++) {
virDomainRedirdevDefPtr redirdev =
virDomainRedirdevDefParseXML(xmlopt, nodes[i], ctxt, flags);
/* analysis of the panic devices */
if ((n = virXPathNodeSet("./devices/panic", ctxt, &nodes)) < 0)
goto error;
- if (n && VIR_ALLOC_N(def->panics, n) < 0)
- goto error;
+ if (n)
+ def->panics = g_new0(virDomainPanicDefPtr, n);
for (i = 0; i < n; i++) {
virDomainPanicDefPtr panic;
/* analysis of the shmem devices */
if ((n = virXPathNodeSet("./devices/shmem", ctxt, &nodes)) < 0)
goto error;
- if (n && VIR_ALLOC_N(def->shmems, n) < 0)
- goto error;
+ if (n)
+ def->shmems = g_new0(virDomainShmemDefPtr, n);
node = ctxt->node;
for (i = 0; i < n; i++) {
/* analysis of memory devices */
if ((n = virXPathNodeSet("./devices/memory", ctxt, &nodes)) < 0)
goto error;
- if (n && VIR_ALLOC_N(def->mems, n) < 0)
- goto error;
+ if (n)
+ def->mems = g_new0(virDomainMemoryDefPtr, n);
for (i = 0; i < n; i++) {
virDomainMemoryDefPtr mem = virDomainMemoryDefParseXML(xmlopt,
{
virDomainIOThreadIDDefPtr iothrid = NULL;
- if (VIR_ALLOC(iothrid) < 0)
- goto error;
+ iothrid = g_new0(virDomainIOThreadIDDef, 1);
iothrid->iothread_id = iothread_id;
return NULL;
}
- if (VIR_ALLOC_N(shortname, len + 1) < 0)
- return NULL;
+ shortname = g_new0(char, len + 1);
if (wcstombs(shortname, wshortname, len) == (size_t) -1) {
virReportSystemError(errno, "%s",
return NULL;
}
- if (VIR_ALLOC(port) < 0)
- return NULL;
+ port = g_new0(virNetworkPortDef, 1);
if (virUUIDGenerate(port->uuid) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
return -1;
}
- if (VIR_ALLOC(actual) < 0)
- return -1;
+ actual = g_new0(virDomainActualNetDef, 1);
switch ((virNetworkPortPlugType)port->plugtype) {
case VIR_NETWORK_PORT_PLUG_TYPE_NONE:
return NULL;
}
- if (VIR_ALLOC(port) < 0)
- return NULL;
+ port = g_new0(virNetworkPortDef, 1);
if (virUUIDIsValid(iface->data.network.portid)) {
memcpy(port->uuid, iface->data.network.portid, VIR_UUID_BUFLEN);