1. 14 12月, 2009 6 次提交
    • P
      add --crash support to "virsh dump" · b927aed8
      Paolo Bonzini 提交于
      This patch adds the --crash option (already present in "xm dump-core")
      to "virsh dump".  virDomainCoreDump already has a flags argument, so
      the API/ABI is untouched.
      
      * include/libvirt/libvirt.h.in (virDomainCoreDumpFlags): New flag for
        CoreDump
      * src/test/test_driver.c (testDomainCoreDump): Do not crash
        after dump unless VIR_DUMP_CRASH is given.
      * src/qemu/qemu_driver.c (qemudDomainCoreDump): Shutdown the domain
        instead of restarting it if --crash is passed.
      * src/xen/xend_internal.c (xenDaemonDomainCoreDump): Support --crash.
      * tools/virsh.c (opts_dump): Add --crash.
        (cmdDump): Map it to flags for virDomainCoreDump and pass them.
      b927aed8
    • P
      fix various breakages in qemu Dump command · f509e162
      Paolo Bonzini 提交于
      1) qemuMigrateToCommand uses ">>" so we have to truncate the file
      before starting the migration;
      
      2) the command wasn't updated to chown the driver and set/restore
      the security lavels;
      
      3) the VM does not have to be resumed if migration fails;
      
      4) the file is not removed when migration fails.
      
      * src/qemu/qemu_driver.c (qemuDomainCoreDump): Truncate file before
        dumping, set/restore ownership and security labels for the file.
      f509e162
    • D
      Fix a couple of problems in last patch · a7d1eb3c
      Daniel Veillard 提交于
      Those were pointed by DanB in his review but not yet fixed
      
      * src/qemu/qemu_driver.c: qemudWaitForMonitor() use EnterMonitorWithDriver()
        and ExitMonitorWithDriver() there
      * src/qemu/qemu_monitor_text.c: checking fro strdu failure and hash
        table add error in qemuMonitorTextGetPtyPaths()
      a7d1eb3c
    • M
      Get QEMU pty paths from the monitor · 60e8977f
      Matthew Booth 提交于
      This change makes the QEMU driver get pty paths from the output of the
      monitor 'info chardev' command. This output is structured, and contains
      both the name of the device and the path on the same line. This is
      considerably more reliable than parsing the startup log output, which
      requires the parsing code to know which order QEMU will print pty
      information in.
      
      Note that we still need to parse the log output as the monitor itself
      may be on a pty. This should be rare, however, and the new code will
      replace all pty paths parsed by the log output method once the monitor
      is available.
      
      * src/qemu/qemu_monitor.(c|h) src/qemu_monitor_text.(c|h): Implement
        qemuMonitorGetPtyPaths().
      * src/qemu/qemu_driver.c: Get pty path information using
        qemuMonitorGetPtyPaths().
      60e8977f
    • M
      Extract the assigned pty device for QEmu channels · 033eef43
      Matthew Booth 提交于
      * src/qemu/qemu_driver.c: Parse pty devices for channels
      033eef43
    • R
      Suppress cgroup error message on sucess startup · 2597f8ec
      Ryota Ozaki 提交于
      Even if qemudStartVMDaemon suceeds, an error was logged such as
      'qemuRemoveCgroup:1778 : internal error Unable to find cgroup for'.
      This is because qemudStartVMDaemon calls qemuRemoveCgroup to
      ensure that old cgroup does not remain. This workaround makes
      sense but leaving an error message may confuse users.
      * src/qemu/qemu_driver.c: a an option to the function to suppress the
        error being logged
      2597f8ec
  2. 11 12月, 2009 3 次提交
  3. 10 12月, 2009 1 次提交
    • M
      Add virBufferFreeAndReset() and replace free() · 1b9d0744
      Matthias Bolte 提交于
      Replace free(virBufferContentAndReset()) with virBufferFreeAndReset().
      Update documentation and replace all remaining calls to free() with
      calls to VIR_FREE(). Also add missing calls to virBufferFreeAndReset()
      and virReportOOMError() in OOM error cases.
      1b9d0744
  4. 09 12月, 2009 1 次提交
    • D
      Fix virDomainObj ref handling in QEMU driver · 8e7d1495
      Daniel P. Berrange 提交于
      Since the monitor I/O is processed out of band from the main
      thread(s) invoking monitor  commands, the virDomainObj may be
      deleted by the I/O thread. The qemuDomainObjBeginJob takes an
      extra reference to protect against final deletion, but this
      reference is released by the corresponding EndJob call. THus
      after the EndJob call it may not be valid to reference the
      virDomainObj any more. To allow callers to detect this, the
      EndJob call is changed to return the remaining reference count.
      
      * src/conf/domain_conf.c: Make virDomainObjUnref return the
        remaining reference count
      * src/qemu/qemu_driver.c: Avoid referencing virDomainObjPtr
        after qemuDomainObjEndJob if it has been deleted.
      8e7d1495
  5. 08 12月, 2009 6 次提交
    • D
      Switch over to passing a callback table to QEMU monitor · e9f4c943
      Daniel P. Berrange 提交于
      With addition of events there will be alot of callbacks.
      To avoid having to add many APIs to register callbacks,
      provide them all at once in a big table
      
      * src/qemu/qemu_driver.c: Pass in a callback table to QEMU
        monitor code
      * src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h Replace
        the EOF and disk secret callbacks with a callback table
      e9f4c943
    • D
      Support for JSON mode monitor · 3a4f172f
      Daniel P. Berrange 提交于
      Initial support for the new QEMU monitor protocol  using JSON
      as the data encoding format instead of plain text
      
      * po/POTFILES.in: Add src/qemu/qemu_monitor_json.c
      * src/qemu/qemu_conf.c, src/qemu/qemu_conf.h: Hack to turn on QMP
        mode. Replace with a version number check on >= 0.12 later
      * src/qemu/qemu_monitor.c: Delegate to json monitor if enabled
      * src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h: Add
        impl of QMP protocol
      * src/Makefile.am: Add src/qemu/qemu_monitor_json.{c,h}
      3a4f172f
    • D
      Introduce callbacks for serializing domain object private data to XML · c5358c0e
      Daniel P. Berrange 提交于
      Now that drivers are using a private domain object state blob,
      the virDomainObjFormat/Parse methods are no longer able to
      directly serialize all neccessary state to/from XML. It is
      thus neccessary to introduce a pair of callbacks fo serializing
      private state.
      
      The code for serializing vCPU PIDs and the monitor device
      config can now move out of domain_conf.c and into the
      qemu_driver.c where they belong.
      
      * src/conf/capabilities.h: Add callbacks for serializing private
        state to/from XML
      * src/conf/domain_conf.c, src/conf/domain_conf.h: Remove the
        monitor, monitor_chr, monitorWatch, nvcpupids and vcpupids
        fields from virDomainObjPtr. Remove code that serialized
        those fields
      * src/libvirt_private.syms: Export virXPathBoolean
      * src/qemu/qemu_driver.c: Add callbacks for serializing monitor
        and vcpupid data to/from XML
      * src/qemu/qemu_monitor.h, src/qemu/qemu_monitor.c: Pass monitor
        char device config into qemuMonitorOpen directly.
      c5358c0e
    • D
      Pull code to start CPUs executing out of qemudInitCpuAffinity() · 5697aa84
      Daniel P. Berrange 提交于
      The code to start CPUs executing has nothing todo with CPU
      affinity masks, so pull it out of the qemudInitCpuAffinity()
      method and up into qemudStartVMDaemon()
      
      * src/qemu/qemu_driver.c: Pull code to start CPUs executing out
        of qemudInitCpuAffinity()
      5697aa84
    • D
      Add a 'format' arg to qemuMonitorChangeMedia() since JSON will support it · 8c12b20c
      Daniel P. Berrange 提交于
      The current QEMU disk media change does not support setting the
      disk format. The new JSON monitor will support this, so add an
      extra parameter to pass this info in
      
      * src/qemu/qemu_driver.c: Pass in disk format when changing media
      * src/qemu/qemu_monitor.h, src/qemu/qemu_monitor.c,
        src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h:
        Add a 'format' arg to qemuMonitorChangeMedia()
      8c12b20c
    • D
      Fix crash when deleting monitor while a command is in progress · 79533da1
      Daniel P. Berrange 提交于
      If QEMU shuts down while we're in the middle of processing a
      monitor command, the monitor will be freed, and upon cleaning
      up we attempt to do  qemuMonitorUnlock(priv->mon) when priv->mon
      is NULL.
      
      To address this we introduce proper reference counting into
      the qemuMonitorPtr object, and hold an extra reference whenever
      executing a command.
      
      * src/qemu/qemu_driver.c: Hold a reference on the monitor while
        executing commands, and only NULL-ify the priv->mon field when
        the last reference is released
      * src/qemu/qemu_monitor.h, src/qemu/qemu_monitor.c: Add reference
        counting to handle safe deletion of monitor objects
      79533da1
  6. 04 12月, 2009 1 次提交
    • M
      Fix some locking issues · 7a18fbee
      Matthias Bolte 提交于
      * src/conf/domain_conf.c: don't call virDomainObjUnlock twice
      * src/qemu/qemu_driver.c: relock driver lock if an error occurs in
        qemuDomainObjBeginJobWithDriver, enter/exit monitor with driver
        in qemudDomainSave
      7a18fbee
  7. 26 11月, 2009 1 次提交
  8. 24 11月, 2009 1 次提交
  9. 23 11月, 2009 1 次提交
    • D
      Pull schedular affinity code out into a separate module · 37f415da
      Daniel P. Berrange 提交于
      * src/Makefile.am: Add processinfo.h/processinfo.c
      * src/util/processinfo.c, src/util/processinfo.h: Module providing
        APIs for getting/setting process CPU affinity
      * src/qemu/qemu_driver.c: Switch over to new APIs for schedular
        affinity
      * src/libvirt_private.syms: Export virProcessInfoSetAffinity
        and virProcessInfoGetAffinity to internal drivers
      37f415da
  10. 19 11月, 2009 1 次提交
    • D
      Ensure driver lock is released when entering QEMU monitor · 278e9478
      Daniel P. Berrange 提交于
      The qemudStartVMDaemon() and several functions it calls use
      the QEMU monitor. The QEMU driver is locked while this function
      is executing, so it is rquired to release the driver lock and
      reacquire it either side of issuing a monitor command. It
      failed todo so, leading to deadlock
      
      * qemu/qemu_driver.c: Release driver when in qemudStartVMDaemon
        and things it calls
      278e9478
  11. 12 11月, 2009 1 次提交
    • C
      Add virConnectGetLibvirtVersion API · ce4c0bf5
      Cole Robinson 提交于
      There is currently no way to determine the libvirt version of a remote
      libvirtd we are connected to. This is a useful piece of data to enable
      feature detection.
      ce4c0bf5
  12. 11 11月, 2009 4 次提交
    • D
      Fix save and restore with non-privileged guests and SELinux · bc0010b3
      Daniel P. Berrange 提交于
      When running qemu:///system instance, libvirtd runs as root,
      but QEMU may optionally be configured to run non-root. When
      then saving a guest to a state file, the file is initially
      created as root, and thus QEMU cannot write to it. It is also
      missing labelling required to allow access via SELinux.
      
      * src/qemu/qemu_driver.c: Set ownership on save image before
        running migrate command in virDomainSave impl. Call out to
        security driver to set save image labelling
      * src/security/security_driver.h: Add driver APIs for setting
        and restoring saved state file labelling
      * src/security/security_selinux.c: Implement saved state file
        labelling for SELinux
      bc0010b3
    • D
      Implmentation of new APIs to checking state/persistence of objects · cabc2cc9
      Daniel P. Berrange 提交于
      This implements the virConnectIsSecure, virConnectIsEncrypted,
      virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
      virNetworkIsPersistent, virStoragePoolIsActive,
      virStoragePoolIsPersistent, virInterfaceIsActive APIs in
      (nearly) all drivers. Exceptions are:
      
       phyp: missing domainIsActive/Persistent
       esx: missing domainIsPersistent
       opennebula: missing domainIsActive/Persistent
      
      * src/remote/remote_protocol.x: Define remote wire ABI for newly
        added APIs.
      * daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
      * src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
        src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
        src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
        src/remote/remote_driver.c, src/storage/storage_driver.c,
        src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
        src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
        src/xen/xen_inotify.h: Implement all the new APIs where possible
      cabc2cc9
    • D
      New APIs for checking some object properties · c04498b3
      Daniel P. Berrange 提交于
      Introduce a number of new APIs to  expose some boolean properties
      of objects, which cannot otherwise reliably determined, nor are
      aspects of the XML configuration.
      
       * virDomainIsActive: Checking virDomainGetID is not reliable
         since it is not possible to distinguish between error condition
         and inactive domain for ID of -1.
       * virDomainIsPersistent: Check whether a persistent config exists
         for the domain
      
       * virNetworkIsActive: Check whether the network is active
       * virNetworkIsPersistent: Check whether a persistent config exists
         for the network
      
       * virStoragePoolIsActive: Check whether the storage pool is active
       * virStoragePoolIsPersistent: Check whether a persistent config exists
         for the storage pool
      
       * virInterfaceIsActive: Check whether the host interface is active
      
       * virConnectIsSecure: whether the communication channel to the
         hypervisor is secure
       * virConnectIsEncrypted: whether any network based commnunication
         channels are encrypted
      
      NB, a channel can be secure, even if not encrypted, eg if it does
      not involve the network, like a UNIX socket, or pipe.
      
       * include/libvirt/libvirt.h.in: Define public API
       * src/driver.h: Define internal driver API
       * src/libvirt.c: Implement public API entry point
       * src/libvirt_public.syms: Export API symbols
       * src/esx/esx_driver.c, src/lxc/lxc_driver.c,
         src/interface/netcf_driver.c, src/network/bridge_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: Stub out driver tables
      c04498b3
    • D
      Various fixes following a code review · 52147a04
      Daniel Veillard 提交于
      * src/libvirt.c src/lxc/lxc_conf.c src/lxc/lxc_container.c
        src/lxc/lxc_controller.c src/node_device/node_device_hal.c
        src/openvz/openvz_conf.c src/qemu/qemu_driver.c
        src/qemu/qemu_monitor_text.c src/remote/remote_driver.c
        src/storage/storage_backend_disk.c src/storage/storage_driver.c
        src/util/logging.c src/xen/sexpr.c src/xen/xend_internal.c
        src/xen/xm_internal.c: Steve Grubb <sgrubb@redhat.com> sent a code
        review and those are the fixes correcting the problems
      52147a04
  13. 10 11月, 2009 10 次提交
    • D
      Allow timeouts waiting for QEMU job lock · 9b6efcfe
      Daniel P. Berrange 提交于
      Some monitor commands may take a very long time to complete. It is
      not desirable to block other incoming API calls forever. With this
      change, if an existing API call is holding the job lock, additional
      API calls will not wait forever. They will time out after a short
      period of time, allowing application to retry later.
      
      * include/libvirt/virterror.h, src/util/virterror.c: Add new
        VIR_ERR_OPERATION_TIMEOUT error code
      * src/qemu/qemu_driver.c: Change to a timed condition variable
        wait for acquiring the monitor job lock
      9b6efcfe
    • D
      Release driver and domain lock when running monitor commands · f9c56cce
      Daniel P. Berrange 提交于
      QEMU monitor commands may sleep for a prolonged period of time.
      If the virDomainObjPtr or qemu driver lock is held this will
      needlessly block execution of many other API calls. it also
      prevents asynchronous monitor events from being dispatched
      while a monitor command is executing, because deadlock will
      ensure.
      
      To resolve this, it is neccessary to release all locks while
      executing a monitor command. This change introduces a flag
      indicating that a monitor job is active, and a condition
      variable to synchronize access to this flag. This ensures that
      only a single thread can be making a state change or executing
      a monitor command at a time, while still allowing other API
      calls to be completed without blocking
      
      * src/qemu/qemu_driver.c: Release driver and domain lock when
        running monitor commands. Re-add locking to disk passphrase
        callback
      * src/qemu/THREADS.txt: Document threading rules
      f9c56cce
    • D
      Fully asynchronous monitor I/O processing · 1dc10a7b
      Daniel P. Berrange 提交于
      Change the QEMU monitor file handle watch to poll for both
      read & write events, as well as EOF. All I/O to/from the
      QEMU monitor FD is now done in the event callback thread.
      
      When the QEMU driver needs to send a command, it puts the
      data to be sent into a qemuMonitorMessagePtr object instance,
      queues it for dispatch, and then goes to sleep on a condition
      variable. The event thread sends all the data, and then waits
      for the reply to arrive, putting the response / error data
      back into the qemuMonitorMessagePtr and notifying the condition
      variable.
      
      There is a temporary hack in the disk passphrase callback to
      avoid acquiring the domain lock.  This avoids a deadlock in
      the command processing, since the domain lock is still held
      when running monitor commands. The next commit will remove
      the locking when running commands & thus allow re-introduction
      of locking the disk passphrase callback
      
      * src/qemu/qemu_driver.c: Temporarily don't acquire lock in
        disk passphrase callback. To be reverted in next commit
      * src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Remove
        raw I/O functions, and a generic qemuMonitorSend() for
        invoking a command
      * src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h:
        Remove all low level I/O, and use the new qemuMonitorSend()
        API. Provide a qemuMonitorTextIOProcess() method for detecting
        command/reply/prompt boundaries in the monitor data stream
      1dc10a7b
    • D
      Locking of the qemuMonitorPtr object · 77cfcccf
      Daniel P. Berrange 提交于
      In preparation of the monitor I/O process becoming fully asynchronous,
      it is neccessary to ensure all access to internals of the qemuMonitorPtr
      object is protected by a mutex lock.
      
      * src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Add mutex for locking
        monitor.
      * src/qemu/qemu_driver.c: Add locking around all monitor commands
      77cfcccf
    • D
      Wrap text mode monitor APIs, pass qemuMonitorPtr directly to APIs · 41d8968d
      Daniel P. Berrange 提交于
      Change the QEMU driver to not directly invoke the text mode monitor
      APIs. Instead add a generic wrapper layer, which will eventually
      invoke either the text or JSON protocol code as needed. Pass an
      qemuMonitorPtr object into the monitor APIs instead of virDomainObjPtr
      to complete the de-coupling of the monitor impl from virDomainObj
      data structures
      
      * src/qemu/qemu_conf.h: Remove qemuDomainObjPrivate definition
      * src/qemu/qemu_driver.c: Add qemuDomainObjPrivate definition.
        Pass qemuMonitorPtr into all monitor APIs instead of the
        virDomainObjPtr instance.
      * src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Add thin
        wrappers for all qemuMonitorXXX command APIs, calling into
        qemu_monitor_text.c/h
      * src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h:
        Rename qemuMonitor -> qemuMonitorText & update to accept
        qemuMonitorPtr instead of virDomainObjPtr
      41d8968d
    • D
      Move encryption lookup back into qemu driver file · 4604c18f
      Daniel P. Berrange 提交于
      Decouple the monitor code from the virDomainDefPtr structure
      by moving the disk encryption lookup code back into the
      qemu_driver.c file. Instead provide a function callback to
      the monitor code which can be invoked to retrieve encryption
      data as required.
      
      * src/qemu/qemu_driver.c: Add findDomainDiskEncryption,
        and findVolumeQcowPassphrase. Pass address of the method
        findVolumeQcowPassphrase into qemuMonitorOpen()
      * src/qemu/qemu_monitor.c: Associate a disk
        encryption function callback with the qemuMonitorPtr
        object.
      * src/qemu/qemu_monitor_text.c: Remove findDomainDiskEncryption
        and findVolumeQcowPassphrase.
      4604c18f
    • D
      Make use of private data structure for monitor state · 1cfd5a00
      Daniel P. Berrange 提交于
      Introduce a new qemuDomainObjPrivate object which is used to store
      the private QEMU specific data associated with each virDomainObjPtr
      instance. This contains a single member, an instance of the new
      qemuMonitorPtr object which encapsulates the QEMU monitor state.
      The internals of the latter are private to the qemu_monitor* files,
      not to be shown to qemu_driver.c
      
      * src/qemu/qemu_conf.h: Definition of qemuDomainObjPrivate.
      * src/qemu/qemu_driver.c: Register a functions for creating
        and freeing qemuDomainObjPrivate instances with the domain
        capabilities. Remove the qemudDispatchVMEvent() watch since
        I/O watches are now handled by the monitor code itself. Pass
        a new qemuHandleMonitorEOF() callback into qemuMonitorOpen
        to allow notification when the monitor quits.
      * src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Introduce
        the 'qemuMonitor' object. Temporarily add new APIs
        qemuMonitorWrite, qemuMonitorRead, qemuMonitorWaitForInput
        to allow text based monitor impl to perform I/O.
      * src/qemu/qemu_monitor_text.c: Call APIs for reading/writing
        to monitor instead of accessing the file handle directly.
      1cfd5a00
    • D
      Move code for low level QEMU monitor interaction into separate file · ff261941
      Daniel P. Berrange 提交于
      The qemu_driver.c code should not contain any code that interacts
      with the QEMU monitor at a low level. A previous commit moved all
      the command invocations out. This change moves out the code which
      actually opens the monitor device.
      
      * src/qemu/qemu_driver.c: Remove qemudOpenMonitor & methods called
        from it.
      * src/Makefile.am: Add qemu_monitor.{c,h}
      * src/qemu/qemu_monitor.h: Add qemuMonitorOpen()
      * src/qemu/qemu_monitor.c: All code for opening the monitor
      ff261941
    • D
      Make pciDeviceList struct opaque · dd9e9c3b
      Daniel P. Berrange 提交于
      * src/util/pci.c, src/util/pci.h: Make the pciDeviceList struct
        opaque to callers of the API. Add accessor methods for managing
        devices in the list
      * src/qemu/qemu_driver.c: Update to use APIs instead of directly
        accessing pciDeviceList fields
      dd9e9c3b
    • M
      Add missing OOM error checks, reports and cleanups · 790f0b30
      Matthias Bolte 提交于
      790f0b30
  14. 06 11月, 2009 3 次提交