Commit Graph

38961 Commits

Author SHA1 Message Date
Pavel Hrdina
e8f00bc82c tests: introduce virgdbusmock to mock GLib DBus functions
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-17 18:19:56 +02:00
Pavel Hrdina
65674622d6 tests/virmock: extend number of arguments
Rewrite to use GLib DBus instead of libdbus will introduce function with
large number of arguments that we will have to mock for our tests so we
need to extend the number of arguments for our macros.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-17 18:19:53 +02:00
Pavel Hrdina
2ef84f000f util: introduce helpers for GLib DBus implementation
With libdbus our wrappers had a special syntax to create the DBus
messages by defining the DBus message signature followed by list
of arguments providing data based on the signature.

There will be no similar helper with GLib implementation as they
provide same functionality via GVariant APIs. The syntax is slightly
different mostly for how arrays, variadic types and dictionaries are
created/parsed.

Additional difference is that with GLib DBus everything is wrapped in
extra tuple (struct). For more details refer to the documentation [1].

[1] <https://developer.gnome.org/glib/stable/gvariant-format-strings.html>

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-17 18:19:50 +02:00
Pavel Hrdina
1db95f72e1 tests: mock libdbus in networkxml2firewalltest
This test calls into src/util/virfirewalld.c where it uses DBus to
figure out if firewalld is registered. Without the mock it luckily
fails and the test works correctly.

To isolate the tests from host environment we should mock the DBus
calls.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-17 18:19:46 +02:00
Pavel Hrdina
de3289e2b5 remove HAL node device driver
There was one attempt a year ago done by me to drop HAL [1] but it was
never resolved. There was another time when Dan suggested to drop HAL
driver [2] but it was decided to keep it around in case device
assignment will be implemented for FreeBSD and the fact that
virt-manager uses node device driver [3].

I checked git history and code and it doesn't look like bhyve supports
device assignment so from that POV it should not block removing HAL.

The argument about virt-manager is not strong as well because libvirt
installed from FreeBSD packages doesn't have HAL support so it will not
affect these users as well [4].

The only users affected by this change would be the ones compiling
libvirt from GIT on FreeBSD.

I looked into alternatives and there is libudev-devd package on FreeBSD
but unfortunately it doesn't work as it doesn't list any devices when
used with libvirt. It provides libudev APIs using devd.

I also looked into devd directly and it provides some APIs but there are
no APIs for device monitoring and events so that would have to be
somehow done by libvirt.

Main motivation for dropping HAL support is to replace libdbus with GLib
dbus implementation and it cannot be done with HAL driver present in
libvirt because HAL APIs heavily depends on symbols provided by libdbus.

[1] <https://www.redhat.com/archives/libvir-list/2019-May/msg00203.html>
[2] <https://www.redhat.com/archives/libvir-list/2016-April/msg00992.html>
[3] <https://www.redhat.com/archives/libvir-list/2016-April/msg00994.html>
[4] <https://svnweb.freebsd.org/ports/head/devel/libvirt/Makefile?view=markup>

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-17 18:19:26 +02:00
Lin Ma
b1cc6f93dd docs: virsh: Document the IO mode 'io_uring'
Signed-off-by: Lin Ma <lma@suse.de>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-17 12:26:00 +02:00
Lin Ma
ea17253970 virsh: event: options --list, --all and --event are mutually exclusive
Signed-off-by: Lin Ma <lma@suse.de>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-17 12:25:53 +02:00
Lin Ma
29f6ba3f18 virsh: net-port-create: log errors for non-existent xml file
Signed-off-by: Lin Ma <lma@suse.de>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-17 12:25:45 +02:00
Daniel P. Berrangé
80fcfab9ce access: ensure ACL files are rebuilt when protocol changes
Meson is not told that the .x protocol files are an input for the
generator, so it doesn't know to setup a rebuild dependancy.

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-09-16 15:53:27 +01:00
Nikolay Shirokovskiy
5756a7bf2a qemu: fix concurrency crash bug in force snapshot revert
This patch is just revert of [1]. Actually we should NOT pass
QEMU_ASYNC_JOB_NONE as that patch suggests while we are in async job in order
to acquire nested jobs correctly. The patch tries to fix issues introduced by
another patch [2] where jobs are mistakenly cleared out in qemuProcessStop.
Later patch [3] fixed the issue introduced by patch [2]. Now we need to revert
[1] as well as we now still have same concurrency crash issues as [3] described
but for the force revert.

[1] 0c4408c83: qemu: Don't use asyncJob after stop during snapshot revert
[2] 888aa4b6b: qemuDomainObjPrivateDataClear: Don't leak @migParams
[3] d75f865fb: qemu: fix concurrency crash bug in snapshot revert

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-16 11:45:41 +03:00
Matt Coleman
1e18d3b833 hyperv: fix the number of threads per core
The operands were reversed, producing an incorrect result.

Co-authored-by: Sri Ramanujam <sramanujam@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-16 10:14:42 +02:00
Peter Krempa
f2d90b558f qemuBuildHostdevSCSIAttachPrepare: Propagate 'readonly' flag also for iSCSI
The 'readonly' hostdev property is stored separately from the
virStorageSource as some hostdevs are not described by a virStorage
source. We need to propagate the flag to the virStorage source also for
iSCSI backends as it's used to generate the backend properties.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1868856

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-16 09:08:56 +02:00
Peter Krempa
c58c970586 qemuxml2argvtest: hostdev-scsi-virtio-scsi: Add <readonly/> to one of the iSCSI hostdevs
Test a readonly iSCSI backend as well.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-16 09:08:56 +02:00
Peter Krempa
1a5f35dbd2 qemu: backup: Write TLS cert and secret object aliases into status XML
We've put the aliases into the backup job definition after the status
XML was already written so they didn't appear in the on-disk state.

Move the code putting them into the private definition earlier, so that
the status XML update done by saving blockjobs already writes them out.

Also add a note notifying that the block job status update writes the
status XML.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1870488
Fixes: 423576679a
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-09-15 15:25:22 +02:00
Peter Krempa
5058062b5d qemu: backup: Remove note that TLS should be implemented
Commit 423576679a implementing TLS forgot to remove the comment.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-09-15 15:25:22 +02:00
Peter Krempa
6c2d91118d qemustatusxml2xml: backup-pull: Test private data formatting/parsing
Modify the test case to enable TLS and add private data containing
aliases of objects corresponding to a TLS setup.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-09-15 15:25:22 +02:00
Peter Krempa
2f7ee6914d qemuxml2argvtest: hostdev-scsi-virtio-scsi: Use longer user-alias for SCSI hostdev
Test that we can cope with a long useralias when generating SCSI hostdev
commandline.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-09-15 15:20:23 +02:00
Peter Krempa
e5dc1427d7 qemuDomainPrepareHostdev: Don't base backend nodename on device alias
QEMU's blockdev nodenames which are used to back SCSI/iSCSI hostdevs are
limited to 32 characters. If a user passes a very long user alias as
name of the host device it's easy to end up with a too-long nodename.

To prevent this from happening don't base the nodename on the possibly
user-specified alias but on the normal sequential node name generator.

We then store the name in the status XML for further use.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-09-15 15:20:23 +02:00
Peter Krempa
a669d68336 qemuDomainPrepareHostdev: base hostdev secret object names on backend alias
The secret object is used to pass data to the backend so it's better
fitting to base the secret object name on the SCSI host device backend
name.

Since we store the object alias in the status XML this modification is
safe in regards to existing guests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-09-15 15:20:23 +02:00
Peter Krempa
ca495825a3 qemuDomainPrepareHostdev: Allocate backend nodenames in the prepare function
Allocate the nodename in the setup function rather than in the command
line generator.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-09-15 15:20:23 +02:00
Peter Krempa
c17e4907fe qemuDomainSecretHostdevPrepare: remove
The function is no longer used once we setup per-hostdev data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-09-15 15:20:23 +02:00
Peter Krempa
3673bdbe13 qemu: domain: Extract preparation of hostdev specific data to a separate function
Historically we've prepared secrets for all objects in one place. This
doesn't make much sense and it's semantically more appealing to prepare
everything for a single device type in one place.

Move the setup of the (iSCSI|SCSI) hostdev secrets into a new function
which will be used to setup other things as well in the future.

This is a similar approach we do for disks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-09-15 15:20:23 +02:00
Peter Krempa
82b60ec8ce qemuBlockStorageSourceAttachData: remove 'storageNodeNameCopy'
This was a hack when we were locally regenerating the nodename so that
it's not leaked. Now that we use proper virStorageSource with
persistence it's no longer required.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-09-15 15:20:23 +02:00
Peter Krempa
cca2dd4890 qemuBuildHostdevSCSI(A|De)tachPrepare: Use virStorageSource in def for SCSI hostdevs
Modify the attach/detach data generators to actually use the
virStorageSourceStructure embedded in the SCSI config data rather than
creating an ad-hoc internal one.

The modification will allow us to properly store the nodename used for
the backend in the status XML rather than re-generating it all the
time.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-09-15 15:20:23 +02:00
Peter Krempa
482c52b177 qemu: domain: Fill in (i)SCSI backend nodename if it is not present in status XML
For upgrade reasons so that we can modify the used nodename we must
generate the old version for all status XMLs which don't have it stored
explicitly.

The change will be required as using the user-provided alias may result
in too-long nodenames which will be rejected by qemu.

Add code which fills in the appropriate old value and add test cases to
validate that it's added and also that existing nodenames are not
overwritten.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-09-15 15:20:23 +02:00
Peter Krempa
8e008c1013 tests: qemustatusxml2xmldata: Add local SCSI hostdev to 'upgrade' case
Add a local SCSI host device to validate upcoming generated data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-09-15 15:20:23 +02:00
Peter Krempa
d240e599e6 tests: qemustatusxml2xmldata: Rename 'disk-secinfo-upgrade' case to 'upgrade'
The test case tests other things besides disk secinfos, so we can make
it more universal.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-09-15 15:20:23 +02:00
Peter Krempa
981d098250 conf: Add virStorageSource member for SCSI host device config data
The backend for the SCSI host device is a storage source. While the
definition doesn't look like that it's converted to a storage source
when the VM is running.

Add the storage source to the definition object and also parse/format
its private data which will be used for internal state storage while
the VM is running.

Note that the virStorageSourcePtr may not be allocated all the time so
the private data parser allocates it if there is any private data
present.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-09-15 15:20:23 +02:00
Peter Krempa
baea669e80 qemuxml2argvtest: hostdev-scsi-virtio-scsi: Add hostdev with useralias
Add a SCSI host device with a user-specified alias to illustrate the
upcoming changes.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-09-15 15:20:23 +02:00
Peter Krempa
931c1d128d syntax-check: Don't forbid curly braces around single line condition body
This syntax rule doesn't make much sense, especially if there are so
much exceptions to it. Just remove it and adjust the coding style.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-09-15 15:20:23 +02:00
Peter Krempa
b4d2cb58b2 virDomainHostdevSubsysSCSIHostDefParseXML: Switch to a more modern XML parsing approach
Use XPath instead of iterating through the nodes.

Few error messages were modified so that the parser can be written in a
simpler way.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-09-15 15:20:23 +02:00
Peter Krempa
00688ea47e virDomainStorageNetworkParseHosts: Switch to a more modern XML parsing approach
Use XPath to get the host list instead of iterating through the nodes.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-09-15 15:20:23 +02:00
Peter Krempa
a269ac0f62 virDomainHostdevSubsysSCSIiSCSIClear: Inline contents into only caller
There's just one caller for the function. Move the code into the caller.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-09-15 15:20:23 +02:00
Ján Tomko
221f2c0383 virsh-completer: use g_new0 instead of VIR_ALLOC_N
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-15 13:46:11 +02:00
Ján Tomko
acdac34c45 virsh-completer: use g_free instead of VIR_FREE
All of them are in the cleanup section right before the variables
they free go out of scope.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-15 13:46:11 +02:00
Ján Tomko
a698dfae9b virsh-completer: use g_clear_pointer in virshCommaStringListComplete
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-15 13:46:11 +02:00
Pino Toscano
66732236a4 esx: implement domainInterfaceAddresses
Implement the .domainInterfaceAddresses hypervisor API, although only
functional for the VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT source.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-15 10:00:48 +02:00
Pino Toscano
7ad86c849f esx: generator: add GuestNicInfo object
Add the definition of the GuestNicInfo object, with all the required
objects for it.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-15 10:00:29 +02:00
Pino Toscano
2e65f0ad4a esx: implement connectListAllNetworks
Implement the .connectListAllNetworks networks API in the esx network
driver.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-15 10:00:09 +02:00
Boris Fiuczynski
9e7aa1c012 node_device: mdev vfio-ccw support
Allow vfio-ccw mdev devices to be created besides vfio-pci mdev devices
as well.

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
2020-09-15 09:06:32 +02:00
Boris Fiuczynski
33bbf589dd node_device: detect DASD devices
Make Direct Access Storage Devices (DASDs) available in the node_device driver.

Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
2020-09-15 09:06:30 +02:00
Boris Fiuczynski
ab655afa18 virsh: nodedev: ability to filter CSS capabilities
Allow to filter for CSS devices.

Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
2020-09-15 09:06:24 +02:00
Boris Fiuczynski
05e6cdafa6 node_device: detect CSS devices
Make channel subsystem (CSS) devices available in the node_device driver.
The CCS devices reside in the computer system and provide CCW devices, e.g.:

  +- css_0_0_003a
      |
      +- ccw_0_0_1a2b
          |
          +- scsi_host0
              |
              +- scsi_target0_0_0
                  |
                  +- scsi_0_0_0_0

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
2020-09-15 09:06:15 +02:00
Boris Fiuczynski
0e7f8bb6c1 node_device: refactor udevProcessCCW
Refactor out CCW address parsing for later reuse.

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
2020-09-15 09:06:13 +02:00
Ján Tomko
af16e754cd qemuProcessReconnect: clear 'oldjob'
After we started copying the privateData pointer in
qemuDomainObjRestoreJob, we should also free them
once we're done with them.

Register the clear function and use g_auto.
Also add a check for job->cb to qemuDomainObjClearJob,
to prevent freeing an uninitialized job.

https://bugzilla.redhat.com/show_bug.cgi?id=1878450

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: aca37c3fb2
2020-09-14 18:10:56 +02:00
Ján Tomko
a3c340e05f qemu: qemuDomainObjClearJob: use g_clear_pointer
The function used g_clear_pointer for all but one pointer.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-09-14 18:10:56 +02:00
Ján Tomko
ce66f9724c qemu: rename qemuDomainObjFreeJob -> qemuDomainObjClearJob
This function does not free the job.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-09-14 18:10:56 +02:00
Tim Wiederhake
cfd4adb51e util: Remove VIR_ALLOC_N_QUIET
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-09-14 17:28:51 +02:00
Tim Wiederhake
f323da47ec util: Use glib memory functions in virJSONValueGetArrayAsBitmap
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-09-14 17:28:51 +02:00
Tim Wiederhake
1fb2a560c3 tests: Use glib memory function in testConfRoundTrip
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-09-14 17:28:51 +02:00