1. 19 9月, 2013 1 次提交
    • D
      Include process start time when doing polkit checks · 65f7c07c
      Daniel P. Berrange 提交于
      Since PIDs can be reused, polkit prefers to be given
      a (PID,start time) pair. If given a PID on its own,
      it will attempt to lookup the start time in /proc/pid/stat,
      though this is subject to races.
      
      It is safer if the client app resolves the PID start
      time itself, because as long as the app has the client
      socket open, the client PID won't be reused.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      (cherry picked from commit 979e9c56)
      
      Conflicts:
      	src/util/virprocess.c
      	src/util/virstring.c
      	src/util/virstring.h
      65f7c07c
  2. 20 8月, 2013 1 次提交
    • P
      virbitmap: Refactor virBitmapParse to avoid access beyond bounds of array · b68a721d
      Peter Krempa 提交于
      The virBitmapParse function was calling virBitmapIsSet() function that
      requires the caller to check the bounds of the bitmap without checking
      them. This resulted into crashes when parsing a bitmap string that was
      exceeding the bounds used as argument.
      
      This patch refactors the function to use virBitmapSetBit without
      checking if the bit is set (this function does the checks internally)
      and then counts the bits in the bitmap afterwards (instead of keeping
      track while parsing the string).
      
      This patch also changes the "parse_error" label to a more common
      "error".
      
      The refactor should also get rid of the need to call sa_assert on the
      returned variable as the callpath should allow coverity to infer the
      possible return values.
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=997367
      
      Thanks to Alex Jia for tracking down the issue. This issue is introduced
      by commit 0fc89098.
      
      (cherry picked from commit 47b9127e)
      b68a721d
  3. 11 7月, 2013 2 次提交
  4. 01 7月, 2013 4 次提交
  5. 20 6月, 2013 2 次提交
    • J
      lxc: Resolve issue with GetScheduler APIs for non running domain · ca62fde8
      John Ferlan 提交于
      Cherry-picked from 38ada092
      
      As a consequence of the cgroup layout changes from commit 'cfed9ad4', the
      lxcDomainGetSchedulerParameters[Flags]()' and lxcGetSchedulerType() APIs
      failed to return data for a non running domain.  This can be seen through
      a 'virsh schedinfo <domain>' command which returns:
      
      Scheduler      : Unknown
      error: Requested operation is not valid: cgroup CPU controller is not mounted
      
      Prior to that change a non running domain would return:
      
      Scheduler      : posix
      cpu_shares     : 0
      vcpu_period    : 0
      vcpu_quota     : 0
      emulator_period: 0
      emulator_quota : 0
      
      This patch will restore the capability to return configuration only data
      for a non running domain regardless of whether cgroups are available.
      
      Conflicts:
      	src/lxc/lxc_driver.c
      
        * Resolved conflict by using former lxcCgroupHasController() rather than
          virCgroupHasController()
        * Needed to add the code to fetch the 'vm'
           vm = virDomainObjListFindByUUID(driver->domains, domain->uuid);
           if (vm == NULL) {
               virReportError(VIR_ERR_INTERNAL_ERROR,
                              _("No such domain %s"), domain->uuid);
               goto cleanup;
           }
        * Used 'ret = strdup("posix");' rather than VIR_STRDUP(ret, "posix");
          and added the virReportOOMError(); on failure.
      ca62fde8
    • J
      qemu: Resolve issue with GetScheduler APIs for non running domain · 94c88b48
      John Ferlan 提交于
      Cherry-picked from b2375453
      
      As a consequence of the cgroup layout changes from commit '632f78ca', the
      qemuDomainGetSchedulerParameters[Flags]()' and qemuGetSchedulerType() APIs
      failed to return data for a non running domain.  This can be seen through
      a 'virsh schedinfo <domain>' command which returns:
      
      Scheduler      : Unknown
      error: Requested operation is not valid: cgroup CPU controller is not mounted
      
      Prior to that change a non running domain would return:
      
      Scheduler      : posix
      cpu_shares     : 0
      vcpu_period    : 0
      vcpu_quota     : 0
      emulator_period: 0
      emulator_quota : 0
      
      This patch will restore the capability to return configuration only data
      for a non running domain regardless of whether cgroups are available.
      
      Conflicts:
      	src/qemu/qemu_driver.c
      
       * Resolved conflict by using former qemuCgroupHasController() rather than
         virCgroupHasController()
       * Needed to add the code to fetch the 'vm'
            vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
            if (vm == NULL) {
                virReportError(VIR_ERR_INTERNAL_ERROR,
                               _("No such domain %s"), dom->uuid);
                goto cleanup;
            }
      * Used 'ret = strdup("posix");' rather than VIR_STRDUP(ret, "posix");
        and added the virReportOOMError(); on failure.
      94c88b48
  6. 18 6月, 2013 3 次提交
  7. 01 6月, 2013 1 次提交
    • L
      qemu: prevent termination of guests w/hostdev on driver reconnect · 1056bbdb
      Laine Stump 提交于
      This should resolve:
      
        https://bugzilla.redhat.com/show_bug.cgi?id=959191
      
      The problem was that qemuUpdateActivePciHostdevs was returning 0
      (success) when no hostdevs were present, but would otherwise return -1
      (failure) even when it completed successfully. It is only called from
      qemuProcessReconnect(), and when qemuProcessReconnect got back an
      error, it would not only stop reconnecting, but would terminate the
      guest qemu process "to remove danger of it ending up running twice if
      user tries to start it again later".
      
      (This bug was introduced in commit 011cf7ad, which was pushed between
      v1.0.2 and v1.0.3, so all maintenance branches from v1.0.3 up to 1.0.5
      will need this one line patch applied.)
      (cherry picked from commit 2ea45647)
      1056bbdb
  8. 16 5月, 2013 1 次提交
    • J
      daemon: fix leak after listing all volumes · 24317824
      Ján Tomko 提交于
      CVE-2013-1962
      
      remoteDispatchStoragePoolListAllVolumes wasn't freeing the pool.
      The pool also held a reference to the connection, preventing it from
      getting freed and closing the netcf interface driver, which held two
      sockets open.
      (cherry picked from commit ca697e90)
      24317824
  9. 09 5月, 2013 4 次提交
  10. 23 4月, 2013 3 次提交
    • E
      maint: update to latest gnulib · 4c003e79
      Eric Blake 提交于
      Upstream gnulib determined that we were needlessly compiling in
      gnulib's regex instead of glibc's when targetting new-enough glibc,
      because the m4 test was being too strict in requiring a particular
      answer to undefined behavior.
      https://lists.gnu.org/archive/html/bug-gnulib/2013-04/msg00032.html
      
      * .gnulib: Update to latest, for regex.
      (cherry picked from commit 84243239)
      
      Cherry picked because I hit a failure of test-regex when swapping
      between incremental builds of libvirt.git master then v1.0.4-maint.
      4c003e79
    • E
      maint: update to latest gnulib · 97cf1706
      Eric Blake 提交于
      While this update doesn't address any reported problems in libvirt,
      doing a post-release update to latest gnulib makes it easier to
      stay in sync with best upstream practices.
      
      * .gnulib: Update to latest.
      * bootstrap: Resynchronize.
      (cherry picked from commit d7468b7d)
      97cf1706
    • E
      audit: properly encode device path in cgroup audit · 79c23e03
      Eric Blake 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=922186
      
      Commit d04916fa introduced a regression in audit quality - even
      though the code was computing the proper escaped name for a
      path, it wasn't feeding that escaped name on to the audit message.
      As a result, /var/log/audit/audit.log would mention a pair of
      fields class=path path=/dev/hpet instead of the intended
      class=path path="/dev/hpet", which in turn caused ausearch to
      format the audit log with path=(null).
      
      * src/conf/domain_audit.c (virDomainAuditCgroupPath): Use
      constructed encoding.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      (cherry picked from commit 31c6bf35)
      79c23e03
  11. 10 4月, 2013 17 次提交
    • A
      98afc745
    • J
      spec: Require pod2man when running autoreconf · 0f641de1
      Jiri Denemark 提交于
      Since commit b8a32e0e, all man pages
      depend on configure.ac so that they are properly regenerated whenever
      libvirt version changes. Thus libvirt.spec needs to have a build
      dependency on pod2man when %{enable_autotools} is set.
      (cherry picked from commit 6f1b9c8d)
      0f641de1
    • E
      build: check correct protocol.o file · dfb42ed1
      Eric Blake 提交于
      By default, libtool builds two .o files for every .lo rule:
      src/foo.o - static builds
      src/.libs/foo.o - shared library builds
      
      But since commit ad42b34b disabled static builds, src/foo.o is
      no longer built by default.  On a fresh checkout, this means our
      protocol check rules using pdwtags were testing a missing file,
      and thanks to a lousy behavior of pdwtags happily giving no output
      and 0 exit status (http://bugzilla.redhat.com/949034), we were
      merely claiming that "dwarves is too old" and skipping the test.
      
      However, if you swap between branches and do incremental builds,
      such as building v0.10.2-maint and then switching back to master,
      you end up with src/foo.o being leftover from its 0.10.2 state,
      and then 'make check' fails because the .o file does not match
      the protocol-structs file due to API additions in the meantime.
      
      A simpler fix would be to always look in .libs for the .o to
      be parsed; but since it is possible to pass ./configure options
      to tell libtool to do a static-only build with no shared .o,
      I went with the approach of finding the newest of the two files,
      whenever both exist.
      
      * src/Makefile.am (PDWTAGS): Ensure we test just-built file.
      (cherry picked from commit 5899e09e)
      dfb42ed1
    • D
      Ensure LD_PRELOAD exists before running test case · a243e21c
      Daniel P. Berrange 提交于
      The linker will ignore LD_PRELOAD libraries which do not
      exist, just printing a warning message. This is not helpful
      for the test suite which will be utterly fubar without the
      preload library present. Add an explicit test for existence
      of the library to protect against this
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      (cherry picked from commit b1d3154a)
      a243e21c
    • P
      rpc: Fix connection close callback race condition and memory corruption/crash · d6ee2113
      Peter Krempa 提交于
      The last Viktor's effort to fix the race and memory corruption unfortunately
      wasn't complete in the case the close callback was not registered in an
      connection. At that time, the trail of event's that I'll describe later could
      still happen and corrupt the memory or cause a crash of the client (including
      the daemon in case of a p2p migration).
      
      Consider the following prerequisities and trail of events:
      Let's have a remote connection to a hypervisor that doesn't have a close
      callback registered and the client is using the event loop. The crash happens in
      cooperation of 2 threads. Thread E is the event loop and thread W is the worker
      that does some stuff. R denotes the remote client.
      
      1.) W - The client finishes everything and sheds the last reference on the client
      2.) W - The virObject stuff invokes virConnectDispose that invokes doRemoteClose
      3.) W - the remote close method invokes the REMOTE_PROC_CLOSE RPC method.
      4.) W - The thread is preempted at this point.
      5.) R - The remote side receives the close and closes the socket.
      6.) E - poll() wakes up due to the closed socket and invokes the close callback
      7.) E - The event loop is preempted right before remoteClientCloseFunc is called
      8.) W - The worker now finishes, and frees the conn object.
      9.) E - The remoteClientCloseFunc accesses the now-freed conn object in the
              attempt to retrieve pointer for the real close callback.
      10.) Kaboom, corrupted memory/segfault.
      
      This patch tries to fix this by introducing a new object that survives the
      freeing of the connection object. We can't increase the reference count on the
      connection object itself or the connection would never be closed, as the
      connection is closed only when the reference count reaches zero.
      
      The new object - virConnectCloseCallbackData - is a lockable object that keeps
      the pointers to the real user registered callback and ensures that the
      connection callback is either not called if the connection was already freed or
      that the connection isn't freed while this is being called.
      (cherry picked from commit 8ad126e6)
      d6ee2113
    • P
      virsh: Register and unregister the close callback also in cmdConnect · 3e13977c
      Peter Krempa 提交于
      This patch improves the error message after disconnecting from the
      hypervisor and adds the close callback operations required not to leak
      the callback reference.
      (cherry picked from commit 69ab0756)
      3e13977c
    • P
      virsh: Move cmdConnect from virsh-host.c to virsh.c · f4a7891e
      Peter Krempa 提交于
      The function is used to establish connection so it should be in the main
      virsh file. This movement also enables further improvements done in next
      patches.
      
      Note that the "connect" command has moved from the host section of virsh to the
      main section. It is now listed by 'virsh help virsh' instead of 'virsh help
      host'.
      (cherry picked from commit ca9e73eb)
      f4a7891e
    • V
      virsh: Unregister the connection close notifier upon termination · bec3cc73
      Viktor Mihajlovski 提交于
      Before closing the connection we unregister the close callback
      to prevent a reference leak.
      
      Further, the messages on virConnectClose != 0 are a bit more specific
      now.
      Signed-off-by: NViktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
      (cherry picked from commit e964ba27)
      bec3cc73
    • V
      libvirt: Increase connection reference count for callbacks · cf7dbdd4
      Viktor Mihajlovski 提交于
      By adjusting the reference count of the connection object we
      prevent races between callback function and virConnectClose.
      Signed-off-by: NViktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
      (cherry picked from commit 03a43efa)
      cf7dbdd4
    • A
      storage: Fix volume cloning for logical volume. · 7156c8c7
      Atsushi Kumagai 提交于
      When creating a logical volume with virStorageVolCreateXMLFrom,
      "qemu-img convert" is called internally if clonevol is a file volume.
      Then, vol->target.format is used as output_fmt parameter but the
      target.format of logical volumes is always 0 because logical volumes
      haven't the volume format type element.
      
      Fortunately, 0 was treated as RAW file format before commit f772b3d9,
      so there was no problem. But now, 0 is treated as the type of none,
      qemu-img fails with "Unknown file format 'none'".
      
      This patch fixes this issue by treating output block devices as RAW
      file format like for input block devices.
      Signed-off-by: NAtsushi Kumagai <kumagai-atsushi@mxc.nes.nec.co.jp>
      (cherry picked from commit d369e508)
      7156c8c7
    • D
      Enable full RELRO mode · d990d6ae
      Daniel P. Berrange 提交于
      By passing the flags -z relro -z now to the linker, we can force
      it to resolve all library symbols at startup, instead of on-demand.
      This allows it to then make the global offset table (GOT) read-only,
      which makes some security attacks harder.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      (cherry picked from commit fc8c1787)
      d990d6ae
    • D
      Build all binaries with PIE · f0158023
      Daniel P. Berrange 提交于
      PIE (position independent executable) adds security to executables
      by composing them entirely of position-independent code (PIC. The
      .so libraries already build with -fPIC. This adds -fPIE which is
      the equivalent to -fPIC, but for executables. This for allows Exec
      Shield to use address space layout randomization to prevent attackers
      from knowing where existing executable code is during a security
      attack using exploits that rely on knowing the offset of the
      executable code in the binary, such as return-to-libc attacks.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      (cherry picked from commit 1150999c)
      f0158023
    • P
      qemu: Fix crash when updating media with shared device · 2a702717
      Peter Krempa 提交于
      Mimic the fix done in 02b90972 to fix crash by
      accessing an already freed structure. Also copy the explaining comment why the
      pointer can't be accessed any more.
      (cherry picked from commit 43b6f304)
      2a702717
    • M
      virsh: Call virDomainFree in cmdDomFSTrim · 5fdccc85
      Michal Privoznik 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=928197
      
      The virsh domfstrim command was not freeing allocated domain,
      leaving leaked references behind.
      (cherry picked from commit deb86ee9)
      5fdccc85
    • E
      smartcard: spell ccid-card-emulated qemu property correctly · 5fa7db63
      Eric Blake 提交于
      Reported by Anthony Messina in
      https://bugzilla.redhat.com/show_bug.cgi?id=904692
      Present since introduction of smartcard support in commit f5fd9baa
      
      * src/qemu/qemu_command.c (qemuBuildCommandLine): Match qemu spelling.
      * tests/qemuxml2argvdata/qemuxml2argv-smartcard-host-certificates.args:
      Fix broken test.
      (cherry picked from commit 6f7e4ea3)
      5fa7db63
    • J
      Resolve valgrind failure · ce0bbe70
      John Ferlan 提交于
      Code added by commit id '523207fe'
      
      TEST: qemuxml2argvtest
            ........................................ 40
            ........................................ 80
            ........................................ 120
            ........................................ 160
            ........................................ 200
            ........................................ 240
            .................................        273 OK
      ==30993== 39 bytes in 1 blocks are definitely lost in loss record 33 of 87
      ==30993==    at 0x4A0887C: malloc (vg_replace_malloc.c:270)
      ==30993==    by 0x41E501: fakeSecretGetValue (qemuxml2argvtest.c:33)
      ==30993==    by 0x427591: qemuBuildDriveURIString (qemu_command.c:2571)
      ==30993==    by 0x42C502: qemuBuildDriveStr (qemu_command.c:2627)
      ==30993==    by 0x4335FC: qemuBuildCommandLine (qemu_command.c:6443)
      ==30993==    by 0x41E8A0: testCompareXMLToArgvHelper (qemuxml2argvtest.c:154
      ==30993==    by 0x41FE8F: virtTestRun (testutils.c:157)
      ==30993==    by 0x418BE3: mymain (qemuxml2argvtest.c:506)
      ==30993==    by 0x4204CA: virtTestMain (testutils.c:719)
      ==30993==    by 0x38D6821A04: (below main) (in /usr/lib64/libc-2.16.so)
      ==30993==
      ==30993== 46 bytes in 1 blocks are definitely lost in loss record 64 of 87
      ==30993==    at 0x4A0887C: malloc (vg_replace_malloc.c:270)
      ==30993==    by 0x38D690A167: __vasprintf_chk (in /usr/lib64/libc-2.16.so)
      ==30993==    by 0x4CB28E7: virVasprintf (stdio2.h:210)
      ==30993==    by 0x4CB29A3: virAsprintf (virutil.c:2017)
      ==30993==    by 0x4275B4: qemuBuildDriveURIString (qemu_command.c:2580)
      ==30993==    by 0x42C502: qemuBuildDriveStr (qemu_command.c:2627)
      ==30993==    by 0x4335FC: qemuBuildCommandLine (qemu_command.c:6443)
      ==30993==    by 0x41E8A0: testCompareXMLToArgvHelper (qemuxml2argvtest.c:154
      ==30993==    by 0x41FE8F: virtTestRun (testutils.c:157)
      ==30993==    by 0x418BE3: mymain (qemuxml2argvtest.c:506)
      ==30993==    by 0x4204CA: virtTestMain (testutils.c:719)
      ==30993==    by 0x38D6821A04: (below main) (in /usr/lib64/libc-2.16.so)
      ==30993==
      ==30993== 385 (56 direct, 329 indirect) bytes in 1 blocks are definitely los
      ==30993==    at 0x4A06B6F: calloc (vg_replace_malloc.c:593)
      ==30993==    by 0x4C6B2CF: virAllocN (viralloc.c:152)
      ==30993==    by 0x4C9C7EB: virObjectNew (virobject.c:191)
      ==30993==    by 0x4D21810: virGetSecret (datatypes.c:642)
      ==30993==    by 0x41E5D5: fakeSecretLookupByUsage (qemuxml2argvtest.c:51)
      ==30993==    by 0x4D4BEC5: virSecretLookupByUsage (libvirt.c:15295)
      ==30993==    by 0x4276A9: qemuBuildDriveURIString (qemu_command.c:2565)
      ==30993==    by 0x42C502: qemuBuildDriveStr (qemu_command.c:2627)
      ==30993==    by 0x4335FC: qemuBuildCommandLine (qemu_command.c:6443)
      ==30993==    by 0x41E8A0: testCompareXMLToArgvHelper (qemuxml2argvtest.c:154
      ==30993==    by 0x41FE8F: virtTestRun (testutils.c:157)
      ==30993==    by 0x418BE3: mymain (qemuxml2argvtest.c:506)
      ==30993==
      PASS: qemuxml2argvtest
      
      Interesting side note is that running the test singularly via 'make -C tests
      check TESTS=qemuxml2argvtest' didn't trip the valgrind error; however,
      running during 'make -C tests valgrind' did cause the error to be seen.
      (cherry picked from commit 9a80050e)
      ce0bbe70
    • L
      Fix crash in virNetDevGetVirtualFunctions · 08b700b4
      Laine Stump 提交于
      Commit 9a3ff01d (which was ACKed at
      the end of January, but for some reason didn't get pushed until during
      the 1.0.4 freeze) fixed the logic in virPCIGetVirtualFunctions().
      Unfortunately, a typo in the fix (replacing VIR_REALLOC_N with
      VIR_ALLOC_N during code movement) caused not only a memory leak, but
      also resulted in most of the elements of the result array being
      replaced with NULL. virNetDevGetVirtualFunctions() assumed (and I think
      rightly so) that virPCIGetVirtualFunctions() wouldn't return any NULL
      elements in the array, so it ended up segfaulting.
      
      This was found when attempting to use a virtual network with an
      auto-created pool of SRIOV VFs, e.g.:
      
          <forward mode='hostdev' managed='yes'>
            <pf dev='eth4'/>
          </forward>
      
      (the pool of PCI addresses is discovered by calling
      virNetDevGetVirtualFunctions() on the PF dev).
      08b700b4
  12. 01 4月, 2013 1 次提交
    • D
      Release of libvirt-1.0.4 · 89d73020
      Daniel Veillard 提交于
      - configure.ac docs/news.html.in libvirt.spec.in: updates for the release
      - po/*.po*: fetch translation updates from Transifex and regenerate
      89d73020