Commit Graph

39659 Commits

Author SHA1 Message Date
Matt Coleman
b1423cf1ea domain_conf: make virDomainDiskSetSource() void
The function only returns zero or aborts, so it might as well be void.
This has the added benefit of simplifying the code that calls it.

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-11-05 16:31:16 +01:00
Yi Li
ed3cc76b48 virsh-domain: Remove unused virshNodeIsSuperset
The function is marked as unused. Remove it from the tree
until a new use case can be found.
Unused since: 38cc07b7bc

Signed-off-by: Yi Li <yili@winhong.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-11-05 10:47:47 +01:00
Jim Fehlig
f035f53baa remote: Add libvirtd dependency to virt-guest-shutdown.target
When restarting libvirt services and sockets *and* libvirt-guests.service
is running, the latter will sometimes hang when trying to connect to
libvirtd. Even though libvirt-guests has 'Wants=libvirtd.service' and
'After=libvirtd.service', we can see via journalctl that it is not
shutdown before libvirtd when executing something like

systemctl try-restart libvirtd.service libvirtd.socket \
libvirtd-ro.socket virtlockd.service virtlockd.socket \
virtlogd.service virtlogd.socket virt-guest-shutdown.target

Oct 28 15:53:31 systemd[1]: Stopping Virtualization daemon...
Oct 28 15:53:31 systemd[1]: libvirtd.service: Succeeded.
Oct 28 15:53:31 systemd[1]: Stopped Virtualization daemon.
Oct 28 15:53:31 systemd[1]: libvirtd-admin.socket: Succeeded.
Oct 28 15:53:31 systemd[1]: Closed Libvirt admin socket.
Oct 28 15:53:31 systemd[1]: Stopping Libvirt admin socket.
Oct 28 15:53:31 systemd[1]: libvirtd-ro.socket: Succeeded.
Oct 28 15:53:31 systemd[1]: Closed Libvirt local read-only socket.
Oct 28 15:53:31 systemd[1]: Stopping Libvirt local read-only socket.
Oct 28 15:53:31 systemd[1]: libvirtd.socket: Succeeded.
Oct 28 15:53:31 systemd[1]: Closed Libvirt local socket.
Oct 28 15:53:31 systemd[1]: Stopping Libvirt local socket.
Oct 28 15:53:31 systemd[1]: Listening on Libvirt local socket.
Oct 28 15:53:31 systemd[1]: Listening on Libvirt admin socket.
Oct 28 15:53:31 systemd[1]: Listening on Libvirt local read-only socket.
Oct 28 15:53:31 systemd[1]: virtlockd.socket: Succeeded.
Oct 28 15:53:31 systemd[1]: Closed Virtual machine lock manager socket.
Oct 28 15:53:31 systemd[1]: Stopping Virtual machine lock manager socket.
Oct 28 15:53:31 systemd[1]: Listening on Virtual machine lock manager socket.
Oct 28 15:53:31 systemd[1]: virtlogd.socket: Succeeded.
Oct 28 15:53:31 systemd[1]: Closed Virtual machine log manager socket.
Oct 28 15:53:31 systemd[1]: Stopping Virtual machine log manager socket.
Oct 28 15:53:31 systemd[1]: Listening on Virtual machine log manager socket.
Oct 28 15:53:31 systemd[1]: Stopping Suspend/Resume Running libvirt Guests...

In this case, the try-restart command hung and libvirt-guests was stuck
trying to connect to libvirtd. In the following case, the try-restart
worked since libvirtd was started again before libvirt-guests was stopped!

Oct 28 15:19:02  systemd[1]: Stopping Virtualization daemon...
Oct 28 15:19:02  systemd[1]: Stopped Virtualization daemon.
Oct 28 15:19:02  systemd[1]: Closed Libvirt admin socket.
Oct 28 15:19:02  systemd[1]: Stopping Libvirt admin socket.
Oct 28 15:19:02  systemd[1]: Closed Virtual machine lock manager socket.
Oct 28 15:19:02  systemd[1]: Stopping Virtual machine lock manager socket.
Oct 28 15:19:02  systemd[1]: Listening on Virtual machine lock manager socket.
Oct 28 15:19:02  systemd[1]: Closed Libvirt local read-only socket.
Oct 28 15:19:02  systemd[1]: Stopping Libvirt local read-only socket.
Oct 28 15:19:02  systemd[1]: Closed Libvirt local socket.
Oct 28 15:19:02  systemd[1]: Stopping Libvirt local socket.
Oct 28 15:19:02  systemd[1]: Listening on Libvirt local socket.
Oct 28 15:19:02  systemd[1]: Listening on Libvirt admin socket.
Oct 28 15:19:02  systemd[1]: Listening on Libvirt local read-only socket.
Oct 28 15:19:02  systemd[1]: Closed Virtual machine log manager socket.
Oct 28 15:19:02  systemd[1]: Stopping Virtual machine log manager socket.
Oct 28 15:19:02  systemd[1]: Listening on Virtual machine log manager socket.
Oct 28 15:19:02  systemd[1]: Starting Virtualization daemon...
Oct 28 15:19:02  systemd[1]: Stopping Suspend/Resume Running libvirt Guests...
Oct 28 15:19:02  systemd[1]: Started Virtualization daemon.
Oct 28 15:19:02  libvirt-guests.sh[4912]: Running guests on default URI: no running guests.
Oct 28 15:19:02  systemd[1]: Stopped Suspend/Resume Running libvirt Guests.
Oct 28 15:19:02  systemd[1]: Stopped target Libvirt guests shutdown.
Oct 28 15:19:02  systemd[1]: Stopping Libvirt guests shutdown.
Oct 28 15:19:02  systemd[1]: Reached target Libvirt guests shutdown.
Oct 28 15:19:02  systemd[1]: Starting Suspend/Resume Running libvirt Guests...
Oct 28 15:19:02  systemd[1]: Started Suspend/Resume Running libvirt Guests.

Adding 'Requires=libvirtd.service' to virt-guest-shutdown.target results
in expected behavior

Oct 28 15:40:00  systemd[1]: Stopping Suspend/Resume Running libvirt Guests...
Oct 28 15:40:00  libvirt-guests.sh[5245]: Running guests on default URI: no running guests.
Oct 28 15:40:00  systemd[1]: Stopped Suspend/Resume Running libvirt Guests.
Oct 28 15:40:00  systemd[1]: Stopped target Libvirt guests shutdown.
Oct 28 15:40:00  systemd[1]: Stopping Libvirt guests shutdown.
Oct 28 15:40:00  systemd[1]: Stopping Virtualization daemon...
Oct 28 15:40:00  systemd[1]: Stopped Virtualization daemon.
Oct 28 15:40:00  systemd[1]: Closed Virtual machine log manager socket.
Oct 28 15:40:00  systemd[1]: Stopping Virtual machine log manager socket.
Oct 28 15:40:00  systemd[1]: Listening on Virtual machine log manager socket.
Oct 28 15:40:00  systemd[1]: Closed Libvirt admin socket.
Oct 28 15:40:00  systemd[1]: Stopping Libvirt admin socket.
Oct 28 15:40:00  systemd[1]: Closed Libvirt local read-only socket.
Oct 28 15:40:00  systemd[1]: Stopping Libvirt local read-only socket.
Oct 28 15:40:00  systemd[1]: Closed Libvirt local socket.
Oct 28 15:40:00  systemd[1]: Stopping Libvirt local socket.
Oct 28 15:40:00  systemd[1]: Listening on Libvirt local socket.
Oct 28 15:40:00  systemd[1]: Listening on Libvirt admin socket.
Oct 28 15:40:00  systemd[1]: Listening on Libvirt local read-only socket.
Oct 28 15:40:00  systemd[1]: Closed Virtual machine lock manager socket.
Oct 28 15:40:00  systemd[1]: Stopping Virtual machine lock manager socket.
Oct 28 15:40:00  systemd[1]: Listening on Virtual machine lock manager socket.
Oct 28 15:40:00  systemd[1]: Starting Virtualization daemon...
Oct 28 15:40:00  systemd[1]: Started Virtualization daemon.
Oct 28 15:40:00  systemd[1]: Reached target Libvirt guests shutdown.
Oct 28 15:40:00  systemd[1]: Starting Suspend/Resume Running libvirt Guests...
Oct 28 15:40:00  systemd[1]: Started Suspend/Resume Running libvirt Guests.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-11-04 16:26:27 -07:00
Boris Fiuczynski
4694299234 conf: node_device: cleanup virNodeDevCapCCWParseXML
Make use of g_autofree

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-11-04 19:15:23 +01:00
Boris Fiuczynski
b5f8c358a3 schema: refactor mdev_types out of PCI nodedev schema
Refactor mdev_types into standalone define for later reuse.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-11-04 19:15:17 +01:00
Boris Fiuczynski
d20735adf5 conf: node_device: refactor CSS formatting
Move XML formatting code into a new method.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-04 19:15:11 +01:00
Boris Fiuczynski
c218c6ec7a conf: node_device: refactor mdev_types XML parsing
Extract PCI code from virNodeDevPCICapMdevTypesParseXML to make
method virNodeDevCapMdevTypesParseXML generic for later reuse.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-11-04 19:15:05 +01:00
Boris Fiuczynski
9f0d3981ce conf: node_device: refactor capability mdev_types formatting
Extract the XML formatting for mdev_types from PCI capability into
a generic standalone method for later reuse.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-04 19:14:58 +01:00
Boris Fiuczynski
f1b08901f7 conf: node_device: refactor GetPCIMdevTypesCaps into GetMdevTypeCapes
Extracting PCI from virNodeDeviceGetPCIMdevTypesCaps creating
virNodeDeviceGetMdevTypesCaps to make later reuse possible.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-04 19:14:52 +01:00
Boris Fiuczynski
da5cf518ad util: refactor mdev_types methods return code usage
Remove mix of array length and error code in the return code.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-04 19:14:07 +01:00
Boris Fiuczynski
65c1f47760 util: refactor mdev_types method from PCI to mdev
Extract virPCIGetMdevTypes from PCI as virMediatedDeviceGetMdevTypes
into mdev for later reuse.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-04 19:11:49 +01:00
Boris Fiuczynski
689ff3c6c6 conf: node_device: fix mdev_types format and XML parsing code to match schema
The nodedev schema defines that a mdev_types capability must have
one or more type elements. The XML parsing and the format allows to
accept and to write mdev_types capability without any type element.
This patches fixes this.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-11-04 19:11:46 +01:00
Brian Turek
ae110dc58b qemu: add docs for 'fmode' and 'dmode' options
Adds documentation for QEMU 9pfs 'fmode' and 'dmode' options.

Signed-off-by: Brian Turek <brian.turek@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-04 18:25:57 +01:00
Brian Turek
1d9b4a9638 qemu: add support for 'fmode' and 'dmode'
Add logic to validate and then pass through 'fmode' and 'dmode' to the
QEMU call.

Signed-off-by: Brian Turek <brian.turek@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-11-04 18:25:56 +01:00
Brian Turek
1d446bd465 qemu: add 'fmode' and 'dmode' options
Expose QEMU's 9pfs 'fmode' and 'dmode' options via attributes on the
'filesystem' node in the domain XML. These options control the creation
mode of files and directories, respectively, when using
accessmode=mapped.

Signed-off-by: Brian Turek <brian.turek@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-04 18:25:55 +01:00
Brian Turek
b0f0e96cdd qemu: capabilities: add QEMU_CAPS_FSDEV_CREATEMODE
The QEMU 9pfs 'fmode' and 'dmode' options have existed since QEMU 2.10.
Probe QEMU's command line set to check whether these options are
available, and if yes, enable this new QEMU_CAPS_FSDEV_CREATEMODE
capability on libvirt side.

Signed-off-by: Brian Turek <brian.turek@gmail.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-11-04 18:25:53 +01:00
Aleksandr Alekseev
d467144cf2 doc: document new filters and not documented ones
Signed-off-by: Aleksandr Alekseev <alexander.alekseev@virtuozzo.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-11-04 17:21:45 +01:00
Aleksandr Alekseev
2d90e34a6f example: add ipv6 filters examples
Signed-off-by: Aleksandr Alekseev <alexander.alekseev@virtuozzo.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-11-04 17:21:45 +01:00
Aleksandr Alekseev
113ccac237 example: fix typo and formatting
Signed-off-by: Aleksandr Alekseev <alexander.alekseev@virtuozzo.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-11-04 17:21:45 +01:00
Julio Faracco
b356d81b89 cpu_ppc64: compare CPU function is ignoring return value
Function to compare CPU on 64-bits PowerPC is ignoring the flag to avoid failure
in case of CPUs (host and guest) are incompatible. Basically, the function is
returning -1 even if it is set to continue.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-11-04 17:13:49 +01:00
Orion Poplawski
a501fa7cae libvirt-guests: Sync time for autostarted guests
Setting SYNC_TIME=1 does not work on autostarted guests.

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

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-11-04 12:18:05 +01:00
Roman Bolshakov
040de3fe46 storagepoolxml2argvtest: Reorder gluster arguments
Commit f00cde7f11 changed order of mount arguments in
virStorageBackendFileSystemMountGlusterArgs() and introduced per-OS
mount options and new test data. Old test data was left unmodified with
prior order of arguments. That causes a test failure on all OSes but
Linux and FreeBSD, i.e. on macOS:

  15) Storage Pool XML-2-argv pool-netfs-gluster
      ...
  In
  '/Users/roolebo/dev/libvirt/tests/storagepoolxml2argvdata/pool-netfs-gluster.argv':
  Offset 39
  Expect [-o direct-io-mode=1 /mnt/gluster]
  Actual [/mnt/gluster -o direct-io-mode=1]

Fixes: f00cde7f11 ("storage: Add default mount options for fs/netfs storage pools")
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-11-04 11:54:03 +01:00
Roman Bolshakov
beece2411d virpcimock: Enable on macOS
In general, it has little sense to use Linux pci mock on macOS but
virPCIDeviceAddressGetIOMMUGroupNum() is relying on the filesystem
layout mocked by virpcimock. And all tests that rely on correct
execution of virPCIDeviceAddressGetIOMMUGroupNum() fail.

The change fixes qemuhotplugtest, qemumemlocktest and qemuxml2xmltest.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-11-04 11:54:02 +01:00
Roman Bolshakov
31eb96358f virpcimock: Initialize real_close before using it
real_close() is not inialized by the first invocation of close(). That
causes an issue when the mock is used before others and a call of
real_close() results in a jump to NULL pointer.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-11-04 11:53:57 +01:00
Pavel Hrdina
457877eae4 vircgroup: drop condition for absolute path from copyPlacement callbacks
Now that every caller to copyPlacement doesn't pass absolute path there
is no need to have a condition to handle that case.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 21:26:32 +01:00
Pavel Hrdina
6f0aa96f41 vircgroup: refactor virCgroupNewPartition
The old code passed an absolute path to virCgroupNewFromParent() which
is not necessary. The code can take the current placement of parent
cgroup and append a relative path.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 21:26:32 +01:00
Pavel Hrdina
14674ad436 vircgroup: move parentPath declaration
It's used only inside the if condition.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 21:26:32 +01:00
Pavel Hrdina
77291414c7 vircgroup: refactor virCgroupEnableMissingControllers
Use virStringSplit() to get the list of directories needed to be
created. This improves readability of the code and stops passing
absolute path to virCgroupNewFromParent().

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 21:26:32 +01:00
Pavel Hrdina
99d2c6519a vircgroup: drop @create from virCgroupNewDomainPartition
All callers pass true.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 21:26:32 +01:00
Pavel Hrdina
085590fee4 vircgroup: introduce virCgroupSetPlacement
Currently this task is done by virCgroupCopyPlacement when the @path
starts with "/".

virCgroupNew is always called with @path starting with "/" and there is
no parent to copy path from. To make it obvious what the code is doing
introduce new helper.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 21:26:32 +01:00
Pavel Hrdina
ca7b305631 vircgroup: drop @pid argument from virCgroupNew
Now it is always -1.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 21:26:32 +01:00
Pavel Hrdina
c16da281e4 vircgroup: no need to use PID in virCgroupEnableMissingControllers
This function is relevant only with cgroups v1 where it creates
hierarchy for controllers that are not managed by systemd. PID is used
to detect a placement of current process but in this situation we are
building the hierarchy for already known placement.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 21:26:32 +01:00
Pavel Hrdina
13958a8c5b vircgroup: expand virCgroupDetect into virCgroupNew
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 21:26:32 +01:00
Pavel Hrdina
95dc2fabe3 vircgroup: virCgroupNew is now always called with absolute path
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 21:26:32 +01:00
Pavel Hrdina
2eb83e270d vircgroup: drop @parent from virCgroupNew
Now it is always NULL.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 21:26:32 +01:00
Pavel Hrdina
bcfa563707 vircgroup: introduce virCgroupNewParent
The current code uses virCgroupNew() as a single point of entry and
calls into virCgroupDetect() as well. Both have logic for several paths
which is difficult to figure out.

Extract the actually used code path from the two functions to make
it obvious what's happening in this case.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 21:26:32 +01:00
Pavel Hrdina
234769b0d5 vircgroup: extract virCgroupNewDetect from virCgroupNew
The current code uses virCgroupNew() as a single point of entry and
calls into virCgroupDetect() as well. Both have logic for several paths
which is difficult to figure out.

Extract the actually used code path from the two functions to make
it obvious what's happening in this case.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 21:26:32 +01:00
Pavel Hrdina
f8ca962589 vircgroup: introduce virCgroupDetectControllers helper
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 21:26:32 +01:00
Pavel Hrdina
20da059e18 vircgroup: introduce virCgroupValidatePlacement helper
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 21:26:32 +01:00
Pavel Hrdina
30f3516053 vircgroup: introduce virCgroupCopyPlacement helper
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 21:26:32 +01:00
Pavel Hrdina
069f0994ab vircgroup: introduce virCgroupCopyMounts helper
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 21:26:32 +01:00
Pavel Hrdina
a4353381f1 vircgroup: introduce virCgroupSetBackends helper
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 21:26:32 +01:00
Pavel Hrdina
c88b3712ca vircgroup: remove useless cgroup->path variable
It is only used for debug and error purposes which can be easily
replaced by @placement.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 21:26:32 +01:00
Pavel Hrdina
9d312af357 vircgroupv2: detect controllers enabled in parent cgroup
With cgroups v2 working with controllers is a bit more complicated then
with cgroups v1 where the controller had to be mounted.

There are two files, cgroups.controllers and cgroup.subtree_control.
The file cgroup.controllers lists all controllers enabled in the current
cgroup and cgroups.subtree_control, as the name suggest, controls which
controllers are enabled for a subtree of cgroups.

Now the issue here is that the current code doesn't make any difference
if the @parent variable is NULL or not because ../cgroup.subtree_control
will list the same controllers as ./cgroup.controllers.

The whole point of the @parent variable is when we are building the
cgroup topology ourselves without systemd help we need to detect which
controllers are enabled in the parent cgroup in order to enable them for
the current cgroup as well and for that we need to check
cgroup.controllers of the parent group.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 21:26:32 +01:00
Pavel Hrdina
902c6644a8 vircgroupv2: properly detect placement of running VM
When libvirtd starts a VM it internally stores a path to the main
cgroup. When we restart libvirtd we should get to the same state.

When we start a VM on host with systemd the cgroup is created for us and
the process is already placed into that cgroup and we detect the path
created by systemd using /proc/$PID/cgroup. After that we create
sub-cgroups and move all threads there.

Once libvirtd is restarted we again detect the cgroup path using
/proc/$PID/cgroup, but in this case we will get a different path because
the main thread was moved to a "emulator" cgroup.

Instead of ignoring the "emulator" directory when validating cgroups
remove it completely when detecting cgroup otherwise cgroups will not
work properly when libvirtd is restarted.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 21:26:32 +01:00
Pavel Hrdina
e85cfb095a vircgroupv2: properly detect empty tasks
With cgroups v2 the file cgroup.procs will never be empty if threading
is enabled as it will always have ID of all processes even if all
threads of the processes are moved to sub-cgroups. If that happens the
file cgroup.threads will be empty.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 21:26:32 +01:00
Pavel Hrdina
09c12ba248 qemu_dbus: use emulator cgroup for dbus-daemon
All other helper processes are moved to cgroup with QEMU emulator
thread as we keep the root VM cgroup without any processes. This
assumption is validated in qemuRestoreCgroupState() which is called
when libvirtd is restarted and reconnected to all running VMs.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 21:26:32 +01:00
Pavel Hrdina
b43acd8e82 qemu: remove dead code that setup cgroups for helper processes
In both cases priv->cgroup will always be NULL because it is called
before the QEMU process is started and cgroups are configured.

In qemuProcessLaunch() the call order is following:

    qemuExtDevicesStart()
    ...
    virCommandRun()
    ...
    qemuSetupCgroup()

where qemuDBusStart() is called from qemuExtDevicesStart() but we
cgroups are created in qemuSetupCgroup().

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 21:26:32 +01:00
Pavel Hrdina
382071b8bf qemu_cgroup: remove unused @empty variable
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 21:26:32 +01:00
Tim Wiederhake
82bebba180 cpu_map: Unify apostrophe and quotation mark usage
Usage was mixed.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-11-03 17:10:26 +01:00