[libvirt] [PATCH] build: fix fresh checkout on RHEL5
by Eric Blake
Building a fresh checkout on RHEL 5 has been broken since commit
29db7a00, due to a gnulib regression in the bootstrap script
(incremental builds from a checkout earlier than that point were
okay, though).
* .gnulib: Update to latest, for bootstrap fixes.
* bootstrap: Resync from gnulib.
* gnulib/local/top/maint.mk.diff: Drop patch that was added
upstream in the meantime.
---
Lots of gnulib changes, and I'm not sure how many of them directly
impact us. But the bootstrap ones definitely affect building a fresh
checkout on RHEL 5, so I'm pushing this under the build-breaker
rule; now's a decent time, since we still have a bit of time before
feature freeze for the 0.9.12 release.
* .gnulib d5612c7...f15a17d (240):
> bootstrap: accommodate older libtool
> autoupdate
> announce-gen: avoid failure due to lack of Digest::SHA1
> bootstrap: don't let a user's CDPATH setting affect this script
> maint: indent ChangeLog entries with TAB, not 8 spaces
> maint.mk: expand syntax-check rule to catch @xref and @pxref abuse
> bootstrap: really use gnulib's po/Makefile.in.in
> configmake: correct minor inconsistency in Makefile rule
> bootstrap: use gnulib's po/Makefile.in.in, not the one from gettext
> Fix recursion of install-* into po directories.
> maint: avoid spurious "make sc_maint" failure
> lseek: Make configure test independent of environment.
> autoupdate
> stat: Bypass buggy override in mingw64.
> pathmax: Fix compilation error on MSVC 9.
> README: document pointer comparison assumption
> Tests for module 'getrusage'.
> New module 'getrusage'.
> Tests for module 'sys_resource'.
> New module 'sys_resource'.
> ioctl: Fix compilation error on mingw.
> autoupdate
> update from texinfo
> regex: correct #pragma guard expression
> regex: remove unnecessary type punning
> Tests for module 'ilogbl'.
> New module 'ilogbl'.
> Tests for module 'ilogbf'.
> New module 'ilogbf'.
> Tests for module 'ilogb'.
> New module 'ilogb'.
> math: Provide FP_ILOGB0 and FP_ILOGBNAN.
> Tests for module 'logbl-ieee'.
> New module 'logbl-ieee'.
> Tests for module 'logb-ieee'.
> New module 'logb-ieee'.
> Tests for module 'logbf-ieee'.
> New module 'logbf-ieee'.
> Tests for module 'logbl'.
> New module 'logbl'.
> Tests for module 'logbf'.
> New module 'logbf'.
> logb tests: More tests.
> logb: Provide replacement and workarounds.
> log10* tests: Speed up.
> logf-ieee: Fix test whether logf works.
> log10l: Work around log10l-ieee test failure on IRIX 6.5.
> log10f-ieee: Work around test failure on NetBSD 5.1.
> log10f-ieee: Work around test failure on Solaris 9.
> log10-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
> Tests for module 'log10l-ieee'.
> New module 'log10l-ieee'.
> Tests for module 'log10-ieee'.
> New module 'log10-ieee'.
> Tests for module 'log10f-ieee'.
> New module 'log10f-ieee'.
> log10l: Work around AIX 5.1, IRIX 6.5, OSF/1 5.1 bug.
> log10f: Work around OSF/1 5.1 bug.
> log10: Work around OSF/1 5.1 bug.
> log10l tests: More tests.
> log10f tests: More tests.
> log10 tests: More tests.
> Fix typo in ChangeLog entry.
> fflush: Fix syntax error.
> regex: pacify GCC when compiling GRUB
> update from texinfo
> warnings.m4: fix errors.
> stdio: don't assume gets any more
> maint.mk: fix syntax checks without exclusions
> strerror_r: avoid compiler warning
> fflush: avoid compiler warning
> warnings.m4: check the compiler, not the preprocessor
> autoupdate
> Tests for module 'localeconv'.
> New module 'localeconv'.
> locale: Provide a complete 'struct lconv'.
> locale: Provide a complete 'struct lconv' on Solaris 10, 11.
> locale: Provide a working 'struct lconv'.
> Enable common subexpression optimization in GCC.
> Enable common subexpression optimization in GCC.
> gnulib-tool: Avoid unintended error output from 'cmp'.
> gnulib-tool: fix imprecise comments w.r.t. an automake bug
> autoupdate
> announce-gen: use Digest::SHA when possible
> tests: avoid gcc warnings about argv vs. const initializers
> README-release: simplify slightly
> git-merge-changelog: add specific example on how to use with hg.
> git-merge-changelog: Report bugs to bug-gnulib(a)gnu.org.
> git-version-gen: don't let "prefix" envvar cause trouble
> regex: diagnose too-large repeat counts in EREs
> doc: some glibc x32 integer width issues
> autoupdate
> fmal: Avoid test failure on OpenBSD 5.1/SPARC64.
> hypotl: Bypass broken implementation in OpenBSD 5.1/SPARC.
> remainderl: Bypass broken implementation in OpenBSD 5.1/SPARC.
> Oops, fix regression on AIX through recent commit.
> Oops, fix cross-compilation guess in recent commits.
> sqrtl: Bypass broken implementation in OpenBSD 5.1/SPARC.
> doc: update timer_* platform portability notes
> cbrtl: Bypass broken implementation in OpenBSD 5.1/SPARC.
> remainderl: Avoid compilation error on AIX >= 5.2.
> Avoid compilation errors with MSVC option -fp:strict.
> uninorm: Don't crash in out-of-memory conditions.
> quote: fix syntax-check
> Collapse list of copyright years to ranges. See <https://lists.gnu.org/archive/html/bug-gnulib/2012-03/msg00051.html>.
> log2f-ieee: Work around test failure on NetBSD 5.1 and Solaris 10.
> log2-ieee: Work around test failure on NetBSD 5.1 and Solaris 10.
> Tests for module 'log2l-ieee'.
> New module 'log2l-ieee'.
> Tests for module 'log2-ieee'.
> New module 'log2-ieee'.
> Tests for module 'log2f-ieee'.
> New module 'log2f-ieee'.
> Tests for module 'log2l'.
> New module 'log2l'.
> Tests for module 'log2f'.
> New module 'log2f'.
> Tests for module 'log2'.
> New module 'log2'.
> exp2* tests: More tests.
> update from texinfo
> autoupdate
> log1p* tests: Reduce running time of tests.
> log1pl-ieee: Work around test failure on AIX 7.1.
> log1pl-ieee: Work around test failure on IRIX 6.5.
> log1pf-ieee: Work around test failure on OpenBSD 4.9 and AIX 7.1.
> log1pf-ieee: Work around test failure on AIX 5.1 and HP-UX 11.
> log1p-ieee: Work around test failure on AIX 7.1 and HP-UX 11.
> Tests for module 'log1pl-ieee'.
> New module 'log1pl-ieee'.
> Tests for module 'log1p-ieee'.
> New module 'log1p-ieee'.
> Tests for module 'log1pf-ieee'.
> New module 'log1pf-ieee'.
> Tests for module 'log1pl'.
> New module 'log1pl'.
> Tests for module 'log1pf'.
> New module 'log1pf'.
> log1p tests: More tests.
> log1p: Provide replacement for Minix and MSVC.
> expm1: Tiny doc fix.
> math tests: Small simplification.
> log tests: Add a comment.
> Fix some comments.
> regex: allow inclusion of <regex.h> before <limits.h>
> fts: depend on fdopendir
> Remove unused variables.
> isnanf-nolibm: Fix last commit.
> isnanf-nolibm: Make it work on IRIX 6.5 with cc.
> logf-ieee: Work around test failure on NetBSD 5.1.
> logf-ieee: Work around test failure on Solaris 9.
> log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
> Tests for module 'logl-ieee'.
> New module 'logl-ieee'.
> Tests for module 'log-ieee'.
> New module 'log-ieee'.
> Tests for module 'logf-ieee'.
> New module 'logf-ieee'.
> log: Fix bug introduced on 2012-03-09.
> timer-time: link explicitly with pthreads on glibc
> log* tests: More tests.
> logl: Work around OSF/1 5.1 bug.
> logf: Work around OSF/1 5.1 bug.
> log: Work around OSF/1 5.1 bug.
> readtokens.c: adjust wording in a comment
> modechange: add notations +40, 00440, etc.
> exp2l-ieee: Work around test failure on OpenBSD 4.9 and IRIX 6.5.
> Tests for module 'exp2l-ieee'.
> New module 'exp2l-ieee'.
> Tests for module 'exp2-ieee'.
> New module 'exp2-ieee'.
> Tests for module 'exp2f-ieee'.
> New module 'exp2f-ieee'.
> Tests for module 'exp2l'.
> New module 'exp2l'.
> Tests for module 'exp2f'.
> New module 'exp2f'.
> Tests for module 'exp2'.
> New module 'exp2'.
> savedir: fix comment typo
> test-readtokens.c: use const; remove unwarranted cast
> autoupdate
> fmal: Avoid compilation error on AIX.
> fma, fmaf, fmal: Override undeclared system functions on IRIX 6.5.
> remainderf: Override buggy system function on IRIX 6.5.
> test-readtokens.c: avoid const-related compilation warnings
> frexp-nolibm, frexpl-nolibm tests: Fix bug introduced on 2012-03-03.
> expm1l: Avoid compilation error on AIX.
> expm1l: Don't override undeclared system function on IRIX 6.5.
> remainderl: Don't override undeclared system function on IRIX 6.5.
> rintf: Don't override undeclared system function on IRIX 6.5.
> roundl: Avoid compilation error on AIX.
> roundl: Don't override undeclared system function on IRIX 6.5.
> roundf: Don't override undeclared system function on IRIX 6.5.
> round: Don't override undeclared system function on IRIX 6.5.
> copysignf: Don't override undeclared system function on IRIX 6.5.
> readtokens: add tests
> quotearg: the module must now include quote.h
> readtokens: avoid core dumps with unusual calling patterns
> quote: Adhere to common module description layout.
> quote: fuse into quotearg
> Tests for module 'expm1l-ieee'.
> New module 'expm1l-ieee'.
> Tests for module 'expm1f-ieee'.
> New module 'expm1f-ieee'.
> Tests for module 'expm1-ieee'.
> New module 'expm1-ieee'.
> Work around expm1f bug on IRIX 6.5.
> Tests for module 'expm1l'.
> New module 'expm1l'.
> Tests for module 'expm1f'.
> New module 'expm1f'.
> Tests for module 'expm1'.
> New module 'expm1'.
> math: Ensure declarations of math functions.
> math: Update module names in warnings.
> expl: Simplify computation.
> exp* tests: More tests.
> expl: Fix precision of computed result.
> cbrt* tests: More tests.
> hypot* tests: More tests.
> fpucw: Doc about FreeBSD.
> sqrt* tests: Rename local variable.
> sqrt* tests: More tests.
> sqrt* tests: More tests.
> remainder* tests: More tests.
> remainder, remainderf, remainderl: Fix computation for large quotients.
> fmodl: Fix last commit.
> fmod* tests: More tests.
> fmod, fmodl: Fix computation for large quotients x / y.
> fmod* tests: More tests.
> rint* tests: More tests.
> modf* tests: More tests.
> fabs* tests: More tests.
> ldexp* tests: More tests.
> frexp* tests: More tests.
> Support for pseudo-random numbers in tests.
> frexp* tests: Refactor.
> maint: don't specify XZ_OPT=-9ev in dist-related rule
> autoupdate
.gnulib | 2 +-
bootstrap | 18 +++++++++++++++---
gnulib/local/top/maint.mk.diff | 32 --------------------------------
3 files changed, 16 insertions(+), 36 deletions(-)
delete mode 100644 gnulib/local/top/maint.mk.diff
diff --git a/.gnulib b/.gnulib
index d5612c7..f15a17d 160000
--- a/.gnulib
+++ b/.gnulib
@@ -1 +1 @@
-Subproject commit d5612c714c87555f1059d71d347e20271dced322
+Subproject commit f15a17dc1f5d2b1fc8a423795c54b211552c0483
diff --git a/bootstrap b/bootstrap
index 31eb651..5aa73cc 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1,6 +1,6 @@
#! /bin/sh
# Print a version string.
-scriptversion=2012-02-11.09; # UTC
+scriptversion=2012-04-19.22; # UTC
# Bootstrap this package from checked-out sources.
@@ -36,6 +36,10 @@ nl='
LC_ALL=C
export LC_ALL
+# Ensure that CDPATH is not set. Otherwise, the output from cd
+# would cause trouble in at least one use below.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
local_gl_dir=gl
me=$0
@@ -758,9 +762,15 @@ fi
# Autoreconf runs aclocal before libtoolize, which causes spurious
# warnings if the initial aclocal is confused by the libtoolized
# (or worse out-of-date) macro directory.
+# libtoolize 1.9b added the --install option; but we support back
+# to libtoolize 1.5.22, where the install action was default.
if test $use_libtool = 1; then
- echo "running: $LIBTOOLIZE --copy --install"
- $LIBTOOLIZE --copy --install
+ install=
+ case $($LIBTOOLIZE --help) in
+ *--install*) install=--install ;;
+ esac
+ echo "running: $LIBTOOLIZE $install --copy"
+ $LIBTOOLIZE $install --copy
fi
version_controlled_file() {
@@ -863,6 +873,8 @@ if test $with_gettext = yes; then
}
' po/Makevars.template >po/Makevars || exit 1
+ cat $GNULIB_SRCDIR/build-aux/po/Makefile.in.in > po/Makefile.in.in || exit 1
+
if test -d runtime-po; then
# Similarly for runtime-po/Makevars, but not quite the same.
rm -f runtime-po/Makevars
diff --git a/gnulib/local/top/maint.mk.diff b/gnulib/local/top/maint.mk.diff
deleted file mode 100644
index 85e97ae..0000000
--- a/gnulib/local/top/maint.mk.diff
+++ /dev/null
@@ -1,32 +0,0 @@
-diff --git i/top/maint.mk w/top/maint.mk
-index 4cbd5f4..2228a37 100644
---- i/top/maint.mk
-+++ w/top/maint.mk
-@@ -279,7 +279,7 @@ define _sc_search_regexp
- if test -n "$$files"; then \
- if test -n "$$prohibit"; then \
- grep $$with_grep_options $(_ignore_case) -nE "$$prohibit" $$files \
-- | grep -vE "$${exclude-^$$}" \
-+ | grep -vE "$${exclude:-^$$}" \
- && { msg="$$halt" $(_sc_say_and_exit) } || :; \
- else \
- grep $$with_grep_options $(_ignore_case) -LE "$$require" $$files \
-@@ -455,7 +455,8 @@ sc_prohibit_quotearg_without_use:
-
- # Don't include quote.h unless you use one of its functions.
- sc_prohibit_quote_without_use:
-- @h='quote.h' re='\<quote(_n)? *\(' $(_sc_header_without_use)
-+ @h='quote.h' re='\<quote((_n)? *\(|_quoting_options\>)' \
-+ $(_sc_header_without_use)
-
- # Don't include this header unless you use one of its functions.
- sc_prohibit_long_options_without_use:
-@@ -1332,7 +1333,7 @@ alpha beta stable: $(local-check) writable-files $(submodule-checks)
- $(MAKE) vc-diff-check
- $(MAKE) news-check
- $(MAKE) distcheck
-- $(MAKE) dist XZ_OPT=-9ev
-+ $(MAKE) dist
- $(MAKE) $(release-prep-hook) RELEASE_TYPE=$@
- $(MAKE) -s emit_upload_commands RELEASE_TYPE=$@
-
--
1.7.7.6
13 years
[libvirt] [PATCHv2] virsh: avoid uninitialized memory usage
by Alex Jia
Detected by valgrind.
* tools/virsh.c (cmdBlockPull): fix uninitialized memory usage.
* How to reproduce?
$ qemu-img create /var/lib/libvirt/images/test 1M
$ cat > /tmp/test.xml <<EOF
<domain type='qemu'>
<name>test</name>
<memory>219200</memory>
<vcpu>1</vcpu>
<os>
<type arch='x86_64'>hvm</type>
<boot dev='hd'/>
</os>
<devices>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/var/lib/libvirt/images/test'/>
<target dev='vda' bus='virtio'/>
</disk>
<input type='mouse' bus='ps2'/>
<graphics type='spice' autoport='yes' listen='0.0.0.0'/>
</devices>
</domain>
EOF
$ virsh define /tmp/test.xml
$ valgrind -v virsh blockpull test /var/lib/libvirt/images/test --wait
actual result:
==10906== 1 errors in context 1 of 1:
==10906== Syscall param rt_sigaction(act->sa_flags) points to uninitialised byte(s)
==10906== at 0x39CF80F5BE: __libc_sigaction (sigaction.c:67)
==10906== by 0x43016C: cmdBlockPull (virsh.c:7638)
==10906== by 0x4150D4: vshCommandRun (virsh.c:18574)
==10906== by 0x425E73: main (virsh.c:20178)
==10906== Address 0x7fefffae8 is on thread 1's stack
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
tools/virsh.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 95ed7bc..4e4ca57 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -7634,6 +7634,7 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd)
intCaught = 0;
sig_action.sa_sigaction = vshCatchInt;
+ sig_action.sa_flags = 0;
sigemptyset(&sig_action.sa_mask);
sigaction(SIGINT, &sig_action, &old_sig_action);
--
1.7.1
13 years
[libvirt] [RFC][PATCH] Revision for message payload encoding error when adding a large mount of virtio disks
by Chen Hanxiao
From: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
When adding a large number of virtio storage devices to
virtual machine by using 'virsh edit' command, there is
a problem:
When we added more than 190 virtio disks by 'virsh edit'
command, we got a feedback as 'error: Unable to encode
message payload'. In virt-mananger, the same defect occurs
with about 180 virtio disks added.
PCI devices are limited by the virtualized system
architecture. Out of the 32 available PCI devices for a
guest, 4 are not removable. This means there are up to
28 free PCI slots available for additional devices per
guest. Each PCI device in a guest can have up to 8 functions.
One slot kept for network interface, we could add at most
216 (27*8) virtio disks.
The length of xml description with multifuction for one virtio
disk is about 290 characters; In virt-manger, an extra tag
'alias name' will come to the xml description, which would add
about 40 more characters.
So for one xml description, 330 characters would be enough.
A brand new virtual machine with one IDE bus disk needs about
1900 characters for xml description.
In src/remote/remote_protocol.x, there is a limitation for XDR
enoding length as REMOTE_STRING_MAX.
According to the analysis above, at least 73180(1900+216*330)
characters are needed for 216 virtio disks. In the view of
variable length in tag 'source file', so I think it would be
better to extend this limitation from 65536 to 80000.
---
src/remote/remote_protocol.x | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 2d57247..2c8dcbb 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -65,7 +65,7 @@
* This is an arbitrary limit designed to stop the decoder from trying
* to allocate unbounded amounts of memory when fed with a bad message.
*/
-const REMOTE_STRING_MAX = 65536;
+const REMOTE_STRING_MAX = 80000;
/* A long string, which may NOT be NULL. */
typedef string remote_nonnull_string<REMOTE_STRING_MAX>;
--
1.7.1
13 years
[libvirt] [test-API 00/14] Reorgnize/refactoring round 3
by Osier Yang
The TODO in round 2 is still not done, but let's get these
cleanups reviewed first.
Osier Yang (14):
Change libvirt-test-api to be executable
Remove NEWS and TODO
Destroy utils/check.py and move the functions into utils/utils.py
Move directory dist to src
Move utils/env_parser.py into src
Improve the comments telling what the scripts does for utils/*.py
Improve more comments to tell what the program does
Remove trainling blank lines for utils/*.sh
Use bash as the interpreter explicitly
Substitute 'guesttype' with 'virt_type'
Update AUTHORS
Rename utils/*.py with consistent naming style
Rename src/logxmlparser.py as src/log_generator.py
Rename 'env.cfg' as 'global.cfg'
AUTHORS | 17 +-
TODO | 4 -
cases/consumption_cpu_topology.conf | 2 +-
cases/consumption_domain_nfs_start.conf | 2 +-
cases/consumption_eventhandler.conf | 2 +-
cases/consumption_libvirtd.conf | 2 +-
cases/consumption_ownership_test.conf | 2 +-
cases/domain_linux_net_inst.conf | 4 +-
cases/linux_domain.conf | 10 +-
cases/migration/ssh_persistent_paused_no_dst.conf | 24 +-
.../migration/ssh_persistent_paused_with_dst.conf | 48 ++--
cases/migration/ssh_persistent_running_no_dst.conf | 24 +-
.../migration/ssh_persistent_running_with_dst.conf | 48 ++--
cases/migration/ssh_transient_paused_no_dst.conf | 22 +-
cases/migration/ssh_transient_paused_with_dst.conf | 48 ++--
cases/migration/ssh_transient_running_no_dst.conf | 24 +-
.../migration/ssh_transient_running_with_dst.conf | 48 ++--
cases/migration/tcp_persistent_paused_no_dst.conf | 24 +-
.../migration/tcp_persistent_paused_with_dst.conf | 48 ++--
cases/migration/tcp_persistent_running_no_dst.conf | 24 +-
.../migration/tcp_persistent_running_with_dst.conf | 48 ++--
.../tcp_sasl_persistent_paused_no_dst.conf | 8 +-
.../tcp_sasl_persistent_paused_with_dst.conf | 16 +-
.../tcp_sasl_persistent_running_no_dst.conf | 8 +-
.../tcp_sasl_persistent_running_with_dst.conf | 16 +-
.../tcp_sasl_transient_paused_no_dst.conf | 8 +-
.../tcp_sasl_transient_paused_with_dst.conf | 16 +-
.../tcp_sasl_transient_running_no_dst.conf | 8 +-
.../tcp_sasl_transient_running_with_dst.conf | 16 +-
cases/migration/tcp_transient_paused_no_dst.conf | 22 +-
cases/migration/tcp_transient_paused_with_dst.conf | 48 ++--
cases/migration/tcp_transient_running_no_dst.conf | 24 +-
.../migration/tcp_transient_running_with_dst.conf | 48 ++--
cases/migration/tls_persistent_paused_no_dst.conf | 24 +-
.../migration/tls_persistent_paused_with_dst.conf | 48 ++--
cases/migration/tls_persistent_running_no_dst.conf | 24 +-
.../migration/tls_persistent_running_with_dst.conf | 48 ++--
.../tls_sasl_persistent_paused_no_dst.conf | 8 +-
.../tls_sasl_persistent_paused_with_dst.conf | 16 +-
.../tls_sasl_persistent_running_no_dst.conf | 8 +-
.../tls_sasl_persistent_running_with_dst.conf | 16 +-
.../tls_sasl_transient_paused_no_dst.conf | 8 +-
.../tls_sasl_transient_paused_with_dst.conf | 16 +-
.../tls_sasl_transient_running_no_dst.conf | 8 +-
.../tls_sasl_transient_running_with_dst.conf | 16 +-
cases/migration/tls_transient_paused_no_dst.conf | 22 +-
cases/migration/tls_transient_paused_with_dst.conf | 48 ++--
cases/migration/tls_transient_running_no_dst.conf | 24 +-
.../migration/tls_transient_running_with_dst.conf | 48 ++--
cases/snapshot.conf | 2 +-
cases/windows_domain.conf | 8 +-
.../en-US/Understanding_libvirt-test-API.xml | 4 +-
.../en-US/Writing_a_test_case.xml | 10 +-
env.cfg => global.cfg | 0
libvirt-test-api | 24 +-
repos/domain/attach_disk.py | 6 +-
repos/domain/attach_interface.py | 4 +-
repos/domain/balloon_memory.py | 2 +-
repos/domain/create.py | 6 +-
repos/domain/define.py | 18 +-
repos/domain/detach_disk.py | 6 +-
repos/domain/detach_interface.py | 4 +-
repos/domain/dump.py | 2 +-
repos/domain/install_image.py | 14 +-
repos/domain/install_linux_cdrom.py | 28 +-
repos/domain/install_linux_check.py | 27 +-
repos/domain/install_linux_net.py | 32 +-
repos/domain/install_windows_cdrom.py | 22 +-
repos/domain/migrate.py | 2 +-
repos/domain/update_devflag.py | 8 +-
repos/interface/create.py | 2 +-
repos/interface/define.py | 4 +-
repos/interface/destroy.py | 2 +-
repos/interface/undefine.py | 2 +-
repos/network/create.py | 4 +-
repos/network/define.py | 4 +-
repos/npiv/create_virtual_hba.py | 4 +-
.../multiple_thread_block_on_domain_create.py | 12 +-
repos/snapshot/file_flag.py | 3 +-
repos/snapshot/flag_check.py | 3 +-
repos/snapshot/internal_create.py | 4 +-
repos/storage/activate_pool.py | 2 +-
repos/storage/create_dir_pool.py | 4 +-
repos/storage/create_dir_volume.py | 4 +-
repos/storage/create_fs_pool.py | 8 +-
repos/storage/create_iscsi_pool.py | 4 +-
repos/storage/create_logical_volume.py | 4 +-
repos/storage/create_netfs_pool.py | 8 +-
repos/storage/create_netfs_volume.py | 4 +-
repos/storage/create_partition_volume.py | 4 +-
repos/storage/define_dir_pool.py | 4 +-
repos/storage/define_disk_pool.py | 4 +-
repos/storage/define_iscsi_pool.py | 4 +-
repos/storage/define_logical_pool.py | 4 +-
repos/storage/define_mpath_pool.py | 4 +-
repos/storage/define_netfs_pool.py | 4 +-
repos/storage/define_scsi_pool.py | 4 +-
repos/storage/delete_partition_volume.py | 2 +-
repos/storage/destroy_pool.py | 2 +-
{dist => src/dist}/__init__.py | 0
{dist => src/dist}/redhat/__init__.py | 0
{dist => src/dist}/redhat/env_inspect.py | 5 +-
{utils => src}/env_parser.py | 6 +-
src/exception.py | 9 +-
src/generator.py | 8 +-
src/{logxmlparser.py => log_generator.py} | 9 +-
src/parser.py | 6 +-
src/process.py | 7 +-
utils/check.py | 392 --------------------
utils/dev_num.sh | 5 +-
utils/disk_num.sh | 5 +-
utils/format.py | 6 +-
utils/ipget.sh | 2 +-
utils/log.py | 6 +-
utils/utils.py | 362 ++++++++++++++++++
utils/{xmlbuilder.py => xml_builder.py} | 62 ++--
utils/{xmlgenerator.py => xml_generator.py} | 70 ++--
utils/{XMLParser.py => xml_parser.py} | 13 +-
118 files changed, 1175 insertions(+), 1240 deletions(-)
delete mode 100644 NEWS
delete mode 100644 TODO
rename env.cfg => global.cfg (100%)
mode change 100644 => 100755 libvirt-test-api
rename {dist => src/dist}/__init__.py (100%)
rename {dist => src/dist}/redhat/__init__.py (100%)
rename {dist => src/dist}/redhat/env_inspect.py (97%)
rename {utils => src}/env_parser.py (96%)
rename src/{logxmlparser.py => log_generator.py} (97%)
delete mode 100644 utils/check.py
rename utils/{xmlbuilder.py => xml_builder.py} (88%)
rename utils/{xmlgenerator.py => xml_generator.py} (95%)
rename utils/{XMLParser.py => xml_parser.py} (95%)
Regards,
Osier
--
1.7.7.3
13 years
[libvirt] [PATCH] conf: remove redundant ()
by Eric Blake
I almost copied-and-pasted some redundant () into my new code,
and figured a general cleanup prereq patch would be better instead.
* src/conf/domain_conf.c (virDomainLeaseDefParseXML)
(virDomainDiskDefParseXML, virDomainFSDefParseXML)
(virDomainActualNetDefParseXML, virDomainNetDefParseXML)
(virDomainGraphicsDefParseXML, virDomainVideoAccelDefParseXML)
(virDomainVideoDefParseXML, virDomainHostdevFind)
(virDomainControllerInsertPreAlloced, virDomainDefParseXML)
(virDomainObjParseXML, virDomainCpuSetFormat)
(virDomainCpuSetParse, virDomainDiskDefFormat)
(virDomainActualNetDefFormat, virDomainNetDefFormat)
(virDomainTimerDefFormat, virDomainGraphicsListenDefFormat)
(virDomainDefFormatInternal, virDomainNetGetActualHostdev)
(virDomainNetGetActualBandwidth, virDomainGraphicsGetListen):
Reduce extra (), per coding styles.
---
This touches enough lines that I won't claim it to be trivial, but
it should have no semantic impact.
src/conf/domain_conf.c | 210 +++++++++++++++++++++++------------------------
1 files changed, 103 insertions(+), 107 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 8f352ea..0d87970 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3233,14 +3233,13 @@ virDomainLeaseDefParseXML(xmlNodePtr node)
cur = node->children;
while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE) {
- if ((key == NULL) &&
- (xmlStrEqual(cur->name, BAD_CAST "key"))) {
+ if (!key && xmlStrEqual(cur->name, BAD_CAST "key")) {
key = (char *)xmlNodeGetContent(cur);
- } else if ((lockspace == NULL) &&
- (xmlStrEqual(cur->name, BAD_CAST "lockspace"))) {
+ } else if (!lockspace &&
+ xmlStrEqual(cur->name, BAD_CAST "lockspace")) {
lockspace = (char *)xmlNodeGetContent(cur);
- } else if ((path == NULL) &&
- (xmlStrEqual(cur->name, BAD_CAST "target"))) {
+ } else if (!path &&
+ xmlStrEqual(cur->name, BAD_CAST "target")) {
path = virXMLPropString(cur, "path");
offset = virXMLPropString(cur, "offset");
}
@@ -3355,8 +3354,8 @@ virDomainDiskDefParseXML(virCapsPtr caps,
cur = node->children;
while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE) {
- if ((source == NULL && hosts == NULL) &&
- (xmlStrEqual(cur->name, BAD_CAST "source"))) {
+ if (!source && !hosts &&
+ xmlStrEqual(cur->name, BAD_CAST "source")) {
sourceNode = cur;
@@ -3433,8 +3432,8 @@ virDomainDiskDefParseXML(virCapsPtr caps,
those broken apps */
if (source && STREQ(source, ""))
VIR_FREE(source);
- } else if ((target == NULL) &&
- (xmlStrEqual(cur->name, BAD_CAST "target"))) {
+ } else if (!target &&
+ xmlStrEqual(cur->name, BAD_CAST "target")) {
target = virXMLPropString(cur, "dev");
bus = virXMLPropString(cur, "bus");
tray = virXMLPropString(cur, "tray");
@@ -3444,8 +3443,8 @@ virDomainDiskDefParseXML(virCapsPtr caps,
if (target &&
STRPREFIX(target, "ioemu:"))
memmove(target, target+6, strlen(target)-5);
- } else if ((driverName == NULL) &&
- (xmlStrEqual(cur->name, BAD_CAST "driver"))) {
+ } else if (!driverName &&
+ xmlStrEqual(cur->name, BAD_CAST "driver")) {
driverName = virXMLPropString(cur, "name");
driverType = virXMLPropString(cur, "type");
cachetag = virXMLPropString(cur, "cache");
@@ -3579,8 +3578,8 @@ virDomainDiskDefParseXML(virCapsPtr caps,
cur);
if (encryption == NULL)
goto error;
- } else if ((serial == NULL) &&
- (xmlStrEqual(cur->name, BAD_CAST "serial"))) {
+ } else if (!serial &&
+ xmlStrEqual(cur->name, BAD_CAST "serial")) {
serial = (char *)xmlNodeGetContent(cur);
} else if (xmlStrEqual(cur->name, BAD_CAST "boot")) {
/* boot is parsed as part of virDomainDeviceInfoParseXML */
@@ -4099,8 +4098,8 @@ virDomainFSDefParseXML(xmlNodePtr node,
cur = node->children;
while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE) {
- if ((source == NULL) &&
- (xmlStrEqual(cur->name, BAD_CAST "source"))) {
+ if (!source &&
+ xmlStrEqual(cur->name, BAD_CAST "source")) {
if (def->type == VIR_DOMAIN_FS_TYPE_MOUNT)
source = virXMLPropString(cur, "dir");
@@ -4110,12 +4109,12 @@ virDomainFSDefParseXML(xmlNodePtr node,
source = virXMLPropString(cur, "dev");
else if (def->type == VIR_DOMAIN_FS_TYPE_TEMPLATE)
source = virXMLPropString(cur, "name");
- } else if ((target == NULL) &&
- (xmlStrEqual(cur->name, BAD_CAST "target"))) {
+ } else if (!target &&
+ xmlStrEqual(cur->name, BAD_CAST "target")) {
target = virXMLPropString(cur, "dir");
} else if (xmlStrEqual(cur->name, BAD_CAST "readonly")) {
def->readonly = 1;
- } else if ((fsdriver == NULL) && (xmlStrEqual(cur->name, BAD_CAST "driver"))) {
+ } else if (!fsdriver && xmlStrEqual(cur->name, BAD_CAST "driver")) {
fsdriver = virXMLPropString(cur, "type");
wrpolicy = virXMLPropString(cur, "wrpolicy");
}
@@ -4261,8 +4260,8 @@ virDomainActualNetDefParseXML(xmlNodePtr node,
*/
addrtype = virXPathString("string(./source/address/@type)", ctxt);
/* if not explicitly stated, source/vendor implies usb device */
- if ((!addrtype) && virXPathNode("./source/vendor", ctxt) &&
- ((addrtype = strdup("usb")) == NULL)) {
+ if (!addrtype && virXPathNode("./source/vendor", ctxt) &&
+ (addrtype = strdup("usb")) == NULL) {
virReportOOMError();
goto error;
}
@@ -4361,61 +4360,60 @@ virDomainNetDefParseXML(virCapsPtr caps,
cur = node->children;
while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE) {
- if ((macaddr == NULL) &&
- (xmlStrEqual(cur->name, BAD_CAST "mac"))) {
+ if (!macaddr && xmlStrEqual(cur->name, BAD_CAST "mac")) {
macaddr = virXMLPropString(cur, "address");
- } else if ((network == NULL) &&
- (def->type == VIR_DOMAIN_NET_TYPE_NETWORK) &&
- (xmlStrEqual(cur->name, BAD_CAST "source"))) {
+ } else if (!network &&
+ def->type == VIR_DOMAIN_NET_TYPE_NETWORK &&
+ xmlStrEqual(cur->name, BAD_CAST "source")) {
network = virXMLPropString(cur, "network");
portgroup = virXMLPropString(cur, "portgroup");
- } else if ((internal == NULL) &&
- (def->type == VIR_DOMAIN_NET_TYPE_INTERNAL) &&
- (xmlStrEqual(cur->name, BAD_CAST "source"))) {
+ } else if (!internal &&
+ def->type == VIR_DOMAIN_NET_TYPE_INTERNAL &&
+ xmlStrEqual(cur->name, BAD_CAST "source")) {
internal = virXMLPropString(cur, "name");
- } else if ((network == NULL) &&
- (def->type == VIR_DOMAIN_NET_TYPE_BRIDGE) &&
- (xmlStrEqual(cur->name, BAD_CAST "source"))) {
+ } else if (!network &&
+ def->type == VIR_DOMAIN_NET_TYPE_BRIDGE &&
+ xmlStrEqual(cur->name, BAD_CAST "source")) {
bridge = virXMLPropString(cur, "bridge");
- } else if ((dev == NULL) &&
+ } else if (!dev &&
(def->type == VIR_DOMAIN_NET_TYPE_ETHERNET ||
def->type == VIR_DOMAIN_NET_TYPE_DIRECT) &&
xmlStrEqual(cur->name, BAD_CAST "source")) {
dev = virXMLPropString(cur, "dev");
mode = virXMLPropString(cur, "mode");
- } else if ((virtPort == NULL) &&
- ((def->type == VIR_DOMAIN_NET_TYPE_DIRECT) ||
- (def->type == VIR_DOMAIN_NET_TYPE_NETWORK) ||
- (def->type == VIR_DOMAIN_NET_TYPE_BRIDGE) ||
- (def->type == VIR_DOMAIN_NET_TYPE_HOSTDEV)) &&
+ } else if (!virtPort &&
+ (def->type == VIR_DOMAIN_NET_TYPE_DIRECT ||
+ def->type == VIR_DOMAIN_NET_TYPE_NETWORK ||
+ def->type == VIR_DOMAIN_NET_TYPE_BRIDGE ||
+ def->type == VIR_DOMAIN_NET_TYPE_HOSTDEV) &&
xmlStrEqual(cur->name, BAD_CAST "virtualport")) {
if (!(virtPort = virNetDevVPortProfileParse(cur)))
goto error;
- } else if ((network == NULL) &&
- ((def->type == VIR_DOMAIN_NET_TYPE_SERVER) ||
- (def->type == VIR_DOMAIN_NET_TYPE_CLIENT) ||
- (def->type == VIR_DOMAIN_NET_TYPE_MCAST)) &&
- (xmlStrEqual(cur->name, BAD_CAST "source"))) {
+ } else if (!network &&
+ (def->type == VIR_DOMAIN_NET_TYPE_SERVER ||
+ def->type == VIR_DOMAIN_NET_TYPE_CLIENT ||
+ def->type == VIR_DOMAIN_NET_TYPE_MCAST) &&
+ xmlStrEqual(cur->name, BAD_CAST "source")) {
address = virXMLPropString(cur, "address");
port = virXMLPropString(cur, "port");
- } else if ((address == NULL) &&
+ } else if (!address &&
(def->type == VIR_DOMAIN_NET_TYPE_ETHERNET ||
def->type == VIR_DOMAIN_NET_TYPE_BRIDGE) &&
- (xmlStrEqual(cur->name, BAD_CAST "ip"))) {
+ xmlStrEqual(cur->name, BAD_CAST "ip")) {
address = virXMLPropString(cur, "address");
- } else if ((ifname == NULL) &&
+ } else if (!ifname &&
xmlStrEqual(cur->name, BAD_CAST "target")) {
ifname = virXMLPropString(cur, "dev");
- if ((ifname != NULL) &&
- ((flags & VIR_DOMAIN_XML_INACTIVE) &&
- (STRPREFIX(ifname, VIR_NET_GENERATED_PREFIX)))) {
+ if (ifname &&
+ (flags & VIR_DOMAIN_XML_INACTIVE) &&
+ STRPREFIX(ifname, VIR_NET_GENERATED_PREFIX)) {
/* An auto-generated target name, blank it out */
VIR_FREE(ifname);
}
- } else if ((linkstate == NULL) &&
+ } else if (!linkstate &&
xmlStrEqual(cur->name, BAD_CAST "link")) {
linkstate = virXMLPropString(cur, "state");
- } else if ((script == NULL) &&
+ } else if (!script &&
xmlStrEqual(cur->name, BAD_CAST "script")) {
script = virXMLPropString(cur, "path");
} else if (xmlStrEqual (cur->name, BAD_CAST "model")) {
@@ -4435,9 +4433,9 @@ virDomainNetDefParseXML(virCapsPtr caps,
devaddr = virXMLPropString(cur, "devaddr");
} else if (xmlStrEqual(cur->name, BAD_CAST "boot")) {
/* boot is parsed as part of virDomainDeviceInfoParseXML */
- } else if ((actual == NULL) &&
+ } else if (!actual &&
(flags & VIR_DOMAIN_XML_INTERNAL_ACTUAL_NET) &&
- (def->type == VIR_DOMAIN_NET_TYPE_NETWORK) &&
+ def->type == VIR_DOMAIN_NET_TYPE_NETWORK &&
xmlStrEqual(cur->name, BAD_CAST "actual")) {
if (virDomainActualNetDefParseXML(cur, ctxt, def,
&actual, flags) < 0) {
@@ -4598,7 +4596,7 @@ virDomainNetDefParseXML(virCapsPtr caps,
def->data.direct.linkdev = dev;
dev = NULL;
- if ((flags & VIR_DOMAIN_XML_INACTIVE))
+ if (flags & VIR_DOMAIN_XML_INACTIVE)
VIR_FREE(ifname);
break;
@@ -4614,7 +4612,7 @@ virDomainNetDefParseXML(virCapsPtr caps,
*/
addrtype = virXPathString("string(./source/address/@type)", ctxt);
/* if not explicitly stated, source/vendor implies usb device */
- if ((!addrtype) && virXPathNode("./source/vendor", ctxt) &&
+ if (!addrtype && virXPathNode("./source/vendor", ctxt) &&
((addrtype = strdup("usb")) == NULL)) {
virReportOOMError();
goto error;
@@ -4660,8 +4658,8 @@ virDomainNetDefParseXML(virCapsPtr caps,
if (def->model && STREQ(def->model, "virtio")) {
if (backend != NULL) {
int name;
- if (((name = virDomainNetBackendTypeFromString(backend)) < 0) ||
- (name == VIR_DOMAIN_NET_BACKEND_TYPE_DEFAULT)) {
+ if ((name = virDomainNetBackendTypeFromString(backend)) < 0 ||
+ name == VIR_DOMAIN_NET_BACKEND_TYPE_DEFAULT) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
_("Unknown interface <driver name='%s'> "
"has been specified"),
@@ -4672,8 +4670,8 @@ virDomainNetDefParseXML(virCapsPtr caps,
}
if (txmode != NULL) {
int m;
- if (((m = virDomainNetVirtioTxModeTypeFromString(txmode)) < 0) ||
- (m == VIR_DOMAIN_NET_VIRTIO_TX_MODE_DEFAULT)) {
+ if ((m = virDomainNetVirtioTxModeTypeFromString(txmode)) < 0 ||
+ m == VIR_DOMAIN_NET_VIRTIO_TX_MODE_DEFAULT) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
_("Unknown interface <driver txmode='%s'> "
"has been specified"),
@@ -5772,8 +5770,8 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def,
* type='network' and we're looking at live XML (i.e. *not*
* inactive). It is otherwise ignored. */
if (address && address[0] &&
- ((def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS) ||
- ((def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK) &&
+ (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS ||
+ (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK &&
!(flags & VIR_DOMAIN_XML_INACTIVE)))) {
def->address = address;
address = NULL;
@@ -5836,9 +5834,9 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
goto error;
}
- if ((def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) ||
- (def->type == VIR_DOMAIN_GRAPHICS_TYPE_RDP) ||
- (def->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE)) {
+ if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ||
+ def->type == VIR_DOMAIN_GRAPHICS_TYPE_RDP ||
+ def->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
/* parse the <listen> subelements for graphics types that support it */
nListens = virXPathNodeSet("./listen", ctxt, &listenNodes);
@@ -6548,7 +6546,7 @@ virDomainVideoAccelDefParseXML(const xmlNodePtr node) {
cur = node->children;
while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE) {
- if ((support3d == NULL) && (support2d == NULL) &&
+ if (!support3d && !support2d &&
xmlStrEqual(cur->name, BAD_CAST "acceleration")) {
support3d = virXMLPropString(cur, "accel3d");
support2d = virXMLPropString(cur, "accel2d");
@@ -6557,7 +6555,7 @@ virDomainVideoAccelDefParseXML(const xmlNodePtr node) {
cur = cur->next;
}
- if ((support3d == NULL) && (support2d == NULL))
+ if (!support3d && !support2d)
return NULL;
if (VIR_ALLOC(def) < 0) {
@@ -6603,7 +6601,7 @@ virDomainVideoDefParseXML(const xmlNodePtr node,
cur = node->children;
while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE) {
- if ((type == NULL) && (vram == NULL) && (heads == NULL) &&
+ if (!type && !vram && !heads &&
xmlStrEqual(cur->name, BAD_CAST "model")) {
type = virXMLPropString(cur, "type");
vram = virXMLPropString(cur, "vram");
@@ -6990,32 +6988,32 @@ virDomainHostdevFind(virDomainDefPtr def,
virDomainHostdevDefPtr compare = def->hostdevs[i];
virDomainHostdevSubsysPtr c_subsys = &compare->source.subsys;
- if ((compare->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) ||
- (c_subsys->type != m_subsys->type)) {
+ if (compare->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
+ c_subsys->type != m_subsys->type) {
continue;
}
switch (m_subsys->type)
{
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
- if ((c_subsys->u.pci.domain == m_subsys->u.pci.domain) &&
- (c_subsys->u.pci.bus == m_subsys->u.pci.bus) &&
- (c_subsys->u.pci.slot == m_subsys->u.pci.slot) &&
- (c_subsys->u.pci.function == m_subsys->u.pci.function)) {
+ if (c_subsys->u.pci.domain == m_subsys->u.pci.domain &&
+ c_subsys->u.pci.bus == m_subsys->u.pci.bus &&
+ c_subsys->u.pci.slot == m_subsys->u.pci.slot &&
+ c_subsys->u.pci.function == m_subsys->u.pci.function) {
*found = compare;
}
break;
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
if (m_subsys->u.usb.bus && m_subsys->u.usb.device) {
/* specified by bus location on host */
- if ((c_subsys->u.usb.bus == m_subsys->u.usb.bus) &&
- (c_subsys->u.usb.device == m_subsys->u.usb.device)) {
+ if (c_subsys->u.usb.bus == m_subsys->u.usb.bus &&
+ c_subsys->u.usb.device == m_subsys->u.usb.device) {
*found = compare;
}
} else {
/* specified by product & vendor id */
- if ((c_subsys->u.usb.product == m_subsys->u.usb.product) &&
- (c_subsys->u.usb.vendor == m_subsys->u.usb.vendor)) {
+ if (c_subsys->u.usb.product == m_subsys->u.usb.product &&
+ c_subsys->u.usb.vendor == m_subsys->u.usb.vendor) {
*found = compare;
}
}
@@ -7249,8 +7247,8 @@ void virDomainControllerInsertPreAlloced(virDomainDefPtr def,
for (i = (def->ncontrollers - 1) ; i >= 0 ; i--) {
/* If bus matches and current controller is after
* new controller, then new controller should go here */
- if ((def->controllers[i]->type == controller->type) &&
- (def->controllers[i]->idx > controller->idx)) {
+ if (def->controllers[i]->type == controller->type &&
+ def->controllers[i]->idx > controller->idx) {
insertAt = i;
} else if (def->controllers[i]->type == controller->type &&
insertAt == -1) {
@@ -7673,7 +7671,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
}
if (!(flags & VIR_DOMAIN_XML_INACTIVE))
- if ((virXPathLong("string(./@id)", ctxt, &id)) < 0)
+ if (virXPathLong("string(./@id)", ctxt, &id) < 0)
id = -1;
def->id = (int)id;
@@ -7988,7 +7986,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
cur = nodes[0]->children;
while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE) {
- if ((xmlStrEqual(cur->name, BAD_CAST "memory"))) {
+ if (xmlStrEqual(cur->name, BAD_CAST "memory")) {
tmp = virXMLPropString(cur, "nodeset");
if (tmp) {
@@ -8397,9 +8395,9 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
def->nets[def->nnets++] = net;
/* <interface type='hostdev'> must also be in the hostdevs array */
- if ((net->type == VIR_DOMAIN_NET_TYPE_HOSTDEV) &&
- (virDomainHostdevInsert(def, &net->data.hostdev.def) < 0)) {
- goto no_memory;
+ if (net->type == VIR_DOMAIN_NET_TYPE_HOSTDEV &&
+ virDomainHostdevInsert(def, &net->data.hostdev.def) < 0) {
+ goto no_memory;
}
}
VIR_FREE(nodes);
@@ -8985,7 +8983,7 @@ static virDomainObjPtr virDomainObjParseXML(virCapsPtr caps,
virDomainObjSetState(obj, state, reason);
- if ((virXPathLong("string(./@pid)", ctxt, &val)) < 0) {
+ if (virXPathLong("string(./@pid)", ctxt, &val) < 0) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("invalid pid"));
goto error;
@@ -10275,7 +10273,7 @@ virDomainCpuSetFormat(char *cpuset, int maxcpu)
int start, cur;
int first = 1;
- if ((cpuset == NULL) || (maxcpu <= 0) || (maxcpu > 100000))
+ if (!cpuset || maxcpu <= 0 || maxcpu > 100000)
return NULL;
cur = 0;
@@ -10339,8 +10337,7 @@ virDomainCpuSetParse(const char *str, char sep,
int i, start, last;
int neg = 0;
- if ((str == NULL) || (cpuset == NULL) || (maxcpu <= 0) ||
- (maxcpu > 100000))
+ if (!str || !cpuset || maxcpu <= 0 || maxcpu > 100000)
return -1;
cur = str;
@@ -10353,7 +10350,7 @@ virDomainCpuSetParse(const char *str, char sep,
cpuset[i] = 0;
ret = 0;
- while ((*cur != 0) && (*cur != sep)) {
+ while (*cur != 0 && *cur != sep) {
/*
* 3 constructs are allowed:
* - N : a single CPU number
@@ -10371,7 +10368,7 @@ virDomainCpuSetParse(const char *str, char sep,
if (start < 0)
goto parse_error;
virSkipSpaces(&cur);
- if ((*cur == ',') || (*cur == 0) || (*cur == sep)) {
+ if (*cur == ',' || *cur == 0 || *cur == sep) {
if (neg) {
if (cpuset[start] == 1) {
cpuset[start] = 0;
@@ -10403,7 +10400,7 @@ virDomainCpuSetParse(const char *str, char sep,
cur++;
virSkipSpaces(&cur);
neg = 0;
- } else if ((*cur == 0) || (*cur == sep)) {
+ } else if (*cur == 0 || *cur == sep) {
break;
} else
goto parse_error;
@@ -10842,7 +10839,7 @@ virDomainDiskDefFormat(virBufferPtr buf,
def->dst, bus);
if ((def->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY ||
def->device == VIR_DOMAIN_DISK_DEVICE_CDROM) &&
- (def->tray_status != VIR_DOMAIN_DISK_TRAY_CLOSED))
+ def->tray_status != VIR_DOMAIN_DISK_TRAY_CLOSED)
virBufferAsprintf(buf, " tray='%s'/>\n",
virDomainDiskTrayTypeToString(def->tray_status));
else
@@ -11138,7 +11135,7 @@ virDomainActualNetDefFormat(virBufferPtr buf,
}
virBufferAsprintf(buf, " <actual type='%s'", type);
- if ((def->type == VIR_DOMAIN_NET_TYPE_HOSTDEV) &&
+ if (def->type == VIR_DOMAIN_NET_TYPE_HOSTDEV &&
def->data.hostdev.def.managed) {
virBufferAddLit(buf, " managed='yes'");
}
@@ -11223,7 +11220,7 @@ virDomainNetDefFormat(virBufferPtr buf,
}
virBufferAsprintf(buf, " <interface type='%s'", type);
- if ((def->type == VIR_DOMAIN_NET_TYPE_HOSTDEV) &&
+ if (def->type == VIR_DOMAIN_NET_TYPE_HOSTDEV &&
def->data.hostdev.def.managed) {
virBufferAddLit(buf, " managed='yes'");
}
@@ -11879,9 +11876,8 @@ virDomainTimerDefFormat(virBufferPtr buf,
}
}
- if ((def->catchup.threshold == 0)
- && (def->catchup.slew == 0)
- && (def->catchup.limit == 0)) {
+ if (def->catchup.threshold == 0 && def->catchup.slew == 0 &&
+ def->catchup.limit == 0) {
virBufferAddLit(buf, "/>\n");
} else {
virBufferAddLit(buf, ">\n");
@@ -11941,8 +11937,8 @@ virDomainGraphicsListenDefFormat(virBufferPtr buf,
}
if (def->address &&
- ((def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS) ||
- ((def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK) &&
+ (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS ||
+ (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK &&
!(flags & VIR_DOMAIN_XML_INACTIVE)))) {
/* address may also be set to show current status when type='network',
* but we don't want to print that if INACTIVE data is requested. */
@@ -12719,8 +12715,8 @@ virDomainDefFormatInternal(virDomainDefPtr def,
* hostdev in a higher-level device (e.g. virDomainNetDef),
* and will have already been formatted there.
*/
- if ((def->hostdevs[n]->parent.type == VIR_DOMAIN_DEVICE_NONE) &&
- (virDomainHostdevDefFormat(buf, def->hostdevs[n], flags) < 0)) {
+ if (def->hostdevs[n]->parent.type == VIR_DOMAIN_DEVICE_NONE &&
+ virDomainHostdevDefFormat(buf, def->hostdevs[n], flags) < 0) {
goto cleanup;
}
}
@@ -14615,8 +14611,8 @@ virDomainNetGetActualHostdev(virDomainNetDefPtr iface)
{
if (iface->type == VIR_DOMAIN_NET_TYPE_HOSTDEV)
return &iface->data.hostdev.def;
- if ((iface->type == VIR_DOMAIN_NET_TYPE_NETWORK) &&
- (iface->data.network.actual->type == VIR_DOMAIN_NET_TYPE_HOSTDEV)) {
+ if (iface->type == VIR_DOMAIN_NET_TYPE_NETWORK &&
+ iface->data.network.actual->type == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
return &iface->data.network.actual->data.hostdev.def;
}
return NULL;
@@ -14653,7 +14649,7 @@ virDomainNetGetActualVirtPortProfile(virDomainNetDefPtr iface)
virNetDevBandwidthPtr
virDomainNetGetActualBandwidth(virDomainNetDefPtr iface)
{
- if ((iface->type == VIR_DOMAIN_NET_TYPE_NETWORK) &&
+ if (iface->type == VIR_DOMAIN_NET_TYPE_NETWORK &&
iface->data.network.actual && iface->data.network.actual->bandwidth) {
return iface->data.network.actual->bandwidth;
}
@@ -14668,9 +14664,9 @@ virDomainNetGetActualBandwidth(virDomainNetDefPtr iface)
static virDomainGraphicsListenDefPtr
virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t ii, bool force0)
{
- if ((def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) ||
- (def->type == VIR_DOMAIN_GRAPHICS_TYPE_RDP) ||
- (def->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE)) {
+ if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ||
+ def->type == VIR_DOMAIN_GRAPHICS_TYPE_RDP ||
+ def->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
if (!def->listens && (ii == 0) && force0) {
if (VIR_ALLOC(def->listens) < 0)
--
1.7.7.6
13 years
[libvirt] [PATCHv2 0/3] tighten up integer parsing
by Eric Blake
v1: https://www.redhat.com/archives/libvir-list/2012-April/msg00954.html
changes in v2: fix regression in patch 1, incomplete change in patch 2
Eric Blake (3):
virsh: avoid strtol
conf: tighten up XML integer parsing
build: avoid strtol and strtod
cfg.mk | 14 ++++++++++
src/conf/domain_conf.c | 24 ++++++++++-------
src/conf/storage_conf.c | 7 +++--
src/util/util.c | 14 +++++-----
src/util/virmacaddr.c | 2 +-
src/util/xml.c | 36 +++----------------------
tools/virsh.c | 67 ++++++++++++++---------------------------------
7 files changed, 64 insertions(+), 100 deletions(-)
--
1.7.7.6
13 years
[libvirt] [PATCH] Improve on virAtomic implementation
by Stefan Berger
This patch improves on the previously added virAtomicInt operations
by testing for the compiler and if GCC >= 4.1 (not found in docs prior to
that) is used on Linux and has the appropriate processor (that I have
access to) then use the implementation based on the gcc-builtins.
I also did not look at other systems (cygwin, win32) that do not need
access to virAtomic right now.
---
src/util/viratomic.h | 88
+++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 72 insertions(+), 16 deletions(-)
Index: libvirt-acl/src/util/viratomic.h
===================================================================
--- libvirt-acl.orig/src/util/viratomic.h
+++ libvirt-acl/src/util/viratomic.h
@@ -30,6 +30,22 @@
typedef struct _virAtomicInt virAtomicInt;
typedef virAtomicInt *virAtomicIntPtr;
+# define __VIR_ATOMIC_USES_LOCK
+
+# if defined(__GNUC__)
+# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 1)) || (__GNUC__ > 4)
+# if defined(__linux__)
+# if defined(__i386__) || defined(__x86_64__) || \
+ defined(__powerpc64__) || defined(__powerpc__)
+# undef __VIR_ATOMIC_USES_LOCK
+# endif
+# endif
+# endif
+# endif
+
+
+# ifdef __VIR_ATOMIC_USES_LOCK
+
struct _virAtomicInt {
virMutex lock;
int value;
@@ -42,22 +58,6 @@ virAtomicIntInit(virAtomicIntPtr vaip)
return virMutexInit(&vaip->lock);
}
-static inline void
-virAtomicIntSet(virAtomicIntPtr vaip, int value)
-{
- virMutexLock(&vaip->lock);
-
- vaip->value = value;
-
- virMutexUnlock(&vaip->lock);
-}
-
-static inline int
-virAtomicIntRead(virAtomicIntPtr vaip)
-{
- return vaip->value;
-}
-
static inline int
virAtomicIntAdd(virAtomicIntPtr vaip, int add)
{
@@ -88,4 +88,60 @@ virAtomicIntSub(virAtomicIntPtr vaip, in
return ret;
}
+# else /* __VIR_ATOMIC_USES_LOCK */
+
+struct _virAtomicInt {
+ int value;
+};
+
+static inline int
+virAtomicIntInit(virAtomicIntPtr vaip)
+{
+ vaip->value = 0;
+ return 0;
+}
+
+static inline int
+virAtomicIntAdd(virAtomicIntPtr vaip, int add)
+{
+ return __sync_add_and_fetch(&vaip->value, add);
+}
+
+static inline int
+virAtomicIntSub(virAtomicIntPtr vaip, int sub)
+{
+ return __sync_sub_and_fetch(&vaip->value, sub);
+}
+
+# endif /* __VIR_ATOMIC_USES_LOCK */
+
+
+
+/* common operations that need no locking or build on others */
+
+
+static inline void
+virAtomicIntSet(virAtomicIntPtr vaip, int value)
+{
+ vaip->value = value;
+}
+
+static inline int
+virAtomicIntRead(virAtomicIntPtr vaip)
+{
+ return *(volatile int *)&vaip->value;
+}
+
+static inline int
+virAtomicIntInc(virAtomicIntPtr vaip)
+{
+ return virAtomicIntAdd(vaip, 1);
+}
+
+static inline int
+virAtomicIntDec(virAtomicIntPtr vaip)
+{
+ return virAtomicIntSub(vaip, 1);
+}
+
#endif /* __VIR_ATOMIC_H */
13 years
[libvirt] [PATCH 0/2 v3 use qemu's dump-guest-meory when vm uses host device
by Wen Congyang
Currently, we use migrate to dump guest's memory. There is one
restriction in migrate command: the device's status should be
stored in qemu because the device's status should be passed to
target machine.
If we passthrough a host device to guest, the device's status
is stored in the real device. So migrate command will fail.
We usually use dump when guest is panicked. So there is no need
to store device's status in the vmcore.
qemu will have a new monitor command dump-guest-memory to dump
guest memory, but it doesn't support async now(it will support
later when the common async API is implemented).
So I use dump-guest-memory only when the guest uses host device
in this patchset.
Note: the patchset for qemu is still queued. Luiz has acked,
but he waits an ACK from Jan and/or Anthony. They are too busy,
and donot reply.
Changes from v2 to v3:
1. qemu supports the fd that is associated with a pipe, socket, or FIFO.
So pass a pipe fd to qemu and O_DIRECT can work now.
Change from v1 to v2:
1. remove the implemention for text mode.
Wen Congyang (2):
qemu: implement qemu's dump-guest-memory
qemu: try to use qemu's dump-guest-meory when vm uses host device
src/qemu/qemu_domain.c | 1 +
src/qemu/qemu_domain.h | 1 +
src/qemu/qemu_driver.c | 39 +++++++++++++++++++++++++++++++++++++--
src/qemu/qemu_monitor.c | 36 ++++++++++++++++++++++++++++++++++++
src/qemu/qemu_monitor.h | 13 +++++++++++++
src/qemu/qemu_monitor_json.c | 42 ++++++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_monitor_json.h | 7 +++++++
7 files changed, 137 insertions(+), 2 deletions(-)
13 years
[libvirt] [PATCH V11 0/7] Add DHCP snooping support to nwfilter
by Stefan Berger
This series of patches adds DHCP snooping support to libvirt's
nwfilter subsystem.
DHCP snooping detects DHCP leases obtained by a VM and automatically
adjusts the network traffic filters to reflect the IP addresses
with which a VM may send its traffic, thus for example preventing
IP address spoofing.
Once leases on IP addresses expire or if a VM gives up on a
lease on an IP address, the filters are also adjusted.
All leases are persisted and automatically applied upon a VM's restart.
Leases are associated with the tuple of VM-UUID and interface MAC
address.
The following interface XML activates and uses the DHCP snooping:
<interface type='bridge'>
<source bridge='virbr0'/>
<filterref filter='clean-traffic'>
<parameter name='ip_learning' value='dhcp'/>
</filterref>
</interface>
Once an IP address has been detected on an interface, 'virsh dumpxml <vm>'
would show the IP address lease in the format <IP address>,<lease timeout
in seconds>:
<interface type='bridge'>
<source bridge='virbr0'/>
<filterref filter='clean-traffic'>
<parameter name='ip_learning' value='dhcp'/>
<parameter name='IP_LEASE' value='192.168.122.210,180'/>
</filterref>
</interface>
Regards,
David and Stefan
13 years