1. 19 9月, 2013 8 次提交
    • D
      Rename virPid{Abort, Wait} to virProcess{Abort, Wait} · 89a18105
      Daniel P. Berrange 提交于
      Change "Pid" to "Process" to align with the virProcessKill
      API naming prefix
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      (cherry picked from commit 0fb58ef5)
      Signed-off-by: NEric Blake <eblake@redhat.com>
      
      Conflicts:
      	src/util/util.c
      	src/lxc/lxc_container.c
      	src/lxc/lxc_controller.c
      89a18105
    • D
      Rename virKillProcess to virProcessKill · ffbf1df4
      Daniel P. Berrange 提交于
      Changing naming to follow the convention of "object" followed
      by "action"
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      (cherry picked from commit cf470068)
      ffbf1df4
    • D
      Introduce APIs for splitting/joining strings · 1bcb4c72
      Daniel P. Berrange 提交于
      This introduces a few new APIs for dealing with strings.
      One to split a char * into a char **, another to join a
      char ** into a char *, and finally one to free a char **
      
      There is a simple test suite to validate the edge cases
      too. No more need to use the horrible strtok_r() API,
      or hand-written code for splitting strings.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      (cherry picked from commit 76c1fd33)
      Signed-off-by: NEric Blake <eblake@redhat.com>
      
      Conflicts:
      	tests/Makefile.am - several intermediate tests not backported
      1bcb4c72
    • D
      Fix TLS tests with gnutls 3 · ec5190af
      Daniel P. Berrange 提交于
      When given a CA cert with basic constraints to set non-critical,
      and key usage of 'key signing', this should be rejected. Version
      of GNUTLS < 3 do not rejecte it though, so we never noticed the
      test case was broken
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      (cherry picked from commit 0204d6d7)
      ec5190af
    • E
      build: avoid confusing make with raw name 'undefine' · c4f884df
      Eric Blake 提交于
      Make has a builtin operator 'undefine', and coupled with latest
      automake.git, this test name ended up confusing make into thinking
      the file name was meant to be used as the make operator.  Renaming
      the file avoids the confusion.
      
      * tests/undefine: Rename...
      * tests/virsh-undefine: ...to this.
      * tests/Makefile.am (test_scripts): Use new name.
      Reported by Jim Meyering.
      
      (cherry picked from commit a20f06d9)
      c4f884df
    • J
      virsh: Fix POD syntax · 42010c28
      Jiri Denemark 提交于
      The first two hunks fix "Unterminated I<...> sequence" error and the
      last one fixes "’=item’ outside of any ’=over’" error.
      
      (cherry picked from commit 61299a1c)
      Signed-off-by: NEric Blake <eblake@redhat.com>
      
      Conflicts:
      	tools/virsh.pod - drop hunks not present this far back
      42010c28
    • E
      build: more workarounds for if_bridge.h · 901af5f4
      Eric Blake 提交于
      This is a second attempt at fixing the problem first attempted
      in commit 2df8d991; basically undoing the fact that it was
      reverted in commit 43cee32f, plus fixing two more issues: the
      code in configure.ac has to EXACTLY match virnetdevbridge.c
      with regards to declaring in6 types before using if_bridge.h,
      and the fact that RHEL 5 has even more conflicts:
      
      In file included from util/virnetdevbridge.c:49:
      /usr/include/linux/in6.h:47: error: conflicting types for 'in6addr_any'
      /usr/include/netinet/in.h:206: error: previous declaration of 'in6addr_any' was here
      /usr/include/linux/in6.h:49: error: conflicting types for 'in6addr_loopback'
      /usr/include/netinet/in.h:207: error: previous declaration of 'in6addr_loopback' was here
      
      The rest of this commit message borrows from the original try
      of 2df8d991:
      
      A fresh checkout on a RHEL 6 machine with these packages:
      kernel-headers-2.6.32-405.el6.x86_64
      glibc-2.12-1.128.el6.x86_64
      failed to configure with this message:
      checking for linux/if_bridge.h... no
      configure: error: You must install kernel-headers in order to compile libvirt with QEMU or LXC support
      
      Digging in config.log, we see that the problem is identical to
      what we fixed earlier in commit d12c2811:
      
      configure:98831: checking for linux/if_bridge.h
      configure:98853: gcc -std=gnu99 -c -g -O2  conftest.c >&5
      In file included from /usr/include/linux/if_bridge.h:17,
                       from conftest.c:559:
      /usr/include/linux/in6.h:31: error: redefinition of 'struct in6_addr'
      /usr/include/linux/in6.h:48: error: redefinition of 'struct sockaddr_in6'
      /usr/include/linux/in6.h:56: error: redefinition of 'struct ipv6_mreq'
      configure:98860: $? = 1
      
      I had not hit it earlier because I was using incremental builds,
      where config.cache had shielded me from the kernel-headers breakage.
      
      * configure.ac (if_bridge.h): Avoid conflicting type definitions.
      * src/util/virnetdevbridge.c (includes): Also sanitize for RHEL 5.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      (cherry picked from commit 70024dc9)
      
      Done in one patch rather than a series for bisectability reasons
      (as intermediate patches suffer from various problems on various
      platforms), and because the intermediate patches include a revert,
      but it is pointless to backport two patches where one undoes the
      other.  Intermediate patches include: 9a2f36ec, c308a9ae, 1bf661ca,
      d12c2811, 2df8d991, 43cee32f (phew, that's a mouthful).
      
      Conflicts:
      	configure.ac - skip the churn of all intermediate patches
      	src/util/virnetdevbridge.c - ditto
      901af5f4
    • E
      build: allow building with newer glibc-headers and -O0 · 9b3cc031
      Eric Blake 提交于
      glibc 2.15 (on Fedora 17) coupled with explicit disabling of
      optimization during development dies a painful death:
      
      In file included from /usr/include/limits.h:27:0,
                       from /usr/lib/gcc/x86_64-redhat-linux/4.7.0/include/limits.h:169,
                       from /usr/lib/gcc/x86_64-redhat-linux/4.7.0/include/syslimits.h:7,
                       from /usr/lib/gcc/x86_64-redhat-linux/4.7.0/include/limits.h:34,
                       from util/bitmap.c:26:
      /usr/include/features.h:314:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp]
      cc1: all warnings being treated as errors
      
      Work around this by only conditionally defining _FORTIFY_SOURCE,
      in the case where glibc can actually use it.  The trick is using
      AH_VERBATIM instead of AC_DEFINE.
      
      * m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Squelch
      _FORTIFY_SOURCE when needed to avoid glibc #warnings.
      
      (cherry picked from commit 2af63b1c)
      9b3cc031
  2. 12 9月, 2013 10 次提交
    • D
      Fix race condition when destroying guests · d70ca364
      Daniel P. Berrange 提交于
      When running virDomainDestroy, we need to make sure that no other
      background thread cleans up the domain while we're doing our work.
      This can happen if we release the domain object while in the
      middle of work, because the monitor might detect EOF in this window.
      For this reason we have a 'beingDestroyed' flag to stop the monitor
      from doing its normal cleanup. Unfortunately this flag was only
      being used to protect qemuDomainBeginJob, and not qemuProcessKill
      
      This left open a race condition where either libvirtd could crash,
      or alternatively report bogus error messages about the domain already
      having been destroyed to the caller
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      (cherry picked from commit 81621f3e)
      
      Conflicts:
      	src/qemu/qemu_driver.c
      d70ca364
    • D
      Don't ignore return value of qemuProcessKill · 9143006c
      Daniel P. Berrange 提交于
      When calling qemuProcessKill from the virDomainDestroy impl
      in QEMU, do not ignore the return value. This ensures that
      if QEMU fails to respond to SIGKILL, the caller will know
      about the failure.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      (cherry picked from commit f1b4021b)
      9143006c
    • P
      conf: Remove console stream callback only when freeing console helper · 1baa2fab
      Peter Krempa 提交于
      Commit ba226d33 tried to fix crash of
      the daemon when a domain with an open console was destroyed. The fix was
      wrong as it tried to remove the callback also when the stream was
      aborted, where at that point the fd stream driver was already freed and
      removed.
      
      This patch clears the callbacks with a helper right before the hash is
      freed, so that it doesn't interfere with other codepaths where the
      stream object is freed.
      
      (cherry picked from commit 45edefc7)
      1baa2fab
    • P
      conf: Remove callback from stream when freeing entries in console hash · b01c3ae8
      Peter Krempa 提交于
      When a domain has a active console connection and is destroyed the
      callback is called on private data that no longer exist causing a
      segfault.
      
      (cherry picked from commit ba226d33)
      b01c3ae8
    • L
      storage: Need to also VIR_FREE(reg) · 3afbdfc3
      Luca Tettamanti 提交于
      Commit-id 'afc4631b' added the regfree(reg) to free resources alloc'd
      during regcomp; however, reg still needed to be VIR_FREE()'d. The call
      to regfree() also didn't account for possible NULL value.  Reformatted
      the call to be closer to usage.
      (cherry picked from commit 71da3b66)
      
      Backported to 0.9.12 with afc4631b and its revert skipped.
      
      Signed-off-by: Luca Tettamanti <ltettamanti acunu com>
      3afbdfc3
    • J
      qemu: Add support for -no-user-config · 6a3787f9
      Jiri Denemark 提交于
      Thanks to this new option we are now able to use modern CPU models (such
      as Westmere) defined in external configuration file.
      
      The qemu-1.1{,-device} data files for qemuhelptest are filled in with
      qemu-1.1-rc2 output for now. I will update those files with real
      qemu-1.1 output once it is released.
      
      (cherry picked from commit 63b42436)
      6a3787f9
    • P
      rpc: Fix crash on error paths of message dispatching · ba92d4a9
      Peter Krempa 提交于
      This patch resolves CVE-2013-0170:
      https://bugzilla.redhat.com/show_bug.cgi?id=893450
      
      When reading and dispatching of a message failed the message was freed
      but wasn't removed from the message queue.
      
      After that when the connection was about to be closed the pointer for
      the message was still present in the queue and it was passed to
      virNetMessageFree which tried to call the callback function from an
      uninitialized pointer.
      
      This patch removes the message from the queue before it's freed.
      
      * rpc/virnetserverclient.c: virNetServerClientDispatchRead:
          - avoid use after free of RPC messages
      
      (cherry picked from commit 46532e3e)
      ba92d4a9
    • P
      qemu: Fix off-by-one error while unescaping monitor strings · 904fa209
      Peter Krempa 提交于
      While unescaping the commands the commands passed through to the monitor
      function qemuMonitorUnescapeArg() initialized lenght of the input string
      to strlen()+1 which is fine for alloc but not for iteration of the
      string.
      
      This patch fixes the off-by-one error and drops the pointless check for
      a single trailing slash that is automaticaly handled by the default
      branch of switch.
      
      (cherry picked from commit 0f4660c8)
      904fa209
    • J
      Revert "rpc: Discard non-blocking calls only when necessary" · 27977c7b
      Jiri Denemark 提交于
      This reverts commit b1e374a7, which was
      rather bad since I failed to consider all sides of the issue. The main
      things I didn't consider properly are:
      
      - a thread which sends a non-blocking call waits for the thread with
        the buck to process the call
      - the code doesn't expect non-blocking calls to remain in the queue
        unless they were already partially sent
      
      Thus, the reverted patch actually breaks more than what it fixes and
      clients (which may even be libvirtd during p2p migrations) will likely
      end up in a deadlock.
      
      (cherry picked from commit 63643f67)
      27977c7b
    • E
      build: fix virnetlink on glibc 2.11 · 16908590
      Eric Blake 提交于
      We were being lazy - virnetlink.c was getting uint32_t as a
      side-effect from glibc 2.14's <unistd.h>, but older glibc 2.11
      does not provide uint32_t from <unistd.h>.  In fact, POSIX states
      that <unistd.h> need only provide intptr_t, not all of <stdint.h>,
      so the bug really is ours.  Reported by Jonathan Alescio.
      
      * src/util/virnetlink.h: Include <stdint.h>.
      
      (cherry picked from commit e8314e78)
      16908590
  3. 11 9月, 2013 2 次提交
    • M
      security: Fix libvirtd crash possibility · addf5e1b
      Martin Kletzander 提交于
      Fix for CVE-2012-4423.
      
      When generating RPC protocol messages, it's strictly needed to have a
      continuous line of numbers or RPC messages. However in case anyone
      tries backporting some functionality and will skip a number, there is
      a possibility to make the daemon segfault with newer virsh (version of
      the library, rpc call, etc.) even unintentionally.
      
      The problem is that the skipped numbers will get func filled with
      NULLs, but there is no check whether these are set before the daemon
      tries to run them. This patch very simply enhances one check and fixes
      that.
      
      (cherry picked from commit b7ff9e69)
      addf5e1b
    • J
      daemon: Fix crash in virTypedParameterArrayClear · 11568ec8
      Jiri Denemark 提交于
      Daemon uses the following pattern when dispatching APIs with typed
      parameters:
      
          VIR_ALLOC_N(params, nparams);
          virDomain*(dom, params, &nparams, flags);
          virTypedParameterArrayClear(params, nparams);
      
      In case nparams was originally set to 0, virDomain* API would fill it
      with the number of typed parameters it can provide and we would use this
      number (rather than zero) to clear params. Because VIR_ALLOC* returns
      non-NULL pointer even if size is 0, the code would end up walking
      through random memory. If we were lucky enough and the memory contained
      7 (VIR_TYPED_PARAM_STRING) at the right place, we would try to free a
      random pointer and crash.
      
      Let's make sure params stays NULL when nparams is 0.
      
      (cherry picked from commit 6039a2cb)
      11568ec8
  4. 14 5月, 2012 1 次提交
    • D
      Release of libvirt-0.9.12 · a25d5cfd
      Daniel Veillard 提交于
      * configure.ac docs/news.html.in libvirt.spec.in: updates for the release
      * po/*.po: pushed new sources and synchronized new languages translations
      a25d5cfd
  5. 13 5月, 2012 1 次提交
    • M
      esx: Fix memory leaks in error paths related to transferred ownership · 3b9a1295
      Matthias Bolte 提交于
      Appending an item to a list transfers ownership of that item to the
      list owner. But an error can occur in between item allocation and
      appending it to the list. In this case the item has to be freed
      explicitly. This was not done in some special cases resulting in
      possible memory leaks.
      
      Reported by Coverity.
      3b9a1295
  6. 11 5月, 2012 6 次提交
    • P
      qemu: Don't skip detection of virtual cpu's on non KVM targets · c8335269
      Peter Krempa 提交于
      This patch lifts the limit of calling thread detection code only on KVM
      guests. With upstream qemu the thread mappings are reported also on
      non-KVM machines.
      
      QEMU adopted the thread_id information from the kvm branch.
      
      To remain compatible with older upstream versions of qemu the check is
      attempted but the failure to detect threads (or even run the monitor
      command - on older versions without SMP support) is treated non-fatal
      and the code reports one vCPU with pid of the hypervisor (in same
      fashion this was done on non-KVM guests).
      c8335269
    • P
      qemu: Re-detect virtual cpu threads after cpu hot (un)plug. · 3163682b
      Peter Krempa 提交于
      After a cpu hotplug the qemu driver did not refresh information about
      virtual processors used by qemu and their corresponding threads. This
      patch forces a re-detection as is done on start of QEMU.
      
      This ensures that correct information is reported by the
      virDomainGetVcpus API and "virsh vcpuinfo".
      
      A failure to obtain the thread<->vcpu mapping is treated non-fatal and
      the mapping is not updated in a case of failure as not all versions of
      QEMU report this in the info cpus command.
      3163682b
    • P
      qemu: Refactor qemuDomainSetVcpusFlags · e99ad93d
      Peter Krempa 提交于
      This patch changes a switch statement into ifs when handling live vs.
      configuration modifications getting rid of redundant code in case when
      both live and persistent configuration gets changed.
      e99ad93d
    • E
      build: fix stamp file name · c0057d9a
      Eric Blake 提交于
      Ever since commit c964b6aa, make was trying to find the timestamp
      of '""./apibuild.py".stamp"', but only touching 'apibuild.py.stamp',
      and thus always rebuilding.  Reported by Daniel P. Berrange.
      
      * docs/Makefile.am (APIBUILD, APIBUILD_STAMP): Omit bogus quotes.
      c0057d9a
    • G
      usb: fix crash when failing to attach a second usb device · ab5fb8f3
      Guannan Ren 提交于
      when failing to attach another usb device to a domain for some reason
      which has one use device attached before, the libvirtd crashed.
      The crash is caused by null-pointer dereference error in invoking
      usbDeviceListSteal passed in NULL value usb variable.
      commit 05abd150 introduces the bug.
      ab5fb8f3
    • E
      docs: mention migration issue of which credentials are used · 38bd605b
      Eric Blake 提交于
      Based on a report by Seth Vidal.  Just because _you_ can use virsh
      to connect to both source and destinations does not mean that libvirtd
      on the source (aka _root_) can likewise connect to the destination;
      this matters when setting up a peer-to-peer migration instead of a
      native one.
      
      * docs/migration.html.in: Mention that in peer-to-peer, the owner
      of the source libvirtd (usually root) must be able to connect to
      the destination.
      38bd605b
  7. 10 5月, 2012 4 次提交
    • O
      build: Fix the typo in configure.ac · eecee94c
      Osier Yang 提交于
      s/nuamd/numad/,
      eecee94c
    • A
      conf: Fix memory leaks in virStoragePoolDefParseSource · 15e0b20a
      Alex Jia 提交于
      Detected by valgrind. Leaks are introduced in commit 122fa379.
      
      src/conf/storage_conf.c: fix memory leaks.
      
      How to reproduce?
      $ make && make -C tests check TESTS=storagepoolxml2xmltest
      $ cd tests && valgrind -v --leak-check=full ./storagepoolxml2xmltest
      
      actual result:
      ==28571== LEAK SUMMARY:
      ==28571==    definitely lost: 40 bytes in 5 blocks
      ==28571==    indirectly lost: 0 bytes in 0 blocks
      ==28571==      possibly lost: 0 bytes in 0 blocks
      ==28571==    still reachable: 1,054 bytes in 21 blocks
      ==28571==         suppressed: 0 bytes in 0 blocks
      Signed-off-by: NAlex Jia <ajia@redhat.com>
      15e0b20a
    • E
      qemu: fix build when !HAVE_NUMACTL · 5c650b98
      Eric Blake 提交于
      Commit 97010eb1 forgot to change the other side of an #ifdef.
      
      * src/qemu/qemu_process.c (qemuProcessInitNumaMemoryPolicy): Add
      argument.
      5c650b98
    • J
      Report error when parsing character device target type · 10a87145
      Jim Fehlig 提交于
      No useful error was being reported when an invalid character device
      target type is specified in the domainXML. E.g.
      
          ...
          <console type="pty">
            <source path="/dev/pts/2"/>
            <target type="kvm" port="0"/>
          </console>
          ...
      
      resulted in
      
      error: Failed to define domain from x.xml
      error: An error occurred, but the cause is unknown
      
      With this small patch, the error is more helpful
      
      error: Failed to define domain from x.xml
      error: XML error: unknown target type 'kvm' specified for character device
      10a87145
  8. 09 5月, 2012 8 次提交
    • J
      netlink: Fix build with libnl-3 · d9d39e62
      Jiri Denemark 提交于
      Commit 64297313 added three direct
      references to nl_handle_* instead of using our aliases which hide
      differences between libnl-3 and libnl-1.
      d9d39e62
    • O
      numad: Update comments in libvirt.spec.in · b736e722
      Osier Yang 提交于
      Not only support CPU placement now.
      b736e722
    • O
      numad: Check numactl-devel if compiled with numad support · b0f32445
      Osier Yang 提交于
      Since now we pre-set memory policy using libnuma to fully
      drive numad, it needs to check numactl-devel if "with_numad"
      is "yes".
      
      configure with groups "--with-numad=yes --with-numactl=yes",
      "--with-numad=no --with-numactl=yes", "--with-numad=yes
      --with-numactl=yes" works fine after the change.
      b0f32445
    • O
      numad: Divide cur_balloon by 1024 before passing it to numad · a00efdda
      Osier Yang 提交于
      Numad expects MB by default.
      a00efdda
    • O
      numad: Always output 'placement' of <vcpu> · d70f2e11
      Osier Yang 提交于
      <vcpu> is not an optional node. The value for its 'placement'
      actually always defaults to 'static' in the underlying codes.
      (Even no 'cpuset' and 'placement' is specified, the domain
      process will be pinned to all the available pCPUs).
      d70f2e11
    • O
      numad: Copy 'placement' of <numatune> to <vcpu> by default · 8d26a7fd
      Osier Yang 提交于
      With this patch, one can also fully drive numad by:
      
        <vcpu>2</vcpu>
        <numatune>
          <memory placement='auto'/>
        </numatune>
      
      New tests are added.
      8d26a7fd
    • O
      numad: Set memory policy from numad advisory nodeset · 97010eb1
      Osier Yang 提交于
      Though numad will manage the memory allocation of task dynamically,
      it wants management application (libvirt) to pre-set the memory
      policy according to the advisory nodeset returned from querying numad,
      (just like pre-bind CPU nodeset for domain process), and thus the
      performance could benefit much more from it.
      
      This patch introduces new XML tag 'placement', value 'auto' indicates
      whether to set the memory policy with the advisory nodeset from numad,
      and its value defaults to the value of <vcpu> placement, or 'static'
      if 'nodeset' is specified. Example of the new XML tag's usage:
      
        <numatune>
          <memory placement='auto' mode='interleave'/>
        </numatune>
      
      Just like what current "numatune" does, the 'auto' numa memory policy
      setting uses libnuma's API too.
      
      If <vcpu> "placement" is "auto", and <numatune> is not specified
      explicitly, a default <numatume> will be added with "placement"
      set as "auto", and "mode" set as "strict".
      
      The following XML can now fully drive numad:
      
      1) <vcpu> placement is 'auto', no <numatune> is specified.
      
         <vcpu placement='auto'>10</vcpu>
      
      2) <vcpu> placement is 'auto', no 'placement' is specified for
         <numatune>.
      
         <vcpu placement='auto'>10</vcpu>
         <numatune>
           <memory mode='interleave'/>
         </numatune>
      
      And it's also able to control the CPU placement and memory policy
      independently. e.g.
      
      1) <vcpu> placement is 'auto', and <numatune> placement is 'static'
      
         <vcpu placement='auto'>10</vcpu>
         <numatune>
           <memory mode='strict' nodeset='0-10,^7'/>
         </numatune>
      
      2) <vcpu> placement is 'static', and <numatune> placement is 'auto'
      
         <vcpu placement='static' cpuset='0-24,^12'>10</vcpu>
         <numatune>
           <memory mode='interleave' placement='auto'/>
         </numatume>
      
      A follow up patch will change the XML formatting codes to always output
      'placement' for <vcpu>, even it's 'static'.
      97010eb1
    • E
      snapshot: allow block devices past cgroup · 8be304ec
      Eric Blake 提交于
      It turns out that when cgroups are enabled, the use of a block device
      for a snapshot target was failing with EPERM due to libvirt failing
      to add the block device to the cgroup whitelist.  See also
      https://bugzilla.redhat.com/show_bug.cgi?id=810200
      
      * src/qemu/qemu_driver.c
      (qemuDomainSnapshotCreateSingleDiskActive)
      (qemuDomainSnapshotUndoSingleDiskActive): Account for cgroup.
      (qemuDomainSnapshotCreateDiskActive): Update caller.
      8be304ec