[libvirt] [PATCH] qemu: check for json allocation failure
by Eric Blake
Detected by Coverity. Introduced in commit b1b5b51.
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONGetBlockInfo):
Avoid null dereference on OOM.
---
src/qemu/qemu_monitor_json.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 18d1c9f..cd8f1e5 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -1364,6 +1364,9 @@ int qemuMonitorJSONGetBlockInfo(qemuMonitorPtr mon,
virJSONValuePtr reply = NULL;
virJSONValuePtr devices;
+ if (!cmd)
+ return -1;
+
ret = qemuMonitorJSONCommand(mon, cmd, &reply);
if (ret == 0)
ret = qemuMonitorJSONCheckError(cmd, reply);
--
1.7.4.4
13 years, 1 month
[libvirt] [PATCH] virFDStream: close also given errfd (fd leak)
by Marc-André Lureau
In virFDStreamOpenFileInternal(), a errfd pipe is opened by
virCommandRunAsync() and given to virFDStreamOpenInternal().
It seems virFDStream should close errfd, just like the other
fd it is given.
This fixes screenshots leaking FDs:
http://bugzilla.redhat.com/show_bug.cgi?id=745761
---
src/fdstream.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/src/fdstream.c b/src/fdstream.c
index b60162c..841f979 100644
--- a/src/fdstream.c
+++ b/src/fdstream.c
@@ -268,6 +268,10 @@ virFDStreamClose(virStreamPtr st)
virCommandFree(fdst->cmd);
fdst->cmd = NULL;
}
+
+ if (VIR_CLOSE(fdst->errfd) < 0)
+ VIR_DEBUG("ignoring failed close on fd %d", fdst->errfd);
+
st->privateData = NULL;
if (fdst->dispatching) {
--
1.7.6.2
13 years, 1 month
[libvirt] [PATCH RESEND] command: avoid fd leak on failure
by Eric Blake
virCommandTransferFD promises that the fd is no longer owned by
the caller. Normally, we want the fd to remain open until the
child runs, but in error situations, we must close it earlier.
* src/util/command.c (virCommandTransferFD): Close fd now if we
can't track it to close later.
(virCommandKeepFD): Adjust helper to make this easier.
---
This leak can only happen on OOM or other extreme error conditions,
but ought to be plugged. When I originally posted this:
https://www.redhat.com/archives/libvir-list/2011-July/msg00674.html
DV was worried that callers might abuse things and use fd
even after this function closed it; but I proved to myself in
writing a (non-working) v2 that all callers were already safe,
and that this v1 was indeed a smaller solution.
src/util/command.c | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/util/command.c b/src/util/command.c
index 699ba2d..c3ce361 100644
--- a/src/util/command.c
+++ b/src/util/command.c
@@ -730,23 +730,26 @@ virCommandNewArgList(const char *binary, ...)
* closing it. FD must not be one of the three standard streams. If
* transfer is true, then fd will be closed in the parent after a call
* to Run/RunAsync/Free, otherwise caller is still responsible for fd.
+ * Returns true if a transferring caller should close FD now, and
+ * false if the transfer is successfully recorded.
*/
-static void
+static bool
virCommandKeepFD(virCommandPtr cmd, int fd, bool transfer)
{
if (!cmd)
- return;
+ return fd > STDERR_FILENO;
if (fd <= STDERR_FILENO || FD_SETSIZE <= fd) {
if (!cmd->has_error)
cmd->has_error = -1;
VIR_DEBUG("cannot preserve %d", fd);
- return;
+ return fd > STDERR_FILENO;
}
FD_SET(fd, &cmd->preserve);
if (transfer)
FD_SET(fd, &cmd->transfer);
+ return false;
}
/**
@@ -761,7 +764,7 @@ virCommandKeepFD(virCommandPtr cmd, int fd, bool transfer)
void
virCommandPreserveFD(virCommandPtr cmd, int fd)
{
- return virCommandKeepFD(cmd, fd, false);
+ virCommandKeepFD(cmd, fd, false);
}
/**
@@ -771,12 +774,14 @@ virCommandPreserveFD(virCommandPtr cmd, int fd)
*
* Transfer the specified file descriptor
* to the child, instead of closing it on exec.
- * Close the fd in the parent during Run/RunAsync/Free.
+ * The parent should no longer use fd, and the parent's copy will
+ * be automatically closed no later than during Run/RunAsync/Free.
*/
void
virCommandTransferFD(virCommandPtr cmd, int fd)
{
- return virCommandKeepFD(cmd, fd, true);
+ if (virCommandKeepFD(cmd, fd, true))
+ VIR_FORCE_CLOSE(fd);
}
--
1.7.4.4
13 years, 1 month
[libvirt] [PATCH RESEND] spec: mingw cleanups
by Eric Blake
* libvirt.spec.in (%configure): Drop unused %{one} macro.
* mingw32-libvirt.spec.in (%{rhel}): Compile ESX but not HyperV on
mingw build for RHEL.
(%build): Make configure honor spec conditionals. Reorder to
match libvirt.spec.
* autobuild.sh (mingw): Update list to match.
Suggested by Daniel P. Berrange.
---
No comment when buried in a thread, so I'll resend:
https://www.redhat.com/archives/libvir-list/2011-September/msg01072.html
autobuild.sh | 16 +++++++-----
libvirt.spec.in | 3 +-
mingw32-libvirt.spec.in | 58 ++++++++++++++++++++++++++++++++++++++++------
3 files changed, 60 insertions(+), 17 deletions(-)
diff --git a/autobuild.sh b/autobuild.sh
index 491f1b8..9853287 100755
--- a/autobuild.sh
+++ b/autobuild.sh
@@ -71,21 +71,23 @@ if [ -x /usr/bin/i686-pc-mingw32-gcc ]; then
--host=i686-pc-mingw32 \
--prefix="$AUTOBUILD_INSTALL_ROOT/i686-pc-mingw32/sys-root/mingw" \
--enable-compile-warnings=error \
- --without-sasl \
- --without-avahi \
- --without-polkit \
- --without-python \
--without-xen \
--without-qemu \
+ --without-openvz \
--without-lxc \
- --without-uml \
--without-vbox \
- --without-openvz \
+ --without-xenapi \
+ --without-uml \
+ --without-sasl \
+ --without-avahi \
+ --without-polkit \
+ --without-python \
+ --without-libvirtd \
--without-phyp \
+ --without-hyperv \
--without-netcf \
--without-audit \
--without-dtrace \
- --without-libvirtd
make
make install
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 7c63710..03bd7c7 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -47,7 +47,7 @@
%define with_libxl 0%{!?_without_libxl:%{server_drivers}}
%define with_vmware 0%{!?_without_vmware:%{server_drivers}}
-# Then the hypervisor drivers that talk a native remote protocol
+# Then the hypervisor drivers that talk via a native remote protocol
%define with_phyp 0%{!?_without_phyp:1}
%define with_esx 0%{!?_without_esx:1}
%define with_hyperv 0%{!?_without_hyperv:1}
@@ -711,7 +711,6 @@ of recent versions of Linux (and other OSes).
%{?_without_python} \
%{?_without_libvirtd} \
%{?_without_uml} \
- %{?_without_one} \
%{?_without_phyp} \
%{?_without_esx} \
%{?_without_hyperv} \
diff --git a/mingw32-libvirt.spec.in b/mingw32-libvirt.spec.in
index f651d11..57c67ae 100644
--- a/mingw32-libvirt.spec.in
+++ b/mingw32-libvirt.spec.in
@@ -5,6 +5,21 @@
%define __find_provides %{_mingw32_findprovides}
%define __debug_install_post %{_mingw32_debug_install_post}
+# The mingw build is client only. Set up defaults for hypervisor drivers
+# that talk via a native remote protocol, and for which prereq mingw
+# libraries exist.
+%define with_phyp 0%{!?_without_phyp:1}
+%define with_esx 0%{!?_without_esx:1}
+%define with_hyperv 0%{!?_without_hyperv:0} # missing libwsman
+%define with_xenapi 0%{!?_without_xenapi:1}
+
+# RHEL ships ESX but not PowerHypervisor, HyperV, or libxenserver (xenapi)
+%if 0%{?rhel}
+%define with_phyp 0
+%define with_xenapi 0
+%define with_hyperv 0
+%endif
+
Name: mingw32-libvirt
Version: @VERSION@
Release: 3%{?dist}%{?extra_release}
@@ -29,6 +44,13 @@ BuildRequires: pkgconfig
# Need native version for msgfmt
BuildRequires: gettext
+%if %{with_phyp}
+BuildRequires: mingw32-libssh2
+%endif
+%if %{with_esx}
+BuildRequires: mingw32-curl
+%endif
+
BuildArch: noarch
%{?_mingw32_debug_package}
@@ -42,23 +64,43 @@ MinGW Windows libvirt virtualization library.
%build
+%if ! %{with_phyp}
+%define _without_phyp --without-phyp
+%endif
+
+%if ! %{with_esx}
+%define _without_esx --without-esx
+%endif
+
+%if ! %{with_hyperv}
+%define _without_hyperv --without-hyperv
+%endif
+
+%if ! %{with_xenapi}
+%define _without_xenapi --without-xenapi
+%endif
+
# XXX enable SASL in future
%{_mingw32_configure} \
+ --without-xen \
+ --without-qemu \
+ --without-openvz \
+ --without-lxc \
+ --without-vbox \
+ %{?_without_xenapi} \
--without-sasl \
--without-avahi \
--without-polkit \
--without-python \
- --without-xen \
- --without-qemu \
- --without-lxc \
+ --without-libvirtd \
--without-uml \
- --without-vbox \
- --without-openvz \
- --without-phyp \
+ %{?_without_phyp} \
+ %{?_without_esx} \
+ %{?_without_hyperv} \
+ --without-vmware \
--without-netcf \
--without-audit \
- --without-dtrace \
- --without-libvirtd
+ --without-dtrace
make
--
1.7.4.4
13 years, 1 month
[libvirt] [PATCH] build: update to latest gnulib
by Eric Blake
358 changes; most probably have no impact on libvirt, but we
might as well stay current.
* .gnulib: Update to latest.
---
* .gnulib da1717b...2394a60 (358):
> atanl: Simplify for platforms where 'long double' == 'double'.
> acosl: Simplify for platforms where 'long double' == 'double'.
> asinl: Simplify for platforms where 'long double' == 'double'.
> tanl: Simplify for platforms where 'long double' == 'double'.
> cosl: Simplify for platforms where 'long double' == 'double'.
> sinl: Simplify for platforms where 'long double' == 'double'.
> logl: Simplify for platforms where 'long double' == 'double'.
> expl: Simplify for platforms where 'long double' == 'double'.
> sqrtl: Simplify for platforms where 'long double' == 'double'.
> ldexpl: Simplify for platforms where 'long double' == 'double'.
> ffsll: set correct witness
> printf-frexpl: Simplify for platforms where 'long double' == 'double'.
> frexpl: Simplify for platforms where 'long double' == 'double'.
> test-renameat: don't leave behind a temporary file
> rint: Determine RINT_LIBM correctly on AIX 7.
> mathfunc.m4: Refactor.
> rintl: Simplify for platforms where 'long double' == 'double'.
> roundl: Simplify for platforms where 'long double' == 'double'.
> truncl: Simplify for platforms where 'long double' == 'double'.
> ceill: Simplify for platforms where 'long double' == 'double'.
> floorl: Simplify for platforms where 'long double' == 'double'.
> rint: Fix ordering constraints.
> copysignl: Simplify for platforms where 'long double' == 'double'.
> Tests for module 'rintl'.
> New module 'rintl'.
> Tests for module 'rintf'.
> New module 'rintf'.
> rint: Support for MSVC.
> rint tests: More tests.
> autoupdate
> Tests for module 'copysignl'.
> New module 'copysignl'.
> Tests for module 'copysignf'.
> New module 'copysignf'.
> Ensure that HAVE_* variables are set to 1 before they are set to 0.
> poll: Make macro safer.
> copysign: Provide replacement.
> isinf: Ensure macro on AIX 5.1.
> *printf-posix tests: Fix for platforms where 'long double' == 'double'.
> *printf: Fix for platforms where 'long double' == 'double'.
> isnanl[-nolibm]: Fix for platforms where 'long double' == 'double'.
> isinf: Fix for platforms where 'long double' == 'double'.
> isfinite: Fix for platforms where 'long double' == 'double'.
> isfinite, isinf, isnan tests: Avoid syntax error on MSVC 9.
> Tests for module 'tanhf'.
> New module 'tanhf'.
> tanh: Use a .m4 file.
> Tests for module 'coshf'.
> New module 'coshf'.
> cosh: Use a .m4 file.
> Tests for module 'sinhf'.
> New module 'sinhf'.
> sinh: Use a .m4 file.
> Tests for module 'atan2f'.
> New module 'atan2f'.
> atan2: Use a .m4 file.
> Tests for module 'atanf'.
> New module 'atanf'.
> atan: Use a .m4 file.
> Tests for module 'acosf'.
> New module 'acosf'.
> acos: Use a .m4 file.
> Tests for module 'asinf'.
> New module 'asinf'.
> asin: Use a .m4 file.
> Tests for module 'tanf'.
> New module 'tanf'.
> tan: Use a .m4 file.
> Tests for module 'cosf'.
> New module 'cosf'.
> cos: Use a .m4 file.
> Tests for module 'sinf'.
> New module 'sinf'.
> sin: Use a .m4 file.
> Tests for module 'powf'.
> New module 'powf'.
> pow: Use a .m4 file.
> Tests for module 'log10f'.
> New module 'log10f'.
> log10: Use a .m4 file.
> Tests for module 'logf'.
> New module 'logf'.
> log: Use a .m4 file.
> Tests for module 'expf'.
> New module 'expf'.
> exp: Use a .m4 file.
> Tests for module 'sqrtf'.
> New module 'sqrtf'.
> Tests: Avoid link failures w.r.t. libintl.
> pow tests: Defeat compiler optimizations.
> gnulib-tool: Improve last commit.
> gnulib-tool: don't follow dependencies to avoided modules
> gnulib-tool: fix typo that broke Emacs on powerpc-apple-darwin9.8.0.
> Fix documentation about math functions on MacOS X.
> modff: Drop assumption about library that defines modff.
> raise tests: Avoid a GCC warning.
> Tests for module 'ldexpf'.
> New module 'ldexpf'.
> Tweak last commit.
> frexpf: Work around problems on IRIX and mingw.
> fabsf: Drop assumption about library that defines fabsf.
> frexpf: Drop assumption about library that defines frexpf.
> Tests for module 'frexpf'.
> New module 'frexpf'.
> math: Sort function declarations of math.in.h.
> Tests for module 'modff'.
> New module 'modff'.
> modf tests: Make test sharper.
> modf: Use a .m4 file.
> Tweak new module 'fmodf'.
> Tweak new module 'fmodf'.
> Tests for module 'fmodf'.
> New module 'fmodf'.
> fmod: Use a .m4 file.
> New module 'fabsf'.
> Tests for module 'fabsf'.
> New module 'fabsf'.
> fabs: Use a .m4 file.
> file-has-acl: revert both recent changes, 80af92af and 95f7c57f
> file-has-acl: revert unintended change in behavior of ls -L
> poll: Avoid link errors on MSVC.
> sys_select tests: Fix link error on MSVC 9.
> sys_select: Fix compilation error on mingw.
> wmemset: Support for MSVC.
> wmemmove: Support for MSVC.
> wmemcpy: Support for MSVC.
> wmemcmp: Support for MSVC.
> wmemchr: Support for MSVC.
> glthread/*, strsignal: Support for MSVC.
> nonblocking tests: Fix test failure on OpenBSD/SPARC64.
> acl: Fix specification.
> relocatable-lib[-lgpl]: Avoid expensive /proc access on Linux, Cygwin.
> autoupdate
> maint.mk: adjust a release-related rule not to require use of gzip
> test-linkat: don't leave behind a temporary file
> float, math: add omitted file
> isinf: Fix for OpenBSD/x86.
> isfinite: Fix syntax error in configure test.
> isfinite: Fix typo.
> nonblocking tests: Fix test failure on Linux/IA-64.
> mkfifoat tests: Fix a test failure on mingw.
> float, math: Fix 'int' to 'long double' conversion on Linux/SPARC64.
> nonblocking tests: Fix test failure on Linux/SPARC (32-bit and 64-bit).
> gnulib-tool: Improve suggestion where to put gl_EARLY invocation.
> Centralize C99 requirement.
> float: Fix LDBL_MAX value on Linux/PowerPC.
> Tweak last ChangeLog entry.
> doc: Improve doc about gl_EARLY.
> fgetc, fputc, fread, fwrite tests: Fix link error.
> fputc, fwrite tests: Avoid test failure on MSVC.
> raise: Fix double declaration with modules 'sigprocmask' and 'sigpipe'.
> autoupdate
> base64-tests: avoid memory leak
> base32: new module
> gnulib: use more-standard license notice wording
> dup2: minor simplification
> strings: Fix compilation error on MSVC.
> fflush et al.: Document limitation on MSVC.
> msvc-inval: Allow three invalid parameter handling modes.
> msvc-inval: Make handler multithread-safe.
> msvc-inval: Install handler globally.
> strerror_r-posix: Fix for MSVC 9.
> ftruncate: Support for MSVC 9.
> New module 'fstat'.
> linkat: Fix compilation on MSVC 9.
> fclose: Support for MSVC 9.
> dup2: minor simplifications
> test-futimens: avoid a warning from gcc -Wshadow
> fdopen: Support for MSVC 9.
> fgetc, fputc, fread, fwrite tests: Avoid compilation error on MSVC.
> dup: Simplify autoconf test.
> Tests for function fwrite().
> Tests for function fread().
> Activate fputc tests.
> Enhance fgetc, fputc tests.
> write: Support for MSVC 9.
> read: Fix last commit.
> dup2: Fix last commit.
> sigprocmask: Make code safer.
> dup2: clarify by coalescing Windows-specific material
> sigprocmask: move #include directive
> read: Support for MSVC 9.
> close: Support for MSVC 9.
> msvc-nothrow: Avoid a compiler warning.
> New module 'dup'.
> getdtablesize: Support for MSVC 9.
> signal-h: Rename from signal.
> sigprocmask: Avoid crashes through signal() on MSVC 9.
> Tests for module 'raise'.
> raise: Support for MSVC.
> pipe2: Fix compilation on pre-C99 compilers.
> dup2: Fix typo in last commit.
> New module 'msvc-nothrow'. Makes _get_osfhandle safe on MSVC 9.
> dup2: Make code more maintainable.
> msvc-inval: Fix compilation error.
> update from texinfo
> mkdir: Tweak for MSVC 9.
> Tests for module 'chdir'.
> New module 'chdir'.
> rmdir: Support for mingw, MSVC 9.
> getcwd: Tweak for MSVC 9.
> strerror_r-posix: Avoid a link error on MSVC.
> select: Avoid link errors on MSVC.
> select: Avoid compilation error on MSVC.
> Consolidate all uses of PATH_MAX in *.m4 files.
> ftruncate: Un-deprecate, concentrate on Win32 support.
> Add dependencies to new dirent related modules.
> opendir: Avoid compilation error on mingw.
> ftruncate tests: Avoid a test failure on mingw.
> select tests: Avoid test failures on OSF/1 5.1 and mingw.
> New module 'fdopen'.
> unlockpt tests: Avoid test failure on NetBSD 5.1.
> getlogin, getlogin_r tests: Avoid test failure on Linux/SPARC.
> time tests: Don't require pid_t.
> time tests: Don't require pid_t.
> fsync tests: Avoid a test failure on mingw.
> euidaccess: Update comments.
> Ensure EBADF returns for socket functions on mingw.
> select tests: EBADF tests.
> Tests for module 'posix_spawn_file_actions_addopen.
> Tests for module 'posix_spawn_file_actions_adddup2'.
> Tests for module 'posix_spawn_file_actions_addclose'.
> Tests for module 'unlockpt'.
> Tests for module 'grantpt'.
> freopen tests: EBADF tests.
> fclose tests: EBADF tests.
> fflush tests: EBADF tests.
> ftello tests: EBADF tests.
> fseeko tests: EBADF tests.
> Tests for function fputc().
> Tests for function fgetc().
> Tests for function fdopen().
> Tests for module 'vdprintf'.
> Tests for module 'dprintf'.
> Tests for module 'ioctl'.
> fcntl tests: EBADF tests.
> utimensat tests: EBADF tests.
> renameat tests: EBADF tests.
> mkfifoat tests: EBADF tests.
> readlinkat tests: EBADF tests.
> symlinkat tests: EBADF tests.
> linkat tests: EBADF tests.
> Tests for module 'faccessat'.
> fdopendir tests: EBADF tests.
> openat tests: EBADF tests.
> utimens, futimens, fdutimensat tests: EBADF tests.
> Tests for function fstat().
> test-ttyname_r tests: EBADF tests.
> Tests for module 'isatty'.
> Tests for module 'write'.
> Tests for module 'read'.
> pwrite tests: EBADF tests.
> pread tests: EBADF tests.
> lseek tests: EBADF tests.
> Tests for module 'ftruncate'.
> fsync tests: EBADF tests.
> fdatasync tests: EBADF tests.
> Tests for module 'fchown'.
> Tests for module 'fchmod'.
> fchdir tests: EBADF tests.
> dup2 tests: EBADF tests.
> Tests for module 'dup'.
> Tests for module 'close'.
> Tests for module 'shutdown'.
> Tests for module 'setsockopt'.
> Tests for module 'sendto'.
> Tests for module 'send'.
> Tests for module 'recvfrom'.
> Tests for module 'recv'.
> Tests for module 'listen'.
> Tests for module 'getsockopt'.
> Tests for module 'getsockname'.
> Tests for module 'getpeername'.
> Tests for module 'connect'.
> Tests for module 'bind'.
> accept4 tests: Fix for native Windows.
> accept tests: Fix for native Windows.
> msvc-inval: Require a semicolon after DONE_MSVC_INVAL.
> sched: Ensure pid_t is defined.
> msvc-inval: Ensure the entire expansion is a single statement.
> tests: use printf, not echo in init.sh's warn_ function
> futimens: enhance test
> date: accept 'hence' as opposite of 'ago'
> getcwd: don't fail in a deep directory on a system without openat
> maint.mk: avoid warnings from perl about missing files
> * lib/stat.c: Move comment.
> stat: use pathmax.h only if needed
> utimens: remove dependency on dup2
> inet_ntop, inet_pton: Look for it also in libresolv.
> accept, accept4 tests: Avoid link error on Solaris.
> accept4: Avoid link error on Solaris.
> socket functions: Avoid link errors on Solaris.
> ptsname tests: Let the test fail rather than hang (e.g. on AIX 5.1).
> posix_spawn_file_actions_add*: Fix module dependencies.
> rename, renameat tests: Avoid test failures on FreeBSD 6.4.
> Tests for module 'accept4'.
> accept tests: Fix last commit.
> Tests for module 'accept'.
> dup2: Support for MSVC.
> New module 'msvc-inval'.
> Tests for module 'pclose'.
> New module 'pclose'.
> popen: Support for MSVC.
> isnanl, isnand, isnanf: Work around MSVC bug.
> sys_socket tests: Fix recent mistake.
> putenv: Support for MSVC.
> math: Avoid macro redefinition warnings on MSVC.
> doc: Mention functions which are declared as macros.
> Add dependencies to new dirent related modules.
> inet_pton: Fix mistake in last commit.
> inet_pton: Support for MSVC on Windows Vista or newer.
> inet_ntop: Support for MSVC on Windows Vista or newer.
> test-fsync: yet another enhancement
> Enhance fsync, fdatasync tests.
> Fix last ChangeLog entry.
> Support for MSVC compiler: Ensure mode_t gets defined.
> sys_stat: Support for MSVC.
> Support for MSVC compiler: Ensure off_t gets defined.
> fdatasync: port to Solaris
> fdatasync: port to MacOS X 10.7
> fdatasync: minor improvements
> unistd: update refs to newer POSIX
> fdatasync: new module
> test-fsync: enhance tests
> Support for MSVC compiler: Ensure ssize_t gets defined.
> Avoid using #, the m4 comment starter character, near brackets.
> Properly quote AC_CHECK_DECLS' 4th argument.
> Properly quote AC_CHECK_DECL's 4th argument.
> opendir: avoid compile warning
> maint.mk: sc_tight_scope: propagate failure from sub-make
> tempname: Support for MSVC.
> sys_time: Support for MSVC.
> stat: Support for MSVC.
> pathmax: Support for native Windows.
> New modules 'opendir', 'readdir', 'rewinddir', 'closedir'.
> asm-underscore.m4: Support for MSVC.
> Expand range of versions of glibc for which _GNU_SOURCE is needed to get crypt.
> doc: Update regarding MSVC 9.
> unistd et al.: Don't assume <unistd.h> exists.
> strcase: Support for MSVC.
> strings: Don't assume <strings.h> exists.
> dirent: Don't assume <dirent.h> exists.
> Fix wint_t on MSVC.
> sys_types: Fix typo.
> autoupdate
> Support for MSVC compiler: Ensure size_t gets defined.
> C++ tests for module 'sys_types'.
> Tests for module 'sys_types'.
> New module 'sys_types'.
> Support for MSVC compiler: Avoid division by a literal 0.
> Ensure pid_t gets defined.
> acl: Fix compilation on Solaris 10 (older version).
> iconv, unsetenv: Add support for MSVC compiler.
> *printf: Add support for MSVC compiler.
> nocrash: Add support for native Windows.
> absolute-header, include-next: Add support for MSVC compiler.
> ChangeLog: change each leading sequence of 8 spaces to a TAB
> maint.mk: mark the post-release commit log with "maint: " prefix
.gnulib | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/.gnulib b/.gnulib
index da1717b..2394a60 160000
--- a/.gnulib
+++ b/.gnulib
@@ -1 +1 @@
-Subproject commit da1717b7f93b77469f980ea5e13178e4e9e7ae09
+Subproject commit 2394a603e7586e671226478e5b15d924c3841f42
--
1.7.4.4
13 years, 1 month
[libvirt] [RFC PATCH 1/5] Add new API virDomainBlockIoThrottle
by Lei Li
Signed-off-by: Zhi Yong Wu <wuzhy(a)linux.vnet.ibm.com>
---
include/libvirt/libvirt.h.in | 22 ++++++++++++
src/conf/domain_conf.c | 77 ++++++++++++++++++++++++++++++++++++++++++
src/conf/domain_conf.h | 11 ++++++
src/driver.h | 11 ++++++
src/libvirt.c | 66 ++++++++++++++++++++++++++++++++++++
src/libvirt_public.syms | 1 +
src/util/xml.h | 3 ++
7 files changed, 191 insertions(+), 0 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 07617be..f7b892d 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1573,6 +1573,28 @@ int virDomainBlockJobSetSpeed(virDomainPtr dom, const char *path,
int virDomainBlockPull(virDomainPtr dom, const char *path,
unsigned long bandwidth, unsigned int flags);
+/*
+ * Block I/O throttling support
+ */
+
+typedef unsigned long long virDomainBlockIoThrottleUnits;
+
+typedef struct _virDomainBlockIoThrottleInfo virDomainBlockIoThrottleInfo;
+struct _virDomainBlockIoThrottleInfo {
+ virDomainBlockIoThrottleUnits bps;
+ virDomainBlockIoThrottleUnits bps_rd;
+ virDomainBlockIoThrottleUnits bps_wr;
+ virDomainBlockIoThrottleUnits iops;
+ virDomainBlockIoThrottleUnits iops_rd;
+ virDomainBlockIoThrottleUnits iops_wr;
+};
+typedef virDomainBlockIoThrottleInfo *virDomainBlockIoThrottleInfoPtr;
+
+int virDomainBlockIoThrottle(virDomainPtr dom,
+ const char *disk,
+ virDomainBlockIoThrottleInfoPtr info,
+ virDomainBlockIoThrottleInfoPtr reply,
+ unsigned int flags);
/*
* NUMA support
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 944cfa9..d0ba07e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2422,6 +2422,42 @@ virDomainDiskDefParseXML(virCapsPtr caps,
iotag = virXMLPropString(cur, "io");
ioeventfd = virXMLPropString(cur, "ioeventfd");
event_idx = virXMLPropString(cur, "event_idx");
+ } else if (xmlStrEqual(cur->name, BAD_CAST "iothrottle")) {
+ char *io_throttle = NULL;
+ io_throttle = virXMLPropString(cur, "bps");
+ if (io_throttle) {
+ def->blkiothrottle.bps = strtoull(io_throttle, NULL, 10);
+ VIR_FREE(io_throttle);
+ }
+
+ io_throttle = virXMLPropString(cur, "bps_rd");
+ if (io_throttle) {
+ def->blkiothrottle.bps_rd = strtoull(io_throttle, NULL, 10);
+ VIR_FREE(io_throttle);
+ }
+
+ io_throttle = virXMLPropString(cur, "bps_wr");
+ if (io_throttle) {
+ def->blkiothrottle.bps_wr = strtoull(io_throttle, NULL, 10);
+ VIR_FREE(io_throttle);
+ }
+
+ io_throttle = virXMLPropString(cur, "iops");
+ if (io_throttle) {
+ def->blkiothrottle.iops = strtoull(io_throttle, NULL, 10);
+ VIR_FREE(io_throttle);
+ }
+
+ io_throttle = virXMLPropString(cur, "iops_rd");
+ if (io_throttle) {
+ def->blkiothrottle.iops_rd = strtoull(io_throttle, NULL, 10);
+ VIR_FREE(io_throttle);
+ }
+
+ io_throttle = virXMLPropString(cur, "iops_wr");
+ if (io_throttle) {
+ def->blkiothrottle.iops_wr = strtoull(io_throttle, NULL, 10);
+ }
} else if (xmlStrEqual(cur->name, BAD_CAST "readonly")) {
def->readonly = 1;
} else if (xmlStrEqual(cur->name, BAD_CAST "shareable")) {
@@ -9249,6 +9285,47 @@ virDomainDiskDefFormat(virBufferPtr buf,
virBufferAsprintf(buf, " <target dev='%s' bus='%s'/>\n",
def->dst, bus);
+ /*disk I/O throttling*/
+ if (def->blkiothrottle.bps
+ || def->blkiothrottle.bps_rd
+ || def->blkiothrottle.bps_wr
+ || def->blkiothrottle.iops
+ || def->blkiothrottle.iops_rd
+ || def->blkiothrottle.iops_wr) {
+ virBufferAsprintf(buf, " <iothrottle");
+ if (def->blkiothrottle.bps) {
+ virBufferAsprintf(buf, " bps='%llu'",
+ def->blkiothrottle.bps);
+ }
+
+ if (def->blkiothrottle.bps_rd) {
+ virBufferAsprintf(buf, " bps_rd='%llu'",
+ def->blkiothrottle.bps_rd);
+ }
+
+ if (def->blkiothrottle.bps_wr) {
+ virBufferAsprintf(buf, " bps_wr='%llu'",
+ def->blkiothrottle.bps_wr);
+ }
+
+ if (def->blkiothrottle.iops) {
+ virBufferAsprintf(buf, " iops='%llu'",
+ def->blkiothrottle.iops);
+ }
+
+ if (def->blkiothrottle.iops_rd) {
+ virBufferAsprintf(buf, " iops_rd='%llu'",
+ def->blkiothrottle.iops_rd);
+ }
+
+ if (def->blkiothrottle.iops_wr) {
+ virBufferAsprintf(buf, " iops_wr='%llu'",
+ def->blkiothrottle.iops_wr);
+ }
+
+ virBufferAsprintf(buf, "/>\n");
+ }
+
if (def->bootIndex)
virBufferAsprintf(buf, " <boot order='%d'/>\n", def->bootIndex);
if (def->readonly)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index e07fd2f..b60a6de 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -283,6 +283,17 @@ struct _virDomainDiskDef {
virDomainDiskHostDefPtr hosts;
char *driverName;
char *driverType;
+
+ /*disk I/O throttling*/
+ struct {
+ unsigned long long bps;
+ unsigned long long bps_rd;
+ unsigned long long bps_wr;
+ unsigned long long iops;
+ unsigned long long iops_rd;
+ unsigned long long iops_wr;
+ } blkiothrottle;
+
char *serial;
int cachemode;
int error_policy; /* enum virDomainDiskErrorPolicy */
diff --git a/src/driver.h b/src/driver.h
index f85a1b1..741e196 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -725,6 +725,16 @@ typedef int
(*virDrvDomainBlockPull)(virDomainPtr dom, const char *path,
unsigned long bandwidth, unsigned int flags);
+/*
+ * Block I/O throttling support
+ */
+
+typedef int
+ (*virDrvDomainBlockIoThrottle)(virDomainPtr dom,
+ const char *disk,
+ virDomainBlockIoThrottleInfoPtr info,
+ virDomainBlockIoThrottleInfoPtr reply,
+ unsigned int flags);
/**
* _virDriver:
@@ -881,6 +891,7 @@ struct _virDriver {
virDrvDomainGetBlockJobInfo domainGetBlockJobInfo;
virDrvDomainBlockJobSetSpeed domainBlockJobSetSpeed;
virDrvDomainBlockPull domainBlockPull;
+ virDrvDomainBlockIoThrottle domainBlockIoThrottle;
};
typedef int
diff --git a/src/libvirt.c b/src/libvirt.c
index 182e031..5f4514c 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -16706,3 +16706,69 @@ error:
virDispatchError(dom->conn);
return -1;
}
+
+/**
+ * virDomainBlockIoThrottle:
+ * @dom: pointer to domain object
+ * @disk: Fully-qualified disk name
+ * @info: specify block I/O limits in bytes
+ * @reply: store block I/O limits setting
+ * @flags: indicate if it set or display block I/O limits info
+ *
+ * This function is mainly to enable Block I/O throttling function in libvirt.
+ * It is used to set or display block I/O throttling setting for specified domain.
+ *
+ * Returns 0 if the operation has started, -1 on failure.
+ */
+int virDomainBlockIoThrottle(virDomainPtr dom,
+ const char *disk,
+ virDomainBlockIoThrottleInfoPtr info,
+ virDomainBlockIoThrottleInfoPtr reply,
+ unsigned int flags)
+{
+ virConnectPtr conn;
+
+ VIR_DOMAIN_DEBUG(dom, "disk=%p, info=%p, reply=%p,flags=%x",
+ disk, info, reply, flags);
+
+ virResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN (dom)) {
+ virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ virDispatchError(NULL);
+ return -1;
+ }
+ conn = dom->conn;
+
+ if (dom->conn->flags & VIR_CONNECT_RO) {
+ virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ goto error;
+ }
+
+ if (!disk) {
+ virLibDomainError(VIR_ERR_INVALID_ARG,
+ _("disk name is NULL"));
+ goto error;
+ }
+
+ if (!reply) {
+ virLibDomainError(VIR_ERR_INVALID_ARG,
+ _("reply is NULL"));
+ goto error;
+ }
+
+ if (conn->driver->domainBlockIoThrottle) {
+ int ret;
+ ret = conn->driver->domainBlockIoThrottle(dom, disk, info, reply, flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ virDispatchError(dom->conn);
+ return -1;
+}
+
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index afea29b..0a79167 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -493,6 +493,7 @@ LIBVIRT_0.9.7 {
global:
virDomainReset;
virDomainSnapshotGetParent;
+ virDomainBlockIoThrottle;
} LIBVIRT_0.9.5;
# .... define new API here using predicted next version number ....
diff --git a/src/util/xml.h b/src/util/xml.h
index d30e066..14b35b2 100644
--- a/src/util/xml.h
+++ b/src/util/xml.h
@@ -50,6 +50,9 @@ xmlNodePtr virXPathNode(const char *xpath,
int virXPathNodeSet(const char *xpath,
xmlXPathContextPtr ctxt,
xmlNodePtr **list);
+int virXMLStringToULongLong (const char *stringval,
+ unsigned long long *value);
+
char * virXMLPropString(xmlNodePtr node,
const char *name);
--
1.7.1
13 years, 1 month
[libvirt] [PATCH v2 0/2] Allow to make disk optional on migration
by Michal Privoznik
If user wants to migrate a machine, it's all or nothing. Either he/she
has all storage accessible under same paths, or migration will fail.
But there are some cases, where allowing migration to drop some disks,
may be useful. E.g. when host gets itself to a state where domains need
to be migrated so host can be say rebooted. Therefore we might want to
give user possibility to mark some cdroms/floppy as optional, meaning
if destination cannot access them, they get ejected (on destination).
This idea is implemented via <migration> element, which basically says
what to do with (currently) disk on migration. Right now it contains
only one attribute 'optional' accepting values 'require', 'optional'
and 'drop'.
Then, if destination cannot access a path and corresponding disk is
marked as:
a) 'require' - migration will fail
b) 'optional' - disk gets force ejected (source is free()'d),
regardless tray being locked
c) 'drop' - disk gets force ejected even if destination could
access the path.
diff to v1:
-change xml representation from 'yes' & 'no' to 'require',
'optional' & 'drop'
Michal Privoznik (2):
migration: Introduce <migration> element for cdrom and floppy
qemu: Implement migration optional disk
docs/formatdomain.html.in | 23 ++++++
docs/schemas/domaincommon.rng | 17 ++++
src/conf/domain_conf.c | 78 +++++++++++++++++++-
src/conf/domain_conf.h | 17 ++++
src/libvirt_private.syms | 2 +
src/qemu/qemu_migration.c | 51 ++++++++++++-
.../domain-qemu-complex-migration.xml | 68 +++++++++++++++++
7 files changed, 253 insertions(+), 3 deletions(-)
create mode 100644 tests/domainschemadata/domain-qemu-complex-migration.xml
--
1.7.3.4
13 years, 1 month
[libvirt] [test-API][PATCH 0/5] Update migrate module
by Wayne Sun
Current migrate module include the remote_guest_define function which
has problem with transient guest created on local, it can't find
persistent domain xml on local and copy to remote.
This series fixes aim to solve this problem. First, remote_guest_define
function in migrate is removed, then add support for define domain on
remote in define module. New xml element uuid is added into xmlgenerator,
and new variable static_uuid is introduced into env.cfg, this will help
domain created on local and defined on remote get the same uuid. At last,
all related conf files are updated.
[test-API][PATCH 1/5] Remove remote_guest_define function in migrate
[test-API][PATCH 2/5] Add new variable static_uuid into env.cfg
[test-API][PATCH 3/5] Update add_option_value function in parser
[test-API][PATCH 4/5] Add new element uuid in xmlgenerator
[test-API][PATCH 5/5] Update the migration case conf file
.../migration/ssh_persistent_paused_with_dst.conf | 192 -------------------
.../migration/ssh_persistent_running_with_dst.conf | 192 -------------------
cases/migration/ssh_transient_paused_with_dst.conf | 200 --------------------
.../migration/ssh_transient_running_with_dst.conf | 198 -------------------
.../migration/tcp_persistent_paused_with_dst.conf | 192 -------------------
.../migration/tcp_persistent_running_with_dst.conf | 192 -------------------
.../tcp_sasl_persistent_paused_with_dst.conf | 64 -------
.../tcp_sasl_persistent_running_with_dst.conf | 64 -------
.../tcp_sasl_transient_paused_with_dst.conf | 64 -------
.../tcp_sasl_transient_running_with_dst.conf | 64 -------
cases/migration/tcp_transient_paused_with_dst.conf | 200 --------------------
.../migration/tcp_transient_running_with_dst.conf | 198 -------------------
.../migration/tls_persistent_paused_with_dst.conf | 192 -------------------
.../migration/tls_persistent_running_with_dst.conf | 192 -------------------
.../tls_sasl_persistent_paused_with_dst.conf | 64 -------
.../tls_sasl_persistent_running_with_dst.conf | 64 -------
.../tls_sasl_transient_paused_with_dst.conf | 64 -------
.../tls_sasl_transient_running_with_dst.conf | 64 -------
cases/migration/tls_transient_paused_with_dst.conf | 200 --------------------
.../migration/tls_transient_running_with_dst.conf | 198 -------------------
env.cfg | 3 -
parser.py | 12 +-
repos/domain/migrate.py | 31 +++-
utils/Python/xmlgenerator.py | 7 -
24 files changed, 33 insertions(+), 2878 deletions(-)
13 years, 1 month
[libvirt] [PATCH] [libvirt-tck] Allow to pass --timer to prove
by Guido Günther
so execution times can be reported too.
---
bin/libvirt-tck | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/bin/libvirt-tck b/bin/libvirt-tck
index dcb053c..816234b 100644
--- a/bin/libvirt-tck
+++ b/bin/libvirt-tck
@@ -109,6 +109,10 @@ Generate an archive containing all the raw test results. The
filename given should end in either C<.bz>, C<.tar.gz> or
C<.tgz>
+=item --timer
+
+Print elapsed time after each test.
+
=back
=cut
@@ -136,6 +140,7 @@ my $quiet = 0;
my $help = 0;
my $force = 0;
my $debug = 0;
+my $timer = 0;
my $archive;
my $config = catfile($confdir, "default.cfg");
my $format = "text";
@@ -149,7 +154,8 @@ if (!GetOptions("verbose" => \$verbose,
"config=s" => \$config,
"force" => \$force,
"format=s" => \$format,
- "testdir=s" => \$testdir) || $help) {
+ "testdir=s" => \$testdir,
+ "timer" => \$timer) || $help) {
pod2usage(-verbose => $help,
-output => $help ? \*STDOUT : \*STDERR,
-exitval => $help ? 0 : 1);
@@ -204,6 +210,9 @@ if ($format eq "xml") {
-output => \*STDERR);
}
+if ($timer) {
+ push @newargv, "--timer";
+}
# This env variable is the only way to pass config into
# the Sys::Virt::TCK module from here
--
1.7.6.3
13 years, 1 month