1. 03 1月, 2020 1 次提交
  2. 17 12月, 2019 1 次提交
  3. 19 11月, 2019 1 次提交
  4. 15 11月, 2019 1 次提交
  5. 12 11月, 2019 2 次提交
  6. 21 10月, 2019 1 次提交
  7. 16 10月, 2019 1 次提交
  8. 15 10月, 2019 1 次提交
  9. 09 9月, 2019 4 次提交
    • D
      virpcimock.c: simplify getrealpath() usage · 2d9b8acf
      Daniel Henrique Barboza 提交于
      Previous patch had to add '/sys/kernel/' prefix in opendir() because
      the path, which is being mocked, wasn't being considered due to
      an 'if SYSFS_PCI_PREFIX' guarding the call to getrealpath().
      
      In fact, all current getrealpath() callers are guarding it with a
      conditional to ensure that the function will never be called with
      a non-mocked path. In this case, an extra non-NULL verification is
      needed for the 'newpath' string to use the variable - which is
      counterintuitive, given that getrealpath() will always write the
      'newpath' string in any non-error conditon.
      
      However, simply removing the guard of all getrealpath() instances
      causes an abort in init_env(). This happens because tests will
      execute access() to non-mocked paths even before the
      LIBVIRT_FAKE_ROOT_DIR variable is declared in the test files. We
      don't need 'fakerootdir' to be created at this point though.
      
      This patch does the following changes to simplify getrealpath()
      usage:
      
      - getrealpath() will now guard the init_env() call by checking if
      both fakeroot isn't created and the required path is being mocked.
      This ensures that we're not failing inside init_env() because
      we're too early and LIBVIRT_FAKE_ROOT_DIR wasn't defined yet;
      
      - remove all conditional guards to call getrealpath() from
      access(), virMockStatRedirect(), open(), open_2(), opendir()
      and virFileCanonicalizePath(). As a bonus, remove all ternary
      conditionals with 'newpath';
      
      - a new 'pathPrefixIsMocked()' helper to aggregate all the prefixes
      we're mocking, making it easier to add/remove them. If a prefix
      is added inside this function, we can be sure that all functions
      are mocking them.
      Signed-off-by: NDaniel Henrique Barboza <danielhb413@gmail.com>
      Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
      2d9b8acf
    • S
      tests: Add test case for QEMU pci-hostdev hotplug · 944a35d7
      Shivaprasad G Bhat 提交于
      This patch adds hostdev test cases in qemuhotplugtest.c.
      
      Note: the small tweak inside virpcimock.c was needed because
      the new tests added a code path in which virHostHasIOMMU()
      (virutil.c) started being called, and the mocked '/sys/kernel/'
      prefix that is mocked in virpcimock.c wasn't being considered
      in the opendir() mock. An alternative to avoid these situations
      in virpcimock.c is implemented in the next patch.
      Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
      Signed-off-by: NShivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
      Signed-off-by: NDaniel Henrique Barboza <danielhb413@gmail.com>
      944a35d7
    • S
      virpcimock: Mock the SRIOV Virtual functions · 5a9dc4a5
      Shivaprasad G Bhat 提交于
      The softlink to physfn is the way to know if the device is
      VF or not. So, the patch softlinks 'physfn' to the parent function.
      The multifunction PCI devices dont have 'physfn' softlinks.
      
      The patch adds few Virtual functions to the mock environment and
      changes the existing VFIO test xmls using the VFs to use the newly
      added VFs for their use case.
      Signed-off-by: NShivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
      Signed-off-by: NDaniel Henrique Barboza <danielhb413@gmail.com>
      Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
      5a9dc4a5
    • D
      virpcimock.c: mock /dev/vfio · 16c98903
      Daniel Henrique Barboza 提交于
      This patch adds mock of the /dev/vfio path, needed for proper
      implementation of the support for multifunction/multiple devices
      per iommu groups.
      
      To do that, the existing bind and unbind operations were adapted
      to operate with the mocked filesystem as well.
      Signed-off-by: NDaniel Henrique Barboza <danielhb413@gmail.com>
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
      16c98903
  10. 23 8月, 2019 3 次提交
  11. 20 8月, 2019 2 次提交
  12. 19 8月, 2019 1 次提交
  13. 17 8月, 2019 12 次提交
  14. 16 8月, 2019 2 次提交
    • P
      tests: virpcimock: Always declare __open_2 · 52dad8c9
      Peter Krempa 提交于
      In some cases e.g. with clang on fedora 30 __open2 isn't even declared
      which results in the following build error:
      
      /home/pipo/libvirt/tests/virpcimock.c:939:1: error: no previous prototype for function
            '__open_2' [-Werror,-Wmissing-prototypes]
      __open_2(const char *path, int flags)
      
      Add a separate declaration to appease the compiler.
      Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
      Reviewed-by: NErik Skultety <eskultet@redhat.com>
      52dad8c9
    • M
      virpcimock: Mock __open_2() · 459f071c
      Michal Privoznik 提交于
      Hold on to your hat, this is going to be a wild ride. As nearly
      nothing in glibc, nor open() is a real function. Just look into
      bits/fcntl2.h and you'll see that open() is actually a thin
      wrapper that calls either __open_alias() or __open_2(). Now,
      before 801ebb5e the open() done in
      virPCIDeviceConfigOpenInternal() had a constant oflags (we were
      opening the pci config with O_RDWR). And since we were not
      passing any mode nor O_CREAT the wrapper decided to call
      __open_alias() which was open() provided by our mock. So far so
      good. But after the referenced commit, the oflags is no longer
      compile time constant and therefore the wrapper calls __open_2()
      which we don't mock and thus the real __open_2() from glibc was
      called and thus we did try to open real path from host's /sys.
      This of course fails with variety of errors.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      Reviewed-by: NErik Skultety <eskultet@redhat.com>
      Reviewed-by: NJán Tomko <jtomko@redhat.com>
      459f071c
  15. 17 6月, 2019 1 次提交
  16. 03 4月, 2019 1 次提交
    • D
      tests: fix mocking of stat() / lstat() functions · ff376c62
      Daniel P. Berrangé 提交于
      Quite a few of the tests have a need to mock the stat() / lstat()
      functions and they are taking somewhat different & inconsistent
      approaches none of which are actually fully correct. This is shown
      by fact that 'make check' fails on 32-bit hosts. Investigation
      revealed that the code was calling into the native C library impl,
      not getting intercepted by our mocks.
      
      The POSIX stat() function might resolve to any number of different
      symbols in the C library.
      
      The may be an additional stat64() function exposed by the headers
      too.
      
      On 64-bit hosts the stat & stat64 functions are identical, always
      refering to the 64-bit ABI.
      
      On 32-bit hosts they refer to the 32-bit & 64-bit ABIs respectively.
      
      Libvirt uses _FILE_OFFSET_BITS=64 on 32-bit hosts, which causes the
      C library to transparently rewrite stat() calls to be stat64() calls.
      Libvirt will never see the 32-bit ABI from the traditional stat()
      call. We cannot assume this rewriting is done using a macro. It might
      be, but on GLibC it is done with a magic __asm__ statement to apply
      the rewrite at link time instead of at preprocessing.
      
      In GLibC there may be two additional functions exposed by the headers,
      __xstat() and __xstat64(). When these exist, stat() and stat64() are
      transparently rewritten to call __xstat() and __xstat64() respectively.
      The former symbols will not actally exist in the library at all, only
      the header. The leading "__" indicates the symbols are a private impl
      detail of the C library that applications should not care about.
      Unfortunately, because we are trying to mock replace the C library,
      we need to know about this internal impl detail.
      
      With all this in mind the list of functions we have to mock will depend
      on several factors
      
       - If _FILE_OFFSET_BITS is set, then we are on a 32-bit host, and we
         only need to mock stat64 and __xstat64. The other stat / __xstat
         functions exist, but we'll never call them so they can be ignored
         for mocking.
      
       - If _FILE_OFFSET_BITS is not set, then we are on a 64-bit host and
         we should mock stat, stat64, __xstat & __xstat64. Either may be
         called by app code.
      
       - If __xstat & __xstat64 exist, then stat & stat64 will not exist
         as symbols in the library, so the latter should not be mocked.
      
      The same all applies to lstat()
      
      These rules are complex enough that we don't want to duplicate them
      across every mock file, so this centralizes all the logic in a helper
      file virmockstathelper.c that should be #included when needed. The
      code merely need to provide a filename rewriting callback called
      virMockStatRedirect(). Optionally VIR_MOCK_STAT_HOOK can be defined
      as a macro if further processing is needed inline.
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      ff376c62
  17. 18 3月, 2019 1 次提交
  18. 14 12月, 2018 1 次提交
    • D
      Remove all Author(s): lines from source file headers · 60046283
      Daniel P. Berrangé 提交于
      In many files there are header comments that contain an Author:
      statement, supposedly reflecting who originally wrote the code.
      In a large collaborative project like libvirt, any non-trivial
      file will have been modified by a large number of different
      contributors. IOW, the Author: comments are quickly out of date,
      omitting people who have made significant contribitions.
      
      In some places Author: lines have been added despite the person
      merely being responsible for creating the file by moving existing
      code out of another file. IOW, the Author: lines give an incorrect
      record of authorship.
      
      With this all in mind, the comments are useless as a means to identify
      who to talk to about code in a particular file. Contributors will always
      be better off using 'git log' and 'git blame' if they need to  find the
      author of a particular bit of code.
      
      This commit thus deletes all Author: comments from the source and adds
      a rule to prevent them reappearing.
      
      The Copyright headers are similarly misleading and inaccurate, however,
      we cannot delete these as they have legal meaning, despite being largely
      inaccurate. In addition only the copyright holder is permitted to change
      their respective copyright statement.
      Reviewed-by: NErik Skultety <eskultet@redhat.com>
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      60046283
  19. 20 9月, 2018 2 次提交
  20. 04 5月, 2018 1 次提交