[libvirt] [PATCH v2] json: fix interface locale dependency
by Martin Kletzander
libvirt creates invalid commands if wrong locale is selected. For
example with locale that uses comma as a decimal point, JSON commands
created with decimal numbers are invalid because comma separates the
entries in JSON. Fortunately even when decimal point is affected,
thousands grouping is not, because for grouping to be enabled with
*printf, there has to be an apostrophe flag specified (and supported).
This patch adds specific internal function for printing with C locale
and a fallback for the particular case with double formatting in case
these functions are not supported.
---
v2:
- added support for xlocale
- fallback option kept, but main function moved to util.c
src/libvirt_private.syms | 1 +
src/util/json.c | 23 ++++++++++++++++++++++-
src/util/util.c | 42 ++++++++++++++++++++++++++++++++++++++++++
src/util/util.h | 2 ++
4 files changed, 67 insertions(+), 1 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 79b4a18..6ce87bf 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1138,6 +1138,7 @@ safezero;
virArgvToString;
virAsprintf;
virBuildPathInternal;
+virCasprintf;
virDirCreate;
virEnumFromString;
virEnumToString;
diff --git a/src/util/json.c b/src/util/json.c
index 5132989..3dfa039 100644
--- a/src/util/json.c
+++ b/src/util/json.c
@@ -22,6 +22,7 @@
#include <config.h>
+#include <locale.h>
#include "json.h"
#include "memory.h"
@@ -201,8 +202,28 @@ virJSONValuePtr virJSONValueNewNumberDouble(double data)
{
virJSONValuePtr val = NULL;
char *str;
- if (virAsprintf(&str, "%lf", data) < 0)
+
+ int ret = virCasprintf(&str, "%lf", data)
+
+ if (ret == -1) {
return NULL;
+ } else if (ret == -2) {
+ char *radix, *tmp;
+ struct lconv *lc;
+
+ if ((ret = virAsprintf(&str, "%lf", data)) < 0)
+ return NULL;
+
+ lc = localeconv();
+ radix = lc->decimal_point;
+ tmp = strstr(str, radix);
+ if (tmp) {
+ *tmp = '.';
+ if (strlen(radix) > 1)
+ memmove(tmp + 1, tmp + strlen(radix), strlen(str) - (tmp - str));
+ }
+ }
+
val = virJSONValueNewNumber(str);
VIR_FREE(str);
return val;
diff --git a/src/util/util.c b/src/util/util.c
index e5bb27b..de090a6 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -44,6 +44,7 @@
#include <signal.h>
#include <termios.h>
#include <pty.h>
+#include <locale.h>
#if HAVE_LIBDEVMAPPER_H
# include <libdevmapper.h>
@@ -2003,6 +2004,47 @@ virAsprintf(char **strp, const char *fmt, ...)
}
/**
+ * virCasprintf
+ *
+ * the same as virAsprintf, but with C locale (thread-safe)
+ *
+ * If thread-safe locales aren't supported, then the return value is -2,
+ * no memory (or other vasnprintf errors) results in -1.
+ * When successful, the value returned by virAsprintf is passed.
+ */
+#if HAVE_XLOCALE_H
+int
+virCasprintf(char **strp, const char *fmt, ...)
+{
+ va_list ap;
+ int ret = -1;
+ locale_t c_loc, old_loc;
+ c_loc = newlocale(LC_ALL, "C", NULL);
+ if (!c_loc)
+ goto no_memory;
+
+ old_loc = uselocale(c_loc);
+
+ va_start(ap, fmt);
+ ret = virVasprintf(strp, fmt, ap);
+ va_end(ap);
+
+ uselocale(old_loc);
+
+ no_memory:
+ freelocale(c_loc);
+ return ret;
+}
+#else
+int
+virCasprintf(char **strp ATTRIBUTE_UNUSED,
+ const char *fmt ATTRIBUTE_UNUSED, ...)
+{
+ return -2;
+}
+#endif
+
+/**
* virStrncpy
*
* A safe version of strncpy. The last parameter is the number of bytes
diff --git a/src/util/util.h b/src/util/util.h
index d151c27..4b7f286 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -201,6 +201,8 @@ int virParseVersionString(const char *str, unsigned long *version,
bool allowMissing);
int virAsprintf(char **strp, const char *fmt, ...)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_FMT_PRINTF(2, 3);
+int virCasprintf(char **strp, const char *fmt, ...)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_FMT_PRINTF(2, 3);
int virVasprintf(char **strp, const char *fmt, va_list list)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_FMT_PRINTF(2, 0);
char *virStrncpy(char *dest, const char *src, size_t n, size_t destbytes)
--
1.7.8.6
12 years, 3 months
[libvirt] [PATCH] virterror: Add error message for unsupported operations.
by Peter Krempa
This patch introduces a new error code VIR_ERR_OPERATION_UNSUPPORTED to
mark error messages regarding operations that failed due to lack of
support on the hypervisor or other than libvirt issues.
The code is first used in reporting error if qemu does not support block
IO tuning variables yielding error message:
error: Unable to get block I/O throttle parameters
error: Operation not supported: block_io_throttle field
'total_bytes_sec' missing in qemu's output
instead of:
error: Unable to get block I/O throttle parameters
error: internal error cannot read total_bytes_sec
---
include/libvirt/virterror.h | 2 ++
src/qemu/qemu_monitor_json.c | 4 ++--
src/util/virterror.c | 6 ++++++
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h
index ad8e101..913fc5d 100644
--- a/include/libvirt/virterror.h
+++ b/include/libvirt/virterror.h
@@ -277,6 +277,8 @@ typedef enum {
VIR_ERR_MIGRATE_UNSAFE = 81, /* Migration is not safe */
VIR_ERR_OVERFLOW = 82, /* integer overflow */
VIR_ERR_BLOCK_COPY_ACTIVE = 83, /* action prevented by block copy job */
+ VIR_ERR_OPERATION_UNSUPPORTED = 84, /* The requested operation is not
+ supported */
} virErrorNumber;
/**
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 3ede88d..7e482d1 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -3652,11 +3652,11 @@ int qemuMonitorJSONOpenGraphics(qemuMonitorPtr mon,
if (virJSONValueObjectGetNumberUlong(inserted, \
FIELD, \
&reply->STORE) < 0) { \
- virReportError(VIR_ERR_INTERNAL_ERROR, \
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, \
_("block_io_throttle field '%s' missing " \
"in qemu's output"), \
#STORE); \
- goto cleanup; \
+ goto cleanup; \
}
static int
qemuMonitorJSONBlockIoThrottleInfo(virJSONValuePtr result,
diff --git a/src/util/virterror.c b/src/util/virterror.c
index a40cfe0..c438de8 100644
--- a/src/util/virterror.c
+++ b/src/util/virterror.c
@@ -1185,6 +1185,12 @@ virErrorMsg(virErrorNumber error, const char *info)
else
errmsg = _("block copy still active: %s");
break;
+ case VIR_ERR_OPERATION_UNSUPPORTED:
+ if (!info)
+ errmsg = _("Operation not supported");
+ else
+ errmsg = _("Operation not supported: %s");
+ break;
}
return errmsg;
}
--
1.7.8.6
12 years, 3 months
[libvirt] [PATCH] Fix timebomb in LIBVIRT_VERSION_INFO calculation
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The way LIBVIRT_VERSION_INFO is calculated has a timebomb that
will cause us to accidentally break soname when we change the
major version number to a non-zero value !
Given CURRENT:REVISION:AGE, libtool will generate
libvirt.so.($CURRENT-$AGE).$AGE.$REVISION
We set CURRENT to be MAJOR+MINOR and AGE to $MINOR, so as
soon as MAJOR changes to non-zero, we get libvirt.so.1
as the soname, eg 1.3.9 would create libvirt.so.1.3.9
Looks natural but is not ABI compatible with libvirt.so.0.x.y
The fix is to set CURRENT to always be exactly the same
as AGE. We want to have the major version reflected in
the so symlinks though. So then we set AGE to MAJOR*1000+MINOR
eg, so 1.3.9 would create libvirt.so.0.1003.9 and libvirt
2.51.3 would create libvirt.so.0.2051.3
---
configure.ac | 41 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 8a04d91..8de2c6c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,16 +23,55 @@ AM_SILENT_RULES([yes])
AC_CANONICAL_HOST
+# First extract pieces from the version number string
LIBVIRT_MAJOR_VERSION=`echo $VERSION | awk -F. '{print $1}'`
LIBVIRT_MINOR_VERSION=`echo $VERSION | awk -F. '{print $2}'`
LIBVIRT_MICRO_VERSION=`echo $VERSION | awk -F. '{print $3}'`
LIBVIRT_VERSION=$LIBVIRT_MAJOR_VERSION.$LIBVIRT_MINOR_VERSION.$LIBVIRT_MICRO_VERSION$LIBVIRT_MICRO_VERSION_SUFFIX
-LIBVIRT_VERSION_INFO=`expr $LIBVIRT_MAJOR_VERSION + $LIBVIRT_MINOR_VERSION`:$LIBVIRT_MICRO_VERSION:$LIBVIRT_MINOR_VERSION
LIBVIRT_VERSION_NUMBER=`expr $LIBVIRT_MAJOR_VERSION \* 1000000 + $LIBVIRT_MINOR_VERSION \* 1000 + $LIBVIRT_MICRO_VERSION`
+# In libtool terminology we need to figure out:
+#
+# CURRENT
+# The most recent interface number that this library implements.
+#
+# REVISION
+# The implementation number of the CURRENT interface.
+#
+# AGE
+# The difference between the newest and oldest interfaces that this
+# library implements.
+#
+# In other words, the library implements all the interface numbers
+# in the range from number `CURRENT - AGE' to `CURRENT'.
+#
+# Libtool assigns the soname version from `CURRENT - AGE', and we
+# don't want that to ever change in libvirt. ie it must always be
+# zero, to produce libvirt.so.0.
+#
+# We would, however, like the libvirt version number reflected
+# in the so version'd symlinks, and this is based on AGE.REVISION
+# eg libvirt.so.0.AGE.REVISION
+#
+# Assuming we do ever want to break soname version, this can
+# toggled. But seriously, don't ever touch this.
+LIBVIRT_SONUM=0
+
+# The following examples show what libtool will do
+#
+# Input: 0.9.14 -> libvirt.so.0.9.14
+# Input: 1.0.0 -> libvirt.so.0.1000.0
+# Input: 2.5.8 -> libvirt.so.0.2005.8
+#
+AGE=`expr $LIBVIRT_MAJOR_VERSION '*' 1000 + $LIBVIRT_MINOR_VERSION`
+REVISION=$LIBVIRT_MICRO_VERSION
+CURRENT=`expr $LIBVIRT_SONUM + $AGE`
+LIBVIRT_VERSION_INFO=$CURRENT:$REVISION:$AGE
+
AC_SUBST([LIBVIRT_MAJOR_VERSION])
AC_SUBST([LIBVIRT_MINOR_VERSION])
AC_SUBST([LIBVIRT_MICRO_VERSION])
+AC_SUBST([LIBVIRT_SONUM])
AC_SUBST([LIBVIRT_VERSION])
AC_SUBST([LIBVIRT_VERSION_INFO])
AC_SUBST([LIBVIRT_VERSION_NUMBER])
--
1.7.11.2
12 years, 3 months
[libvirt] [PATCH 0/7] qapi: add commands to remove the need to parse -help output
by Anthony Liguori
This series implements the necessary commands to implements danpb's idea to
remove -help parsing in libvirt. We would introduce all of these commands in
1.2 and then change the -help output starting in 1.3.
Here is Dan's plan from a previous thread:
<danpb>
Basically I'd sum up my new idea as "just use QMP".
* No new command line arguments like -capabilities
* libvirt invokes something like
$QEMUBINARY -qmp CHARDEV -nodefault -nodefconfig -nographics
* libvirt then runs a number of QMP commands to find out
what it needs to know. I'd expect the following existing
commands would be used
- query-version - already supported
- query-commands - already supported
- query-events - already supported
- query-kvm - already supported
- qom-{list,list-types,get} - already supported
- query-spice/vnc - already supported
And add the following new commands
- query-devices - new, -device ?, and/or -device NAME,? data
in QMP
- query-machines - new, -M ? in QMP
- query-cpu-types - new, -cpu ? in QMP
The above would take care of probably 50% of the current libvirt
capabilities probing, including a portion of the -help stuff. Then
there is all the rest of the crap we detect from the -help. We could
just take the view, that "as of 1.2", we assume everything we previously
detected is just available by default, and thus don't need to probe
it. For stuff that is QOM based, I expect we'll be able to detect new
features in the future using the qom-XXX monitor commands. For stuff
that is non-qdev, and non-qom, libvirt can just do a plain version
number check, unless we decide there is specific info worth exposing
via other new 'query-XXX' monitor commands.
Basically I'd sum up my new idea as "just use QMP".
* No new command line arguments like -capabilities
* libvirt invokes something like
$QEMUBINARY -qmp CHARDEV -nodefault -nodefconfig -nographics
* libvirt then runs a number of QMP commands to find out
what it needs to know. I'd expect the following existing
commands would be used
- query-version - already supported
- query-commands - already supported
- query-events - already supported
- query-kvm - already supported
- qom-{list,list-types,get} - already supported
- query-spice/vnc - already supported
And add the following new commands
- query-devices - new, -device ?, and/or -device NAME,? data
in QMP
- query-machines - new, -M ? in QMP
- query-cpu-types - new, -cpu ? in QMP
The above would take care of probably 50% of the current libvirt
capabilities probing, including a portion of the -help stuff. Then
there is all the rest of the crap we detect from the -help. We could
just take the view, that "as of 1.2", we assume everything we previously
detected is just available by default, and thus don't need to probe
it. For stuff that is QOM based, I expect we'll be able to detect new
features in the future using the qom-XXX monitor commands. For stuff
that is non-qdev, and non-qom, libvirt can just do a plain version
number check, unless we decide there is specific info worth exposing
via other new 'query-XXX' monitor commands.
</danpb>
The one thing to note is that I didn't add a query-devices command because you
can already do:
qmp query-devices --implements=device --abstract=False
To get the equivalent output of -device ?. Instead, I added a command to list
specific properties of a device which is the equivalent of -device FOO,?
12 years, 3 months
[libvirt] [PATCH v8 0/7] file descriptor passing using fd sets
by Corey Bryant
libvirt's sVirt security driver provides SELinux MAC isolation for
Qemu guest processes and their corresponding image files. In other
words, sVirt uses SELinux to prevent a QEMU process from opening
files that do not belong to it.
sVirt provides this support by labeling guests and resources with
security labels that are stored in file system extended attributes.
Some file systems, such as NFS, do not support the extended
attribute security namespace, and therefore cannot support sVirt
isolation.
A solution to this problem is to provide fd passing support, where
libvirt opens files and passes file descriptors to QEMU. This,
along with SELinux policy to prevent QEMU from opening files, can
provide image file isolation for NFS files stored on the same NFS
mount.
This patch series adds the add-fd, remove-fd, and query-fdsets
QMP monitor commands, which allow file descriptors to be passed
via SCM_RIGHTS, and assigned to specified fd sets. This allows
fd sets to be created per file with fds having, for example,
different access rights. When QEMU needs to reopen a file with
different access rights, it can search for a matching fd in the
fd set. Fd sets also allow for easy tracking of fds per file,
helping to prevent fd leaks.
Support is also added to the block layer to allow QEMU to dup an
fd from an fdset when the filename is of the /dev/fdset/nnn format,
where nnn is the fd set ID.
No new SELinux policy is required to prevent open of NFS files
(files with type nfs_t). The virt_use_nfs boolean type simply
needs to be set to false, and open will be prevented (and dup will
be allowed). For example:
# setsebool virt_use_nfs 0
# getsebool virt_use_nfs
virt_use_nfs --> off
Corey Bryant (7):
qemu-char: Add MSG_CMSG_CLOEXEC flag to recvmsg
qapi: Introduce add-fd, remove-fd, query-fdsets
monitor: Clean up fd sets on monitor disconnect
block: Prevent detection of /dev/fdset/ as floppy
block: Convert open calls to qemu_open
block: Convert close calls to qemu_close
block: Enable qemu_open/close to work with fd sets
block/raw-posix.c | 46 +++++----
block/raw-win32.c | 6 +-
block/vdi.c | 5 +-
block/vmdk.c | 25 ++---
block/vpc.c | 4 +-
block/vvfat.c | 16 +--
cutils.c | 5 +
monitor.c | 294 +++++++++++++++++++++++++++++++++++++++++++++++++++++
monitor.h | 5 +
osdep.c | 117 +++++++++++++++++++++
qapi-schema.json | 98 ++++++++++++++++++
qemu-char.c | 12 ++-
qemu-common.h | 2 +
qemu-tool.c | 20 ++++
qmp-commands.hx | 117 +++++++++++++++++++++
savevm.c | 4 +-
16 files changed, 721 insertions(+), 55 deletions(-)
--
1.7.10.4
12 years, 3 months
[libvirt] [PATCH 0/3] Minor docs fixes
by Martin Kletzander
Here are some fixes I was still having in my local branch. I finally
found a way to generate search.php automatically (even though it is
not the way I wanted it) and since the others are fixing docs as well,
I'm sending them in a series.
Last patch of the series is more like a question if we can change it
or not.
Martin Kletzander (3):
docs: fix 404 page when fetched from different location
docs: autogenerate search.php
docs/virsh: various minor fixes
.gitignore | 1 +
docs/404.html.in | 2 +-
docs/Makefile.am | 24 +++++++-
docs/api_extension.html.in | 4 --
docs/pending.html.in | 4 --
docs/{search.php => search.php.code.in} | 90 ++-----------------------------
docs/search.php.in | 17 ++++++
docs/site.xsl | 11 ++++-
tools/virsh-host.c | 4 +-
9 files changed, 57 insertions(+), 100 deletions(-)
rename docs/{search.php => search.php.code.in} (66%)
create mode 100644 docs/search.php.in
--
1.7.8.6
12 years, 3 months
[libvirt] Question about networkNotifyActualDevice
by Shradha Shah
Hello All,
I have recently found a bug in my patches to support forward mode="hostdev".
The bug is that libvirtd restart forgets about the netdef->forwardIfs.
Steps to reproduce:
1) virsh net-define hostdev.xml
<network>
<name>hostdev</name>
<uuid>81ff0d90-c91e-6742-64da-4a736edb9a8f</uuid>
<forward mode='hostdev' managed='yes'>
<pf dev='eth4'/>
</forward>
</network>
2) virsh define guest.xml
3) virsh start guest
[root@c6100m libvirt]# virsh net-dumpxml hostdev
<network>
<name>hostdev</name>
<uuid>81ff0d90-c91e-6742-64da-4a736edb9a8f</uuid>
<forward managed='yes' mode='hostdev'>
<pf dev='eth4'/>
<address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x2'/>
<address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x4'/>
<address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x6'/>
<address type='pci' domain='0x0000' bus='0x04' slot='0x01' function='0x0'/>
<address type='pci' domain='0x0000' bus='0x04' slot='0x01' function='0x2'/>
<address type='pci' domain='0x0000' bus='0x04' slot='0x01' function='0x4'/>
<address type='pci' domain='0x0000' bus='0x04' slot='0x01' function='0x6'/>
<address type='pci' domain='0x0000' bus='0x04' slot='0x02' function='0x0'/>
</forward>
</network>
4) service libvirtd restart
After libvirtd is restarted I observe that the guest is shutdown.
/var/log/libvirt/libvirtd.log complains with the following error message:
networkNotifyActualDevice:3299 : internal error network 'hostdev' doesn't have dev in use by domain.
Using gdb when I breakpoint on networkNotifyActualDevice on libvirtd start I observe that netdef->nForwardIfs has been reset to 0, but netdef->nForwardPfs is correctly assigned to 1.
So my question is does libvirtd restart cause the network to remember only the inactive XML and not the active XML?
Does anyone have any ideas on how I should proceed on this bug?
--
Many Thanks,
Regards,
Shradha Shah
12 years, 3 months
[libvirt] Segfault problem with nwfilter-define in Libvirt
by [Vo2Labs] Jean-Charles Passard
Hello,
At first a big thanks to Laine, who kindly tried to help me !
My problem is the following :
I use a linux from scratch distro ( home made)
pure X86_64
glibc 2.10.1
gcc 4.4.1
uname -a SMP Sat Aug 4 20:07:49 CEST 2012 x86_64 x86_64 x86_64 GNU/Linux
Each time I use nwfilter-define, libvirtd crash with a segfault. I tried
nearly all version from 0.9.8 to 0.9.13 and even 0.10 with the same problem
Here is a sample of newfilter.xml :
<filter name='nova-base'>
<filterref filter='no-ip-spoofing'/>
</filter>
and here the bt unde gdb with v0.9.13
#0 __pthread_mutex_lock (mutex=0x0) at pthread_mutex_lock.c:50
#1 0x00007ffff77ba07e in virNWFilterCallbackDriversLock () at
conf/nwfilter_conf.c:2846
#2 0x00007fffe8ed9d24 in nwfilterDefine (conn=0x67d8e0, xml=0x67e000
"<filter name='nova-base'>\n\t<filterref
filter='no-ip-spoofing'/>\n</filter>\n\n")
at nwfilter/nwfilter_driver.c:348
#3 0x00007ffff77eb753 in virNWFilterDefineXML (conn=0x67d8e0,
xmlDesc=0x67e000 "<filter name='nova-base'>\n\t<filterref
filter='no-ip-spoofing'/>\n</filter>\n\n") at libvirt.c:15925
#4 0x000000000041969c in remoteDispatchNWFilterDefineXML
(ret=<optimized out>, args=<optimized out>, rerr=<optimized out>,
msg=<optimized out>,
client=<optimized out>, server=<optimized out>) at
remote_dispatch.h:10442
#5 remoteDispatchNWFilterDefineXMLHelper (server=<optimized out>,
client=0x67d210, msg=<optimized out>, rerr=0x7fffec57cf60,
args=0x67dea0, ret=0x67ba20)
at remote_dispatch.h:10422
#6 0x00007ffff784d48d in virNetServerProgramDispatchCall
(msg=<optimized out>, client=<optimized out>, server=<optimized out>,
prog=<optimized out>)
at rpc/virnetserverprogram.c:416
#7 virNetServerProgramDispatch (prog=0x675090, server=0x670370,
client=0x67d210, msg=0x67e3d0) at rpc/virnetserverprogram.c:289
#8 0x00007ffff784a0d1 in virNetServerHandleJob (jobOpaque=<optimized
out>, opaque=0x670370) at rpc/virnetserver.c:161
#9 0x00007ffff776d282 in virThreadPoolWorker (opaque=<optimized out>)
at util/threadpool.c:143
#10 0x00007ffff776c926 in virThreadHelper (data=<optimized out>) at
util/threads-pthread.c:161
#11 0x00007ffff457257a in start_thread (arg=<optimized out>) at
pthread_create.c:297
#12 0x00007ffff3edd14d in clone () at
../sysdeps/unix/sysv/linux/x86_64/clone.S:115
Thank for help
JC
12 years, 3 months
[libvirt] [PATCH] build: fix PROBE() usage of intptr_t
by Eric Blake
Otherwise, in locations like virobject.c where PROBE is used,
for certain configure options, the compiler warns:
util/virobject.c:110:1: error: 'intptr_t' undeclared (first use in this function)
As long as we are making this header always available, we can
clean up several other files.
* src/internal.h (includes): Pull in <stdint.h>.
* src/conf/nwfilter_conf.h: Rely on internal.h.
* src/storage/storage_backend.c: Likewise.
* src/storage/storage_backend.h: Likewise.
* src/util/cgroup.c: Likewise.
* src/util/sexpr.h: Likewise.
* src/util/virhashcode.h: Likewise.
* src/util/virnetdevvportprofile.h: Likewise.
* src/util/virnetlink.h: Likewise.
* src/util/virrandom.h: Likewise.
* src/vbox/vbox_driver.c: Likewise.
* src/xenapi/xenapi_driver.c: Likewise.
* src/xenapi/xenapi_utils.c: Likewise.
* src/xenapi/xenapi_utils.h: Likewise.
* src/xenxs/xenxs_private.h: Likewise.
* tests/storagebackendsheepdogtest.c: Likewise.
Reported by Matthias Bolte.
---
Almost qualifies for the build-breaker rule, except that I didn't
reproduce the particular configure settings that Matthias was
experiencing on IRC.
src/conf/nwfilter_conf.h | 5 +----
src/internal.h | 1 +
src/storage/storage_backend.c | 1 -
src/storage/storage_backend.h | 3 +--
src/util/cgroup.c | 1 -
src/util/sexpr.h | 8 ++------
src/util/virhashcode.h | 1 -
src/util/virnetdevvportprofile.h | 4 +---
src/util/virnetlink.h | 2 --
src/util/virrandom.h | 1 -
src/vbox/vbox_driver.c | 4 +---
src/xenapi/xenapi_driver.c | 1 -
src/xenapi/xenapi_utils.c | 1 -
src/xenapi/xenapi_utils.h | 2 +-
src/xenxs/xenxs_private.h | 3 +--
tests/storagebackendsheepdogtest.c | 2 --
16 files changed, 9 insertions(+), 31 deletions(-)
diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h
index 8b05d04..ca6bd16 100644
--- a/src/conf/nwfilter_conf.h
+++ b/src/conf/nwfilter_conf.h
@@ -2,7 +2,7 @@
* nwfilter_conf.h: network filter XML processing
* (derived from storage_conf.h)
*
- * Copyright (C) 2006-2010 Red Hat, Inc.
+ * Copyright (C) 2006-2010, 2012 Red Hat, Inc.
* Copyright (C) 2006-2008 Daniel P. Berrange
*
* Copyright (C) 2010 IBM Corporation
@@ -26,9 +26,6 @@
#ifndef NWFILTER_CONF_H
# define NWFILTER_CONF_H
-# include <stdint.h>
-# include <stddef.h>
-
# include "internal.h"
# include "util.h"
diff --git a/src/internal.h b/src/internal.h
index fd8d190..300de3a 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -9,6 +9,7 @@
# include <limits.h>
# include <verify.h>
# include <stdbool.h>
+# include <stdint.h>
# if STATIC_ANALYSIS
# undef NDEBUG /* Don't let a prior NDEBUG definition cause trouble. */
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 4a2109e..df3833a 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -32,7 +32,6 @@
#include <sys/wait.h>
#include <unistd.h>
#include <fcntl.h>
-#include <stdint.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <dirent.h>
diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h
index bafd6b6..5352f5d 100644
--- a/src/storage/storage_backend.h
+++ b/src/storage/storage_backend.h
@@ -1,7 +1,7 @@
/*
* storage_backend.h: internal storage driver backend contract
*
- * Copyright (C) 2007-2010 Red Hat, Inc.
+ * Copyright (C) 2007-2010, 2012 Red Hat, Inc.
* Copyright (C) 2007-2008 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -24,7 +24,6 @@
#ifndef __VIR_STORAGE_BACKEND_H__
# define __VIR_STORAGE_BACKEND_H__
-# include <stdint.h>
# include "internal.h"
# include "storage_conf.h"
# include "command.h"
diff --git a/src/util/cgroup.c b/src/util/cgroup.c
index 6c29c87..2256c23 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -24,7 +24,6 @@
#include <config.h>
#include <stdio.h>
-#include <stdint.h>
#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
# include <mntent.h>
#endif
diff --git a/src/util/sexpr.h b/src/util/sexpr.h
index 8dfd89a..b4b41ed 100644
--- a/src/util/sexpr.h
+++ b/src/util/sexpr.h
@@ -1,9 +1,8 @@
/*
* sexpr.h : S-Expression interfaces needed to communicate with the Xen Daemon
*
- * Copyright (C) 2005
- *
- * Anthony Liguori <aliguori(a)us.ibm.com>
+ * Copyright (C) 2012 Red Hat, Inc.
+ * Copyright (C) 2005 Anthony Liguori <aliguori(a)us.ibm.com>
*
* This file is subject to the terms and conditions of the GNU Lesser General
* Public License. See the file COPYING.LIB in the main directory of this
@@ -16,9 +15,6 @@
# include "internal.h"
# include "buf.h"
-# include <sys/types.h>
-# include <stdint.h>
-
enum sexpr_type {
SEXPR_NIL,
SEXPR_CONS,
diff --git a/src/util/virhashcode.h b/src/util/virhashcode.h
index 2fb7a95..34254b6 100644
--- a/src/util/virhashcode.h
+++ b/src/util/virhashcode.h
@@ -29,7 +29,6 @@
# define __VIR_HASH_CODE_H__
# include "internal.h"
-# include <stdint.h>
extern uint32_t virHashCodeGen(const void *key, size_t len, uint32_t seed);
diff --git a/src/util/virnetdevvportprofile.h b/src/util/virnetdevvportprofile.h
index 6cce1bb..f33da18 100644
--- a/src/util/virnetdevvportprofile.h
+++ b/src/util/virnetdevvportprofile.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 Red Hat, Inc.
+ * Copyright (C) 2009-2012 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
@@ -23,8 +23,6 @@
#ifndef __VIR_NETDEV_VPORT_PROFILE_H__
# define __VIR_NETDEV_VPORT_PROFILE_H__
-# include <stdint.h>
-
# include "internal.h"
# include "uuid.h"
# include "util.h"
diff --git a/src/util/virnetlink.h b/src/util/virnetlink.h
index 1997c8d..5d8337d 100644
--- a/src/util/virnetlink.h
+++ b/src/util/virnetlink.h
@@ -24,8 +24,6 @@
# include "internal.h"
# include "virmacaddr.h"
-# include <stdint.h>
-
# if defined(__linux__) && defined(HAVE_LIBNL)
# include <netlink/msg.h>
diff --git a/src/util/virrandom.h b/src/util/virrandom.h
index 8d3cad7..29a055d 100644
--- a/src/util/virrandom.h
+++ b/src/util/virrandom.h
@@ -23,7 +23,6 @@
# define __VIR_RANDOM_H__
# include "internal.h"
-# include <stdint.h>
uint64_t virRandomBits(int nbits);
int virRandomGenerateWWN(char **wwn, const char *virt_type);
diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c
index b340b7c..c4037f8 100644
--- a/src/vbox/vbox_driver.c
+++ b/src/vbox/vbox_driver.c
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2010-2011 Red Hat, Inc.
+ * Copyright (C) 2010-2012 Red Hat, Inc.
* Copyright (C) 2008-2009 Sun Microsystems, Inc.
*
* This file is part of a free software library; you can redistribute
@@ -29,9 +29,7 @@
#include <config.h>
-#include <stdint.h>
#include <unistd.h>
-#include <sys/types.h>
#include "internal.h"
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index 5608de8..f57449e 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -23,7 +23,6 @@
#include <config.h>
#include <limits.h>
-#include <stdint.h>
#include <string.h>
#include <curl/curl.h>
#include <xen/api/xen_all.h>
diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c
index 3031a17..d62192a 100644
--- a/src/xenapi/xenapi_utils.c
+++ b/src/xenapi/xenapi_utils.c
@@ -24,7 +24,6 @@
#include <stdio.h>
#include <string.h>
-#include <stdint.h>
#include <xen/api/xen_all.h>
#include "internal.h"
#include "domain_conf.h"
diff --git a/src/xenapi/xenapi_utils.h b/src/xenapi/xenapi_utils.h
index 5912446..86af07c 100644
--- a/src/xenapi/xenapi_utils.h
+++ b/src/xenapi/xenapi_utils.h
@@ -1,5 +1,6 @@
/*
* xenapi_utils.h: Xen API driver -- utils header
+ * Copyright (C) 2012, Red Hat, Inc.
* Copyright (C) 2009, 2010 Citrix Ltd.
*
* This library is free software; you can redistribute it and/or
@@ -22,7 +23,6 @@
#ifndef __VIR_XENAPI_UTILS__
# define __VIR_XENAPI_UTILS__
-# include <stdint.h>
# include <xen/api/xen_all.h>
# include "internal.h"
# include "viruri.h"
diff --git a/src/xenxs/xenxs_private.h b/src/xenxs/xenxs_private.h
index d0ba59a..17b481b 100644
--- a/src/xenxs/xenxs_private.h
+++ b/src/xenxs/xenxs_private.h
@@ -1,8 +1,8 @@
/*
* xenxs_private.h: Private definitions for Xen parsing
*
+ * Copyright (C) 2007, 2010, 2012 Red Hat, Inc.
* Copyright (C) 2011 Univention GmbH
- * Copyright (C) 2007, 2010 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
@@ -27,7 +27,6 @@
# include "internal.h"
-# include <stdint.h>
# include <xen/xen.h>
# include "xen_sxpr.h"
diff --git a/tests/storagebackendsheepdogtest.c b/tests/storagebackendsheepdogtest.c
index b7b3b35..ba5bc36 100644
--- a/tests/storagebackendsheepdogtest.c
+++ b/tests/storagebackendsheepdogtest.c
@@ -25,10 +25,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-#include <stdint.h>
#include <string.h>
-#include <sys/types.h>
#include <fcntl.h>
#include "internal.h"
--
1.7.11.2
12 years, 3 months