1. 27 3月, 2017 17 次提交
    • L
      util: replace virHostdevNetConfigReplace with ...(Save|Set)NetConfig() · b684734b
      Laine Stump 提交于
      These two operations will need to be separated so that saving of the
      original config is done before detaching the host net driver, and
      setting the new config is done after attaching vfio-pci. This patch
      splits the single function into two, but for now calls them together
      (to make bisecting easier if there is a regression).
      b684734b
    • L
      util: use new virNetDev*NetConfig() functions for hostdev setup/teardown · 9c004d55
      Laine Stump 提交于
      virHostdevNetConfigReplace() and virHostdevNetConfigRestore() are
      modified to use the new virNetDev*NetConfig() functions.
      
      Note that due to the VF's original MAC addresses being saved after it
      has already been un-bound from the host net driver, the actual current
      VF MAC address won't be saved (because it no longer exists) - only the
      "admin MAC" will be saved. This reflects existing behavior that will
      be fixed in an upcoming patch.
      9c004d55
    • L
      util: use new virNetDev*NetConfig() functions for macvtap setup/teardown · b91a3363
      Laine Stump 提交于
      This patch modifies the macvtap passthrough setup to use
      virNetDevSaveNetConfig()+virNetDevSetConfig() instead of
      virNetDevReplaceNetConfig() or virNetDevReplaceMacAddress(), and the
      teardown to use virNetDevReadNetConfig()+virNetDevSetConfig() instead
      of virNetDevRestoreNetConfig() or virNetDevRestoreMacAddress().
      
      Since the older functions only saved/restored the admin MAC and vlan
      tag (which is incorrect) and the new functions save/restore the VF's
      own MAC address and vlan tag (correct), this actually fixes a bug
      (which was introduced by commit cb3fe38c, which was itself supposed
      to be a fix for https://bugzilla.redhat.com/1113474 ).
      
      The downside to this patch is that it causes an *apparent* regression
      in that bug (because there will once again be an error reported if the
      interface had previously been used for VFIO device assignment), but in
      reality, the code hasn't been working for *any* case before this
      current patch (at least not with any recent kernel). Anyway, that
      "regression" will be fixed with an upcoming patch that fixes it the
      *right* way.
      b91a3363
    • L
      util: new functions virNetDev(Save|Read|Set)NetConfig() · 26694daf
      Laine Stump 提交于
      These three functions are destined to replace
      virNetDev(Replace|Restore)NetConfig() and
      virNetDev(Replace|Restore)MacAddress(), which both do the save and set
      together as a single step. We need to separate the save, read, and set
      steps because there will be situations where we need to do something
      else in between (in particular, we will need to rebind a VF's driver
      after save but before set).
      
      This patch creates the new functions, but doesn't call them - that
      will come in a subsequent patch. Note that the new functions to
      read/write the file that stores the original network config now uses
      JSON rather than plaintext (it still recognizes the old format as well
      though, so it won't get confused during an upgrade).
      26694daf
    • E
      hostdev: Maintain a driver list of active mediated devices · a4a39d90
      Erik Skultety 提交于
      Keep track of the assigned mediated devices the same way we do it for
      the rest of hostdevs. Methods like 'Prepare', 'Update', and 'ReAttach'
      are introduced by this patch.
      Signed-off-by: NErik Skultety <eskultet@redhat.com>
      a4a39d90
    • E
      util: Introduce new module virmdev · e1ec4f88
      Erik Skultety 提交于
      Beside creation, disposal, getter, and setter methods the module exports
      methods to work with lists of mediated devices.
      Signed-off-by: NErik Skultety <eskultet@redhat.com>
      e1ec4f88
    • E
      util: fix build on RHEL 6 · 04419847
      Eric Blake 提交于
      We keep forgetting that older setups don't like 'index':
      
        CC     util/libvirt_util_la-virsysinfo.lo
      cc1: warnings being treated as errors
      util/virstoragefile.c: In function 'virStorageSourceFindByNodeName':
      util/virstoragefile.c:3804: error: declaration of 'index' shadows a global declaration [-Wshadow]
      /usr/include/string.h:489: error: shadowed declaration is here [-Wshadow]
      Signed-off-by: NEric Blake <eblake@redhat.com>
      04419847
    • M
      util: Fix naming in util/virnodesuspend · d2d1dec1
      Martin Kletzander 提交于
      That file has only two exported files and each one of them has
      different naming.  virNode is what all the other files use, so let's
      use it.  It wasn't used before because the clash with public API
      naming, so let's fix that by shortening the name (there is no other
      private variant of it anyway).
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      d2d1dec1
    • M
      Move src/fdstream to src/util/virfdstream · bdcb1995
      Martin Kletzander 提交于
      There is no reason for it not to be in the utils, all global symbols
      under that file already have prefix vir* and there is no reason for it
      to be part of DRIVER_SOURCES because that is just a leftover from
      older days (pre-driver modules era, I believe).
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      bdcb1995
    • M
      util: Adapt virhostcpu to the new virsysfs · c67e04e2
      Martin Kletzander 提交于
      While on that, drop support for kernels from RHEL-5 era (missing
      cpu/present file).  Also add some useful functions and export them.
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      c67e04e2
    • M
      util: Add virsysfs for handling sysfs files · a7b902c0
      Martin Kletzander 提交于
      By using this we are able to easily switch the sysfs path being
      used (fake it).  This will not only help tests in the future but can
      be also used from files where the code is duplicated currently.
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      a7b902c0
    • M
      virfile: Add helpers for reading simple values · 9fdd077d
      Martin Kletzander 提交于
      These helpers are doing just a read and covert the value, but they
      properly size the read limit, handle additional whitespace characters,
      and unify error reporting.
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      9fdd077d
    • M
      Fix build with GCC's static analysis · eec3b255
      Martin Kletzander 提交于
      STREQ_NULLABLE returns true if both parameters are NULL.  And that's
      not what we want here.  We just want to skop comparing source nodes
      that don't have that info set.  The function wouldn't make much sense
      with nodeName == NULL, so we don't need to check that.  Moreover, the
      function's declaration uses ATTRIBUDE_NONNULL for nodeName, which not
      only means that function expects the parameter not to be NULL, but
      actually tells the compiler that it can optimize out the NULL checks.
      That way it could end up calling strcmp on NULL (either nodeformat or
      nodebacking).  GCC figures this out if libvirt is compiled with
      lv_cv_static_analysis=yes, unfortunately not everyone uses that.
      
      Caused by cbc6d535.
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      eec3b255
    • P
      util: json: Make function to free JSON values in virHash universal · 86e51d68
      Peter Krempa 提交于
      Move the helper that frees JSON entries put into hash tables into the
      JSON module so that it does not have to be reimplemented.
      86e51d68
    • P
      util: storage: Add variables for node names into virStorageSource · cbc6d535
      Peter Krempa 提交于
      'nodeformat' should be used for strings which describe the storage
      format object, and 'nodebacking' for the actual storage object itself.
      cbc6d535
    • P
      util: storage: Split out useful bits of virStorageFileParseChainIndex · ad36f385
      Peter Krempa 提交于
      The function has very specific semantics. Split out the part that parses
      the backing store specification string into a separate helper so that it
      can be reused later while keeping the wrapper with existing semantics.
      
      Note that virStorageFileParseChainIndex is pretty well covered by the
      test suite.
      ad36f385
    • P
      util: buffer: Add API to set indentation level to a given value · 91e7862c
      Peter Krempa 提交于
      It will be useful to set indentation level to 0 after formatting a
      nested structure rather than having to track the depth.
      91e7862c
  2. 26 3月, 2017 1 次提交
  3. 25 3月, 2017 1 次提交
    • R
      util: fix build on non-Linux · a7496ad2
      Roman Bogorodskiy 提交于
      Fix typo in virNetDevPFGetVF() stub:
      
        ATTRUBUTE_UNUSED -> ATTRIBUTE_UNUSED.
      
      While here, use common indent style for arguments in
      virNetDevGetVirtualFunctionIndex() stub.
      a7496ad2
  4. 24 3月, 2017 10 次提交
    • L
      util: new function virNetDevPFGetVF() · 554253ad
      Laine Stump 提交于
      Given an SRIOV PF netdev name (e.g. "enp2s0f0") and VF#, this new
      function returns the netdev name of the referenced VF device
      (e.g. "enp2s11f6"), or NULL if the device isn't bound to a net driver.
      554253ad
    • L
      util: new internal function to permit silent failure of virNetDevSetMAC() · f4ef3a71
      Laine Stump 提交于
      We will want to allow silent failure of virNetDevSetMAC() in the case
      that the SIOSIFHWADDR ioctl fails with errno == EADDRNOTAVAIL. (Yes,
      that is very specific, but we really *do* want a logged failure in all
      other circumstances, and don't want to duplicate code in the caller
      for the other possibilities).
      
      This patch renames the 3 different virNetDevSetMAC() functions to
      virNetDevSetMACInternal(), adding a 3rd arg called "quiet" and making
      them static (because this extra control will only be needed within
      virnetdev.c). A new global virNetDevSetMAC() is defined that calls
      whichever of the three *Internal() functions gets compiled with quiet
      = false. Callers in virnetdev.c that want to notice a failure with
      errno == EADDRNOTAVAIL and retry with a different strategy rather than
      immediately failing, can call virNetDevSetMACInternal(..., true).
      f4ef3a71
    • L
      util: new function virPCIDeviceRebind() · 251d179b
      Laine Stump 提交于
      This function unbinds a device from its driver, then immediately
      rebinds it to its driver again. The code for this new function is just
      the 2nd half of virPCIDeviceBindWithDriverOverride(), so that
      function's 2nd half is replaced with a call to virPCIDeviceRebind().
      251d179b
    • L
      util: make virPCIGetDeviceAddressFromSysfsLink() public · 9a238c16
      Laine Stump 提交于
      This function will be useful in virnetdev.c, so promote it from static.
      9a238c16
    • L
      util: change virPCIGetNetName() to not return error if device has no net name · d6ee56d7
      Laine Stump 提交于
      ...and cleanup the callers to report it when it *is* an error.
      
      In many cases It's useful for virPCIGetNetName() to not log an error
      and simply return a NULL pointer when the given device isn't bound to
      a net driver (e.g. we're looking at a VF that is permanently bound to
      vfio-pci). The existing code would silently return an error in this
      case, which could eventually lead to the dreaded "An error occurred
      but the cause is unknown" log message.
      
      This patch changes virPCIGetNetName() to still return success if the
      device simply isn't bound to a net driver, and adjusts all the callers
      that require a non-null netname to check for that condition and log an
      error when it happens.
      d6ee56d7
    • L
      util: make virMacAddrParse more versatile · 30b07a42
      Laine Stump 提交于
      Previously the MAC address text was required to be terminated with a
      NULL. After this, it can be terminated with a space or any control
      character.
      30b07a42
    • L
      util: eliminate useless local variable · 606a0133
      Laine Stump 提交于
      vf in virNetDevMacVLanDeleteWithVPortProfile() is initialized to -1
      and never set. It's not set for a good reason - because it doesn't
      make sense during macvtap device setup to refer to a VF device as
      "PF:VF#". This patch replaces the two uses of "vf" with "-1", and
      removes the local variable, so that it's more clear we are always
      calling the utility functions with vf set to -1.
      606a0133
    • L
      util: use cleanup label consistently in virHostdevNetConfigReplace() · 19c5db74
      Laine Stump 提交于
      This will make an upcoming functional change more straightforward.
      19c5db74
    • L
      util: remove unused args from virNetDevSetVfConfig() · 0a583c26
      Laine Stump 提交于
      This function is only called in two places, and the ifindex,
      nltarget_kernel, and getPidFunc args are never used (and never will
      be).
      
      ifindex - we always know the name of the device, and never know the
      ifindex - if we really did need the ifindex we would have to get it
      from the name using virNetDevGetIndex(). In practice, we just send -1
      to virNetDevSetVfConfig(), which doesn't bother to learn the real
      ifindex (you only need a name *or* an ifindex for the netlink command
      to succeed, not both).
      
      nltarget_kernel - messages to set the config of an SRIOV VF will
      always go to netlink in the kernel, not to another user process, so
      this arg is always true (there are other uses of netlink messages
      where the message might need to go to another user process, but never
      in the case of RTM_SETLINK for SRIOV).
      
      getPidFunc - this arg is only used if nltarget_kernel is false, and it
      never is.
      
      None of this has any functional effect, it just makes it easier to
      follow what's happening when virNetDevSetVfConfig() is called.
      0a583c26
    • L
      util: permit querying a VF MAC address or VLAN tag by itself · 176229dd
      Laine Stump 提交于
      virNetDevParseVfConfig() assumed that both the MAC address and VLAN
      tag pointers were valid, so even if you only wanted one or the other,
      you would need a variable to hold the returned value for both. This
      patch checks each for a NULL pointer before filling it in.
      176229dd
  5. 23 3月, 2017 11 次提交