1. 14 1月, 2013 1 次提交
    • D
      Introduce an LXC specific public API & library · 3d1596b0
      Daniel P. Berrange 提交于
      This patch introduces support for LXC specific public APIs. In
      common with what was done for QEMU, this creates a libvirt_lxc.so
      library and libvirt/libvirt-lxc.h header file.
      
      The actual APIs are
      
        int virDomainLxcOpenNamespace(virDomainPtr domain,
                                      int **fdlist,
                                      unsigned int flags);
      
        int virDomainLxcEnterNamespace(virDomainPtr domain,
                                       unsigned int nfdlist,
                                       int *fdlist,
                                       unsigned int *noldfdlist,
                                       int **oldfdlist,
                                       unsigned int flags);
      
      which provide a way to use the setns() system call to move the
      calling process into the container's namespace. It is not
      practical to write in a generically applicable manner. The
      nearest that we could get to such an API would be an API which
      allows to pass a command + argv to be executed inside a
      container. Even if we had such a generic API, this LXC specific
      API is still useful, because it allows the caller to maintain
      the current process context, in particular any I/O streams they
      have open.
      
      NB the virDomainLxcEnterNamespace() API is special in that it
      runs client side, so does not involve the internal driver API.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      3d1596b0
  2. 13 12月, 2012 1 次提交
  3. 12 10月, 2012 1 次提交
  4. 28 9月, 2012 2 次提交
  5. 07 9月, 2012 1 次提交
    • E
      build: improved handling of <execinfo.h>, BSD <net/if.h> · ccaf0bee
      Eric Blake 提交于
      FreeBSD and OpenBSD have a <net/if.h> that is not self-contained;
      and mingw lacks the header altogether.  But gnulib has just taken
      care of that for us, so we might as well simplify our code.  In
      the process, I got a syntax-check failure if we don't also take
      the gnulib execinfo module.
      
      * .gnulib: Update to latest, for execinfo and net_if.
      * bootstrap.conf (gnulib_modules): Add execinfo and net_if modules.
      * configure.ac: Let gnulib check for headers.  Simplify check for
      'struct ifreq', while also including enough prereq headers.
      * src/internal.h (IF_NAMESIZE): Drop, now that gnulib guarantees it.
      * src/nwfilter/nwfilter_learnipaddr.h: Use correct header for
      IF_NAMESIZE.
      * src/util/virnetdev.c (includes): Assume <net/if.h> exists.
      * src/util/virnetdevbridge.c (includes): Likewise.
      * src/util/virnetdevtap.c (includes): Likewise.
      * src/util/logging.c (includes): Assume <execinfo.h> exists.
      (virLogStackTraceToFd): Handle gnulib's fallback implementation.
      ccaf0bee
  6. 06 9月, 2012 1 次提交
    • E
      build: avoid warnings from gcc 4.2.1 · c579d6b3
      Eric Blake 提交于
      OpenBSD ships with gcc 4.2.1, which annoyingly treats all format
      strings as though they were also attribute((nonnull)).  The two
      concepts are orthogonal, though, as evidenced by the number of
      spurious warnings it generates on uses where we know that
      virReportError specifically handles NULL instead of a format
      string; worse, since we now force -Werror on git builds, it
      prevents development builds on OpenBSD.
      
      I hate to do this, as it disables ALL format checking on older
      gcc, and therefore misses out on some useful checks (code that
      happened to compile on Linux may still have type mismatches
      when compiled on other platforms, as evidenced by the number
      of times I have fixed formatting mismatches for uid_t as found
      by warnings on Cygwin), but I don't see any other way to keep
      -Werror alive and still compile on OpenBSD.
      
      A more invasive change would be to make virReportError() mark
      its format attribute as nonnull, and fix (a lot of) fallout;
      we may end up doing that anyways as part of danpb's error
      refactoring improvements, but not today.
      
      * src/internal.h (ATTRIBUTE_FMT_PRINTF): Use preferred spellings.
      * m4/virt-compile-warnings.m4 (-Wformat): Disable on older gcc.
      c579d6b3
  7. 21 8月, 2012 1 次提交
    • E
      build: silence stupid gcc warning on STREQ_NULLABLE · 8d8527de
      Eric Blake 提交于
      Our existing STRNEQ_NULLABLE() triggered a warning in gcc 4.7 when
      used with a literal NULL argument:
      
      qemumonitorjsontest.c: In function 'testQemuMonitorJSONGetMachines':
      qemumonitorjsontest.c:289:5: error: null argument where non-null required (argument 1) [-Werror=nonnull]
      
      even though the strcmp is provably dead when a null argument is
      present.  Squelch the warning by refactoring things so that gcc
      never sees strcmp() called with NULL arguments (we still compare
      NULL as not equal to "", this rewrite merely aids gcc).
      
      Next, gcc has a valid warning about a literal NULLSTR(NULL):
      
      qemumonitorjsontest.c:289:5: error: invalid application of 'sizeof' to a void type [-Werror=pointer-arith]
      
      Of course, you'd never write NULLSTR(NULL) directly, but it is
      handy to use through macros.  But the entire part about verify_true()
      is unnecessary - gcc already warns about type mismatch with ?:,
      without needing to make it more complex.
      
      * src/internal.h (STREQ_NULLABLE, STRNEQ_NULLABLE): Avoid gcc 4.7
      stupidity.
      (NULLSTR): Simplify, to allow passing compile-time constants.
      8d8527de
  8. 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
  9. 28 6月, 2012 1 次提交
  10. 19 6月, 2012 1 次提交
    • P
      error: Fix typos in argument checking macros · fbc72a1d
      Peter Krempa 提交于
      Macro virCheckNullArgGoto is supposed to check for NULL argument but
      checks non-NULL instead.
      
      Macro virCheckNonNullArgReturn reports error as if the argument should
      be NULL when it shouldn't.
      fbc72a1d
  11. 28 5月, 2012 1 次提交
    • D
      Santize the reporting of VIR_ERR_INVALID_ERROR · d91f3ef4
      Daniel P. Berrange 提交于
      To ensure consistent error reporting of invalid arguments,
      provide a number of predefined helper methods & macros.
      
       - An arg which must not be NULL:
      
         virCheckNonNullArgReturn(argname, retvalue)
         virCheckNonNullArgGoto(argname, label)
      
       - An arg which must be NULL
      
         virCheckNullArgGoto(argname, label)
      
       - An arg which must be positive (ie 1 or greater)
      
         virCheckPositiveArgGoto(argname, label)
      
       - An arg which must not be 0
      
         virCheckNonZeroArgGoto(argname, label)
      
       - An arg which must be zero
      
         virCheckZeroArgGoto(argname, label)
      
       - An arg which must not be negative (ie 0 or greater)
      
         virCheckNonNegativeArgGoto(argname, label)
      
      * src/libvirt.c, src/libvirt-qemu.c,
        src/nodeinfo.c, src/datatypes.c: Update to use
        virCheckXXXX macros
      * po/POTFILES.in: Add libvirt-qemu.c and virterror_internal.h
      * src/internal.h: Define macros for checking invalid args
      * src/util/virterror_internal.h: Define macros for reporting
        invalid args
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      d91f3ef4
  12. 24 5月, 2012 1 次提交
    • D
      Split QEMU dtrace probes into separate file · a4e45a06
      Daniel P. Berrange 提交于
      When building as driver modules, it is not possible for the QEMU
      driver module to reference the DTrace/SystemTAP probes linked into
      the main libvirt.so. Thus we need to move the QEMU probes into a
      separate file 'libvirt_qemu_probes.d'. Also rename the existing
      file from 'probes.d' to 'libvirt_probes.d' while we're at it
      
      * daemon/Makefile.am, src/internal.h: Include libvirt_probes.h
        instead of probes.h
      * src/Makefile.am: Add rules for libvirt_qemu_probes.d
      * src/qemu/qemu_monitor.c, src/qemu/qemu_monitor_json.c,
        src/qemu/qemu_monitor_text.c: Include libvirt_qemu_probes.h
      * src/libvirt_probes.d: Rename from probes.d
      * src/libvirt_qemu_probes.d: QEMU specific probes formerly
        in probes.d
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      a4e45a06
  13. 02 5月, 2012 1 次提交
    • L
      build: make ATTRIBUTE_NONNULL() a NOP unless STATIC_ANALYSIS is on · eefb881d
      Laine Stump 提交于
      The ATTRIBUTE_NONNULL(m) macro normally resolves to the gcc builtin
      __attribute__((__nonnull__(m))). The effect of this in gcc is
      unfortunately only to make gcc believe that "m" can never possibly be
      NULL, *not* to add in any checks to guarantee that it isn't ever NULL
      (i.e. it is an optimization aid, *not* something to verify code
      correctness.) - see the following gcc bug report for more details:
      
        http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17308
      
      Static source analyzers such as clang and coverity apparently can use
      ATTRIBUTE_NONNULL(), though, to detect dead code (in the case that the
      arg really is guaranteed non-NULL), as well as situations where an
      obviously NULL arg is given to the function.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=815270 is a good example
      of a bug caused by erroneous application of ATTRIBUTE_NONNULL().
      Several people spent a long time staring at this code and not finding
      the problem, because the problem wasn't in the function itself, but in
      the prototype that specified ATTRIBUTE_NONNULL() for an arg that
      actually *wasn't* always non-NULL, and caused a segv when dereferenced
      (even though the code that dereferenced the pointer was inside an if()
      that checked for a NULL pointer, that code was optimized out by gcc).
      
      There may be some very small gain to be had from the optimizations
      that can be inferred from ATTRIBUTE_NONNULL(), but it seems safer to
      err on the side of generating code that behaves as expected, while
      turning on the attribute for static analyzers.
      eefb881d
  14. 30 3月, 2012 1 次提交
  15. 25 2月, 2012 1 次提交
    • D
      Workaround python header file insanity · 1d4c4d9d
      Daniel P. Berrange 提交于
      The /usr/include/python/pyconfig.h file pollutes the global
      namespace with a huge number of HAVE_XXX and WITH_XXX
      defines. These change what we detected in our own config.h
      In particular if you try to build without DTrace, python's
      headers turn it back on with predictable fail.
      
      THe hack to workaround this is to rename WITH_DTRACE to
      WITH_DTRACE_PROBES to avoid the namespace clash
      1d4c4d9d
  16. 21 1月, 2012 1 次提交
    • E
      API: make declaration of _LAST enum values conditional · 7b4e5693
      Eric Blake 提交于
      Although this is a public API break, it only affects users that
      were compiling against *_LAST values, and can be trivially
      worked around without impacting compilation against older
      headers, by the user defining VIR_ENUM_SENTINELS before using
      libvirt.h.  It is not an ABI break, since enum values do not
      appear as .so entry points.  Meanwhile, it prevents users from
      using non-stable enum values without explicitly acknowledging
      the risk of doing so.
      
      See this list discussion:
      https://www.redhat.com/archives/libvir-list/2012-January/msg00804.html
      
      * include/libvirt/libvirt.h.in: Hide all sentinels behind
      LIBVIRT_ENUM_SENTINELS, and add missing sentinels.
      * src/internal.h (VIR_DEPRECATED): Allow inclusion after
      libvirt.h.
      (LIBVIRT_ENUM_SENTINELS): Expose sentinels internally.
      * daemon/libvirtd.h: Use the sentinels.
      * src/remote/remote_protocol.x (includes): Don't expose sentinels.
      * python/generator.py (enum): Likewise.
      * tests/cputest.c (cpuTestCompResStr): Silence compiler warning.
      * tools/virsh.c (vshDomainStateReasonToString)
      (vshDomainControlStateToString): Likewise.
      7b4e5693
  17. 11 10月, 2011 1 次提交
    • D
      Rewrite all the DTrace/SystemTAP probing · ddf3bd32
      Daniel P. Berrange 提交于
      The libvirtd daemon had a few crude system tap probes. Some of
      these were broken during the RPC rewrite. The new modular RPC
      code is structured in a way that allows much more effective
      tracing. Instead of trying to hook up the original probes,
      define a new set of probes for the RPC and event code.
      
      The master probes file is now src/probes.d.  This contains
      probes for virNetServerClientPtr, virNetClientPtr, virSocketPtr
      virNetTLSContextPtr and virNetTLSSessionPtr modules. Also add
      probes for the poll event loop.
      
      The src/dtrace2systemtap.pl script can convert the probes.d
      file into a libvirt_probes.stp file to make use from systemtap
      much simpler.
      
      The src/rpc/gensystemtap.pl script can generate a set of
      systemtap functions for translating RPC enum values into
      printable strings. This works for all RPC header enums (program,
      type, status, procedure) and also the authentication enum
      
      The PROBE macro will automatically generate a VIR_DEBUG
      statement, so any place with a PROBE can remove any existing
      manual DEBUG statements.
      
      * daemon/libvirtd.stp, daemon/probes.d: Remove obsolete probing
      * daemon/libvirtd.h: Remove probe macros
      * daemon/Makefile.am: Remove all probe buildings/install
      * daemon/remote.c: Update authentication probes
      * src/dtrace2systemtap.pl, src/rpc/gensystemtap.pl: Scripts
        to generate STP files
      * src/internal.h: Add probe macros
      * src/probes.d: Master list of probes
      * src/rpc/virnetclient.c, src/rpc/virnetserverclient.c,
        src/rpc/virnetsocket.c, src/rpc/virnettlscontext.c,
        src/util/event_poll.c: Insert probe points, removing any
        DEBUG statements that duplicate the info
      ddf3bd32
  18. 21 7月, 2011 1 次提交
    • E
      maint: fix typos on guaranteed · a7143405
      Eric Blake 提交于
      * src/conf/domain_event.c (virDomainEventDispatch): Fix typo.
      * src/internal.h (ATTRIBUTE_FMT_PRINTF): Likewise.
      * src/libvirt.c (virStreamEventUpdateCallback): Likewise.
      * src/remote/remote_driver.c (doRemoteOpen): Likewise.
      * src/storage/storage_backend_fs.c (virStorageBackendProbeTarget):
      Likewise.
      * src/util/virterror.c (virConnCopyLastError, virCopyLastError):
      Likewise.
      * src/xen/xend_internal.h (xend_wait_for_devices): Likewise.
      a7143405
  19. 17 5月, 2011 1 次提交
    • E
      build: drop unused <sys/syslimits.h> header · d4982b86
      Eric Blake 提交于
      <sys/syslimits.h> is not standardized, so portable programs should
      not need to rely on it.  If there really is something that we need
      where <sys/syslimits.h> provided the limit but <limits.h> did not,
      then that would be a candidate for fixing in gnulib.  But this patch
      did not turn up any compilation failures on Linux.
      
      * src/internal.h (includes): Drop unused header.
      * daemon/libvirtd.h (includes): Likewise.
      * configure.ac (AC_CHECK_HEADERS): Likewise.
      Based on a report by Matthias Bolte.
      d4982b86
  20. 17 4月, 2011 1 次提交
  21. 05 4月, 2011 1 次提交
    • D
      Enable use of -Wmissing-noreturn · 329e9dc6
      Daniel P. Berrange 提交于
      * src/internal.h: Define a ATTRIBUTE_NO_RETURN annotation
      * src/lxc/lxc_container.c: Annotate lxcContainerDummyChild
        with ATTRIBUTE_NO_RETURN
      * tests/eventtest.c: Mark async thread as ATTRIBUTE_NO_RETURN
      * m4/virt-compile-warnings.m4: Enable -Wmissing-noreturn
      329e9dc6
  22. 31 3月, 2011 1 次提交
    • E
      maint: avoid locale-sensitivity in string case comparisons · 6c9e89bb
      Eric Blake 提交于
      strcase{cmp/str} have the drawback of being sensitive to the global
      locale; this is unacceptable in a library setting.  Prefer a
      hard-coded C locale alternative for all but virsh, which is user
      facing and where the global locale isn't changing externally.
      
      * .gnulib: Update to latest, for c-strcasestr change.
      * bootstrap.conf (gnulib_modules): Drop strcasestr, add c-strcase
      and c-strcasestr.
      * cfg.mk (sc_avoid_strcase): New rule.
      (exclude_file_name_regexp--sc_avoid_strcase): New exception.
      * src/internal.h (STRCASEEQ, STRCASENEQ, STRCASEEQLEN)
      (STRCASENEQLEN): Adjust offenders.
      * src/qemu/qemu_monitor_text.c (qemuMonitorTextEjectMedia):
      Likewise.
      * tools/virsh.c (namesorter): Document exception.
      6c9e89bb
  23. 24 2月, 2011 1 次提交
  24. 04 2月, 2011 1 次提交
    • J
      qemu: Add shortcut for HMP pass through · 2169472a
      Jiri Denemark 提交于
      Currently users who want to use virDomainQemuMonitorCommand() API or
      it's virsh equivalent has to use the same protocol as libvirt uses for
      communication to qemu. Since the protocol is QMP with current qemu and
      HMP much more usable for humans, one ends up typing something like the
      following:
      
          virsh qemu-monitor-command DOM \
      '{"execute":"human-monitor-command","arguments":{"command-line":"info kvm"}}'
      
      which is not a very convenient way of debugging qemu.
      
      This patch introduces --hmp option to qemu-monitor-command, which says
      that the provided command is in HMP. If libvirt uses QMP to talk with
      qemu, the command will automatically be converted into QMP. So the
      example above is simplified to just
      
          virsh qemu-monitor-command --hmp DOM "info kvm"
      
      Also the result is converted from
      
          {"return":"kvm support: enabled\r\n"}
      
      to just plain HMP:
      
          kvm support: enabled
      
      If libvirt talks to qemu in HMP, --hmp flag is obviously a noop.
      2169472a
  25. 29 1月, 2011 1 次提交
    • M
      Add VIR_DIV_UP to divide memory or storage request sizes with round up · d9ad8ac3
      Matthias Bolte 提交于
      Use it in all places where a memory or storage request size is converted
      to a larger granularity. This avoids requesting too small memory or storage
      sizes that could result from the truncation done by a simple division.
      
      This extends the round up fix in 6002e040
      to the whole codebase.
      
      Instead of reporting errors for odd values in the VMX code round them up.
      
      Update the QEMU Argv tests accordingly as the original memory size 219200
      isn't a even multiple of 1024 and is rounded up to 215 megabyte now. Change
      it to 219100 and 219136. Use two different values intentionally to make
      sure that rounding up works.
      
      Update virsh.pod accordingly, as rounding down and rejecting are replaced
      by rounding up.
      d9ad8ac3
  26. 22 12月, 2010 1 次提交
    • E
      maint: avoid space-tab · 831aaf4a
      Eric Blake 提交于
      * daemon/Makefile.am: Avoid spurious space before tabs.
      * src/Makefile.am: Likewise.
      * examples/dominfo/Makefile.am: Likewise.
      * examples/domsuspend/Makefile.am: Likewise.
      * tools/Makefile.am: Likewise.
      * src/datatypes.h (VIR_CONNECT_MAGIC): Likewise.
      * src/internal.h (TODO): Likewise.
      * src/qemu/qemu_monitor.h (QEMU_MONITOR_MIGRATE): Likewise.
      * src/xen/xen_hypervisor.c (XEN_V2_OP_GETAVAILHEAP): Likewise.
      * src/xen/xs_internal.h: Likewise.
      831aaf4a
  27. 18 11月, 2010 1 次提交
    • E
      maint: improve i18n on non-Linux · 981d2cda
      Eric Blake 提交于
      Per the gettext developer:
      http://lists.gnu.org/archive/html/bug-gnu-utils/2010-10/msg00019.html
      http://lists.gnu.org/archive/html/bug-gnu-utils/2010-10/msg00021.html
      
      gettext() doesn't work correctly on all platforms unless you have
      called setlocale().  Furthermore, gnulib's gettext.h has provisions
      for setting up a default locale, which is the preferred method for
      libraries to use gettext without having to call textdomain() and
      override the main program's default domain (virInitialize already
      calls bindtextdomain(), but this is insufficient without the
      setlocale() added in this patch; and a redundant bindtextdomain()
      in this patch doesn't hurt, but serves as a good example for other
      packages that need to bind a second translation domain).
      
      This patch is needed to silence a new gnulib 'make syntax-check'
      rule in the next patch.
      
      * daemon/libvirtd.c (main): Setup locale and gettext.
      * src/lxc/lxc_controller.c (main): Likewise.
      * src/security/virt-aa-helper.c (main): Likewise.
      * src/storage/parthelper.c (main): Likewise.
      * tools/virsh.c (main): Fix exit status.
      * src/internal.h (DEFAULT_TEXT_DOMAIN): Define, for gettext.h.
      (_): Simplify definition accordingly.
      * po/POTFILES.in: Add src/storage/parthelper.c.
      981d2cda
  28. 17 11月, 2010 1 次提交
    • E
      maint: use gnulib configmake rather than open-coding things · 0d5f54bb
      Eric Blake 提交于
      * bootstrap.conf (gnulib_modules): Add configmake.
      * daemon/Makefile.am (libvirtd_CFLAGS): Drop defines provided by
      gnulib.
      * src/Makefile.am (INCLUDES): Likewise.
      * tests/Makefile.am (INCLUDES): Likewise.
      * tools/Makefile.am (virsh_CFLAGS): Likewise.
      * daemon/libvirtd.c (qemudInitPaths, usage, main): Update
      clients.
      * src/cpu/cpu_map.c (CPUMAPFILE): Likewise.
      * src/driver.c (DEFAULT_DRIVER_DIR): Likewise.
      * src/internal.h (_): Likewise.
      * src/libvirt.c (virInitialize): Likewise.
      * src/lxc/lxc_conf.h (LXC_CONFIG_DIR, LXC_STATE_DIR, LXC_LOG_DIR):
      Likewise.
      * src/lxc/lxc_conf.c (lxcCapsInit, lxcLoadDriverConfig):
      Likewise.
      * src/network/bridge_driver.c (NETWORK_PID_DIR)
      (NETWORK_STATE_DIR, DNSMASQ_STATE_DIR, networkStartup): Likewise.
      * src/nwfilter/nwfilter_driver.c (nwfilterDriverStartup):
      Likewise.
      * src/qemu/qemu_conf.c (qemudLoadDriverConfig): Likewise.
      * src/qemu/qemu_driver.c (qemudStartup): Likewise.
      * src/remote/remote_driver.h (LIBVIRTD_PRIV_UNIX_SOCKET)
      (LIBVIRTD_PRIV_UNIX_SOCKET_RO, LIBVIRTD_CONFIGURATION_FILE)
      (LIBVIRT_PKI_DIR): Likewise.
      * src/secret/secret_driver.c (secretDriverStartup): Likewise.
      * src/security/security_apparmor.c (VIRT_AA_HELPER): Likewise.
      * src/security/virt-aa-helper.c (main): Likewise.
      * src/storage/storage_backend_disk.c (PARTHELPER): Likewise.
      * src/storage/storage_driver.c (storageDriverStartup): Likewise.
      * src/uml/uml_driver.c (TEMPDIR, umlStartup): Likewise.
      * src/util/hooks.c (LIBVIRT_HOOK_DIR): Likewise.
      * tools/virsh.c (main): Likewise.
      * docs/hooks.html.in: Likewise.
      0d5f54bb
  29. 25 5月, 2010 1 次提交
    • C
      Fix up basic migration. · 93500040
      Chris Lalancette 提交于
      Basic live migration was broken by the commit that added
      non-shared block support in two ways:
      
      1)  It added a virCheckFlags() to doNativeMigrate().  Besides
      the fact that typical usage of virCheckFlags() is in driver
      entry points, and doNativeMigrate() is not an entry point,
      it was missing important flags like VIR_MIGRATE_LIVE.  Move
      the virCheckFlags to the top-level qemuDomainMigratePrepare2
      and friends.
      
      2)  It also added a memory leak in qemuMonitorTextMigrate()
      by not freeing the memory used by virBufferContentAndReset().
      This is fixed by storing the pointer in a temporary variable
      and freeing it at the end.
      
      With this patch in place, normal live migration works again.
      
      v3: Instead of the churn for virCheckFlagsUI and UL, instead
      always promote flags to an unsigned long and always use %lx
      for the fprintf.
      v2: Add back flags check, which required adding virCheckFlagsUI
      and virCheckFlagsUL
      Signed-off-by: NChris Lalancette <clalance@redhat.com>
      93500040
  30. 16 4月, 2010 1 次提交
    • J
      Introduce virCheckFlags for consistent flags checking · 070da02f
      Jiri Denemark 提交于
      The idea is that every API implementation in driver which has flags
      parameter should first call virCheckFlags() macro to check the function
      was called with supported flags:
      
          virCheckFlags(VIR_SUPPORTED_FLAG_1 |
                        VIR_SUPPORTED_FLAG_2 |
                        VIR_ANOTHER_SUPPORTED_FLAG, -1);
      
      The error massage which is printed when unsupported flags are passed
      looks like:
      
          invalid argument in virFooBar: unsupported flags (0x2)
      
      Where the unsupported flags part only prints those flags which were
      passed but are not supported rather than all flags passed.
      070da02f
  31. 15 4月, 2010 1 次提交
    • J
      sa_assert: assert-like macro, enabled only for use with static analyzers · e078fa3c
      Jim Meyering 提交于
      Among some here, there is a strong aversion to the use of "assert", yet
      some others think it is essential (when applied judiciously) even --
      perhaps "especially" -- at the heart of libraries and core hypervisor-
      related code.
      Here is a compromise that lets us make assertions about the code (e.g.,
      to tell static analyzers about invariants) without even a hint of risk
      of an abort.
      * src/internal.h [STATIC_ANALYSIS]: Include <assert.h>.
      (sa_assert): Define.  A no-op most of the time, but equivalent
      to classical assert when STATIC_ANALYSIS is nonzero.
      e078fa3c
  32. 08 4月, 2010 1 次提交
    • S
      nwfilter: Support for learning a VM's IP address · 3bf24abc
      Stefan Berger 提交于
      This patch implements support for learning a VM's IP address. It uses
      the pcap library to listen on the VM's backend network interface (tap)
      or the physical ethernet device (macvtap) and tries to capture packets
      with source or destination MAC address of the VM and learn from DHCP
      Offers, ARP traffic, or first-sent IPv4 packet what the IP address of
      the VM's interface is. This then allows to instantiate the network
      traffic filtering rules without the user having to provide the IP
      parameter somewhere in the filter description or in the interface
      description as a parameter. This only supports to detect the parameter
      IP, which is for the assumed single IPv4 address of a VM. There is not
      support for interfaces that may have multiple  IP addresses (IP
      aliasing) or IPv6 that may then require more than one valid IP address
      to be detected. A VM can have multiple independent interfaces that each
      uses a different IP address and in that case it will be attempted to
      detect each one of the address independently.
      
      So, when for example an interface description in the domain XML has
      looked like this up to now:
      
          <interface type='bridge'>
            <source bridge='mybridge'/>
            <model type='virtio'/>
            <filterref filter='clean-traffic'>
              <parameter name='IP' value='10.2.3.4'/>
            </filterref>
          </interface>
      
      you may omit the IP parameter:
      
          <interface type='bridge'>
            <source bridge='mybridge'/>
            <model type='virtio'/>
            <filterref filter='clean-traffic'/>
          </interface>
      
      Internally I am walking the 'tree' of a VM's referenced network filters
      and determine with the given variables which variables are missing. Now,
      the above IP parameter may be missing and this causes a libvirt-internal
      thread to be started that uses the pcap library's API to listen to the
      backend interface  (in case of macvtap to the physical interface) in an
      attempt to determine the missing IP parameter. If the backend interface
      disappears the thread terminates assuming the VM was brought down. In
      case of a macvtap device a timeout is being used to wait for packets
      from the given VM (filtering by VM's interface MAC address). If the VM's
      macvtap device disappeared the thread also terminates. In all other
      cases it tries to determine the IP address of the VM and will then apply
      the rules late on the given interface, which would have happened
      immediately if the IP parameter had been explicitly given. In case an
      error happens while the firewall rules are applied, the VM's backend
      interface is 'down'ed preventing it to communicate. Reasons for failure
      for applying the network firewall rules may that an ebtables/iptables
      command failes or OOM errors. Essentially the same failure reasons may
      occur as when the firewall rules are applied immediately on VM start,
      except that due to the late application of the filtering rules the VM
      now is already running and cannot be hindered anymore from starting.
      Bringing down the whole VM would probably be considered too drastic.
      While a VM's IP address is attempted to be determined only limited
      updates to network filters are allowed. In particular it is prevented
      that filters are modified in such a way that they would introduce new
      variables.
      
      A caveat: The algorithm does not know which one is the appropriate IP
      address of a VM. If the VM spoofs an IP address in its first ARP traffic
      or IPv4 packets its filtering rules will be instantiated for this IP
      address, thus 'locking' it to the found IP address. So, it's still
      'safer' to explicitly provide the IP address of a VM's interface in the
      filter description if it is known beforehand.
      
      * configure.ac: detect libpcap
      * libvirt.spec.in: require libpcap[-devel] if qemu is built
      * src/internal.h: add the new ATTRIBUTE_PACKED define
      * src/Makefile.am src/libvirt_private.syms: add the new modules and symbols
      * src/nwfilter/nwfilter_learnipaddr.[ch]: new module being added
      * src/nwfilter/nwfilter_driver.c src/conf/nwfilter_conf.[ch]
        src/nwfilter/nwfilter_ebiptables_driver.[ch]
        src/nwfilter/nwfilter_gentech_driver.[ch]: plu the new functionality in
      * tests/nwfilterxml2xmltest: extend testing
      3bf24abc
  33. 01 4月, 2010 1 次提交
  34. 26 3月, 2010 1 次提交
    • D
      Implement VNC password change in QEMU · ab952024
      Daniel P. Berrange 提交于
      Use the new virDomainUpdateDeviceFlags API to allow the VNC password
      to be changed on the fly
      
      * src/internal.h: Define STREQ_NULLABLE() which is like STREQ()
        but does not crash if either argument is NULL, and treats two
        NULLs as equal.
      * src/libvirt_private.syms: Export virDomainGraphicsTypeToString
      * src/qemu/qemu_driver.c: Support VNC password change on a live
        machine
      * src/qemu/qemu_monitor.c: Disable crazy debugging info. Treat a
        NULL password as "" (empty string), allowing passwords to be
        disabled in the monitor
      ab952024
  35. 10 3月, 2010 2 次提交
    • E
      build: consistently indent preprocessor directives · 36d8e7d8
      Eric Blake 提交于
      * global: patch created by running:
      for f in $(git ls-files '*.[ch]') ; do
          cppi $f > $f.t && mv $f.t $f
      done
      36d8e7d8
    • E
      virsh: fix existing N_ uses · f6876e10
      Eric Blake 提交于
      It is a bad idea to call gettext on an already-translated
      string.  In cases where a string must be translated separately
      from where it is exposed to xgettext, the gettext manual
      recommends the idiom of N_() wrapping gettext_noop for
      marking the string.
      
      * src/internal.h (N_): Fix definition to match gettext manual.
      * tools/virsh.c: (cmdHelp, cmdList, cmdDomstate, cmdDominfo)
      (cmdVcpuinfo, vshUsage): Replace incorrect use of N_ with _.
      (vshCmddefHelp): Likewise.  Mark C format strings appropriately.
      f6876e10
  36. 02 2月, 2010 1 次提交
    • E
      maint: avoid excess parens in STREQ · 6b8d8395
      Eric Blake 提交于
      * src/internal.h (STREQ, STRCASEEQ, STRNEQ, STRCASENEQ, STREQLEN)
      (STRCASEEQLEN, STRNEQLEN, STRCASENEQLEN, STRPREFIX): Avoid
      redundant parenthesis.
      * examples/domain-events/events-c/event-test.c (STREQ): Likewise.
      * src/storage/parthelper.c (STREQ): Likewise.
      6b8d8395
  37. 22 12月, 2009 1 次提交
  38. 06 11月, 2009 1 次提交
    • P
      Add sentinel attribute for NULL terminated arg lists · 649bcd72
      Paolo Bonzini 提交于
      * src/internal.h (ATTRIBUTE_SENTINEL): New, it's a ggc feature and
        protected as such
      * src/util/buf.c (virBufferStrcat): Use it.
      * src/util/ebtables.c (ebtablesAddRemoveRule): Use it.
      * src/util/iptables.c (iptableAddRemoveRule: Use it.
      * src/util/qparams.h (new_qparam_set, append_qparams): Use it.
      * docs/apibuild.py: avoid breaking the API generator with that new
        internal keyword macro
      649bcd72