1. 25 9月, 2018 2 次提交
    • M
      lxc_monitor: Avoid AB / BA lock race · 7882c6ec
      Mark Asselstine 提交于
      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: NMark Asselstine <mark.asselstine@windriver.com>
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      7882c6ec
    • P
      vircgroup: rename virCgroupAdd.*Task to virCgroupAdd.*Process · 0772c346
      Pavel Hrdina 提交于
      In cgroup v2 we need to handle processes and threads differently,
      following patch will introduce virCgroupAddThread.
      Reviewed-by: NFabiano Fidêncio <fidencio@redhat.com>
      Reviewed-by: NJán Tomko <jtomko@redhat.com>
      Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
      0772c346
  2. 24 9月, 2018 2 次提交
  3. 20 9月, 2018 2 次提交
  4. 18 9月, 2018 1 次提交
    • M
      security_manager: Load lock plugin on init · 3e26b476
      Michal Privoznik 提交于
      Now that we know what metadata lock manager user wishes to use we
      can load it when initializing security driver. This is achieved
      by adding new argument to virSecurityManagerNewDriver() and
      subsequently to all functions that end up calling it.
      
      The cfg.mk change is needed in order to allow lock_manager.h
      inclusion in security driver without 'syntax-check' complaining.
      This is safe thing to do as locking APIs will always exist (it's
      only backend implementation that changes). However, instead of
      allowing the include for all other drivers (like cpu, network,
      and so on) allow it only for security driver. This will still
      trigger the error if including from other drivers.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
      3e26b476
  5. 13 8月, 2018 1 次提交
  6. 30 7月, 2018 1 次提交
  7. 27 7月, 2018 4 次提交
  8. 26 7月, 2018 5 次提交
  9. 23 7月, 2018 1 次提交
    • A
      src: Make virStr*cpy*() functions return an int · 6c0d0210
      Andrea Bolognani 提交于
      Currently, the functions return a pointer to the
      destination buffer on success or NULL on failure.
      
      Not only does this kind of error handling look quite
      alien in the context of libvirt, where most functions
      return zero on success and a negative int on failure,
      but it's also somewhat pointless because unless there's
      been a failure the returned pointer will be the same
      one passed in by the user, thus offering no additional
      value.
      
      Change the functions so that they return an int
      instead.
      Signed-off-by: NAndrea Bolognani <abologna@redhat.com>
      6c0d0210
  10. 03 7月, 2018 3 次提交
  11. 27 6月, 2018 4 次提交
  12. 12 6月, 2018 1 次提交
  13. 06 6月, 2018 1 次提交
  14. 05 6月, 2018 1 次提交
  15. 14 5月, 2018 1 次提交
  16. 04 5月, 2018 4 次提交
  17. 23 4月, 2018 2 次提交
  18. 18 4月, 2018 1 次提交
    • M
      virobject: Introduce VIR_CLASS_NEW() macro · 10f94828
      Michal Privoznik 提交于
      So far we are repeating the following lines over and over:
      
        if (!(virSomeObjectClass = virClassNew(virClassForObject(),
                                   "virSomeObject",
                                   sizeof(virSomeObject),
                                   virSomeObjectDispose)))
            return -1;
      
      While this works, it is impossible to do some checking. Firstly,
      the class name (the 2nd argument) doesn't match the name in the
      code in all cases (the 3rd argument). Secondly, the current style
      is needlessly verbose. This commit turns example into following:
      
        if (!(VIR_CLASS_NEW(virSomeObject,
                            virClassForObject)))
            return -1;
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
      10f94828
  19. 17 4月, 2018 1 次提交
  20. 12 4月, 2018 2 次提交