[PATCH] NEWS: Mention shared filesystem detection fix
by Jiri Denemark
From: Jiri Denemark <jdenemar(a)redhat.com>
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
NEWS.rst | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/NEWS.rst b/NEWS.rst
index ee4e9a022e..089224cbe3 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -66,6 +66,12 @@ v11.5.0 (unreleased)
domain XML acquires QUERY job. But this caused a regression when the API
might timeout for incoming migration. This is now fixed.
+ * qemu: Fix shared filesystem detection on nonexistent paths
+
+ Since ``libvirt-11.1.0`` nonexistent paths within directories marked as
+ shared filesystem (via the ``shared_filesystems`` option in ``qemu.conf``
+ would not be properly detected as being on a shared filesystem.
+
v11.4.0 (2025-06-02)
====================
--
2.49.0
1 month
[PATCH] NEWS: Document features/improvements/bug fixes I've participated in
by Michal Privoznik
From: Michal Privoznik <mprivozn(a)redhat.com>
There are some features/improvements/bug fixes I've either
contributed or reviewed/merged. Document them for upcoming
release.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
NEWS.rst | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/NEWS.rst b/NEWS.rst
index 184df16547..ee4e9a022e 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -60,6 +60,12 @@ v11.5.0 (unreleased)
* **Bug fixes**
+ * qemu: Be more forgiving when acquiring QUERY job when formatting domain XML
+
+ Since ``libvirt-11.0.0`` the ``virDomainGetXMLDesc()`` API used to format
+ domain XML acquires QUERY job. But this caused a regression when the API
+ might timeout for incoming migration. This is now fixed.
+
v11.4.0 (2025-06-02)
====================
--
2.49.0
1 month
Re: [PATCH v3 2/2] virt-aa-helper: Allow SR-IOV VF PCI for hostdev
networks
by Michal Prívozník
On 6/25/25 18:49, Tim Small wrote:
>
>
> On 09/06/2025 13:51, Michal Prívozník wrote:
>
>> But this new IPC got me thinking - the XML we're parsing here in the aa
>> helper is formatted by libvirtd who already know the actual type of each
>> net. But looking into the code - this is lost when the daemon talks to
>> the helper. I'm not on an AppArmor machine right now, so can you please
>> check whether the following change (applied on the top of this very
>> patch) works? It would save us from those IPCs.
>
> Thanks Michal. The additional patches which you posted (below) did not
> work in isolation, but with an additional change to the src/qemu/
> qemu_process.c to ensure that the network is resolved before the
> apparmor helper is called, it works.
>
> I've updated my branch and tested, and will post the updated patch to
> the mailing list, but before I do-so...
>
> What would you like me to do with regard to the changes with you proposed?
>
> . Post with credit in the patch commentary.
> . Post with credit in the commit message.
If you want, then you can put
Suggested-by: Michal Privoznik <mprivozn(a)redhat.com>
line just above your SoB line. Thanks!
> . Something else?
>
> Thanks for the tip!
No problem. Introducing new RPC call always sets my alarm off :-D
Michal
1 month
Entering freeze for libvirt-11.5.0
by Jiri Denemark
I have just tagged v11.5.0-rc1 in the repository and pushed signed
tarballs to https://download.libvirt.org/
Please give the release candidate some testing and in case you find a
serious issue which should have a fix in the upcoming release, feel
free to reply to this thread to make sure the issue is more visible.
If you have not done so yet, please update NEWS.rst to document any
significant change you made since the last release.
Jirka
1 month
[PATCH v4 0/8] qemu: acpi-generic-initiator support
by Andrea Righi
= Overview =
This patch set introduces support for acpi-generic-initiator devices,
supported by QEMU [1].
The acpi-generic-initiator object is required to support Multi-Instance GPU
(MIG) configurations on NVIDIA GPUs [2]. MIG enables partitioning of GPU
resources into multiple isolated instances, each requiring a dedicated NUMA
node definition.
= Implementation =
This patch set implements the libvirt counterpart to the QEMU feature,
enabling users to configure acpi-generic-initiator objects within libvirt
domain XML.
This includes:
- adding XML syntax to define acpi-generic-initiator objects,
- resolving the acpi-generic-initiator definitions into the proper QEMU
command-line arguments,
- ensuring compatibility with existing NUMA configuration.
= Example =
- Domain XML:
```
...
<cpu mode='host-passthrough' check='none'>
<numa>
<cell id='0' cpus='0-15' memory='8388608' unit='KiB'/>
<cell id='1' memory='0' unit='KiB'/>
<cell id='2' memory='0' unit='KiB'/>
<cell id='3' memory='0' unit='KiB'/>
<cell id='4' memory='0' unit='KiB'/>
<cell id='5' memory='0' unit='KiB'/>
<cell id='6' memory='0' unit='KiB'/>
<cell id='7' memory='0' unit='KiB'/>
<cell id='8' memory='0' unit='KiB'/>
</numa>
</cpu>
...
<devices>
...
<hostdev mode='subsystem' type='pci' managed='no'>
<source>
<address domain='0x0009' bus='0x01' slot='0x00' function='0x0'/>
</source>
<address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
</hostdev>
<acpi-generic-initiator>
<pci-dev>hostdev0</pci-dev>
<numa-node>1</numa-node>
</acpi-generic-initiator>
<acpi-generic-initiator>
<pci-dev>hostdev0</pci-dev>
<numa-node>2</numa-node>
</acpi-generic-initiator>
<acpi-generic-initiator>
<pci-dev>hostdev0</pci-dev>
<numa-node>3</numa-node>
</acpi-generic-initiator>
<acpi-generic-initiator>
<pci-dev>hostdev0</pci-dev>
<numa-node>4</numa-node>
</acpi-generic-initiator>
<acpi-generic-initiator>
<pci-dev>hostdev0</pci-dev>
<numa-node>5</numa-node>
</acpi-generic-initiator>
<acpi-generic-initiator>
<pci-dev>hostdev0</pci-dev>
<numa-node>6</numa-node>
</acpi-generic-initiator>
<acpi-generic-initiator>
<pci-dev>hostdev0</pci-dev>
<numa-node>7</numa-node>
</acpi-generic-initiator>
<acpi-generic-initiator>
<pci-dev>hostdev0</pci-dev>
<numa-node>8</numa-node>
</acpi-generic-initiator>
</devices>
```
- Generated QEMU command line options:
```
... /usr/bin/qemu-system-aarch64 \
...
-object '{"qom-type":"memory-backend-ram","id":"ram-node0","size":8589934592}' \
-numa node,nodeid=0,cpus=0-15,memdev=ram-node0 \
-numa node,nodeid=1 \
-numa node,nodeid=2 \
-numa node,nodeid=3 \
-numa node,nodeid=4 \
-numa node,nodeid=5 \
-numa node,nodeid=6 \
-numa node,nodeid=7 \
-numa node,nodeid=8 \
...
-device '{"driver":"vfio-pci","host":"0009:01:00.0","id":"hostdev0","bus":"pci.3","addr":"0x0"}'
...
-object acpi-generic-initiator,id=gi0,pci-dev=hostdev0,node=1 \
-object acpi-generic-initiator,id=gi1,pci-dev=hostdev0,node=2 \
-object acpi-generic-initiator,id=gi2,pci-dev=hostdev0,node=3 \
-object acpi-generic-initiator,id=gi3,pci-dev=hostdev0,node=4 \
-object acpi-generic-initiator,id=gi4,pci-dev=hostdev0,node=5 \
-object acpi-generic-initiator,id=gi5,pci-dev=hostdev0,node=6 \
-object acpi-generic-initiator,id=gi6,pci-dev=hostdev0,node=7 \
-object acpi-generic-initiator,id=gi7,pci-dev=hostdev0,node=8
```
= References =
[1] https://lore.kernel.org/all/20231225045603.7654-2-ankita@nvidia.com/
[2] https://www.nvidia.com/en-in/technologies/multi-instance-gpu/
This patchset is also available in the following git branch:
https://github.com/arighi/libvirt.git acpi-generic-initiator-v4
ChangeLog v3 -> v4:
- add acpi-generic-initiator documentation
- refactor virDomainAcpiInitiatorDef to use info->alias and drop the name
attribute
- auto-generate alias for the acpi-generic-initiator devices via
qemuAssignDeviceAliases()
- use g_autoptr() when possible
- add a new entry to NEWS.rst
ChangeLog v2 -> v3:
- replaced <text/> with proper types in the XML schema
- avoid mixing g_free() and VIR_FREE()
- use virXMLPropString() instead of looping all XML nodes
- report proper errors with virReportError()
- use virBufferEscapeString() to process strings passed by the user
- fix broken formatting of function headers
- misc coding style fixes
ChangeLog v1 -> v2:
- split parser and driver changes in separate patches
- introduce a new qemu capability flag
- introduce test in qemuxmlconftest
Andrea Righi (8):
schema: Introduce acpi-generic-initiator definition
conf: Introduce acpi-generic-initiator device
qemu: Allow to define NUMA nodes without memory or CPUs assigned
qemu: capabilies: Introduce QEMU_CAPS_ACPI_GENERIC_INITIATOR
qemu: Support acpi-generic-initiator
qemu: Add test case for acpi-generic-initiator
docs: Document acpi-generic-initiator device
NEWS: Mention new acpi-generic-initiator device
NEWS.rst | 8 ++
docs/formatdomain.rst | 36 ++++++
src/ch/ch_domain.c | 1 +
src/conf/domain_conf.c | 138 +++++++++++++++++++++
src/conf/domain_conf.h | 14 +++
src/conf/domain_postparse.c | 1 +
src/conf/domain_validate.c | 37 ++++++
src/conf/numa_conf.c | 3 +
src/conf/schemas/domaincommon.rng | 14 +++
src/conf/virconftypes.h | 2 +
src/hyperv/hyperv_driver.c | 1 +
src/libxl/libxl_driver.c | 6 +
src/lxc/lxc_driver.c | 6 +
src/qemu/qemu_alias.c | 11 ++
src/qemu/qemu_capabilities.c | 2 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 49 ++++++--
src/qemu/qemu_domain.c | 2 +
src/qemu/qemu_domain_address.c | 4 +
src/qemu/qemu_driver.c | 3 +
src/qemu/qemu_hotplug.c | 5 +
src/qemu/qemu_postparse.c | 1 +
src/qemu/qemu_validate.c | 1 +
src/test/test_driver.c | 4 +
tests/qemucapabilitiesdata/caps_10.0.0_aarch64.xml | 1 +
.../caps_10.0.0_x86_64+amdsev.xml | 1 +
tests/qemucapabilitiesdata/caps_10.0.0_x86_64.xml | 1 +
tests/qemucapabilitiesdata/caps_9.0.0_x86_64.xml | 1 +
tests/qemucapabilitiesdata/caps_9.1.0_riscv64.xml | 1 +
tests/qemucapabilitiesdata/caps_9.1.0_x86_64.xml | 1 +
.../caps_9.2.0_aarch64+hvf.xml | 1 +
.../caps_9.2.0_x86_64+amdsev.xml | 1 +
tests/qemucapabilitiesdata/caps_9.2.0_x86_64.xml | 1 +
.../acpi-generic-initiator.x86_64-latest.args | 55 ++++++++
.../acpi-generic-initiator.x86_64-latest.xml | 94 ++++++++++++++
tests/qemuxmlconfdata/acpi-generic-initiator.xml | 94 ++++++++++++++
tests/qemuxmlconftest.c | 1 +
37 files changed, 596 insertions(+), 7 deletions(-)
create mode 100644 tests/qemuxmlconfdata/acpi-generic-initiator.x86_64-latest.args
create mode 100644 tests/qemuxmlconfdata/acpi-generic-initiator.x86_64-latest.xml
create mode 100644 tests/qemuxmlconfdata/acpi-generic-initiator.xml
1 month
[PATCH 0/4] USB hostdev: allow addressing by port
by Maximilian Martin
This resubmission splits up the previous patch into multiple patches and
incorporates review comments from Michal Prívozník.
Currently, only vendor/product and bus/device matching are supported for USB host
devices. Neither of these provide a stable and persistent way of assigning a guest
a specific host device. Vendor/product can be ambiguous. Device numbers change on
every enumeration.
This patch adds a bus/port matching, which allows a specific port on the host to be
specified using the dotted notation found in Linux's "devpath" sysfs attribute.
This patch is based on the previous work of Thomas Hebb: https://lists.libvirt.org/archives/list/devel@lists.libvirt.org/message/7...
Resolves: https://gitlab.com/libvirt/libvirt/-/issues/513
Signed-off-by: Maximilian Martin <maximilian_martin(a)gmx.de>
Maximilian Martin (4):
virusb test data: add devpath files for port addressing
domain_conf, virhostdev, virusb, virusb test: add bus/port matching
schema: add USB port attribute
docs: add description for USB port matching
docs/formatdomain.rst | 29 ++--
src/conf/domain_conf.c | 69 +++++++-
src/conf/domain_conf.h | 1 +
src/conf/schemas/domaincommon.rng | 11 +-
src/hypervisor/virhostdev.c | 131 +++++++++------
src/libvirt_private.syms | 2 -
src/util/virusb.c | 156 ++++++------------
src/util/virusb.h | 32 ++--
tests/virusbtest.c | 149 ++++++++++++-----
.../sys_bus_usb/devices/1-1.5.3.1/devpath | 1 +
.../sys_bus_usb/devices/1-1.5.3.3/devpath | 1 +
.../sys_bus_usb/devices/1-1.5.3/devpath | 1 +
.../sys_bus_usb/devices/1-1.5.4/devpath | 1 +
.../sys_bus_usb/devices/1-1.5.5/devpath | 1 +
.../sys_bus_usb/devices/1-1.5.6/devpath | 1 +
.../sys_bus_usb/devices/1-1.5/devpath | 1 +
.../sys_bus_usb/devices/1-1.6/devpath | 1 +
.../sys_bus_usb/devices/1-1/devpath | 1 +
.../sys_bus_usb/devices/2-1.2/devpath | 1 +
.../sys_bus_usb/devices/2-1/devpath | 1 +
.../sys_bus_usb/devices/usb1/devpath | 1 +
.../sys_bus_usb/devices/usb2/devpath | 1 +
.../sys_bus_usb/devices/usb3/devpath | 1 +
.../sys_bus_usb/devices/usb4/devpath | 1 +
24 files changed, 351 insertions(+), 244 deletions(-)
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.5.3.1/devpath
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.5.3.3/devpath
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.5.3/devpath
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.5.4/devpath
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.5.5/devpath
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.5.6/devpath
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.5/devpath
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.6/devpath
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1/devpath
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/2-1.2/devpath
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/2-1/devpath
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/usb1/devpath
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/usb2/devpath
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/usb3/devpath
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/usb4/devpath
--
2.39.5
1 month
[PATCH v2 00/21] LIBVIRT: X86: TDX support
by Zhenzhong Duan
Hi,
This series brings libvirt the x86 TDX support.
* What's TDX?
TDX stands for Trust Domain Extensions which isolates VMs from
the virtual-machine manager (VMM)/hypervisor and any other software on
the platform.
This patchset extends libvirt to support TDX, with which one can start a TDX
guest from high level rather than running qemu directly.
* Misc
As QEMU use a software emulated way to reset guest which isn't supported by TDX
guest for security reason. We simulate reboot for TDX guest by kill and create a
new one in FakeReboot framework.
Complete code can be found at [1].
* Test
Tested with upstream qemu v10.0.0-1724-gf9a3def17b
shutdown/reboot/reset with virsh
shutdown/reboot trigger in guest
shutdown with on_poweroff=destroy/restart
reboot with on_reboot=destroy/restart
* Patch organization
- patch 1-4: Support query of TDX capabilities
- patch 5-11: Add TDX type to launchsecurity framework
- patch 12-17: Add reboot/reset support to TDX guest
- patch 18-20: Add test data/cases
- patch 21: Add docs
TODO:
- add reconnect logic in virsh command
[1] https://github.com/intel/libvirt-tdx/commits/tdx_for_upstream_v2
Thanks
Zhenzhong
Changelog:
v2:
- add capability and xmlconf test (Peter Krempa)
v1:
- s/virQEMUCapsKVMSupportsSecureGuestINTEL/virQEMUCapsKVMSupportsSecureGuestTDX (Daniel)
- make policy element optional and expose to QEMU directly (Daniel)
- s/qemuProcessSecFakeReboot/qemuProcessFakeRebootViaRecreate (Daniel)
- simplify QGS element schema by supporting only UNIX socket (Daniel)
- add new events VIR_DOMAIN_EVENT_[STOPPED|STARTED] for control plane (Daniel)
- s/quoteGenerationService/quoteGenerationSocket as QEMU
- add virsh reset support
rfcv4:
- add a check to tools/virt-host-validate-qemu.c (Daniel)
- remove check of q35 (Daniel)
- model 'SocktetAddress' QAPI in xml schema (Daniel)
- s/Quote-Generation-Service/quoteGenerationService/ (Daniel)
- define bits in tdx->policy and add validating logic (Daniel)
- presume QEMU choose split kernel irqchip for TDX guest by default (Daniel)
- utilize existing FakeReboot framework to do reboot for TDX guest (Daniel)
- drop patch11 'conf: Add support to keep same domid for hard reboot' (Daniel)
- add test in tests/ to validate parsing and formatting logic (Daniel)
- add doc in docs/formatdomain.rst (Daniel)
- add R-B
rfcv3:
- Change to generate qemu cmdline with -bios
- drop firmware auto match as -bios is used
- add a hard reboot method to reboot TDX guest
rfcv3: https://www.mail-archive.com/devel@lists.libvirt.org/msg00385.html
rfcv2:
- give up using qmp cmd and check TDX directly on host for TDX capabilities.
- use launchsecurity framework to support TDX
- use <os>.<loader> for general loader
- add auto firmware match feature for TDX
A example TDVF fimware description file 70-edk2-x86_64-tdx.json:
{
"description": "UEFI firmware for x86_64, supporting Intel TDX",
"interface-types": [
"uefi"
],
"mapping": {
"device": "generic",
"filename": "/usr/share/OVMF/OVMF_CODE-tdx.fd"
},
"targets": [
{
"architecture": "x86_64",
"machines": [
"pc-q35-*"
]
}
],
"features": [
"intel-tdx",
"verbose-dynamic"
],
"tags": [
]
}
rfcv2: https://www.mail-archive.com/libvir-list@redhat.com/msg219378.html
Zhenzhong Duan (21):
tools: Secure guest check for Intel in virt-host-validate
qemu: Check if INTEL Trust Domain Extention support is enabled
qemu: Add TDX capability
conf: Expose TDX feature in domain capabilities
conf: Add tdx as launch security type
conf: Validate TDX launchSecurity element
mrConfigId/mrOwner/mrOwnerConfig
qemu: Add command line and validation for TDX type
conf: Expose TDX type in domain launch security capability
qemu: Force special parameters enabled for TDX guest
conf: Add Intel TDX Quote Generation Service(QGS) support
qemu: Add command line for TDX Quote Generation Service(QGS)
qemu: Add FakeReboot support for TDX guest
qemu: Support reboot command in guest
qemu: Avoid duplicate FakeReboot for secure guest
qemu: Send event VIR_DOMAIN_EVENT_[STOPPED|STARTED] during recreation
qemu: Bypass sending VIR_DOMAIN_EVENT_RESUMED event when TD VM reboot
qemu: Support domain reset command for TDX guest
qemucapabilitiesdata: Document '+inteltdx' variant
qemucapabilitiestest: Add data for the qemu-11.0 dev cycle on x86_64
for the '+inteltdx' variant
qemuxmlconftest: Add latest version of 'launch-security-tdx*' test
data
docs: domain: Add documentation for Intel TDX guest
docs/formatdomain.rst | 63 +
docs/formatdomaincaps.rst | 1 +
examples/c/misc/event-test.c | 6 +
include/libvirt/libvirt-domain.h | 2 +
src/conf/domain_capabilities.c | 1 +
src/conf/domain_capabilities.h | 1 +
src/conf/domain_conf.c | 82 +
src/conf/domain_conf.h | 21 +
src/conf/domain_validate.c | 11 +
src/conf/schemas/domaincaps.rng | 9 +
src/conf/schemas/domaincommon.rng | 41 +
src/conf/virconftypes.h | 2 +
src/qemu/qemu_capabilities.c | 38 +-
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_cgroup.c | 1 +
src/qemu/qemu_command.c | 54 +
src/qemu/qemu_driver.c | 7 +
src/qemu/qemu_firmware.c | 1 +
src/qemu/qemu_monitor.c | 28 +-
src/qemu/qemu_monitor.h | 2 +-
src/qemu/qemu_monitor_json.c | 6 +-
src/qemu/qemu_namespace.c | 1 +
src/qemu/qemu_process.c | 104 +-
src/qemu/qemu_process.h | 2 +
src/qemu/qemu_validate.c | 45 +
src/security/security_dac.c | 2 +
.../qemu_11.0.0-q35.x86_64+inteltdx.xml | 782 +
.../qemu_11.0.0-tcg.x86_64+inteltdx.xml | 1830 +
.../qemu_11.0.0.x86_64+inteltdx.xml | 782 +
tests/qemucapabilitiesdata/README.rst | 5 +
.../caps_11.0.0_x86_64+inteltdx.replies | 44552 ++++++++++++++++
.../caps_11.0.0_x86_64+inteltdx.xml | 3585 ++
.../caps.x86_64+inteltdx.xml | 29 +
...h-security-tdx.x86_64-latest+inteltdx.args | 44 +
...ch-security-tdx.x86_64-latest+inteltdx.xml | 74 +
tests/qemuxmlconfdata/launch-security-tdx.xml | 27 +
tests/qemuxmlconftest.c | 3 +
tools/virsh-domain-event.c | 6 +-
tools/virt-host-validate-common.c | 31 +-
tools/virt-host-validate-common.h | 1 +
40 files changed, 52270 insertions(+), 13 deletions(-)
create mode 100644 tests/domaincapsdata/qemu_11.0.0-q35.x86_64+inteltdx.xml
create mode 100644 tests/domaincapsdata/qemu_11.0.0-tcg.x86_64+inteltdx.xml
create mode 100644 tests/domaincapsdata/qemu_11.0.0.x86_64+inteltdx.xml
create mode 100644 tests/qemucapabilitiesdata/caps_11.0.0_x86_64+inteltdx.replies
create mode 100644 tests/qemucapabilitiesdata/caps_11.0.0_x86_64+inteltdx.xml
create mode 100644 tests/qemucaps2xmloutdata/caps.x86_64+inteltdx.xml
create mode 100644 tests/qemuxmlconfdata/launch-security-tdx.x86_64-latest+inteltdx.args
create mode 100644 tests/qemuxmlconfdata/launch-security-tdx.x86_64-latest+inteltdx.xml
create mode 100644 tests/qemuxmlconfdata/launch-security-tdx.xml
--
2.34.1
1 month
[PATCH v3] remote/stream-event: Fix a memory leak in
remoteStreamCallbackFree()
by liu.xuemei1@zte.com.cn
From: Liu Song <liu.song13(a)zte.com.cn>
The ff callback is never called in remoteStreamCallbackFree() because
cbdata->cb can not be NULL. This causes a leak of 'cbdata->opaque'.
The leak can be reproduced by attaching and detaching to the console of
an VM using `virsh console`.
ASAN reports the leak stack as:
Direct leak of 288 byte(s) in 1 object(s) allocated from:
#0 0x7f6edf6ba0c7 in calloc (/lib64/libasan.so.8+0xba0c7)
#1 0x7f6edf5175b0 in g_malloc0 (/lib64/libglib-2.0.so.0+0x615b0)
#2 0x7f6ede6d0be3 in g_type_create_instance (/lib64/libgobject-2.0.so.0+0x3cbe3)
#3 0x7f6ede6b82cf in g_object_new_internal (/lib64/libgobject-2.0.so.0+0x242cf)
#4 0x7f6ede6b9877 in g_object_new_with_properties (/lib64/libgobject-2.0.so.0+0x25877)
#5 0x7f6ede6ba620 in g_object_new (/lib64/libgobject-2.0.so.0+0x26620)
#6 0x7f6edeb78138 in virObjectNew ../src/util/virobject.c:252
#7 0x7f6edeb7a78b in virObjectLockableNew ../src/util/virobject.c:274
#8 0x558251e427e1 in virConsoleNew ../tools/virsh-console.c:369
#9 0x558251e427e1 in virshRunConsole ../tools/virsh-console.c:427
Signed-off-by: Liu Song <liu.song13(a)zte.com.cn>
---
Changes in v3:
- Remove the second reference to 'client', and unref 'client' in error
path.
src/remote/remote_daemon_stream.c | 7 ++++---
src/remote/remote_driver.c | 2 +-
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/remote/remote_daemon_stream.c b/src/remote/remote_daemon_stream.c
index 453728a66b..b6099e3bc7 100644
--- a/src/remote/remote_daemon_stream.c
+++ b/src/remote/remote_daemon_stream.c
@@ -437,12 +437,13 @@ int daemonAddClientStream(virNetServerClient *client,
return -1;
}
+ virObjectRef(client);
if (virStreamEventAddCallback(stream->st, 0,
daemonStreamEvent, client,
- virObjectUnref) < 0)
+ virObjectUnref) < 0) {
+ virObjectUnref(client);
return -1;
-
- virObjectRef(client);
+ }
if ((stream->filterID = virNetServerClientAddFilter(client,
daemonStreamFilter,
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 2690c05267..9ac13469e9 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -5336,7 +5336,7 @@ static void remoteStreamCallbackFree(void *opaque)
{
struct remoteStreamCallbackData *cbdata = opaque;
- if (!cbdata->cb && cbdata->ff)
+ if (cbdata->ff)
(cbdata->ff)(cbdata->opaque);
virObjectUnref(cbdata->st);
--
2.27.0
1 month
Re: [PATCH] remote/stream-event: Fix a memory leak in??
remoteStreamCallbackFree()
by Bjorn Helgaas
[+to libvirt development list, since this looks like a libvirt patch,
not a Linux kernel patch]
On Thu, Jun 26, 2025 at 02:10:38PM +0800, liu.xuemei1(a)zte.com.cn wrote:
> From: Liu Song <liu.song13(a)zte.com.cn>
>
> The ff callback is never called in remoteStreamCallbackFree() because
> cbdata->cb can not be NULL. This causes a leak of 'cbdata->opaque'.
>
> The leak can be reproduced by attaching and detaching to the console of
> an VM using `virsh console`.
>
> ASAN reports the leak stack as:
> Direct leak of 288 byte(s) in 1 object(s) allocated from:
> #0 0x7f6edf6ba0c7 in calloc (/lib64/libasan.so.8+0xba0c7)
> #1 0x7f6edf5175b0 in g_malloc0 (/lib64/libglib-2.0.so.0+0x615b0)
> #2 0x7f6ede6d0be3 in g_type_create_instance (/lib64/libgobject-2.0.so.0+0x3cbe3)
> #3 0x7f6ede6b82cf in g_object_new_internal (/lib64/libgobject-2.0.so.0+0x242cf)
> #4 0x7f6ede6b9877 in g_object_new_with_properties (/lib64/libgobject-2.0.so.0+0x25877)
> #5 0x7f6ede6ba620 in g_object_new (/lib64/libgobject-2.0.so.0+0x26620)
> #6 0x7f6edeb78138 in virObjectNew ../src/util/virobject.c:252
> #7 0x7f6edeb7a78b in virObjectLockableNew ../src/util/virobject.c:274
> #8 0x558251e427e1 in virConsoleNew ../tools/virsh-console.c:369
> #9 0x558251e427e1 in virshRunConsole ../tools/virsh-console.c:427
>
> Signed-off-by: Liu Song <liu.song13(a)zte.com.cn>
> ---
> src/remote/remote_daemon_stream.c | 2 +-
> src/remote/remote_driver.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/remote/remote_daemon_stream.c b/src/remote/remote_daemon_stream.c
> index 453728a66b..a5032f9a43 100644
> --- a/src/remote/remote_daemon_stream.c
> +++ b/src/remote/remote_daemon_stream.c
> @@ -437,13 +437,13 @@ int daemonAddClientStream(virNetServerClient *client,
> return -1;
> }
>
> + virObjectRef(client);
> if (virStreamEventAddCallback(stream->st, 0,
> daemonStreamEvent, client,
> virObjectUnref) < 0)
> return -1;
>
> virObjectRef(client);
> -
> if ((stream->filterID = virNetServerClientAddFilter(client,
> daemonStreamFilter,
> stream)) < 0) {
> diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
> index 2690c05267..9ac13469e9 100644
> --- a/src/remote/remote_driver.c
> +++ b/src/remote/remote_driver.c
> @@ -5336,7 +5336,7 @@ static void remoteStreamCallbackFree(void *opaque)
> {
> struct remoteStreamCallbackData *cbdata = opaque;
>
> - if (!cbdata->cb && cbdata->ff)
> + if (cbdata->ff)
> (cbdata->ff)(cbdata->opaque);
>
> virObjectUnref(cbdata->st);
> --
> 2.27.0
1 month
[PATCH v2] remote/stream-event: Fix a memory leak in
remoteStreamCallbackFree()
by liu.xuemei1@zte.com.cn
From: Liu Song <liu.song13(a)zte.com.cn>
The ff callback is never called in remoteStreamCallbackFree() because
cbdata->cb can not be NULL. This causes a leak of 'cbdata->opaque'.
The leak can be reproduced by attaching and detaching to the console of
an VM using `virsh console`.
ASAN reports the leak stack as:
Direct leak of 288 byte(s) in 1 object(s) allocated from:
#0 0x7f6edf6ba0c7 in calloc (/lib64/libasan.so.8+0xba0c7)
#1 0x7f6edf5175b0 in g_malloc0 (/lib64/libglib-2.0.so.0+0x615b0)
#2 0x7f6ede6d0be3 in g_type_create_instance (/lib64/libgobject-2.0.so.0+0x3cbe3)
#3 0x7f6ede6b82cf in g_object_new_internal (/lib64/libgobject-2.0.so.0+0x242cf)
#4 0x7f6ede6b9877 in g_object_new_with_properties (/lib64/libgobject-2.0.so.0+0x25877)
#5 0x7f6ede6ba620 in g_object_new (/lib64/libgobject-2.0.so.0+0x26620)
#6 0x7f6edeb78138 in virObjectNew ../src/util/virobject.c:252
#7 0x7f6edeb7a78b in virObjectLockableNew ../src/util/virobject.c:274
#8 0x558251e427e1 in virConsoleNew ../tools/virsh-console.c:369
#9 0x558251e427e1 in virshRunConsole ../tools/virsh-console.c:427
Signed-off-by: Liu Song <liu.song13(a)zte.com.cn>
---
Changes in v2:
- Fixed email formatting to ensure patch applies correctly
src/remote/remote_daemon_stream.c | 2 +-
src/remote/remote_driver.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/remote/remote_daemon_stream.c b/src/remote/remote_daemon_stream.c
index 453728a66b..a5032f9a43 100644
--- a/src/remote/remote_daemon_stream.c
+++ b/src/remote/remote_daemon_stream.c
@@ -437,13 +437,13 @@ int daemonAddClientStream(virNetServerClient *client,
return -1;
}
+ virObjectRef(client);
if (virStreamEventAddCallback(stream->st, 0,
daemonStreamEvent, client,
virObjectUnref) < 0)
return -1;
virObjectRef(client);
-
if ((stream->filterID = virNetServerClientAddFilter(client,
daemonStreamFilter,
stream)) < 0) {
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 2690c05267..9ac13469e9 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -5336,7 +5336,7 @@ static void remoteStreamCallbackFree(void *opaque)
{
struct remoteStreamCallbackData *cbdata = opaque;
- if (!cbdata->cb && cbdata->ff)
+ if (cbdata->ff)
(cbdata->ff)(cbdata->opaque);
virObjectUnref(cbdata->st);
--
2.27.0
1 month