[libvirt] [v7 0/6] Write separate module for hostdev passthrough
by Chunyan Liu
These patches implements a separate module for hostdev passthrough so that it
could be shared by different drivers and can maintain a global state of a host
device.
patch 1/6: extract hostdev passthrough function from qemu_hostdev.c and make it
reusable by multiple drivers.
patch 2/6: switch qemu driver to use the common library instead of its own
hostdev passthrough APIs.
patch 3/6: switch lxc driver to use the common library instead of its own
hostdev passthrough APIs.
patch 4/6: add a unit test for hostdev common library, based on virpcimock.
patch 5/6: add a hostdev pci backend type for xen usage. For xen, the default
stub driver would be 'pciback'.
patch 6/6: add pci passthrough to libxl driver.
---
Changes:
* fix v6 comments
* rebase to latest source code
* add unit test for hostdev common library
Chunyan Liu (6):
add hostdev passthrough common library
change qemu driver to use hostdev common library
change lxc driver to use hostdev common library
add unit test for hostdev common library
add hostdev pci backend type for xen
add pci passthrough to libxl driver
docs/schemas/domaincommon.rng | 1 +
po/POTFILES.in | 3 +-
src/Makefile.am | 3 +-
src/conf/domain_conf.c | 3 +-
src/conf/domain_conf.h | 1 +
src/libvirt_private.syms | 21 +
src/libxl/libxl_conf.c | 63 ++
src/libxl/libxl_conf.h | 4 +
src/libxl/libxl_domain.c | 9 +
src/libxl/libxl_driver.c | 448 +++++++++++-
src/lxc/lxc_conf.h | 4 -
src/lxc/lxc_driver.c | 47 +-
src/lxc/lxc_hostdev.c | 413 ----------
src/lxc/lxc_hostdev.h | 43 -
src/lxc/lxc_process.c | 24 +-
src/qemu/qemu_command.c | 4 +-
src/qemu/qemu_conf.h | 9 +-
src/qemu/qemu_domain.c | 22 +
src/qemu/qemu_driver.c | 81 +--
src/qemu/qemu_hostdev.c | 1454 -----------------------------------
src/qemu/qemu_hostdev.h | 76 --
src/qemu/qemu_hotplug.c | 136 ++--
src/qemu/qemu_process.c | 40 +-
src/util/virhostdev.c | 1703 +++++++++++++++++++++++++++++++++++++++++
src/util/virhostdev.h | 134 ++++
src/util/virpci.c | 30 +-
src/util/virpci.h | 9 +-
src/util/virscsi.c | 28 +-
src/util/virscsi.h | 8 +-
src/util/virusb.c | 29 +-
src/util/virusb.h | 8 +-
tests/Makefile.am | 5 +
tests/virhostdevtest.c | 481 ++++++++++++
tests/virpcimock.c | 45 ++-
34 files changed, 3177 insertions(+), 2212 deletions(-)
delete mode 100644 src/lxc/lxc_hostdev.c
delete mode 100644 src/lxc/lxc_hostdev.h
delete mode 100644 src/qemu/qemu_hostdev.c
delete mode 100644 src/qemu/qemu_hostdev.h
create mode 100644 src/util/virhostdev.c
create mode 100644 src/util/virhostdev.h
create mode 100644 tests/virhostdevtest.c
10 years, 11 months
[libvirt] Implementation deficiency in virInitctlSetRunLevel
by Reco
Hello, list.
I was pointed here by maintainer of libvirt package in Debian, Guido
Günther. For the sake of completeness, the original bug report can be
viewed at this link:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=732394
To sum up the bug report, current implementation of
virInitctlSetRunLevel function (src/util/virinitctl.c) lacks any sanity
checks before writing to container's /dev/initctl. In the absence of
such checks, libvirtd can be easily tricked to write runlevel check
request to an arbitrary main hosts' file (including
hosts' /run/initctl, as described in the bug report). All it takes is
one symlink in place of containers' /dev/initctl.
I've checked current libvirtd's git, and it seems to me that the
problem is still here.
Attached to this letter is a patch which tries to mitigate the issue by
checking whenever container's /dev/initctl is a pipe actually.
Sincerely yours, Reco
PS I'm not subscribed to this list, in case of further questions please
CC me.
10 years, 11 months
[libvirt] [PATCH] Remove stray semicolon after pragma macros
by Daniel P. Berrange
The VIR_WARNINGS_NO_CAST_ALIGN / VIR_WARNINGS_RESET should
not have any trailing ';' since they are pragmas. The use
of a ';' results in an empty statement which confuses CIL.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/nwfilter/nwfilter_dhcpsnoop.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c
index e8fcfef..a96a790 100644
--- a/src/nwfilter/nwfilter_dhcpsnoop.c
+++ b/src/nwfilter/nwfilter_dhcpsnoop.c
@@ -981,9 +981,9 @@ virNWFilterSnoopDHCPDecode(virNWFilterSnoopReqPtr req,
/* go through the protocol headers */
switch (ntohs(pep->eh_type)) {
case ETHERTYPE_IP:
- VIR_WARNINGS_NO_CAST_ALIGN;
+ VIR_WARNINGS_NO_CAST_ALIGN
pip = (struct iphdr *) pep->eh_data;
- VIR_WARNINGS_RESET;
+ VIR_WARNINGS_RESET
len -= offsetof(virNWFilterSnoopEthHdr, eh_data);
break;
default:
--
1.8.4.2
10 years, 11 months
[libvirt] [PATCH 0/2] undefine with storage fixes
by Peter Krempa
Two fixes related to the virsh undefine --storage command.
Peter Krempa (2):
virsh: man: Mention that volumes need to be in storage pool for
undefine
virsh: domain: Fix undefine with storage of 'volume' disks
tools/virsh-domain.c | 36 ++++++++++++++++++++++++++++++++++--
tools/virsh.pod | 3 ++-
2 files changed, 36 insertions(+), 3 deletions(-)
--
1.8.5.1
10 years, 11 months
[libvirt] [PATCH] Fix crash in virsystemdtest with dbus 1.7.6
by Cédric Bosdonnat
D-bus introduced some changes in its locking code. Overriding the init
function skips the new locking init and thus crashes later in libvirt
test. Removing the function makes the test pass again.
---
tests/virsystemdmock.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/tests/virsystemdmock.c b/tests/virsystemdmock.c
index b8fc031..b3b82b4 100644
--- a/tests/virsystemdmock.c
+++ b/tests/virsystemdmock.c
@@ -31,11 +31,6 @@ void dbus_connection_set_change_sigpipe(dbus_bool_t will_modify_sigpipe ATTRIBUT
{
}
-dbus_bool_t dbus_threads_init_default(void)
-{
- return 1;
-}
-
DBusConnection *dbus_bus_get(DBusBusType type ATTRIBUTE_UNUSED,
DBusError *error ATTRIBUTE_UNUSED)
{
--
1.8.4.4
10 years, 11 months
[libvirt] python pypi package - backport older version?
by Jason Antman
Hello,
First off, thanks for the wonderful project, and thanks even more for
all of the excellent work on the Python bindings lately.
I'm working on a small project to collect data on kvm hosts/guests via a
python collector client and display the data in a web interface. It
works beautifully when using my various distros' OS packages for
libvirt-python, but I've hit a bit of a snag when trying to do automated
testing. I'm quite happy to see libvirt-python packaged as a python
package and on pypi, but the version there is 1.2.0, which requires
libvirt >= 0.9.11.
Unfortunately, I was planning to test my python app on travis-ci, which
runs Ubuntu Precise (12.04 LTS), and the latest version of libvirt for
that is 0.9.8 (package python-libvirt 0.9.8-2ubuntu17.13).
If I were to submit a patch, would there be any interest in me
backporting the setup.py/packaging work to an older version of the
python bindings - say 0.9.8 - and getting it published on pypi?
Thanks,
Jason Antman
CMGdigital
Atlanta, GA
10 years, 11 months
[libvirt] [PATCH v2] libxl: libxl_get_max_cpus returning a libxl error from 4.4 onward
by Dario Faggioli
Starting from commit 2e82c18c in Xen (will be included in Xen 4.4)
both libxl_get_max_cpus() and libxl_get_max_ndoes() start returning
a proper libxl error code, in case of failure. This patch fixes
this in the libxl driver.
Note that, although it is now basically impossible for them to return
0, that would, theoretically, still be wrong. Also, checking that the
returned value is '<= 0' makes the code correct for both Xen 4.4 and
Xen 4.3 (and 4.2), and that is why we go for it (rather than
just '< 0').
Signed-off-by: Dario Faggioli <dario.faggioli(a)citrix.com>
Cc: Jim Fehlig <jfehlig(a)suse.com>
Cc: Ian Jackson <Ian.Jackson(a)eu.citrix.com>
Cc: Martin Kletzander <mkletzan(a)redhat.com>
---
Changes from v1:
* taking care of libxl_get_max_nodes() too
---
src/libxl/libxl_driver.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 692c3b7..29aa6c7 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -1101,9 +1101,11 @@ libxlConnectGetMaxVcpus(virConnectPtr conn, const char *type ATTRIBUTE_UNUSED)
cfg = libxlDriverConfigGet(driver);
ret = libxl_get_max_cpus(cfg->ctx);
- /* libxl_get_max_cpus() will return 0 if there were any failures,
- e.g. xc_physinfo() failing */
- if (ret == 0)
+ /* On failure, libxl_get_max_cpus() will return ERROR_FAIL from Xen 4.4
+ * onward, but it ever returning 0 is obviously wrong too (and it is
+ * what happens, on failure, on Xen 4.3 and earlier). Therefore, a 'less
+ * or equal' is the catchall we want. */
+ if (ret <= 0)
ret = -1;
virObjectUnref(cfg);
@@ -3980,6 +3982,7 @@ libxlDomainGetNumaParameters(virDomainPtr dom,
for (i = 0; i < LIBXL_NUMA_NPARAM && i < *nparams; i++) {
virMemoryParameterPtr param = ¶ms[i];
+ int numnodes;
switch (i) {
case 0:
@@ -3998,8 +4001,12 @@ libxlDomainGetNumaParameters(virDomainPtr dom,
/* Node affinity */
/* Let's allocate both libxl and libvirt bitmaps */
+ numnodes = libxl_get_max_nodes(priv->ctx);
+ if (numnodes <= 0)
+ goto cleanup;
+
if (libxl_node_bitmap_alloc(priv->ctx, &nodemap, 0) ||
- !(nodes = virBitmapNew(libxl_get_max_nodes(priv->ctx)))) {
+ !(nodes = virBitmapNew(numnodes))) {
virReportOOMError();
goto cleanup;
}
10 years, 11 months
[libvirt] [PATCH] Remove redefinition of bool type when --enable-test-locking
by Daniel P. Berrange
Old versions of CIL did not understand the 'bool' data type,
but at least 1.7.3 does now cope. We can remove the old hack
which redefined bool and no longer compiles successfully.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
configure.ac | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 5446634..675f1fc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2129,7 +2129,7 @@ AC_ARG_ENABLE([test-locking],
enable_locking=$enableval
if test "$enable_locking" = "yes"; then
- LOCK_CHECKING_CFLAGS="-Dbool=char -D_Bool=char -save-temps"
+ LOCK_CHECKING_CFLAGS="-save-temps"
AC_SUBST([LOCK_CHECKING_CFLAGS])
fi
AM_CONDITIONAL([WITH_CIL],[test "$enable_locking" = "yes"])
--
1.8.4.2
10 years, 11 months
[libvirt] libxl: cannot connect to PV console
by Dario Faggioli
Hey Jim,
I'm on libvirt.git's trunk and I see the following:
[xen@ghoul3 libvirt.git]$ sudo ./tools/virsh list
Id Name State
----------------------------------------------------
3 debian_32 running
4 fedora20_64 running
[xen@ghoul3 libvirt.git]$ sudo ./tools/virsh console debian_32
Connected to domain debian_32
Escape character is ^]
error: internal error: cannot find character device (null)
[xen@ghoul3 libvirt.git]$ sudo ./tools/virsh console fedora20_64
Connected to domain fedora20_64
Escape character is ^]
error: internal error: cannot find character device (null)
And this:
[xen@ghoul3 libvirt.git]$ sudo ./daemon/libvirtd -v
[sudo] password for xen:
2013-12-17 13:19:35.366+0000: 22124: info : libvirt version: 1.2.1
2013-12-17 14:00:06.587+0000: 22122: error : libxlDomainOpenConsole:3885 : internal error: cannot find character device (null)
2013-12-17 14:00:15.705+0000: 22125: error : libxlDomainOpenConsole:3885 : internal error: cannot find character device (null)
What I have in /var/log/libvirt/libxl does not look useful, while below
it comes my xenstore-ls.
What is it that is going wrong?
[xen@ghoul3 libvirt.git]$ sudo xenstore-ls
tool = ""
xenstored = ""
local = ""
domain = ""
0 = ""
name = "Domain-0"
domid = "0"
device-model = ""
0 = ""
state = "running"
memory = ""
target = "13118716"
static-max = "4294967292"
freemem-slack = "317576"
libxl = ""
disable_udev = "1"
backend = ""
vbd = ""
3 = ""
51712 = ""
frontend = "/local/domain/3/device/vbd/51712"
params = "/dev/fedora_ghoul3/debian_32"
script = "/etc/xen/scripts/block"
physical-device = "fd:2"
frontend-id = "3"
online = "1"
removable = "1"
bootable = "1"
state = "4"
dev = "xvda"
type = "phy"
mode = "w"
device-type = "disk"
feature-flush-cache = "1"
feature-discard = "0"
feature-barrier = "1"
feature-persistent = "1"
feature-max-indirect-segments = "256"
sectors = "10485760"
info = "0"
sector-size = "512"
physical-sector-size = "512"
4 = ""
51712 = ""
frontend = "/local/domain/4/device/vbd/51712"
params = "/dev/fedora_ghoul3/fedora20_64"
script = "/etc/xen/scripts/block"
physical-device = "fd:3"
frontend-id = "4"
online = "1"
removable = "1"
bootable = "1"
state = "4"
dev = "xvda"
type = "phy"
mode = "w"
device-type = "disk"
feature-flush-cache = "1"
feature-discard = "0"
feature-barrier = "1"
feature-persistent = "1"
feature-max-indirect-segments = "256"
sectors = "10485760"
info = "0"
sector-size = "512"
physical-sector-size = "512"
console = ""
3 = ""
0 = ""
frontend = "/local/domain/3/console"
frontend-id = "3"
online = "1"
state = "1"
domain = "debian_32"
protocol = "vt100"
4 = ""
0 = ""
frontend = "/local/domain/4/console"
frontend-id = "4"
online = "1"
state = "1"
domain = "fedora20_64"
protocol = "vt100"
vif = ""
3 = ""
0 = ""
frontend = "/local/domain/3/device/vif/0"
frontend-id = "3"
online = "1"
state = "4"
script = "/etc/xen/scripts/vif-bridge"
mac = "00:16:3e:9f:ea:e6"
bridge = "virbr0"
handle = "0"
type = "vif"
feature-sg = "1"
feature-gso-tcpv4 = "1"
feature-rx-copy = "1"
feature-rx-flip = "0"
feature-split-event-channels = "1"
hotplug-status = "connected"
4 = ""
0 = ""
frontend = "/local/domain/4/device/vif/0"
frontend-id = "4"
online = "1"
state = "4"
script = "/etc/xen/scripts/vif-bridge"
mac = "00:16:3e:a8:fd:05"
bridge = "virbr0"
handle = "0"
type = "vif"
feature-sg = "1"
feature-gso-tcpv4 = "1"
feature-rx-copy = "1"
feature-rx-flip = "0"
feature-split-event-channels = "1"
hotplug-status = "connected"
3 = ""
vm = "/vm/d3c586b2-f26d-4671-a6b3-6782fa01f49f"
name = "debian_32"
cpu = ""
0 = ""
availability = "online"
1 = ""
availability = "online"
memory = ""
static-max = "1048576"
target = "1048577"
videoram = "-1"
device = ""
suspend = ""
event-channel = ""
vbd = ""
51712 = ""
backend = "/local/domain/0/backend/vbd/3/51712"
backend-id = "0"
state = "4"
virtual-device = "51712"
device-type = "disk"
protocol = "x86_32-abi"
ring-ref = "8"
event-channel = "15"
feature-persistent = "1"
vif = ""
0 = ""
backend = "/local/domain/0/backend/vif/3/0"
backend-id = "0"
state = "4"
handle = "0"
mac = "00:16:3e:9f:ea:e6"
tx-ring-ref = "9"
rx-ring-ref = "10"
event-channel-tx = "16"
event-channel-rx = "17"
request-rx-copy = "1"
feature-rx-notify = "1"
feature-sg = "1"
feature-gso-tcpv4 = "1"
control = ""
shutdown = ""
platform-feature-multiprocessor-suspend = "1"
platform-feature-xs_reset_watches = "1"
data = ""
domid = "3"
store = ""
port = "1"
ring-ref = "1353957"
console = ""
backend = "/local/domain/0/backend/console/3/0"
backend-id = "0"
limit = "1048576"
type = "xenconsoled"
output = "pty"
tty = "/dev/pts/2"
port = "2"
ring-ref = "2366273"
4 = ""
vm = "/vm/d02acb9a-e99e-42ca-b2a4-9e32a65b9a0f"
name = "fedora20_64"
cpu = ""
0 = ""
availability = "online"
1 = ""
availability = "online"
memory = ""
static-max = "2097152"
target = "2097153"
videoram = "-1"
device = ""
suspend = ""
event-channel = ""
vbd = ""
51712 = ""
backend = "/local/domain/0/backend/vbd/4/51712"
backend-id = "0"
state = "4"
virtual-device = "51712"
device-type = "disk"
protocol = "x86_64-abi"
ring-ref = "8"
event-channel = "15"
feature-persistent = "1"
vif = ""
0 = ""
backend = "/local/domain/0/backend/vif/4/0"
backend-id = "0"
state = "4"
handle = "0"
mac = "00:16:3e:a8:fd:05"
tx-ring-ref = "135"
rx-ring-ref = "136"
event-channel-tx = "16"
event-channel-rx = "17"
request-rx-copy = "1"
feature-rx-notify = "1"
feature-sg = "1"
feature-gso-tcpv4 = "1"
control = ""
shutdown = ""
platform-feature-multiprocessor-suspend = "1"
platform-feature-xs_reset_watches = "1"
data = ""
domid = "4"
store = ""
port = "1"
ring-ref = "2486615"
console = ""
backend = "/local/domain/0/backend/console/4/0"
backend-id = "0"
limit = "1048576"
type = "xenconsoled"
output = "pty"
tty = "/dev/pts/4"
port = "2"
ring-ref = "1364170"
vm = ""
00000000-0000-0000-0000-000000000000 = ""
memory = "12811"
d3c586b2-f26d-4671-a6b3-6782fa01f49f = ""
uuid = "d3c586b2-f26d-4671-a6b3-6782fa01f49f"
name = "debian_32"
image = ""
ostype = "linux"
kernel = "/var/run/xen/bootloader.3.d/boot_kernel.eYl1YW"
ramdisk = "/var/run/xen/bootloader.3.d/boot_ramdisk.BxZLo9"
cmdline = "root=UUID=9df3cd14-ed12-4cee-a252-d0cd29f75b55 ro quiet"
start_time = "1387288160.47"
d02acb9a-e99e-42ca-b2a4-9e32a65b9a0f = ""
uuid = "d02acb9a-e99e-42ca-b2a4-9e32a65b9a0f"
name = "fedora20_64"
image = ""
ostype = "linux"
kernel = "/var/run/xen/bootloader.4.d/boot_kernel.w1Ntxo"
ramdisk = "/var/run/xen/bootloader.4.d/boot_ramdisk.XU7an0"
cmdline = "root=/dev/mapper/fedora-root ro rd.lvm.lv=fedora/swap rd.lvm.lv=fedora/root vconsole.font=latarcyrheb-sun16 LANG=en_US.UTF-8"
start_time = "1387288245.20"
libxl = ""
3 = ""
dm-version = "qemu_xen"
4 = ""
dm-version = "qemu_xen"
Regards,
Dario
--
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
10 years, 11 months
[libvirt] [PATCH] build: fix building with '--enable-test-locking'
by Martin Kletzander
When test-locking is enabled, CFLAGS have -Dbool=char, which makes
pipefd[bool] fail (obviously). Forcing the subscript to be bool by
double negation fixes the build breaker.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
Notes:
I still can't build with '--enable-test-locking' and I'm not sure this
is the proper way to fix it. Also, the code wasn't touched for
months, so I'm not pushing it as a build-breaker.
src/util/virfile.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 631cd06..88674ec 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -262,7 +262,7 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned int flags)
}
VIR_FORCE_CLOSE(*fd);
- *fd = pipefd[output];
+ *fd = pipefd[!!output];
return ret;
error:
--
1.8.5.1
10 years, 11 months