[libvirt] [PATCH 1/3] use virReportOOMError, not VIR_ERR_NO_MEMORY
by Jim Meyering
Here's the big one:
>From 099536470ae2cbe9503ed471d391e403fb2587a4 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 27 Jan 2009 12:20:06 +0100
Subject: [PATCH 1/3] 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.
---
src/conf.c | 18 +++++++------
src/datatypes.c | 28 +++++++++++----------
src/domain_conf.c | 47 +++++++++++++++++------------------
src/libvirt.c | 4 ++-
src/lxc_conf.c | 5 ++-
src/lxc_container.c | 8 +++---
src/lxc_controller.c | 2 +-
src/lxc_driver.c | 11 ++++----
src/network_conf.c | 18 +++++++-------
src/network_driver.c | 15 ++++-------
src/node_device.c | 4 ++-
src/node_device_conf.c | 8 +++---
src/openvz_conf.c | 8 ++++--
src/openvz_driver.c | 9 ++++---
src/proxy_internal.c | 6 ++--
src/qemu_conf.c | 25 +++++++------------
src/qemu_driver.c | 54 +++++++++++++++++-----------------------
src/remote_internal.c | 16 ++++++------
src/sexpr.c | 7 +++--
src/stats_linux.c | 7 +++--
src/storage_backend_iscsi.c | 17 ++++++-------
src/storage_backend_logical.c | 27 +++++++++-----------
src/storage_conf.c | 34 ++++++++++----------------
src/uml_conf.c | 16 ++++++------
src/util.c | 6 ++--
src/xen_internal.c | 20 ++++++---------
src/xend_internal.c | 35 +++++++++++++-------------
src/xml.c | 11 ++++----
src/xs_internal.c | 10 ++++----
29 files changed, 225 insertions(+), 251 deletions(-)
diff --git a/src/conf.c b/src/conf.c
index 339a150..b5bfc0c 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -25,6 +25,8 @@
#include "c-ctype.h"
#include "memory.h"
+#define VIR_FROM_THIS VIR_FROM_CONF
+
/************************************************************************
* *
* Structures and macros used by the mini parser *
@@ -161,7 +163,7 @@ virConfNew(void)
virConfPtr ret;
if (VIR_ALLOC(ret) < 0) {
- virConfError(NULL, VIR_ERR_NO_MEMORY, _("allocating configuration"));
+ virReportOOMError(NULL);
return(NULL);
}
ret->filename = NULL;
@@ -209,7 +211,7 @@ virConfAddEntry(virConfPtr conf, char *name, virConfValuePtr value, char *comm)
return(NULL);
if (VIR_ALLOC(ret) < 0) {
- virConfError(NULL, VIR_ERR_NO_MEMORY, _("allocating configuration"));
+ virReportOOMError(NULL);
return(NULL);
}
@@ -488,7 +490,7 @@ virConfParseValue(virConfParserCtxtPtr ctxt)
return(NULL);
}
if (VIR_ALLOC(ret) < 0) {
- virConfError(ctxt, VIR_ERR_NO_MEMORY, _("allocating configuration"));
+ virReportOOMError(NULL);
virConfFreeList(lst);
VIR_FREE(str);
return(NULL);
@@ -525,7 +527,7 @@ virConfParseName(virConfParserCtxtPtr ctxt)
NEXT;
ret = strndup(base, ctxt->cur - base);
if (ret == NULL) {
- virConfError(ctxt, VIR_ERR_NO_MEMORY, _("allocating configuration"));
+ virReportOOMError(NULL);
return(NULL);
}
return(ret);
@@ -552,7 +554,7 @@ virConfParseComment(virConfParserCtxtPtr ctxt)
while ((ctxt->cur < ctxt->end) && (!IS_EOL(CUR))) NEXT;
comm = strndup(base, ctxt->cur - base);
if (comm == NULL) {
- virConfError(ctxt, VIR_ERR_NO_MEMORY, _("allocating configuration"));
+ virReportOOMError(NULL);
return(-1);
}
virConfAddEntry(ctxt->conf, NULL, NULL, comm);
@@ -627,7 +629,7 @@ virConfParseStatement(virConfParserCtxtPtr ctxt)
while ((ctxt->cur < ctxt->end) && (!IS_EOL(CUR))) NEXT;
comm = strndup(base, ctxt->cur - base);
if (comm == NULL) {
- virConfError(ctxt, VIR_ERR_NO_MEMORY, _("allocating configuration"));
+ virReportOOMError(NULL);
VIR_FREE(name);
virConfFreeValue(value);
return(-1);
@@ -888,7 +890,7 @@ virConfWriteFile(const char *filename, virConfPtr conf)
}
if (virBufferError(&buf)) {
- virConfError(NULL, VIR_ERR_NO_MEMORY, _("allocate buffer"));
+ virReportOOMError(NULL);
return -1;
}
@@ -944,7 +946,7 @@ virConfWriteMem(char *memory, int *len, virConfPtr conf)
}
if (virBufferError(&buf)) {
- virConfError(NULL, VIR_ERR_NO_MEMORY, _("allocate buffer"));
+ virReportOOMError(NULL);
return -1;
}
diff --git a/src/datatypes.c b/src/datatypes.c
index d59c5b4..3b2c958 100644
--- a/src/datatypes.c
+++ b/src/datatypes.c
@@ -1,7 +1,7 @@
/*
* 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
* modify it under the terms of the GNU Lesser General Public
@@ -26,6 +26,8 @@
#include "logging.h"
#include "memory.h"
+#define VIR_FROM_THIS VIR_FROM_NONE
+
/************************************************************************
* *
* Domain and Connections allocations *
@@ -120,7 +122,7 @@ virGetConnect(void) {
virConnectPtr ret;
if (VIR_ALLOC(ret) < 0) {
- virLibConnError(NULL, VIR_ERR_NO_MEMORY, _("allocating connection"));
+ virReportOOMError(NULL);
goto failed;
}
if (virMutexInit(&ret->lock) < 0) {
@@ -262,12 +264,12 @@ virGetDomain(virConnectPtr conn, const char *name, const unsigned char *uuid) {
/* TODO check the UUID */
if (ret == NULL) {
if (VIR_ALLOC(ret) < 0) {
- virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating domain"));
+ virReportOOMError(conn);
goto error;
}
ret->name = strdup(name);
if (ret->name == NULL) {
- virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating domain"));
+ virReportOOMError(conn);
goto error;
}
ret->magic = VIR_DOMAIN_MAGIC;
@@ -398,12 +400,12 @@ virGetNetwork(virConnectPtr conn, const char *name, const unsigned char *uuid) {
/* TODO check the UUID */
if (ret == NULL) {
if (VIR_ALLOC(ret) < 0) {
- virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating network"));
+ virReportOOMError(conn);
goto error;
}
ret->name = strdup(name);
if (ret->name == NULL) {
- virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating network"));
+ virReportOOMError(conn);
goto error;
}
ret->magic = VIR_NETWORK_MAGIC;
@@ -530,12 +532,12 @@ virGetStoragePool(virConnectPtr conn, const char *name, const unsigned char *uui
/* TODO check the UUID */
if (ret == NULL) {
if (VIR_ALLOC(ret) < 0) {
- virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating storage pool"));
+ virReportOOMError(conn);
goto error;
}
ret->name = strdup(name);
if (ret->name == NULL) {
- virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating storage pool"));
+ virReportOOMError(conn);
goto error;
}
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);
if (ret == NULL) {
if (VIR_ALLOC(ret) < 0) {
- virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating storage vol"));
+ virReportOOMError(conn);
goto error;
}
ret->pool = strdup(pool);
if (ret->pool == NULL) {
- virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating storage vol"));
+ virReportOOMError(conn);
goto error;
}
ret->name = strdup(name);
if (ret->name == NULL) {
- virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating storage vol"));
+ virReportOOMError(conn);
goto error;
}
strncpy(ret->key, key, sizeof(ret->key)-1);
@@ -798,14 +800,14 @@ virGetNodeDevice(virConnectPtr conn, const char *name)
ret = (virNodeDevicePtr) virHashLookup(conn->nodeDevices, name);
if (ret == NULL) {
if (VIR_ALLOC(ret) < 0) {
- virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating node dev"));
+ virReportOOMError(conn);
goto error;
}
ret->magic = VIR_NODE_DEVICE_MAGIC;
ret->conn = conn;
ret->name = strdup(name);
if (ret->name == NULL) {
- virLibConnError(conn, VIR_ERR_NO_MEMORY, _("copying node dev name"));
+ virReportOOMError(conn);
goto error;
}
diff --git a/src/domain_conf.c b/src/domain_conf.c
index 30336d4..f696b6a 100644
--- a/src/domain_conf.c
+++ b/src/domain_conf.c
@@ -483,7 +483,7 @@ virDomainObjPtr virDomainAssignDef(virConnectPtr conn,
}
if (VIR_ALLOC(domain) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
@@ -499,7 +499,7 @@ virDomainObjPtr virDomainAssignDef(virConnectPtr conn,
domain->def = def;
if (VIR_REALLOC_N(doms->objs, doms->count + 1) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
VIR_FREE(domain);
return NULL;
}
@@ -569,7 +569,7 @@ virDomainDiskDefParseXML(virConnectPtr conn,
char *bus = NULL;
if (VIR_ALLOC(def) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
@@ -753,7 +753,7 @@ virDomainFSDefParseXML(virConnectPtr conn,
char *target = NULL;
if (VIR_ALLOC(def) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
@@ -847,7 +847,7 @@ virDomainNetDefParseXML(virConnectPtr conn,
char *model = NULL;
if (VIR_ALLOC(def) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
@@ -1087,7 +1087,7 @@ virDomainChrDefParseXML(virConnectPtr conn,
virDomainChrDefPtr def;
if (VIR_ALLOC(def) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
@@ -1300,7 +1300,7 @@ virDomainInputDefParseXML(virConnectPtr conn,
char *bus = NULL;
if (VIR_ALLOC(def) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
@@ -1385,7 +1385,7 @@ virDomainGraphicsDefParseXML(virConnectPtr conn,
char *type = NULL;
if (VIR_ALLOC(def) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
@@ -1480,7 +1480,7 @@ virDomainSoundDefParseXML(virConnectPtr conn,
virDomainSoundDefPtr def;
if (VIR_ALLOC(def) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
@@ -1714,7 +1714,7 @@ virDomainHostdevDefParseXML(virConnectPtr conn,
char *mode, *type = NULL;
if (VIR_ALLOC(def) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
def->target = NULL;
@@ -1826,7 +1826,7 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(virConnectPtr conn,
}
if (VIR_ALLOC(dev) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto error;
}
@@ -1892,8 +1892,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
virDomainDefPtr def;
if (VIR_ALLOC(def) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for xmlXPathContext"));
+ virReportOOMError(conn);
return NULL;
}
@@ -1958,7 +1957,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
char *set = tmp;
def->cpumasklen = VIR_DOMAIN_CPUMASK_LEN;
if (VIR_ALLOC_N(def->cpumask, def->cpumasklen) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto error;
}
if (virDomainCpuSetParse(conn, (const char **)&set,
@@ -2008,7 +2007,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
if (def->os.bootloader) {
def->os.type = strdup("xen");
if (!def->os.type) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto error;
}
} else {
@@ -2026,7 +2025,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
def->virtType == VIR_DOMAIN_VIRT_XEN) {
VIR_FREE(def->os.type);
if (!(def->os.type = strdup("xen"))) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto error;
}
}
@@ -2047,7 +2046,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
goto error;
}
if (!(def->os.arch = strdup(defaultArch))) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto error;
}
}
@@ -2059,7 +2058,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
def->os.arch);
if (defaultMachine != NULL) {
if (!(def->os.machine = strdup(defaultMachine))) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto error;
}
}
@@ -2310,7 +2309,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
virDomainInputDefPtr input;
if (VIR_ALLOC(input) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto error;
}
if (STREQ(def->os.type, "hvm")) {
@@ -2382,7 +2381,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
return def;
no_memory:
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
/* fallthrough */
error:
@@ -2514,7 +2513,7 @@ virDomainDefPtr virDomainDefParseNode(virConnectPtr conn,
ctxt = xmlXPathNewContext(xml);
if (ctxt == NULL) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto cleanup;
}
@@ -2611,7 +2610,7 @@ virDomainCpuSetFormat(virConnectPtr conn, char *cpuset, int maxcpu)
}
if (virBufferError(&buf)) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
@@ -3400,7 +3399,7 @@ char *virDomainDefFormat(virConnectPtr conn,
return virBufferContentAndReset(&buf);
no_memory:
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
cleanup:
tmp = virBufferContentAndReset(&buf);
VIR_FREE(tmp);
@@ -3624,7 +3623,7 @@ char *virDomainConfigFile(virConnectPtr conn,
char *ret = NULL;
if (virAsprintf(&ret, "%s/%s.xml", dir, name) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
diff --git a/src/libvirt.c b/src/libvirt.c
index 71df57d..72095dd 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -57,6 +57,8 @@
#endif
#endif
+#define VIR_FROM_THIS VIR_FROM_NONE
+
/*
* TODO:
* - use lock to protect against concurrent accesses ?
@@ -1323,7 +1325,7 @@ virConnectGetURI (virConnectPtr conn)
name = (char *)xmlSaveUri(conn->uri);
if (!name) {
- virLibConnError (conn, VIR_ERR_NO_MEMORY, __FUNCTION__);
+ virReportOOMError (conn);
goto error;
}
return name;
diff --git a/src/lxc_conf.c b/src/lxc_conf.c
index fe964c2..34c8aea 100644
--- a/src/lxc_conf.c
+++ b/src/lxc_conf.c
@@ -31,6 +31,8 @@
#include "nodeinfo.h"
#include "virterror_internal.h"
+#define VIR_FROM_THIS VIR_FROM_LXC
+
/* Functions */
virCapsPtr lxcCapsInit(void)
{
@@ -87,7 +89,6 @@ int lxcLoadDriverConfig(lxc_driver_t *driver)
return 0;
no_memory:
- lxcError(NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("while loading LXC driver config"));
+ virReportOOMError(NULL);
return -1;
}
diff --git a/src/lxc_container.c b/src/lxc_container.c
index 3bf533c..ea52eed 100644
--- a/src/lxc_container.c
+++ b/src/lxc_container.c
@@ -386,7 +386,7 @@ static int lxcContainerMountNewFS(virDomainDefPtr vmDef)
continue;
if (virAsprintf(&src, "/.oldroot/%s", vmDef->fss[i]->src) < 0) {
- lxcError(NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(NULL);
return -1;
}
@@ -432,12 +432,12 @@ static int lxcContainerUnmountOldFS(void)
if (VIR_REALLOC_N(mounts, nmounts+1) < 0) {
endmntent(procmnt);
- lxcError(NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(NULL);
return -1;
}
if (!(mounts[nmounts++] = strdup(mntent.mnt_dir))) {
endmntent(procmnt);
- lxcError(NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(NULL);
return -1;
}
}
@@ -618,7 +618,7 @@ int lxcContainerStart(virDomainDefPtr def,
/* allocate a stack for the container */
if (VIR_ALLOC_N(stack, stacksize) < 0) {
- lxcError(NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(NULL);
return -1;
}
stacktop = stack + stacksize;
diff --git a/src/lxc_controller.c b/src/lxc_controller.c
index 2ef88d9..e25fe76 100644
--- a/src/lxc_controller.c
+++ b/src/lxc_controller.c
@@ -127,7 +127,7 @@ static char*lxcMonitorPath(virDomainDefPtr def)
if (virAsprintf(&sockpath, "%s/%s.sock",
LXC_STATE_DIR, def->name) < 0)
- lxcError(NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(NULL);
return sockpath;
}
diff --git a/src/lxc_driver.c b/src/lxc_driver.c
index a702635..300b919 100644
--- a/src/lxc_driver.c
+++ b/src/lxc_driver.c
@@ -90,7 +90,7 @@ static virDrvOpenStatus lxcOpen(virConnectPtr conn,
if (conn->uri == NULL) {
conn->uri = xmlParseURI("lxc:///");
if (!conn->uri) {
- lxcError(conn, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return VIR_DRV_OPEN_ERROR;
}
} else if (conn->uri->scheme == NULL ||
@@ -231,8 +231,7 @@ static int lxcListDefinedDomains(virConnectPtr conn,
virDomainObjLock(driver->domains.objs[i]);
if (!virDomainIsActive(driver->domains.objs[i])) {
if (!(names[got++] = strdup(driver->domains.objs[i]->def->name))) {
- lxcError(conn, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for VM name string"));
+ virReportOOMError(conn);
virDomainObjUnlock(driver->domains.objs[i]);
goto cleanup;
}
@@ -613,7 +612,7 @@ static int lxcMonitorClient(virConnectPtr conn,
if (virAsprintf(&sockpath, "%s/%s.sock",
driver->stateDir, vm->def->name) < 0) {
- lxcError(conn, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return -1;
}
@@ -816,7 +815,7 @@ cleanup:
return ret;
no_memory:
- lxcError(conn, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto cleanup;
}
@@ -853,7 +852,7 @@ static int lxcVmStart(virConnectPtr conn,
if (virAsprintf(&logfile, "%s/%s.log",
driver->logDir, vm->def->name) < 0) {
- lxcError(conn, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return -1;
}
diff --git a/src/network_conf.c b/src/network_conf.c
index 4186629..e19f0fe 100644
--- a/src/network_conf.c
+++ b/src/network_conf.c
@@ -161,7 +161,7 @@ virNetworkObjPtr virNetworkAssignDef(virConnectPtr conn,
}
if (VIR_ALLOC(network) < 0) {
- virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
if (virMutexInit(&network->lock) < 0) {
@@ -174,7 +174,7 @@ virNetworkObjPtr virNetworkAssignDef(virConnectPtr conn,
network->def = def;
if (VIR_REALLOC_N(nets->objs, nets->count + 1) < 0) {
- virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
VIR_FREE(network);
return NULL;
}
@@ -240,7 +240,7 @@ virNetworkDHCPRangeDefParseXML(virConnectPtr conn,
if (VIR_REALLOC_N(def->ranges, def->nranges + 1) < 0) {
xmlFree(start);
xmlFree(end);
- virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return -1;
}
def->ranges[def->nranges].start = (char *)start;
@@ -291,7 +291,7 @@ virNetworkDHCPRangeDefParseXML(virConnectPtr conn,
VIR_FREE(ip);
VIR_FREE(mac);
VIR_FREE(name);
- virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return -1;
}
def->hosts[def->nhosts].mac = (char *)mac;
@@ -314,7 +314,7 @@ virNetworkDefParseXML(virConnectPtr conn,
char *tmp;
if (VIR_ALLOC(def) < 0) {
- virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
@@ -382,7 +382,7 @@ virNetworkDefParseXML(virConnectPtr conn,
netaddr = inet_ntoa(inaddress);
if (virAsprintf(&def->network, "%s/%s", netaddr, def->netmask) < 0) {
- virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto error;
}
@@ -544,7 +544,7 @@ virNetworkDefPtr virNetworkDefParseNode(virConnectPtr conn,
ctxt = xmlXPathNewContext(xml);
if (ctxt == NULL) {
- virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto cleanup;
}
@@ -632,7 +632,7 @@ char *virNetworkDefFormat(virConnectPtr conn,
return virBufferContentAndReset(&buf);
no_memory:
- virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
tmp = virBufferContentAndReset(&buf);
VIR_FREE(tmp);
return NULL;
@@ -840,7 +840,7 @@ char *virNetworkConfigFile(virConnectPtr conn,
char *ret = NULL;
if (virAsprintf(&ret, "%s/%s.xml", dir, name) < 0) {
- virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
diff --git a/src/network_driver.c b/src/network_driver.c
index c546a2b..dcc6ad9 100644
--- a/src/network_driver.c
+++ b/src/network_driver.c
@@ -252,8 +252,7 @@ networkStartup(void) {
}
if (!(driverState->iptables = iptablesContextNew())) {
- networkReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for IP tables support"));
+ virReportOOMError(NULL);
goto error;
}
@@ -502,8 +501,7 @@ networkBuildDnsmasqArgv(virConnectPtr conn,
VIR_FREE((*argv)[i]);
VIR_FREE(*argv);
}
- networkReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for dnsmasq argv"));
+ virReportOOMError(conn);
return -1;
}
@@ -1062,8 +1060,7 @@ static int networkListNetworks(virConnectPtr conn, char **const names, int nname
if (virNetworkIsActive(driver->networks.objs[i])) {
if (!(names[got] = strdup(driver->networks.objs[i]->def->name))) {
virNetworkObjUnlock(driver->networks.objs[i]);
- networkReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for VM name string"));
+ virReportOOMError(conn);
goto cleanup;
}
got++;
@@ -1107,8 +1104,7 @@ static int networkListDefinedNetworks(virConnectPtr conn, char **const names, in
if (!virNetworkIsActive(driver->networks.objs[i])) {
if (!(names[got] = strdup(driver->networks.objs[i]->def->name))) {
virNetworkObjUnlock(driver->networks.objs[i]);
- networkReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for VM name string"));
+ virReportOOMError(conn);
goto cleanup;
}
got++;
@@ -1331,8 +1327,7 @@ static char *networkGetBridgeName(virNetworkPtr net) {
bridge = strdup(network->def->bridge);
if (!bridge)
- networkReportError(net->conn, NULL, net, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for network bridge string"));
+ virReportOOMError(net->conn);
cleanup:
if (network)
diff --git a/src/node_device.c b/src/node_device.c
index 9586fa6..1b7be60 100644
--- a/src/node_device.c
+++ b/src/node_device.c
@@ -33,6 +33,8 @@
#include "node_device_conf.h"
#include "node_device.h"
+#define VIR_FROM_THIS VIR_FROM_NODEDEV
+
static int dev_has_cap(const virNodeDeviceObjPtr dev, const char *cap)
{
virNodeDevCapsDefPtr caps = dev->def->caps;
@@ -176,7 +178,7 @@ static char *nodeDeviceGetParent(virNodeDevicePtr dev)
ret = strdup(obj->def->parent);
if (!ret)
- virNodeDeviceReportError(dev->conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(dev->conn);
cleanup:
if (obj)
diff --git a/src/node_device_conf.c b/src/node_device_conf.c
index ff022b7..af2f9a3 100644
--- a/src/node_device_conf.c
+++ b/src/node_device_conf.c
@@ -36,6 +36,7 @@
#include "buf.h"
#include "uuid.h"
+#define VIR_FROM_THIS VIR_FROM_NODEDEV
VIR_ENUM_IMPL(virNodeDevCap, VIR_NODE_DEV_CAP_LAST,
"system",
@@ -126,7 +127,7 @@ virNodeDeviceObjPtr virNodeDeviceAssignDef(virConnectPtr conn,
}
if (VIR_ALLOC(device) < 0) {
- virNodeDeviceReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
@@ -143,7 +144,7 @@ virNodeDeviceObjPtr virNodeDeviceAssignDef(virConnectPtr conn,
device->def = NULL;
virNodeDeviceObjUnlock(device);
virNodeDeviceObjFree(device);
- virNodeDeviceReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
devs->objs[devs->count++] = device;
@@ -360,7 +361,7 @@ char *virNodeDeviceDefFormat(virConnectPtr conn,
return virBufferContentAndReset(&buf);
no_memory:
- virNodeDeviceReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
tmp = virBufferContentAndReset(&buf);
VIR_FREE(tmp);
return NULL;
@@ -425,4 +426,3 @@ void virNodeDeviceObjUnlock(virNodeDeviceObjPtr obj)
{
virMutexUnlock(&obj->lock);
}
-
diff --git a/src/openvz_conf.c b/src/openvz_conf.c
index 54474b7..ff3d607 100644
--- a/src/openvz_conf.c
+++ b/src/openvz_conf.c
@@ -51,6 +51,8 @@
#include "util.h"
#include "nodeinfo.h"
+#define VIR_FROM_THIS VIR_FROM_OPENVZ
+
static char *openvzLocateConfDir(void);
static int openvzGetVPSUUID(int vpsid, char *uuidstr);
static int openvzLocateConfFile(int vpsid, char *conffile, int maxlen, const char *ext);
@@ -305,7 +307,7 @@ openvzReadNetworkConf(virConnectPtr conn,
return 0;
no_memory:
- openvzError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
error:
virDomainNetDefFree(net);
return -1;
@@ -346,7 +348,7 @@ openvzReadFSConf(virConnectPtr conn,
return 0;
no_memory:
- openvzError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
error:
virDomainFSDefFree(fs);
return -1;
@@ -461,7 +463,7 @@ int openvzLoadDomains(struct openvz_driver *driver) {
return 0;
no_memory:
- openvzError(NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(NULL);
cleanup:
fclose(fp);
diff --git a/src/openvz_driver.c b/src/openvz_driver.c
index d22ea39..e004819 100644
--- a/src/openvz_driver.c
+++ b/src/openvz_driver.c
@@ -58,6 +58,8 @@
#include "memory.h"
#include "bridge.h"
+#define VIR_FROM_THIS VIR_FROM_OPENVZ
+
#define OPENVZ_MAX_ARG 28
#define CMDBUF_LEN 1488
#define CMDOP_LEN 288
@@ -213,7 +215,7 @@ static char *openvzGetOSType(virDomainPtr dom)
}
if (!(ret = strdup(vm->def->os.type)))
- openvzError(dom->conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(dom->conn);
cleanup:
if (vm)
@@ -1056,7 +1058,7 @@ static virDrvOpenStatus openvzOpen(virConnectPtr conn,
}
if (VIR_ALLOC(driver) < 0) {
- openvzError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return VIR_DRV_OPEN_ERROR;
}
@@ -1194,7 +1196,7 @@ static int openvzListDefinedDomains(virConnectPtr conn,
return got;
no_memory:
- openvzError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
for ( ; got >= 0 ; got--)
VIR_FREE(names[got]);
return -1;
@@ -1329,4 +1331,3 @@ int openvzRegister(void) {
virRegisterDriver(&openvzDriver);
return 0;
}
-
diff --git a/src/proxy_internal.c b/src/proxy_internal.c
index d1255ae..6a34e7e 100644
--- a/src/proxy_internal.c
+++ b/src/proxy_internal.c
@@ -948,7 +948,7 @@ xenProxyGetCapabilities (virConnectPtr conn)
xmllen = ans.len - sizeof (virProxyPacket);
if (VIR_ALLOC_N(xml, xmllen+1) < 0) {
- virProxyError (conn, VIR_ERR_NO_MEMORY, __FUNCTION__);
+ virReportOOMError (conn);
return NULL;
}
memmove (xml, ans.extra.str, xmllen);
@@ -998,7 +998,7 @@ xenProxyDomainDumpXML(virDomainPtr domain, int flags ATTRIBUTE_UNUSED)
}
xmllen = ans.len - sizeof(virProxyPacket);
if (VIR_ALLOC_N(xml, xmllen+1) < 0) {
- virProxyError(domain->conn, VIR_ERR_NO_MEMORY, __FUNCTION__);
+ virReportOOMError(domain->conn);
return NULL;
}
memmove(xml, &ans.extra.dinfo, xmllen);
@@ -1050,7 +1050,7 @@ xenProxyDomainGetOSType(virDomainPtr domain)
}
oslen = ans.len - sizeof(virProxyPacket);
if (VIR_ALLOC_N(ostype, oslen+1) < 0) {
- virProxyError(domain->conn, VIR_ERR_NO_MEMORY, __FUNCTION__);
+ virReportOOMError(domain->conn);
return NULL;
}
memmove(ostype, &ans.extra.dinfo, oslen);
diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index bd5d414..ce9278e 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -70,13 +70,11 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
/* Setup 2 critical defaults */
if (!(driver->vncListen = strdup("127.0.0.1"))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate vncListen"));
+ virReportOOMError(NULL);
return -1;
}
if (!(driver->vncTLSx509certdir = strdup(SYSCONF_DIR "/pki/libvirt-vnc"))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate vncTLSx509certdir"));
+ virReportOOMError(NULL);
return -1;
}
@@ -110,8 +108,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
if (p && p->str) {
VIR_FREE(driver->vncTLSx509certdir);
if (!(driver->vncTLSx509certdir = strdup(p->str))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate vncTLSx509certdir"));
+ virReportOOMError(NULL);
virConfFree(conf);
return -1;
}
@@ -122,8 +119,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
if (p && p->str) {
VIR_FREE(driver->vncListen);
if (!(driver->vncListen = strdup(p->str))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate vnc_listen"));
+ virReportOOMError(NULL);
virConfFree(conf);
return -1;
}
@@ -512,7 +508,7 @@ qemudNetworkIfaceConnect(virConnectPtr conn,
strchr(net->ifname, '%')) {
VIR_FREE(net->ifname);
if (!(net->ifname = strdup("vnet%d"))) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto error;
}
}
@@ -555,8 +551,7 @@ qemudNetworkIfaceConnect(virConnectPtr conn,
return retval;
no_memory:
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for tapfds string"));
+ virReportOOMError(conn);
error:
VIR_FREE(retval);
if (tapfd != -1)
@@ -1296,8 +1291,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
return 0;
no_memory:
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for argv string"));
+ virReportOOMError(conn);
error:
if (tapfds &&
*tapfds) {
@@ -1371,8 +1365,7 @@ qemudDomainStatusParseFile(virConnectPtr conn,
qemudDomainStatusPtr status = NULL;
if (VIR_ALLOC(status) < 0) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for vm status"));
+ virReportOOMError(conn);
goto error;
}
@@ -1402,7 +1395,7 @@ qemudDomainStatusParseFile(virConnectPtr conn,
ctxt = xmlXPathNewContext(xml);
if (ctxt == NULL) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto error;
}
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 3d9a0a2..aae29a9 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -1,7 +1,7 @@
/*
* 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
*
* This library is free software; you can redistribute it and/or
@@ -275,8 +275,7 @@ qemudRemoveDomainStatus(virConnectPtr conn,
char *file = NULL;
if (virAsprintf(&file, "%s/%s.xml", driver->stateDir, vm->def->name) < 0) {
- qemudReportError(conn, vm, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for status file"));
+ virReportOOMError(conn);
goto cleanup;
}
@@ -728,8 +727,7 @@ static int qemudOpenMonitor(virConnectPtr conn,
goto error;
if (!(vm->monitorpath = strdup(monitor))) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for monitor path"));
+ virReportOOMError(conn);
goto error;
}
@@ -770,8 +768,7 @@ static int qemudExtractMonitorPath(virConnectPtr conn,
while (*tmp) {
if (c_isspace(*tmp)) {
if (VIR_ALLOC_N(*path, (tmp-dev)+1) < 0) {
- qemudReportError(conn, NULL, NULL,
- VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return -1;
}
strncpy(*path, dev, (tmp-dev));
@@ -876,8 +873,7 @@ qemudDetectVcpuPIDs(virConnectPtr conn,
vm->nvcpupids = vm->def->vcpus;
if (VIR_ALLOC_N(vm->vcpupids, vm->nvcpupids) < 0) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("allocate cpumap"));
+ virReportOOMError(conn);
return -1;
}
@@ -1434,7 +1430,7 @@ static virDrvOpenStatus qemudOpen(virConnectPtr conn,
if (conn->uri == NULL) {
conn->uri = xmlParseURI(uid ? "qemu:///session" : "qemu:///system");
if (!conn->uri) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,NULL);
+ virReportOOMError(conn);
return VIR_DRV_OPEN_ERROR;
}
} else if (conn->uri->scheme == NULL ||
@@ -1537,8 +1533,7 @@ static char *qemudGetCapabilities(virConnectPtr conn) {
qemuDriverLock(driver);
if ((xml = virCapabilitiesFormatXML(driver->caps)) == NULL)
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for capabilities support"));
+ virReportOOMError(conn);
qemuDriverUnlock(driver);
return xml;
@@ -2020,8 +2015,7 @@ static char *qemudDomainGetOSType(virDomainPtr dom) {
}
if (!(type = strdup(vm->def->os.type)))
- qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for ostype"));
+ virReportOOMError(dom->conn);
cleanup:
if (vm)
@@ -2785,8 +2779,7 @@ static int qemudListDefinedDomains(virConnectPtr conn,
virDomainObjLock(driver->domains.objs[i]);
if (!virDomainIsActive(driver->domains.objs[i])) {
if (!(names[got++] = strdup(driver->domains.objs[i]->def->name))) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for VM name string"));
+ virReportOOMError(conn);
virDomainObjUnlock(driver->domains.objs[i]);
goto cleanup;
}
@@ -2996,7 +2989,7 @@ static char *qemudDiskDeviceName(const virConnectPtr conn,
}
if (ret == -1) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
@@ -3060,7 +3053,7 @@ static int qemudDomainChangeEjectableMedia(virConnectPtr conn,
}
if (!devname) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return -1;
}
}
@@ -3068,12 +3061,12 @@ static int qemudDomainChangeEjectableMedia(virConnectPtr conn,
if (newdisk->src) {
safe_path = qemudEscapeMonitorArg(newdisk->src);
if (!safe_path) {
- qemudReportError(conn, dom, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
VIR_FREE(devname);
return -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(devname);
return -1;
@@ -3081,7 +3074,7 @@ static int qemudDomainChangeEjectableMedia(virConnectPtr conn,
VIR_FREE(safe_path);
} else if (virAsprintf(&cmd, "eject %s", devname) == -1) {
- qemudReportError(conn, dom, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
VIR_FREE(devname);
return -1;
}
@@ -3133,7 +3126,7 @@ static int qemudDomainAttachPciDiskDevice(virConnectPtr conn,
}
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;
}
@@ -3148,7 +3141,7 @@ static int qemudDomainAttachPciDiskDevice(virConnectPtr conn,
safe_path, type);
VIR_FREE(safe_path);
if (ret == -1) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return ret;
}
@@ -3203,7 +3196,7 @@ static int qemudDomainAttachUsbMassstorageDevice(virConnectPtr conn,
}
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;
}
@@ -3217,7 +3210,7 @@ static int qemudDomainAttachUsbMassstorageDevice(virConnectPtr conn,
ret = virAsprintf(&cmd, "usb_add disk:%s", safe_path);
VIR_FREE(safe_path);
if (ret == -1) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return ret;
}
@@ -3257,7 +3250,7 @@ static int qemudDomainAttachHostDevice(virConnectPtr conn,
char *cmd, *reply;
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;
}
@@ -3271,7 +3264,7 @@ static int qemudDomainAttachHostDevice(virConnectPtr conn,
dev->data.hostdev->source.subsys.u.usb.device);
}
if (ret == -1) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return -1;
}
@@ -3398,7 +3391,7 @@ static int qemudDomainDetachPciDiskDevice(virConnectPtr conn,
}
if (virAsprintf(&cmd, "pci_del 0 %d", detach->slotnum) < 0) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto cleanup;
}
@@ -3421,7 +3414,7 @@ static int qemudDomainDetachPciDiskDevice(virConnectPtr conn,
if (vm->def->ndisks > 1) {
vm->def->disks[i] = vm->def->disks[--vm->def->ndisks];
if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks) < 0) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto cleanup;
}
qsort(vm->def->disks, vm->def->ndisks, sizeof(*vm->def->disks),
@@ -4071,8 +4064,7 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn,
/* Caller frees */
if (virAsprintf(uri_out, "tcp:%s:%d", hostname, this_port) < 0) {
- qemudReportError (dconn, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", strerror (errno));
+ virReportOOMError (dconn);
goto cleanup;
}
} else {
diff --git a/src/remote_internal.c b/src/remote_internal.c
index 93b27af..8ed52bc 100644
--- a/src/remote_internal.c
+++ b/src/remote_internal.c
@@ -507,7 +507,7 @@ doRemoteOpen (virConnectPtr conn,
}
if (!name) {
- error(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto failed;
}
@@ -803,7 +803,7 @@ doRemoteOpen (virConnectPtr conn,
conn->uri = xmlParseURI(uriret.uri);
VIR_FREE(uriret.uri);
if (!conn->uri) {
- error (conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError (conn);
goto failed;
}
}
@@ -862,7 +862,7 @@ doRemoteOpen (virConnectPtr conn,
return retcode;
out_of_memory:
- error (conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError (conn);
failed:
/* Close the socket if we failed. */
@@ -904,7 +904,7 @@ remoteOpen (virConnectPtr conn,
return VIR_DRV_OPEN_DECLINED;
if (VIR_ALLOC(priv) < 0) {
- error (conn, VIR_ERR_NO_MEMORY, _("struct private_data"));
+ virReportOOMError (conn);
return VIR_DRV_OPEN_ERROR;
}
@@ -2837,7 +2837,7 @@ remoteDomainSetSchedulerParameters (virDomainPtr domain,
// call() will free this:
args.params.params_val[i].field = strdup (params[i].field);
if (args.params.params_val[i].field == NULL) {
- error (domain->conn, VIR_ERR_NO_MEMORY, _("out of memory"));
+ virReportOOMError (domain->conn);
do_error = 1;
}
args.params.params_val[i].value.type = params[i].type;
@@ -3087,7 +3087,7 @@ remoteNetworkOpen (virConnectPtr conn,
struct private_data *priv;
int ret, rflags = 0;
if (VIR_ALLOC(priv) < 0) {
- error (conn, VIR_ERR_NO_MEMORY, _("struct private_data"));
+ virReportOOMError (conn);
return VIR_DRV_OPEN_ERROR;
}
if (virMutexInit(&priv->lock) < 0) {
@@ -3600,7 +3600,7 @@ remoteStorageOpen (virConnectPtr conn,
struct private_data *priv;
int ret, rflags = 0;
if (VIR_ALLOC(priv) < 0) {
- error (NULL, VIR_ERR_NO_MEMORY, _("struct private_data"));
+ virReportOOMError (NULL);
return VIR_DRV_OPEN_ERROR;
}
if (virMutexInit(&priv->lock) < 0) {
@@ -4553,7 +4553,7 @@ remoteDevMonOpen(virConnectPtr conn,
struct private_data *priv;
int ret, rflags = 0;
if (VIR_ALLOC(priv) < 0) {
- error (NULL, VIR_ERR_NO_MEMORY, _("struct private_data"));
+ virReportOOMError (NULL);
return VIR_DRV_OPEN_ERROR;
}
if (virMutexInit(&priv->lock) < 0) {
diff --git a/src/sexpr.c b/src/sexpr.c
index d97bf77..7450c79 100644
--- a/src/sexpr.c
+++ b/src/sexpr.c
@@ -23,6 +23,8 @@
#include "util.h"
#include "memory.h"
+#define VIR_FROM_THIS VIR_FROM_SEXPR
+
#define virSexprError(code, fmt...) \
virReportErrorHelper(NULL, VIR_FROM_SEXPR, code, __FILE__, \
__FUNCTION__, __LINE__, fmt)
@@ -40,7 +42,7 @@ sexpr_new(void)
struct sexpr *ret;
if (VIR_ALLOC(ret) < 0) {
- virSexprError(VIR_ERR_NO_MEMORY, "%s", _("failed to allocate a node"));
+ virReportOOMError(NULL);
return (NULL);
}
ret->kind = SEXPR_NIL;
@@ -343,8 +345,7 @@ _string2sexpr(const char *buffer, size_t * end)
ret->u.value = strndup(start, ptr - start);
if (ret->u.value == NULL) {
- virSexprError(VIR_ERR_NO_MEMORY,
- "%s", _("failed to copy a string"));
+ virReportOOMError(NULL);
goto error;
}
diff --git a/src/stats_linux.c b/src/stats_linux.c
index b58457d..eccda94 100644
--- a/src/stats_linux.c
+++ b/src/stats_linux.c
@@ -1,7 +1,7 @@
/*
* 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
*
@@ -31,6 +31,8 @@
#include "stats_linux.h"
#include "memory.h"
+#define VIR_FROM_THIS VIR_FROM_STATS_LINUX
+
/**
* statsErrorFunc:
* @conn: the connection
@@ -297,8 +299,7 @@ xenLinuxDomainDeviceID(virConnectPtr conn, int domid, const char *path)
retval = virAsprintf(&mod_path, "/dev/%s", path);
if (retval < 0) {
- statsErrorFunc (conn, VIR_ERR_NO_MEMORY, __FUNCTION__,
- "allocating mod_path", domid);
+ virReportOOMError (conn);
return -1;
}
diff --git a/src/storage_backend_iscsi.c b/src/storage_backend_iscsi.c
index 1d909c5..bbb94a5 100644
--- a/src/storage_backend_iscsi.c
+++ b/src/storage_backend_iscsi.c
@@ -97,7 +97,7 @@ virStorageBackendISCSIExtractSession(virConnectPtr conn,
if (STREQ(groups[1], pool->def->source.devices[0].path)) {
if ((*session = strdup(groups[0])) == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("session"));
+ virReportOOMError(conn);
return -1;
}
}
@@ -179,19 +179,19 @@ virStorageBackendISCSINewLun(virConnectPtr conn, virStoragePoolObjPtr pool,
int opentries = 0;
if (VIR_ALLOC(vol) < 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("volume"));
+ virReportOOMError(conn);
goto cleanup;
}
vol->type = VIR_STORAGE_VOL_BLOCK;
if (virAsprintf(&(vol->name), "lun-%d", lun) < 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("name"));
+ virReportOOMError(conn);
goto cleanup;
}
if (virAsprintf(&devpath, "/dev/%s", dev) < 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("devpath"));
+ virReportOOMError(conn);
goto cleanup;
}
@@ -234,7 +234,7 @@ virStorageBackendISCSINewLun(virConnectPtr conn, virStoragePoolObjPtr pool,
/* XXX use unique iSCSI id instead */
vol->key = strdup(vol->target.path);
if (vol->key == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("key"));
+ virReportOOMError(conn);
goto cleanup;
}
@@ -244,7 +244,7 @@ virStorageBackendISCSINewLun(virConnectPtr conn, virStoragePoolObjPtr pool,
if (VIR_REALLOC_N(pool->volumes.objs,
pool->volumes.count+1) < 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto cleanup;
}
pool->volumes.objs[pool->volumes.count++] = vol;
@@ -477,8 +477,7 @@ virStorageBackendISCSIFindLUNs(virConnectPtr conn,
scsidev = strdup(block2);
}
if (scsidev == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s",
- _("Failed allocating memory for scsidev"));
+ virReportOOMError(conn);
retval = -1;
goto namelist_cleanup;
}
@@ -559,7 +558,7 @@ virStorageBackendISCSIPortal(virConnectPtr conn,
return NULL;
if (VIR_ALLOC_N(portal, strlen(ipaddr) + 1 + 4 + 2 + 1) < 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("portal"));
+ virReportOOMError(conn);
return NULL;
}
diff --git a/src/storage_backend_logical.c b/src/storage_backend_logical.c
index 474c3d8..461c110 100644
--- a/src/storage_backend_logical.c
+++ b/src/storage_backend_logical.c
@@ -84,21 +84,21 @@ virStorageBackendLogicalMakeVol(virConnectPtr conn,
/* Or a completely new volume */
if (vol == NULL) {
if (VIR_ALLOC(vol) < 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("volume"));
+ virReportOOMError(conn);
return -1;
}
vol->type = VIR_STORAGE_VOL_BLOCK;
if ((vol->name = strdup(groups[0])) == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("volume"));
+ virReportOOMError(conn);
virStorageVolDefFree(vol);
return -1;
}
if (VIR_REALLOC_N(pool->volumes.objs,
pool->volumes.count + 1)) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
virStorageVolDefFree(vol);
return -1;
}
@@ -108,7 +108,7 @@ virStorageBackendLogicalMakeVol(virConnectPtr conn,
if (vol->target.path == NULL) {
if (VIR_ALLOC_N(vol->target.path, strlen(pool->def->target.path) +
1 + strlen(vol->name) + 1) < 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("volume"));
+ virReportOOMError(conn);
return -1;
}
strcpy(vol->target.path, pool->def->target.path);
@@ -118,7 +118,7 @@ virStorageBackendLogicalMakeVol(virConnectPtr conn,
if (vol->key == NULL &&
(vol->key = strdup(groups[1])) == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("volume"));
+ virReportOOMError(conn);
return -1;
}
@@ -129,13 +129,13 @@ virStorageBackendLogicalMakeVol(virConnectPtr conn,
/* Finally fill in extents information */
if (VIR_REALLOC_N(vol->source.extents,
vol->source.nextent + 1) < 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("extents"));
+ virReportOOMError(conn);
return -1;
}
if ((vol->source.extents[vol->source.nextent].path =
strdup(groups[2])) == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("extents"));
+ virReportOOMError(conn);
return -1;
}
@@ -256,8 +256,7 @@ virStorageBackendLogicalFindPoolSourcesFunc(virConnectPtr conn,
vgname = strdup(groups[1]);
if (pvname == NULL || vgname == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s",
- _("allocating pvname or vgname"));
+ virReportOOMError(conn);
goto err_no_memory;
}
@@ -271,8 +270,7 @@ virStorageBackendLogicalFindPoolSourcesFunc(virConnectPtr conn,
if (thisSource == NULL) {
if (VIR_REALLOC_N(sourceList->sources, sourceList->nsources + 1) != 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s",
- _("allocating new source"));
+ virReportOOMError(conn);
goto err_no_memory;
}
@@ -286,8 +284,7 @@ virStorageBackendLogicalFindPoolSourcesFunc(virConnectPtr conn,
VIR_FREE(vgname);
if (VIR_REALLOC_N(thisSource->devices, thisSource->ndevice + 1) != 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s",
- _("allocating new device"));
+ virReportOOMError(conn);
goto err_no_memory;
}
@@ -386,7 +383,7 @@ virStorageBackendLogicalBuildPool(virConnectPtr conn,
memset(zeros, 0, sizeof(zeros));
if (VIR_ALLOC_N(vgargv, 3 + pool->def->source.ndevice) < 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("command line"));
+ virReportOOMError(conn);
return -1;
}
@@ -581,7 +578,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn,
}
if (VIR_ALLOC_N(vol->target.path, strlen(pool->def->target.path) +
1 + strlen(vol->name) + 1) < 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("volume"));
+ virReportOOMError(conn);
return -1;
}
strcpy(vol->target.path, pool->def->target.path);
diff --git a/src/storage_conf.c b/src/storage_conf.c
index 9d3f5a7..a2b7fab 100644
--- a/src/storage_conf.c
+++ b/src/storage_conf.c
@@ -426,8 +426,7 @@ virStoragePoolDefParseDoc(virConnectPtr conn,
char *authType = NULL;
if (VIR_ALLOC(ret) < 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- "%s", _("cannot allocate storage pool"));
+ virReportOOMError(conn);
return NULL;
}
@@ -511,7 +510,7 @@ virStoragePoolDefParseDoc(virConnectPtr conn,
}
if (VIR_ALLOC_N(ret->source.devices, nsource) < 0) {
VIR_FREE(nodeset);
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("device"));
+ virReportOOMError(conn);
goto cleanup;
}
for (i = 0 ; i < nsource ; i++) {
@@ -541,8 +540,7 @@ virStoragePoolDefParseDoc(virConnectPtr conn,
/* source name defaults to pool name */
ret->source.name = strdup(ret->name);
if (ret->source.name == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s",
- _("pool name"));
+ virReportOOMError(conn);
goto cleanup;
}
}
@@ -640,8 +638,7 @@ virStoragePoolDefParse(virConnectPtr conn,
ctxt = xmlXPathNewContext(xml);
if (ctxt == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- "%s", _("xmlXPathContext"));
+ virReportOOMError(conn);
goto cleanup;
}
@@ -791,7 +788,7 @@ virStoragePoolDefFormat(virConnectPtr conn,
return virBufferContentAndReset(&buf);
no_memory:
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("xml"));
+ virReportOOMError(conn);
cleanup:
free(virBufferContentAndReset(&buf));
return NULL;
@@ -934,8 +931,7 @@ virStorageVolDefParseDoc(virConnectPtr conn,
return NULL;
if (VIR_ALLOC(ret) < 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- "%s", _("cannot allocate storage vol"));
+ virReportOOMError(conn);
return NULL;
}
@@ -1041,8 +1037,7 @@ virStorageVolDefParse(virConnectPtr conn,
ctxt = xmlXPathNewContext(xml);
if (ctxt == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- "%s", _("xmlXPathContext"));
+ virReportOOMError(conn);
goto cleanup;
}
@@ -1155,7 +1150,7 @@ virStorageVolDefFormat(virConnectPtr conn,
return virBufferContentAndReset(&buf);
no_memory:
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("xml"));
+ virReportOOMError(conn);
cleanup:
tmp = virBufferContentAndReset(&buf);
VIR_FREE(tmp);
@@ -1259,8 +1254,7 @@ virStoragePoolObjAssignDef(virConnectPtr conn,
}
if (VIR_ALLOC(pool) < 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- "%s", _("pool"));
+ virReportOOMError(conn);
return NULL;
}
@@ -1278,7 +1272,7 @@ virStoragePoolObjAssignDef(virConnectPtr conn,
pool->def = NULL;
virStoragePoolObjUnlock(pool);
virStoragePoolObjFree(pool);
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
pools->objs[pools->count++] = pool;
@@ -1420,8 +1414,7 @@ virStoragePoolObjSaveDef(virConnectPtr conn,
return -1;
}
if (!(pool->configFile = strdup(path))) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- "%s", _("configFile"));
+ virReportOOMError(conn);
return -1;
}
@@ -1434,8 +1427,7 @@ virStoragePoolObjSaveDef(virConnectPtr conn,
return -1;
}
if (!(pool->autostartLink = strdup(path))) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- "%s", _("config file"));
+ virReportOOMError(conn);
VIR_FREE(pool->configFile);
return -1;
}
@@ -1534,7 +1526,7 @@ char *virStoragePoolSourceListFormat(virConnectPtr conn,
return virBufferContentAndReset(&buf);
no_memory:
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
cleanup:
free(virBufferContentAndReset(&buf));
return NULL;
diff --git a/src/uml_conf.c b/src/uml_conf.c
index f2bf09f..c0d086e 100644
--- a/src/uml_conf.c
+++ b/src/uml_conf.c
@@ -1,7 +1,7 @@
/*
* 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
*
* This library is free software; you can redistribute it and/or
@@ -45,6 +45,7 @@
#include "nodeinfo.h"
#include "verify.h"
+#define VIR_FROM_THIS VIR_FROM_UML
#define umlLog(level, msg, ...) \
virLogMessage(__FILE__, level, 0, msg, __VA_ARGS__)
@@ -100,14 +101,14 @@ umlBuildCommandLineChr(virConnectPtr conn,
switch (def->type) {
case VIR_DOMAIN_CHR_TYPE_NULL:
if (virAsprintf(&ret, "%s%d=null", dev, def->dstPort) < 0) {
- umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
break;
case VIR_DOMAIN_CHR_TYPE_PTY:
if (virAsprintf(&ret, "%s%d=pts", dev, def->dstPort) < 0) {
- umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
break;
@@ -115,14 +116,14 @@ umlBuildCommandLineChr(virConnectPtr conn,
case VIR_DOMAIN_CHR_TYPE_DEV:
if (virAsprintf(&ret, "%s%d=tty:%s", dev, def->dstPort,
def->data.file.path) < 0) {
- umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
break;
case VIR_DOMAIN_CHR_TYPE_STDIO:
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;
}
break;
@@ -136,7 +137,7 @@ umlBuildCommandLineChr(virConnectPtr conn,
if (virAsprintf(&ret, "%s%d=port:%s", dev, def->dstPort,
def->data.tcp.service) < 0) {
- umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
break;
@@ -308,8 +309,7 @@ int umlBuildCommandLine(virConnectPtr conn,
return 0;
no_memory:
- umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for argv string"));
+ virReportOOMError(conn);
error:
if (tapfds &&
*tapfds) {
diff --git a/src/util.c b/src/util.c
index b513559..e049999 100644
--- a/src/util.c
+++ b/src/util.c
@@ -458,7 +458,7 @@ virExec(virConnectPtr conn,
char *argv_str;
if ((argv_str = virArgvToString(argv)) == NULL) {
- ReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("command debug string"));
+ virReportOOMError(conn);
return -1;
}
DEBUG0(argv_str);
@@ -526,7 +526,7 @@ virPipeReadUntilEOF(virConnectPtr conn, int outfd, int errfd,
buf = ((fds[i].fd == outfd) ? outbuf : errbuf);
size = (*buf ? strlen(*buf) : 0);
if (VIR_REALLOC_N(*buf, size+got+1) < 0) {
- ReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto error;
}
memmove(*buf+size, data, got);
@@ -576,7 +576,7 @@ virRun(virConnectPtr conn,
char *argv_str = NULL;
if ((argv_str = virArgvToString(argv)) == NULL) {
- ReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("command debug string"));
+ virReportOOMError(conn);
goto error;
}
DEBUG0(argv_str);
diff --git a/src/xen_internal.c b/src/xen_internal.c
index 1ef835e..9a7272f 100644
--- a/src/xen_internal.c
+++ b/src/xen_internal.c
@@ -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' */
if (maplen < 8) {
if (VIR_ALLOC_N(new, sizeof(uint64_t)) < 0) {
- virXenErrorFunc(NULL, VIR_ERR_NO_MEMORY, __FUNCTION__,
- "allocating private data", 0);
+ virReportOOMError(NULL);
return (-1);
}
memcpy(new, cpumap, maplen);
@@ -1965,7 +1964,7 @@ xenHypervisorInit(void)
hypervisor_version = 2;
if (VIR_ALLOC(ipt) < 0) {
- virXenError(NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(NULL);
return(-1);
}
/* Currently consider RHEL5.0 Fedora7, xen-3.1, and xen-unstable */
@@ -2359,7 +2358,7 @@ xenHypervisorMakeCapabilitiesSunOS(virConnectPtr conn)
utsname.machine,
pae, hvm,
guest_arches, i)) == NULL)
- virXenError(NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(NULL);
return caps;
}
@@ -2520,7 +2519,7 @@ xenHypervisorMakeCapabilitiesInternal(virConnectPtr conn,
return caps;
no_memory:
- virXenError(NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(NULL);
virCapabilitiesFree(caps);
return NULL;
}
@@ -2593,7 +2592,7 @@ xenHypervisorGetCapabilities (virConnectPtr conn)
char *xml;
if (!(xml = virCapabilitiesFormatXML(priv->caps))) {
- virXenError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
@@ -2626,8 +2625,7 @@ xenHypervisorNumOfDomains(virConnectPtr conn)
retry:
if (!(XEN_GETDOMAININFOLIST_ALLOC(dominfos, maxids))) {
- virXenError(conn, VIR_ERR_NO_MEMORY, _("allocating %d domain info"),
- maxids);
+ virReportOOMError(conn);
return(-1);
}
@@ -2688,8 +2686,7 @@ xenHypervisorListDomains(virConnectPtr conn, int *ids, int maxids)
return(0);
if (!(XEN_GETDOMAININFOLIST_ALLOC(dominfos, maxids))) {
- virXenError(conn, VIR_ERR_NO_MEMORY, "allocating %d domain info",
- maxids);
+ virReportOOMError(conn);
return(-1);
}
@@ -2798,8 +2795,7 @@ xenHypervisorLookupDomainByUUID(virConnectPtr conn,
retry:
if (!(XEN_GETDOMAININFOLIST_ALLOC(dominfos, maxids))) {
- virXenError(conn, VIR_ERR_NO_MEMORY, "allocating %d domain info",
- maxids);
+ virReportOOMError(conn);
return(NULL);
}
diff --git a/src/xend_internal.c b/src/xend_internal.c
index 3bd70ad..75a4324 100644
--- a/src/xend_internal.c
+++ b/src/xend_internal.c
@@ -526,7 +526,7 @@ xend_op_ext(virConnectPtr xend, const char *path, char *error,
}
if (virBufferError(&buf)) {
- virXendError(NULL, VIR_ERR_NO_MEMORY, "%s", _("allocate buffer"));
+ virReportOOMError(NULL);
return -1;
}
@@ -706,7 +706,7 @@ urlencode(const char *string)
size_t i;
if (VIR_ALLOC_N(buffer, len * 3 + 1) < 0) {
- virXendError(NULL, VIR_ERR_NO_MEMORY, "%s", _("allocate new buffer"));
+ virReportOOMError(NULL);
return (NULL);
}
ptr = buffer;
@@ -1186,7 +1186,7 @@ xenDaemonParseSxprOS(virConnectPtr xend,
return 0;
no_memory:
- virXendError(xend, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(xend);
return -1;
}
@@ -1399,8 +1399,7 @@ xend_parse_sexp_desc_char(virConnectPtr conn,
if (ret == -1) {
no_memory:
- virXendError(conn, VIR_ERR_NO_MEMORY,
- "%s", _("no memory for char device config"));
+ virReportOOMError(conn);
}
error:
@@ -1424,7 +1423,7 @@ xenDaemonParseSxprChar(virConnectPtr conn,
virDomainChrDefPtr def;
if (VIR_ALLOC(def) < 0) {
- virXendError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
@@ -1553,7 +1552,7 @@ xenDaemonParseSxprChar(virConnectPtr conn,
return def;
no_memory:
- virXendError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
error:
virDomainChrDefFree(def);
return NULL;
@@ -1722,7 +1721,7 @@ xenDaemonParseSxprDisks(virConnectPtr conn,
return 0;
no_memory:
- virXendError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
error:
virDomainDiskDefFree(disk);
@@ -1824,7 +1823,7 @@ xenDaemonParseSxprNets(virConnectPtr conn,
return 0;
no_memory:
- virXendError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
cleanup:
virDomainNetDefFree(net);
return -1;
@@ -1905,7 +1904,7 @@ xenDaemonParseSxprSound(virConnectPtr conn,
return 0;
no_memory:
- virXendError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
error:
return -1;
}
@@ -1949,7 +1948,7 @@ xenDaemonParseSxprUSB(virConnectPtr conn,
return 0;
no_memory:
- virXendError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return -1;
}
@@ -2032,7 +2031,7 @@ xenDaemonParseSxprGraphicsOld(virConnectPtr conn,
return 0;
no_memory:
- virXendError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
virDomainGraphicsDefFree(graphics);
return -1;
}
@@ -2122,7 +2121,7 @@ xenDaemonParseSxprGraphicsNew(virConnectPtr conn,
return 0;
no_memory:
- virXendError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
error:
virDomainGraphicsDefFree(graphics);
return -1;
@@ -2416,7 +2415,7 @@ xenDaemonParseSxpr(virConnectPtr conn,
return def;
no_memory:
- virXendError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
error:
VIR_FREE(tty);
virDomainDefFree(def);
@@ -2637,7 +2636,7 @@ sexpr_to_xend_topology(virConnectPtr conn,
memory_error:
VIR_FREE(cpuNums);
VIR_FREE(cpuset);
- virXendError(conn, VIR_ERR_NO_MEMORY, "%s", _("allocate buffer"));
+ virReportOOMError(conn);
return (-1);
}
@@ -4205,7 +4204,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
}
hostname = strdup (uriptr->server);
if (!hostname) {
- virXendError (conn, VIR_ERR_NO_MEMORY, "%s", _("strdup failed"));
+ virReportOOMError (conn);
xmlFreeURI (uriptr);
return -1;
}
@@ -4227,7 +4226,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
n = p - uri; /* n = Length of hostname in bytes. */
hostname = strdup (uri);
if (!hostname) {
- virXendError (conn, VIR_ERR_NO_MEMORY, "%s", _("strdup failed"));
+ virReportOOMError (conn);
return -1;
}
hostname[n] = '\0';
@@ -4235,7 +4234,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
else { /* "hostname" (or IP address) */
hostname = strdup (uri);
if (!hostname) {
- virXendError (conn, VIR_ERR_NO_MEMORY, "%s", _("strdup failed"));
+ virReportOOMError (conn);
return -1;
}
}
diff --git a/src/xml.c b/src/xml.c
index a7ebe7c..ad77eca 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -1,7 +1,7 @@
/*
* 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
*
@@ -23,6 +23,8 @@
#include "util.h"
#include "memory.h"
+#define VIR_FROM_THIS VIR_FROM_XML
+
#define virXMLError(conn, code, fmt...) \
virReportErrorHelper(conn, VIR_FROM_XML, code, __FILE__, \
__FUNCTION__, __LINE__, fmt)
@@ -68,7 +70,7 @@ virXPathString(virConnectPtr conn,
ret = strdup((char *) obj->stringval);
xmlXPathFreeObject(obj);
if (ret == NULL) {
- virXMLError(conn, VIR_ERR_NO_MEMORY, "%s", _("strdup failed"));
+ virReportOOMError(conn);
}
ctxt->node = relnode;
return (ret);
@@ -350,9 +352,7 @@ virXPathNodeSet(virConnectPtr conn,
ret = obj->nodesetval->nodeNr;
if (list != NULL && ret) {
if (VIR_ALLOC_N(*list, ret) < 0) {
- virXMLError(conn, VIR_ERR_NO_MEMORY,
- _("allocate string array size %lu"),
- (unsigned long)ret * sizeof(**list));
+ virReportOOMError(conn);
ret = -1;
} else {
memcpy(*list, obj->nodesetval->nodeTab,
@@ -363,4 +363,3 @@ virXPathNodeSet(virConnectPtr conn,
ctxt->node = relnode;
return (ret);
}
-
diff --git a/src/xs_internal.c b/src/xs_internal.c
index dbbf7f2..c7087ed 100644
--- a/src/xs_internal.c
+++ b/src/xs_internal.c
@@ -1,7 +1,7 @@
/*
* 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
*
@@ -37,6 +37,8 @@
#include "xs_internal.h"
#include "xen_internal.h"
+#define VIR_FROM_THIS VIR_FROM_XEN
+
#ifndef PROXY
static char *xenStoreDomainGetOSType(virDomainPtr domain);
static void xenStoreWatchEvent(int watch, int fd, int events, void *data);
@@ -1271,8 +1273,7 @@ int xenStoreDomainIntroduced(virConnectPtr conn,
retry:
new_domain_cnt = xenStoreNumOfDomains(conn);
if( VIR_ALLOC_N(new_domids,new_domain_cnt) < 0 ) {
- virXenStoreError(NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate domids"));
+ virReportOOMError(NULL);
return -1;
}
nread = xenStoreDoListDomains(priv, new_domids, new_domain_cnt);
@@ -1353,8 +1354,7 @@ retry:
new_domain_cnt = xenStoreNumOfDomains(conn);
if( VIR_ALLOC_N(new_domids,new_domain_cnt) < 0 ) {
- virXenStoreError(NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate domids"));
+ virReportOOMError(NULL);
return -1;
}
nread = xenStoreDoListDomains(priv, new_domids, new_domain_cnt);
--
1.6.1.1.363.g2a3bd
16 years, 2 months
[libvirt] [PATCH] Fixes for VNC port handling
by john.levon@sun.com
# HG changeset patch
# User john.levon(a)sun.com
# Date 1233118371 28800
# Node ID f91041f0c607be72c4b5695f081d20716521f6c5
# Parent 8fce2ce6108eb1ff1865ecc21d57114db036f2a2
Fixes for VNC port handling
When parsing sexpr, the VNC port should not be ignored, even when vncunused is
set. Fix the parsing of vncdisplay, which was broken due to strtol() (never
use this function!).
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/src/xend_internal.c b/src/xend_internal.c
--- a/src/xend_internal.c
+++ b/src/xend_internal.c
@@ -612,7 +612,9 @@ sexpr_get(virConnectPtr xend, const char
*
* convenience function to lookup an int value in the S-Expression
*
- * Returns the value found or 0 if not found (but may not be an error)
+ * Returns the value found or 0 if not found (but may not be an error).
+ * This function suffers from the flaw that zero is both a correct
+ * return value and an error indicator: careful!
*/
static int
sexpr_int(const struct sexpr *sexpr, const char *name)
@@ -2091,15 +2093,16 @@ xenDaemonParseSxprGraphicsNew(virConnect
port = xenStoreDomainGetVNCPort(conn, def->id);
xenUnifiedUnlock(priv);
+ // Didn't find port entry in xenstore
if (port == -1) {
- // Didn't find port entry in xenstore
- port = sexpr_int(node, "device/vfb/vncdisplay");
+ const char *value = sexpr_node(node,
+ "device/vfb/vncdisplay");
+ if (value != NULL)
+ port = strtol(value, NULL, 0);
}
- if ((unused && STREQ(unused, "1")) || port == -1) {
+ if ((unused && STREQ(unused, "1")) || port == -1)
graphics->data.vnc.autoport = 1;
- port = -1;
- }
if (port >= 0 && port < 5900)
port += 5900;
diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-autoport.sexpr b/tests/sexpr2xmldata/sexpr2xml-fv-autoport.sexpr
new file mode 100644
--- /dev/null
+++ b/tests/sexpr2xmldata/sexpr2xml-fv-autoport.sexpr
@@ -0,0 +1,85 @@
+(domain
+ (domid 21)
+ (on_crash destroy)
+ (uuid e0c172e6-4ad8-7353-0ece-515d2f181365)
+ (bootloader_args )
+ (vcpus 1)
+ (name domu-224)
+ (on_poweroff destroy)
+ (on_reboot destroy)
+ (bootloader )
+ (maxmem 512)
+ (memory 512)
+ (shadow_memory 5)
+ (cpu_weight 256)
+ (cpu_cap 0)
+ (features )
+ (on_xend_start ignore)
+ (on_xend_stop shutdown)
+ (start_time 1233108538.42)
+ (cpu_time 907.159661051)
+ (online_vcpus 1)
+ (image
+ (hvm
+ (kernel /usr/lib/xen/boot/hvmloader)
+ (boot d)
+ (device_model /usr/lib/xen/bin/qemu-dm)
+ (keymap en-us)
+ (localtime 1)
+ (pae 1)
+ (serial pty)
+ (usb 1)
+ (usbdevice tablet)
+ (notes (SUSPEND_CANCEL 1))
+ )
+ )
+ (status 2)
+ (state r-----)
+ (store_mfn 131070)
+ (device
+ (vif
+ (bridge e1000g0)
+ (mac 00:16:3e:1b:e8:18)
+ (script vif-vnic)
+ (uuid 7da8c614-018b-dc87-6bfc-a296a95bca4f)
+ (backend 0)
+ )
+ )
+ (device
+ (vbd
+ (uname phy:/iscsi/winxp)
+ (uuid 65e19258-f4a2-a9ff-3b31-469ceaf4ec8d)
+ (mode w)
+ (dev hda:disk)
+ (backend 0)
+ (bootable 1)
+ )
+ )
+ (device
+ (vbd
+ (uname file:/net/heaped/export/netimage/windows/xp-sp2-vol.iso)
+ (uuid 87d9383b-f0ad-11a4-d668-b965f55edc3f)
+ (mode r)
+ (dev hdc:cdrom)
+ (backend 0)
+ (bootable 0)
+ )
+ )
+ (device (vkbd (backend 0)))
+ (device
+ (vfb
+ (vncunused 1)
+ (keymap en-us)
+ (type vnc)
+ (uuid 09666ad1-0c94-d79c-1439-99e05394ee51)
+ (location localhost:5900)
+ )
+ )
+ (device
+ (console
+ (protocol vt100)
+ (location 3)
+ (uuid cabfc0f5-1c9c-0e6f-aaa8-9974262aff66)
+ )
+ )
+)
diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml b/tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml
new file mode 100644
--- /dev/null
+++ b/tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml
@@ -0,0 +1,48 @@
+<domain type='xen' id='21'>
+ <name>domu-224</name>
+ <uuid>e0c172e6-4ad8-7353-0ece-515d2f181365</uuid>
+ <memory>524288</memory>
+ <currentMemory>524288</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type>hvm</type>
+ <loader>/usr/lib/xen/boot/hvmloader</loader>
+ <boot dev='cdrom'/>
+ </os>
+ <features>
+ <pae/>
+ </features>
+ <clock offset='localtime'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>destroy</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
+ <disk type='block' device='disk'>
+ <driver name='phy'/>
+ <source dev='/iscsi/winxp'/>
+ <target dev='hda' bus='ide'/>
+ </disk>
+ <disk type='file' device='cdrom'>
+ <driver name='file'/>
+ <source file='/net/heaped/export/netimage/windows/xp-sp2-vol.iso'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ </disk>
+ <interface type='bridge'>
+ <mac address='00:16:3e:1b:e8:18'/>
+ <source bridge='e1000g0'/>
+ <script path='vif-vnic'/>
+ <target dev='vif21.0'/>
+ </interface>
+ <serial type='pty'>
+ <target port='0'/>
+ </serial>
+ <console type='pty'>
+ <target port='0'/>
+ </console>
+ <input type='tablet' bus='usb'/>
+ <input type='mouse' bus='ps2'/>
+ <graphics type='vnc' port='5900' autoport='yes' keymap='en-us'/>
+ </devices>
+</domain>
16 years, 2 months
[libvirt] [PATCH] proxy: Fix use of uninitalized memory
by Rasputin
On short read, members of packet header are checked before actually read.
If uninitialized values can pass the test, they can be set to arbitrary
values while reading remaining portion of a packet.
Buffer overflow is possible. libvirt_proxy is suid-root.
diff -urp libvirt-0.5.1/proxy/libvirt_proxy.c libvirt-dev/proxy/libvirt_proxy.c
--- libvirt-0.5.1/proxy/libvirt_proxy.c 2008-11-20 08:58:43.000000000 +0100
+++ libvirt-dev/proxy/libvirt_proxy.c 2009-01-25 12:51:33.000000000 +0100
@@ -385,7 +385,8 @@ retry:
fprintf(stderr, "read %d bytes from client %d on socket %d\n",
ret, nr, pollInfos[nr].fd);
- if ((req->version != PROXY_PROTO_VERSION) ||
+ if ((ret != sizeof(virProxyPacket)) ||
+ (req->version != PROXY_PROTO_VERSION) ||
(req->len < sizeof(virProxyPacket)) ||
(req->len > sizeof(virProxyFullPacket)))
goto comm_error;
16 years, 2 months
[libvirt] PATCH: Detect SASL library on Solaris
by Daniel P. Berrange
I did a test build of CVS on Solaris and noticed it didn't detect SASL,
even though SASL was available. It turns out the library on SOlaris is
called libsasl.so, instead of libsasl2.so. It is still API compatible
with the Linux one, so there does not seem to be a reason not to use it
So this patch extends the configure test to make this work
Daniel
Index: configure.in
===================================================================
RCS file: /data/cvs/libvirt/configure.in,v
retrieving revision 1.202
diff -u -p -u -p -r1.202 configure.in
--- configure.in 27 Jan 2009 15:29:53 -0000 1.202
+++ configure.in 28 Jan 2009 11:38:25 -0000
@@ -517,18 +517,26 @@ if test "x$with_sasl" != "xno"; then
fail=1
fi])
if test "x$with_sasl" != "xno" ; then
- AC_CHECK_LIB([sasl2], [sasl_client_init],[with_sasl=yes],[
- if test "x$with_sasl" = "xcheck" ; then
+ AC_CHECK_LIB([sasl2], [sasl_client_init],[
+ SASL_LIBS="$SASL_LIBS -lsasl2"
+ with_sasl=yes
+ ],[
+ AC_CHECK_LIB([sasl], [sasl_client_init],[
+ SASL_LIBS="$SASL_LIBS -lsasl"
+ with_sasl=yes
+ ],[
+ if test "x$with_sasl" = "xcheck" ; then
with_sasl=no
- else
+ else
fail=1
- fi])
+ fi
+ ])
+ ])
fi
test $fail = 1 &&
AC_MSG_ERROR([You must install the Cyrus SASL development package in order to compile libvirt])
CFLAGS="$old_cflags"
LIBS="$old_libs"
- SASL_LIBS="$SASL_LIBS -lsasl2"
if test "x$with_sasl" = "xyes" ; then
AC_DEFINE_UNQUOTED([HAVE_SASL], 1,
[whether Cyrus SASL is available for authentication])
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
16 years, 2 months
[libvirt] PATCH: Reset global error object at end of test
by Daniel P. Berrange
There statstest test case is expected to raise a number of libvirt
errors. Since these are now stored in thread locals, it is expected
that this won't be free'd automatically at system shutdown. This
patch adds a call to virResetError() at the end to release the memory
associated with the stored error object. There is still one block of
memory alocated though, which is the thread local error error object
itself. We can't free this easily, so I just add a valgrind suppression
rule instead. This lets 'make valgrind' pass again
Also since the test case doesn't call virInitialize()as a normal
app would do, we need to explicitly initialize the thread local storage
to ensure things work correctly.
Daniel
diff -r 93337ec227d6 tests/.valgrind.supp
--- a/tests/.valgrind.supp Mon Jan 26 15:25:53 2009 +0000
+++ b/tests/.valgrind.supp Tue Jan 27 11:15:47 2009 +0000
@@ -238,3 +238,18 @@
fun:virtTestRun
fun:mymain
}
+{
+ ignoreThreadLocalErrorObject
+ Memcheck:Leak
+ fun:calloc
+ fun:virAlloc
+ fun:virLastErrorObject
+ fun:virRaiseError
+ fun:statsErrorFunc
+ fun:xenLinuxDomainDeviceID
+ fun:testDeviceHelper
+ fun:virtTestRun
+ fun:mymain
+ fun:virtTestMain
+ fun:main
+}
diff -r 93337ec227d6 tests/testutils.c
--- a/tests/testutils.c Mon Jan 26 15:25:53 2009 +0000
+++ b/tests/testutils.c Tue Jan 27 11:15:47 2009 +0000
@@ -26,6 +26,8 @@
#include "internal.h"
#include "memory.h"
#include "util.h"
+#include "threads.h"
+#include "virterror_internal.h"
#if TEST_OOM_TRACE
#include <execinfo.h>
@@ -319,8 +321,8 @@ int virtTestMain(int argc,
int (*func)(int, char **))
{
char *debugStr;
+ int ret;
#if TEST_OOM
- int ret;
int approxAlloc = 0;
int n;
char *oomStr = NULL;
@@ -330,6 +332,10 @@ int virtTestMain(int argc,
int worker = 0;
#endif
+ if (virThreadInitialize() < 0 ||
+ virErrorInitialize() < 0)
+ return 1;
+
if ((debugStr = getenv("VIR_TEST_DEBUG")) != NULL) {
if (virStrToLong_ui(debugStr, NULL, 10, &testDebug) < 0)
testDebug = 0;
@@ -349,8 +355,10 @@ int virtTestMain(int argc,
if (getenv("VIR_TEST_MP") != NULL) {
mp = sysconf(_SC_NPROCESSORS_ONLN);
fprintf(stderr, "Using %d worker processes\n", mp);
- if (VIR_ALLOC_N(workers, mp) < 0)
- return EXIT_FAILURE;
+ if (VIR_ALLOC_N(workers, mp) < 0) {
+ ret = EXIT_FAILURE;
+ goto cleanup;
+ }
}
if (testOOM)
@@ -359,7 +367,7 @@ int virtTestMain(int argc,
/* Run once to count allocs, and ensure it passes :-) */
ret = (func)(argc, argv);
if (ret != EXIT_SUCCESS)
- return EXIT_FAILURE;
+ goto cleanup;
#if TEST_OOM_TRACE
if (testDebug)
@@ -431,9 +439,11 @@ int virtTestMain(int argc,
else
fprintf(stderr, " FAILED\n");
}
+cleanup:
+#else
+ ret = (func)(argc, argv);
+#endif
+
+ virResetLastError();
return ret;
-
-#else
- return (func)(argc, argv);
-#endif
}
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
16 years, 2 months
[libvirt] [PATCH] Fix stderr spewage from docs/examples install
by john.levon@sun.com
# HG changeset patch
# User John Levon <john.levon(a)sun.com>
# Date 1232970961 28800
# Node ID 839f1721d6d9c2cfdbc9327814a4c4a9564ff814
# Parent 26d337992a98a00d98f83247eb113ca3d729d8ef
Fix stderr spewage from docs/examples install
*.res don't exist, so shouldn't be in the generated Makefile.am
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/docs/examples/Makefile.am b/docs/examples/Makefile.am
--- a/docs/examples/Makefile.am
+++ b/docs/examples/Makefile.am
@@ -20,7 +20,7 @@ install-data-local:
install-data-local:
$(mkinstalldirs) $(DESTDIR)$(HTML_DIR)
-@INSTALL@ -m 0644 $(srcdir)/*.html $(srcdir)/*.c $(srcdir)/*.xml \
- $(srcdir)/*.xsl $(srcdir)/*.res $(DESTDIR)$(HTML_DIR)
+ $(srcdir)/*.xsl $(DESTDIR)$(HTML_DIR)
EXTRA_DIST=examples.xsl index.py examples.xml
diff --git a/docs/examples/index.py b/docs/examples/index.py
--- a/docs/examples/index.py
+++ b/docs/examples/index.py
@@ -241,7 +241,7 @@ install-data-local:
install-data-local:
$(mkinstalldirs) $(DESTDIR)$(HTML_DIR)
-@INSTALL@ -m 0644 $(srcdir)/*.html $(srcdir)/*.c $(srcdir)/*.xml \\
- $(srcdir)/*.xsl $(srcdir)/*.res $(DESTDIR)$(HTML_DIR)
+ $(srcdir)/*.xsl $(DESTDIR)$(HTML_DIR)
"""
EXTRA_DIST= string.join(extras, ' ')
16 years, 2 months
[libvirt] [PATCH] Fix misuse of PF_UNIX
by john.levon@sun.com
# HG changeset patch
# User john.levon(a)sun.com
# Date 1233105335 28800
# Node ID b3a2537e2f3d5ccb055df1820c112b469a26efdb
# Parent 35f5d4f77a3f50cadacf32100fdbd992394f6002
Fix misuse of PF_UNIX
PF_UNIX is a protocol familay, not a valid protocol, so isn't suitable
for the 3rd socket() argument. Solaris should be ignoring the invalid
protocol anyway, but this fix is correct regardless.
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/src/xend_internal.c b/src/xend_internal.c
--- a/src/xend_internal.c
+++ b/src/xend_internal.c
@@ -752,7 +752,11 @@ xenDaemonOpen_unix(virConnectPtr conn, c
memset(&priv->addr, 0, sizeof(priv->addr));
priv->addrfamily = AF_UNIX;
- priv->addrprotocol = PF_UNIX;
+ /*
+ * This must be zero on Solaris at least for AF_UNIX (which should
+ * really be PF_UNIX, but doesn't matter).
+ */
+ priv->addrprotocol = 0;
priv->addrlen = sizeof(struct sockaddr_un);
addr = (struct sockaddr_un *)&priv->addr;
16 years, 2 months
[libvirt] [PATCH] Install schemas into correct location for Solaris
by john.levon@sun.com
# HG changeset patch
# User john.levon(a)sun.com
# Date 1233119659 28800
# Node ID cc848242fa810e8d0126b651849de715c7ef32e4
# Parent f91041f0c607be72c4b5695f081d20716521f6c5
Install schemas into correct location for Solaris
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/configure.in b/configure.in
--- a/configure.in
+++ b/configure.in
@@ -141,6 +141,10 @@ if test -n "$UDEVSETTLE"; then
AC_DEFINE_UNQUOTED([UDEVSETTLE],["$UDEVSETTLE"],
[Location or name of the udevsettle program])
fi
+
+SCHEMA_DIR=${pkgdatadir}/schemas
+test `uname -s` = SunOS && SCHEMA_DIR=${datadir}/lib/xml/rng/libvirt
+AC_SUBST([SCHEMA_DIR])
dnl Specific dir for HTML output ?
AC_ARG_WITH([html-dir], [AC_HELP_STRING([--with-html-dir=path],
diff --git a/docs/schemas/Makefile.am b/docs/schemas/Makefile.am
--- a/docs/schemas/Makefile.am
+++ b/docs/schemas/Makefile.am
@@ -1,6 +1,7 @@
-schemadir = $(pkgdatadir)/schemas
+schemadir = $(SCHEMA_DIR)
+
schema_DATA = \
domain.rng \
network.rng \
16 years, 2 months
[libvirt] [PATCH] avoid printf format-mismatch warnings
by Jim Meyering
autobuild.sh fails like this on at least RHEL5.3:
cc1: warnings being treated as errors
qemud.c: In function 'qemudClientReadBuf':
qemud.c:1470: warning: format '%d' expects type 'int', but argument 7 has type 'ssize_t'
qemud.c: In function 'qemudClientWriteBuf':
qemud.c:1695: warning: format '%d' expects type 'int', but argument 7 has type 'ssize_t'
make[2]: *** [libvirtd-qemud.o] Error 1
so I'm about to apply the following fix:
>From 162177b69fec410b7d940cf9242cba9b147f0bdb Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 28 Jan 2009 12:08:26 +0100
Subject: [PATCH] avoid printf format-mismatch warnings
* qemud/qemud.c (qemudClientReadBuf, qemudClientWriteBuf):
Use %lld and a (long long int) cast to print a ssize_t value.
---
qemud/qemud.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/qemud/qemud.c b/qemud/qemud.c
index eb91533..fa5e17d 100644
--- a/qemud/qemud.c
+++ b/qemud/qemud.c
@@ -1467,7 +1467,8 @@ static ssize_t qemudClientReadBuf(struct qemud_client *client,
ssize_t ret;
if (len < 0) {
- VIR_ERROR(_("unexpected negative length request %d"), len);
+ VIR_ERROR(_("unexpected negative length request %lld"),
+ (long long int) len);
qemudDispatchClientFailure(client);
return -1;
}
@@ -1692,7 +1693,8 @@ static ssize_t qemudClientWriteBuf(struct qemud_client *client,
ssize_t ret;
if (len < 0) {
- VIR_ERROR(_("unexpected negative length request %d"), len);
+ VIR_ERROR(_("unexpected negative length request %lld"),
+ (long long int) len);
qemudDispatchClientFailure(client);
return -1;
}
--
1.6.1.1.374.g0d9d7
16 years, 2 months
[libvirt] use virReportOOMError, not VIR_ERR_NO_MEMORY
by Jim Meyering
I've changed over 200 uses of <some_error_function> with the
VIR_ERR_NO_MEMORY flag to call virReportOOMError with whatever
"conn"-like argument (if any) was in the original call.
I don't claim to have tested these changes (OOM is a pain to simulate,
and besides, testing so many failure points would take more
infrastructure than we have right now).
However, I did automate most of the process.
most of the changes were performed automatically via this:
perl -0x0 -pi -e \
's/\w+( ?)\(([\w>-]+), *(?:(?:VIR_FROM_NONE|domcode|vm|dom|net|NULL), ?){0,3}VIR_ERR_NO_MEMORY,.*?\);/virReportOOMError$1($2);/sg' \
$(g grep -l VIR_ERR_NO_MEMORY|grep '\.c$'|grep -vF virterror.c)
Exceptions:
======================
Exceptions (as noted in ChangeLog) were to add the now-required
definitions of VIR_FROM_THIS, as needed, e.g.,
#define VIR_FROM_THIS VIR_FROM_OPENVZ
in openvz-related files.
Also, I replaced uses of qparam_report_oom automatically:
perl -pi -e 's/qparam_report_oom\(\);/virReportOOMError(NULL);/' \
src/qparams.c
and removed the definition of that macro manually.
I spotted and manually adjusted one misuse of VIR_ERR_NO_MEMORY:
remote_internal.c: fix typo that would mistakenly report OOM
* src/remote_internal.c (addrToString): Report VIR_ERR_UNKNOWN_HOST,
not VIR_ERR_NO_MEMORY.
ctxt in src/conf.c is not usable:
perl -pi -e 's/virReportOOMError\(ctxt\);/virReportOOMError(NULL);/' \
src/conf.c
I manually converted two uses of virSexprError(VIR_ERR_NO_MEMORY in
src/sexpr.c.
And of course, copyright dates were updated via an emacs write hook.
The first iteration involved applying the perl-based xforms
more of less file by file, and making sure everything still compiled.
Once done, I repeated the process on a new branch, automating as much
as possible, and then diff'd the branches. The diff was nearly empty,
modulo copyright dates and added VIR_FROM_THIS definitions.
I'm posting two small sort-of-different changes here.
I'll post this big first one separately.
>From 099536470ae2cbe9503ed471d391e403fb2587a4 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 27 Jan 2009 12:20:06 +0100
Subject: [PATCH 1/3] 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.
---
...
>From a223b8f6064e867d304df9a0a1498ef2940631ef Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 27 Jan 2009 15:58:07 +0100
Subject: [PATCH 2/3] qparams.c: Use virReportOOMError(NULL), not qparam_report_oom()
* src/qparams.c (VIR_FROM_THIS): Define to VIR_FROM_NONE.
(qparam_report_oom): Remove definition.
Replace all uses.
---
src/qparams.c | 22 ++++++++++------------
1 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/src/qparams.c b/src/qparams.c
index 22c5853..d0a84b3 100644
--- a/src/qparams.c
+++ b/src/qparams.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007 Red Hat, Inc.
+/* Copyright (C) 2007, 2009 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -33,9 +33,7 @@
#include "memory.h"
#include "qparams.h"
-#define qparam_report_oom(void) \
- virReportErrorHelper(NULL, VIR_FROM_NONE, VIR_ERR_NO_MEMORY, \
- __FILE__, __FUNCTION__, __LINE__, NULL)
+#define VIR_FROM_THIS VIR_FROM_NONE
struct qparam_set *
new_qparam_set (int init_alloc, ...)
@@ -47,14 +45,14 @@ new_qparam_set (int init_alloc, ...)
if (init_alloc <= 0) init_alloc = 1;
if (VIR_ALLOC(ps) < 0) {
- qparam_report_oom();
+ virReportOOMError(NULL);
return NULL;
}
ps->n = 0;
ps->alloc = init_alloc;
if (VIR_ALLOC_N(ps->p, ps->alloc) < 0) {
VIR_FREE (ps);
- qparam_report_oom();
+ virReportOOMError(NULL);
return NULL;
}
@@ -98,7 +96,7 @@ grow_qparam_set (struct qparam_set *ps)
{
if (ps->n >= ps->alloc) {
if (VIR_REALLOC_N(ps->p, ps->alloc * 2) < 0) {
- qparam_report_oom();
+ virReportOOMError(NULL);
return -1;
}
ps->alloc *= 2;
@@ -115,14 +113,14 @@ append_qparam (struct qparam_set *ps,
pname = strdup (name);
if (!pname) {
- qparam_report_oom();
+ virReportOOMError(NULL);
return -1;
}
pvalue = strdup (value);
if (!pvalue) {
VIR_FREE (pname);
- qparam_report_oom();
+ virReportOOMError(NULL);
return -1;
}
@@ -156,7 +154,7 @@ qparam_get_query (const struct qparam_set *ps)
}
if (virBufferError(&buf)) {
- qparam_report_oom();
+ virReportOOMError(NULL);
return NULL;
}
@@ -184,7 +182,7 @@ qparam_query_parse (const char *query)
ps = new_qparam_set (0, NULL);
if (!ps) {
- qparam_report_oom();
+ virReportOOMError(NULL);
return NULL;
}
@@ -257,7 +255,7 @@ qparam_query_parse (const char *query)
return ps;
out_of_memory:
- qparam_report_oom();
+ virReportOOMError(NULL);
free_qparam_set (ps);
return NULL;
}
--
1.6.1.1.363.g2a3bd
>From dd9477353e930ba75dea1e06ccbced5b1cb61e09 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 27 Jan 2009 15:53:27 +0100
Subject: [PATCH 3/3] remote_internal.c: fix typo that would mistakenly report OOM
* src/remote_internal.c (addrToString): Report VIR_ERR_UNKNOWN_HOST,
not VIR_ERR_NO_MEMORY.
---
src/remote_internal.c | 11 +++++------
1 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/remote_internal.c b/src/remote_internal.c
index 8ed52bc..5c2e705 100644
--- a/src/remote_internal.c
+++ b/src/remote_internal.c
@@ -2,7 +2,7 @@
* remote_internal.c: driver to provide access to libvirtd running
* on a remote machine
*
- * Copyright (C) 2007-2008 Red Hat, Inc.
+ * Copyright (C) 2007-2009 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -4949,10 +4949,10 @@ static char *addrToString(struct sockaddr_storage *sa, socklen_t salen)
port, sizeof(port),
NI_NUMERICHOST | NI_NUMERICSERV)) != 0) {
virRaiseError (NULL, NULL, NULL, VIR_FROM_REMOTE,
- VIR_ERR_NO_MEMORY, VIR_ERR_ERROR,
- NULL, NULL, NULL, 0, 0,
- _("Cannot resolve address %d: %s"),
- err, gai_strerror(err));
+ VIR_ERR_UNKNOWN_HOST, VIR_ERR_ERROR,
+ NULL, NULL, NULL, 0, 0,
+ _("Cannot resolve address %d: %s"),
+ err, gai_strerror(err));
return NULL;
}
@@ -6836,4 +6836,3 @@ remoteRegister (void)
return 0;
}
-
--
1.6.1.1.363.g2a3bd
16 years, 2 months