Index: configure.in =================================================================== RCS file: /data/cvs/libvirt/configure.in,v retrieving revision 1.139 diff -u -r1.139 configure.in --- configure.in 8 Apr 2008 16:45:57 -0000 1.139 +++ configure.in 17 Apr 2008 18:55:05 -0000 @@ -81,6 +81,13 @@ [test "x$ac_cv_path_RPCGEN" != "xno" && $ac_cv_path_RPCGEN -t /dev/null 2>&1]) +dnl pthread? +AC_CHECK_HEADER(pthread.h, + AC_CHECK_LIB(pthread,pthread_join,[ + AC_DEFINE([HAVE_LIBPTHREAD],[],[Define if pthread (-lpthread)]) + AC_DEFINE([HAVE_PTHREAD_H],[],[Define if ]) + ])) + dnl Miscellaneous external programs. AC_PATH_PROG(RM, rm, /bin/rm) AC_PATH_PROG(MV, mv, /bin/mv) @@ -301,7 +308,7 @@ if test "x$with_libxml" = "xno" ; then AC_MSG_CHECKING(for libxml2 libraries >= $LIBXML_REQUIRED) AC_MSG_ERROR(libxml2 >= $LIBXML_REQUIRED is required for libvirt) -elif test "x$with_libxml" = "x" -a "x$PKG_CONFIG" = "x" ; then +elif test "x$with_libxml" = "x" -a "x$PKG_CONFIG" != "x" ; then PKG_CHECK_MODULES(LIBXML, libxml-2.0 >= $LIBXML_REQUIRED, [LIBXML_FOUND=yes], [LIBXML_FOUND=no]) fi if test "$LIBXML_FOUND" = "no" ; then @@ -356,7 +363,8 @@ AC_CHECK_LIB(gnutls, gnutls_handshake, [], [AC_MSG_ERROR( - [You must install the GnuTLS library in order to compile and run libvirt])]) + [You must install the GnuTLS library in order to compile and run libvirt])], + [-lgcrypt]) GNUTLS_LIBS=$LIBS LIBS="$old_libs" fi Index: src/Makefile.am =================================================================== RCS file: /data/cvs/libvirt/src/Makefile.am,v retrieving revision 1.76 diff -u -r1.76 Makefile.am --- src/Makefile.am 10 Apr 2008 07:30:53 -0000 1.76 +++ src/Makefile.am 17 Apr 2008 18:55:15 -0000 @@ -61,17 +61,21 @@ openvz_driver.c openvz_driver.h \ lxc_driver.c lxc_driver.h \ lxc_conf.c lxc_conf.h \ - lxc_container.c lxc_container.h \ + lxc_container.c lxc_container.h \ nodeinfo.h nodeinfo.c \ - storage_conf.h storage_conf.c \ - storage_driver.h storage_driver.c \ - storage_backend.h storage_backend.c \ - storage_backend_fs.h storage_backend_fs.c \ util.c util.h SERVER_SOURCES = \ ../qemud/remote_protocol.c ../qemud/remote_protocol.h +if WITH_LIBVIRTD + +CLIENT_SOURCES += \ + storage_conf.h storage_conf.c \ + storage_driver.h storage_driver.c \ + storage_backend.h storage_backend.c \ + storage_backend_fs.h storage_backend_fs.c + if WITH_STORAGE_LVM CLIENT_SOURCES += storage_backend_logical.h storage_backend_logical.c else @@ -90,7 +94,7 @@ EXTRA_DIST += storage_backend_disk.h storage_backend_disk.c endif - +endif libvirt_la_SOURCES = $(CLIENT_SOURCES) $(SERVER_SOURCES) @@ -130,12 +134,14 @@ virsh_CFLAGS = $(COVERAGE_CFLAGS) $(READLINE_CFLAGS) if WITH_STORAGE_DISK +if WITH_LIBVIRTD libexec_PROGRAMS = libvirt_parthelper libvirt_parthelper_SOURCES = parthelper.c libvirt_parthelper_LDFLAGS = $(WARN_CFLAGS) $(COVERAGE_LDCFLAGS) libvirt_parthelper_LDADD = $(LIBPARTED_LIBS) libvirt_parthelper_CFLAGS = $(LIBPARTED_CFLAGS) +endif else EXTRA_DIST += parthelper.c endif Index: src/hash.c =================================================================== RCS file: /data/cvs/libvirt/src/hash.c,v retrieving revision 1.36 diff -u -r1.36 hash.c --- src/hash.c 10 Apr 2008 16:53:29 -0000 1.36 +++ src/hash.c 17 Apr 2008 18:55:16 -0000 @@ -25,7 +25,10 @@ #include #include "internal.h" #include "hash.h" + +#if HAVE_PTHREAD_H #include +#endif #define MAX_HASH_LEN 8 @@ -713,7 +716,9 @@ if (ret->storageVols == NULL) goto failed; +#if HAVE_LIBPTHREAD pthread_mutex_init(&ret->lock, NULL); +#endif ret->refs = 1; return(ret); @@ -729,7 +734,9 @@ if (ret->storageVols != NULL) virHashFree(ret->storageVols, (virHashDeallocator) virStorageVolFreeName); +#if HAVE_LIBPTHREAD pthread_mutex_destroy(&ret->lock); +#endif free(ret); } return(NULL); @@ -762,8 +769,10 @@ free(conn->name); +#if HAVE_LIBPTHREAD pthread_mutex_unlock(&conn->lock); pthread_mutex_destroy(&conn->lock); +#endif free(conn); } @@ -784,7 +793,9 @@ virHashError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__); return(-1); } +#if HAVE_LIBPTHREAD pthread_mutex_lock(&conn->lock); +#endif DEBUG("unref connection %p %s %d", conn, conn->name, conn->refs); conn->refs--; refs = conn->refs; @@ -793,7 +804,9 @@ /* Already unlocked mutex */ return (0); } +#if HAVE_LIBPTHREAD pthread_mutex_unlock(&conn->lock); +#endif return (refs); } @@ -818,7 +831,9 @@ virHashError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__); return(NULL); } +#if HAVE_LIBPTHREAD pthread_mutex_lock(&conn->lock); +#endif /* TODO search by UUID first as they are better differenciators */ @@ -849,11 +864,15 @@ conn->refs++; } ret->refs++; +#if HAVE_LIBPTHREAD pthread_mutex_unlock(&conn->lock); +#endif return(ret); error: +#if HAVE_LIBPTHREAD pthread_mutex_unlock(&conn->lock); +#endif if (ret != NULL) { free(ret->name ); free(ret); @@ -900,7 +919,9 @@ return; } +#if HAVE_LIBPTHREAD pthread_mutex_unlock(&conn->lock); +#endif } @@ -921,7 +942,9 @@ virHashError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__); return(-1); } +#if HAVE_LIBPTHREAD pthread_mutex_lock(&domain->conn->lock); +#endif DEBUG("unref domain %p %s %d", domain, domain->name, domain->refs); domain->refs--; refs = domain->refs; @@ -931,7 +954,9 @@ return (0); } +#if HAVE_LIBPTHREAD pthread_mutex_unlock(&domain->conn->lock); +#endif return (refs); } @@ -956,7 +981,9 @@ virHashError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__); return(NULL); } +#if HAVE_LIBPTHREAD pthread_mutex_lock(&conn->lock); +#endif /* TODO search by UUID first as they are better differenciators */ @@ -986,11 +1013,15 @@ conn->refs++; } ret->refs++; +#if HAVE_LIBPTHREAD pthread_mutex_unlock(&conn->lock); +#endif return(ret); error: +#if HAVE_LIBPTHREAD pthread_mutex_unlock(&conn->lock); +#endif if (ret != NULL) { free(ret->name ); free(ret); @@ -1037,7 +1068,9 @@ return; } +#if HAVE_LIBPTHREAD pthread_mutex_unlock(&conn->lock); +#endif } @@ -1058,7 +1091,9 @@ virHashError(network->conn, VIR_ERR_INVALID_ARG, __FUNCTION__); return(-1); } +#if HAVE_LIBPTHREAD pthread_mutex_lock(&network->conn->lock); +#endif DEBUG("unref network %p %s %d", network, network->name, network->refs); network->refs--; refs = network->refs; @@ -1068,7 +1103,9 @@ return (0); } +#if HAVE_LIBPTHREAD pthread_mutex_unlock(&network->conn->lock); +#endif return (refs); } @@ -1094,7 +1131,9 @@ virHashError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__); return(NULL); } +#if HAVE_LIBPTHREAD pthread_mutex_lock(&conn->lock); +#endif /* TODO search by UUID first as they are better differenciators */ @@ -1124,11 +1163,15 @@ conn->refs++; } ret->refs++; +#if HAVE_LIBPTHREAD pthread_mutex_unlock(&conn->lock); +#endif return(ret); error: +#if HAVE_LIBPTHREAD pthread_mutex_unlock(&conn->lock); +#endif if (ret != NULL) { free(ret->name); free(ret); @@ -1171,7 +1214,9 @@ return; } +#if HAVE_LIBPTHREAD pthread_mutex_unlock(&conn->lock); +#endif } @@ -1192,7 +1237,9 @@ virHashError(pool->conn, VIR_ERR_INVALID_ARG, __FUNCTION__); return(-1); } +#if HAVE_LIBPTHREAD pthread_mutex_lock(&pool->conn->lock); +#endif DEBUG("unref pool %p %s %d", pool, pool->name, pool->refs); pool->refs--; refs = pool->refs; @@ -1202,7 +1249,9 @@ return (0); } +#if HAVE_LIBPTHREAD pthread_mutex_unlock(&pool->conn->lock); +#endif return (refs); } @@ -1229,7 +1278,9 @@ virHashError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__); return(NULL); } +#if HAVE_LIBPTHREAD pthread_mutex_lock(&conn->lock); +#endif ret = (virStorageVolPtr) virHashLookup(conn->storageVols, key); if (ret == NULL) { @@ -1261,11 +1312,15 @@ conn->refs++; } ret->refs++; +#if HAVE_LIBPTHREAD pthread_mutex_unlock(&conn->lock); +#endif return(ret); error: +#if HAVE_LIBPTHREAD pthread_mutex_unlock(&conn->lock); +#endif if (ret != NULL) { free(ret->name); free(ret->pool); @@ -1310,7 +1365,9 @@ return; } +#if HAVE_LIBPTHREAD pthread_mutex_unlock(&conn->lock); +#endif } @@ -1331,7 +1388,9 @@ virHashError(vol->conn, VIR_ERR_INVALID_ARG, __FUNCTION__); return(-1); } +#if HAVE_LIBPTHREAD pthread_mutex_lock(&vol->conn->lock); +#endif DEBUG("unref vol %p %s %d", vol, vol->name, vol->refs); vol->refs--; refs = vol->refs; @@ -1341,6 +1400,8 @@ return (0); } +#if HAVE_LIBPTHREAD pthread_mutex_unlock(&vol->conn->lock); +#endif return (refs); } Index: src/internal.h =================================================================== RCS file: /data/cvs/libvirt/src/internal.h,v retrieving revision 1.67 diff -u -r1.67 internal.h --- src/internal.h 10 Apr 2008 16:54:54 -0000 1.67 +++ src/internal.h 17 Apr 2008 18:55:16 -0000 @@ -195,7 +195,9 @@ * count of any virDomain/virNetwork object associated with * this connection */ +#if HAVE_LIBPTHREAD pthread_mutex_t lock; +#endif virHashTablePtr domains; /* hash table for known domains */ virHashTablePtr networks; /* hash table for known domains */ virHashTablePtr storagePools;/* hash table for known storage pools */ Index: src/storage_driver.c =================================================================== RCS file: /data/cvs/libvirt/src/storage_driver.c,v retrieving revision 1.4 diff -u -r1.4 storage_driver.c --- src/storage_driver.c 10 Apr 2008 16:53:29 -0000 1.4 +++ src/storage_driver.c 17 Apr 2008 18:55:17 -0000 @@ -26,7 +26,9 @@ #include #include #include +#if HAVE_PWD_H #include +#endif #include #include Index: src/util.c =================================================================== RCS file: /data/cvs/libvirt/src/util.c,v retrieving revision 1.31 diff -u -r1.31 util.c --- src/util.c 10 Apr 2008 16:54:54 -0000 1.31 +++ src/util.c 17 Apr 2008 18:55:18 -0000 @@ -33,7 +33,9 @@ #include #include #include +#if HAVE_SYS_WAIT_H #include +#endif #include #include