1. 16 5月, 2012 14 次提交
    • D
      Avoid LXC pivot root in the root source is still / · c16b4c43
      Daniel P. Berrange 提交于
      If the LXC config has a filesystem
      
        <filesystem>
           <source dir='/'/>
           <target dir='/'/>
        </filesystem>
      
      then there is no need to go down the pivot root codepath.
      We can simply use the existing root as needed.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      c16b4c43
    • D
      Mount fresh instance of sysfs/selinux in LXC · e8639920
      Daniel P. Berrange 提交于
      Currently to make sysfs readonly, we remount the existing
      instance and then bind it readonly. Unfortunately this means
      sysfs is still showing device objects wrt the host OS namespace.
      We need it to reflect the container namespace, so we must mount
      a completely new instance of it. Do the same for selinuxfs since
      there is no benefit to bind mounting & this lets us simplify
      the code.
      
      * src/lxc/lxc_container.c: Mount fresh sysfs instance
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      e8639920
    • D
      Convert the LXC driver to use the security driver API for mount options · 8dd5794f
      Daniel Walsh 提交于
      Instead of hardcoding use of SELinux contexts in the LXC driver,
      switch over to using the official security driver API.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      8dd5794f
    • D
      Add security driver APIs for getting mount options · abf2ebbd
      Daniel Walsh 提交于
      Some security drivers require special options to be passed to
      the mount system call. Add a security driver API for handling
      this data.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      abf2ebbd
    • D
      Add support for LXC specific SELinux configuration · 6844cead
      Daniel Walsh 提交于
      The SELinux policy for LXC uses a different configuration file
      than the traditional svirt one. Thus we need to load
      /etc/selinux/targeted/contexts/lxc_contexts which contains
      something like this:
      
       process = "system_u:system_r:svirt_lxc_net_t:s0"
       file = "system_u:object_r:svirt_lxc_file_t:s0"
       content = "system_u:object_r:virt_var_lib_t:s0"
      
      cleverly designed to be parsable by virConfPtr
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      6844cead
    • D
      Use private data struct in SELinux driver · fa5e68ff
      Daniel Walsh 提交于
      Currently the SELinux driver stores its state in a set of global
      variables. This switches it to use a private data struct instead.
      This will enable different instances to have their own data.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      fa5e68ff
    • D
      Don't enable the AppArmour security driver with LXC · cf36c23b
      Daniel Walsh 提交于
      The AppArmour driver does not currently have support for LXC
      so ensure that when probing, it claims to be disabled
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      cf36c23b
    • D
      Pass the virt driver name into security drivers · 73580c60
      Daniel Walsh 提交于
      To allow the security drivers to apply different configuration
      information per hypervisor, pass the virtualization driver name
      into the security manager constructor.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      73580c60
    • J
      qemu: Add support for -no-user-config · 63b42436
      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.
      63b42436
    • D
      Set a sensible default master start port for ehci companion controllers · 03b804a2
      Daniel P. Berrange 提交于
      The uhci1, uhci2, uhci3 companion controllers for ehci1 must
      have a master start port set. Since this value is predictable
      we should set it automatically if the app does not supply it
      03b804a2
    • D
      Fix logic for assigning PCI addresses to USB2 companion controllers · 1ebd52cb
      Daniel P. Berrange 提交于
      Currently each USB2 companion controller gets put on a separate
      PCI slot. Not only is this wasteful of PCI slots, but it is not
      in compliance with the spec for USB2 controllers. The master
      echi1 and all companion controllers should be in the same slot,
      with echi1 in function 7, and uhci1-3 in functions 0-2 respectively.
      
      * src/qemu/qemu_command.c: Special case handling of USB2 controllers
        to apply correct pci slot assignment
      * tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-ehci-addr.args,
        tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-ehci-addr.xml: Expand
        test to cover automatic slot assignment
      1ebd52cb
    • D
      Fix virDomainDeviceInfoIsSet() to check all struct fields · 2c195fdb
      Daniel P. Berrange 提交于
      The virDomainDeviceInfoIsSet API was only checking if an
      address or alias was set in the struct. Thus if only a
      rom bar setting / filename, boot index, or USB master
      value was set, they could be accidentally dropped when
      formatting XML
      2c195fdb
    • D
      Remove redundant trailing slash in user dir paths · b3567ef3
      Daniel P. Berrange 提交于
      Callers of virGetUser{Config,Runtime,Cache}Directory all
      append further path component. We should not be
      adding a trailing slash in the return path otherwise we
      get paths containing '//'
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      b3567ef3
    • D
      Allow stack traces to be included with log messages · 54856395
      Daniel P. Berrange 提交于
      Sometimes it is useful to see the callpath for log messages.
      This change enhances the log filter syntax so that stack traces
      can be show by setting '1:+NAME' instead of '1:NAME'.
      
      This results in output like:
      
      2012-05-09 14:18:45.136+0000: 13314: debug : virInitialize:414 : register drivers
      /home/berrange/src/virt/libvirt/src/.libs/libvirt.so.0(virInitialize+0xd6)[0x7f89188ebe86]
      /home/berrange/src/virt/libvirt/tools/.libs/lt-virsh[0x431921]
      /lib64/libc.so.6(__libc_start_main+0xf5)[0x3a21e21735]
      /home/berrange/src/virt/libvirt/tools/.libs/lt-virsh[0x40a279]
      
      2012-05-09 14:18:45.136+0000: 13314: debug : virRegisterDriver:775 : driver=0x7f8918d02760 name=Test
      /home/berrange/src/virt/libvirt/src/.libs/libvirt.so.0(virRegisterDriver+0x6b)[0x7f89188ec717]
      /home/berrange/src/virt/libvirt/src/.libs/libvirt.so.0(+0x11b3ad)[0x7f891891e3ad]
      /home/berrange/src/virt/libvirt/src/.libs/libvirt.so.0(virInitialize+0xf3)[0x7f89188ebea3]
      /home/berrange/src/virt/libvirt/tools/.libs/lt-virsh[0x431921]
      /lib64/libc.so.6(__libc_start_main+0xf5)[0x3a21e21735]
      /home/berrange/src/virt/libvirt/tools/.libs/lt-virsh[0x40a279]
      
      * docs/logging.html.in: Document new syntax
      * configure.ac: Check for execinfo.h
      * src/util/logging.c, src/util/logging.h: Add support for
        stack traces
      * tests/testutils.c: Adapt to API change
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      54856395
  2. 15 5月, 2012 9 次提交
    • D
      Move user libvirtd socket out of abstract namespace · 905be03d
      Daniel P. Berrange 提交于
      The current unprivileged user libvirtd sockets are in the abstract
      namespace. This has a number of problems
      
       - You can't connect to them remotely using the nc/ssh tunnel
       - This is not portable for OS-X, BSD & probably others
       - Parent directory permissions don't apply
      905be03d
    • G
      openvz: determine kb/pages only once · 80fd8367
      Guido Günther 提交于
      to save some syscalls (as suggested by Eric Blake)
      80fd8367
    • O
      nodeinfo: Get the correct CPU number on AMD Magny Cours platform · 10d9038b
      Osier Yang 提交于
      "Instead of developing one CPU with 12 cores, the Magny Cours is
      actually two 6 core “Bulldozer” CPUs combined in to one package"
      
      I.e, each package has two NUMA nodes, and the two numa nodes share
      the same core ID set (0-6), which means parsing the cores number
      from sysfs doesn't work in this case.
      
      And the wrong CPU number could cause three problems for libvirt:
      
      1) performance lost
      
        A domain without "cpuset" or "placement='auto'" (to drive numad)
      specified will be only pinned to part of the CPUs.
      
      2) domain can be started
      
        If a domain uses numad, and the advisory nodeset returned from
      numad contains node which exceeds the range of wrong total CPU
      number. The domain will fail to start, as the bitmask passed to
      sched_setaffinity could be fully filled with zero.
      
      3) wrong CPU number affects lots of stuffs.
      
        E.g. for command "virsh vcpuinfo", "virsh vcpupin", it will always
      output with the truncated CPU list.
      
      For more details:
      
      https://www.redhat.com/archives/libvir-list/2012-May/msg00607.html
      
      This patch is to fix the problem by parsing /proc/cpuinfo to get
      the value of field "cpu cores", and use it as nodeinfo->cores if
      it's greater than the cores number from sysfs.
      10d9038b
    • O
      qemu: Set memory policy using cgroup if placement is auto · be9f6ecb
      Osier Yang 提交于
      Like for 'static' placement, when the memory policy mode is
      'strict', set the memory policy by writing the advisory nodeset
      returned from numad to cgroup file cpuset.mems,
      be9f6ecb
    • O
      qemu: Use the CPU index in capabilities to map NUMA node to cpu list. · d1bdeca8
      Osier Yang 提交于
      On some of the NUMA platforms, the CPU index in each NUMA node
      grows non-consecutive. While on other platforms, it can be inconsecutive,
      E.g.
      
      % numactl --hardware
      available: 4 nodes (0-3)
      node 0 cpus: 0 4 8 12 16 20 24 28
      node 0 size: 131058 MB
      node 0 free: 86531 MB
      node 1 cpus: 1 5 9 13 17 21 25 29
      node 1 size: 131072 MB
      node 1 free: 127070 MB
      node 2 cpus: 2 6 10 14 18 22 26 30
      node 2 size: 131072 MB
      node 2 free: 127758 MB
      node 3 cpus: 3 7 11 15 19 23 27 31
      node 3 size: 131072 MB
      node 3 free: 127226 MB
      node distances:
      node   0   1   2   3
        0:  10  20  20  20
        1:  20  10  20  20
        2:  20  20  10  20
        3:  20  20  20  10
      
      This patch is to fix the problem by using the CPU index in
      caps->host.numaCell[i]->cpus[i] to set the bitmask instead of
      assuming the CPU index of the NUMA nodes are always sequential.
      d1bdeca8
    • L
      Assign spapr-vio bus address to ibmvscsi controller · bb725ac1
      Li Zhang 提交于
      For pseries guest, the default controller model is
      ibmvscsi controller, this controller only can work
      on spapr-vio address.
      
      This patch is to assign spapr-vio address type to
      ibmvscsi controller and correct vscsi test case.
      Signed-off-by: NLi Zhang <zhlcindy@linux.vnet.ibm.com>
      bb725ac1
    • D
      sanlock: fix locking for readonly devices · b8012ce9
      David Weber 提交于
      Add ignore param for readonly and shared disk in sanlock
      b8012ce9
    • E
      nodeinfo: avoid probing host filesystem during test · 2b366b46
      Eric Blake 提交于
      We had previously weakened our nodeinfotest in order to ignore parsed
      node values, because the parse function was mistakenly relying on
      host files.  A better fix is to avoid using the numactl library, but
      to instead parse the same files that numactl would read, all while
      allowing the files to be relative to our choice of directory.
      
      * src/nodeinfo.c (CPU_SYS_PATH, NODE_SYS_PATH): Replace with...
      (SYSFS_SYSTEM_PATH): ...parent directory.
      (linuxNodeInfoCPUPopulate): Check NUMA nodes from requested
      directory (by inlining numactl code).
      (nodeGetCPUmap, nodeGetMemoryStats): Adjust macro use.
      * tests/nodeinfotest.c (linuxTestCompareFiles, linuxTestNodeInfo):
      Update test to match.
      2b366b46
    • E
      nodeinfo: drop static variable · 88f12a36
      Eric Blake 提交于
      We were wasting time to malloc a copy of a constant string, then
      copy it into static storage, for every call to nodeGetInfo.  At
      least we were lucky that it was a constant source, and thus not
      subject to even worse issues with one thread clobbering the static
      storage while another was using it.  This gets rid of the waste,
      by passing the string through the stack instead, as well as renaming
      internal functions to better match our conventions.
      
      * src/nodeinfo.c (sysfs_path): Delete.
      (get_cpu_value, count_thread_siblings, parse_socket): Add
      parameter, and rename...
      (virNodeGetCpuValue, virNodeCountThreadSiblings)
      (virNodeParseSocket): ... into a common namespace.
      (cpu_online, parse_core): Inline into callers.
      (linuxNodeInfoCPUPopulate): Update caller.
      (nodeGetInfo): Drop a useless malloc.
      88f12a36
  3. 14 5月, 2012 2 次提交
    • E
      build: really silence the 32-bit warning · 5f89c860
      Eric Blake 提交于
      Commit cdce2f42 tried to silence a compiler warning on 32-bit builds,
      but the gcc shipped with RHEL 5 is old enough that the type conversion
      via multiplication by 1 was insufficient for the task.
      
      * src/qemu/qemu_monitor.c (qemuMonitorBlockJob): Previous attempt
      didn't get past all gcc versions.
      5f89c860
    • W
      Use XDG Base Directories instead of storing in home directory · 32a9aac2
      William Jon McCann 提交于
      As defined in:
      http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
      
      This offers a number of advantages:
       * Allows sharing a home directory between different machines, or
      sessions (eg. using NFS)
       * Cleanly separates cache, runtime (eg. sockets), or app data from
      user settings
       * Supports performing smart or selective migration of settings
      between different OS versions
       * Supports reseting settings without breaking things
       * Makes it possible to clear cache data to make room when the disk
      is filling up
       * Allows us to write a robust and efficient backup solution
       * Allows an admin flexibility to change where data and settings are stored
       * Dramatically reduces the complexity and incoherence of the
      system for administrators
      32a9aac2
  4. 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
  5. 11 5月, 2012 4 次提交
    • 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
    • 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
  6. 10 5月, 2012 3 次提交
    • 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
  7. 09 5月, 2012 7 次提交
    • 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: 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
    • A
      domain_conf: add "default" to list of valid spice channels · ba97e4ed
      Alon Levy 提交于
      qemu's behavior in this case is to change the spice server behavior to
      require secure connection to any channel not otherwise specified as
      being in plaintext mode. libvirt doesn't currently allow requesting this
      (via plaintext-channel=<channel name>).
      
      RHBZ: 819499
      Signed-off-by: NAlon Levy <alevy@redhat.com>
      ba97e4ed