[libvirt] [PATCH] lib: Avoid double free when passing FDs with virCommandPassFD()
by Michal Privoznik
If an FD is passed into a child using:
virCommandPassFD(cmd, fd, VIR_COMMAND_PASS_FD_CLOSE_PARENT);
then the parent should refrain from touching @fd thereafter. This
is even documented in virCommandPassFD() comment. The reason is
that either at virCommandRun()/virCommandRunAsync() or
virCommandFree() time the @fd will be closed. Closing it earlier,
e.g. right after virCommandPassFD() call might result in
undesired results. Another thread might open a file and receive
the same FD which is then unexpectedly closed by virCommandFree()
or virCommandRun().
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_command.c | 10 ++++++----
src/util/virpolkit.c | 1 +
tests/commandtest.c | 2 +-
3 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index bf1fb539b1..92bd1524db 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8978,17 +8978,19 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
if (qemuSecuritySetTapFDLabel(driver->securityManager,
def, tapfd[i]) < 0)
goto cleanup;
- virCommandPassFD(cmd, tapfd[i],
- VIR_COMMAND_PASS_FD_CLOSE_PARENT);
if (virAsprintf(&tapfdName[i], "%d", tapfd[i]) < 0)
goto cleanup;
+ virCommandPassFD(cmd, tapfd[i],
+ VIR_COMMAND_PASS_FD_CLOSE_PARENT);
+ tapfd[i] = -1;
}
for (i = 0; i < vhostfdSize; i++) {
- virCommandPassFD(cmd, vhostfd[i],
- VIR_COMMAND_PASS_FD_CLOSE_PARENT);
if (virAsprintf(&vhostfdName[i], "%d", vhostfd[i]) < 0)
goto cleanup;
+ virCommandPassFD(cmd, vhostfd[i],
+ VIR_COMMAND_PASS_FD_CLOSE_PARENT);
+ vhostfd[i] = -1;
}
if (chardev)
diff --git a/src/util/virpolkit.c b/src/util/virpolkit.c
index 25eaad2c63..634b46e82b 100644
--- a/src/util/virpolkit.c
+++ b/src/util/virpolkit.c
@@ -187,6 +187,7 @@ virPolkitAgentCreate(void)
virCommandSetOutputFD(agent->cmd, &outfd);
virCommandSetErrorFD(agent->cmd, &errfd);
virCommandPassFD(agent->cmd, pipe_fd[1], VIR_COMMAND_PASS_FD_CLOSE_PARENT);
+ pipe_fd[1] = -1;
if (virCommandRunAsync(agent->cmd, NULL) < 0)
goto error;
diff --git a/tests/commandtest.c b/tests/commandtest.c
index 816a70860f..146cc4c1bf 100644
--- a/tests/commandtest.c
+++ b/tests/commandtest.c
@@ -1024,6 +1024,7 @@ static int test24(const void *unused ATTRIBUTE_UNUSED)
virCommandDaemonize(cmd);
virCommandPassFD(cmd, newfd2, VIR_COMMAND_PASS_FD_CLOSE_PARENT);
virCommandPassFD(cmd, newfd3, VIR_COMMAND_PASS_FD_CLOSE_PARENT);
+ newfd2 = newfd3 = -1;
virCommandPassListenFDs(cmd);
if (virCommandRun(cmd, NULL) < 0) {
@@ -1053,7 +1054,6 @@ static int test24(const void *unused ATTRIBUTE_UNUSED)
VIR_FREE(prefix);
virCommandFree(cmd);
VIR_FORCE_CLOSE(newfd1);
- /* coverity[double_close] */
VIR_FORCE_CLOSE(newfd2);
VIR_FORCE_CLOSE(newfd3);
return ret;
--
2.21.0
5 years, 7 months
[libvirt] [PATCH] examples: Fix installation on Windows
by Andrea Bolognani
We can't rely on $(noinst_PROGRAMS) retaining its original
value, so let's use a separate $(EXAMPLES) variable instead.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
examples/Makefile.am | 35 ++++++++++++++++++++++++++++-------
1 file changed, 28 insertions(+), 7 deletions(-)
diff --git a/examples/Makefile.am b/examples/Makefile.am
index c7688c7c3d..11c9f44917 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -34,11 +34,32 @@ LDADD = $(STATIC_BINARIES) $(WARN_CFLAGS) \
$(top_builddir)/src/libvirt.la \
$(top_builddir)/src/libvirt-admin.la
-noinst_PROGRAMS=dominfo/info1 dommigrate/dommigrate domsuspend/suspend \
- domtop/domtop hellolibvirt/hellolibvirt object-events/event-test \
- openauth/openauth rename/rename admin/list_servers admin/list_clients \
- admin/threadpool_params admin/client_limits admin/client_info \
- admin/client_close admin/logging
+# List of example programs. We need to list them here instead of using
+# $(noinst_PROGRAMS) directly because we want to have access to the
+# unmodified list during (un)installation, but at the same time automake
+# might tweak $(noinst_PROGRAMS) to eg. automatically add the .exe file
+# extension when targeting Windows.
+EXAMPLES = \
+ admin/client_close \
+ admin/client_info \
+ admin/client_limits \
+ admin/list_clients \
+ admin/list_servers \
+ admin/logging \
+ admin/threadpool_params \
+ dominfo/info1 \
+ dommigrate/dommigrate \
+ domsuspend/suspend \
+ domtop/domtop \
+ hellolibvirt/hellolibvirt \
+ object-events/event-test \
+ openauth/openauth \
+ rename/rename \
+ $(NULL)
+
+noinst_PROGRAMS = \
+ $(EXAMPLES) \
+ $(NULL)
dominfo_info1_SOURCES = dominfo/info1.c
dommigrate_dommigrate_SOURCES = dommigrate/dommigrate.c
@@ -88,13 +109,13 @@ examplesdir = $(docdir)/examples
install-data-local: $(INSTALL_DATA_LOCAL)
$(mkinstalldirs) $(DESTDIR)$(examplesdir)
- for p in $(noinst_PROGRAMS); do \
+ for p in $(EXAMPLES); do \
d=$$(dirname $$p); \
$(mkinstalldirs) $(DESTDIR)$(examplesdir)/$$d; \
$(INSTALL_DATA) $(srcdir)/$${p}.c $(DESTDIR)$(examplesdir)/$$d/; \
done
uninstall-local: $(UNINSTALL_LOCAL)
- for p in $(noinst_PROGRAMS); do \
+ for p in $(EXAMPLES); do \
rm -f $(DESTDIR)$(examplesdir)/$${p}.c; \
done
--
2.21.0
5 years, 7 months
[libvirt] [PATCH 0/4] virutil: Rework how 'udevadm settle' is called
by Michal Privoznik
Apparently, some build systems have a very minimalistic approach to
their default build root. Not even udevadm is there. This renders our
virWaitForDevices() to be no-op. But with this rework we can still run
udevadm settle just fine with no extra build dependency added.
Michal Prívozník (4):
virWaitForDevices: Drop untrue part of comment
lib: Drop UDEVSETTLE
m4: Provide default value fore UDEVADM
m4: Drop needless string checks
m4/virt-external-programs.m4 | 26 +++++++-------------------
src/util/virutil.c | 20 ++++++--------------
2 files changed, 13 insertions(+), 33 deletions(-)
--
2.21.0
5 years, 7 months
[libvirt] [PATCH 0/6] qemu: Rework the way we probe machine type properties
by Andrea Bolognani
This is a prerequisite for vSMMUv3 support, which I'm currently
working on, but I'm posting it separately because it still makes
perfect sense as a standalone series and I think it's a nice
cleanup in its own right.
Unfortunately there's quite a bit of test suite churn associated
with these changes, but hopefully that should be for the most part
compensated by the *lack* of test suite churn when I introduce
vSMMUv3 support.
Andrea Bolognani (6):
qemu: Introduce virQEMUCapsProbeQMPMachineProps()
qemu: Add -machine suffix automatically
qemu: Move call to virQEMUCapsProbeQMPMachineProps()
qemu: Probe canonicalized machine type
tests: Refresh capabilities for QEMU on ppc64
qemu: Only probe available machine types
src/qemu/qemu_capabilities.c | 63 +++-
.../caps_2.12.0.aarch64.replies | 48 +--
.../caps_2.12.0.ppc64.replies | 290 ++++++++--------
.../caps_2.12.0.s390x.replies | 52 +--
.../caps_2.12.0.x86_64.replies | 64 ++--
.../caps_3.0.0.ppc64.replies | 300 ++++++++--------
.../caps_3.0.0.riscv32.replies | 40 +--
.../caps_3.0.0.riscv64.replies | 40 +--
.../caps_3.0.0.s390x.replies | 52 +--
.../caps_3.0.0.x86_64.replies | 64 ++--
.../caps_3.1.0.ppc64.replies | 315 +++++++++--------
.../caps_3.1.0.x86_64.replies | 64 ++--
.../caps_4.0.0.aarch64.replies | 48 +--
.../caps_4.0.0.ppc64.replies | 328 ++++++++++--------
.../caps_4.0.0.riscv32.replies | 40 +--
.../caps_4.0.0.riscv64.replies | 40 +--
.../caps_4.0.0.s390x.replies | 52 +--
.../caps_4.0.0.x86_64.replies | 64 ++--
18 files changed, 938 insertions(+), 1026 deletions(-)
--
2.21.0
5 years, 7 months
[libvirt] [PATCH] qemu: blockjob: Fix saving of inactive XML after completed legacy blockjob
by Peter Krempa
Commit 0ba9afc6b28 introduced a logic bug where we will never save the
inactive XML after a blockjob as the variable which was determining
whether to do so is cleared right before. Thus even if we correctly
modify the inactive state it will be rolled back when libvirtd is
restarted.
Reported-by: Thomas Stein <hello(a)himbee.re>
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_blockjob.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index fa7e4c8625..f105632a09 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -363,7 +363,7 @@ qemuBlockJobEventProcessLegacy(virQEMUDriverPtr driver,
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0)
VIR_WARN("Unable to save status on vm %s after block job", vm->def->name);
- if (job->newstate == VIR_DOMAIN_BLOCK_JOB_COMPLETED && vm->newDef) {
+ if (job->state == VIR_DOMAIN_BLOCK_JOB_COMPLETED && vm->newDef) {
if (virDomainSaveConfig(cfg->configDir, driver->caps, vm->newDef) < 0)
VIR_WARN("Unable to update persistent definition on vm %s "
"after block job", vm->def->name);
--
2.21.0
5 years, 7 months
[libvirt] [PATCH v2] src: don't statically link code that's already in libvirt.so
by Daniel P. Berrangé
Various binaries are statically linking to libvirt_util.la and
other intermediate libraries we build. These intermediate libs
all get built into the main libvirt.so shared library eventually,
so we can dynamically link to that instead and reduce the on disk
footprint.
In libvirt-daemon RPM:
virtlockd: 1.6 MB -> 153 KB
virtlogd: 1.6 MB -> 157 KB
libvirt_iohelper: 937 KB -> 23 KB
In libvirt-daemon-driver-network RPM:
libvirt_leaseshelper: 940 KB -> 26 KB
In libvirt-daemon-driver-storage-core RPM:
libvirt_parthelper: 926 KB -> 21 KB
IOW, about 5.6 MB total space saving
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/Makefile.am | 2 +-
src/libvirt_remote.syms | 1 +
src/locking/Makefile.inc.am | 4 +---
src/logging/Makefile.inc.am | 4 +---
src/network/Makefile.inc.am | 2 +-
src/security/Makefile.inc.am | 2 --
src/storage/Makefile.inc.am | 2 +-
7 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 7d452a9490..0b562dc250 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -851,7 +851,7 @@ libvirt_iohelper_LDFLAGS = \
$(PIE_LDFLAGS) \
$(NULL)
libvirt_iohelper_LDADD = \
- libvirt_util.la \
+ libvirt.la \
../gnulib/lib/libgnu.la
if WITH_DTRACE_PROBES
libvirt_iohelper_LDADD += libvirt_probes.lo
diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms
index 98586d1584..3d68f6ce0a 100644
--- a/src/libvirt_remote.syms
+++ b/src/libvirt_remote.syms
@@ -176,6 +176,7 @@ virNetServerClientSetAuthLocked;
virNetServerClientSetAuthPendingLocked;
virNetServerClientSetCloseHook;
virNetServerClientSetDispatcher;
+virNetServerClientSetQuietEOF;
virNetServerClientSetReadonly;
virNetServerClientStartKeepAlive;
virNetServerClientWantCloseLocked;
diff --git a/src/locking/Makefile.inc.am b/src/locking/Makefile.inc.am
index da26fab91f..46ab11c2a9 100644
--- a/src/locking/Makefile.inc.am
+++ b/src/locking/Makefile.inc.am
@@ -145,10 +145,8 @@ virtlockd_LDFLAGS = \
$(NO_UNDEFINED_LDFLAGS) \
$(NULL)
virtlockd_LDADD = \
+ libvirt.la \
libvirt_driver_admin.la \
- libvirt-net-rpc-server.la \
- libvirt-net-rpc.la \
- libvirt_util.la \
../gnulib/lib/libgnu.la \
$(CYGWIN_EXTRA_LIBADD) \
$(NULL)
diff --git a/src/logging/Makefile.inc.am b/src/logging/Makefile.inc.am
index f5eba2a4f7..d57394cbde 100644
--- a/src/logging/Makefile.inc.am
+++ b/src/logging/Makefile.inc.am
@@ -80,9 +80,7 @@ virtlogd_LDFLAGS = \
$(NULL)
virtlogd_LDADD = \
libvirt_driver_admin.la \
- libvirt-net-rpc-server.la \
- libvirt-net-rpc.la \
- libvirt_util.la \
+ libvirt.la \
../gnulib/lib/libgnu.la \
$(CYGWIN_EXTRA_LIBADD) \
$(NULL)
diff --git a/src/network/Makefile.inc.am b/src/network/Makefile.inc.am
index 3fed59c13b..52270049d5 100644
--- a/src/network/Makefile.inc.am
+++ b/src/network/Makefile.inc.am
@@ -56,7 +56,7 @@ libvirt_leaseshelper_LDFLAGS = \
$(PIE_LDFLAGS) \
$(NULL)
libvirt_leaseshelper_LDADD = \
- libvirt_util.la \
+ libvirt.la \
../gnulib/lib/libgnu.la
if WITH_DTRACE_PROBES
libvirt_leaseshelper_LDADD += libvirt_probes.lo
diff --git a/src/security/Makefile.inc.am b/src/security/Makefile.inc.am
index 7fb6d8cc4f..64e0f46857 100644
--- a/src/security/Makefile.inc.am
+++ b/src/security/Makefile.inc.am
@@ -72,8 +72,6 @@ virt_aa_helper_LDFLAGS = \
$(NULL)
virt_aa_helper_LDADD = \
libvirt.la \
- libvirt_conf.la \
- libvirt_util.la \
libvirt_driver_storage_impl.la \
../gnulib/lib/libgnu.la \
$(NULL)
diff --git a/src/storage/Makefile.inc.am b/src/storage/Makefile.inc.am
index ea4681f70e..538709256d 100644
--- a/src/storage/Makefile.inc.am
+++ b/src/storage/Makefile.inc.am
@@ -378,7 +378,7 @@ libvirt_parthelper_LDFLAGS = \
$(NULL)
libvirt_parthelper_LDADD = \
$(LIBPARTED_LIBS) \
- libvirt_util.la \
+ libvirt.la \
../gnulib/lib/libgnu.la \
$(NULL)
if WITH_DTRACE_PROBES
--
2.21.0
5 years, 7 months
[libvirt] surprising <backingStore type='file'> setting in domain.xml
by Thomas Stein
Hello all.
My currently used versions: libvirt-5.2.0 and qemu-4.0.0.
Here is my problem. I'm struggeling since a few weeks with a strange
behaviour by either qemu or libvirt. After a reboot of
the hardware node the $domain.xml contains suddenly a backingStore
setting which was not there before reboot.
Something like that:
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source
file='/var/lib/libvirt/shinymail/shinymail_weekly.qcow2-2019-05-15'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/shinymail.qcow2'/>
</backingStore>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x07'
function='0x0'/>
</disk>
...
This obviousely happens after a backup has been running. The Backup
Script looks like this:
<snip>
virsh snapshot-create-as --domain shinymail weekly --diskspec
vda,file=/var/lib/libvirt/shinymail/shinymail_weekly.qcow2-$(date
+%Y-%m-%d) --disk-only --atomic --no-metadata
cp ...
virsh blockcommit shinymail vda --active --verbose --pivot
<snip>
So after that "dmblklist shinymail" does show the right source file but
after a reboot it tries to use the weekly snapshot
again which leads to filesystem errors.
Someone has an idea what could cause such a behaviour?
cheers
t.
5 years, 7 months
[libvirt] [PATCH 0/2] build: bump minimum udev version to 219
by Ján Tomko
Inspired-by: Pavel Hrdina <phardina(a)redhat.com>
Ján Tomko (2):
build: bump minimum udev version to 219
build: drop check for udev_monitor_set_receive_buffer_size
m4/virt-udev.m4 | 14 ++------------
src/node_device/node_device_udev.c | 2 --
2 files changed, 2 insertions(+), 14 deletions(-)
--
2.19.2
5 years, 7 months
[libvirt] [PATCH] src: don't statically link code that's already in libvirt.so
by Daniel P. Berrangé
virtlockd and virtlogd statically link to libvirt-net-rpc-server.la
libvirt-net-rpc.la and libvirt_util.la. libvirt-iohelper statically
links to libvirt_util.la. All this code is all already built into
the main libvirt.so, so we should dynamically link all these pieces.
This reduces the size of the libvirt-daemon RPM from 5.4 MB down to
1.2 MB which is useful for container installs seeking minimal disk
footprint.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/Makefile.am | 2 +-
src/libvirt_remote.syms | 1 +
src/locking/Makefile.inc.am | 4 +---
src/logging/Makefile.inc.am | 4 +---
4 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 7d452a9490..0b562dc250 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -851,7 +851,7 @@ libvirt_iohelper_LDFLAGS = \
$(PIE_LDFLAGS) \
$(NULL)
libvirt_iohelper_LDADD = \
- libvirt_util.la \
+ libvirt.la \
../gnulib/lib/libgnu.la
if WITH_DTRACE_PROBES
libvirt_iohelper_LDADD += libvirt_probes.lo
diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms
index 98586d1584..3d68f6ce0a 100644
--- a/src/libvirt_remote.syms
+++ b/src/libvirt_remote.syms
@@ -176,6 +176,7 @@ virNetServerClientSetAuthLocked;
virNetServerClientSetAuthPendingLocked;
virNetServerClientSetCloseHook;
virNetServerClientSetDispatcher;
+virNetServerClientSetQuietEOF;
virNetServerClientSetReadonly;
virNetServerClientStartKeepAlive;
virNetServerClientWantCloseLocked;
diff --git a/src/locking/Makefile.inc.am b/src/locking/Makefile.inc.am
index da26fab91f..46ab11c2a9 100644
--- a/src/locking/Makefile.inc.am
+++ b/src/locking/Makefile.inc.am
@@ -145,10 +145,8 @@ virtlockd_LDFLAGS = \
$(NO_UNDEFINED_LDFLAGS) \
$(NULL)
virtlockd_LDADD = \
+ libvirt.la \
libvirt_driver_admin.la \
- libvirt-net-rpc-server.la \
- libvirt-net-rpc.la \
- libvirt_util.la \
../gnulib/lib/libgnu.la \
$(CYGWIN_EXTRA_LIBADD) \
$(NULL)
diff --git a/src/logging/Makefile.inc.am b/src/logging/Makefile.inc.am
index f5eba2a4f7..d57394cbde 100644
--- a/src/logging/Makefile.inc.am
+++ b/src/logging/Makefile.inc.am
@@ -80,9 +80,7 @@ virtlogd_LDFLAGS = \
$(NULL)
virtlogd_LDADD = \
libvirt_driver_admin.la \
- libvirt-net-rpc-server.la \
- libvirt-net-rpc.la \
- libvirt_util.la \
+ libvirt.la \
../gnulib/lib/libgnu.la \
$(CYGWIN_EXTRA_LIBADD) \
$(NULL)
--
2.21.0
5 years, 7 months
[libvirt] [PATCH] virt-aa-helper: clean old reference to libvirt-sandbox
by Christian Ehrhardt
It came up that libvirt-sandbox is a failed (and removed) experiment.
Let us clean up and remove it from the virt-aa-helper source as well.
Signed-off-by: Christian Ehrhardt <christian.ehrhardt(a)canonical.com>
---
src/security/virt-aa-helper.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index ad9a7dda94..fea4da80dc 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -511,8 +511,7 @@ valid_path(const char *path, const bool readonly)
/* override the above with these */
const char * const override[] = {
"/sys/devices/pci", /* for hostdev pci devices */
- "/sys/kernel/config/target/vhost", /* for hostdev vhost_scsi devices */
- "/etc/libvirt-sandbox/services/" /* for virt-sandbox service config */
+ "/sys/kernel/config/target/vhost" /* for hostdev vhost_scsi devices */
};
const int nropaths = ARRAY_CARDINALITY(restricted);
--
2.21.0
5 years, 7 months