1. 26 8月, 2019 27 次提交
  2. 23 8月, 2019 13 次提交
    • M
      storage_driver: Don't crash in storagePoolCreateXML · 9935b435
      Michal Privoznik 提交于
      In my recent patches I've introduced
      virStoragePoolObjIsStarting() which is then used to protect
      storage pool definition when the pool object is locked and
      unlocked during long running jobs. Well, my patches did not
      anticipate that @obj can be NULL under 'cleanup' label in
      storagePoolCreateXML() (for instance when parsing XML fails).
      This imperfection is causing libvirtd to crash then.
      
      Fixes: 13284a6b storage_driver: Protect pool def during startup and build
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      Reviewed-by: NMartin Kletzander <mkletzan@redhat.com>
      9935b435
    • R
      tools: console: Relax stream EOF handling · 277c8c4c
      Roman Bolshakov 提交于
      Regular VM shutdown triggers the error for existing session of virsh
      console and it returns with non-zero exit code:
        error: internal error: console stream EOF
      
      The message and status code are misleading because there's no real
      error. virStreamRecv returns 0 correctly when EOF is reached.
      
      Existing implementations of esx, fd, and remote streams behave the same
      for virStreamFinish and virStreamAbort: they close the stream. So, we
      can continue to use virStreamAbort to handle EOF and errors from
      virStreamRecv but additonally we can report error if virStreamAbort
      fails.
      
      Fixes: 29f2b524 ("tools: console: pass stream/fd errors to user")
      Signed-off-by: NRoman Bolshakov <r.bolshakov@yadro.com>
      Reviewed-by: NDaniel Henrique Barboza <danielhb413@gmail.com>
      Tested-by: NDaniel Henrique Barboza <danielhb413@gmail.com>
      Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
      277c8c4c
    • R
      tests: Make references to global symbols indirect in test drivers · f6d6086d
      Roman Bolshakov 提交于
      A library has to be built with -flat_namespace to get all references to
      global symbols indirected. That can also be achieved with two-level
      namespace interposition but we're not using explicit symbol
      interposition since it's more verbose and requires massive changes to
      the mocks.
      
      This provides a way to interpose a mock for virQEMUCapsProbeHostCPU from
      qemucpumock and fixes domaincapstest on macOS.
      Signed-off-by: NRoman Bolshakov <r.bolshakov@yadro.com>
      f6d6086d
    • R
      tests: Avoid gnulib replacements in mocks · 0ae6f5ce
      Roman Bolshakov 提交于
      gnulib headers change stat, lstat and open to replacement functions,
      even for function definitions. This effectively disables standard
      library overrides in virfilewrapper and virmockstathelpers since they
      are never reached.
      
      Rename the functions and provide a declartion that uses correct
      assembler name for the mocks.
      
      This fixes firmware lookup in domaincapstest on macOS.
      Signed-off-by: NRoman Bolshakov <r.bolshakov@yadro.com>
      0ae6f5ce
    • R
      tests: Use flat namespace on macOS · fefc4ff4
      Roman Bolshakov 提交于
      Test executables and mocks have assumption that any symbol can be
      replaced with LD_PRELOAD. That's not a case for macOS unless flat
      namespace is used, because every external symbol reference records the
      library to be looked up. And the symbols cannot be replaced unless dyld
      interposing is used.
      
      Setting DYLD_FORCE_FLAT_NAMESPACE changes symbol lookup behaviour to be
      similar to Linux dynamic linker. It's more lightweight solution than
      explicitly decorating all mock symbols as interpositions and building
      libvirt as interposable dynamic library.
      
      This fixes vircryptotest and allows to proceed other tests that rely on
      mocks a little bit further.
      Signed-off-by: NRoman Bolshakov <r.bolshakov@yadro.com>
      fefc4ff4
    • R
      tests: Lookup extended stat/lstat in mocks · d6b17edd
      Roman Bolshakov 提交于
      macOS syscall interface (/usr/lib/system/libsystem_kernel.dylib) has
      three kinds of stat but only one of them can be used to fill
      "struct stat": stat$INODE64.
      
      virmockstathelpers looks up regular stat instead of stat$INODE64.  That
      causes a failure in qemufirmwaretest because "struct stat" is laid out
      differently from the values returned by stat.
      
      Introduce VIR_MOCK_REAL_INIT_ALIASED that can be used to lookup
      stat$INODE64 and lstat$INODE64 and use it to setup real functions on
      macOS.
      Signed-off-by: NRoman Bolshakov <r.bolshakov@yadro.com>
      d6b17edd
    • R
      build: Use flat namespace for libvirt on macOS · 740f181c
      Roman Bolshakov 提交于
      >From ld(1):
      
        By default all references resolved to a dynamic library record the
        library to which they were resolved. At runtime, dyld uses that
        information to directly resolve symbols. The alternative is to use the
        -flat_namespace option.  With flat namespace, the library is not
        recorded.  At runtime, dyld will search each dynamic library in load
        order when resolving symbols. This is slower, but more like how other
        operating systems resolve symbols.
      
      That fixes the set of tests that preload a mock library to replace
      library symbols:
        qemublocktest
        qemumonitorjsontest
        viriscsitest
        virmacmaptest
        virnetserverclienttest
      Signed-off-by: NRoman Bolshakov <r.bolshakov@yadro.com>
      740f181c
    • R
      tests: Drop /private CWD prefix in commandhelper · c6b3bf93
      Roman Bolshakov 提交于
      /tmp is a symbolic link to /private/tmp on macOS. That causes failures
      in commandtest, because getcwd returns /private/tmp and the expected
      output doesn't match to "CWD: /tmp".
      
      Rathern than making a copy of commanddata solely for macOS, the /private
      prefix is stripped.
      Signed-off-by: NRoman Bolshakov <r.bolshakov@yadro.com>
      c6b3bf93
    • R
      tests: Remove -module flag for mocks · 647c6518
      Roman Bolshakov 提交于
      macOS has two kinds of loadable libraries: MH_BUNDLE, and MH_DYLIB.
      bundle is used for plugins that are loaded with dlopen/dlsym/dlclose.
      And there's no way to preload a bundle into an application. dynamic
      linker (dyld) will reject it when finds it in DYLD_INSERT_LIBRARIES.
      
      Unfortunately, a bundle is built if -module flag is provided to libtool.
      The flag has been removed to build dylibs with ".dylib" suffix.
      Signed-off-by: NRoman Bolshakov <r.bolshakov@yadro.com>
      647c6518
    • R
      tests: Add lib- prefix to all mocks · fde36108
      Roman Bolshakov 提交于
      In preparation libtool "-module" flag removal, add lib prefix to all
      mock shared objects.
      
      While at it, introduce VIR_TEST_MOCK macros that makes path out of mock
      name to be used with VIR_TEST_PRELOAD or VIR_TEST_MAIN_PRELOAD.  That,
      hopefully, improves readability, reduces line length and allows to
      tailor VIR_TEST_MOCK for specific platform if it has shared library
      suffix different from ".so".
      Signed-off-by: NRoman Bolshakov <r.bolshakov@yadro.com>
      fde36108
    • R
      tests: Preload mocks with DYLD_INSERT_LIBRARIES on macOS · 351492e3
      Roman Bolshakov 提交于
      LD_PRELOAD has no effect on macOS. Instead, dyld(1) provides a way for
      symbol hooking via DYLD_INSERT_LIBRARIES. The variable should contain
      colon-separated paths to the dylibs to be inserted.
      Signed-off-by: NRoman Bolshakov <r.bolshakov@yadro.com>
      351492e3
    • R
      tests: Avoid IPv4-translated IPv6 address in sockettest · dbb5e20e
      Roman Bolshakov 提交于
      getnameinfo on macOS formats certain IPv6 addresses as IPv4-translated
      addresses. The following pattern has been observed:
        ::ffff is formated as ::0.0.255.255
        ::fffe is formated as ::0.0.255.254
        ::ffff:0 is formated as ::255.255.0.0
        ::fffe:0 is formated as ::255.254.0.0
        ::ffff:0:0 is formated as ::ffff:0.0.0.0
        ::fffe:0:0 is formated as ::fffe:0:0
        ::ffff:0:0:0 is formated as ::ffff:0:0:0
      
      The getnameinfo behavior causes a failure for:
        DO_TEST_PARSE_AND_FORMAT("::ffff", AF_UNSPEC, true);
      
      Use non-ambigious IPv6 for parse/format testing.
      Signed-off-by: NRoman Bolshakov <r.bolshakov@yadro.com>
      dbb5e20e
    • R
      tests: Don't test octal localhost IP in sockettest on macOS · 0f1b090b
      Roman Bolshakov 提交于
      getaddrinfo on macOS doesn't interpret octal IPv4 addresses. Only
      inet_aton can be used for that. Therefore, from macOS standpoint
      "0177.0.0.01" is not the same as "127.0.0.1".
      
      The issue was also discovered by python and dotnet core:
        https://bugs.python.org/issue27612
        https://github.com/dotnet/corefx/issues/8362Signed-off-by: NRoman Bolshakov <r.bolshakov@yadro.com>
      0f1b090b