1. 19 7月, 2013 1 次提交
    • E
      tests: split long lines · 684c90bf
      Eric Blake 提交于
      Long lines are harder to read and harder to diff; in fact, if lines get
      too long (> 1000 bytes), it starts causing issues where git send-email
      refuses to send patches for the file.  I've cleaned up the tests
      directory in the past (see commits bd6c46fa, 3b750d13), but new long
      lines have been introduced in the meantime.
      
      Why 90 instead of 80? Because there were too many tests on the fringe
      edge, and I didn't want to edit that many files.
      
      Add a syntax check to prevent future long lines.
      
      * cfg.mk (sc_prohibit_long_lines): New rule.
      * tests/qemuxml2argvdata/qemuxml2argv-*.args: Split lines of any
      file with content longer than 90 columns.
      * tests/storagevolxml2argvdata/*.argv: Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      684c90bf
  2. 11 7月, 2013 1 次提交
  3. 10 7月, 2013 2 次提交
    • M
      Introduce OOM reporting to virAsprintf · dc6f2dad
      Michal Privoznik 提交于
      Actually, I'm turning this function into a macro as filename,
      function name and line number needs to be passed. The new
      function virAsprintfInternal is introduced with the extended set
      of arguments.
      dc6f2dad
    • E
      build: honor autogen.sh --no-git · 1e503ee5
      Eric Blake 提交于
      Based on a report by Chandrashekar Shastri, at
      https://bugzilla.redhat.com/show_bug.cgi?id=979360
      
      On systems where git cannot access the outside world, a developer
      can instead arrange to get a copy of gnulib at the right commit
      via side channels (such as NFS share drives), set GNULIB_SRCDIR,
      then use ./autogen.sh --no-git.  In this setup, we will now
      avoid direct use of git.  Of course, this means no automatic
      gnulib updates when libvirt.git updates its submodule, but it
      is expected that any developer in such a situation is already
      prepared to deal with the fallout.
      
      * .gnulib: Update to latest, for bootstrap.
      * bootstrap: Synchronize from gnulib.
      * autogen.sh (no_git): Avoid git when requested.
      * cfg.mk (_update_required): Skip automatic rerun of bootstrap if
      we can't use git.
      * docs/compiling.html.in: Document this setup.
      * docs/hacking.html.in: Mention this.
      * HACKING: Regenerate.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      1e503ee5
  4. 25 6月, 2013 1 次提交
  5. 05 6月, 2013 1 次提交
    • E
      maint: don't use config.h in .h files · 1add9c78
      Eric Blake 提交于
      Enforce the rule that .h files don't need to (redundantly)
      include <config.h>.
      
      * cfg.mk (sc_prohibit_config_h_in_headers): New rule.
      (_virsh_includes): Delete; instead, inline a smaller number of
      exclusions...
      (exclude_file_name_regexp--sc_require_config_h)
      (exclude_file_name_regexp--sc_require_config_h_first): ...here.
      * daemon/libvirtd.h (includes): Fix offenders.
      * src/driver.h (includes): Likewise.
      * src/gnutls_1_0_compat.h (includes): Likewise.
      * src/libxl/libxl_conf.h (includes): Likewise.
      * src/libxl/libxl_driver.h (includes): Likewise.
      * src/lxc/lxc_conf.h (includes): Likewise.
      * src/lxc/lxc_driver.h (includes): Likewise.
      * src/lxc/lxc_fuse.h (includes): Likewise.
      * src/network/bridge_driver.h (includes): Likewise.
      * src/phyp/phyp_driver.h (includes): Likewise.
      * src/qemu/qemu_conf.h (includes): Likewise.
      * src/util/virnetlink.h (includes): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      1add9c78
  6. 28 5月, 2013 2 次提交
    • E
      syntax: fix broken error message in previous patch · 0c8926da
      Eric Blake 提交于
      Osier Yang pointed out that I introduced a syntax error in my
      syntax check (I really shouldn't make last-minute changes without
      testing them....).
      
      /bin/sh: -c: line 2: syntax error near unexpected token `;'
      /bin/sh: -c: line 2: `  { echo 'maint.mk: incorrect whitespace, see HACKING for rules' 2>&; \'
      make: *** [bracket-spacing-check] Error 1
      
      * cfg.mk (bracket-spacing-check): Fix copy-and-paste error.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      0c8926da
    • E
      syntax-check: mandate space after mid-line semicolon · 134e685b
      Eric Blake 提交于
      Enforce the style cleanup in the previous patch.
      
      * build-aux/bracket-spacing.pl: Enforce trailing spacing.
      * cfg.mk (bracket-spacing-check): Tweak error wording.
      * docs/hacking.html.in: Document the rule.
      * HACKING: Regenerate.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      134e685b
  7. 24 5月, 2013 1 次提交
  8. 21 5月, 2013 2 次提交
    • E
      maint: enforce correct copyright usage · 0e55024e
      Eric Blake 提交于
      To ensure we don't regress and cause the need for further
      cleanups, add a 'make syntax-check' rule that ensures new
      files have proper copyright contents.
      
      * cfg.mk (sc_copyright_address): Rename...
      (sc_copyright_usage): ...and enhance.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      0e55024e
    • E
      maint: follow recommended practice for using LGPL · de483052
      Eric Blake 提交于
      https://www.gnu.org/licenses/gpl-howto.html states:
      
      You should also include a copy of the license itself somewhere in the
      distribution of your program. All programs, whether they are released
      under the GPL or LGPL, should include the text version of the GPL. In
      GNU programs the license is usually in a file called COPYING.
      
      If you are releasing your program under the LGPL, you should also
      include the text version of the LGPL, usually in a file called
      COPYING.LESSER. Please note that, since the LGPL is a set of
      additional permissions on top of the GPL, it's important to include
      both licenses so users have all the materials they need to understand
      their rights.
      
      * configure.ac (COPYING): No more games with non-git file.
      * COPYING: New file, copied from gnulib.
      * COPYING.LIB: Rename...
      * COPYING.LESSER: ...to this.
      * .gitignore: Track licenses in git.
      * cfg.mk (exclude_file_name_regexp--sc_copyright_address): Tweak
      rule.
      * libvirt.spec.in (daemon, client, python): Reflect rename.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      de483052
  9. 14 5月, 2013 1 次提交
    • 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. 11 5月, 2013 1 次提交
    • 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
  11. 07 5月, 2013 1 次提交
  12. 03 5月, 2013 1 次提交
    • E
      build: avoid useless virAsprintf · 25ae3d30
      Eric Blake 提交于
      virAsprintf(&foo, "%s", bar) is wasteful compared to
      foo = strdup(bar) (or eventually, VIR_STRDUP(foo, bar),
      but one thing at a time...).
      
      Noticed while reviewing Laine's attempt to clean up broken
      qemu:///session.
      
      * cfg.mk (sc_prohibit_asprintf): Enhance rule.
      * src/esx/esx_storage_backend_vmfs.c
      (esxStorageBackendVMFSVolumeLookupByKey): Fix offender.
      * src/network/bridge_driver.c (networkStateInitialize): Likewise.
      * src/nwfilter/nwfilter_dhcpsnoop.c (virNWFilterSnoopDHCPOpen):
      Likewise.
      * src/storage/storage_backend_sheepdog.c
      (virStorageBackendSheepdogRefreshVol): Likewise.
      * src/util/vircgroup.c (virCgroupAddTaskStrController): Likewise.
      * src/util/virdnsmasq.c (addnhostsAdd): Likewise.
      * src/xen/block_stats.c (xenLinuxDomainDeviceID): Likewise.
      * src/xen/xen_driver.c (xenUnifiedConnectOpen): Likewise.
      * tools/virsh.c (vshGetTypedParamValue): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      25ae3d30
  13. 02 5月, 2013 1 次提交
    • M
      virutil: Move string related functions to virstring.c · 7c9a2d88
      Michal Privoznik 提交于
      The source code base needs to be adapted as well. Some files
      include virutil.h just for the string related functions (here,
      the include is substituted to match the new file), some include
      virutil.h without any need (here, the include is removed), and
      some require both.
      7c9a2d88
  14. 26 4月, 2013 1 次提交
    • E
      build: avoid unsafe functions in libgen.h · 1fbf1905
      Eric Blake 提交于
      POSIX says that both basename() and dirname() may return static
      storage (aka they need not be thread-safe); and that they may but
      not must modify their input argument.  Furthermore, <libgen.h>
      is not available on all platforms.  For these reasons, you should
      never use these functions in a multi-threaded library.
      
      Gnulib instead recommends a way to avoid the portability nightmare:
      gnulib's "dirname.h" provides useful thread-safe counterparts.  The
      obvious dir_name() and base_name() are GPL (because they malloc(),
      but call exit() on failure) so we can't use them; but the LGPL
      variants mdir_name() (malloc's or returns NULL) and last_component
      (always points into the incoming string without modifying it,
      differing from basename semantics only on corner cases like the
      empty string that we shouldn't be hitting in the first place) are
      already in use in libvirt.  This finishes the swap over to the safe
      functions.
      
      * cfg.mk (sc_prohibit_libgen): New rule.
      * src/util/vircgroup.c: Fix offenders.
      * src/parallels/parallels_storage.c (parallelsPoolAddByDomain):
      Likewise.
      * src/parallels/parallels_network.c (parallelsGetBridgedNetInfo):
      Likewise.
      * src/node_device/node_device_udev.c (udevProcessSCSIHost)
      (udevProcessSCSIDevice): Likewise.
      * src/storage/storage_backend_disk.c
      (virStorageBackendDiskDeleteVol): Likewise.
      * src/util/virpci.c (virPCIGetDeviceAddressFromSysfsLink):
      Likewise.
      * src/util/virstoragefile.h (_virStorageFileMetadata): Avoid false
      positive.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      1fbf1905
  15. 18 4月, 2013 3 次提交
  16. 16 4月, 2013 1 次提交
    • D
      Add a test suite for cgroups functionality · d1452470
      Daniel P. Berrange 提交于
      Some aspects of the cgroups setup / detection code are quite subtle
      and easy to break. It would greatly benefit from unit testing, but
      this is difficult because the test suite won't have privileges to
      play around with cgroups. The solution is to use monkey patching
      via LD_PRELOAD to override the fopen, open, mkdir, access functions
      to redirect access of cgroups files to some magic stubs in the
      test suite.
      
      Using this we provide custom content for the /proc/cgroup and
      /proc/self/mounts files which report a fixed cgroup setup. We
      then override open/mkdir/access so that access to the cgroups
      filesystem gets redirected into files in a temporary directory
      tree in the test suite build dir.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      d1452470
  17. 16 3月, 2013 1 次提交
    • E
      util: portably check for unchanged uid · 7af86379
      Eric Blake 提交于
      We've already scrubbed for comparisons of 'uid_t == -1' (which fail
      on platforms where uid_t is a u16), but another one snuck in.
      
      * src/util/virutil.c (virSetUIDGIDWithCaps): Correct uid comparison.
      * cfg.mk (sc_prohibit_risky_id_promotion): New rule.
      7af86379
  18. 26 2月, 2013 1 次提交
    • E
      tests: uniformly report test failures · dce95297
      Eric Blake 提交于
      testutils.c likes to print summaries after a test completes,
      including if it failed.  But if the test outright exit()s,
      this summary is skipped.  Enforce that we return instead of exit.
      
      * cfg.mk (sc_prohibit_exit_in_tests): New syntax check.
      * tests/commandhelper.c (main): Fix offenders.
      * tests/qemumonitorjsontest.c (mymain): Likewise.
      * tests/seclabeltest.c (main): Likewise.
      * tests/securityselinuxlabeltest.c (mymain): Likewise.
      * tests/securityselinuxtest.c (mymain): Likewise.
      * tests/testutils.h (VIRT_TEST_MAIN_PRELOAD): Likewise.
      * tests/testutils.c (virtTestMain): Likewise.
      (virtTestCaptureProgramOutput): Use symbolic name.
      dce95297
  19. 08 2月, 2013 3 次提交
  20. 26 1月, 2013 1 次提交
    • J
      vbox: Adjust the UTF FREE macros · 97278ab4
      John Ferlan 提交于
      Adjust the macros to free memory allocated during various calls to
      perform the check if parameter is NULL prior to really freeing and to
      set the pointer to NULL after done freeing.
      97278ab4
  21. 22 1月, 2013 1 次提交
    • E
      spec: indent %if to make it easier to see conditions · c8f79c9b
      Eric Blake 提交于
      Nested conditionals are hard to read if they are not indented.
      We can't add arbitrary whitespace to everything in spec files,
      but we CAN add spaces before %if and %define.  Use this trick,
      plus a fancy sed script that rewrites a spec file into a C
      file, so we can use cppi to keep our spec file nice.
      
      For reference, the sed script converts code like:
      
      |# RHEL-5 builds are client-only for s390, ppc
      |%if 0%{?rhel} == 5
      |    %ifnarch %{ix86} x86_64 ia64
      |        %define client_only        1
      |    %endif
      |%endif
      
      into the following for cppi:
      
      |// # RHEL-5 builds are client-only for s390, ppc
      |#if a // 0%{?rhel} == 5
      |# if a // %{ix86} x86_64 ia64
      |#  define client_only        1
      |# endif
      |#endif
      
      and errors from 'make syntax-check' look like:
      spec_indentation
      cppi: mingw-libvirt.spec.in: line 130: not properly indented
      maint.mk: incorrect preprocessor indentation
      
      * libvirt.spec.in: Add some indentation to make it easier to follow
      various conditionals.
      * mingw-libvirt-spec.in: Likewise.
      * cfg.mk (sc_spec_indentation): New syntax check to enforce it.
      c8f79c9b
  22. 14 1月, 2013 2 次提交
    • 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
    • D
      Add a test suite for validating SELinux labelling · 907a39e7
      Daniel P. Berrange 提交于
      There are many aspects of the guest XML which result in the
      SELinux driver applying file labelling. With the increasing
      configuration options it is desirable to test this behaviour.
      It is not possible to assume that the test suite has the
      ability to set SELinux labels. Most filesystems though will
      support extended attributes. Thus for the purpose of testing,
      it is possible to extend the existing LD_PRELOAD hack to
      override setfilecon() and getfilecon() to simply use the
      'user.libvirt.selinux' attribute for the sake of testing.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      907a39e7
  23. 11 1月, 2013 1 次提交
    • D
      Add some autoconf helper macros for checking for libraries · cd699ed1
      Daniel P. Berrange 提交于
      Most checks for libraries take the same format
      
        * --with-libFOO=yes|no|check|/some/path  argument
        * check for a function NNN in libFOO.so
        * check for a header file DDD/HHH.h
        * Define a WITH_FOO config.h symbol
        * Define a WITH_FOO make conditional
        * Substitute FOO_CFLAGS and FOO_LIBS make variables
        * Print CFLAGS & LIBS summary at the end
      
      Doing all this correctly is rather difficult, typically
      done by copy+paste of a previous usage. Further small
      improvements people make are not applied to all previous
      usages.
      
      Improve this by creating some helper macros to apply
      good practice. First, to perform the actual checks:
      
        LIBVIRT_CHECK_LIB([SELINUX], [selinux],
           [getfilecon], [selinux/selinux.h])
      
      This checks for 'getfilecon' in -lselinux, and the
      existence of 'selinux/selinux.h' header file. If successful
      it sets SELINUX_CFLAGS and SELINUX_LIBS. The WITH_SELINUX
      config.h macro and WITH_SELINUX make conditional are also
      defined.
      
      In some cases we need to check two variants of the same
      library
      
        LIBVIRT_CHECK_LIB_ALT([SASL], [sasl2],
                              [sasl_client_init], [sasl/sasl.h],
                              [SASL1], [sasl],
                              [sasl_client_init], [sasl/sasl.h])
      
      This checks for sasl_client_init in libsasl2, and if that
      is not found, checks sasl_client_init in libsasl. If the
      first check succeeds WITH_SASL is set, while if the second
      check succeeds *both* WITH_SASL and WITH_SASL1 are set.
      
      If the library supports pkg-config, then another variant
      is available
      
        LIBVIRT_CHECK_PKG([AVAHI], [avahi-client], [0.6.0])
      
      This checks for avahi-client >= 0.6.0 via pkg-config
      and sets WITH_AVAHI if found.
      
      Finally to print a summary of CFLAGS & LIBs found (if any):
      
        LIBVIRT_RESULT_LIB([SELINUX])
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      cd699ed1
  24. 08 1月, 2013 1 次提交
  25. 21 12月, 2012 6 次提交
  26. 18 12月, 2012 1 次提交
  27. 13 12月, 2012 1 次提交