error-reporting calls using VIR_ERR_NO_MEMORY: use virReportOOMError instead

* src/uml_conf.c (VIR_FROM_THIS): Define to VIR_FROM_UML.
* src/xs_internal.c (VIR_FROM_THIS): Define to VIR_FROM_XEN.
* src/xml.c (VIR_FROM_THIS): Define to VIR_FROM_XML.
* src/stats_linux.c (VIR_FROM_THIS): Define to VIR_FROM_STATS_LINUX.
* src/datatypes.c (VIR_FROM_THIS): Define to VIR_FROM_NONE.
* src/lxc_conf.c (VIR_FROM_THIS): Define to VIR_FROM_LXC.
* src/libvirt.c (VIR_FROM_THIS): Define to VIR_FROM_NONE.
* src/node_device_conf.c (VIR_FROM_THIS): Define to VIR_FROM_NODEDEV.
* src/openvz_conf.c (VIR_FROM_THIS): Define to VIR_FROM_OPENVZ.
* src/openvz_driver.c (VIR_FROM_THIS): Define to VIR_FROM_OPENVZ.
* src/conf.c (VIR_FROM_THIS): Define to VIR_FROM_CONF.
Note: this loses config_filename:config_lineno diagnostics,
but that's ok.
* src/node_device.c (VIR_FROM_THIS): Define to VIR_FROM_NODEDEV.
* src/sexpr.c (VIR_FROM_THIS): Define to VIR_FROM_SEXPR.
* po/POTFILES.in: remove src/sexpr.c and src/lxc_conf.c
This commit is contained in:
Jim Meyering 2009-01-29 12:10:32 +00:00
parent a99e5ccba4
commit bc18a91f91
32 changed files with 251 additions and 265 deletions

View File

@ -1,3 +1,23 @@
Thu Jan 29 13:06:51 +0100 2009 Jim Meyering <meyering@redhat.com>
error-reporting calls using VIR_ERR_NO_MEMORY: use virReportOOMError instead
* src/uml_conf.c (VIR_FROM_THIS): Define to VIR_FROM_UML.
* src/xs_internal.c (VIR_FROM_THIS): Define to VIR_FROM_XEN.
* src/xml.c (VIR_FROM_THIS): Define to VIR_FROM_XML.
* src/stats_linux.c (VIR_FROM_THIS): Define to VIR_FROM_STATS_LINUX.
* src/datatypes.c (VIR_FROM_THIS): Define to VIR_FROM_NONE.
* src/lxc_conf.c (VIR_FROM_THIS): Define to VIR_FROM_LXC.
* src/libvirt.c (VIR_FROM_THIS): Define to VIR_FROM_NONE.
* src/node_device_conf.c (VIR_FROM_THIS): Define to VIR_FROM_NODEDEV.
* src/openvz_conf.c (VIR_FROM_THIS): Define to VIR_FROM_OPENVZ.
* src/openvz_driver.c (VIR_FROM_THIS): Define to VIR_FROM_OPENVZ.
* src/conf.c (VIR_FROM_THIS): Define to VIR_FROM_CONF.
Note: this loses config_filename:config_lineno diagnostics,
but that's ok.
* src/node_device.c (VIR_FROM_THIS): Define to VIR_FROM_NODEDEV.
* src/sexpr.c (VIR_FROM_THIS): Define to VIR_FROM_SEXPR.
* po/POTFILES.in: remove src/sexpr.c and src/lxc_conf.c
Thu Jan 29 12:44:15 CET 2009 Guido Günther <agx@sigxcpu.org> Thu Jan 29 12:44:15 CET 2009 Guido Günther <agx@sigxcpu.org>
* src/virsh.c (main): don't abort when setlocale() fails * src/virsh.c (main): don't abort when setlocale() fails

View File

@ -8,7 +8,6 @@ src/datatypes.c
src/domain_conf.c src/domain_conf.c
src/iptables.c src/iptables.c
src/libvirt.c src/libvirt.c
src/lxc_conf.c
src/lxc_container.c src/lxc_container.c
src/lxc_controller.c src/lxc_controller.c
src/lxc_driver.c src/lxc_driver.c
@ -23,7 +22,6 @@ src/proxy_internal.c
src/qemu_conf.c src/qemu_conf.c
src/qemu_driver.c src/qemu_driver.c
src/remote_internal.c src/remote_internal.c
src/sexpr.c
src/storage_backend.c src/storage_backend.c
src/storage_backend_disk.c src/storage_backend_disk.c
src/storage_backend_fs.c src/storage_backend_fs.c

View File

@ -25,6 +25,8 @@
#include "c-ctype.h" #include "c-ctype.h"
#include "memory.h" #include "memory.h"
#define VIR_FROM_THIS VIR_FROM_CONF
/************************************************************************ /************************************************************************
* * * *
* Structures and macros used by the mini parser * * Structures and macros used by the mini parser *
@ -161,7 +163,7 @@ virConfNew(void)
virConfPtr ret; virConfPtr ret;
if (VIR_ALLOC(ret) < 0) { if (VIR_ALLOC(ret) < 0) {
virConfError(NULL, VIR_ERR_NO_MEMORY, _("allocating configuration")); virReportOOMError(NULL);
return(NULL); return(NULL);
} }
ret->filename = NULL; ret->filename = NULL;
@ -209,7 +211,7 @@ virConfAddEntry(virConfPtr conf, char *name, virConfValuePtr value, char *comm)
return(NULL); return(NULL);
if (VIR_ALLOC(ret) < 0) { if (VIR_ALLOC(ret) < 0) {
virConfError(NULL, VIR_ERR_NO_MEMORY, _("allocating configuration")); virReportOOMError(NULL);
return(NULL); return(NULL);
} }
@ -488,7 +490,7 @@ virConfParseValue(virConfParserCtxtPtr ctxt)
return(NULL); return(NULL);
} }
if (VIR_ALLOC(ret) < 0) { if (VIR_ALLOC(ret) < 0) {
virConfError(ctxt, VIR_ERR_NO_MEMORY, _("allocating configuration")); virReportOOMError(NULL);
virConfFreeList(lst); virConfFreeList(lst);
VIR_FREE(str); VIR_FREE(str);
return(NULL); return(NULL);
@ -525,7 +527,7 @@ virConfParseName(virConfParserCtxtPtr ctxt)
NEXT; NEXT;
ret = strndup(base, ctxt->cur - base); ret = strndup(base, ctxt->cur - base);
if (ret == NULL) { if (ret == NULL) {
virConfError(ctxt, VIR_ERR_NO_MEMORY, _("allocating configuration")); virReportOOMError(NULL);
return(NULL); return(NULL);
} }
return(ret); return(ret);
@ -552,7 +554,7 @@ virConfParseComment(virConfParserCtxtPtr ctxt)
while ((ctxt->cur < ctxt->end) && (!IS_EOL(CUR))) NEXT; while ((ctxt->cur < ctxt->end) && (!IS_EOL(CUR))) NEXT;
comm = strndup(base, ctxt->cur - base); comm = strndup(base, ctxt->cur - base);
if (comm == NULL) { if (comm == NULL) {
virConfError(ctxt, VIR_ERR_NO_MEMORY, _("allocating configuration")); virReportOOMError(NULL);
return(-1); return(-1);
} }
virConfAddEntry(ctxt->conf, NULL, NULL, comm); virConfAddEntry(ctxt->conf, NULL, NULL, comm);
@ -627,7 +629,7 @@ virConfParseStatement(virConfParserCtxtPtr ctxt)
while ((ctxt->cur < ctxt->end) && (!IS_EOL(CUR))) NEXT; while ((ctxt->cur < ctxt->end) && (!IS_EOL(CUR))) NEXT;
comm = strndup(base, ctxt->cur - base); comm = strndup(base, ctxt->cur - base);
if (comm == NULL) { if (comm == NULL) {
virConfError(ctxt, VIR_ERR_NO_MEMORY, _("allocating configuration")); virReportOOMError(NULL);
VIR_FREE(name); VIR_FREE(name);
virConfFreeValue(value); virConfFreeValue(value);
return(-1); return(-1);
@ -888,7 +890,7 @@ virConfWriteFile(const char *filename, virConfPtr conf)
} }
if (virBufferError(&buf)) { if (virBufferError(&buf)) {
virConfError(NULL, VIR_ERR_NO_MEMORY, _("allocate buffer")); virReportOOMError(NULL);
return -1; return -1;
} }
@ -944,7 +946,7 @@ virConfWriteMem(char *memory, int *len, virConfPtr conf)
} }
if (virBufferError(&buf)) { if (virBufferError(&buf)) {
virConfError(NULL, VIR_ERR_NO_MEMORY, _("allocate buffer")); virReportOOMError(NULL);
return -1; return -1;
} }

View File

@ -1,7 +1,7 @@
/* /*
* datatypes.h: management of structs for public data types * datatypes.h: management of structs for public data types
* *
* Copyright (C) 2006-2008 Red Hat, Inc. * Copyright (C) 2006-2009 Red Hat, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -26,6 +26,8 @@
#include "logging.h" #include "logging.h"
#include "memory.h" #include "memory.h"
#define VIR_FROM_THIS VIR_FROM_NONE
/************************************************************************ /************************************************************************
* * * *
* Domain and Connections allocations * * Domain and Connections allocations *
@ -120,7 +122,7 @@ virGetConnect(void) {
virConnectPtr ret; virConnectPtr ret;
if (VIR_ALLOC(ret) < 0) { if (VIR_ALLOC(ret) < 0) {
virLibConnError(NULL, VIR_ERR_NO_MEMORY, _("allocating connection")); virReportOOMError(NULL);
goto failed; goto failed;
} }
if (virMutexInit(&ret->lock) < 0) { if (virMutexInit(&ret->lock) < 0) {
@ -262,12 +264,12 @@ virGetDomain(virConnectPtr conn, const char *name, const unsigned char *uuid) {
/* TODO check the UUID */ /* TODO check the UUID */
if (ret == NULL) { if (ret == NULL) {
if (VIR_ALLOC(ret) < 0) { if (VIR_ALLOC(ret) < 0) {
virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating domain")); virReportOOMError(conn);
goto error; goto error;
} }
ret->name = strdup(name); ret->name = strdup(name);
if (ret->name == NULL) { if (ret->name == NULL) {
virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating domain")); virReportOOMError(conn);
goto error; goto error;
} }
ret->magic = VIR_DOMAIN_MAGIC; ret->magic = VIR_DOMAIN_MAGIC;
@ -398,12 +400,12 @@ virGetNetwork(virConnectPtr conn, const char *name, const unsigned char *uuid) {
/* TODO check the UUID */ /* TODO check the UUID */
if (ret == NULL) { if (ret == NULL) {
if (VIR_ALLOC(ret) < 0) { if (VIR_ALLOC(ret) < 0) {
virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating network")); virReportOOMError(conn);
goto error; goto error;
} }
ret->name = strdup(name); ret->name = strdup(name);
if (ret->name == NULL) { if (ret->name == NULL) {
virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating network")); virReportOOMError(conn);
goto error; goto error;
} }
ret->magic = VIR_NETWORK_MAGIC; ret->magic = VIR_NETWORK_MAGIC;
@ -530,12 +532,12 @@ virGetStoragePool(virConnectPtr conn, const char *name, const unsigned char *uui
/* TODO check the UUID */ /* TODO check the UUID */
if (ret == NULL) { if (ret == NULL) {
if (VIR_ALLOC(ret) < 0) { if (VIR_ALLOC(ret) < 0) {
virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating storage pool")); virReportOOMError(conn);
goto error; goto error;
} }
ret->name = strdup(name); ret->name = strdup(name);
if (ret->name == NULL) { if (ret->name == NULL) {
virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating storage pool")); virReportOOMError(conn);
goto error; goto error;
} }
ret->magic = VIR_STORAGE_POOL_MAGIC; ret->magic = VIR_STORAGE_POOL_MAGIC;
@ -661,17 +663,17 @@ virGetStorageVol(virConnectPtr conn, const char *pool, const char *name, const c
ret = (virStorageVolPtr) virHashLookup(conn->storageVols, key); ret = (virStorageVolPtr) virHashLookup(conn->storageVols, key);
if (ret == NULL) { if (ret == NULL) {
if (VIR_ALLOC(ret) < 0) { if (VIR_ALLOC(ret) < 0) {
virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating storage vol")); virReportOOMError(conn);
goto error; goto error;
} }
ret->pool = strdup(pool); ret->pool = strdup(pool);
if (ret->pool == NULL) { if (ret->pool == NULL) {
virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating storage vol")); virReportOOMError(conn);
goto error; goto error;
} }
ret->name = strdup(name); ret->name = strdup(name);
if (ret->name == NULL) { if (ret->name == NULL) {
virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating storage vol")); virReportOOMError(conn);
goto error; goto error;
} }
strncpy(ret->key, key, sizeof(ret->key)-1); strncpy(ret->key, key, sizeof(ret->key)-1);
@ -798,14 +800,14 @@ virGetNodeDevice(virConnectPtr conn, const char *name)
ret = (virNodeDevicePtr) virHashLookup(conn->nodeDevices, name); ret = (virNodeDevicePtr) virHashLookup(conn->nodeDevices, name);
if (ret == NULL) { if (ret == NULL) {
if (VIR_ALLOC(ret) < 0) { if (VIR_ALLOC(ret) < 0) {
virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating node dev")); virReportOOMError(conn);
goto error; goto error;
} }
ret->magic = VIR_NODE_DEVICE_MAGIC; ret->magic = VIR_NODE_DEVICE_MAGIC;
ret->conn = conn; ret->conn = conn;
ret->name = strdup(name); ret->name = strdup(name);
if (ret->name == NULL) { if (ret->name == NULL) {
virLibConnError(conn, VIR_ERR_NO_MEMORY, _("copying node dev name")); virReportOOMError(conn);
goto error; goto error;
} }

View File

@ -483,7 +483,7 @@ virDomainObjPtr virDomainAssignDef(virConnectPtr conn,
} }
if (VIR_ALLOC(domain) < 0) { if (VIR_ALLOC(domain) < 0) {
virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return NULL; return NULL;
} }
@ -499,7 +499,7 @@ virDomainObjPtr virDomainAssignDef(virConnectPtr conn,
domain->def = def; domain->def = def;
if (VIR_REALLOC_N(doms->objs, doms->count + 1) < 0) { if (VIR_REALLOC_N(doms->objs, doms->count + 1) < 0) {
virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
VIR_FREE(domain); VIR_FREE(domain);
return NULL; return NULL;
} }
@ -569,7 +569,7 @@ virDomainDiskDefParseXML(virConnectPtr conn,
char *bus = NULL; char *bus = NULL;
if (VIR_ALLOC(def) < 0) { if (VIR_ALLOC(def) < 0) {
virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return NULL; return NULL;
} }
@ -753,7 +753,7 @@ virDomainFSDefParseXML(virConnectPtr conn,
char *target = NULL; char *target = NULL;
if (VIR_ALLOC(def) < 0) { if (VIR_ALLOC(def) < 0) {
virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return NULL; return NULL;
} }
@ -847,7 +847,7 @@ virDomainNetDefParseXML(virConnectPtr conn,
char *model = NULL; char *model = NULL;
if (VIR_ALLOC(def) < 0) { if (VIR_ALLOC(def) < 0) {
virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return NULL; return NULL;
} }
@ -1087,7 +1087,7 @@ virDomainChrDefParseXML(virConnectPtr conn,
virDomainChrDefPtr def; virDomainChrDefPtr def;
if (VIR_ALLOC(def) < 0) { if (VIR_ALLOC(def) < 0) {
virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return NULL; return NULL;
} }
@ -1300,7 +1300,7 @@ virDomainInputDefParseXML(virConnectPtr conn,
char *bus = NULL; char *bus = NULL;
if (VIR_ALLOC(def) < 0) { if (VIR_ALLOC(def) < 0) {
virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return NULL; return NULL;
} }
@ -1385,7 +1385,7 @@ virDomainGraphicsDefParseXML(virConnectPtr conn,
char *type = NULL; char *type = NULL;
if (VIR_ALLOC(def) < 0) { if (VIR_ALLOC(def) < 0) {
virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return NULL; return NULL;
} }
@ -1480,7 +1480,7 @@ virDomainSoundDefParseXML(virConnectPtr conn,
virDomainSoundDefPtr def; virDomainSoundDefPtr def;
if (VIR_ALLOC(def) < 0) { if (VIR_ALLOC(def) < 0) {
virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return NULL; return NULL;
} }
@ -1714,7 +1714,7 @@ virDomainHostdevDefParseXML(virConnectPtr conn,
char *mode, *type = NULL; char *mode, *type = NULL;
if (VIR_ALLOC(def) < 0) { if (VIR_ALLOC(def) < 0) {
virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return NULL; return NULL;
} }
def->target = NULL; def->target = NULL;
@ -1826,7 +1826,7 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(virConnectPtr conn,
} }
if (VIR_ALLOC(dev) < 0) { if (VIR_ALLOC(dev) < 0) {
virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
goto error; goto error;
} }
@ -1892,8 +1892,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
virDomainDefPtr def; virDomainDefPtr def;
if (VIR_ALLOC(def) < 0) { if (VIR_ALLOC(def) < 0) {
virDomainReportError(conn, VIR_ERR_NO_MEMORY, virReportOOMError(conn);
"%s", _("failed to allocate space for xmlXPathContext"));
return NULL; return NULL;
} }
@ -1958,7 +1957,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
char *set = tmp; char *set = tmp;
def->cpumasklen = VIR_DOMAIN_CPUMASK_LEN; def->cpumasklen = VIR_DOMAIN_CPUMASK_LEN;
if (VIR_ALLOC_N(def->cpumask, def->cpumasklen) < 0) { if (VIR_ALLOC_N(def->cpumask, def->cpumasklen) < 0) {
virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
goto error; goto error;
} }
if (virDomainCpuSetParse(conn, (const char **)&set, if (virDomainCpuSetParse(conn, (const char **)&set,
@ -2008,7 +2007,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
if (def->os.bootloader) { if (def->os.bootloader) {
def->os.type = strdup("xen"); def->os.type = strdup("xen");
if (!def->os.type) { if (!def->os.type) {
virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
goto error; goto error;
} }
} else { } else {
@ -2026,7 +2025,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
def->virtType == VIR_DOMAIN_VIRT_XEN) { def->virtType == VIR_DOMAIN_VIRT_XEN) {
VIR_FREE(def->os.type); VIR_FREE(def->os.type);
if (!(def->os.type = strdup("xen"))) { if (!(def->os.type = strdup("xen"))) {
virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
goto error; goto error;
} }
} }
@ -2047,7 +2046,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
goto error; goto error;
} }
if (!(def->os.arch = strdup(defaultArch))) { if (!(def->os.arch = strdup(defaultArch))) {
virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
goto error; goto error;
} }
} }
@ -2059,7 +2058,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
def->os.arch); def->os.arch);
if (defaultMachine != NULL) { if (defaultMachine != NULL) {
if (!(def->os.machine = strdup(defaultMachine))) { if (!(def->os.machine = strdup(defaultMachine))) {
virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
goto error; goto error;
} }
} }
@ -2310,7 +2309,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
virDomainInputDefPtr input; virDomainInputDefPtr input;
if (VIR_ALLOC(input) < 0) { if (VIR_ALLOC(input) < 0) {
virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
goto error; goto error;
} }
if (STREQ(def->os.type, "hvm")) { if (STREQ(def->os.type, "hvm")) {
@ -2382,7 +2381,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
return def; return def;
no_memory: no_memory:
virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
/* fallthrough */ /* fallthrough */
error: error:
@ -2514,7 +2513,7 @@ virDomainDefPtr virDomainDefParseNode(virConnectPtr conn,
ctxt = xmlXPathNewContext(xml); ctxt = xmlXPathNewContext(xml);
if (ctxt == NULL) { if (ctxt == NULL) {
virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
goto cleanup; goto cleanup;
} }
@ -2611,7 +2610,7 @@ virDomainCpuSetFormat(virConnectPtr conn, char *cpuset, int maxcpu)
} }
if (virBufferError(&buf)) { if (virBufferError(&buf)) {
virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return NULL; return NULL;
} }
@ -3400,7 +3399,7 @@ char *virDomainDefFormat(virConnectPtr conn,
return virBufferContentAndReset(&buf); return virBufferContentAndReset(&buf);
no_memory: no_memory:
virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
cleanup: cleanup:
tmp = virBufferContentAndReset(&buf); tmp = virBufferContentAndReset(&buf);
VIR_FREE(tmp); VIR_FREE(tmp);
@ -3624,7 +3623,7 @@ char *virDomainConfigFile(virConnectPtr conn,
char *ret = NULL; char *ret = NULL;
if (virAsprintf(&ret, "%s/%s.xml", dir, name) < 0) { if (virAsprintf(&ret, "%s/%s.xml", dir, name) < 0) {
virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return NULL; return NULL;
} }

View File

@ -57,6 +57,8 @@
#endif #endif
#endif #endif
#define VIR_FROM_THIS VIR_FROM_NONE
/* /*
* TODO: * TODO:
* - use lock to protect against concurrent accesses ? * - use lock to protect against concurrent accesses ?
@ -1323,7 +1325,7 @@ virConnectGetURI (virConnectPtr conn)
name = (char *)xmlSaveUri(conn->uri); name = (char *)xmlSaveUri(conn->uri);
if (!name) { if (!name) {
virLibConnError (conn, VIR_ERR_NO_MEMORY, __FUNCTION__); virReportOOMError (conn);
goto error; goto error;
} }
return name; return name;

View File

@ -31,6 +31,8 @@
#include "nodeinfo.h" #include "nodeinfo.h"
#include "virterror_internal.h" #include "virterror_internal.h"
#define VIR_FROM_THIS VIR_FROM_LXC
/* Functions */ /* Functions */
virCapsPtr lxcCapsInit(void) virCapsPtr lxcCapsInit(void)
{ {
@ -87,7 +89,6 @@ int lxcLoadDriverConfig(lxc_driver_t *driver)
return 0; return 0;
no_memory: no_memory:
lxcError(NULL, NULL, VIR_ERR_NO_MEMORY, virReportOOMError(NULL);
"%s", _("while loading LXC driver config"));
return -1; return -1;
} }

View File

@ -386,7 +386,7 @@ static int lxcContainerMountNewFS(virDomainDefPtr vmDef)
continue; continue;
if (virAsprintf(&src, "/.oldroot/%s", vmDef->fss[i]->src) < 0) { if (virAsprintf(&src, "/.oldroot/%s", vmDef->fss[i]->src) < 0) {
lxcError(NULL, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(NULL);
return -1; return -1;
} }
@ -432,12 +432,12 @@ static int lxcContainerUnmountOldFS(void)
if (VIR_REALLOC_N(mounts, nmounts+1) < 0) { if (VIR_REALLOC_N(mounts, nmounts+1) < 0) {
endmntent(procmnt); endmntent(procmnt);
lxcError(NULL, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(NULL);
return -1; return -1;
} }
if (!(mounts[nmounts++] = strdup(mntent.mnt_dir))) { if (!(mounts[nmounts++] = strdup(mntent.mnt_dir))) {
endmntent(procmnt); endmntent(procmnt);
lxcError(NULL, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(NULL);
return -1; return -1;
} }
} }
@ -618,7 +618,7 @@ int lxcContainerStart(virDomainDefPtr def,
/* allocate a stack for the container */ /* allocate a stack for the container */
if (VIR_ALLOC_N(stack, stacksize) < 0) { if (VIR_ALLOC_N(stack, stacksize) < 0) {
lxcError(NULL, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(NULL);
return -1; return -1;
} }
stacktop = stack + stacksize; stacktop = stack + stacksize;

View File

@ -127,7 +127,7 @@ static char*lxcMonitorPath(virDomainDefPtr def)
if (virAsprintf(&sockpath, "%s/%s.sock", if (virAsprintf(&sockpath, "%s/%s.sock",
LXC_STATE_DIR, def->name) < 0) LXC_STATE_DIR, def->name) < 0)
lxcError(NULL, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(NULL);
return sockpath; return sockpath;
} }

View File

@ -90,7 +90,7 @@ static virDrvOpenStatus lxcOpen(virConnectPtr conn,
if (conn->uri == NULL) { if (conn->uri == NULL) {
conn->uri = xmlParseURI("lxc:///"); conn->uri = xmlParseURI("lxc:///");
if (!conn->uri) { if (!conn->uri) {
lxcError(conn, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return VIR_DRV_OPEN_ERROR; return VIR_DRV_OPEN_ERROR;
} }
} else if (conn->uri->scheme == NULL || } else if (conn->uri->scheme == NULL ||
@ -231,8 +231,7 @@ static int lxcListDefinedDomains(virConnectPtr conn,
virDomainObjLock(driver->domains.objs[i]); virDomainObjLock(driver->domains.objs[i]);
if (!virDomainIsActive(driver->domains.objs[i])) { if (!virDomainIsActive(driver->domains.objs[i])) {
if (!(names[got++] = strdup(driver->domains.objs[i]->def->name))) { if (!(names[got++] = strdup(driver->domains.objs[i]->def->name))) {
lxcError(conn, NULL, VIR_ERR_NO_MEMORY, virReportOOMError(conn);
"%s", _("failed to allocate space for VM name string"));
virDomainObjUnlock(driver->domains.objs[i]); virDomainObjUnlock(driver->domains.objs[i]);
goto cleanup; goto cleanup;
} }
@ -613,7 +612,7 @@ static int lxcMonitorClient(virConnectPtr conn,
if (virAsprintf(&sockpath, "%s/%s.sock", if (virAsprintf(&sockpath, "%s/%s.sock",
driver->stateDir, vm->def->name) < 0) { driver->stateDir, vm->def->name) < 0) {
lxcError(conn, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return -1; return -1;
} }
@ -816,7 +815,7 @@ cleanup:
return ret; return ret;
no_memory: no_memory:
lxcError(conn, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
goto cleanup; goto cleanup;
} }
@ -853,7 +852,7 @@ static int lxcVmStart(virConnectPtr conn,
if (virAsprintf(&logfile, "%s/%s.log", if (virAsprintf(&logfile, "%s/%s.log",
driver->logDir, vm->def->name) < 0) { driver->logDir, vm->def->name) < 0) {
lxcError(conn, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return -1; return -1;
} }

View File

@ -161,7 +161,7 @@ virNetworkObjPtr virNetworkAssignDef(virConnectPtr conn,
} }
if (VIR_ALLOC(network) < 0) { if (VIR_ALLOC(network) < 0) {
virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return NULL; return NULL;
} }
if (virMutexInit(&network->lock) < 0) { if (virMutexInit(&network->lock) < 0) {
@ -174,7 +174,7 @@ virNetworkObjPtr virNetworkAssignDef(virConnectPtr conn,
network->def = def; network->def = def;
if (VIR_REALLOC_N(nets->objs, nets->count + 1) < 0) { if (VIR_REALLOC_N(nets->objs, nets->count + 1) < 0) {
virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
VIR_FREE(network); VIR_FREE(network);
return NULL; return NULL;
} }
@ -240,7 +240,7 @@ virNetworkDHCPRangeDefParseXML(virConnectPtr conn,
if (VIR_REALLOC_N(def->ranges, def->nranges + 1) < 0) { if (VIR_REALLOC_N(def->ranges, def->nranges + 1) < 0) {
xmlFree(start); xmlFree(start);
xmlFree(end); xmlFree(end);
virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return -1; return -1;
} }
def->ranges[def->nranges].start = (char *)start; def->ranges[def->nranges].start = (char *)start;
@ -291,7 +291,7 @@ virNetworkDHCPRangeDefParseXML(virConnectPtr conn,
VIR_FREE(ip); VIR_FREE(ip);
VIR_FREE(mac); VIR_FREE(mac);
VIR_FREE(name); VIR_FREE(name);
virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return -1; return -1;
} }
def->hosts[def->nhosts].mac = (char *)mac; def->hosts[def->nhosts].mac = (char *)mac;
@ -314,7 +314,7 @@ virNetworkDefParseXML(virConnectPtr conn,
char *tmp; char *tmp;
if (VIR_ALLOC(def) < 0) { if (VIR_ALLOC(def) < 0) {
virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return NULL; return NULL;
} }
@ -382,7 +382,7 @@ virNetworkDefParseXML(virConnectPtr conn,
netaddr = inet_ntoa(inaddress); netaddr = inet_ntoa(inaddress);
if (virAsprintf(&def->network, "%s/%s", netaddr, def->netmask) < 0) { if (virAsprintf(&def->network, "%s/%s", netaddr, def->netmask) < 0) {
virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
goto error; goto error;
} }
@ -544,7 +544,7 @@ virNetworkDefPtr virNetworkDefParseNode(virConnectPtr conn,
ctxt = xmlXPathNewContext(xml); ctxt = xmlXPathNewContext(xml);
if (ctxt == NULL) { if (ctxt == NULL) {
virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
goto cleanup; goto cleanup;
} }
@ -632,7 +632,7 @@ char *virNetworkDefFormat(virConnectPtr conn,
return virBufferContentAndReset(&buf); return virBufferContentAndReset(&buf);
no_memory: no_memory:
virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
tmp = virBufferContentAndReset(&buf); tmp = virBufferContentAndReset(&buf);
VIR_FREE(tmp); VIR_FREE(tmp);
return NULL; return NULL;
@ -840,7 +840,7 @@ char *virNetworkConfigFile(virConnectPtr conn,
char *ret = NULL; char *ret = NULL;
if (virAsprintf(&ret, "%s/%s.xml", dir, name) < 0) { if (virAsprintf(&ret, "%s/%s.xml", dir, name) < 0) {
virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return NULL; return NULL;
} }

View File

@ -252,8 +252,7 @@ networkStartup(void) {
} }
if (!(driverState->iptables = iptablesContextNew())) { if (!(driverState->iptables = iptablesContextNew())) {
networkReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY, virReportOOMError(NULL);
"%s", _("failed to allocate space for IP tables support"));
goto error; goto error;
} }
@ -502,8 +501,7 @@ networkBuildDnsmasqArgv(virConnectPtr conn,
VIR_FREE((*argv)[i]); VIR_FREE((*argv)[i]);
VIR_FREE(*argv); VIR_FREE(*argv);
} }
networkReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, virReportOOMError(conn);
"%s", _("failed to allocate space for dnsmasq argv"));
return -1; return -1;
} }
@ -1062,8 +1060,7 @@ static int networkListNetworks(virConnectPtr conn, char **const names, int nname
if (virNetworkIsActive(driver->networks.objs[i])) { if (virNetworkIsActive(driver->networks.objs[i])) {
if (!(names[got] = strdup(driver->networks.objs[i]->def->name))) { if (!(names[got] = strdup(driver->networks.objs[i]->def->name))) {
virNetworkObjUnlock(driver->networks.objs[i]); virNetworkObjUnlock(driver->networks.objs[i]);
networkReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, virReportOOMError(conn);
"%s", _("failed to allocate space for VM name string"));
goto cleanup; goto cleanup;
} }
got++; got++;
@ -1107,8 +1104,7 @@ static int networkListDefinedNetworks(virConnectPtr conn, char **const names, in
if (!virNetworkIsActive(driver->networks.objs[i])) { if (!virNetworkIsActive(driver->networks.objs[i])) {
if (!(names[got] = strdup(driver->networks.objs[i]->def->name))) { if (!(names[got] = strdup(driver->networks.objs[i]->def->name))) {
virNetworkObjUnlock(driver->networks.objs[i]); virNetworkObjUnlock(driver->networks.objs[i]);
networkReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, virReportOOMError(conn);
"%s", _("failed to allocate space for VM name string"));
goto cleanup; goto cleanup;
} }
got++; got++;
@ -1331,8 +1327,7 @@ static char *networkGetBridgeName(virNetworkPtr net) {
bridge = strdup(network->def->bridge); bridge = strdup(network->def->bridge);
if (!bridge) if (!bridge)
networkReportError(net->conn, NULL, net, VIR_ERR_NO_MEMORY, virReportOOMError(net->conn);
"%s", _("failed to allocate space for network bridge string"));
cleanup: cleanup:
if (network) if (network)

View File

@ -33,6 +33,8 @@
#include "node_device_conf.h" #include "node_device_conf.h"
#include "node_device.h" #include "node_device.h"
#define VIR_FROM_THIS VIR_FROM_NODEDEV
static int dev_has_cap(const virNodeDeviceObjPtr dev, const char *cap) static int dev_has_cap(const virNodeDeviceObjPtr dev, const char *cap)
{ {
virNodeDevCapsDefPtr caps = dev->def->caps; virNodeDevCapsDefPtr caps = dev->def->caps;
@ -176,7 +178,7 @@ static char *nodeDeviceGetParent(virNodeDevicePtr dev)
ret = strdup(obj->def->parent); ret = strdup(obj->def->parent);
if (!ret) if (!ret)
virNodeDeviceReportError(dev->conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(dev->conn);
cleanup: cleanup:
if (obj) if (obj)

View File

@ -36,6 +36,7 @@
#include "buf.h" #include "buf.h"
#include "uuid.h" #include "uuid.h"
#define VIR_FROM_THIS VIR_FROM_NODEDEV
VIR_ENUM_IMPL(virNodeDevCap, VIR_NODE_DEV_CAP_LAST, VIR_ENUM_IMPL(virNodeDevCap, VIR_NODE_DEV_CAP_LAST,
"system", "system",
@ -126,7 +127,7 @@ virNodeDeviceObjPtr virNodeDeviceAssignDef(virConnectPtr conn,
} }
if (VIR_ALLOC(device) < 0) { if (VIR_ALLOC(device) < 0) {
virNodeDeviceReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return NULL; return NULL;
} }
@ -143,7 +144,7 @@ virNodeDeviceObjPtr virNodeDeviceAssignDef(virConnectPtr conn,
device->def = NULL; device->def = NULL;
virNodeDeviceObjUnlock(device); virNodeDeviceObjUnlock(device);
virNodeDeviceObjFree(device); virNodeDeviceObjFree(device);
virNodeDeviceReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return NULL; return NULL;
} }
devs->objs[devs->count++] = device; devs->objs[devs->count++] = device;
@ -360,7 +361,7 @@ char *virNodeDeviceDefFormat(virConnectPtr conn,
return virBufferContentAndReset(&buf); return virBufferContentAndReset(&buf);
no_memory: no_memory:
virNodeDeviceReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
tmp = virBufferContentAndReset(&buf); tmp = virBufferContentAndReset(&buf);
VIR_FREE(tmp); VIR_FREE(tmp);
return NULL; return NULL;
@ -425,4 +426,3 @@ void virNodeDeviceObjUnlock(virNodeDeviceObjPtr obj)
{ {
virMutexUnlock(&obj->lock); virMutexUnlock(&obj->lock);
} }

View File

@ -51,6 +51,8 @@
#include "util.h" #include "util.h"
#include "nodeinfo.h" #include "nodeinfo.h"
#define VIR_FROM_THIS VIR_FROM_OPENVZ
static char *openvzLocateConfDir(void); static char *openvzLocateConfDir(void);
static int openvzGetVPSUUID(int vpsid, char *uuidstr); static int openvzGetVPSUUID(int vpsid, char *uuidstr);
static int openvzLocateConfFile(int vpsid, char *conffile, int maxlen, const char *ext); static int openvzLocateConfFile(int vpsid, char *conffile, int maxlen, const char *ext);
@ -305,7 +307,7 @@ openvzReadNetworkConf(virConnectPtr conn,
return 0; return 0;
no_memory: no_memory:
openvzError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
error: error:
virDomainNetDefFree(net); virDomainNetDefFree(net);
return -1; return -1;
@ -346,7 +348,7 @@ openvzReadFSConf(virConnectPtr conn,
return 0; return 0;
no_memory: no_memory:
openvzError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
error: error:
virDomainFSDefFree(fs); virDomainFSDefFree(fs);
return -1; return -1;
@ -461,7 +463,7 @@ int openvzLoadDomains(struct openvz_driver *driver) {
return 0; return 0;
no_memory: no_memory:
openvzError(NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(NULL);
cleanup: cleanup:
fclose(fp); fclose(fp);

View File

@ -58,6 +58,8 @@
#include "memory.h" #include "memory.h"
#include "bridge.h" #include "bridge.h"
#define VIR_FROM_THIS VIR_FROM_OPENVZ
#define OPENVZ_MAX_ARG 28 #define OPENVZ_MAX_ARG 28
#define CMDBUF_LEN 1488 #define CMDBUF_LEN 1488
#define CMDOP_LEN 288 #define CMDOP_LEN 288
@ -213,7 +215,7 @@ static char *openvzGetOSType(virDomainPtr dom)
} }
if (!(ret = strdup(vm->def->os.type))) if (!(ret = strdup(vm->def->os.type)))
openvzError(dom->conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(dom->conn);
cleanup: cleanup:
if (vm) if (vm)
@ -1056,7 +1058,7 @@ static virDrvOpenStatus openvzOpen(virConnectPtr conn,
} }
if (VIR_ALLOC(driver) < 0) { if (VIR_ALLOC(driver) < 0) {
openvzError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return VIR_DRV_OPEN_ERROR; return VIR_DRV_OPEN_ERROR;
} }
@ -1194,7 +1196,7 @@ static int openvzListDefinedDomains(virConnectPtr conn,
return got; return got;
no_memory: no_memory:
openvzError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
for ( ; got >= 0 ; got--) for ( ; got >= 0 ; got--)
VIR_FREE(names[got]); VIR_FREE(names[got]);
return -1; return -1;
@ -1329,4 +1331,3 @@ int openvzRegister(void) {
virRegisterDriver(&openvzDriver); virRegisterDriver(&openvzDriver);
return 0; return 0;
} }

View File

@ -948,7 +948,7 @@ xenProxyGetCapabilities (virConnectPtr conn)
xmllen = ans.len - sizeof (virProxyPacket); xmllen = ans.len - sizeof (virProxyPacket);
if (VIR_ALLOC_N(xml, xmllen+1) < 0) { if (VIR_ALLOC_N(xml, xmllen+1) < 0) {
virProxyError (conn, VIR_ERR_NO_MEMORY, __FUNCTION__); virReportOOMError (conn);
return NULL; return NULL;
} }
memmove (xml, ans.extra.str, xmllen); memmove (xml, ans.extra.str, xmllen);
@ -998,7 +998,7 @@ xenProxyDomainDumpXML(virDomainPtr domain, int flags ATTRIBUTE_UNUSED)
} }
xmllen = ans.len - sizeof(virProxyPacket); xmllen = ans.len - sizeof(virProxyPacket);
if (VIR_ALLOC_N(xml, xmllen+1) < 0) { if (VIR_ALLOC_N(xml, xmllen+1) < 0) {
virProxyError(domain->conn, VIR_ERR_NO_MEMORY, __FUNCTION__); virReportOOMError(domain->conn);
return NULL; return NULL;
} }
memmove(xml, &ans.extra.dinfo, xmllen); memmove(xml, &ans.extra.dinfo, xmllen);
@ -1050,7 +1050,7 @@ xenProxyDomainGetOSType(virDomainPtr domain)
} }
oslen = ans.len - sizeof(virProxyPacket); oslen = ans.len - sizeof(virProxyPacket);
if (VIR_ALLOC_N(ostype, oslen+1) < 0) { if (VIR_ALLOC_N(ostype, oslen+1) < 0) {
virProxyError(domain->conn, VIR_ERR_NO_MEMORY, __FUNCTION__); virReportOOMError(domain->conn);
return NULL; return NULL;
} }
memmove(ostype, &ans.extra.dinfo, oslen); memmove(ostype, &ans.extra.dinfo, oslen);

View File

@ -70,13 +70,11 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
/* Setup 2 critical defaults */ /* Setup 2 critical defaults */
if (!(driver->vncListen = strdup("127.0.0.1"))) { if (!(driver->vncListen = strdup("127.0.0.1"))) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY, virReportOOMError(NULL);
"%s", _("failed to allocate vncListen"));
return -1; return -1;
} }
if (!(driver->vncTLSx509certdir = strdup(SYSCONF_DIR "/pki/libvirt-vnc"))) { if (!(driver->vncTLSx509certdir = strdup(SYSCONF_DIR "/pki/libvirt-vnc"))) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY, virReportOOMError(NULL);
"%s", _("failed to allocate vncTLSx509certdir"));
return -1; return -1;
} }
@ -110,8 +108,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
if (p && p->str) { if (p && p->str) {
VIR_FREE(driver->vncTLSx509certdir); VIR_FREE(driver->vncTLSx509certdir);
if (!(driver->vncTLSx509certdir = strdup(p->str))) { if (!(driver->vncTLSx509certdir = strdup(p->str))) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY, virReportOOMError(NULL);
"%s", _("failed to allocate vncTLSx509certdir"));
virConfFree(conf); virConfFree(conf);
return -1; return -1;
} }
@ -122,8 +119,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
if (p && p->str) { if (p && p->str) {
VIR_FREE(driver->vncListen); VIR_FREE(driver->vncListen);
if (!(driver->vncListen = strdup(p->str))) { if (!(driver->vncListen = strdup(p->str))) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY, virReportOOMError(NULL);
"%s", _("failed to allocate vnc_listen"));
virConfFree(conf); virConfFree(conf);
return -1; return -1;
} }
@ -512,7 +508,7 @@ qemudNetworkIfaceConnect(virConnectPtr conn,
strchr(net->ifname, '%')) { strchr(net->ifname, '%')) {
VIR_FREE(net->ifname); VIR_FREE(net->ifname);
if (!(net->ifname = strdup("vnet%d"))) { if (!(net->ifname = strdup("vnet%d"))) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
goto error; goto error;
} }
} }
@ -555,8 +551,7 @@ qemudNetworkIfaceConnect(virConnectPtr conn,
return retval; return retval;
no_memory: no_memory:
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, virReportOOMError(conn);
"%s", _("failed to allocate space for tapfds string"));
error: error:
VIR_FREE(retval); VIR_FREE(retval);
if (tapfd != -1) if (tapfd != -1)
@ -1296,8 +1291,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
return 0; return 0;
no_memory: no_memory:
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, virReportOOMError(conn);
"%s", _("failed to allocate space for argv string"));
error: error:
if (tapfds && if (tapfds &&
*tapfds) { *tapfds) {
@ -1371,8 +1365,7 @@ qemudDomainStatusParseFile(virConnectPtr conn,
qemudDomainStatusPtr status = NULL; qemudDomainStatusPtr status = NULL;
if (VIR_ALLOC(status) < 0) { if (VIR_ALLOC(status) < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, virReportOOMError(conn);
"%s", _("failed to allocate space for vm status"));
goto error; goto error;
} }
@ -1402,7 +1395,7 @@ qemudDomainStatusParseFile(virConnectPtr conn,
ctxt = xmlXPathNewContext(xml); ctxt = xmlXPathNewContext(xml);
if (ctxt == NULL) { if (ctxt == NULL) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
goto error; goto error;
} }

View File

@ -1,7 +1,7 @@
/* /*
* driver.c: core driver methods for managing qemu guests * driver.c: core driver methods for managing qemu guests
* *
* Copyright (C) 2006, 2007, 2008 Red Hat, Inc. * Copyright (C) 2006, 2007, 2008, 2009 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange * Copyright (C) 2006 Daniel P. Berrange
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
@ -275,8 +275,7 @@ qemudRemoveDomainStatus(virConnectPtr conn,
char *file = NULL; char *file = NULL;
if (virAsprintf(&file, "%s/%s.xml", driver->stateDir, vm->def->name) < 0) { if (virAsprintf(&file, "%s/%s.xml", driver->stateDir, vm->def->name) < 0) {
qemudReportError(conn, vm, NULL, VIR_ERR_NO_MEMORY, virReportOOMError(conn);
"%s", _("failed to allocate space for status file"));
goto cleanup; goto cleanup;
} }
@ -728,8 +727,7 @@ static int qemudOpenMonitor(virConnectPtr conn,
goto error; goto error;
if (!(vm->monitorpath = strdup(monitor))) { if (!(vm->monitorpath = strdup(monitor))) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, virReportOOMError(conn);
"%s", _("failed to allocate space for monitor path"));
goto error; goto error;
} }
@ -770,8 +768,7 @@ static int qemudExtractMonitorPath(virConnectPtr conn,
while (*tmp) { while (*tmp) {
if (c_isspace(*tmp)) { if (c_isspace(*tmp)) {
if (VIR_ALLOC_N(*path, (tmp-dev)+1) < 0) { if (VIR_ALLOC_N(*path, (tmp-dev)+1) < 0) {
qemudReportError(conn, NULL, NULL, virReportOOMError(conn);
VIR_ERR_NO_MEMORY, NULL);
return -1; return -1;
} }
strncpy(*path, dev, (tmp-dev)); strncpy(*path, dev, (tmp-dev));
@ -876,8 +873,7 @@ qemudDetectVcpuPIDs(virConnectPtr conn,
vm->nvcpupids = vm->def->vcpus; vm->nvcpupids = vm->def->vcpus;
if (VIR_ALLOC_N(vm->vcpupids, vm->nvcpupids) < 0) { if (VIR_ALLOC_N(vm->vcpupids, vm->nvcpupids) < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, virReportOOMError(conn);
"%s", _("allocate cpumap"));
return -1; return -1;
} }
@ -1434,7 +1430,7 @@ static virDrvOpenStatus qemudOpen(virConnectPtr conn,
if (conn->uri == NULL) { if (conn->uri == NULL) {
conn->uri = xmlParseURI(uid ? "qemu:///session" : "qemu:///system"); conn->uri = xmlParseURI(uid ? "qemu:///session" : "qemu:///system");
if (!conn->uri) { if (!conn->uri) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,NULL); virReportOOMError(conn);
return VIR_DRV_OPEN_ERROR; return VIR_DRV_OPEN_ERROR;
} }
} else if (conn->uri->scheme == NULL || } else if (conn->uri->scheme == NULL ||
@ -1537,8 +1533,7 @@ static char *qemudGetCapabilities(virConnectPtr conn) {
qemuDriverLock(driver); qemuDriverLock(driver);
if ((xml = virCapabilitiesFormatXML(driver->caps)) == NULL) if ((xml = virCapabilitiesFormatXML(driver->caps)) == NULL)
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, virReportOOMError(conn);
"%s", _("failed to allocate space for capabilities support"));
qemuDriverUnlock(driver); qemuDriverUnlock(driver);
return xml; return xml;
@ -2020,8 +2015,7 @@ static char *qemudDomainGetOSType(virDomainPtr dom) {
} }
if (!(type = strdup(vm->def->os.type))) if (!(type = strdup(vm->def->os.type)))
qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_MEMORY, virReportOOMError(dom->conn);
"%s", _("failed to allocate space for ostype"));
cleanup: cleanup:
if (vm) if (vm)
@ -2785,8 +2779,7 @@ static int qemudListDefinedDomains(virConnectPtr conn,
virDomainObjLock(driver->domains.objs[i]); virDomainObjLock(driver->domains.objs[i]);
if (!virDomainIsActive(driver->domains.objs[i])) { if (!virDomainIsActive(driver->domains.objs[i])) {
if (!(names[got++] = strdup(driver->domains.objs[i]->def->name))) { if (!(names[got++] = strdup(driver->domains.objs[i]->def->name))) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, virReportOOMError(conn);
"%s", _("failed to allocate space for VM name string"));
virDomainObjUnlock(driver->domains.objs[i]); virDomainObjUnlock(driver->domains.objs[i]);
goto cleanup; goto cleanup;
} }
@ -2996,7 +2989,7 @@ static char *qemudDiskDeviceName(const virConnectPtr conn,
} }
if (ret == -1) { if (ret == -1) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return NULL; return NULL;
} }
@ -3060,7 +3053,7 @@ static int qemudDomainChangeEjectableMedia(virConnectPtr conn,
} }
if (!devname) { if (!devname) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return -1; return -1;
} }
} }
@ -3068,12 +3061,12 @@ static int qemudDomainChangeEjectableMedia(virConnectPtr conn,
if (newdisk->src) { if (newdisk->src) {
safe_path = qemudEscapeMonitorArg(newdisk->src); safe_path = qemudEscapeMonitorArg(newdisk->src);
if (!safe_path) { if (!safe_path) {
qemudReportError(conn, dom, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
VIR_FREE(devname); VIR_FREE(devname);
return -1; return -1;
} }
if (virAsprintf(&cmd, "change %s \"%s\"", devname, safe_path) == -1) { if (virAsprintf(&cmd, "change %s \"%s\"", devname, safe_path) == -1) {
qemudReportError(conn, dom, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
VIR_FREE(safe_path); VIR_FREE(safe_path);
VIR_FREE(devname); VIR_FREE(devname);
return -1; return -1;
@ -3081,7 +3074,7 @@ static int qemudDomainChangeEjectableMedia(virConnectPtr conn,
VIR_FREE(safe_path); VIR_FREE(safe_path);
} else if (virAsprintf(&cmd, "eject %s", devname) == -1) { } else if (virAsprintf(&cmd, "eject %s", devname) == -1) {
qemudReportError(conn, dom, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
VIR_FREE(devname); VIR_FREE(devname);
return -1; return -1;
} }
@ -3133,7 +3126,7 @@ static int qemudDomainAttachPciDiskDevice(virConnectPtr conn,
} }
if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0) { if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return -1; return -1;
} }
@ -3148,7 +3141,7 @@ static int qemudDomainAttachPciDiskDevice(virConnectPtr conn,
safe_path, type); safe_path, type);
VIR_FREE(safe_path); VIR_FREE(safe_path);
if (ret == -1) { if (ret == -1) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return ret; return ret;
} }
@ -3203,7 +3196,7 @@ static int qemudDomainAttachUsbMassstorageDevice(virConnectPtr conn,
} }
if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0) { if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return -1; return -1;
} }
@ -3217,7 +3210,7 @@ static int qemudDomainAttachUsbMassstorageDevice(virConnectPtr conn,
ret = virAsprintf(&cmd, "usb_add disk:%s", safe_path); ret = virAsprintf(&cmd, "usb_add disk:%s", safe_path);
VIR_FREE(safe_path); VIR_FREE(safe_path);
if (ret == -1) { if (ret == -1) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return ret; return ret;
} }
@ -3257,7 +3250,7 @@ static int qemudDomainAttachHostDevice(virConnectPtr conn,
char *cmd, *reply; char *cmd, *reply;
if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs+1) < 0) { if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs+1) < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return -1; return -1;
} }
@ -3271,7 +3264,7 @@ static int qemudDomainAttachHostDevice(virConnectPtr conn,
dev->data.hostdev->source.subsys.u.usb.device); dev->data.hostdev->source.subsys.u.usb.device);
} }
if (ret == -1) { if (ret == -1) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return -1; return -1;
} }
@ -3398,7 +3391,7 @@ static int qemudDomainDetachPciDiskDevice(virConnectPtr conn,
} }
if (virAsprintf(&cmd, "pci_del 0 %d", detach->slotnum) < 0) { if (virAsprintf(&cmd, "pci_del 0 %d", detach->slotnum) < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
goto cleanup; goto cleanup;
} }
@ -3421,7 +3414,7 @@ static int qemudDomainDetachPciDiskDevice(virConnectPtr conn,
if (vm->def->ndisks > 1) { if (vm->def->ndisks > 1) {
vm->def->disks[i] = vm->def->disks[--vm->def->ndisks]; vm->def->disks[i] = vm->def->disks[--vm->def->ndisks];
if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks) < 0) { if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks) < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
goto cleanup; goto cleanup;
} }
qsort(vm->def->disks, vm->def->ndisks, sizeof(*vm->def->disks), qsort(vm->def->disks, vm->def->ndisks, sizeof(*vm->def->disks),
@ -4071,8 +4064,7 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn,
/* Caller frees */ /* Caller frees */
if (virAsprintf(uri_out, "tcp:%s:%d", hostname, this_port) < 0) { if (virAsprintf(uri_out, "tcp:%s:%d", hostname, this_port) < 0) {
qemudReportError (dconn, NULL, NULL, VIR_ERR_NO_MEMORY, virReportOOMError (dconn);
"%s", strerror (errno));
goto cleanup; goto cleanup;
} }
} else { } else {

View File

@ -507,7 +507,7 @@ doRemoteOpen (virConnectPtr conn,
} }
if (!name) { if (!name) {
error(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
goto failed; goto failed;
} }
@ -803,7 +803,7 @@ doRemoteOpen (virConnectPtr conn,
conn->uri = xmlParseURI(uriret.uri); conn->uri = xmlParseURI(uriret.uri);
VIR_FREE(uriret.uri); VIR_FREE(uriret.uri);
if (!conn->uri) { if (!conn->uri) {
error (conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError (conn);
goto failed; goto failed;
} }
} }
@ -862,7 +862,7 @@ doRemoteOpen (virConnectPtr conn,
return retcode; return retcode;
out_of_memory: out_of_memory:
error (conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError (conn);
failed: failed:
/* Close the socket if we failed. */ /* Close the socket if we failed. */
@ -904,7 +904,7 @@ remoteOpen (virConnectPtr conn,
return VIR_DRV_OPEN_DECLINED; return VIR_DRV_OPEN_DECLINED;
if (VIR_ALLOC(priv) < 0) { if (VIR_ALLOC(priv) < 0) {
error (conn, VIR_ERR_NO_MEMORY, _("struct private_data")); virReportOOMError (conn);
return VIR_DRV_OPEN_ERROR; return VIR_DRV_OPEN_ERROR;
} }
@ -2837,7 +2837,7 @@ remoteDomainSetSchedulerParameters (virDomainPtr domain,
// call() will free this: // call() will free this:
args.params.params_val[i].field = strdup (params[i].field); args.params.params_val[i].field = strdup (params[i].field);
if (args.params.params_val[i].field == NULL) { if (args.params.params_val[i].field == NULL) {
error (domain->conn, VIR_ERR_NO_MEMORY, _("out of memory")); virReportOOMError (domain->conn);
do_error = 1; do_error = 1;
} }
args.params.params_val[i].value.type = params[i].type; args.params.params_val[i].value.type = params[i].type;
@ -3087,7 +3087,7 @@ remoteNetworkOpen (virConnectPtr conn,
struct private_data *priv; struct private_data *priv;
int ret, rflags = 0; int ret, rflags = 0;
if (VIR_ALLOC(priv) < 0) { if (VIR_ALLOC(priv) < 0) {
error (conn, VIR_ERR_NO_MEMORY, _("struct private_data")); virReportOOMError (conn);
return VIR_DRV_OPEN_ERROR; return VIR_DRV_OPEN_ERROR;
} }
if (virMutexInit(&priv->lock) < 0) { if (virMutexInit(&priv->lock) < 0) {
@ -3600,7 +3600,7 @@ remoteStorageOpen (virConnectPtr conn,
struct private_data *priv; struct private_data *priv;
int ret, rflags = 0; int ret, rflags = 0;
if (VIR_ALLOC(priv) < 0) { if (VIR_ALLOC(priv) < 0) {
error (NULL, VIR_ERR_NO_MEMORY, _("struct private_data")); virReportOOMError (NULL);
return VIR_DRV_OPEN_ERROR; return VIR_DRV_OPEN_ERROR;
} }
if (virMutexInit(&priv->lock) < 0) { if (virMutexInit(&priv->lock) < 0) {
@ -4553,7 +4553,7 @@ remoteDevMonOpen(virConnectPtr conn,
struct private_data *priv; struct private_data *priv;
int ret, rflags = 0; int ret, rflags = 0;
if (VIR_ALLOC(priv) < 0) { if (VIR_ALLOC(priv) < 0) {
error (NULL, VIR_ERR_NO_MEMORY, _("struct private_data")); virReportOOMError (NULL);
return VIR_DRV_OPEN_ERROR; return VIR_DRV_OPEN_ERROR;
} }
if (virMutexInit(&priv->lock) < 0) { if (virMutexInit(&priv->lock) < 0) {
@ -4957,10 +4957,7 @@ static char *addrToString(struct sockaddr_storage *sa, socklen_t salen)
} }
if (VIR_ALLOC_N(addr, strlen(host) + 1 + strlen(port) + 1) < 0) { if (VIR_ALLOC_N(addr, strlen(host) + 1 + strlen(port) + 1) < 0) {
virRaiseError (NULL, NULL, NULL, VIR_FROM_REMOTE, virReportOOMError (NULL);
VIR_ERR_NO_MEMORY, VIR_ERR_ERROR,
NULL, NULL, NULL, 0, 0,
"address");
return NULL; return NULL;
} }
@ -6329,8 +6326,7 @@ call (virConnectPtr conn, struct private_data *priv,
ret_filter, ret); ret_filter, ret);
if (!thiscall) { if (!thiscall) {
error (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, virReportOOMError (flags & REMOTE_CALL_IN_OPEN ? NULL : conn);
VIR_ERR_NO_MEMORY, NULL);
return -1; return -1;
} }

View File

@ -23,6 +23,8 @@
#include "util.h" #include "util.h"
#include "memory.h" #include "memory.h"
#define VIR_FROM_THIS VIR_FROM_SEXPR
#define virSexprError(code, fmt...) \ #define virSexprError(code, fmt...) \
virReportErrorHelper(NULL, VIR_FROM_SEXPR, code, __FILE__, \ virReportErrorHelper(NULL, VIR_FROM_SEXPR, code, __FILE__, \
__FUNCTION__, __LINE__, fmt) __FUNCTION__, __LINE__, fmt)
@ -40,7 +42,7 @@ sexpr_new(void)
struct sexpr *ret; struct sexpr *ret;
if (VIR_ALLOC(ret) < 0) { if (VIR_ALLOC(ret) < 0) {
virSexprError(VIR_ERR_NO_MEMORY, "%s", _("failed to allocate a node")); virReportOOMError(NULL);
return (NULL); return (NULL);
} }
ret->kind = SEXPR_NIL; ret->kind = SEXPR_NIL;
@ -343,8 +345,7 @@ _string2sexpr(const char *buffer, size_t * end)
ret->u.value = strndup(start, ptr - start); ret->u.value = strndup(start, ptr - start);
if (ret->u.value == NULL) { if (ret->u.value == NULL) {
virSexprError(VIR_ERR_NO_MEMORY, virReportOOMError(NULL);
"%s", _("failed to copy a string"));
goto error; goto error;
} }
@ -360,8 +361,7 @@ _string2sexpr(const char *buffer, size_t * end)
ret->u.value = strndup(start, ptr - start); ret->u.value = strndup(start, ptr - start);
if (ret->u.value == NULL) { if (ret->u.value == NULL) {
virSexprError(VIR_ERR_NO_MEMORY, virReportOOMError(NULL);
"%s", _("failed to copy a string"));
goto error; goto error;
} }
} }

View File

@ -1,7 +1,7 @@
/* /*
* Linux block and network stats. * Linux block and network stats.
* *
* Copyright (C) 2007, 2008 Red Hat, Inc. * Copyright (C) 2007-2009 Red Hat, Inc.
* *
* See COPYING.LIB for the License of this software * See COPYING.LIB for the License of this software
* *
@ -31,6 +31,8 @@
#include "stats_linux.h" #include "stats_linux.h"
#include "memory.h" #include "memory.h"
#define VIR_FROM_THIS VIR_FROM_STATS_LINUX
/** /**
* statsErrorFunc: * statsErrorFunc:
* @conn: the connection * @conn: the connection
@ -297,8 +299,7 @@ xenLinuxDomainDeviceID(virConnectPtr conn, int domid, const char *path)
retval = virAsprintf(&mod_path, "/dev/%s", path); retval = virAsprintf(&mod_path, "/dev/%s", path);
if (retval < 0) { if (retval < 0) {
statsErrorFunc (conn, VIR_ERR_NO_MEMORY, __FUNCTION__, virReportOOMError (conn);
"allocating mod_path", domid);
return -1; return -1;
} }

View File

@ -196,7 +196,7 @@ qcowXGetBackingStore(virConnectPtr conn,
if (size + 1 == 0) if (size + 1 == 0)
return BACKING_STORE_INVALID; return BACKING_STORE_INVALID;
if (VIR_ALLOC_N(*res, size + 1) < 0) { if (VIR_ALLOC_N(*res, size + 1) < 0) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, _("backing store path")); virReportOOMError(conn);
return BACKING_STORE_ERROR; return BACKING_STORE_ERROR;
} }
memcpy(*res, buf + offset, size); memcpy(*res, buf + offset, size);
@ -237,7 +237,7 @@ vmdk4GetBackingStore(virConnectPtr conn,
*end = '\0'; *end = '\0';
*res = strdup(start); *res = strdup(start);
if (*res == NULL) { if (*res == NULL) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, _("backing store path")); virReportOOMError(conn);
return BACKING_STORE_ERROR; return BACKING_STORE_ERROR;
} }
return BACKING_STORE_OK; return BACKING_STORE_OK;
@ -395,8 +395,7 @@ static int virStorageBackendProbeTarget(virConnectPtr conn,
= absolutePathFromBaseFile(target->path, base); = absolutePathFromBaseFile(target->path, base);
VIR_FREE(base); VIR_FREE(base);
if (*backingStore == NULL) { if (*backingStore == NULL) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, virReportOOMError(conn);
_("backing store path"));
return -1; return -1;
} }
} }

View File

@ -97,7 +97,7 @@ virStorageBackendISCSIExtractSession(virConnectPtr conn,
if (STREQ(groups[1], pool->def->source.devices[0].path)) { if (STREQ(groups[1], pool->def->source.devices[0].path)) {
if ((*session = strdup(groups[0])) == NULL) { if ((*session = strdup(groups[0])) == NULL) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("session")); virReportOOMError(conn);
return -1; return -1;
} }
} }
@ -179,19 +179,19 @@ virStorageBackendISCSINewLun(virConnectPtr conn, virStoragePoolObjPtr pool,
int opentries = 0; int opentries = 0;
if (VIR_ALLOC(vol) < 0) { if (VIR_ALLOC(vol) < 0) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("volume")); virReportOOMError(conn);
goto cleanup; goto cleanup;
} }
vol->type = VIR_STORAGE_VOL_BLOCK; vol->type = VIR_STORAGE_VOL_BLOCK;
if (virAsprintf(&(vol->name), "lun-%d", lun) < 0) { if (virAsprintf(&(vol->name), "lun-%d", lun) < 0) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("name")); virReportOOMError(conn);
goto cleanup; goto cleanup;
} }
if (virAsprintf(&devpath, "/dev/%s", dev) < 0) { if (virAsprintf(&devpath, "/dev/%s", dev) < 0) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("devpath")); virReportOOMError(conn);
goto cleanup; goto cleanup;
} }
@ -238,7 +238,7 @@ virStorageBackendISCSINewLun(virConnectPtr conn, virStoragePoolObjPtr pool,
/* XXX use unique iSCSI id instead */ /* XXX use unique iSCSI id instead */
vol->key = strdup(vol->target.path); vol->key = strdup(vol->target.path);
if (vol->key == NULL) { if (vol->key == NULL) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("key")); virReportOOMError(conn);
goto cleanup; goto cleanup;
} }
@ -248,7 +248,7 @@ virStorageBackendISCSINewLun(virConnectPtr conn, virStoragePoolObjPtr pool,
if (VIR_REALLOC_N(pool->volumes.objs, if (VIR_REALLOC_N(pool->volumes.objs,
pool->volumes.count+1) < 0) { pool->volumes.count+1) < 0) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
goto cleanup; goto cleanup;
} }
pool->volumes.objs[pool->volumes.count++] = vol; pool->volumes.objs[pool->volumes.count++] = vol;
@ -481,8 +481,7 @@ virStorageBackendISCSIFindLUNs(virConnectPtr conn,
scsidev = strdup(block2); scsidev = strdup(block2);
} }
if (scsidev == NULL) { if (scsidev == NULL) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", virReportOOMError(conn);
_("Failed allocating memory for scsidev"));
retval = -1; retval = -1;
goto namelist_cleanup; goto namelist_cleanup;
} }
@ -563,7 +562,7 @@ virStorageBackendISCSIPortal(virConnectPtr conn,
return NULL; return NULL;
if (VIR_ALLOC_N(portal, strlen(ipaddr) + 1 + 4 + 2 + 1) < 0) { if (VIR_ALLOC_N(portal, strlen(ipaddr) + 1 + 4 + 2 + 1) < 0) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("portal")); virReportOOMError(conn);
return NULL; return NULL;
} }

View File

@ -1,7 +1,7 @@
/* /*
* storage_backend_logvol.c: storage backend for logical volume handling * storage_backend_logvol.c: storage backend for logical volume handling
* *
* Copyright (C) 2007-2008 Red Hat, Inc. * Copyright (C) 2007-2009 Red Hat, Inc.
* Copyright (C) 2007-2008 Daniel P. Berrange * Copyright (C) 2007-2008 Daniel P. Berrange
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
@ -84,21 +84,21 @@ virStorageBackendLogicalMakeVol(virConnectPtr conn,
/* Or a completely new volume */ /* Or a completely new volume */
if (vol == NULL) { if (vol == NULL) {
if (VIR_ALLOC(vol) < 0) { if (VIR_ALLOC(vol) < 0) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("volume")); virReportOOMError(conn);
return -1; return -1;
} }
vol->type = VIR_STORAGE_VOL_BLOCK; vol->type = VIR_STORAGE_VOL_BLOCK;
if ((vol->name = strdup(groups[0])) == NULL) { if ((vol->name = strdup(groups[0])) == NULL) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("volume")); virReportOOMError(conn);
virStorageVolDefFree(vol); virStorageVolDefFree(vol);
return -1; return -1;
} }
if (VIR_REALLOC_N(pool->volumes.objs, if (VIR_REALLOC_N(pool->volumes.objs,
pool->volumes.count + 1)) { pool->volumes.count + 1)) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
virStorageVolDefFree(vol); virStorageVolDefFree(vol);
return -1; return -1;
} }
@ -127,7 +127,7 @@ virStorageBackendLogicalMakeVol(virConnectPtr conn,
if (vol->key == NULL && if (vol->key == NULL &&
(vol->key = strdup(groups[2])) == NULL) { (vol->key = strdup(groups[2])) == NULL) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("volume")); virReportOOMError(conn);
return -1; return -1;
} }
@ -138,13 +138,13 @@ virStorageBackendLogicalMakeVol(virConnectPtr conn,
/* Finally fill in extents information */ /* Finally fill in extents information */
if (VIR_REALLOC_N(vol->source.extents, if (VIR_REALLOC_N(vol->source.extents,
vol->source.nextent + 1) < 0) { vol->source.nextent + 1) < 0) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("extents")); virReportOOMError(conn);
return -1; return -1;
} }
if ((vol->source.extents[vol->source.nextent].path = if ((vol->source.extents[vol->source.nextent].path =
strdup(groups[3])) == NULL) { strdup(groups[3])) == NULL) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("extents")); virReportOOMError(conn);
return -1; return -1;
} }
@ -265,8 +265,7 @@ virStorageBackendLogicalFindPoolSourcesFunc(virConnectPtr conn,
vgname = strdup(groups[1]); vgname = strdup(groups[1]);
if (pvname == NULL || vgname == NULL) { if (pvname == NULL || vgname == NULL) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", virReportOOMError(conn);
_("allocating pvname or vgname"));
goto err_no_memory; goto err_no_memory;
} }
@ -280,8 +279,7 @@ virStorageBackendLogicalFindPoolSourcesFunc(virConnectPtr conn,
if (thisSource == NULL) { if (thisSource == NULL) {
if (VIR_REALLOC_N(sourceList->sources, sourceList->nsources + 1) != 0) { if (VIR_REALLOC_N(sourceList->sources, sourceList->nsources + 1) != 0) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", virReportOOMError(conn);
_("allocating new source"));
goto err_no_memory; goto err_no_memory;
} }
@ -295,8 +293,7 @@ virStorageBackendLogicalFindPoolSourcesFunc(virConnectPtr conn,
VIR_FREE(vgname); VIR_FREE(vgname);
if (VIR_REALLOC_N(thisSource->devices, thisSource->ndevice + 1) != 0) { if (VIR_REALLOC_N(thisSource->devices, thisSource->ndevice + 1) != 0) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", virReportOOMError(conn);
_("allocating new device"));
goto err_no_memory; goto err_no_memory;
} }
@ -395,7 +392,7 @@ virStorageBackendLogicalBuildPool(virConnectPtr conn,
memset(zeros, 0, sizeof(zeros)); memset(zeros, 0, sizeof(zeros));
if (VIR_ALLOC_N(vgargv, 3 + pool->def->source.ndevice) < 0) { if (VIR_ALLOC_N(vgargv, 3 + pool->def->source.ndevice) < 0) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("command line")); virReportOOMError(conn);
return -1; return -1;
} }
@ -605,7 +602,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn,
} }
if (VIR_ALLOC_N(vol->target.path, strlen(pool->def->target.path) + if (VIR_ALLOC_N(vol->target.path, strlen(pool->def->target.path) +
1 + strlen(vol->name) + 1) < 0) { 1 + strlen(vol->name) + 1) < 0) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("volume")); virReportOOMError(conn);
return -1; return -1;
} }
strcpy(vol->target.path, pool->def->target.path); strcpy(vol->target.path, pool->def->target.path);

View File

@ -428,8 +428,7 @@ virStoragePoolDefParseDoc(virConnectPtr conn,
char *authType = NULL; char *authType = NULL;
if (VIR_ALLOC(ret) < 0) { if (VIR_ALLOC(ret) < 0) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, virReportOOMError(conn);
"%s", _("cannot allocate storage pool"));
return NULL; return NULL;
} }
@ -513,7 +512,7 @@ virStoragePoolDefParseDoc(virConnectPtr conn,
} }
if (VIR_ALLOC_N(ret->source.devices, nsource) < 0) { if (VIR_ALLOC_N(ret->source.devices, nsource) < 0) {
VIR_FREE(nodeset); VIR_FREE(nodeset);
virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("device")); virReportOOMError(conn);
goto cleanup; goto cleanup;
} }
for (i = 0 ; i < nsource ; i++) { for (i = 0 ; i < nsource ; i++) {
@ -543,8 +542,7 @@ virStoragePoolDefParseDoc(virConnectPtr conn,
/* source name defaults to pool name */ /* source name defaults to pool name */
ret->source.name = strdup(ret->name); ret->source.name = strdup(ret->name);
if (ret->source.name == NULL) { if (ret->source.name == NULL) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", virReportOOMError(conn);
_("pool name"));
goto cleanup; goto cleanup;
} }
} }
@ -642,8 +640,7 @@ virStoragePoolDefParse(virConnectPtr conn,
ctxt = xmlXPathNewContext(xml); ctxt = xmlXPathNewContext(xml);
if (ctxt == NULL) { if (ctxt == NULL) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, virReportOOMError(conn);
"%s", _("xmlXPathContext"));
goto cleanup; goto cleanup;
} }
@ -793,7 +790,7 @@ virStoragePoolDefFormat(virConnectPtr conn,
return virBufferContentAndReset(&buf); return virBufferContentAndReset(&buf);
no_memory: no_memory:
virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("xml")); virReportOOMError(conn);
cleanup: cleanup:
free(virBufferContentAndReset(&buf)); free(virBufferContentAndReset(&buf));
return NULL; return NULL;
@ -936,8 +933,7 @@ virStorageVolDefParseDoc(virConnectPtr conn,
return NULL; return NULL;
if (VIR_ALLOC(ret) < 0) { if (VIR_ALLOC(ret) < 0) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, virReportOOMError(conn);
"%s", _("cannot allocate storage vol"));
return NULL; return NULL;
} }
@ -1065,8 +1061,7 @@ virStorageVolDefParse(virConnectPtr conn,
ctxt = xmlXPathNewContext(xml); ctxt = xmlXPathNewContext(xml);
if (ctxt == NULL) { if (ctxt == NULL) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, virReportOOMError(conn);
"%s", _("xmlXPathContext"));
goto cleanup; goto cleanup;
} }
@ -1198,7 +1193,7 @@ virStorageVolDefFormat(virConnectPtr conn,
return virBufferContentAndReset(&buf); return virBufferContentAndReset(&buf);
no_memory: no_memory:
virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("xml")); virReportOOMError(conn);
cleanup: cleanup:
tmp = virBufferContentAndReset(&buf); tmp = virBufferContentAndReset(&buf);
VIR_FREE(tmp); VIR_FREE(tmp);
@ -1302,8 +1297,7 @@ virStoragePoolObjAssignDef(virConnectPtr conn,
} }
if (VIR_ALLOC(pool) < 0) { if (VIR_ALLOC(pool) < 0) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, virReportOOMError(conn);
"%s", _("pool"));
return NULL; return NULL;
} }
@ -1321,7 +1315,7 @@ virStoragePoolObjAssignDef(virConnectPtr conn,
pool->def = NULL; pool->def = NULL;
virStoragePoolObjUnlock(pool); virStoragePoolObjUnlock(pool);
virStoragePoolObjFree(pool); virStoragePoolObjFree(pool);
virStorageReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return NULL; return NULL;
} }
pools->objs[pools->count++] = pool; pools->objs[pools->count++] = pool;
@ -1463,8 +1457,7 @@ virStoragePoolObjSaveDef(virConnectPtr conn,
return -1; return -1;
} }
if (!(pool->configFile = strdup(path))) { if (!(pool->configFile = strdup(path))) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, virReportOOMError(conn);
"%s", _("configFile"));
return -1; return -1;
} }
@ -1477,8 +1470,7 @@ virStoragePoolObjSaveDef(virConnectPtr conn,
return -1; return -1;
} }
if (!(pool->autostartLink = strdup(path))) { if (!(pool->autostartLink = strdup(path))) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY, virReportOOMError(conn);
"%s", _("config file"));
VIR_FREE(pool->configFile); VIR_FREE(pool->configFile);
return -1; return -1;
} }
@ -1577,7 +1569,7 @@ char *virStoragePoolSourceListFormat(virConnectPtr conn,
return virBufferContentAndReset(&buf); return virBufferContentAndReset(&buf);
no_memory: no_memory:
virStorageReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
cleanup: cleanup:
free(virBufferContentAndReset(&buf)); free(virBufferContentAndReset(&buf));
return NULL; return NULL;

View File

@ -1,7 +1,7 @@
/* /*
* uml_conf.c: UML driver configuration * uml_conf.c: UML driver configuration
* *
* Copyright (C) 2006, 2007, 2008 Red Hat, Inc. * Copyright (C) 2006-2009 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange * Copyright (C) 2006 Daniel P. Berrange
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
@ -45,6 +45,7 @@
#include "nodeinfo.h" #include "nodeinfo.h"
#include "verify.h" #include "verify.h"
#define VIR_FROM_THIS VIR_FROM_UML
#define umlLog(level, msg, ...) \ #define umlLog(level, msg, ...) \
virLogMessage(__FILE__, level, 0, msg, __VA_ARGS__) virLogMessage(__FILE__, level, 0, msg, __VA_ARGS__)
@ -100,14 +101,14 @@ umlBuildCommandLineChr(virConnectPtr conn,
switch (def->type) { switch (def->type) {
case VIR_DOMAIN_CHR_TYPE_NULL: case VIR_DOMAIN_CHR_TYPE_NULL:
if (virAsprintf(&ret, "%s%d=null", dev, def->dstPort) < 0) { if (virAsprintf(&ret, "%s%d=null", dev, def->dstPort) < 0) {
umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return NULL; return NULL;
} }
break; break;
case VIR_DOMAIN_CHR_TYPE_PTY: case VIR_DOMAIN_CHR_TYPE_PTY:
if (virAsprintf(&ret, "%s%d=pts", dev, def->dstPort) < 0) { if (virAsprintf(&ret, "%s%d=pts", dev, def->dstPort) < 0) {
umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return NULL; return NULL;
} }
break; break;
@ -115,14 +116,14 @@ umlBuildCommandLineChr(virConnectPtr conn,
case VIR_DOMAIN_CHR_TYPE_DEV: case VIR_DOMAIN_CHR_TYPE_DEV:
if (virAsprintf(&ret, "%s%d=tty:%s", dev, def->dstPort, if (virAsprintf(&ret, "%s%d=tty:%s", dev, def->dstPort,
def->data.file.path) < 0) { def->data.file.path) < 0) {
umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return NULL; return NULL;
} }
break; break;
case VIR_DOMAIN_CHR_TYPE_STDIO: case VIR_DOMAIN_CHR_TYPE_STDIO:
if (virAsprintf(&ret, "%s%d=fd:0,fd:1", dev, def->dstPort) < 0) { if (virAsprintf(&ret, "%s%d=fd:0,fd:1", dev, def->dstPort) < 0) {
umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return NULL; return NULL;
} }
break; break;
@ -136,7 +137,7 @@ umlBuildCommandLineChr(virConnectPtr conn,
if (virAsprintf(&ret, "%s%d=port:%s", dev, def->dstPort, if (virAsprintf(&ret, "%s%d=port:%s", dev, def->dstPort,
def->data.tcp.service) < 0) { def->data.tcp.service) < 0) {
umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return NULL; return NULL;
} }
break; break;
@ -308,8 +309,7 @@ int umlBuildCommandLine(virConnectPtr conn,
return 0; return 0;
no_memory: no_memory:
umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, virReportOOMError(conn);
"%s", _("failed to allocate space for argv string"));
error: error:
if (tapfds && if (tapfds &&
*tapfds) { *tapfds) {

View File

@ -458,7 +458,7 @@ virExec(virConnectPtr conn,
char *argv_str; char *argv_str;
if ((argv_str = virArgvToString(argv)) == NULL) { if ((argv_str = virArgvToString(argv)) == NULL) {
ReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("command debug string")); virReportOOMError(conn);
return -1; return -1;
} }
DEBUG0(argv_str); DEBUG0(argv_str);
@ -526,7 +526,7 @@ virPipeReadUntilEOF(virConnectPtr conn, int outfd, int errfd,
buf = ((fds[i].fd == outfd) ? outbuf : errbuf); buf = ((fds[i].fd == outfd) ? outbuf : errbuf);
size = (*buf ? strlen(*buf) : 0); size = (*buf ? strlen(*buf) : 0);
if (VIR_REALLOC_N(*buf, size+got+1) < 0) { if (VIR_REALLOC_N(*buf, size+got+1) < 0) {
ReportError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
goto error; goto error;
} }
memmove(*buf+size, data, got); memmove(*buf+size, data, got);
@ -576,7 +576,7 @@ virRun(virConnectPtr conn,
char *argv_str = NULL; char *argv_str = NULL;
if ((argv_str = virArgvToString(argv)) == NULL) { if ((argv_str = virArgvToString(argv)) == NULL) {
ReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("command debug string")); virReportOOMError(conn);
goto error; goto error;
} }
DEBUG0(argv_str); DEBUG0(argv_str);

View File

@ -1639,8 +1639,7 @@ virXen_setvcpumap(int handle, int id, unsigned int vcpu,
* for Xen, and also nr_cpus must be 'sizeof(uint64_t) * 8' */ * for Xen, and also nr_cpus must be 'sizeof(uint64_t) * 8' */
if (maplen < 8) { if (maplen < 8) {
if (VIR_ALLOC_N(new, sizeof(uint64_t)) < 0) { if (VIR_ALLOC_N(new, sizeof(uint64_t)) < 0) {
virXenErrorFunc(NULL, VIR_ERR_NO_MEMORY, __FUNCTION__, virReportOOMError(NULL);
"allocating private data", 0);
return (-1); return (-1);
} }
memcpy(new, cpumap, maplen); memcpy(new, cpumap, maplen);
@ -1965,7 +1964,7 @@ xenHypervisorInit(void)
hypervisor_version = 2; hypervisor_version = 2;
if (VIR_ALLOC(ipt) < 0) { if (VIR_ALLOC(ipt) < 0) {
virXenError(NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(NULL);
return(-1); return(-1);
} }
/* Currently consider RHEL5.0 Fedora7, xen-3.1, and xen-unstable */ /* Currently consider RHEL5.0 Fedora7, xen-3.1, and xen-unstable */
@ -2359,7 +2358,7 @@ xenHypervisorMakeCapabilitiesSunOS(virConnectPtr conn)
utsname.machine, utsname.machine,
pae, hvm, pae, hvm,
guest_arches, i)) == NULL) guest_arches, i)) == NULL)
virXenError(NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(NULL);
return caps; return caps;
} }
@ -2520,7 +2519,7 @@ xenHypervisorMakeCapabilitiesInternal(virConnectPtr conn,
return caps; return caps;
no_memory: no_memory:
virXenError(NULL, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(NULL);
virCapabilitiesFree(caps); virCapabilitiesFree(caps);
return NULL; return NULL;
} }
@ -2593,7 +2592,7 @@ xenHypervisorGetCapabilities (virConnectPtr conn)
char *xml; char *xml;
if (!(xml = virCapabilitiesFormatXML(priv->caps))) { if (!(xml = virCapabilitiesFormatXML(priv->caps))) {
virXenError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return NULL; return NULL;
} }
@ -2626,8 +2625,7 @@ xenHypervisorNumOfDomains(virConnectPtr conn)
retry: retry:
if (!(XEN_GETDOMAININFOLIST_ALLOC(dominfos, maxids))) { if (!(XEN_GETDOMAININFOLIST_ALLOC(dominfos, maxids))) {
virXenError(conn, VIR_ERR_NO_MEMORY, _("allocating %d domain info"), virReportOOMError(conn);
maxids);
return(-1); return(-1);
} }
@ -2688,8 +2686,7 @@ xenHypervisorListDomains(virConnectPtr conn, int *ids, int maxids)
return(0); return(0);
if (!(XEN_GETDOMAININFOLIST_ALLOC(dominfos, maxids))) { if (!(XEN_GETDOMAININFOLIST_ALLOC(dominfos, maxids))) {
virXenError(conn, VIR_ERR_NO_MEMORY, "allocating %d domain info", virReportOOMError(conn);
maxids);
return(-1); return(-1);
} }
@ -2798,8 +2795,7 @@ xenHypervisorLookupDomainByUUID(virConnectPtr conn,
retry: retry:
if (!(XEN_GETDOMAININFOLIST_ALLOC(dominfos, maxids))) { if (!(XEN_GETDOMAININFOLIST_ALLOC(dominfos, maxids))) {
virXenError(conn, VIR_ERR_NO_MEMORY, "allocating %d domain info", virReportOOMError(conn);
maxids);
return(NULL); return(NULL);
} }

View File

@ -526,7 +526,7 @@ xend_op_ext(virConnectPtr xend, const char *path, char *error,
} }
if (virBufferError(&buf)) { if (virBufferError(&buf)) {
virXendError(NULL, VIR_ERR_NO_MEMORY, "%s", _("allocate buffer")); virReportOOMError(NULL);
return -1; return -1;
} }
@ -706,7 +706,7 @@ urlencode(const char *string)
size_t i; size_t i;
if (VIR_ALLOC_N(buffer, len * 3 + 1) < 0) { if (VIR_ALLOC_N(buffer, len * 3 + 1) < 0) {
virXendError(NULL, VIR_ERR_NO_MEMORY, "%s", _("allocate new buffer")); virReportOOMError(NULL);
return (NULL); return (NULL);
} }
ptr = buffer; ptr = buffer;
@ -1190,7 +1190,7 @@ xenDaemonParseSxprOS(virConnectPtr xend,
return 0; return 0;
no_memory: no_memory:
virXendError(xend, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(xend);
return -1; return -1;
} }
@ -1403,8 +1403,7 @@ xend_parse_sexp_desc_char(virConnectPtr conn,
if (ret == -1) { if (ret == -1) {
no_memory: no_memory:
virXendError(conn, VIR_ERR_NO_MEMORY, virReportOOMError(conn);
"%s", _("no memory for char device config"));
} }
error: error:
@ -1428,7 +1427,7 @@ xenDaemonParseSxprChar(virConnectPtr conn,
virDomainChrDefPtr def; virDomainChrDefPtr def;
if (VIR_ALLOC(def) < 0) { if (VIR_ALLOC(def) < 0) {
virXendError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return NULL; return NULL;
} }
@ -1557,7 +1556,7 @@ xenDaemonParseSxprChar(virConnectPtr conn,
return def; return def;
no_memory: no_memory:
virXendError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
error: error:
virDomainChrDefFree(def); virDomainChrDefFree(def);
return NULL; return NULL;
@ -1726,7 +1725,7 @@ xenDaemonParseSxprDisks(virConnectPtr conn,
return 0; return 0;
no_memory: no_memory:
virXendError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
error: error:
virDomainDiskDefFree(disk); virDomainDiskDefFree(disk);
@ -1828,7 +1827,7 @@ xenDaemonParseSxprNets(virConnectPtr conn,
return 0; return 0;
no_memory: no_memory:
virXendError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
cleanup: cleanup:
virDomainNetDefFree(net); virDomainNetDefFree(net);
return -1; return -1;
@ -1909,7 +1908,7 @@ xenDaemonParseSxprSound(virConnectPtr conn,
return 0; return 0;
no_memory: no_memory:
virXendError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
error: error:
return -1; return -1;
} }
@ -1953,7 +1952,7 @@ xenDaemonParseSxprUSB(virConnectPtr conn,
return 0; return 0;
no_memory: no_memory:
virXendError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
return -1; return -1;
} }
@ -2036,7 +2035,7 @@ xenDaemonParseSxprGraphicsOld(virConnectPtr conn,
return 0; return 0;
no_memory: no_memory:
virXendError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
virDomainGraphicsDefFree(graphics); virDomainGraphicsDefFree(graphics);
return -1; return -1;
} }
@ -2126,7 +2125,7 @@ xenDaemonParseSxprGraphicsNew(virConnectPtr conn,
return 0; return 0;
no_memory: no_memory:
virXendError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
error: error:
virDomainGraphicsDefFree(graphics); virDomainGraphicsDefFree(graphics);
return -1; return -1;
@ -2420,7 +2419,7 @@ xenDaemonParseSxpr(virConnectPtr conn,
return def; return def;
no_memory: no_memory:
virXendError(conn, VIR_ERR_NO_MEMORY, NULL); virReportOOMError(conn);
error: error:
VIR_FREE(tty); VIR_FREE(tty);
virDomainDefFree(def); virDomainDefFree(def);
@ -2641,7 +2640,7 @@ sexpr_to_xend_topology(virConnectPtr conn,
memory_error: memory_error:
VIR_FREE(cpuNums); VIR_FREE(cpuNums);
VIR_FREE(cpuset); VIR_FREE(cpuset);
virXendError(conn, VIR_ERR_NO_MEMORY, "%s", _("allocate buffer")); virReportOOMError(conn);
return (-1); return (-1);
} }
@ -4209,7 +4208,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
} }
hostname = strdup (uriptr->server); hostname = strdup (uriptr->server);
if (!hostname) { if (!hostname) {
virXendError (conn, VIR_ERR_NO_MEMORY, "%s", _("strdup failed")); virReportOOMError (conn);
xmlFreeURI (uriptr); xmlFreeURI (uriptr);
return -1; return -1;
} }
@ -4231,7 +4230,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
n = p - uri; /* n = Length of hostname in bytes. */ n = p - uri; /* n = Length of hostname in bytes. */
hostname = strdup (uri); hostname = strdup (uri);
if (!hostname) { if (!hostname) {
virXendError (conn, VIR_ERR_NO_MEMORY, "%s", _("strdup failed")); virReportOOMError (conn);
return -1; return -1;
} }
hostname[n] = '\0'; hostname[n] = '\0';
@ -4239,7 +4238,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
else { /* "hostname" (or IP address) */ else { /* "hostname" (or IP address) */
hostname = strdup (uri); hostname = strdup (uri);
if (!hostname) { if (!hostname) {
virXendError (conn, VIR_ERR_NO_MEMORY, "%s", _("strdup failed")); virReportOOMError (conn);
return -1; return -1;
} }
} }

View File

@ -1,7 +1,7 @@
/* /*
* xml.c: XML based interfaces for the libvir library * xml.c: XML based interfaces for the libvir library
* *
* Copyright (C) 2005, 2007, 2008 Red Hat, Inc. * Copyright (C) 2005, 2007-2009 Red Hat, Inc.
* *
* See COPYING.LIB for the License of this software * See COPYING.LIB for the License of this software
* *
@ -23,6 +23,8 @@
#include "util.h" #include "util.h"
#include "memory.h" #include "memory.h"
#define VIR_FROM_THIS VIR_FROM_XML
#define virXMLError(conn, code, fmt...) \ #define virXMLError(conn, code, fmt...) \
virReportErrorHelper(conn, VIR_FROM_XML, code, __FILE__, \ virReportErrorHelper(conn, VIR_FROM_XML, code, __FILE__, \
__FUNCTION__, __LINE__, fmt) __FUNCTION__, __LINE__, fmt)
@ -68,7 +70,7 @@ virXPathString(virConnectPtr conn,
ret = strdup((char *) obj->stringval); ret = strdup((char *) obj->stringval);
xmlXPathFreeObject(obj); xmlXPathFreeObject(obj);
if (ret == NULL) { if (ret == NULL) {
virXMLError(conn, VIR_ERR_NO_MEMORY, "%s", _("strdup failed")); virReportOOMError(conn);
} }
ctxt->node = relnode; ctxt->node = relnode;
return (ret); return (ret);
@ -350,9 +352,7 @@ virXPathNodeSet(virConnectPtr conn,
ret = obj->nodesetval->nodeNr; ret = obj->nodesetval->nodeNr;
if (list != NULL && ret) { if (list != NULL && ret) {
if (VIR_ALLOC_N(*list, ret) < 0) { if (VIR_ALLOC_N(*list, ret) < 0) {
virXMLError(conn, VIR_ERR_NO_MEMORY, virReportOOMError(conn);
_("allocate string array size %lu"),
(unsigned long)ret * sizeof(**list));
ret = -1; ret = -1;
} else { } else {
memcpy(*list, obj->nodesetval->nodeTab, memcpy(*list, obj->nodesetval->nodeTab,
@ -363,4 +363,3 @@ virXPathNodeSet(virConnectPtr conn,
ctxt->node = relnode; ctxt->node = relnode;
return (ret); return (ret);
} }

View File

@ -1,7 +1,7 @@
/* /*
* xs_internal.c: access to Xen Store * xs_internal.c: access to Xen Store
* *
* Copyright (C) 2006 Red Hat, Inc. * Copyright (C) 2006, 2009 Red Hat, Inc.
* *
* See COPYING.LIB for the License of this software * See COPYING.LIB for the License of this software
* *
@ -37,6 +37,8 @@
#include "xs_internal.h" #include "xs_internal.h"
#include "xen_internal.h" #include "xen_internal.h"
#define VIR_FROM_THIS VIR_FROM_XEN
#ifndef PROXY #ifndef PROXY
static char *xenStoreDomainGetOSType(virDomainPtr domain); static char *xenStoreDomainGetOSType(virDomainPtr domain);
static void xenStoreWatchEvent(int watch, int fd, int events, void *data); static void xenStoreWatchEvent(int watch, int fd, int events, void *data);
@ -1271,8 +1273,7 @@ int xenStoreDomainIntroduced(virConnectPtr conn,
retry: retry:
new_domain_cnt = xenStoreNumOfDomains(conn); new_domain_cnt = xenStoreNumOfDomains(conn);
if( VIR_ALLOC_N(new_domids,new_domain_cnt) < 0 ) { if( VIR_ALLOC_N(new_domids,new_domain_cnt) < 0 ) {
virXenStoreError(NULL, VIR_ERR_NO_MEMORY, virReportOOMError(NULL);
"%s", _("failed to allocate domids"));
return -1; return -1;
} }
nread = xenStoreDoListDomains(priv, new_domids, new_domain_cnt); nread = xenStoreDoListDomains(priv, new_domids, new_domain_cnt);
@ -1353,8 +1354,7 @@ retry:
new_domain_cnt = xenStoreNumOfDomains(conn); new_domain_cnt = xenStoreNumOfDomains(conn);
if( VIR_ALLOC_N(new_domids,new_domain_cnt) < 0 ) { if( VIR_ALLOC_N(new_domids,new_domain_cnt) < 0 ) {
virXenStoreError(NULL, VIR_ERR_NO_MEMORY, virReportOOMError(NULL);
"%s", _("failed to allocate domids"));
return -1; return -1;
} }
nread = xenStoreDoListDomains(priv, new_domids, new_domain_cnt); nread = xenStoreDoListDomains(priv, new_domids, new_domain_cnt);