int64_t r;
for (i = 0; i < ARRAY_CARDINALITY(paths); ++i) {
- if (virAsprintf(&path, paths[i], domid, device, str) < 0) {
- virReportOOMError();
+ if (virAsprintf(&path, paths[i], domid, device, str) < 0)
return -1;
- }
r = read_stat(path);
if (VIR_STRDUP(mod_path, path) < 0)
return -1;
} else {
- if (virAsprintf(&mod_path, "/dev/%s", path) < 0) {
- virReportOOMError();
+ if (virAsprintf(&mod_path, "/dev/%s", path) < 0)
return -1;
- }
}
retval = -1;
if (xenUnifiedNodeGetInfo(dom->conn, &nodeinfo) < 0)
return NULL;
- if (!(cpulist = virBitmapNew(priv->nbNodeCpus))) {
- virReportOOMError();
+ if (!(cpulist = virBitmapNew(priv->nbNodeCpus)))
goto done;
- }
- if (VIR_ALLOC_N(cpuinfo, nb_vcpu) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(cpuinfo, nb_vcpu) < 0)
goto done;
- }
cpumaplen = VIR_CPU_MAPLEN(VIR_NODEINFO_MAXCPUS(nodeinfo));
if (xalloc_oversized(nb_vcpu, cpumaplen) ||
- VIR_ALLOC_N(cpumap, nb_vcpu * cpumaplen) < 0) {
- virReportOOMError();
+ VIR_ALLOC_N(cpumap, nb_vcpu * cpumaplen) < 0)
goto done;
- }
if ((ncpus = xenUnifiedDomainGetVcpus(dom, cpuinfo, nb_vcpu,
cpumap, cpumaplen)) >= 0) {
return VIR_DRV_OPEN_ERROR;
/* Allocate per-connection private data. */
- if (VIR_ALLOC(priv) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(priv) < 0)
return VIR_DRV_OPEN_ERROR;
- }
if (virMutexInit(&priv->lock) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot initialize mutex"));
/* If its running there's no official way to tell, so we
* go behind xend's back & look at the config dir */
virUUIDFormat(dom->uuid, uuidstr);
- if (virAsprintf(&path, "%s/%s", XEND_DOMAINS_DIR, uuidstr) < 0) {
- virReportOOMError();
+ if (virAsprintf(&path, "%s/%s", XEND_DOMAINS_DIR, uuidstr) < 0)
goto cleanup;
- }
if (access(path, R_OK) == 0)
ret = 1;
else if (errno == ENOENT)
{
char *ret;
- if (virAsprintf(&ret, "%s/%s.save", priv->saveDir, def->name) < 0) {
- virReportOOMError();
+ if (virAsprintf(&ret, "%s/%s.save", priv->saveDir, def->name) < 0)
return NULL;
- }
VIR_DEBUG("managed save image: %s", ret);
return ret;
if (!conf)
goto cleanup;
- if (VIR_ALLOC_N(ret, len) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(ret, len) < 0)
goto cleanup;
- }
if (virConfWriteMem(ret, &len, conf) < 0) {
VIR_FREE(ret);
return ret;
}
if (numdomains > 0){
- if (VIR_ALLOC_N(ids, numdomains) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(ids, numdomains) < 0)
goto out;
- }
if ((numdomains = xenUnifiedConnectListDomains(conn, &ids[0], numdomains)) < 0) {
goto out;
}
goto out;
if (virAsprintf(&bdf, "%04x:%02x:%02x.%0x",
- domain, bus, slot, function) < 0) {
- virReportOOMError();
+ domain, bus, slot, function) < 0)
goto out;
- }
xenUnifiedLock(priv);
/* Check if bdf is assigned to one of active domains */
}
if (VIR_ALLOC(info) < 0)
- goto memory_error;
+ goto error;
if (VIR_STRDUP(info->name, name) < 0)
goto error;
/* Make space on list */
n = list->count;
if (VIR_REALLOC_N(list->doms, n + 1) < 0) {
- goto memory_error;
+ goto error;
}
list->doms[n] = info;
list->count++;
return 0;
-memory_error:
- virReportOOMError();
error:
if (info)
VIR_FREE(info->name);
/* The allocated memory to cpumap must be 'sizeof(uint64_t)' byte *
* for Xen, and also nr_cpus must be 'sizeof(uint64_t) * 8' */
if (maplen < 8) {
- if (VIR_ALLOC_N(new, sizeof(uint64_t)) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(new, sizeof(uint64_t)) < 0)
return -1;
- }
memcpy(new, cpumap, maplen);
bitmap = new;
nr_cpus = sizeof(uint64_t) * 8;
*/
hv_versions.hypervisor = 2;
- if (VIR_ALLOC(ipt) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(ipt) < 0)
return -1;
- }
/* Currently consider RHEL5.0 Fedora7, xen-3.1, and xen-unstable */
hv_versions.sys_interface = 2; /* XEN_SYSCTL_INTERFACE_VERSION */
if (virXen_getdomaininfo(fd, 0, &info) == 1) {
}
}
- if ((caps = xenHypervisorBuildCapabilities(conn,
- virArchFromHost(),
- pae, hvm,
- guest_arches, i)) == NULL)
- virReportOOMError();
+ caps = xenHypervisorBuildCapabilities(conn,
+ virArchFromHost(),
+ pae, hvm,
+ guest_arches, i);
return caps;
}
return caps;
no_memory:
- virReportOOMError();
virObjectUnref(caps);
return NULL;
}
priv->configDir = XEND_DOMAINS_DIR;
priv->useXenConfigCache = 0;
- if (VIR_ALLOC(priv->configInfoList) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(priv->configInfoList) < 0)
return -1;
- }
/* populate initial list */
if (!(dh = opendir(priv->configDir))) {
int content_length = 0;
int retcode = 0;
- if (VIR_ALLOC_N(buffer, buffer_size) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(buffer, buffer_size) < 0)
return -1;
- }
while (sreads(fd, buffer, buffer_size) > 0) {
if (STREQ(buffer, "\r\n"))
/* Allocate one byte beyond the end of the largest buffer we will read.
Combined with the fact that VIR_ALLOC_N zeros the returned buffer,
this guarantees that "content" will always be NUL-terminated. */
- if (VIR_ALLOC_N(*content, content_length + 1) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(*content, content_length + 1) < 0)
return -1;
- }
ret = sread(fd, *content, content_length);
if (ret < 0)
count++;
}
- if (VIR_ALLOC_N(ret, count + 1) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(ret, count + 1) < 0)
goto error;
- }
i = 0;
for (_for_i = root, node = root->u.s.car; _for_i->kind == SEXPR_CONS;
if (STRPREFIX(cur, "no cpus")) {
nb_cpus = 0;
if (!(cpuset = virBitmapNew(numCpus)))
- goto memory_error;
+ goto error;
} else {
nb_cpus = virBitmapParse(cur, 'n', &cpuset, numCpus);
if (nb_cpus < 0)
if (VIR_ALLOC_N(cpuInfo, numCpus) < 0) {
virBitmapFree(cpuset);
- goto memory_error;
+ goto error;
}
for (n = 0, cpu = 0; cpu < numCpus; cpu++) {
virBitmapFree(cpuset);
if (virCapabilitiesAddHostNUMACell(caps, cell, nb_cpus, 0, cpuInfo) < 0)
- goto memory_error;
+ goto error;
cpuInfo = NULL;
}
virCapabilitiesClearHostNUMACellCPUTopology(cpuInfo, nb_cpus);
VIR_FREE(cpuInfo);
return -1;
-
- memory_error:
- virReportOOMError();
- goto error;
}
goto failed;
} else if (STRCASEEQ(conn->uri->scheme, "http")) {
if (conn->uri->port &&
- virAsprintf(&port, "%d", conn->uri->port) == -1) {
- virReportOOMError();
+ virAsprintf(&port, "%d", conn->uri->port) == -1)
goto failed;
- }
if (xenDaemonOpen_tcp(conn,
conn->uri->server ? conn->uri->server : "localhost",
if (ret == 0) {
if (!def->cputune.vcpupin) {
- if (VIR_ALLOC(def->cputune.vcpupin) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def->cputune.vcpupin) < 0)
goto cleanup;
- }
def->cputune.nvcpupin = 0;
}
if (virDomainVcpuPinAdd(&def->cputune.vcpupin,
PCIAddr = dev->data.hostdev->source.subsys.u.pci.addr;
if (virAsprintf(&target, "PCI device: %.4x:%.2x:%.2x",
- PCIAddr.domain, PCIAddr.bus, PCIAddr.slot) < 0) {
- virReportOOMError();
+ PCIAddr.domain, PCIAddr.bus, PCIAddr.slot) < 0)
goto cleanup;
- }
} else {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("unsupported device type"));
hostdef->source.subsys.u.pci.addr.domain,
hostdef->source.subsys.u.pci.addr.bus,
hostdef->source.subsys.u.pci.addr.slot,
- hostdef->source.subsys.u.pci.addr.function) < 0) {
- virReportOOMError();
+ hostdef->source.subsys.u.pci.addr.function) < 0)
return -1;
- }
strcpy(class, "pci");
entry->def = NULL;
} else { /* Completely new entry */
newborn = 1;
- if (VIR_ALLOC(entry) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(entry) < 0)
return -1;
- }
if (VIR_STRDUP(entry->filename, filename) < 0) {
VIR_FREE(entry);
return -1;
if (virConfWriteFile(filename, conf) < 0)
goto error;
- if (VIR_ALLOC(entry) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(entry) < 0)
goto error;
- }
if ((entry->refreshedAt = time(NULL)) == ((time_t)-1)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
switch (dev->type) {
case VIR_DOMAIN_DEVICE_DISK:
{
- if (virDomainDiskInsert(def, dev->data.disk) < 0) {
- virReportOOMError();
+ if (virDomainDiskInsert(def, dev->data.disk) < 0)
goto cleanup;
- }
dev->data.disk = NULL;
}
break;
case VIR_DOMAIN_DEVICE_NET:
{
- if (VIR_REALLOC_N(def->nets, def->nnets+1) < 0) {
- virReportOOMError();
+ if (VIR_REALLOC_N(def->nets, def->nnets+1) < 0)
goto cleanup;
- }
def->nets[def->nnets++] = dev->data.net;
dev->data.net = NULL;
break;
char *config = xenXMDomainConfigName(def);
int ret = -1;
- if (!linkname || !config) {
- virReportOOMError();
+ if (!linkname || !config)
goto cleanup;
- }
*autostart = virFileLinkPointsTo(linkname, config);
if (*autostart < 0) {
char *config = xenXMDomainConfigName(def);
int ret = -1;
- if (!linkname || !config) {
- virReportOOMError();
+ if (!linkname || !config)
goto cleanup;
- }
if (autostart) {
if (symlink(config, linkname) < 0 &&
}
/* Init activeDomainList */
- if (VIR_ALLOC(priv->activeDomainList) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(priv->activeDomainList) < 0)
return -1;
- }
/* Init watch list before filling in domInfoList,
so we can know if it is the first time through
when the callback fires */
- if (VIR_ALLOC(priv->xsWatchList) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(priv->xsWatchList) < 0)
return -1;
- }
/* This will get called once at start */
if (xenStoreAddWatch(conn, "@releaseDomain",
}
}
- if (VIR_ALLOC(watch) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(watch) < 0)
goto error;
- }
watch->cb = cb;
watch->opaque = opaque;
/* Make space on list */
n = list->count;
- if (VIR_REALLOC_N(list->watches, n + 1) < 0) {
- virReportOOMError();
+ if (VIR_REALLOC_N(list->watches, n + 1) < 0)
goto error;
- }
list->watches[n] = watch;
list->count++;
if (new_domain_cnt < 0)
return -1;
- if (VIR_ALLOC_N(new_domids,new_domain_cnt) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(new_domids,new_domain_cnt) < 0)
return -1;
- }
nread = xenStoreDoListDomains(conn, priv, new_domids, new_domain_cnt);
if (nread != new_domain_cnt) {
/* mismatch. retry this read */
if (new_domain_cnt < 0)
return -1;
- if (VIR_ALLOC_N(new_domids,new_domain_cnt) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(new_domids,new_domain_cnt) < 0)
return -1;
- }
nread = xenStoreDoListDomains(conn, priv, new_domids, new_domain_cnt);
if (nread != new_domain_cnt) {
/* mismatch. retry this read */