[PATCH v6 0/5] migration/dirtyrate: Introduce APIs for getting domain memory dirty rate
by Hao Wang
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=measured
dirtyrate.calc_start_time=502814
dirtyrate.calc_period=1
dirtyrate.megabytes_per_second=2
Hao Wang (5):
migration/dirtyrate: Introduce virDomainStartDirtyRateCalc API
migration/dirtyrate: Implement qemuDomainStartDirtyRateCalc
migration/dirtyrate: Introduce domdirtyrate-calc virsh api
migration/dirtyrate: Implement qemuMonitorQueryDirtyRate
migration/dirtyrate: Introduce command 'virsh domstats --dirtyrate'
docs/manpages/virsh.rst | 33 ++++++++-
include/libvirt/libvirt-domain.h | 5 ++
src/driver-hypervisor.h | 6 ++
src/libvirt-domain.c | 57 +++++++++++++++
src/libvirt_public.syms | 5 ++
src/qemu/qemu_driver.c | 115 +++++++++++++++++++++++++++++++
src/qemu/qemu_monitor.c | 24 +++++++
src/qemu/qemu_monitor.h | 18 +++++
src/qemu/qemu_monitor_json.c | 88 +++++++++++++++++++++++
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 | 63 +++++++++++++++++
15 files changed, 447 insertions(+), 3 deletions(-)
--
2.23.0
3 years, 9 months
[PATCH 00/33] Remove the now misleading virReportOOMError infra
by Peter Krempa
'virReportOOMError' is nowadays mostly useless since an OOM error will
trigger yet another allocation failure in the logger when attempting to
log the error.
Additionally it was also used in few places which can fail with other
failures than OOM.
To prevent both errorneous usage types, let's remove it completely. In
the rare case we'd want to allocate a massive buffer and want to fail
gracefully we still can use virReportError with VIR_ERR_NO_MEMORY.
The series starts by some cleanup, then removes error handling from
places where it's now dead code as we'll abort before the reporting,
then converts some real OOM scenarios to abort() directly and lastly
fixes the error message for cases where other errors are possible and
lastly removes virReportOOMError.
Pipelines are stuck, so hopefully it will go through:
https://gitlab.com/pipo.sk/libvirt/-/pipelines/261161989
Peter Krempa (33):
Remove useless comments for VIR_FROM_THIS definition
util: xml: Introduce autoptr cleanup support for 'xmlNode'
virDomainDefSetMetadata: Avoid temporary variable for string copy
virCommandAddEnv: Make stealing of argument more obvious
virCommandAddArgBuffer: Simplify clearing of @buf
virCPUx86DataParse: Don't check error from x86FeatureNames
virhostcputest: linuxCPUStatsCompareFiles: Don't check return value of
virBufferContentAndReset
virBuildPath: Remove return value
lxc_process: Remove OOM handling from logging setup
virDomainDefSetMetadata: Rework memory handling
util: vircommand: Remove OOM handling
virCloseCallbacksGetForConn: Remove OOM handling
virfirewall: Don't check OOM in ADD_ARG macro
virfirewall: Remove OOM checks from virFirewallStartTransaction
virfirewall: virFirewallAddRuleFullV: Remove OOM check from
VIR_APPEND_ELEMENT
virfirewall: Remove impossible OOM error reporting
util: virnetlink: Add wrapper for 'nlmsg_alloc_simple'
util: xml: Add virXMLBufferCreate wrapper
util: xml: Add wrapper for 'xmlNewNode'
Don't report OOM error on xmlCopyNode failure
virXMLXPathContextNew: abort() on allocation failure
virXMLParseHelper: abort() on allocation failure
util: virprocess: abort() on CPU_ALLOC failure
virURIFormat: abort() on failure
util: iohelper: Don't handle OOM from posix_memalign
hyperv: abort() failure of wsmc_fault_new()
vbox: abort() on allocation failure in UTF8<->UTF16 conversion
libxl: abort() on failure of libxl_cpu_bitmap_alloc()
virVBoxSnapshotConfSaveVboxFile: abort() on failure to allocate xmlDoc
and comment
util: json: Report non-OOM error on yajl failure
storage: Don't report OOM error on failure of glfs_new
virVMXConvertToUTF8: Report non-OOM error on failure of
xmlBufferCreateStatic
util: virerror: Remove virReportOOMError
build-aux/syntax-check.mk | 8 --
docs/internals/command.html.in | 8 +-
src/conf/domain_conf.c | 62 ++++-----
src/conf/network_conf.c | 5 +-
src/cpu/cpu_x86.c | 6 +-
src/hyperv/hyperv_wmi.c | 8 +-
src/hypervisor/virclosecallbacks.c | 15 +--
src/libvirt_private.syms | 3 +-
src/libxl/libxl_conf.c | 6 +-
src/libxl/libxl_driver.c | 7 +-
src/lxc/lxc_process.c | 9 +-
src/storage/storage_backend_gluster.c | 3 +-
.../storage_file_backend_gluster.c | 3 +-
src/test/test_driver.c | 6 +-
src/util/iohelper.c | 7 +-
src/util/vircommand.c | 119 +++++-------------
src/util/virerror.c | 22 ----
src/util/virerror.h | 8 --
src/util/virfcp.c | 3 +-
src/util/virfile.c | 7 +-
src/util/virfile.h | 2 +-
src/util/virfirewall.c | 62 ++-------
src/util/virhook.c | 14 +--
src/util/virjson.c | 6 +-
src/util/virnetdev.c | 18 +--
src/util/virnetdevbridge.c | 10 +-
src/util/virnetdevip.c | 15 +--
src/util/virnetdevvportprofile.c | 6 +-
src/util/virnetlink.c | 38 +++---
src/util/virnetlink.h | 4 +
src/util/virpci.c | 12 +-
src/util/virprocess.c | 12 +-
src/util/virscsi.c | 1 -
src/util/virscsivhost.c | 1 -
src/util/viruri.c | 8 +-
src/util/virxml.c | 44 ++++---
src/util/virxml.h | 8 ++
src/vbox/vbox_common.c | 20 ---
src/vbox/vbox_common.h | 15 ++-
src/vbox/vbox_snapshot_conf.c | 46 ++-----
src/vmx/vmx.c | 9 +-
tests/virhostcputest.c | 5 +-
tools/virsh-domain.c | 5 +-
43 files changed, 214 insertions(+), 462 deletions(-)
--
2.29.2
3 years, 9 months
[PATCH 0/4] use g_autofree and g_autoptr
by Kristina Hanicova
This uses g_autofree (if possible) in files: vsh-table,
netdev_bandwidth_conf and g_autoptr instead of
virNetDevBandwidthFree where possible.
Kristina Hanicova (4):
vsh-table: Use g_autofree where possible
netdev_bandwidth_conf: Use g_autofree where possible
Use g_autoptr instead of virNetDevBandwidthFree where possible
netdev_bandwidth_conf: Remove redundant variables/labels
src/conf/netdev_bandwidth_conf.c | 67 ++++++++++++--------------------
src/network/bridge_driver.c | 6 +--
src/qemu/qemu_driver.c | 11 ++----
src/test/test_driver.c | 3 +-
src/util/virnetdevbandwidth.h | 2 +
tests/virnetdevbandwidthtest.c | 3 +-
tools/vsh-table.c | 16 +++-----
7 files changed, 40 insertions(+), 68 deletions(-)
--
2.29.2
3 years, 9 months
Some confusion about lsilogic controller
by xingchaochao
Hello,
I have been confused by such a phenomenon recently.
Libvirt is the master branch , and the VM is centos8.2(kernel is 4.18.0-193.el8.aarch64).
When I hot-plug the scsi disk for a virtual machine without a virtio-scsi controller, libvirt will automatically generate an lsilogic controller for the scsi disk.
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='none' io='native'/>
<source file='/Images/xcc/tmp.img'/>
<backingStore/>
<target dev='sdt' bus='scsi'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
linux-upcHIq:/Images/xcc # virsh list
Id Name State
----------------------
12 g1 running
linux-upcHIq:/Images/xcc # virsh attach-device g1 disk.xml
Device attached successfully
linux-upcHIq:/Images/xcc # virsh dumpxml g1 | grep scsi
<target dev='sdt' bus='scsi'/>
<alias name='scsi0-0-0'/>
<controller type='scsi' index='0' model='lsilogic'>
<alias name='scsi0'/>
But this scsi disk cannot be found through the lsblk command inside the virtual machine.
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 252:0 0 20G 0 disk
├─vda1 252:1 0 600M 0 part /boot/efi
├─vda2 252:2 0 1G 0 part /boot
└─vda3 252:3 0 18.4G 0 part
├─cl-root 253:0 0 16.4G 0 lvm /
└─cl-swap 253:1 0 2G 0 lvm [SWAP]
After hot unplugging the scsi disk, I performed the hot unplug operation of the lsilogic controller. libvirt shows "Device detached successfully", but in fact, the lsilogic controller is not removed from the live XML and persistent XML. Through "virsh dumpxml vmname" and "virsh edit vmname", I can see <controller type='scsi' index='0' model='lsilogic'> is always there.
linux-upcHIq:/Images/xcc # virsh detach-device g1 disk.xml
Device detached successfully
linux-upcHIq:/Images/xcc # virsh dumpxml g1 | grep scsi
<controller type='scsi' index='0' model='lsilogic'>
<alias name='scsi0'/>
linux-upcHIq:/Images/xcc #
linux-upcHIq:/Images/xcc # cat lsi.xml
<controller type='scsi' index='0' model='lsilogic'>
<alias name='scsi0'/>
<address type='pci' domain='0x0000' bus='0x03' slot='0x05' function='0x0'/>
</controller>
linux-upcHIq:/Images/xcc # virsh detach-device g1 lsi.xml
Device detached successfully
linux-upcHIq:/Images/xcc # virsh dumpxml g1 | grep scsi
<controller type='scsi' index='0' model='lsilogic'>
<alias name='scsi0'/>
I am confused, why libvirt chooses to generate an lsilogic controller for the scsi disk when there is no scsi controller, instead of directly reporting an error and exiting the hot plug operation. After all, the scsi disk based on the lsilogic controller is not perceived inside the virtual machine, and lsilogic will remain in the XML file of the virtual machine.
3 years, 9 months
[PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add
by Kevin Wolf
This series adds a QAPI type for the properties of all user creatable
QOM types and finally makes the --object command line option (in all
binaries) and the object-add monitor commands (in QMP and HMP) use the
new ObjectOptions union.
This change improves things in more than just one way:
1. Documentation for QOM object types has always been lacking. Adding
the schema, we get documentation for every property.
2. It prevents bugs by performing parts of the input validation (e.g.
checking presence of mandatory properties) already in QAPI instead of
relying on separate manual implementations in each class.
3. It provides QAPI introspection for user creatable objects.
4. Non-scalar properties are now supported everywhere because the
command line parsers (including HMP) use the keyval parser now.
If you are in the CC list and didn't expect this series, it's probably
because you're the maintainer of one of the objects for which I'm adding
a QAPI schema description. Please just have a look at the specific patch
for your object and check whether the schema and its documentation make
sense to you. You can ignore all other patches.
In a next step after this series, we can add make use of the QAPI
structs in the implementation of the object and separate their
configuration from the runtime state. Specifically, the plan is to
add a .configure() callback to ObjectClass that allows configuring the
object in one place at creation time and keeping QOM property setters
only for properties that can actually be changed at runtime. Paolo made
an example of what the state could look like after this:
https://wiki.qemu.org/Features/QOM-QAPI_integration
Finally, the intention is to extend the QAPI schema to have separate
'object' entities and generate some of the code that was written
manually in the intermediate state before.
This series is available as a git tag at:
https://repo.or.cz/qemu/kevin.git qapi-object-v2
v2:
- Convert not only object-add, but all external interfaces so that the
schema will always be enforced and mismatch between implementation and
schema can't go unnoticed.
- Rebased, covering properties and object types added since v1 (yes,
things do become outdated rather quickly when you touch all user
creatable objects)
- Changed the "Since:" version number in the schema documentation to
refer to the version when the object was introduced rather than 6.0
where the schema will (hopefully) be added
- Probably some other minor changes
Kevin Wolf (31):
tests: Drop 'props' from object-add calls
qapi/qom: Drop deprecated 'props' from object-add
qapi/qom: Add ObjectOptions for iothread
qapi/qom: Add ObjectOptions for authz-*
qapi/qom: Add ObjectOptions for cryptodev-*
qapi/qom: Add ObjectOptions for dbus-vmstate
qapi/qom: Add ObjectOptions for memory-backend-*
qapi/qom: Add ObjectOptions for rng-*, deprecate 'opened'
qapi/qom: Add ObjectOptions for throttle-group
qapi/qom: Add ObjectOptions for secret*, deprecate 'loaded'
qapi/qom: Add ObjectOptions for tls-*, deprecate 'loaded'
qapi/qom: Add ObjectOptions for can-*
qapi/qom: Add ObjectOptions for colo-compare
qapi/qom: Add ObjectOptions for filter-*
qapi/qom: Add ObjectOptions for pr-manager-helper
qapi/qom: Add ObjectOptions for confidential-guest-support
qapi/qom: Add ObjectOptions for input-*
qapi/qom: Add ObjectOptions for x-remote-object
qapi/qom: QAPIfy object-add
qom: Make "object" QemuOptsList optional
qemu-storage-daemon: Implement --object with qmp_object_add()
qom: Remove user_creatable_add_dict()
qom: Factor out user_creatable_process_cmdline()
qemu-io: Use user_creatable_process_cmdline() for --object
qemu-img: Use user_creatable_process_cmdline() for --object
qemu-nbd: Use user_creatable_process_cmdline() for --object
qom: Add user_creatable_add_from_str()
hmp: QAPIfy object_add
qom: Add user_creatable_parse_str()
vl: QAPIfy -object
qom: Drop QemuOpts based interfaces
qapi/authz.json | 62 +++
qapi/block-core.json | 27 ++
qapi/common.json | 52 +++
qapi/crypto.json | 159 +++++++
qapi/machine.json | 22 +-
qapi/net.json | 20 -
qapi/qom.json | 639 ++++++++++++++++++++++++++-
qapi/ui.json | 13 +-
docs/system/deprecated.rst | 25 +-
docs/system/removed-features.rst | 5 +
include/qom/object_interfaces.h | 106 ++---
hw/block/xen-block.c | 16 +-
monitor/hmp-cmds.c | 17 +-
monitor/misc.c | 2 -
qemu-img.c | 239 ++--------
qemu-io.c | 33 +-
qemu-nbd.c | 34 +-
qom/object_interfaces.c | 168 +++----
qom/qom-qmp-cmds.c | 28 +-
softmmu/vl.c | 109 +++--
storage-daemon/qemu-storage-daemon.c | 25 +-
tests/check-qom-proplist.c | 42 +-
tests/qtest/qmp-cmd-test.c | 16 +-
tests/qtest/test-netfilter.c | 54 +--
hmp-commands.hx | 2 +-
storage-daemon/qapi/qapi-schema.json | 1 +
tests/qemu-iotests/087 | 8 +-
tests/qemu-iotests/184 | 18 +-
tests/qemu-iotests/218 | 2 +-
tests/qemu-iotests/235 | 2 +-
tests/qemu-iotests/245 | 4 +-
tests/qemu-iotests/258 | 6 +-
tests/qemu-iotests/258.out | 4 +-
tests/qemu-iotests/295 | 2 +-
tests/qemu-iotests/296 | 2 +-
35 files changed, 1270 insertions(+), 694 deletions(-)
--
2.29.2
3 years, 9 months
[PATCH v2 0/3] Use g_autoptr and g_autofree
by Kristina Hanicova
This is v2 from
https://listman.redhat.com/archives/libvir-list/2021-February/msg01129.html
I changed variable names in patch 1/3 as suggested by Laine. Patches 2/3
and 3/3 have already been reviewed-by and I am sending them for
completeness.
This uses g_autofree (if possible) in file networkcommon_conf and
g_autoptr instead of virNetDevIPRouteFree where possible.
Kristina Hanicova (3):
networkcommon_conf: Use g_autofree where possible
Use g_autoptr instead of virNetDevIPRouteFree if possible
Remove redundant variables/labels
src/conf/domain_conf.c | 3 +-
src/conf/networkcommon_conf.c | 90 +++++++++++++++--------------------
src/lxc/lxc_native.c | 10 ++--
src/vz/vz_sdk.c | 3 +-
4 files changed, 44 insertions(+), 62 deletions(-)
--
2.29.2
3 years, 9 months
[libvirt PATCH 0/5] cpu_map: Sync with Qemu
by Tim Wiederhake
Qemu updated its list of known cpu features. Follow suit.
Tim Wiederhake (5):
cpu_map/sync_qemu_i386.py: Add mapping for amd-ssbd
cpu_map/sync_qemu_i386.py: Add mapping for ibrs
cpu_map/sync_qemu_i386.py: Add mapping for svme-addr-check
cpumap: Add support for ibrs CPU feature
cpumap: Add support for svme-addr-check CPU feature
src/cpu_map/sync_qemu_i386.py | 3 +++
src/cpu_map/x86_features.xml | 6 ++++++
tests/cputestdata/x86_64-cpuid-EPYC-7502-32-Core-guest.xml | 1 +
tests/cputestdata/x86_64-cpuid-EPYC-7502-32-Core-host.xml | 1 +
4 files changed, 11 insertions(+)
--
2.26.2
3 years, 9 months
[libvirt PATCH v4 00/25] Add support for persistent mediated devices
by Jonathon Jongsma
This patch series follows the previously-merged series which added support for
transient mediated devices. This series expands mdev support to include
persistent device definitions. Again, it relies on mdevctl as the backend.
It follows the common libvirt pattern of APIs by adding the following new APIs
for node devices:
- virNodeDeviceDefineXML() - defines a persistent device
- virNodeDeviceUndefine() - undefines a persistent device
- virNodeDeviceCreate() - starts a previously-defined device
It also adds virsh commands mapping to these new APIs: nodedev-define,
nodedev-undefine, and nodedev-start.
Since we rely on mdevctl for the definition of mediated devices, we need a way
to stay up-to-date with devices that are defined by mdevctl (outside of
libvirt). The method for staying up-to-date is currently a little bit crude
due to the fact that mdevctl does not emit any events when new devices are
added or removed. As a workaround, we create a file monitor for the mdevctl
config directory and re-query mdevctl when we detect changes within that
directory. In the future, mdevctl may introduce a more elegant solution.
Changes in v4:
- rebase to git master
- switch to throwaway thread for querying mdevctl
- fixed a bug when removing devices because I was accidentally using
virHashForEach() instead of virHashForeachSafe()
- use DEFINED/UNDEFINED events instead of STARTED/STOPPED events
- changes related to merging information about mdev devices from both udev a=
nd
mdevctl:
- Re-used the same function to copy extra data from mdevctl regardless of
whether we're processing a udev event or a mdevctl event (recommended by
Erik). This results in slightly more complex handling of the object
lifetimes (see patch 9), but it consolidates some code.
- nodeDeviceDefCopyFromMdevctl() previously only copied the data that was
unique to mdevctl and didn't exist in udev. It now copies additional data
(possibly overwriting some udev). This solves a problem where a device =
is
defined but not active (i.e. we have not gotten any data from udev), and
then changed (e.g. somebody calls 'mdevctl modify' to change the mdev
type), but libvirt was not updating to the new definition.
- fix a bug where we were mistakenly emitting 'update' events for devices th=
at
had not changed
- Added the ability to specify a uuid for an mdev via device XML.
- split some commits into multiple patches
- updated new API version info to 7.1.0
- Fixed a bug reported by Yan Fu which hangs the client when attempting to
destroy a nodedev that is in use by an active vm. See
https://www.redhat.com/archives/libvir-list/2021-February/msg00116.html for
solution suggested by Alex.
- numerous smaller fixes from review findings
changes in v3:
- streamlined tests -- removed some unnecessary duplication
- split out patch to factor out node device name generation function
- split nodeDeviceParseMdevctlChildDevice() into a separate function
- added follow-up patch to remove space-padded alignment in header
- refactored the mdevctl update handling significantly:
- no longer a separate persistent thread that gets signaled by a timer
- now piggybacks onto the existing udev thread and signals the thread in t=
he
same way that the udev event does.
- Daniel suggested spawning a throw-away thread to handle mdevctl updates,
but that introduces the complexity of possibly serializing multiple
throw-away threads (e.g. if we get an 'created' event followed immediate=
ly
by a 'deleted' event, two threads may be spawned and we'd need to ensure
they are properly ordered)
- added virNodeDeviceObjListForEach() and virNodeDeviceObjListRemoveLocked()
to simplify removing devices that are removed from mdevctl.
- coding style fixes
- NOTE: per Erik's request, I experimented with changing the way that mdevctl
commands were generated and tested (e.g. introducing something like
virMdevctlGetCommand(def, MDEVCTL_COMMAND_<SUBCOMMAND>, ...)), but it was
too invasive and awkward and didn't seem worthwhile
Changes in v2:
- rebase to latest git master
Jonathon Jongsma (25):
tests: remove extra trailing semicolon
nodedev: introduce concept of 'active' node devices
nodedev: Add ability to filter by active state
nodedev: expose internal helper for naming devices
nodedev: add ability to parse mdevs from mdevctl
nodedev: add ability to list defined mdevs
nodedev: add persistence to virNodeDeviceObj
nodedev: add DEFINED/UNDEFINED lifecycle events
nodedev: add mdevctl devices to node device list
nodedev: add helper functions to remove node devices
nodedev: handle mdevs that disappear from mdevctl
nodedev: Refresh mdev devices when changes are detected
nodedev: add function to generate mdevctl define command
api: add virNodeDeviceDefineXML()
virsh: Add --inactive, --all to nodedev-list
virsh: add nodedev-define command
nodedev: refactor tests to support mdev undefine
api: add virNodeDeviceUndefine()
virsh: Factor out function to find node device
virsh: add nodedev-undefine command
api: add virNodeDeviceCreate()
virsh: add "nodedev-start" command
nodedev: add <uuid> element to mdev caps
nodedev: add ability to specify UUID for new mdevs
nodedev: fix hang when destroying an mdev in use
docs/schemas/nodedev.rng | 43 +-
examples/c/misc/event-test.c | 4 +
include/libvirt/libvirt-nodedev.h | 19 +-
src/access/viraccessperm.c | 2 +-
src/access/viraccessperm.h | 6 +
src/conf/node_device_conf.c | 15 +
src/conf/node_device_conf.h | 8 +
src/conf/virnodedeviceobj.c | 149 +++-
src/conf/virnodedeviceobj.h | 25 +
src/driver-nodedev.h | 14 +
src/libvirt-nodedev.c | 115 +++
src/libvirt_private.syms | 6 +
src/libvirt_public.syms | 7 +
src/node_device/node_device_driver.c | 657 +++++++++++++++++-
src/node_device/node_device_driver.h | 41 ++
src/node_device/node_device_udev.c | 214 +++++-
src/remote/remote_driver.c | 3 +
src/remote/remote_protocol.x | 40 +-
src/remote_protocol-structs | 16 +
src/rpc/gendispatch.pl | 1 +
...19_36ea_4111_8f0a_8c9a70e21366-define.argv | 2 +
...19_36ea_4111_8f0a_8c9a70e21366-define.json | 1 +
...019_36ea_4111_8f0a_8c9a70e21366-start.argv | 3 +-
...39_495e_4243_ad9f_beb3f14c23d9-define.argv | 1 +
...39_495e_4243_ad9f_beb3f14c23d9-define.json | 1 +
...16_1ca8_49ac_b176_871d16c13076-define.argv | 1 +
...16_1ca8_49ac_b176_871d16c13076-define.json | 1 +
tests/nodedevmdevctldata/mdevctl-create.argv | 1 +
.../mdevctl-list-defined.argv | 1 +
.../mdevctl-list-multiple.json | 59 ++
.../mdevctl-list-multiple.out.xml | 43 ++
.../nodedevmdevctldata/mdevctl-undefine.argv | 1 +
tests/nodedevmdevctltest.c | 222 +++++-
...v_d069d019_36ea_4111_8f0a_8c9a70e21366.xml | 1 +
tools/virsh-nodedev.c | 268 ++++++-
35 files changed, 1853 insertions(+), 138 deletions(-)
create mode 100644 tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9=
a70e21366-define.argv
create mode 100644 tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9=
a70e21366-define.json
create mode 100644 tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb=
3f14c23d9-define.argv
create mode 100644 tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb=
3f14c23d9-define.json
create mode 100644 tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871=
d16c13076-define.argv
create mode 100644 tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871=
d16c13076-define.json
create mode 100644 tests/nodedevmdevctldata/mdevctl-create.argv
create mode 100644 tests/nodedevmdevctldata/mdevctl-list-defined.argv
create mode 100644 tests/nodedevmdevctldata/mdevctl-list-multiple.json
create mode 100644 tests/nodedevmdevctldata/mdevctl-list-multiple.out.xml
create mode 100644 tests/nodedevmdevctldata/mdevctl-undefine.argv
--=20
2.26.2
3 years, 9 months
[PATCH] Use g_steal_pointer where possible
by Kristina Hanicova
Via coccinelle (not the hanbag!)
spatches used:
@ rule1 @
identifier a, b;
symbol NULL;
@@
- b = a;
... when != a
- a = NULL;
+ b = g_steal_pointer(&a);
@@
- *b = a;
... when != a
- a = NULL;
+ *b = g_steal_pointer(&a);
Signed-off-by: Kristina Hanicova <khanicov(a)redhat.com>
---
src/admin/admin_server.c | 6 ++----
src/conf/capabilities.c | 3 +--
src/conf/netdev_bandwidth_conf.c | 3 +--
src/conf/virdomainobjlist.c | 3 +--
src/conf/virnwfilterobj.c | 3 +--
src/interface/interface_backend_netcf.c | 3 +--
src/interface/interface_backend_udev.c | 3 +--
src/qemu/qemu_driver.c | 12 ++++-------
src/qemu/qemu_monitor_json.c | 27 +++++++++----------------
src/remote/remote_driver.c | 12 ++++-------
src/rpc/virnetserver.c | 3 +--
src/util/virfile.c | 9 +++------
src/util/virlog.c | 6 ++----
src/util/virmdev.c | 3 +--
src/util/virsysinfo.c | 21 +++++++------------
src/util/virtypedparam.c | 3 +--
src/vbox/vbox_common.c | 3 +--
src/vz/vz_driver.c | 3 +--
tests/commandhelper.c | 3 +--
tools/virsh-checkpoint.c | 3 +--
tools/virsh-domain.c | 3 +--
21 files changed, 45 insertions(+), 90 deletions(-)
diff --git a/src/admin/admin_server.c b/src/admin/admin_server.c
index ebc0cfb045..7d1a21a678 100644
--- a/src/admin/admin_server.c
+++ b/src/admin/admin_server.c
@@ -50,8 +50,7 @@ adminConnectListServers(virNetDaemonPtr dmn,
goto cleanup;
if (servers) {
- *servers = srvs;
- srvs = NULL;
+ *servers = g_steal_pointer(&srvs);
}
cleanup:
if (ret > 0)
@@ -179,8 +178,7 @@ adminServerListClients(virNetServerPtr srv,
return -1;
if (clients) {
- *clients = clts;
- clts = NULL;
+ *clients = g_steal_pointer(&clts);
}
virObjectListFreeCount(clts, ret);
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index 69d9bb0e38..f610975ae5 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -1501,9 +1501,8 @@ virCapabilitiesGetNUMASiblingInfo(int node,
if (VIR_REALLOC_N(tmp, tmp_size) < 0)
goto cleanup;
- *siblings = tmp;
*nsiblings = tmp_size;
- tmp = NULL;
+ *siblings = g_steal_pointer(&tmp);
tmp_size = 0;
ret = 0;
cleanup:
diff --git a/src/conf/netdev_bandwidth_conf.c b/src/conf/netdev_bandwidth_conf.c
index 4fb7aa4e3d..ff25641b2c 100644
--- a/src/conf/netdev_bandwidth_conf.c
+++ b/src/conf/netdev_bandwidth_conf.c
@@ -205,8 +205,7 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidth,
if (!def->in && !def->out)
VIR_FREE(def);
- *bandwidth = def;
- def = NULL;
+ *bandwidth = g_steal_pointer(&def);
ret = 0;
cleanup:
diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c
index 2521cd56c2..d37bbc94a6 100644
--- a/src/conf/virdomainobjlist.c
+++ b/src/conf/virdomainobjlist.c
@@ -1083,8 +1083,7 @@ virDomainObjListExport(virDomainObjListPtr domlist,
goto cleanup;
}
- *domains = doms;
- doms = NULL;
+ *domains = g_steal_pointer(&doms);
}
ret = nvms;
diff --git a/src/conf/virnwfilterobj.c b/src/conf/virnwfilterobj.c
index 3157522eb2..f4bf1b083d 100644
--- a/src/conf/virnwfilterobj.c
+++ b/src/conf/virnwfilterobj.c
@@ -464,8 +464,7 @@ virNWFilterObjListExport(virConnectPtr conn,
virNWFilterObjUnlock(obj);
}
- *filters = tmp_filters;
- tmp_filters = NULL;
+ *filters = g_steal_pointer(&tmp_filters);
ret = nfilters;
cleanup:
diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interface_backend_netcf.c
index e40a4cb108..f8613fea86 100644
--- a/src/interface/interface_backend_netcf.c
+++ b/src/interface/interface_backend_netcf.c
@@ -715,8 +715,7 @@ netcfConnectListAllInterfaces(virConnectPtr conn,
if (tmp_iface_objs) {
/* trim the array to the final size */
ignore_value(VIR_REALLOC_N(tmp_iface_objs, niface_objs + 1));
- *ifaces = tmp_iface_objs;
- tmp_iface_objs = NULL;
+ *ifaces = g_steal_pointer(&tmp_iface_objs);
}
ret = niface_objs;
diff --git a/src/interface/interface_backend_udev.c b/src/interface/interface_backend_udev.c
index 6a94a45044..ab95b2e3ff 100644
--- a/src/interface/interface_backend_udev.c
+++ b/src/interface/interface_backend_udev.c
@@ -394,8 +394,7 @@ udevConnectListAllInterfaces(virConnectPtr conn,
/* Trim the array to its final size */
if (ifaces) {
ignore_value(VIR_REALLOC_N(ifaces_list, count + 1));
- *ifaces = ifaces_list;
- ifaces_list = NULL;
+ *ifaces = g_steal_pointer(&ifaces_list);
}
return count;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b9bbdf8d48..d1a3659774 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5097,8 +5097,7 @@ qemuDomainGetIOThreadsConfig(virDomainDefPtr targetDef,
bitmap = NULL;
}
- *info = info_ret;
- info_ret = NULL;
+ *info = g_steal_pointer(&info_ret);
ret = targetDef->niothreadids;
cleanup:
@@ -9133,9 +9132,8 @@ qemuDomainGetPerfEvents(virDomainPtr dom,
goto endjob;
}
- *params = par;
*nparams = npar;
- par = NULL;
+ *params = g_steal_pointer(&par);
npar = 0;
ret = 0;
@@ -18729,8 +18727,7 @@ qemuConnectGetAllDomainStats(virConnectPtr conn,
virObjectUnlock(vm);
}
- *retStats = tmpstats;
- tmpstats = NULL;
+ *retStats = g_steal_pointer(&tmpstats);
ret = nstats;
@@ -19259,9 +19256,8 @@ qemuDomainGetGuestVcpusParams(virTypedParameterPtr *params,
#undef ADD_BITMAP
- *params = par;
*nparams = npar;
- par = NULL;
+ *params = g_steal_pointer(&par);
ret = 0;
cleanup:
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index f8c78d9093..819389f5f9 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -5820,8 +5820,7 @@ int qemuMonitorJSONGetMachines(qemuMonitorPtr mon,
}
ret = n;
- *machines = infolist;
- infolist = NULL;
+ *machines = g_steal_pointer(&infolist);
cleanup:
if (infolist) {
@@ -6268,8 +6267,7 @@ int qemuMonitorJSONGetCommands(qemuMonitorPtr mon,
}
ret = n;
- *commands = commandlist;
- commandlist = NULL;
+ *commands = g_steal_pointer(&commandlist);
cleanup:
@@ -6327,8 +6325,7 @@ int qemuMonitorJSONGetEvents(qemuMonitorPtr mon,
}
ret = n;
- *events = eventlist;
- eventlist = NULL;
+ *events = g_steal_pointer(&eventlist);
cleanup:
g_strfreev(eventlist);
@@ -6472,8 +6469,7 @@ int qemuMonitorJSONGetObjectTypes(qemuMonitorPtr mon,
}
ret = n;
- *types = typelist;
- typelist = NULL;
+ *types = g_steal_pointer(&typelist);
cleanup:
g_strfreev(typelist);
@@ -6542,8 +6538,7 @@ int qemuMonitorJSONGetObjectListPaths(qemuMonitorPtr mon,
}
ret = n;
- *paths = pathlist;
- pathlist = NULL;
+ *paths = g_steal_pointer(&pathlist);
cleanup:
if (pathlist) {
@@ -6779,8 +6774,7 @@ qemuMonitorJSONParsePropsList(virJSONValuePtr cmd,
}
ret = count;
- *props = proplist;
- proplist = NULL;
+ *props = g_steal_pointer(&proplist);
cleanup:
g_strfreev(proplist);
@@ -6962,8 +6956,7 @@ qemuMonitorJSONGetMigrationCapabilities(qemuMonitorPtr mon,
}
ret = n;
- *capabilities = list;
- list = NULL;
+ *capabilities = g_steal_pointer(&list);
cleanup:
g_strfreev(list);
@@ -7091,8 +7084,7 @@ qemuMonitorJSONGetGICCapabilities(qemuMonitorPtr mon,
}
ret = n;
- *capabilities = list;
- list = NULL;
+ *capabilities = g_steal_pointer(&list);
cleanup:
VIR_FREE(list);
@@ -8157,8 +8149,7 @@ qemuMonitorJSONGetIOThreads(qemuMonitorPtr mon,
}
*niothreads = n;
- *iothreads = infolist;
- infolist = NULL;
+ *iothreads = g_steal_pointer(&infolist);
ret = 0;
cleanup:
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index a83cd866e7..31868269b1 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -6299,8 +6299,7 @@ remoteConnectGetCPUModelNames(virConnectPtr conn,
retmodels[i] = ret.models.models_val[i];
ret.models.models_val[i] = NULL;
}
- *models = retmodels;
- retmodels = NULL;
+ *models = g_steal_pointer(&retmodels);
}
rv = ret.ret;
@@ -7464,8 +7463,7 @@ remoteNetworkGetDHCPLeases(virNetworkPtr net,
goto cleanup;
}
- *leases = leases_ret;
- leases_ret = NULL;
+ *leases = g_steal_pointer(&leases_ret);
}
rv = ret.ret;
@@ -7555,8 +7553,7 @@ remoteConnectGetAllDomainStats(virConnectPtr conn,
elem = NULL;
}
- *retStats = tmpret;
- tmpret = NULL;
+ *retStats = g_steal_pointer(&tmpret);
rv = ret.retStats.retStats_len;
cleanup:
@@ -7774,8 +7771,7 @@ remoteDomainInterfaceAddresses(virDomainPtr dom,
}
}
}
- *ifaces = ifaces_ret;
- ifaces_ret = NULL;
+ *ifaces = g_steal_pointer(&ifaces_ret);
rv = ret.ifaces.ifaces_len;
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index f0b866a962..265400ecfa 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -1146,8 +1146,7 @@ virNetServerGetClients(virNetServerPtr srv,
}
}
- *clts = list;
- list = NULL;
+ *clts = g_steal_pointer(&list);
ret = nclients;
cleanup:
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 5710495bbf..7cb60e66d3 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -840,8 +840,7 @@ int virFileLoopDeviceAssociate(const char *file,
}
VIR_DEBUG("Attached loop device %s %d to %s", file, lofd, loname);
- *dev = loname;
- loname = NULL;
+ *dev = g_steal_pointer(&loname);
ret = 0;
@@ -3200,8 +3199,7 @@ virFileOpenTty(int *ttyprimary, char **ttyName, int rawmode)
errno = rc;
goto cleanup;
}
- *ttyName = name;
- name = NULL;
+ *ttyName = g_steal_pointer(&name);
}
ret = 0;
@@ -3637,9 +3635,8 @@ virFileFindHugeTLBFS(virHugeTLBFSPtr *ret_fs,
tmp->deflt = tmp->size == default_hugepagesz;
}
- *ret_fs = fs;
*ret_nfs = nfs;
- fs = NULL;
+ *ret_fs = g_steal_pointer(&fs);
nfs = 0;
ret = 0;
diff --git a/src/util/virlog.c b/src/util/virlog.c
index cdfeba8251..00c0fcc457 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -1658,8 +1658,7 @@ virLogParseOutputs(const char *src, virLogOutputPtr **outputs)
}
ret = noutputs;
- *outputs = list;
- list = NULL;
+ *outputs = g_steal_pointer(&list);
cleanup:
g_strfreev(strings);
return ret;
@@ -1708,8 +1707,7 @@ virLogParseFilters(const char *src, virLogFilterPtr **filters)
}
ret = nfilters;
- *filters = list;
- list = NULL;
+ *filters = g_steal_pointer(&list);
cleanup:
g_strfreev(strings);
return ret;
diff --git a/src/util/virmdev.c b/src/util/virmdev.c
index db40fe8cc3..2b7f730bd1 100644
--- a/src/util/virmdev.c
+++ b/src/util/virmdev.c
@@ -95,8 +95,7 @@ virMediatedDeviceGetSysfsDeviceAPI(virMediatedDevicePtr dev,
if ((tmp = strchr(buf, '\n')))
*tmp = '\0';
- *device_api = buf;
- buf = NULL;
+ *device_api = g_steal_pointer(&buf);
return 0;
}
diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c
index 995650334c..0016028254 100644
--- a/src/util/virsysinfo.c
+++ b/src/util/virsysinfo.c
@@ -258,8 +258,7 @@ virSysinfoParsePPCSystem(const char *base, virSysinfoSystemDefPtr *sysdef)
def = NULL;
}
- *sysdef = def;
- def = NULL;
+ *sysdef = g_steal_pointer(&def);
ret = 0;
virSysinfoSystemDefFree(def);
return ret;
@@ -381,8 +380,7 @@ virSysinfoParseARMSystem(const char *base, virSysinfoSystemDefPtr *sysdef)
def = NULL;
}
- *sysdef = def;
- def = NULL;
+ *sysdef = g_steal_pointer(&def);
ret = 0;
virSysinfoSystemDefFree(def);
return ret;
@@ -521,8 +519,7 @@ virSysinfoParseS390System(const char *base, virSysinfoSystemDefPtr *sysdef)
def = NULL;
}
- *sysdef = def;
- def = NULL;
+ *sysdef = g_steal_pointer(&def);
ret = 0;
cleanup:
virSysinfoSystemDefFree(def);
@@ -686,8 +683,7 @@ virSysinfoParseBIOS(const char *base, virSysinfoBIOSDefPtr *bios)
def = NULL;
}
- *bios = def;
- def = NULL;
+ *bios = g_steal_pointer(&def);
ret = 0;
virSysinfoBIOSDefFree(def);
return ret;
@@ -763,8 +759,7 @@ virSysinfoParseX86System(const char *base, virSysinfoSystemDefPtr *sysdef)
def = NULL;
}
- *sysdef = def;
- def = NULL;
+ *sysdef = g_steal_pointer(&def);
ret = 0;
virSysinfoSystemDefFree(def);
return ret;
@@ -845,9 +840,8 @@ virSysinfoParseX86BaseBoard(const char *base,
ignore_value(VIR_REALLOC_N(boards, nboards));
}
- *baseBoard = boards;
*nbaseBoard = nboards;
- boards = NULL;
+ *baseBoard = g_steal_pointer(&boards);
nboards = 0;
ret = 0;
cleanup:
@@ -915,8 +909,7 @@ virSysinfoParseX86Chassis(const char *base,
def = NULL;
}
- *chassisdef = def;
- def = NULL;
+ *chassisdef = g_steal_pointer(&def);
ret = 0;
virSysinfoChassisDefFree(def);
return ret;
diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c
index f9ab6f6042..c4c26a1183 100644
--- a/src/util/virtypedparam.c
+++ b/src/util/virtypedparam.c
@@ -706,9 +706,8 @@ virTypedParamsSerialize(virTypedParameterPtr params,
j++;
}
- *remote_params_val = params_val;
*remote_params_len = params_len;
- params_val = NULL;
+ *remote_params_val = g_steal_pointer(¶ms_val);
rv = 0;
cleanup:
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 138403b034..0c4126bd38 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -7583,8 +7583,7 @@ vboxConnectListAllDomains(virConnectPtr conn,
/* safe to ignore, new size will be equal or less than
* previous allocation */
ignore_value(VIR_REALLOC_N(doms, count + 1));
- *domains = doms;
- doms = NULL;
+ *domains = g_steal_pointer(&doms);
}
ret = count;
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 0ebcb06234..60ed286cee 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -3817,8 +3817,7 @@ vzConnectGetAllDomainStats(virConnectPtr conn,
tmpstats[nstats++] = tmp;
}
- *retStats = tmpstats;
- tmpstats = NULL;
+ *retStats = g_steal_pointer(&tmpstats);
ret = nstats;
cleanup:
diff --git a/tests/commandhelper.c b/tests/commandhelper.c
index b3c65ab3cc..ee06339392 100644
--- a/tests/commandhelper.c
+++ b/tests/commandhelper.c
@@ -116,8 +116,7 @@ static struct Arguments *parseArguments(int argc, char** argv)
}
}
- ret = args;
- args = NULL;
+ ret = g_steal_pointer(&args);
return ret;
}
diff --git a/tools/virsh-checkpoint.c b/tools/virsh-checkpoint.c
index 6e68ba66ff..91f7c963c1 100644
--- a/tools/virsh-checkpoint.c
+++ b/tools/virsh-checkpoint.c
@@ -633,8 +633,7 @@ virshCheckpointListCollect(vshControl *ctl,
qsort(checkpointlist->chks, checkpointlist->nchks,
sizeof(*checkpointlist->chks), virshChkSorter);
- ret = checkpointlist;
- checkpointlist = NULL;
+ ret = g_steal_pointer(&checkpointlist);
cleanup:
virshCheckpointListFree(checkpointlist);
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index d40995f44d..3597190523 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -5187,8 +5187,7 @@ cmdSchedInfoUpdate(vshControl *ctl, const vshCmd *cmd,
goto cleanup;
ret = nparams;
- *update_params = params;
- params = NULL;
+ *update_params = g_steal_pointer(¶ms);
cleanup:
VIR_FREE(set_field);
--
2.29.2
3 years, 9 months
[PATCH 0/2] backup: Don't try to update stats if VM isn't alive
by Peter Krempa
Doing so results in a crash.
Peter Krempa (2):
qemuBackupJobTerminate: Move cleanup of temp files earlier
qemuBackupJobTerminate: Don't calculate backup job stats if VM isn't
active
src/qemu/qemu_backup.c | 33 ++++++++++++++++++---------------
1 file changed, 18 insertions(+), 15 deletions(-)
--
2.29.2
3 years, 9 months