1. 12 8月, 2017 3 次提交
    • L
      util: make virPCIGetNetName() more versatile · b3b5aa75
      Laine Stump 提交于
      A single PCI device may have multiple netdevs associated with it. Each
      of those netdevs will have a different phys_port_id entry in
      sysfs. This patch modifies virPCIGetNetName() to allow selecting one
      of the potential many netdevs in two different ways:
      
      1) by setting the "idx" argument, the caller can select the 1st (0),
      2nd (1), etc. netdev from the PCI device's net subdirectory.
      
      2) If the physPortID arg is set (to a null-terminated string) then
      virPCIGetNetName() returns the netdev that has that phys_port_id in
      the sysfs file of the same name in the netdev's directory.
      b3b5aa75
    • L
      util: Fix const'ness of 1st arg to virPCIGetNetName() · 0dc67e6d
      Laine Stump 提交于
      The first arg isn't modified in the function, so it should be const.
      0dc67e6d
    • L
      util: new function virNetDevGetPhysPortID() · 48f33bb5
      Laine Stump 提交于
      On Linux each network device *can* (but not necessarily *does*) have
      an attribute called phys_port_id which can be read from the file of
      that name in the netdev's sysfs directory. The examples I've seen have
      been a many-digit hexadecimal number (as an ASCII string).
      
      This value can be useful when a single PCI device is associated with
      multiple netdevs (e.g a dual port Mellanox SR-IOV NIC - this card has
      a single PCI Physical Function (PF), and that PF has two netdevs
      associated with it (the "net" subdirectory of the PF in sysfs has two
      links rather than the usual single link to a netdev directory). Each
      of the PF netdevs has a different phys_port_id. The Virtual Functions
      (VF) are similar - the PF (a PCI device) has "n" VFs (also each of
      these is a PCI device), each VF has two netdevs, and each of the VF
      netdevs points back to the VF PCI device (with the "device" entry in
      its sysfs directory) as well as having a phys_port_id matching the PF
      netdev it is associated with.
      
      virNetDevGetPhysPortID() simply attempts to read the phys_port_id for
      the given netdev and return it to the caller. If this particular
      netdev driver doesn't support phys_port_id, it returns NULL (*not* a
      NULL-terminated string, but a NULL pointer) but still counts it as a
      success.
      48f33bb5
  2. 10 8月, 2017 3 次提交
  3. 08 8月, 2017 4 次提交
  4. 07 8月, 2017 5 次提交
  5. 06 8月, 2017 1 次提交
  6. 04 8月, 2017 2 次提交
  7. 03 8月, 2017 7 次提交
  8. 02 8月, 2017 14 次提交
  9. 01 8月, 2017 1 次提交
    • M
      virNetDaemonCallInhibit: Call virNetDaemonGotInhibitReply properly · ace45e67
      Michal Privoznik 提交于
      So there are couple of issues here. Firstly, we never unref the
      @pendingReply and thus it leaks.
      
      ==13279== 144 (72 direct, 72 indirect) bytes in 1 blocks are definitely lost in loss record 1,095 of 1,259
      ==13279==    at 0x4C2E080: calloc (vg_replace_malloc.c:711)
      ==13279==    by 0x781FA97: _dbus_pending_call_new_unlocked (in /usr/lib64/libdbus-1.so.3.14.11)
      ==13279==    by 0x7812A4C: dbus_connection_send_with_reply (in /usr/lib64/libdbus-1.so.3.14.11)
      ==13279==    by 0x56BEDF3: virNetDaemonCallInhibit (virnetdaemon.c:514)
      ==13279==    by 0x56BEF18: virNetDaemonAddShutdownInhibition (virnetdaemon.c:536)
      ==13279==    by 0x12473B: daemonInhibitCallback (libvirtd.c:742)
      ==13279==    by 0x1249BD: daemonRunStateInit (libvirtd.c:823)
      ==13279==    by 0x554FBCF: virThreadHelper (virthread.c:206)
      ==13279==    by 0x8F913D3: start_thread (in /lib64/libpthread-2.23.so)
      ==13279==    by 0x928DE3C: clone (in /lib64/libc-2.23.so)
      
      Secondly, while we send the message, we are suspended ('cos we're
      talking to a UNIX socket).  However, until we are resumed back
      again the reply might have came therefore subsequent
      dbus_pending_call_set_notify() has no effect and in fact the
      virNetDaemonGotInhibitReply() callback is never called. Thirdly,
      the dbus_connection_send_with_reply() has really stupid policy
      for return values. To cite the man page:
      
        Returns
            FALSE if no memory, TRUE otherwise.
      
      Yes, that's right. If anything goes wrong and it's not case of
      OOM then TRUE is returned, i.e. you're trying to pass FDs and
      it's not supported, or you're not connected, or anything else.
      Therefore, checking for return value of
      dbus_connection_send_with_reply() is not enoguh. We also have to
      check if @pendingReply is not NULL before proceeding any further.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      ace45e67