[libvirt] [PATCH]util: Helper function for checking existence of hook files for specific driver
by Chen Hanxiao
From: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
We refresh the status of hook scripts
only when start/restart libvirt or reloads its configuration.
But hooks scripts may be changed.
This function will help to check its existence.
And we do not need to start/restart libvirt if
we add/remove hook files.
Signed-off-by: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
---
src/util/virhook.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/util/virhook.c b/src/util/virhook.c
index 159efdb..c4a1a15 100644
--- a/src/util/virhook.c
+++ b/src/util/virhook.c
@@ -129,6 +129,12 @@ virHookCheck(int no, const char *driver) {
return ret;
}
+static int
+virHookDriverCheck(int driver) {
+ return virHookCheck(driver,
+ virHookDriverTypeToString(driver));
+}
+
/*
* virHookInitialize:
*
@@ -170,11 +176,12 @@ virHookPresent(int driver) {
if ((driver < VIR_HOOK_DRIVER_DAEMON) ||
(driver >= VIR_HOOK_DRIVER_LAST))
return 0;
- if (virHooksFound == -1)
+ if (virHookDriverCheck(driver) != 1) {
+ VIR_DEBUG("Driver %s hooks files not found",
+ virHookDriverTypeToString(driver));
return 0;
+ }
- if ((virHooksFound & (1 << driver)) == 0)
- return 0;
return 1;
}
--
1.8.2.1
11 years, 2 months
[libvirt] [PATCH v3 0/4] don't masquerade local broadcast/multicast packets
by Laszlo Ersek
Masquerading local broadcast breaks DHCP replies for some clients.
There has been a report about broken local multicast too.
(See references in the patches.)
Regarding multicast, right now the series disables masquerading for the
most restrictive local multicast range only.
v2->v3 changes:
- Rename iptables(Add|Remove)ForwardDontMasquerade to
iptables(Add|Remove)DontMasquerade [Laine].
- Pass (address, prefix) pairs as both source and destination parameters
to these functions.
- Introduce virPfxSocketAddr structure for simpler handling of said
(address, prefix) pairs.
- Also prevent masquerading of directed broadcast [Laine].
- Start to get serious about pointers-to-const.
Testing:
- "make check" and "make syntax-check" pass,
- thanks to the great docs on libvirt.org (compiling & deployment) I
even managed to test this on my RHEL-6 laptop, with repeated net-start
/ net-destroy commands.
Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 RETURN all -- * * 192.168.122.0/24 224.0.0.0/24
0 0 RETURN all -- * * 192.168.122.0/24 192.168.122.255
0 0 RETURN all -- * * 192.168.122.0/24 255.255.255.255
0 0 MASQUERADE tcp -- * * 192.168.122.0/24 !192.168.122.0/24 masq ports: 1024-65535
0 0 MASQUERADE udp -- * * 192.168.122.0/24 !192.168.122.0/24 masq ports: 1024-65535
0 0 MASQUERADE all -- * * 192.168.122.0/24 !192.168.122.0/24
Laszlo Ersek (4):
iptablesFormatNetwork(): constify target of "netaddr" parameter
util/viriptables: add/remove rules that short-circuit masquerading
virSocketAddrBroadcastByPrefix(): constify target of "addr" parameter
bridge driver: don't masquerade local subnet broadcast/multicast
packets
src/util/viriptables.h | 11 +++
src/util/virsocketaddr.h | 8 +-
src/network/bridge_driver_linux.c | 151 +++++++++++++++++++++++++++++++++++++-
src/util/viriptables.c | 84 ++++++++++++++++++++-
src/util/virsocketaddr.c | 8 +-
src/libvirt_private.syms | 2 +
6 files changed, 251 insertions(+), 13 deletions(-)
--
1.8.3.1
11 years, 2 months
[libvirt] [PATCH]util: Refresh virHook before checking its existence
by Chen Hanxiao
From: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
We refresh the status of hook scripts
only when start/stop libvirt, or reload its configuration.
But the status of hooks scripts may be changed.
We need to refresh its status before checking its existence.
Signed-off-by: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
---
src/util/virhook.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/util/virhook.c b/src/util/virhook.c
index 159efdb..5500f62 100644
--- a/src/util/virhook.c
+++ b/src/util/virhook.c
@@ -170,11 +170,15 @@ virHookPresent(int driver) {
if ((driver < VIR_HOOK_DRIVER_DAEMON) ||
(driver >= VIR_HOOK_DRIVER_LAST))
return 0;
- if (virHooksFound == -1)
- return 0;
+ if (virHookInitialize() > 0) {
+ if (virHooksFound == -1)
+ return 0;
- if ((virHooksFound & (1 << driver)) == 0)
+ if ((virHooksFound & (1 << driver)) == 0)
+ return 0;
+ } else {
return 0;
+ }
return 1;
}
--
1.8.2.1
11 years, 2 months
Re: [libvirt] virDomainGetInfo() returns wrong domain state
by Panday Ritesh Sharma (rpanday)
Hi Libvirt support team,
Could you please help me with below query.
Regards
Ritesh Sharma
From: Panday Ritesh Sharma (rpanday)
Sent: Tuesday, September 24, 2013 8:22 PM
To: 'libvir-list(a)redhat.com'; 'libvirt-users(a)redhat.com'; Vinay Shankarkumar (vinays)
Cc: Basavaraj Bendigeri (bbendige); q-se-dev(mailer list)
Subject: virDomainGetInfo() returns wrong domain state
Hi Team,
I have written below code to get the VM state at run time. I found, though the VM is in shut-off state, when I use the function virDomainGetInfo(); I get state as running. Could you please let me know what wrong I am doing. To know the actual VM state I used 'virsh list' and it clearly shows the VM is in shut-off state. Please find the log and code snippet below.
Log from virsh:
=================
[host:~]$ virsh list --all
Id Name State
----------------------------------------------------
1 calvados running
2 LCXR running
3 default-sdr--1 running
- test--2 shut off
Out put:
=========
04.03.06.698923264:INFO: vm_libvirt_state_to_vmm_state: state returned is 1
Note : Here 1 is actually running.
Code snippet:
===============
enum cidl_vmm_vm_state
vm_libvirt_state_to_vmm_state(unsigned char libvirt_state)
{
enum cidl_vmm_vm_state state;
INFO("%s: state returned is %u\n",__FUNCTION__, libvirt_state); <<<<<<<<<<<<<<<<<<
if (libvirt_state == VIR_DOMAIN_RUNNING) {
state = cidl_vm_state_running;
} else if ((libvirt_state == VIR_DOMAIN_PAUSED) ||
(libvirt_state == VIR_DOMAIN_BLOCKED)) {
state = cidl_vm_state_paused;
} else if (libvirt_state == VIR_DOMAIN_SHUTOFF) {
state = cidl_vm_state_defined;
} else {
state = cidl_vm_state_not_defined;
}
return state;
}
virDomainInfo res_util;
virDomainPtr dom = virDomainLookupByName(virt,
private_names[vm_idx]);
res = virDomainGetInfo(dom, &res_util);
vminfo[vm_idx].vm_state =
vm_libvirt_state_to_vmm_state(res_util.state);
Regards
Ritesh Sharma
11 years, 2 months
[libvirt] bug. libvirt related to selinux.
by yue
hi,all
when 'virsh start testname-1' failed, but i can start it throught commandline which is copy from libvirtd.log.
selinux is disabled now.
----------------
libvirtError: internal error Process exited while reading console log output: char device redirected to /dev/pts/3
qemu-kvm: -drive file=/rhev/data-center/7828f2ae-955e-4e4b-a4bb-43807629dc52/d028d521-d4a9-4dd7-a0fe-3e9b60e7c4e4/images/ac025dc1-4e25-4b71-8c56-88dcb61b9f09/c1bfddb4-3562-4893-9df8-3f3239b277a9,if=none,id=drive-ide0-0-0,format=qcow2,serial=ac025dc1-4e25-4b71-8c56-88dcb61b9f09,cache=none,werror=stop,rerror=stop,aio=native: could not open disk image /rhev/data-center/7828f2ae-955e-4e4b-a4bb-43807629dc52/d028d521-d4a9-4dd7-a0fe-3e9b60e7c4e4/images/ac025dc1-4e25-4b71-8c56-88dcb61b9f09/c1bfddb4-3562-4893-9df8-3f3239b277a9: Operation not permitted
audit.log
type=VIRT_CONTROL msg=audit(1379810795.213:41569): user pid=1637 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:virtd_t:s0-s0:c0.c1023 msg='virt=kvm op=start reason=booted vm="testname-1" uuid=24f7e975-9aa5-4a14-b0f0-590add14c8b5 vm-pid=-1 exe="/usr/sbin/libvirtd" hostname=? addr=? terminal=? res=failed'
11 years, 2 months
[libvirt] [PATCH v2 0/2] don't masquerade local broadcast/multicast packets
by Laszlo Ersek
Masquerading local broadcast breaks DHCP replies for some clients.
There has been a report about broken local multicast too.
(See references in the patches.)
Testing: build tested the upstream series. Tested the RHEL-6.4.z and
RHEL-7.0 backports with OVMF netboot on virbr0.
Changes between v1 (at
http://www.redhat.com/archives/libvir-list/2013-May/msg01872.html
) and v2:
- forward-ported to current upstream master (commit 49a5262d).
This includes conflict resolution for:
commit 477a619e1b37694e3c59c0d6c84ede6d2e28b878
Author: Roman Bogorodskiy <bogorodskiy(a)gmail.com>
Date: Fri Jun 28 00:52:30 2013 -0400
Drop iptablesContext
in both patches #1 and #2, and for
commit 4ac708f250867f65091a20b153c204862d389cb9
Author: Roman Bogorodskiy <bogorodskiy(a)gmail.com>
Date: Wed Jul 24 16:22:54 2013 +0400
bridge driver: extract platform specifics
in patch #2.
Laszlo Ersek (2):
util/viriptables: add/remove rules that short-circuit masquerading
bridge driver: don't masquerade local subnet broadcast/multicast
packets
src/util/viriptables.h | 8 ++++
src/network/bridge_driver_linux.c | 70 +++++++++++++++++++++++++++++--
src/util/viriptables.c | 88 +++++++++++++++++++++++++++++++++++++++
src/libvirt_private.syms | 2 +
4 files changed, 164 insertions(+), 4 deletions(-)
--
1.8.3.1
11 years, 2 months
[libvirt] [PATCH] Fix format specifier for OOM test fprintfs
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The testutils.c file had some fprintfs which had not been
converted from %d to %zu, when 'testCounter' change to be
a size_t. This was a build breaker if --enable-test-oom
was enabled
Pushed as a build fix
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
tests/testutils.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/testutils.c b/tests/testutils.c
index a215f3f..45882c5 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -717,9 +717,9 @@ int virtTestMain(int argc,
approxAlloc = virAllocTestCount();
testCounter++;
if (virTestGetDebug())
- fprintf(stderr, "%d) OOM...\n", testCounter);
+ fprintf(stderr, "%zu) OOM...\n", testCounter);
else
- fprintf(stderr, "%d) OOM of %d allocs ", testCounter, approxAlloc);
+ fprintf(stderr, "%zu) OOM of %d allocs ", testCounter, approxAlloc);
if (mp) {
size_t i;
--
1.8.3.1
11 years, 2 months
[libvirt] [PATCH 0/4] Improve passthrough of early errors from qemu log
by Peter Krempa
Upgrade error messages in some cases of early failure. See 4/4 for better
explanation.
Peter Krempa (4):
qemu_process: Make qemuProcessReadLog() more versatile and reusable
qemu: monitor: Add infrastructure to access VM logs for better err
msgs
qemu: monitor: Produce better errors on monitor hangup
qemu: Wire up better early error reporting
src/qemu/qemu_monitor.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++---
src/qemu/qemu_monitor.h | 2 +
src/qemu/qemu_process.c | 54 +++++++++++++++++++--------
src/qemu/qemu_process.h | 2 +
4 files changed, 133 insertions(+), 22 deletions(-)
--
1.8.3.2
11 years, 2 months
[libvirt] [PATCHv2 0/3] Change preference of default PCI passthrough type to VFIO
by Peter Krempa
Peter Krempa (3):
qemu: hostdev: Refactor PCI passhrough handling
qemu: hostdev: Add checks if PCI passthrough is availabe in the host
qemu: Prefer VFIO for PCI device passthrough
docs/formatdomain.html.in | 9 ++-
src/conf/domain_conf.h | 2 +-
src/qemu/qemu_command.c | 28 ++++++---
src/qemu/qemu_hostdev.c | 143 ++++++++++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_hostdev.h | 5 ++
src/qemu/qemu_hotplug.c | 29 ++++++----
src/qemu/qemu_process.c | 6 ++
tests/qemuxml2argvtest.c | 11 ++++
8 files changed, 208 insertions(+), 25 deletions(-)
--
1.8.3.2
11 years, 2 months
[libvirt] [PATCH] maint: update to latest gnulib
by Eric Blake
Since we're about to freeze, it's time to pick up the latest
upstream gnulib. Among other changes, gnulib now guarantees the
use of some -f flags that we were previously manually adding.
* .gnulib: Update to latest, in part for warning improvements.
* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Drop
flags that are now guaranteed by gnulib.
* bootstrap: Resync to gnulib.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Pushing under my gnulib maintenance rule.
* .gnulib 0ba0877...4a5ee89 (31):
> manywarnings: enable nicer gcc warning messages
> timespec: use the new TIMESPEC_RESOLUTION in a few more places
> warnings: port --enable-gcc-warnings to Solaris Studio 12.3
> configmake: support new --runstatedir option
> ctype, string: depend on extern-inline
> userspec: support optional parameters to parse_user_spec()
> timespec: new function make_timespec, and new constants
> stdio: OS X port of putc_unlocked + extern inline
> signal: OS X port of sigaddset etc. + extern inline
> extern-inline: do not always suppress extern inline on OS X
> extern-inline: document fixes for ctype and wctype macros
> fflush, freadahead, fseeko: Fix for Android
> pmccabe2html: fix portability issues
> getgroups: statement without effect
> autoupdate
> update from texinfo
> update from texinfo
> glob: fix compilation
> glob: fix build for platforms without __THROW
> autoupdate
> regex-quote: fix buffer access out of bounds
> glob: avoid -Wattribute warnings on glibc
> headers: check that _GL_INLINE_HEADER_BEGIN is defined
> bootstrap: remove the --version requirement from ancillary tools
> gc: support HMAC-SHA256 and HMAC-SHA512.
> gettext: update to version 0.18.3.1
> selinux-at: omit unnecessary include
> autoupdate
> d-ino: avoid false negative on symlink
> update from texinfo
> autoupdate
.gnulib | 2 +-
bootstrap | 19 +++++++++++--------
m4/virt-compile-warnings.m4 | 2 --
3 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/.gnulib b/.gnulib
index 0ba0877..4a5ee89 160000
--- a/.gnulib
+++ b/.gnulib
@@ -1 +1 @@
-Subproject commit 0ba087759d2797c8f7d3c34bef6268ba3fd212cb
+Subproject commit 4a5ee89c8a8be7350a8fd8ca1bacb196a190e492
diff --git a/bootstrap b/bootstrap
index cc7fc1b..e31d17d 100755
--- a/bootstrap
+++ b/bootstrap
@@ -209,12 +209,16 @@ bootstrap_sync=false
# Use git to update gnulib sources
use_git=true
+check_exists() {
+ ($1 --version </dev/null) >/dev/null 2>&1
+ test $? -lt 126
+}
+
# find_tool ENVVAR NAMES...
# -------------------------
# Search for a required program. Use the value of ENVVAR, if set,
-# otherwise find the first of the NAMES that can be run (i.e.,
-# supports --version). If found, set ENVVAR to the program name,
-# die otherwise.
+# otherwise find the first of the NAMES that can be run.
+# If found, set ENVVAR to the program name, die otherwise.
#
# FIXME: code duplication, see also gnu-web-doc-update.
find_tool ()
@@ -225,7 +229,7 @@ find_tool ()
eval "find_tool_res=\$$find_tool_envvar"
if test x"$find_tool_res" = x; then
for i; do
- if ($i --version </dev/null) >/dev/null 2>&1; then
+ if check_exists $i; then
find_tool_res=$i
break
fi
@@ -463,8 +467,7 @@ check_versions() {
if [ "$req_ver" = "-" ]; then
# Merely require app to exist; not all prereq apps are well-behaved
# so we have to rely on $? rather than get_version.
- $app --version >/dev/null 2>&1 </dev/null
- if [ 126 -le $? ]; then
+ if ! check_exists $app; then
warn_ "Error: '$app' not found"
ret=1
fi
@@ -551,10 +554,10 @@ fi
echo "$0: Bootstrapping from checked-out $package sources..."
# See if we can use gnulib's git-merge-changelog merge driver.
-if $use_git && test -d .git && (git --version) >/dev/null 2>/dev/null ; then
+if $use_git && test -d .git && check_exists git; then
if git config merge.merge-changelog.driver >/dev/null ; then
:
- elif (git-merge-changelog --version) >/dev/null 2>/dev/null ; then
+ elif check_exists git-merge-changelog; then
echo "$0: initializing git-merge-changelog driver"
git config merge.merge-changelog.name 'GNU-style ChangeLog merge driver'
git config merge.merge-changelog.driver 'git-merge-changelog %O %A %B'
diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4
index 938c8bb..8f905cc 100644
--- a/m4/virt-compile-warnings.m4
+++ b/m4/virt-compile-warnings.m4
@@ -187,8 +187,6 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
esac
wantwarn="$wantwarn -fexceptions"
wantwarn="$wantwarn -fasynchronous-unwind-tables"
- wantwarn="$wantwarn -fdiagnostics-show-option"
- wantwarn="$wantwarn -funit-at-a-time"
# Need -fipa-pure-const in order to make -Wsuggest-attribute=pure
# fire even without -O.
--
1.8.3.1
11 years, 2 months