mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
50c7a272441f32aff2c8f1a98afa3e5b451d0e99
In recent commit ofbf8bd93df0(and friends) we switched the way we process queried command line arguments: from string lists to virJSONValue stored in a hash table. To achieve this qemuMonitorJSONGetCommandLineOptions() helper was introduced which executes the "query-command-line-options" monitor command and then calls virJSONValueArrayForeachSteal() to process the output. The array process function is also given qemuMonitorJSONGetCommandLineOptionsWorker() as the callback which is called over each item of the returned array. This callback then steals "parameters" attribute of each array iteam storing it in the hash table, but it leaves behind "option" attribute (because it's g_strdup()-ed). After all of this, the callback returns 0 which is a signal to the array processing function that the callback took ownership of the array item. But this is not true. While it removed "parameters" it did not take the rest ("option" for instance). And therefore, it leads to a memory leak: 5,347 (1,656 direct, 3,691 indirect) bytes in 69 blocks are definitely lost in loss record 2,752 of 2,794 at 0x483BEC5: calloc (vg_replace_malloc.c:760) by 0x4E25A10: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.6400.5) by 0x4943317: virJSONValueNewObject (virjson.c:569) by 0x4945692: virJSONParserHandleStartMap (virjson.c:1768) by 0x5825A86: yajl_do_parse (in /usr/lib64/libyajl.so.2.1.0) by 0x4945BFA: virJSONValueFromString (virjson.c:1896) by 0xAF5C115: qemuMonitorJSONIOProcessLine (qemu_monitor_json.c:224) by 0xAF5C45E: qemuMonitorJSONIOProcess (qemu_monitor_json.c:279) by 0xAF4BB6C: qemuMonitorIOProcess (qemu_monitor.c:342) by 0xAF4C444: qemuMonitorIO (qemu_monitor.c:574) by 0x4FEF846: socket_source_dispatch (in /usr/lib64/libgio-2.0.so.0.6400.5) by 0x4E1F727: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.6400.5) The callback must return 1 so that the array item is properly freed. Fixes:ebeff6cd57Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
.. image:: https://gitlab.com/libvirt/libvirt/badges/master/pipeline.svg
:target: https://gitlab.com/libvirt/libvirt/pipelines
:alt: GitLab CI Build Status
.. image:: https://bestpractices.coreinfrastructure.org/projects/355/badge
:target: https://bestpractices.coreinfrastructure.org/projects/355
:alt: CII Best Practices
.. image:: https://translate.fedoraproject.org/widgets/libvirt/-/libvirt/svg-badge.svg
:target: https://translate.fedoraproject.org/engage/libvirt/
:alt: Translation status
==============================
Libvirt API for virtualization
==============================
Libvirt provides a portable, long term stable C API for managing the
virtualization technologies provided by many operating systems. It
includes support for QEMU, KVM, Xen, LXC, bhyve, Virtuozzo, VMware
vCenter and ESX, VMware Desktop, Hyper-V, VirtualBox and the POWER
Hypervisor.
For some of these hypervisors, it provides a stateful management
daemon which runs on the virtualization host allowing access to the
API both by non-privileged local users and remote users.
Layered packages provide bindings of the libvirt C API into other
languages including Python, Perl, PHP, Go, Java, OCaml, as well as
mappings into object systems such as GObject, CIM and SNMP.
Further information about the libvirt project can be found on the
website:
https://libvirt.org
License
=======
The libvirt C API is distributed under the terms of GNU Lesser General
Public License, version 2.1 (or later). Some parts of the code that are
not part of the C library may have the more restrictive GNU General
Public License, version 2.0 (or later). See the files ``COPYING.LESSER``
and ``COPYING`` for full license terms & conditions.
Installation
============
Instructions on building and installing libvirt can be found on the website:
https://libvirt.org/compiling.html
Contributing
============
The libvirt project welcomes contributions in many ways. For most components
the best way to contribute is to send patches to the primary development
mailing list. Further guidance on this can be found on the website:
https://libvirt.org/contribute.html
Contact
=======
The libvirt project has two primary mailing lists:
* libvirt-users@redhat.com (**for user discussions**)
* libvir-list@redhat.com (**for development only**)
Further details on contacting the project are available on the website:
https://libvirt.org/contact.html
Description
Read-only mirror. Please submit merge requests / issues to https://gitlab.com/libvirt/libvirt
Languages
C
94.8%
Python
2%
Meson
0.9%
Shell
0.8%
Dockerfile
0.6%
Other
0.8%