Libvirt provides a portable, long term stable C API for managing the virtualization technologies provided by many operating systems. It includes support for QEMU, KVM, Xen, LXC, bhyve, Virtuozzo, VMware vCenter and ESX, VMware Desktop, Hyper-V, VirtualBox and the POWER Hypervisor.
Go to file
Laine Stump 58320848d2 util: do a better job of matching up pids with their binaries
This patch resolves: https://bugzilla.redhat.com/show_bug.cgi?id=871201

If libvirt is restarted after updating the dnsmasq or radvd packages,
a subsequent "virsh net-destroy" will fail to kill the dnsmasq/radvd
process.

The problem is that when libvirtd restarts, it re-reads the dnsmasq
and radvd pidfiles, then does a sanity check on each pid it finds,
including checking that the symbolic link in /proc/$pid/exe actually
points to the same file as the path used by libvirt to execute the
binary in the first place. If this fails, libvirt assumes that the
process is no longer alive.

But if the original binary has been replaced, the link in /proc is set
to "$binarypath (deleted)" (it literally has the string " (deleted)"
appended to the link text stored in the filesystem), so even if a new
binary exists in the same location, attempts to resolve the link will
fail.

In the end, not only is the old dnsmasq/radvd not terminated when the
network is stopped, but a new dnsmasq can't be started when the
network is later restarted (because the original process is still
listening on the ports that the new process wants).

The solution is, when the initial "use stat to check for identical
inodes" check for identity between /proc/$pid/exe and $binpath fails,
to check /proc/$pid/exe for a link ending with " (deleted)" and if so,
truncate that part of the link and compare what's left with the
original binarypath.

A twist to this problem is that on systems with "merged" /sbin and
/usr/sbin (i.e. /sbin is really just a symlink to /usr/sbin; Fedora
17+ is an example of this), libvirt may have started the process using
one path, but /proc/$pid/exe lists a different path (indeed, on F17
this is the case - libvirtd uses /sbin/dnsmasq, but /proc/$pid/exe
shows "/usr/sbin/dnsmasq"). The further bit of code to resolve this is
to call virFileResolveAllLinks() on both the original binarypath and
on the truncated link we read from /proc/$pid/exe, and compare the
results.

The resulting code still succeeds in all the same cases it did before,
but also succeeds if the binary was deleted or replaced after it was
started.
(cherry picked from commit 7bafe009d9)
2012-12-09 16:07:04 -05:00
.gnulib@b4938324b7 build: avoid infinite autogen loop 2012-10-27 15:06:31 -04:00
build-aux maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
daemon daemon: Avoid 'Could not find keytab file' in syslog 2012-10-27 15:11:09 -04:00
docs documentation: HTML tag fix 2012-10-27 15:16:41 -04:00
examples maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
gnulib build: fix fresh checkout on RHEL5 2012-04-19 17:11:43 -06:00
include maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
m4 build: avoid -Wno-format on new-enough gcc 2012-10-18 13:11:29 -04:00
po Prep for release 0.10.2.1 2012-10-27 16:57:20 -04:00
python Properly parse (unsigned) long long 2012-10-18 13:19:51 -04:00
src util: do a better job of matching up pids with their binaries 2012-12-09 16:07:04 -05:00
tests qemu: pass -usb and usb hubs earlier, so USB disks with static address are handled properly 2012-12-09 15:43:01 -05:00
tools virsh: Fix segfault of snapshot-list 2012-10-27 15:11:48 -04:00
.dir-locals.el build: avoid tabs that failed syntax-check 2012-09-06 09:43:46 -06:00
.gitignore Autogenerate AUTHORS 2012-10-27 15:07:44 -04:00
.gitmodules make .gnulib a submodule 2009-07-08 16:17:51 +02:00
.mailmap Autogenerate AUTHORS 2012-10-27 15:07:44 -04:00
AUTHORS.in Remove a couple duplicates from AUTHORS.in 2012-10-27 15:14:05 -04:00
autobuild.sh Switch automated builds to use Mingw64 toolchain instead of Mingw32 2012-06-25 10:41:10 +01:00
autogen.sh build: avoid infinite autogen loop 2012-10-27 15:06:31 -04:00
bootstrap maint: regenerate bootstrap 2012-07-27 09:34:04 -06:00
bootstrap.conf Autogenerate AUTHORS 2012-10-27 15:07:44 -04:00
cfg.mk util: do a better job of matching up pids with their binaries 2012-12-09 16:07:04 -05:00
ChangeLog-old virterror.c: Fix several spelling mistakes 2012-02-03 11:32:51 -07:00
configure.ac Prep for release 0.10.2.1 2012-10-27 16:57:20 -04:00
COPYING.LIB remove all trailing blank lines 2009-07-16 15:06:42 +02:00
HACKING Update how to compile with -Werror 2012-10-17 16:18:22 -04:00
libvirt.pc.in build: silence warning from autoconf 2012-05-30 09:22:02 -06:00
libvirt.spec.in add ppc64 and s390x to arches where qemu-kvm exists 2012-11-16 11:07:05 -07:00
Makefile.am Autogenerate AUTHORS 2012-10-27 15:07:44 -04:00
Makefile.nonreentrant Ban use of all inet_* functions 2010-10-22 11:59:23 +01:00
mingw-libvirt.spec.in parallels: add driver skeleton 2012-08-01 11:44:26 +08:00
README Correct typos in the documentation (Atsushi SAKAI) 2008-01-24 10:15:13 +00:00
README-hacking maint: relax git minimum version 2010-02-24 14:29:27 -05:00
run.in syntax-check: fix run.in 2012-09-18 13:59:53 +02:00
TODO Update todo list file to point at bugzilla/website 2010-10-13 16:45:26 +01:00

         LibVirt : simple API for virtualization

  Libvirt is a C toolkit to interact with the virtualization capabilities
of recent versions of Linux (and other OSes). It is free software
available under the GNU Lesser General Public License. Virtualization of
the Linux Operating System means the ability to run multiple instances of
Operating Systems concurrently on a single hardware system where the basic
resources are driven by a Linux instance. The library aim at providing
long term stable C API initially for the Xen paravirtualization but
should be able to integrate other virtualization mechanisms if needed.

Daniel Veillard <veillard@redhat.com>