[libvirt PATCH 00/15] eliminate VIR_FREE in all *Dispose() functions
by Laine Stump
A *Dispose() function is similar to a *Free() function, except that 1)
the object is always sent as a void* so it has to be typecast into
some other object-specific pointer at the top of the function, and 2)
it frees all the resources inside the object, but never frees the
object itself (this is done by the caller, somewhere deep in the
bowels of virObjectDispose or something I guess; frankly I've always
ignored the details simply "because I could").
The important point is that the contents of the object are never
referenced in any way after return from the Dispose function, so it is
unnecessary to clear any pointers, ergo (always wanted to use that
word!) it's completely safe to replace all VIR_FREEs in a *Dispose()
function with g_free (as long as there's nothing within the Dispose
function itself that depends on the pointers being cleared).
After this series is applied, there will be exactly 0 instances of
VIR_FREE in any *Dispose() (or *Free()) function. As with the *Free()
series, almost all were accomplished by directly replacing VIR_FREE
with g_free, but there were a couple oddities that needed separate
patches just to call them out:
* Patch 1 & 2 - in both cases a Dispose() function was the only
caller to a *Free() function that didn't fit the normal pattern of
a *Free() function. Since each of the Free()s had only one caller
(their respective *Dispose() parents), their contents were just
moved into the caller, clearing the way for their VIR_FREEs to be
g_free-ified (in later patches, along with the other *Dispose()
functions in the same directories).
220 VIR_FREE uses eliminated in this series, so a total of 762 for the
two series combined (nearly 20% of all remaining VIR_FREEs).
Laine Stump (15):
conf: simplify virDomainCapsDispose()
rpc: eliminate static function virNetLibsshSessionAuthMethodsFree()
bhyve: replace VIR_FREE with g_free in all *Dispose() functions
libxl: replace VIR_FREE with g_free in all *Dispose() functions
qemu: replace VIR_FREE with g_free in all *Dispose() functions
interface: replace VIR_FREE with g_free in all *Dispose() functions
access: replace VIR_FREE with g_free in all *Dispose() functions
hypervisor: replace VIR_FREE with g_free in all *Dispose() functions
logging: replace VIR_FREE with g_free in all *Dispose() functions
rpc: replace VIR_FREE with g_free in all *Dispose() functions
security: replace VIR_FREE with g_free in all *Dispose() functions
util: replace VIR_FREE with g_free in all *Dispose() functions
conf: replace VIR_FREE with g_free in all *Dispose() functions
tests: replace VIR_FREE with g_free in all *Dispose() functions
datatypes: replace VIR_FREE with g_free in all *Dispose() functions
src/access/viraccessmanager.c | 2 +-
src/bhyve/bhyve_conf.c | 2 +-
src/conf/capabilities.c | 22 ++---
src/conf/checkpoint_conf.c | 2 +-
src/conf/domain_capabilities.c | 29 ++----
src/conf/domain_conf.c | 2 +-
src/conf/domain_event.c | 52 +++++-----
src/conf/moment_conf.c | 6 +-
src/conf/object_event.c | 4 +-
src/conf/snapshot_conf.c | 4 +-
src/conf/virsecretobj.c | 6 +-
src/conf/virstorageobj.c | 4 +-
src/datatypes.c | 34 +++----
src/hypervisor/virhostdev.c | 2 +-
src/interface/interface_backend_netcf.c | 2 +-
src/libxl/libxl_conf.c | 20 ++--
src/libxl/libxl_migration.c | 2 +-
src/logging/log_handler.c | 2 +-
src/qemu/qemu_agent.c | 2 +-
src/qemu/qemu_capabilities.c | 10 +-
src/qemu/qemu_conf.c | 122 ++++++++++++------------
src/qemu/qemu_domain.c | 10 +-
src/qemu/qemu_monitor.c | 4 +-
src/rpc/virnetclient.c | 4 +-
src/rpc/virnetdaemon.c | 6 +-
src/rpc/virnetlibsshsession.c | 37 +++----
src/rpc/virnetsaslcontext.c | 2 +-
src/rpc/virnetserver.c | 8 +-
src/rpc/virnetserverservice.c | 2 +-
src/rpc/virnetsocket.c | 6 +-
src/rpc/virnetsshsession.c | 8 +-
src/rpc/virnettlscontext.c | 6 +-
src/security/security_manager.c | 2 +-
src/util/virdnsmasq.c | 2 +-
src/util/virfilecache.c | 4 +-
src/util/virmdev.c | 2 +-
src/util/virnvme.c | 2 +-
src/util/virpci.c | 2 +-
src/util/virresctrl.c | 40 ++++----
src/util/virscsi.c | 2 +-
src/util/virscsivhost.c | 2 +-
src/util/virusb.c | 2 +-
tests/virfilecachetest.c | 2 +-
43 files changed, 235 insertions(+), 251 deletions(-)
--
2.29.2
3 years, 9 months
Re: [PATCH 3/3] utils: Deprecate inexact fractional suffix sizes
by Eric Blake
On 2/4/21 1:07 PM, Eric Blake wrote:
> The value '1.1k' is inexact; 1126.4 bytes is not possible, so we
> happen to truncate it to 1126. Our use of fractional sizes is
> intended for convenience, but when a user specifies a fraction that is
> not a clean translation to binary, truncating/rounding behind their
> backs can cause confusion. Better is to deprecate inexact values,
> which still leaves '1.5k' as valid, but alerts the user to spell out
> their values as a precise byte number in cases where they are
> currently being rounded.
And I promptly forgot to save my changes in my editor. Consider this
squashed in:
diff --git i/docs/system/deprecated.rst w/docs/system/deprecated.rst
index c404c3926e6f..8e5e05a10642 100644
--- i/docs/system/deprecated.rst
+++ w/docs/system/deprecated.rst
@@ -154,6 +154,15 @@ Input parameters that take a size value should only
use a size suffix
the value is hexadecimal. That is, '0x20M' is deprecated, and should
be written either as '32M' or as '0x2000000'.
+inexact sizes via scaled fractions (since 6.0)
+''''''''''''''''''''''''''''''''''''''''''''''
+
+Input parameters that take a size value should only use a fractional
+size (such as '1.5M') that will result in an exact byte value. The
+use of inexact values (such as '1.1M') that require truncation or
+rounding is deprecated, and you should instead consider writing your
+unusual size in bytes (here, '1153433' or '1153434' as desired).
+
QEMU Machine Protocol (QMP) commands
------------------------------------
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
3 years, 9 months
[libvirt PATCH v2 00/24] eliminate VIR_FREE in all *Free() functions
by Laine Stump
When I sent a patch to convert (what I thought was) all of the
VIR_FREEs in any *Free() function in the conf directory to g_free
(with the justification that it was trivial to verify that the
pointers weren't being referenced after they had been freed), there
were two responses that stuck in my mind:
1) Daniel said that this was a reasonable class of uses to change and
a reasonable way to arrive at the desired end result.
2) Peter justifiably expressing concern over the amount of churn in
the code, and also said that he'd rather not have things "halfway" for
an indeterminate time.
The combination of those two comments (ignoring the part about
"concern for churn" :-) let me to sit down last night and make this
patch series that eliminates all uses of VIR_FREE from any function
whose name ends in "Free" (or eliminate/rename the function, just for
completeness' sake)
In the vast majority of cases, this was done by replacing the
VIR_FREEs in the functions with g_free (while verifying that
everything being g_freed was actually something pointed to by the
parent object that was sent to the *Free() function, and that the
parent object itself was subsequently freed).
But there were a a couple of cases where this wasn't quite the right
thing to do:
* in patch 20, two functions ending with Free() don't actually free
the pointer they're sent. They instead behave like a *Clear()
function, VIR_FREEing their components. Since we can see that
these functions aren't actually be used as *Clear() functions (and
never will be used that way), but don't want to promote confusion
by leaving them misnamed, the patch renames them to *FreeContent()
(more accurate name) and changes their VIR_FREEs to g_frees (it
takes more than just looking at one function, but it's very easy
to verify that the pointers are never referenced after they're
freed).
* In Patch 21-23, several *Free() functions were actually being
passed a full copy of an object, and then VIR_FREEing all the
pointers in the copied object. So the name was misleading, the
function was inefficiently copying entire objects, and was
unnecessarily NULLing the pointers that were then tossed out when
the function returned. So I renamed the functions (21), changed
the calling sequences to use pointers instead of copied objects
(22), and (of course) changed the VIR_FREEs into g_free (23).
* in Patch 24, a *Free() function actually appears to be used as a
Clear() function. So I left the VIR_FREEs in place, but renamed
the function to *Clear(). However, its one use as a *Clear() is
when being called from a "Reset" function that (as far as I can
see) is never used. If we could get rid of that Reset function, I
could just fold the *Clear() function into its one remaining
caller, and eliminate the VIR_FREEs. If someone knows more about
the function virNetSSHSessionAuthReset() (which is in a section of
the file labeled "Public API") please enlighten me.
**
The last time I ran wc over the diffs of these patches, it showed they
are eliminating 542 uses of VIR_FREE, which is > 13% of the 4k
remaining.
There is a companion series that eliminates VIR_FREE from all
*Dispose() functions, but I'm sending it separately since the two
series are completely independent, and I didn't want to scare anyone
off. (Really, most of these can be very mechanically reviewed - just
verify that all the items being g_freed are subordinates of the main
argument to the function, and that that object is freed before return)
Laine Stump (24):
conf: replace remaining straggler VIR_FREE with g_free in vir*Free()
util: replace VIR_FREE with g_free in all vir*Free() functions
bhyve: replace VIR_FREE with g_free in all vir*Free() functions
libxl: replace VIR_FREE with g_free in all vir*Free() functions
qemu: replace VIR_FREE with g_free in all vir*Free() functions
test_driver: replace VIR_FREE with g_free in all vir*Free() functions
vbox: replace VIR_FREE with g_free in all vir*Free() functions
vmx: replace VIR_FREE with g_free in all vir*Free() functions
vz: replace VIR_FREE with g_free in all vir*Free() functions
admin: replace VIR_FREE with g_free in all vir*Free() functions
locking: replace VIR_FREE with g_free in all vir*Free() functions
logging: replace VIR_FREE with g_free in all vir*Free() functions
remote: replace VIR_FREE with g_free in all vir*Free() functions
rpc: replace VIR_FREE with g_free in all vir*Free() functions
security: replace VIR_FREE with g_free in all vir*Free() functions
tools: replace VIR_FREE with g_free in all vir*Free() functions
tests: replace VIR_FREE with g_free in all vir*Free() functions
storage: replace VIR_FREE with g_free in all vir*Free() functions
libvirtd: replace straggler VIR_FREE with g_free in all vir*Free()
functions
util: rename two *Free() functions while changing VIR_FREE to g_free
qemu: rename virFirmware*Free() functions to have more accurate names
qemu: pass pointers instead of copying objects for
qemuFirmware*FreeContent()
qemu: replace VIR_FREE with g_free in qemuFirmware*FreeContent()
rpc: rename virNetSessionAuthMethodsFree to
virNetSessionAuthMethodsClear
src/admin/admin_server_dispatch.c | 2 +-
src/bhyve/bhyve_conf.c | 6 +-
src/bhyve/bhyve_domain.c | 2 +-
src/conf/domain_conf.c | 6 +-
src/conf/numa_conf.c | 10 +--
src/conf/storage_encryption_conf.c | 2 +-
src/conf/virchrdev.c | 6 +-
src/libvirt-domain.c | 18 +++---
src/libvirt-network.c | 14 ++---
src/libxl/libxl_domain.c | 2 +-
src/libxl/libxl_driver.c | 2 +-
src/libxl/libxl_migration.c | 6 +-
src/locking/lock_daemon.c | 6 +-
src/locking/lock_daemon_config.c | 6 +-
src/locking/lock_driver_lockd.c | 10 +--
src/locking/lock_driver_sanlock.c | 6 +-
src/locking/lock_manager.c | 2 +-
src/logging/log_daemon.c | 4 +-
src/logging/log_daemon_config.c | 6 +-
src/logging/log_handler.c | 6 +-
src/logging/log_manager.c | 2 +-
src/qemu/qemu_block.c | 36 +++++------
src/qemu/qemu_capabilities.c | 8 +--
src/qemu/qemu_cgroup.c | 4 +-
src/qemu/qemu_conf.c | 6 +-
src/qemu/qemu_domain.c | 14 ++---
src/qemu/qemu_firmware.c | 42 ++++++-------
src/qemu/qemu_migration_params.c | 4 +-
src/qemu/qemu_monitor.c | 48 +++++++--------
src/qemu/qemu_monitor_json.c | 22 +++----
src/qemu/qemu_process.c | 24 ++++----
src/qemu/qemu_saveimage.c | 6 +-
src/qemu/qemu_slirp.c | 2 +-
src/qemu/qemu_vhost_user.c | 8 +--
src/remote/remote_daemon_config.c | 48 +++++++--------
src/remote/remote_daemon_dispatch.c | 4 +-
src/remote/remote_driver.c | 2 +-
src/rpc/virnetmessage.c | 2 +-
src/rpc/virnetsshsession.c | 6 +-
src/security/security_dac.c | 8 +--
src/security/security_selinux.c | 10 +--
src/storage/storage_backend_fs.c | 6 +-
src/storage/storage_backend_rbd.c | 10 +--
src/storage/storage_backend_scsi.c | 4 +-
src/storage/storage_driver.c | 4 +-
src/test/test_driver.c | 6 +-
src/util/virarptable.c | 8 +--
src/util/virauthconfig.c | 4 +-
src/util/virbitmap.c | 4 +-
src/util/vircgroup.c | 12 ++--
src/util/vircommand.c | 24 ++++----
src/util/virconf.c | 10 +--
src/util/virdnsmasq.c | 32 +++++-----
src/util/virebtables.c | 4 +-
src/util/virfdstream.c | 10 +--
src/util/virfile.c | 4 +-
src/util/virfirewall.c | 16 ++---
src/util/virfirmware.c | 8 +--
src/util/virjson.c | 12 ++--
src/util/virlockspace.c | 12 ++--
src/util/virlog.c | 12 ++--
src/util/virmacaddr.c | 2 +-
src/util/virmdev.c | 16 ++---
src/util/virnetdev.c | 12 ++--
src/util/virnetdevbandwidth.c | 6 +-
src/util/virnetdevip.c | 6 +-
src/util/virnetdevmacvlan.c | 8 +--
src/util/virnetdevvlan.c | 2 +-
src/util/virnvme.c | 2 +-
src/util/virobject.c | 2 +-
src/util/virpci.c | 18 +++---
src/util/virperf.c | 2 +-
src/util/virportallocator.c | 4 +-
src/util/virresctrl.c | 6 +-
src/util/virrotatingfile.c | 14 ++---
src/util/virscsi.c | 16 ++---
src/util/virscsivhost.c | 10 +--
src/util/virseclabel.c | 16 ++---
src/util/virsocketaddr.c | 2 +-
src/util/virsysinfo.c | 96 ++++++++++++++---------------
src/util/virsystemd.c | 6 +-
src/util/virthreadpool.c | 6 +-
src/util/virtypedparam-public.c | 2 +-
src/util/virtypedparam.c | 8 +--
src/util/viruri.c | 20 +++---
src/util/virusb.c | 8 +--
src/util/virxml.c | 4 +-
src/vbox/vbox_snapshot_conf.c | 54 ++++++++--------
src/vmx/vmx.c | 6 +-
src/vz/vz_driver.c | 8 +--
src/vz/vz_utils.c | 2 +-
tests/nodedevmdevctltest.c | 4 +-
tests/nwfilterxml2firewalltest.c | 2 +-
tests/qemuhotplugtest.c | 12 ++--
tests/qemumonitortestutils.c | 28 ++++-----
tests/virnetdaemontest.c | 2 +-
tests/virnetserverclienttest.c | 2 +-
tools/virsh-checkpoint.c | 6 +-
tools/virsh-domain-monitor.c | 4 +-
tools/virsh-domain.c | 2 +-
tools/virsh-interface.c | 4 +-
tools/virsh-network.c | 8 +--
tools/virsh-nodedev.c | 4 +-
tools/virsh-nwfilter.c | 8 +--
tools/virsh-pool.c | 4 +-
tools/virsh-secret.c | 4 +-
tools/virsh-snapshot.c | 6 +-
tools/virsh-volume.c | 4 +-
tools/vsh-table.c | 10 +--
tools/vsh.c | 6 +-
110 files changed, 557 insertions(+), 557 deletions(-)
--
2.29.2
3 years, 9 months
[libvirt PATCH] qemu_monitor_json: fix JSON generator for VC chardev
by Pavel Hrdina
The correct backend type is 'vc', same as in qemuBuildChrChardevStr()
where we generate qemu command line.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/qemu/qemu_monitor_json.c | 5 ++++-
tests/qemumonitorjsontest.c | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 97c5e5b36c..231f0ded32 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -7438,10 +7438,13 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID,
switch ((virDomainChrType)chr->type) {
case VIR_DOMAIN_CHR_TYPE_NULL:
- case VIR_DOMAIN_CHR_TYPE_VC:
backend_type = "null";
break;
+ case VIR_DOMAIN_CHR_TYPE_VC:
+ backend_type = "vc";
+ break;
+
case VIR_DOMAIN_CHR_TYPE_PTY:
backend_type = "pty";
break;
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 29c396891b..956423f10f 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -718,7 +718,7 @@ qemuMonitorJSONTestAttachChardev(virDomainXMLOptionPtr xmlopt,
chr = (virDomainChrSourceDef) { .type = VIR_DOMAIN_CHR_TYPE_VC };
CHECK("vc", false,
- "{'id':'alias','backend':{'type':'null','data':{}}}");
+ "{'id':'alias','backend':{'type':'vc','data':{}}}");
chr = (virDomainChrSourceDef) { .type = VIR_DOMAIN_CHR_TYPE_PTY };
if (qemuMonitorJSONTestAttachOneChardev(xmlopt, schema, "pty", &chr,
--
2.29.2
3 years, 9 months
[libvirt PATCH] qemu_driver: increase recorded counter for disk block stats
by Pavel Hrdina
Commit <318d807a0bd3372b634d1952b559c5c627ccfa5b> added a fix to skip
most of the block stat code to not log error message for missing storage
sources but forgot to increase the recordnr counter.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/qemu/qemu_driver.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 69fcd28666..c34af6b7d1 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -18414,8 +18414,14 @@ qemuDomainGetStatsBlockExportDisk(virDomainDiskDefPtr disk,
VIR_INFO("optional disk '%s' source file is missing, "
"skip getting stats", disk->dst);
- return qemuDomainGetStatsBlockExportHeader(disk, disk->src, *recordnr,
- params);
+ if (qemuDomainGetStatsBlockExportHeader(disk, disk->src, *recordnr,
+ params) < 0) {
+ return -1;
+ }
+
+ (*recordnr)++;
+
+ return 0;
}
/* vhost-user disk doesn't support getting block stats */
--
2.29.2
3 years, 9 months
[libvirt PATCH 0/2] tests: Improve macOS stat() mocking logic
by Andrea Bolognani
See 2/2 for more information.
Andrea Bolognani (2):
tests: Split macOS stat() mocking logic
tests: Improve macOS stat() mocking logic
tests/virmockstathelpers.c | 75 ++++++++++++++++++++++----------------
1 file changed, 43 insertions(+), 32 deletions(-)
--
2.26.2
3 years, 9 months
[libvirt PATCH 00/21] eliminate VIR_FREE in all *Free() functions
by Laine Stump
When I sent a patch to convert (what I thought was) all of the
VIR_FREEs in any *Free() function in the conf directory to g_free
(with the justification that it was trivial to verify that the
pointers weren't being referenced after they had been freed), there
were two responses that stuck in my mind:
1) Daniel said that this was a reasonable class of uses to change and
a reasonable way to arrive at the desired end result.
2) Peter justifiably expressing concern over the amount of churn in
the code, and also said that he'd rather not have things "halfway" for
an indeterminate time.
The combination of those two comments (ignoring the part about
"concern for churn" :-) let me to sit down last night and make this
patch series that eliminates all uses of VIR_FREE from any function
whose name ends in "Free" (or eliminate/rename the function, just for
completeness' sake)
In the vast majority of cases, this was done by replacing the
VIR_FREEs in the functions with g_free (while verifying that
everything being g_freed was actually something pointed to by the
parent object that was sent to the *Free() function, and that the
parent object itself was subsequently freed).
But there were a a couple of cases where this wasn't quite the right
thing to do:
* in patch 20, two functions ending with Free() don't actually free
the pointer they're sent. They instead behave like a *Clear()
function, VIR_FREEing their components. Since we can see that
these functions aren't actually be used as *Clear() functions (and
never will be used that way), but don't want to promote confusion
by leaving them misnamed, the patch renames them to *FreeContent()
(more accurate name) and changes their VIR_FREEs to g_frees (it
takes more than just looking at one function, but it's very easy
to verify that the pointers are never referenced after they're
freed).
* In Patch 21, a *Free() function actually appears to be used as a
*Clear() function, I left the VIR_FREEs in place, but renamed the
*function to *Clear(). However, its one use as a *Clear() is when
*being called from a "Reset" function that (as far as I can see)
*is never used. If we could get rid of that Reset function, I
*could just fold the *Clear() function into its one remaining
*caller, and eliminate the VIR_FREEs.
There is a companion series that eliminates VIR_FREE from all
*Dispose() functions, but I'm sending it separately since the two
series are completely independent.
The last time I ran wc over the diffs of these patches, it showed they
are eliminating 436 uses of VIR_FREE, which is > 10% of the 4k
remaining.
Laine Stump (21):
conf: replace remaining straggler VIR_FREE with g_free in vir*Free()
util: replace VIR_FREE with g_free in all vir*Free() functions
bhyve: replace VIR_FREE with g_free in all vir*Free() functions
libxl: replace VIR_FREE with g_free in all vir*Free() functions
qemu: replace VIR_FREE with g_free in all vir*Free() functions
test_driver: replace VIR_FREE with g_free in all vir*Free() functions
vbox: replace VIR_FREE with g_free in all vir*Free() functions
vmx: replace VIR_FREE with g_free in all vir*Free() functions
vz: replace VIR_FREE with g_free in all vir*Free() functions
admin: replace VIR_FREE with g_free in all vir*Free() functions
locking: replace VIR_FREE with g_free in all vir*Free() functions
logging: replace VIR_FREE with g_free in all vir*Free() functions
remote: replace VIR_FREE with g_free in all vir*Free() functions
rpc: replace VIR_FREE with g_free in all vir*Free() functions
security: replace VIR_FREE with g_free in all vir*Free() functions
tools: replace VIR_FREE with g_free in all vir*Free() functions
tests: replace VIR_FREE with g_free in all vir*Free() functions
storage: replace VIR_FREE with g_free in all vir*Free() functions
libvirtd: replace straggler VIR_FREE with g_free in all vir*Free()
functions
util: rename two *Free() functions while changing VIR_FREE to g_free
rpc: rename virNetSessionAuthMethodsFree to
virNetSessionAuthMethodsClear
src/admin/admin_server_dispatch.c | 2 +-
src/bhyve/bhyve_conf.c | 6 +-
src/bhyve/bhyve_domain.c | 2 +-
src/conf/domain_conf.c | 6 +-
src/conf/numa_conf.c | 10 +--
src/conf/storage_encryption_conf.c | 2 +-
src/conf/virchrdev.c | 6 +-
src/libvirt-domain.c | 18 +++---
src/libvirt-network.c | 14 ++---
src/libxl/libxl_domain.c | 2 +-
src/libxl/libxl_driver.c | 2 +-
src/libxl/libxl_migration.c | 6 +-
src/locking/lock_daemon.c | 6 +-
src/locking/lock_daemon_config.c | 6 +-
src/locking/lock_driver_lockd.c | 10 +--
src/locking/lock_driver_sanlock.c | 6 +-
src/locking/lock_manager.c | 2 +-
src/logging/log_daemon.c | 4 +-
src/logging/log_daemon_config.c | 6 +-
src/logging/log_handler.c | 6 +-
src/logging/log_manager.c | 2 +-
src/qemu/qemu_block.c | 36 +++++------
src/qemu/qemu_capabilities.c | 8 +--
src/qemu/qemu_cgroup.c | 4 +-
src/qemu/qemu_conf.c | 6 +-
src/qemu/qemu_domain.c | 14 ++---
src/qemu/qemu_firmware.c | 10 +--
src/qemu/qemu_migration_params.c | 4 +-
src/qemu/qemu_monitor.c | 48 +++++++--------
src/qemu/qemu_monitor_json.c | 22 +++----
src/qemu/qemu_process.c | 24 ++++----
src/qemu/qemu_saveimage.c | 6 +-
src/qemu/qemu_slirp.c | 2 +-
src/qemu/qemu_vhost_user.c | 8 +--
src/remote/remote_daemon_config.c | 48 +++++++--------
src/remote/remote_daemon_dispatch.c | 4 +-
src/remote/remote_driver.c | 2 +-
src/rpc/virnetmessage.c | 2 +-
src/rpc/virnetsshsession.c | 6 +-
src/security/security_dac.c | 8 +--
src/security/security_selinux.c | 10 +--
src/storage/storage_backend_fs.c | 6 +-
src/storage/storage_backend_rbd.c | 10 +--
src/storage/storage_backend_scsi.c | 4 +-
src/storage/storage_driver.c | 4 +-
src/test/test_driver.c | 6 +-
src/util/virarptable.c | 8 +--
src/util/virauthconfig.c | 4 +-
src/util/virbitmap.c | 4 +-
src/util/vircgroup.c | 12 ++--
src/util/vircommand.c | 24 ++++----
src/util/virconf.c | 10 +--
src/util/virdnsmasq.c | 32 +++++-----
src/util/virebtables.c | 4 +-
src/util/virfdstream.c | 10 +--
src/util/virfile.c | 4 +-
src/util/virfirewall.c | 16 ++---
src/util/virfirmware.c | 8 +--
src/util/virjson.c | 12 ++--
src/util/virlockspace.c | 12 ++--
src/util/virlog.c | 12 ++--
src/util/virmacaddr.c | 2 +-
src/util/virmdev.c | 16 ++---
src/util/virnetdev.c | 12 ++--
src/util/virnetdevbandwidth.c | 6 +-
src/util/virnetdevip.c | 6 +-
src/util/virnetdevmacvlan.c | 8 +--
src/util/virnetdevvlan.c | 2 +-
src/util/virnvme.c | 2 +-
src/util/virobject.c | 2 +-
src/util/virpci.c | 18 +++---
src/util/virperf.c | 2 +-
src/util/virportallocator.c | 4 +-
src/util/virresctrl.c | 6 +-
src/util/virrotatingfile.c | 14 ++---
src/util/virscsi.c | 16 ++---
src/util/virscsivhost.c | 10 +--
src/util/virseclabel.c | 16 ++---
src/util/virsocketaddr.c | 2 +-
src/util/virsysinfo.c | 96 ++++++++++++++---------------
src/util/virsystemd.c | 6 +-
src/util/virthreadpool.c | 6 +-
src/util/virtypedparam-public.c | 2 +-
src/util/virtypedparam.c | 8 +--
src/util/viruri.c | 20 +++---
src/util/virusb.c | 8 +--
src/util/virxml.c | 4 +-
src/vbox/vbox_snapshot_conf.c | 54 ++++++++--------
src/vmx/vmx.c | 6 +-
src/vz/vz_driver.c | 8 +--
src/vz/vz_utils.c | 2 +-
tests/nodedevmdevctltest.c | 4 +-
tests/nwfilterxml2firewalltest.c | 2 +-
tests/qemuhotplugtest.c | 12 ++--
tests/qemumonitortestutils.c | 28 ++++-----
tests/virnetdaemontest.c | 2 +-
tests/virnetserverclienttest.c | 2 +-
tools/virsh-checkpoint.c | 6 +-
tools/virsh-domain-monitor.c | 4 +-
tools/virsh-domain.c | 2 +-
tools/virsh-interface.c | 4 +-
tools/virsh-network.c | 8 +--
tools/virsh-nodedev.c | 4 +-
tools/virsh-nwfilter.c | 8 +--
tools/virsh-pool.c | 4 +-
tools/virsh-secret.c | 4 +-
tools/virsh-snapshot.c | 6 +-
tools/virsh-volume.c | 4 +-
tools/vsh-table.c | 10 +--
tools/vsh.c | 6 +-
110 files changed, 541 insertions(+), 541 deletions(-)
--
2.29.2
3 years, 9 months
[PATCH] vircgroup: Don't leak @parent in virCgroupEnableMissingControllers()
by Michal Privoznik
A memory leak was identified in
virCgroupEnableMissingControllers():
==11680== at 0x483EAE5: calloc (vg_replace_malloc.c:760)
==11680== by 0x4E51780: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.6701.0)
==11680== by 0x4908618: virCgroupNew (vircgroup.c:701)
==11680== by 0x49096F4: virCgroupEnableMissingControllers (vircgroup.c:1146)
==11680== by 0x4909B17: virCgroupNewMachineSystemd (vircgroup.c:1228)
==11680== by 0x4909E94: virCgroupNewMachine (vircgroup.c:1313)
==11680== by 0x1694FDBC: qemuInitCgroup (qemu_cgroup.c:946)
==11680== by 0x1695046B: qemuSetupCgroup (qemu_cgroup.c:1083)
==11680== by 0x16A60126: qemuProcessLaunch (qemu_process.c:7077)
==11680== by 0x16A61504: qemuProcessStart (qemu_process.c:7384)
==11680== by 0x169B84C2: qemuDomainObjStart (qemu_driver.c:6590)
==11680== by 0x169B8776: qemuDomainCreateWithFlags (qemu_driver.c:6641)
What happens is that new virCgroup is created and stored into
@parent. Then, if @tokens is not empty the for() loop is entered
into where another virCgroup is created and @parent is replaced
with this new virCgroup. But nothing freed the old @parent.
Fixes: 77291414c7a8745cf4d2b06d3c38d269cfbcfe32
Reported-by: Andrea Bolognani <abologna(a)redhat.com>
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/util/vircgroup.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 15071d8b1b..9fb1b45a8f 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -1159,6 +1159,7 @@ virCgroupEnableMissingControllers(char *path,
if (virCgroupMakeGroup(parent, tmp, true, VIR_CGROUP_SYSTEMD) < 0)
return -1;
+ virCgroupFree(parent);
parent = g_steal_pointer(&tmp);
}
--
2.26.2
3 years, 9 months
[libvirt PATCH v2 0/6] implement vhost-user-blk support
by Pavel Hrdina
Pavel Hrdina (6):
qemu_alias: introduce qemuDomainGetVhostUserAlias helper
qemu_validate: move and refactor
qemuValidateDomainDefVirtioFSSharedMemory
docs: introduces new vhostuser disk type
conf: implement support for vhostuser disk
qemu_capabilities: introduce vhost-user-blk capability
qemu: implement vhost-user-blk support
docs/formatdomain.rst | 37 +++-
docs/schemas/domaincommon.rng | 19 ++
src/conf/domain_conf.c | 87 ++++++++
src/conf/domain_validate.c | 188 ++++++++++++++++++
src/conf/storage_source_conf.c | 3 +
src/conf/storage_source_conf.h | 4 +
src/libxl/xen_xl.c | 1 +
src/qemu/qemu_alias.c | 6 +
src/qemu/qemu_alias.h | 2 +
src/qemu/qemu_block.c | 48 +++++
src/qemu/qemu_block.h | 7 +
src/qemu/qemu_capabilities.c | 4 +
src/qemu/qemu_capabilities.h | 3 +
src/qemu/qemu_command.c | 100 +++++++++-
src/qemu/qemu_command.h | 8 +
src/qemu/qemu_domain.c | 12 ++
src/qemu/qemu_driver.c | 72 +++++++
src/qemu/qemu_hotplug.c | 14 +-
src/qemu/qemu_migration.c | 2 +
src/qemu/qemu_snapshot.c | 4 +
src/qemu/qemu_validate.c | 124 +++++++-----
src/storage_file/storage_source.c | 1 +
.../caps_2.12.0.aarch64.xml | 1 +
.../caps_2.12.0.ppc64.xml | 1 +
.../caps_2.12.0.s390x.xml | 1 +
.../caps_2.12.0.x86_64.xml | 1 +
.../qemucapabilitiesdata/caps_3.0.0.ppc64.xml | 1 +
.../caps_3.0.0.riscv32.xml | 1 +
.../caps_3.0.0.riscv64.xml | 1 +
.../qemucapabilitiesdata/caps_3.0.0.s390x.xml | 1 +
.../caps_3.0.0.x86_64.xml | 1 +
.../qemucapabilitiesdata/caps_3.1.0.ppc64.xml | 1 +
.../caps_3.1.0.x86_64.xml | 1 +
.../caps_4.0.0.aarch64.xml | 1 +
.../qemucapabilitiesdata/caps_4.0.0.ppc64.xml | 1 +
.../caps_4.0.0.riscv32.xml | 1 +
.../caps_4.0.0.riscv64.xml | 1 +
.../qemucapabilitiesdata/caps_4.0.0.s390x.xml | 1 +
.../caps_4.0.0.x86_64.xml | 1 +
.../caps_4.1.0.x86_64.xml | 1 +
.../caps_4.2.0.aarch64.xml | 1 +
.../qemucapabilitiesdata/caps_4.2.0.ppc64.xml | 1 +
.../qemucapabilitiesdata/caps_4.2.0.s390x.xml | 1 +
.../caps_4.2.0.x86_64.xml | 1 +
.../caps_5.0.0.aarch64.xml | 1 +
.../qemucapabilitiesdata/caps_5.0.0.ppc64.xml | 1 +
.../caps_5.0.0.riscv64.xml | 1 +
.../caps_5.0.0.x86_64.xml | 1 +
.../caps_5.1.0.x86_64.xml | 1 +
.../caps_5.2.0.aarch64.xml | 1 +
.../qemucapabilitiesdata/caps_5.2.0.ppc64.xml | 1 +
.../caps_5.2.0.riscv64.xml | 1 +
.../qemucapabilitiesdata/caps_5.2.0.s390x.xml | 1 +
.../caps_5.2.0.x86_64.xml | 1 +
.../caps_6.0.0.x86_64.xml | 1 +
.../disk-vhostuser.x86_64-latest.args | 41 ++++
tests/qemuxml2argvdata/disk-vhostuser.xml | 30 +++
tests/qemuxml2argvtest.c | 1 +
.../disk-vhostuser.x86_64-latest.xml | 48 +++++
tests/qemuxml2xmltest.c | 1 +
60 files changed, 836 insertions(+), 64 deletions(-)
create mode 100644 tests/qemuxml2argvdata/disk-vhostuser.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/disk-vhostuser.xml
create mode 100644 tests/qemuxml2xmloutdata/disk-vhostuser.x86_64-latest.xml
--
2.29.2
3 years, 9 months
[libvirt PATCH 00/16] expose tainting and deprecations in public API
by Daniel P. Berrangé
Libvirt has a notion of "tainting" which we use to mark a guest which
has some undesirable configuration or behaviour from libvirt's POV.
This ends up in the libvirtd logs and in the per-VM log file, but is
not exposed to management applications directly.
QMP has the ability to report whether a CPU or machine type is
deprecated.
QEMU itself prints warnings to stderr which end up in the per VM log:
2021-01-22T12:22:53.566239Z qemu-system-x86_64: Machine type 'pc-1.3' is depr=
ecated: use a newer machine type instead
2021-01-22T12:22:53.566613Z qemu-system-x86_64: warning: CPU model Icelake-Cl=
ient-x86_64-cpu is deprecated -- use Icelake-Server instead
We can use the deprecation info from QMP to add tainting to the
domain too. This will appear in the pre-VM log file again:
2021-01-22 12:22:53.492+0000: Domain id=3D2 is tainted: deprecated-configurat=
ion (machine type 'pc-1.3')
2021-01-22 12:22:53.492+0000: Domain id=3D2 is tainted: deprecated-configurat=
ion (CPU model 'Icelake-Client')
and more usefully in the libvirtd log
2021-01-22 13:18:09.619+0000: 3299849: warning :
qemuDomainObjTaintMsg:6208 :
Domain id=3D3 name=3D'demo' uuid=3Deadf8ef0-bf14-4c5f-9708-4a19bacf9e81
is tainted: deprecated-configuration (machine type 'pc-1.3')
2021-01-22 13:18:09.619+0000: 3299849: warning :
qemuDomainObjTaintMsg:6208 :
Domain id=3D3 name=3D'demo' uuid=3Deadf8ef0-bf14-4c5f-9708-4a19bacf9e81
is tainted: deprecated-configuration (CPU model 'Icelake-Client')
This series goes further and also exposes the deprecation info in the
capabilities (machine types) or domain capabilities (CPU) XML. This
lets mgmt apps avoid using the feature upfront if desired.
Finally both deprecation messages and tainting flags are exposed in
new public APIs, and wired into virsh
$ virsh dominfo demo
Id: 3
Name: demo
UUID: eadf8ef0-bf14-4c5f-9708-4a19bacf9e81
OS Type: hvm
State: running
CPU(s): 2
CPU time: 1.3s
Max memory: 1536000 KiB
Used memory: 1536000 KiB
Persistent: yes
Autostart: disable
Managed save: no
Security model: selinux
Security DOI: 0
Security label: unconfined_u:unconfined_r:svirt_t:s0:c578,c807 (permissive)
Tainting: custom-monitor
deprecated-config
Deprecations: CPU model 'Icelake-Client'
machine type 'pc-1.3'
The deprecations API is simple, just returning a list of free form
opaque strings, which are eeffectively warning messages.
I'm not entirely convinced by tainting API though. I didn't especially
want to expose the virDomainTaintFlags enum in the public API since it
feels like the enum flags are (almost) all QEMU driver specific. I thus
took the approach of having an API return opaque strings which are
declared to be hypervisor specific.
I'm worried though that mgmt apps will none the less simply match on
the strings to detect things, at which point we might as well just use
an enum after all.
So perhaps it should just be turned into
virDomainGetTainting(virDomainPtr obj,
int **codes,
unsigned int flags);
enum virDomainTaintCodes {
....
}
Daniel P. Berrang=C3=A9 (16):
qemu: report whether a CPU model is deprecated in dom capabilities
qemu: report whether a machine type is deprecated in capabilities
conf: introduce new taint flag for deprecated configuration
qemu: add ability to associate a string message with taint warning
qemu: taint the VM if it is using a deprecated CPU model
qemu: taint the VM if it is using a deprecated machine type
conf: record deprecation messages against the domain
qemu: record deprecation messages against the domain
src: define virDomainGetDeprecations API
remote: add RPC support for the virDomainGetDeprecations API
qemu: implement virDomainGetDeprecations API
tools: report deprecations for 'dominfo' command
src: define virDomainGetTainting API
remote: add RPC support for the virDomainGetTainting API
qemu: implement virDomainGetTainting API
tools: report tainting for 'dominfo' command
docs/formatdomaincaps.html.in | 10 +-
docs/schemas/capability.rng | 8 ++
docs/schemas/domaincaps.rng | 8 ++
include/libvirt/libvirt-domain.h | 7 ++
src/conf/capabilities.c | 2 +
src/conf/capabilities.h | 1 +
src/conf/domain_capabilities.c | 14 ++-
src/conf/domain_capabilities.h | 4 +-
src/conf/domain_conf.c | 29 ++++-
src/conf/domain_conf.h | 5 +
src/driver-hypervisor.h | 11 ++
src/libvirt-domain.c | 95 +++++++++++++++
src/libvirt_private.syms | 1 +
src/libvirt_public.syms | 6 +
src/qemu/qemu_capabilities.c | 60 +++++++++-
src/qemu/qemu_capabilities.h | 6 +
src/qemu/qemu_capspriv.h | 3 +-
src/qemu/qemu_domain.c | 111 ++++++++++++++++--
src/qemu/qemu_domain.h | 7 ++
src/qemu/qemu_driver.c | 66 +++++++++++
src/qemu/qemu_monitor.c | 1 +
src/qemu/qemu_monitor.h | 2 +
src/qemu/qemu_monitor_json.c | 8 ++
src/qemu/qemu_process.c | 5 +
src/remote/remote_daemon_dispatch.c | 91 ++++++++++++++
src/remote/remote_driver.c | 88 ++++++++++++++
src/remote/remote_protocol.x | 39 +++++-
tests/cputest.c | 4 +-
.../domaincapsdata/qemu_5.2.0-q35.x86_64.xml | 4 +-
.../domaincapsdata/qemu_5.2.0-tcg.x86_64.xml | 4 +-
tests/domaincapsdata/qemu_5.2.0.x86_64.xml | 4 +-
.../caps_4.1.0.x86_64.xml | 16 +--
.../qemucapabilitiesdata/caps_4.2.0.ppc64.xml | 4 +-
.../caps_4.2.0.x86_64.xml | 16 +--
.../caps_5.0.0.x86_64.xml | 16 +--
.../caps_5.1.0.x86_64.xml | 16 +--
.../caps_5.2.0.x86_64.xml | 32 ++---
tests/testutilsqemu.c | 8 +-
tools/virsh-domain-monitor.c | 25 ++++
39 files changed, 745 insertions(+), 92 deletions(-)
--=20
2.29.2
3 years, 9 months