1. 19 11月, 2010 3 次提交
    • E
      memory: make it easier to avoid quadratic scaling of arrays · 269d3b72
      Eric Blake 提交于
      * src/util/memory.h (VIR_RESIZE_N): New macro.
      * src/util/memory.c (virResizeN): New function.
      * src/libvirt_private.syms: Export new helper.
      * docs/hacking.html.in: Document it.
      * HACKING: Regenerate.
      269d3b72
    • E
      memory: make it safer to expand arrays · 5a0beacc
      Eric Blake 提交于
      * src/util/memory.h (VIR_REALLOC_N): Update docs.
      (VIR_EXPAND_N, VIR_SHRINK_N): New macros.
      (virAlloc, virAllocN, virReallocN, virAllocVar, virFree): Add some
      gcc attributes.
      * src/util/memory.c (virExpandN, virShrinkN): New functions.
      (virReallocN): Update docs.
      * src/libvirt_private.syms: Export new helpers.
      * docs/hacking.html.in: Prefer newer interfaces over
      VIR_REALLOC_N, since uninitialized memory can bite us.
      * HACKING: Regenerate.
      5a0beacc
    • D
      Fix a failure to restore SELinux label for character devices · 83fa1184
      Daniel Veillard 提交于
      The code in SELinuxRestoreSecurityChardevLabel() was trying to
      use SELinuxSetFilecon directly for devices or file types while
      it should really use SELinuxRestoreSecurityFileLabel encapsulating
      routine, which avoid various problems like resolving symlinks,
      making sure he file exists and work around NFS problems
      83fa1184
  2. 18 11月, 2010 4 次提交
    • M
      virt-aa-helper: Fix several compile errors · c505eafe
      Matthias Bolte 提交于
      Include locale.h for setlocale().
      
      Revert the usage string back to it's original form.
      
      Use puts() instead of fputs(), as fputs() expects a FILE*.
      
      Add closing parenthesis to some vah_error() calls.
      
      Use argv[0] instead of an undefined argv0.
      c505eafe
    • E
      maint: avoid remaining sprintf uses · e8aba782
      Eric Blake 提交于
      * cfg.mk (sc_prohibit_sprintf): New rule.
      (sc_prohibit_asprintf): Avoid false positives.
      * docs/hacking.html.in (Printf-style functions): Document the
      policy.
      * HACKING: Regenerate.
      * .x-sc_prohibit_sprintf: New exemptions.
      * Makefile.am (syntax_check_exceptions): Ship new file.
      * src/vbox/vbox_tmpl.c (vboxStartMachine, vboxAttachUSB): Use
      virAsprintf instead.
      * src/uml/uml_driver.c (umlOpenMonitor): Use snprintf instead.
      * tools/virsh.c (cmdDetachInterface): Likewise.
      * src/security/security_selinux.c (SELinuxGenSecurityLabel):
      Likewise.
      * src/openvz/openvz_driver.c (openvzDomainDefineCmd): Likewise,
      and ensure large enough buffer.
      e8aba782
    • E
      virt-aa-helper: translate error messages · c811d46f
      Eric Blake 提交于
      These messages are visible to the user, so they should be
      consistently translated.
      
      * cfg.mk (msg_gen_function): Add vah_error, vah_warning.
      * src/security/virt-aa-helper.c: Translate messages.
      (catchXMLError): Fix capitalization.
      c811d46f
    • 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
  3. 17 11月, 2010 6 次提交
    • 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
    • S
      replace last instances of close() · 8e3051af
      Stefan Berger 提交于
      I am replacing the last instances of close() I found with VIR_CLOSE() / VIR_FORCE_CLOSE respectively.
      
      The first part patches virsh, which I missed out on previously.
      
      The 2nd patch I had left out intentionally to look at it more carefully:
      The 'closed' variable could be easily removed since it wasn't used anywhere else. The possible race condition that could result from the filedescriptor being closed and not set to -1 (and possibly let us write into 'something' totally different if the fd was allocated by another thread) seems to be prevented by the qemuMonitorLock() already placed around the code that reads from or writes to the fd. So the change of this code as shown in the patch should not have any side-effects.
      8e3051af
    • S
      nwfilter: also purge ip(6)tables rules before detecting IP address · d4897acf
      Stefan Berger 提交于
      Rather than only cleaning any remaining ebtables rules, also clean those applied to iptables and ip6tables when detecting the IP address of an interface. Previous applied iptables rules may hinder DHCP packets.
      d4897acf
    • S
      deprecate fclose() and introduce VIR_{FORCE_}FCLOSE() · 7b7cb1ec
      Stefan Berger 提交于
      Similarly to deprecating close(), I am now deprecating fclose() and
      introduce VIR_FORCE_FCLOSE() and VIR_FCLOSE(). Also, fdopen() is replaced with
      VIR_FDOPEN().
      
      Most of the files are opened in read-only mode, so usage of
      VIR_FORCE_CLOSE() seemed appropriate. Others that are opened in write
      mode already had the fclose()<  0 check and I converted those to
      VIR_FCLOSE()<  0.
      
      I did not find occurrences of possible double-closed files on the way.
      7b7cb1ec
    • O
      qemu: fix typos in qemu_monitor_text.c · 54837455
      Osier Yang 提交于
      * src/qemu/qemu_monitor_text.c (qemuMonitorTextChangeMedia)
      54837455
    • O
      qemu: record timestamp in qemu domain log · 93bc093a
      Osier Yang 提交于
      Currently only support domain start and shutdown, for domain start,
      record timestamp before the qemu command line, and for domain shutdown,
      just say it's shutting down with timestamp.
      
      * src/qemu/qemu_driver.c (qemudStartVMDaemon, qemudShutdownVMDaemon
        introduced two macros - START_POSTFIX, SHUTDOWN_POSTFIX)
      93bc093a
  4. 16 11月, 2010 3 次提交
  5. 15 11月, 2010 3 次提交
  6. 12 11月, 2010 16 次提交
    • J
      90afacb3
    • M
      phyp: Don't do a flags check in the storage driver · d941eb13
      Matthias Bolte 提交于
      This makes the storage driver fail when the connection is
      opened with the VIR_CONNECT_RO flag, resulting in a read-only
      connection with no storage driver.
      d941eb13
    • M
      qemu: Add qemu-system-s390x to the emulators list · f6d9a3e2
      Matthias Bolte 提交于
      f6d9a3e2
    • S
      macvtap: convert nl msg construction to use libnl · 77e7c13b
      Stefan Berger 提交于
      In a first step I am converting the netlink message construction in
      macvtap code to use libnl. It's pretty much a 1:1 conversion except that
      now the message needs to be allocated and deallocated.
      77e7c13b
    • J
      virt-aa-helper should require <uuid> in XML · 29318e17
      Jamie Strandboge 提交于
      When <uuid> is not in the XML, a virUUIDGenerate() ends up being called which
      is unnecessary and can lead to crashes if /dev/urandom isn't available
      because virRandomInitialize() is not called within virt-aa-helper. This patch
      adds verify_xpath_context() and updates caps_mockup() to use it.
      
      Bug-Ubuntu: https://launchpad.net/bugs/672943
      29318e17
    • M
      esx: Support SMBIOS host mode · 52888813
      Matthias Bolte 提交于
      52888813
    • L
      45dc5a14
    • L
      ignore SELinuxSetFilecon error in SELinuxSetSecurityFileLabel if on nfs · 5b04f42c
      Laine Stump 提交于
      If virDomainAttachDevice() was called with an image that was located
      on a root-squashed NFS server, and in a directory that was unreadable
      by root on the machine running libvirtd, the attach would fail due to
      an attempt to change the selinux label of the image with EACCES (which
      isn't covered as an ignore case in SELinuxSetFilecon())
      
      NFS doesn't support SELinux labelling anyway, so we mimic the failure
      handling of commit 93a18bba, which
      just ignores the errors if the target is on an NFS filesystem (in
      SELinuxSetSecurityAllLabel() only, though.)
      
      This can be seen as a follow-on to commit
      347d266c, which ignores file open
      failures of files on NFS that occur directly in
      virDomainDiskDefForeachPath() (also necessary), but does not ignore
      failures in functions that are called from there (eg
      SELinuxSetSecurityFileLabel()).
      5b04f42c
    • D
      Wire up virDomainOpenConsole for LXC, Xen and UML · 5fb9db27
      Daniel P. Berrange 提交于
      Introduce implementations of the virDomainOpenConsole() API
      for LXC, Xen and UML drivers.
      
      * src/lxc/lxc_driver.c, src/lxc/lxc_driver.c,
        src/xen/xen_driver.c: Wire up virDomainOpenConsole
      5fb9db27
    • D
      Introduce portability APIs for creating threads · 64d67507
      Daniel P. Berrange 提交于
      The util/threads.c/h code already has APIs for mutexes,
      condition variables and thread locals. This commit adds
      in code for actually creating threads.
      
      * src/libvirt_private.syms: Export new symbols
      * src/util/threads.h: Define APIs virThreadCreate, virThreadSelf,
        virThreadIsSelf and virThreadJoin
      * src/util/threads-win32.c, src/util/threads-win32.h: Win32
        impl of threads
      * src/util/threads-pthread.c, src/util/threads-pthread.h: POSIX
        impl of threads
      64d67507
    • D
      Support virDomainOpenConsole with QEMU · bdb28f44
      Daniel P. Berrange 提交于
      This provides an implementation of the virDomainOpenConsole
      API with the QEMU driver. For the streams code, this reuses
      most of the code previously added for the tunnelled migration
      streams since it is generic.
      
      * src/qemu/qemu_driver.c: Support virDomainOpenConsole
      bdb28f44
    • D
      Add a generic internal API for handling any FD based stream · 7c08fcc4
      Daniel P. Berrange 提交于
      To avoid the need for duplicating implementations of virStream
      drivers, provide a generic implementation that can handle any
      FD based stream. This code is copied from the existing impl
      in the QEMU driver, with the locking moved into the stream
      impl, and addition of a read callback
      
      The FD stream code will refuse to operate on regular files or
      block devices, since those can't report EAGAIN properly when
      they would block on I/O
      
      * include/libvirt/virterror.h, include/libvirt/virterror.h: Add
        VIR_FROM_STREAM error domain
      * src/qemu/qemu_driver.c: Remove code obsoleted by the new
        generic streams driver.
      * src/fdstream.h, src/fdstream.c, src/fdstream.c,
        src/libvirt_private.syms: Generic reusable FD based streams
      7c08fcc4
    • D
      Lower logging level in remote driver streams · 4ef40df1
      Daniel P. Berrange 提交于
      Now that bi-directional, non-blocking streams are supported
      in the remote driver, some of the VIR_WARN statements need
      to be reduced to VIR_DEBUG.
      
      * src/remote/remote_driver.c: Lower logging level
      4ef40df1
    • D
      Remote driver client and server for virDomainOpenConsole · 73d8b03c
      Daniel P. Berrange 提交于
      This provides an implementation of the virDomainOpenConsole
      API for the remote driver client and server.
      
      * daemon/remote.c: Server side impl
      * src/remote/remote_driver.c: Client impl
      * src/remote/remote_protocol.x: Wire definition
      73d8b03c
    • D
      Introduce a virDomainOpenConsole API · 88a9b382
      Daniel P. Berrange 提交于
      To enable virsh console (or equivalent) to be used remotely
      it is necessary to provide remote access to the /dev/pts/XXX
      pseudo-TTY associated with the console/serial/parallel device
      in the guest. The virStream API provide a bi-directional I/O
      stream capability that can be used for this purpose. This
      patch thus introduces a virDomainOpenConsole API that uses
      the stream APIs.
      
      * src/libvirt.c, src/libvirt_public.syms,
        include/libvirt/libvirt.h.in, src/driver.h: Define the
        new virDomainOpenConsole API
      * src/esx/esx_driver.c, src/lxc/lxc_driver.c,
        src/opennebula/one_driver.c, src/openvz/openvz_driver.c,
        src/phyp/phyp_driver.c, src/qemu/qemu_driver.c,
        src/remote/remote_driver.c, src/test/test_driver.c,
        src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
        src/xen/xen_driver.c, src/xenapi/xenapi_driver.c: Stub
        API entry point
      88a9b382
    • D
      Support callbacks on virStream APIs in remote driver client · 51269265
      Daniel P. Berrange 提交于
      The current remote driver code for streams only supports
      blocking I/O mode. This is fine for the usage with migration
      but is a problem for more general use cases, in particular
      bi-directional streams.
      
      This adds supported for the stream callbacks and non-blocking
      I/O. with the minor caveat is that it doesn't actually do
      non-blocking I/O for sending stream data, only receiving it.
      A future patch will try to do non-blocking sends, but this is
      quite tricky to get right.
      
      * src/remote/remote_driver.c: Allow non-blocking I/O for
        streams and support callbacks
      51269265
  7. 11 11月, 2010 2 次提交
    • D
      Fix LXC container console device setup · 2fbec002
      Daniel P. Berrange 提交于
      The /dev/console device inside the container must NOT map
      to the real /dev/console device node, since this allows the
      container control over the current host console. A fun side
      effect of this is that starting a container containing a
      real Fedora OS will kill off your X server.
      
      Remove the /dev/console node, and replace it with a symlink
      to the primary console TTY
      
      * src/lxc/lxc_container.c: Replace /dev/console with a
        symlink to /dev/pty/0
      * src/lxc/lxc_controller.c: Remove /dev/console from cgroups
        ACL
      2fbec002
    • C
      qemu: Add flag to force a CDROM eject · 96d52fcf
      Cole Robinson 提交于
      QEMU allows forcing a CDROM eject even if the guest has locked the device.
      Expose this via a new UpdateDevice flag, VIR_DOMAIN_DEVICE_MODIFY_FORCE.
      
      This has been requested for RHEV:
      
      https://bugzilla.redhat.com/show_bug.cgi?id=626305
      
      v2: Change flag name, bool cleanups
      96d52fcf
  8. 10 11月, 2010 3 次提交
    • A
      Allow non-file disk backingStores · 9c7c4a4f
      Adam Litke 提交于
      I am trying to use a qcow image with libvirt where the backing 'file' is a
      qemu-nbd server.  Unfortunately virDomainDiskDefForeachPath() assumes that
      backingStore is always a real file so something like 'nbd:0:3333' is rejected
      because a file with that name cannot be accessed.  Note that I am not worried
      about directly using nbd images.  That would require a new disk type with XML
      markup, etc.  I only want it to be permitted as a backingStore
      
      The following patch implements danpb's suggestion:
      > I think I'm inclined to push the logic for skipping NBD one stage higher.
      > I'd rather expect virStorageFileGetMetadata() to return all backing
      > stores, even if not files. The virDomainDiskDefForeachPath() method
      > should definitely ignore non-file backing stores though.
      >
      > So what I'm thinking is to extend the virStorageFileMetadata struct and
      > just add a 'bool isFile' field to it. Default this field to true, unless
      > you see the prefix of nbd: in which case set it to false. The
      > virDomainDiskDefForeachPath() method can then skip over any backing
      > store with isFile == false
      Signed-off-by: NAdam Litke <agl@us.ibm.com>
      Cc: Daniel P. Berrange <berrange@redhat.com>
      9c7c4a4f
    • M
      xencapstest: Don't fail when Xen is installed · c2e9e907
      Matthias Bolte 提交于
      xencapstest calls xenHypervisorMakeCapabilitiesInternal with conn == NULL
      which calls xenDaemonNodeGetTopology with conn == NULL when a recent
      enough Xen was detected (sys_interface_version >= SYS_IFACE_MIN_VERS_NUMA).
      But xenDaemonNodeGetTopology insists in having conn != NULL and fails,
      because it expects to be able to talk to an actual xend.
      
      We cannot do that in a 'make check' test. Therefore, only call the xend
      subdriver function when conn isn't NULL.
      
      Reported by Andy Howell and Jim Fehlig.
      c2e9e907
    • S
      bye to close(), welcome to VIR_(FORCE_)CLOSE() · 60ae1c34
      Stefan Berger 提交于
      Using automated replacement with sed and editing I have now replaced all
      occurrences of close() with VIR_(FORCE_)CLOSE() except for one, of
      course. Some replacements were straight forward, others I needed to pay
      attention. I hope I payed attention in all the right places... Please
      have a look. This should have at least solved one more double-close
      error.
      60ae1c34