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
Osier Yang 3f29d6c91f qemu: Do not free the device from activePciHostdevs if it's in use
* src/qemu/qemu_hostdev.c (qemuDomainReAttachHostdevDevices):
pciDeviceListFree(pcidevs) in the end free()s the device even if
it's in use by other domain, which can cause a race.

How to reproduce:

<script>

virsh nodedev-dettach pci_0000_00_19_0
virsh start test
virsh attach-device test hostdev.xml
virsh start test2

for i in {1..5}; do
        echo "[ -- ${i}th time --]"
        virsh nodedev-reattach pci_0000_00_19_0
done

echo "clean up"
virsh destroy test
virsh nodedev-reattach pci_0000_00_19_0
</script>

Device pci_0000_00_19_0 dettached

Domain test started

Device attached successfully

error: Failed to start domain test2
error: Requested operation is not valid: PCI device 0000:00:19.0 is in use by domain test

[ -- 1th time --]
Device pci_0000_00_19_0 re-attached

[ -- 2th time --]
Device pci_0000_00_19_0 re-attached

[ -- 3th time --]
Device pci_0000_00_19_0 re-attached

[ -- 4th time --]
Device pci_0000_00_19_0 re-attached

[ -- 5th time --]
Device pci_0000_00_19_0 re-attached

clean up
Domain test destroyed

Device pci_0000_00_19_0 re-attached

The patch also fixes another problem, there won't be error like
"qemuDomainReAttachHostdevDevices: Not reattaching active
device 0000:00:19.0" in daemon log if some device is in active.
As pciResetDevice and pciReattachDevice won't be called for
the device anymore. This is sensible as we already reported
error when preparing the device if it's active. Blindly trying
to pciResetDevice & pciReattachDevice on the device and getting
an error is just redundant.
2011-12-15 10:18:20 +08:00
.gnulib@6b93d00f54 build: update to latest gnulib 2011-12-01 14:12:59 -07:00
daemon build: follow directory install conventions 2011-12-12 10:26:57 -07:00
docs docs: document <address> elements in one place 2011-12-12 12:03:32 -07:00
examples examples: Update event tests for shutdown event 2011-12-05 17:35:29 +01:00
gnulib build: update to latest gnulib 2011-12-01 14:12:59 -07:00
include qemu: Rework handling of shutdown event 2011-12-05 14:14:31 +01:00
m4 build: reduce warnings from older gcc 2011-12-05 10:14:55 -07:00
po Release of libvirt-0.9.8 2011-12-08 15:13:50 +08:00
python python: Fix export of virDomainSnapshotListChildrenNames 2011-12-13 23:29:28 +01:00
src qemu: Do not free the device from activePciHostdevs if it's in use 2011-12-15 10:18:20 +08:00
tests tests: plug memory leak on linuxTestNodeInfo 2011-12-13 10:03:01 +01:00
tools virsh: support multifunction in attach-disk 2011-12-13 16:15:20 -07:00
.dir-locals.el maint: let emacs avoid tabs in rng files 2011-08-13 08:56:26 -06:00
.gitignore Define keepalive protocol 2011-11-24 11:44:08 +01:00
.gitmodules make .gnulib a submodule 2009-07-08 16:17:51 +02:00
.mailmap maint: use mailmap, not AUTHORS, for secondary addresses 2011-11-11 08:56:19 -07:00
AUTHORS Maint: Update AUTHORs 2011-12-12 21:58:52 +08:00
autobuild.sh spec: mingw cleanups 2011-10-13 09:21:02 -06:00
autogen.sh build: allow for local gnulib diffs 2011-11-09 09:03:33 -07:00
bootstrap build: fix compilation on mingw64 2011-08-19 07:20:10 -06:00
bootstrap.conf maint: allow bootstrap in a sandbox 2011-12-08 14:37:15 -07:00
cfg.mk build: update to latest gnulib 2011-12-01 14:12:59 -07:00
ChangeLog-old generate ChangeLog from git logs into distribution tarball 2009-07-08 16:17:51 +02:00
configure.ac Release of libvirt-0.9.8 2011-12-08 15:13:50 +08:00
COPYING.LIB remove all trailing blank lines 2009-07-16 15:06:42 +02:00
HACKING Document STREQ_NULLABLE and STRNEQ_NULLABLE 2011-10-06 16:50:38 +02:00
libvirt.pc.in * libvirt.pc.in: applied patch from Daniel Berrange to fix --cflags 2006-03-24 13:18:12 +00:00
libvirt.spec.in spec: fix inverted logic on sanlock 2011-12-14 10:31:30 -07:00
Makefile.am maint: add missing copyright notices 2011-07-28 15:01:17 -06:00
Makefile.nonreentrant Ban use of all inet_* functions 2010-10-22 11:59:23 +01:00
mingw32-libvirt.spec.in spec: make it easier to autoreconf when building rpm 2011-12-08 09:49:50 -07: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
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>