Devel
Threads by month
- ----- 2026 -----
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- 18 participants
- 40170 discussions
08 Jan '09
On Thu, Jan 08, 2009 at 05:02:14PM +0100, Jim Meyering wrote:
[..snip..]
> Hi Guido,
>
> libvirt doesn't build right now, because of this:
>
> xm_internal.c:2288: error: too few arguments to function 'virDomainDefParseString'
> xm_internal.c:2530: error: too few arguments to function 'virDomainDeviceDefParse'
> xm_internal.c:2619: error: too few arguments to function 'virDomainDeviceDefParse'
> xend_internal.c:3860: error: too few arguments to function 'virDomainDeviceDefParse'
> xend_internal.c:3950: error: too few arguments to function 'virDomainDeviceDefParse'
Thought I had tested this with the Xen driver enabled, but seems I
didn't. Sorry! Attached patch fixes the build and passes "make check".
Thanks for pointing this out!
-- Guido
1
1
08 Jan '09
On Thu, Dec 04, 2008 at 02:16:06PM +0100, Daniel Veillard wrote:
> On Thu, Dec 04, 2008 at 01:15:23PM +0100, Guido Günther wrote:
> > On Thu, Dec 04, 2008 at 10:56:25AM +0000, Daniel P. Berrange wrote:
> > > On Wed, Dec 03, 2008 at 06:20:12PM +0100, Guido G?nther wrote:
> > > > On Sun, Nov 30, 2008 at 12:43:48PM +0100, Guido Günther wrote:
> > > > > >From 87db4a698ed9b49294c0f94137fc6beef13bd4e8 Mon Sep 17 00:00:00 2001
> > > > > From: =?utf-8?q?Guido=20G=C3=BCnther?= <agx(a)sigxcpu.org>
> > > > > Date: Tue, 25 Nov 2008 13:02:43 +0100
> > > > > Subject: [PATCH] differentiate between active and inactive configs
> > > > >
> > > > > by honoring the VIR_DOMAIN_XML_INACTIVE flag.
> > > > O.k. to commit this part as a start so you can readily use it vor lxc?
> > >
> > > ACK, assuming 'make check' still passes.
> > It does here, sure. Patch Applied now. I've added the flag to the
> > functions currently needed for qemu but if nobody objects I'd like to
> > add them to:
> >
> > virDomainDeviceDefParse
> > virDomainDefParseString
> > virDomainHostdevSubsysUsbDefParseXML
> > virDomainDiskDefParseXML
> > virDomainFSDefParseXML
> > virDomainNetDefParseXML
> > virDomainInputDefParseXML
> > virDomainSoundDefParseXML
> > virDomainHostdevDefParseXML
> > virDomainChrDefParseXML
>
> I'm about to release an intermediate 0.5.1 release with the bug and
> small improvement fixes since 0.5.0, I assume the more generic patch
> can wait after that, but that sounds right to me in principle.
Attached patch adds a flag parameter to the above functions and passes
VIR_DOMAIN_XML_INACTIVE from the upper levels. I see two advantages in
this:
* symmetric interfaces to the XML parsing functions (why has
virDomainDefParseFile a flags argument while virDomainDefParseString
hasn't)
* other drivers can use this very easily (IIRC lxc has some use for it)
otherwise there's not too much gain so I'm a bit undecided if this is
actually necessary.
-- Guido
3
3
Daniel Berrange fixed this yesterday.
http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=74e2d5b2fd5
It's in gnulib now, along with a change to make
the cpp nesting a little more readable.
This pulls the update poll.c into libvirt:
Thu Jan 8 09:48:04 CET 2009 Daniel P. Berrange <berrange(a)redhat.com>
poll: don't return uninitialized
* gnulib/lib/poll.c (poll) [WIN32_NATIVE]: Initialize "rc".
[sync from gnulib also adjusts cpp indentation to reflect nesting.]
>From 212721560f3f2bcf7329c48417e0ba24243fc554 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Thu, 8 Jan 2009 09:49:53 +0100
Subject: [PATCH] poll: don't return uninitialized
* gnulib/lib/poll.c (poll) [WIN32_NATIVE]: Initialize "rc".
[sync from gnulib also adjusts cpp indentation to reflect nesting.]
---
gnulib/lib/poll.c | 54 ++++++++++++++++++++++++++--------------------------
1 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/gnulib/lib/poll.c b/gnulib/lib/poll.c
index 87ddf3c..da9c9f2 100644
--- a/gnulib/lib/poll.c
+++ b/gnulib/lib/poll.c
@@ -1,7 +1,7 @@
/* Emulation for poll(2)
Contributed by Paolo Bonzini.
- Copyright 2001, 2002, 2003, 2006, 2007, 2008 Free Software Foundation, Inc.
+ Copyright 2001-2003, 2006-2009 Free Software Foundation, Inc.
This file is part of gnulib.
@@ -29,35 +29,35 @@
#include <assert.h>
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-#define WIN32_NATIVE
-#include <winsock2.h>
-#include <windows.h>
-#include <io.h>
-#include <stdio.h>
-#include <conio.h>
+# define WIN32_NATIVE
+# include <winsock2.h>
+# include <windows.h>
+# include <io.h>
+# include <stdio.h>
+# include <conio.h>
#else
-#include <sys/time.h>
-#include <sys/socket.h>
-#include <sys/select.h>
-#include <unistd.h>
+# include <sys/time.h>
+# include <sys/socket.h>
+# include <sys/select.h>
+# include <unistd.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
-#include <sys/ioctl.h>
+# include <sys/ioctl.h>
#endif
#ifdef HAVE_SYS_FILIO_H
-#include <sys/filio.h>
+# include <sys/filio.h>
#endif
#include <time.h>
#ifndef INFTIM
-#define INFTIM (-1)
+# define INFTIM (-1)
#endif
/* BeOS does not have MSG_PEEK. */
#ifndef MSG_PEEK
-#define MSG_PEEK 0
+# define MSG_PEEK 0
#endif
#ifdef WIN32_NATIVE
@@ -92,9 +92,9 @@ typedef enum _FILE_INFORMATION_CLASS {
typedef DWORD (WINAPI *PNtQueryInformationFile)
(HANDLE, IO_STATUS_BLOCK *, VOID *, ULONG, FILE_INFORMATION_CLASS);
-#ifndef PIPE_BUF
-#define PIPE_BUF 512
-#endif
+# ifndef PIPE_BUF
+# define PIPE_BUF 512
+# endif
/* Compute revents values for file handle H. */
@@ -234,7 +234,7 @@ compute_revents (int fd, int sought, fd_set *rfds, fd_set *wfds, fd_set *efds)
int r;
int socket_errno;
-#if defined __MACH__ && defined __APPLE__
+# if defined __MACH__ && defined __APPLE__
/* There is a bug in Mac OS X that causes it to ignore MSG_PEEK
for some kinds of descriptors. Detect if this descriptor is a
connected socket, a server socket, or something else using a
@@ -243,11 +243,11 @@ compute_revents (int fd, int sought, fd_set *rfds, fd_set *wfds, fd_set *efds)
socket_errno = (r < 0) ? errno : 0;
if (r == 0 || socket_errno == ENOTSOCK)
ioctl (fd, FIONREAD, &r);
-#else
+# else
char data[64];
r = recv (fd, data, sizeof (data), MSG_PEEK);
socket_errno = (r < 0) ? errno : 0;
-#endif
+# endif
if (r == 0)
happened |= POLLHUP;
@@ -288,7 +288,7 @@ poll (pfd, nfd, timeout)
int maxfd, rc;
nfds_t i;
-#ifdef _SC_OPEN_MAX
+# ifdef _SC_OPEN_MAX
static int sc_open_max = -1;
if (nfd < 0
@@ -299,15 +299,15 @@ poll (pfd, nfd, timeout)
errno = EINVAL;
return -1;
}
-#else /* !_SC_OPEN_MAX */
-#ifdef OPEN_MAX
+# else /* !_SC_OPEN_MAX */
+# ifdef OPEN_MAX
if (nfd < 0 || nfd > OPEN_MAX)
{
errno = EINVAL;
return -1;
}
-#endif /* OPEN_MAX -- else, no check is needed */
-#endif /* !_SC_OPEN_MAX */
+# endif /* OPEN_MAX -- else, no check is needed */
+# endif /* !_SC_OPEN_MAX */
/* EFAULT is not necessary to implement, but let's do it in the
simplest case. */
@@ -405,7 +405,7 @@ poll (pfd, nfd, timeout)
BOOL poll_again;
MSG msg;
char sockbuf[256];
- int rc;
+ int rc = 0;
nfds_t i;
if (nfd < 0 || timeout < -1)
--
1.6.1.121.g866a4a
1
0
The current public API for error reporting consists of
- A global error object
- A per-connection error object
Some functions always set errors on the global object. Other functions
always set errors on the per-connection object, except when they set
errors on the global object. Both have built-in race conditions if they
are accessed from multiple threads because of the time between the API
call raising the error, and the caller querying it.
The solution to this is to do away with all of the existing error objects
and replace them with a per-thread error object. Well, except we can't
do away with existing objects because of ABI compatability. This turns
out to not be such a bad problem after all....
So with this patch...
virterror.c gets ability to track a per-thread virErrorPtr instance. This
object is stored in a thread local variable via pthread_{get,set}specific.
It is allocated when first required, and deleted when the thread exits
Every single API will *always* set the virErrorPtr object associated with
its current thread.
In the public virterror.h we add
virErrorPtr virThreadGetLastError (void);
int virThreadCopyLastError (virErrorPtr to);
void virThreadResetLastError (void);
This provides a guarenteed thread-safe public API for fetching error
information. All the other existing APIs have docs updated to recommend
against their use.
In libvirt.c, in any exit paths which result in an error code, we copy
the per-thread virErrorPtr object into either the global error object
or per-connection object as applicable for the scenario. This gives us
100% backwards compatability. NB, we hold a lock when doing this so
that these are race-free when setting them.
At the start of every API call, we call virThreadResetLastError() and
at any exit path with an error, if the error object is not set, then
we set a generic error message. This means that if the internal driver
code is broken and forgets to raise an error, the caller will still
at least see a generic error report.
Finally, virCopyLastError and virConnCopyLastError were not correctly
strdup'ing the char * fields. This meant that if the original error
was cleared, you'd get a use-after-free error, shortly followed by
a double-free error if the first didn't kill you. This patch also
fixes those two methods to correctly strdup the char *.
As for language bindings, they should *all* be updated to use the
virThreadGetLastError() method, and *never* call virGetLastError()
or the virConnGetLastError() calls.
With this patch applied, assuming all the per-hypervisor drivers are
thread-safe (they are except for Xen which is still TODO), then the
public API for virConectPtr is also (almost[1]) guarenteed to be thread-
safe.
include/libvirt/virterror.h | 7
src/datatypes.c | 11
src/datatypes.h | 15
src/libvirt.c | 3729 ++++++++++++++++++++++++++++++--------------
src/libvirt_sym.version.in | 8
src/virterror.c | 281 +++
src/virterror_internal.h | 4
7 files changed, 2902 insertions(+), 1153 deletions(-)
Daniel
[1] We need to fix lots of stupid internal mistakes like strerror()
vs strerror_r() - these were already a problem even with libvirt
being single-threaded on virConnectPtr, because the app using
libvirt could be threaded. More on this later...
diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h
--- a/include/libvirt/virterror.h
+++ b/include/libvirt/virterror.h
@@ -187,6 +187,13 @@ void virConnSetErrorFunc (virConnectPt
virErrorFunc handler);
int virConnCopyLastError (virConnectPtr conn,
virErrorPtr to);
+
+
+virErrorPtr virThreadGetLastError (void);
+int virThreadCopyLastError (virErrorPtr to);
+void virThreadResetLastError (void);
+
+
#ifdef __cplusplus
}
#endif
diff --git a/src/datatypes.c b/src/datatypes.c
--- a/src/datatypes.c
+++ b/src/datatypes.c
@@ -192,8 +192,6 @@ virReleaseConnect(virConnectPtr conn) {
virHashFree(conn->nodeDevices, (virHashDeallocator) virNodeDeviceFree);
virResetError(&conn->err);
- if (virLastErr.conn == conn)
- virLastErr.conn = NULL;
xmlFreeURI(conn->uri);
@@ -320,10 +318,6 @@ virReleaseDomain(virDomainPtr domain) {
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
_("domain missing from connection hash table"));
- if (conn->err.dom == domain)
- conn->err.dom = NULL;
- if (virLastErr.dom == domain)
- virLastErr.dom = NULL;
domain->magic = -1;
domain->id = -1;
VIR_FREE(domain->name);
@@ -456,11 +450,6 @@ virReleaseNetwork(virNetworkPtr network)
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
_("network missing from connection hash table"));
- if (conn->err.net == network)
- conn->err.net = NULL;
- if (virLastErr.net == network)
- virLastErr.net = NULL;
-
network->magic = -1;
VIR_FREE(network->name);
VIR_FREE(network);
diff --git a/src/datatypes.h b/src/datatypes.h
--- a/src/datatypes.h
+++ b/src/datatypes.h
@@ -95,6 +95,10 @@
* Internal structure associated to a connection
*/
struct _virConnect {
+ /* All the variables from here, until the 'lock' declaration
+ * are setup at time of connection open, and never changed
+ * since. Thus no need to lock when accessing them
+ */
unsigned int magic; /* specific value to check */
int flags; /* a set of connection flags */
xmlURIPtr uri; /* connection URI */
@@ -114,11 +118,6 @@ struct _virConnect {
void * storagePrivateData;
void * devMonPrivateData;
- /* Per-connection error. */
- virError err; /* the last error */
- virErrorFunc handler; /* associated handlet */
- void *userData; /* the user data */
-
/*
* The lock mutex must be acquired before accessing/changing
* any of members following this point, or changing the ref
@@ -126,6 +125,12 @@ struct _virConnect {
* this connection
*/
PTHREAD_MUTEX_T (lock);
+
+ /* Per-connection error. */
+ virError err; /* the last error */
+ virErrorFunc handler; /* associated handlet */
+ void *userData; /* the user data */
+
virHashTablePtr domains; /* hash table for known domains */
virHashTablePtr networks; /* hash table for known domains */
virHashTablePtr storagePools;/* hash table for known storage pools */
diff --git a/src/libvirt.c b/src/libvirt.c
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -778,6 +778,8 @@ virGetVersion(unsigned long *libVer, con
#endif
if (*typeVer == 0) {
virLibConnError(NULL, VIR_ERR_NO_SUPPORT, type);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
}
@@ -791,6 +793,8 @@ do_open (const char *name,
{
int i, res;
virConnectPtr ret;
+
+ virThreadResetLastError();
ret = virGetConnect();
if (ret == NULL)
@@ -945,17 +949,8 @@ failed:
failed:
if (ret->driver) ret->driver->close (ret);
- /* If no global error was set, copy any error set
- in the connection object we're about to dispose of */
- if (virLastErr.code == VIR_ERR_OK) {
- memcpy(&virLastErr, &ret->err, sizeof(ret->err));
- memset(&ret->err, 0, sizeof(ret->err));
- }
-
- /* Still no error set, then raise a generic error */
- if (virLastErr.code == VIR_ERR_OK)
- virLibConnError (NULL, VIR_ERR_INTERNAL_ERROR,
- _("unable to open connection"));
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
virUnrefConnect(ret);
@@ -1050,8 +1045,16 @@ virConnectClose(virConnectPtr conn)
{
DEBUG("conn=%p", conn);
- if (!VIR_IS_CONNECT(conn))
- return (-1);
+ virThreadResetLastError();
+
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
if (conn->networkDriver)
conn->networkDriver->close (conn);
@@ -1061,8 +1064,11 @@ virConnectClose(virConnectPtr conn)
conn->deviceMonitor->close (conn);
conn->driver->close (conn);
- if (virUnrefConnect(conn) < 0)
- return (-1);
+ if (virUnrefConnect(conn) < 0) {
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
return (0);
}
@@ -1073,12 +1079,22 @@ int
int
virDrvSupportsFeature (virConnectPtr conn, int feature)
{
+ int ret;
DEBUG("conn=%p, feature=%d", conn, feature);
- if (!VIR_IS_CONNECT(conn))
- return (-1);
-
- return VIR_DRV_SUPPORTS_FEATURE (conn->driver, conn, feature);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+
+ ret = VIR_DRV_SUPPORTS_FEATURE (conn->driver, conn, feature);
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
+ return ret;
}
/**
@@ -1098,8 +1114,12 @@ virConnectGetType(virConnectPtr conn)
const char *ret;
DEBUG("conn=%p", conn);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
@@ -1128,20 +1148,32 @@ virConnectGetVersion(virConnectPtr conn,
{
DEBUG("conn=%p, hvVer=%p", conn, hvVer);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
- return (-1);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return -1;
}
if (hvVer == NULL) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
-
- if (conn->driver->version)
- return conn->driver->version (conn, hvVer);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->driver->version) {
+ int ret = conn->driver->version (conn, hvVer);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return -1;
}
@@ -1162,15 +1194,27 @@ virConnectGetHostname (virConnectPtr con
{
DEBUG("conn=%p", conn);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
- return NULL;
- }
-
- if (conn->driver->getHostname)
- return conn->driver->getHostname (conn);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return NULL;
+ }
+
+ if (conn->driver->getHostname) {
+ char *ret = conn->driver->getHostname (conn);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return NULL;
}
@@ -1193,26 +1237,37 @@ virConnectGetURI (virConnectPtr conn)
virConnectGetURI (virConnectPtr conn)
{
char *name;
-
- DEBUG("conn=%p", conn);
-
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ DEBUG("conn=%p", conn);
+
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return NULL;
}
/* Drivers may override getURI, but if they don't then
* we provide a default implementation.
*/
- if (conn->driver->getURI)
- return conn->driver->getURI (conn);
+ if (conn->driver->getURI) {
+ name = conn->driver->getURI (conn);
+ if (!name)
+ goto error;
+ }
name = (char *)xmlSaveUri(conn->uri);
if (!name) {
virLibConnError (conn, VIR_ERR_NO_MEMORY, __FUNCTION__);
- return NULL;
+ goto error;
}
return name;
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
+ return NULL;
}
/**
@@ -1232,15 +1287,26 @@ virConnectGetMaxVcpus(virConnectPtr conn
{
DEBUG("conn=%p, type=%s", conn, type);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
- return (-1);
- }
-
- if (conn->driver->getMaxVcpus)
- return conn->driver->getMaxVcpus (conn, type);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return -1;
+ }
+
+ if (conn->driver->getMaxVcpus) {
+ int ret = conn->driver->getMaxVcpus (conn, type);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return -1;
}
@@ -1259,20 +1325,31 @@ virConnectListDomains(virConnectPtr conn
{
DEBUG("conn=%p, ids=%p, maxids=%d", conn, ids, maxids);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
- return (-1);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return -1;
}
if ((ids == NULL) || (maxids < 0)) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
-
- if (conn->driver->listDomains)
- return conn->driver->listDomains (conn, ids, maxids);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->driver->listDomains) {
+ int ret = conn->driver->listDomains (conn, ids, maxids);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return -1;
}
@@ -1289,15 +1366,26 @@ virConnectNumOfDomains(virConnectPtr con
{
DEBUG("conn=%p", conn);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
- return (-1);
- }
-
- if (conn->driver->numOfDomains)
- return conn->driver->numOfDomains (conn);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ goto error;
+ }
+
+ if (conn->driver->numOfDomains) {
+ int ret = conn->driver->numOfDomains (conn);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return -1;
}
@@ -1320,8 +1408,12 @@ virDomainGetConnect (virDomainPtr dom)
{
DEBUG("dom=%p", dom);
+ virThreadResetLastError();
+
if (!VIR_IS_DOMAIN (dom)) {
virLibDomainError (NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return NULL;
}
return dom->conn;
@@ -1348,23 +1440,35 @@ virDomainCreateXML(virConnectPtr conn, c
{
DEBUG("conn=%p, xmlDesc=%s, flags=%d", conn, xmlDesc, flags);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
if (xmlDesc == NULL) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
+ goto error;
}
if (conn->flags & VIR_CONNECT_RO) {
virLibConnError(conn, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (NULL);
- }
-
- if (conn->driver->domainCreateXML)
- return conn->driver->domainCreateXML (conn, xmlDesc, flags);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->driver->domainCreateXML) {
+ virDomainPtr ret;
+ ret = conn->driver->domainCreateXML (conn, xmlDesc, flags);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return NULL;
}
@@ -1404,19 +1508,32 @@ virDomainLookupByID(virConnectPtr conn,
{
DEBUG("conn=%p, id=%d", conn, id);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
if (id < 0) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
- }
-
- if (conn->driver->domainLookupByID)
- return conn->driver->domainLookupByID (conn, id);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->driver->domainLookupByID) {
+ virDomainPtr ret;
+ ret = conn->driver->domainLookupByID (conn, id);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return NULL;
}
@@ -1435,19 +1552,32 @@ virDomainLookupByUUID(virConnectPtr conn
{
DEBUG("conn=%p, uuid=%s", conn, uuid);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
if (uuid == NULL) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
- }
-
- if (conn->driver->domainLookupByUUID)
- return conn->driver->domainLookupByUUID (conn, uuid);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->driver->domainLookupByUUID) {
+ virDomainPtr ret;
+ ret = conn->driver->domainLookupByUUID (conn, uuid);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return NULL;
}
@@ -1470,14 +1600,17 @@ virDomainLookupByUUIDString(virConnectPt
DEBUG("conn=%p, uuidstr=%s", conn, uuidstr);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
if (uuidstr == NULL) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
-
+ goto error;
}
/* XXX: sexpr_uuid() also supports 'xxxx-xxxx-xxxx-xxxx' format.
* We needn't it here. Right?
@@ -1495,12 +1628,17 @@ virDomainLookupByUUIDString(virConnectPt
if (ret!=VIR_UUID_BUFLEN) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
+ goto error;
}
for (i = 0; i < VIR_UUID_BUFLEN; i++)
uuid[i] = raw[i] & 0xFF;
return virDomainLookupByUUID(conn, &uuid[0]);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
+ return NULL;
}
/**
@@ -1518,19 +1656,32 @@ virDomainLookupByName(virConnectPtr conn
{
DEBUG("conn=%p, name=%s", conn, name);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
if (name == NULL) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
- }
-
- if (conn->driver->domainLookupByName)
- return conn->driver->domainLookupByName (conn, name);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->driver->domainLookupByName) {
+ virDomainPtr dom;
+ dom = conn->driver->domainLookupByName (conn, name);
+ if (!dom)
+ goto error;
+ return dom;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return NULL;
}
@@ -1552,21 +1703,34 @@ virDomainDestroy(virDomainPtr domain)
DEBUG("domain=%p", domain);
- if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return (-1);
- }
-
- conn = domain->conn;
- if (conn->flags & VIR_CONNECT_RO) {
- virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (-1);
- }
-
- if (conn->driver->domainDestroy)
- return conn->driver->domainDestroy (domain);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+
+ conn = domain->conn;
+ if (conn->flags & VIR_CONNECT_RO) {
+ virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->driver->domainDestroy) {
+ int ret;
+ ret = conn->driver->domainDestroy (domain);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return -1;
}
@@ -1584,12 +1748,18 @@ virDomainFree(virDomainPtr domain)
{
DEBUG("domain=%p", domain);
- if (!VIR_IS_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return (-1);
- }
- if (virUnrefDomain(domain) < 0)
- return (-1);
+ virThreadResetLastError();
+
+ if (!VIR_IS_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+ if (virUnrefDomain(domain) < 0) {
+ virThreadSetGlobalError();
+ return -1;
+ }
return(0);
}
@@ -1611,21 +1781,34 @@ virDomainSuspend(virDomainPtr domain)
virConnectPtr conn;
DEBUG("domain=%p", domain);
- if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return (-1);
- }
- if (domain->conn->flags & VIR_CONNECT_RO) {
- virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (-1);
- }
-
- conn = domain->conn;
-
- if (conn->driver->domainSuspend)
- return conn->driver->domainSuspend (domain);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+ if (domain->conn->flags & VIR_CONNECT_RO) {
+ virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ goto error;
+ }
+
+ conn = domain->conn;
+
+ if (conn->driver->domainSuspend) {
+ int ret;
+ ret = conn->driver->domainSuspend (domain);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
return -1;
}
@@ -1645,21 +1828,34 @@ virDomainResume(virDomainPtr domain)
virConnectPtr conn;
DEBUG("domain=%p", domain);
- if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return (-1);
- }
- if (domain->conn->flags & VIR_CONNECT_RO) {
- virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (-1);
- }
-
- conn = domain->conn;
-
- if (conn->driver->domainResume)
- return conn->driver->domainResume (domain);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+ if (domain->conn->flags & VIR_CONNECT_RO) {
+ virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ goto error;
+ }
+
+ conn = domain->conn;
+
+ if (conn->driver->domainResume) {
+ int ret;
+ ret = conn->driver->domainResume (domain);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
return -1;
}
@@ -1682,18 +1878,22 @@ virDomainSave(virDomainPtr domain, const
virConnectPtr conn;
DEBUG("domain=%p, to=%s", domain, to);
- if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return (-1);
- }
- if (domain->conn->flags & VIR_CONNECT_RO) {
- virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (-1);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+ if (domain->conn->flags & VIR_CONNECT_RO) {
+ virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ goto error;
}
conn = domain->conn;
if (to == NULL) {
virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
+ goto error;
}
/*
@@ -1716,10 +1916,19 @@ virDomainSave(virDomainPtr domain, const
}
- if (conn->driver->domainSave)
- return conn->driver->domainSave (domain, to);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ if (conn->driver->domainSave) {
+ int ret;
+ ret = conn->driver->domainSave (domain, to);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
return -1;
}
@@ -1738,17 +1947,21 @@ virDomainRestore(virConnectPtr conn, con
char filepath[4096];
DEBUG("conn=%p, from=%s", conn, from);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
if (conn->flags & VIR_CONNECT_RO) {
virLibConnError(conn, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (-1);
+ goto error;
}
if (from == NULL) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
+ goto error;
}
/*
@@ -1759,21 +1972,36 @@ virDomainRestore(virConnectPtr conn, con
unsigned int len, t;
t = strlen(from);
- if (getcwd(filepath, sizeof(filepath) - (t + 3)) == NULL)
- return (-1);
+ if (getcwd(filepath, sizeof(filepath) - (t + 3)) == NULL) {
+ virLibConnError(conn, VIR_ERR_SYSTEM_ERROR,
+ _("cannot get working directory"));
+ goto error;
+ }
len = strlen(filepath);
/* that should be covered by getcwd() semantic, but be 100% sure */
- if (len > sizeof(filepath) - (t + 3))
- return (-1);
+ if (len > sizeof(filepath) - (t + 3)) {
+ virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("path too long"));
+ goto error;
+ }
filepath[len] = '/';
strcpy(&filepath[len + 1], from);
from = &filepath[0];
}
- if (conn->driver->domainRestore)
- return conn->driver->domainRestore (conn, from);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ if (conn->driver->domainRestore) {
+ int ret;
+ ret = conn->driver->domainRestore (conn, from);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return -1;
}
@@ -1796,18 +2024,22 @@ virDomainCoreDump(virDomainPtr domain, c
virConnectPtr conn;
DEBUG("domain=%p, to=%s, flags=%d", domain, to, flags);
- if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return (-1);
- }
- if (domain->conn->flags & VIR_CONNECT_RO) {
- virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (-1);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+ if (domain->conn->flags & VIR_CONNECT_RO) {
+ virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ goto error;
}
conn = domain->conn;
if (to == NULL) {
virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
+ goto error;
}
/*
@@ -1818,22 +2050,37 @@ virDomainCoreDump(virDomainPtr domain, c
unsigned int len, t;
t = strlen(to);
- if (getcwd(filepath, sizeof(filepath) - (t + 3)) == NULL)
- return (-1);
+ if (getcwd(filepath, sizeof(filepath) - (t + 3)) == NULL) {
+ virLibDomainError(domain, VIR_ERR_SYSTEM_ERROR,
+ _("cannot get current directory"));
+ goto error;
+ }
len = strlen(filepath);
/* that should be covered by getcwd() semantic, but be 100% sure */
- if (len > sizeof(filepath) - (t + 3))
- return (-1);
+ if (len > sizeof(filepath) - (t + 3)) {
+ virLibDomainError(domain, VIR_ERR_INTERNAL_ERROR,
+ _("path too long"));
+ goto error;
+ }
filepath[len] = '/';
strcpy(&filepath[len + 1], to);
to = &filepath[0];
}
- if (conn->driver->domainCoreDump)
- return conn->driver->domainCoreDump (domain, to, flags);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ if (conn->driver->domainCoreDump) {
+ int ret;
+ ret = conn->driver->domainCoreDump (domain, to, flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
return -1;
}
@@ -1856,21 +2103,34 @@ virDomainShutdown(virDomainPtr domain)
virConnectPtr conn;
DEBUG("domain=%p", domain);
- if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return (-1);
- }
- if (domain->conn->flags & VIR_CONNECT_RO) {
- virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (-1);
- }
-
- conn = domain->conn;
-
- if (conn->driver->domainShutdown)
- return conn->driver->domainShutdown (domain);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+ if (domain->conn->flags & VIR_CONNECT_RO) {
+ virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ goto error;
+ }
+
+ conn = domain->conn;
+
+ if (conn->driver->domainShutdown) {
+ int ret;
+ ret = conn->driver->domainShutdown (domain);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
return -1;
}
@@ -1891,21 +2151,34 @@ virDomainReboot(virDomainPtr domain, uns
virConnectPtr conn;
DEBUG("domain=%p, flags=%u", domain, flags);
- if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return (-1);
- }
- if (domain->conn->flags & VIR_CONNECT_RO) {
- virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (-1);
- }
-
- conn = domain->conn;
-
- if (conn->driver->domainReboot)
- return conn->driver->domainReboot (domain, flags);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+ if (domain->conn->flags & VIR_CONNECT_RO) {
+ virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ goto error;
+ }
+
+ conn = domain->conn;
+
+ if (conn->driver->domainReboot) {
+ int ret;
+ ret = conn->driver->domainReboot (domain, flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
return -1;
}
@@ -1923,8 +2196,12 @@ virDomainGetName(virDomainPtr domain)
{
DEBUG("domain=%p", domain);
- if (!VIR_IS_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
return (domain->name);
@@ -1944,12 +2221,18 @@ virDomainGetUUID(virDomainPtr domain, un
{
DEBUG("domain=%p, uuid=%p", domain, uuid);
- if (!VIR_IS_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
if (uuid == NULL) {
virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
return (-1);
}
@@ -1974,20 +2257,29 @@ virDomainGetUUIDString(virDomainPtr doma
unsigned char uuid[VIR_UUID_BUFLEN];
DEBUG("domain=%p, buf=%p", domain, buf);
- if (!VIR_IS_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
if (buf == NULL) {
virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
+ goto error;
}
if (virDomainGetUUID(domain, &uuid[0]))
- return (-1);
+ goto error;
virUUIDFormat(uuid, buf);
return (0);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
+ return -1;
}
/**
@@ -2003,8 +2295,12 @@ virDomainGetID(virDomainPtr domain)
{
DEBUG("domain=%p", domain);
- if (!VIR_IS_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return ((unsigned int) -1);
}
return (domain->id);
@@ -2025,17 +2321,30 @@ virDomainGetOSType(virDomainPtr domain)
virConnectPtr conn;
DEBUG("domain=%p", domain);
- if (!VIR_IS_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return (NULL);
- }
-
- conn = domain->conn;
-
- if (conn->driver->domainGetOSType)
- return conn->driver->domainGetOSType (domain);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
+ return (NULL);
+ }
+
+ conn = domain->conn;
+
+ if (conn->driver->domainGetOSType) {
+ char *ret;
+ ret = conn->driver->domainGetOSType (domain);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
return NULL;
}
@@ -2055,17 +2364,30 @@ virDomainGetMaxMemory(virDomainPtr domai
virConnectPtr conn;
DEBUG("domain=%p", domain);
- if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (0);
}
conn = domain->conn;
- if (conn->driver->domainGetMaxMemory)
- return conn->driver->domainGetMaxMemory (domain);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ if (conn->driver->domainGetMaxMemory) {
+ unsigned long ret;
+ ret = conn->driver->domainGetMaxMemory (domain);
+ if (ret == 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
return 0;
}
@@ -2087,28 +2409,37 @@ virDomainSetMaxMemory(virDomainPtr domai
virConnectPtr conn;
DEBUG("domain=%p, memory=%lu", domain, memory);
- if (domain == NULL) {
- TODO
- return (-1);
- }
- if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return (-1);
- }
- if (domain->conn->flags & VIR_CONNECT_RO) {
- virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (-1);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+ if (domain->conn->flags & VIR_CONNECT_RO) {
+ virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ goto error;
}
if (memory < 4096) {
virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
- conn = domain->conn;
-
- if (conn->driver->domainSetMaxMemory)
- return conn->driver->domainSetMaxMemory (domain, memory);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+ conn = domain->conn;
+
+ if (conn->driver->domainSetMaxMemory) {
+ int ret;
+ ret = conn->driver->domainSetMaxMemory (domain, memory);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
return -1;
}
@@ -2130,29 +2461,38 @@ virDomainSetMemory(virDomainPtr domain,
virConnectPtr conn;
DEBUG("domain=%p, memory=%lu", domain, memory);
- if (domain == NULL) {
- TODO
- return (-1);
- }
- if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return (-1);
- }
- if (domain->conn->flags & VIR_CONNECT_RO) {
- virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (-1);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+ if (domain->conn->flags & VIR_CONNECT_RO) {
+ virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ goto error;
}
if (memory < 4096) {
virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
-
- conn = domain->conn;
-
- if (conn->driver->domainSetMemory)
- return conn->driver->domainSetMemory (domain, memory);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ conn = domain->conn;
+
+ if (conn->driver->domainSetMemory) {
+ int ret;
+ ret = conn->driver->domainSetMemory (domain, memory);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
return -1;
}
@@ -2173,23 +2513,36 @@ virDomainGetInfo(virDomainPtr domain, vi
virConnectPtr conn;
DEBUG("domain=%p, info=%p", domain, info);
- if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
if (info == NULL) {
virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
+ goto error;
}
memset(info, 0, sizeof(virDomainInfo));
conn = domain->conn;
- if (conn->driver->domainGetInfo)
- return conn->driver->domainGetInfo (domain, info);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ if (conn->driver->domainGetInfo) {
+ int ret;
+ ret = conn->driver->domainGetInfo (domain, info);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
return -1;
}
@@ -2210,17 +2563,30 @@ virDomainGetXMLDesc(virDomainPtr domain,
virConnectPtr conn;
DEBUG("domain=%p, flags=%d", domain, flags);
- if (!VIR_IS_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return (NULL);
- }
-
- conn = domain->conn;
-
- if (conn->driver->domainDumpXML)
- return conn->driver->domainDumpXML (domain, flags);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
+ return (NULL);
+ }
+
+ conn = domain->conn;
+
+ if (conn->driver->domainDumpXML) {
+ char *ret;
+ ret = conn->driver->domainDumpXML (domain, flags);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
return NULL;
}
@@ -2289,14 +2655,18 @@ virDomainMigrate (virDomainPtr domain,
DEBUG("domain=%p, dconn=%p, flags=%lu, dname=%s, uri=%s, bandwidth=%lu",
domain, dconn, flags, dname, uri, bandwidth);
+ virThreadResetLastError();
+
if (!VIR_IS_DOMAIN (domain)) {
virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return NULL;
}
conn = domain->conn; /* Source connection. */
if (!VIR_IS_CONNECT (dconn)) {
virLibConnError (conn, VIR_ERR_INVALID_CONN, __FUNCTION__);
- return NULL;
+ goto error;
}
/* Check that migration is supported by both drivers. */
@@ -2312,7 +2682,7 @@ virDomainMigrate (virDomainPtr domain,
version = 2;
else {
virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
- return NULL;
+ goto error;
}
/* Prepare the migration.
@@ -2347,13 +2717,13 @@ virDomainMigrate (virDomainPtr domain,
*/
if (!conn->driver->domainDumpXML) {
virLibConnError (conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__);
- return NULL;
+ goto error;
}
dom_xml = conn->driver->domainDumpXML (domain,
VIR_DOMAIN_XML_SECURE);
if (!dom_xml)
- return NULL;
+ goto error;
ret = dconn->driver->domainMigratePrepare2
(dconn, &cookie, &cookielen, uri, &uri_out, flags, dname,
@@ -2403,6 +2773,11 @@ virDomainMigrate (virDomainPtr domain,
free (uri_out);
free (cookie);
return ddomain;
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
+ return NULL;
}
/*
@@ -2421,17 +2796,30 @@ virDomainMigratePrepare (virConnectPtr d
{
DEBUG("dconn=%p, cookie=%p, cookielen=%p, uri_in=%s, uri_out=%p, flags=%lu, dname=%s, bandwidth=%lu", dconn, cookie, cookielen, uri_in, uri_out, flags, dname, bandwidth);
+ virThreadResetLastError();
+
if (!VIR_IS_CONNECT (dconn)) {
virLibConnError (NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
- return -1;
- }
-
- if (dconn->driver->domainMigratePrepare)
- return dconn->driver->domainMigratePrepare (dconn, cookie, cookielen,
- uri_in, uri_out,
- flags, dname, bandwidth);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return -1;
+ }
+
+ if (dconn->driver->domainMigratePrepare) {
+ int ret;
+ ret = dconn->driver->domainMigratePrepare (dconn, cookie, cookielen,
+ uri_in, uri_out,
+ flags, dname, bandwidth);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
virLibConnError (dconn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(dconn);
return -1;
}
@@ -2451,18 +2839,31 @@ virDomainMigratePerform (virDomainPtr do
virConnectPtr conn;
DEBUG("domain=%p, cookie=%p, cookielen=%d, uri=%s, flags=%lu, dname=%s, bandwidth=%lu", domain, cookie, cookielen, uri, flags, dname, bandwidth);
+ virThreadResetLastError();
+
if (!VIR_IS_DOMAIN (domain)) {
virLibDomainError (NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return -1;
- }
- conn = domain->conn;
-
- if (conn->driver->domainMigratePerform)
- return conn->driver->domainMigratePerform (domain, cookie, cookielen,
- uri,
- flags, dname, bandwidth);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
+ return -1;
+ }
+ conn = domain->conn;
+
+ if (conn->driver->domainMigratePerform) {
+ int ret;
+ ret = conn->driver->domainMigratePerform (domain, cookie, cookielen,
+ uri,
+ flags, dname, bandwidth);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
virLibDomainError (domain, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
return -1;
}
@@ -2480,17 +2881,30 @@ virDomainMigrateFinish (virConnectPtr dc
{
DEBUG("dconn=%p, dname=%s, cookie=%p, cookielen=%d, uri=%s, flags=%lu", dconn, dname, cookie, cookielen, uri, flags);
+ virThreadResetLastError();
+
if (!VIR_IS_CONNECT (dconn)) {
virLibConnError (NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
- return NULL;
- }
-
- if (dconn->driver->domainMigrateFinish)
- return dconn->driver->domainMigrateFinish (dconn, dname,
- cookie, cookielen,
- uri, flags);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return NULL;
+ }
+
+ if (dconn->driver->domainMigrateFinish) {
+ virDomainPtr ret;
+ ret = dconn->driver->domainMigrateFinish (dconn, dname,
+ cookie, cookielen,
+ uri, flags);
+ if (!ret)
+ goto error;
+ return ret;
+ }
virLibConnError (dconn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(dconn);
return NULL;
}
@@ -2512,18 +2926,31 @@ virDomainMigratePrepare2 (virConnectPtr
{
DEBUG("dconn=%p, cookie=%p, cookielen=%p, uri_in=%s, uri_out=%p, flags=%lu, dname=%s, bandwidth=%lu, dom_xml=%s", dconn, cookie, cookielen, uri_in, uri_out, flags, dname, bandwidth, dom_xml);
+ virThreadResetLastError();
+
if (!VIR_IS_CONNECT (dconn)) {
virLibConnError (NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
- return -1;
- }
-
- if (dconn->driver->domainMigratePrepare2)
- return dconn->driver->domainMigratePrepare2 (dconn, cookie, cookielen,
- uri_in, uri_out,
- flags, dname, bandwidth,
- dom_xml);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return -1;
+ }
+
+ if (dconn->driver->domainMigratePrepare2) {
+ int ret;
+ ret = dconn->driver->domainMigratePrepare2 (dconn, cookie, cookielen,
+ uri_in, uri_out,
+ flags, dname, bandwidth,
+ dom_xml);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
virLibConnError (dconn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(dconn);
return -1;
}
@@ -2542,18 +2969,31 @@ virDomainMigrateFinish2 (virConnectPtr d
{
DEBUG("dconn=%p, dname=%s, cookie=%p, cookielen=%d, uri=%s, flags=%lu, retcode=%d", dconn, dname, cookie, cookielen, uri, flags, retcode);
+ virThreadResetLastError();
+
if (!VIR_IS_CONNECT (dconn)) {
virLibConnError (NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
- return NULL;
- }
-
- if (dconn->driver->domainMigrateFinish2)
- return dconn->driver->domainMigrateFinish2 (dconn, dname,
- cookie, cookielen,
- uri, flags,
- retcode);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return NULL;
+ }
+
+ if (dconn->driver->domainMigrateFinish2) {
+ virDomainPtr ret;
+ ret = dconn->driver->domainMigrateFinish2 (dconn, dname,
+ cookie, cookielen,
+ uri, flags,
+ retcode);
+ if (!ret)
+ goto error;
+ return ret;
+ }
virLibConnError (dconn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(dconn);
return NULL;
}
@@ -2572,19 +3012,32 @@ virNodeGetInfo(virConnectPtr conn, virNo
{
DEBUG("conn=%p, info=%p", conn, info);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
if (info == NULL) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
-
- if (conn->driver->nodeGetInfo)
- return conn->driver->nodeGetInfo (conn, info);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->driver->nodeGetInfo) {
+ int ret;
+ ret = conn->driver->nodeGetInfo (conn, info);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return -1;
}
@@ -2603,15 +3056,28 @@ virConnectGetCapabilities (virConnectPtr
{
DEBUG("conn=%p", conn);
+ virThreadResetLastError();
+
if (!VIR_IS_CONNECT (conn)) {
virLibConnError (NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
- return NULL;
- }
-
- if (conn->driver->getCapabilities)
- return conn->driver->getCapabilities (conn);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return NULL;
+ }
+
+ if (conn->driver->getCapabilities) {
+ char *ret;
+ ret = conn->driver->getCapabilities (conn);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return NULL;
}
@@ -2628,15 +3094,28 @@ virNodeGetFreeMemory(virConnectPtr conn)
{
DEBUG("conn=%p", conn);
+ virThreadResetLastError();
+
if (!VIR_IS_CONNECT (conn)) {
virLibConnError (NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return 0;
}
- if (conn->driver->getFreeMemory)
- return conn->driver->getFreeMemory (conn);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ if (conn->driver->getFreeMemory) {
+ unsigned long long ret;
+ ret = conn->driver->getFreeMemory (conn);
+ if (ret == 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return 0;
}
@@ -2656,18 +3135,28 @@ virDomainGetSchedulerType(virDomainPtr d
char *schedtype;
DEBUG("domain=%p, nparams=%p", domain, nparams);
- if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return NULL;
}
conn = domain->conn;
if (conn->driver->domainGetSchedulerType){
schedtype = conn->driver->domainGetSchedulerType (domain, nparams);
+ if (!schedtype)
+ goto error;
return schedtype;
}
virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
return NULL;
}
@@ -2693,16 +3182,29 @@ virDomainGetSchedulerParameters(virDomai
virConnectPtr conn;
DEBUG("domain=%p, params=%p, nparams=%p", domain, params, nparams);
- if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return -1;
- }
- conn = domain->conn;
-
- if (conn->driver->domainGetSchedulerParameters)
- return conn->driver->domainGetSchedulerParameters (domain, params, nparams);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return -1;
+ }
+ conn = domain->conn;
+
+ if (conn->driver->domainGetSchedulerParameters) {
+ int ret;
+ ret = conn->driver->domainGetSchedulerParameters (domain, params, nparams);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
return -1;
}
@@ -2725,20 +3227,33 @@ virDomainSetSchedulerParameters(virDomai
virConnectPtr conn;
DEBUG("domain=%p, params=%p, nparams=%d", domain, params, nparams);
- if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return -1;
- }
- if (domain->conn->flags & VIR_CONNECT_RO) {
- virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return -1;
- }
- conn = domain->conn;
-
- if (conn->driver->domainSetSchedulerParameters)
- return conn->driver->domainSetSchedulerParameters (domain, params, nparams);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return -1;
+ }
+ if (domain->conn->flags & VIR_CONNECT_RO) {
+ virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ goto error;
+ }
+ conn = domain->conn;
+
+ if (conn->driver->domainSetSchedulerParameters) {
+ int ret;
+ ret = conn->driver->domainSetSchedulerParameters (domain, params, nparams);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
return -1;
}
@@ -2774,25 +3289,33 @@ virDomainBlockStats (virDomainPtr dom, c
struct _virDomainBlockStats stats2 = { -1, -1, -1, -1, -1 };
DEBUG("domain=%p, path=%s, stats=%p, size=%zi", dom, path, stats, size);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN (dom)) {
+ virLibDomainError (NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return -1;
+ }
if (!stats || size > sizeof stats2) {
virLibDomainError (dom, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return -1;
- }
- if (!VIR_IS_CONNECTED_DOMAIN (dom)) {
- virLibDomainError (NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return -1;
+ goto error;
}
conn = dom->conn;
if (conn->driver->domainBlockStats) {
if (conn->driver->domainBlockStats (dom, path, &stats2) == -1)
- return -1;
+ goto error;
memcpy (stats, &stats2, size);
return 0;
}
virLibDomainError (dom, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(dom->conn);
return -1;
}
@@ -2826,25 +3349,33 @@ virDomainInterfaceStats (virDomainPtr do
-1, -1, -1, -1 };
DEBUG("domain=%p, path=%s, stats=%p, size=%zi", dom, path, stats, size);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN (dom)) {
+ virLibDomainError (NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return -1;
+ }
if (!stats || size > sizeof stats2) {
virLibDomainError (dom, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return -1;
- }
- if (!VIR_IS_CONNECTED_DOMAIN (dom)) {
- virLibDomainError (NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return -1;
+ goto error;
}
conn = dom->conn;
if (conn->driver->domainInterfaceStats) {
if (conn->driver->domainInterfaceStats (dom, path, &stats2) == -1)
- return -1;
+ goto error;
memcpy (stats, &stats2, size);
return 0;
}
virLibDomainError (dom, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(dom->conn);
return -1;
}
@@ -2899,8 +3430,12 @@ virDomainBlockPeek (virDomainPtr dom,
DEBUG("domain=%p, path=%s, offset=%lld, size=%zi, buffer=%p",
dom, path, offset, size, buffer);
+ virThreadResetLastError();
+
if (!VIR_IS_CONNECTED_DOMAIN (dom)) {
virLibDomainError (NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return -1;
}
conn = dom->conn;
@@ -2908,27 +3443,36 @@ virDomainBlockPeek (virDomainPtr dom,
if (!path) {
virLibDomainError (dom, VIR_ERR_INVALID_ARG,
_("path is NULL"));
- return -1;
+ goto error;
}
if (flags != 0) {
virLibDomainError (dom, VIR_ERR_INVALID_ARG,
_("flags must be zero"));
- return -1;
+ goto error;
}
/* Allow size == 0 as an access test. */
if (size > 0 && !buffer) {
virLibDomainError (dom, VIR_ERR_INVALID_ARG,
_("buffer is NULL"));
- return -1;
- }
-
- if (conn->driver->domainBlockPeek)
- return conn->driver->domainBlockPeek (dom, path, offset, size,
- buffer, flags);
+ goto error;
+ }
+
+ if (conn->driver->domainBlockPeek) {
+ int ret;
+ ret =conn->driver->domainBlockPeek (dom, path, offset, size,
+ buffer, flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
virLibDomainError (dom, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(dom->conn);
return -1;
}
@@ -2974,8 +3518,12 @@ virDomainMemoryPeek (virDomainPtr dom,
DEBUG ("domain=%p, start=%lld, size=%zi, buffer=%p, flags=%d",
dom, start, size, buffer, flags);
+ virThreadResetLastError();
+
if (!VIR_IS_CONNECTED_DOMAIN (dom)) {
virLibDomainError (NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return -1;
}
conn = dom->conn;
@@ -3004,21 +3552,30 @@ virDomainMemoryPeek (virDomainPtr dom,
if (flags != VIR_MEMORY_VIRTUAL) {
virLibDomainError (dom, VIR_ERR_INVALID_ARG,
_("flags parameter must be VIR_MEMORY_VIRTUAL"));
- return -1;
+ goto error;
}
/* Allow size == 0 as an access test. */
if (size > 0 && !buffer) {
virLibDomainError (dom, VIR_ERR_INVALID_ARG,
_("buffer is NULL but size is non-zero"));
- return -1;
- }
-
- if (conn->driver->domainMemoryPeek)
- return conn->driver->domainMemoryPeek (dom, start, size,
- buffer, flags);
+ goto error;
+ }
+
+ if (conn->driver->domainMemoryPeek) {
+ int ret;
+ ret = conn->driver->domainMemoryPeek (dom, start, size,
+ buffer, flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
virLibDomainError (dom, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(dom->conn);
return -1;
}
@@ -3044,23 +3601,36 @@ virDomainDefineXML(virConnectPtr conn, c
virDomainDefineXML(virConnectPtr conn, const char *xml) {
DEBUG("conn=%p, xml=%s", conn, xml);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
if (conn->flags & VIR_CONNECT_RO) {
virLibConnError(conn, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (NULL);
+ goto error;
}
if (xml == NULL) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
- }
-
- if (conn->driver->domainDefineXML)
- return conn->driver->domainDefineXML (conn, xml);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->driver->domainDefineXML) {
+ virDomainPtr ret;
+ ret = conn->driver->domainDefineXML (conn, xml);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return NULL;
}
@@ -3077,20 +3647,33 @@ virDomainUndefine(virDomainPtr domain) {
virConnectPtr conn;
DEBUG("domain=%p", domain);
- if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return (-1);
- }
- conn = domain->conn;
- if (conn->flags & VIR_CONNECT_RO) {
- virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (-1);
- }
-
- if (conn->driver->domainUndefine)
- return conn->driver->domainUndefine (domain);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+ conn = domain->conn;
+ if (conn->flags & VIR_CONNECT_RO) {
+ virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->driver->domainUndefine) {
+ int ret;
+ ret = conn->driver->domainUndefine (domain);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
return -1;
}
@@ -3107,15 +3690,28 @@ virConnectNumOfDefinedDomains(virConnect
{
DEBUG("conn=%p", conn);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
- return (-1);
- }
-
- if (conn->driver->numOfDefinedDomains)
- return conn->driver->numOfDefinedDomains (conn);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+
+ if (conn->driver->numOfDefinedDomains) {
+ int ret;
+ ret = conn->driver->numOfDefinedDomains (conn);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return -1;
}
@@ -3135,20 +3731,33 @@ virConnectListDefinedDomains(virConnectP
int maxnames) {
DEBUG("conn=%p, names=%p, maxnames=%d", conn, names, maxnames);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
if ((names == NULL) || (maxnames < 0)) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
-
- if (conn->driver->listDefinedDomains)
- return conn->driver->listDefinedDomains (conn, names, maxnames);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->driver->listDefinedDomains) {
+ int ret;
+ ret = conn->driver->listDefinedDomains (conn, names, maxnames);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return -1;
}
@@ -3166,24 +3775,33 @@ virDomainCreate(virDomainPtr domain) {
virConnectPtr conn;
DEBUG("domain=%p", domain);
- if (domain == NULL) {
- TODO
- return (-1);
- }
- if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return (-1);
- }
- conn = domain->conn;
- if (conn->flags & VIR_CONNECT_RO) {
- virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (-1);
- }
-
- if (conn->driver->domainCreate)
- return conn->driver->domainCreate (domain);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+ conn = domain->conn;
+ if (conn->flags & VIR_CONNECT_RO) {
+ virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->driver->domainCreate) {
+ int ret;
+ ret = conn->driver->domainCreate (domain);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
return -1;
}
@@ -3205,21 +3823,34 @@ virDomainGetAutostart(virDomainPtr domai
virConnectPtr conn;
DEBUG("domain=%p, autostart=%p", domain, autostart);
- if (!VIR_IS_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
if (!autostart) {
virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
-
- conn = domain->conn;
-
- if (conn->driver->domainGetAutostart)
- return conn->driver->domainGetAutostart (domain, autostart);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ conn = domain->conn;
+
+ if (conn->driver->domainGetAutostart) {
+ int ret;
+ ret = conn->driver->domainGetAutostart (domain, autostart);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
return -1;
}
@@ -3240,17 +3871,30 @@ virDomainSetAutostart(virDomainPtr domai
virConnectPtr conn;
DEBUG("domain=%p, autostart=%d", domain, autostart);
- if (!VIR_IS_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return (-1);
- }
-
- conn = domain->conn;
-
- if (conn->driver->domainSetAutostart)
- return conn->driver->domainSetAutostart (domain, autostart);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+
+ conn = domain->conn;
+
+ if (conn->driver->domainSetAutostart) {
+ int ret;
+ ret = conn->driver->domainSetAutostart (domain, autostart);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
return -1;
}
@@ -3273,29 +3917,38 @@ virDomainSetVcpus(virDomainPtr domain, u
virConnectPtr conn;
DEBUG("domain=%p, nvcpus=%u", domain, nvcpus);
- if (domain == NULL) {
- TODO
- return (-1);
- }
- if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return (-1);
- }
- if (domain->conn->flags & VIR_CONNECT_RO) {
- virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (-1);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+ if (domain->conn->flags & VIR_CONNECT_RO) {
+ virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ goto error;
}
if (nvcpus < 1) {
virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
- conn = domain->conn;
-
- if (conn->driver->domainSetVcpus)
- return conn->driver->domainSetVcpus (domain, nvcpus);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+ conn = domain->conn;
+
+ if (conn->driver->domainSetVcpus) {
+ int ret;
+ ret = conn->driver->domainSetVcpus (domain, nvcpus);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
return -1;
}
@@ -3324,30 +3977,39 @@ virDomainPinVcpu(virDomainPtr domain, un
virConnectPtr conn;
DEBUG("domain=%p, vcpu=%u, cpumap=%p, maplen=%d", domain, vcpu, cpumap, maplen);
- if (domain == NULL) {
- TODO
- return (-1);
- }
- if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return (-1);
- }
- if (domain->conn->flags & VIR_CONNECT_RO) {
- virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (-1);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+ if (domain->conn->flags & VIR_CONNECT_RO) {
+ virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ goto error;
}
if ((vcpu > 32000) || (cpumap == NULL) || (maplen < 1)) {
virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
-
- conn = domain->conn;
-
- if (conn->driver->domainPinVcpu)
- return conn->driver->domainPinVcpu (domain, vcpu, cpumap, maplen);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ conn = domain->conn;
+
+ if (conn->driver->domainPinVcpu) {
+ int ret;
+ ret = conn->driver->domainPinVcpu (domain, vcpu, cpumap, maplen);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
return -1;
}
@@ -3379,30 +4041,39 @@ virDomainGetVcpus(virDomainPtr domain, v
virConnectPtr conn;
DEBUG("domain=%p, info=%p, maxinfo=%d, cpumaps=%p, maplen=%d", domain, info, maxinfo, cpumaps, maplen);
- if (domain == NULL) {
- TODO
- return (-1);
- }
- if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
if ((info == NULL) || (maxinfo < 1)) {
virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
+ goto error;
}
if (cpumaps != NULL && maplen < 1) {
virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
-
- conn = domain->conn;
-
- if (conn->driver->domainGetVcpus)
- return conn->driver->domainGetVcpus (domain, info, maxinfo,
- cpumaps, maplen);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ conn = domain->conn;
+
+ if (conn->driver->domainGetVcpus) {
+ int ret;
+ ret = conn->driver->domainGetVcpus (domain, info, maxinfo,
+ cpumaps, maplen);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
return -1;
}
@@ -3424,17 +4095,30 @@ virDomainGetMaxVcpus(virDomainPtr domain
virConnectPtr conn;
DEBUG("domain=%p", domain);
- if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return (-1);
- }
-
- conn = domain->conn;
-
- if (conn->driver->domainGetMaxVcpus)
- return conn->driver->domainGetMaxVcpus (domain);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+
+ conn = domain->conn;
+
+ if (conn->driver->domainGetMaxVcpus) {
+ int ret;
+ ret = conn->driver->domainGetMaxVcpus (domain);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
return -1;
}
@@ -3454,20 +4138,33 @@ virDomainAttachDevice(virDomainPtr domai
virConnectPtr conn;
DEBUG("domain=%p, xml=%s", domain, xml);
- if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return (-1);
- }
- if (domain->conn->flags & VIR_CONNECT_RO) {
- virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (-1);
- }
- conn = domain->conn;
-
- if (conn->driver->domainAttachDevice)
- return conn->driver->domainAttachDevice (domain, xml);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+ if (domain->conn->flags & VIR_CONNECT_RO) {
+ virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ goto error;
+ }
+ conn = domain->conn;
+
+ if (conn->driver->domainAttachDevice) {
+ int ret;
+ ret = conn->driver->domainAttachDevice (domain, xml);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
return -1;
}
@@ -3486,20 +4183,33 @@ virDomainDetachDevice(virDomainPtr domai
virConnectPtr conn;
DEBUG("domain=%p, xml=%s", domain, xml);
- if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
- virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return (-1);
- }
- if (domain->conn->flags & VIR_CONNECT_RO) {
- virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (-1);
- }
- conn = domain->conn;
-
- if (conn->driver->domainDetachDevice)
- return conn->driver->domainDetachDevice (domain, xml);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+ if (domain->conn->flags & VIR_CONNECT_RO) {
+ virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ goto error;
+ }
+ conn = domain->conn;
+
+ if (conn->driver->domainDetachDevice) {
+ int ret;
+ ret = conn->driver->domainDetachDevice (domain, xml);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(domain->conn);
return -1;
}
@@ -3528,20 +4238,33 @@ virNodeGetCellsFreeMemory(virConnectPtr
DEBUG("conn=%p, freeMems=%p, startCell=%d, maxCells=%d",
conn, freeMems, startCell, maxCells);
+ virThreadResetLastError();
+
if (!VIR_IS_CONNECT(conn)) {
virLibConnError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
if ((freeMems == NULL) || (maxCells <= 0) || (startCell < 0)) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
-
- if (conn->driver->nodeGetCellsFreeMemory)
- return conn->driver->nodeGetCellsFreeMemory (conn, freeMems, startCell, maxCells);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->driver->nodeGetCellsFreeMemory) {
+ int ret;
+ ret = conn->driver->nodeGetCellsFreeMemory (conn, freeMems, startCell, maxCells);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return -1;
}
@@ -3564,8 +4287,12 @@ virNetworkGetConnect (virNetworkPtr net)
{
DEBUG("net=%p", net);
+ virThreadResetLastError();
+
if (!VIR_IS_NETWORK (net)) {
virLibNetworkError (NULL, VIR_ERR_INVALID_NETWORK, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return NULL;
}
return net->conn;
@@ -3584,15 +4311,28 @@ virConnectNumOfNetworks(virConnectPtr co
{
DEBUG("conn=%p", conn);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
- return (-1);
- }
-
- if (conn->networkDriver && conn->networkDriver->numOfNetworks)
- return conn->networkDriver->numOfNetworks (conn);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+
+ if (conn->networkDriver && conn->networkDriver->numOfNetworks) {
+ int ret;
+ ret = conn->networkDriver->numOfNetworks (conn);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return -1;
}
@@ -3611,20 +4351,33 @@ virConnectListNetworks(virConnectPtr con
{
DEBUG("conn=%p, names=%p, maxnames=%d", conn, names, maxnames);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
if ((names == NULL) || (maxnames < 0)) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
-
- if (conn->networkDriver && conn->networkDriver->listNetworks)
- return conn->networkDriver->listNetworks (conn, names, maxnames);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->networkDriver && conn->networkDriver->listNetworks) {
+ int ret;
+ ret = conn->networkDriver->listNetworks (conn, names, maxnames);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return -1;
}
@@ -3641,15 +4394,28 @@ virConnectNumOfDefinedNetworks(virConnec
{
DEBUG("conn=%p", conn);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
- return (-1);
- }
-
- if (conn->networkDriver && conn->networkDriver->numOfDefinedNetworks)
- return conn->networkDriver->numOfDefinedNetworks (conn);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+
+ if (conn->networkDriver && conn->networkDriver->numOfDefinedNetworks) {
+ int ret;
+ ret = conn->networkDriver->numOfDefinedNetworks (conn);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return -1;
}
@@ -3669,21 +4435,34 @@ virConnectListDefinedNetworks(virConnect
{
DEBUG("conn=%p, names=%p, maxnames=%d", conn, names, maxnames);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
if ((names == NULL) || (maxnames < 0)) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
-
- if (conn->networkDriver && conn->networkDriver->listDefinedNetworks)
- return conn->networkDriver->listDefinedNetworks (conn,
- names, maxnames);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->networkDriver && conn->networkDriver->listDefinedNetworks) {
+ int ret;
+ ret = conn->networkDriver->listDefinedNetworks (conn,
+ names, maxnames);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return -1;
}
@@ -3702,19 +4481,32 @@ virNetworkLookupByName(virConnectPtr con
{
DEBUG("conn=%p, name=%s", conn, name);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
if (name == NULL) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
- }
-
- if (conn->networkDriver && conn->networkDriver->networkLookupByName)
- return conn->networkDriver->networkLookupByName (conn, name);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->networkDriver && conn->networkDriver->networkLookupByName) {
+ virNetworkPtr ret;
+ ret = conn->networkDriver->networkLookupByName (conn, name);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return NULL;
}
@@ -3733,19 +4525,32 @@ virNetworkLookupByUUID(virConnectPtr con
{
DEBUG("conn=%p, uuid=%s", conn, uuid);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
if (uuid == NULL) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
- }
-
- if (conn->networkDriver && conn->networkDriver->networkLookupByUUID)
- return conn->networkDriver->networkLookupByUUID (conn, uuid);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->networkDriver && conn->networkDriver->networkLookupByUUID){
+ virNetworkPtr ret;
+ ret = conn->networkDriver->networkLookupByUUID (conn, uuid);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return NULL;
}
@@ -3767,13 +4572,17 @@ virNetworkLookupByUUIDString(virConnectP
int ret;
DEBUG("conn=%p, uuidstr=%s", conn, uuidstr);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
if (uuidstr == NULL) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
+ goto error;
}
/* XXX: sexpr_uuid() also supports 'xxxx-xxxx-xxxx-xxxx' format.
@@ -3792,12 +4601,17 @@ virNetworkLookupByUUIDString(virConnectP
if (ret!=VIR_UUID_BUFLEN) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
+ goto error;
}
for (i = 0; i < VIR_UUID_BUFLEN; i++)
uuid[i] = raw[i] & 0xFF;
return virNetworkLookupByUUID(conn, &uuid[0]);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
+ return NULL;
}
/**
@@ -3815,23 +4629,36 @@ virNetworkCreateXML(virConnectPtr conn,
{
DEBUG("conn=%p, xmlDesc=%s", conn, xmlDesc);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
if (xmlDesc == NULL) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
+ goto error;
}
if (conn->flags & VIR_CONNECT_RO) {
virLibConnError(conn, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (NULL);
- }
-
- if (conn->networkDriver && conn->networkDriver->networkCreateXML)
- return conn->networkDriver->networkCreateXML (conn, xmlDesc);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->networkDriver && conn->networkDriver->networkCreateXML) {
+ virNetworkPtr ret;
+ ret = conn->networkDriver->networkCreateXML (conn, xmlDesc);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return NULL;
}
@@ -3849,23 +4676,36 @@ virNetworkDefineXML(virConnectPtr conn,
{
DEBUG("conn=%p, xml=%s", conn, xml);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
if (conn->flags & VIR_CONNECT_RO) {
virLibConnError(conn, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (NULL);
+ goto error;
}
if (xml == NULL) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
- }
-
- if (conn->networkDriver && conn->networkDriver->networkDefineXML)
- return conn->networkDriver->networkDefineXML (conn, xml);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->networkDriver && conn->networkDriver->networkDefineXML) {
+ virNetworkPtr ret;
+ ret = conn->networkDriver->networkDefineXML (conn, xml);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return NULL;
}
@@ -3882,20 +4722,33 @@ virNetworkUndefine(virNetworkPtr network
virConnectPtr conn;
DEBUG("network=%p", network);
+ virThreadResetLastError();
+
if (!VIR_IS_CONNECTED_NETWORK(network)) {
virLibNetworkError(NULL, VIR_ERR_INVALID_NETWORK, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
conn = network->conn;
if (conn->flags & VIR_CONNECT_RO) {
virLibNetworkError(network, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (-1);
- }
-
- if (conn->networkDriver && conn->networkDriver->networkUndefine)
- return conn->networkDriver->networkUndefine (network);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->networkDriver && conn->networkDriver->networkUndefine) {
+ int ret;
+ ret = conn->networkDriver->networkUndefine (network);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(network->conn);
return -1;
}
@@ -3914,24 +4767,33 @@ virNetworkCreate(virNetworkPtr network)
virConnectPtr conn;
DEBUG("network=%p", network);
- if (network == NULL) {
- TODO
- return (-1);
- }
+ virThreadResetLastError();
+
if (!VIR_IS_CONNECTED_NETWORK(network)) {
virLibNetworkError(NULL, VIR_ERR_INVALID_NETWORK, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
conn = network->conn;
if (conn->flags & VIR_CONNECT_RO) {
virLibNetworkError(network, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (-1);
- }
-
- if (conn->networkDriver && conn->networkDriver->networkCreate)
- return conn->networkDriver->networkCreate (network);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->networkDriver && conn->networkDriver->networkCreate) {
+ int ret;
+ ret = conn->networkDriver->networkCreate (network);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(network->conn);
return -1;
}
@@ -3952,21 +4814,34 @@ virNetworkDestroy(virNetworkPtr network)
virConnectPtr conn;
DEBUG("network=%p", network);
+ virThreadResetLastError();
+
if (!VIR_IS_CONNECTED_NETWORK(network)) {
virLibNetworkError(NULL, VIR_ERR_INVALID_NETWORK, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
conn = network->conn;
if (conn->flags & VIR_CONNECT_RO) {
virLibNetworkError(network, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (-1);
- }
-
- if (conn->networkDriver && conn->networkDriver->networkDestroy)
- return conn->networkDriver->networkDestroy (network);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->networkDriver && conn->networkDriver->networkDestroy) {
+ int ret;
+ ret = conn->networkDriver->networkDestroy (network);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(network->conn);
return -1;
}
@@ -3984,12 +4859,19 @@ virNetworkFree(virNetworkPtr network)
{
DEBUG("network=%p", network);
- if (!VIR_IS_NETWORK(network)) {
- virLibNetworkError(NULL, VIR_ERR_INVALID_NETWORK, __FUNCTION__);
- return (-1);
- }
- if (virUnrefNetwork(network) < 0)
- return (-1);
+ virThreadResetLastError();
+
+ if (!VIR_IS_NETWORK(network)) {
+ virLibNetworkError(NULL, VIR_ERR_INVALID_NETWORK, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+ if (virUnrefNetwork(network) < 0) {
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
return(0);
}
@@ -4007,8 +4889,12 @@ virNetworkGetName(virNetworkPtr network)
{
DEBUG("network=%p", network);
- if (!VIR_IS_NETWORK(network)) {
- virLibNetworkError(NULL, VIR_ERR_INVALID_NETWORK, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_NETWORK(network)) {
+ virLibNetworkError(NULL, VIR_ERR_INVALID_NETWORK, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
return (network->name);
@@ -4028,18 +4914,27 @@ virNetworkGetUUID(virNetworkPtr network,
{
DEBUG("network=%p, uuid=%p", network, uuid);
- if (!VIR_IS_NETWORK(network)) {
- virLibNetworkError(NULL, VIR_ERR_INVALID_NETWORK, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_NETWORK(network)) {
+ virLibNetworkError(NULL, VIR_ERR_INVALID_NETWORK, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
if (uuid == NULL) {
virLibNetworkError(network, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
+ goto error;
}
memcpy(uuid, &network->uuid[0], VIR_UUID_BUFLEN);
return (0);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(network->conn);
+ return -1;
}
/**
@@ -4058,13 +4953,17 @@ virNetworkGetUUIDString(virNetworkPtr ne
unsigned char uuid[VIR_UUID_BUFLEN];
DEBUG("network=%p, buf=%p", network, buf);
- if (!VIR_IS_NETWORK(network)) {
- virLibNetworkError(NULL, VIR_ERR_INVALID_NETWORK, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_NETWORK(network)) {
+ virLibNetworkError(NULL, VIR_ERR_INVALID_NETWORK, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
if (buf == NULL) {
virLibNetworkError(network, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
+ goto error;
}
if (virNetworkGetUUID(network, &uuid[0]))
@@ -4072,6 +4971,11 @@ virNetworkGetUUIDString(virNetworkPtr ne
virUUIDFormat(uuid, buf);
return (0);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(network->conn);
+ return -1;
}
/**
@@ -4091,21 +4995,34 @@ virNetworkGetXMLDesc(virNetworkPtr netwo
virConnectPtr conn;
DEBUG("network=%p, flags=%d", network, flags);
- if (!VIR_IS_NETWORK(network)) {
- virLibNetworkError(NULL, VIR_ERR_INVALID_NETWORK, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_NETWORK(network)) {
+ virLibNetworkError(NULL, VIR_ERR_INVALID_NETWORK, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
if (flags != 0) {
virLibNetworkError(network, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
+ goto error;
}
conn = network->conn;
- if (conn->networkDriver && conn->networkDriver->networkDumpXML)
- return conn->networkDriver->networkDumpXML (network, flags);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ if (conn->networkDriver && conn->networkDriver->networkDumpXML) {
+ char *ret;
+ ret = conn->networkDriver->networkDumpXML (network, flags);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(network->conn);
return NULL;
}
@@ -4125,17 +5042,30 @@ virNetworkGetBridgeName(virNetworkPtr ne
virConnectPtr conn;
DEBUG("network=%p", network);
- if (!VIR_IS_NETWORK(network)) {
- virLibNetworkError(NULL, VIR_ERR_INVALID_NETWORK, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_NETWORK(network)) {
+ virLibNetworkError(NULL, VIR_ERR_INVALID_NETWORK, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
conn = network->conn;
- if (conn->networkDriver && conn->networkDriver->networkGetBridgeName)
- return conn->networkDriver->networkGetBridgeName (network);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ if (conn->networkDriver && conn->networkDriver->networkGetBridgeName) {
+ char *ret;
+ ret = conn->networkDriver->networkGetBridgeName (network);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(network->conn);
return NULL;
}
@@ -4157,21 +5087,34 @@ virNetworkGetAutostart(virNetworkPtr net
virConnectPtr conn;
DEBUG("network=%p, autostart=%p", network, autostart);
- if (!VIR_IS_NETWORK(network)) {
- virLibNetworkError(NULL, VIR_ERR_INVALID_NETWORK, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_NETWORK(network)) {
+ virLibNetworkError(NULL, VIR_ERR_INVALID_NETWORK, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
if (!autostart) {
virLibNetworkError(network, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
+ goto error;
}
conn = network->conn;
- if (conn->networkDriver && conn->networkDriver->networkGetAutostart)
- return conn->networkDriver->networkGetAutostart (network, autostart);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ if (conn->networkDriver && conn->networkDriver->networkGetAutostart) {
+ int ret;
+ ret = conn->networkDriver->networkGetAutostart (network, autostart);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(network->conn);
return -1;
}
@@ -4192,17 +5135,30 @@ virNetworkSetAutostart(virNetworkPtr net
virConnectPtr conn;
DEBUG("network=%p, autostart=%d", network, autostart);
- if (!VIR_IS_NETWORK(network)) {
- virLibNetworkError(NULL, VIR_ERR_INVALID_NETWORK, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_NETWORK(network)) {
+ virLibNetworkError(NULL, VIR_ERR_INVALID_NETWORK, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
conn = network->conn;
- if (conn->networkDriver && conn->networkDriver->networkSetAutostart)
- return conn->networkDriver->networkSetAutostart (network, autostart);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ if (conn->networkDriver && conn->networkDriver->networkSetAutostart) {
+ int ret;
+ ret = conn->networkDriver->networkSetAutostart (network, autostart);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(network->conn);
return -1;
}
@@ -4226,8 +5182,12 @@ virStoragePoolGetConnect (virStoragePool
{
DEBUG("pool=%p", pool);
+ virThreadResetLastError();
+
if (!VIR_IS_STORAGE_POOL (pool)) {
virLibStoragePoolError (NULL, VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return NULL;
}
return pool->conn;
@@ -4246,15 +5206,28 @@ virConnectNumOfStoragePools (virConnectP
{
DEBUG("conn=%p", conn);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
- return (-1);
- }
-
- if (conn->storageDriver && conn->storageDriver->numOfPools)
- return conn->storageDriver->numOfPools (conn);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+
+ if (conn->storageDriver && conn->storageDriver->numOfPools) {
+ int ret;
+ ret = conn->storageDriver->numOfPools (conn);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return -1;
}
@@ -4277,22 +5250,34 @@ virConnectListStoragePools (virConnectPt
{
DEBUG("conn=%p, names=%p, maxnames=%d", conn, names, maxnames);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
if ((names == NULL) || (maxnames < 0)) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
-
- if (conn->storageDriver && conn->storageDriver->listPools)
- return conn->storageDriver->listPools (conn, names, maxnames);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
- return -1;
-
+ goto error;
+ }
+
+ if (conn->storageDriver && conn->storageDriver->listPools) {
+ int ret;
+ ret = conn->storageDriver->listPools (conn, names, maxnames);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
+ return -1;
}
@@ -4309,15 +5294,28 @@ virConnectNumOfDefinedStoragePools(virCo
{
DEBUG("conn=%p", conn);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
- return (-1);
- }
-
- if (conn->storageDriver && conn->storageDriver->numOfDefinedPools)
- return conn->storageDriver->numOfDefinedPools (conn);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+
+ if (conn->storageDriver && conn->storageDriver->numOfDefinedPools) {
+ int ret;
+ ret = conn->storageDriver->numOfDefinedPools (conn);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return -1;
}
@@ -4341,20 +5339,33 @@ virConnectListDefinedStoragePools(virCon
{
DEBUG("conn=%p, names=%p, maxnames=%d", conn, names, maxnames);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
if ((names == NULL) || (maxnames < 0)) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
-
- if (conn->storageDriver && conn->storageDriver->listDefinedPools)
- return conn->storageDriver->listDefinedPools (conn, names, maxnames);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->storageDriver && conn->storageDriver->listDefinedPools) {
+ int ret;
+ ret = conn->storageDriver->listDefinedPools (conn, names, maxnames);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return -1;
}
@@ -4386,19 +5397,34 @@ virConnectFindStoragePoolSources(virConn
const char *srcSpec,
unsigned int flags)
{
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ DEBUG("conn=%p, type=%s, src=%s, flags=%u", conn, type ? type : "", srcSpec ? srcSpec : "", flags);
+
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return NULL;
}
if (type == NULL) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return NULL;
- }
-
- if (conn->storageDriver && conn->storageDriver->findPoolSources)
- return conn->storageDriver->findPoolSources(conn, type, srcSpec, flags);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->storageDriver && conn->storageDriver->findPoolSources) {
+ char *ret;
+ ret = conn->storageDriver->findPoolSources(conn, type, srcSpec, flags);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return NULL;
}
@@ -4418,19 +5444,32 @@ virStoragePoolLookupByName(virConnectPtr
{
DEBUG("conn=%p, name=%s", conn, name);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
if (name == NULL) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
- }
-
- if (conn->storageDriver && conn->storageDriver->poolLookupByName)
- return conn->storageDriver->poolLookupByName (conn, name);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->storageDriver && conn->storageDriver->poolLookupByName) {
+ virStoragePoolPtr ret;
+ ret = conn->storageDriver->poolLookupByName (conn, name);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return NULL;
}
@@ -4450,21 +5489,33 @@ virStoragePoolLookupByUUID(virConnectPtr
{
DEBUG("conn=%p, uuid=%s", conn, uuid);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
if (uuid == NULL) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
- }
-
- if (conn->storageDriver && conn->storageDriver->poolLookupByUUID)
- return conn->storageDriver->poolLookupByUUID (conn, uuid);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
- return NULL;
-
+ goto error;
+ }
+
+ if (conn->storageDriver && conn->storageDriver->poolLookupByUUID) {
+ virStoragePoolPtr ret;
+ ret = conn->storageDriver->poolLookupByUUID (conn, uuid);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
+ return NULL;
}
@@ -4479,26 +5530,35 @@ virStoragePoolLookupByUUID(virConnectPtr
*/
virStoragePoolPtr
virStoragePoolLookupByUUIDString(virConnectPtr conn,
- const char *uuidstr)
+ const char *uuidstr)
{
unsigned char uuid[VIR_UUID_BUFLEN];
DEBUG("conn=%p, uuidstr=%s", conn, uuidstr);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
if (uuidstr == NULL) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
+ goto error;
}
if (virUUIDParse(uuidstr, uuid) < 0) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
+ goto error;
}
return virStoragePoolLookupByUUID(conn, uuid);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
+ return NULL;
}
@@ -4515,17 +5575,29 @@ virStoragePoolLookupByVolume(virStorageV
{
DEBUG("vol=%p", vol);
+ virThreadResetLastError();
+
if (!VIR_IS_STORAGE_VOL(vol)) {
virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
- return (NULL);
- }
-
- if (vol->conn->storageDriver && vol->conn->storageDriver->poolLookupByVolume)
- return vol->conn->storageDriver->poolLookupByVolume (vol);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
+ return (NULL);
+ }
+
+ if (vol->conn->storageDriver && vol->conn->storageDriver->poolLookupByVolume) {
+ virStoragePoolPtr ret;
+ ret = vol->conn->storageDriver->poolLookupByVolume (vol);
+ if (!ret)
+ goto error;
+ return ret;
+ }
virLibConnError (vol->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
- return NULL;
-
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(vol->conn);
+ return NULL;
}
/**
@@ -4547,23 +5619,36 @@ virStoragePoolCreateXML(virConnectPtr co
{
DEBUG("conn=%p, xmlDesc=%s", conn, xmlDesc);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
if (xmlDesc == NULL) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
+ goto error;
}
if (conn->flags & VIR_CONNECT_RO) {
virLibConnError(conn, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (NULL);
- }
-
- if (conn->storageDriver && conn->storageDriver->poolCreateXML)
- return conn->storageDriver->poolCreateXML (conn, xmlDesc, flags);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->storageDriver && conn->storageDriver->poolCreateXML) {
+ virStoragePoolPtr ret;
+ ret = conn->storageDriver->poolCreateXML (conn, xmlDesc, flags);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return NULL;
}
@@ -4585,25 +5670,37 @@ virStoragePoolDefineXML(virConnectPtr co
{
DEBUG("conn=%p, xml=%s", conn, xml);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
if (conn->flags & VIR_CONNECT_RO) {
virLibConnError(conn, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (NULL);
+ goto error;
}
if (xml == NULL) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
- }
-
- if (conn->storageDriver && conn->storageDriver->poolDefineXML)
- return conn->storageDriver->poolDefineXML (conn, xml, flags);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
- return NULL;
-
+ goto error;
+ }
+
+ if (conn->storageDriver && conn->storageDriver->poolDefineXML) {
+ virStoragePoolPtr ret;
+ ret = conn->storageDriver->poolDefineXML (conn, xml, flags);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
+ return NULL;
}
/**
@@ -4622,22 +5719,34 @@ virStoragePoolBuild(virStoragePoolPtr po
virConnectPtr conn;
DEBUG("pool=%p, flags=%u", pool, flags);
+ virThreadResetLastError();
+
if (!VIR_IS_CONNECTED_STORAGE_POOL(pool)) {
virLibStoragePoolError(NULL, VIR_ERR_INVALID_NETWORK, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
conn = pool->conn;
if (conn->flags & VIR_CONNECT_RO) {
virLibStoragePoolError(pool, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (-1);
- }
-
- if (conn->storageDriver && conn->storageDriver->poolBuild)
- return conn->storageDriver->poolBuild (pool, flags);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
- return -1;
-
+ goto error;
+ }
+
+ if (conn->storageDriver && conn->storageDriver->poolBuild) {
+ int ret;
+ ret = conn->storageDriver->poolBuild (pool, flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(pool->conn);
+ return -1;
}
@@ -4654,23 +5763,35 @@ virStoragePoolUndefine(virStoragePoolPtr
{
virConnectPtr conn;
DEBUG("pool=%p", pool);
+
+ virThreadResetLastError();
if (!VIR_IS_CONNECTED_STORAGE_POOL(pool)) {
virLibStoragePoolError(NULL, VIR_ERR_INVALID_NETWORK, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
conn = pool->conn;
if (conn->flags & VIR_CONNECT_RO) {
virLibStoragePoolError(pool, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (-1);
- }
-
- if (conn->storageDriver && conn->storageDriver->poolUndefine)
- return conn->storageDriver->poolUndefine (pool);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
- return -1;
-
+ goto error;
+ }
+
+ if (conn->storageDriver && conn->storageDriver->poolUndefine) {
+ int ret;
+ ret = conn->storageDriver->poolUndefine (pool);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(pool->conn);
+ return -1;
}
@@ -4690,26 +5811,34 @@ virStoragePoolCreate(virStoragePoolPtr p
virConnectPtr conn;
DEBUG("pool=%p", pool);
- if (pool == NULL) {
- TODO;
- return (-1);
- }
+ virThreadResetLastError();
+
if (!VIR_IS_CONNECTED_STORAGE_POOL(pool)) {
virLibStoragePoolError(NULL, VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
conn = pool->conn;
if (conn->flags & VIR_CONNECT_RO) {
virLibStoragePoolError(pool, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (-1);
- }
-
- if (conn->storageDriver && conn->storageDriver->poolCreate)
- return conn->storageDriver->poolCreate (pool, flags);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
- return -1;
-
+ goto error;
+ }
+
+ if (conn->storageDriver && conn->storageDriver->poolCreate) {
+ int ret;
+ ret = conn->storageDriver->poolCreate (pool, flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(pool->conn);
+ return -1;
}
@@ -4731,21 +5860,34 @@ virStoragePoolDestroy(virStoragePoolPtr
virConnectPtr conn;
DEBUG("pool=%p", pool);
+ virThreadResetLastError();
+
if (!VIR_IS_CONNECTED_STORAGE_POOL(pool)) {
virLibStoragePoolError(NULL, VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
conn = pool->conn;
if (conn->flags & VIR_CONNECT_RO) {
virLibStoragePoolError(pool, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (-1);
- }
-
- if (conn->storageDriver && conn->storageDriver->poolDestroy)
- return conn->storageDriver->poolDestroy (pool);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->storageDriver && conn->storageDriver->poolDestroy) {
+ int ret;
+ ret = conn->storageDriver->poolDestroy (pool);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(pool->conn);
return -1;
}
@@ -4767,21 +5909,34 @@ virStoragePoolDelete(virStoragePoolPtr p
virConnectPtr conn;
DEBUG("pool=%p, flags=%u", pool, flags);
+ virThreadResetLastError();
+
if (!VIR_IS_CONNECTED_STORAGE_POOL(pool)) {
virLibStoragePoolError(NULL, VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
conn = pool->conn;
if (conn->flags & VIR_CONNECT_RO) {
virLibStoragePoolError(pool, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (-1);
- }
-
- if (conn->storageDriver && conn->storageDriver->poolDelete)
- return conn->storageDriver->poolDelete (pool, flags);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->storageDriver && conn->storageDriver->poolDelete) {
+ int ret;
+ ret = conn->storageDriver->poolDelete (pool, flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(pool->conn);
return -1;
}
@@ -4800,12 +5955,19 @@ virStoragePoolFree(virStoragePoolPtr poo
{
DEBUG("pool=%p", pool);
- if (!VIR_IS_STORAGE_POOL(pool)) {
- virLibStoragePoolError(NULL, VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__);
- return (-1);
- }
- if (virUnrefStoragePool(pool) < 0)
- return (-1);
+ virThreadResetLastError();
+
+ if (!VIR_IS_STORAGE_POOL(pool)) {
+ virLibStoragePoolError(NULL, VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+ if (virUnrefStoragePool(pool) < 0) {
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
return(0);
}
@@ -4829,21 +5991,34 @@ virStoragePoolRefresh(virStoragePoolPtr
virConnectPtr conn;
DEBUG("pool=%p flags=%u", pool, flags);
+ virThreadResetLastError();
+
if (!VIR_IS_CONNECTED_STORAGE_POOL(pool)) {
virLibStoragePoolError(NULL, VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
conn = pool->conn;
if (conn->flags & VIR_CONNECT_RO) {
virLibStoragePoolError(pool, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (-1);
- }
-
- if (conn->storageDriver && conn->storageDriver->poolRefresh)
- return conn->storageDriver->poolRefresh (pool, flags);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->storageDriver && conn->storageDriver->poolRefresh) {
+ int ret;
+ ret = conn->storageDriver->poolRefresh (pool, flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(pool->conn);
return -1;
}
@@ -4861,12 +6036,15 @@ virStoragePoolGetName(virStoragePoolPtr
{
DEBUG("pool=%p", pool);
- if (!VIR_IS_STORAGE_POOL(pool)) {
- virLibStoragePoolError(NULL, VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_STORAGE_POOL(pool)) {
+ virLibStoragePoolError(NULL, VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
return (pool->name);
-
}
@@ -4885,19 +6063,27 @@ virStoragePoolGetUUID(virStoragePoolPtr
{
DEBUG("pool=%p, uuid=%p", pool, uuid);
- if (!VIR_IS_STORAGE_POOL(pool)) {
- virLibStoragePoolError(NULL, VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_STORAGE_POOL(pool)) {
+ virLibStoragePoolError(NULL, VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
if (uuid == NULL) {
virLibStoragePoolError(pool, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
+ goto error;
}
memcpy(uuid, &pool->uuid[0], VIR_UUID_BUFLEN);
return (0);
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(pool->conn);
+ return -1;
}
/**
@@ -4916,21 +6102,29 @@ virStoragePoolGetUUIDString(virStoragePo
unsigned char uuid[VIR_UUID_BUFLEN];
DEBUG("pool=%p, buf=%p", pool, buf);
- if (!VIR_IS_STORAGE_POOL(pool)) {
- virLibStoragePoolError(NULL, VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_STORAGE_POOL(pool)) {
+ virLibStoragePoolError(NULL, VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
if (buf == NULL) {
virLibStoragePoolError(pool, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
+ goto error;
}
if (virStoragePoolGetUUID(pool, &uuid[0]))
- return (-1);
+ goto error;
virUUIDFormat(uuid, buf);
return (0);
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(pool->conn);
+ return -1;
}
@@ -4951,25 +6145,37 @@ virStoragePoolGetInfo(virStoragePoolPtr
virConnectPtr conn;
DEBUG("pool=%p, info=%p", pool, info);
+ virThreadResetLastError();
+
if (!VIR_IS_CONNECTED_STORAGE_POOL(pool)) {
virLibStoragePoolError(NULL, VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
if (info == NULL) {
virLibStoragePoolError(pool, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
+ goto error;
}
memset(info, 0, sizeof(virStoragePoolInfo));
conn = pool->conn;
- if (conn->storageDriver->poolGetInfo)
- return conn->storageDriver->poolGetInfo (pool, info);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
- return -1;
-
+ if (conn->storageDriver->poolGetInfo) {
+ int ret;
+ ret = conn->storageDriver->poolGetInfo (pool, info);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(pool->conn);
+ return -1;
}
@@ -4991,23 +6197,35 @@ virStoragePoolGetXMLDesc(virStoragePoolP
virConnectPtr conn;
DEBUG("pool=%p, flags=%u", pool, flags);
- if (!VIR_IS_STORAGE_POOL(pool)) {
- virLibStoragePoolError(NULL, VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_STORAGE_POOL(pool)) {
+ virLibStoragePoolError(NULL, VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
if (flags != 0) {
virLibStoragePoolError(pool, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
- }
-
- conn = pool->conn;
-
- if (conn->storageDriver && conn->storageDriver->poolGetXMLDesc)
- return conn->storageDriver->poolGetXMLDesc (pool, flags);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
- return NULL;
-
+ goto error;
+ }
+
+ conn = pool->conn;
+
+ if (conn->storageDriver && conn->storageDriver->poolGetXMLDesc) {
+ char *ret;
+ ret = conn->storageDriver->poolGetXMLDesc (pool, flags);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(pool->conn);
+ return NULL;
}
@@ -5028,21 +6246,34 @@ virStoragePoolGetAutostart(virStoragePoo
virConnectPtr conn;
DEBUG("pool=%p, autostart=%p", pool, autostart);
- if (!VIR_IS_STORAGE_POOL(pool)) {
- virLibStoragePoolError(NULL, VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_STORAGE_POOL(pool)) {
+ virLibStoragePoolError(NULL, VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
if (!autostart) {
virLibStoragePoolError(pool, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
-
- conn = pool->conn;
-
- if (conn->storageDriver && conn->storageDriver->poolGetAutostart)
- return conn->storageDriver->poolGetAutostart (pool, autostart);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ conn = pool->conn;
+
+ if (conn->storageDriver && conn->storageDriver->poolGetAutostart) {
+ int ret;
+ ret = conn->storageDriver->poolGetAutostart (pool, autostart);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(pool->conn);
return -1;
}
@@ -5063,17 +6294,30 @@ virStoragePoolSetAutostart(virStoragePoo
virConnectPtr conn;
DEBUG("pool=%p, autostart=%d", pool, autostart);
- if (!VIR_IS_STORAGE_POOL(pool)) {
- virLibStoragePoolError(NULL, VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__);
- return (-1);
- }
-
- conn = pool->conn;
-
- if (conn->storageDriver && conn->storageDriver->poolSetAutostart)
- return conn->storageDriver->poolSetAutostart (pool, autostart);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_STORAGE_POOL(pool)) {
+ virLibStoragePoolError(NULL, VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+
+ conn = pool->conn;
+
+ if (conn->storageDriver && conn->storageDriver->poolSetAutostart) {
+ int ret;
+ ret = conn->storageDriver->poolSetAutostart (pool, autostart);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(pool->conn);
return -1;
}
@@ -5091,15 +6335,28 @@ virStoragePoolNumOfVolumes(virStoragePoo
{
DEBUG("pool=%p", pool);
+ virThreadResetLastError();
+
if (!VIR_IS_STORAGE_POOL(pool)) {
virLibConnError(NULL, VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__);
- return (-1);
- }
-
- if (pool->conn->storageDriver && pool->conn->storageDriver->poolNumOfVolumes)
- return pool->conn->storageDriver->poolNumOfVolumes (pool);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+
+ if (pool->conn->storageDriver && pool->conn->storageDriver->poolNumOfVolumes) {
+ int ret;
+ ret = pool->conn->storageDriver->poolNumOfVolumes (pool);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
virLibConnError (pool->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(pool->conn);
return -1;
}
@@ -5122,20 +6379,33 @@ virStoragePoolListVolumes(virStoragePool
{
DEBUG("pool=%p, names=%p, maxnames=%d", pool, names, maxnames);
+ virThreadResetLastError();
+
if (!VIR_IS_STORAGE_POOL(pool)) {
virLibConnError(NULL, VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
if ((names == NULL) || (maxnames < 0)) {
virLibConnError(pool->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
-
- if (pool->conn->storageDriver && pool->conn->storageDriver->poolListVolumes)
- return pool->conn->storageDriver->poolListVolumes (pool, names, maxnames);
+ goto error;
+ }
+
+ if (pool->conn->storageDriver && pool->conn->storageDriver->poolListVolumes) {
+ int ret;
+ ret = pool->conn->storageDriver->poolListVolumes (pool, names, maxnames);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
virLibConnError (pool->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(pool->conn);
return -1;
}
@@ -5159,8 +6429,12 @@ virStorageVolGetConnect (virStorageVolPt
{
DEBUG("vol=%p", vol);
+ virThreadResetLastError();
+
if (!VIR_IS_STORAGE_VOL (vol)) {
virLibStoragePoolError (NULL, VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return NULL;
}
return vol->conn;
@@ -5183,19 +6457,32 @@ virStorageVolLookupByName(virStoragePool
{
DEBUG("pool=%p, name=%s", pool, name);
- if (!VIR_IS_STORAGE_POOL(pool)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_STORAGE_POOL(pool)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
if (name == NULL) {
virLibConnError(pool->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
- }
-
- if (pool->conn->storageDriver && pool->conn->storageDriver->volLookupByName)
- return pool->conn->storageDriver->volLookupByName (pool, name);
+ goto error;
+ }
+
+ if (pool->conn->storageDriver && pool->conn->storageDriver->volLookupByName) {
+ virStorageVolPtr ret;
+ ret = pool->conn->storageDriver->volLookupByName (pool, name);
+ if (!ret)
+ goto error;
+ return ret;
+ }
virLibConnError (pool->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(pool->conn);
return NULL;
}
@@ -5217,19 +6504,32 @@ virStorageVolLookupByKey(virConnectPtr c
{
DEBUG("conn=%p, key=%s", conn, key);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
if (key == NULL) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
- }
-
- if (conn->storageDriver && conn->storageDriver->volLookupByKey)
- return conn->storageDriver->volLookupByKey (conn, key);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->storageDriver && conn->storageDriver->volLookupByKey) {
+ virStorageVolPtr ret;
+ ret = conn->storageDriver->volLookupByKey (conn, key);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return NULL;
}
@@ -5249,19 +6549,32 @@ virStorageVolLookupByPath(virConnectPtr
{
DEBUG("conn=%p, path=%s", conn, path);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
if (path == NULL) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
- }
-
- if (conn->storageDriver && conn->storageDriver->volLookupByPath)
- return conn->storageDriver->volLookupByPath (conn, path);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->storageDriver && conn->storageDriver->volLookupByPath) {
+ virStorageVolPtr ret;
+ ret = conn->storageDriver->volLookupByPath (conn, path);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return NULL;
}
@@ -5280,8 +6593,12 @@ virStorageVolGetName(virStorageVolPtr vo
{
DEBUG("vol=%p", vol);
+ virThreadResetLastError();
+
if (!VIR_IS_STORAGE_VOL(vol)) {
virLibStorageVolError(NULL, VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
return (vol->name);
@@ -5303,8 +6620,12 @@ virStorageVolGetKey(virStorageVolPtr vol
{
DEBUG("vol=%p", vol);
+ virThreadResetLastError();
+
if (!VIR_IS_STORAGE_VOL(vol)) {
virLibStorageVolError(NULL, VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
return (vol->key);
@@ -5330,20 +6651,33 @@ virStorageVolCreateXML(virStoragePoolPtr
{
DEBUG("pool=%p, flags=%u", pool, flags);
+ virThreadResetLastError();
+
if (!VIR_IS_STORAGE_POOL(pool)) {
virLibConnError(NULL, VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
if (pool->conn->flags & VIR_CONNECT_RO) {
virLibConnError(pool->conn, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (NULL);
- }
-
- if (pool->conn->storageDriver && pool->conn->storageDriver->volCreateXML)
- return pool->conn->storageDriver->volCreateXML (pool, xmldesc, flags);
+ goto error;
+ }
+
+ if (pool->conn->storageDriver && pool->conn->storageDriver->volCreateXML) {
+ virStorageVolPtr ret;
+ ret = pool->conn->storageDriver->volCreateXML (pool, xmldesc, flags);
+ if (!ret)
+ goto error;
+ return ret;
+ }
virLibConnError (pool->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(pool->conn);
return NULL;
}
@@ -5364,21 +6698,34 @@ virStorageVolDelete(virStorageVolPtr vol
virConnectPtr conn;
DEBUG("vol=%p, flags=%u", vol, flags);
+ virThreadResetLastError();
+
if (!VIR_IS_CONNECTED_STORAGE_VOL(vol)) {
virLibStorageVolError(NULL, VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
conn = vol->conn;
if (conn->flags & VIR_CONNECT_RO) {
virLibStorageVolError(vol, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- return (-1);
- }
-
- if (conn->storageDriver && conn->storageDriver->volDelete)
- return conn->storageDriver->volDelete (vol, flags);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->storageDriver && conn->storageDriver->volDelete) {
+ int ret;
+ ret = conn->storageDriver->volDelete (vol, flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(vol->conn);
return -1;
}
@@ -5397,12 +6744,19 @@ virStorageVolFree(virStorageVolPtr vol)
{
DEBUG("vol=%p", vol);
+ virThreadResetLastError();
+
if (!VIR_IS_STORAGE_VOL(vol)) {
virLibStorageVolError(NULL, VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__);
- return (-1);
- }
- if (virUnrefStorageVol(vol) < 0)
- return (-1);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+ if (virUnrefStorageVol(vol) < 0) {
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
return(0);
}
@@ -5424,23 +6778,36 @@ virStorageVolGetInfo(virStorageVolPtr vo
virConnectPtr conn;
DEBUG("vol=%p, info=%p", vol, info);
+ virThreadResetLastError();
+
if (!VIR_IS_CONNECTED_STORAGE_VOL(vol)) {
virLibStorageVolError(NULL, VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
if (info == NULL) {
virLibStorageVolError(vol, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
+ goto error;
}
memset(info, 0, sizeof(virStorageVolInfo));
conn = vol->conn;
- if (conn->storageDriver->volGetInfo)
- return conn->storageDriver->volGetInfo (vol, info);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ if (conn->storageDriver->volGetInfo){
+ int ret;
+ ret = conn->storageDriver->volGetInfo (vol, info);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(vol->conn);
return -1;
}
@@ -5462,23 +6829,35 @@ virStorageVolGetXMLDesc(virStorageVolPtr
virConnectPtr conn;
DEBUG("vol=%p, flags=%u", vol, flags);
+ virThreadResetLastError();
+
if (!VIR_IS_STORAGE_VOL(vol)) {
virLibStorageVolError(NULL, VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
if (flags != 0) {
virLibStorageVolError(vol, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
+ goto error;
}
conn = vol->conn;
- if (conn->storageDriver && conn->storageDriver->volGetXMLDesc)
- return conn->storageDriver->volGetXMLDesc (vol, flags);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
- return NULL;
-
+ if (conn->storageDriver && conn->storageDriver->volGetXMLDesc) {
+ char *ret;
+ ret = conn->storageDriver->volGetXMLDesc (vol, flags);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(vol->conn);
+ return NULL;
}
@@ -5500,17 +6879,30 @@ virStorageVolGetPath(virStorageVolPtr vo
virConnectPtr conn;
DEBUG("vol=%p", vol);
+ virThreadResetLastError();
+
if (!VIR_IS_STORAGE_VOL(vol)) {
virLibStorageVolError(NULL, VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__);
+ /* Copy to global error object for back compatability */
+ virThreadSetGlobalError();
return (NULL);
}
conn = vol->conn;
- if (conn->storageDriver && conn->storageDriver->volGetPath)
- return conn->storageDriver->volGetPath (vol);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ if (conn->storageDriver && conn->storageDriver->volGetPath) {
+ char *ret;
+ ret = conn->storageDriver->volGetPath (vol);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(vol->conn);
return NULL;
}
@@ -5535,19 +6927,32 @@ virNodeNumOfDevices(virConnectPtr conn,
{
DEBUG("conn=%p, cap=%s, flags=%d", conn, cap, flags);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
if (flags != 0) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
-
- if (conn->deviceMonitor && conn->deviceMonitor->numOfDevices)
- return conn->deviceMonitor->numOfDevices (conn, cap, flags);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->deviceMonitor && conn->deviceMonitor->numOfDevices) {
+ int ret;
+ ret = conn->deviceMonitor->numOfDevices (conn, cap, flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return -1;
}
@@ -5576,19 +6981,32 @@ virNodeListDevices(virConnectPtr conn,
DEBUG("conn=%p, cap=%s, names=%p, maxnames=%d, flags=%d",
conn, cap, names, maxnames, flags);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
if ((flags != 0) || (names == NULL) || (maxnames < 0)) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
-
- if (conn->deviceMonitor && conn->deviceMonitor->listDevices)
- return conn->deviceMonitor->listDevices (conn, cap, names, maxnames, flags);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->deviceMonitor && conn->deviceMonitor->listDevices) {
+ int ret;
+ ret = conn->deviceMonitor->listDevices (conn, cap, names, maxnames, flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return -1;
}
@@ -5606,20 +7024,33 @@ virNodeDevicePtr virNodeDeviceLookupByNa
{
DEBUG("conn=%p, name=%p", conn, name);
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return NULL;
}
if (name == NULL) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return NULL;
- }
-
- if (conn->deviceMonitor && conn->deviceMonitor->deviceLookupByName)
- return conn->deviceMonitor->deviceLookupByName (conn, name);
-
- virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->deviceMonitor && conn->deviceMonitor->deviceLookupByName) {
+ virNodeDevicePtr ret;
+ ret = conn->deviceMonitor->deviceLookupByName (conn, name);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return NULL;
}
@@ -5638,15 +7069,28 @@ char *virNodeDeviceGetXMLDesc(virNodeDev
{
DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL);
+ virThreadResetLastError();
+
if (!VIR_IS_CONNECTED_NODE_DEVICE(dev)) {
virLibNodeDeviceError(NULL, VIR_ERR_INVALID_NODE_DEVICE, __FUNCTION__);
- return NULL;
- }
-
- if (dev->conn->deviceMonitor && dev->conn->deviceMonitor->deviceDumpXML)
- return dev->conn->deviceMonitor->deviceDumpXML (dev, flags);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return NULL;
+ }
+
+ if (dev->conn->deviceMonitor && dev->conn->deviceMonitor->deviceDumpXML) {
+ char *ret;
+ ret = dev->conn->deviceMonitor->deviceDumpXML (dev, flags);
+ if (!ret)
+ goto error;
+ return ret;
+ }
virLibConnError (dev->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(dev->conn);
return NULL;
}
@@ -5684,8 +7128,12 @@ const char *virNodeDeviceGetParent(virNo
{
DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL);
+ virThreadResetLastError();
+
if (!VIR_IS_CONNECTED_NODE_DEVICE(dev)) {
virLibNodeDeviceError(NULL, VIR_ERR_INVALID_NODE_DEVICE, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return NULL;
}
@@ -5712,15 +7160,28 @@ int virNodeDeviceNumOfCaps(virNodeDevice
{
DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL);
+ virThreadResetLastError();
+
if (!VIR_IS_CONNECTED_NODE_DEVICE(dev)) {
virLibNodeDeviceError(NULL, VIR_ERR_INVALID_NODE_DEVICE, __FUNCTION__);
- return -1;
- }
-
- if (dev->conn->deviceMonitor && dev->conn->deviceMonitor->deviceNumOfCaps)
- return dev->conn->deviceMonitor->deviceNumOfCaps (dev);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return -1;
+ }
+
+ if (dev->conn->deviceMonitor && dev->conn->deviceMonitor->deviceNumOfCaps) {
+ int ret;
+ ret = dev->conn->deviceMonitor->deviceNumOfCaps (dev);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
virLibConnError (dev->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(dev->conn);
return -1;
}
@@ -5741,15 +7202,28 @@ int virNodeDeviceListCaps(virNodeDeviceP
DEBUG("dev=%p, conn=%p, names=%p, maxnames=%d",
dev, dev ? dev->conn : NULL, names, maxnames);
+ virThreadResetLastError();
+
if (!VIR_IS_CONNECTED_NODE_DEVICE(dev)) {
virLibNodeDeviceError(NULL, VIR_ERR_INVALID_NODE_DEVICE, __FUNCTION__);
- return -1;
- }
-
- if (dev->conn->deviceMonitor && dev->conn->deviceMonitor->deviceListCaps)
- return dev->conn->deviceMonitor->deviceListCaps (dev, names, maxnames);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return -1;
+ }
+
+ if (dev->conn->deviceMonitor && dev->conn->deviceMonitor->deviceListCaps) {
+ int ret;
+ ret = dev->conn->deviceMonitor->deviceListCaps (dev, names, maxnames);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
virLibConnError (dev->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(dev->conn);
return -1;
}
@@ -5767,12 +7241,19 @@ int virNodeDeviceFree(virNodeDevicePtr d
{
DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL);
+ virThreadResetLastError();
+
if (!VIR_IS_CONNECTED_NODE_DEVICE(dev)) {
virLibNodeDeviceError(NULL, VIR_ERR_INVALID_NODE_DEVICE, __FUNCTION__);
- return (-1);
- }
- if (virUnrefNodeDevice(dev) < 0)
- return (-1);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
+ if (virUnrefNodeDevice(dev) < 0) {
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
+ return (-1);
+ }
return(0);
}
@@ -5799,18 +7280,32 @@ virConnectDomainEventRegister(virConnect
void *opaque,
virFreeCallback freecb)
{
-
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ DEBUG("conn=%p, cb=%p, opaque=%p, freecb=%p", conn, cb, opaque, freecb);
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
if (cb == NULL) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
-
- if ((conn->driver) && (conn->driver->domainEventRegister))
- return conn->driver->domainEventRegister (conn, cb, opaque, freecb);
+ goto error;
+ }
+
+ if ((conn->driver) && (conn->driver->domainEventRegister)) {
+ int ret;
+ ret = conn->driver->domainEventRegister (conn, cb, opaque, freecb);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
return -1;
}
@@ -5829,19 +7324,33 @@ virConnectDomainEventDeregister(virConne
virConnectDomainEventDeregister(virConnectPtr conn,
virConnectDomainEventCallback cb)
{
-
- if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ DEBUG("conn=%p, cb=%p", conn, cb);
+
+ virThreadResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ /* Copy to connection error object for back compatability */
+ virThreadSetGlobalError();
return (-1);
}
if (cb == NULL) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
- if ((conn->driver) && (conn->driver->domainEventDeregister))
- return conn->driver->domainEventDeregister (conn, cb);
-
- return -1;
-}
-
-
+ goto error;
+ }
+ if ((conn->driver) && (conn->driver->domainEventDeregister)) {
+ int ret;
+ ret = conn->driver->domainEventDeregister (conn, cb);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+error:
+ /* Copy to connection error object for back compatability */
+ virThreadSetConnError(conn);
+ return -1;
+}
+
+
diff --git a/src/libvirt_sym.version.in b/src/libvirt_sym.version.in
--- a/src/libvirt_sym.version.in
+++ b/src/libvirt_sym.version.in
@@ -249,7 +249,13 @@ LIBVIRT_0.5.0 {
} LIBVIRT_0.4.5;
-/* no new entry point in 0.5.1 */
+LIBVIRT_0.5.2 {
+ global:
+ virThreadGetLastError;
+ virThreadCopyLastError;
+ virThreadResetLastError;
+} LIBVIRT_0.5.0;
+
/* .... define new API here using predicted next version number .... */
diff --git a/src/virterror.c b/src/virterror.c
--- a/src/virterror.c
+++ b/src/virterror.c
@@ -17,11 +17,14 @@
#include "virterror_internal.h"
#include "datatypes.h"
+#include "memory.h"
-virError virLastErr = /* the last error */
+static virError virLastErr = /* the last error */
{ .code = 0, .domain = 0, .message = NULL, .level = VIR_ERR_NONE,
.conn = NULL, .dom = NULL, .str1 = NULL, .str2 = NULL, .str3 = NULL,
.int1 = 0, .int2 = 0, .net = NULL };
+static PTHREAD_MUTEX_T(virLastErrLock);
+
virErrorFunc virErrorHandler = NULL; /* global error handler */
void *virUserData = NULL; /* associated data */
@@ -62,12 +65,49 @@ void *virUserData = NULL; /* asso
}} \
}
-/*
+static int
+virCopyError(virErrorPtr from,
+ virErrorPtr to)
+{
+ int ret = 0;
+ if (!to)
+ return 0;
+ virResetError(to);
+ if (!from)
+ return 0;
+ to->code = from->code;
+ to->domain = from->domain;
+ to->level = from->level;
+ if (from->message && !(to->message = strdup(from->message)))
+ ret = -1;
+ if (from->str1 && !(to->str1 = strdup(from->str1)))
+ ret = -1;
+ if (from->str2 && !(to->str2 = strdup(from->str2)))
+ ret = -1;
+ if (from->str3 && !(to->str3 = strdup(from->str3)))
+ ret = -1;
+ to->int1 = from->int1;
+ to->int2 = from->int2;
+ /*
+ * Delibrately not setting 'conn', 'dom', 'net' references
+ */
+ return ret;
+}
+
+
+
+/**
* virGetLastError:
*
* Provide a pointer to the last error caught at the library level
- * Simpler but may not be suitable for multithreaded accesses, in which
- * case use virCopyLastError()
+ *
+ * This function is not safe for use in a multi-threaded
+ * application. Use virThreadGetLastError() instead.
+ *
+ * This function is also not very suitable for single-threaded
+ * applications because for any API call, it is impossible
+ * to determine whether an error was set globally or on the
+ * connection. Always use virThreadGetLastError()
*
* Returns a pointer to the last error or NULL if none occurred.
*/
@@ -79,11 +119,20 @@ virGetLastError(void)
return (&virLastErr);
}
-/*
+/**
* virCopyLastError:
* @to: target to receive the copy
*
* Copy the content of the last error caught at the library level
+ *
+ * This function is not safe for use in a multi-threaded
+ * application. Use virThreadCopyLastError() instead.
+ *
+ * This function is also not very suitable for single-threaded
+ * applications because for any API call, it is impossible
+ * to determine whether an error was set globally or on the
+ * connection. Always use virThreadCopyLastError()
+ *
* One will need to free the result with virResetError()
*
* Returns 0 if no error was found and the error code otherwise and -1 in case
@@ -92,12 +141,8 @@ int
int
virCopyLastError(virErrorPtr to)
{
- if (to == NULL)
- return (-1);
- if (virLastErr.code == VIR_ERR_OK)
- return (0);
- memcpy(to, &virLastErr, sizeof(virError));
- return (virLastErr.code);
+ virCopyError(&virLastErr, to);
+ return to->code;
}
/**
@@ -118,10 +163,19 @@ virResetError(virErrorPtr err)
memset(err, 0, sizeof(virError));
}
+
/**
* virResetLastError:
*
* Reset the last error caught at the library level.
+ *
+ * This function is not safe for use in a multi-threaded
+ * application. Use virThreadResetLastError() instead.
+ *
+ * This function is also not very suitable for single-threaded
+ * applications because for any API call, it is impossible
+ * to determine whether an error was set globally or on the
+ * connection. Always use virThreadResetLastError()
*/
void
virResetLastError(void)
@@ -134,8 +188,14 @@ virResetLastError(void)
* @conn: pointer to the hypervisor connection
*
* Provide a pointer to the last error caught on that connection
- * Simpler but may not be suitable for multithreaded accesses, in which
- * case use virConnCopyLastError()
+ *
+ * This function is not safe for use in a multi-threaded
+ * application. Use virThreadGetLastError() instead.
+ *
+ * This function is also not very suitable for single-threaded
+ * applications because for any API call, it is impossible
+ * to determine whether an error was set globally or on the
+ * connection. Always use virThreadGetLastError()
*
* Returns a pointer to the last error or NULL if none occurred.
*/
@@ -153,6 +213,15 @@ virConnGetLastError(virConnectPtr conn)
* @to: target to receive the copy
*
* Copy the content of the last error caught on that connection
+ *
+ * This function is not safe for use in a multi-threaded
+ * application. Use virThreadCopyLastError() instead.
+ *
+ * This function is also not very suitable for single-threaded
+ * applications because for any API call, it is impossible
+ * to determine whether an error was set globally or on the
+ * connection. Always use virThreadCopyLastError()
+ *
* One will need to free the result with virResetError()
*
* Returns 0 if no error was found and the error code otherwise and -1 in case
@@ -163,17 +232,21 @@ virConnCopyLastError(virConnectPtr conn,
{
if (conn == NULL)
return (-1);
- if (to == NULL)
- return (-1);
- if (conn->err.code == VIR_ERR_OK)
- return (0);
- memcpy(to, &conn->err, sizeof(virError));
- return (conn->err.code);
+ virCopyError(&conn->err, to);
+ return to->code;
}
/**
* virConnResetLastError:
* @conn: pointer to the hypervisor connection
+ *
+ * This function is not safe for use in a multi-threaded
+ * application. Use virThreadResetLastError() instead.
+ *
+ * This function is also not very suitable for single-threaded
+ * applications because for any API call, it is impossible
+ * to determine whether an error was set globally or on the
+ * connection. Always use virThreadResetLastError()
*
* Reset the last error caught on that connection
*/
@@ -217,8 +290,10 @@ virConnSetErrorFunc(virConnectPtr conn,
{
if (conn == NULL)
return;
+ pthread_mutex_lock(&conn->lock);
conn->handler = handler;
conn->userData = userData;
+ pthread_mutex_unlock(&conn->lock);
}
/**
@@ -338,6 +413,146 @@ virDefaultErrorFunc(virErrorPtr err)
dom, lvl, domain, network, err->message);
}
+
+pthread_once_t virErrorKeyInit = PTHREAD_ONCE_INIT;
+pthread_key_t virErrorKey;
+
+static void
+virErrorKeyFreeData(void *data)
+{
+ virErrorPtr err = data;
+ virResetError(err);
+ VIR_FREE(err);
+}
+
+static void
+virErrorKeyCreate(void)
+{
+ pthread_key_create(&virErrorKey, virErrorKeyFreeData);
+}
+
+
+static void
+virErrorGenericFailure(virErrorPtr err)
+{
+ err->code = VIR_ERR_INTERNAL_ERROR;
+ err->domain = VIR_FROM_NONE;
+ err->level = VIR_ERR_ERROR;
+ err->message = strdup(_("Unknown failure"));
+}
+
+/**
+ * virThreadGetLastError:
+ *
+ * Provide a pointer to the last error caught during an API
+ * call in this thread.
+ *
+ * The contents of the returned error object are only valid
+ * until the next API call is made, or until the thread exits
+ *
+ * Returns a pointer to the last error or NULL if none occurred.
+ */
+virErrorPtr
+virThreadGetLastError(void)
+{
+ virErrorPtr err;
+ pthread_once(&virErrorKeyInit, virErrorKeyCreate);
+ err = pthread_getspecific(virErrorKey);
+ if (!err) {
+ if (VIR_ALLOC(err) < 0)
+ return NULL;
+ pthread_setspecific(virErrorKey, err);
+ }
+ return err;
+}
+
+
+/**
+ * virThreadCopyLastError:
+ * @to: target to receive the copy
+ *
+ * Copy the content of the last error caught during an API
+ * call in this thread.
+ *
+ * One will need to free the result with virResetError()
+ *
+ * Returns 0 if no error was found and the error code otherwise and -1 in case
+ * of parameter error.
+ */
+int
+virThreadCopyLastError (virErrorPtr to)
+{
+ virErrorPtr err;
+
+ err = virThreadGetLastError();
+ if (virCopyError(err, to) < 0)
+ return -1;
+
+ return to->code;
+}
+
+
+/**
+ * virThreadResetLastError:
+ *
+ * Reset the last error caught during an API call
+ * in this thread
+ */
+void
+virThreadResetLastError (void)
+{
+ virErrorPtr err;
+
+ err = virThreadGetLastError();
+ if (err)
+ virResetError(err);
+}
+
+
+/**
+ * virThreadSetConnError:
+ *
+ * Initialize the global error with the contents of the
+ * the thread local error
+ */
+void
+virThreadSetGlobalError(void)
+{
+ virErrorPtr err;
+
+ err = virThreadGetLastError();
+
+ if (err && err->code == VIR_ERR_OK)
+ virErrorGenericFailure(err);
+
+ pthread_mutex_lock(&virLastErrLock);
+ virCopyError(err, &virLastErr);
+ pthread_mutex_unlock(&virLastErrLock);
+}
+
+/**
+ * virThreadSetConnError:
+ *
+ * Initialize the connection error with the contents of the
+ * the thread local error
+ */
+void
+virThreadSetConnError(virConnectPtr conn)
+{
+ virErrorPtr err;
+
+ err = virThreadGetLastError();
+
+ if (err && err->code == VIR_ERR_OK)
+ virErrorGenericFailure(err);
+
+ pthread_mutex_lock(&conn->lock);
+ virCopyError(err, &conn->err);
+ pthread_mutex_unlock(&conn->lock);
+}
+
+
+
/**
* virRaiseError:
* @conn: the connection to the hypervisor if available
@@ -358,15 +573,29 @@ virDefaultErrorFunc(virErrorPtr err)
* immediately if a callback is found and store it for later handling.
*/
void
-virRaiseError(virConnectPtr conn, virDomainPtr dom, virNetworkPtr net,
+virRaiseError(virConnectPtr conn,
+ virDomainPtr dom ATTRIBUTE_UNUSED,
+ virNetworkPtr net ATTRIBUTE_UNUSED,
int domain, int code, virErrorLevel level,
const char *str1, const char *str2, const char *str3,
int int1, int int2, const char *msg, ...)
{
- virErrorPtr to = &virLastErr;
+ virErrorPtr to;
void *userData = virUserData;
virErrorFunc handler = virErrorHandler;
char *str;
+
+ /*
+ * All errors are recorded in thread local storage
+ * For compatability, public API calls will copy them
+ * to the global or per-connection error object when
+ * neccessary
+ */
+ to = virThreadGetLastError();
+ if (!to)
+ return; /* Hit OOM allocating thread error object, sod all we can do now */
+
+ virResetError(to);
if (code == VIR_ERR_OK)
return;
@@ -375,11 +604,12 @@ virRaiseError(virConnectPtr conn, virDom
* try to find the best place to save and report the error
*/
if (conn != NULL) {
- to = &conn->err;
+ pthread_mutex_lock(&conn->lock);
if (conn->handler != NULL) {
handler = conn->handler;
userData = conn->userData;
}
+ pthread_mutex_unlock(&conn->lock);
}
/*
@@ -395,9 +625,10 @@ virRaiseError(virConnectPtr conn, virDom
* Save the information about the error
*/
virResetError(to);
- to->conn = conn;
- to->dom = dom;
- to->net = net;
+ /*
+ * Delibrately not setting conn, dom & net fields since
+ * they're utterly unsafe
+ */
to->domain = domain;
to->code = code;
to->message = str;
diff --git a/src/virterror_internal.h b/src/virterror_internal.h
--- a/src/virterror_internal.h
+++ b/src/virterror_internal.h
@@ -24,7 +24,6 @@
#include "internal.h"
-extern virError virLastErr;
extern virErrorFunc virErrorHandler;
extern void *virUserData;
@@ -53,4 +52,7 @@ void virReportErrorHelper(virConnectPtr
ATTRIBUTE_FORMAT(printf, 7, 8);
+void virThreadSetGlobalError(void);
+void virThreadSetConnError(virConnectPtr conn);
+
#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 :|
2
6
1: cvs-ignore a stray, generated file
2: bootstrap: pull in gnulib's ioctl module (Daniel Berrange will
use it shortly)
3: add more files pulled in via yesterday's gnulib upgrade
The third is highest priority, since without it, running
autogen.sh from just-checked-out sources fails due to 3 missing
.m4 files. This isn't the first time that's happened. I tracked
the problem to the way gnulib-tool updates .cvsignore files to
mark pulled-in files as ignored, by default. That made it
hard to use vc tools like cvs or git to identify new files.
The 2nd patch adds gnulib-tools' --no-vc-files option to inhibit
that behavior.
>From 4b63b91ff4b8308cfde641686ea22ff51499bb00 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 7 Jan 2009 15:43:41 +0100
Subject: [PATCH 1/3] ignore generated libvirtd.logrotate.
* qemud/.cvsignore: Add libvirtd.logrotate.
* qemud/.gitignore: Regenerate.
---
qemud/.cvsignore | 13 +++++++------
qemud/.gitignore | 13 +++++++------
2 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/qemud/.cvsignore b/qemud/.cvsignore
index 04fed54..38cf28d 100644
--- a/qemud/.cvsignore
+++ b/qemud/.cvsignore
@@ -1,11 +1,12 @@
-Makefile
-Makefile.in
+*.gcda
+*.gcno
+*.la
+*.lo
.deps
.libs
-*.lo
-*.la
+Makefile
+Makefile.in
libvirt_qemud
libvirtd
libvirtd.init
-*.gcno
-*.gcda
+libvirtd.logrotate
diff --git a/qemud/.gitignore b/qemud/.gitignore
index 04fed54..38cf28d 100644
--- a/qemud/.gitignore
+++ b/qemud/.gitignore
@@ -1,11 +1,12 @@
-Makefile
-Makefile.in
+*.gcda
+*.gcno
+*.la
+*.lo
.deps
.libs
-*.lo
-*.la
+Makefile
+Makefile.in
libvirt_qemud
libvirtd
libvirtd.init
-*.gcno
-*.gcda
+libvirtd.logrotate
--
1.6.1.121.g866a4a
>From 8d6654775a277eca6bf52b011671920091cde9a4 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 7 Jan 2009 16:11:02 +0100
Subject: [PATCH 2/3] bootstrap: pull in gnulib's ioctl module
* bootstrap: Invoke gnulib-tool with its --no-vc-files
option, since we version-control the files it imports.
This tells it not to mark imported files as cvs-ignored.
(modules): Add ioctl.
* gnulib/lib/ioctl.c: New file.
* gnulib/lib/sys_ioctl.in.h: New file.
* gnulib/tests/sys_ioctl.in.h: Removed.
* gnulib/tests/ioctl.c: Removed.
* gnulib/lib/Makefile.am: Update.
* gnulib/m4/gnulib-cache.m4: Likewise.
* gnulib/m4/gnulib-comp.m4: Likewise.
* gnulib/tests/Makefile.am: Likewise.
* gnulib/lib/.cvsignore: Ignore sys_ioctl.h.
* gnulib/lib/.gitignore: Regenerate.
---
bootstrap | 2 +
gnulib/lib/.cvsignore | 1 +
gnulib/lib/.gitignore | 1 +
gnulib/lib/Makefile.am | 38 +++++++++++++++++++++++++++++++++-
gnulib/{tests => lib}/ioctl.c | 8 +++---
gnulib/{tests => lib}/sys_ioctl.in.h | 8 +++---
gnulib/m4/gnulib-cache.m4 | 4 ++-
gnulib/m4/gnulib-comp.m4 | 22 +++++++++---------
gnulib/tests/Makefile.am | 36 --------------------------------
9 files changed, 63 insertions(+), 57 deletions(-)
rename gnulib/{tests => lib}/ioctl.c (78%)
rename gnulib/{tests => lib}/sys_ioctl.in.h (85%)
diff --git a/bootstrap b/bootstrap
index c5487b2..38dd3ae 100755
--- a/bootstrap
+++ b/bootstrap
@@ -73,6 +73,7 @@ gethostname
getpass
gettext
inet_pton
+ioctl
mkstemp
mktempd
perror
@@ -100,6 +101,7 @@ vc-list-files
# put *.[ch] files in new gnulib/lib/ dir.
$gnulib_tool \
+ --no-vc-files \
--lgpl=2 \
--with-tests \
--m4-base=gnulib/m4 \
diff --git a/gnulib/lib/.cvsignore b/gnulib/lib/.cvsignore
index 5a82aa0..9d6b35f 100644
--- a/gnulib/lib/.cvsignore
+++ b/gnulib/lib/.cvsignore
@@ -16,6 +16,7 @@ stdint.h
stdio.h
stdlib.h
string.h
+sys_ioctl.h
sys_select.h
sys_socket.h
sys_stat.h
diff --git a/gnulib/lib/.gitignore b/gnulib/lib/.gitignore
index 5a82aa0..9d6b35f 100644
--- a/gnulib/lib/.gitignore
+++ b/gnulib/lib/.gitignore
@@ -16,6 +16,7 @@ stdint.h
stdio.h
stdlib.h
string.h
+sys_ioctl.h
sys_select.h
sys_socket.h
sys_stat.h
diff --git a/gnulib/lib/Makefile.am b/gnulib/lib/Makefile.am
index 528142e..746881c 100644
--- a/gnulib/lib/Makefile.am
+++ b/gnulib/lib/Makefile.am
@@ -9,7 +9,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gnulib/lib --m4-base=gnulib/m4 --doc-base=doc --tests-base=gnulib/tests --aux-dir=build-aux --with-tests --lgpl=2 --libtool --macro-prefix=gl c-ctype close connect getaddrinfo gethostname getpass gettext inet_pton mkstemp mktempd perror physmem poll posix-shell recv send setsockopt socket strerror strndup strsep sys_stat time_r useless-if-before-free vasprintf vc-list-files verify
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gnulib/lib --m4-base=gnulib/m4 --doc-base=doc --tests-base=gnulib/tests --aux-dir=build-aux --with-tests --lgpl=2 --libtool --macro-prefix=gl --no-vc-files c-ctype close connect getaddrinfo gethostname getpass gettext inet_pton ioctl mkstemp mktempd perror physmem poll posix-shell recv send setsockopt socket strerror strndup strsep sys_stat time_r useless-if-before-free vasprintf vc-list-files verify
AUTOMAKE_OPTIONS = 1.5 gnits
@@ -291,6 +291,15 @@ EXTRA_DIST += intprops.h
## end gnulib module intprops
+## begin gnulib module ioctl
+
+
+EXTRA_DIST += ioctl.c w32sock.h
+
+EXTRA_libgnu_la_SOURCES += ioctl.c
+
+## end gnulib module ioctl
+
## begin gnulib module link-warning
LINK_WARNING_H=$(top_srcdir)/build-aux/link-warning.h
@@ -831,6 +840,33 @@ EXTRA_libgnu_la_SOURCES += strsep.c
## end gnulib module strsep
+## begin gnulib module sys_ioctl
+
+BUILT_SOURCES += $(SYS_IOCTL_H)
+
+# We need the following in order to create <sys/ioctl.h> when the system
+# does not have a complete one.
+sys/ioctl.h: sys_ioctl.in.h
+ @MKDIR_P@ sys
+ rm -f $@-t $@
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''HAVE_SYS_IOCTL_H''@|$(HAVE_SYS_IOCTL_H)|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''NEXT_SYS_IOCTL_H''@|$(NEXT_SYS_IOCTL_H)|g' \
+ -e 's|@''GNULIB_IOCTL''@|$(GNULIB_IOCTL)|g' \
+ -e 's|@''SYS_IOCTL_H_HAVE_WINSOCK2_H''@|$(SYS_IOCTL_H_HAVE_WINSOCK2_H)|g' \
+ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+ < $(srcdir)/sys_ioctl.in.h; \
+ } > $@-t
+ mv $@-t $@
+MOSTLYCLEANFILES += sys/ioctl.h sys/ioctl.h-t
+MOSTLYCLEANDIRS += sys
+
+EXTRA_DIST += sys_ioctl.in.h
+
+## end gnulib module sys_ioctl
+
## begin gnulib module sys_select
BUILT_SOURCES += $(SYS_SELECT_H)
diff --git a/gnulib/tests/ioctl.c b/gnulib/lib/ioctl.c
similarity index 78%
rename from gnulib/tests/ioctl.c
rename to gnulib/lib/ioctl.c
index a23d363..77e0101 100644
--- a/gnulib/tests/ioctl.c
+++ b/gnulib/lib/ioctl.c
@@ -3,16 +3,16 @@
Copyright (C) 2008 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ GNU Lesser General Public License for more details.
- You should have received a copy of the GNU General Public License
+ You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Written by Paolo Bonzini */
diff --git a/gnulib/tests/sys_ioctl.in.h b/gnulib/lib/sys_ioctl.in.h
similarity index 85%
rename from gnulib/tests/sys_ioctl.in.h
rename to gnulib/lib/sys_ioctl.in.h
index 65c2c4a..6ce02d4 100644
--- a/gnulib/tests/sys_ioctl.in.h
+++ b/gnulib/lib/sys_ioctl.in.h
@@ -2,16 +2,16 @@
Copyright (C) 2008 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3, or (at your option)
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ GNU Lesser General Public License for more details.
- You should have received a copy of the GNU General Public License
+ You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
diff --git a/gnulib/m4/gnulib-cache.m4 b/gnulib/m4/gnulib-cache.m4
index 9eb6064..77a285f 100644
--- a/gnulib/m4/gnulib-cache.m4
+++ b/gnulib/m4/gnulib-cache.m4
@@ -15,7 +15,7 @@
# Specification in the form of a command-line invocation:
-# gnulib-tool --import --dir=. --lib=libgnu --source-base=gnulib/lib --m4-base=gnulib/m4 --doc-base=doc --tests-base=gnulib/tests --aux-dir=build-aux --with-tests --lgpl=2 --libtool --macro-prefix=gl c-ctype close connect getaddrinfo gethostname getpass gettext inet_pton mkstemp mktempd perror physmem poll posix-shell recv send setsockopt socket strerror strndup strsep sys_stat time_r useless-if-before-free vasprintf vc-list-files verify
+# gnulib-tool --import --dir=. --lib=libgnu --source-base=gnulib/lib --m4-base=gnulib/m4 --doc-base=doc --tests-base=gnulib/tests --aux-dir=build-aux --with-tests --lgpl=2 --libtool --macro-prefix=gl --no-vc-files c-ctype close connect getaddrinfo gethostname getpass gettext inet_pton ioctl mkstemp mktempd perror physmem poll posix-shell recv send setsockopt socket strerror strndup strsep sys_stat time_r useless-if-before-free vasprintf vc-list-files verify
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([])
@@ -28,6 +28,7 @@ gl_MODULES([
getpass
gettext
inet_pton
+ ioctl
mkstemp
mktempd
perror
@@ -61,3 +62,4 @@ gl_MAKEFILE_NAME([])
gl_LIBTOOL
gl_MACRO_PREFIX([gl])
gl_PO_DOMAIN([])
+gl_VC_FILES([false])
diff --git a/gnulib/m4/gnulib-comp.m4 b/gnulib/m4/gnulib-comp.m4
index 072b9f0..1393b97 100644
--- a/gnulib/m4/gnulib-comp.m4
+++ b/gnulib/m4/gnulib-comp.m4
@@ -82,6 +82,13 @@ AC_SUBST([LTALLOCA])
gl_ARPA_INET_MODULE_INDICATOR([inet_ntop])
gl_INET_PTON
gl_ARPA_INET_MODULE_INDICATOR([inet_pton])
+ AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+ if test "$ac_cv_header_winsock2_h" = yes; then
+ AC_LIBOBJ([ioctl])
+ gl_REPLACE_SYS_IOCTL_H
+ fi
+ gl_SYS_IOCTL_MODULE_INDICATOR([ioctl])
+ gl_MODULE_INDICATOR([ioctl])
gl_FUNC_LSEEK
gl_UNISTD_MODULE_INDICATOR([lseek])
gl_FUNC_LSTAT
@@ -141,6 +148,8 @@ AC_SUBST([LTALLOCA])
gl_STRING_MODULE_INDICATOR([strnlen])
gl_FUNC_STRSEP
gl_STRING_MODULE_INDICATOR([strsep])
+ gl_SYS_IOCTL_H
+ AC_PROG_MKDIR_P
gl_HEADER_SYS_SELECT
AC_PROG_MKDIR_P
gl_HEADER_SYS_SOCKET
@@ -213,13 +222,6 @@ AC_SUBST([LTALLOCA])
gl_SYS_SOCKET_MODULE_INDICATOR([bind])
AC_REQUIRE([gl_HEADER_SYS_SOCKET])
if test "$ac_cv_header_winsock2_h" = yes; then
- AC_LIBOBJ([ioctl])
- gl_REPLACE_SYS_IOCTL_H
- fi
- gl_SYS_IOCTL_MODULE_INDICATOR([ioctl])
- gl_MODULE_INDICATOR([ioctl])
- AC_REQUIRE([gl_HEADER_SYS_SOCKET])
- if test "$ac_cv_header_winsock2_h" = yes; then
AC_LIBOBJ([listen])
fi
gl_SYS_SOCKET_MODULE_INDICATOR([listen])
@@ -227,8 +229,6 @@ AC_SUBST([LTALLOCA])
gl_SOCKETS
gt_TYPE_WCHAR_T
gt_TYPE_WINT_T
- gl_SYS_IOCTL_H
- AC_PROG_MKDIR_P
AC_CHECK_FUNCS([shutdown])
abs_aux_dir=`cd "$ac_aux_dir"; pwd`
AC_SUBST([abs_aux_dir])
@@ -354,6 +354,7 @@ AC_DEFUN([gl_FILE_LIST], [
lib/inet_ntop.c
lib/inet_pton.c
lib/intprops.h
+ lib/ioctl.c
lib/lseek.c
lib/lstat.c
lib/malloc.c
@@ -388,6 +389,7 @@ AC_DEFUN([gl_FILE_LIST], [
lib/strndup.c
lib/strnlen.c
lib/strsep.c
+ lib/sys_ioctl.in.h
lib/sys_select.in.h
lib/sys_socket.in.h
lib/sys_stat.in.h
@@ -535,10 +537,8 @@ AC_DEFUN([gl_FILE_LIST], [
tests/test-wchar.c
tests=lib/accept.c
tests=lib/bind.c
- tests=lib/ioctl.c
tests=lib/listen.c
tests=lib/sockets.c
tests=lib/sockets.h
- tests=lib/sys_ioctl.in.h
tests=lib/w32sock.h
])
diff --git a/gnulib/tests/Makefile.am b/gnulib/tests/Makefile.am
index 4273d6c..ea40a21 100644
--- a/gnulib/tests/Makefile.am
+++ b/gnulib/tests/Makefile.am
@@ -150,15 +150,6 @@ EXTRA_DIST += test-gettimeofday.c
## end gnulib module gettimeofday-tests
-## begin gnulib module ioctl
-
-
-EXTRA_DIST += ioctl.c w32sock.h
-
-EXTRA_libtests_a_SOURCES += ioctl.c
-
-## end gnulib module ioctl
-
## begin gnulib module listen
@@ -298,33 +289,6 @@ EXTRA_DIST += test-string.c
## end gnulib module string-tests
-## begin gnulib module sys_ioctl
-
-BUILT_SOURCES += $(SYS_IOCTL_H)
-
-# We need the following in order to create <sys/ioctl.h> when the system
-# does not have a complete one.
-sys/ioctl.h: sys_ioctl.in.h
- @MKDIR_P@ sys
- rm -f $@-t $@
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''HAVE_SYS_IOCTL_H''@|$(HAVE_SYS_IOCTL_H)|g' \
- -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
- -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
- -e 's|@''NEXT_SYS_IOCTL_H''@|$(NEXT_SYS_IOCTL_H)|g' \
- -e 's|@''GNULIB_IOCTL''@|$(GNULIB_IOCTL)|g' \
- -e 's|@''SYS_IOCTL_H_HAVE_WINSOCK2_H''@|$(SYS_IOCTL_H_HAVE_WINSOCK2_H)|g' \
- -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
- < $(srcdir)/sys_ioctl.in.h; \
- } > $@-t
- mv $@-t $@
-MOSTLYCLEANFILES += sys/ioctl.h sys/ioctl.h-t
-MOSTLYCLEANDIRS += sys
-
-EXTRA_DIST += sys_ioctl.in.h
-
-## end gnulib module sys_ioctl
-
## begin gnulib module sys_select-tests
TESTS += test-sys_select
--
1.6.1.121.g866a4a
>From ca8eae50325df82b8f44d75bb80c3812d07fc30c Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 7 Jan 2009 16:13:08 +0100
Subject: [PATCH 3/3] add more files pulled in via yesterday's gnulib upgrade
* gnulib/m4/multiarch.m4: New file.
* gnulib/m4/hostent.m4: New file.
* gnulib/m4/servent.m4: New file.
* .x-sc_prohibit_gethostby: Exempt all gnulib/m4/* files, so
hostent.m4's uses of gethostbyname and gethostbyaddr does not
trigger a "make syntax-check" failure.
---
.x-sc_prohibit_gethostby | 2 +-
gnulib/m4/hostent.m4 | 45 ++++++++++++++++++++++++++++
gnulib/m4/multiarch.m4 | 74 ++++++++++++++++++++++++++++++++++++++++++++++
gnulib/m4/servent.m4 | 47 +++++++++++++++++++++++++++++
4 files changed, 167 insertions(+), 1 deletions(-)
create mode 100644 gnulib/m4/hostent.m4
create mode 100644 gnulib/m4/multiarch.m4
create mode 100644 gnulib/m4/servent.m4
diff --git a/.x-sc_prohibit_gethostby b/.x-sc_prohibit_gethostby
index d74ea40..c771142 100644
--- a/.x-sc_prohibit_gethostby
+++ b/.x-sc_prohibit_gethostby
@@ -1,3 +1,3 @@
gnulib/lib/getaddrinfo.c
-gnulib/m4/getaddrinfo.m4
+gnulib/m4/
src/xend_internal.c
diff --git a/gnulib/m4/hostent.m4 b/gnulib/m4/hostent.m4
new file mode 100644
index 0000000..4a96af7
--- /dev/null
+++ b/gnulib/m4/hostent.m4
@@ -0,0 +1,45 @@
+# hostent.m4 serial 1
+dnl Copyright (C) 2008 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_HOSTENT],
+[
+ dnl Where are gethostent(), sethostent(), endhostent(), gethostbyname(),
+ dnl gethostbyaddr() defined?
+ dnl - On Solaris, they are in libnsl. Ignore libxnet.
+ dnl - On Haiku, they are in libnetwork.
+ dnl - On BeOS, they are in libnet.
+ dnl - On native Windows, they are in ws2_32.dll.
+ dnl - Otherwise they are in libc.
+ AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
+ HOSTENT_LIB=
+ gl_saved_libs="$LIBS"
+ AC_SEARCH_LIBS([gethostbyname], [nsl network net],
+ [if test "$ac_cv_search_gethostbyname" != "none required"; then
+ HOSTENT_LIB="$ac_cv_search_gethostbyname"
+ fi])
+ LIBS="$gl_saved_libs"
+ if test -z "$HOSTENT_LIB"; then
+ AC_CHECK_FUNCS([gethostbyname], , [
+ AC_CACHE_CHECK([for gethostbyname in winsock2.h and -lws2_32],
+ [gl_cv_w32_gethostbyname],
+ [gl_cv_w32_gethostbyname=no
+ gl_save_LIBS="$LIBS"
+ LIBS="$LIBS -lws2_32"
+ AC_TRY_LINK([
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
+#include <stddef.h>
+], [gethostbyname(NULL);], [gl_cv_w32_gethostbyname=yes])
+ LIBS="$gl_save_LIBS"
+ ])
+ if test "$gl_cv_w32_gethostbyname" = "yes"; then
+ HOSTENT_LIB="-lws2_32"
+ fi
+ ])
+ fi
+ AC_SUBST([HOSTENT_LIB])
+])
diff --git a/gnulib/m4/multiarch.m4 b/gnulib/m4/multiarch.m4
new file mode 100644
index 0000000..7b73e15
--- /dev/null
+++ b/gnulib/m4/multiarch.m4
@@ -0,0 +1,74 @@
+# multiarch.m4 serial 3
+dnl Copyright (C) 2008 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+# Determine whether the compiler is or may be producing universal binaries.
+#
+# On MacOS X 10.5 and later systems, the user can create libraries and
+# executables that work on multiple system types--known as "fat" or
+# "universal" binaries--by specifying multiple '-arch' options to the
+# compiler but only a single '-arch' option to the preprocessor. Like
+# this:
+#
+# ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+# CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+# CPP="gcc -E" CXXCPP="g++ -E"
+#
+# Detect this situation and set the macro AA_APPLE_UNIVERSAL_BUILD at the
+# beginning of config.h and set APPLE_UNIVERSAL_BUILD accordingly.
+
+AC_DEFUN([gl_MULTIARCH],
+[
+ dnl This AC_REQUIRE is not necessary in theory. It works around a bug in
+ dnl autoconf <= 2.63: AC_REQUIRE invocations inside AC_REQUIREd macros are
+ dnl being handled better than AC_REQUIRE invocations inside normally invoked
+ dnl macros.
+ AC_REQUIRE([gl_MULTIARCH_BODY])
+])
+
+AC_DEFUN([gl_MULTIARCH_BODY],
+[
+ dnl Code similar to autoconf-2.63 AC_C_BIGENDIAN.
+ gl_cv_c_multiarch=no
+ AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE(
+ [[#ifndef __APPLE_CC__
+ not a universal capable compiler
+ #endif
+ typedef int dummy;
+ ]])],
+ [
+ dnl Check for potential -arch flags. It is not universal unless
+ dnl there are at least two -arch flags with different values.
+ arch=
+ prev=
+ for word in ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do
+ if test -n "$prev"; then
+ case $word in
+ i?86 | x86_64 | ppc | ppc64)
+ if test -z "$arch" || test "$arch" = "$word"; then
+ arch="$word"
+ else
+ gl_cv_c_multiarch=yes
+ fi
+ ;;
+ esac
+ prev=
+ else
+ if test "x$word" = "x-arch"; then
+ prev=arch
+ fi
+ fi
+ done
+ ])
+ if test $gl_cv_c_multiarch = yes; then
+ AC_DEFINE([AA_APPLE_UNIVERSAL_BUILD], [1],
+ [Define if the compiler is building for multiple architectures of Apple platforms at once.])
+ APPLE_UNIVERSAL_BUILD=1
+ else
+ APPLE_UNIVERSAL_BUILD=0
+ fi
+ AC_SUBST([APPLE_UNIVERSAL_BUILD])
+])
diff --git a/gnulib/m4/servent.m4 b/gnulib/m4/servent.m4
new file mode 100644
index 0000000..242f9e3
--- /dev/null
+++ b/gnulib/m4/servent.m4
@@ -0,0 +1,47 @@
+# servent.m4 serial 1
+dnl Copyright (C) 2008 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_SERVENT],
+[
+ dnl Where are getservent(), setservent(), endservent(), getservbyname(),
+ dnl getservbyport() defined?
+ dnl Where are getprotoent(), setprotoent(), endprotoent(), getprotobyname(),
+ dnl getprotobynumber() defined?
+ dnl - On Solaris, they are in libsocket. Ignore libxnet.
+ dnl - On Haiku, they are in libnetwork.
+ dnl - On BeOS, they are in libnet.
+ dnl - On native Windows, they are in ws2_32.dll.
+ dnl - Otherwise they are in libc.
+ AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
+ SERVENT_LIB=
+ gl_saved_libs="$LIBS"
+ AC_SEARCH_LIBS([getservbyname], [socket network net],
+ [if test "$ac_cv_search_getservbyname" != "none required"; then
+ SERVENT_LIB="$ac_cv_search_getservbyname"
+ fi])
+ LIBS="$gl_saved_libs"
+ if test -z "$SERVENT_LIB"; then
+ AC_CHECK_FUNCS([getservbyname], , [
+ AC_CACHE_CHECK([for getservbyname in winsock2.h and -lws2_32],
+ [gl_cv_w32_getservbyname],
+ [gl_cv_w32_getservbyname=no
+ gl_save_LIBS="$LIBS"
+ LIBS="$LIBS -lws2_32"
+ AC_TRY_LINK([
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
+#include <stddef.h>
+], [getservbyname(NULL,NULL);], [gl_cv_w32_getservbyname=yes])
+ LIBS="$gl_save_LIBS"
+ ])
+ if test "$gl_cv_w32_getservbyname" = "yes"; then
+ SERVENT_LIB="-lws2_32"
+ fi
+ ])
+ fi
+ AC_SUBST([SERVENT_LIB])
+])
--
1.6.1.121.g866a4a
1
0
Hi,
This patch adds support for the -pcidevice host=bus:dev.func
added in kvm-79
I used the structure as already defined in src/domain_conf.h
so analog to usb one now can add pci devices
as example:
lspci: 06:02.0 Network controller: Eicon Networks Corporation Diva
Server 2FX (rev 01)
<hostdev mode='subsystem' type='pci'>
<source>
<address bus="0x06" slot="0x02" function="0x0"/>
</source>
</hostdev>
values are hex so for bus: 0 to ff, slot: 0 to 1f and function: 0 to 7
Hope this patch is useful it applies to libvirt-0.5.1 and cvs checkout
from today (with some hunks)
Regards Jason
--
Collax GmbH . Burkheimer Str. 3 . 79111 Freiburg . Germany
p: +49 (0) 89-990157-0
f: +49 (0) 89-990157-11 . http://www.collax.com
4
5
07 Jan '09
Hi, guys.
During domain creation from xml like this:
<domain type="openvz" id="3005">
<name>3005</name>
<memory>131072</memory>
<currentMemory>131072</currentMemory>
<vcpu>1</vcpu>
<os>
<type>exe</type>
</os>
<devices>
<filesystem type="template">
<source name="altlinux-4.0"/>
<target dir="/"/>
</filesystem>
<interface type="bridge">
<source bridge="vzrb0"/>
<target dev="veth3005.0"/>
</interface>
</devices>
i get veth3005.0 on a HW node connected to virtual bridge vzbr0 and eth0 inside a container. So that annoying bug with confused <source> and <target> tags seems to be fixed. Thanks for that!
But mac generation still seems to be an issue, caz mac of eth0 and veth3005.0 are the same:
[root@alt-03 ~]# cat /etc/vz/conf/3005.conf | grep NETIF
NETIF="ifname=eth0,bridge=vzbr0,mac=52:54:00:97:72:8E,host_ifname=veth3005.0,host_mac=52:54:00:97:72:8E"
So when i connect two containers via bridge they cannot "talk" to each other due to macs conflict. Can something be done to improve mac generation behaviour?
Version I use at the moment:
[root@alt-03 ~]# rpm -qa | grep libvirt
libvirt-python-0.5.0-alt1
libvirt-0.5.0-alt1
libvirt-devel-0.5.0-alt1
And one more not an OpenVZ-specific question: I am working on a project using python and python API bindings in libvirt. I don't see a python method for virNetworkCreateXML:
>>> dir(libvirt.virConnect.networkCreateXML)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: class virConnect has no attribute 'networkCreateXML'
There are two methods for virNetworkDefineXML and virNetworkCreate separately:
>>> dir(libvirt.virConnect.networkDefineXML)
['__call__', '__class__', '__cmp__', '__delattr__', '__doc__', '__get__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 'im_class', 'im_func', 'im_self']
>>> dir(libvirt.virNetwork.create)
['__call__', '__class__', '__cmp__', '__delattr__', '__doc__', '__get__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 'im_class', 'im_func', 'im_self']
Is networkCreateXML missed?
________________________________
This message (including attachments) is private and confidential. If you have received this message in error, please notify us and remove it from your system.
2
1
Hello,
after updating to the last official release 0.5.1 my application stopped working. No errors to the log file though i raised exceptions where it was possible.
i checked with virsh xml description used for creating OpenVZ container and got the following:
virsh # create ovz.xml
Segmentation fault
after that virsh just closed (as well as my application did before). But itself container was created:
[root@alt-03 ~]# vzlist -a
CTID NPROC STATUS IP_ADDR HOSTNAME
3005 5 running - -
Ovz.xml looks like this:
<domain type="openvz" id="3005">
<name>3005</name>
<memory>131072</memory>
<vcpu>1</vcpu>
<os>
<type>exe</type>
<init>/sbin/init</init>
</os>
<devices>
<filesystem type="template">
<source name="altlinux-4.0"/>
<target dir="/"/>
</filesystem>
<interface type="bridge">
<source bridge="vzrb1"/>
<target dev="veth3005.0"/>
</interface>
</devices>
<domain>
With previous version it worked just fine.
Further, it is impossible to create OpenVZ container without <memory> tag though i didn't notice any effects from it. Does it realy needed?
<vcpu> tag stopped working. Previously it added in config file of the container a record like CPUS="1". No it doesn't add anything.
Mac generation still an issue. It seems my notification about it was missed. Here is a string from config file for created container.
[root@alt-03 ~]# cat /etc/vz/conf/3005.conf | grep NETIF
NETIF="ifname=eth0,bridge=vzrb1,mac=52:54:00:4B:BB:F4,host_ifname=veth3005.0,host_mac=52:54:00:4B:BB:F4"
mac = host_mac = network issue.
________________________________
This message (including attachments) is private and confidential. If you have received this message in error, please notify us and remove it from your system.
5
11
[libvirt] [PATCH] virConnectGetHostname: return a fully qualified hostname
by David Lutterkort 07 Jan '09
by David Lutterkort 07 Jan '09
07 Jan '09
The attached patch makes virConnectGetHostname try a little harder to get a
FQDN on systems where gethostname only returns a short name without a
domain (which is pretty useless). The behavior is equivalent to 'hostname
--fqdn'.
> From 2ae57d0c8c68c453b3f9715fcc9f83af0ebe84a0 Mon Sep 17 00:00:00 2001
From: David Lutterkort <lutter(a)redhat.com>
Date: Wed, 10 Dec 2008 18:34:39 -0800
Subject: [PATCH] virConnectGetHostname: return a fully qualified hostname
Instead of doing the equivalent of 'hostname', do 'hostname --fqdn',
i.e. try to qualify the local host name by an additional call to
gethostbyname(3)
---
src/libvirt_sym.version.in | 1 +
src/qemu_driver.c | 16 ++++------------
src/test.c | 16 +++++-----------
src/uml_driver.c | 15 ++++-----------
src/util.c | 17 +++++++++++++++++
src/util.h | 2 ++
src/xen_unified.c | 15 +++++----------
7 files changed, 38 insertions(+), 44 deletions(-)
diff --git a/src/libvirt_sym.version.in b/src/libvirt_sym.version.in
index de0bc4a..f02d9e0 100644
--- a/src/libvirt_sym.version.in
+++ b/src/libvirt_sym.version.in
@@ -594,6 +594,7 @@ LIBVIRT_PRIVATE_@VERSION@ {
virFileReadLimFD;
virFileReadPid;
virFileLinkPointsTo;
+ virGetHostname;
virParseNumber;
virRun;
virSkipSpaces;
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 5f6fbd1..d6b7515 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -1562,23 +1562,16 @@ cleanup:
static char *
qemudGetHostname (virConnectPtr conn)
{
- int r;
- char hostname[HOST_NAME_MAX+1], *str;
+ char *result;
- r = gethostname (hostname, HOST_NAME_MAX+1);
- if (r == -1) {
+ result = virGetHostname();
+ if (result == NULL) {
qemudReportError (conn, NULL, NULL, VIR_ERR_SYSTEM_ERROR,
"%s", strerror (errno));
return NULL;
}
/* Caller frees this string. */
- str = strdup (hostname);
- if (str == NULL) {
- qemudReportError (conn, NULL, NULL, VIR_ERR_SYSTEM_ERROR,
- "%s", strerror (errno));
- return NULL;
- }
- return str;
+ return result;
}
static int qemudListDomains(virConnectPtr conn, int *ids, int nids) {
@@ -4249,4 +4242,3 @@ int qemuRegister(void) {
virRegisterStateDriver(&qemuStateDriver);
return 0;
}
-
diff --git a/src/test.c b/src/test.c
index 257fc8a..cb623ed 100644
--- a/src/test.c
+++ b/src/test.c
@@ -651,22 +651,16 @@ static int testGetVersion(virConnectPtr conn ATTRIBUTE_UNUSED,
static char *testGetHostname (virConnectPtr conn)
{
- int r;
- char hostname [HOST_NAME_MAX+1], *str;
+ char *result;
- r = gethostname (hostname, HOST_NAME_MAX+1);
- if (r == -1) {
+ result = virGetHostname();
+ if (result == NULL) {
testError (conn, VIR_ERR_SYSTEM_ERROR, "%s",
strerror (errno));
return NULL;
}
- str = strdup (hostname);
- if (str == NULL) {
- testError (conn, VIR_ERR_SYSTEM_ERROR, "%s",
- strerror (errno));
- return NULL;
- }
- return str;
+ /* Caller frees this string. */
+ return result;
}
static int testGetMaxVCPUs(virConnectPtr conn ATTRIBUTE_UNUSED,
diff --git a/src/uml_driver.c b/src/uml_driver.c
index 408096e..52a4e5b 100644
--- a/src/uml_driver.c
+++ b/src/uml_driver.c
@@ -1150,23 +1150,16 @@ cleanup:
static char *
umlGetHostname (virConnectPtr conn)
{
- int r;
- char hostname[HOST_NAME_MAX+1], *str;
+ char *result;
- r = gethostname (hostname, HOST_NAME_MAX+1);
- if (r == -1) {
+ result = virGetHostname();
+ if (result == NULL) {
umlReportError (conn, NULL, NULL, VIR_ERR_SYSTEM_ERROR,
"%s", strerror (errno));
return NULL;
}
/* Caller frees this string. */
- str = strdup (hostname);
- if (str == NULL) {
- umlReportError (conn, NULL, NULL, VIR_ERR_SYSTEM_ERROR,
- "%s", strerror (errno));
- return NULL;
- }
- return str;
+ return result;
}
static int umlListDomains(virConnectPtr conn, int *ids, int nids) {
diff --git a/src/util.c b/src/util.c
index da26009..7188239 100644
--- a/src/util.c
+++ b/src/util.c
@@ -47,6 +47,7 @@
#ifdef HAVE_PATHS_H
#include <paths.h>
#endif
+#include <netdb.h>
#include "virterror_internal.h"
#include "logging.h"
@@ -1306,3 +1307,19 @@ int virDiskNameToIndex(const char *name) {
return idx;
}
+
+char *virGetHostname(void)
+{
+ int r;
+ char hostname[HOST_NAME_MAX+1], *str;
+ struct hostent *he;
+
+ r = gethostname (hostname, HOST_NAME_MAX+1);
+ if (r == -1)
+ return NULL;
+ if (!(he = gethostbyname(hostname)))
+ return NULL;
+
+ /* Caller frees this string. */
+ return strdup (he->h_name);
+}
diff --git a/src/util.h b/src/util.h
index 0748cbf..f85a61e 100644
--- a/src/util.h
+++ b/src/util.h
@@ -161,4 +161,6 @@ static inline int getuid (void) { return 0; }
static inline int getgid (void) { return 0; }
#endif
+char *virGetHostname(void);
+
#endif /* __VIR_UTIL_H__ */
diff --git a/src/xen_unified.c b/src/xen_unified.c
index a60bc79..dbda3b5 100644
--- a/src/xen_unified.c
+++ b/src/xen_unified.c
@@ -447,20 +447,15 @@ xenUnifiedGetVersion (virConnectPtr conn, unsigned long *hvVer)
static char *
xenUnifiedGetHostname (virConnectPtr conn)
{
- int r;
- char hostname [HOST_NAME_MAX+1], *str;
+ char *result;
- r = gethostname (hostname, HOST_NAME_MAX+1);
- if (r == -1) {
- xenUnifiedError (conn, VIR_ERR_SYSTEM_ERROR, "%s", strerror(errno));
- return NULL;
- }
- str = strdup (hostname);
- if (str == NULL) {
+ result = virGetHostname();
+ if (result == NULL) {
xenUnifiedError (conn, VIR_ERR_SYSTEM_ERROR, "%s", strerror(errno));
return NULL;
}
- return str;
+ /* Caller frees this string. */
+ return result;
}
static int
--
1.6.0.4
5
10
Hi,
current domstatus code saves the domain as number, attached patch safes
it as string which looks a bit nicer.
Cheers,
-- Guido
3
4
The addition of virKill to src/util.c breaks Windows build which lacks the
kill() function. Now we technically don't have any code which runs virKill
when built on Windows, but after the 2 weeks holiday I'm very motivated so
wrote a basic implement of virKill() which is a starting point for Win32
in case we need it based on the recommendations in this thread
http://www.nabble.com/kill-signal-td149789.html
Seems Perl does much the same for its kill() implement on Win32 (and is
even more thorough/complete), though we can't just use the Perl code
directly since its GPL licensed. So I've done a minimal stub
Daniel
Index: src/util.c
===================================================================
RCS file: /data/cvs/libvirt/src/util.c,v
retrieving revision 1.78
diff -u -p -u -p -r1.78 util.c
--- src/util.c 6 Jan 2009 17:46:46 -0000 1.78
+++ src/util.c 6 Jan 2009 20:47:09 -0000
@@ -1346,5 +1346,50 @@ int virKillProcess(pid_t pid, int sig)
return -1;
}
+#ifdef WIN32
+ /* Mingw / Windows don't have many signals (AFAIK) */
+ switch (sig) {
+ case SIGINT:
+ /* This does a Ctrl+C equiv */
+ if (!GenerateConsoleCtrlEvent(CTRL_C_EVENT, pid)) {
+ errno = ESRCH;
+ return -1;
+ }
+ break;
+
+ case SIGTERM:
+ /* Since TerminateProcess is closer to SIG_KILL, we do
+ * a Ctrl+Break equiv which is more pleasant like the
+ * good old unix SIGTERM/HUP
+ */
+ if (!GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, pid)) {
+ errno = ESRCH;
+ return -1;
+ }
+ break;
+
+ default:
+ {
+ HANDLE proc;
+ proc = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
+ if (!proc) {
+ errno = ESRCH; /* Not entirely accurate, but close enough */
+ return -1;
+ }
+
+ /*
+ * TerminateProcess is more or less equiv to SIG_KILL, in that
+ * a process can't trap / block it
+ */
+ if (!TerminateProcess(proc, sig)) {
+ errno = ESRCH;
+ return -1;
+ }
+ CloseHandle(proc);
+ }
+ }
+ return 0;
+#else
return kill(pid, sig);
+#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 :|
1
0
There are a number of problems breaking the windows / mingw
build currently.
- Use of 'close' without importing unistd.h
- Use of non-existant localtime_r
- ERROR macro from logging.h clashes with a symbol imported
from windows.h
So this patch does
- Adds the missing unistd.h include
- Uses localtime() if localtime_r() is missing (as checked from
configure)
- Adds a VIR_ prefix onto all logging macros, keeping
DEBUG() around because its just used in sooooo many
places
The use of localtime() on Windows is OK, because the MicroSoft
implementation of this uses thread-local storage:
http://msdn.microsoft.com/en-us/library/a442x3ye.aspx
And all other OS we care about have localtime_r
Finally I fix a few compile warnings, so that Mingw can now be
built with --enable-compile-warnings=error to detect these
problems more quickly in future.
configure.in | 3
qemud/qemud.c | 206 ++++++++++++++++++++++++------------------------
qemud/remote.c | 104 ++++++++++++------------
qemud/remote_protocol.c | 4
qemud/rpcgen_fix.pl | 1
src/logging.c | 20 +++-
src/logging.h | 57 +++++++------
src/test.c | 5 +
tests/nodeinfotest.c | 2
9 files changed, 212 insertions(+), 190 deletions(-)
Daniel
diff --git a/configure.in b/configure.in
--- a/configure.in
+++ b/configure.in
@@ -73,6 +73,9 @@ AC_SYS_LARGEFILE
dnl Availability of various common functions (non-fatal if missing).
AC_CHECK_FUNCS([cfmakeraw regexec uname sched_getaffinity getuid getgid])
+
+dnl Availablility of threadsafe functions - fallback to non-threadsafe if missing
+AC_CHECK_FUNCS([localtime_r])
dnl Availability of various common headers (non-fatal if missing).
AC_CHECK_HEADERS([pwd.h paths.h regex.h sys/syslimits.h sys/utsname.h sys/wait.h winsock2.h sched.h termios.h sys/poll.h syslog.h])
diff --git a/qemud/qemud.c b/qemud/qemud.c
--- a/qemud/qemud.c
+++ b/qemud/qemud.c
@@ -171,7 +171,7 @@ remoteCheckCertFile(const char *type, co
{
struct stat sb;
if (stat(file, &sb) < 0) {
- ERROR(_("Cannot access %s '%s': %s (%d)"),
+ VIR_ERROR(_("Cannot access %s '%s': %s (%d)"),
type, file, strerror(errno), errno);
return -1;
}
@@ -188,7 +188,7 @@ remoteInitializeGnuTLS (void)
err = gnutls_certificate_allocate_credentials (&x509_cred);
if (err) {
- ERROR(_("gnutls_certificate_allocate_credentials: %s"),
+ VIR_ERROR(_("gnutls_certificate_allocate_credentials: %s"),
gnutls_strerror (err));
return -1;
}
@@ -201,7 +201,7 @@ remoteInitializeGnuTLS (void)
err = gnutls_certificate_set_x509_trust_file (x509_cred, ca_file,
GNUTLS_X509_FMT_PEM);
if (err < 0) {
- ERROR(_("gnutls_certificate_set_x509_trust_file: %s"),
+ VIR_ERROR(_("gnutls_certificate_set_x509_trust_file: %s"),
gnutls_strerror (err));
return -1;
}
@@ -215,7 +215,7 @@ remoteInitializeGnuTLS (void)
err = gnutls_certificate_set_x509_crl_file (x509_cred, crl_file,
GNUTLS_X509_FMT_PEM);
if (err < 0) {
- ERROR(_("gnutls_certificate_set_x509_crl_file: %s"),
+ VIR_ERROR(_("gnutls_certificate_set_x509_crl_file: %s"),
gnutls_strerror (err));
return -1;
}
@@ -232,7 +232,7 @@ remoteInitializeGnuTLS (void)
cert_file, key_file,
GNUTLS_X509_FMT_PEM);
if (err < 0) {
- ERROR(_("gnutls_certificate_set_x509_key_file: %s"),
+ VIR_ERROR(_("gnutls_certificate_set_x509_key_file: %s"),
gnutls_strerror (err));
return -1;
}
@@ -245,12 +245,12 @@ remoteInitializeGnuTLS (void)
*/
err = gnutls_dh_params_init (&dh_params);
if (err < 0) {
- ERROR(_("gnutls_dh_params_init: %s"), gnutls_strerror (err));
+ VIR_ERROR(_("gnutls_dh_params_init: %s"), gnutls_strerror (err));
return -1;
}
err = gnutls_dh_params_generate2 (dh_params, DH_BITS);
if (err < 0) {
- ERROR(_("gnutls_dh_params_generate2: %s"), gnutls_strerror (err));
+ VIR_ERROR(_("gnutls_dh_params_generate2: %s"), gnutls_strerror (err));
return -1;
}
@@ -271,7 +271,7 @@ qemudDispatchSignalEvent(int watch ATTRI
pthread_mutex_lock(&server->lock);
if (saferead(server->sigread, &siginfo, sizeof(siginfo)) != sizeof(siginfo)) {
- ERROR(_("Failed to read from signal pipe: %s"), strerror(errno));
+ VIR_ERROR(_("Failed to read from signal pipe: %s"), strerror(errno));
pthread_mutex_unlock(&server->lock);
return;
}
@@ -280,20 +280,20 @@ qemudDispatchSignalEvent(int watch ATTRI
switch (siginfo.si_signo) {
case SIGHUP:
- INFO0(_("Reloading configuration on SIGHUP"));
+ VIR_INFO0(_("Reloading configuration on SIGHUP"));
if (virStateReload() < 0)
- WARN0(_("Error while reloading drivers"));
+ VIR_WARN0(_("Error while reloading drivers"));
break;
case SIGINT:
case SIGQUIT:
case SIGTERM:
- WARN(_("Shutting down on signal %d"), siginfo.si_signo);
+ VIR_WARN(_("Shutting down on signal %d"), siginfo.si_signo);
server->shutdown = 1;
break;
default:
- INFO(_("Received unexpected signal %d"), siginfo.si_signo);
+ VIR_INFO(_("Received unexpected signal %d"), siginfo.si_signo);
break;
}
@@ -312,7 +312,7 @@ int qemudSetCloseExec(int fd) {
goto error;
return 0;
error:
- ERROR0(_("Failed to set close-on-exec file descriptor flag"));
+ VIR_ERROR0(_("Failed to set close-on-exec file descriptor flag"));
return -1;
}
@@ -326,7 +326,7 @@ int qemudSetNonBlock(int fd) {
goto error;
return 0;
error:
- ERROR0(_("Failed to set non-blocking file descriptor flag"));
+ VIR_ERROR0(_("Failed to set non-blocking file descriptor flag"));
return -1;
}
@@ -404,28 +404,28 @@ static int qemudWritePidFile(const char
return 0;
if ((fd = open(pidFile, O_WRONLY|O_CREAT|O_EXCL, 0644)) < 0) {
- ERROR(_("Failed to open pid file '%s' : %s"),
- pidFile, strerror(errno));
+ VIR_ERROR(_("Failed to open pid file '%s' : %s"),
+ pidFile, strerror(errno));
return -1;
}
if (!(fh = fdopen(fd, "w"))) {
- ERROR(_("Failed to fdopen pid file '%s' : %s"),
- pidFile, strerror(errno));
+ VIR_ERROR(_("Failed to fdopen pid file '%s' : %s"),
+ pidFile, strerror(errno));
close(fd);
return -1;
}
if (fprintf(fh, "%lu\n", (unsigned long)getpid()) < 0) {
- ERROR(_("Failed to write to pid file '%s' : %s"),
- pidFile, strerror(errno));
+ VIR_ERROR(_("Failed to write to pid file '%s' : %s"),
+ pidFile, strerror(errno));
close(fd);
return -1;
}
if (fclose(fh) == EOF) {
- ERROR(_("Failed to close pid file '%s' : %s"),
- pidFile, strerror(errno));
+ VIR_ERROR(_("Failed to close pid file '%s' : %s"),
+ pidFile, strerror(errno));
return -1;
}
@@ -440,7 +440,7 @@ static int qemudListenUnix(struct qemud_
gid_t oldgrp;
if (VIR_ALLOC(sock) < 0) {
- ERROR("%s", _("Failed to allocate memory for struct qemud_socket"));
+ VIR_ERROR("%s", _("Failed to allocate memory for struct qemud_socket"));
return -1;
}
@@ -450,8 +450,8 @@ static int qemudListenUnix(struct qemud_
sock->auth = auth;
if ((sock->fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
- ERROR(_("Failed to create socket: %s"),
- strerror(errno));
+ VIR_ERROR(_("Failed to create socket: %s"),
+ strerror(errno));
goto cleanup;
}
@@ -472,8 +472,8 @@ static int qemudListenUnix(struct qemud_
setgid(unix_sock_gid);
if (bind(sock->fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
- ERROR(_("Failed to bind socket to '%s': %s"),
- path, strerror(errno));
+ VIR_ERROR(_("Failed to bind socket to '%s': %s"),
+ path, strerror(errno));
goto cleanup;
}
umask(oldmask);
@@ -481,8 +481,8 @@ static int qemudListenUnix(struct qemud_
setgid(oldgrp);
if (listen(sock->fd, 30) < 0) {
- ERROR(_("Failed to listen for connections on '%s': %s"),
- path, strerror(errno));
+ VIR_ERROR(_("Failed to listen for connections on '%s': %s"),
+ path, strerror(errno));
goto cleanup;
}
@@ -492,7 +492,7 @@ static int qemudListenUnix(struct qemud_
VIR_EVENT_HANDLE_HANGUP,
qemudDispatchServerEvent,
server, NULL)) < 0) {
- ERROR0(_("Failed to add server event callback"));
+ VIR_ERROR0(_("Failed to add server event callback"));
goto cleanup;
}
@@ -521,7 +521,7 @@ remoteMakeSockets (int *fds, int max_fds
int e = getaddrinfo (node, service, &hints, &ai);
if (e != 0) {
- ERROR(_("getaddrinfo: %s\n"), gai_strerror (e));
+ VIR_ERROR(_("getaddrinfo: %s\n"), gai_strerror (e));
return -1;
}
@@ -530,7 +530,7 @@ remoteMakeSockets (int *fds, int max_fds
fds[*nfds_r] = socket (runp->ai_family, runp->ai_socktype,
runp->ai_protocol);
if (fds[*nfds_r] == -1) {
- ERROR(_("socket: %s"), strerror (errno));
+ VIR_ERROR(_("socket: %s"), strerror (errno));
return -1;
}
@@ -539,14 +539,14 @@ remoteMakeSockets (int *fds, int max_fds
if (bind (fds[*nfds_r], runp->ai_addr, runp->ai_addrlen) == -1) {
if (errno != EADDRINUSE) {
- ERROR(_("bind: %s"), strerror (errno));
+ VIR_ERROR(_("bind: %s"), strerror (errno));
return -1;
}
close (fds[*nfds_r]);
}
else {
if (listen (fds[*nfds_r], SOMAXCONN) == -1) {
- ERROR(_("listen: %s"), strerror (errno));
+ VIR_ERROR(_("listen: %s"), strerror (errno));
return -1;
}
++*nfds_r;
@@ -581,7 +581,7 @@ remoteListenTCP (struct qemud_server *se
socklen_t salen = sizeof(sa);
if (VIR_ALLOC(sock) < 0) {
- ERROR(_("remoteListenTCP: calloc: %s"), strerror (errno));
+ VIR_ERROR(_("remoteListenTCP: calloc: %s"), strerror (errno));
goto cleanup;
}
@@ -611,7 +611,7 @@ remoteListenTCP (struct qemud_server *se
goto cleanup;
if (listen (sock->fd, 30) < 0) {
- ERROR(_("remoteListenTCP: listen: %s"), strerror (errno));
+ VIR_ERROR(_("remoteListenTCP: listen: %s"), strerror (errno));
goto cleanup;
}
@@ -621,7 +621,7 @@ remoteListenTCP (struct qemud_server *se
VIR_EVENT_HANDLE_HANGUP,
qemudDispatchServerEvent,
server, NULL)) < 0) {
- ERROR0(_("Failed to add server event callback"));
+ VIR_ERROR0(_("Failed to add server event callback"));
goto cleanup;
}
@@ -660,7 +660,7 @@ static int qemudInitPaths(struct qemud_s
struct passwd *pw;
if (!(pw = getpwuid(uid))) {
- ERROR(_("Failed to find user record for uid '%d': %s"),
+ VIR_ERROR(_("Failed to find user record for uid '%d': %s"),
uid, strerror(errno));
return -1;
}
@@ -676,7 +676,7 @@ static int qemudInitPaths(struct qemud_s
return 0;
snprintf_error:
- ERROR("%s", _("Resulting path too long for buffer in qemudInitPaths()"));
+ VIR_ERROR("%s", _("Resulting path too long for buffer in qemudInitPaths()"));
return -1;
}
@@ -684,7 +684,7 @@ static struct qemud_server *qemudInitial
struct qemud_server *server;
if (VIR_ALLOC(server) < 0) {
- ERROR0(_("Failed to allocate struct qemud_server"));
+ VIR_ERROR0(_("Failed to allocate struct qemud_server"));
return NULL;
}
@@ -696,7 +696,7 @@ static struct qemud_server *qemudInitial
server->sigread = sigread;
if (virEventInit() < 0) {
- ERROR0(_("Failed to initialize event system"));
+ VIR_ERROR0(_("Failed to initialize event system"));
VIR_FREE(server);
return NULL;
}
@@ -781,8 +781,8 @@ static struct qemud_server *qemudNetwork
auth_tcp == REMOTE_AUTH_SASL ||
auth_tls == REMOTE_AUTH_SASL) {
if ((err = sasl_server_init(NULL, "libvirt")) != SASL_OK) {
- ERROR(_("Failed to initialize SASL authentication %s"),
- sasl_errstring(err, NULL, NULL));
+ VIR_ERROR(_("Failed to initialize SASL authentication %s"),
+ sasl_errstring(err, NULL, NULL));
goto cleanup;
}
}
@@ -795,8 +795,8 @@ static struct qemud_server *qemudNetwork
dbus_error_init(&derr);
server->sysbus = dbus_bus_get(DBUS_BUS_SYSTEM, &derr);
if (!(server->sysbus)) {
- ERROR(_("Failed to connect to system bus for PolicyKit auth: %s"),
- derr.message);
+ VIR_ERROR(_("Failed to connect to system bus for PolicyKit auth: %s"),
+ derr.message);
dbus_error_free(&derr);
goto cleanup;
}
@@ -906,7 +906,7 @@ remoteInitializeTLSSession (void)
return session;
failed:
- ERROR(_("remoteInitializeTLSSession: %s"),
+ VIR_ERROR(_("remoteInitializeTLSSession: %s"),
gnutls_strerror (err));
return NULL;
}
@@ -922,7 +922,7 @@ remoteCheckDN (gnutls_x509_crt_t cert)
err = gnutls_x509_crt_get_dn (cert, name, &namesize);
if (err != 0) {
- ERROR(_("remoteCheckDN: gnutls_x509_cert_get_dn: %s"),
+ VIR_ERROR(_("remoteCheckDN: gnutls_x509_cert_get_dn: %s"),
gnutls_strerror (err));
return 0;
}
@@ -954,40 +954,40 @@ remoteCheckCertificate (gnutls_session_t
time_t now;
if ((ret = gnutls_certificate_verify_peers2 (session, &status)) < 0){
- ERROR(_("remoteCheckCertificate: verify failed: %s"),
+ VIR_ERROR(_("remoteCheckCertificate: verify failed: %s"),
gnutls_strerror (ret));
return -1;
}
if (status != 0) {
if (status & GNUTLS_CERT_INVALID)
- ERROR0(_("remoteCheckCertificate: "
- "the client certificate is not trusted."));
+ VIR_ERROR0(_("remoteCheckCertificate: "
+ "the client certificate is not trusted."));
if (status & GNUTLS_CERT_SIGNER_NOT_FOUND)
- ERROR0(_("remoteCheckCertificate: the client "
- "certificate has unknown issuer."));
+ VIR_ERROR0(_("remoteCheckCertificate: the client "
+ "certificate has unknown issuer."));
if (status & GNUTLS_CERT_REVOKED)
- ERROR0(_("remoteCheckCertificate: "
- "the client certificate has been revoked."));
+ VIR_ERROR0(_("remoteCheckCertificate: "
+ "the client certificate has been revoked."));
#ifndef GNUTLS_1_0_COMPAT
if (status & GNUTLS_CERT_INSECURE_ALGORITHM)
- ERROR0(_("remoteCheckCertificate: the client certificate"
- " uses an insecure algorithm."));
+ VIR_ERROR0(_("remoteCheckCertificate: the client certificate"
+ " uses an insecure algorithm."));
#endif
return -1;
}
if (gnutls_certificate_type_get (session) != GNUTLS_CRT_X509) {
- ERROR0(_("remoteCheckCertificate: certificate is not X.509"));
+ VIR_ERROR0(_("remoteCheckCertificate: certificate is not X.509"));
return -1;
}
if (!(certs = gnutls_certificate_get_peers(session, &nCerts))) {
- ERROR0(_("remoteCheckCertificate: no peers"));
+ VIR_ERROR0(_("remoteCheckCertificate: no peers"));
return -1;
}
@@ -997,7 +997,7 @@ remoteCheckCertificate (gnutls_session_t
gnutls_x509_crt_t cert;
if (gnutls_x509_crt_init (&cert) < 0) {
- ERROR0(_("remoteCheckCertificate: gnutls_x509_crt_init failed"));
+ VIR_ERROR0(_("remoteCheckCertificate: gnutls_x509_crt_init failed"));
return -1;
}
@@ -1007,15 +1007,15 @@ remoteCheckCertificate (gnutls_session_t
}
if (gnutls_x509_crt_get_expiration_time (cert) < now) {
- ERROR0(_("remoteCheckCertificate: "
- "the client certificate has expired"));
+ VIR_ERROR0(_("remoteCheckCertificate: "
+ "the client certificate has expired"));
gnutls_x509_crt_deinit (cert);
return -1;
}
if (gnutls_x509_crt_get_activation_time (cert) > now) {
- ERROR0(_("remoteCheckCertificate: the client "
- "certificate is not yet activated"));
+ VIR_ERROR0(_("remoteCheckCertificate: the client "
+ "certificate is not yet activated"));
gnutls_x509_crt_deinit (cert);
return -1;
}
@@ -1023,7 +1023,7 @@ remoteCheckCertificate (gnutls_session_t
if (i == 0) {
if (!remoteCheckDN (cert)) {
/* This is the most common error: make it informative. */
- ERROR0(_("remoteCheckCertificate: client's Distinguished Name is not on the list of allowed clients (tls_allowed_dn_list). Use 'openssl x509 -in clientcert.pem -text' to view the Distinguished Name field in the client certificate, or run this daemon with --verbose option."));
+ VIR_ERROR0(_("remoteCheckCertificate: client's Distinguished Name is not on the list of allowed clients (tls_allowed_dn_list). Use 'openssl x509 -in clientcert.pem -text' to view the Distinguished Name field in the client certificate, or run this daemon with --verbose option."));
gnutls_x509_crt_deinit (cert);
return -1;
}
@@ -1039,11 +1039,11 @@ remoteCheckAccess (struct qemud_client *
{
/* Verify client certificate. */
if (remoteCheckCertificate (client->tlssession) == -1) {
- ERROR0(_("remoteCheckCertificate: "
- "failed to verify client's certificate"));
+ VIR_ERROR0(_("remoteCheckCertificate: "
+ "failed to verify client's certificate"));
if (!tls_no_verify_certificate) return -1;
- else INFO0(_("remoteCheckCertificate: tls_no_verify_certificate "
- "is set so the bad certificate is ignored"));
+ else VIR_INFO0(_("remoteCheckCertificate: tls_no_verify_certificate "
+ "is set so the bad certificate is ignored"));
}
/* Checks have succeeded. Write a '\1' byte back to the client to
@@ -1064,8 +1064,8 @@ int qemudGetSocketIdentity(int fd, uid_t
unsigned int cr_len = sizeof (cr);
if (getsockopt (fd, SOL_SOCKET, SO_PEERCRED, &cr, &cr_len) < 0) {
- ERROR(_("Failed to verify client credentials: %s"),
- strerror(errno));
+ VIR_ERROR(_("Failed to verify client credentials: %s"),
+ strerror(errno));
return -1;
}
@@ -1089,18 +1089,18 @@ static int qemudDispatchServer(struct qe
if ((fd = accept(sock->fd, (struct sockaddr *)&addr, &addrlen)) < 0) {
if (errno == EAGAIN)
return 0;
- ERROR(_("Failed to accept connection: %s"), strerror(errno));
+ VIR_ERROR(_("Failed to accept connection: %s"), strerror(errno));
return -1;
}
if (server->nclients >= max_clients) {
- ERROR0(_("Too many active clients, dropping connection"));
+ VIR_ERROR0(_("Too many active clients, dropping connection"));
close(fd);
return -1;
}
if (VIR_REALLOC_N(server->clients, server->nclients+1) < 0) {
- ERROR0(_("Out of memory allocating clients"));
+ VIR_ERROR0(_("Out of memory allocating clients"));
close(fd);
return -1;
}
@@ -1143,7 +1143,7 @@ static int qemudDispatchServer(struct qe
/* Client is running as root, so disable auth */
if (uid == 0) {
- INFO(_("Turn off polkit auth for privileged client %d"), pid);
+ VIR_INFO(_("Turn off polkit auth for privileged client %d"), pid);
client->auth = REMOTE_AUTH_NONE;
}
}
@@ -1182,7 +1182,7 @@ static int qemudDispatchServer(struct qe
if (qemudRegisterClientEvent (server, client, 0) < 0)
goto cleanup;
} else {
- ERROR(_("TLS handshake failed: %s"),
+ VIR_ERROR(_("TLS handshake failed: %s"),
gnutls_strerror (ret));
goto cleanup;
}
@@ -1288,7 +1288,7 @@ static int qemudClientReadBuf(struct qem
if ((ret = read (client->fd, data, len)) <= 0) {
if (ret == 0 || errno != EAGAIN) {
if (ret != 0)
- ERROR(_("read: %s"), strerror (errno));
+ VIR_ERROR(_("read: %s"), strerror (errno));
qemudDispatchClientFailure(server, client);
}
return -1;
@@ -1301,7 +1301,7 @@ static int qemudClientReadBuf(struct qem
if (ret == 0 || (ret != GNUTLS_E_AGAIN &&
ret != GNUTLS_E_INTERRUPTED)) {
if (ret != 0)
- ERROR(_("gnutls_record_recv: %s"),
+ VIR_ERROR(_("gnutls_record_recv: %s"),
gnutls_strerror (ret));
qemudDispatchClientFailure (server, client);
}
@@ -1461,7 +1461,7 @@ static void qemudDispatchClientRead(stru
else if (qemudRegisterClientEvent (server, client, 1) < 0)
qemudDispatchClientFailure (server, client);
} else if (ret != GNUTLS_E_AGAIN && ret != GNUTLS_E_INTERRUPTED) {
- ERROR(_("TLS handshake failed: %s"),
+ VIR_ERROR(_("TLS handshake failed: %s"),
gnutls_strerror (ret));
qemudDispatchClientFailure (server, client);
} else {
@@ -1485,7 +1485,7 @@ static int qemudClientWriteBuf(struct qe
int ret;
if (!client->tlssession) {
if ((ret = safewrite(client->fd, data, len)) == -1) {
- ERROR(_("write: %s"), strerror (errno));
+ VIR_ERROR(_("write: %s"), strerror (errno));
qemudDispatchClientFailure(server, client);
return -1;
}
@@ -1495,7 +1495,7 @@ static int qemudClientWriteBuf(struct qe
qemudDispatchClientFailure (server, client);
else if (ret < 0) {
if (ret != GNUTLS_E_INTERRUPTED && ret != GNUTLS_E_AGAIN) {
- ERROR(_("gnutls_record_send: %s"), gnutls_strerror (ret));
+ VIR_ERROR(_("gnutls_record_send: %s"), gnutls_strerror (ret));
qemudDispatchClientFailure (server, client);
}
return -1;
@@ -1604,7 +1604,7 @@ qemudDispatchClientWrite(struct qemud_se
else if (qemudRegisterClientEvent (server, client, 1))
qemudDispatchClientFailure (server, client);
} else if (ret != GNUTLS_E_AGAIN && ret != GNUTLS_E_INTERRUPTED) {
- ERROR(_("TLS handshake failed: %s"), gnutls_strerror (ret));
+ VIR_ERROR(_("TLS handshake failed: %s"), gnutls_strerror (ret));
qemudDispatchClientFailure (server, client);
} else {
if (qemudRegisterClientEvent (server, client, 1))
@@ -1731,7 +1731,7 @@ static int qemudOneLoop(void) {
errors = sig_errors;
if (errors) {
sig_errors -= errors;
- ERROR(_("Signal handler reported %d errors: last error: %s"),
+ VIR_ERROR(_("Signal handler reported %d errors: last error: %s"),
errors, strerror (sig_lasterrno));
return -1;
}
@@ -1756,7 +1756,7 @@ static int qemudRunLoop(struct qemud_ser
server->nworkers = min_workers;
if (VIR_ALLOC_N(server->workers, server->nworkers) < 0) {
- ERROR0(_("Failed to allocate workers"));
+ VIR_ERROR0(_("Failed to allocate workers"));
return -1;
}
@@ -1882,13 +1882,13 @@ remoteConfigGetStringList(virConfPtr con
switch (p->type) {
case VIR_CONF_STRING:
if (VIR_ALLOC_N(list, 2) < 0) {
- ERROR(_("failed to allocate memory for %s config list"), key);
+ VIR_ERROR(_("failed to allocate memory for %s config list"), key);
return -1;
}
list[0] = strdup (p->str);
list[1] = NULL;
if (list[0] == NULL) {
- ERROR(_("failed to allocate memory for %s config list value"),
+ VIR_ERROR(_("failed to allocate memory for %s config list value"),
key);
VIR_FREE(list);
return -1;
@@ -1901,13 +1901,13 @@ remoteConfigGetStringList(virConfPtr con
for (pp = p->list; pp; pp = pp->next)
len++;
if (VIR_ALLOC_N(list, 1+len) < 0) {
- ERROR(_("failed to allocate memory for %s config list"), key);
+ VIR_ERROR(_("failed to allocate memory for %s config list"), key);
return -1;
}
for (i = 0, pp = p->list; pp; ++i, pp = pp->next) {
if (pp->type != VIR_CONF_STRING) {
- ERROR(_("remoteReadConfigFile: %s: %s:"
- " must be a string or list of strings\n"),
+ VIR_ERROR(_("remoteReadConfigFile: %s: %s:"
+ " must be a string or list of strings\n"),
filename, key);
VIR_FREE(list);
return -1;
@@ -1918,8 +1918,8 @@ remoteConfigGetStringList(virConfPtr con
for (j = 0 ; j < i ; j++)
VIR_FREE(list[j]);
VIR_FREE(list);
- ERROR(_("failed to allocate memory for %s config list value"),
- key);
+ VIR_ERROR(_("failed to allocate memory for %s config list value"),
+ key);
return -1;
}
@@ -1929,8 +1929,8 @@ remoteConfigGetStringList(virConfPtr con
}
default:
- ERROR(_("remoteReadConfigFile: %s: %s:"
- " must be a string or list of strings\n"),
+ VIR_ERROR(_("remoteReadConfigFile: %s: %s:"
+ " must be a string or list of strings\n"),
filename, key);
return -1;
}
@@ -1945,7 +1945,7 @@ checkType (virConfValuePtr p, const char
const char *key, virConfType required_type)
{
if (p->type != required_type) {
- ERROR(_("remoteReadConfigFile: %s: %s: invalid type:"
+ VIR_ERROR(_("remoteReadConfigFile: %s: %s: invalid type:"
" got %s; expected %s\n"), filename, key,
virConfTypeName (p->type),
virConfTypeName (required_type));
@@ -1966,7 +1966,7 @@ checkType (virConfValuePtr p, const char
goto free_and_fail; \
(var_name) = strdup (p->str); \
if ((var_name) == NULL) { \
- ERROR(_("remoteReadConfigFile: %s\n"),strerror (errno));\
+ VIR_ERROR(_("remoteReadConfigFile: %s\n"),strerror (errno)); \
goto free_and_fail; \
} \
} \
@@ -2008,7 +2008,7 @@ static int remoteConfigGetAuth(virConfPt
*auth = REMOTE_AUTH_POLKIT;
#endif
} else {
- ERROR(_("remoteReadConfigFile: %s: %s: unsupported auth %s\n"),
+ VIR_ERROR(_("remoteReadConfigFile: %s: %s: unsupported auth %s\n"),
filename, key, p->str);
return -1;
}
@@ -2155,11 +2155,11 @@ remoteReadConfigFile (struct qemud_serve
GET_CONF_STR (conf, filename, unix_sock_group);
if (unix_sock_group) {
if (getuid() != 0) {
- WARN0(_("Cannot set group when not running as root"));
+ VIR_WARN0(_("Cannot set group when not running as root"));
} else {
struct group *grp = getgrnam(unix_sock_group);
if (!grp) {
- ERROR(_("Failed to lookup group '%s'"), unix_sock_group);
+ VIR_ERROR(_("Failed to lookup group '%s'"), unix_sock_group);
goto free_and_fail;
}
unix_sock_gid = grp->gr_gid;
@@ -2171,7 +2171,7 @@ remoteReadConfigFile (struct qemud_serve
GET_CONF_STR (conf, filename, unix_sock_ro_perms);
if (unix_sock_ro_perms) {
if (virStrToLong_i (unix_sock_ro_perms, NULL, 8, &unix_sock_ro_mask) != 0) {
- ERROR(_("Failed to parse mode '%s'"), unix_sock_ro_perms);
+ VIR_ERROR(_("Failed to parse mode '%s'"), unix_sock_ro_perms);
goto free_and_fail;
}
free (unix_sock_ro_perms);
@@ -2181,7 +2181,7 @@ remoteReadConfigFile (struct qemud_serve
GET_CONF_STR (conf, filename, unix_sock_rw_perms);
if (unix_sock_rw_perms) {
if (virStrToLong_i (unix_sock_rw_perms, NULL, 8, &unix_sock_rw_mask) != 0) {
- ERROR(_("Failed to parse mode '%s'"), unix_sock_rw_perms);
+ VIR_ERROR(_("Failed to parse mode '%s'"), unix_sock_rw_perms);
goto free_and_fail;
}
free (unix_sock_rw_perms);
@@ -2374,7 +2374,7 @@ int main(int argc, char **argv) {
if (godaemon) {
if (qemudGoDaemon() < 0) {
- ERROR(_("Failed to fork as daemon: %s"), strerror(errno));
+ VIR_ERROR(_("Failed to fork as daemon: %s"), strerror(errno));
goto error1;
}
}
@@ -2395,7 +2395,7 @@ int main(int argc, char **argv) {
qemudSetNonBlock(sigpipe[1]) < 0 ||
qemudSetCloseExec(sigpipe[0]) < 0 ||
qemudSetCloseExec(sigpipe[1]) < 0) {
- ERROR(_("Failed to create pipe: %s"), strerror(errno));
+ VIR_ERROR(_("Failed to create pipe: %s"), strerror(errno));
goto error2;
}
sigwrite = sigpipe[1];
@@ -2427,14 +2427,14 @@ int main(int argc, char **argv) {
const char *sockdirname = LOCAL_STATE_DIR "/run/libvirt";
if (chown(sockdirname, -1, unix_sock_gid) < 0)
- ERROR(_("Failed to change group ownership of %s"), sockdirname);
+ VIR_ERROR(_("Failed to change group ownership of %s"), sockdirname);
}
if (virEventAddHandleImpl(sigpipe[0],
VIR_EVENT_HANDLE_READABLE,
qemudDispatchSignalEvent,
server, NULL) < 0) {
- ERROR0(_("Failed to register callback for signal pipe"));
+ VIR_ERROR0(_("Failed to register callback for signal pipe"));
ret = 3;
goto error2;
}
diff --git a/qemud/remote.c b/qemud/remote.c
--- a/qemud/remote.c
+++ b/qemud/remote.c
@@ -2542,7 +2542,7 @@ remoteDispatchAuthSaslInit (struct qemud
REMOTE_DEBUG("Initialize SASL auth %d", client->fd);
if (client->auth != REMOTE_AUTH_SASL ||
client->saslconn != NULL) {
- ERROR0(_("client tried invalid SASL init request"));
+ VIR_ERROR0(_("client tried invalid SASL init request"));
goto authfail;
}
@@ -2582,8 +2582,8 @@ remoteDispatchAuthSaslInit (struct qemud
VIR_FREE(localAddr);
VIR_FREE(remoteAddr);
if (err != SASL_OK) {
- ERROR(_("sasl context setup failed %d (%s)"),
- err, sasl_errstring(err, NULL, NULL));
+ VIR_ERROR(_("sasl context setup failed %d (%s)"),
+ err, sasl_errstring(err, NULL, NULL));
client->saslconn = NULL;
goto authfail;
}
@@ -2595,7 +2595,7 @@ remoteDispatchAuthSaslInit (struct qemud
cipher = gnutls_cipher_get(client->tlssession);
if (!(ssf = (sasl_ssf_t)gnutls_cipher_get_key_size(cipher))) {
- ERROR0(_("cannot TLS get cipher size"));
+ VIR_ERROR0(_("cannot TLS get cipher size"));
sasl_dispose(&client->saslconn);
client->saslconn = NULL;
goto authfail;
@@ -2604,8 +2604,8 @@ remoteDispatchAuthSaslInit (struct qemud
err = sasl_setprop(client->saslconn, SASL_SSF_EXTERNAL, &ssf);
if (err != SASL_OK) {
- ERROR(_("cannot set SASL external SSF %d (%s)"),
- err, sasl_errstring(err, NULL, NULL));
+ VIR_ERROR(_("cannot set SASL external SSF %d (%s)"),
+ err, sasl_errstring(err, NULL, NULL));
sasl_dispose(&client->saslconn);
client->saslconn = NULL;
goto authfail;
@@ -2632,8 +2632,8 @@ remoteDispatchAuthSaslInit (struct qemud
err = sasl_setprop(client->saslconn, SASL_SEC_PROPS, &secprops);
if (err != SASL_OK) {
- ERROR(_("cannot set SASL security props %d (%s)"),
- err, sasl_errstring(err, NULL, NULL));
+ VIR_ERROR(_("cannot set SASL security props %d (%s)"),
+ err, sasl_errstring(err, NULL, NULL));
sasl_dispose(&client->saslconn);
client->saslconn = NULL;
goto authfail;
@@ -2648,8 +2648,8 @@ remoteDispatchAuthSaslInit (struct qemud
NULL,
NULL);
if (err != SASL_OK) {
- ERROR(_("cannot list SASL mechanisms %d (%s)"),
- err, sasl_errdetail(client->saslconn));
+ VIR_ERROR(_("cannot list SASL mechanisms %d (%s)"),
+ err, sasl_errdetail(client->saslconn));
sasl_dispose(&client->saslconn);
client->saslconn = NULL;
goto authfail;
@@ -2657,7 +2657,7 @@ remoteDispatchAuthSaslInit (struct qemud
REMOTE_DEBUG("Available mechanisms for client: '%s'", mechlist);
ret->mechlist = strdup(mechlist);
if (!ret->mechlist) {
- ERROR0(_("cannot allocate mechlist"));
+ VIR_ERROR0(_("cannot allocate mechlist"));
sasl_dispose(&client->saslconn);
client->saslconn = NULL;
goto authfail;
@@ -2688,8 +2688,8 @@ remoteSASLCheckSSF (struct qemud_client
err = sasl_getprop(client->saslconn, SASL_SSF, &val);
if (err != SASL_OK) {
- ERROR(_("cannot query SASL ssf on connection %d (%s)"),
- err, sasl_errstring(err, NULL, NULL));
+ VIR_ERROR(_("cannot query SASL ssf on connection %d (%s)"),
+ err, sasl_errstring(err, NULL, NULL));
remoteDispatchAuthError(rerr);
sasl_dispose(&client->saslconn);
client->saslconn = NULL;
@@ -2698,7 +2698,7 @@ remoteSASLCheckSSF (struct qemud_client
ssf = *(const int *)val;
REMOTE_DEBUG("negotiated an SSF of %d", ssf);
if (ssf < 56) { /* 56 is good for Kerberos */
- ERROR(_("negotiated SSF %d was not strong enough"), ssf);
+ VIR_ERROR(_("negotiated SSF %d was not strong enough"), ssf);
remoteDispatchAuthError(rerr);
sasl_dispose(&client->saslconn);
client->saslconn = NULL;
@@ -2727,15 +2727,15 @@ remoteSASLCheckAccess (struct qemud_serv
err = sasl_getprop(client->saslconn, SASL_USERNAME, &val);
if (err != SASL_OK) {
- ERROR(_("cannot query SASL username on connection %d (%s)"),
- err, sasl_errstring(err, NULL, NULL));
+ VIR_ERROR(_("cannot query SASL username on connection %d (%s)"),
+ err, sasl_errstring(err, NULL, NULL));
remoteDispatchAuthError(rerr);
sasl_dispose(&client->saslconn);
client->saslconn = NULL;
return -1;
}
if (val == NULL) {
- ERROR0(_("no client username was found"));
+ VIR_ERROR0(_("no client username was found"));
remoteDispatchAuthError(rerr);
sasl_dispose(&client->saslconn);
client->saslconn = NULL;
@@ -2745,7 +2745,7 @@ remoteSASLCheckAccess (struct qemud_serv
client->saslUsername = strdup((const char*)val);
if (client->saslUsername == NULL) {
- ERROR0(_("out of memory copying username"));
+ VIR_ERROR0(_("out of memory copying username"));
remoteDispatchAuthError(rerr);
sasl_dispose(&client->saslconn);
client->saslconn = NULL;
@@ -2764,7 +2764,7 @@ remoteSASLCheckAccess (struct qemud_serv
}
/* Denied */
- ERROR(_("SASL client %s not allowed in whitelist"), client->saslUsername);
+ VIR_ERROR(_("SASL client %s not allowed in whitelist"), client->saslUsername);
remoteDispatchAuthError(rerr);
sasl_dispose(&client->saslconn);
client->saslconn = NULL;
@@ -2794,7 +2794,7 @@ remoteDispatchAuthSaslStart (struct qemu
REMOTE_DEBUG("Start SASL auth %d", client->fd);
if (client->auth != REMOTE_AUTH_SASL ||
client->saslconn == NULL) {
- ERROR0(_("client tried invalid SASL start request"));
+ VIR_ERROR0(_("client tried invalid SASL start request"));
goto authfail;
}
@@ -2809,14 +2809,14 @@ remoteDispatchAuthSaslStart (struct qemu
&serveroutlen);
if (err != SASL_OK &&
err != SASL_CONTINUE) {
- ERROR(_("sasl start failed %d (%s)"),
- err, sasl_errdetail(client->saslconn));
+ VIR_ERROR(_("sasl start failed %d (%s)"),
+ err, sasl_errdetail(client->saslconn));
sasl_dispose(&client->saslconn);
client->saslconn = NULL;
goto authfail;
}
if (serveroutlen > REMOTE_AUTH_SASL_DATA_MAX) {
- ERROR(_("sasl start reply data too long %d"), serveroutlen);
+ VIR_ERROR(_("sasl start reply data too long %d"), serveroutlen);
sasl_dispose(&client->saslconn);
client->saslconn = NULL;
goto authfail;
@@ -2881,7 +2881,7 @@ remoteDispatchAuthSaslStep (struct qemud
REMOTE_DEBUG("Step SASL auth %d", client->fd);
if (client->auth != REMOTE_AUTH_SASL ||
client->saslconn == NULL) {
- ERROR0(_("client tried invalid SASL start request"));
+ VIR_ERROR0(_("client tried invalid SASL start request"));
goto authfail;
}
@@ -2895,16 +2895,16 @@ remoteDispatchAuthSaslStep (struct qemud
&serveroutlen);
if (err != SASL_OK &&
err != SASL_CONTINUE) {
- ERROR(_("sasl step failed %d (%s)"),
- err, sasl_errdetail(client->saslconn));
+ VIR_ERROR(_("sasl step failed %d (%s)"),
+ err, sasl_errdetail(client->saslconn));
sasl_dispose(&client->saslconn);
client->saslconn = NULL;
goto authfail;
}
if (serveroutlen > REMOTE_AUTH_SASL_DATA_MAX) {
- ERROR(_("sasl step reply data too long %d"),
- serveroutlen);
+ VIR_ERROR(_("sasl step reply data too long %d"),
+ serveroutlen);
sasl_dispose(&client->saslconn);
client->saslconn = NULL;
goto authfail;
@@ -2959,7 +2959,7 @@ remoteDispatchAuthSaslInit (struct qemud
void *args ATTRIBUTE_UNUSED,
remote_auth_sasl_init_ret *ret ATTRIBUTE_UNUSED)
{
- ERROR0(_("client tried unsupported SASL init request"));
+ VIR_ERROR0(_("client tried unsupported SASL init request"));
remoteDispatchAuthError(rerr);
return -1;
}
@@ -2972,7 +2972,7 @@ remoteDispatchAuthSaslStart (struct qemu
remote_auth_sasl_start_args *args ATTRIBUTE_UNUSED,
remote_auth_sasl_start_ret *ret ATTRIBUTE_UNUSED)
{
- ERROR0(_("client tried unsupported SASL start request"));
+ VIR_ERROR0(_("client tried unsupported SASL start request"));
remoteDispatchAuthError(rerr);
return -1;
}
@@ -2985,7 +2985,7 @@ remoteDispatchAuthSaslStep (struct qemud
remote_auth_sasl_step_args *args ATTRIBUTE_UNUSED,
remote_auth_sasl_step_ret *ret ATTRIBUTE_UNUSED)
{
- ERROR0(_("client tried unsupported SASL step request"));
+ VIR_ERROR0(_("client tried unsupported SASL step request"));
remoteDispatchAuthError(rerr);
return -1;
}
@@ -3021,26 +3021,26 @@ remoteDispatchAuthPolkit (struct qemud_s
REMOTE_DEBUG("Start PolicyKit auth %d", client->fd);
if (client->auth != REMOTE_AUTH_POLKIT) {
- ERROR0(_("client tried invalid PolicyKit init request"));
+ VIR_ERROR0(_("client tried invalid PolicyKit init request"));
goto authfail;
}
if (qemudGetSocketIdentity(client->fd, &callerUid, &callerPid) < 0) {
- ERROR0(_("cannot get peer socket identity"));
- goto authfail;
- }
-
- INFO(_("Checking PID %d running as %d"), callerPid, callerUid);
+ VIR_ERROR0(_("cannot get peer socket identity"));
+ goto authfail;
+ }
+
+ VIR_INFO(_("Checking PID %d running as %d"), callerPid, callerUid);
dbus_error_init(&err);
if (!(pkcaller = polkit_caller_new_from_pid(server->sysbus,
callerPid, &err))) {
- ERROR(_("Failed to lookup policy kit caller: %s"), err.message);
+ VIR_ERROR(_("Failed to lookup policy kit caller: %s"), err.message);
dbus_error_free(&err);
goto authfail;
}
if (!(pkaction = polkit_action_new())) {
- ERROR(_("Failed to create polkit action %s\n"), strerror(errno));
+ VIR_ERROR(_("Failed to create polkit action %s\n"), strerror(errno));
polkit_caller_unref(pkcaller);
goto authfail;
}
@@ -3048,9 +3048,9 @@ remoteDispatchAuthPolkit (struct qemud_s
if (!(pkcontext = polkit_context_new()) ||
!polkit_context_init(pkcontext, &pkerr)) {
- ERROR(_("Failed to create polkit context %s\n"),
- (pkerr ? polkit_error_get_error_message(pkerr)
- : strerror(errno)));
+ VIR_ERROR(_("Failed to create polkit context %s\n"),
+ (pkerr ? polkit_error_get_error_message(pkerr)
+ : strerror(errno)));
if (pkerr)
polkit_error_free(pkerr);
polkit_caller_unref(pkcaller);
@@ -3066,9 +3066,9 @@ remoteDispatchAuthPolkit (struct qemud_s
0,
&pkerr);
if (pkerr && polkit_error_is_set(pkerr)) {
- ERROR(_("Policy kit failed to check authorization %d %s"),
- polkit_error_get_error_code(pkerr),
- polkit_error_get_error_message(pkerr));
+ VIR_ERROR(_("Policy kit failed to check authorization %d %s"),
+ polkit_error_get_error_code(pkerr),
+ polkit_error_get_error_message(pkerr));
goto authfail;
}
#else
@@ -3080,12 +3080,12 @@ remoteDispatchAuthPolkit (struct qemud_s
polkit_caller_unref(pkcaller);
polkit_action_unref(pkaction);
if (pkresult != POLKIT_RESULT_YES) {
- ERROR(_("Policy kit denied action %s from pid %d, uid %d, result: %s\n"),
- action, callerPid, callerUid,
- polkit_result_to_string_representation(pkresult));
- goto authfail;
- }
- INFO(_("Policy allowed action %s from pid %d, uid %d, result %s"),
+ VIR_ERROR(_("Policy kit denied action %s from pid %d, uid %d, result: %s\n"),
+ action, callerPid, callerUid,
+ polkit_result_to_string_representation(pkresult));
+ goto authfail;
+ }
+ VIR_INFO(_("Policy allowed action %s from pid %d, uid %d, result %s"),
action, callerPid, callerUid,
polkit_result_to_string_representation(pkresult));
ret->complete = 1;
@@ -3110,7 +3110,7 @@ remoteDispatchAuthPolkit (struct qemud_s
void *args ATTRIBUTE_UNUSED,
remote_auth_polkit_ret *ret ATTRIBUTE_UNUSED)
{
- ERROR0(_("client tried unsupported PolicyKit init request"));
+ VIR_ERROR0(_("client tried unsupported PolicyKit init request"));
remoteDispatchAuthError(rerr);
return -1;
}
diff --git a/qemud/remote_protocol.c b/qemud/remote_protocol.c
--- a/qemud/remote_protocol.c
+++ b/qemud/remote_protocol.c
@@ -332,7 +332,7 @@ xdr_remote_node_get_info_ret (XDR *xdrs,
return FALSE;
if (!xdr_quad_t (xdrs, &objp->memory))
return FALSE;
- buf = XDR_INLINE (xdrs, 6 * BYTES_PER_XDR_UNIT);
+ buf = (int32_t*)XDR_INLINE (xdrs, 6 * BYTES_PER_XDR_UNIT);
if (buf == NULL) {
if (!xdr_int (xdrs, &objp->cpus))
return FALSE;
@@ -361,7 +361,7 @@ xdr_remote_node_get_info_ret (XDR *xdrs,
return FALSE;
if (!xdr_quad_t (xdrs, &objp->memory))
return FALSE;
- buf = XDR_INLINE (xdrs, 6 * BYTES_PER_XDR_UNIT);
+ buf = (int32_t*)XDR_INLINE (xdrs, 6 * BYTES_PER_XDR_UNIT);
if (buf == NULL) {
if (!xdr_int (xdrs, &objp->cpus))
return FALSE;
diff --git a/qemud/rpcgen_fix.pl b/qemud/rpcgen_fix.pl
--- a/qemud/rpcgen_fix.pl
+++ b/qemud/rpcgen_fix.pl
@@ -68,6 +68,7 @@ while (<>) {
# be ignored. Correct both these mistakes.
@function =
map { s/\bIXDR_PUT_((U_)?)LONG\b/(void)IXDR_PUT_$1INT32/; $_ }
+ map { s/\bXDR_INLINE\b/(int32_t*)XDR_INLINE/; $_ }
@function;
print (join ("", @function));
diff --git a/src/logging.c b/src/logging.c
--- a/src/logging.c
+++ b/src/logging.c
@@ -29,6 +29,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <unistd.h>
#if HAVE_SYSLOG_H
#include <syslog.h>
#endif
@@ -483,7 +484,10 @@ void virLogMessage(const char *category,
char *str = NULL;
char *msg;
struct timeval cur_time;
- struct tm time_info;
+#if HAVE_LOCALTIME_R
+ struct tm tmdata;
+#endif
+ struct tm *tm;
int len, fprio, i, ret;
if (!virLogInitialized)
@@ -509,17 +513,21 @@ void virLogMessage(const char *category,
if (str == NULL)
return;
gettimeofday(&cur_time, NULL);
- localtime_r(&cur_time.tv_sec, &time_info);
+#if HAVE_LOCALTIME_R
+ tm = localtime_r(&cur_time.tv_sec, &tmdata);
+#else
+ tm = localtime(&cur_time.tv_sec);
+#endif
if ((funcname != NULL) && (priority == VIR_LOG_DEBUG)) {
ret = virAsprintf(&msg, "%02d:%02d:%02d.%03d: %s : %s:%lld : %s\n",
- time_info.tm_hour, time_info.tm_min,
- time_info.tm_sec, (int) cur_time.tv_usec / 1000,
+ tm->tm_hour, tm->tm_min,
+ tm->tm_sec, (int) cur_time.tv_usec / 1000,
virLogPriorityString(priority), funcname, linenr, str);
} else {
ret = virAsprintf(&msg, "%02d:%02d:%02d.%03d: %s : %s\n",
- time_info.tm_hour, time_info.tm_min,
- time_info.tm_sec, (int) cur_time.tv_usec / 1000,
+ tm->tm_hour, tm->tm_min,
+ tm->tm_sec, (int) cur_time.tv_usec / 1000,
virLogPriorityString(priority), str);
}
VIR_FREE(str);
diff --git a/src/logging.h b/src/logging.h
--- a/src/logging.h
+++ b/src/logging.h
@@ -30,48 +30,53 @@
* defined at runtime of from the libvirt daemon configuration file
*/
#ifdef ENABLE_DEBUG
-#define VIR_DEBUG(category, f, l, fmt,...) \
+#define VIR_DEBUG_INT(category, f, l, fmt,...) \
virLogMessage(category, VIR_LOG_DEBUG, f, l, 0, fmt, __VA_ARGS__)
-#define VIR_INFO(category, f, l, fmt,...) \
+#define VIR_INFO_INT(category, f, l, fmt,...) \
virLogMessage(category, VIR_LOG_INFO, f, l, 0, fmt, __VA_ARGS__)
-#define VIR_WARN(category, f, l, fmt,...) \
+#define VIR_WARN_INT(category, f, l, fmt,...) \
virLogMessage(category, VIR_LOG_WARN, f, l, 0, fmt, __VA_ARGS__)
-#define VIR_ERROR(category, f, l, fmt,...) \
+#define VIR_ERROR_INT(category, f, l, fmt,...) \
virLogMessage(category, VIR_LOG_ERROR, f, l, 0, fmt, __VA_ARGS__)
#else
-#define VIR_DEBUG(category, f, l, fmt,...) \
+#define VIR_DEBUG_INT(category, f, l, fmt,...) \
do { } while (0)
-#define VIR_INFO(category, f, l, fmt,...) \
+#define VIR_INFO_INT(category, f, l, fmt,...) \
do { } while (0)
-#define VIR_WARN(category, f, l, fmt,...) \
+#define VIR_WARN_INT(category, f, l, fmt,...) \
do { } while (0)
-#define VIR_ERROR(category, f, l, fmt,...) \
+#define VIR_ERROR_INT(category, f, l, fmt,...) \
do { } while (0)
-#define VIR_INFO(category, fmt,...) \
+#define VIR_INFO_INT(category, fmt,...) \
do { } while (0)
-#define VIR_WARN(category, fmt,...) \
+#define VIR_WARN_INT(category, fmt,...) \
do { } while (0)
-#define VIR_ERROR(category, fmt,...) \
+#define VIR_ERROR_INT(category, fmt,...) \
do { } while (0)
#endif /* !ENABLE_DEBUG */
+#define VIR_DEBUG(fmt,...) \
+ VIR_DEBUG_INT("file." __FILE__, __func__, __LINE__, fmt, __VA_ARGS__)
+#define VIR_DEBUG0(msg) \
+ VIR_DEBUG_INT("file." __FILE__, __func__, __LINE__, "%s", msg)
+#define VIR_INFO(fmt,...) \
+ VIR_INFO_INT("file." __FILE__, __func__, __LINE__, fmt, __VA_ARGS__)
+#define VIR_INFO0(msg) \
+ VIR_INFO_INT("file." __FILE__, __func__, __LINE__, "%s", msg)
+#define VIR_WARN(fmt,...) \
+ VIR_WARN_INT("file." __FILE__, __func__, __LINE__, fmt, __VA_ARGS__)
+#define VIR_WARN0(msg) \
+ VIR_WARN_INT("file." __FILE__, __func__, __LINE__, "%s", msg)
+#define VIR_ERROR(fmt,...) \
+ VIR_ERROR_INT("file." __FILE__, __func__, __LINE__, fmt, __VA_ARGS__)
+#define VIR_ERROR0(msg) \
+ VIR_ERROR_INT("file." __FILE__, __func__, __LINE__, "%s", msg)
+
+/* Legacy compat */
#define DEBUG(fmt,...) \
- VIR_DEBUG("file." __FILE__, __func__, __LINE__, fmt, __VA_ARGS__)
+ VIR_DEBUG_INT("file." __FILE__, __func__, __LINE__, fmt, __VA_ARGS__)
#define DEBUG0(msg) \
- VIR_DEBUG("file." __FILE__, __func__, __LINE__, "%s", msg)
-#define INFO(fmt,...) \
- VIR_INFO("file." __FILE__, __func__, __LINE__, fmt, __VA_ARGS__)
-#define INFO0(msg) \
- VIR_INFO("file." __FILE__, __func__, __LINE__, "%s", msg)
-#define WARN(fmt,...) \
- VIR_WARN("file." __FILE__, __func__, __LINE__, fmt, __VA_ARGS__)
-#define WARN0(msg) \
- VIR_WARN("file." __FILE__, __func__, __LINE__, "%s", msg)
-#define ERROR(fmt,...) \
- VIR_ERROR("file." __FILE__, __func__, __LINE__, fmt, __VA_ARGS__)
-#define ERROR0(msg) \
- VIR_ERROR("file." __FILE__, __func__, __LINE__, "%s", msg)
-
+ VIR_DEBUG_INT("file." __FILE__, __func__, __LINE__, "%s", msg)
/*
* To be made public
diff --git a/src/test.c b/src/test.c
--- a/src/test.c
+++ b/src/test.c
@@ -93,6 +93,7 @@ static const virNodeInfo defaultNodeInfo
virReportErrorHelper(conn, VIR_FROM_TEST, code, __FILE__, \
__FUNCTION__, __LINE__, fmt)
+#ifdef HAVE_THREAD_H
static void testDriverLock(testConnPtr driver)
{
pthread_mutex_lock(&driver->lock);
@@ -102,6 +103,10 @@ static void testDriverUnlock(testConnPtr
{
pthread_mutex_unlock(&driver->lock);
}
+#else
+static void testDriverLock(testConnPtr driver ATTRIBUTE_UNUSED) {}
+static void testDriverUnlock(testConnPtr driver ATTRIBUTE_UNUSED) {}
+#endif
static virCapsPtr
testBuildCapabilities(virConnectPtr conn) {
diff --git a/tests/nodeinfotest.c b/tests/nodeinfotest.c
--- a/tests/nodeinfotest.c
+++ b/tests/nodeinfotest.c
@@ -13,7 +13,7 @@
#ifndef __linux__
static int
-mymain(int argc, char **argv)
+mymain(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
{
exit (77); /* means 'test skipped' for automake */
}
--
|: 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 :|
3
6
Daniel Veillard noticed that "make dist" would fail
when run from a clean source directory, due to our
attempt to distribute a no-longer-generated file.
I've committed this:
>From 97e99d702dbb15176177bfd2055632ee6fdb6491 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 6 Jan 2009 16:21:24 +0100
Subject: [PATCH] fix "make dist" (from scratch) failure
* src/Makefile.am (EXTRA_DIST): Don't distribute libvirt_sym.version,
now that it's been removed. Spotted by Daniel Veillard.
---
src/Makefile.am | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index b3020cc..dd7dea8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -28,7 +28,7 @@ ICON_FILES = \
libvirt_win_icon_64x64.ico \
virsh_win_icon.rc
-EXTRA_DIST = libvirt_sym.version $(conf_DATA) $(ICON_FILES)
+EXTRA_DIST = $(conf_DATA) $(ICON_FILES)
lib_LTLIBRARIES = libvirt.la
--
1.6.1.121.g866a4a
2
1
Make sure vms don't get killed when the libvirtd quits unexpectedly.
Needs the previous patch since it looks at the pid file.
---
src/qemu_driver.c | 36 ++++++++++++++++++++++++------------
1 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index a2e573e..7804094 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -858,6 +858,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
const char *emulator;
uid_t uid = geteuid();
mode_t logmode;
+ pid_t child;
FD_ZERO(&keepfd);
@@ -988,12 +989,26 @@ static int qemudStartVMDaemon(virConnectPtr conn,
for (i = 0 ; i < ntapfds ; i++)
FD_SET(tapfds[i], &keepfd);
- ret = virExec(conn, argv, progenv, &keepfd, &vm->pid,
+ ret = virExec(conn, argv, progenv, &keepfd, &child,
vm->stdin_fd, &vm->stdout_fd, &vm->stderr_fd,
- VIR_EXEC_NONBLOCK);
- if (ret == 0)
+ VIR_EXEC_NONBLOCK | VIR_EXEC_DAEMON);
+
+ /* wait for qemu process to to show up */
+ if (ret == 0) {
+ int retries = 100;
+ while (retries) {
+ if ((ret = virFileReadPid(driver->stateDir, vm->def->name, &vm->pid)) == 0)
+ break;
+ usleep(10*1000);
+ retries--;
+ }
+ if (ret)
+ qemudLog(QEMUD_WARN, _("Domain %s didn't show up\n"), vm->def->name);
+ }
+
+ if (ret == 0) {
vm->state = migrateFrom ? VIR_DOMAIN_PAUSED : VIR_DOMAIN_RUNNING;
- else
+ } else
vm->def->id = -1;
for (i = 0 ; argv[i] ; i++)
@@ -1069,7 +1084,9 @@ static void qemudShutdownVMDaemon(virConnectPtr conn ATTRIBUTE_UNUSED,
qemudLog(QEMUD_INFO, _("Shutting down VM '%s'\n"), vm->def->name);
- kill(vm->pid, SIGTERM);
+ if (kill(vm->pid, SIGTERM) < 0)
+ qemudLog(QEMUD_ERROR, _("Failed to send SIGTERM to %s (%d): %s\n"),
+ vm->def->name, vm->pid, strerror(errno));
qemudVMData(driver, vm, vm->stdout_fd);
qemudVMData(driver, vm, vm->stderr_fd);
@@ -1089,13 +1106,8 @@ static void qemudShutdownVMDaemon(virConnectPtr conn ATTRIBUTE_UNUSED,
vm->stderr_fd = -1;
vm->monitor = -1;
- if (waitpid(vm->pid, NULL, WNOHANG) != vm->pid) {
- kill(vm->pid, SIGKILL);
- if (waitpid(vm->pid, NULL, 0) != vm->pid) {
- qemudLog(QEMUD_WARN,
- "%s", _("Got unexpected pid, damn\n"));
- }
- }
+ /* shut it off for sure */
+ kill(vm->pid, SIGKILL);
vm->pid = -1;
vm->def->id = -1;
--
1.6.0.2
3
8
Hi,
these accumulated over time. O.k. to apply?
-- Guido
3
3
06 Jan '09
Some of the new libvirt_*.syms files were
included in EXTRA_DIST only conditionally.
Here's the fix:
>From 272938681646e3aeefe5d9b13fab312a47e5d862 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 6 Jan 2009 12:09:40 +0100
Subject: [PATCH] dist: distribute all libvirt_*.syms files, ...
* src/Makefile.am (EXTRA_DIST): Distribute all libvirt_*.syms files,
not just those that happen to be selected at configure time.
---
src/Makefile.am | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 1f707e2..b3020cc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -192,7 +192,7 @@ libvirt_driver_la_SOURCES = \
libvirt_driver_la_CFLAGS = $(XEN_CFLAGS) $(NUMACTL_CFLAGS)
libvirt_driver_la_LDFLAGS = $(XEN_LIBS) $(NUMACTL_LIBS)
-PRIVSYMFILES = libvirt_private.syms
+USED_SYM_FILES = libvirt_private.syms
if WITH_TEST
if WITH_DRIVER_MODULES
@@ -412,31 +412,37 @@ EXTRA_DIST += \
#
if ENABLE_DEBUG
-PRIVSYMFILES += libvirt_debug.syms
+USED_SYM_FILES += libvirt_debug.syms
endif
if WITH_DRIVER_MODULES
-PRIVSYMFILES += libvirt_driver_modules.syms
+USED_SYM_FILES += libvirt_driver_modules.syms
endif
if WITH_BRIDGE
-PRIVSYMFILES += libvirt_bridge.syms
+USED_SYM_FILES += libvirt_bridge.syms
endif
if WITH_LINUX
-PRIVSYMFILES += libvirt_linux.syms
+USED_SYM_FILES += libvirt_linux.syms
endif
-EXTRA_DIST += libvirt_public.syms $(PRIVSYMFILES)
+EXTRA_DIST += \
+ libvirt_public.syms \
+ libvirt_private.syms \
+ libvirt_debug.syms \
+ libvirt_driver_modules.syms \
+ libvirt_bridge.syms \
+ libvirt_linux.syms
-libvirt.syms: libvirt_public.syms $(PRIVSYMFILES)
+libvirt.syms: libvirt_public.syms $(USED_SYM_FILES)
rm -f $@-tmp $@
printf '# WARNING: generated from the following:\n# $^\n\n' >$@-tmp
cat $(srcdir)/libvirt_public.syms >>$@-tmp
printf '\n\n# Private symbols\n\n' >>$@-tmp
printf 'LIBVIRT_PRIVATE_$(VERSION) {\n\n' >>$@-tmp
printf 'global:\n\n' >>$@-tmp
- for file in $(PRIVSYMFILES); do \
+ for file in $(USED_SYM_FILES); do \
cat $(srcdir)/$$file >>$@-tmp; \
done
printf '\n\nlocal:\n*;\n\n};' >>$@-tmp
--
1.6.1.rc3.350.g541da
2
2
Hi
Our VM's currently run on top of Xen Enterprise, not my choice but thats
the way it has to be at the moment. I'd like to be able to still use
cobbler/koan to provision the systems and so i have managed to get
libvirt installed onto a Xen Enterprise host. Libvirt starts but it cant
connect to Xend as i presume Xen Enterprise behaves differently to Xen.
Does anyone have any success with libvirt and Xen Enterprise ?
thanks for any tips/experience
2
3
[libvirt] [PATCH] avoid syntax-check (po-check) failure due to FP match on gettext.m4
by Jim Meyering 06 Jan '09
by Jim Meyering 06 Jan '09
06 Jan '09
spotted by Dan Berrange
and the autobuilder
http://builder.virt-manager.org/logs/modules/libvirt--devel-build-output.log
>From ee91ab81dbd458078df39ef52e22e9a489d5cc72 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 6 Jan 2009 10:42:29 +0100
Subject: [PATCH] avoid syntax-check (po-check) failure due to FP match on gettext.m4
* Makefile.maint (po-check): Exclude .m4 files.
---
Makefile.maint | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/Makefile.maint b/Makefile.maint
index 4e2d347..cfbdf56 100644
--- a/Makefile.maint
+++ b/Makefile.maint
@@ -558,6 +558,7 @@ po-check:
files=; \
for file in $$($(VC_LIST_EXCEPT)); do \
case $$file in \
+ *.m4) continue;; \
*.?|*.??) ;; \
*) continue;; \
esac; \
--
1.6.1.rc3.350.g541da
3
2
# HG changeset patch
# User john.levon(a)sun.com
# Date 1229980020 28800
# Node ID 4fbf7139ca42757d771f03578e91038bf28a5e0e
# Parent fd97ec8e5799120ebf5ea9ed73d681c6d1386970
Fix !SASL qemud compile
Replace qemudLog() with ERROR0()
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/qemud/remote.c b/qemud/remote.c
--- a/qemud/remote.c
+++ b/qemud/remote.c
@@ -2968,7 +2968,7 @@ remoteDispatchAuthSaslInit (struct qemud
void *args ATTRIBUTE_UNUSED,
remote_auth_sasl_init_ret *ret ATTRIBUTE_UNUSED)
{
- qemudLog(QEMUD_ERR, "%s", _("client tried unsupported SASL init request"));
+ ERROR0(_("client tried unsupported SASL init request"));
remoteDispatchAuthError(rerr);
return -1;
}
@@ -2981,7 +2981,7 @@ remoteDispatchAuthSaslStart (struct qemu
remote_auth_sasl_start_args *args ATTRIBUTE_UNUSED,
remote_auth_sasl_start_ret *ret ATTRIBUTE_UNUSED)
{
- qemudLog(QEMUD_ERR, "%s", _("client tried unsupported SASL start request"));
+ ERROR0(_("client tried unsupported SASL start request"));
remoteDispatchAuthError(rerr);
return -1;
}
@@ -2994,7 +2994,7 @@ remoteDispatchAuthSaslStep (struct qemud
remote_auth_sasl_step_args *args ATTRIBUTE_UNUSED,
remote_auth_sasl_step_ret *ret ATTRIBUTE_UNUSED)
{
- qemudLog(QEMUD_ERR, "%s", _("client tried unsupported SASL step request"));
+ ERROR0(_("client tried unsupported SASL step request"));
remoteDispatchAuthError(rerr);
return -1;
}
2
1
06 Jan '09
# HG changeset patch
# User john.levon(a)sun.com
# Date 1229789393 28800
# Node ID c433c57ef39b2c343653910df84130c8849a7c11
# Parent 100de621beed6e146b239df3691bd426090955b4
Make mntent.h specific to the FS storage backend
It's Linux specific, so for now, put it behind a WITH_STORAGE_FS guard.
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/src/storage_backend_fs.c b/src/storage_backend_fs.c
--- a/src/storage_backend_fs.c
+++ b/src/storage_backend_fs.c
@@ -31,7 +31,6 @@
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
-#include <mntent.h>
#include <string.h>
#include <libxml/parser.h>
@@ -242,6 +241,9 @@ static int virStorageBackendProbeFile(vi
}
#if WITH_STORAGE_FS
+
+#include <mntent.h>
+
struct _virNetfsDiscoverState {
const char *host;
virStoragePoolSourceList list;
2
1
Hi,
please find a possible asprintf vs. virAsprintf cleanup attached. There
were several occations where the result of a failed asprintf was used.
Cheers,
-- Guido
3
5
Re: [libvirt] KVM/qemu: problems with autostart of vms with non-bridged nets
by Gerd v. Egidy 05 Jan '09
by Gerd v. Egidy 05 Jan '09
05 Jan '09
> > I came up with the attached patch to fix this for me, but
> > a) I'm not sure if it is a clean use of the api to call virConnectOpen()
> > from within a state-initializer function
> > b) This is just for qemu/kvm, I haven't looked at any other drivers
> >
> > It would be nice if an experienced libvirt-developer could take a look at
> > this. Thank you very much.
>
> Thanks for the bug report & patch.
>
> Did this patch actually make it work for you ? AFAICT, there's a problem
> even earlier, which is that we are doing autostart of the virtual machines,
> before autostart of the networks and storage pools, so I'm not sure that
> this patch is sufficient.
This patch alone not, but this patch + the one in my first mail
(see https://www.redhat.com/archives/libvir-list/2008-November/msg00457.html)
together make it work for me. The first patch fixes the autostart order, the
second one adds the necessary conn structure.
Kind regards,
Gerd
--
Address (better: trap) for people I really don't want to get mail from:
james(a)cactusamerica.com
3
7
This series starts splitting up the linker script into various portions, as described within.
4
11
05 Jan '09
Building "make distcheck", I saw this go by:
/usr/bin/xgettext: warning: The option --msgid-bugs-address was not specified.
If you are using a `Makevars' file, please specify
the MSGID_BUGS_ADDRESS variable there; otherwise please
specify an --msgid-bugs-address command line option.
Here's the part of Makevars where that's defined:
# This is the email address or URL to which the translators shall report
# bugs in the untranslated strings:
# - Strings which are not entire sentences, see the maintainer guidelines
# in the GNU gettext documentation, section 'Preparing Strings'.
# - Strings which use unclear terms or require additional context to be
# understood.
# - Strings which make invalid assumptions about notation of date, time or
# money.
# - Pluralisation problems.
# - Incorrect English spelling.
# - Incorrect formatting.
# It can be your email address, or a mailing list address where translators
# can write to without being subscribed, or the URL of a web page through
# which the translators can contact you.
MSGID_BUGS_ADDRESS = http://translate.fedoraproject.org/
I figure it's better to point people at the Fedora Translation pages
than at libvirt's mailing list.
I had to propagate this into libvirt.pot as well to avoid
a "make distcheck" failure when update-po would try to move
the just-changed libvirt.po onto a read-only libvirt.pot file
because of the differing Report-Msgid-Bugs-To line.
>From 1bb5f75174200e465038ac5cb5b7eee2e798627b Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Mon, 5 Jan 2009 10:23:52 +0100
Subject: [PATCH] avoid xgettext warning aboug bug-reporting address
* po/Makevars (MSGID_BUGS_ADDRESS): Set, to avoid xgettext warning.
* po/libvirt.pot: Set bug-reporting address.
---
po/Makevars | 2 +-
po/libvirt.pot | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/po/Makevars b/po/Makevars
index 32692ab..9fbda10 100644
--- a/po/Makevars
+++ b/po/Makevars
@@ -34,7 +34,7 @@ COPYRIGHT_HOLDER = Free Software Foundation, Inc.
# It can be your email address, or a mailing list address where translators
# can write to without being subscribed, or the URL of a web page through
# which the translators can contact you.
-MSGID_BUGS_ADDRESS =
+MSGID_BUGS_ADDRESS = http://translate.fedoraproject.org/
# This is the list of locale categories, beyond LC_MESSAGES, for which the
# message catalogs shall be used. It is usually empty.
diff --git a/po/libvirt.pot b/po/libvirt.pot
index 92d6d88..23e6987 100644
--- a/po/libvirt.pot
+++ b/po/libvirt.pot
@@ -7,7 +7,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
+"Report-Msgid-Bugs-To: http://translate.fedoraproject.org/\n"
"POT-Creation-Date: 2008-12-04 16:26+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
--
1.6.1.rc3.350.g541da
4
4
Here are two warning-avoidance changes I'm about to commit:
>From 588ecf78ffd6f284aa7872c13d946b9b5a146ef0 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 23 Dec 2008 16:49:26 +0100
Subject: [PATCH 1/2] mark a few diagnostics for translation
* src/xen_inotify.c (xenInotifyXendDomainsDirLookup): Mark a diagnostic.
(xenInotifyXendDomainsDirRemoveEntry, xenInotifyOpen): Likewise.
---
src/xen_inotify.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/xen_inotify.c b/src/xen_inotify.c
index fe1bc76..f6a7992 100644
--- a/src/xen_inotify.c
+++ b/src/xen_inotify.c
@@ -128,7 +128,7 @@ xenInotifyXendDomainsDirLookup(virConnectPtr conn, const char *filename,
if (virUUIDParse(uuid_str, rawuuid) < 0) {
virXenInotifyError(NULL, VIR_ERR_INTERNAL_ERROR,
- "parsing uuid %s", uuid_str);
+ _("parsing uuid %s"), uuid_str);
return -1;
}
/* call directly into xend here, as driver may not yet
@@ -145,7 +145,7 @@ xenInotifyXendDomainsDirLookup(virConnectPtr conn, const char *filename,
*name = strdup(configInfoList->doms[i]->name);
if (!*name) {
virXenInotifyError(NULL, VIR_ERR_INTERNAL_ERROR,
- "finding dom for %s", uuid_str);
+ _("finding dom for %s"), uuid_str);
return -1;
}
memcpy(uuid, configInfoList->doms[i]->uuid, VIR_UUID_BUFLEN);
@@ -201,7 +201,7 @@ xenInotifyXendDomainsDirRemoveEntry(virConnectPtr conn ATTRIBUTE_UNUSED,
if (virUUIDParse(uuidstr, uuid) < 0) {
virXenInotifyError(NULL, VIR_ERR_INTERNAL_ERROR,
- "parsing uuid %s", uuidstr);
+ _("parsing uuid %s"), uuidstr);
return -1;
}
@@ -428,7 +428,7 @@ xenInotifyOpen(virConnectPtr conn ATTRIBUTE_UNUSED,
IN_CLOSE_WRITE | IN_DELETE |
IN_MOVED_TO | IN_MOVED_FROM) < 0) {
virXenInotifyError(NULL, VIR_ERR_INTERNAL_ERROR,
- "adding watch on %s", _(configDir));
+ _("adding watch on %s"), _(configDir));
return -1;
}
--
1.6.1.302.gccd4d
>From 527665ea39b24b46c9f276b879dbcf12049787c4 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 23 Dec 2008 16:54:05 +0100
Subject: [PATCH 2/2] * Makefile.maint (msg_gen_function): Add to the list.
---
Makefile.maint | 64 +++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 47 insertions(+), 17 deletions(-)
diff --git a/Makefile.maint b/Makefile.maint
index 0f43b1c..2f65bcf 100644
--- a/Makefile.maint
+++ b/Makefile.maint
@@ -361,36 +361,66 @@ sc_two_space_separator_in_usage:
echo "$(ME): an option and its description"; \
1>&2; exit 1; } || :
+# Many of the function names below came from this filter:
+# git grep -B2 '\<_('|grep -E '\.c- *[[:alpha:]_][[:alnum:]_]* ?\(.*[,;]$' \
+# |sed 's/.*\.c- *//'|perl -pe 's/ ?\(.*//'|sort -u \
+# |grep -vE '^(qsort|if|close|assert|fputc|free|N_|vir.*GetName|.*Unlock|virNodeListDevices|virHashRemoveEntry|freeaddrinfo|.*[fF]ree|xdrmem_create|xmlXPathFreeObject|virUUIDFormat|openvzSetProgramSentinal|polkit_action_unref)$'
+
msg_gen_function =
+msg_gen_function += DEBUG0
msg_gen_function += DISABLE_fprintf
-msg_gen_function += virXendError
-msg_gen_function += virXMLError
-msg_gen_function += virHashError
+msg_gen_function += ERROR
+msg_gen_function += ERROR0
+msg_gen_function += REMOTE_DEBUG
+msg_gen_function += ReportError
+msg_gen_function += VIR_FREE
+msg_gen_function += VIR_USE_CPU
+msg_gen_function += errorf
+msg_gen_function += lxcError
+msg_gen_function += networkLog
+msg_gen_function += networkReportError
+msg_gen_function += openvzError
+msg_gen_function += openvzLog
+msg_gen_function += qemudDispatchClientFailure
+msg_gen_function += qemudLog
+msg_gen_function += qemudReportError
+msg_gen_function += regerror
+msg_gen_function += remoteDispatchError
+msg_gen_function += remoteDispatchFormatError
+msg_gen_function += umlError
+msg_gen_function += umlLog
+msg_gen_function += umlReportError
msg_gen_function += virConfError
-msg_gen_function += virTestError
+msg_gen_function += virDomainReportError
+msg_gen_function += virHashError
msg_gen_function += virLibConnError
-msg_gen_function += virStorageReportError
-msg_gen_function += virxmlRpcError
+msg_gen_function += virLibDomainError
msg_gen_function += virLog
-msg_gen_function += qemudLog
-msg_gen_function += remoteDispatchError
+msg_gen_function += virNetworkReportError
+msg_gen_function += virNodeDeviceReportError
+msg_gen_function += virRaiseError
+msg_gen_function += virReportErrorHelper
+msg_gen_function += virSexprError
msg_gen_function += virStorageLog
+msg_gen_function += virStorageReportError
+msg_gen_function += virTestError
+msg_gen_function += virXMLError
+msg_gen_function += virXenInotifyError
+msg_gen_function += virXenStoreError
+msg_gen_function += virXendError
+msg_gen_function += virxmlRpcError
+msg_gen_function += vshCloseLogFile
msg_gen_function += xenXMError
-msg_gen_function += ReportError
-msg_gen_function += qemudReportError
-msg_gen_function += openvzLog
-msg_gen_function += openvzError
-msg_gen_function += virDomainReportError
-msg_gen_function += virReportErrorHelper
-msg_gen_function += lxcError
-msg_gen_function += umlError
# Uncomment the following and run "make syntax-check" to see diagnostics
# that are not yet marked for translation, but that need to be rewritten
# so that they are translatable.
# msg_gen_function += error
-# msg_gen_function += virXenError
+# msg_gen_function += fprintf
# msg_gen_function += testError
+# msg_gen_function += virXenError
+# msg_gen_function += vshPrint
+# msg_gen_function += vshError
func_or := $(shell printf '$(msg_gen_function)'|tr -s '[[:space:]]' '|')
func_re := ($(func_or))
--
1.6.1.302.gccd4d
3
2