[PATCH] NEWS: Document domain memory dirty rate APIs
by Hao Wang
Signed-off-by: Hao Wang <wanghao232(a)huawei.com>
---
NEWS.rst | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/NEWS.rst b/NEWS.rst
index bd40373a80..df35044ef0 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -13,6 +13,17 @@ v7.2.0 (unreleased)
* **New features**
+ * qemu: Implement domain memory dirty rate calculation API
+
+ New API (``virDomainStartDirtyRateCalc()``) and virsh command
+ (``domdirtyrate-calc``) are added to start calculating a live domain's
+ memory dirty rate.
+
+ * qemu: Support reporting memory dirty rate stats
+
+ The memory dirty rate stats can be obtained through ``virsh domstats
+ --dirtyrate`` via the virConnectGetAllDomainStats API.
+
* **Improvements**
* **Bug fixes**
--
2.23.0
3 years, 9 months
[libvirt PATCH v2 0/6] ci: helper: Rewrite image listing in Python and add stale Docker image checker
by Erik Skultety
Technically v2 of
https://listman.redhat.com/archives/libvir-list/2021-February/msg00641.html,
but the changes are not minor anymore so I had to change the subject.
since v1:
- integrated the standalone script to the recently added 'helper' script
- ditched the hardcode libvirt project ID and instead we work with
namespacing instead (which is converted to the right URL under the hood)
- util module moved to the ci/ directory
- all util functions now use proper Python type hinting
- ID is now printed along with the stale image name
- address formatting issues raised
v1: https://listman.redhat.com/archives/libvir-list/2021-February/msg00641.ht=
ml
EXAMPLE OUTPUT OF THE REGISTRY CHECKER:
The following images can be purged from the registry:
ci-debian-9: 1154661
ci-debian-9-cross-aarch64: 1154667
ci-debian-9-cross-mipsel: 1154669
ci-debian-9-cross-armv7l: 1154671
ci-debian-9-cross-armv6l: 1154676
ci-debian-9-cross-mips: 1154678
ci-debian-9-cross-ppc64le: 1154682
ci-debian-9-cross-s390x: 1154683
ci-debian-9-cross-mips64el: 1154686
ci-fedora-31: 1154687
ci-opensuse-151: 1154724
You can remove the above images over the API with the following code snippet:
$ for image_id in 1154661 1154667 1154669 1154671 1154676 1154678 1154682=
\
1154683 1154686 1154687 1154724; do \
curl --request DELETE --header "PRIVATE-TOKEN: <access_token>" \
https://gitlab.com/api/v4/projects/libvirt%2Flibvirt/registry/repos=
itories/$image_id \
done
Erik Skultety (6):
ci: Makefile: Specify a help target to replace ci-help
ci: helper: Use the ArgumentDefaultsHelpFormatter help formatter
ci: helper: Introduce --quiet
ci: Introduce a util module
ci: helper: Rewrite image listing to Python
ci: util: Add a registry checker for stale images
ci/Makefile | 16 ++-----
ci/helper | 108 ++++++++++++++++++++++++++++++++++++++++++++--
ci/list-images.sh | 14 ------
ci/util.py | 52 ++++++++++++++++++++++
4 files changed, 159 insertions(+), 31 deletions(-)
delete mode 100644 ci/list-images.sh
create mode 100644 ci/util.py
--=20
2.29.2
3 years, 9 months
[PATCH v7 0/7] migration/dirtyrate: Introduce APIs for getting domain memory dirty rate
by Hao Wang
V6 -> V7:
add virDomainDirtyRateStatus enum
define calc_status as int
split 5/5 in v6 into two parts:
6/7 in v7: extend dirtyrate statistics for domGetStats
7/7 in v7: extend corresponding virsh command
V5 -> V6:
split DomainGetDirtyRateInfo(domdirtyrate) API into two parts:
1. DomainStartDirtyRateCalc(domdirtyrate-calc) for starting dirty rate
calculation;
2. qemuDomainGetStatsDirtyRate(domstats --dirtyrate) for querying dirty
rate infomation.
V4 -> V5:
squash 1/7 and bits of 5/7 and 6/7 into 2/7 in v4 (to be 1/5 in v5)
squash left of 5/7 into 4/7 in v4 (to be 3/5 in v5)
add VIR_DOMAIN_DIRTYRATE_DEFAULT flag
remove redundant error report
rename virsh api to "domdirtyrate"
use vshTablePtr for virsh api output
add description in docs/manpages/virsh.rst
other format optimize
V3 -> V4:
define flags to unsigned int
fix some compile warnings
V2 -> V3:
reorganize patchset to fix compile warning
V1 -> V2:
replace QEMU_JOB_ASYNC with QEMU_JOB_QUERY
Sometimes domain's memory dirty rate is expected by user in order to
decide whether it's proper to be migrated out or not.
We have already completed the QEMU part of the capability:
https://patchew.org/QEMU/1600237327-33618-1-git-send-email-zhengchuan@hua...
And this serial of patches introduce the corresponding LIBVIRT part:
1. Calculating
Introduce a new API DomainStartDirtyRateCalc and corresponding virsh api
(domdirtyrate-calc) for starting dirty rate calculation by calling qmp
'calc-dirty-rate'.
# virsh domdirtyrate-calc <domain> [--seconds <sec>]
2. Querying
Introduce command 'virsh domstats --dirtyrate' for reporting memory
dirty rate infomation by calling qmp 'query-dirty-rate'.
The info is listed as:
Domain: 'vm0'
dirtyrate.calc_status=2
dirtyrate.calc_start_time=1534523
dirtyrate.calc_period=1
dirtyrate.megabytes_per_second=5
Hao Wang (7):
migration/dirtyrate: Introduce virDomainStartDirtyRateCalc API
migration/dirtyrate: Implement qemuDomainStartDirtyRateCalc
migration/dirtyrate: Introduce domdirtyrate-calc virsh api
migration/dirtyrate: Introduce virDomainDirtyRateStatus enum
migration/dirtyrate: Implement qemuMonitorQueryDirtyRate
migration/dirtyrate: Extend dirtyrate statistics for domGetStats
migration/dirtyrate: Introduce command 'virsh domstats --dirtyrate'
docs/manpages/virsh.rst | 33 +++++++++-
include/libvirt/libvirt-domain.h | 23 +++++++
src/driver-hypervisor.h | 6 ++
src/libvirt-domain.c | 59 +++++++++++++++++
src/libvirt_public.syms | 5 ++
src/qemu/qemu_driver.c | 110 +++++++++++++++++++++++++++++++
src/qemu/qemu_monitor.c | 24 +++++++
src/qemu/qemu_monitor.h | 19 ++++++
src/qemu/qemu_monitor_json.c | 101 ++++++++++++++++++++++++++++
src/qemu/qemu_monitor_json.h | 8 +++
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 14 +++-
src/remote_protocol-structs | 6 ++
tools/virsh-domain-monitor.c | 7 ++
tools/virsh-domain.c | 58 ++++++++++++++++
15 files changed, 471 insertions(+), 3 deletions(-)
--
2.23.0
3 years, 9 months
[PATCH v1] tests: Adjust libxlxml2domconfigtest to work with Xen < 4.8
by Olaf Hering
Commit fcdc387410fadfb066b95395c5b5d2a6a16f7066 used a libxl API which
is only available since Xen 4.8.
Due to lack of a specific guard for this API change, reuse another
guard from libxl.h.
Signed-off-by: Olaf Hering <olaf(a)aepfle.de>
---
tests/libxlxml2domconfigtest.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tests/libxlxml2domconfigtest.c b/tests/libxlxml2domconfigtest.c
index d58be1211b..c13a562a3c 100644
--- a/tests/libxlxml2domconfigtest.c
+++ b/tests/libxlxml2domconfigtest.c
@@ -105,7 +105,13 @@ testCompareXMLToDomConfig(const char *xmlfile,
*/
# ifndef LIBXL_HAVE_BUILDINFO_APIC
if (expectconfig.c_info.type == LIBXL_DOMAIN_TYPE_HVM) {
+# ifdef LIBXL_HAVE_MEMKB_64BITS
+ /*
+ * This part of the libxl API was changed without a guard in Xen 4.8.
+ * Reuse another Xen 4.8 specific conditional.
+ */
libxl_defbool_unset(&expectconfig.b_info.acpi);
+# endif
libxl_defbool_set(&expectconfig.b_info.u.hvm.apic, true);
libxl_defbool_set(&expectconfig.b_info.u.hvm.acpi, true);
}
3 years, 9 months
[PULL 00/13] misc patches removing deprecated features
by Daniel P. Berrangé
The following changes since commit 6e31b3a5c34c6e5be7ef60773e607f189eaa15f3:
Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging (2021-03-16 10:53:47 +0000)
are available in the Git repository at:
https://gitlab.com/berrange/qemu tags/dep-many-pull-request
for you to fetch changes up to 13bf1a48d1671e26ca2fa13817d388fbdc4215ff:
block: remove support for using "file" driver with block/char devices (2021-03-16 16:33:52 +0000)
----------------------------------------------------------------
Remove many old deprecated features
The following features have been deprecated for well over the 2
release cycle we promise
``-drive file=json:{...{'driver':'file'}}`` (since 3.0)
``-vnc acl`` (since 4.0.0)
``-mon ...,control=readline,pretty=on|off`` (since 4.1)
``migrate_set_downtime`` and ``migrate_set_speed`` (since 2.8.0)
``query-named-block-nodes`` result ``encryption_key_missing`` (since 2.10.0)
``query-block`` result ``inserted.encryption_key_missing`` (since 2.10.0)
``migrate-set-cache-size`` and ``query-migrate-cache-size`` (since 2.11.0)
``query-named-block-nodes`` and ``query-block`` result dirty-bitmaps[i].status (since 4.0)
``query-cpus`` (since 2.12.0)
``query-cpus-fast`` ``arch`` output member (since 3.0.0)
``query-events`` (since 4.0)
chardev client socket with ``wait`` option (since 4.0)
``acl_show``, ``acl_reset``, ``acl_policy``, ``acl_add``, ``acl_remove`` (since 4.0.0)
``ide-drive`` (since 4.2)
``scsi-disk`` (since 4.2)
----------------------------------------------------------------
Daniel P. Berrangé (13):
ui, monitor: remove deprecated VNC ACL option and HMP commands
monitor: raise error when 'pretty' option is used with HMP
monitor: remove 'query-events' QMP command
migrate: remove QMP/HMP commands for speed, downtime and cache size
machine: remove 'query-cpus' QMP command
machine: remove 'arch' field from 'query-cpus-fast' QMP command
chardev: reject use of 'wait' flag for socket client chardevs
hw/ide: remove 'ide-drive' device
hw/scsi: remove 'scsi-disk' device
block: remove 'encryption_key_missing' flag from QAPI
block: remove dirty bitmaps 'status' field
block: remove 'dirty-bitmaps' field from 'BlockInfo' struct
block: remove support for using "file" driver with block/char devices
block/dirty-bitmap.c | 38 --
block/file-posix.c | 17 +-
block/qapi.c | 6 -
chardev/char-socket.c | 12 +-
docs/devel/migration.rst | 2 +-
docs/qdev-device-use.txt | 2 +-
docs/rdma.txt | 2 +-
docs/system/deprecated.rst | 108 -----
docs/system/removed-features.rst | 109 +++++
docs/xbzrle.txt | 5 -
hmp-commands-info.hx | 13 -
hmp-commands.hx | 121 ------
hw/core/machine-hmp-cmds.c | 8 +-
hw/core/machine-qmp-cmds.c | 120 ------
hw/i386/pc.c | 2 -
hw/ide/qdev.c | 38 --
hw/ppc/mac_newworld.c | 13 -
hw/ppc/mac_oldworld.c | 13 -
hw/scsi/scsi-disk.c | 62 ---
hw/sparc64/sun4u.c | 15 -
include/block/dirty-bitmap.h | 1 -
include/monitor/hmp.h | 4 -
migration/migration.c | 45 ---
migration/ram.c | 2 +-
monitor/hmp-cmds.c | 34 --
monitor/misc.c | 187 ---------
monitor/monitor.c | 4 +-
monitor/qmp-cmds-control.c | 24 --
qapi/block-core.json | 64 +--
qapi/control.json | 45 ---
qapi/machine.json | 181 +--------
qapi/migration.json | 98 -----
qemu-options.hx | 5 +-
scripts/device-crash-test | 2 -
softmmu/vl.c | 1 -
tests/acceptance/pc_cpu_hotplug_props.py | 2 +-
tests/acceptance/x86_cpu_model_versions.py | 2 +-
tests/migration/guestperf/engine.py | 18 +-
tests/qemu-iotests/051 | 4 -
tests/qemu-iotests/051.pc.out | 20 -
tests/qemu-iotests/124 | 4 -
tests/qemu-iotests/181 | 2 +-
tests/qemu-iotests/184.out | 6 +-
tests/qemu-iotests/191.out | 48 +--
tests/qemu-iotests/194 | 4 +-
tests/qemu-iotests/194.out | 4 +-
tests/qemu-iotests/226.out | 10 +-
tests/qemu-iotests/236 | 2 +-
tests/qemu-iotests/236.out | 42 +-
tests/qemu-iotests/246 | 3 +-
tests/qemu-iotests/246.out | 66 +--
tests/qemu-iotests/254 | 2 +-
tests/qemu-iotests/254.out | 9 +-
tests/qemu-iotests/257.out | 378 ++++++------------
tests/qemu-iotests/260 | 5 +-
tests/qemu-iotests/273.out | 15 +-
.../tests/migrate-bitmaps-postcopy-test | 6 +-
tests/qtest/migration-test.c | 48 ---
tests/qtest/numa-test.c | 6 +-
tests/qtest/qmp-test.c | 6 +-
tests/qtest/test-hmp.c | 6 +-
tests/qtest/test-x86-cpuid-compat.c | 4 +-
tests/qtest/vhost-user-test.c | 8 +-
ui/vnc.c | 38 --
64 files changed, 370 insertions(+), 1801 deletions(-)
--
2.30.2
3 years, 9 months
[PULL 00/11] Ui 20210316 patches
by Gerd Hoffmann
The following changes since commit 6157b0e19721aadb4c7fdcfe57b2924af6144b14:
Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-6.0-pull-=
request' into staging (2021-03-14 17:47:49 +0000)
are available in the Git repository at:
git://git.kraxel.org/qemu tags/ui-20210316-pull-request
for you to fetch changes up to ad7f2f8ee9fbded410fbf77158b0065f8e2f08e3:
ui/cocoa: Comment about modifier key input quirks (2021-03-16 06:36:45 +010=
0)
----------------------------------------------------------------
vnc+spice: password-secret option.
bugfixes for cocoa, vnc, opengl.
----------------------------------------------------------------
Akihiko Odaki (3):
opengl: Do not convert format with glTexImage2D on OpenGL ES
ui/cocoa: Do not exit immediately after shutdown
ui/cocoa: Comment about modifier key input quirks
Daniel P. Berrang=C3=A9 (7):
ui: introduce "password-secret" option for VNC servers
ui: introduce "password-secret" option for SPICE server
ui: deprecate "password" option for SPICE server
ui: add more trace points for VNC client/server messages
ui: avoid sending framebuffer updates outside client desktop bounds
ui: use client width/height in WMVi message
ui: honour the actual guest display dimensions without rounding
Marc-Andr=C3=A9 Lureau (1):
ui: fold qemu_alloc_display in only caller
ui/vnc.h | 1 +
ui/console-gl.c | 19 +++++++---
ui/console.c | 14 ++------
ui/spice-core.c | 32 +++++++++++++++--
ui/vnc-jobs.c | 44 ++++++++++++++++++++---
ui/vnc.c | 71 +++++++++++++++++++++++++++++++++-----
docs/system/deprecated.rst | 8 +++++
qemu-options.hx | 18 ++++++++--
ui/cocoa.m | 46 ++++++++++++++++++++++--
ui/trace-events | 16 +++++++++
10 files changed, 234 insertions(+), 35 deletions(-)
--=20
2.29.2
3 years, 9 months
[PULL 00/13] Usb 20210315 patches
by Gerd Hoffmann
The following changes since commit 6157b0e19721aadb4c7fdcfe57b2924af6144b14:
Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-6.0-pull-=
request' into staging (2021-03-14 17:47:49 +0000)
are available in the Git repository at:
git://git.kraxel.org/qemu tags/usb-20210315-pull-request
for you to fetch changes up to 39912c14da07a2dbc73854addcfa0a42596340ac:
usb/storage: clear csw on reset (2021-03-15 17:01:17 +0100)
----------------------------------------------------------------
usb: -usbdevice cleanup and un-deprecation.
usb: split usb-storage.
usb: misc fixes and cleanups.
----------------------------------------------------------------
Gerd Hoffmann (5):
usb/storage: move declarations to usb/msd.h header
usb/storage: move usb-bot device to separate source file
usb/storage move usb-storage device to separate source file
usb/storage: add kconfig symbols
usb/storage: clear csw on reset
Paolo Bonzini (2):
usb: remove support for -usbdevice parameters
usb: remove '-usbdevice u2f-key'
Philippe Mathieu-Daud=C3=A9 (3):
hw/southbridge: Add missing Kconfig dependency VT82C686 on USB_UHCI
hw/usb/hcd-uhci: Expose generic prototypes to local header
hw/usb: Extract VT82C686 UHCI PCI function into a new unit
Thomas Huth (3):
hw/usb/bus: Remove the "full-path" property
usb: Un-deprecate -usbdevice (except for -usbdevice audio which gets
removed)
usb: Document the missing -usbdevice options
hw/usb/hcd-uhci.h | 93 +++++++++++++
include/hw/usb.h | 3 +-
include/hw/usb/msd.h | 54 ++++++++
hw/usb/bus.c | 39 ++----
hw/usb/dev-audio.c | 1 -
hw/usb/dev-serial.c | 2 +-
hw/usb/dev-storage-bot.c | 63 +++++++++
hw/usb/dev-storage-classic.c | 156 +++++++++++++++++++++
hw/usb/dev-storage.c | 226 +------------------------------
hw/usb/hcd-uhci.c | 83 +-----------
hw/usb/u2f.c | 1 -
hw/usb/vt82c686-uhci-pci.c | 43 ++++++
softmmu/vl.c | 2 -
MAINTAINERS | 1 +
docs/system/deprecated.rst | 9 --
docs/system/removed-features.rst | 8 ++
hw/isa/Kconfig | 1 +
hw/usb/Kconfig | 13 +-
hw/usb/meson.build | 5 +-
qemu-options.hx | 35 ++++-
20 files changed, 484 insertions(+), 354 deletions(-)
create mode 100644 hw/usb/hcd-uhci.h
create mode 100644 include/hw/usb/msd.h
create mode 100644 hw/usb/dev-storage-bot.c
create mode 100644 hw/usb/dev-storage-classic.c
create mode 100644 hw/usb/vt82c686-uhci-pci.c
--=20
2.29.2
3 years, 9 months
[libvirt PATCH] util: tell users that memory locking ulimit is too low for BPF
by Daniel P. Berrangé
If running libvirtd via systemd, it gets a 64 MB memlock limit, but if
running from the shell it will only get 64 KB on a Fedora 33 system.
The latter low limit causes any attempt to use BPF to fail and it is
not obvious why.
This improves the error message thus:
# virsh -c lxc:/// start sh
error: Failed to start domain 'sh'
error: internal error: guest failed to start: Failure in libvirt_lxc startup: failed to initialize device BPF map; locked memory limit for libvirtd probably needs to be raised: Operation not permitted
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/util/vircgroupv2devices.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/util/vircgroupv2devices.c b/src/util/vircgroupv2devices.c
index 71591be4c4..4bcc1d52fe 100644
--- a/src/util/vircgroupv2devices.c
+++ b/src/util/vircgroupv2devices.c
@@ -443,9 +443,17 @@ virCgroupV2DevicesCreateMap(size_t size)
sizeof(uint32_t), size);
if (mapfd < 0) {
- virReportSystemError(errno, "%s",
- _("failed to initialize device BPF map"));
- return -1;
+ if (errno == EPERM) {
+ virReportSystemError(errno, "%s",
+ _("failed to initialize device BPF map; "
+ "locked memory limit for libvirtd probably "
+ "needs to be raised"));
+ return -1;
+ } else {
+ virReportSystemError(errno, "%s",
+ _("failed to initialize device BPF map"));
+ return -1;
+ }
}
return mapfd;
--
2.30.2
3 years, 9 months
[libvirt PATCH] src: ensure GSource background unref happens in correct event loop
by Daniel P. Berrangé
The g_idle_add function adds a callback to the primary GMainContext.
To workaround the GSource unref bugs, we need to add our callbacks
to the GMainContext that is associated with the GSource being
unref'd. Thus code using the per-VM virEventThread must use its
private GMainContext.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
meson.build | 3 ---
src/libvirt_glib_crash_workaround.syms | 11 -----------
src/libvirt_private.syms | 1 +
src/meson.build | 7 -------
src/qemu/qemu_agent.c | 2 +-
src/qemu/qemu_monitor.c | 2 +-
src/util/glibcompat.c | 20 ++++++++++++++++++--
src/util/glibcompat.h | 11 +----------
src/util/vireventglib.c | 12 ++++++------
9 files changed, 28 insertions(+), 41 deletions(-)
delete mode 100644 src/libvirt_glib_crash_workaround.syms
diff --git a/meson.build b/meson.build
index 69a7b4c88e..ea93a2a8ec 100644
--- a/meson.build
+++ b/meson.build
@@ -1049,9 +1049,6 @@ if host_machine.system() == 'windows'
else
gio_dep = dependency('gio-unix-2.0', version: '>=' + glib_version)
endif
-# GLib event loop race workaround in glibcompat.h, remove when minimum required
-# glib is >= 2.64.0
-glib_crash_workaround = glib_dep.version().version_compare('<2.64.0')
glib_dep = declare_dependency(
dependencies: [ glib_dep, gobject_dep, gio_dep ],
)
diff --git a/src/libvirt_glib_crash_workaround.syms b/src/libvirt_glib_crash_workaround.syms
deleted file mode 100644
index 249058b65b..0000000000
--- a/src/libvirt_glib_crash_workaround.syms
+++ /dev/null
@@ -1,11 +0,0 @@
-#
-# Private symbols specific for pre-2.64.0 GLib workaround
-#
-
-# util/glibcompat.h
-virEventGLibSourceUnrefIdle;
-
-# Let emacs know we want case-insensitive sorting
-# Local Variables:
-# sort-fold-case: t
-# End:
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 767d665613..526dcee11a 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1733,6 +1733,7 @@ virStorageSourceUpdatePhysicalSize;
# util/glibcompat.h
vir_g_canonicalize_filename;
vir_g_fsync;
+vir_g_source_unref;
vir_g_strdup_printf;
vir_g_strdup_vprintf;
diff --git a/src/meson.build b/src/meson.build
index 70a5a83eea..c7ff9e978c 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -124,13 +124,6 @@ else
sym_files += 'libvirt_libssh2.syms'
endif
-if glib_crash_workaround
- used_sym_files += 'libvirt_glib_crash_workaround.syms'
-else
- sym_files += 'libvirt_glib_crash_workaround.syms'
-endif
-
-
# variables filled by subdirectories
libvirt_libs = []
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 01ba2c78c1..787a7bb41c 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -533,7 +533,7 @@ qemuAgentUnregister(qemuAgentPtr agent)
{
if (agent->watch) {
g_source_destroy(agent->watch);
- g_vir_source_unref_safe(agent->watch);
+ vir_g_source_unref(agent->watch, agent->context);
agent->watch = NULL;
}
}
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index b4f2641504..f6cd9d9eda 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -862,7 +862,7 @@ qemuMonitorUnregister(qemuMonitorPtr mon)
{
if (mon->watch) {
g_source_destroy(mon->watch);
- g_vir_source_unref_safe(mon->watch);
+ vir_g_source_unref(mon->watch, mon->context);
mon->watch = NULL;
}
}
diff --git a/src/util/glibcompat.c b/src/util/glibcompat.c
index fe19ffa87b..eb6dcc0111 100644
--- a/src/util/glibcompat.c
+++ b/src/util/glibcompat.c
@@ -231,9 +231,14 @@ vir_g_strdup_vprintf(const char *msg, va_list args)
*
* Drop when min glib >= 2.64.0
*/
-#if GLIB_CHECK_VERSION(2, 64, 0) != TRUE
+#if GLIB_CHECK_VERSION(2, 64, 0)
+void vir_g_source_unref(GSource *src, GMainContext *ctx G_GNUC_UNUSED)
+{
+ g_source_unref(src);
+}
+#else
-gboolean
+static gboolean
virEventGLibSourceUnrefIdle(gpointer data)
{
GSource *src = data;
@@ -243,4 +248,15 @@ virEventGLibSourceUnrefIdle(gpointer data)
return FALSE;
}
+void vir_g_source_unref(GSource *src, GMainContext *ctx)
+{
+ GSource *idle = g_idle_source_new();
+
+ g_source_set_callback(idle, virEventGLibSourceUnrefIdle, src, NULL);
+
+ g_source_attach(idle, ctx);
+
+ g_source_unref(idle);
+}
+
#endif
diff --git a/src/util/glibcompat.h b/src/util/glibcompat.h
index 9c52843274..697687b967 100644
--- a/src/util/glibcompat.h
+++ b/src/util/glibcompat.h
@@ -85,13 +85,4 @@ char *vir_g_strdup_vprintf(const char *msg, va_list args)
#undef g_fsync
#define g_fsync vir_g_fsync
-/* Drop when min glib >= 2.64.0 */
-#if GLIB_CHECK_VERSION(2, 64, 0)
-# define g_vir_source_unref_safe(source) g_source_unref(source)
-#else
-# define g_vir_source_unref_safe(source) g_idle_add(virEventGLibSourceUnrefIdle, source)
-
-gboolean
-virEventGLibSourceUnrefIdle(gpointer data);
-
-#endif
+void vir_g_source_unref(GSource *src, GMainContext *ctx);
diff --git a/src/util/vireventglib.c b/src/util/vireventglib.c
index 88e3ec6d5d..f3e5a344b0 100644
--- a/src/util/vireventglib.c
+++ b/src/util/vireventglib.c
@@ -214,7 +214,7 @@ virEventGLibHandleUpdate(int watch,
if (data->source != NULL) {
VIR_DEBUG("Removed old handle source=%p", data->source);
g_source_destroy(data->source);
- g_vir_source_unref_safe(data->source);
+ vir_g_source_unref(data->source, NULL);
}
data->source = virEventGLibAddSocketWatch(
@@ -228,7 +228,7 @@ virEventGLibHandleUpdate(int watch,
VIR_DEBUG("Removed old handle source=%p", data->source);
g_source_destroy(data->source);
- g_vir_source_unref_safe(data->source);
+ vir_g_source_unref(data->source, NULL);
data->source = NULL;
data->events = 0;
}
@@ -277,7 +277,7 @@ virEventGLibHandleRemove(int watch)
if (data->source != NULL) {
g_source_destroy(data->source);
- g_vir_source_unref_safe(data->source);
+ vir_g_source_unref(data->source, NULL);
data->source = NULL;
data->events = 0;
}
@@ -410,7 +410,7 @@ virEventGLibTimeoutUpdate(int timer,
if (interval >= 0) {
if (data->source != NULL) {
g_source_destroy(data->source);
- g_vir_source_unref_safe(data->source);
+ vir_g_source_unref(data->source, NULL);
}
data->interval = interval;
@@ -420,7 +420,7 @@ virEventGLibTimeoutUpdate(int timer,
goto cleanup;
g_source_destroy(data->source);
- g_vir_source_unref_safe(data->source);
+ vir_g_source_unref(data->source, NULL);
data->source = NULL;
}
@@ -469,7 +469,7 @@ virEventGLibTimeoutRemove(int timer)
if (data->source != NULL) {
g_source_destroy(data->source);
- g_vir_source_unref_safe(data->source);
+ vir_g_source_unref(data->source, NULL);
data->source = NULL;
}
--
2.30.2
3 years, 9 months