VIR_STRDUP(dst->vendor, src->vendor) < 0 ||
VIR_STRDUP(dst->vendor_id, src->vendor_id) < 0 ||
VIR_ALLOC_N(dst->features, src->nfeatures) < 0)
- goto no_memory;
+ return -1;
dst->nfeatures_max = dst->nfeatures = src->nfeatures;
for (i = 0; i < dst->nfeatures; i++) {
}
return 0;
-
-no_memory:
- virReportOOMError();
- return -1;
}
virCPUDefPtr
virCPUDefPtr copy;
unsigned int i;
- if (!cpu)
+ if (!cpu || VIR_ALLOC(copy) < 0)
return NULL;
- if (VIR_ALLOC(copy) < 0)
- goto no_memory;
-
copy->type = cpu->type;
copy->mode = cpu->mode;
copy->match = cpu->match;
if (cpu->ncells) {
if (VIR_ALLOC_N(copy->cells, cpu->ncells) < 0)
- goto no_memory;
+ goto error;
copy->ncells_max = copy->ncells = cpu->ncells;
for (i = 0; i < cpu->ncells; i++) {
copy->cells[i].cpumask = virBitmapNewCopy(cpu->cells[i].cpumask);
if (!copy->cells[i].cpumask)
- goto no_memory;
+ goto error;
if (VIR_STRDUP(copy->cells[i].cpustr, cpu->cells[i].cpustr) < 0)
goto error;
return copy;
-no_memory:
- virReportOOMError();
error:
virCPUDefFree(copy);
return NULL;
return NULL;
}
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
if (mode == VIR_CPU_TYPE_AUTO) {
if (virXPathBoolean("boolean(./arch)", ctxt)) {
if (VIR_RESIZE_N(def->features, def->nfeatures_max,
def->nfeatures, n) < 0)
- goto no_memory;
+ goto error;
def->nfeatures = n;
}
if (VIR_RESIZE_N(def->cells, def->ncells_max,
def->ncells, n) < 0)
- goto no_memory;
+ goto error;
def->ncells = n;
VIR_FREE(nodes);
return def;
-no_memory:
- virReportOOMError();
-
error:
virCPUDefFree(def);
def = NULL;
if (VIR_RESIZE_N(def->features, def->nfeatures_max,
def->nfeatures, 1) < 0)
- goto no_memory;
+ return -1;
if (def->type == VIR_CPU_TYPE_HOST)
policy = -1;
def->nfeatures++;
return 0;
-
-no_memory:
- virReportOOMError();
- return -1;
}
bool
{
virDomainHostdevDefPtr def = NULL;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
- return NULL;
- }
- if (VIR_ALLOC(def->info) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0 ||
+ VIR_ALLOC(def->info) < 0)
VIR_FREE(def);
- return NULL;
- }
return def;
}
int i = 0;
virDomainVcpuPinDefPtr *ret = NULL;
- if (VIR_ALLOC_N(ret, nvcpupin) < 0) {
- goto no_memory;
- }
+ if (VIR_ALLOC_N(ret, nvcpupin) < 0)
+ goto error;
for (i = 0; i < nvcpupin; i++) {
if (VIR_ALLOC(ret[i]) < 0)
- goto no_memory;
+ goto error;
ret[i]->vcpuid = src[i]->vcpuid;
if ((ret[i]->cpumask = virBitmapNewCopy(src[i]->cpumask)) == NULL)
- goto no_memory;
+ goto error;
}
return ret;
-no_memory:
+error:
if (ret) {
for (; i >= 0; --i) {
if (ret[i]) {
}
VIR_FREE(ret);
}
- virReportOOMError();
return NULL;
}
return NULL;
if (xmlopt->privateData.alloc) {
- if (!(domain->privateData = (xmlopt->privateData.alloc)())) {
- virReportOOMError();
+ if (!(domain->privateData = (xmlopt->privateData.alloc)()))
goto error;
- }
domain->privateDataFreeFunc = xmlopt->privateData.free;
}
{
virDomainDefPtr def;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
if (VIR_STRDUP(def->name, name) < 0) {
VIR_FREE(def);
for (i = 0; i < VIR_DOMAIN_CONTROLLER_TYPE_LAST; i++) {
if (max_idx[i] >= 0 && !(bitmaps[i] = virBitmapNew(max_idx[i] + 1)))
- goto no_memory;
+ goto cleanup;
nbitmaps++;
}
for (i = 0; i < nbitmaps; i++)
virBitmapFree(bitmaps[i]);
return ret;
-
-no_memory:
- virReportOOMError();
- goto cleanup;
}
/* create the serial port definition from the console definition */
if (def->nserials == 0) {
- if (VIR_APPEND_ELEMENT_QUIET(def->serials,
- def->nserials,
- def->consoles[0]) < 0)
- goto no_memory;
+ if (VIR_APPEND_ELEMENT(def->serials,
+ def->nserials,
+ def->consoles[0]) < 0)
+ return -1;
/* modify it to be a serial port */
def->serials[0]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
if (!def->consoles[0]) {
/* allocate a new console type for the stolen one */
if (VIR_ALLOC(def->consoles[0]) < 0)
- goto no_memory;
+ return -1;
/* Create an console alias for the serial port */
def->consoles[0]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
if (virDomainDefRejectDuplicateControllers(def) < 0)
return -1;
return 0;
-
-no_memory:
- virReportOOMError();
- return -1;
}
char *p;
virSecurityLabelDefPtr def = NULL;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
goto error;
- }
p = virXPathStringLimit("string(./@type)",
VIR_SECURITY_LABEL_BUFLEN-1, ctxt);
if (n == 0)
return 0;
- if (VIR_ALLOC_N(def->seclabels, n) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(def->seclabels, n) < 0)
goto error;
- }
/* Parse each "seclabel" tag */
for (i = 0; i < n; i++) {
if (n == 0)
return 0;
- if (VIR_ALLOC_N(seclabels, n) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(seclabels, n) < 0)
goto error;
- }
nseclabels = n;
for (i = 0; i < n; i++) {
- if (VIR_ALLOC(seclabels[i]) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(seclabels[i]) < 0)
goto error;
- }
}
for (i = 0; i < n; i++) {
char *path = NULL;
char *offset = NULL;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
cur = node->children;
while (cur != NULL) {
goto cleanup;
}
- if (VIR_ALLOC(def->srcpool) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def->srcpool) < 0)
goto cleanup;
- }
def->srcpool->pool = pool;
pool = NULL;
int expected_secret_usage = -1;
int auth_secret_usage = -1;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
def->geometry.cylinders = 0;
def->geometry.heads = 0;
while (child != NULL) {
if (child->type == XML_ELEMENT_NODE &&
xmlStrEqual(child->name, BAD_CAST "host")) {
- if (VIR_REALLOC_N(hosts, nhosts + 1) < 0) {
- virReportOOMError();
+ if (VIR_REALLOC_N(hosts, nhosts + 1) < 0)
goto error;
- }
hosts[nhosts].name = NULL;
hosts[nhosts].port = NULL;
hosts[nhosts].transport = VIR_DOMAIN_DISK_PROTO_TRANS_TCP;
if (def->srcpool) {
char *tmp;
if (virAsprintf(&tmp, "pool = '%s', volume = '%s'",
- def->srcpool->pool, def->srcpool->volume) < 0) {
- virReportOOMError();
+ def->srcpool->pool, def->srcpool->volume) < 0)
goto error;
- }
virReportError(VIR_ERR_NO_TARGET, "%s", tmp);
VIR_FREE(tmp);
char *model = NULL;
char *queues = NULL;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
type = virXMLPropString(node, "type");
if (type) {
unsigned long long bytes;
*val = 0;
- if (virAsprintf(&xpath_full, "string(%s)", xpath) < 0) {
- virReportOOMError();
+ if (virAsprintf(&xpath_full, "string(%s)", xpath) < 0)
goto cleanup;
- }
ret = virXPathULongLong(xpath_full, ctxt, &bytes);
if (ret < 0) {
if (ret == -2)
}
VIR_FREE(xpath_full);
- if (virAsprintf(&xpath_full, "string(%s/@unit)", xpath) < 0) {
- virReportOOMError();
+ if (virAsprintf(&xpath_full, "string(%s/@unit)", xpath) < 0)
goto cleanup;
- }
unit = virXPathString(xpath_full, ctxt);
if (virScaleInteger(&bytes, unit, scale, max) < 0)
ctxt->node = node;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
type = virXMLPropString(node, "type");
if (type) {
char *mode = NULL;
char *addrtype = NULL;
- if (VIR_ALLOC(actual) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(actual) < 0)
return -1;
- }
ctxt->node = node;
xmlNodePtr oldnode = ctxt->node;
int ret;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
ctxt->node = node;
addrStr = virXMLPropString(cur, "address");
portStr = virXMLPropString(cur, "port");
- if (VIR_ALLOC(def->target.addr) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def->target.addr) < 0)
goto error;
- }
if (addrStr == NULL) {
virReportError(VIR_ERR_XML_ERROR, "%s",
virDomainChrDefNew(void) {
virDomainChrDefPtr def = NULL;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
def->target.port = -1;
return def;
virDomainSmartcardDefPtr def;
int i;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
mode = virXMLPropString(node, "mode");
if (mode == NULL) {
xmlNodePtr *backends = NULL;
int nbackends;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
model = virXMLPropString(node, "model");
if (model != NULL &&
char *type = NULL;
char *bus = NULL;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
type = virXMLPropString(node, "type");
bus = virXMLPropString(node, "bus");
virDomainHubDefPtr def;
char *type = NULL;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
type = virXMLPropString(node, "type");
xmlNodePtr catchup;
int ret;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
ctxt->node = node;
char *listenAddr = NULL;
xmlNodePtr save = ctxt->node;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
ctxt->node = node;
if (nListens > 0) {
int ii;
- if (VIR_ALLOC_N(def->listens, nListens) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(def->listens, nListens) < 0)
goto error;
- }
for (ii = 0; ii < nListens; ii++) {
int ret = virDomainGraphicsListenDefParseXML(&def->listens[ii],
char *type;
virDomainSoundCodecDefPtr def;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
type = virXMLPropString(node, "type");
if ((def->type = virDomainSoundCodecTypeFromString(type)) < 0) {
virDomainSoundDefPtr def;
xmlNodePtr save = ctxt->node;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
ctxt->node = node;
int ii;
if (VIR_ALLOC_N(def->codecs, ncodecs) < 0) {
- virReportOOMError();
VIR_FREE(codecNodes);
goto error;
}
char *action = NULL;
virDomainWatchdogDefPtr def;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
model = virXMLPropString(node, "model");
if (model == NULL) {
xmlNodePtr *backends = NULL;
int nbackends;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
if (!(model = virXMLPropString(node, "model"))) {
virReportError(VIR_ERR_XML_ERROR, "%s", _("missing RNG device model"));
goto error;
}
- if (VIR_ALLOC(def->source.chardev) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def->source.chardev) < 0)
goto error;
- }
def->source.chardev->type = virDomainChrTypeFromString(type);
if (def->source.chardev->type < 0) {
char *model;
virDomainMemballoonDefPtr def;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
model = virXMLPropString(node, "model");
if (model == NULL) {
{
virDomainNVRAMDefPtr def;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0)
goto error;
return NULL;
}
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
type = virXMLPropString(node, "type");
if (type == NULL) {
if (!support3d && !support2d)
return NULL;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
if (support3d) {
if (STREQ(support3d, "yes"))
char *ram = NULL;
char *primary = NULL;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
cur = node->children;
while (cur != NULL) {
char *bus, *type = NULL;
int remaining;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
bus = virXMLPropString(node, "bus");
if (bus) {
char *version = NULL, *allow = NULL;
virDomainRedirFilterUsbDevDefPtr def;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
class = virXMLPropString(node, "class");
if (class) {
virDomainRedirFilterDefPtr def = NULL;
if (VIR_ALLOC(def) < 0)
- goto no_memory;
+ goto error;
ctxt->node = node;
if ((n = virXPathNodeSet("./usbdev", ctxt, &nodes)) < 0) {
}
if (n && VIR_ALLOC_N(def->usbdevs, n) < 0)
- goto no_memory;
+ goto error;
for (i = 0; i < n; i++) {
virDomainRedirFilterUsbDevDefPtr usbdev =
ctxt->node = save;
return def;
-no_memory:
- virReportOOMError();
-
error:
VIR_FREE(nodes);
virDomainRedirFilterDefFree(def);
node = ctxt->node;
- if (VIR_ALLOC(dev) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(dev) < 0)
goto error;
- }
if (xmlStrEqual(node->name, BAD_CAST "disk")) {
dev->type = VIR_DOMAIN_DEVICE_DISK;
int virDomainLeaseInsertPreAlloc(virDomainDefPtr def)
{
- if (VIR_EXPAND_N(def->leases, def->nleases, 1) < 0) {
- virReportOOMError();
- return -1;
- }
- return 0;
+ return VIR_EXPAND_N(def->leases, def->nleases, 1);
}
int virDomainLeaseInsert(virDomainDefPtr def,
virDomainIdMapEntryPtr idmap = NULL;
xmlNodePtr save_ctxt = ctxt->node;
- if (VIR_ALLOC_N(idmap, num) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(idmap, num) < 0)
goto cleanup;
- }
for (i = 0; i < num; i++) {
ctxt->node = node[i];
char *tmp = NULL;
int ret;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
ctxt->node = node;
return 0;
}
- if (VIR_ALLOC(cont) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(cont) < 0)
return -1;
- }
cont->type = type;
cont->idx = idx;
cont->opts.vioserial.vectors = -1;
}
- if (VIR_APPEND_ELEMENT_QUIET(def->controllers, def->ncontrollers, cont) < 0) {
+ if (VIR_APPEND_ELEMENT(def->controllers, def->ncontrollers, cont) < 0) {
VIR_FREE(cont);
- virReportOOMError();
return -1;
}
ctxt->node = node;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
goto error;
- }
/* Find out what type of virtualization to use */
if (!(def->partition = virXPathString("string(./partition)", ctxt))) {
bool usb_master = false;
bool primaryVideo = false;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
if (!(flags & VIR_DOMAIN_XML_INACTIVE))
if (virXPathLong("string(./@id)", ctxt, &id) < 0)
goto error;
}
if (n && VIR_ALLOC_N(def->blkio.devices, n) < 0)
- goto no_memory;
+ goto error;
for (i = 0; i < n; i++) {
int j;
goto error;
if (n && VIR_ALLOC_N(def->cputune.vcpupin, n) < 0)
- goto no_memory;
+ goto error;
if (n > def->maxvcpus) {
virReportError(VIR_ERR_INTERNAL_ERROR,
* the policy specified explicitly as def->cpuset.
*/
if (def->cpumask) {
- if (VIR_REALLOC_N(def->cputune.vcpupin, def->vcpus) < 0) {
- virReportOOMError();
+ if (VIR_REALLOC_N(def->cputune.vcpupin, def->vcpus) < 0)
goto error;
- }
for (i = 0; i < def->vcpus; i++) {
if (virDomainVcpuPinIsDuplicate(def->cputune.vcpupin,
virDomainVcpuPinDefPtr vcpupin = NULL;
- if (VIR_ALLOC(vcpupin) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(vcpupin) < 0)
goto error;
- }
vcpupin->cpumask = virBitmapNew(VIR_DOMAIN_CPUMASK_LEN);
virBitmapCopy(vcpupin->cpumask, def->cpumask);
goto error;
if (n && VIR_ALLOC_N(def->clock.timers, n) < 0)
- goto no_memory;
+ goto error;
for (i = 0; i < n; i++) {
virDomainTimerDefPtr timer = virDomainTimerDefParseXML(nodes[i],
}
if (VIR_ALLOC_N(def->os.initargv, n+1) < 0)
- goto no_memory;
+ goto error;
for (i = 0; i < n; i++) {
if (!nodes[i]->children ||
!nodes[i]->children->content) {
goto error;
if (n && VIR_ALLOC_N(def->disks, n) < 0)
- goto no_memory;
+ goto error;
for (i = 0; i < n; i++) {
virDomainDiskDefPtr disk = virDomainDiskDefParseXML(xmlopt,
goto error;
if (n && VIR_ALLOC_N(def->controllers, n) < 0)
- goto no_memory;
+ goto error;
for (i = 0; i < n; i++) {
virDomainControllerDefPtr controller = virDomainControllerDefParseXML(nodes[i],
goto error;
}
if (n && VIR_ALLOC_N(def->leases, n) < 0)
- goto no_memory;
+ goto error;
for (i = 0; i < n; i++) {
virDomainLeaseDefPtr lease = virDomainLeaseDefParseXML(nodes[i]);
if (!lease)
goto error;
}
if (n && VIR_ALLOC_N(def->fss, n) < 0)
- goto no_memory;
+ goto error;
for (i = 0; i < n; i++) {
virDomainFSDefPtr fs = virDomainFSDefParseXML(nodes[i], ctxt,
flags);
goto error;
}
if (n && VIR_ALLOC_N(def->nets, n) < 0)
- goto no_memory;
+ goto error;
for (i = 0; i < n; i++) {
virDomainNetDefPtr net = virDomainNetDefParseXML(xmlopt,
nodes[i],
/* <interface type='hostdev'> must also be in the hostdevs array */
if (net->type == VIR_DOMAIN_NET_TYPE_HOSTDEV &&
virDomainHostdevInsert(def, &net->data.hostdev.def) < 0) {
- goto no_memory;
+ goto error;
}
}
VIR_FREE(nodes);
goto error;
}
if (n && VIR_ALLOC_N(def->smartcards, n) < 0)
- goto no_memory;
+ goto error;
for (i = 0; i < n; i++) {
virDomainSmartcardDefPtr card = virDomainSmartcardDefParseXML(nodes[i],
goto error;
}
if (n && VIR_ALLOC_N(def->parallels, n) < 0)
- goto no_memory;
+ goto error;
for (i = 0; i < n; i++) {
virDomainChrDefPtr chr = virDomainChrDefParseXML(ctxt,
goto error;
if (n && VIR_ALLOC_N(def->serials, n) < 0)
- goto no_memory;
+ goto error;
for (i = 0; i < n; i++) {
virDomainChrDefPtr chr = virDomainChrDefParseXML(ctxt,
goto error;
}
if (n && VIR_ALLOC_N(def->consoles, n) < 0)
- goto no_memory;
+ goto error;
for (i = 0; i < n; i++) {
virDomainChrDefPtr chr = virDomainChrDefParseXML(ctxt,
goto error;
}
if (n && VIR_ALLOC_N(def->channels, n) < 0)
- goto no_memory;
+ goto error;
for (i = 0; i < n; i++) {
virDomainChrDefPtr chr = virDomainChrDefParseXML(ctxt,
goto error;
}
if (n && VIR_ALLOC_N(def->inputs, n) < 0)
- goto no_memory;
+ goto error;
for (i = 0; i < n; i++) {
virDomainInputDefPtr input = virDomainInputDefParseXML(def->os.type,
goto error;
}
if (n && VIR_ALLOC_N(def->graphics, n) < 0)
- goto no_memory;
+ goto error;
for (i = 0; i < n; i++) {
virDomainGraphicsDefPtr graphics = virDomainGraphicsDefParseXML(nodes[i],
ctxt,
virDomainInputDefPtr input;
if (VIR_ALLOC(input) < 0) {
- goto no_memory;
+ goto error;
}
if (STREQ(def->os.type, "hvm")) {
input->type = VIR_DOMAIN_INPUT_TYPE_MOUSE;
if (VIR_REALLOC_N(def->inputs, def->ninputs + 1) < 0) {
virDomainInputDefFree(input);
- goto no_memory;
+ goto error;
}
def->inputs[def->ninputs] = input;
def->ninputs++;
goto error;
}
if (n && VIR_ALLOC_N(def->sounds, n) < 0)
- goto no_memory;
+ goto error;
for (i = 0; i < n; i++) {
virDomainSoundDefPtr sound = virDomainSoundDefParseXML(nodes[i],
ctxt,
goto error;
}
if (n && VIR_ALLOC_N(def->videos, n) < 0)
- goto no_memory;
+ goto error;
for (i = 0; i < n; i++) {
size_t ii = def->nvideos;
virDomainVideoDefPtr video = virDomainVideoDefParseXML(nodes[i],
ii = 0;
primaryVideo = true;
}
- if (VIR_INSERT_ELEMENT_INPLACE_QUIET(def->videos,
- ii,
- def->nvideos,
- video) < 0) {
+ if (VIR_INSERT_ELEMENT_INPLACE(def->videos,
+ ii,
+ def->nvideos,
+ video) < 0) {
virDomainVideoDefFree(video);
goto error;
}
if (def->ngraphics && !def->nvideos) {
virDomainVideoDefPtr video;
if (VIR_ALLOC(video) < 0)
- goto no_memory;
+ goto error;
video->type = virDomainVideoDefaultType(def);
if (video->type < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
video->heads = 1;
if (VIR_ALLOC_N(def->videos, 1) < 0) {
virDomainVideoDefFree(video);
- goto no_memory;
+ goto error;
}
def->videos[def->nvideos++] = video;
}
goto error;
}
if (n && VIR_REALLOC_N(def->hostdevs, def->nhostdevs + n) < 0)
- goto no_memory;
+ goto error;
for (i = 0; i < n; i++) {
virDomainHostdevDefPtr hostdev;
def->virtType == VIR_DOMAIN_VIRT_KVM) {
virDomainMemballoonDefPtr memballoon;
if (VIR_ALLOC(memballoon) < 0)
- goto no_memory;
+ goto error;
memballoon->model = def->virtType == VIR_DOMAIN_VIRT_XEN ?
VIR_DOMAIN_MEMBALLOON_MODEL_XEN :
VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO;
goto error;
}
if (n && VIR_ALLOC_N(def->hubs, n) < 0)
- goto no_memory;
+ goto error;
for (i = 0; i < n; i++) {
virDomainHubDefPtr hub = virDomainHubDefParseXML(nodes[i], flags);
if (!hub)
goto error;
}
if (n && VIR_ALLOC_N(def->redirdevs, n) < 0)
- goto no_memory;
+ goto error;
for (i = 0; i < n; i++) {
virDomainRedirdevDefPtr redirdev = virDomainRedirdevDefParseXML(nodes[i],
bootHash,
return def;
-no_memory:
- virReportOOMError();
error:
VIR_FREE(tmp);
VIR_FREE(nodes);
vcpupin->vcpuid = vcpu;
virBitmapFree(vcpupin->cpumask);
vcpupin->cpumask = virBitmapNewData(cpumap, maplen);
- if (!vcpupin->cpumask) {
- virReportOOMError();
+ if (!vcpupin->cpumask)
return -1;
- }
return 0;
}
/* No existing vcpupin matches vcpu, adding a new one */
if (VIR_ALLOC(vcpupin) < 0)
- goto no_memory;
+ goto error;
vcpupin->vcpuid = vcpu;
vcpupin->cpumask = virBitmapNewData(cpumap, maplen);
if (!vcpupin->cpumask)
- goto no_memory;
+ goto error;
if (VIR_REALLOC_N(*vcpupin_list, *nvcpupin + 1) < 0)
- goto no_memory;
+ goto error;
(*vcpupin_list)[(*nvcpupin)++] = vcpupin;
return 0;
-no_memory:
- virReportOOMError();
+error:
virDomainVcpuPinDefFree(vcpupin);
return -1;
}
if (--def->cputune.nvcpupin == 0) {
VIR_FREE(def->cputune.vcpupin);
} else {
- if (VIR_REALLOC_N(def->cputune.vcpupin, def->cputune.nvcpupin) < 0) {
- virReportOOMError();
+ if (VIR_REALLOC_N(def->cputune.vcpupin, def->cputune.nvcpupin) < 0)
return -1;
- }
}
return 0;
if (!def->cputune.emulatorpin) {
/* No emulatorpin exists yet. */
- if (VIR_ALLOC(emulatorpin) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(emulatorpin) < 0)
return -1;
- }
emulatorpin->vcpuid = -1;
emulatorpin->cpumask = virBitmapNewData(cpumap, maplen);
{
char *ret;
- if (virAsprintf(&ret, "%s/%s.xml", dir, name) < 0)
- virReportOOMError();
-
+ ignore_value(virAsprintf(&ret, "%s/%s.xml", dir, name));
return ret;
}
def->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
if (!def->listens && (ii == 0) && force0) {
- if (VIR_ALLOC(def->listens) < 0)
- virReportOOMError();
- else
+ if (VIR_ALLOC(def->listens) >= 0)
def->nListens = 1;
}
};
virObjectLock(doms);
- if (domains) {
- if (VIR_ALLOC_N(data.domains, virHashSize(doms->objs) + 1) < 0) {
- virReportOOMError();
- goto cleanup;
- }
- }
+ if (domains &&
+ VIR_ALLOC_N(data.domains, virHashSize(doms->objs) + 1) < 0)
+ goto cleanup;
virHashForEach(doms->objs, virDomainListPopulate, &data);
if (VIR_ALLOC(seclabel) < 0 ||
VIR_STRDUP(seclabel->model, model) < 0) {
- virReportOOMError();
virSecurityLabelDefFree(seclabel);
seclabel = NULL;
}
if (VIR_ALLOC(seclabel) < 0 ||
VIR_STRDUP(seclabel->model, model) < 0) {
- virReportOOMError();
virSecurityDeviceLabelDefFree(seclabel);
seclabel = NULL;
}
}
/* Allocate new event */
if (VIR_ALLOC(event) < 0)
- goto no_memory;
+ goto error;
event->conn = conn;
event->cb = callback;
event->eventID = eventID;
if (dom) {
if (VIR_ALLOC(event->dom) < 0)
- goto no_memory;
+ goto error;
if (VIR_STRDUP(event->dom->name, dom->name) < 0)
goto error;
memcpy(event->dom->uuid, dom->uuid, VIR_UUID_BUFLEN);
/* Make space on list */
if (VIR_REALLOC_N(cbList->callbacks, cbList->count + 1) < 0)
- goto no_memory;
+ goto error;
virObjectRef(event->conn);
return ret;
-no_memory:
- virReportOOMError();
error:
if (event) {
if (event->dom)
{
virDomainEventQueuePtr ret;
- if (VIR_ALLOC(ret) < 0) {
- virReportOOMError();
- return NULL;
- }
-
+ ignore_value(VIR_ALLOC(ret));
return ret;
}
{
virDomainEventStatePtr state = NULL;
- if (VIR_ALLOC(state) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(state) < 0)
goto error;
- }
if (virMutexInit(&state->lock) < 0) {
virReportSystemError(errno, "%s",
goto error;
}
- if (VIR_ALLOC(state->callbacks) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(state->callbacks) < 0)
goto error;
- }
if (!(state->queue = virDomainEventQueueNew()))
goto error;
{
virDomainEventPtr event;
- if (VIR_ALLOC(event) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(event) < 0)
return NULL;
- }
event->eventID = eventID;
if (VIR_STRDUP(event->dom.name, name) < 0) {
/* Make space on queue */
if (VIR_REALLOC_N(evtQueue->events,
- evtQueue->count + 1) < 0) {
- virReportOOMError();
+ evtQueue->count + 1) < 0)
return -1;
- }
evtQueue->events[evtQueue->count] = event;
evtQueue->count++;
if (ipNodes == NULL)
return 0;
- if (VIR_ALLOC_N(def->ips, nIpNodes) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(def->ips, nIpNodes) < 0)
goto error;
- }
def->nips = 0;
for (ii = 0; ii < nIpNodes; ii++) {
virInterfaceIpDefPtr ip;
- if (VIR_ALLOC(ip) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(ip) < 0)
goto error;
- }
ctxt->node = ipNodes[ii];
ret = virInterfaceDefParseIp(ip, ctxt);
if (ipNodes == NULL)
return 0;
- if (VIR_ALLOC_N(def->ips, nIpNodes) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(def->ips, nIpNodes) < 0)
goto error;
- }
def->nips = 0;
for (ii = 0; ii < nIpNodes; ii++) {
virInterfaceIpDefPtr ip;
- if (VIR_ALLOC(ip) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(ip) < 0)
goto error;
- }
ctxt->node = ipNodes[ii];
ret = virInterfaceDefParseIp(ip, ctxt);
return 0;
}
- if (VIR_ALLOC_N(def->protos, nProtoNodes) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(def->protos, nProtoNodes) < 0)
goto error;
- }
def->nprotos = 0;
for (pp = 0; pp < nProtoNodes; pp++) {
virInterfaceProtocolDefPtr proto;
- if (VIR_ALLOC(proto) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(proto) < 0)
goto error;
- }
ctxt->node = protoNodes[pp];
tmp = virXPathString("string(./@family)", ctxt);
}
if (nbItf > 0) {
if (VIR_ALLOC_N(def->data.bridge.itf, nbItf) < 0) {
- virReportOOMError();
ret = -1;
goto error;
}
}
if (VIR_ALLOC_N(def->data.bond.itf, nbItf) < 0) {
- virReportOOMError();
ret = -1;
goto error;
}
}
VIR_FREE(tmp);
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
if (((parentIfType == VIR_INTERFACE_TYPE_BOND)
&& (type != VIR_INTERFACE_TYPE_ETHERNET))
return iface;
}
- if (VIR_ALLOC(iface) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(iface) < 0)
return NULL;
- }
if (virMutexInit(&iface->lock) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot initialize mutex"));
iface->def = def;
if (VIR_REALLOC_N(interfaces->objs, interfaces->count + 1) < 0) {
- virReportOOMError();
VIR_FREE(iface);
return NULL;
}
xmlNodePtr cur;
xmlNodePtr in = NULL, out = NULL;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
if (!node || !xmlStrEqual(node->name, BAD_CAST "bandwidth")) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
}
if (in) {
- if (VIR_ALLOC(def->in) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def->in) < 0)
goto error;
- }
if (virNetDevBandwidthParseRate(in, def->in) < 0) {
/* helper reported error for us */
}
if (out) {
- if (VIR_ALLOC(def->out) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def->out) < 0)
goto error;
- }
if (virNetDevBandwidthParseRate(out, def->out) < 0) {
/* helper reported error for us */
goto cleanup;
}
- if (VIR_ALLOC_N(def->tag, nTags) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(def->tag, nTags) < 0)
goto cleanup;
- }
def->nativeMode = 0;
def->nativeTag = 0;
virNetDevVPortProfilePtr virtPort = NULL;
xmlNodePtr cur = node->children;
- if (VIR_ALLOC(virtPort) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(virtPort) < 0)
return NULL;
- }
if ((virtPortType = virXMLPropString(node, "type")) &&
(virtPort->virtPortType = virNetDevVPortTypeFromString(virtPortType)) <= 0) {
return network;
}
- if (VIR_REALLOC_N(nets->objs, nets->count + 1) < 0) {
- virReportOOMError();
+ if (VIR_REALLOC_N(nets->objs, nets->count + 1) < 0)
return NULL;
- }
- if (VIR_ALLOC(network) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(network) < 0)
return NULL;
- }
if (virMutexInit(&network->lock) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot initialize mutex"));
virNetworkObjLock(network);
network->def = def;
- if (!(network->class_id = virBitmapNew(CLASS_ID_BITMAP_SIZE))) {
- virReportOOMError();
+ if (!(network->class_id = virBitmapNew(CLASS_ID_BITMAP_SIZE)))
goto error;
- }
/* The first three class IDs are already taken */
ignore_value(virBitmapSetBit(network->class_id, 0));
if (cur->type == XML_ELEMENT_NODE &&
xmlStrEqual(cur->name, BAD_CAST "range")) {
- if (VIR_REALLOC_N(def->ranges, def->nranges + 1) < 0) {
- virReportOOMError();
+ if (VIR_REALLOC_N(def->ranges, def->nranges + 1) < 0)
return -1;
- }
if (virSocketAddrRangeParseXML(networkName, cur,
&def->ranges[def->nranges]) < 0) {
return -1;
} else if (cur->type == XML_ELEMENT_NODE &&
xmlStrEqual(cur->name, BAD_CAST "host")) {
- if (VIR_REALLOC_N(def->hosts, def->nhosts + 1) < 0) {
- virReportOOMError();
+ if (VIR_REALLOC_N(def->hosts, def->nhosts + 1) < 0)
return -1;
- }
if (virNetworkDHCPHostDefParseXML(networkName, def, cur,
&def->hosts[def->nhosts],
false) < 0) {
if (cur->type == XML_ELEMENT_NODE &&
xmlStrEqual(cur->name, BAD_CAST "hostname")) {
if (cur->children != NULL) {
- if (VIR_REALLOC_N(def->names, def->nnames + 1) < 0) {
- virReportOOMError();
+ if (VIR_REALLOC_N(def->names, def->nnames + 1) < 0)
goto error;
- }
def->names[def->nnames++] = (char *)xmlNodeGetContent(cur);
if (!def->names[def->nnames - 1]) {
virReportError(VIR_ERR_XML_DETAIL,
goto cleanup;
}
if (nhosts > 0) {
- if (VIR_ALLOC_N(def->hosts, nhosts) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(def->hosts, nhosts) < 0)
goto cleanup;
- }
for (ii = 0; ii < nhosts; ii++) {
if (virNetworkDNSHostDefParseXML(networkName, hostNodes[ii],
goto cleanup;
}
if (nsrvs > 0) {
- if (VIR_ALLOC_N(def->srvs, nsrvs) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(def->srvs, nsrvs) < 0)
goto cleanup;
- }
for (ii = 0; ii < nsrvs; ii++) {
if (virNetworkDNSSrvDefParseXML(networkName, srvNodes[ii], ctxt,
goto cleanup;
}
if (ntxts > 0) {
- if (VIR_ALLOC_N(def->txts, ntxts) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(def->txts, ntxts) < 0)
goto cleanup;
- }
for (ii = 0; ii < ntxts; ii++) {
if (virNetworkDNSTxtDefParseXML(networkName, txtNodes[ii],
}
if (nForwardIfs > 0 || forwardDev) {
-
- if (VIR_ALLOC_N(def->ifs, MAX(nForwardIfs, 1)) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(def->ifs, MAX(nForwardIfs, 1)) < 0)
goto cleanup;
- }
if (forwardDev) {
def->ifs[0].device.dev = forwardDev;
}
} else if (nForwardAddrs > 0) {
-
- if (VIR_ALLOC_N(def->ifs, nForwardAddrs) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(def->ifs, nForwardAddrs) < 0)
goto cleanup;
- }
for (ii = 0; ii < nForwardAddrs; ii++) {
if (!(type = virXMLPropString(forwardAddrNodes[ii], "type"))) {
networkName);
goto cleanup;
} else if (nForwardPfs == 1) {
-
- if (VIR_ALLOC_N(def->pfs, nForwardPfs) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(def->pfs, nForwardPfs) < 0)
goto cleanup;
- }
forwardDev = virXMLPropString(*forwardPfNodes, "dev");
if (!forwardDev) {
def->pfs->dev = forwardDev;
forwardDev = NULL;
def->npfs++;
-
}
ret = 0;
xmlNodePtr bandwidthNode = NULL;
xmlNodePtr vlanNode;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
/* Extract network name */
def->name = virXPathString("string(./name[1])", ctxt);
int ii;
/* allocate array to hold all the portgroups */
- if (VIR_ALLOC_N(def->portGroups, nPortGroups) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(def->portGroups, nPortGroups) < 0)
goto error;
- }
/* parse each portgroup */
for (ii = 0; ii < nPortGroups; ii++) {
int ret = virNetworkPortGroupParseXML(&def->portGroups[ii],
int ii;
/* allocate array to hold all the addrs */
- if (VIR_ALLOC_N(def->ips, nIps) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(def->ips, nIps) < 0)
goto error;
- }
/* parse each addr */
for (ii = 0; ii < nIps; ii++) {
int ret = virNetworkIPDefParseXML(def->name, ipNodes[ii],
int ii;
/* allocate array to hold all the route definitions */
- if (VIR_ALLOC_N(def->routes, nRoutes) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(def->routes, nRoutes) < 0)
goto error;
- }
/* parse each definition */
for (ii = 0; ii < nRoutes; ii++) {
int ret = virNetworkRouteDefParseXML(def->name, routeNodes[ii],
{
char *ret = NULL;
- if (virAsprintf(&ret, "%s/%s.xml", dir, name) < 0) {
- virReportOOMError();
- return NULL;
- }
-
+ ignore_value(virAsprintf(&ret, "%s/%s.xml", dir, name));
return ret;
}
template = "virbr%d";
do {
- if (virAsprintf(&newname, template, id) < 0) {
- virReportOOMError();
+ if (virAsprintf(&newname, template, id) < 0)
return NULL;
- }
if (!virNetworkBridgeInUse(nets, newname, NULL)) {
return newname;
}
}
/* add to beginning/end of list */
- if (VIR_INSERT_ELEMENT_QUIET(ipdef->hosts,
- command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST
- ? 0 : ipdef->nhosts,
- ipdef->nhosts, host) < 0) {
- virReportOOMError();
+ if (VIR_INSERT_ELEMENT(ipdef->hosts,
+ command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST
+ ? 0 : ipdef->nhosts,
+ ipdef->nhosts, host) < 0)
goto cleanup;
- }
} else if (command == VIR_NETWORK_UPDATE_COMMAND_DELETE) {
if (virNetworkDHCPHostDefParseXML(def->name, ipdef,
}
/* add to beginning/end of list */
- if (VIR_INSERT_ELEMENT_QUIET(ipdef->ranges,
- command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST
- ? 0 : ipdef->nranges,
- ipdef->nranges, range) < 0) {
- virReportOOMError();
+ if (VIR_INSERT_ELEMENT(ipdef->ranges,
+ command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST
+ ? 0 : ipdef->nranges,
+ ipdef->nranges, range) < 0)
goto cleanup;
- }
-
} else if (command == VIR_NETWORK_UPDATE_COMMAND_DELETE) {
if (ii == ipdef->nranges) {
}
/* add to beginning/end of list */
- if (VIR_INSERT_ELEMENT_QUIET(def->forward.ifs,
- command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST
- ? 0 : def->forward.nifs,
- def->forward.nifs, iface) < 0) {
- virReportOOMError();
+ if (VIR_INSERT_ELEMENT(def->forward.ifs,
+ command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST
+ ? 0 : def->forward.nifs,
+ def->forward.nifs, iface) < 0)
goto cleanup;
- }
-
} else if (command == VIR_NETWORK_UPDATE_COMMAND_DELETE) {
if (ii == def->forward.nifs) {
(command == VIR_NETWORK_UPDATE_COMMAND_ADD_LAST)) {
/* add to beginning/end of list */
- if (VIR_INSERT_ELEMENT_QUIET(def->portGroups,
- command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST
- ? 0 : def->nPortGroups,
- def->nPortGroups, portgroup) < 0) {
- virReportOOMError();
+ if (VIR_INSERT_ELEMENT(def->portGroups,
+ command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST
+ ? 0 : def->nPortGroups,
+ def->nPortGroups, portgroup) < 0)
goto cleanup;
- }
-
} else if (command == VIR_NETWORK_UPDATE_COMMAND_DELETE) {
/* remove it */
}
/* add to beginning/end of list */
- if (VIR_INSERT_ELEMENT_QUIET(dns->hosts,
- command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST
- ? 0 : dns->nhosts, dns->nhosts, host) < 0) {
- virReportOOMError();
+ if (VIR_INSERT_ELEMENT(dns->hosts,
+ command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST
+ ? 0 : dns->nhosts, dns->nhosts, host) < 0)
goto cleanup;
- }
-
} else if (command == VIR_NETWORK_UPDATE_COMMAND_DELETE) {
if (foundCt == 0) {
}
/* add to beginning/end of list */
- if (VIR_INSERT_ELEMENT_QUIET(dns->srvs,
- command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST
- ? 0 : dns->nsrvs, dns->nsrvs, srv) < 0) {
- virReportOOMError();
+ if (VIR_INSERT_ELEMENT(dns->srvs,
+ command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST
+ ? 0 : dns->nsrvs, dns->nsrvs, srv) < 0)
goto cleanup;
- }
-
} else if (command == VIR_NETWORK_UPDATE_COMMAND_DELETE) {
if (foundCt == 0) {
}
/* add to beginning/end of list */
- if (VIR_INSERT_ELEMENT_QUIET(dns->txts,
- command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST
- ? 0 : dns->ntxts, dns->ntxts, txt) < 0) {
- virReportOOMError();
+ if (VIR_INSERT_ELEMENT(dns->txts,
+ command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST
+ ? 0 : dns->ntxts, dns->ntxts, txt) < 0)
goto cleanup;
- }
-
} else if (command == VIR_NETWORK_UPDATE_COMMAND_DELETE) {
if (foundIdx == dns->ntxts) {
int ret = -1;
int i;
- if (nets) {
- if (VIR_ALLOC_N(tmp_nets, netobjs.count + 1) < 0) {
- virReportOOMError();
- goto cleanup;
- }
- }
+ if (nets && VIR_ALLOC_N(tmp_nets, netobjs.count + 1) < 0)
+ goto cleanup;
for (i = 0; i < netobjs.count; i++) {
virNetworkObjPtr netobj = netobjs.objs[i];
return device;
}
- if (VIR_ALLOC(device) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(device) < 0)
return NULL;
- }
if (virMutexInit(&device->lock) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
device->def = NULL;
virNodeDeviceObjUnlock(device);
virNodeDeviceObjFree(device);
- virReportOOMError();
return NULL;
}
devs->objs[devs->count++] = device;
virDevicePCIAddress addr = { 0, 0, 0, 0, 0 };
if (virDevicePCIAddressParseXML(addrNodes[ii], &addr) < 0)
goto cleanup;
- if (VIR_ALLOC(pciAddr) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(pciAddr) < 0)
goto cleanup;
- }
pciAddr->domain = addr.domain;
pciAddr->bus = addr.bus;
pciAddr->slot = addr.slot;
pciAddr->function = addr.function;
if (VIR_APPEND_ELEMENT(data->pci_dev.iommuGroupDevices,
data->pci_dev.nIommuGroupDevices,
- pciAddr) < 0) {
- virReportOOMError();
+ pciAddr) < 0)
goto cleanup;
- }
}
ret = 0;
char *tmp;
int val, ret;
- if (VIR_ALLOC(caps) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(caps) < 0)
return NULL;
- }
tmp = virXMLPropString(node, "type");
if (!tmp) {
xmlNodePtr *nodes;
int n, i;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
return NULL;
- }
/* Extract device name */
if (create == EXISTING_DEVICE) {
int ret = -1;
int i;
- if (devices) {
- if (VIR_ALLOC_N(tmp_devices, devobjs.count + 1) < 0) {
- virReportOOMError();
- goto cleanup;
- }
- }
+ if (devices && VIR_ALLOC_N(tmp_devices, devobjs.count + 1) < 0)
+ goto cleanup;
for (i = 0; i < devobjs.count; i++) {
virNodeDeviceObjPtr devobj = devobjs.objs[i];
}
if (VIR_EXPAND_N(nwf->varAccess, nwf->nVarAccess, 1) < 0) {
- virReportOOMError();
virNWFilterVarAccessFree(varAccess);
return -1;
}
const char *string,
size_t maxstrlen)
{
- if (VIR_REALLOC_N(nwf->strings, nwf->nstrings+1) < 0) {
- virReportOOMError();
+ if (VIR_REALLOC_N(nwf->strings, nwf->nstrings+1) < 0)
return NULL;
- }
if (VIR_STRNDUP(nwf->strings[nwf->nstrings], string, maxstrlen) < 0)
return NULL;
{
virNWFilterIncludeDefPtr ret;
- if (VIR_ALLOC(ret) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(ret) < 0)
return NULL;
- }
ret->filterref = virXMLPropString(cur, "filter");
if (!ret->filterref) {
xmlNodePtr cur;
virNWFilterRuleDefPtr ret;
- if (VIR_ALLOC(ret) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(ret) < 0)
return NULL;
- }
action = virXMLPropString(node, "action");
direction = virXMLPropString(node, "direction");
int chain_priority;
const char *name_prefix;
- if (VIR_ALLOC(ret) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(ret) < 0)
return NULL;
- }
ret->name = virXPathString("string(./@name)", ctxt);
if (!ret->name) {
while (curr != NULL) {
if (curr->type == XML_ELEMENT_NODE) {
- if (VIR_ALLOC(entry) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(entry) < 0)
goto cleanup;
- }
/* ignore malformed rule and include elements */
if (xmlStrEqual(curr->name, BAD_CAST "rule"))
if (entry->rule || entry->include) {
if (VIR_REALLOC_N(ret->filterEntries, ret->nentries+1) < 0) {
VIR_FREE(entry);
- virReportOOMError();
goto cleanup;
}
ret->filterEntries[ret->nentries++] = entry;
virNWFilterUnlockFilterUpdates();
- if (VIR_ALLOC(nwfilter) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(nwfilter) < 0)
return NULL;
- }
if (virMutexInitRecursive(&nwfilter->lock) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
nwfilter->def = NULL;
virNWFilterObjUnlock(nwfilter);
virNWFilterObjFree(nwfilter);
- virReportOOMError();
return NULL;
}
nwfilters->objs[nwfilters->count++] = nwfilter;
{
char *ret = NULL;
- if (virAsprintf(&ret, "%s/%s.xml", dir, name) < 0) {
- virReportOOMError();
- return NULL;
- }
-
+ ignore_value(virAsprintf(&ret, "%s/%s.xml", dir, name));
return ret;
}
val = virHashLookup(ipAddressMap->hashTable, ifname);
if (!val) {
val = virNWFilterVarValueCreateSimple(addr);
- if (!val) {
- virReportOOMError();
+ if (!val)
goto cleanup;
- }
ret = virNWFilterHashTablePut(ipAddressMap, ifname, val, 1);
goto cleanup;
} else {
virNWFilterIPAddrMapInit(void)
{
ipAddressMap = virNWFilterHashTableCreate(0);
- if (!ipAddressMap) {
- virReportOOMError();
+ if (!ipAddressMap)
return -1;
- }
if (virMutexInit(&ipAddressMapLock) < 0) {
virNWFilterIPAddrMapShutdown();
unsigned i;
char *str;
- if (VIR_ALLOC(res) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(res) < 0)
return NULL;
- }
res->valType = val->valType;
switch (res->valType) {
return res;
err_exit:
- virReportOOMError();
virNWFilterVarValueFree(res);
return NULL;
}
return NULL;
}
- if (VIR_ALLOC(val) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(val) < 0)
return NULL;
- }
val->valType = NWFILTER_VALUE_TYPE_SIMPLE;
val->u.simple.value = value;
tmp = val->u.simple.value;
if (VIR_ALLOC_N(val->u.array.values, 2) < 0) {
val->u.simple.value = tmp;
- virReportOOMError();
return -1;
}
val->valType = NWFILTER_VALUE_TYPE_ARRAY;
case NWFILTER_VALUE_TYPE_ARRAY:
if (VIR_EXPAND_N(val->u.array.values,
- val->u.array.nValues, 1) < 0) {
- virReportOOMError();
+ val->u.array.nValues, 1) < 0)
return -1;
- }
val->u.array.values[val->u.array.nValues - 1] = value;
rc = 0;
break;
}
}
- if (VIR_EXPAND_N(cie->varNames, cie->nVarNames, 1) < 0) {
- virReportOOMError();
+ if (VIR_EXPAND_N(cie->varNames, cie->nVarNames, 1) < 0)
return -1;
- }
cie->varNames[cie->nVarNames - 1] = varName;
int iterIndex = -1;
unsigned int nextIntIterId = VIR_NWFILTER_MAX_ITERID + 1;
- if (VIR_ALLOC_VAR(res, virNWFilterVarCombIterEntry, 1 + nVarAccess) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_VAR(res, virNWFilterVarCombIterEntry, 1 + nVarAccess) < 0)
return NULL;
- }
res->hashTable = hash;
virNWFilterHashTableCreate(int n) {
virNWFilterHashTablePtr ret;
- if (VIR_ALLOC(ret) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(ret) < 0)
return NULL;
- }
ret->hashTable = virHashCreate(n, hashDataFree);
if (!ret->hashTable) {
VIR_FREE(ret);
val = virNWFilterVarValueCopy((virNWFilterVarValuePtr)payload);
if (!val) {
- virReportOOMError();
atts->errOccurred = 1;
return;
}
virNWFilterVarValuePtr value;
virNWFilterHashTablePtr table = virNWFilterHashTableCreate(0);
- if (!table) {
- virReportOOMError();
+ if (!table)
return NULL;
- }
cur = cur->children;
virNWFilterVarAccessPtr dest;
const char *input = varAccess;
- if (VIR_ALLOC(dest) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(dest) < 0)
return NULL;
- }
idx = strspn(input, VALID_VARNAME);
}
ctxt->node = root;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
goto cleanup;
- }
prop = virXPathString("string(./@ephemeral)", ctxt);
if (prop != NULL) {
}
xmlKeepBlanksDefault(keepBlanksDefault);
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
goto cleanup;
- }
if (!xmlStrEqual(ctxt->node->name, BAD_CAST "domainsnapshot")) {
virReportError(VIR_ERR_XML_ERROR, "%s", _("domainsnapshot"));
_("a redefined snapshot must have a name"));
goto cleanup;
}
- if (virAsprintf(&def->name, "%lld", (long long)tv.tv_sec) < 0) {
- virReportOOMError();
+ if (virAsprintf(&def->name, "%lld", (long long)tv.tv_sec) < 0)
goto cleanup;
- }
}
def->description = virXPathString("string(./description)", ctxt);
goto cleanup;
if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_DISKS) {
def->ndisks = i;
- if (def->ndisks && VIR_ALLOC_N(def->disks, def->ndisks) < 0) {
- virReportOOMError();
+ if (def->ndisks && VIR_ALLOC_N(def->disks, def->ndisks) < 0)
goto cleanup;
- }
for (i = 0; i < def->ndisks; i++) {
if (virDomainSnapshotDiskDefParseXML(nodes[i], &def->disks[i]) < 0)
goto cleanup;
goto cleanup;
}
- if (!(map = virBitmapNew(def->dom->ndisks))) {
- virReportOOMError();
+ if (!(map = virBitmapNew(def->dom->ndisks)))
goto cleanup;
- }
/* Double check requested disks. */
for (i = 0; i < def->ndisks; i++) {
/* Provide defaults for all remaining disks. */
ndisks = def->ndisks;
if (VIR_EXPAND_N(def->disks, def->ndisks,
- def->dom->ndisks - def->ndisks) < 0) {
- virReportOOMError();
+ def->dom->ndisks - def->ndisks) < 0)
goto cleanup;
- }
for (i = 0; i < def->dom->ndisks; i++) {
virDomainSnapshotDiskDefPtr disk;
tmp = strrchr(original, '.');
if (!tmp || strchr(tmp, '/')) {
- ignore_value(virAsprintf(&disk->file, "%s.%s",
- original, def->name));
+ if (virAsprintf(&disk->file, "%s.%s", original, def->name) < 0)
+ goto cleanup;
} else {
if ((tmp - original) > INT_MAX) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("integer overflow"));
goto cleanup;
}
- ignore_value(virAsprintf(&disk->file, "%.*s.%s",
- (int) (tmp - original), original,
- def->name));
- }
- if (!disk->file) {
- virReportOOMError();
- goto cleanup;
+ if (virAsprintf(&disk->file, "%.*s.%s",
+ (int) (tmp - original), original,
+ def->name) < 0)
+ goto cleanup;
}
}
}
{
virDomainSnapshotObjPtr snapshot;
- if (VIR_ALLOC(snapshot) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(snapshot) < 0)
return NULL;
- }
VIR_DEBUG("obj=%p", snapshot);
virDomainSnapshotObjListNew(void)
{
virDomainSnapshotObjListPtr snapshots;
- if (VIR_ALLOC(snapshots) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(snapshots) < 0)
return NULL;
- }
snapshots->objs = virHashCreate(50, virDomainSnapshotObjListDataFree);
if (!snapshots->objs) {
VIR_FREE(snapshots);
if (!snaps || count < 0)
return count;
if (VIR_ALLOC_N(names, count) < 0 ||
- VIR_ALLOC_N(list, count + 1) < 0) {
- virReportOOMError();
+ VIR_ALLOC_N(list, count + 1) < 0)
goto cleanup;
- }
if (virDomainSnapshotObjListGetNames(snapshots, from, names, count,
flags) < 0)
source->nhost = n;
if (source->nhost) {
- if (VIR_ALLOC_N(source->hosts, source->nhost) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(source->hosts, source->nhost) < 0)
goto cleanup;
- }
for (i = 0; i < source->nhost; i++) {
name = virXMLPropString(nodeset[i], "name");
if (nsource > 0) {
if (VIR_ALLOC_N(source->devices, nsource) < 0) {
VIR_FREE(nodeset);
- virReportOOMError();
goto cleanup;
}
&xpath_ctxt)))
goto cleanup;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
goto cleanup;
- }
if (!(node = virXPathNode("/source", xpath_ctxt))) {
virReportError(VIR_ERR_XML_ERROR, "%s",
char *uuid = NULL;
char *target_path = NULL;
- if (VIR_ALLOC(ret) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(ret) < 0)
return NULL;
- }
type = virXPathString("string(./@type)", ctxt);
if (type == NULL) {
if (options == NULL)
return NULL;
- if (VIR_ALLOC(ret) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(ret) < 0)
return NULL;
- }
ret->name = virXPathString("string(./name)", ctxt);
if (ret->name == NULL) {
goto error;
if (!(ret->target.features = virBitmapNew(VIR_STORAGE_FILE_FEATURE_LAST)))
- goto no_memory;
+ goto error;
for (i = 0; i < n; i++) {
int f = options->featureFromString((const char*)nodes[i]->name);
VIR_FREE(unit);
return ret;
-no_memory:
- virReportOOMError();
error:
virStorageVolDefFree(ret);
ret = NULL;
return pool;
}
- if (VIR_ALLOC(pool) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(pool) < 0)
return NULL;
- }
if (virMutexInit(&pool->lock) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
pool->def = NULL;
virStoragePoolObjUnlock(pool);
virStoragePoolObjFree(pool);
- virReportOOMError();
return NULL;
}
pools->objs[pools->count++] = pool;
{
virStoragePoolSourcePtr source;
- if (VIR_REALLOC_N(list->sources, list->nsources + 1) < 0) {
- virReportOOMError();
+ if (VIR_REALLOC_N(list->sources, list->nsources + 1) < 0)
return NULL;
- }
source = &list->sources[list->nsources++];
memset(source, 0, sizeof(*source));
int ret = -1;
int i;
- if (pools) {
- if (VIR_ALLOC_N(tmp_pools, poolobjs.count + 1) < 0) {
- virReportOOMError();
- goto cleanup;
- }
- }
+ if (pools && VIR_ALLOC_N(tmp_pools, poolobjs.count + 1) < 0)
+ goto cleanup;
for (i = 0; i < poolobjs.count; i++) {
virStoragePoolObjPtr poolobj = poolobjs.objs[i];
int type;
char *uuidstr = NULL;
- if (VIR_ALLOC(ret) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(ret) < 0)
return NULL;
- }
old_node = ctxt->node;
ctxt->node = node;
char *format_str;
int format, i, n;
- if (VIR_ALLOC(ret) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(ret) < 0)
return NULL;
- }
format_str = virXPathString("string(./@format)", ctxt);
if (format_str == NULL) {
if (n < 0){
goto cleanup;
}
- if (n != 0 && VIR_ALLOC_N(ret->secrets, n) < 0) {
- virReportOOMError();
+ if (n != 0 && VIR_ALLOC_N(ret->secrets, n) < 0)
goto cleanup;
- }
ret->nsecrets = n;
for (i = 0; i < n; i++) {
ret->secrets[i] = virStorageEncryptionSecretParse(ctxt, nodes[i]);
++p;
}
- if (virAsprintf(&path, "%s/LCK..%s", VIR_CHRDEV_LOCK_FILE_PATH, filename) < 0) {
- virReportOOMError();
+ if (virAsprintf(&path, "%s/LCK..%s", VIR_CHRDEV_LOCK_FILE_PATH, filename) < 0)
goto cleanup;
- }
sanitizedPath = virFileSanitizePath(path);
/* ensure correct format according to filesystem hierarchy standard */
/* http://www.pathname.com/fhs/pub/fhs-2.3.html#VARLOCKLOCKFILES */
- if (virAsprintf(&pidStr, "%10lld\n", (long long) getpid()) < 0) {
- virReportOOMError();
+ if (virAsprintf(&pidStr, "%10lld\n", (long long) getpid()) < 0)
goto cleanup;
- }
/* create the lock file */
if ((lockfd = open(path, O_WRONLY | O_CREAT | O_EXCL, 00644)) < 0) {
return NULL;
if (virMutexInit(&devs->lock) < 0) {
+ virReportSystemError(errno, "%s",
+ _("Unable to init device stream mutex"));
VIR_FREE(devs);
return NULL;
}
return -1;
}
- if (VIR_ALLOC(cbdata) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(cbdata) < 0)
goto error;
- }
if (virHashAddEntry(devs->hash, path, st) < 0)
goto error;
}
-static void
-*qemuDomainObjPrivateAlloc(void)
+static void *
+qemuDomainObjPrivateAlloc(void)
{
qemuDomainObjPrivatePtr priv;
if (VIR_ALLOC(priv) < 0)
return NULL;
- if (qemuDomainObjInitJob(priv) < 0)
+ if (qemuDomainObjInitJob(priv) < 0) {
+ virReportSystemError(errno, "%s",
+ _("Unable to init qemu driver mutexes"));
goto error;
+ }
if (!(priv->devs = virChrdevAlloc()))
goto error;
#include "c-ctype.h"
#include "count-one-bits.h"
#include "virstring.h"
+#include "virerror.h"
#define VIR_FROM_THIS VIR_FROM_NONE
virBitmapPtr bitmap;
size_t sz;
- if (SIZE_MAX - VIR_BITMAP_BITS_PER_UNIT < size || size == 0)
+ if (SIZE_MAX - VIR_BITMAP_BITS_PER_UNIT < size || size == 0) {
+ virReportOOMError();
return NULL;
+ }
sz = (size + VIR_BITMAP_BITS_PER_UNIT - 1) /
VIR_BITMAP_BITS_PER_UNIT;