1. 22 8月, 2012 7 次提交
    • H
      Introduce the function virCgroupMoveTask · 91028296
      Hu Tao 提交于
      Introduce a new API to move tasks of one controller from a cgroup to another cgroup
      Signed-off-by: NWen Congyang <wency@cn.fujitsu.com>
      Signed-off-by: NTang Chen <tangchen@cn.fujitsu.com>
      Signed-off-by: NHu Tao <hutao@cn.fujitsu.com>
      91028296
    • W
      Introduce the function virCgroupForEmulator · 92741ef3
      Wen Congyang 提交于
      Introduce the function virCgroupForEmulator() to create sub directory
      for simulator thread(include I/O thread, vhost-net thread)
      Signed-off-by: NWen Congyang <wency@cn.fujitsu.com>
      Signed-off-by: NTang Chen <tangchen@cn.fujitsu.com>
      Signed-off-by: NHu Tao <hutao@cn.fujitsu.com>
      92741ef3
    • E
      atomic: fix whitespace in previous patch · cd8f8c8d
      Eric Blake 提交于
      cd8f8c8d
    • E
      atomic: mark header functions static · bf76174b
      Eric Blake 提交于
      When gcc atomic intrinsics are not available (such as on RHEL 5
      with gcc 4.1.2), we were getting link errors due to multiple
      definitions:
      
      ./.libs/libvirt_util.a(libvirt_util_la-virobject.o): In function `virAtomicIntXor':
      /home/dummy/l,ibvirt/src/util/viratomoic.h:404: multiple definition of `virAtomicIntXor'
      ./.libs/libvirt_util.a(libvirt_util_la-viratomic.o):/home/dummy/libvirt/src/util/viratomic.h:404: first defined here
      
      Solve this by conditionally marking the functions static (the
      condition avoids falling foul of gcc warnings about unused
      static function declarations).
      
      * src/util/viratomic.h: When not using gcc intrinsics, use static
      functions to avoid linker errors on duplicate functions.
      bf76174b
    • E
      build: work with older RHEL 5 kernel · 77de1f35
      Eric Blake 提交于
      We already skip out on building the LXC under RHEL 5, because the
      kernel is too old (commits 4c18acff, 2dee8965); but commit 9612e4b2
      moved some LXC-only code into common files, resulting in this
      build failure:
      
      util/virfile.c: In function 'virFileLoopDeviceAssociate':
      util/virfile.c:580: error: 'LO_FLAGS_AUTOCLEAR' undeclared (first use in this function)
      
      Unfortunately, the kernel folks only made it an enum, rather than
      also a #define, so we have to modify configure.ac to record when
      it is usable.
      
      * configure.ac (with_lxc): Mark when LO_FLAGS_AUTOCLEAR was found.
      * src/util/virfile.c (virFileLoopDeviceAssociate): Avoid
      compilation when kernel is too old.
      77de1f35
    • J
      command: avoid double close in virExecWithHook · 8211c677
      Ján Tomko 提交于
      Fix possible double close in the child process after the fork in case
      infd and outfd are equal, just like they are after being called from
      virNetSocketNewConnectCommand.
      8211c677
    • T
      network: use firewalld instead of iptables, when available · bf156385
      Thomas Woerner 提交于
      * configure.ac, spec file: firewalld defaults to enabled if dbus is
        available, otherwise is disabled. If --with_firewalld is explicitly
        requested and dbus is not available, configure will fail.
      
      * bridge_driver: add dbus filters to get the FirewallD1.Reloaded
        signal and DBus.NameOwnerChanged on org.fedoraproject.FirewallD1.
        When these are encountered, reload all the iptables reuls of all
        libvirt's virtual networks (similar to what happens when libvirtd is
        restarted).
      
      * iptables, ebtables: use firewall-cmd's direct passthrough interface
        when available, otherwise use iptables and ebtables commands. This
        decision is made once the first time libvirt calls
        iptables/ebtables, and that decision is maintained for the life of
        libvirtd.
      
      * Note that the nwfilter part of this patch was separated out into
        another patch by Stefan in V2, so that needs to be revised and
        re-reviewed as well.
      
      ================
      
      All the configure.ac and specfile changes are unchanged from Thomas'
      V3.
      
      V3 re-ran "firewall-cmd --state" every time a new rule was added,
      which was extremely inefficient.  V4 uses VIR_ONCE_GLOBAL_INIT to set
      up a one-time initialization function.
      
      The VIR_ONCE_GLOBAL_INIT(x) macro references a static function called
      vir(Ip|Eb)OnceInit(), which will then be called the first time that
      the static function vir(Ip|Eb)TablesInitialize() is called (that
      function is defined for you by the macro). This is
      thread-safe, so there is no chance of any race.
      
      IMPORTANT NOTE: I've left the VIR_DEBUG messages in these two init
      functions (one for iptables, on for ebtables) as VIR_WARN so that I
      don't have to turn on all the other debug message just to see
      these. Even if this patch doesn't need any other modification, those
      messages need to be changed to VIR_DEBUG before pushing.
      
      This one-time initialization works well. However, I've encountered
      problems with testing:
      
      1) Whenever I have enabled the firewalld service, *all* attempts to
      call firewall-cmd from within libvirtd end with firewall-cmd hanging
      internally somewhere. This is *not* the case if firewall-cmd returns
      non-0 in response to "firewall-cmd --state" (i.e. *that* command runs
      and returns to libvirt successfully.)
      
      2) If I start libvirtd while firewalld is stopped, then start
      firewalld later, this triggers libvirtd to reload its iptables rules,
      however it also spits out a *ton* of complaints about deletion failing
      (I suppose because firewalld has nuked all of libvirt's rules). I
      guess we need to suppress those messages (which is a more annoying
      problem to fix than you might think, but that's another story).
      
      3) I noticed a few times during this long line of errors that
      firewalld made a complaint about "Resource Temporarily
      unavailable. Having libvirtd access iptables commands directly at the
      same time as firewalld is doing so is apparently problematic.
      
      4) In general, I'm concerned about the "set it once and never change
      it" method - if firewalld is disabled at libvirtd startup, causing
      libvirtd to always use iptables/ebtables directly, this won't cause
      *terrible* problems, but if libvirtd decides to use firewall-cmd and
      firewalld is later disabled, libvirtd will not be able to recover.
      bf156385
  2. 21 8月, 2012 1 次提交
    • P
      libssh2_transport: add main libssh2 transport implementation · 1193fc5f
      Peter Krempa 提交于
      This patch adds helper functions that enable us to use libssh2 in
      conjunction with libvirt's virNetSockets for ssh transport instead of
      spawning "ssh" client process.
      
      This implemetation supports tunneled plaintext, keyboard-interactive,
      private key, ssh agent based and null authentication. Libvirt's Auth
      callback is used for interaction with the user. (Keyboard interactive
      authentication, adding of host keys, private key passphrases). This
      enables seamless integration into the application using libvirt. No
      helpers as "ssh-askpass" are needed.
      
      Reading and writing of OpenSSH style "known_hosts" files is supported.
      
      Communication is done using SSH exec channel, where the user may specify
      arbitrary command to be executed on the remote side and reads and writes
      to/from stdin/out are sent through the ssh channel. Usage of stderr is
      not (yet) supported.
      1193fc5f
  3. 18 8月, 2012 2 次提交
  4. 17 8月, 2012 1 次提交
  5. 16 8月, 2012 2 次提交
    • L
      util: properly save/restore original vlan tag for VFs · e979226b
      Laine Stump 提交于
      When a network device that is a VF of an SR-IOV card was assigned to a
      guest using <interface type='hostdev'>, only the MAC address was being
      saved/restored, but the VLAN tag was left untouched. Up to now we
      haven't actually used vlan tags on SR-IOV devices, so the guest would
      have used whatever was set, and left it the same at the end.
      
      The patch following this one will hook up the <vlan> element from the
      interface config, so save/restore of the device state needs to also
      include the vlan tag.
      
      MAC address is being saved as a simple ASCII string in a file named
      for the device under /var/run.  The VLAN tag is now just added at the
      end of that file, after a newline. It might be nicer if the file was
      XML (in case it ever gets more complicated) but at the moment there's
      nothing else on the horizon, and this makes backward compatibility
      easier.
      e979226b
    • L
      util: add virNetDevVlanType · cfbdd005
      Laine Stump 提交于
      To allow for the possibility of vlan "trunks", which have more than
      one vlan tag associated with them, we need a vlan struct. Since it
      will be used by multiple files in src/util, src/conf, src/network, and
      src/qemu, it must be defined in src/util. Unfortunately there isn't
      currently a common file for simple netdev data definitions, so I
      created a new file.
      cfbdd005
  6. 15 8月, 2012 9 次提交
    • L
      util: include memory.h even if WITH_VIRTUALPORT isn't defined · 5faff3d3
      Laine Stump 提交于
      This caused compilation of virnetdevvportprofile.c to fail on systems
      without IFLA support in netlink (these are netlink commands used to
      configure the VF's of SR-IOV network devices).
      5faff3d3
    • D
      Fix virJSONValueToString prototype for Mingw32 · f376d24e
      Daniel P. Berrange 提交于
      Fix build on platforms lacking YAJL library by adding missing
      'bool pretty' parameter to virJSONValueToString.
      f376d24e
    • D
      Add APIs for virThreadPoolPtr to query some config params · 2241582c
      Daniel P. Berrange 提交于
      It is desirable to be able to query the config params of
      the thread pool, in order to save the server state. Add
      virThreadPoolGetMinWorkers, virThreadPoolGetMaxWorkers
      and virThreadPoolGetPriorityWorkers APIs.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      2241582c
    • D
      Allow control over JSON string pretty printing · ecf00158
      Daniel P. Berrange 提交于
      While the QEMU monitor/agent do not want JSON strings pretty
      printed, other parts of libvirt might. Instead of hardcoding
      QEMU's desired behaviour in virJSONValueToString(), add a
      boolean flag to control pretty printing
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      ecf00158
    • E
      random: link with -lm when needed · c606671a
      Eric Blake 提交于
      Use of ldexp() requires -lm on some platforms; use gnulib to determine
      this for our makefile.  Also, optimize virRandomInt() for the case
      of a power-of-two limit (actually rather common, given that Daniel
      has a pending patch to replace virRandomBits(10) with code that will
      default to virRandomInt(1024) on default SELinux settings).
      
      * .gnulib: Update to latest, for ldexp.
      * bootstrap.conf (gnulib_modules): Import ldexp.
      * src/Makefile.am (libvirt_util_la_CFLAGS): Link with -lm when
      needed.
      * src/util/virrandom.c (virRandomInt): Optimize powers of 2.
      c606671a
    • L
      util: utility functions for virNetDevVPortProfile · 1c02ed14
      Laine Stump 提交于
      This patch adds three utility functions that operate on
      virNetDevVPortProfile objects.
      
      * virNetDevVPortProfileCheckComplete() - verifies that all attributes
          required for the type of the given virtport are specified.
      
      * virNetDevVPortProfileCheckNoExtras() - verifies that there are no
          attributes specified which are inappropriate for the type of the
          given virtport.
      
      * virNetDevVPortProfileMerge3() - merges 3 virtports into a single,
          newly allocated virtport. If any attributes are specified in
          more than one of the three sources, and do not exactly match,
          an error is logged and the function fails.
      
      These new functions depend on new fields in the virNetDevVPortProfile
      object that keep track of whether or not each attribute was
      specified. Since the higher level parse function doesn't yet set those
      fields, these functions are not actually usable yet (but that's okay,
      because they also aren't yet used - all of that functionality comes in
      a later patch.)
      
      Note that these three functions return 0 on success and -1 on
      failure. This may seem odd for the first two Check functions, since
      they could also easily return true/false, but since they actually log
      an error when the requested condition isn't met (and should result in
      a failure of the calling function), I thought 0/-1 was more
      appropriate.
      1c02ed14
    • L
      util: add openvswitch case to virNetDevVPortProfileEqual · 8450d7b2
      Laine Stump 提交于
      This function was overlooked when openvswitch support was
      added. Fortunately it's only use for update-device, which is
      relatively new and seldom-used.
      8450d7b2
    • L
      util: eliminate union in virNetDevVPortProfile · 21ea73e8
      Laine Stump 提交于
      virNetDevVPortProfile has (had) a type field that can be set to one of
      several values, and a union of several structs, one for each
      type. When a domain's interface object is of type "network", the
      domain config may not know beforehand which type of virtualport is
      going to be provided in the actual device handed down from the network
      driver at runtime, but may want to set some values in the virtualport
      that may or may not be used, depending on the type. To support this
      usage, this patch replaces the union of structs with toplevel fields
      in the struct, making it possible for all of the fields to be set at
      the same time.
      21ea73e8
    • L
      util: make return value of virUUIDFormat and virMacAddrFormat useful · 85d9c17d
      Laine Stump 提交于
      Both of these functions returned void, but it's convenient for them to
      return a const char* of the char* that is passed in. This was you can
      call the function and use the result in the same expression/arg.
      85d9c17d
  7. 14 8月, 2012 3 次提交
    • D
      Add virRandom() API to generate numbers with non-power-of-2 limit · aa5bd8b9
      Daniel P. Berrange 提交于
      The current virRandomBits() API is only usable if the caller wants
      a random number in the range [0, n-1) where n is a power of two.
      This adds a virRandom() API which generates a double in the
      range [0.0,1.0) with 48 bits of entropy. It then also adds a
      virRandomInt(uint32_t max) API which generates an unsigned
      in the range [0,@max)
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      aa5bd8b9
    • M
      util: typos in fallback code fo virDoubleToStr · 0a6504d4
      Martin Kletzander 提交于
      Fixes for some typos that somehow didn't get to the final push of the
      commit 43bfa23e.
      0a6504d4
    • M
      json: fix interface locale dependency · 43bfa23e
      Martin Kletzander 提交于
      libvirt creates invalid commands if wrong locale is selected. For
      example with locale that uses comma as a decimal point, JSON commands
      created with decimal numbers are invalid because comma separates the
      entries in JSON. Fortunately even when decimal point is affected,
      thousands grouping is not, because for grouping to be enabled with
      *printf, there has to be an apostrophe flag specified (and supported).
      
      This patch adds specific internal function for converting doubles to
      strings with C locale.
      43bfa23e
  8. 11 8月, 2012 1 次提交
    • P
      virterror: Add error message for unsupported operations. · e9a24e3e
      Peter Krempa 提交于
      This patch introduces a new error code VIR_ERR_OPERATION_UNSUPPORTED to
      mark error messages regarding operations that failed due to lack of
      support on the hypervisor or other than libvirt issues.
      
      The code is first used in reporting error if qemu does not support block
      IO tuning variables yielding error message:
      error: Unable to get block I/O throttle parameters
      error: Operation not supported: block_io_throttle field
      'total_bytes_sec' missing in qemu's output
      
      instead of:
      error: Unable to get block I/O throttle parameters
      error: internal error cannot read total_bytes_sec
      e9a24e3e
  9. 10 8月, 2012 1 次提交
    • E
      build: fix PROBE() usage of intptr_t · 51ee43aa
      Eric Blake 提交于
      Otherwise, in locations like virobject.c where PROBE is used,
      for certain configure options, the compiler warns:
      
      util/virobject.c:110:1: error: 'intptr_t' undeclared (first use in this function)
      
      As long as we are making this header always available, we can
      clean up several other files.
      
      * src/internal.h (includes): Pull in <stdint.h>.
      * src/conf/nwfilter_conf.h: Rely on internal.h.
      * src/storage/storage_backend.c: Likewise.
      * src/storage/storage_backend.h: Likewise.
      * src/util/cgroup.c: Likewise.
      * src/util/sexpr.h: Likewise.
      * src/util/virhashcode.h: Likewise.
      * src/util/virnetdevvportprofile.h: Likewise.
      * src/util/virnetlink.h: Likewise.
      * src/util/virrandom.h: Likewise.
      * src/vbox/vbox_driver.c: Likewise.
      * src/xenapi/xenapi_driver.c: Likewise.
      * src/xenapi/xenapi_utils.c: Likewise.
      * src/xenapi/xenapi_utils.h: Likewise.
      * src/xenxs/xenxs_private.h: Likewise.
      * tests/storagebackendsheepdogtest.c: Likewise.
      51ee43aa
  10. 09 8月, 2012 3 次提交
    • D
      Add APIs for obtaining the unique ID of LVM & SCSI volumes · efd6824c
      Daniel P. Berrange 提交于
      Both LVM volumes and SCSI LUNs have a globally unique
      identifier associated with them. It is useful to be able
      to query this identifier to then perform disk locking,
      rather than try to figure out a stable pathname.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      efd6824c
    • P
      Allow rbd backing stores · 16d3ab86
      Peter Feiner 提交于
      Prevents libvirt from treating RBD backing stores as files. Without this
      patch, creating a domain with a qcow2 overlay on an RBD would fail.
      
      This patch essentially extends 9c7c4a4f,
      which allows nbd backing stores, to allow rbd backing stores.
      16d3ab86
    • P
      Fix errno check, prevent spurious errors under heavy load · bfa74ebe
      Peter Feiner 提交于
      From man poll(2), poll does not set errno=EAGAIN on interrupt, however
      it does set errno=EINTR. Have libvirt retry on the appropriate errno.
      
      Under heavy load, a program of mine kept getting libvirt errors 'poll on
      socket failed: Interrupted system call'. The signals were SIGCHLD from
      processes forked by threads unrelated to those using libvirt.
      bfa74ebe
  11. 08 8月, 2012 1 次提交
    • L
      util: include stderr in log message when an external command fails · b8c298d3
      Laine Stump 提交于
      This patch is in response to:
      
        https://bugzilla.redhat.com/show_bug.cgi?id=818467
      
      If a caller to virCommandRun doesn't ask for the exitstatus of the
      program it's running, the virCommand functions assume that they should
      log an error message and return failure if the exit code isn't
      0. However, only the commandline and exit status are logged, while
      potentially useful information sent by the program to stderr is
      discarded.
      
      Fortunately, virCommandRun is already checking if the caller had asked
      for stderr to be saved and, if not, sets things up to save it in
      *cmd->errbuf. This makes it fairly simple for virCommandWait to
      include *cmd->errbuf in the error log (there are still other callers
      that don't setup errbuf, and even virCommandRun won't set it up if the
      command is being daemonized, so we have to check that it's non-zero).
      b8c298d3
  12. 07 8月, 2012 1 次提交
    • D
      Add a generic reference counted virObject type · 784a99f7
      Daniel P. Berrange 提交于
      This introduces a fairly basic reference counted virObject type
      and an associated virClass type, that use atomic operations for
      ref counting.
      
      In a global initializer (recommended to be invoked using the
      virOnceInit API), a virClass type must be allocated for each
      object type. This requires a class name, a "dispose" callback
      which will be invoked to free memory associated with the object's
      fields, and the size in bytes of the object struct.
      
      eg,
      
         virClassPtr  connclass = virClassNew("virConnect",
                                              sizeof(virConnect),
                                              virConnectDispose);
      
      The struct for the object, must include 'virObject' as its
      first member
      
      eg
      
        struct _virConnect {
          virObject object;
      
          virURIPtr uri;
        };
      
      The 'dispose' callback is only responsible for freeing
      fields in the object, not the object itself. eg a suitable
      impl for the above struct would be
      
        void virConnectDispose(void *obj) {
           virConnectPtr conn = obj;
           virURIFree(conn->uri);
        }
      
      There is no need to reset fields to 'NULL' or '0' in the
      dispose callback, since the entire object will be memset
      to 0, and the klass pointer & magic integer fields will
      be poisoned with 0xDEADBEEF before being free()d
      
      When creating an instance of an object, one needs simply
      pass the virClassPtr eg
      
         virConnectPtr conn = virObjectNew(connclass);
         if (!conn)
            return NULL;
         conn->uri = virURIParse("foo:///bar")
      
      Object references can be manipulated with
      
         virObjectRef(conn)
         virObjectUnref(conn)
      
      The latter returns a true value, if the object has been
      freed (ie its ref count hit zero)
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      784a99f7
  13. 06 8月, 2012 1 次提交
    • E
      virrandom: make virRandomInitialize an automatic one-shot · 87de27b7
      Eric Blake 提交于
      All callers used the same initialization seed (well, the new
      viratomictest forgot to look at getpid()); so we might as well
      make this value automatic.  And while it may feel like we are
      giving up functionality, I documented how to get it back in the
      unlikely case that you actually need to debug with a fixed
      pseudo-random sequence.  I left that crippled by default, so
      that a stray environment variable doesn't cause a lack of
      randomness to become a security issue.
      
      * src/util/virrandom.c (virRandomInitialize): Rename...
      (virRandomOnceInit): ...and make static, with one-shot call.
      Document how to do fixed-seed debugging.
      * src/util/virrandom.h (virRandomInitialize): Drop prototype.
      * src/libvirt_private.syms (virrandom.h): Don't export it.
      * src/libvirt.c (virInitialize): Adjust caller.
      * src/lxc/lxc_controller.c (main): Likewise.
      * src/security/virt-aa-helper.c (main): Likewise.
      * src/util/iohelper.c (main): Likewise.
      * tests/seclabeltest.c (main): Likewise.
      * tests/testutils.c (virtTestMain): Likewise.
      * tests/viratomictest.c (mymain): Likewise.
      87de27b7
  14. 02 8月, 2012 2 次提交
    • D
      Rewrite virAtomic APIs using GLib's atomic ops code · 0c9fd4cf
      Daniel P. Berrange 提交于
      There are a few issues with the current virAtomic APIs
      
       - They require use of a virAtomicInt struct instead of a plain
         int type
       - Several of the methods do not implement memory barriers
       - The methods do not implement compiler re-ordering barriers
       - There is no Win32 native impl
      
      The GLib library has a nice LGPLv2+ licensed impl of atomic
      ops that works with GCC, Win32, or pthreads.h that addresses
      all these problems. The main downside to their code is that
      the pthreads impl uses a single global mutex, instead of
      a per-variable mutex. Given that it does have a Win32 impl
      though, we don't expect anyone to seriously use the pthread.h
      impl, so this downside is not significant.
      
      * .gitignore: Ignore test case
      * configure.ac: Check for which atomic ops impl to use
      * src/Makefile.am: Add viratomic.c
      * src/nwfilter/nwfilter_dhcpsnoop.c: Switch to new atomic
        ops APIs and plain int datatype
      * src/util/viratomic.h: inline impls of all atomic ops
        for GCC, Win32 and pthreads
      * src/util/viratomic.c: Global pthreads mutex for atomic
        ops
      * tests/viratomictest.c: Test validate to validate safety
        of atomic ops.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      0c9fd4cf
    • D
      Remove manual one-shot global initializers · b49890de
      Daniel P. Berrange 提交于
      Remove the use of a manually run virLogStartup and
      virNodeSuspendInitialize methods. Instead make sure they
      are automatically run using VIR_ONCE_GLOBAL_INIT
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      b49890de
  15. 01 8月, 2012 2 次提交
  16. 27 7月, 2012 1 次提交
    • O
      maint: Use consistent copyright. · a4bcefbc
      Osier Yang 提交于
      This is a follow up patch of commit f9ce7dad, it modifies all
      the files which declare the copyright like "See COPYING.LIB for
      the License of this software" to use the detailed/consistent one.
      
      And deserts the outdated comments like:
      
       * libvirt-qemu.h:
       * Summary: qemu specific interfaces
       * Description: Provides the interfaces of the libvirt library to handle
       *              qemu specific methods
       *
       * Copy:  Copyright (C) 2010, 2012 Red Hat, Inc.
      
      Uses the more compact style like:
      
       * libvirt-qemu.h: Interfaces specific for QEMU/KVM driver
       *
       * Copyright (C) 2010, 2012 Red Hat, Inc.
      a4bcefbc
  17. 26 7月, 2012 1 次提交
  18. 25 7月, 2012 1 次提交