[libvirt] [PATCH] Fix another printf("%s", NULL) case
by john.levon@sun.com
# HG changeset patch
# User john.levon(a)sun.com
# Date 1233199841 28800
# Node ID 3f2af372963ddbae509bd0d1b2e7bdf3ebb4f217
# Parent 76d670ab6ea5476be96441ea88af94644c985201
Fix another printf("%s", NULL) case
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/src/libvirt.c b/src/libvirt.c
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -6922,7 +6922,7 @@ int
int
virNodeNumOfDevices(virConnectPtr conn, const char *cap, unsigned int flags)
{
- DEBUG("conn=%p, cap=%s, flags=%d", conn, cap, flags);
+ DEBUG("conn=%p, cap=%s, flags=%d", conn, NULLSTR(cap), flags);
virResetLastError();
15 years, 11 months
[libvirt] [PATCH] Fixes for VNC port handling
by john.levon@sun.com
# HG changeset patch
# User john.levon(a)sun.com
# Date 1233162577 28800
# Node ID 6ab030d99574ee01193e92846eb7c9b41bfcd149
# Parent 5a0860d81ed44d5f189788fc340f975517595160
Fixes for VNC port handling
When parsing sexpr, the VNC port should not be ignored, even when vncunused is
set. Fix the parsing of vncdisplay, which was broken due to strtol() (never
use this function!).
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/src/util.c b/src/util.c
--- a/src/util.c
+++ b/src/util.c
@@ -1041,6 +1041,7 @@ cleanup:
return rc;
}
+#endif /* PROXY */
/* Like strtol, but produce an "int" result, and check more carefully.
@@ -1123,7 +1124,6 @@ virStrToLong_ull(char const *s, char **e
*result = val;
return 0;
}
-#endif /* PROXY */
/**
* virSkipSpaces:
diff --git a/src/xend_internal.c b/src/xend_internal.c
--- a/src/xend_internal.c
+++ b/src/xend_internal.c
@@ -612,7 +612,9 @@ sexpr_get(virConnectPtr xend, const char
*
* convenience function to lookup an int value in the S-Expression
*
- * Returns the value found or 0 if not found (but may not be an error)
+ * Returns the value found or 0 if not found (but may not be an error).
+ * This function suffers from the flaw that zero is both a correct
+ * return value and an error indicator: careful!
*/
static int
sexpr_int(const struct sexpr *sexpr, const char *name)
@@ -2091,15 +2093,16 @@ xenDaemonParseSxprGraphicsNew(virConnect
port = xenStoreDomainGetVNCPort(conn, def->id);
xenUnifiedUnlock(priv);
+ // Didn't find port entry in xenstore
if (port == -1) {
- // Didn't find port entry in xenstore
- port = sexpr_int(node, "device/vfb/vncdisplay");
+ const char *str = sexpr_node(node, "device/vfb/vncdisplay");
+ int val;
+ if (str != NULL && virStrToLong_i(str, NULL, 0, &val) == 0)
+ port = val;
}
- if ((unused && STREQ(unused, "1")) || port == -1) {
+ if ((unused && STREQ(unused, "1")) || port == -1)
graphics->data.vnc.autoport = 1;
- port = -1;
- }
if (port >= 0 && port < 5900)
port += 5900;
diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-autoport.sexpr b/tests/sexpr2xmldata/sexpr2xml-fv-autoport.sexpr
new file mode 100644
--- /dev/null
+++ b/tests/sexpr2xmldata/sexpr2xml-fv-autoport.sexpr
@@ -0,0 +1,86 @@
+(domain
+ (domid 21)
+ (on_crash destroy)
+ (uuid e0c172e6-4ad8-7353-0ece-515d2f181365)
+ (bootloader_args )
+ (vcpus 1)
+ (name domu-224)
+ (on_poweroff destroy)
+ (on_reboot destroy)
+ (bootloader )
+ (maxmem 512)
+ (memory 512)
+ (shadow_memory 5)
+ (cpu_weight 256)
+ (cpu_cap 0)
+ (features )
+ (on_xend_start ignore)
+ (on_xend_stop shutdown)
+ (start_time 1233108538.42)
+ (cpu_time 907.159661051)
+ (online_vcpus 1)
+ (image
+ (hvm
+ (kernel /usr/lib/xen/boot/hvmloader)
+ (boot d)
+ (device_model /usr/lib/xen/bin/qemu-dm)
+ (keymap en-us)
+ (localtime 1)
+ (pae 1)
+ (serial pty)
+ (usb 1)
+ (usbdevice tablet)
+ (notes (SUSPEND_CANCEL 1))
+ )
+ )
+ (status 2)
+ (state r-----)
+ (store_mfn 131070)
+ (device
+ (vif
+ (bridge e1000g0)
+ (mac 00:16:3e:1b:e8:18)
+ (script vif-vnic)
+ (uuid 7da8c614-018b-dc87-6bfc-a296a95bca4f)
+ (backend 0)
+ )
+ )
+ (device
+ (vbd
+ (uname phy:/iscsi/winxp)
+ (uuid 65e19258-f4a2-a9ff-3b31-469ceaf4ec8d)
+ (mode w)
+ (dev hda:disk)
+ (backend 0)
+ (bootable 1)
+ )
+ )
+ (device
+ (vbd
+ (uname file:/net/heaped/export/netimage/windows/xp-sp2-vol.iso)
+ (uuid 87d9383b-f0ad-11a4-d668-b965f55edc3f)
+ (mode r)
+ (dev hdc:cdrom)
+ (backend 0)
+ (bootable 0)
+ )
+ )
+ (device (vkbd (backend 0)))
+ (device
+ (vfb
+ (vncdisplay 25)
+ (vncunused 1)
+ (keymap en-us)
+ (type vnc)
+ (uuid 09666ad1-0c94-d79c-1439-99e05394ee51)
+ (location localhost:5925)
+ )
+ )
+ (device
+ (console
+ (protocol vt100)
+ (location 3)
+ (uuid cabfc0f5-1c9c-0e6f-aaa8-9974262aff66)
+ )
+ )
+)
diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml b/tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml
new file mode 100644
--- /dev/null
+++ b/tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml
@@ -0,0 +1,48 @@
+<domain type='xen' id='21'>
+ <name>domu-224</name>
+ <uuid>e0c172e6-4ad8-7353-0ece-515d2f181365</uuid>
+ <memory>524288</memory>
+ <currentMemory>524288</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type>hvm</type>
+ <loader>/usr/lib/xen/boot/hvmloader</loader>
+ <boot dev='cdrom'/>
+ </os>
+ <features>
+ <pae/>
+ </features>
+ <clock offset='localtime'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>destroy</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
+ <disk type='block' device='disk'>
+ <driver name='phy'/>
+ <source dev='/iscsi/winxp'/>
+ <target dev='hda' bus='ide'/>
+ </disk>
+ <disk type='file' device='cdrom'>
+ <driver name='file'/>
+ <source file='/net/heaped/export/netimage/windows/xp-sp2-vol.iso'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ </disk>
+ <interface type='bridge'>
+ <mac address='00:16:3e:1b:e8:18'/>
+ <source bridge='e1000g0'/>
+ <script path='vif-vnic'/>
+ <target dev='vif21.0'/>
+ </interface>
+ <serial type='pty'>
+ <target port='0'/>
+ </serial>
+ <console type='pty'>
+ <target port='0'/>
+ </console>
+ <input type='tablet' bus='usb'/>
+ <input type='mouse' bus='ps2'/>
+ <graphics type='vnc' port='5925' autoport='yes' keymap='en-us'/>
+ </devices>
+</domain>
diff --git a/tests/sexpr2xmltest.c b/tests/sexpr2xmltest.c
--- a/tests/sexpr2xmltest.c
+++ b/tests/sexpr2xmltest.c
@@ -127,6 +127,7 @@ mymain(int argc, char **argv)
DO_TEST("pv-vfb-orig", "pv-vfb-orig", 2);
DO_TEST("pv-vfb-new", "pv-vfb-new", 3);
DO_TEST("pv-vfb-new-vncdisplay", "pv-vfb-new-vncdisplay", 3);
+ DO_TEST("fv-autoport", "fv-autoport", 3);
DO_TEST("pv-bootloader", "pv-bootloader", 1);
DO_TEST("disk-file", "disk-file", 2);
15 years, 11 months
[libvirt] [Patch][RFC] Fine grained access control in libvirt by rbac (0/3)
by Syunsuke HAYASHI
The series of patches introduces a fine grained access control to
libvirt. They enable libvirt to enforce users what operations to invoke
in role-based way. Our team found that Konrad and Daniel have similar
interest to ours. Comments and suggestions are very welcome.
Patches:
- Embedding hooks in libvirt (1/3)
- Access control library (2/3)
- Example policy files (3/3)
15 years, 11 months
[libvirt] PATCH: rpcgen portability fixes for remote_protocol.c/h
by Daniel P. Berrange
As per previous patches from John for Solaris, we ned a couple more fixes
to the generated remote_protocol.c/h files for good portability.
Specifically we need
s/u_quad_t/uint64_t/g;
s/quad_t/int64_t/g;
s/xdr_u_quad_t/xdr_uint64_t/g;
s/xdr_quad_t/xdr_int64_t/g;
s/IXDR_GET_LONG/IXDR_GET_INT32/g;
I have finally got around to verifying that this won't change wire
ABI on Linux
The first two data types int64 and quad_t are all fixed 64-bit ints,
so that's safe.
And the xdr_quad functions have this in the source
strong_alias (xdr_int64_t, xdr_quad_t)
strong_alias (xdr_int64_t, xdr_u_quad_t)
So that change is no-op.
Finally the glibc rpc/xdr.h has
#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))
So I believe this is all safe.
Daniel
Index: configure.in
===================================================================
RCS file: /data/cvs/libvirt/configure.in,v
retrieving revision 1.202
diff -u -p -r1.202 configure.in
--- configure.in 27 Jan 2009 15:29:53 -0000 1.202
+++ configure.in 28 Jan 2009 12:30:59 -0000
@@ -92,9 +92,9 @@ AC_CHECK_LIB([intl],[gettext],[])
dnl Do we have rpcgen?
AC_PATH_PROG([RPCGEN], [rpcgen], [no])
-AM_CONDITIONAL([RPCGEN], [test "x$ac_cv_path_RPCGEN" != "xno"])
+AM_CONDITIONAL([HAVE_RPCGEN], [test "x$ac_cv_path_RPCGEN" != "xno"])
dnl Is this GLIBC's buggy rpcgen?
-AM_CONDITIONAL([GLIBC_RPCGEN],
+AM_CONDITIONAL([HAVE_GLIBC_RPCGEN],
[test "x$ac_cv_path_RPCGEN" != "xno" &&
$ac_cv_path_RPCGEN -t </dev/null >/dev/null 2>&1])
Index: qemud/Makefile.am
===================================================================
RCS file: /data/cvs/libvirt/qemud/Makefile.am,v
retrieving revision 1.72
diff -u -p -r1.72 Makefile.am
--- qemud/Makefile.am 12 Jan 2009 19:19:22 -0000 1.72
+++ qemud/Makefile.am 28 Jan 2009 12:31:00 -0000
@@ -1,7 +1,5 @@
## Process this file with automake to produce Makefile.in
-RPCGEN = $(RPCGEN)
-
DAEMON_SOURCES = \
event.c event.h \
qemud.c qemud.h \
@@ -33,32 +31,34 @@ EXTRA_DIST = \
$(AVAHI_SOURCES) \
$(DAEMON_SOURCES)
-if RPCGEN
-SUFFIXES = .x
-# The subshell ensures that remote_protocol.c ends up
-# including <config.h> before "remote_protocol.h".
-.x.c:
- rm -f $@ $@-t $@-t1 $@-t2
- $(RPCGEN) -c -o $@-t $<
- (echo '#include <config.h>'; cat $@-t) > $@-t1
-if GLIBC_RPCGEN
- perl -w rpcgen_fix.pl $@-t1 > $@-t2
- rm $@-t1
- chmod 444 $@-t2
- mv $@-t2 $@
+if HAVE_RPCGEN
+#
+# Maintainer-only target for re-generating the derived .c/.h source
+# files, which are actually derived from the .x file.
+#
+# For committing protocol changes to CVS, the GLIBC rpcgen *must*
+# be used.
+#
+# Support for non-GLIB rpcgen is here as a convenience for
+# non-Linux people needing to test changes during dev.
+#
+rpcgen:
+ rm -f rp.c-t rp.h-t rp.c-t1 rp.c-t2 rp.h-t1
+ $(RPCGEN) -h -o rp.h-t $(srcdir)/remote_protocol.x
+ $(RPCGEN) -c -o rp.c-t $(srcdir)/remote_protocol.x
+if HAVE_GLIBC_RPCGEN
+ perl -w $(srcdir)/rpcgen_fix.pl rp.h-t > rp.h-t1
+ perl -w $(srcdir)/rpcgen_fix.pl rp.c-t > rp.c-t1
+ (echo '#include <config.h>'; cat rp.c-t1) > rp.c-t2
+ chmod 0444 rp.c-t2 rp.h-t1
+ mv -f rp.h-t1 $(srcdir)/remote_protocol.h
+ mv -f rp.c-t2 $(srcdir)/remote_protocol.c
+ rm -f rp.c-t rp.h-t rp.c-t1
else
- chmod 444 $@-t1
- mv $@-t1 $@
-endif
-
-.x.h:
- rm -f $@ $@-t
- $(RPCGEN) -h -o $@-t $<
-if GLIBC_RPCGEN
- perl -pi -e 's/\t/ /g' $@-t
+ chmod 0444 rp.c-t rp.h-t
+ mv -f rp.h-t $(srcdir)/remote_protocol.h
+ mv -f rp.c-t $(srcdir)/remote_protocol.c
endif
- chmod 444 $@-t
- mv $@-t $@
endif
remote_protocol.c: remote_protocol.h
Index: qemud/remote_protocol.c
===================================================================
RCS file: /data/cvs/libvirt/qemud/remote_protocol.c,v
retrieving revision 1.27
diff -u -p -r1.27 remote_protocol.c
--- qemud/remote_protocol.c 6 Jan 2009 18:32:03 -0000 1.27
+++ qemud/remote_protocol.c 28 Jan 2009 12:31:00 -0000
@@ -183,7 +183,7 @@ xdr_remote_vcpu_info (XDR *xdrs, remote_
return FALSE;
if (!xdr_int (xdrs, &objp->state))
return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->cpu_time))
+ if (!xdr_uint64_t (xdrs, &objp->cpu_time))
return FALSE;
if (!xdr_int (xdrs, &objp->cpu))
return FALSE;
@@ -205,11 +205,11 @@ xdr_remote_sched_param_value (XDR *xdrs,
return FALSE;
break;
case VIR_DOMAIN_SCHED_FIELD_LLONG:
- if (!xdr_quad_t (xdrs, &objp->remote_sched_param_value_u.l))
+ if (!xdr_int64_t (xdrs, &objp->remote_sched_param_value_u.l))
return FALSE;
break;
case VIR_DOMAIN_SCHED_FIELD_ULLONG:
- if (!xdr_u_quad_t (xdrs, &objp->remote_sched_param_value_u.ul))
+ if (!xdr_uint64_t (xdrs, &objp->remote_sched_param_value_u.ul))
return FALSE;
break;
case VIR_DOMAIN_SCHED_FIELD_DOUBLE:
@@ -279,7 +279,7 @@ bool_t
xdr_remote_get_version_ret (XDR *xdrs, remote_get_version_ret *objp)
{
- if (!xdr_quad_t (xdrs, &objp->hv_ver))
+ if (!xdr_int64_t (xdrs, &objp->hv_ver))
return FALSE;
return TRUE;
}
@@ -330,7 +330,7 @@ xdr_remote_node_get_info_ret (XDR *xdrs,
if (!xdr_vector (xdrs, (char *)objp->model, 32,
sizeof (char), (xdrproc_t) xdr_char))
return FALSE;
- if (!xdr_quad_t (xdrs, &objp->memory))
+ if (!xdr_int64_t (xdrs, &objp->memory))
return FALSE;
buf = (int32_t*)XDR_INLINE (xdrs, 6 * BYTES_PER_XDR_UNIT);
if (buf == NULL) {
@@ -359,7 +359,7 @@ xdr_remote_node_get_info_ret (XDR *xdrs,
if (!xdr_vector (xdrs, (char *)objp->model, 32,
sizeof (char), (xdrproc_t) xdr_char))
return FALSE;
- if (!xdr_quad_t (xdrs, &objp->memory))
+ if (!xdr_int64_t (xdrs, &objp->memory))
return FALSE;
buf = (int32_t*)XDR_INLINE (xdrs, 6 * BYTES_PER_XDR_UNIT);
if (buf == NULL) {
@@ -376,12 +376,12 @@ xdr_remote_node_get_info_ret (XDR *xdrs,
if (!xdr_int (xdrs, &objp->threads))
return FALSE;
} else {
- objp->cpus = IXDR_GET_LONG(buf);
- objp->mhz = IXDR_GET_LONG(buf);
- objp->nodes = IXDR_GET_LONG(buf);
- objp->sockets = IXDR_GET_LONG(buf);
- objp->cores = IXDR_GET_LONG(buf);
- objp->threads = IXDR_GET_LONG(buf);
+ objp->cpus = IXDR_GET_INT32(buf);
+ objp->mhz = IXDR_GET_INT32(buf);
+ objp->nodes = IXDR_GET_INT32(buf);
+ objp->sockets = IXDR_GET_INT32(buf);
+ objp->cores = IXDR_GET_INT32(buf);
+ objp->threads = IXDR_GET_INT32(buf);
}
return TRUE;
}
@@ -389,7 +389,7 @@ xdr_remote_node_get_info_ret (XDR *xdrs,
if (!xdr_vector (xdrs, (char *)objp->model, 32,
sizeof (char), (xdrproc_t) xdr_char))
return FALSE;
- if (!xdr_quad_t (xdrs, &objp->memory))
+ if (!xdr_int64_t (xdrs, &objp->memory))
return FALSE;
if (!xdr_int (xdrs, &objp->cpus))
return FALSE;
@@ -432,7 +432,7 @@ xdr_remote_node_get_cells_free_memory_re
char **objp_cpp0 = (char **) (void *) &objp->freeMems.freeMems_val;
if (!xdr_array (xdrs, objp_cpp0, (u_int *) &objp->freeMems.freeMems_len, REMOTE_NODE_MAX_CELLS,
- sizeof (quad_t), (xdrproc_t) xdr_quad_t))
+ sizeof (int64_t), (xdrproc_t) xdr_int64_t))
return FALSE;
return TRUE;
}
@@ -441,7 +441,7 @@ bool_t
xdr_remote_node_get_free_memory_ret (XDR *xdrs, remote_node_get_free_memory_ret *objp)
{
- if (!xdr_quad_t (xdrs, &objp->freeMem))
+ if (!xdr_int64_t (xdrs, &objp->freeMem))
return FALSE;
return TRUE;
}
@@ -516,15 +516,15 @@ bool_t
xdr_remote_domain_block_stats_ret (XDR *xdrs, remote_domain_block_stats_ret *objp)
{
- if (!xdr_quad_t (xdrs, &objp->rd_req))
+ if (!xdr_int64_t (xdrs, &objp->rd_req))
return FALSE;
- if (!xdr_quad_t (xdrs, &objp->rd_bytes))
+ if (!xdr_int64_t (xdrs, &objp->rd_bytes))
return FALSE;
- if (!xdr_quad_t (xdrs, &objp->wr_req))
+ if (!xdr_int64_t (xdrs, &objp->wr_req))
return FALSE;
- if (!xdr_quad_t (xdrs, &objp->wr_bytes))
+ if (!xdr_int64_t (xdrs, &objp->wr_bytes))
return FALSE;
- if (!xdr_quad_t (xdrs, &objp->errs))
+ if (!xdr_int64_t (xdrs, &objp->errs))
return FALSE;
return TRUE;
}
@@ -544,21 +544,21 @@ bool_t
xdr_remote_domain_interface_stats_ret (XDR *xdrs, remote_domain_interface_stats_ret *objp)
{
- if (!xdr_quad_t (xdrs, &objp->rx_bytes))
+ if (!xdr_int64_t (xdrs, &objp->rx_bytes))
return FALSE;
- if (!xdr_quad_t (xdrs, &objp->rx_packets))
+ if (!xdr_int64_t (xdrs, &objp->rx_packets))
return FALSE;
- if (!xdr_quad_t (xdrs, &objp->rx_errs))
+ if (!xdr_int64_t (xdrs, &objp->rx_errs))
return FALSE;
- if (!xdr_quad_t (xdrs, &objp->rx_drop))
+ if (!xdr_int64_t (xdrs, &objp->rx_drop))
return FALSE;
- if (!xdr_quad_t (xdrs, &objp->tx_bytes))
+ if (!xdr_int64_t (xdrs, &objp->tx_bytes))
return FALSE;
- if (!xdr_quad_t (xdrs, &objp->tx_packets))
+ if (!xdr_int64_t (xdrs, &objp->tx_packets))
return FALSE;
- if (!xdr_quad_t (xdrs, &objp->tx_errs))
+ if (!xdr_int64_t (xdrs, &objp->tx_errs))
return FALSE;
- if (!xdr_quad_t (xdrs, &objp->tx_drop))
+ if (!xdr_int64_t (xdrs, &objp->tx_drop))
return FALSE;
return TRUE;
}
@@ -571,7 +571,7 @@ xdr_remote_domain_block_peek_args (XDR *
return FALSE;
if (!xdr_remote_nonnull_string (xdrs, &objp->path))
return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->offset))
+ if (!xdr_uint64_t (xdrs, &objp->offset))
return FALSE;
if (!xdr_u_int (xdrs, &objp->size))
return FALSE;
@@ -596,7 +596,7 @@ xdr_remote_domain_memory_peek_args (XDR
if (!xdr_remote_nonnull_domain (xdrs, &objp->dom))
return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->offset))
+ if (!xdr_uint64_t (xdrs, &objp->offset))
return FALSE;
if (!xdr_u_int (xdrs, &objp->size))
return FALSE;
@@ -796,7 +796,7 @@ bool_t
xdr_remote_domain_get_max_memory_ret (XDR *xdrs, remote_domain_get_max_memory_ret *objp)
{
- if (!xdr_u_quad_t (xdrs, &objp->memory))
+ if (!xdr_uint64_t (xdrs, &objp->memory))
return FALSE;
return TRUE;
}
@@ -807,7 +807,7 @@ xdr_remote_domain_set_max_memory_args (X
if (!xdr_remote_nonnull_domain (xdrs, &objp->dom))
return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->memory))
+ if (!xdr_uint64_t (xdrs, &objp->memory))
return FALSE;
return TRUE;
}
@@ -818,7 +818,7 @@ xdr_remote_domain_set_memory_args (XDR *
if (!xdr_remote_nonnull_domain (xdrs, &objp->dom))
return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->memory))
+ if (!xdr_uint64_t (xdrs, &objp->memory))
return FALSE;
return TRUE;
}
@@ -838,13 +838,13 @@ xdr_remote_domain_get_info_ret (XDR *xdr
if (!xdr_u_char (xdrs, &objp->state))
return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->max_mem))
+ if (!xdr_uint64_t (xdrs, &objp->max_mem))
return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->memory))
+ if (!xdr_uint64_t (xdrs, &objp->memory))
return FALSE;
if (!xdr_u_short (xdrs, &objp->nr_virt_cpu))
return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->cpu_time))
+ if (!xdr_uint64_t (xdrs, &objp->cpu_time))
return FALSE;
return TRUE;
}
@@ -908,11 +908,11 @@ xdr_remote_domain_migrate_prepare_args (
if (!xdr_remote_string (xdrs, &objp->uri_in))
return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->flags))
+ if (!xdr_uint64_t (xdrs, &objp->flags))
return FALSE;
if (!xdr_remote_string (xdrs, &objp->dname))
return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->resource))
+ if (!xdr_uint64_t (xdrs, &objp->resource))
return FALSE;
return TRUE;
}
@@ -940,11 +940,11 @@ xdr_remote_domain_migrate_perform_args (
return FALSE;
if (!xdr_remote_nonnull_string (xdrs, &objp->uri))
return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->flags))
+ if (!xdr_uint64_t (xdrs, &objp->flags))
return FALSE;
if (!xdr_remote_string (xdrs, &objp->dname))
return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->resource))
+ if (!xdr_uint64_t (xdrs, &objp->resource))
return FALSE;
return TRUE;
}
@@ -960,7 +960,7 @@ xdr_remote_domain_migrate_finish_args (X
return FALSE;
if (!xdr_remote_nonnull_string (xdrs, &objp->uri))
return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->flags))
+ if (!xdr_uint64_t (xdrs, &objp->flags))
return FALSE;
return TRUE;
}
@@ -980,11 +980,11 @@ xdr_remote_domain_migrate_prepare2_args
if (!xdr_remote_string (xdrs, &objp->uri_in))
return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->flags))
+ if (!xdr_uint64_t (xdrs, &objp->flags))
return FALSE;
if (!xdr_remote_string (xdrs, &objp->dname))
return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->resource))
+ if (!xdr_uint64_t (xdrs, &objp->resource))
return FALSE;
if (!xdr_remote_nonnull_string (xdrs, &objp->dom_xml))
return FALSE;
@@ -1014,7 +1014,7 @@ xdr_remote_domain_migrate_finish2_args (
return FALSE;
if (!xdr_remote_nonnull_string (xdrs, &objp->uri))
return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->flags))
+ if (!xdr_uint64_t (xdrs, &objp->flags))
return FALSE;
if (!xdr_int (xdrs, &objp->retcode))
return FALSE;
@@ -1798,11 +1798,11 @@ xdr_remote_storage_pool_get_info_ret (XD
if (!xdr_u_char (xdrs, &objp->state))
return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->capacity))
+ if (!xdr_uint64_t (xdrs, &objp->capacity))
return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->allocation))
+ if (!xdr_uint64_t (xdrs, &objp->allocation))
return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->available))
+ if (!xdr_uint64_t (xdrs, &objp->available))
return FALSE;
return TRUE;
}
@@ -2000,9 +2000,9 @@ xdr_remote_storage_vol_get_info_ret (XDR
if (!xdr_char (xdrs, &objp->type))
return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->capacity))
+ if (!xdr_uint64_t (xdrs, &objp->capacity))
return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->allocation))
+ if (!xdr_uint64_t (xdrs, &objp->allocation))
return FALSE;
return TRUE;
}
Index: qemud/remote_protocol.h
===================================================================
RCS file: /data/cvs/libvirt/qemud/remote_protocol.h,v
retrieving revision 1.26
diff -u -p -r1.26 remote_protocol.h
--- qemud/remote_protocol.h 17 Dec 2008 17:23:21 -0000 1.26
+++ qemud/remote_protocol.h 28 Jan 2009 12:31:00 -0000
@@ -3,8 +3,8 @@
* It was generated using rpcgen.
*/
-#ifndef _REMOTE_PROTOCOL_H_RPCGEN
-#define _REMOTE_PROTOCOL_H_RPCGEN
+#ifndef _RP_H_RPCGEN
+#define _RP_H_RPCGEN
#include <rpc/rpc.h>
@@ -107,7 +107,7 @@ typedef enum remote_auth_type remote_aut
struct remote_vcpu_info {
u_int number;
int state;
- u_quad_t cpu_time;
+ uint64_t cpu_time;
int cpu;
};
typedef struct remote_vcpu_info remote_vcpu_info;
@@ -117,8 +117,8 @@ struct remote_sched_param_value {
union {
int i;
u_int ui;
- quad_t l;
- u_quad_t ul;
+ int64_t l;
+ uint64_t ul;
double d;
int b;
} remote_sched_param_value_u;
@@ -153,7 +153,7 @@ struct remote_get_type_ret {
typedef struct remote_get_type_ret remote_get_type_ret;
struct remote_get_version_ret {
- quad_t hv_ver;
+ int64_t hv_ver;
};
typedef struct remote_get_version_ret remote_get_version_ret;
@@ -179,7 +179,7 @@ typedef struct remote_get_max_vcpus_ret
struct remote_node_get_info_ret {
char model[32];
- quad_t memory;
+ int64_t memory;
int cpus;
int mhz;
int nodes;
@@ -203,13 +203,13 @@ typedef struct remote_node_get_cells_fre
struct remote_node_get_cells_free_memory_ret {
struct {
u_int freeMems_len;
- quad_t *freeMems_val;
+ int64_t *freeMems_val;
} freeMems;
};
typedef struct remote_node_get_cells_free_memory_ret remote_node_get_cells_free_memory_ret;
struct remote_node_get_free_memory_ret {
- quad_t freeMem;
+ int64_t freeMem;
};
typedef struct remote_node_get_free_memory_ret remote_node_get_free_memory_ret;
@@ -254,11 +254,11 @@ struct remote_domain_block_stats_args {
typedef struct remote_domain_block_stats_args remote_domain_block_stats_args;
struct remote_domain_block_stats_ret {
- quad_t rd_req;
- quad_t rd_bytes;
- quad_t wr_req;
- quad_t wr_bytes;
- quad_t errs;
+ int64_t rd_req;
+ int64_t rd_bytes;
+ int64_t wr_req;
+ int64_t wr_bytes;
+ int64_t errs;
};
typedef struct remote_domain_block_stats_ret remote_domain_block_stats_ret;
@@ -269,21 +269,21 @@ struct remote_domain_interface_stats_arg
typedef struct remote_domain_interface_stats_args remote_domain_interface_stats_args;
struct remote_domain_interface_stats_ret {
- quad_t rx_bytes;
- quad_t rx_packets;
- quad_t rx_errs;
- quad_t rx_drop;
- quad_t tx_bytes;
- quad_t tx_packets;
- quad_t tx_errs;
- quad_t tx_drop;
+ int64_t rx_bytes;
+ int64_t rx_packets;
+ int64_t rx_errs;
+ int64_t rx_drop;
+ int64_t tx_bytes;
+ int64_t tx_packets;
+ int64_t tx_errs;
+ int64_t tx_drop;
};
typedef struct remote_domain_interface_stats_ret remote_domain_interface_stats_ret;
struct remote_domain_block_peek_args {
remote_nonnull_domain dom;
remote_nonnull_string path;
- u_quad_t offset;
+ uint64_t offset;
u_int size;
u_int flags;
};
@@ -299,7 +299,7 @@ typedef struct remote_domain_block_peek_
struct remote_domain_memory_peek_args {
remote_nonnull_domain dom;
- u_quad_t offset;
+ uint64_t offset;
u_int size;
u_int flags;
};
@@ -414,19 +414,19 @@ struct remote_domain_get_max_memory_args
typedef struct remote_domain_get_max_memory_args remote_domain_get_max_memory_args;
struct remote_domain_get_max_memory_ret {
- u_quad_t memory;
+ uint64_t memory;
};
typedef struct remote_domain_get_max_memory_ret remote_domain_get_max_memory_ret;
struct remote_domain_set_max_memory_args {
remote_nonnull_domain dom;
- u_quad_t memory;
+ uint64_t memory;
};
typedef struct remote_domain_set_max_memory_args remote_domain_set_max_memory_args;
struct remote_domain_set_memory_args {
remote_nonnull_domain dom;
- u_quad_t memory;
+ uint64_t memory;
};
typedef struct remote_domain_set_memory_args remote_domain_set_memory_args;
@@ -437,10 +437,10 @@ typedef struct remote_domain_get_info_ar
struct remote_domain_get_info_ret {
u_char state;
- u_quad_t max_mem;
- u_quad_t memory;
+ uint64_t max_mem;
+ uint64_t memory;
u_short nr_virt_cpu;
- u_quad_t cpu_time;
+ uint64_t cpu_time;
};
typedef struct remote_domain_get_info_ret remote_domain_get_info_ret;
@@ -475,9 +475,9 @@ typedef struct remote_domain_dump_xml_re
struct remote_domain_migrate_prepare_args {
remote_string uri_in;
- u_quad_t flags;
+ uint64_t flags;
remote_string dname;
- u_quad_t resource;
+ uint64_t resource;
};
typedef struct remote_domain_migrate_prepare_args remote_domain_migrate_prepare_args;
@@ -497,9 +497,9 @@ struct remote_domain_migrate_perform_arg
char *cookie_val;
} cookie;
remote_nonnull_string uri;
- u_quad_t flags;
+ uint64_t flags;
remote_string dname;
- u_quad_t resource;
+ uint64_t resource;
};
typedef struct remote_domain_migrate_perform_args remote_domain_migrate_perform_args;
@@ -510,7 +510,7 @@ struct remote_domain_migrate_finish_args
char *cookie_val;
} cookie;
remote_nonnull_string uri;
- u_quad_t flags;
+ uint64_t flags;
};
typedef struct remote_domain_migrate_finish_args remote_domain_migrate_finish_args;
@@ -521,9 +521,9 @@ typedef struct remote_domain_migrate_fin
struct remote_domain_migrate_prepare2_args {
remote_string uri_in;
- u_quad_t flags;
+ uint64_t flags;
remote_string dname;
- u_quad_t resource;
+ uint64_t resource;
remote_nonnull_string dom_xml;
};
typedef struct remote_domain_migrate_prepare2_args remote_domain_migrate_prepare2_args;
@@ -544,7 +544,7 @@ struct remote_domain_migrate_finish2_arg
char *cookie_val;
} cookie;
remote_nonnull_string uri;
- u_quad_t flags;
+ uint64_t flags;
int retcode;
};
typedef struct remote_domain_migrate_finish2_args remote_domain_migrate_finish2_args;
@@ -1002,9 +1002,9 @@ typedef struct remote_storage_pool_get_i
struct remote_storage_pool_get_info_ret {
u_char state;
- u_quad_t capacity;
- u_quad_t allocation;
- u_quad_t available;
+ uint64_t capacity;
+ uint64_t allocation;
+ uint64_t available;
};
typedef struct remote_storage_pool_get_info_ret remote_storage_pool_get_info_ret;
@@ -1115,8 +1115,8 @@ typedef struct remote_storage_vol_get_in
struct remote_storage_vol_get_info_ret {
char type;
- u_quad_t capacity;
- u_quad_t allocation;
+ uint64_t capacity;
+ uint64_t allocation;
};
typedef struct remote_storage_vol_get_info_ret remote_storage_vol_get_info_ret;
@@ -1793,4 +1793,4 @@ extern bool_t xdr_remote_message_header
}
#endif
-#endif /* !_REMOTE_PROTOCOL_H_RPCGEN */
+#endif /* !_RP_H_RPCGEN */
Index: qemud/rpcgen_fix.pl
===================================================================
RCS file: /data/cvs/libvirt/qemud/rpcgen_fix.pl,v
retrieving revision 1.4
diff -u -p -r1.4 rpcgen_fix.pl
--- qemud/rpcgen_fix.pl 6 Jan 2009 18:32:03 -0000 1.4
+++ qemud/rpcgen_fix.pl 28 Jan 2009 12:31:00 -0000
@@ -26,6 +26,14 @@ while (<>) {
s/\t/ /g;
+ # Portability for Solaris RPC
+ s/u_quad_t/uint64_t/g;
+ s/quad_t/int64_t/g;
+ s/xdr_u_quad_t/xdr_uint64_t/g;
+ s/xdr_quad_t/xdr_int64_t/g;
+ s/IXDR_GET_LONG/IXDR_GET_INT32/g;
+ s,#include "\./remote_protocol\.h",#include "remote_protocol.h",;
+
if (m/^}/) {
$in_function = 0;
--
|: 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 :|
15 years, 11 months
[libvirt] PATCH: Fix remote driver RPC recv handling
by Daniel P. Berrange
I noticed a odd error message randomly appearing from virsh after all
commands had been run
# virsh dominfo VirtTest
Id: -
Name: VirtTest
UUID: 82038f2a-1344-aaf7-1a85-2a7250be2076
OS Type: hvm
State: shut off
CPU(s): 3
Max memory: 256000 kB
Used memory: 256000 kB
Autostart: disable
libvir: Remote error : server closed connection
It turns out that inthe for(;;) loop where I'm procesing incoming data,
it was forgetting to break out of the loop when a completed RPC call
had been received. Most of the time this wasn't problem, because there'd
rarely be more data following, so it'd get EAGAIN next iteration & quit
the loop. When shutting down though, you'd occassionally see the SIGHUP
from read() before you get an EAGAIN, causing this error to be raised
even though the RPC call had been successfully received.
In addition, if there was a 2nd RPC reply already pending, we'd read and
loose some of its data. Though I never saw this happen, it is a definite
theoretical possibility, particularly over a TCP link with bad latency
or fragementation or bursty traffic.
Daniel
diff -r e582072116a3 src/remote_internal.c
--- a/src/remote_internal.c Mon Jan 26 16:21:42 2009 +0000
+++ b/src/remote_internal.c Mon Jan 26 17:02:15 2009 +0000
@@ -6135,12 +6135,27 @@ processCallRecv(virConnectPtr conn, stru
if (priv->bufferOffset == priv->bufferLength) {
if (priv->bufferOffset == 4) {
ret = processCallRecvLen(conn, priv, in_open);
+ if (ret < 0)
+ return -1;
+
+ /*
+ * We'll carry on around the loop to immediately
+ * process the message body, because it has probably
+ * already arrived. Worst case, we'll get EAGAIN on
+ * next iteration.
+ */
} else {
ret = processCallRecvMsg(conn, priv, in_open);
priv->bufferOffset = priv->bufferLength = 0;
- }
- if (ret < 0)
- return -1;
+ /*
+ * We've completed one call, so return even
+ * though there might still be more data on
+ * the wire. We need to actually let the caller
+ * deal with this arrived message to keep good
+ * response, and also to correctly handle EOF.
+ */
+ return ret;
+ }
}
}
}
--
|: 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 :|
15 years, 11 months
[libvirt] setting up dnsmasq options for PXE boot
by Dmitry Guryanov
Hello,
I want to use PXE boot in kvm's virtual machines, but I've not found, how to
configure libvirt for starting dhcp server with correct options for this.
Now i have libvirt-0.5.1-2.fc10.x86_64 and virt-manager-0.6.0-5.fc10.x86_64,
I've created VM using virt manager, with specifying PXE boot option. VM config
contains following sections:
<os>
<type arch='x86_64' machine='pc'>hvm</type>
<boot dev='network'/>
</os>
.....
<interface type='network'>
<mac address='54:52:00:0a:f6:00'/>
<source network='nat_net'/>
<model type='virtio'/>
</interface>
and config for virtual network nat_net:
<network>
<name>nat_net</name>
<uuid>e02cfc6f-d7f8-6f81-8c19-bfa9d2a13a85</uuid>
<forward dev='eth0' mode='nat'/>
<bridge stp='on' forwardDelay='0' />
<ip address='192.168.107.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.107.128' end='192.168.107.254' />
</dhcp>
</ip>
</network>
dnsmasq starts with following command line:
/usr/sbin/dnsmasq --keep-in-foreground --strict-order --bind-interfaces--pid-
file --conf-file --listen-address 192.168.107.1 --except-interface lo --dhcp-
leasefile=/var/lib/libvirt/dhcp-nat_net.leases --dhcp-range
192.168.107.128,192.168.107.254
But for working PXE boot it should have also something like
--dhcp-boot=pxelinux.0,itchy,192.168.107.1
So after starting VM it tries to boot from network, gets DHCP response and
reports, that it doesn't contains filename option.
So the question is - how to get it working correctly ? (If i start dnsmasq by
hand with option --dhcp-boot=pxelinux.0,itchy,192.168.107.1 PXE boot works)
--
Dmitry Guryanov
15 years, 11 months
[libvirt] PATCH: Misc Xen driver bug fixes
by Daniel P. Berrange
Testing current CVS on RHEL-5 host exposed a number of problems in the
Xen driver
- When opening the remote driver for the network / storage / nodedev
APIs, we had missed the initialization of several fields, resulting
in a crash
- Reporting of errors from the remote driver was leaking memory, due
to missing xdr_free call.
- Small possibility of de-referencing NULL when handling an error
from the server, if no error message were provided
- Mistakenly tries to activate Xen INotify driver when non-root, even
though the directories it needs to monitor are chmod 0700 root.root
- Gratuitous reporting of failure to connect to XenD's TCP port when
running non-root, even though the proxy / remote driver will suceed
- Bad return values from the xenDaemonOpen() method
- Double free in the new xenStoreDoListDomains() method probably due
to merge error
The only really intreresting bit of the patch is for the first issue
in the remote driver. I've basically pulled out alot of duplicated
code into a couple of helper methods, so make these missing initialization
less likely in future.
remote_internal.c | 153 +++++++++++++++++++++++++-----------------------------
xen_unified.c | 12 ++--
xend_internal.c | 50 ++++++-----------
xs_internal.c | 2
4 files changed, 97 insertions(+), 120 deletions(-)
Daniel
Index: src/remote_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/remote_internal.c,v
retrieving revision 1.130
diff -u -p -u -p -r1.130 remote_internal.c
--- src/remote_internal.c 28 Jan 2009 16:14:24 -0000 1.130
+++ src/remote_internal.c 28 Jan 2009 16:24:20 -0000
@@ -892,31 +892,70 @@ doRemoteOpen (virConnectPtr conn,
goto cleanup;
}
-static virDrvOpenStatus
-remoteOpen (virConnectPtr conn,
- virConnectAuthPtr auth,
- int flags)
+static struct private_data *
+remoteAllocPrivateData(virConnectPtr conn)
{
struct private_data *priv;
- int ret, rflags = 0;
-
- if (inside_daemon)
- return VIR_DRV_OPEN_DECLINED;
-
if (VIR_ALLOC(priv) < 0) {
- error (conn, VIR_ERR_NO_MEMORY, _("struct private_data"));
- return VIR_DRV_OPEN_ERROR;
+ virReportOOMError(conn);
+ return NULL;
}
if (virMutexInit(&priv->lock) < 0) {
error(conn, VIR_ERR_INTERNAL_ERROR,
_("cannot initialize mutex"));
VIR_FREE(priv);
- return VIR_DRV_OPEN_ERROR;
+ return NULL;
}
remoteDriverLock(priv);
priv->localUses = 1;
priv->watch = -1;
+ priv->sock = -1;
+
+ return priv;
+}
+
+static int
+remoteOpenSecondaryDriver(virConnectPtr conn,
+ virConnectAuthPtr auth,
+ int flags,
+ struct private_data **priv)
+{
+ int ret;
+ int rflags = 0;
+
+ if (!((*priv) = remoteAllocPrivateData(conn)))
+ return VIR_DRV_OPEN_ERROR;
+
+ if (flags & VIR_CONNECT_RO)
+ rflags |= VIR_DRV_OPEN_REMOTE_RO;
+ rflags |= VIR_DRV_OPEN_REMOTE_UNIX;
+
+ ret = doRemoteOpen(conn, *priv, auth, rflags);
+ if (ret != VIR_DRV_OPEN_SUCCESS) {
+ remoteDriverUnlock(*priv);
+ VIR_FREE(*priv);
+ } else {
+ (*priv)->localUses = 1;
+ remoteDriverUnlock(*priv);
+ }
+
+ return ret;
+}
+
+static virDrvOpenStatus
+remoteOpen (virConnectPtr conn,
+ virConnectAuthPtr auth,
+ int flags)
+{
+ struct private_data *priv;
+ int ret, rflags = 0;
+
+ if (inside_daemon)
+ return VIR_DRV_OPEN_DECLINED;
+
+ if (!(priv = remoteAllocPrivateData(conn)))
+ return VIR_DRV_OPEN_ERROR;
if (flags & VIR_CONNECT_RO)
rflags |= VIR_DRV_OPEN_REMOTE_RO;
@@ -971,7 +1010,6 @@ remoteOpen (virConnectPtr conn,
#endif
}
- priv->sock = -1;
ret = doRemoteOpen(conn, priv, auth, rflags);
if (ret != VIR_DRV_OPEN_SUCCESS) {
conn->privateData = NULL;
@@ -3085,30 +3123,13 @@ remoteNetworkOpen (virConnectPtr conn,
* which doesn't have its own impl of the network APIs.
*/
struct private_data *priv;
- int ret, rflags = 0;
- if (VIR_ALLOC(priv) < 0) {
- error (conn, VIR_ERR_NO_MEMORY, _("struct private_data"));
- return VIR_DRV_OPEN_ERROR;
- }
- if (virMutexInit(&priv->lock) < 0) {
- error(conn, VIR_ERR_INTERNAL_ERROR,
- _("cannot initialize mutex"));
- VIR_FREE(priv);
- return VIR_DRV_OPEN_ERROR;
- }
- if (flags & VIR_CONNECT_RO)
- rflags |= VIR_DRV_OPEN_REMOTE_RO;
- rflags |= VIR_DRV_OPEN_REMOTE_UNIX;
-
- priv->sock = -1;
- ret = doRemoteOpen(conn, priv, auth, rflags);
- if (ret != VIR_DRV_OPEN_SUCCESS) {
- conn->networkPrivateData = NULL;
- VIR_FREE(priv);
- } else {
- priv->localUses = 1;
+ int ret;
+ ret = remoteOpenSecondaryDriver(conn,
+ auth,
+ flags,
+ &priv);
+ if (ret == VIR_DRV_OPEN_SUCCESS)
conn->networkPrivateData = priv;
- }
return ret;
}
}
@@ -3598,30 +3619,13 @@ remoteStorageOpen (virConnectPtr conn,
* which doesn't have its own impl of the network APIs.
*/
struct private_data *priv;
- int ret, rflags = 0;
- if (VIR_ALLOC(priv) < 0) {
- error (NULL, VIR_ERR_NO_MEMORY, _("struct private_data"));
- return VIR_DRV_OPEN_ERROR;
- }
- if (virMutexInit(&priv->lock) < 0) {
- error(conn, VIR_ERR_INTERNAL_ERROR,
- _("cannot initialize mutex"));
- VIR_FREE(priv);
- return VIR_DRV_OPEN_ERROR;
- }
- if (flags & VIR_CONNECT_RO)
- rflags |= VIR_DRV_OPEN_REMOTE_RO;
- rflags |= VIR_DRV_OPEN_REMOTE_UNIX;
-
- priv->sock = -1;
- ret = doRemoteOpen(conn, priv, auth, rflags);
- if (ret != VIR_DRV_OPEN_SUCCESS) {
- conn->storagePrivateData = NULL;
- VIR_FREE(priv);
- } else {
- priv->localUses = 1;
+ int ret;
+ ret = remoteOpenSecondaryDriver(conn,
+ auth,
+ flags,
+ &priv);
+ if (ret == VIR_DRV_OPEN_SUCCESS)
conn->storagePrivateData = priv;
- }
return ret;
}
}
@@ -4551,30 +4555,13 @@ remoteDevMonOpen(virConnectPtr conn,
* which doesn't have its own impl of the network APIs.
*/
struct private_data *priv;
- int ret, rflags = 0;
- if (VIR_ALLOC(priv) < 0) {
- error (NULL, VIR_ERR_NO_MEMORY, _("struct private_data"));
- return VIR_DRV_OPEN_ERROR;
- }
- if (virMutexInit(&priv->lock) < 0) {
- error(conn, VIR_ERR_INTERNAL_ERROR,
- _("cannot initialize mutex"));
- VIR_FREE(priv);
- return VIR_DRV_OPEN_ERROR;
- }
- if (flags & VIR_CONNECT_RO)
- rflags |= VIR_DRV_OPEN_REMOTE_RO;
- rflags |= VIR_DRV_OPEN_REMOTE_UNIX;
-
- priv->sock = -1;
- ret = doRemoteOpen(conn, priv, auth, rflags);
- if (ret != VIR_DRV_OPEN_SUCCESS) {
- conn->devMonPrivateData = NULL;
- VIR_FREE(priv);
- } else {
- priv->localUses = 1;
+ int ret;
+ ret = remoteOpenSecondaryDriver(conn,
+ auth,
+ flags,
+ &priv);
+ if (ret == VIR_DRV_OPEN_SUCCESS)
conn->devMonPrivateData = priv;
- }
return ret;
}
}
@@ -6419,6 +6406,7 @@ cleanup:
thiscall->err.domain == VIR_FROM_REMOTE &&
thiscall->err.code == VIR_ERR_RPC &&
thiscall->err.level == VIR_ERR_ERROR &&
+ thiscall->err.message &&
STRPREFIX(*thiscall->err.message, "unknown procedure")) {
rv = -2;
} else {
@@ -6426,6 +6414,7 @@ cleanup:
&thiscall->err);
rv = -1;
}
+ xdr_free((xdrproc_t)xdr_remote_error, (char *)&thiscall->err);
} else {
rv = 0;
}
Index: src/xen_unified.c
===================================================================
RCS file: /data/cvs/libvirt/src/xen_unified.c,v
retrieving revision 1.81
diff -u -p -u -p -r1.81 xen_unified.c
--- src/xen_unified.c 27 Jan 2009 08:50:04 -0000 1.81
+++ src/xen_unified.c 28 Jan 2009 16:24:21 -0000
@@ -355,11 +355,13 @@ xenUnifiedOpen (virConnectPtr conn, virC
}
#if WITH_XEN_INOTIFY
- DEBUG0("Trying Xen inotify sub-driver");
- if (drivers[XEN_UNIFIED_INOTIFY_OFFSET]->open(conn, auth, flags) ==
- VIR_DRV_OPEN_SUCCESS) {
- DEBUG0("Activated Xen inotify sub-driver");
- priv->opened[XEN_UNIFIED_INOTIFY_OFFSET] = 1;
+ if (xenHavePrivilege()) {
+ DEBUG0("Trying Xen inotify sub-driver");
+ if (drivers[XEN_UNIFIED_INOTIFY_OFFSET]->open(conn, auth, flags) ==
+ VIR_DRV_OPEN_SUCCESS) {
+ DEBUG0("Activated Xen inotify sub-driver");
+ priv->opened[XEN_UNIFIED_INOTIFY_OFFSET] = 1;
+ }
}
#endif
Index: src/xend_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/xend_internal.c,v
retrieving revision 1.243
diff -u -p -u -p -r1.243 xend_internal.c
--- src/xend_internal.c 28 Jan 2009 14:36:23 -0000 1.243
+++ src/xend_internal.c 28 Jan 2009 16:24:21 -0000
@@ -838,9 +838,11 @@ xenDaemonOpen_tcp(virConnectPtr conn, co
freeaddrinfo (res);
if (!priv->addrlen) {
- virReportSystemError(conn, saved_errno,
- _("unable to connect to '%s:%s'"),
- host, port);
+ /* Don't raise error when unprivileged, since proxy takes over */
+ if (xenHavePrivilege())
+ virReportSystemError(conn, saved_errno,
+ _("unable to connect to '%s:%s'"),
+ host, port);
return -1;
}
@@ -2721,7 +2723,6 @@ error:
* @flags: combination of virDrvOpenFlag(s)
*
* Creates a localhost Xen Daemon connection
- * Note: this doesn't try to check if the connection actually works
*
* Returns 0 in case of success, -1 in case of error.
*/
@@ -2730,7 +2731,8 @@ xenDaemonOpen(virConnectPtr conn,
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
int flags ATTRIBUTE_UNUSED)
{
- int ret;
+ char *port = NULL;
+ int ret = VIR_DRV_OPEN_ERROR;
/* Switch on the scheme, which we expect to be NULL (file),
* "http" or "xen".
@@ -2741,45 +2743,30 @@ xenDaemonOpen(virConnectPtr conn,
virXendError(NULL, VIR_ERR_NO_CONNECT, __FUNCTION__);
goto failed;
}
- ret = xenDaemonOpen_unix(conn, conn->uri->path);
- if (ret < 0)
- goto failed;
-
- ret = xend_detect_config_version(conn);
- if (ret == -1)
+ if (xenDaemonOpen_unix(conn, conn->uri->path) < 0 ||
+ xend_detect_config_version(conn) == -1)
goto failed;
}
else if (STRCASEEQ (conn->uri->scheme, "xen")) {
/*
* try first to open the unix socket
*/
- ret = xenDaemonOpen_unix(conn, "/var/lib/xend/xend-socket");
- if (ret < 0)
- goto try_http;
- ret = xend_detect_config_version(conn);
- if (ret != -1)
+ if (xenDaemonOpen_unix(conn, "/var/lib/xend/xend-socket") == 0 &&
+ xend_detect_config_version(conn) != -1)
goto done;
- try_http:
/*
* try though http on port 8000
*/
- ret = xenDaemonOpen_tcp(conn, "localhost", "8000");
- if (ret < 0)
- goto failed;
- ret = xend_detect_config_version(conn);
- if (ret == -1)
+ if (xenDaemonOpen_tcp(conn, "localhost", "8000") < 0 ||
+ xend_detect_config_version(conn) == -1)
goto failed;
} else if (STRCASEEQ (conn->uri->scheme, "http")) {
- char *port;
if (virAsprintf(&port, "%d", conn->uri->port) == -1)
goto failed;
- ret = xenDaemonOpen_tcp(conn, conn->uri->server, port);
- VIR_FREE(port);
- if (ret < 0)
- goto failed;
- ret = xend_detect_config_version(conn);
- if (ret == -1)
+
+ if (xenDaemonOpen_tcp(conn, conn->uri->server, port) < 0 ||
+ xend_detect_config_version(conn) == -1)
goto failed;
} else {
virXendError(NULL, VIR_ERR_NO_CONNECT, __FUNCTION__);
@@ -2787,10 +2774,11 @@ xenDaemonOpen(virConnectPtr conn,
}
done:
- return(ret);
+ ret = VIR_DRV_OPEN_SUCCESS;
failed:
- return(-1);
+ VIR_FREE(port);
+ return ret;
}
Index: src/xs_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/xs_internal.c,v
retrieving revision 1.85
diff -u -p -u -p -r1.85 xs_internal.c
--- src/xs_internal.c 23 Jan 2009 19:18:24 -0000 1.85
+++ src/xs_internal.c 28 Jan 2009 16:24:21 -0000
@@ -597,8 +597,6 @@ xenStoreDoListDomains(xenUnifiedPrivateP
ids[ret++] = (int) id;
}
- free(idlist);
-
out:
VIR_FREE (idlist);
return ret;
--
|: 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 :|
15 years, 11 months
[libvirt] [PATCH 1/3] use virReportOOMError, not VIR_ERR_NO_MEMORY
by Jim Meyering
Here's the big one:
>From 099536470ae2cbe9503ed471d391e403fb2587a4 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 27 Jan 2009 12:20:06 +0100
Subject: [PATCH 1/3] error-reporting calls using VIR_ERR_NO_MEMORY: use virReportOOMError instead
* src/uml_conf.c (VIR_FROM_THIS): Define to VIR_FROM_UML.
* src/xs_internal.c (VIR_FROM_THIS): Define to VIR_FROM_XEN.
* src/xml.c (VIR_FROM_THIS): Define to VIR_FROM_XML.
* src/stats_linux.c (VIR_FROM_THIS): Define to VIR_FROM_STATS_LINUX.
* src/datatypes.c (VIR_FROM_THIS): Define to VIR_FROM_NONE.
* src/lxc_conf.c (VIR_FROM_THIS): Define to VIR_FROM_LXC.
* src/libvirt.c (VIR_FROM_THIS): Define to VIR_FROM_NONE.
* src/node_device_conf.c (VIR_FROM_THIS): Define to VIR_FROM_NODEDEV.
* src/openvz_conf.c (VIR_FROM_THIS): Define to VIR_FROM_OPENVZ.
* src/openvz_driver.c (VIR_FROM_THIS): Define to VIR_FROM_OPENVZ.
* src/conf.c (VIR_FROM_THIS): Define to VIR_FROM_CONF.
Note: this loses config_filename:config_lineno diagnostics,
but that's ok.
* src/node_device.c (VIR_FROM_THIS): Define to VIR_FROM_NODEDEV.
* src/sexpr.c (VIR_FROM_THIS): Define to VIR_FROM_SEXPR.
---
src/conf.c | 18 +++++++------
src/datatypes.c | 28 +++++++++++----------
src/domain_conf.c | 47 +++++++++++++++++------------------
src/libvirt.c | 4 ++-
src/lxc_conf.c | 5 ++-
src/lxc_container.c | 8 +++---
src/lxc_controller.c | 2 +-
src/lxc_driver.c | 11 ++++----
src/network_conf.c | 18 +++++++-------
src/network_driver.c | 15 ++++-------
src/node_device.c | 4 ++-
src/node_device_conf.c | 8 +++---
src/openvz_conf.c | 8 ++++--
src/openvz_driver.c | 9 ++++---
src/proxy_internal.c | 6 ++--
src/qemu_conf.c | 25 +++++++------------
src/qemu_driver.c | 54 +++++++++++++++++-----------------------
src/remote_internal.c | 16 ++++++------
src/sexpr.c | 7 +++--
src/stats_linux.c | 7 +++--
src/storage_backend_iscsi.c | 17 ++++++-------
src/storage_backend_logical.c | 27 +++++++++-----------
src/storage_conf.c | 34 ++++++++++----------------
src/uml_conf.c | 16 ++++++------
src/util.c | 6 ++--
src/xen_internal.c | 20 ++++++---------
src/xend_internal.c | 35 +++++++++++++-------------
src/xml.c | 11 ++++----
src/xs_internal.c | 10 ++++----
29 files changed, 225 insertions(+), 251 deletions(-)
diff --git a/src/conf.c b/src/conf.c
index 339a150..b5bfc0c 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -25,6 +25,8 @@
#include "c-ctype.h"
#include "memory.h"
+#define VIR_FROM_THIS VIR_FROM_CONF
+
/************************************************************************
* *
* Structures and macros used by the mini parser *
@@ -161,7 +163,7 @@ virConfNew(void)
virConfPtr ret;
if (VIR_ALLOC(ret) < 0) {
- virConfError(NULL, VIR_ERR_NO_MEMORY, _("allocating configuration"));
+ virReportOOMError(NULL);
return(NULL);
}
ret->filename = NULL;
@@ -209,7 +211,7 @@ virConfAddEntry(virConfPtr conf, char *name, virConfValuePtr value, char *comm)
return(NULL);
if (VIR_ALLOC(ret) < 0) {
- virConfError(NULL, VIR_ERR_NO_MEMORY, _("allocating configuration"));
+ virReportOOMError(NULL);
return(NULL);
}
@@ -488,7 +490,7 @@ virConfParseValue(virConfParserCtxtPtr ctxt)
return(NULL);
}
if (VIR_ALLOC(ret) < 0) {
- virConfError(ctxt, VIR_ERR_NO_MEMORY, _("allocating configuration"));
+ virReportOOMError(NULL);
virConfFreeList(lst);
VIR_FREE(str);
return(NULL);
@@ -525,7 +527,7 @@ virConfParseName(virConfParserCtxtPtr ctxt)
NEXT;
ret = strndup(base, ctxt->cur - base);
if (ret == NULL) {
- virConfError(ctxt, VIR_ERR_NO_MEMORY, _("allocating configuration"));
+ virReportOOMError(NULL);
return(NULL);
}
return(ret);
@@ -552,7 +554,7 @@ virConfParseComment(virConfParserCtxtPtr ctxt)
while ((ctxt->cur < ctxt->end) && (!IS_EOL(CUR))) NEXT;
comm = strndup(base, ctxt->cur - base);
if (comm == NULL) {
- virConfError(ctxt, VIR_ERR_NO_MEMORY, _("allocating configuration"));
+ virReportOOMError(NULL);
return(-1);
}
virConfAddEntry(ctxt->conf, NULL, NULL, comm);
@@ -627,7 +629,7 @@ virConfParseStatement(virConfParserCtxtPtr ctxt)
while ((ctxt->cur < ctxt->end) && (!IS_EOL(CUR))) NEXT;
comm = strndup(base, ctxt->cur - base);
if (comm == NULL) {
- virConfError(ctxt, VIR_ERR_NO_MEMORY, _("allocating configuration"));
+ virReportOOMError(NULL);
VIR_FREE(name);
virConfFreeValue(value);
return(-1);
@@ -888,7 +890,7 @@ virConfWriteFile(const char *filename, virConfPtr conf)
}
if (virBufferError(&buf)) {
- virConfError(NULL, VIR_ERR_NO_MEMORY, _("allocate buffer"));
+ virReportOOMError(NULL);
return -1;
}
@@ -944,7 +946,7 @@ virConfWriteMem(char *memory, int *len, virConfPtr conf)
}
if (virBufferError(&buf)) {
- virConfError(NULL, VIR_ERR_NO_MEMORY, _("allocate buffer"));
+ virReportOOMError(NULL);
return -1;
}
diff --git a/src/datatypes.c b/src/datatypes.c
index d59c5b4..3b2c958 100644
--- a/src/datatypes.c
+++ b/src/datatypes.c
@@ -1,7 +1,7 @@
/*
* datatypes.h: management of structs for public data types
*
- * Copyright (C) 2006-2008 Red Hat, Inc.
+ * Copyright (C) 2006-2009 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -26,6 +26,8 @@
#include "logging.h"
#include "memory.h"
+#define VIR_FROM_THIS VIR_FROM_NONE
+
/************************************************************************
* *
* Domain and Connections allocations *
@@ -120,7 +122,7 @@ virGetConnect(void) {
virConnectPtr ret;
if (VIR_ALLOC(ret) < 0) {
- virLibConnError(NULL, VIR_ERR_NO_MEMORY, _("allocating connection"));
+ virReportOOMError(NULL);
goto failed;
}
if (virMutexInit(&ret->lock) < 0) {
@@ -262,12 +264,12 @@ virGetDomain(virConnectPtr conn, const char *name, const unsigned char *uuid) {
/* TODO check the UUID */
if (ret == NULL) {
if (VIR_ALLOC(ret) < 0) {
- virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating domain"));
+ virReportOOMError(conn);
goto error;
}
ret->name = strdup(name);
if (ret->name == NULL) {
- virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating domain"));
+ virReportOOMError(conn);
goto error;
}
ret->magic = VIR_DOMAIN_MAGIC;
@@ -398,12 +400,12 @@ virGetNetwork(virConnectPtr conn, const char *name, const unsigned char *uuid) {
/* TODO check the UUID */
if (ret == NULL) {
if (VIR_ALLOC(ret) < 0) {
- virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating network"));
+ virReportOOMError(conn);
goto error;
}
ret->name = strdup(name);
if (ret->name == NULL) {
- virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating network"));
+ virReportOOMError(conn);
goto error;
}
ret->magic = VIR_NETWORK_MAGIC;
@@ -530,12 +532,12 @@ virGetStoragePool(virConnectPtr conn, const char *name, const unsigned char *uui
/* TODO check the UUID */
if (ret == NULL) {
if (VIR_ALLOC(ret) < 0) {
- virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating storage pool"));
+ virReportOOMError(conn);
goto error;
}
ret->name = strdup(name);
if (ret->name == NULL) {
- virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating storage pool"));
+ virReportOOMError(conn);
goto error;
}
ret->magic = VIR_STORAGE_POOL_MAGIC;
@@ -661,17 +663,17 @@ virGetStorageVol(virConnectPtr conn, const char *pool, const char *name, const c
ret = (virStorageVolPtr) virHashLookup(conn->storageVols, key);
if (ret == NULL) {
if (VIR_ALLOC(ret) < 0) {
- virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating storage vol"));
+ virReportOOMError(conn);
goto error;
}
ret->pool = strdup(pool);
if (ret->pool == NULL) {
- virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating storage vol"));
+ virReportOOMError(conn);
goto error;
}
ret->name = strdup(name);
if (ret->name == NULL) {
- virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating storage vol"));
+ virReportOOMError(conn);
goto error;
}
strncpy(ret->key, key, sizeof(ret->key)-1);
@@ -798,14 +800,14 @@ virGetNodeDevice(virConnectPtr conn, const char *name)
ret = (virNodeDevicePtr) virHashLookup(conn->nodeDevices, name);
if (ret == NULL) {
if (VIR_ALLOC(ret) < 0) {
- virLibConnError(conn, VIR_ERR_NO_MEMORY, _("allocating node dev"));
+ virReportOOMError(conn);
goto error;
}
ret->magic = VIR_NODE_DEVICE_MAGIC;
ret->conn = conn;
ret->name = strdup(name);
if (ret->name == NULL) {
- virLibConnError(conn, VIR_ERR_NO_MEMORY, _("copying node dev name"));
+ virReportOOMError(conn);
goto error;
}
diff --git a/src/domain_conf.c b/src/domain_conf.c
index 30336d4..f696b6a 100644
--- a/src/domain_conf.c
+++ b/src/domain_conf.c
@@ -483,7 +483,7 @@ virDomainObjPtr virDomainAssignDef(virConnectPtr conn,
}
if (VIR_ALLOC(domain) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
@@ -499,7 +499,7 @@ virDomainObjPtr virDomainAssignDef(virConnectPtr conn,
domain->def = def;
if (VIR_REALLOC_N(doms->objs, doms->count + 1) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
VIR_FREE(domain);
return NULL;
}
@@ -569,7 +569,7 @@ virDomainDiskDefParseXML(virConnectPtr conn,
char *bus = NULL;
if (VIR_ALLOC(def) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
@@ -753,7 +753,7 @@ virDomainFSDefParseXML(virConnectPtr conn,
char *target = NULL;
if (VIR_ALLOC(def) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
@@ -847,7 +847,7 @@ virDomainNetDefParseXML(virConnectPtr conn,
char *model = NULL;
if (VIR_ALLOC(def) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
@@ -1087,7 +1087,7 @@ virDomainChrDefParseXML(virConnectPtr conn,
virDomainChrDefPtr def;
if (VIR_ALLOC(def) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
@@ -1300,7 +1300,7 @@ virDomainInputDefParseXML(virConnectPtr conn,
char *bus = NULL;
if (VIR_ALLOC(def) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
@@ -1385,7 +1385,7 @@ virDomainGraphicsDefParseXML(virConnectPtr conn,
char *type = NULL;
if (VIR_ALLOC(def) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
@@ -1480,7 +1480,7 @@ virDomainSoundDefParseXML(virConnectPtr conn,
virDomainSoundDefPtr def;
if (VIR_ALLOC(def) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
@@ -1714,7 +1714,7 @@ virDomainHostdevDefParseXML(virConnectPtr conn,
char *mode, *type = NULL;
if (VIR_ALLOC(def) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
def->target = NULL;
@@ -1826,7 +1826,7 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(virConnectPtr conn,
}
if (VIR_ALLOC(dev) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto error;
}
@@ -1892,8 +1892,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
virDomainDefPtr def;
if (VIR_ALLOC(def) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for xmlXPathContext"));
+ virReportOOMError(conn);
return NULL;
}
@@ -1958,7 +1957,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
char *set = tmp;
def->cpumasklen = VIR_DOMAIN_CPUMASK_LEN;
if (VIR_ALLOC_N(def->cpumask, def->cpumasklen) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto error;
}
if (virDomainCpuSetParse(conn, (const char **)&set,
@@ -2008,7 +2007,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
if (def->os.bootloader) {
def->os.type = strdup("xen");
if (!def->os.type) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto error;
}
} else {
@@ -2026,7 +2025,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
def->virtType == VIR_DOMAIN_VIRT_XEN) {
VIR_FREE(def->os.type);
if (!(def->os.type = strdup("xen"))) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto error;
}
}
@@ -2047,7 +2046,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
goto error;
}
if (!(def->os.arch = strdup(defaultArch))) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto error;
}
}
@@ -2059,7 +2058,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
def->os.arch);
if (defaultMachine != NULL) {
if (!(def->os.machine = strdup(defaultMachine))) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto error;
}
}
@@ -2310,7 +2309,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
virDomainInputDefPtr input;
if (VIR_ALLOC(input) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto error;
}
if (STREQ(def->os.type, "hvm")) {
@@ -2382,7 +2381,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
return def;
no_memory:
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
/* fallthrough */
error:
@@ -2514,7 +2513,7 @@ virDomainDefPtr virDomainDefParseNode(virConnectPtr conn,
ctxt = xmlXPathNewContext(xml);
if (ctxt == NULL) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto cleanup;
}
@@ -2611,7 +2610,7 @@ virDomainCpuSetFormat(virConnectPtr conn, char *cpuset, int maxcpu)
}
if (virBufferError(&buf)) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
@@ -3400,7 +3399,7 @@ char *virDomainDefFormat(virConnectPtr conn,
return virBufferContentAndReset(&buf);
no_memory:
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
cleanup:
tmp = virBufferContentAndReset(&buf);
VIR_FREE(tmp);
@@ -3624,7 +3623,7 @@ char *virDomainConfigFile(virConnectPtr conn,
char *ret = NULL;
if (virAsprintf(&ret, "%s/%s.xml", dir, name) < 0) {
- virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
diff --git a/src/libvirt.c b/src/libvirt.c
index 71df57d..72095dd 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -57,6 +57,8 @@
#endif
#endif
+#define VIR_FROM_THIS VIR_FROM_NONE
+
/*
* TODO:
* - use lock to protect against concurrent accesses ?
@@ -1323,7 +1325,7 @@ virConnectGetURI (virConnectPtr conn)
name = (char *)xmlSaveUri(conn->uri);
if (!name) {
- virLibConnError (conn, VIR_ERR_NO_MEMORY, __FUNCTION__);
+ virReportOOMError (conn);
goto error;
}
return name;
diff --git a/src/lxc_conf.c b/src/lxc_conf.c
index fe964c2..34c8aea 100644
--- a/src/lxc_conf.c
+++ b/src/lxc_conf.c
@@ -31,6 +31,8 @@
#include "nodeinfo.h"
#include "virterror_internal.h"
+#define VIR_FROM_THIS VIR_FROM_LXC
+
/* Functions */
virCapsPtr lxcCapsInit(void)
{
@@ -87,7 +89,6 @@ int lxcLoadDriverConfig(lxc_driver_t *driver)
return 0;
no_memory:
- lxcError(NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("while loading LXC driver config"));
+ virReportOOMError(NULL);
return -1;
}
diff --git a/src/lxc_container.c b/src/lxc_container.c
index 3bf533c..ea52eed 100644
--- a/src/lxc_container.c
+++ b/src/lxc_container.c
@@ -386,7 +386,7 @@ static int lxcContainerMountNewFS(virDomainDefPtr vmDef)
continue;
if (virAsprintf(&src, "/.oldroot/%s", vmDef->fss[i]->src) < 0) {
- lxcError(NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(NULL);
return -1;
}
@@ -432,12 +432,12 @@ static int lxcContainerUnmountOldFS(void)
if (VIR_REALLOC_N(mounts, nmounts+1) < 0) {
endmntent(procmnt);
- lxcError(NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(NULL);
return -1;
}
if (!(mounts[nmounts++] = strdup(mntent.mnt_dir))) {
endmntent(procmnt);
- lxcError(NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(NULL);
return -1;
}
}
@@ -618,7 +618,7 @@ int lxcContainerStart(virDomainDefPtr def,
/* allocate a stack for the container */
if (VIR_ALLOC_N(stack, stacksize) < 0) {
- lxcError(NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(NULL);
return -1;
}
stacktop = stack + stacksize;
diff --git a/src/lxc_controller.c b/src/lxc_controller.c
index 2ef88d9..e25fe76 100644
--- a/src/lxc_controller.c
+++ b/src/lxc_controller.c
@@ -127,7 +127,7 @@ static char*lxcMonitorPath(virDomainDefPtr def)
if (virAsprintf(&sockpath, "%s/%s.sock",
LXC_STATE_DIR, def->name) < 0)
- lxcError(NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(NULL);
return sockpath;
}
diff --git a/src/lxc_driver.c b/src/lxc_driver.c
index a702635..300b919 100644
--- a/src/lxc_driver.c
+++ b/src/lxc_driver.c
@@ -90,7 +90,7 @@ static virDrvOpenStatus lxcOpen(virConnectPtr conn,
if (conn->uri == NULL) {
conn->uri = xmlParseURI("lxc:///");
if (!conn->uri) {
- lxcError(conn, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return VIR_DRV_OPEN_ERROR;
}
} else if (conn->uri->scheme == NULL ||
@@ -231,8 +231,7 @@ static int lxcListDefinedDomains(virConnectPtr conn,
virDomainObjLock(driver->domains.objs[i]);
if (!virDomainIsActive(driver->domains.objs[i])) {
if (!(names[got++] = strdup(driver->domains.objs[i]->def->name))) {
- lxcError(conn, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for VM name string"));
+ virReportOOMError(conn);
virDomainObjUnlock(driver->domains.objs[i]);
goto cleanup;
}
@@ -613,7 +612,7 @@ static int lxcMonitorClient(virConnectPtr conn,
if (virAsprintf(&sockpath, "%s/%s.sock",
driver->stateDir, vm->def->name) < 0) {
- lxcError(conn, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return -1;
}
@@ -816,7 +815,7 @@ cleanup:
return ret;
no_memory:
- lxcError(conn, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto cleanup;
}
@@ -853,7 +852,7 @@ static int lxcVmStart(virConnectPtr conn,
if (virAsprintf(&logfile, "%s/%s.log",
driver->logDir, vm->def->name) < 0) {
- lxcError(conn, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return -1;
}
diff --git a/src/network_conf.c b/src/network_conf.c
index 4186629..e19f0fe 100644
--- a/src/network_conf.c
+++ b/src/network_conf.c
@@ -161,7 +161,7 @@ virNetworkObjPtr virNetworkAssignDef(virConnectPtr conn,
}
if (VIR_ALLOC(network) < 0) {
- virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
if (virMutexInit(&network->lock) < 0) {
@@ -174,7 +174,7 @@ virNetworkObjPtr virNetworkAssignDef(virConnectPtr conn,
network->def = def;
if (VIR_REALLOC_N(nets->objs, nets->count + 1) < 0) {
- virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
VIR_FREE(network);
return NULL;
}
@@ -240,7 +240,7 @@ virNetworkDHCPRangeDefParseXML(virConnectPtr conn,
if (VIR_REALLOC_N(def->ranges, def->nranges + 1) < 0) {
xmlFree(start);
xmlFree(end);
- virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return -1;
}
def->ranges[def->nranges].start = (char *)start;
@@ -291,7 +291,7 @@ virNetworkDHCPRangeDefParseXML(virConnectPtr conn,
VIR_FREE(ip);
VIR_FREE(mac);
VIR_FREE(name);
- virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return -1;
}
def->hosts[def->nhosts].mac = (char *)mac;
@@ -314,7 +314,7 @@ virNetworkDefParseXML(virConnectPtr conn,
char *tmp;
if (VIR_ALLOC(def) < 0) {
- virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
@@ -382,7 +382,7 @@ virNetworkDefParseXML(virConnectPtr conn,
netaddr = inet_ntoa(inaddress);
if (virAsprintf(&def->network, "%s/%s", netaddr, def->netmask) < 0) {
- virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto error;
}
@@ -544,7 +544,7 @@ virNetworkDefPtr virNetworkDefParseNode(virConnectPtr conn,
ctxt = xmlXPathNewContext(xml);
if (ctxt == NULL) {
- virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto cleanup;
}
@@ -632,7 +632,7 @@ char *virNetworkDefFormat(virConnectPtr conn,
return virBufferContentAndReset(&buf);
no_memory:
- virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
tmp = virBufferContentAndReset(&buf);
VIR_FREE(tmp);
return NULL;
@@ -840,7 +840,7 @@ char *virNetworkConfigFile(virConnectPtr conn,
char *ret = NULL;
if (virAsprintf(&ret, "%s/%s.xml", dir, name) < 0) {
- virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
diff --git a/src/network_driver.c b/src/network_driver.c
index c546a2b..dcc6ad9 100644
--- a/src/network_driver.c
+++ b/src/network_driver.c
@@ -252,8 +252,7 @@ networkStartup(void) {
}
if (!(driverState->iptables = iptablesContextNew())) {
- networkReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for IP tables support"));
+ virReportOOMError(NULL);
goto error;
}
@@ -502,8 +501,7 @@ networkBuildDnsmasqArgv(virConnectPtr conn,
VIR_FREE((*argv)[i]);
VIR_FREE(*argv);
}
- networkReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for dnsmasq argv"));
+ virReportOOMError(conn);
return -1;
}
@@ -1062,8 +1060,7 @@ static int networkListNetworks(virConnectPtr conn, char **const names, int nname
if (virNetworkIsActive(driver->networks.objs[i])) {
if (!(names[got] = strdup(driver->networks.objs[i]->def->name))) {
virNetworkObjUnlock(driver->networks.objs[i]);
- networkReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for VM name string"));
+ virReportOOMError(conn);
goto cleanup;
}
got++;
@@ -1107,8 +1104,7 @@ static int networkListDefinedNetworks(virConnectPtr conn, char **const names, in
if (!virNetworkIsActive(driver->networks.objs[i])) {
if (!(names[got] = strdup(driver->networks.objs[i]->def->name))) {
virNetworkObjUnlock(driver->networks.objs[i]);
- networkReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for VM name string"));
+ virReportOOMError(conn);
goto cleanup;
}
got++;
@@ -1331,8 +1327,7 @@ static char *networkGetBridgeName(virNetworkPtr net) {
bridge = strdup(network->def->bridge);
if (!bridge)
- networkReportError(net->conn, NULL, net, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for network bridge string"));
+ virReportOOMError(net->conn);
cleanup:
if (network)
diff --git a/src/node_device.c b/src/node_device.c
index 9586fa6..1b7be60 100644
--- a/src/node_device.c
+++ b/src/node_device.c
@@ -33,6 +33,8 @@
#include "node_device_conf.h"
#include "node_device.h"
+#define VIR_FROM_THIS VIR_FROM_NODEDEV
+
static int dev_has_cap(const virNodeDeviceObjPtr dev, const char *cap)
{
virNodeDevCapsDefPtr caps = dev->def->caps;
@@ -176,7 +178,7 @@ static char *nodeDeviceGetParent(virNodeDevicePtr dev)
ret = strdup(obj->def->parent);
if (!ret)
- virNodeDeviceReportError(dev->conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(dev->conn);
cleanup:
if (obj)
diff --git a/src/node_device_conf.c b/src/node_device_conf.c
index ff022b7..af2f9a3 100644
--- a/src/node_device_conf.c
+++ b/src/node_device_conf.c
@@ -36,6 +36,7 @@
#include "buf.h"
#include "uuid.h"
+#define VIR_FROM_THIS VIR_FROM_NODEDEV
VIR_ENUM_IMPL(virNodeDevCap, VIR_NODE_DEV_CAP_LAST,
"system",
@@ -126,7 +127,7 @@ virNodeDeviceObjPtr virNodeDeviceAssignDef(virConnectPtr conn,
}
if (VIR_ALLOC(device) < 0) {
- virNodeDeviceReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
@@ -143,7 +144,7 @@ virNodeDeviceObjPtr virNodeDeviceAssignDef(virConnectPtr conn,
device->def = NULL;
virNodeDeviceObjUnlock(device);
virNodeDeviceObjFree(device);
- virNodeDeviceReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
devs->objs[devs->count++] = device;
@@ -360,7 +361,7 @@ char *virNodeDeviceDefFormat(virConnectPtr conn,
return virBufferContentAndReset(&buf);
no_memory:
- virNodeDeviceReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
tmp = virBufferContentAndReset(&buf);
VIR_FREE(tmp);
return NULL;
@@ -425,4 +426,3 @@ void virNodeDeviceObjUnlock(virNodeDeviceObjPtr obj)
{
virMutexUnlock(&obj->lock);
}
-
diff --git a/src/openvz_conf.c b/src/openvz_conf.c
index 54474b7..ff3d607 100644
--- a/src/openvz_conf.c
+++ b/src/openvz_conf.c
@@ -51,6 +51,8 @@
#include "util.h"
#include "nodeinfo.h"
+#define VIR_FROM_THIS VIR_FROM_OPENVZ
+
static char *openvzLocateConfDir(void);
static int openvzGetVPSUUID(int vpsid, char *uuidstr);
static int openvzLocateConfFile(int vpsid, char *conffile, int maxlen, const char *ext);
@@ -305,7 +307,7 @@ openvzReadNetworkConf(virConnectPtr conn,
return 0;
no_memory:
- openvzError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
error:
virDomainNetDefFree(net);
return -1;
@@ -346,7 +348,7 @@ openvzReadFSConf(virConnectPtr conn,
return 0;
no_memory:
- openvzError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
error:
virDomainFSDefFree(fs);
return -1;
@@ -461,7 +463,7 @@ int openvzLoadDomains(struct openvz_driver *driver) {
return 0;
no_memory:
- openvzError(NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(NULL);
cleanup:
fclose(fp);
diff --git a/src/openvz_driver.c b/src/openvz_driver.c
index d22ea39..e004819 100644
--- a/src/openvz_driver.c
+++ b/src/openvz_driver.c
@@ -58,6 +58,8 @@
#include "memory.h"
#include "bridge.h"
+#define VIR_FROM_THIS VIR_FROM_OPENVZ
+
#define OPENVZ_MAX_ARG 28
#define CMDBUF_LEN 1488
#define CMDOP_LEN 288
@@ -213,7 +215,7 @@ static char *openvzGetOSType(virDomainPtr dom)
}
if (!(ret = strdup(vm->def->os.type)))
- openvzError(dom->conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(dom->conn);
cleanup:
if (vm)
@@ -1056,7 +1058,7 @@ static virDrvOpenStatus openvzOpen(virConnectPtr conn,
}
if (VIR_ALLOC(driver) < 0) {
- openvzError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return VIR_DRV_OPEN_ERROR;
}
@@ -1194,7 +1196,7 @@ static int openvzListDefinedDomains(virConnectPtr conn,
return got;
no_memory:
- openvzError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
for ( ; got >= 0 ; got--)
VIR_FREE(names[got]);
return -1;
@@ -1329,4 +1331,3 @@ int openvzRegister(void) {
virRegisterDriver(&openvzDriver);
return 0;
}
-
diff --git a/src/proxy_internal.c b/src/proxy_internal.c
index d1255ae..6a34e7e 100644
--- a/src/proxy_internal.c
+++ b/src/proxy_internal.c
@@ -948,7 +948,7 @@ xenProxyGetCapabilities (virConnectPtr conn)
xmllen = ans.len - sizeof (virProxyPacket);
if (VIR_ALLOC_N(xml, xmllen+1) < 0) {
- virProxyError (conn, VIR_ERR_NO_MEMORY, __FUNCTION__);
+ virReportOOMError (conn);
return NULL;
}
memmove (xml, ans.extra.str, xmllen);
@@ -998,7 +998,7 @@ xenProxyDomainDumpXML(virDomainPtr domain, int flags ATTRIBUTE_UNUSED)
}
xmllen = ans.len - sizeof(virProxyPacket);
if (VIR_ALLOC_N(xml, xmllen+1) < 0) {
- virProxyError(domain->conn, VIR_ERR_NO_MEMORY, __FUNCTION__);
+ virReportOOMError(domain->conn);
return NULL;
}
memmove(xml, &ans.extra.dinfo, xmllen);
@@ -1050,7 +1050,7 @@ xenProxyDomainGetOSType(virDomainPtr domain)
}
oslen = ans.len - sizeof(virProxyPacket);
if (VIR_ALLOC_N(ostype, oslen+1) < 0) {
- virProxyError(domain->conn, VIR_ERR_NO_MEMORY, __FUNCTION__);
+ virReportOOMError(domain->conn);
return NULL;
}
memmove(ostype, &ans.extra.dinfo, oslen);
diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index bd5d414..ce9278e 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -70,13 +70,11 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
/* Setup 2 critical defaults */
if (!(driver->vncListen = strdup("127.0.0.1"))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate vncListen"));
+ virReportOOMError(NULL);
return -1;
}
if (!(driver->vncTLSx509certdir = strdup(SYSCONF_DIR "/pki/libvirt-vnc"))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate vncTLSx509certdir"));
+ virReportOOMError(NULL);
return -1;
}
@@ -110,8 +108,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
if (p && p->str) {
VIR_FREE(driver->vncTLSx509certdir);
if (!(driver->vncTLSx509certdir = strdup(p->str))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate vncTLSx509certdir"));
+ virReportOOMError(NULL);
virConfFree(conf);
return -1;
}
@@ -122,8 +119,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
if (p && p->str) {
VIR_FREE(driver->vncListen);
if (!(driver->vncListen = strdup(p->str))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate vnc_listen"));
+ virReportOOMError(NULL);
virConfFree(conf);
return -1;
}
@@ -512,7 +508,7 @@ qemudNetworkIfaceConnect(virConnectPtr conn,
strchr(net->ifname, '%')) {
VIR_FREE(net->ifname);
if (!(net->ifname = strdup("vnet%d"))) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto error;
}
}
@@ -555,8 +551,7 @@ qemudNetworkIfaceConnect(virConnectPtr conn,
return retval;
no_memory:
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for tapfds string"));
+ virReportOOMError(conn);
error:
VIR_FREE(retval);
if (tapfd != -1)
@@ -1296,8 +1291,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
return 0;
no_memory:
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for argv string"));
+ virReportOOMError(conn);
error:
if (tapfds &&
*tapfds) {
@@ -1371,8 +1365,7 @@ qemudDomainStatusParseFile(virConnectPtr conn,
qemudDomainStatusPtr status = NULL;
if (VIR_ALLOC(status) < 0) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for vm status"));
+ virReportOOMError(conn);
goto error;
}
@@ -1402,7 +1395,7 @@ qemudDomainStatusParseFile(virConnectPtr conn,
ctxt = xmlXPathNewContext(xml);
if (ctxt == NULL) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto error;
}
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 3d9a0a2..aae29a9 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -1,7 +1,7 @@
/*
* driver.c: core driver methods for managing qemu guests
*
- * Copyright (C) 2006, 2007, 2008 Red Hat, Inc.
+ * Copyright (C) 2006, 2007, 2008, 2009 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -275,8 +275,7 @@ qemudRemoveDomainStatus(virConnectPtr conn,
char *file = NULL;
if (virAsprintf(&file, "%s/%s.xml", driver->stateDir, vm->def->name) < 0) {
- qemudReportError(conn, vm, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for status file"));
+ virReportOOMError(conn);
goto cleanup;
}
@@ -728,8 +727,7 @@ static int qemudOpenMonitor(virConnectPtr conn,
goto error;
if (!(vm->monitorpath = strdup(monitor))) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for monitor path"));
+ virReportOOMError(conn);
goto error;
}
@@ -770,8 +768,7 @@ static int qemudExtractMonitorPath(virConnectPtr conn,
while (*tmp) {
if (c_isspace(*tmp)) {
if (VIR_ALLOC_N(*path, (tmp-dev)+1) < 0) {
- qemudReportError(conn, NULL, NULL,
- VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return -1;
}
strncpy(*path, dev, (tmp-dev));
@@ -876,8 +873,7 @@ qemudDetectVcpuPIDs(virConnectPtr conn,
vm->nvcpupids = vm->def->vcpus;
if (VIR_ALLOC_N(vm->vcpupids, vm->nvcpupids) < 0) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("allocate cpumap"));
+ virReportOOMError(conn);
return -1;
}
@@ -1434,7 +1430,7 @@ static virDrvOpenStatus qemudOpen(virConnectPtr conn,
if (conn->uri == NULL) {
conn->uri = xmlParseURI(uid ? "qemu:///session" : "qemu:///system");
if (!conn->uri) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,NULL);
+ virReportOOMError(conn);
return VIR_DRV_OPEN_ERROR;
}
} else if (conn->uri->scheme == NULL ||
@@ -1537,8 +1533,7 @@ static char *qemudGetCapabilities(virConnectPtr conn) {
qemuDriverLock(driver);
if ((xml = virCapabilitiesFormatXML(driver->caps)) == NULL)
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for capabilities support"));
+ virReportOOMError(conn);
qemuDriverUnlock(driver);
return xml;
@@ -2020,8 +2015,7 @@ static char *qemudDomainGetOSType(virDomainPtr dom) {
}
if (!(type = strdup(vm->def->os.type)))
- qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for ostype"));
+ virReportOOMError(dom->conn);
cleanup:
if (vm)
@@ -2785,8 +2779,7 @@ static int qemudListDefinedDomains(virConnectPtr conn,
virDomainObjLock(driver->domains.objs[i]);
if (!virDomainIsActive(driver->domains.objs[i])) {
if (!(names[got++] = strdup(driver->domains.objs[i]->def->name))) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for VM name string"));
+ virReportOOMError(conn);
virDomainObjUnlock(driver->domains.objs[i]);
goto cleanup;
}
@@ -2996,7 +2989,7 @@ static char *qemudDiskDeviceName(const virConnectPtr conn,
}
if (ret == -1) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
@@ -3060,7 +3053,7 @@ static int qemudDomainChangeEjectableMedia(virConnectPtr conn,
}
if (!devname) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return -1;
}
}
@@ -3068,12 +3061,12 @@ static int qemudDomainChangeEjectableMedia(virConnectPtr conn,
if (newdisk->src) {
safe_path = qemudEscapeMonitorArg(newdisk->src);
if (!safe_path) {
- qemudReportError(conn, dom, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
VIR_FREE(devname);
return -1;
}
if (virAsprintf(&cmd, "change %s \"%s\"", devname, safe_path) == -1) {
- qemudReportError(conn, dom, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
VIR_FREE(safe_path);
VIR_FREE(devname);
return -1;
@@ -3081,7 +3074,7 @@ static int qemudDomainChangeEjectableMedia(virConnectPtr conn,
VIR_FREE(safe_path);
} else if (virAsprintf(&cmd, "eject %s", devname) == -1) {
- qemudReportError(conn, dom, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
VIR_FREE(devname);
return -1;
}
@@ -3133,7 +3126,7 @@ static int qemudDomainAttachPciDiskDevice(virConnectPtr conn,
}
if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return -1;
}
@@ -3148,7 +3141,7 @@ static int qemudDomainAttachPciDiskDevice(virConnectPtr conn,
safe_path, type);
VIR_FREE(safe_path);
if (ret == -1) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return ret;
}
@@ -3203,7 +3196,7 @@ static int qemudDomainAttachUsbMassstorageDevice(virConnectPtr conn,
}
if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return -1;
}
@@ -3217,7 +3210,7 @@ static int qemudDomainAttachUsbMassstorageDevice(virConnectPtr conn,
ret = virAsprintf(&cmd, "usb_add disk:%s", safe_path);
VIR_FREE(safe_path);
if (ret == -1) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return ret;
}
@@ -3257,7 +3250,7 @@ static int qemudDomainAttachHostDevice(virConnectPtr conn,
char *cmd, *reply;
if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs+1) < 0) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return -1;
}
@@ -3271,7 +3264,7 @@ static int qemudDomainAttachHostDevice(virConnectPtr conn,
dev->data.hostdev->source.subsys.u.usb.device);
}
if (ret == -1) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return -1;
}
@@ -3398,7 +3391,7 @@ static int qemudDomainDetachPciDiskDevice(virConnectPtr conn,
}
if (virAsprintf(&cmd, "pci_del 0 %d", detach->slotnum) < 0) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto cleanup;
}
@@ -3421,7 +3414,7 @@ static int qemudDomainDetachPciDiskDevice(virConnectPtr conn,
if (vm->def->ndisks > 1) {
vm->def->disks[i] = vm->def->disks[--vm->def->ndisks];
if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks) < 0) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto cleanup;
}
qsort(vm->def->disks, vm->def->ndisks, sizeof(*vm->def->disks),
@@ -4071,8 +4064,7 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn,
/* Caller frees */
if (virAsprintf(uri_out, "tcp:%s:%d", hostname, this_port) < 0) {
- qemudReportError (dconn, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", strerror (errno));
+ virReportOOMError (dconn);
goto cleanup;
}
} else {
diff --git a/src/remote_internal.c b/src/remote_internal.c
index 93b27af..8ed52bc 100644
--- a/src/remote_internal.c
+++ b/src/remote_internal.c
@@ -507,7 +507,7 @@ doRemoteOpen (virConnectPtr conn,
}
if (!name) {
- error(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto failed;
}
@@ -803,7 +803,7 @@ doRemoteOpen (virConnectPtr conn,
conn->uri = xmlParseURI(uriret.uri);
VIR_FREE(uriret.uri);
if (!conn->uri) {
- error (conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError (conn);
goto failed;
}
}
@@ -862,7 +862,7 @@ doRemoteOpen (virConnectPtr conn,
return retcode;
out_of_memory:
- error (conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError (conn);
failed:
/* Close the socket if we failed. */
@@ -904,7 +904,7 @@ remoteOpen (virConnectPtr conn,
return VIR_DRV_OPEN_DECLINED;
if (VIR_ALLOC(priv) < 0) {
- error (conn, VIR_ERR_NO_MEMORY, _("struct private_data"));
+ virReportOOMError (conn);
return VIR_DRV_OPEN_ERROR;
}
@@ -2837,7 +2837,7 @@ remoteDomainSetSchedulerParameters (virDomainPtr domain,
// call() will free this:
args.params.params_val[i].field = strdup (params[i].field);
if (args.params.params_val[i].field == NULL) {
- error (domain->conn, VIR_ERR_NO_MEMORY, _("out of memory"));
+ virReportOOMError (domain->conn);
do_error = 1;
}
args.params.params_val[i].value.type = params[i].type;
@@ -3087,7 +3087,7 @@ remoteNetworkOpen (virConnectPtr conn,
struct private_data *priv;
int ret, rflags = 0;
if (VIR_ALLOC(priv) < 0) {
- error (conn, VIR_ERR_NO_MEMORY, _("struct private_data"));
+ virReportOOMError (conn);
return VIR_DRV_OPEN_ERROR;
}
if (virMutexInit(&priv->lock) < 0) {
@@ -3600,7 +3600,7 @@ remoteStorageOpen (virConnectPtr conn,
struct private_data *priv;
int ret, rflags = 0;
if (VIR_ALLOC(priv) < 0) {
- error (NULL, VIR_ERR_NO_MEMORY, _("struct private_data"));
+ virReportOOMError (NULL);
return VIR_DRV_OPEN_ERROR;
}
if (virMutexInit(&priv->lock) < 0) {
@@ -4553,7 +4553,7 @@ remoteDevMonOpen(virConnectPtr conn,
struct private_data *priv;
int ret, rflags = 0;
if (VIR_ALLOC(priv) < 0) {
- error (NULL, VIR_ERR_NO_MEMORY, _("struct private_data"));
+ virReportOOMError (NULL);
return VIR_DRV_OPEN_ERROR;
}
if (virMutexInit(&priv->lock) < 0) {
diff --git a/src/sexpr.c b/src/sexpr.c
index d97bf77..7450c79 100644
--- a/src/sexpr.c
+++ b/src/sexpr.c
@@ -23,6 +23,8 @@
#include "util.h"
#include "memory.h"
+#define VIR_FROM_THIS VIR_FROM_SEXPR
+
#define virSexprError(code, fmt...) \
virReportErrorHelper(NULL, VIR_FROM_SEXPR, code, __FILE__, \
__FUNCTION__, __LINE__, fmt)
@@ -40,7 +42,7 @@ sexpr_new(void)
struct sexpr *ret;
if (VIR_ALLOC(ret) < 0) {
- virSexprError(VIR_ERR_NO_MEMORY, "%s", _("failed to allocate a node"));
+ virReportOOMError(NULL);
return (NULL);
}
ret->kind = SEXPR_NIL;
@@ -343,8 +345,7 @@ _string2sexpr(const char *buffer, size_t * end)
ret->u.value = strndup(start, ptr - start);
if (ret->u.value == NULL) {
- virSexprError(VIR_ERR_NO_MEMORY,
- "%s", _("failed to copy a string"));
+ virReportOOMError(NULL);
goto error;
}
diff --git a/src/stats_linux.c b/src/stats_linux.c
index b58457d..eccda94 100644
--- a/src/stats_linux.c
+++ b/src/stats_linux.c
@@ -1,7 +1,7 @@
/*
* Linux block and network stats.
*
- * Copyright (C) 2007, 2008 Red Hat, Inc.
+ * Copyright (C) 2007-2009 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
@@ -31,6 +31,8 @@
#include "stats_linux.h"
#include "memory.h"
+#define VIR_FROM_THIS VIR_FROM_STATS_LINUX
+
/**
* statsErrorFunc:
* @conn: the connection
@@ -297,8 +299,7 @@ xenLinuxDomainDeviceID(virConnectPtr conn, int domid, const char *path)
retval = virAsprintf(&mod_path, "/dev/%s", path);
if (retval < 0) {
- statsErrorFunc (conn, VIR_ERR_NO_MEMORY, __FUNCTION__,
- "allocating mod_path", domid);
+ virReportOOMError (conn);
return -1;
}
diff --git a/src/storage_backend_iscsi.c b/src/storage_backend_iscsi.c
index 1d909c5..bbb94a5 100644
--- a/src/storage_backend_iscsi.c
+++ b/src/storage_backend_iscsi.c
@@ -97,7 +97,7 @@ virStorageBackendISCSIExtractSession(virConnectPtr conn,
if (STREQ(groups[1], pool->def->source.devices[0].path)) {
if ((*session = strdup(groups[0])) == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("session"));
+ virReportOOMError(conn);
return -1;
}
}
@@ -179,19 +179,19 @@ virStorageBackendISCSINewLun(virConnectPtr conn, virStoragePoolObjPtr pool,
int opentries = 0;
if (VIR_ALLOC(vol) < 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("volume"));
+ virReportOOMError(conn);
goto cleanup;
}
vol->type = VIR_STORAGE_VOL_BLOCK;
if (virAsprintf(&(vol->name), "lun-%d", lun) < 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("name"));
+ virReportOOMError(conn);
goto cleanup;
}
if (virAsprintf(&devpath, "/dev/%s", dev) < 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("devpath"));
+ virReportOOMError(conn);
goto cleanup;
}
@@ -234,7 +234,7 @@ virStorageBackendISCSINewLun(virConnectPtr conn, virStoragePoolObjPtr pool,
/* XXX use unique iSCSI id instead */
vol->key = strdup(vol->target.path);
if (vol->key == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("key"));
+ virReportOOMError(conn);
goto cleanup;
}
@@ -244,7 +244,7 @@ virStorageBackendISCSINewLun(virConnectPtr conn, virStoragePoolObjPtr pool,
if (VIR_REALLOC_N(pool->volumes.objs,
pool->volumes.count+1) < 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto cleanup;
}
pool->volumes.objs[pool->volumes.count++] = vol;
@@ -477,8 +477,7 @@ virStorageBackendISCSIFindLUNs(virConnectPtr conn,
scsidev = strdup(block2);
}
if (scsidev == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s",
- _("Failed allocating memory for scsidev"));
+ virReportOOMError(conn);
retval = -1;
goto namelist_cleanup;
}
@@ -559,7 +558,7 @@ virStorageBackendISCSIPortal(virConnectPtr conn,
return NULL;
if (VIR_ALLOC_N(portal, strlen(ipaddr) + 1 + 4 + 2 + 1) < 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("portal"));
+ virReportOOMError(conn);
return NULL;
}
diff --git a/src/storage_backend_logical.c b/src/storage_backend_logical.c
index 474c3d8..461c110 100644
--- a/src/storage_backend_logical.c
+++ b/src/storage_backend_logical.c
@@ -84,21 +84,21 @@ virStorageBackendLogicalMakeVol(virConnectPtr conn,
/* Or a completely new volume */
if (vol == NULL) {
if (VIR_ALLOC(vol) < 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("volume"));
+ virReportOOMError(conn);
return -1;
}
vol->type = VIR_STORAGE_VOL_BLOCK;
if ((vol->name = strdup(groups[0])) == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("volume"));
+ virReportOOMError(conn);
virStorageVolDefFree(vol);
return -1;
}
if (VIR_REALLOC_N(pool->volumes.objs,
pool->volumes.count + 1)) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
virStorageVolDefFree(vol);
return -1;
}
@@ -108,7 +108,7 @@ virStorageBackendLogicalMakeVol(virConnectPtr conn,
if (vol->target.path == NULL) {
if (VIR_ALLOC_N(vol->target.path, strlen(pool->def->target.path) +
1 + strlen(vol->name) + 1) < 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("volume"));
+ virReportOOMError(conn);
return -1;
}
strcpy(vol->target.path, pool->def->target.path);
@@ -118,7 +118,7 @@ virStorageBackendLogicalMakeVol(virConnectPtr conn,
if (vol->key == NULL &&
(vol->key = strdup(groups[1])) == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("volume"));
+ virReportOOMError(conn);
return -1;
}
@@ -129,13 +129,13 @@ virStorageBackendLogicalMakeVol(virConnectPtr conn,
/* Finally fill in extents information */
if (VIR_REALLOC_N(vol->source.extents,
vol->source.nextent + 1) < 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("extents"));
+ virReportOOMError(conn);
return -1;
}
if ((vol->source.extents[vol->source.nextent].path =
strdup(groups[2])) == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("extents"));
+ virReportOOMError(conn);
return -1;
}
@@ -256,8 +256,7 @@ virStorageBackendLogicalFindPoolSourcesFunc(virConnectPtr conn,
vgname = strdup(groups[1]);
if (pvname == NULL || vgname == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s",
- _("allocating pvname or vgname"));
+ virReportOOMError(conn);
goto err_no_memory;
}
@@ -271,8 +270,7 @@ virStorageBackendLogicalFindPoolSourcesFunc(virConnectPtr conn,
if (thisSource == NULL) {
if (VIR_REALLOC_N(sourceList->sources, sourceList->nsources + 1) != 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s",
- _("allocating new source"));
+ virReportOOMError(conn);
goto err_no_memory;
}
@@ -286,8 +284,7 @@ virStorageBackendLogicalFindPoolSourcesFunc(virConnectPtr conn,
VIR_FREE(vgname);
if (VIR_REALLOC_N(thisSource->devices, thisSource->ndevice + 1) != 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s",
- _("allocating new device"));
+ virReportOOMError(conn);
goto err_no_memory;
}
@@ -386,7 +383,7 @@ virStorageBackendLogicalBuildPool(virConnectPtr conn,
memset(zeros, 0, sizeof(zeros));
if (VIR_ALLOC_N(vgargv, 3 + pool->def->source.ndevice) < 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("command line"));
+ virReportOOMError(conn);
return -1;
}
@@ -581,7 +578,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn,
}
if (VIR_ALLOC_N(vol->target.path, strlen(pool->def->target.path) +
1 + strlen(vol->name) + 1) < 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("volume"));
+ virReportOOMError(conn);
return -1;
}
strcpy(vol->target.path, pool->def->target.path);
diff --git a/src/storage_conf.c b/src/storage_conf.c
index 9d3f5a7..a2b7fab 100644
--- a/src/storage_conf.c
+++ b/src/storage_conf.c
@@ -426,8 +426,7 @@ virStoragePoolDefParseDoc(virConnectPtr conn,
char *authType = NULL;
if (VIR_ALLOC(ret) < 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- "%s", _("cannot allocate storage pool"));
+ virReportOOMError(conn);
return NULL;
}
@@ -511,7 +510,7 @@ virStoragePoolDefParseDoc(virConnectPtr conn,
}
if (VIR_ALLOC_N(ret->source.devices, nsource) < 0) {
VIR_FREE(nodeset);
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("device"));
+ virReportOOMError(conn);
goto cleanup;
}
for (i = 0 ; i < nsource ; i++) {
@@ -541,8 +540,7 @@ virStoragePoolDefParseDoc(virConnectPtr conn,
/* source name defaults to pool name */
ret->source.name = strdup(ret->name);
if (ret->source.name == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s",
- _("pool name"));
+ virReportOOMError(conn);
goto cleanup;
}
}
@@ -640,8 +638,7 @@ virStoragePoolDefParse(virConnectPtr conn,
ctxt = xmlXPathNewContext(xml);
if (ctxt == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- "%s", _("xmlXPathContext"));
+ virReportOOMError(conn);
goto cleanup;
}
@@ -791,7 +788,7 @@ virStoragePoolDefFormat(virConnectPtr conn,
return virBufferContentAndReset(&buf);
no_memory:
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("xml"));
+ virReportOOMError(conn);
cleanup:
free(virBufferContentAndReset(&buf));
return NULL;
@@ -934,8 +931,7 @@ virStorageVolDefParseDoc(virConnectPtr conn,
return NULL;
if (VIR_ALLOC(ret) < 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- "%s", _("cannot allocate storage vol"));
+ virReportOOMError(conn);
return NULL;
}
@@ -1041,8 +1037,7 @@ virStorageVolDefParse(virConnectPtr conn,
ctxt = xmlXPathNewContext(xml);
if (ctxt == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- "%s", _("xmlXPathContext"));
+ virReportOOMError(conn);
goto cleanup;
}
@@ -1155,7 +1150,7 @@ virStorageVolDefFormat(virConnectPtr conn,
return virBufferContentAndReset(&buf);
no_memory:
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("xml"));
+ virReportOOMError(conn);
cleanup:
tmp = virBufferContentAndReset(&buf);
VIR_FREE(tmp);
@@ -1259,8 +1254,7 @@ virStoragePoolObjAssignDef(virConnectPtr conn,
}
if (VIR_ALLOC(pool) < 0) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- "%s", _("pool"));
+ virReportOOMError(conn);
return NULL;
}
@@ -1278,7 +1272,7 @@ virStoragePoolObjAssignDef(virConnectPtr conn,
pool->def = NULL;
virStoragePoolObjUnlock(pool);
virStoragePoolObjFree(pool);
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
pools->objs[pools->count++] = pool;
@@ -1420,8 +1414,7 @@ virStoragePoolObjSaveDef(virConnectPtr conn,
return -1;
}
if (!(pool->configFile = strdup(path))) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- "%s", _("configFile"));
+ virReportOOMError(conn);
return -1;
}
@@ -1434,8 +1427,7 @@ virStoragePoolObjSaveDef(virConnectPtr conn,
return -1;
}
if (!(pool->autostartLink = strdup(path))) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- "%s", _("config file"));
+ virReportOOMError(conn);
VIR_FREE(pool->configFile);
return -1;
}
@@ -1534,7 +1526,7 @@ char *virStoragePoolSourceListFormat(virConnectPtr conn,
return virBufferContentAndReset(&buf);
no_memory:
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
cleanup:
free(virBufferContentAndReset(&buf));
return NULL;
diff --git a/src/uml_conf.c b/src/uml_conf.c
index f2bf09f..c0d086e 100644
--- a/src/uml_conf.c
+++ b/src/uml_conf.c
@@ -1,7 +1,7 @@
/*
* uml_conf.c: UML driver configuration
*
- * Copyright (C) 2006, 2007, 2008 Red Hat, Inc.
+ * Copyright (C) 2006-2009 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -45,6 +45,7 @@
#include "nodeinfo.h"
#include "verify.h"
+#define VIR_FROM_THIS VIR_FROM_UML
#define umlLog(level, msg, ...) \
virLogMessage(__FILE__, level, 0, msg, __VA_ARGS__)
@@ -100,14 +101,14 @@ umlBuildCommandLineChr(virConnectPtr conn,
switch (def->type) {
case VIR_DOMAIN_CHR_TYPE_NULL:
if (virAsprintf(&ret, "%s%d=null", dev, def->dstPort) < 0) {
- umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
break;
case VIR_DOMAIN_CHR_TYPE_PTY:
if (virAsprintf(&ret, "%s%d=pts", dev, def->dstPort) < 0) {
- umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
break;
@@ -115,14 +116,14 @@ umlBuildCommandLineChr(virConnectPtr conn,
case VIR_DOMAIN_CHR_TYPE_DEV:
if (virAsprintf(&ret, "%s%d=tty:%s", dev, def->dstPort,
def->data.file.path) < 0) {
- umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
break;
case VIR_DOMAIN_CHR_TYPE_STDIO:
if (virAsprintf(&ret, "%s%d=fd:0,fd:1", dev, def->dstPort) < 0) {
- umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
break;
@@ -136,7 +137,7 @@ umlBuildCommandLineChr(virConnectPtr conn,
if (virAsprintf(&ret, "%s%d=port:%s", dev, def->dstPort,
def->data.tcp.service) < 0) {
- umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
break;
@@ -308,8 +309,7 @@ int umlBuildCommandLine(virConnectPtr conn,
return 0;
no_memory:
- umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate space for argv string"));
+ virReportOOMError(conn);
error:
if (tapfds &&
*tapfds) {
diff --git a/src/util.c b/src/util.c
index b513559..e049999 100644
--- a/src/util.c
+++ b/src/util.c
@@ -458,7 +458,7 @@ virExec(virConnectPtr conn,
char *argv_str;
if ((argv_str = virArgvToString(argv)) == NULL) {
- ReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("command debug string"));
+ virReportOOMError(conn);
return -1;
}
DEBUG0(argv_str);
@@ -526,7 +526,7 @@ virPipeReadUntilEOF(virConnectPtr conn, int outfd, int errfd,
buf = ((fds[i].fd == outfd) ? outbuf : errbuf);
size = (*buf ? strlen(*buf) : 0);
if (VIR_REALLOC_N(*buf, size+got+1) < 0) {
- ReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
goto error;
}
memmove(*buf+size, data, got);
@@ -576,7 +576,7 @@ virRun(virConnectPtr conn,
char *argv_str = NULL;
if ((argv_str = virArgvToString(argv)) == NULL) {
- ReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("command debug string"));
+ virReportOOMError(conn);
goto error;
}
DEBUG0(argv_str);
diff --git a/src/xen_internal.c b/src/xen_internal.c
index 1ef835e..9a7272f 100644
--- a/src/xen_internal.c
+++ b/src/xen_internal.c
@@ -1639,8 +1639,7 @@ virXen_setvcpumap(int handle, int id, unsigned int vcpu,
* for Xen, and also nr_cpus must be 'sizeof(uint64_t) * 8' */
if (maplen < 8) {
if (VIR_ALLOC_N(new, sizeof(uint64_t)) < 0) {
- virXenErrorFunc(NULL, VIR_ERR_NO_MEMORY, __FUNCTION__,
- "allocating private data", 0);
+ virReportOOMError(NULL);
return (-1);
}
memcpy(new, cpumap, maplen);
@@ -1965,7 +1964,7 @@ xenHypervisorInit(void)
hypervisor_version = 2;
if (VIR_ALLOC(ipt) < 0) {
- virXenError(NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(NULL);
return(-1);
}
/* Currently consider RHEL5.0 Fedora7, xen-3.1, and xen-unstable */
@@ -2359,7 +2358,7 @@ xenHypervisorMakeCapabilitiesSunOS(virConnectPtr conn)
utsname.machine,
pae, hvm,
guest_arches, i)) == NULL)
- virXenError(NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(NULL);
return caps;
}
@@ -2520,7 +2519,7 @@ xenHypervisorMakeCapabilitiesInternal(virConnectPtr conn,
return caps;
no_memory:
- virXenError(NULL, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(NULL);
virCapabilitiesFree(caps);
return NULL;
}
@@ -2593,7 +2592,7 @@ xenHypervisorGetCapabilities (virConnectPtr conn)
char *xml;
if (!(xml = virCapabilitiesFormatXML(priv->caps))) {
- virXenError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
@@ -2626,8 +2625,7 @@ xenHypervisorNumOfDomains(virConnectPtr conn)
retry:
if (!(XEN_GETDOMAININFOLIST_ALLOC(dominfos, maxids))) {
- virXenError(conn, VIR_ERR_NO_MEMORY, _("allocating %d domain info"),
- maxids);
+ virReportOOMError(conn);
return(-1);
}
@@ -2688,8 +2686,7 @@ xenHypervisorListDomains(virConnectPtr conn, int *ids, int maxids)
return(0);
if (!(XEN_GETDOMAININFOLIST_ALLOC(dominfos, maxids))) {
- virXenError(conn, VIR_ERR_NO_MEMORY, "allocating %d domain info",
- maxids);
+ virReportOOMError(conn);
return(-1);
}
@@ -2798,8 +2795,7 @@ xenHypervisorLookupDomainByUUID(virConnectPtr conn,
retry:
if (!(XEN_GETDOMAININFOLIST_ALLOC(dominfos, maxids))) {
- virXenError(conn, VIR_ERR_NO_MEMORY, "allocating %d domain info",
- maxids);
+ virReportOOMError(conn);
return(NULL);
}
diff --git a/src/xend_internal.c b/src/xend_internal.c
index 3bd70ad..75a4324 100644
--- a/src/xend_internal.c
+++ b/src/xend_internal.c
@@ -526,7 +526,7 @@ xend_op_ext(virConnectPtr xend, const char *path, char *error,
}
if (virBufferError(&buf)) {
- virXendError(NULL, VIR_ERR_NO_MEMORY, "%s", _("allocate buffer"));
+ virReportOOMError(NULL);
return -1;
}
@@ -706,7 +706,7 @@ urlencode(const char *string)
size_t i;
if (VIR_ALLOC_N(buffer, len * 3 + 1) < 0) {
- virXendError(NULL, VIR_ERR_NO_MEMORY, "%s", _("allocate new buffer"));
+ virReportOOMError(NULL);
return (NULL);
}
ptr = buffer;
@@ -1186,7 +1186,7 @@ xenDaemonParseSxprOS(virConnectPtr xend,
return 0;
no_memory:
- virXendError(xend, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(xend);
return -1;
}
@@ -1399,8 +1399,7 @@ xend_parse_sexp_desc_char(virConnectPtr conn,
if (ret == -1) {
no_memory:
- virXendError(conn, VIR_ERR_NO_MEMORY,
- "%s", _("no memory for char device config"));
+ virReportOOMError(conn);
}
error:
@@ -1424,7 +1423,7 @@ xenDaemonParseSxprChar(virConnectPtr conn,
virDomainChrDefPtr def;
if (VIR_ALLOC(def) < 0) {
- virXendError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return NULL;
}
@@ -1553,7 +1552,7 @@ xenDaemonParseSxprChar(virConnectPtr conn,
return def;
no_memory:
- virXendError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
error:
virDomainChrDefFree(def);
return NULL;
@@ -1722,7 +1721,7 @@ xenDaemonParseSxprDisks(virConnectPtr conn,
return 0;
no_memory:
- virXendError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
error:
virDomainDiskDefFree(disk);
@@ -1824,7 +1823,7 @@ xenDaemonParseSxprNets(virConnectPtr conn,
return 0;
no_memory:
- virXendError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
cleanup:
virDomainNetDefFree(net);
return -1;
@@ -1905,7 +1904,7 @@ xenDaemonParseSxprSound(virConnectPtr conn,
return 0;
no_memory:
- virXendError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
error:
return -1;
}
@@ -1949,7 +1948,7 @@ xenDaemonParseSxprUSB(virConnectPtr conn,
return 0;
no_memory:
- virXendError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
return -1;
}
@@ -2032,7 +2031,7 @@ xenDaemonParseSxprGraphicsOld(virConnectPtr conn,
return 0;
no_memory:
- virXendError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
virDomainGraphicsDefFree(graphics);
return -1;
}
@@ -2122,7 +2121,7 @@ xenDaemonParseSxprGraphicsNew(virConnectPtr conn,
return 0;
no_memory:
- virXendError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
error:
virDomainGraphicsDefFree(graphics);
return -1;
@@ -2416,7 +2415,7 @@ xenDaemonParseSxpr(virConnectPtr conn,
return def;
no_memory:
- virXendError(conn, VIR_ERR_NO_MEMORY, NULL);
+ virReportOOMError(conn);
error:
VIR_FREE(tty);
virDomainDefFree(def);
@@ -2637,7 +2636,7 @@ sexpr_to_xend_topology(virConnectPtr conn,
memory_error:
VIR_FREE(cpuNums);
VIR_FREE(cpuset);
- virXendError(conn, VIR_ERR_NO_MEMORY, "%s", _("allocate buffer"));
+ virReportOOMError(conn);
return (-1);
}
@@ -4205,7 +4204,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
}
hostname = strdup (uriptr->server);
if (!hostname) {
- virXendError (conn, VIR_ERR_NO_MEMORY, "%s", _("strdup failed"));
+ virReportOOMError (conn);
xmlFreeURI (uriptr);
return -1;
}
@@ -4227,7 +4226,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
n = p - uri; /* n = Length of hostname in bytes. */
hostname = strdup (uri);
if (!hostname) {
- virXendError (conn, VIR_ERR_NO_MEMORY, "%s", _("strdup failed"));
+ virReportOOMError (conn);
return -1;
}
hostname[n] = '\0';
@@ -4235,7 +4234,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
else { /* "hostname" (or IP address) */
hostname = strdup (uri);
if (!hostname) {
- virXendError (conn, VIR_ERR_NO_MEMORY, "%s", _("strdup failed"));
+ virReportOOMError (conn);
return -1;
}
}
diff --git a/src/xml.c b/src/xml.c
index a7ebe7c..ad77eca 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -1,7 +1,7 @@
/*
* xml.c: XML based interfaces for the libvir library
*
- * Copyright (C) 2005, 2007, 2008 Red Hat, Inc.
+ * Copyright (C) 2005, 2007-2009 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
@@ -23,6 +23,8 @@
#include "util.h"
#include "memory.h"
+#define VIR_FROM_THIS VIR_FROM_XML
+
#define virXMLError(conn, code, fmt...) \
virReportErrorHelper(conn, VIR_FROM_XML, code, __FILE__, \
__FUNCTION__, __LINE__, fmt)
@@ -68,7 +70,7 @@ virXPathString(virConnectPtr conn,
ret = strdup((char *) obj->stringval);
xmlXPathFreeObject(obj);
if (ret == NULL) {
- virXMLError(conn, VIR_ERR_NO_MEMORY, "%s", _("strdup failed"));
+ virReportOOMError(conn);
}
ctxt->node = relnode;
return (ret);
@@ -350,9 +352,7 @@ virXPathNodeSet(virConnectPtr conn,
ret = obj->nodesetval->nodeNr;
if (list != NULL && ret) {
if (VIR_ALLOC_N(*list, ret) < 0) {
- virXMLError(conn, VIR_ERR_NO_MEMORY,
- _("allocate string array size %lu"),
- (unsigned long)ret * sizeof(**list));
+ virReportOOMError(conn);
ret = -1;
} else {
memcpy(*list, obj->nodesetval->nodeTab,
@@ -363,4 +363,3 @@ virXPathNodeSet(virConnectPtr conn,
ctxt->node = relnode;
return (ret);
}
-
diff --git a/src/xs_internal.c b/src/xs_internal.c
index dbbf7f2..c7087ed 100644
--- a/src/xs_internal.c
+++ b/src/xs_internal.c
@@ -1,7 +1,7 @@
/*
* xs_internal.c: access to Xen Store
*
- * Copyright (C) 2006 Red Hat, Inc.
+ * Copyright (C) 2006, 2009 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
@@ -37,6 +37,8 @@
#include "xs_internal.h"
#include "xen_internal.h"
+#define VIR_FROM_THIS VIR_FROM_XEN
+
#ifndef PROXY
static char *xenStoreDomainGetOSType(virDomainPtr domain);
static void xenStoreWatchEvent(int watch, int fd, int events, void *data);
@@ -1271,8 +1273,7 @@ int xenStoreDomainIntroduced(virConnectPtr conn,
retry:
new_domain_cnt = xenStoreNumOfDomains(conn);
if( VIR_ALLOC_N(new_domids,new_domain_cnt) < 0 ) {
- virXenStoreError(NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate domids"));
+ virReportOOMError(NULL);
return -1;
}
nread = xenStoreDoListDomains(priv, new_domids, new_domain_cnt);
@@ -1353,8 +1354,7 @@ retry:
new_domain_cnt = xenStoreNumOfDomains(conn);
if( VIR_ALLOC_N(new_domids,new_domain_cnt) < 0 ) {
- virXenStoreError(NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate domids"));
+ virReportOOMError(NULL);
return -1;
}
nread = xenStoreDoListDomains(priv, new_domids, new_domain_cnt);
--
1.6.1.1.363.g2a3bd
15 years, 11 months