1. 17 8月, 2017 9 次提交
  2. 16 8月, 2017 2 次提交
    • M
      libvirtd.conf: Drop max_requests · 733359a6
      Michal Privoznik 提交于
      Since its introduction in f6134117 it was never
      implemented nor there are plans to implement it. Drop it.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      733359a6
    • J
      qemu: Fix bug assuming usage of default UUID for certificate passphrase · fdab78b5
      John Ferlan 提交于
      If an environment specific _tls_x509_cert_dir is provided, then
      do not VIR_STRDUP the defaultTLSx509secretUUID as that would be
      for the "default" environment and not the vnc, spice, chardev, or
      migrate environments. If the environment needs a secret to decode
      it's certificate, then it must provide the secret. If the secrets
      happen to be the same, then configuration would use the same UUID
      as the default (but we cannot assume that nor can we assume that
      the secret would be necessary).
      fdab78b5
  3. 15 8月, 2017 10 次提交
    • J
      util: Add object checking for virObject{Ref|Unref} · d3e17259
      John Ferlan 提交于
      Rather than assuming that what's passed to virObject{Ref|Unref}
      would be a virObjectPtr as long as it's not NULL, let's do the
      similar checks virObjectIsClass in order to prevent a possible
      increment or decrement to some field at the obj->u.s.refs offset.
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      d3e17259
    • J
      util: Add magic number check for object validity · dfa0efbb
      John Ferlan 提交于
      The virObjectIsClass API has only ever checked object validity
      based on if the @obj is not NULL and it was derived from some class.
      While this has worked well in general, there is one additional
      check that could be made prior to calling virClassIsDerivedFrom
      which loops through the classes checking the magic number against
      the klass expected magic number.
      
      If by chance a non virObject is passed, rather than assuming the
      void * @obj is a _virObject and thus offsetting to obj->klass,
      obj->magic, and obj->parent, let's check that the void * @obj
      has at least the "base part" of the magic number in the right
      place and generate a more specific VIR_WARN message if not.
      
      There are many consumers to virObjectIsClass, include the locking
      primitives virObject{Lock|Unlock}, virObjectRWLock{Read|Write},
      and virObjectRWUnlock. For those callers, the locking call will
      not fail, but it also will not attempt a virMutex* call which
      will "most likely" fail since the &obj->lock is used.
      
      In order to avoid some possible future wrap on the 0xCAFExxxx
      value, add a check during initialization that some new class
      won't cause the wrap. Should be good for a few years at least!
      
      It is still left up to the caller to handle the failed API calls
      just as it would be if it passed a NULL opaque pointer anyobj.
      dfa0efbb
    • J
      util: Create common error path for invalid object · 19f43952
      John Ferlan 提交于
      If virObjectIsClass fails "internally" to virobject.c, create a
      macro to generate the VIR_WARN describing what the problem is.
      Also improve the checks and message a bit to indicate which was
      the failure - whether the obj was NULL or just not the right class
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      19f43952
    • J
      util: Introduce and use virObjectRWUnlock · 045d712c
      John Ferlan 提交于
      Rather than overload virObjectUnlock as commit id '77f4593b' has
      done, create a separate virObjectRWUnlock API that will force the
      consumers to make the proper decision regarding unlocking the
      RWLock's. Similar to the RWLockRead and RWLockWrite, use the
      virObjectGetRWLockableObj helper. This restores the virObjectUnlock
      code to using the virObjectGetLockableObj.
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      045d712c
    • J
      util: Introduce virObjectGetRWLockableObj · bf09f002
      John Ferlan 提交于
      Introduce a helper to handle the error path more cleanly. The same
      as virObjectGetLockableObj in order to essentially follow the original
      logic of commit 'b545f65d' to ensure that the input argument at least
      has some validity before using.
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      bf09f002
    • J
      util: Only have virObjectLock handle virObjectLockable · 8b03a609
      John Ferlan 提交于
      Now that virObjectRWLockWrite exists to handle the virObjectRWLockable
      objects, let's restore virObjectLock to only handle virObjectLockable
      class locks. There still exists the possibility that the input @anyobj
      isn't a valid object and the resource isn't truly locked, but that
      also exists before commit id '77f4593b'.
      
      This also restores some logic that commit id '77f4593b' removed
      with respect to a common code path that commit id '10c2bb2b' had
      introduced as virObjectGetLockableObj. This code path merely does
      the same checks as the original virObjectLock commit 'b545f65d',
      but in callable/reusable helper to ensure the @obj at least has
      some validity before using.
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      8b03a609
    • J
      util: Introduce and use virObjectRWLockWrite · 908b3364
      John Ferlan 提交于
      Instead of making virObjectLock be the entry point for two
      different types of locks, let's create a virObjectRWLockWrite API
      which will only handle the virObjectRWLockableClass objects.
      
      Use the new virObjectRWLockWrite for the virdomainobjlist code
      in order to handle the Add, Remove, Rename, and Load operations
      that need to be very synchronous.
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      908b3364
    • J
      util: Rename virObjectLockRead to virObjectRWLockRead · 99a72b3e
      John Ferlan 提交于
      Since the class it represents is based on virObjectRWLockableClass
      and in order to make sure we differentiate just in case anyone somehow
      believes they could use virObjectLockRead for a virObjectLockableClass,
      let's rename the API to use the RW in the name. Besides the RW locks
      refer to pthread_rwlock_{init|rdlock|wrlock|unlock|destroy} while the
      other locks refer to pthread_mutex_{init|lock|unlock|destroy}.
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      99a72b3e
    • P
      qemu: fix nwfilter deadlock in qemuProcessReconnect · 40cc355c
      Pavel Hrdina 提交于
      The correct lock order is:
      
        nwfilter driver lock (not used in this code path)
        nwfilter update lock
        virt driver lock (not used in this code path)
        domain object lock
      
      but the current code have this order:
      
        domain object lock
        nwfilter update lock
      Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
      40cc355c
    • P
      qemu: fix nwfilter deadlock while reverting to snapshot · 231c7104
      Pavel Hrdina 提交于
      Introduced by commit <41127244>.
      Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
      231c7104
  4. 14 8月, 2017 16 次提交
  5. 12 8月, 2017 3 次提交
    • L
      util: check for PF online status earlier in guest startup · 489a937e
      Laine Stump 提交于
      When using a VF from an SRIOV-capable network card in a guest (either
      in macvtap passthrough mode, or via VFIO PCI device assignment), The
      associated PF netdev must be online in order for the VF to be usable
      by the guest. The guest, however, is not able to change the state of
      the PF. And libvirt *could* set the PF online as needed, but that
      could lead to the host receiving unexpected IPv6 traffic (since the
      default for an unconfigured interface is to participate in IPv6
      autoconf). For this reason, before assigning a VF to a guest, libvirt
      verifies that the related PF netdev is online - if it isn't, then we
      log an error and don't allow the guest startup to continue.
      
      Until now, this check was done during virNetDevSetNetConfig(). This
      works nicely because the same function is called both for macvtap
      passthrough and for VFIO device assignment. But in the case of VFIO,
      the VF has already been unbound from its netdev driver by the time we
      get to virNetDevSetNetConfig(), and in the case of dual port Mellanox
      NICs that have their VFs setup in single port mode, the *only* way to
      determine the proper PF netdev to query for online status is via the
      "phys_port_id" file that is in the VF netdev's sysfs directory. *BUT*
      if we've unbound the VF from the netdev driver, then it doesn't *have*
      a netdev sysfs directory.
      
      So, in order to check the correct PF netdev for online status, this
      patch moved the check earlier in the setup, into
      virNetDevSaveNetConfig(), which is called *before* unbinding the VF
      from its netdev driver.
      
      (Note that this implies that if you are using VFIO device assignment
      for the VFs of a Mellanox NIC that has the VFs programmed in single
      port mode, you must let the VFs be bound to their net driver and use
      "managed='yes'" in the device definition. To be more specific, this is
      only true if the VFs in single port mode are using port *2* of the PF
      - if the VFs are using only port 1, then the correct PF netdev will be
      arrived at by default/chance))
      
        This resolves: https://bugzilla.redhat.com/267191
      489a937e
    • L
      util: restructure virNetDevReadNetConfig() to eliminate false error logs · 9a081683
      Laine Stump 提交于
      virHostdevRestoreNetConfig() calls virNetDevReadNetConfig() to try and
      read the "original config" of a netdev, and if that fails, it tries
      again with a different directory/netdev name. This achieves the
      desired effect (we end up finding the config wherever it may be), but
      for each failure, virNetDevReadNetConfig() places a nice error message
      in the system logs. Experience has shown that false-positive error
      logs like this lead to erroneous bug reports, and can often mislead
      those searching for *real* bugs.
      
      This patch changes virNetDevReadNetConfig() to explicitly check if the
      file exists before calling virFileReadAll(); if it doesn't exist,
      virNetDevReadNetConfig() returns a success, but leaves all the
      variables holding the results as NULL. (This makes sense if you define
      the purpose of the function as "read a netdev's config from its config
      file *if that file exists*).
      
      To take advantage of that change, the caller,
      virHostdevRestoreNetConfig() is modified to fail immediately if
      virNetDevReadNetConfig() returns an error, and otherwise to try the
      different directory/netdev name if adminMAC & vlan & MAC are all NULL
      after the preceding attempt.
      9a081683
    • L
      util: save the correct VF's info when using a dual port SRIOV NIC in single port mode · b67eaa63
      Laine Stump 提交于
      Mellanox ConnectX-3 dual port SRIOV NICs present a bit of a challenge
      when assigning one of their VFs to a guest using VFIO device
      assignment.
      
      These NICs have only a single PCI PF device, and that single PF has
      two netdevs sharing the single PCI address - one for port 1 and one
      for port 2. When a VF is created it can also have 2 netdevs, or it can
      be setup in "single port" mode, where the VF has only a single netdev,
      and that netdev is connected either to port 1 or to port 2.
      
      When the VF is created in dual port mode, you get/set the MAC
      address/vlan tag for the port 1 VF by sending a netlink message to the
      PF's port1 netdev, and you get/set the MAC address/vlan tag for the
      port 2 VF by sending a netlink message to the PF's port 2 netdev. (Of
      course libvirt doesn't have any way to describe MAC/vlan info for 2
      ports in a single hostdev interface, so that's a bit of a moot point)
      
      When the VF is created in single port mode, you can *set* the MAC/vlan
      info by sending a netlink message to *either* PF netdev - the driver
      is smart enough to understand that there's only a single netdev, and
      set the MAC/vlan for that netdev. When you want to *get* it, however,
      the driver is more accurate - it will return 00:00:00:00:00:00 for the
      MAC if you request it from the port 1 PF netdev when the VF was
      configured to be single port on port 2, or if you request if from the
      port 2 PF netdev when the VF was configured to be single port on port
      1.
      
      Based on this information, when *getting* the MAC/vlan info (to save
      the original setting prior to assignment), we determine the correct PF
      netdev by matching phys_port_id between VF and PF.
      
      (IMPORTANT NOTE: this implies that to do PCI device assignment of the
      VFs on dual port Mellanox cards using <interface type='hostdev'>
      (i.e. if you want the MAC address/vlan tag to be set), not only must
      the VFs be configured in single port mode, but also the VFs *must* be
      bound to the host VF net driver, and libvirt must use managed='yes')
      
      By the time libvirt is ready to set the new MAC/vlan tag, the VF has
      already been unbound from the host net driver and bound to
      vfio-pci. This isn't problematic though because, as stated earlier,
      when a VF is created in single port mode, commands to configure it can
      be sent to either the port 1 PF netdev or the port 2 PF netdev.
      
      When it is time to restore the original MAC/vlan tag, again the VF
      will *not* be bound to a host net driver, so it won't be possible to
      learn from sysfs whether to use the port 1 or port 2 PF netdev for the
      netlink commands. And again, it doesn't matter which netdev you
      use. However, we must keep in mind that we saved the original settings
      to a file called "${PF}_${VFNUM}". To solve this problem, we just
      check for the existence of ${PF1}_${VFNUM} and ${PF2}_${VFNUM}, and
      use whichever one we find (since we know that only one can be there)
      b67eaa63