[libvirt] [PATCH] build: fix some mingw issues
by Eric Blake
On Fedora 13 with sufficient mingw32-* packages installed, running
./autobuild.sh failed to cross-compile to mingw because
mingw32-pthreads installed a broken <pthread.h>. With that
issue fixed, the build still failed due to use of O_SYNC.
Meanwhile, recent .spec.in changes got out of sync, and running
./autobuild.sh generates some leftover files worth ignoring.
* bootstrap.conf (gnulib_modules): Add fcntl-h, for O_SYNC.
* .gnulib: Update to latest, to work around buggy pthreads-win32
library.
* bootstrap: Import latest from gnulib.
* mingw32-libvirt.spec.in: Distribute new file.
* .gitignore: Ignore files built by ./autobuild.sh.
---
Took me the better part of a day to track all of this down,
but I got back to the point where ./autobuild.sh works
when you have a mingw cross-compiler installed.
.gitignore | 4 ++++
.gnulib | 2 +-
bootstrap | 14 ++++++++------
bootstrap.conf | 1 +
mingw32-libvirt.spec.in | 1 +
5 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/.gitignore b/.gitignore
index 39ed671..fee8f8e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,6 +12,10 @@
/GNUmakefile
/libvirt-[0-9]*
/maint.mk
+/tools/virsh-console.gcda
+/tools/virsh-console.gcno
+/tools/virsh-virsh.gcda
+/tools/virsh-virsh.gcno
ABOUT-NLS
COPYING
ChangeLog
diff --git a/.gnulib b/.gnulib
index 28e5820..df6774c 160000
--- a/.gnulib
+++ b/.gnulib
@@ -1 +1 @@
-Subproject commit 28e58203a7ab14264f8fa450884a89e9ae48025c
+Subproject commit df6774c09485e6b0f31f4659eb55d50c68c008a8
diff --git a/bootstrap b/bootstrap
index 365a3d9..2422549 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1,6 +1,6 @@
#! /bin/sh
# Print a version string.
-scriptversion=2010-02-24.17; # UTC
+scriptversion=2010-05-17.18; # UTC
# Bootstrap this package from checked-out sources.
@@ -409,6 +409,7 @@ git_modules_config () {
}
gnulib_path=`git_modules_config submodule.gnulib.path`
+: ${gnulib_path=gnulib}
# Get gnulib files.
@@ -424,7 +425,8 @@ case ${GNULIB_SRCDIR--} in
trap cleanup_gnulib 1 2 13 15
- git clone --help|grep depth > /dev/null && shallow='--depth 2' || shallow=
+ shallow=
+ git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2'
git clone $shallow git://git.sv.gnu.org/gnulib "$gnulib_path" ||
cleanup_gnulib
@@ -437,7 +439,7 @@ case ${GNULIB_SRCDIR--} in
if test -d "$GNULIB_SRCDIR"/.git && \
git_modules_config submodule.gnulib.url >/dev/null; then
echo "$0: getting gnulib files..."
- if git submodule --help|grep reference > /dev/null; then
+ if git submodule -h|grep -- --reference > /dev/null; then
# Prefer the one-liner available in git 1.6.4 or newer.
git submodule update --init --reference "$GNULIB_SRCDIR" \
"$gnulib_path" || exit $?
@@ -488,7 +490,7 @@ update_po_files() {
test -d $ref_po_dir || mkdir $ref_po_dir || return
download_po_files $ref_po_dir $domain \
&& ls "$ref_po_dir"/*.po 2>/dev/null |
- sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS"
+ sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS" || return
langs=`cd $ref_po_dir && echo *.po|sed 's/\.po//g'`
test "$langs" = '*' && langs=x
@@ -819,7 +821,7 @@ if test $with_gettext = yes; then
a\
'"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
}
- ' po/Makevars.template >po/Makevars
+ ' po/Makevars.template >po/Makevars || exit 1
if test -d runtime-po; then
# Similarly for runtime-po/Makevars, but not quite the same.
@@ -833,7 +835,7 @@ if test $with_gettext = yes; then
a\
'"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
}
- ' <po/Makevars.template >runtime-po/Makevars
+ ' po/Makevars.template >runtime-po/Makevars || exit 1
# Copy identical files from po to runtime-po.
(cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
diff --git a/bootstrap.conf b/bootstrap.conf
index 1e193d9..44d6d0e 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -27,6 +27,7 @@ close
connect
count-one-bits
dirname-lgpl
+fcntl-h
getaddrinfo
gethostname
getpass
diff --git a/mingw32-libvirt.spec.in b/mingw32-libvirt.spec.in
index fc90203..6b2b5c6 100644
--- a/mingw32-libvirt.spec.in
+++ b/mingw32-libvirt.spec.in
@@ -91,6 +91,7 @@ rm -rf $RPM_BUILD_ROOT
%dir %{_mingw32_datadir}/libvirt/
%dir %{_mingw32_datadir}/libvirt/schemas/
%{_mingw32_datadir}/libvirt/schemas/domain.rng
+%{_mingw32_datadir}/libvirt/schemas/domainsnapshot.rng
%{_mingw32_datadir}/libvirt/schemas/network.rng
%{_mingw32_datadir}/libvirt/schemas/storagepool.rng
%{_mingw32_datadir}/libvirt/schemas/storagevol.rng
--
1.7.0.1
14 years, 5 months
[libvirt] [PATCH] build: restore operation of bit-rotted 'make cov'
by Eric Blake
'./autobuild.sh' with lcov installed discovered that our
coverage support has been bit-rotting for a while. This
restores it back to a successful state, although I have
not yet spent any time looking through the resulting files to
look for low-hanging fruit in the unit test coverage front.
* configure.ac: Clear COMPILER_FLAGS at right place.
* Makefile.am (cov): Newer genhtml no longer likes plain -s.
* m4/compiler-flags.m4 (gl_COMPILER_FLAGS): Don't AC_SUBST
COMPILER_FLAGS; it is a shell variable for use in configure only.
* src/Makefile.am (AM_CFLAGS, AM_LDFLAGS): New variables, to make
it easier to provide global flag additions. Use throughout, to
uniformly apply coverage flags.
* .gitignore: Globally ignore gcov output.
* daemon/.gitignore: Simplify.
* src/.gitignore: Likewise.
* tests/.gitignore: Likewise.
---
I almost decided to tear out lcov support altogether; fortunately,
it turned out to be simple enough to get it back into decent
enough shape to pass './autobuild.sh' again. That has been a
good project file for me, finding a number of build improvements;
once it is running cleanly, we need to automate running it on a
regular basis (I still have unapproved mingw and VPATH patches
posted on the list that need to be merged in before autobuild.sh
can reliably be automated).
If desired, I can do a followup patch that factors the common
-I@top_srcdir@/src/conf in all the *_CFLAGS into the new
AM_CFLAGS variable, which matches automake recommendations
for quickly setting a global flag across all per-object compilations.
.gitignore | 3 +
Makefile.am | 9 +++-
configure.ac | 1 +
daemon/.gitignore | 2 -
m4/compiler-flags.m4 | 1 -
src/.gitignore | 3 -
src/Makefile.am | 111 ++++++++++++++++++++++++++-----------------------
tests/.gitignore | 2 -
8 files changed, 69 insertions(+), 63 deletions(-)
diff --git a/.gitignore b/.gitignore
index 39ed671..c62e885 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,9 @@
*.#*#
*.a
*.exe
+*.gcda
+*.gcno
+*.gcov
*.o
*.orig
*.rej
diff --git a/Makefile.am b/Makefile.am
index 286b13b..1343d7c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -68,10 +68,13 @@ tests:
cov: clean-cov
mkdir $(top_builddir)/coverage
- $(LCOV) -c -o $(top_builddir)/coverage/libvirt.info.tmp -d $(top_srcdir)/src -d $(top_srcdir)/daemon -d $(top_srcdir)/tests
- $(LCOV) -r $(top_builddir)/coverage/libvirt.info.tmp -o $(top_builddir)/coverage/libvirt.info *usr*
+ $(LCOV) -c -o $(top_builddir)/coverage/libvirt.info.tmp \
+ -d $(top_srcdir)/src -d $(top_srcdir)/daemon -d $(top_srcdir)/tests
+ $(LCOV) -r $(top_builddir)/coverage/libvirt.info.tmp \
+ -o $(top_builddir)/coverage/libvirt.info
rm $(top_builddir)/coverage/libvirt.info.tmp
- $(GENHTML) -s -t "libvirt" -o $(top_builddir)/coverage --legend $(top_builddir)/coverage/libvirt.info
+ $(GENHTML) --show-details -t "libvirt" -o $(top_builddir)/coverage \
+ --legend $(top_builddir)/coverage/libvirt.info
clean-cov:
rm -rf $(top_builddir)/coverage
diff --git a/configure.ac b/configure.ac
index 691ef69..67aaac2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1688,6 +1688,7 @@ AC_ARG_ENABLE([test-coverage],
enable_coverage=$enableval
if test "${enable_coverage}" = yes; then
+ COMPILER_FLAGS=
gl_COMPILER_FLAGS(-fprofile-arcs)
gl_COMPILER_FLAGS(-ftest-coverage)
AC_SUBST([COVERAGE_CFLAGS], [$COMPILER_FLAGS])
diff --git a/daemon/.gitignore b/daemon/.gitignore
index 4f4b612..ca390e2 100644
--- a/daemon/.gitignore
+++ b/daemon/.gitignore
@@ -1,5 +1,3 @@
-*.gcda
-*.gcno
*.la
*.lo
.deps
diff --git a/m4/compiler-flags.m4 b/m4/compiler-flags.m4
index 628bd1f..6db4816 100644
--- a/m4/compiler-flags.m4
+++ b/m4/compiler-flags.m4
@@ -23,7 +23,6 @@
AC_DEFUN([gl_COMPILER_FLAGS],
[AC_MSG_CHECKING(whether compiler accepts $1)
- AC_SUBST(COMPILER_FLAGS)
ac_save_CFLAGS="$CFLAGS"
dnl Some flags are dependant, so we set all previously checked
dnl flags when testing. Except for -Werror which we have to
diff --git a/src/.gitignore b/src/.gitignore
index d24a87d..5d114c9 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -6,9 +6,6 @@ Makefile.in
*.loT
*.la
*.exe
-*.gcda
-*.gcno
-*.gcov
*.cov
libvirt_parthelper
libvirt_lxc
diff --git a/src/Makefile.am b/src/Makefile.am
index 6bdf73c..cf453ff 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -24,6 +24,9 @@ INCLUDES = \
-DIN_LIBVIRT \
$(WIN32_EXTRA_CFLAGS)
+AM_CFLAGS = $(COVERAGE_CFLAGS)
+AM_LDFLAGS = $(COVERAGE_LDFLAGS)
+
EXTRA_DIST = $(conf_DATA)
BUILT_SOURCES =
@@ -417,20 +420,20 @@ libvirt_la_LIBADD = $(libvirt_la_BUILT_LIBADD)
libvirt_la_BUILT_LIBADD = libvirt_util.la
libvirt_util_la_SOURCES = \
$(UTIL_SOURCES)
-libvirt_util_la_CFLAGS = $(CAPNG_CFLAGS) $(YAJL_CFLAGS)
+libvirt_util_la_CFLAGS = $(CAPNG_CFLAGS) $(YAJL_CFLAGS) $(AM_CFLAGS)
libvirt_util_la_LIBADD = $(CAPNG_LIBS) $(YAJL_LIBS) $(LIB_PTHREAD)
noinst_LTLIBRARIES += libvirt_conf.la
libvirt_la_BUILT_LIBADD += libvirt_conf.la
libvirt_conf_la_SOURCES = $(CONF_SOURCES)
-libvirt_conf_la_CFLAGS =
-libvirt_conf_la_LDFLAGS =
+libvirt_conf_la_CFLAGS = $(AM_CFLAGS)
+libvirt_conf_la_LDFLAGS = $(AM_LDFLAGS)
noinst_LTLIBRARIES += libvirt_cpu.la
libvirt_la_BUILT_LIBADD += libvirt_cpu.la
libvirt_cpu_la_CFLAGS = \
- -I@top_srcdir@/src/conf
+ -I@top_srcdir@/src/conf $(AM_CFLAGS)
libvirt_cpu_la_SOURCES = $(CPU_SOURCES)
@@ -439,7 +442,7 @@ libvirt_la_BUILT_LIBADD += libvirt_driver.la
libvirt_driver_la_SOURCES = $(DRIVER_SOURCES)
libvirt_driver_la_CFLAGS = $(NUMACTL_CFLAGS) \
- -I@top_srcdir@/src/conf
+ -I@top_srcdir@/src/conf $(AM_CFLAGS)
libvirt_driver_la_LIBADD = $(NUMACTL_LIBS)
USED_SYM_FILES = libvirt_private.syms
@@ -452,9 +455,9 @@ noinst_LTLIBRARIES += libvirt_driver_test.la
libvirt_la_BUILT_LIBADD += libvirt_driver_test.la
endif
libvirt_driver_test_la_CFLAGS = \
- -I@top_srcdir@/src/conf
+ -I@top_srcdir@/src/conf $(AM_CFLAGS)
if WITH_DRIVER_MODULES
-libvirt_driver_test_la_LDFLAGS = -module -avoid-version
+libvirt_driver_test_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS)
endif
libvirt_driver_test_la_SOURCES = $(TEST_DRIVER_SOURCES)
endif
@@ -469,8 +472,9 @@ endif
libvirt_driver_remote_la_CFLAGS = \
$(GNUTLS_CFLAGS) \
$(SASL_CFLAGS) \
- -I@top_srcdir@/src/conf
-libvirt_driver_remote_la_LDFLAGS =
+ -I@top_srcdir@/src/conf \
+ $(AM_CFLAGS)
+libvirt_driver_remote_la_LDFLAGS = $(AM_LDFLAGS)
libvirt_driver_remote_la_LIBADD = $(GNUTLS_LIBS) $(SASL_LIBS)
if WITH_DRIVER_MODULES
libvirt_driver_remote_la_LDFLAGS += -module -avoid-version
@@ -519,8 +523,9 @@ libvirt_la_BUILT_LIBADD += libvirt_driver_xen.la
endif
libvirt_driver_xen_la_CFLAGS = \
$(XEN_CFLAGS) \
- -I@top_srcdir@/src/conf
-libvirt_driver_xen_la_LDFLAGS =
+ -I@top_srcdir@/src/conf \
+ $(AM_CFLAGS)
+libvirt_driver_xen_la_LDFLAGS = $(AM_LDFLAGS)
libvirt_driver_xen_la_LIBADD = $(XEN_LIBS)
if WITH_DRIVER_MODULES
libvirt_driver_xen_la_LDFLAGS += -module -avoid-version
@@ -537,7 +542,7 @@ libvirt_la_BUILT_LIBADD += libvirt_driver_phyp.la
endif
libvirt_driver_phyp_la_LIBADD = $(LIBSSH2_LIBS)
libvirt_driver_phyp_la_CFLAGS = $(LIBSSH2_CFLAGS) \
- -I@top_srcdir@/src/conf
+ -I@top_srcdir@/src/conf $(AM_CFLAGS)
libvirt_driver_phyp_la_SOURCES = $(PHYP_DRIVER_SOURCES)
endif
@@ -549,9 +554,9 @@ noinst_LTLIBRARIES += libvirt_driver_openvz.la
libvirt_la_BUILT_LIBADD += libvirt_driver_openvz.la
endif
libvirt_driver_openvz_la_CFLAGS = \
- -I@top_srcdir@/src/conf
+ -I@top_srcdir@/src/conf $(AM_CFLAGS)
if WITH_DRIVER_MODULES
-libvirt_driver_openvz_la_LDFLAGS = -module -avoid-version
+libvirt_driver_openvz_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS)
endif
libvirt_driver_openvz_la_SOURCES = $(OPENVZ_DRIVER_SOURCES)
endif
@@ -564,9 +569,9 @@ noinst_LTLIBRARIES += libvirt_driver_vbox.la
libvirt_la_BUILT_LIBADD += libvirt_driver_vbox.la
endif
libvirt_driver_vbox_la_CFLAGS = \
- -I@top_srcdir@/src/conf
+ -I@top_srcdir@/src/conf $(AM_CFLAGS)
if WITH_DRIVER_MODULES
-libvirt_driver_vbox_la_LDFLAGS = -module -avoid-version
+libvirt_driver_vbox_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS)
endif
libvirt_driver_vbox_la_LIBADD = $(DLOPEN_LIBS)
libvirt_driver_vbox_la_SOURCES = $(VBOX_DRIVER_SOURCES)
@@ -580,8 +585,8 @@ noinst_LTLIBRARIES += libvirt_driver_xenapi.la
libvirt_la_BUILT_LIBADD += libvirt_driver_xenapi.la
endif
libvirt_driver_xenapi_la_CFLAGS = $(LIBXENSERVER_CFLAGS) $(LIBCURL_CFLAGS) \
- -I@top_srcdir@/src/conf
-libvirt_driver_xenapi_la_LDFLAGS =
+ -I@top_srcdir@/src/conf $(AM_CFLAGS)
+libvirt_driver_xenapi_la_LDFLAGS = $(AM_LDFLAGS)
libvirt_driver_xenapi_la_LIBADD = $(LIBXENSERVER_LIBS) $(LIBCURL_LIBS)
if WITH_DRIVER_MODULES
libvirt_driver_xenapi_la_LDFLAGS += -module -avoid-version
@@ -598,8 +603,8 @@ noinst_LTLIBRARIES += libvirt_driver_qemu.la
#libvirt_la_BUILT_LIBADD += libvirt_driver_qemu.la
endif
libvirt_driver_qemu_la_CFLAGS = $(NUMACTL_CFLAGS) \
- -I@top_srcdir@/src/conf
-libvirt_driver_qemu_la_LDFLAGS =
+ -I@top_srcdir@/src/conf $(AM_CFLAGS)
+libvirt_driver_qemu_la_LDFLAGS = $(AM_LDFLAGS)
libvirt_driver_qemu_la_LIBADD = $(NUMACTL_LIBS)
if WITH_DRIVER_MODULES
libvirt_driver_qemu_la_LDFLAGS += -module -avoid-version
@@ -625,9 +630,9 @@ noinst_LTLIBRARIES += libvirt_driver_lxc.la
#libvirt_la_BUILT_LIBADD += libvirt_driver_lxc.la
endif
libvirt_driver_lxc_la_CFLAGS = \
- -I@top_srcdir@/src/conf
+ -I@top_srcdir@/src/conf $(AM_CFLAGS)
if WITH_DRIVER_MODULES
-libvirt_driver_lxc_la_LDFLAGS = -module -avoid-version
+libvirt_driver_lxc_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS)
endif
libvirt_driver_lxc_la_SOURCES = $(LXC_DRIVER_SOURCES)
@@ -648,8 +653,8 @@ noinst_LTLIBRARIES += libvirt_driver_uml.la
#libvirt_la_BUILT_LIBADD += libvirt_driver_uml.la
endif
libvirt_driver_uml_la_CFLAGS = $(NUMACTL_CFLAGS) \
- -I@top_srcdir@/src/conf
-libvirt_driver_uml_la_LDFLAGS =
+ -I@top_srcdir@/src/conf $(AM_CFLAGS)
+libvirt_driver_uml_la_LDFLAGS = $(AM_LDFLAGS)
libvirt_driver_uml_la_LIBADD = $(NUMACTL_LIBS)
if WITH_DRIVER_MODULES
libvirt_driver_uml_la_LDFLAGS += -module -avoid-version
@@ -666,8 +671,8 @@ noinst_LTLIBRARIES += libvirt_driver_one.la
#libvirt_la_BUILT_LIBADD += libvirt_driver_one.la
endif
libvirt_driver_one_la_CFLAGS = $(XMLRPC_CFLAGS) \
- -I@top_srcdir@/src/conf
-libvirt_driver_one_la_LDFLAGS =
+ -I@top_srcdir@/src/conf $(AM_CFLAGS)
+libvirt_driver_one_la_LDFLAGS = $(AM_LDFLAGS)
libvirt_driver_one_la_LIBADD = $(XMLRPC_LIBS)
#libvirt_driver_one_la_CFLAGS = "-DWITH_ONE"
if WITH_DRIVER_MODULES
@@ -690,8 +695,8 @@ noinst_LTLIBRARIES += libvirt_driver_esx.la
libvirt_la_BUILT_LIBADD += libvirt_driver_esx.la
endif
libvirt_driver_esx_la_CFLAGS = $(LIBCURL_CFLAGS) \
- -I@top_srcdir@/src/conf
-libvirt_driver_esx_la_LDFLAGS =
+ -I@top_srcdir@/src/conf $(AM_CFLAGS)
+libvirt_driver_esx_la_LDFLAGS = $(AM_LDFLAGS)
libvirt_driver_esx_la_LIBADD = $(LIBCURL_LIBS)
if WITH_DRIVER_MODULES
libvirt_driver_esx_la_LDFLAGS += -module -avoid-version
@@ -709,9 +714,9 @@ noinst_LTLIBRARIES += libvirt_driver_network.la
#libvirt_la_BUILT_LIBADD += libvirt_driver_network.la
endif
libvirt_driver_network_la_CFLAGS = \
- -I@top_srcdir@/src/conf
+ -I@top_srcdir@/src/conf $(AM_CFLAGS)
if WITH_DRIVER_MODULES
-libvirt_driver_network_la_LDFLAGS = -module -avoid-version
+libvirt_driver_network_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS)
endif
libvirt_driver_network_la_SOURCES = $(NETWORK_DRIVER_SOURCES)
endif
@@ -728,8 +733,8 @@ noinst_LTLIBRARIES += libvirt_driver_interface.la
libvirt_la_BUILT_LIBADD += libvirt_driver_interface.la
endif
libvirt_driver_interface_la_CFLAGS = $(NETCF_CFLAGS) \
- -I@top_srcdir@/src/conf
-libvirt_driver_interface_la_LDFLAGS =
+ -I@top_srcdir@/src/conf $(AM_CFLAGS)
+libvirt_driver_interface_la_LDFLAGS = $(AM_LDFLAGS)
libvirt_driver_interface_la_LIBADD = $(NETCF_LIBS)
if WITH_DRIVER_MODULES
libvirt_driver_interface_la_LDFLAGS += -module -avoid-version
@@ -746,9 +751,9 @@ noinst_LTLIBRARIES += libvirt_driver_secret.la
#libvirt_la_BUILT_LIBADD += libvirt_driver_secret.la
endif
libvirt_driver_secret_la_CFLAGS = \
- -I@top_srcdir@/src/conf
+ -I@top_srcdir@/src/conf $(AM_CFLAGS)
if WITH_DRIVER_MODULES
-libvirt_driver_secret_la_LDFLAGS = -module -avoid-version
+libvirt_driver_secret_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS)
libvirt_driver_secret_la_LIBADD = ../gnulib/lib/libgnu.la
endif
libvirt_driver_secret_la_SOURCES = $(SECRET_DRIVER_SOURCES)
@@ -757,8 +762,8 @@ endif
# Needed to keep automake quiet about conditionals
libvirt_driver_storage_la_SOURCES =
libvirt_driver_storage_la_CFLAGS = \
- -I@top_srcdir@/src/conf
-libvirt_driver_storage_la_LDFLAGS =
+ -I@top_srcdir@/src/conf $(AM_CFLAGS)
+libvirt_driver_storage_la_LDFLAGS = $(AM_LDFLAGS)
libvirt_driver_storage_la_LIBADD =
if WITH_STORAGE_DIR
if WITH_DRIVER_MODULES
@@ -809,8 +814,8 @@ endif
libvirt_driver_nodedev_la_SOURCES = $(NODE_DEVICE_DRIVER_SOURCES)
libvirt_driver_nodedev_la_CFLAGS = \
- -I@top_srcdir@/src/conf
-libvirt_driver_nodedev_la_LDFLAGS =
+ -I@top_srcdir@/src/conf $(AM_CFLAGS)
+libvirt_driver_nodedev_la_LDFLAGS = $(AM_LDFLAGS)
libvirt_driver_nodedev_la_LIBADD =
if HAVE_HAL
libvirt_driver_nodedev_la_SOURCES += $(NODE_DEVICE_DRIVER_HAL_SOURCES)
@@ -837,8 +842,8 @@ libvirt_la_BUILT_LIBADD += libvirt_driver_nwfilter.la
noinst_LTLIBRARIES += libvirt_driver_nwfilter.la
endif
libvirt_driver_nwfilter_la_CFLAGS = $(LIBPCAP_CFLAGS) \
- -I@top_srcdir@/src/conf
-libvirt_driver_nwfilter_la_LDFLAGS =
+ -I@top_srcdir@/src/conf $(AM_CFLAGS)
+libvirt_driver_nwfilter_la_LDFLAGS = $(LD_AMFLAGS)
libvirt_driver_nwfilter_la_LIBADD = $(LIBPCAP_LIBS)
if WITH_DRIVER_MODULES
libvirt_driver_nwfilter_la_LDFLAGS += -module -avoid-version
@@ -852,8 +857,8 @@ libvirt_driver_security_la_SOURCES = $(SECURITY_DRIVER_SOURCES)
noinst_LTLIBRARIES += libvirt_driver_security.la
libvirt_la_BUILT_LIBADD += libvirt_driver_security.la
libvirt_driver_security_la_CFLAGS = \
- -I@top_srcdir@/src/conf
-libvirt_driver_security_la_LDFLAGS =
+ -I@top_srcdir@/src/conf $(AM_CFLAGS)
+libvirt_driver_security_la_LDFLAGS = $(AM_LDFLAGS)
libvirt_driver_security_la_LIBADD =
if WITH_SECDRIVER_SELINUX
libvirt_driver_security_la_SOURCES += $(SECURITY_DRIVER_SELINUX_SOURCES)
@@ -996,14 +1001,14 @@ libvirt.def: libvirt.syms
libvirt_la_SOURCES =
libvirt_la_LDFLAGS = $(VERSION_SCRIPT_FLAGS)$(LIBVIRT_SYMBOL_FILE) \
-version-info $(LIBVIRT_VERSION_INFO) \
- $(COVERAGE_CFLAGS:-f%=-Wc,-f%) \
+ $(AM_LDFLAGS) \
$(CYGWIN_EXTRA_LDFLAGS) $(MINGW_EXTRA_LDFLAGS)
libvirt_la_BUILT_LIBADD += ../gnulib/lib/libgnu.la
libvirt_la_LIBADD += $(LIBXML_LIBS) \
$(LIBPCAP_LIBS) $(LIBNL_LIBS) \
$(DRIVER_MODULE_LIBS) \
$(CYGWIN_EXTRA_LIBADD)
-libvirt_la_CFLAGS = $(COVERAGE_CFLAGS) -DIN_LIBVIRT
+libvirt_la_CFLAGS = -DIN_LIBVIRT $(AM_CFLAGS)
# Because we specify libvirt_la_DEPENDENCIES for $(LIBVIRT_SYMBOL_FILE), we
# lose automake's automatic dependencies on an appropriate subset of
# $(libvirt_la_LIBADD). But we were careful to create
@@ -1025,8 +1030,8 @@ test_LDFLAGS = \
# Just like the above, but with a slightly different set of public symbols.
libvirt_test_la_SOURCES = $(libvirt_la_SOURCES)
libvirt_test_la_LIBADD = $(libvirt_la_LIBADD)
-libvirt_test_la_LDFLAGS = $(test_LDFLAGS)
-libvirt_test_la_CFLAGS = $(COVERAGE_CFLAGS)
+libvirt_test_la_LDFLAGS = $(test_LDFLAGS) $(AM_LDFLAGS)
+libvirt_test_la_CFLAGS = $(AM_CFLAGS)
libexec_PROGRAMS =
@@ -1036,9 +1041,9 @@ if WITH_LIBVIRTD
libexec_PROGRAMS += libvirt_parthelper
libvirt_parthelper_SOURCES = $(STORAGE_HELPER_DISK_SOURCES)
-libvirt_parthelper_LDFLAGS = $(WARN_LDFLAGS) $(COVERAGE_LDFLAGS)
+libvirt_parthelper_LDFLAGS = $(WARN_LDFLAGS) $(AM_LDFLAGS)
libvirt_parthelper_LDADD = $(LIBPARTED_LIBS)
-libvirt_parthelper_CFLAGS = $(LIBPARTED_CFLAGS)
+libvirt_parthelper_CFLAGS = $(LIBPARTED_CFLAGS) $(AM_CFLAGS)
endif
endif
EXTRA_DIST += $(STORAGE_HELPER_DISK_SOURCES)
@@ -1056,7 +1061,7 @@ libvirt_lxc_SOURCES = \
$(DOMAIN_CONF_SOURCES) \
$(CPU_CONF_SOURCES) \
$(NWFILTER_PARAM_CONF_SOURCES)
-libvirt_lxc_LDFLAGS = $(WARN_CFLAGS) $(COVERAGE_LDFLAGS)
+libvirt_lxc_LDFLAGS = $(WARN_CFLAGS) $(AM_LDFLAGS)
libvirt_lxc_LDADD = $(CAPNG_LIBS) $(YAJL_LIBS) \
$(LIBXML_LIBS) $(NUMACTL_LIBS) $(LIB_PTHREAD) \
$(LIBNL_LIBS) ../gnulib/lib/libgnu.la
@@ -1065,7 +1070,8 @@ libvirt_lxc_CFLAGS = \
$(NUMACTL_CFLAGS) \
$(CAPNG_CFLAGS) \
$(YAJL_CFLAGS) \
- -I@top_srcdir@/src/conf
+ -I@top_srcdir@/src/conf \
+ $(AM_CFLAGS)
endif
endif
EXTRA_DIST += $(LXC_CONTROLLER_SOURCES)
@@ -1076,7 +1082,7 @@ libexec_PROGRAMS += virt-aa-helper
virt_aa_helper_SOURCES = $(SECURITY_DRIVER_APPARMOR_HELPER_SOURCES)
-virt_aa_helper_LDFLAGS = $(WARN_LDFLAGS)
+virt_aa_helper_LDFLAGS = $(WARN_LDFLAGS) $(AM_LDFLAGS)
virt_aa_helper_LDADD = \
$(LIBXML_LIBS) \
libvirt_conf.la \
@@ -1084,7 +1090,8 @@ virt_aa_helper_LDADD = \
../gnulib/lib/libgnu.la
virt_aa_helper_CFLAGS = \
-I@top_srcdir@/src/conf \
- -I@top_srcdir@/src/security
+ -I@top_srcdir@/src/security \
+ $(AM_CFLAGS)
endif
endif
EXTRA_DIST += $(SECURITY_DRIVER_APPARMOR_HELPER_SOURCES)
diff --git a/tests/.gitignore b/tests/.gitignore
index 387a924..3f32939 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -23,8 +23,6 @@ statstest
qparamtest
seclabeltest
eventtest
-*.gcda
-*.gcno
*.exe
object-locking
object-locking.cmi
--
1.7.0.1
14 years, 5 months
[libvirt] [PATCH 0/2] Add multiIQN XML dump output
by David Allan
The first of these two patches adds XML output for multi-IQN iSCSI pools. The second makes the rng consistent with the existing code and adds regression tests. My RelaxNG skills are rusty, so I would much appreciate a careful review of the rng change.
Dave
David Allan (2):
Add multiiqn XML dump
Add multiIQN tests
docs/schemas/storagepool.rng | 16 ++++++++------
src/conf/storage_conf.c | 7 ++++++
tests/storagepoolxml2xmlin/pool-iscsi-multiiqn.xml | 22 ++++++++++++++++++++
.../storagepoolxml2xmlout/pool-iscsi-multiiqn.xml | 22 ++++++++++++++++++++
tests/storagepoolxml2xmltest.c | 1 +
5 files changed, 61 insertions(+), 7 deletions(-)
create mode 100644 tests/storagepoolxml2xmlin/pool-iscsi-multiiqn.xml
create mode 100644 tests/storagepoolxml2xmlout/pool-iscsi-multiiqn.xml
14 years, 5 months
[libvirt] [PATCH] virsh: add the volume commands to the virsh man page
by Justin Clift
This patch also includes the new vol-pool command.
---
tools/virsh.pod | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 105 insertions(+), 0 deletions(-)
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 08e361d..3b0cf16 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -755,6 +755,111 @@ Returns the UUID of the named I<pool>.
=back
+=head1 VOLUME COMMANDS
+
+=item B<vol-create> I<pool-or-uuid> I<FILE>
+
+Create a volume from an XML <file>.
+I<pool-or-uuid> is the name or UUID of the storage pool to create the volume in.
+I<FILE> is the XML <file> with the volume definition. An easy way to create the
+XML <file> is to use the B<vol-dumpxml> command to obtain the definition of a
+pre-existing volume.
+
+B<Example>
+
+ virsh vol-dumpxml --pool storagepool1 appvolume1 > newvolume.xml
+ edit newvolume.xml
+ virsh vol-create differentstoragepool newvolume.xml
+
+=item B<vol-create-from> I<pool-or-uuid> I<FILE> [optional I<--inputpool>
+I<pool-or-uuid>] I<vol-name-or-key-or-path>
+
+Create a volume, using another volume as input.
+I<pool-or-uuid> is the name or UUID of the storage pool to create the volume in.
+I<FILE> is the XML <file> with the volume definition.
+I<--inputpool> I<pool-or-uuid> is the name or uuid of the storage pool the
+source volume is in.
+I<vol-name-or-key-or-path> is the name or key or path of the source volume.
+
+=item B<vol-create-as> I<pool-or-uuid> I<name> I<capacity> optional
+I<--allocation> I<size> I<--format> I<string> I<--snapshot-source-vol>
+I<vol-name-or-key-or-path> I<--snapshot-source-format> I<string>
+
+Create a volume from a set of arguments.
+I<pool-or-uuid> is the name or UUID of the storage pool to create the volume
+in.
+I<name> is the name of the new volume.
+I<capacity> is the size of the volume to be created, with optional k, M, G, or
+T suffix.
+I<--allocation> I<size> is the initial size to be allocated in the volume, with
+optional k, M, G, or T suffix.
+I<--format> I<string> is used in file based storage pools to specify the volume
+file format to use; raw, bochs, qcow, qcow2, vmdk.
+I<--snapshot-source-vol> I<vol-name-or-key-or-path> is the source backing
+volume to be used if taking a snapshot of an existing volume.
+I<--snapshot-source-format> I<string> is the format of the snapshot backing volume;
+raw, bochs, qcow, qcow2, vmdk.
+
+=item B<vol-clone> [optional I<--pool> I<pool-or-uuid>] I<vol-name-or-key-or-path> I<name>
+
+Clone an existing volume. Less powerful, but easier to type, version of
+B<vol-create-from>.
+I<--pool> I<pool-or-uuid> is the name or UUID of the storage pool to create the volume in.
+I<vol-name-or-key-or-path> is the name or key or path of the source volume.
+I<name> is the name of the new volume.
+
+=item B<vol-delete> [optional I<--pool> I<pool-or-uuid>] I<vol-name-or-key-or-path>
+
+Delete a given volume.
+I<--pool> I<pool-or-uuid> is the name or UUID of the storage pool the volume is in.
+I<vol-name-or-key-or-path> is the name or key or path of the volume to delete.
+
+=item B<vol-wipe> [optional I<--pool> I<pool-or-uuid>] I<vol-name-or-key-or-path>
+
+Wipe a volume, ensure data previously on the volume is not accessible to future reads.
+I<--pool> I<pool-or-uuid> is the name or UUID of the storage pool the volume is in.
+I<vol-name-or-key-or-path> is the name or key or path of the volume to wipe.
+
+=item B<vol-dumpxml> [optional I<--pool> I<pool-or-uuid>] I<vol-name-or-key-or-path>
+
+Output the volume information as an XML dump to stdout.
+I<--pool> I<pool-or-uuid> is the name or UUID of the storage pool the volume is in.
+I<vol-name-or-key-or-path> is the name or key or path of the volume to output the XML of.
+
+=item B<vol-info> [optional I<--pool> I<pool-or-uuid>] I<vol-name-or-key-or-path>
+
+Returns basic information about the given storage volume.
+I<--pool> I<pool-or-uuid> is the name or UUID of the storage pool the volume is in.
+I<vol-name-or-key-or-path> is the name or key or path of the volume to return information for.
+
+=item B<vol-list> I<--pool> I<pool-or-uuid>
+
+Return the list of volumes in the given storage pool.
+I<--pool> I<pool-or-uuid> is the name or UUID of the storage pool.
+
+=item B<vol-pool> I<vol-key-or-path>
+
+Return the pool for a given volume.
+I<vol-key-or-path> is the key or path of the volume to return the pool name for.
+
+=item B<vol-path> [optional I<--pool> I<pool-or-uuid>] I<vol-name-or-key>
+
+Return the path for a given volume.
+I<--pool> I<pool-or-uuid> is the name or UUID of the storage pool the volume is in.
+I<vol-name-or-key> is the name or key of the volume to return the path for.
+
+=item B<vol-name> I<vol-key-or-path>
+
+Return the name for a given volume.
+I<vol-key-or-path> is the key or path of the volume to return the name for.
+
+=item B<vol-key> I<vol-uuid>
+
+Return the volume key for a given volume UUID.
+I<vol-uuid> is the UUID of the volume to return the volume key for.
+
+=back
+
=head1 SECRET COMMMANDS
The following commands manipulate "secrets" (e.g. passwords, passphrases and
--
1.7.0.1
14 years, 5 months
[libvirt] [PATCH] virsh: fixed trivial comment and debug message in vshCommandOptVolBy function
by Justin Clift
---
tools/virsh.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index e444501..2e8cbec 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -9411,17 +9411,19 @@ vshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd,
if (name)
*name = n;
- /* try it by PATH */
+ /* try it by name */
if (pool && (flag & VSH_BYNAME)) {
- vshDebug(ctl, 5, "%s: <%s> trying as vol UUID\n",
+ vshDebug(ctl, 5, "%s: <%s> trying as vol name\n",
cmd->def->name, optname);
vol = virStorageVolLookupByName(pool, n);
}
+ /* try it by key */
if (vol == NULL && (flag & VSH_BYUUID)) {
vshDebug(ctl, 5, "%s: <%s> trying as vol key\n",
cmd->def->name, optname);
vol = virStorageVolLookupByKey(ctl->conn, n);
}
+ /* try it by path */
if (vol == NULL && (flag & VSH_BYUUID)) {
vshDebug(ctl, 5, "%s: <%s> trying as vol path\n",
cmd->def->name, optname);
--
1.7.0.1
14 years, 5 months
[libvirt] [PATCH] virsh: remove xen reference in header comment v2
by Justin Clift
With libvirt and virsh now being used for much more than Xen, this
patch removes the outdated reference to Xen in the file header.
---
Also changed the commit message to be all lower case, as previously
mentioned by Eric. ;)
tools/virsh.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 1279f41..e444501 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1,5 +1,5 @@
/*
- * virsh.c: a Xen shell used to exercise the libvirt API
+ * virsh.c: a shell to exercise the libvirt API
*
* Copyright (C) 2005, 2007-2010 Red Hat, Inc.
*
--
1.7.0.1
14 years, 5 months
[libvirt] [PATCH] esx: Add proxy query parameter
by Matthias Bolte
Allow to specify a proxy to be used by libcurl.
---
docs/drvesx.html.in | 20 ++++++++++++++++-
src/esx/esx_driver.c | 12 +++++++---
src/esx/esx_util.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/esx/esx_util.h | 4 +++
src/esx/esx_vi.c | 17 ++++++++++++--
src/esx/esx_vi.h | 4 ++-
6 files changed, 105 insertions(+), 9 deletions(-)
diff --git a/docs/drvesx.html.in b/docs/drvesx.html.in
index d454904..3c48c77 100644
--- a/docs/drvesx.html.in
+++ b/docs/drvesx.html.in
@@ -116,7 +116,25 @@ type://[username@]hostname[:port]/[?extraparameters]
If set to 1, the driver answers all
<a href="#questions">questions</a> with the default answer.
If set to 0, questions are reported as errors. The default
- value it 0.
+ value it 0. <span class="since">Since 0.7.5</span>.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <code>proxy</code>
+ </td>
+ <td>
+ <code>[type://]hostname[:port]</code>
+ </td>
+ <td>
+ Allows to specify a proxy for HTTP and HTTPS communication.
+ <span class="since">Since 0.8.2</span>.
+ The optional <code>type</code> part may be one of:
+ <code>http</code>, <code>socks</code>, <code>socks4</code>,
+ <code>socks4a</code> or <code>socks5</code>. The default is
+ <code>http</code> and <code>socks</code> is synonymous for
+ <code>socks5</code>. The optional <code>port</code> allows to
+ override the default port 1080.
</td>
</tr>
</table>
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 0c12a31..3854f85 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -279,7 +279,7 @@ esxCapsInit(esxPrivate *priv)
/*
- * URI format: {esx|gsx}://[<user>@]<server>[:<port>]/[<query parameter> ...]
+ * URI format: {esx|gsx}://[<username>@]<hostname>[:<port>]/[<query parameter> ...]
*
* If no port is specified the default port is set dependent on the scheme and
* transport parameter:
@@ -293,6 +293,7 @@ esxCapsInit(esxPrivate *priv)
* - vcenter={<vcenter>|*}
* - no_verify={0|1}
* - auto_answer={0|1}
+ * - proxy=[{http|socks|socks4|socks4a|socks5}://]<hostname>[:<port>]
*
* If no transport parameter is specified https is used.
*
@@ -308,6 +309,10 @@ esxCapsInit(esxPrivate *priv)
* If the auto_answer parameter is set to 1, the driver will respond to all
* virtual machine questions with the default answer, otherwise virtual machine
* questions will be reported as errors. The default value it 0.
+ *
+ * The proxy parameter allows to specify a proxy for to be used by libcurl.
+ * The default for the optional <type> part is http and socks is synonymous for
+ * socks5. The optional <port> part allows to override the default port 1080.
*/
static virDrvOpenStatus
esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
@@ -421,7 +426,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
if (esxVI_Context_Alloc(&priv->host) < 0 ||
esxVI_Context_Connect(priv->host, url, hostIpAddress, username,
- password, parsedQuery->noVerify) < 0) {
+ password, parsedQuery) < 0) {
goto cleanup;
}
@@ -554,8 +559,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
}
if (esxVI_Context_Connect(priv->vCenter, url, vCenterIpAddress,
- username, password,
- parsedQuery->noVerify) < 0) {
+ username, password, parsedQuery) < 0) {
goto cleanup;
}
diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c
index dba9bc3..27c3a12 100644
--- a/src/esx/esx_util.c
+++ b/src/esx/esx_util.c
@@ -49,6 +49,7 @@ esxUtil_ParseQuery(esxUtil_ParsedQuery **parsedQuery, xmlURIPtr uri)
int i;
int noVerify;
int autoAnswer;
+ char *tmp;
if (parsedQuery == NULL || *parsedQuery != NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
@@ -120,6 +121,61 @@ esxUtil_ParseQuery(esxUtil_ParsedQuery **parsedQuery, xmlURIPtr uri)
}
(*parsedQuery)->autoAnswer = autoAnswer != 0;
+ } else if (STRCASEEQ(queryParam->name, "proxy")) {
+ /* Expected format: [<type>://]<hostname>[:<port>] */
+ (*parsedQuery)->proxy = true;
+ (*parsedQuery)->proxy_type = CURLPROXY_HTTP;
+ VIR_FREE((*parsedQuery)->proxy_hostname);
+ (*parsedQuery)->proxy_port = 1080;
+
+ if ((tmp = STRSKIP(queryParam->value, "http://")) != NULL) {
+ (*parsedQuery)->proxy_type = CURLPROXY_HTTP;
+ } else if ((tmp = STRSKIP(queryParam->value, "socks://")) != NULL ||
+ (tmp = STRSKIP(queryParam->value, "socks5://")) != NULL) {
+ (*parsedQuery)->proxy_type = CURLPROXY_SOCKS5;
+ } else if ((tmp = STRSKIP(queryParam->value, "socks4://")) != NULL) {
+ (*parsedQuery)->proxy_type = CURLPROXY_SOCKS4;
+ } else if ((tmp = STRSKIP(queryParam->value, "socks4a://")) != NULL) {
+ (*parsedQuery)->proxy_type = CURLPROXY_SOCKS4A;
+ } else if ((tmp = strstr(queryParam->value, "://")) != NULL) {
+ *tmp = '\0';
+
+ ESX_ERROR(VIR_ERR_INVALID_ARG,
+ _("Query parameter 'proxy' contains unexpected "
+ "type '%s' (should be (http|socks(|4|4a|5))"),
+ queryParam->value);
+ goto cleanup;
+ } else {
+ tmp = queryParam->value;
+ }
+
+ (*parsedQuery)->proxy_hostname = strdup(tmp);
+
+ if ((*parsedQuery)->proxy_hostname == NULL) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ if ((tmp = strchr((*parsedQuery)->proxy_hostname, ':')) != NULL) {
+ if (tmp == (*parsedQuery)->proxy_hostname) {
+ ESX_ERROR(VIR_ERR_INVALID_ARG, "%s",
+ _("Query parameter 'proxy' doesn't contain a "
+ "hostname"));
+ goto cleanup;
+ }
+
+ *tmp++ = '\0';
+
+ if (virStrToLong_i(tmp, NULL, 10,
+ &(*parsedQuery)->proxy_port) < 0 ||
+ (*parsedQuery)->proxy_port < 1 ||
+ (*parsedQuery)->proxy_port > 65535) {
+ ESX_ERROR(VIR_ERR_INVALID_ARG,
+ _("Query parameter 'proxy' has unexpected port"
+ "value '%s' (should be [1..65535])"), tmp);
+ goto cleanup;
+ }
+ }
} else {
VIR_WARN("Ignoring unexpected query parameter '%s'",
queryParam->name);
@@ -161,6 +217,7 @@ esxUtil_FreeParsedQuery(esxUtil_ParsedQuery **parsedQuery)
VIR_FREE((*parsedQuery)->transport);
VIR_FREE((*parsedQuery)->vCenter);
+ VIR_FREE((*parsedQuery)->proxy_hostname);
VIR_FREE(*parsedQuery);
}
diff --git a/src/esx/esx_util.h b/src/esx/esx_util.h
index ae6e38b..26c456d 100644
--- a/src/esx/esx_util.h
+++ b/src/esx/esx_util.h
@@ -36,6 +36,10 @@ struct _esxUtil_ParsedQuery {
char *vCenter;
bool noVerify;
bool autoAnswer;
+ bool proxy;
+ int proxy_type;
+ char *proxy_hostname;
+ int proxy_port;
};
int esxUtil_ParseQuery(esxUtil_ParsedQuery **parsedQuery, xmlURIPtr uri);
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 4332f2b..8c43d67 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -277,7 +277,7 @@ esxVI_CURL_Perform(esxVI_Context *ctx, const char *url)
int
esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
const char *ipAddress, const char *username,
- const char *password, bool noVerify)
+ const char *password, esxUtil_ParsedQuery *parsedQuery)
{
int result = -1;
esxVI_String *propertyNameList = NULL;
@@ -328,8 +328,10 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
curl_easy_setopt(ctx->curl_handle, CURLOPT_USERAGENT, "libvirt-esx");
curl_easy_setopt(ctx->curl_handle, CURLOPT_HEADER, 0);
curl_easy_setopt(ctx->curl_handle, CURLOPT_FOLLOWLOCATION, 0);
- curl_easy_setopt(ctx->curl_handle, CURLOPT_SSL_VERIFYPEER, noVerify ? 0 : 1);
- curl_easy_setopt(ctx->curl_handle, CURLOPT_SSL_VERIFYHOST, noVerify ? 0 : 2);
+ curl_easy_setopt(ctx->curl_handle, CURLOPT_SSL_VERIFYPEER,
+ parsedQuery->noVerify ? 0 : 1);
+ curl_easy_setopt(ctx->curl_handle, CURLOPT_SSL_VERIFYHOST,
+ parsedQuery->noVerify ? 0 : 2);
curl_easy_setopt(ctx->curl_handle, CURLOPT_COOKIEFILE, "");
curl_easy_setopt(ctx->curl_handle, CURLOPT_HTTPHEADER, ctx->curl_headers);
curl_easy_setopt(ctx->curl_handle, CURLOPT_READFUNCTION,
@@ -343,6 +345,15 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
curl_easy_setopt(ctx->curl_handle, CURLOPT_VERBOSE, 1);
#endif
+ if (parsedQuery->proxy) {
+ curl_easy_setopt(ctx->curl_handle, CURLOPT_PROXY,
+ parsedQuery->proxy_hostname);
+ curl_easy_setopt(ctx->curl_handle, CURLOPT_PROXYTYPE,
+ parsedQuery->proxy_type);
+ curl_easy_setopt(ctx->curl_handle, CURLOPT_PROXYPORT,
+ parsedQuery->proxy_port);
+ }
+
if (virMutexInit(&ctx->curl_lock) < 0) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not initialize CURL mutex"));
diff --git a/src/esx/esx_vi.h b/src/esx/esx_vi.h
index 521be0c..f5e89e9 100644
--- a/src/esx/esx_vi.h
+++ b/src/esx/esx_vi.h
@@ -31,6 +31,7 @@
# include "virterror_internal.h"
# include "datatypes.h"
# include "esx_vi_types.h"
+# include "esx_util.h"
@@ -161,7 +162,8 @@ int esxVI_Context_Alloc(esxVI_Context **ctx);
void esxVI_Context_Free(esxVI_Context **ctx);
int esxVI_Context_Connect(esxVI_Context *ctx, const char *ipAddress,
const char *url, const char *username,
- const char *password, bool noVerify);
+ const char *password,
+ esxUtil_ParsedQuery *parsedQuery);
int esxVI_Context_DownloadFile(esxVI_Context *ctx, const char *url,
char **content);
int esxVI_Context_UploadFile(esxVI_Context *ctx, const char *url,
--
1.7.0.4
14 years, 5 months
[libvirt] [PATCH] esx: Refactor esxUtil_ParseQuery's parameter handling
by Matthias Bolte
Pass a struct containing the parameters instead of passing each
one individually. This make future extensions a bit simpler.
---
src/esx/esx_driver.c | 44 ++++++++++-----------
src/esx/esx_util.c | 100 +++++++++++++++++++++++++-------------------------
src/esx/esx_util.h | 15 ++++++-
src/esx/esx_vi.c | 2 +-
src/esx/esx_vi.h | 2 +-
5 files changed, 86 insertions(+), 77 deletions(-)
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 7257d6a..0c12a31 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -314,12 +314,11 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
{
virDrvOpenStatus result = VIR_DRV_OPEN_ERROR;
esxPrivate *priv = NULL;
+ esxUtil_ParsedQuery *parsedQuery = NULL;
char hostIpAddress[NI_MAXHOST] = "";
char vCenterIpAddress[NI_MAXHOST] = "";
char *url = NULL;
char *vCenter = NULL;
- int noVerify = 0; // boolean
- int autoAnswer = 0; // boolean
char *username = NULL;
char *password = NULL;
esxVI_String *propertyNameList = NULL;
@@ -349,21 +348,20 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
goto cleanup;
}
+ if (esxUtil_ParseQuery(&parsedQuery, conn->uri) < 0) {
+ goto cleanup;
+ }
+
+ priv->transport = parsedQuery->transport;
+ parsedQuery->transport = NULL;
+
priv->maxVcpus = -1;
priv->supportsVMotion = esxVI_Boolean_Undefined;
priv->supportsLongMode = esxVI_Boolean_Undefined;
- priv->autoAnswer = esxVI_Boolean_False;
+ priv->autoAnswer = parsedQuery->autoAnswer ? esxVI_Boolean_True
+ : esxVI_Boolean_False;
priv->usedCpuTimeCounterId = -1;
- if (esxUtil_ParseQuery(conn->uri, &priv->transport, &vCenter, &noVerify,
- &autoAnswer) < 0) {
- goto cleanup;
- }
-
- if (autoAnswer) {
- priv->autoAnswer = esxVI_Boolean_True;
- }
-
/*
* Set the port dependent on the transport protocol if no port is
* specified. This allows us to rely on the port parameter being
@@ -414,10 +412,6 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
}
}
- if (esxVI_Context_Alloc(&priv->host) < 0) {
- goto cleanup;
- }
-
password = virRequestPassword(auth, username, conn->uri->server);
if (password == NULL) {
@@ -425,8 +419,9 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
goto cleanup;
}
- if (esxVI_Context_Connect(priv->host, url, hostIpAddress, username,
- password, noVerify) < 0) {
+ if (esxVI_Context_Alloc(&priv->host) < 0 ||
+ esxVI_Context_Connect(priv->host, url, hostIpAddress, username,
+ password, parsedQuery->noVerify) < 0) {
goto cleanup;
}
@@ -559,7 +554,8 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
}
if (esxVI_Context_Connect(priv->vCenter, url, vCenterIpAddress,
- username, password, noVerify) < 0) {
+ username, password,
+ parsedQuery->noVerify) < 0) {
goto cleanup;
}
@@ -594,6 +590,8 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
VIR_FREE(priv);
}
+
+ esxUtil_FreeParsedQuery(&parsedQuery);
VIR_FREE(url);
VIR_FREE(vCenter);
VIR_FREE(password);
@@ -2961,14 +2959,14 @@ esxDomainMigratePrepare(virConnectPtr dconn,
unsigned long resource ATTRIBUTE_UNUSED)
{
int result = -1;
- char *transport = NULL;
+ esxUtil_ParsedQuery *parsedQuery = NULL;
if (uri_in == NULL) {
- if (esxUtil_ParseQuery(dconn->uri, &transport, NULL, NULL, NULL) < 0) {
+ if (esxUtil_ParseQuery(&parsedQuery, dconn->uri) < 0) {
return -1;
}
- if (virAsprintf(uri_out, "%s://%s:%d/sdk", transport,
+ if (virAsprintf(uri_out, "%s://%s:%d/sdk", parsedQuery->transport,
dconn->uri->server, dconn->uri->port) < 0) {
virReportOOMError();
goto cleanup;
@@ -2978,7 +2976,7 @@ esxDomainMigratePrepare(virConnectPtr dconn,
result = 0;
cleanup:
- VIR_FREE(transport);
+ esxUtil_FreeParsedQuery(&parsedQuery);
return result;
}
diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c
index 1ffcc22..dba9bc3 100644
--- a/src/esx/esx_util.c
+++ b/src/esx/esx_util.c
@@ -39,29 +39,25 @@
#define VIR_FROM_THIS VIR_FROM_ESX
+
int
-esxUtil_ParseQuery(xmlURIPtr uri, char **transport, char **vCenter,
- int *noVerify, int *autoAnswer)
+esxUtil_ParseQuery(esxUtil_ParsedQuery **parsedQuery, xmlURIPtr uri)
{
int result = -1;
- int i;
struct qparam_set *queryParamSet = NULL;
struct qparam *queryParam = NULL;
+ int i;
+ int noVerify;
+ int autoAnswer;
- if (transport != NULL) {
- *transport = NULL;
- }
-
- if (vCenter != NULL) {
- *vCenter = NULL;
- }
-
- if (noVerify != NULL) {
- *noVerify = 0;
+ if (parsedQuery == NULL || *parsedQuery != NULL) {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
+ return -1;
}
- if (autoAnswer != NULL) {
- *autoAnswer = 0;
+ if (VIR_ALLOC(*parsedQuery) < 0) {
+ virReportOOMError();
+ return -1;
}
#ifdef HAVE_XMLURI_QUERY_RAW
@@ -71,75 +67,69 @@ esxUtil_ParseQuery(xmlURIPtr uri, char **transport, char **vCenter,
#endif
if (queryParamSet == NULL) {
- return -1;
+ goto cleanup;
}
for (i = 0; i < queryParamSet->n; i++) {
queryParam = &queryParamSet->p[i];
if (STRCASEEQ(queryParam->name, "transport")) {
- if (transport == NULL) {
- continue;
- }
+ VIR_FREE((*parsedQuery)->transport);
- *transport = strdup(queryParam->value);
+ (*parsedQuery)->transport = strdup(queryParam->value);
- if (*transport == NULL) {
+ if ((*parsedQuery)->transport == NULL) {
virReportOOMError();
goto cleanup;
}
- if (STRNEQ(*transport, "http") && STRNEQ(*transport, "https")) {
+ if (STRNEQ((*parsedQuery)->transport, "http") &&
+ STRNEQ((*parsedQuery)->transport, "https")) {
ESX_ERROR(VIR_ERR_INVALID_ARG,
_("Query parameter 'transport' has unexpected value "
- "'%s' (should be http|https)"), *transport);
+ "'%s' (should be http|https)"),
+ (*parsedQuery)->transport);
goto cleanup;
}
} else if (STRCASEEQ(queryParam->name, "vcenter")) {
- if (vCenter == NULL) {
- continue;
- }
+ VIR_FREE((*parsedQuery)->vCenter);
- *vCenter = strdup(queryParam->value);
+ (*parsedQuery)->vCenter = strdup(queryParam->value);
- if (*vCenter == NULL) {
+ if ((*parsedQuery)->vCenter == NULL) {
virReportOOMError();
goto cleanup;
}
} else if (STRCASEEQ(queryParam->name, "no_verify")) {
- if (noVerify == NULL) {
- continue;
- }
-
- if (virStrToLong_i(queryParam->value, NULL, 10, noVerify) < 0 ||
- (*noVerify != 0 && *noVerify != 1)) {
+ if (virStrToLong_i(queryParam->value, NULL, 10, &noVerify) < 0 ||
+ (noVerify != 0 && noVerify != 1)) {
ESX_ERROR(VIR_ERR_INVALID_ARG,
_("Query parameter 'no_verify' has unexpected value "
"'%s' (should be 0 or 1)"), queryParam->value);
goto cleanup;
}
- } else if (STRCASEEQ(queryParam->name, "auto_answer")) {
- if (autoAnswer == NULL) {
- continue;
- }
- if (virStrToLong_i(queryParam->value, NULL, 10, autoAnswer) < 0 ||
- (*autoAnswer != 0 && *autoAnswer != 1)) {
+ (*parsedQuery)->noVerify = noVerify != 0;
+ } else if (STRCASEEQ(queryParam->name, "auto_answer")) {
+ if (virStrToLong_i(queryParam->value, NULL, 10, &autoAnswer) < 0 ||
+ (autoAnswer != 0 && autoAnswer != 1)) {
ESX_ERROR(VIR_ERR_INVALID_ARG,
_("Query parameter 'auto_answer' has unexpected "
"value '%s' (should be 0 or 1)"), queryParam->value);
goto cleanup;
}
+
+ (*parsedQuery)->autoAnswer = autoAnswer != 0;
} else {
VIR_WARN("Ignoring unexpected query parameter '%s'",
queryParam->name);
}
}
- if (transport != NULL && *transport == NULL) {
- *transport = strdup("https");
+ if ((*parsedQuery)->transport == NULL) {
+ (*parsedQuery)->transport = strdup("https");
- if (*transport == NULL) {
+ if ((*parsedQuery)->transport == NULL) {
virReportOOMError();
goto cleanup;
}
@@ -149,13 +139,7 @@ esxUtil_ParseQuery(xmlURIPtr uri, char **transport, char **vCenter,
cleanup:
if (result < 0) {
- if (transport != NULL) {
- VIR_FREE(*transport);
- }
-
- if (vCenter != NULL) {
- VIR_FREE(*vCenter);
- }
+ esxUtil_FreeParsedQuery(parsedQuery);
}
if (queryParamSet != NULL) {
@@ -167,6 +151,22 @@ esxUtil_ParseQuery(xmlURIPtr uri, char **transport, char **vCenter,
+
+void
+esxUtil_FreeParsedQuery(esxUtil_ParsedQuery **parsedQuery)
+{
+ if (parsedQuery == NULL || *parsedQuery == NULL) {
+ return;
+ }
+
+ VIR_FREE((*parsedQuery)->transport);
+ VIR_FREE((*parsedQuery)->vCenter);
+
+ VIR_FREE(*parsedQuery);
+}
+
+
+
int
esxUtil_ParseVirtualMachineIDString(const char *id_string, int *id)
{
diff --git a/src/esx/esx_util.h b/src/esx/esx_util.h
index 5298184..ae6e38b 100644
--- a/src/esx/esx_util.h
+++ b/src/esx/esx_util.h
@@ -23,13 +23,24 @@
#ifndef __ESX_UTIL_H__
# define __ESX_UTIL_H__
+# include <stdbool.h>
# include <libxml/uri.h>
# include "internal.h"
# include "conf.h"
-int esxUtil_ParseQuery(xmlURIPtr uri, char **transport, char **vCenter,
- int *noVerify, int *autoAnswer);
+typedef struct _esxUtil_ParsedQuery esxUtil_ParsedQuery;
+
+struct _esxUtil_ParsedQuery {
+ char *transport;
+ char *vCenter;
+ bool noVerify;
+ bool autoAnswer;
+};
+
+int esxUtil_ParseQuery(esxUtil_ParsedQuery **parsedQuery, xmlURIPtr uri);
+
+void esxUtil_FreeParsedQuery(esxUtil_ParsedQuery **parsedQuery);
int esxUtil_ParseVirtualMachineIDString(const char *id_string, int *id);
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index c535dbb..4332f2b 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -277,7 +277,7 @@ esxVI_CURL_Perform(esxVI_Context *ctx, const char *url)
int
esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
const char *ipAddress, const char *username,
- const char *password, int noVerify)
+ const char *password, bool noVerify)
{
int result = -1;
esxVI_String *propertyNameList = NULL;
diff --git a/src/esx/esx_vi.h b/src/esx/esx_vi.h
index e2687c4..521be0c 100644
--- a/src/esx/esx_vi.h
+++ b/src/esx/esx_vi.h
@@ -161,7 +161,7 @@ int esxVI_Context_Alloc(esxVI_Context **ctx);
void esxVI_Context_Free(esxVI_Context **ctx);
int esxVI_Context_Connect(esxVI_Context *ctx, const char *ipAddress,
const char *url, const char *username,
- const char *password, int noVerify);
+ const char *password, bool noVerify);
int esxVI_Context_DownloadFile(esxVI_Context *ctx, const char *url,
char **content);
int esxVI_Context_UploadFile(esxVI_Context *ctx, const char *url,
--
1.7.0.4
14 years, 5 months
[libvirt] [PATCH] virsh: add pool support to vol-key command v2
by Justin Clift
Presently the vol-key command only supports being provided with
a volume path.
This patch adds support for providing it with a pool and volume
identifier pair as well.
virsh # vol-key --pool <pool-name-or-uuid> <vol-name-or-path>
---
This is a clean patch against current git head, plus avoids a
potential memory leak in the previous code.
Also unlike the previous patch, this one doesn't change the
help text for the vol-path nor vol-name commands. A separate
patch will be provided to update their help text.
tools/virsh.c | 6 +++---
tools/virsh.pod | 7 ++++---
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 546e247..db8b28d 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -6032,12 +6032,13 @@ cmdVolPool(vshControl *ctl, const vshCmd *cmd)
* "vol-key" command
*/
static const vshCmdInfo info_vol_key[] = {
- {"help", N_("convert a vol UUID to vol key")},
+ {"help", N_("returns the volume key for a given volume name or path")},
{"desc", ""},
{NULL, NULL}
};
static const vshCmdOptDef opts_vol_key[] = {
+ {"pool", VSH_OT_STRING, 0, N_("pool name or uuid")},
{"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("vol uuid")},
{NULL, 0, 0, NULL}
};
@@ -6050,8 +6051,7 @@ cmdVolKey(vshControl *ctl, const vshCmd *cmd)
if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
return FALSE;
- if (!(vol = vshCommandOptVolBy(ctl, cmd, "vol", "pool", NULL,
- VSH_BYUUID)))
+ if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
return FALSE;
vshPrint(ctl, "%s\n", virStorageVolGetKey(vol));
diff --git a/tools/virsh.pod b/tools/virsh.pod
index b54003c..f6d7808 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -855,10 +855,11 @@ I<vol-name-or-key> is the name or key of the volume to return the path for.
Return the name for a given volume.
I<vol-key-or-path> is the key or path of the volume to return the name for.
-=item B<vol-key> I<vol-uuid>
+=item B<vol-key> [optional I<--pool> I<pool-or-uuid>] I<vol-name-or-path>
-Return the volume key for a given volume UUID.
-I<vol-uuid> is the UUID of the volume to return the volume key for.
+Return the volume key for a given volume.
+I<--pool> I<pool-or-uuid> is the name or UUID of the storage pool the volume is in.
+I<vol-name-or-path> is the name or path of the volume to return the volume key for.
=back
--
1.7.0.1
14 years, 5 months
[libvirt] [PATCH] virsh: add new vol-pool command
by Justin Clift
This patch adds a new "vol-pool" command to virsh, to round out the
identifier conversion functions for volumes in virsh. Now it is
possible to work with volumes when starting from just a volume key
or volume path.
---
tools/virsh.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 1279f41..b45cf38 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -5975,6 +5975,53 @@ cmdVolName(vshControl *ctl, const vshCmd *cmd)
}
+/*
+ * "vol-pool" command
+ */
+static const vshCmdInfo info_vol_pool[] = {
+ {"help", N_("returns the storage pool for a given volume key or path")},
+ {"desc", ""},
+ {NULL, NULL}
+};
+
+static const vshCmdOptDef opts_vol_pool[] = {
+ {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("volume key or path")},
+ {NULL, 0, 0, NULL}
+};
+
+static int
+cmdVolPool(vshControl *ctl, const vshCmd *cmd)
+{
+ virStoragePoolPtr pool;
+ virStorageVolPtr vol;
+
+ /* Check the connection to libvirtd daemon is still working */
+ if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
+ return FALSE;
+
+ /* Use the supplied string to locate the volume */
+ if (!(vol = vshCommandOptVolBy(ctl, cmd, "vol", "pool", NULL,
+ VSH_BYUUID))) {
+ return FALSE;
+ }
+
+ /* Look up the parent storage pool for the volume */
+ pool = virStoragePoolLookupByVolume(vol);
+ if (pool == NULL) {
+ vshError(ctl, "%s", _("failed to get parent pool"));
+ virStorageVolFree(vol);
+ return FALSE;
+ }
+
+ /* Return the name of the parent storage pool */
+ vshPrint(ctl, "%s\n", virStoragePoolGetName(pool));
+
+ /* Cleanup */
+ virStorageVolFree(vol);
+ virStoragePoolFree(pool);
+ return TRUE;
+}
+
/*
* "vol-key" command
@@ -8837,6 +8884,7 @@ static const vshCmdDef commands[] = {
{"vol-dumpxml", cmdVolDumpXML, opts_vol_dumpxml, info_vol_dumpxml},
{"vol-info", cmdVolInfo, opts_vol_info, info_vol_info},
{"vol-list", cmdVolList, opts_vol_list, info_vol_list},
+ {"vol-pool", cmdVolPool, opts_vol_pool, info_vol_pool},
{"vol-path", cmdVolPath, opts_vol_path, info_vol_path},
{"vol-name", cmdVolName, opts_vol_name, info_vol_name},
{"vol-key", cmdVolKey, opts_vol_key, info_vol_key},
--
1.7.0.1
14 years, 5 months