1. 24 5月, 2013 2 次提交
  2. 23 5月, 2013 1 次提交
  3. 22 5月, 2013 2 次提交
    • M
      qemu: Adapt qemuBuildInterfaceCommandLine to to multiqueue net · 1f24f682
      Michal Privoznik 提交于
      In order to learn libvirt multiqueue several things must be done:
      
      1) The '/dev/net/tun' device needs to be opened multiple times with
      IFF_MULTI_QUEUE flag passed to ioctl(fd, TUNSETIFF, &ifr);
      
      2) Similarly, '/dev/vhost-net' must be opened as many times as in 1)
      in order to keep 1:1 ratio recommended by qemu and kernel folks.
      
      3) The command line construction code needs to switch from 'fd=X' to
      'fds=X:Y:...:Z' and from 'vhostfd=X' to 'vhostfds=X:Y:...:Z'.
      
      4) The monitor handling code needs to learn to pass multiple FDs.
      1f24f682
    • E
      cgroup: be robust against cgroup movement races · 83e4c775
      Eric Blake 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=965169 documents a
      problem starting domains when cgroups are enabled; I was able
      to reliably reproduce the race about 5% of the time when I added
      hooks to domain startup by 3 seconds (as that seemed to be about
      the length of time that qemu created and then closed a temporary
      thread, probably related to aio handling of initially opening
      a disk image).  The problem has existed since we introduced
      virCgroupMoveTask in commit 91028296 (v0.10.0).
      
      There are some inherent TOCTTOU races when moving tasks between
      kernel cgroups, precisely because threads can be created or
      completed in the window between when we read a thread id from the
      source and when we write to the destination.  As the goal of
      virCgroupMoveTask is merely to move ALL tasks into the new
      cgroup, it is sufficient to iterate until no more threads are
      being created in the old group, and ignoring any threads that
      die before we can move them.
      
      It would be nicer to start the threads in the right cgroup to
      begin with, but by default, all child threads are created in
      the same cgroup as their parent, and we don't want vcpu child
      threads in the emulator cgroup, so I don't see any good way
      of avoiding the move.  It would also be nice if the kernel were
      to implement something like rename() as a way to atomically move
      a group of threads from one cgroup to another, instead of forcing
      a window where we have to read and parse the source, then format
      and write back into the destination.
      
      * src/util/vircgroup.c (virCgroupAddTaskStrController): Ignore
      ESRCH, because a thread ended between read and write attempts.
      (virCgroupMoveTask): Loop until all threads have moved.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      83e4c775
  4. 21 5月, 2013 1 次提交
  5. 18 5月, 2013 1 次提交
  6. 17 5月, 2013 2 次提交
    • G
      qemu: report useful error failling to destroy domain gracefully · 6459af6a
      Guannan Ren 提交于
      Resolves:https://bugzilla.redhat.com/show_bug.cgi?id=927620
      
       #kill -STOP `pidof qemu-kvm`
       #virsh destroy $guest --graceful
       error: Failed to destroy domain testVM
       error: An error occurred, but the cause is unknown
      
      With --graceful, SIGTERM always is emitted to kill driver
      process, but it won't success till burning out waiting time
      in case of process being stopped.
      But domain destroy without --graceful can work, SIGKILL will
      be emitted to the stopped process after 10 secs which always
      kills a process even one that is currently stopped.
      So report an error after burning out waiting time in this case.
      6459af6a
    • D
      Fix failure to detect missing cgroup partitions · c2cf5f1c
      Daniel P. Berrange 提交于
      Change bbe97ae9 caused the
      QEMU driver to ignore ENOENT errors from cgroups, in order
      to cope with missing /proc/cgroups. This is not good though
      because many other things can cause ENOENT and should not
      be ignored. The callers expect to see ENXIO when cgroups
      are not present, so adjust the code to report that errno
      when /proc/cgroups is missing
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      c2cf5f1c
  7. 16 5月, 2013 2 次提交
  8. 15 5月, 2013 1 次提交
  9. 14 5月, 2013 4 次提交
    • E
      json: support removing a value from an object · 547a7c77
      Eric Blake 提交于
      In an upcoming patch, I need the way to safely transfer a nested
      virJSON object out of its parent container for independent use,
      even after the parent is freed.
      
      * src/util/virjson.h (virJSONValueObjectRemoveKey): New function.
      (_virJSONObject, _virJSONArray): Use correct type.
      * src/util/virjson.c (virJSONValueObjectRemoveKey): Implement it.
      * src/libvirt_private.syms (virjson.h): Export it.
      * tests/jsontest.c (mymain): Test it.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      547a7c77
    • G
      Support for static routes on a virtual bridge · ccff335f
      Gene Czarcinski 提交于
      network: static route support for <network>
      
      This patch adds the <route> subelement of <network> to define a static
      route.  the address and prefix (or netmask) attribute identify the
      destination network, and the gateway attribute specifies the next hop
      address (which must be directly reachable from the containing
      <network>) which is to receive the packets destined for
      "address/(prefix|netmask)".
      
      These attributes are translated into an "ip route add" command that is
      executed when the network is started. The command used is of the
      following form:
      
        ip route add <address>/<prefix> via <gateway> \
                     dev <virbr-bridge> proto static metric <metric>
      
      Tests are done to validate that the input data are correct.  For
      example, for a static route ip definition, the address must be a
      network address and not a host address.  Additional checks are added
      to ensure that the specified gateway is directly reachable via this
      network (i.e. that the gateway IP address is in the same subnet as one
      of the IP's defined for the network).
      
      prefix='0' is supported for both family='ipv4' address='0.0.0.0'
      netmask='0.0.0.0' or prefix='0', and for family='ipv6' address='::',
      prefix=0', although care should be taken to not override a desired
      system default route.
      
      Anytime an attempt is made to define a static route which *exactly*
      duplicates an existing static route (for example, address=::,
      prefix=0, metric=1), the following error message will be sent to
      syslog:
      
          RTNETLINK answers: File exists
      
      This can be overridden by decreasing the metric value for the route
      that should be preferred, or increasing the metric for the route that
      shouldn't be preferred (and is thus in place only in anticipation that
      the preferred route may be removed in the future).  Caution should be
      used when manipulating route metrics, especially for a default route.
      
      Note: The use of the command-line interface should be replaced by
      direct use of libnl so that error conditions can be handled better.  But,
      that is being left as an exercise for another day.
      Signed-off-by: NGene Czarcinski <gene@czarc.net>
      Signed-off-by: NLaine Stump <laine@laine.org>
      ccff335f
    • D
      Don't overwrite useful message when creating macvlan fails · 3407e3b3
      Daniel P. Berrange 提交于
      Currently we report a bogus error message when macvlan
      creation fails:
      
      error: Failed to start domain migtest
      error: operation failed: Unable to create macvlan device
      
      With this removed, we see the real error:
      
      error: Failed to start domain migtest
      error: Unable to get index for interface p31p1: No such device
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      3407e3b3
    • D
      Remove & ban use of select() for waiting for I/O · 8845d8df
      Daniel P. Berrange 提交于
      Use of the select() system call is inherantly dangerous since
      applications will hit a buffer overrun if any FD number exceeds
      the size of the select set size (typically 1024). Replace the
      two uses of select() with poll() and use cfg.mk to ban any
      future use of select().
      
      NB: This changes the phyp driver so that it uses an infinite
      timeout, instead of busy-waiting for 1ms at a time.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      8845d8df
  10. 13 5月, 2013 11 次提交
  11. 11 5月, 2013 5 次提交
    • E
      build: fix use of mmap · d34ef017
      Eric Blake 提交于
      Commit bfe7721d introduced a regression, but only on platforms
      like FreeBSD that lack posix_fallocate and where mmap serves as
      a nice fallback for safezero.
      
      util/virfile.c: In function 'safezero':
      util/virfile.c:837: error: 'PROT_READ' undeclared (first use in this function)
      
      * src/util/virutil.c (includes): Move use of <sys/mman.h>...
      * src/util/virfile.c (includes): ...to the file that uses mmap.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      d34ef017
    • D
      Add a virGetLastErrorMessage() function · 69c6a58a
      Daniel P. Berrange 提交于
      Apps using libvirt will often have code like
      
         if (virXXXX() < 0) {
            virErrorPtr err = virGetLastError();
            fprintf(stderr, "Something failed: %s\n",
                    err && err->message ? err->message :
                    "unknown error");
            return -1;
         }
      
      Checking for a NULL error object or message leads to very
      verbose code. A virGetLastErrorMessage() helper from libvirt
      can simplify this to
      
         if (virXXXX() < 0) {
            fprintf(stderr, "Something failed: %s\n",
                    virGetLastErrorMessage());
            return -1;
         }
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      69c6a58a
    • R
      portability: fix virNetDevSetMAC and virNetDevExists on BSD · 95934171
      Roman Bogorodskiy 提交于
      - provide virNetDevSetMAC() implementation based on SIOCSIFLLADDR
        ioctl.
      - adjust virNetDevExists() to check for ENXIO error because
        FreeBSD throws it when device doesn't exist
      Signed-off-by: NEric Blake <eblake@redhat.com>
      95934171
    • L
      util: move virFile* functions from virutil.c to virfile.c · bfe7721d
      Laine Stump 提交于
      These all existed before virfile.c was created, and for some reason
      weren't moved.
      
      This is mostly straightfoward, although the syntax rule prohibiting
      write() had to be changed to have an exception for virfile.c instead
      of virutil.c.
      
      This movement pointed out that there is a function called
      virBuildPath(), and another almost identical function called
      virFileBuildPath(). They really should be a single function, which
      I'll take care of as soon as I figure out what the arglist should look
      like.
      bfe7721d
    • L
      util: fix virFileOpenAs return value and resulting error logs · a2c1bedb
      Laine Stump 提交于
      This resolves:
      
           https://bugzilla.redhat.com/show_bug.cgi?id=851411
           https://bugzilla.redhat.com/show_bug.cgi?id=955500
      
      The first problem was that virFileOpenAs was returning fd (-1) in one
      of the error cases rather than ret (-errno), so the caller thought
      that the error was EPERM rather than ENOENT.
      
      The second problem was that some log messages in the general purpose
      qemuOpenFile() function would always say "Failed to create" even if
      the caller hadn't included O_CREAT (i.e. they were trying to open an
      existing file).
      
      This fixes virFileOpenAs to jump down to the error return (which
      returns ret instead of fd) in the previously mentioned incorrect
      failure case of virFileOpenAs(), removes all error logging from
      virFileOpenAs() (since the callers report it), and modifies
      qemuOpenFile to appropriately use "open" or "create" in its log
      messages.
      
      NB: I seriously considered removing logging from all callers of
      virFileOpenAs(), but there is at least one case where the caller
      doesn't want virFileOpenAs() to log any errors, because it's just
      going to try again (qemuOpenFile()). We can't simply make a silent
      variation of virFileOpenAs() though, because qemuOpenFile() can't make
      the decision about whether or not it wants to retry until after
      virFileOpenAs() has already returned an error code.
      
      Likewise, I also considered changing virFileOpenAs() to return -1 with
      errno set on return, and may still do that, but only as a separate
      patch, as it obscures the intent of this patch too much.
      a2c1bedb
  12. 08 5月, 2013 6 次提交
    • D
      Separate internal node suspend APIs from public API · 4a044d02
      Daniel P. Berrange 提交于
      The individual hypervisor drivers were directly referencing
      APIs in virnodesuspend.c in their virDriverPtr struct. Separate
      these methods, so there is always a wrapper in the hypervisor
      driver. This allows the unused virConnectPtr args to be removed
      from the virnodesuspend.c file. Again this will ensure that
      ACL checks will only be performed on invocations that are
      directly associated with public API usage.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      4a044d02
    • D
      Separate virGetHostname() API contract from driver APIs · ead63031
      Daniel P. Berrange 提交于
      Currently the virGetHostname() API has a bogus virConnectPtr
      parameter. This is because virtualization drivers directly
      reference this API in their virDriverPtr tables, tieing its
      API design to the public virConnectGetHostname API design.
      
      This also causes problems for access control checks since
      these must only be done for invocations from the public
      API, not internal invocation.
      
      Remove the bogus virConnectPtr parameter, and make each
      hypervisor driver provide a dedicated function for the
      driver API impl. This will allow access control checks
      to be easily inserted later.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      ead63031
    • D
      Include process start time when doing polkit checks · 979e9c56
      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>
      979e9c56
    • D
      Rename "security context" to "selinux context" · b1d753fe
      Daniel P. Berrange 提交于
      There are various methods named "virXXXXSecurityContext",
      which are specific to SELinux. Rename them all to
      "virXXXXSELinuxContext". They will still raise errors at
      runtime if SELinux is not compiled in
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      b1d753fe
    • E
      string: make VIR_STRDUP easier to use · 6b74a9f5
      Eric Blake 提交于
      While reviewing proposed VIR_STRDUP conversions, I've already noticed
      several places that do:
      
      if (str && VIR_STRDUP(dest, str) < 0)
      
      which can be simplified by allowing str to be NULL (something that
      strdup() doesn't allow).  Meanwhile, code that wants to ensure a
      non-NULL dest regardless of the source can check for <= 0.
      
      Also, make it part of the VIR_STRDUP contract that macro arguments
      are evaluated exactly once.
      
      * src/util/virstring.h (VIR_STRDUP, VIR_STRDUP_QUIET, VIR_STRNDUP)
      (VIR_STRNDUP_QUIET): Improve contract.
      * src/util/virstring.c (virStrdup, virStrndup): Change return
      conventions.
      * docs/hacking.html.in: Document this.
      * HACKING: Regenerate.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      6b74a9f5
    • E
      alloc: make VIR_APPEND_ELEMENT safer · ddcfc549
      Eric Blake 提交于
      VIR_APPEND_ELEMENT(array, size, elem) was not safe if the expression
      for 'size' had side effects.  While no one in the current code base
      was trying to pass side effects, we might as well be robust and
      explicitly document our intentions.
      
      * src/util/viralloc.c (virInsertElementsN): Add special case.
      * src/util/viralloc.h (VIR_APPEND_ELEMENT): Use it.
      (VIR_ALLOC, VIR_ALLOC_N, VIR_REALLOC_N, VIR_EXPAND_N)
      (VIR_RESIZE_N, VIR_SHRINK_N, VIR_INSERT_ELEMENT)
      (VIR_DELETE_ELEMENT, VIR_ALLOC_VAR, VIR_FREE): Document
      which macros are safe in the presence of side effects.
      * docs/hacking.html.in: Document this.
      * HACKING: Regenerate.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      ddcfc549
  13. 07 5月, 2013 1 次提交
  14. 05 5月, 2013 1 次提交
    • M
      virstring: Introduce VIR_STRDUP and VIR_STRNDUP · c3abb5c4
      Michal Privoznik 提交于
      The code adaptation is not done right now, but in subsequent patches.
      Hence I am not implementing syntax-check rule as it would break
      compilation. Developers are strongly advised to use these new macros.
      They are similar to VIR_ALLOC() logic: VIR_STRDUP(dst, src) returns zero
      on success, -1 otherwise. In case you don't want to report OOM error,
      use the _QUIET variant of a macro.
      c3abb5c4