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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>