qemu modularization of qemu-5.1 vs libvirt domcapabilities cache?
by Mark Mielke
Hi all:
In testing qemu-5.1rc2 on my Fedora 32 home system, I found that the Fedora
rawhide package has broken out both the QXL display device and the USB
redirect device into separate RPM modules:
qemu-device-display-qxl.x86_64 2:5.1.0-0.1.rc2.fc32
@@commandline
qemu-device-usb-redirect.x86_64 2:5.1.0-0.1.rc2.fc32
@@commandline
The upgrade from 5.0.0 to 5.1.0 does not treat these sub-packages as
mandatory packages, therefore a straight upgrade of packages causes these
domcapabilities to disappear.
If the user tries to use libvirt after this, then existing domains using
QXL display device or USB redirect device will fail to start. If the user
then investigates and realizes that they now need to install the above
packages separately, they find that qemu-kvm recognizes the modules right
away, but libvirt does not. This looks to be due to the libvirt
domcapabilities cache?
The domcapabilities cache will be automatically updated only under certain
conditions such as the qemu binary ctime changing - but that isn't
triggering any action here? With the devices broken out into modules, such
as the Fedora rawhide RPM .spec file is proposing, this allows the devices
to be individually installed or uninstalled at any time, and causes libvirt
domcapabilities cache to be out-of-date.
I was able to sometimes see it work by downgrading to qemu-5.0, upgrading
to qemu-5.1rc2, and installing the device packages prior to calling "virsh
domcapabilities" (or otherwise using them). I was also able to do the same
by removing the libvirt cache files and restarted libvirtd service. Both of
these are pretty non-obvious actions for a user.
I'm wondering how to codify this when I use it for real on a production
system. The upgrade path here seems unreliable, especially given that
libvirt domcapabilities cache may even persist across reboots? This means I
need to be very careful about the procedure to upgrade, and also I need to
make sure to never install or remove any of the device packages without
checking the procedure. Ouch. :-(
Thoughts?
--
Mark Mielke <mark.mielke(a)gmail.com>
4 years, 3 months
[PATCH] lxc: Add TPM passthrough option for LXC driver
by Julio Faracco
There is no support to use TPM for passthrough for LXC libvirt driver
this commit adds the option to use host TPM inside containers.
Signed-off-by: Julio Faracco <jcfaracco(a)gmail.com>
---
src/lxc/lxc_cgroup.c | 27 +++++++++++++++++++
src/lxc/lxc_controller.c | 56 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 83 insertions(+)
diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c
index d13f2adde5..955d2b4fc1 100644
--- a/src/lxc/lxc_cgroup.c
+++ b/src/lxc/lxc_cgroup.c
@@ -374,6 +374,33 @@ static int virLXCCgroupSetupDeviceACL(virDomainDefPtr def,
return -1;
}
+ for (i = 0; i < def->ntpms; i++) {
+ virDomainTPMDefPtr tpm = def->tpms[i];
+ const char *dev = NULL;
+
+ switch (tpm->type) {
+ case VIR_DOMAIN_TPM_TYPE_EMULATOR:
+ case VIR_DOMAIN_TPM_TYPE_LAST:
+ break;
+ case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
+ dev = "/dev/tpm0";
+ break;
+ }
+
+ if (!dev)
+ continue;
+
+ if (!virFileExists(dev)) {
+ VIR_DEBUG("Ignoring non-existent device %s", dev);
+ continue;
+ }
+
+ if (virCgroupAllowDevicePath(cgroup, dev,
+ VIR_CGROUP_DEVICE_READ,
+ false) < 0)
+ return -1;
+ }
+
VIR_DEBUG("Device ACL setup complete");
return 0;
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index ae6b737b60..70ca773bbf 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -1644,6 +1644,59 @@ virLXCControllerSetupHostdevSubsysUSB(virDomainDefPtr vmDef,
}
+static int
+virLXCControllerSetupTPM(virLXCControllerPtr ctrl)
+{
+ virDomainDefPtr def = ctrl->def;
+ size_t i;
+
+ for (i = 0; i < def->ntpms; i++) {
+ virDomainTPMDefPtr tpm = def->tpms[i];
+ g_autofree char *path = NULL;
+ const char *tpm_dev = NULL;
+ struct stat sb;
+ dev_t dev;
+
+ switch (tpm->type) {
+ case VIR_DOMAIN_TPM_TYPE_EMULATOR:
+ case VIR_DOMAIN_TPM_TYPE_LAST:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unsupported timer type (name) '%s'"),
+ virDomainTPMBackendTypeToString(tpm->type));
+ return -1;
+ case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
+ tpm_dev = "/dev/tpm0";
+ path = g_strdup_printf("/%s/%s.dev/%s", LXC_STATE_DIR,
+ def->name, "/rtc");
+ break;
+ }
+
+ if (!tpm_dev)
+ continue;
+
+ if (stat(tpm_dev, &sb) < 0) {
+ virReportSystemError(errno, _("Unable to access %s"),
+ tpm_dev);
+ return -1;
+ }
+
+ dev = makedev(major(sb.st_rdev), minor(sb.st_rdev));
+ if (mknod(path, S_IFCHR, dev) < 0 ||
+ chmod(path, sb.st_mode)) {
+ virReportSystemError(errno,
+ _("Failed to make device %s"),
+ path);
+ return -1;
+ }
+
+ if (lxcContainerChown(def, path) < 0)
+ return -1;
+ }
+
+ return 0;
+}
+
+
static int
virLXCControllerSetupHostdevCapsStorage(virDomainDefPtr vmDef,
virDomainHostdevDefPtr def,
@@ -2358,6 +2411,9 @@ virLXCControllerRun(virLXCControllerPtr ctrl)
if (virLXCControllerSetupAllHostdevs(ctrl) < 0)
goto cleanup;
+ if (virLXCControllerSetupTPM(ctrl) < 0)
+ goto cleanup;
+
if (virLXCControllerSetupFuse(ctrl) < 0)
goto cleanup;
--
2.25.1
4 years, 3 months
[PATCH 0/2] Fix a few deadlocks with musl libc
by Natanael Copa
Fix a couple of deadlocks due to use of async-unsafe calls (malloc/free)
after fork() and before exec(). They don't fix all theoretical problems
but at least they make libvirt usable again with musl 1.2 on Alpine Linux.
Natanael Copa (2):
util: avoid free() when reset log after fork
util: command: improve generic mass close of fds
src/util/vircommand.c | 80 ++++++++++++++++++++++++++++++++-----------
src/util/virlog.c | 44 ++++++++++++++++++------
src/util/virlog.h | 1 +
3 files changed, 95 insertions(+), 30 deletions(-)
--
2.28.0
4 years, 3 months
[PATCH] virdevmapper: Ignore all errors when opening /dev/mapper/control
by Michal Privoznik
So far, only ENOENT is ignored (to deal with kernels without
devmapper). However, as reported on the list, under certain
scenarios a different error can occur. For instance, when libvirt
is running inside a container which doesn't have permissions to
talk to the devmapper. If this is the case, then open() returns
-1 and sets errno=EPERM.
Assuming that multipath devices are fairly narrow use case and
using them in a restricted container is even more narrow the best
fix seems to be to ignore all open errors BUT produce a warning
on failure. To avoid flooding logs with warnings on kernels
without devmapper the level is reduced to a plain debug message.
Reported-by: Christian Ehrhardt <christian.ehrhardt(a)canonical.com>
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/util/virdevmapper.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/src/util/virdevmapper.c b/src/util/virdevmapper.c
index 3cc399f382..7c89c2a952 100644
--- a/src/util/virdevmapper.c
+++ b/src/util/virdevmapper.c
@@ -35,9 +35,12 @@
# include "viralloc.h"
# include "virstring.h"
# include "virfile.h"
+# include "virlog.h"
# define VIR_FROM_THIS VIR_FROM_STORAGE
+VIR_LOG_INIT("util.virdevmapper");
+
# define PROC_DEVICES "/proc/devices"
# define DM_NAME "device-mapper"
# define DEV_DM_DIR "/dev/" DM_DIR
@@ -130,11 +133,15 @@ virDMOpen(void)
memset(&dm, 0, sizeof(dm));
if ((controlFD = open(CONTROL_PATH, O_RDWR)) < 0) {
- if (errno == ENOENT)
- return -2;
-
- virReportSystemError(errno, _("Unable to open %s"), CONTROL_PATH);
- return -1;
+ /* We can't talk to devmapper. Produce a warning and let
+ * the caller decide what to do next. */
+ if (errno == ENOENT) {
+ VIR_DEBUG("device mapper not available");
+ } else {
+ VIR_WARN("unable to open %s: %s",
+ CONTROL_PATH, g_strerror(errno));
+ }
+ return -2;
}
if (!virDMIoctl(controlFD, DM_VERSION, &dm, &tmp)) {
@@ -309,9 +316,9 @@ virDevMapperGetTargets(const char *path,
if ((controlFD = virDMOpen()) < 0) {
if (controlFD == -2) {
- /* The CONTROL_PATH doesn't exist. Probably the
- * module isn't loaded, yet. Don't error out, just
- * exit. */
+ /* The CONTROL_PATH doesn't exist or is unusable.
+ * Probably the module isn't loaded, yet. Don't error
+ * out, just exit. */
return 0;
}
--
2.26.2
4 years, 3 months
[libvirt PATCH 0/2] meson: AppArmor fixes
by Andrea Bolognani
Found while updating the Debian package for libvirt to a snapshot
taken from master. Possibly more to come.
Andrea Bolognani (2):
meson: Set WITH_APPARMOR_PROFILES
meson: Don't hardcode /etc in APPARMOR_DIR
meson.build | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
--
2.26.2
4 years, 3 months
[libvirt PATCH 0/2] meson: Introduce rpath option
by Andrea Bolognani
See 1/2 for details.
Andrea Bolognani (2):
meson: Introduce rpath option
spec: Disable RPATH
libvirt.spec.in | 1 +
meson.build | 7 +
meson_options.txt | 1 +
src/meson.build | 485 +++++++++++++++++++++++++++++++---------------
tools/meson.build | 332 ++++++++++++++++++++-----------
5 files changed, 567 insertions(+), 259 deletions(-)
--
2.26.2
4 years, 3 months
libvirt 6.6.0 tarball breaks on Homebrew/MacOS
by Scott Shambarger
The latest release at https://libvirt.org/sources/libvirt-6.6.0.tar.xz
includes a configure script that breaks Homebrew (and other builds on
MacOS/Darwin). The breaking change is related to a new version of the
file m4/libtool.m4; line 2648 was changed to:
shrext_cmds='`test .$module = .yes && echo .bundle || echo .dylib`'
However, src/driver.c loads modules with ".so" extensions, at line 56:
if (!(modfile = virFileFindResourceFull(name,
"libvirt_driver_",
".so",
The released tarball for 6.5.0 had the same shrext_cmds as upstream
libtool:
shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
Not sure where to submit the issue (as the m4 files aren't in libvirt
source control)... it appears to only affect the distribution tarball.
Perhaps the tarball could be re-released with autoconf from the official
upstream libtool? (2.4.6)
Thanks,
Scott
PS. MacPorts is unaffected as it runs autogen.sh... but that shouldn't
be necessary with a distribution tarball :)
4 years, 3 months
[libvirt PATCH 0/2] meson: Small style fixes
by Andrea Bolognani
All pushed as trivial.
Andrea Bolognani (2):
meson: Fix indentation
meson: Don't use spaces after parentheses
meson.build | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
--
2.26.2
4 years, 3 months
[libvirt PATCH] meson: Fix typo supprt -> support
by Andrea Bolognani
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
Pushed as trivial.
meson_options.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/meson_options.txt b/meson_options.txt
index 1d19094e2e..c538d323c1 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -36,7 +36,7 @@ option('pciaccess', type: 'feature', value: 'auto', description: 'pciaccess supp
option('polkit', type: 'feature', value: 'auto', description: 'use PolicyKit for UNIX socket access checks')
option('readline', type: 'feature', value: 'auto', description: 'readline support')
option('sanlock', type: 'feature', value: 'auto', description: 'sanlock support')
-option('sasl', type: 'feature', value: 'auto', description: 'sasl supprt')
+option('sasl', type: 'feature', value: 'auto', description: 'sasl support')
option('selinux', type: 'feature', value: 'auto', description: 'selinux support')
option('selinux_mount', type: 'string', value: '', description: 'set SELinux mount point')
option('udev', type: 'feature', value: 'auto', description: 'udev support')
--
2.26.2
4 years, 3 months