[libvirt] [PATCH] rpcgen fixes
by john.levon@sun.com
# HG changeset patch
# User john.levon(a)sun.com
# Date 1229399266 28800
# Node ID 12c9b283b11f5e20b9dcc91e3d10a862da5d6e81
# Parent 1ba824db09286ebc758e035211da2c533bbd1e0f
rpcgen fixes
quad_t is not a portable type, but rather than force rpcgen
every build, we just patch in the fixes needed.
Also, since we ship the rpcgen-derived files in CVS, don't leave
Makefile rules that could trigger during a normal build: make a special
maintainer target for refreshing the derived sources.
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/qemud/Makefile.am b/qemud/Makefile.am
--- a/qemud/Makefile.am
+++ b/qemud/Makefile.am
@@ -32,23 +32,23 @@ EXTRA_DIST = \
$(DAEMON_SOURCES)
if RPCGEN
-SUFFIXES = .x
-.x.c:
- rm -f $@ $@-t $@-t2
- rpcgen -c -o $@-t $<
+#
+# Maintainer-only target for re-generating the derived .c/.h source
+# files, which are actually derived from the .x file.
+#
+rpcgen:
+ rm -f rp.c-t rp.h-t
+ rpcgen -h -o rp.h-t @top_srcdir(a)/qemud/remote_protocol.x
+ rpcgen -c -o rp.c-t @top_srcdir(a)/qemud/remote_protocol.x
if GLIBC_RPCGEN
- perl -w rpcgen_fix.pl $@-t > $@-t2
- chmod 444 $@-t2
- mv $@-t2 $@
-endif
-
-.x.h:
- rm -f $@ $@-t
- rpcgen -h -o $@-t $<
-if GLIBC_RPCGEN
- perl -pi -e 's/\t/ /g' $@-t
- chmod 444 $@-t
- mv $@-t $@
+ perl -w @top_srcdir(a)/qemud/rpcgen_fix.pl rp.h-t \
+ >@top_srcdir(a)/qemud/remote_protocol.h
+ perl -w @top_srcdir(a)/qemud/rpcgen_fix.pl rp.c-t \
+ >@top_srcdir(a)/qemud/remote_protocol.c
+ rm -f rp.c-t rp.h-t
+else
+ mv rp.h-t @top_srcdir(a)/remote_protocol.h
+ mv rp.c-t @top_srcdir(a)/remote_protocol.c
endif
endif
diff --git a/qemud/rpcgen_fix.pl b/qemud/rpcgen_fix.pl
--- a/qemud/rpcgen_fix.pl
+++ b/qemud/rpcgen_fix.pl
@@ -25,6 +25,15 @@ 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/XDR_INLINE/(int32_t *)XDR_INLINE/g;
+ s/#include <rpc\/rpc.h>/#include <config.h>\n#include <rpc\/rpc.h>/g;
if (m/^}/) {
$in_function = 0;
15 years, 11 months
[libvirt] [PATCH] __FUNCTION__ is not portable
by john.levon@sun.com
# HG changeset patch
# User john.levon(a)sun.com
# Date 1229399267 28800
# Node ID ee6ccfc062f49f514d7ae8924d5a596b18441fee
# Parent b105e5a7cd6190e0b952a1587d7e80f39d02e63c
__FUNCTION__ is not portable
__func__ is. Some places aren't covered by the back-compat define (why
is that there?)
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/examples/domain-events/events-c/event-test.c b/examples/domain-events/events-c/event-test.c
--- a/examples/domain-events/events-c/event-test.c
+++ b/examples/domain-events/events-c/event-test.c
@@ -11,9 +11,9 @@
#include <libvirt/libvirt.h>
#define DEBUG0(fmt) printf("%s:%d :: " fmt "\n", \
- __FUNCTION__, __LINE__)
+ __func__, __LINE__)
#define DEBUG(fmt, ...) printf("%s:%d: " fmt "\n", \
- __FUNCTION__, __LINE__, __VA_ARGS__)
+ __func__, __LINE__, __VA_ARGS__)
#define STREQ(a,b) (strcmp((a),(b)) == 0)
#ifndef ATTRIBUTE_UNUSED
@@ -158,7 +158,7 @@ int myDomainEventCallback1 (virConnectPt
int detail,
void *opaque ATTRIBUTE_UNUSED)
{
- printf("%s EVENT: Domain %s(%d) %s %s\n", __FUNCTION__, virDomainGetName(dom),
+ printf("%s EVENT: Domain %s(%d) %s %s\n", __func__, virDomainGetName(dom),
virDomainGetID(dom), eventToString(event),
eventDetailToString(event, detail));
return 0;
@@ -170,7 +170,7 @@ int myDomainEventCallback2 (virConnectPt
int detail,
void *opaque ATTRIBUTE_UNUSED)
{
- printf("%s EVENT: Domain %s(%d) %s %s\n", __FUNCTION__, virDomainGetName(dom),
+ printf("%s EVENT: Domain %s(%d) %s %s\n", __func__, virDomainGetName(dom),
virDomainGetID(dom), eventToString(event),
eventDetailToString(event, detail));
return 0;
@@ -179,7 +179,7 @@ static void myFreeFunc(void *opaque)
static void myFreeFunc(void *opaque)
{
char *str = opaque;
- printf("%s: Freeing [%s]\n", __FUNCTION__, str);
+ printf("%s: Freeing [%s]\n", __func__, str);
free(str);
}
diff --git a/python/types.c b/python/types.c
--- a/python/types.c
+++ b/python/types.c
@@ -185,7 +185,7 @@ libvirt_virEventHandleCallbackWrap(virEv
if (node == NULL) {
Py_INCREF(Py_None);
- printf("%s: WARNING - Wrapping None\n", __FUNCTION__);
+ printf("%s: WARNING - Wrapping None\n", __func__);
return (Py_None);
}
ret =
@@ -200,7 +200,7 @@ libvirt_virEventTimeoutCallbackWrap(virE
PyObject *ret;
if (node == NULL) {
- printf("%s: WARNING - Wrapping None\n", __FUNCTION__);
+ printf("%s: WARNING - Wrapping None\n", __func__);
Py_INCREF(Py_None);
return (Py_None);
}
15 years, 11 months
[libvirt] [PATCH] Fix compiler error when !HAVE_POLKIT
by john.levon@sun.com
# HG changeset patch
# User john.levon(a)sun.com
# Date 1229399439 28800
# Node ID f622c9de5e2488de8ae16bc7a0b50d8fa76af364
# Parent db36391b739c117f5887388f65f31e6a9d2d361b
Fix compiler error when !HAVE_POLKIT
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/qemud/remote.c b/qemud/remote.c
--- a/qemud/remote.c
+++ b/qemud/remote.c
@@ -3116,7 +3116,7 @@ static int
static int
remoteDispatchAuthPolkit (struct qemud_server *server ATTRIBUTE_UNUSED,
struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
+ virConnectPtr conn ATTRIBUTE_UNUSED,
remote_error *rerr,
void *args ATTRIBUTE_UNUSED,
remote_auth_polkit_ret *ret ATTRIBUTE_UNUSED)
15 years, 11 months
[libvirt] [PATCH] pid_t portability in virExec()
by john.levon@sun.com
# HG changeset patch
# User john.levon(a)sun.com
# Date 1229399267 28800
# Node ID 020f8b8e9340287a6ab3d869b359e39b905cd0ff
# Parent 1b81ac255ad765ab782829e7fe0a55dc7bab72ab
pid_t portability in virExec()
Use the right type for handling process IDs.
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/src/openvz_driver.c b/src/openvz_driver.c
--- a/src/openvz_driver.c
+++ b/src/openvz_driver.c
@@ -1093,7 +1093,8 @@ static char *openvzGetCapabilities(virCo
static int openvzListDomains(virConnectPtr conn, int *ids, int nids) {
int got = 0;
- int veid, pid;
+ int veid;
+ pid_t pid;
int outfd = -1;
int errfd = -1;
int ret;
@@ -1144,7 +1145,8 @@ static int openvzListDefinedDomains(virC
static int openvzListDefinedDomains(virConnectPtr conn,
char **const names, int nnames) {
int got = 0;
- int veid, pid, outfd = -1, errfd = -1, ret;
+ int veid, outfd = -1, errfd = -1, ret;
+ pid_t pid;
char vpsname[32];
char buf[32];
char *endptr;
diff --git a/src/proxy_internal.c b/src/proxy_internal.c
--- a/src/proxy_internal.c
+++ b/src/proxy_internal.c
@@ -144,7 +144,8 @@ virProxyForkServer(void)
virProxyForkServer(void)
{
const char *proxyPath = virProxyFindServerPath();
- int ret, pid, status;
+ int ret, status;
+ pid_t pid;
const char *proxyarg[2];
if (!proxyPath) {
diff --git a/src/remote_internal.c b/src/remote_internal.c
--- a/src/remote_internal.c
+++ b/src/remote_internal.c
@@ -252,7 +252,8 @@ remoteForkDaemon(virConnectPtr conn)
{
const char *daemonPath = remoteFindDaemonPath();
const char *const daemonargs[] = { daemonPath, "--timeout=30", NULL };
- int ret, pid, status;
+ int ret, status;
+ pid_t pid;
if (!daemonPath) {
error(conn, VIR_ERR_INTERNAL_ERROR, _("failed to find libvirtd binary"));
diff --git a/src/storage_backend.c b/src/storage_backend.c
--- a/src/storage_backend.c
+++ b/src/storage_backend.c
@@ -411,7 +411,8 @@ virStorageBackendRunProgRegex(virConnect
void *data,
int *outexit)
{
- int child = 0, fd = -1, exitstatus, err, failed = 1;
+ int fd = -1, exitstatus, err, failed = 1;
+ pid_t child = 0;
FILE *list = NULL;
regex_t *reg;
regmatch_t *vars = NULL;
@@ -575,7 +576,8 @@ virStorageBackendRunProgNul(virConnectPt
void *data)
{
size_t n_tok = 0;
- int child = 0, fd = -1, exitstatus;
+ int fd = -1, exitstatus;
+ pid_t child = 0;
FILE *fp = NULL;
char **v;
int err = -1;
diff --git a/src/uml_driver.c b/src/uml_driver.c
--- a/src/uml_driver.c
+++ b/src/uml_driver.c
@@ -711,7 +711,8 @@ static int umlStartVMDaemon(virConnectPt
virDomainObjPtr vm) {
const char **argv = NULL, **tmp;
const char **progenv = NULL;
- int i, ret, pid;
+ int i, ret;
+ pid_t pid;
char *logfile;
int logfd = -1;
struct stat sb;
diff --git a/src/util.c b/src/util.c
--- a/src/util.c
+++ b/src/util.c
@@ -182,10 +182,11 @@ __virExec(virConnectPtr conn,
const char *const*argv,
const char *const*envp,
const fd_set *keepfd,
- int *retpid,
+ pid_t *retpid,
int infd, int *outfd, int *errfd,
int flags) {
- int pid, null, i, openmax;
+ pid_t pid;
+ int null, i, openmax;
int pipeout[2] = {-1,-1};
int pipeerr[2] = {-1,-1};
int childout = -1;
@@ -439,7 +440,7 @@ virExec(virConnectPtr conn,
const char *const*argv,
const char *const*envp,
const fd_set *keepfd,
- int *retpid,
+ pid_t *retpid,
int infd, int *outfd, int *errfd,
int flags) {
char *argv_str;
@@ -554,7 +555,8 @@ virRun(virConnectPtr conn,
virRun(virConnectPtr conn,
const char *const*argv,
int *status) {
- int childpid, exitstatus, execret, waitret;
+ pid_t childpid;
+ int exitstatus, execret, waitret;
int ret = -1;
int errfd = -1, outfd = -1;
char *outbuf = NULL;
diff --git a/src/util.h b/src/util.h
--- a/src/util.h
+++ b/src/util.h
@@ -27,6 +27,7 @@
#include "verify.h"
#include <sys/select.h>
+#include <sys/types.h>
int saferead(int fd, void *buf, size_t count);
ssize_t safewrite(int fd, const void *buf, size_t count);
@@ -41,7 +42,7 @@ int virExec(virConnectPtr conn,
const char *const*argv,
const char *const*envp,
const fd_set *keepfd,
- int *retpid,
+ pid_t *retpid,
int infd,
int *outfd,
int *errfd,
15 years, 11 months
[libvirt] [PATCH] Makefile portability in qemud
by john.levon@sun.com
# HG changeset patch
# User john.levon(a)sun.com
# Date 1229399267 28800
# Node ID 35512df785342cd15214790e17e0c1f4d2182b32
# Parent 57c76efe37988edc64beb12ca5dc1ff5863f0085
Makefile portability in qemud
Neither uuidgen nor sed -i are portable - only make the edit on
platforms that can do so.
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/qemud/Makefile.am b/qemud/Makefile.am
--- a/qemud/Makefile.am
+++ b/qemud/Makefile.am
@@ -56,7 +56,7 @@ remote_protocol.c: remote_protocol.h
if WITH_LIBVIRTD
-UUID=$(shell uuidgen)
+UUID=$(shell type uuidgen >/dev/null 2>&1 && uuidgen)
sbin_PROGRAMS = libvirtd
@@ -142,8 +142,9 @@ install-data-local: install-init install
mkdir -p $(DESTDIR)$(sysconfdir)/libvirt/qemu/networks/autostart
$(INSTALL_DATA) $(srcdir)/default-network.xml \
$(DESTDIR)$(sysconfdir)/$(default_xml_dest)
- sed -i -e "s,</name>,</name>\n <uuid>$(UUID)</uuid>," \
- $(DESTDIR)$(sysconfdir)/$(default_xml_dest)
+ test -z "$(UUID)" || \
+ sed -i -e "s,</name>,</name>\n <uuid>$(UUID)</uuid>," \
+ $(DESTDIR)$(sysconfdir)/$(default_xml_dest)
test -e $(DESTDIR)$(sysconfdir)/libvirt/qemu/networks/autostart/default.xml || \
ln -s ../default.xml \
$(DESTDIR)$(sysconfdir)/libvirt/qemu/networks/autostart/default.xml
15 years, 11 months
[libvirt] [PATCH] Improve compiler flag checking
by john.levon@sun.com
# HG changeset patch
# User john.levon(a)sun.com
# Date 1229399267 28800
# Node ID 1f7707a3d49b20397011897cdc04c347322ad0c5
# Parent a6c317b5fe1b4081ccb40ba90af7d31298cf6b44
Improve compiler flag checking
Some compilers (including GCC) don't set the return value consistently
if an erroneous option is passed on the command line. Account for that.
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/acinclude.m4 b/acinclude.m4
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -45,21 +45,9 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
;;
esac
- compiler_flags=
+ COMPILER_FLAGS=
for option in $try_compiler_flags; do
- SAVE_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $option"
- AC_MSG_CHECKING([whether gcc understands $option])
- AC_TRY_LINK([], [],
- has_option=yes,
- has_option=no,)
- CFLAGS="$SAVE_CFLAGS"
- AC_MSG_RESULT($has_option)
- if test $has_option = yes; then
- compiler_flags="$compiler_flags $option"
- fi
- unset has_option
- unset SAVE_CFLAGS
+ gl_COMPILER_FLAGS($option)
done
unset option
unset try_compiler_flags
@@ -85,7 +73,7 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
fi
AC_MSG_RESULT($complCFLAGS)
- WARN_CFLAGS="$compiler_flags $complCFLAGS"
+ WARN_CFLAGS="$COMPILER_FLAGS $complCFLAGS"
AC_SUBST(WARN_CFLAGS)
])
diff --git a/m4/compiler-flags.m4 b/m4/compiler-flags.m4
--- a/m4/compiler-flags.m4
+++ b/m4/compiler-flags.m4
@@ -23,12 +23,14 @@ AC_DEFUN([gl_COMPILER_FLAGS],
AC_DEFUN([gl_COMPILER_FLAGS],
[AC_MSG_CHECKING(whether compiler accepts $1)
AC_SUBST(COMPILER_FLAGS)
- ac_save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $1"
- AC_TRY_COMPILE(,
- [int x;],
- COMPILER_FLAGS="$COMPILER_FLAGS $1"
- AC_MSG_RESULT(yes),
- AC_MSG_RESULT(no))
- CFLAGS="$ac_save_CFLAGS"
+ echo 'int x;' >conftest.c
+ $CC $CFLAGS $1 -c conftest.c 2>conftest.err
+ ret=$?
+ if test $ret != 0 -o -s conftest.err; then
+ AC_MSG_RESULT(no)
+ else
+ AC_MSG_RESULT(yes)
+ COMPILER_FLAGS="$COMPILER_FLAGS $1"
+ fi
+ rm -f conftest*
])
15 years, 11 months