]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
6 years agosecurity: Grab a reference to virSecurityManager for transactions
Michal Privoznik [Thu, 20 Sep 2018 12:22:13 +0000 (14:22 +0200)]
security: Grab a reference to virSecurityManager for transactions

This shouldn't be needed per-se. Security manager shouldn't
disappear during transactions - it's immutable. However, it
doesn't hurt to grab a reference either - transaction code uses
it after all.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirSecuritySELinuxContextListFree: Don't leak list->items
Michal Privoznik [Wed, 26 Sep 2018 07:19:31 +0000 (09:19 +0200)]
virSecuritySELinuxContextListFree: Don't leak list->items

This array is allocated in virSecuritySELinuxContextListAppend()
but never freed. This commit is essentially the same as ca25026.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirdbus: Use the mnemonic macros for dbus_bool_t values
Marc Hartmayer [Fri, 21 Sep 2018 13:02:04 +0000 (15:02 +0200)]
virdbus: Use the mnemonic macros for dbus_bool_t values

Use the mnemonic macros of libdbus for 1 (TRUE) and 0 (FALSE).

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirdbus: Report a debug message that dbus_watch_handle() has failed
Marc Hartmayer [Fri, 21 Sep 2018 13:02:03 +0000 (15:02 +0200)]
virdbus: Report a debug message that dbus_watch_handle() has failed

Report a debug message if dbus_watch_handle() returns FALSE.
dbus_watch_handle() returns FALSE if there wasn't enough memory for
reading or writing.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirdbus: Unref the D-Bus connection when closing
Marc Hartmayer [Fri, 21 Sep 2018 13:02:02 +0000 (15:02 +0200)]
virdbus: Unref the D-Bus connection when closing

As documented at
https://dbus.freedesktop.org/doc/api/html/group__DBusConnection.html#ga2522ac5075dfe0a1535471f6e045e1ee
the creator of a non-shared D-Bus connection has to release the last
reference after closing for freeing.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirdbus: Grab a ref as long as the while loop is executed
Marc Hartmayer [Fri, 21 Sep 2018 13:02:01 +0000 (15:02 +0200)]
virdbus: Grab a ref as long as the while loop is executed

Grab a ref for info->bus (a DBus connection) as long as the while loop
is running. With the grabbed reference it is ensured that info->bus
isn't freed as long as the while loop is executed. This is necessary
as it's allowed to drop the last ref for the bus connection in a
handler.

There was already a bug of this kind in libdbus itself:
https://bugs.freedesktop.org/show_bug.cgi?id=15635.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Avoid duplicate resume events and state changes
Jiri Denemark [Wed, 12 Sep 2018 12:34:33 +0000 (14:34 +0200)]
qemu: Avoid duplicate resume events and state changes

The only place where VIR_DOMAIN_EVENT_RESUMED should be generated is the
RESUME event handler to make sure we don't generate duplicate events or
state changes. In the worse case the duplicity can revert or cover
changes done by other event handlers.

For example, after QEMU sent RESUME, BLOCK_IO_ERROR, and STOP events
we could happily mark the domain as running and report
VIR_DOMAIN_EVENT_RESUMED to registered clients.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Map running reason to resume event detail
Jiri Denemark [Tue, 11 Sep 2018 13:13:08 +0000 (15:13 +0200)]
qemu: Map running reason to resume event detail

Thanks to the previous commit the RESUME event handler knows what reason
should be used when changing the domain state to VIR_DOMAIN_RUNNING, but
the emitted VIR_DOMAIN_EVENT_RESUMED event still uses a generic
VIR_DOMAIN_EVENT_RESUMED_UNPAUSED detail. Luckily, the event detail can
be easily deduced from the running reason, which saves us from having to
pass one more value to the handler.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Pass running reason to RESUME event handler
Jiri Denemark [Mon, 10 Sep 2018 17:41:53 +0000 (19:41 +0200)]
qemu: Pass running reason to RESUME event handler

Whenever we get the RESUME event from QEMU, we change the state of the
affected domain to VIR_DOMAIN_RUNNING with VIR_DOMAIN_RUNNING_UNPAUSED
reason. This is fine if the domain is resumed unexpectedly, but when we
sent "cont" to QEMU we usually have a better reason for the state
change. The better reason is used in qemuProcessStartCPUs which also
sets the domain state to running if qemuMonitorStartCPUs reports
success. Thus we may end up with two state updates in a row, but the
final reason is correct.

This patch is a preparation for dropping the state change done in
qemuMonitorStartCPUs for which we need to pass the actual running reason
to the RESUME event handler and use it there instead of
VIR_DOMAIN_RUNNING_UNPAUSED.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Report more appropriate running reasons
Jiri Denemark [Tue, 11 Sep 2018 17:26:07 +0000 (19:26 +0200)]
qemu: Report more appropriate running reasons

This patch replaces some rather generic VIR_DOMAIN_RUNNING_UNPAUSED
reasons when changing domain state to running with more specific ones.
All of them are done when libvirtd reconnects to an existing domain
after being restarted and sees an unfinished migration or save.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Properly report VIR_DOMAIN_EVENT_RESUMED_FROM_SNAPSHOT
Jiri Denemark [Mon, 10 Sep 2018 13:10:54 +0000 (15:10 +0200)]
qemu: Properly report VIR_DOMAIN_EVENT_RESUMED_FROM_SNAPSHOT

VIR_DOMAIN_EVENT_RESUMED_FROM_SNAPSHOT was defined but not used anywhere
in our event generation code. This fixes qemuDomainRevertToSnapshot to
properly report why the domain was resumed.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agolxc_monitor: Avoid AB / BA lock race
Mark Asselstine [Mon, 24 Sep 2018 15:11:35 +0000 (11:11 -0400)]
lxc_monitor: Avoid AB / BA lock race

A deadlock situation can occur when autostarting a LXC domain 'guest'
due to two threads attempting to take opposing locks while holding
opposing locks (AB BA problem). Thread A takes and holds the 'vm' lock
while attempting to take the 'client' lock, meanwhile, thread B takes
and holds the 'client' lock while attempting to take the 'vm' lock.

The potential for this can be seen as follows:

Thread A:
virLXCProcessAutostartDomain (takes vm lock)
 --> virLXCProcessStart
  --> virLXCProcessConnectMonitor
   --> virLXCMonitorNew
    --> virNetClientSetCloseCallback (wants client lock)

Thread B:
virNetClientIncomingEvent (takes client lock)
 --> virNetClientIOHandleInput
  --> virNetClientCallDispatch
   --> virNetClientCallDispatchMessage
    --> virNetClientProgramDispatch
     --> virLXCMonitorHandleEventInit
      --> virLXCProcessMonitorInitNotify (wants vm lock)

Since these threads are scheduled independently and are preemptible it
is possible for the deadlock scenario to occur where each thread locks
their first lock but both will fail to get their second lock and just
spin forever. You get something like:

virLXCProcessAutostartDomain (takes vm lock)
 --> virLXCProcessStart
  --> virLXCProcessConnectMonitor
   --> virLXCMonitorNew
<...>
virNetClientIncomingEvent (takes client lock)
 --> virNetClientIOHandleInput
  --> virNetClientCallDispatch
   --> virNetClientCallDispatchMessage
    --> virNetClientProgramDispatch
     --> virLXCMonitorHandleEventInit
      --> virLXCProcessMonitorInitNotify (wants vm lock but spins)
<...>
    --> virNetClientSetCloseCallback (wants client lock but spins)

Neither thread ever gets the lock it needs to be able to continue
while holding the lock that the other thread needs.

The actual window for preemption which can cause this deadlock is
rather small, between the calls to virNetClientProgramNew() and
execution of virNetClientSetCloseCallback(), both in
virLXCMonitorNew(). But it can be seen in real world use that this
small window is enough.

By moving the call to virNetClientSetCloseCallback() ahead of
virNetClientProgramNew() we can close any possible chance of the
deadlock taking place. There should be no other implications to the
move since the close callback (in the unlikely event was called) will
spin on the vm lock. The remaining work that takes place between the
old call location of virNetClientSetCloseCallback() and the new
location is unaffected by the move.

Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agovircgroup: rename controllers to legacy
Pavel Hrdina [Mon, 24 Sep 2018 23:17:02 +0000 (01:17 +0200)]
vircgroup: rename controllers to legacy

With the introduction of cgroup v2 there are new names used with
cgroups based on which version is used:

    - legacy: cgroup v1
    - unified: cgroup v2
    - hybrid: cgroup v1 and cgroup v2

Let's use 'legacy' instead of 'cgroupv1' or 'controllers' in our code.

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: rename virCgroupController into virCgroupV1Controller
Pavel Hrdina [Tue, 18 Sep 2018 15:36:06 +0000 (17:36 +0200)]
vircgroup: rename virCgroupController into virCgroupV1Controller

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1(Set|Get)CpusetCpus
Pavel Hrdina [Mon, 20 Aug 2018 08:01:10 +0000 (10:01 +0200)]
vircgroup: extract virCgroupV1(Set|Get)CpusetCpus

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1(Set|Get)CpusetMemoryMigrate
Pavel Hrdina [Mon, 20 Aug 2018 08:00:57 +0000 (10:00 +0200)]
vircgroup: extract virCgroupV1(Set|Get)CpusetMemoryMigrate

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1(Set|Get)CpusetMems
Pavel Hrdina [Mon, 20 Aug 2018 08:00:04 +0000 (10:00 +0200)]
vircgroup: extract virCgroupV1(Set|Get)CpusetMems

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1(Set|Get)FreezerState
Pavel Hrdina [Thu, 16 Aug 2018 16:22:08 +0000 (18:22 +0200)]
vircgroup: extract virCgroupV1(Set|Get)FreezerState

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1GetCpuacctStat
Pavel Hrdina [Mon, 20 Aug 2018 07:58:33 +0000 (09:58 +0200)]
vircgroup: extract virCgroupV1GetCpuacctStat

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1GetCpuacct*Usage
Pavel Hrdina [Mon, 20 Aug 2018 07:57:51 +0000 (09:57 +0200)]
vircgroup: extract virCgroupV1GetCpuacct*Usage

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1SupportsCpuBW
Pavel Hrdina [Fri, 17 Aug 2018 14:23:14 +0000 (16:23 +0200)]
vircgroup: extract virCgroupV1SupportsCpuBW

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1(Set|Get)CpuCfsQuota
Pavel Hrdina [Fri, 17 Aug 2018 14:22:56 +0000 (16:22 +0200)]
vircgroup: extract virCgroupV1(Set|Get)CpuCfsQuota

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1(Set|Get)CpuCfsPeriod
Pavel Hrdina [Fri, 17 Aug 2018 14:22:30 +0000 (16:22 +0200)]
vircgroup: extract virCgroupV1(Set|Get)CpuCfsPeriod

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1(Set|Get)CpuShares
Pavel Hrdina [Wed, 5 Sep 2018 18:11:38 +0000 (20:11 +0200)]
vircgroup: extract virCgroupV1(Set|Get)CpuShares

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1(Allow|Deny)AllDevices
Pavel Hrdina [Wed, 5 Sep 2018 18:10:02 +0000 (20:10 +0200)]
vircgroup: extract virCgroupV1(Allow|Deny)AllDevices

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1(Allow|Deny)Device
Pavel Hrdina [Wed, 5 Sep 2018 18:08:48 +0000 (20:08 +0200)]
vircgroup: extract virCgroupV1(Allow|Deny)Device

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1GetMemSwapUsage
Pavel Hrdina [Fri, 17 Aug 2018 14:19:08 +0000 (16:19 +0200)]
vircgroup: extract virCgroupV1GetMemSwapUsage

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1(Set|Get)Memory*Limit
Pavel Hrdina [Fri, 17 Aug 2018 14:18:38 +0000 (16:18 +0200)]
vircgroup: extract virCgroupV1(Set|Get)Memory*Limit

They all need virCgroupV1GetMemoryUnlimitedKB() so it's easier to
move them in one commit.

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1GetMemoryUsage
Pavel Hrdina [Fri, 17 Aug 2018 13:56:33 +0000 (15:56 +0200)]
vircgroup: extract virCgroupV1GetMemoryUsage

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1GetMemoryStat
Pavel Hrdina [Fri, 17 Aug 2018 13:55:47 +0000 (15:55 +0200)]
vircgroup: extract virCgroupV1GetMemoryStat

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1SetMemory
Pavel Hrdina [Fri, 17 Aug 2018 13:53:41 +0000 (15:53 +0200)]
vircgroup: extract virCgroupV1SetMemory

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1(Set|Get)BlkioDeviceWriteBps
Pavel Hrdina [Mon, 24 Sep 2018 10:21:21 +0000 (12:21 +0200)]
vircgroup: extract virCgroupV1(Set|Get)BlkioDeviceWriteBps

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1(Set|Get)BlkioDeviceReadBps
Pavel Hrdina [Mon, 24 Sep 2018 10:21:07 +0000 (12:21 +0200)]
vircgroup: extract virCgroupV1(Set|Get)BlkioDeviceReadBps

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1(Set|Get)BlkioDeviceWriteIops
Pavel Hrdina [Mon, 24 Sep 2018 10:20:50 +0000 (12:20 +0200)]
vircgroup: extract virCgroupV1(Set|Get)BlkioDeviceWriteIops

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1(Set|Get)BlkioDeviceReadIops
Pavel Hrdina [Mon, 24 Sep 2018 10:20:31 +0000 (12:20 +0200)]
vircgroup: extract virCgroupV1(Set|Get)BlkioDeviceReadIops

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1(Set|Get)BlkioDeviceWeight
Pavel Hrdina [Mon, 24 Sep 2018 10:20:19 +0000 (12:20 +0200)]
vircgroup: extract virCgroupV1(Set|Get)BlkioDeviceWeight

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1GetBlkioIoDeviceServiced
Pavel Hrdina [Fri, 17 Aug 2018 13:30:21 +0000 (15:30 +0200)]
vircgroup: extract virCgroupV1GetBlkioIoDeviceServiced

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1GetBlkioIoServiced
Pavel Hrdina [Fri, 17 Aug 2018 13:29:39 +0000 (15:29 +0200)]
vircgroup: extract virCgroupV1GetBlkioIoServiced

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1(Set|Get)BlkioWeight
Pavel Hrdina [Fri, 17 Aug 2018 13:28:50 +0000 (15:28 +0200)]
vircgroup: extract virCgroupV1(Set|Get)BlkioWeight

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1SetOwner
Pavel Hrdina [Fri, 17 Aug 2018 08:09:49 +0000 (10:09 +0200)]
vircgroup: extract virCgroupV1SetOwner

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1BindMount
Pavel Hrdina [Fri, 17 Aug 2018 08:04:20 +0000 (10:04 +0200)]
vircgroup: extract virCgroupV1BindMount

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1HasEmptyTasks
Pavel Hrdina [Fri, 17 Aug 2018 13:25:48 +0000 (15:25 +0200)]
vircgroup: extract virCgroupV1HasEmptyTasks

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1AddTask
Pavel Hrdina [Mon, 24 Sep 2018 23:14:36 +0000 (01:14 +0200)]
vircgroup: extract virCgroupV1AddTask

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1Remove
Pavel Hrdina [Fri, 17 Aug 2018 08:02:05 +0000 (10:02 +0200)]
vircgroup: extract virCgroupV1Remove

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1MakeGroup
Pavel Hrdina [Tue, 18 Sep 2018 14:11:47 +0000 (16:11 +0200)]
vircgroup: extract virCgroupV1MakeGroup

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1PathOfController
Pavel Hrdina [Sun, 19 Aug 2018 17:24:58 +0000 (19:24 +0200)]
vircgroup: extract virCgroupV1PathOfController

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1GetAnyController
Pavel Hrdina [Sun, 19 Aug 2018 17:20:25 +0000 (19:20 +0200)]
vircgroup: extract virCgroupV1GetAnyController

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1HasController
Pavel Hrdina [Sun, 19 Aug 2018 17:17:27 +0000 (19:17 +0200)]
vircgroup: extract virCgroupV1HasController

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1DetectControllers
Pavel Hrdina [Mon, 24 Sep 2018 23:12:22 +0000 (01:12 +0200)]
vircgroup: extract virCgroupV1DetectControllers

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1StealPlacement
Pavel Hrdina [Fri, 17 Aug 2018 10:00:29 +0000 (12:00 +0200)]
vircgroup: extract virCgroupV1StealPlacement

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1ValidatePlacement
Pavel Hrdina [Fri, 24 Aug 2018 13:15:23 +0000 (15:15 +0200)]
vircgroup: extract virCgroupV1ValidatePlacement

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1CopyPlacement
Pavel Hrdina [Fri, 14 Sep 2018 10:53:47 +0000 (12:53 +0200)]
vircgroup: extract virCgroupV1CopyPlacement

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract v1 detect functions
Pavel Hrdina [Fri, 14 Sep 2018 10:51:27 +0000 (12:51 +0200)]
vircgroup: extract v1 detect functions

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1CopyMounts
Pavel Hrdina [Fri, 17 Aug 2018 07:46:10 +0000 (09:46 +0200)]
vircgroup: extract virCgroupV1CopyMounts

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1ValidateMachineGroup
Pavel Hrdina [Fri, 14 Sep 2018 11:21:19 +0000 (13:21 +0200)]
vircgroup: extract virCgroupV1ValidateMachineGroup

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: detect available backend for cgroup
Pavel Hrdina [Wed, 12 Sep 2018 11:47:21 +0000 (13:47 +0200)]
vircgroup: detect available backend for cgroup

We need to update one test-case because now new cgroup object will be
created only if there is any cgroup backend available.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: extract virCgroupV1Available
Pavel Hrdina [Thu, 13 Sep 2018 14:27:56 +0000 (16:27 +0200)]
vircgroup: extract virCgroupV1Available

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: introduce cgroup v1 backend files
Pavel Hrdina [Fri, 17 Aug 2018 08:19:59 +0000 (10:19 +0200)]
vircgroup: introduce cgroup v1 backend files

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agoutil: introduce vircgroupbackend files
Pavel Hrdina [Wed, 15 Aug 2018 11:10:24 +0000 (13:10 +0200)]
util: introduce vircgroupbackend files

We will need to extract current cgroup v1 implementation into separate
backend because there will be new cgroup v2 implementation and both will
have to co-exist.

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgrouptest: call virCgroupNewSelf instead virCgroupDetectMounts
Pavel Hrdina [Fri, 14 Sep 2018 11:17:07 +0000 (13:17 +0200)]
vircgrouptest: call virCgroupNewSelf instead virCgroupDetectMounts

This will be required once cgroup v2 is introduced.  The cgroup
detection is not simple and we will have multiple backends so we
should not just jump into the middle of the detection code.

In order to use virCgroupNewSelf we need to create all the remaining
data files:

    - {name}.cgroups represents /proc/cgroups, it is a list of cgroup
      controllers compiled into kernel

    - {name}.self.cgroup represents /proc/self/cgroup, it describes
      cgroups to which the process belongs

For "no-cgroups" we need to modify the expected behavior because
virCgroupNewSelf() will fail if there are no controllers available.

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgrouptest: call virCgroupDetectMounts directly
Pavel Hrdina [Fri, 14 Sep 2018 10:38:54 +0000 (12:38 +0200)]
vircgrouptest: call virCgroupDetectMounts directly

Because we can set which files to return for cgroup tests there
is no need to have special function tailored to run tests.

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroupmock: rewrite cgroup fopen mocking
Pavel Hrdina [Mon, 24 Sep 2018 15:17:00 +0000 (17:17 +0200)]
vircgroupmock: rewrite cgroup fopen mocking

Move all the cgroup data into separate files out of vircgroupmock.c
and rework the fopen function to load data from files.  This will
make it easier to add more test cases.

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroupmock: cleanup unused cgroup files
Pavel Hrdina [Sun, 19 Aug 2018 09:43:38 +0000 (11:43 +0200)]
vircgroupmock: cleanup unused cgroup files

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: introduce virCgroupAddThread
Pavel Hrdina [Mon, 24 Sep 2018 22:54:04 +0000 (00:54 +0200)]
vircgroup: introduce virCgroupAddThread

Once we introduce cgroup v2 support we need to handle processes and
threads differently.

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: introduce virCgroupTaskFlags
Pavel Hrdina [Tue, 11 Sep 2018 13:06:29 +0000 (15:06 +0200)]
vircgroup: introduce virCgroupTaskFlags

Use flags in virCgroupAddTaskInternal instead of boolean parameter.
Following patch will add new flag to indicate thread instead of process.

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: rename virCgroupAdd.*Task to virCgroupAdd.*Process
Pavel Hrdina [Tue, 11 Sep 2018 13:03:22 +0000 (15:03 +0200)]
vircgroup: rename virCgroupAdd.*Task to virCgroupAdd.*Process

In cgroup v2 we need to handle processes and threads differently,
following patch will introduce virCgroupAddThread.

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: fix bug in virCgroupEnableMissingControllers
Pavel Hrdina [Mon, 10 Sep 2018 13:43:42 +0000 (15:43 +0200)]
vircgroup: fix bug in virCgroupEnableMissingControllers

If we are on host with systemd we need to build cgroup hierarchy
ourselves for controllers that are not managed by systemd.

As a starting parent we need to force root group because
virCgroupMakeGroup() takes that parent in order to inherit values
for cpuset controller.

By default cpuset controller is managed by systemd so we will never
hit the issue but for v2 cgroups we need to use parent cgroup every
time.

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: cleanup controllers not managed by systemd on error
Pavel Hrdina [Mon, 10 Sep 2018 12:46:24 +0000 (14:46 +0200)]
vircgroup: cleanup controllers not managed by systemd on error

If virCgroupEnableMissingControllers() fails it could have already
created some directories, we should clean it up as well.

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agolibxl: prefer new location of nested_hvm in libxl_domain_build_info
Marek Marczykowski-Górecki [Wed, 19 Sep 2018 00:50:32 +0000 (02:50 +0200)]
libxl: prefer new location of nested_hvm in libxl_domain_build_info

If available, use b_info->nested_hvm instead of
b_info->u.hvm.nested_hvm. This will make nested HVM config available
also for PVH domains.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
6 years agolibxl: set shadow memory for any guest type, not only HVM
Marek Marczykowski-Górecki [Wed, 19 Sep 2018 00:50:31 +0000 (02:50 +0200)]
libxl: set shadow memory for any guest type, not only HVM

Otherwise starting PVH guest will result in "arch_setup_bootlate:
mapping shared_info failed (pfn=..., rc=-1, errno: 12): Internal error".

After this change the behavior is the same as in `xl`.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
6 years agodocs: add documentation of arch element of capabilities.xml
Marek Marczykowski-Górecki [Wed, 19 Sep 2018 00:50:30 +0000 (02:50 +0200)]
docs: add documentation of arch element of capabilities.xml

Specifically, list sub-elements and where they can be used. In addition,
describe supported machine types for Xen.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
6 years agolxc: Resolve memory leak
John Ferlan [Thu, 20 Sep 2018 20:50:37 +0000 (16:50 -0400)]
lxc: Resolve memory leak

Commit 40b5c99a modified the virConfGetValue callers to use
virConfGetValueString. However, using the virConfGetValueString
resulted in leaking the returned @value string in each case.
So, let's modify each instance to use the VIR_AUTOFREE(char *)
syntax. In some instances changing the variable name since
@value was used more than once.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agolxc: Remove unnecessary error label
John Ferlan [Fri, 21 Sep 2018 11:26:00 +0000 (07:26 -0400)]
lxc: Remove unnecessary error label

Since lxcConvertSize already creates an error message, there
is no need to use an error: label in lxcSetMemTune to just
overwrite or essentially rewrite the same error. So remove
the label.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agotests: Resolve possible overrun
John Ferlan [Thu, 20 Sep 2018 21:34:38 +0000 (17:34 -0400)]
tests: Resolve possible overrun

Coverity noted that each of the fmemopen called used the strlen value
in order to allocate space, but that neglected space for terminating
null string. So just add 1 to the strlen.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoconf: Alter when ctxt->node is set
John Ferlan [Thu, 20 Sep 2018 21:34:36 +0000 (17:34 -0400)]
conf: Alter when ctxt->node is set

In virDomainMemoryDefParseXML and virDomainVideoDefParseXML if
the VIR_ALLOC fails and NULL is returned, then the alteration
to ctxt->node isn't reversed.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agotools: Fix printf format
Michal Privoznik [Mon, 24 Sep 2018 08:45:44 +0000 (10:45 +0200)]
tools: Fix printf format

We're passing size_t but using format for unsigned long.
Introduced in latest vshTable rework patches.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agobuild-aux:check-spacing: Introduce a new rule to check misaligned stuff in parenthesises
Shi Lei [Wed, 19 Sep 2018 08:38:19 +0000 (16:38 +0800)]
build-aux:check-spacing: Introduce a new rule to check misaligned stuff in parenthesises

This patch introduces a new rule to check misaligned stuff in parenthesis:
1. For misaligned arguments of function
2. For misaligned conditions of [if|while|switch|...]

There're too much misalignment, so it adds a temporary filter which
permits 'src/util' now. It _should_ be removed as soon as fixing all.

Signed-off-by: Shi Lei <shi_lei@massclouds.com>
6 years agobuild-aux:check-spacing: Add wrapper function of CheckCurlyBrackets
Shi Lei [Wed, 19 Sep 2018 08:38:18 +0000 (16:38 +0800)]
build-aux:check-spacing: Add wrapper function of CheckCurlyBrackets

This patch adds CheckCurlyBrackets to simplify check-spacing.

Signed-off-by: Shi Lei <shi_lei@massclouds.com>
6 years agobuild-aux:check-spacing: Add wrapper function of CheckWhiteSpaces
Shi Lei [Wed, 19 Sep 2018 08:38:17 +0000 (16:38 +0800)]
build-aux:check-spacing: Add wrapper function of CheckWhiteSpaces

This patch adds CheckWhiteSpaces to simplify check-spacing.

Signed-off-by: Shi Lei <shi_lei@massclouds.com>
6 years agobuild-aux:check-spacing: Add wrapper function of KillComments
Shi Lei [Wed, 19 Sep 2018 08:38:16 +0000 (16:38 +0800)]
build-aux:check-spacing: Add wrapper function of KillComments

This patch adds KillComments to simplifies check-spacing.

Signed-off-by: Shi Lei <shi_lei@massclouds.com>
6 years agobuild-aux:check-spacing: Add wrapper function of CheckFunctionBody
Shi Lei [Wed, 19 Sep 2018 08:38:15 +0000 (16:38 +0800)]
build-aux:check-spacing: Add wrapper function of CheckFunctionBody

This patch adds CheckFunctionBody to simplifies check-spacing.

Signed-off-by: Shi Lei <shi_lei@massclouds.com>
6 years agoutil: Fix misaligned arguments and misaligned conditions for [if|while|...]
Shi Lei [Wed, 19 Sep 2018 08:38:14 +0000 (16:38 +0800)]
util: Fix misaligned arguments and misaligned conditions for [if|while|...]

This patch just fixes misaligned arguments and misaligned conditions
of src/util/*.c.

Signed-off-by: Shi Lei <shi_lei@massclouds.com>
6 years agovirt-admin: Implement vshTable API to server-list and client-list
Simon Kobyda [Fri, 21 Sep 2018 14:17:24 +0000 (16:17 +0200)]
virt-admin: Implement vshTable API to server-list and client-list

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
6 years agovirsh: Implement vshTable API to vol-list
Simon Kobyda [Fri, 21 Sep 2018 14:17:23 +0000 (16:17 +0200)]
virsh: Implement vshTable API to vol-list

Local lengthy unicode-unreliable table formatting was replaced by new
API. Great example of how new API saves space and time.
Removed a lot of string lenght calculation used by the local table.

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
6 years agovirsh: Implement vshTable API to pool-list
Simon Kobyda [Fri, 21 Sep 2018 14:17:22 +0000 (16:17 +0200)]
virsh: Implement vshTable API to pool-list

Local lengthy unicode-unreliable table formatting was replaced by new
API. Great example of how new API saves space and time.
Removed a lot of string lenght canculation used by the local table.

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
6 years agovirsh: Implement vshTable API to vcpupin, iothreadinfo, domfsinfo
Simon Kobyda [Fri, 21 Sep 2018 14:17:21 +0000 (16:17 +0200)]
virsh: Implement vshTable API to vcpupin, iothreadinfo, domfsinfo

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
6 years agovirsh: Implement vshTable API to domiflist
Simon Kobyda [Fri, 21 Sep 2018 14:17:20 +0000 (16:17 +0200)]
virsh: Implement vshTable API to domiflist

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
6 years agovirsh: Implement vshTable API to domblklist
Simon Kobyda [Fri, 21 Sep 2018 14:17:19 +0000 (16:17 +0200)]
virsh: Implement vshTable API to domblklist

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
6 years agovirsh: Implement vshTable API to domblkinfo
Simon Kobyda [Fri, 21 Sep 2018 14:17:18 +0000 (16:17 +0200)]
virsh: Implement vshTable API to domblkinfo

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
6 years agovirsh: Set up cmdDomblkinfo() and cmdDomblkinfoPrint() for vshTable API implementation
Simon Kobyda [Fri, 21 Sep 2018 14:17:17 +0000 (16:17 +0200)]
virsh: Set up cmdDomblkinfo() and cmdDomblkinfoPrint() for vshTable API implementation

I've moved all the printing from cmdDomblkinfoPrint() to cmdDomblkinfo(),
and renamed the cmdDomblkinfoPrint() to cmdDomblkinfoGet(), since nature of
that function changed from gathering and printing informations only to
gathering information. This I believe simplifies the functions and
makes the implementation of vshTable API simpler.

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
6 years agovirsh: Implement vshTable API to snapshot-list.
Simon Kobyda [Fri, 21 Sep 2018 14:17:16 +0000 (16:17 +0200)]
virsh: Implement vshTable API to snapshot-list.

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
6 years agovirsh: Implement vshTable API to nwfilter-list and nwfilterbinding-list
Simon Kobyda [Fri, 21 Sep 2018 14:17:15 +0000 (16:17 +0200)]
virsh: Implement vshTable API to nwfilter-list and nwfilterbinding-list

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
6 years agovirsh: Implement vshTable API to secret-list
Simon Kobyda [Fri, 21 Sep 2018 14:17:14 +0000 (16:17 +0200)]
virsh: Implement vshTable API to secret-list

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
6 years agovirsh: Implement vshTable API to net-list and net-dhcp-leases
Simon Kobyda [Fri, 21 Sep 2018 14:17:13 +0000 (16:17 +0200)]
virsh: Implement vshTable API to net-list and net-dhcp-leases

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
6 years agovirsh: Implement vsh-table to iface-list
Simon Kobyda [Fri, 21 Sep 2018 14:17:12 +0000 (16:17 +0200)]
virsh: Implement vsh-table to iface-list

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
6 years agoqemu: Update hostdevs device lists before connecting qemu monitor
Wu Zongyong [Fri, 21 Sep 2018 02:33:53 +0000 (10:33 +0800)]
qemu: Update hostdevs device lists before connecting qemu monitor

In a following case:

    virsh start $domain
    service libvirtd stop
    <shutdown> the guest from within the $domain
    service libvirtd start

Notice that PCI devices which have been assigned to the $domain will
still be bound to stub drivers instead rebound to host drivers.
In that case the call stack is like below:

    libvirtd start
        qemuProcessReconnect
            qemuProcessStop (because $domain was shutdown without
                             libvirtd event to process that)
                qemuHostdevReAttachDomainDevices
                    qemuHostdevReAttachPCIDevices
                        virHostdevReAttachPCIDevices

However, because qemuHostdevUpdateActiveDomainDevices was called
after the qemuConnectMonitor, the setup of the tracking of each
host device in the $domain on either the activePCIHostdevs list
or inactivePCIHostdev list will not occur in an orderly manner.
Therefore, virHostdevReAttachPCIDevices just neglects these host PCI
devices which are bound to stub drivers and doesn't rebind them to
host drivers.

This patch fixs that by moving qemuHostdevUpdateActiveDomainDevices before
qemuConnectMonitor during libvirtd reconnection processing.

Signed-off-by: Wu Zongyong <cordius.wu@huawei.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Fix deadlock if create qemuProcessReconnect thread failed
Wang Yechao [Fri, 21 Sep 2018 04:35:11 +0000 (12:35 +0800)]
qemu: Fix deadlock if create qemuProcessReconnect thread failed

Use the new qemuDomainRemoveInactiveJobLocked to remove the
@obj during the virDomainObjListForEach call which holds a
lock on the domain object list.

Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Introduce qemuDomainRemoveInactiveJobLocked
Wang Yechao [Fri, 21 Sep 2018 04:35:09 +0000 (12:35 +0800)]
qemu: Introduce qemuDomainRemoveInactiveJobLocked

Create a qemuDomainRemoveInactiveJobLocked which copies
qemuDomainRemoveInactiveJob except of course calling
another new helper qemuDomainRemoveInactiveLocked.

The qemuDomainRemoveInactiveLocked is a copy of
qemuDomainRemoveInactive except that instead of calling
virDomainObjListRemove it calls virDomainObjListRemoveLocked.

Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Split up qemuDomainRemoveInactive
Wang Yechao [Fri, 21 Sep 2018 04:35:08 +0000 (12:35 +0800)]
qemu: Split up qemuDomainRemoveInactive

Introduce qemuDomainRemoveInactiveJobCommon to handle what will
be the common parts of the code with a new function that will
be used to call virDomainObjListRemoveLocked instead of the
unlocked variant.

Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Drop QEMU_CAPS_DEVICE_SCSI_GENERIC
Andrea Bolognani [Tue, 18 Sep 2018 10:29:10 +0000 (12:29 +0200)]
qemu: Drop QEMU_CAPS_DEVICE_SCSI_GENERIC

It was already available in 1.5.0, so we can assume it's
present and avoid checking for it at runtime.

This commit is best viewed with 'git show -w'.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>