[libvirt] [libvirt-php] About the inconsistency in libvirt-php
by Lyre
Hi all:
I noticed that there's some inconsistent behaviors in libvirt-php, and
wondering what's the best way to handle them.
In libvirt-php:
libvirt_list_domains() returns an array of all domain resource;
libvirt_list_active_domains() returns an array of running domain ids;
libvirt_list_defined_domains() returns an array of defined domain names.
and
libvirt_list_storagepools() returns an array of actived storagepool names.
In my opinion, returning an array of names would be better when listing all
kinds of objects.
And the naming convenances, let's take domains as an example.
libvirt-php provied
libvirt_list_domains() for all domains, which has no corresponding function
in libvirt.
libvirt_list_active_domains() for running domains, corresponding to
virConnectListDomains() in libvirt.
libvirt_list_defined_domains() for defined domains, corresponding to
virConnectListDefinedDomains() in libvirt.
I believe it is fine. However, for defined objects, sometimes it used term
"defined" (libvirt_list_defined_domains),
and sometimes use term "inactive" (libvirt_get_inactive_domain_count) in
contrast to "active". Which would be better?
13 years, 9 months
[libvirt] hello, Would I request some support about libvirt API?
by Saint yeyo
Hello, honorific developers,
I'm a rookie came here to study something about libvirt, I find it a
little bit difficult for me to use the API, there is absence of
explanation of specific functions and examples. May I ask some kind of
you who provide some docs about that for me, I'll very appreciate for
you.
Thank you!
Best regard!
13 years, 9 months
[libvirt] [libvirt-php 0/1] Added many apis for storagepool
by Lyre
Hi all:
This patch added the followings for storagepool:
libvirt_storagepool_get_uuid_string
libvirt_storagepool_get_name
libvirt_storagepool_lookup_by_uuid_string
libvirt_storagepool_get_xml_desc
libvirt_storagepool_define_xml
libvirt_storagepool_undefine
libvirt_storagepool_create
libvirt_storagepool_destroy
libvirt_storagepool_is_active
libvirt_storagepool_get_volume_count
libvirt_storagepool_refresh
libvirt_storagepool_set_autostart
libvirt_storagepool_get_autostart
These functions were taken from my own branch of original php-libvirt,
with some modification, and litte tests.
I've put the function prototype in git log, but it seems not a good idea.
Maybe I should provie the documents as well.
In my original branch, I've extended php-libvirt a lot with their own documents.
But I'm not able to simply merge it into libvirt-php: there're too many functions
, some designs are really problematical, libvirt-php have indent the source.
The documents may be not welly written, some statment don't looks like native
English, since I'm not English speaker.
I'm tring to find a way to move the source to into libvirt-php,
currently it was copy & paste with some adjustment.
Lyre (1):
storagepool: added apis for control and query
src/libvirt.c | 226 +++++++++++++++++++++++++++++++++++++++++++++++++++++
src/php_libvirt.h | 13 +++
2 files changed, 239 insertions(+), 0 deletions(-)
13 years, 9 months
[libvirt] [libvirt-php] Fixed checking for libxml2 and prerequisites
by Lyre
Repalced AM_PATH_XML2 with with the script borrowed
from libvirt, which was borrowed from xmlsec.
modified: configure.ac
modified: src/Makefile.am
---
configure.ac | 50 ++++++++++++++++++++++++++++++++++++++++++++++++--
src/Makefile.am | 4 ++--
2 files changed, 50 insertions(+), 4 deletions(-)
diff --git a/configure.ac b/configure.ac
index ac31bd0..b87c7f9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -10,12 +10,58 @@ AC_PROG_CC
AC_LANG([C])
AC_PROG_INSTALL
AC_PROG_SED
+AC_PROG_AWK
AC_CHECK_TOOL([STRIP], [strip])
AC_CHECK_TOOL([ECHO], [echo])
AC_CHECK_TOOL([RM], [rm])
-dnl Check for libxml2
-AM_PATH_XML2([2.0.0])
+dnl Need to test if pkg-config exists
+PKG_PROG_PKG_CONFIG
+
+dnl ==========================================================================
+dnl required minimum version of libxml2
+dnl replace "2.0.0" with an appropriate one
+dnl ==========================================================================
+LIBXML_REQUIRED="2.0.0"
+
+dnl ==========================================================================
+dnl find libxml2 library, borrowed from xmlsec
+dnl ==========================================================================
+LIBXML_CONFIG="xml2-config"
+LIBXML_CFLAGS=""
+LIBXML_LIBS=""
+LIBXML_FOUND="no"
+
+AC_ARG_WITH([libxml], AC_HELP_STRING([--with-libxml=@<:@PFX@:>@], [libxml2 location]))
+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" && test "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
+ if test "x$with_libxml" != "x" ; then
+ LIBXML_CONFIG=$with_libxml/bin/$LIBXML_CONFIG
+ fi
+ AC_MSG_CHECKING(libxml2 $LIBXML_CONFIG >= $LIBXML_REQUIRED )
+ if ! $LIBXML_CONFIG --version > /dev/null 2>&1 ; then
+ AC_MSG_ERROR([Could not find libxml2 anywhere (see config.log for details).])
+ fi
+ vers=`$LIBXML_CONFIG --version | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
+ minvers=`echo $LIBXML_REQUIRED | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
+ if test "$vers" -ge "$minvers" ; then
+ LIBXML_LIBS="`$LIBXML_CONFIG --libs`"
+ LIBXML_CFLAGS="`$LIBXML_CONFIG --cflags`"
+ LIBXML_FOUND="yes"
+ AC_MSG_RESULT(yes)
+ else
+ AC_MSG_ERROR(
+ [You need at least libxml2 $LIBXML_REQUIRED for this version of libvirt])
+ fi
+fi
+
+AC_SUBST([LIBXML_CFLAGS])
+AC_SUBST([LIBXML_LIBS])
dnl Specific XML catalog file for validation of generated html
AC_ARG_WITH([xml-catalog-file],
diff --git a/src/Makefile.am b/src/Makefile.am
index 9e89f9f..1826b09 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,8 +7,8 @@ EXTRA_DIST = libvirt.c php_libvirt.h
all-am: build clean-temp
build:
- $(CC) -Wall -fpic -DCOMPILE_DL_LIBVIRT=1 $(PHPINC) -c -o $(PACKAGE).o libvirt.c $(XML_CPPFLAGS)
- $(CC) -Wall -shared $(LIBS) -rdynamic -o $(PACKAGE).so $(PACKAGE).o -ldl -lvirt $(XML_LIBS)
+ $(CC) -Wall -fpic -DCOMPILE_DL_LIBVIRT=1 $(PHPINC) -c -o $(PACKAGE).o libvirt.c $(LIBXML_CFLAGS)
+ $(CC) -Wall -shared $(LIBS) -rdynamic -o $(PACKAGE).so $(PACKAGE).o -ldl -lvirt $(LIBXML_LIBS)
$(ECHO) "Extension compiled as $(PACKAGE).so"
install-exec-local:
--
1.7.1
13 years, 9 months
[libvirt] [PATCH] storage: make debug log more useful
by Osier Yang
"__func__" should be replaced with "__FUNCTION__" instead for
better portability, however, VIR_DEBUG already prints the function
name, so it's useless, replace it with more useful log.
* src/storage/storage_backend_mpath.c
---
src/storage/storage_backend_mpath.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_backend_mpath.c
index 2e85561..2d48a9d 100644
--- a/src/storage/storage_backend_mpath.c
+++ b/src/storage/storage_backend_mpath.c
@@ -316,7 +316,7 @@ virStorageBackendMpathRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
{
int retval = 0;
- VIR_DEBUG("in %s", __func__);
+ VIR_DEBUG("conn=%p, pool=%p", conn, pool);
pool->def->allocation = pool->def->capacity = pool->def->available = 0;
--
1.7.4
13 years, 9 months
[libvirt] [PATCH] virsh: replace vshPrint with vshPrintExtra for snapshot list
by Osier Yang
Otherwise extra information will be printed even if "--quiet"
is specified.
* tools/virsh.c
---
tools/virsh.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index ce275f1..2837e0f 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -10000,8 +10000,8 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
if (numsnaps < 0)
goto cleanup;
- vshPrint(ctl, " %-20s %-25s %s\n", _("Name"), _("Creation Time"), _("State"));
- vshPrint(ctl, "---------------------------------------------------\n");
+ vshPrintExtra(ctl, " %-20s %-25s %s\n", _("Name"), _("Creation Time"), _("State"));
+ vshPrintExtra(ctl, "---------------------------------------------------\n");
if (numsnaps) {
if (VIR_ALLOC_N(names, numsnaps) < 0)
--
1.7.4
13 years, 9 months
[libvirt] [libvirt-php] rewrite checking for libxml2
by Lyre
Dropped the complex macro AM_PATH_XML2.
* configure.ac: repalce the AM_PATH_XML2 with the script borrowed
from libvirt, which was borrowed from xmlsec.
* src/Makefile.am: changed XML_CPPFLAGS to XML_CFLAGS
---
aclocal.m4 | 347 +++++++++++++++++++++++++------------------------------
configure.ac | 43 +++++++-
src/Makefile.am | 2 +-
3 files changed, 199 insertions(+), 193 deletions(-)
diff --git a/aclocal.m4 b/aclocal.m4
index da878b3..45dac6f 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -13,200 +13,167 @@
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
-m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.66],,
-[m4_warning([this file was generated for autoconf 2.66.
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.65],,
+[m4_warning([this file was generated for autoconf 2.65.
You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically `autoreconf'.])])
-# Configure paths for LIBXML2
-# Mike Hommey 2004-06-19
-# use CPPFLAGS instead of CFLAGS
-# Toshio Kuratomi 2001-04-21
-# Adapted from:
-# Configure paths for GLIB
-# Owen Taylor 97-11-3
-
-dnl AM_PATH_XML2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
-dnl Test for XML, and define XML_CPPFLAGS and XML_LIBS
-dnl
-AC_DEFUN([AM_PATH_XML2],[
-AC_ARG_WITH(xml-prefix,
- [ --with-xml-prefix=PFX Prefix where libxml is installed (optional)],
- xml_config_prefix="$withval", xml_config_prefix="")
-AC_ARG_WITH(xml-exec-prefix,
- [ --with-xml-exec-prefix=PFX Exec prefix where libxml is installed (optional)],
- xml_config_exec_prefix="$withval", xml_config_exec_prefix="")
-AC_ARG_ENABLE(xmltest,
- [ --disable-xmltest Do not try to compile and run a test LIBXML program],,
- enable_xmltest=yes)
-
- if test x$xml_config_exec_prefix != x ; then
- xml_config_args="$xml_config_args"
- if test x${XML2_CONFIG+set} != xset ; then
- XML2_CONFIG=$xml_config_exec_prefix/bin/xml2-config
- fi
- fi
- if test x$xml_config_prefix != x ; then
- xml_config_args="$xml_config_args --prefix=$xml_config_prefix"
- if test x${XML2_CONFIG+set} != xset ; then
- XML2_CONFIG=$xml_config_prefix/bin/xml2-config
- fi
- fi
+# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
+#
+# Copyright © 2004 Scott James Remnant <scott(a)netsplit.com>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
- AC_PATH_PROG(XML2_CONFIG, xml2-config, no)
- min_xml_version=ifelse([$1], ,2.0.0,[$1])
- AC_MSG_CHECKING(for libxml - version >= $min_xml_version)
- no_xml=""
- if test "$XML2_CONFIG" = "no" ; then
- no_xml=yes
- else
- XML_CPPFLAGS=`$XML2_CONFIG $xml_config_args --cflags`
- XML_LIBS=`$XML2_CONFIG $xml_config_args --libs`
- xml_config_major_version=`$XML2_CONFIG $xml_config_args --version | \
- sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
- xml_config_minor_version=`$XML2_CONFIG $xml_config_args --version | \
- sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
- xml_config_micro_version=`$XML2_CONFIG $xml_config_args --version | \
- sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
- if test "x$enable_xmltest" = "xyes" ; then
- ac_save_CPPFLAGS="$CPPFLAGS"
- ac_save_LIBS="$LIBS"
- CPPFLAGS="$CPPFLAGS $XML_CPPFLAGS"
- LIBS="$XML_LIBS $LIBS"
-dnl
-dnl Now check if the installed libxml is sufficiently new.
-dnl (Also sanity checks the results of xml2-config to some extent)
-dnl
- rm -f conf.xmltest
- AC_TRY_RUN([
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <libxml/xmlversion.h>
-
-int
-main()
-{
- int xml_major_version, xml_minor_version, xml_micro_version;
- int major, minor, micro;
- char *tmp_version;
-
- system("touch conf.xmltest");
-
- /* Capture xml2-config output via autoconf/configure variables */
- /* HP/UX 9 (%@#!) writes to sscanf strings */
- tmp_version = (char *)strdup("$min_xml_version");
- if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
- printf("%s, bad version string from xml2-config\n", "$min_xml_version");
- exit(1);
- }
- free(tmp_version);
-
- /* Capture the version information from the header files */
- tmp_version = (char *)strdup(LIBXML_DOTTED_VERSION);
- if (sscanf(tmp_version, "%d.%d.%d", &xml_major_version, &xml_minor_version, &xml_micro_version) != 3) {
- printf("%s, bad version string from libxml includes\n", "LIBXML_DOTTED_VERSION");
- exit(1);
- }
- free(tmp_version);
-
- /* Compare xml2-config output to the libxml headers */
- if ((xml_major_version != $xml_config_major_version) ||
- (xml_minor_version != $xml_config_minor_version) ||
- (xml_micro_version != $xml_config_micro_version))
- {
- printf("*** libxml header files (version %d.%d.%d) do not match\n",
- xml_major_version, xml_minor_version, xml_micro_version);
- printf("*** xml2-config (version %d.%d.%d)\n",
- $xml_config_major_version, $xml_config_minor_version, $xml_config_micro_version);
- return 1;
- }
-/* Compare the headers to the library to make sure we match */
- /* Less than ideal -- doesn't provide us with return value feedback,
- * only exits if there's a serious mismatch between header and library.
- */
- LIBXML_TEST_VERSION;
-
- /* Test that the library is greater than our minimum version */
- if ((xml_major_version > major) ||
- ((xml_major_version == major) && (xml_minor_version > minor)) ||
- ((xml_major_version == major) && (xml_minor_version == minor) &&
- (xml_micro_version >= micro)))
- {
- return 0;
- }
- else
- {
- printf("\n*** An old version of libxml (%d.%d.%d) was found.\n",
- xml_major_version, xml_minor_version, xml_micro_version);
- printf("*** You need a version of libxml newer than %d.%d.%d. The latest version of\n",
- major, minor, micro);
- printf("*** libxml is always available from ftp://ftp.xmlsoft.org.\n");
- printf("***\n");
- printf("*** If you have already installed a sufficiently new version, this error\n");
- printf("*** probably means that the wrong copy of the xml2-config shell script is\n");
- printf("*** being found. The easiest way to fix this is to remove the old version\n");
- printf("*** of LIBXML, but you can also set the XML2_CONFIG environment to point to the\n");
- printf("*** correct copy of xml2-config. (In this case, you will have to\n");
- printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
- printf("*** so that the correct libraries are found at run-time))\n");
- }
- return 1;
-}
-],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
- CPPFLAGS="$ac_save_CPPFLAGS"
- LIBS="$ac_save_LIBS"
- fi
- fi
+# PKG_PROG_PKG_CONFIG([MIN-VERSION])
+# ----------------------------------
+AC_DEFUN([PKG_PROG_PKG_CONFIG],
+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
+m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+ AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+fi
+if test -n "$PKG_CONFIG"; then
+ _pkg_min_version=m4_default([$1], [0.9.0])
+ AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
+ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ PKG_CONFIG=""
+ fi
+
+fi[]dnl
+])# PKG_PROG_PKG_CONFIG
+
+# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+#
+# Check to see whether a particular set of modules exists. Similar
+# to PKG_CHECK_MODULES(), but does not set variables or print errors.
+#
+#
+# Similar to PKG_CHECK_MODULES, make sure that the first instance of
+# this or PKG_CHECK_MODULES is called, or make sure to call
+# PKG_CHECK_EXISTS manually
+# --------------------------------------------------------------
+AC_DEFUN([PKG_CHECK_EXISTS],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+if test -n "$PKG_CONFIG" && \
+ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
+ m4_ifval([$2], [$2], [:])
+m4_ifvaln([$3], [else
+ $3])dnl
+fi])
+
+
+# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+# ---------------------------------------------
+m4_define([_PKG_CONFIG],
+[if test -n "$$1"; then
+ pkg_cv_[]$1="$$1"
+ elif test -n "$PKG_CONFIG"; then
+ PKG_CHECK_EXISTS([$3],
+ [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
+ [pkg_failed=yes])
+ else
+ pkg_failed=untried
+fi[]dnl
+])# _PKG_CONFIG
+
+# _PKG_SHORT_ERRORS_SUPPORTED
+# -----------------------------
+AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+ _pkg_short_errors_supported=yes
+else
+ _pkg_short_errors_supported=no
+fi[]dnl
+])# _PKG_SHORT_ERRORS_SUPPORTED
- if test "x$no_xml" = x ; then
- AC_MSG_RESULT(yes (version $xml_config_major_version.$xml_config_minor_version.$xml_config_micro_version))
- ifelse([$2], , :, [$2])
- else
- AC_MSG_RESULT(no)
- if test "$XML2_CONFIG" = "no" ; then
- echo "*** The xml2-config script installed by LIBXML could not be found"
- echo "*** If libxml was installed in PREFIX, make sure PREFIX/bin is in"
- echo "*** your path, or set the XML2_CONFIG environment variable to the"
- echo "*** full path to xml2-config."
- else
- if test -f conf.xmltest ; then
- :
- else
- echo "*** Could not run libxml test program, checking why..."
- CPPFLAGS="$CPPFLAGS $XML_CPPFLAGS"
- LIBS="$LIBS $XML_LIBS"
- AC_TRY_LINK([
-#include <libxml/xmlversion.h>
-#include <stdio.h>
-], [ LIBXML_TEST_VERSION; return 0;],
- [ echo "*** The test program compiled, but did not run. This usually means"
- echo "*** that the run-time linker is not finding LIBXML or finding the wrong"
- echo "*** version of LIBXML. If it is not finding LIBXML, you'll need to set your"
- echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
- echo "*** to the installed location Also, make sure you have run ldconfig if that"
- echo "*** is required on your system"
- echo "***"
- echo "*** If you have an old version installed, it is best to remove it, although"
- echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
- [ echo "*** The test program failed to compile or link. See the file config.log for the"
- echo "*** exact error that occured. This usually means LIBXML was incorrectly installed"
- echo "*** or that you have moved LIBXML since it was installed. In the latter case, you"
- echo "*** may want to edit the xml2-config script: $XML2_CONFIG" ])
- CPPFLAGS="$ac_save_CPPFLAGS"
- LIBS="$ac_save_LIBS"
- fi
- fi
-
- XML_CPPFLAGS=""
- XML_LIBS=""
- ifelse([$3], , :, [$3])
- fi
- AC_SUBST(XML_CPPFLAGS)
- AC_SUBST(XML_LIBS)
- rm -f conf.xmltest
-])
+
+# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+# [ACTION-IF-NOT-FOUND])
+#
+#
+# Note that if there is a possibility the first call to
+# PKG_CHECK_MODULES might not happen, you should be sure to include an
+# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
+#
+#
+# --------------------------------------------------------------
+AC_DEFUN([PKG_CHECK_MODULES],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
+
+pkg_failed=no
+AC_MSG_CHECKING([for $1])
+
+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
+_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+
+m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
+and $1[]_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details.])
+
+if test $pkg_failed = yes; then
+ _PKG_SHORT_ERRORS_SUPPORTED
+ if test $_pkg_short_errors_supported = yes; then
+ $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1`
+ else
+ $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
+ fi
+ # Put the nasty error message in config.log where it belongs
+ echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
+
+ ifelse([$4], , [AC_MSG_ERROR(dnl
+[Package requirements ($2) were not met:
+
+$$1_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+_PKG_TEXT
+])],
+ [AC_MSG_RESULT([no])
+ $4])
+elif test $pkg_failed = untried; then
+ ifelse([$4], , [AC_MSG_FAILURE(dnl
+[The pkg-config script could not be found or is too old. Make sure it
+is in your PATH or set the PKG_CONFIG environment variable to the full
+path to pkg-config.
+
+_PKG_TEXT
+
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.])],
+ [$4])
+else
+ $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
+ $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
+ AC_MSG_RESULT([yes])
+ ifelse([$3], , :, [$3])
+fi[]dnl
+])# PKG_CHECK_MODULES
# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
#
diff --git a/configure.ac b/configure.ac
index ac31bd0..7c64c86 100644
--- a/configure.ac
+++ b/configure.ac
@@ -14,8 +14,47 @@ AC_CHECK_TOOL([STRIP], [strip])
AC_CHECK_TOOL([ECHO], [echo])
AC_CHECK_TOOL([RM], [rm])
-dnl Check for libxml2
-AM_PATH_XML2([2.0.0])
+dnl ==========================================================================
+dnl required minimum version of libxml2
+dnl replace "2.0.0" with an appropriate one
+dnl ==========================================================================
+LIBXML_REQUIRED="2.0.0"
+
+dnl ==========================================================================
+dnl find libxml2 library, borrowed from xmlsec
+dnl ==========================================================================
+LIBXML_CONFIG="xml2-config"
+LIBXML_CFLAGS=""
+LIBXML_LIBS=""
+LIBXML_FOUND="no"
+
+AC_ARG_WITH([libxml], AC_HELP_STRING([--with-libxml=@<:@PFX@:>@], [libxml2 location]))
+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" && test "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
+ if test "x$with_libxml" != "x" ; then
+ LIBXML_CONFIG=$with_libxml/bin/$LIBXML_CONFIG
+ fi
+ AC_MSG_CHECKING(libxml2 $LIBXML_CONFIG >= $LIBXML_REQUIRED )
+ if ! $LIBXML_CONFIG --version > /dev/null 2>&1 ; then
+ AC_MSG_ERROR([Could not find libxml2 anywhere (see config.log for details).])
+ fi
+ vers=`$LIBXML_CONFIG --version | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
+ minvers=`echo $LIBXML_REQUIRED | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
+ if test "$vers" -ge "$minvers" ; then
+ LIBXML_LIBS="`$LIBXML_CONFIG --libs`"
+ LIBXML_CFLAGS="`$LIBXML_CONFIG --cflags`"
+ LIBXML_FOUND="yes"
+ AC_MSG_RESULT(yes)
+ else
+ AC_MSG_ERROR(
+ [You need at least libxml2 $LIBXML_REQUIRED for this version of libvirt])
+ fi
+fi
dnl Specific XML catalog file for validation of generated html
AC_ARG_WITH([xml-catalog-file],
diff --git a/src/Makefile.am b/src/Makefile.am
index 9e89f9f..f7dcffc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,7 +7,7 @@ EXTRA_DIST = libvirt.c php_libvirt.h
all-am: build clean-temp
build:
- $(CC) -Wall -fpic -DCOMPILE_DL_LIBVIRT=1 $(PHPINC) -c -o $(PACKAGE).o libvirt.c $(XML_CPPFLAGS)
+ $(CC) -Wall -fpic -DCOMPILE_DL_LIBVIRT=1 $(PHPINC) -c -o $(PACKAGE).o libvirt.c $(XML_CFLAGS)
$(CC) -Wall -shared $(LIBS) -rdynamic -o $(PACKAGE).so $(PACKAGE).o -ldl -lvirt $(XML_LIBS)
$(ECHO) "Extension compiled as $(PACKAGE).so"
--
1.7.1
13 years, 9 months
[libvirt] [RFC PATCH 0/2] audit cgroup ACL actions in qemu
by Eric Blake
I'm following up on danpb's patches to add initial audit support to
qemu actions (see around commit 8dc136b in Oct 2010). Another useful
thing to audit is all changes to the device ACL whitelist via the
cgroup device controller - namely, any time that the qemu cgroup is
altered to allow or deny access to a (set of) devices.
I saw an alternate suggestion for collecting the needed audit
information by using an inotify script outside of libvirt that
monitors changes to the cgroup file system corresponding to each qemu
instance; however, this had the drawback that it can only monitor that
a change is being attempted, but not the actual change being made. It
is necessary to use libvirt to provide the audit information, in order
to have a rich enough set of information to make the audit worthwhile.
I believe this patch series catches all instances where libvirt
modifies the whitelist for a qemu instance, but I didn't do anything
for when libvirt first creates a separate cgroup device whitelist as
part of starting a new guest. Also, I'm not sure if the amount of
information passed to the audit is adequate, or if it needs tweaking.
Also, libvirt blindly passes a long list of paths through the
low-level util/cgroup.c functions, including non-devices where it
ignores the EINVAL failure later. But this could pollute the audit
log with entries corresponding to cases where altering the actual
cgroup was never even attempted. Should I tweak things to only do an
audit when an actual cgroup change was attempted (perhaps by modifying
util/cgroup.c to return 0 on success, 1 on skip, and -errno on
failure, rather than the current -EINVAL on skip)?
This is post-0.8.8 material.
Eric Blake (2):
audit: prepare qemu for listing vm in cgroup audits
audit: add qemu hooks for auditing cgroup events
src/qemu/qemu_audit.c | 48 ++++++++++++++++++++++++++++++-
src/qemu/qemu_audit.h | 9 +++++-
src/qemu/qemu_cgroup.c | 73 +++++++++++++++++++++++++++++++----------------
src/qemu/qemu_cgroup.h | 21 ++++++--------
src/qemu/qemu_driver.c | 12 +++++--
src/qemu/qemu_hotplug.c | 7 ++--
6 files changed, 124 insertions(+), 46 deletions(-)
--
1.7.4
13 years, 9 months
[libvirt] [PATCH] build: fix broken mingw cross-compilation
by Eric Blake
Two regressions:
Commit df1011ca broke builds for systems that lack devmapper
(non-Linux, as well as Linux with ./autogen.sh --without-libvirtd
and without the libraries present).
Commit ce6fd650 broke cross-compilation, due to a gnulib bug.
* .gnulib: Update to latest, for cross-compilation fix.
* src/util/util.c (virIsDevMapperDevice): Provide stub for
platforms not using storage driver.
* configure.ac (devmapper): Arrange to define HAVE_LIBDEVMAPPER_H.
devmapper issue reported by Wen Congyang.
---
Thankfully, neither regression was in the 0.8.7 release.
Pushing this under the build-breaker rule, as verified by
./autobuild.sh.
* .gnulib aa0f5d7...17adb5d (9):
> longlong: skip, rather than fail, on cross-compilation
> * NEWS: Mention 2011-02-08 change to stdlib.
> getloadavg: Add comments about platforms.
> getloadavg: Fix link error on Solaris 2.6.
> * lib/getloadavg.c (getloadavg) [sgi]: Make ldav_off of type ptrdiff_t.
> Oops, fix syntax error in last config.rpath commit.
> havelib: Fix comments.
> havelib: Update config.rpath.
> getloadavg test: Add some plausibility checks.
.gnulib | 2 +-
configure.ac | 2 +-
src/util/util.c | 11 ++++++++++-
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/.gnulib b/.gnulib
index aa0f5d7..17adb5d 160000
--- a/.gnulib
+++ b/.gnulib
@@ -1 +1 @@
-Subproject commit aa0f5d7586efe7044f6ca9e07be3f579ee0d5618
+Subproject commit 17adb5d75404cf6cdde0eb3b2edc6110d9fa8001
diff --git a/configure.ac b/configure.ac
index f79babb..2b26e57 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1711,12 +1711,12 @@ if test "$with_storage_mpath" = "yes"; then
save_LIBS="$LIBS"
save_CFLAGS="$CFLAGS"
DEVMAPPER_FOUND=yes
- AC_CHECK_HEADER([libdevmapper.h],,[DEVMAPPER_FOUND=no])
AC_CHECK_LIB([devmapper], [dm_task_run],,[DEVMAPPER_FOUND=no])
DEVMAPPER_LIBS="-ldevmapper"
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
fi
+ AC_CHECK_HEADERS([libdevmapper.h],,[DEVMAPPER_FOUND=no])
if test "$DEVMAPPER_FOUND" = "no" ; then
AC_MSG_ERROR([You must install device-mapper-devel/libdevmapper >= $DEVMAPPER_REQUIRED to compile libvirt])
fi
diff --git a/src/util/util.c b/src/util/util.c
index a7ce4b3..cbdae67 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -45,7 +45,9 @@
#include <string.h>
#include <signal.h>
#include <termios.h>
-#include <libdevmapper.h>
+#if HAVE_LIBDEVMAPPER_H
+# include <libdevmapper.h>
+#endif
#include "c-ctype.h"
#ifdef HAVE_PATHS_H
@@ -3125,6 +3127,7 @@ virTimestamp(void)
return timestamp;
}
+#if HAVE_LIBDEVMAPPER_H
bool
virIsDevMapperDevice(const char *devname)
{
@@ -3137,3 +3140,9 @@ virIsDevMapperDevice(const char *devname)
return false;
}
+#else
+bool virIsDevMapperDevice(const char *devname ATTRIBUTE_UNUSED)
+{
+ return false;
+}
+#endif
--
1.7.4
13 years, 9 months
[libvirt] [PATCH 1/2] virt-pki-validate: behave when CERTTOOL is missing
by Dan Kenigsberg
---
tools/virt-pki-validate.in | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/virt-pki-validate.in b/tools/virt-pki-validate.in
index 207fa76..96659cf 100755
--- a/tools/virt-pki-validate.in
+++ b/tools/virt-pki-validate.in
@@ -14,7 +14,7 @@ PORT=16514
# First get certtool
#
CERTOOL=`which certtool 2>/dev/null`
-if [ ! -x $CERTOOL ]
+if [ ! -x "$CERTOOL" ]
then
echo "Could not locate the certtool program"
echo "make sure the gnutls-utils (or gnutls-bin) package is installed"
--
1.7.4
13 years, 9 months