1. 21 12月, 2012 3 次提交
  2. 19 12月, 2012 3 次提交
  3. 13 12月, 2012 1 次提交
    • J
      Support network boot for HVM guests in libxl · f6b5ed5e
      Jim Fehlig 提交于
      The libxl driver ignored boot devices in the domain config,
      preventing PXE booting HVM domains.  This patch accounts for
      user-specified boot devices when building the libxl domain
      configuration.
      f6b5ed5e
  4. 07 12月, 2012 1 次提交
    • J
      Convert libxl driver to Xen 4.2 · dfa1e1dd
      Jim Fehlig 提交于
      Based on a patch originally authored by Daniel De Graaf
      
        http://lists.xen.org/archives/html/xen-devel/2012-05/msg00565.html
      
      This patch converts the Xen libxl driver to support only Xen >= 4.2.
      Support for Xen 4.1 libxl is dropped since that version of libxl is
      designated 'technology preview' only and is incompatible with Xen 4.2
      libxl.  Additionally, the default toolstack in Xen 4.1 is still xend,
      for which libvirt has a stable, functional driver.
      dfa1e1dd
  5. 04 12月, 2012 1 次提交
  6. 30 11月, 2012 1 次提交
  7. 10 11月, 2012 1 次提交
    • V
      capabilities: defaultConsoleTargetType can depend on architecture · b1c88c14
      Viktor Mihajlovski 提交于
      For S390, the default console target type cannot be of type 'serial'.
      It is necessary to at least interpret the 'arch' attribute
      value of the os/type element to produce the correct default type.
      
      Therefore we need to extend the signature of defaultConsoleTargetType
      to account for architecture. As a consequence all the drivers
      supporting this capability function must be updated.
      
      Despite the amount of changed files, the only change in behavior is
      that for S390 the default console target type will be 'virtio'.
      
      N.B.: A more future-proof approach could be to to use hypervisor
      specific capabilities to determine the best possible console type.
      For instance one could add an opaque private data pointer to the
      virCaps structure (in case of QEMU to hold capsCache) which could
      then be passed to the defaultConsoleTargetType callback to determine
      the console target type.
      Seems to be however a bit overengineered for the use case...
      Signed-off-by: NViktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
      b1c88c14
  8. 02 11月, 2012 1 次提交
  9. 20 10月, 2012 1 次提交
    • E
      storage: use enum for disk driver type · e5e8d5d0
      Eric Blake 提交于
      Actually use the enum in the domain conf structure.
      
      * src/conf/domain_conf.h (_virDomainDiskDef): Store enum rather
      than string for disk type.
      * src/conf/domain_conf.c (virDomainDiskDefFree)
      (virDomainDiskDefParseXML, virDomainDiskDefFormat)
      (virDomainDiskDefForeachPath): Adjust users.
      * src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenFormatSxprDisk):
      Likewise.
      * src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
      * src/vbox/vbox_tmpl.c (vboxAttachDrives): Likewise.
      * src/libxl/libxl_conf.c (libxlMakeDisk): Likewise.
      e5e8d5d0
  10. 21 9月, 2012 1 次提交
  11. 18 9月, 2012 1 次提交
  12. 30 8月, 2012 1 次提交
    • P
      vcpupin: Fix returning of arrays from virDomainVcpuPinAdd · 077e7bf5
      Peter Krempa 提交于
      virDomainVcpuPinAdd does a realloc on vcpupin_list if the new vcpu pin
      definition doesn't fit into the array. The list is an array of pointers
      but the function definition didn't support returning the changed pointer
      to the caller if it was realloced. This caused segfaults if realloc
      would change the base pointer.
      077e7bf5
  13. 22 8月, 2012 1 次提交
  14. 14 8月, 2012 1 次提交
    • O
      Destroy virdomainlist.[ch] · bb705e25
      Osier Yang 提交于
      As the consensus in:
      https://www.redhat.com/archives/libvir-list/2012-July/msg01692.html,
      this patch is to destroy conf/virdomainlist.[ch], folding the
      helpers into conf/domain_conf.[ch].
      
      * src/Makefile.am:
        - Various indention fixes incidentally
        - Add macro DATATYPES_SOURCES (datatypes.[ch])
        - Link datatypes.[ch] for libvirt_lxc
      
      * src/conf/domain_conf.c:
        - Move all the stuffs from virdomainlist.c into it
        - Use virUnrefDomain and virUnrefDomainSnapshot instead of
          virDomainFree and virDomainSnapshotFree, which are defined
          in libvirt.c, and we don't want to link to it.
        - Remove "if" before "free" the object, as virObjectUnref
          is in the list "useless_free_options".
      
      * src/conf/domain_conf.h:
        - Move all the stuffs from virdomainlist.h into it
        - s/LIST_FILTER/LIST_DOMAINS_FILTER/
      
      * src/libxl/libxl_driver.c:
        - s/LIST_FILTER/LIST_DOMAINS_FILTER/
        - no (include "virdomainlist.h")
      
      * src/libxl/libxl_driver.c: Likewise
      
      * src/lxc/lxc_driver.c: Likewise
      
      * src/openvz/openvz_driver.c: Likewise
      
      * src/parallels/parallels_driver.c: Likewise
      
      * src/qemu/qemu_driver.c: Likewise
      
      * src/test/test_driver.c: Likewise
      
      * src/uml/uml_driver.c: Likewise
      
      * src/vbox/vbox_tmpl.c: Likewise
      
      * src/vmware/vmware_driver.c: Likewise
      
      * tools/virsh-domain-monitor.c: Likewise
      
      * tools/virsh.c: Likewise
      bb705e25
  15. 07 8月, 2012 1 次提交
  16. 23 7月, 2012 1 次提交
    • O
      Desert the FSF address in copyright · f9ce7dad
      Osier Yang 提交于
      Per the FSF address could be changed from time to time, and GNU
      recommends the following now: (http://www.gnu.org/licenses/gpl-howto.html)
      
        You should have received a copy of the GNU General Public License
        along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
      
      This patch removes the explicit FSF address, and uses above instead
      (of course, with inserting 'Lesser' before 'General').
      
      Except a bunch of files for security driver, all others are changed
      automatically, the copyright for securify files are not complete,
      that's why to do it manually:
      
        src/security/security_selinux.h
        src/security/security_driver.h
        src/security/security_selinux.c
        src/security/security_apparmor.h
        src/security/security_apparmor.c
        src/security/security_driver.c
      f9ce7dad
  17. 20 7月, 2012 2 次提交
  18. 17 7月, 2012 1 次提交
    • S
      Convert 'raw MAC address' usages to use virMacAddr · 387117ad
      Stefan Berger 提交于
      Introduce new members in the virMacAddr 'class'
      - virMacAddrSet: set virMacAddr from a virMacAddr
      - virMacAddrSetRaw: setting virMacAddr from raw 6 byte MAC address buffer
      - virMacAddrGetRaw: writing virMacAddr into raw 6 byte MAC address buffer
      - virMacAddrCmp: comparing two virMacAddr
      - virMacAddrCmpRaw: comparing a virMacAddr with a raw 6 byte MAC address buffer
      
      then replace raw MAC addresses by replacing
      
      - 'unsigned char *' with virMacAddrPtr
      - 'unsigned char ... [VIR_MAC_BUFLEN]' with virMacAddr
      
      and introduce usage of above functions where necessary.
      387117ad
  19. 20 6月, 2012 1 次提交
    • P
      drivers: Implement virListAllDomains for drivers using virDomainObj · 33dc8cf0
      Peter Krempa 提交于
      This patch adds support for listing all domains into drivers that use
      the common virDomainObj implementation: libxl, lxc, openvz, qemu, test,
      uml, vmware.
      
      For drivers that don't support managed save images the guests are
      treated as if they had none, so filtering guests that do have such an
      image on this driver succeeds and produces 0 results.
      33dc8cf0
  20. 19 6月, 2012 1 次提交
  21. 22 5月, 2012 2 次提交
    • E
      build: fix unused variable after last patch · b8e6021e
      Eric Blake 提交于
      The previous commit (2cb0899e) left a dead variable behind.
      
      * src/libxl/libxl_driver.c (libxlClose): Drop dead variable.
      b8e6021e
    • D
      Fix potential events deadlock when unref'ing virConnectPtr · 2cb0899e
      Daniel P. Berrange 提交于
      When the last reference to a virConnectPtr is released by
      libvirtd, it was possible for a deadlock to occur in the
      virDomainEventState functions. The virDomainEventStatePtr
      holds a reference on virConnectPtr for each registered
      callback. When removing a callback, the virUnrefConnect
      function is run. If this causes the last reference on the
      virConnectPtr to be released, then virReleaseConnect can
      be run, which in turns calls qemudClose. This function has
      a call to virDomainEventStateDeregisterConn which is intended
      to remove all callbacks associated with the virConnectPtr
      instance. This will try to grab a lock on virDomainEventState
      but this lock is already held. Deadlock ensues
      
      Thread 1 (Thread 0x7fcbb526a840 (LWP 23185)):
      
      Since each callback associated with a virConnectPtr holds a
      reference on virConnectPtr, it is impossible for the qemudClose
      method to be invoked while any callbacks are still registered.
      Thus the call to virDomainEventStateDeregisterConn must in fact
      be a no-op. Thus it is possible to just remove all trace of
      virDomainEventStateDeregisterConn and avoid the deadlock.
      
      * src/conf/domain_event.c, src/conf/domain_event.h,
        src/libvirt_private.syms: Delete virDomainEventStateDeregisterConn
      * src/libxl/libxl_driver.c, src/lxc/lxc_driver.c,
        src/qemu/qemu_driver.c, src/uml/uml_driver.c: Remove
        calls to virDomainEventStateDeregisterConn
      2cb0899e
  22. 30 3月, 2012 1 次提交
  23. 27 3月, 2012 1 次提交
    • L
      build: avoid frame size error when building without -O2 · cf57d345
      Laine Stump 提交于
      libvirt always adds -Werror-frame-larger-than=4096 to the flags when
      it builds. When building on Fedora 17, two functions with multiple
      1024 buffers declared inside if {} blocks would generate frame size
      errors; apparently the version of gcc on Fedora 16 will merge these
      multiple buffers into a single buffer even when optimization is off,
      but Fedora 17 won't.
      
      The fix is to declare a single 1024 buffer at the top of the two
      offending functions, and reuse the single buffer throughout the
      functions.
      cf57d345
  24. 23 3月, 2012 1 次提交
    • D
      Centralize error reporting for URI parsing/formatting problems · 1f66c18f
      Daniel P. Berrange 提交于
      Move error reporting out of the callers, into virURIParse
      and virURIFormat, to get consistency.
      
      * include/libvirt/virterror.h, src/util/virterror.c: Add VIR_FROM_URI
      * src/util/viruri.c, src/util/viruri.h: Add error reporting
      * src/esx/esx_driver.c, src/libvirt.c, src/libxl/libxl_driver.c,
        src/lxc/lxc_driver.c, src/openvz/openvz_driver.c,
        src/qemu/qemu_driver.c, src/qemu/qemu_migration.c,
        src/remote/remote_driver.c, src/uml/uml_driver.c,
        src/vbox/vbox_tmpl.c, src/vmx/vmx.c, src/xen/xen_driver.c,
        src/xen/xend_internal.c, tests/viruritest.c: Remove error
        reporting
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      1f66c18f
  25. 09 3月, 2012 1 次提交
    • L
      util: eliminate device object leaks related to virDomain*Remove*() · f985773d
      Laine Stump 提交于
      There are several functions in domain_conf.c that remove a device
      object from the domain's list of that object type, but don't free the
      object or return it to the caller to free. In many cases this isn't a
      problem because the caller already had a pointer to the object and
      frees it afterward, but in several cases the removed object was just
      left floating around with no references to it.
      
      In particular, the function qemuDomainDetachDeviceConfig() calls
      functions to locate and remove net (virDomainNetRemoveByMac), disk
      (virDomainDiskRemoveByName()), and lease (virDomainLeaseRemove())
      devices, but neither it nor its caller qemuDomainModifyDeviceConfig()
      ever obtain a pointer to the device being removed, much less free it.
      
      This patch modifies the following "remove" functions to return a
      pointer to the device object being removed from the domain device
      arrays, to give the caller the option of freeing the device object
      using that pointer if needed. In places where the object was
      previously leaked, it is now freed:
      
        virDomainDiskRemove
        virDomainDiskRemoveByName
        virDomainNetRemove
        virDomainNetRemoveByMac
        virDomainHostdevRemove
        virDomainLeaseRemove
        virDomainLeaseRemoveAt
      
      The functions that had been leaking:
      
        libxlDomainDetachConfig - leaked a virDomainDiskDef
        qemuDomainDetachDeviceConfig - could leak a virDomainDiskDef,
                                  a virDomainNetDef, or a
                                  virDomainLeaseDef
        qemuDomainDetachLease   - leaked a virDomainLeaseDef
      f985773d
  26. 08 3月, 2012 1 次提交
    • E
      xml: use long long internally, to centralize overflow checks · 73b99771
      Eric Blake 提交于
      On 64-bit platforms, unsigned long and unsigned long long are
      identical, so we don't have to worry about overflow checks.
      On 32-bit platforms, anywhere we narrow unsigned long long back
      to unsigned long, we have to worry about overflow; it's easier
      to do this in one place by having most of the code use the same
      or wider types, and only doing the narrowing at the last minute.
      Therefore, the memory set commands remain unsigned long, and
      the memory get command now centralizes the overflow check into
      libvirt.c, so that drivers don't have to repeat the work.
      
      This also fixes a bug where xen returned the wrong value on
      failure (most APIs return -1 on failure, but getMaxMemory
      must return 0 on failure).
      
      * src/driver.h (virDrvDomainGetMaxMemory): Use long long.
      * src/libvirt.c (virDomainGetMaxMemory): Raise overflow.
      * src/test/test_driver.c (testGetMaxMemory): Fix driver.
      * src/rpc/gendispatch.pl (name_to_ProcName): Likewise.
      * src/xen/xen_hypervisor.c (xenHypervisorGetMaxMemory): Likewise.
      * src/xen/xen_driver.c (xenUnifiedDomainGetMaxMemory): Likewise.
      * src/xen/xend_internal.c (xenDaemonDomainGetMaxMemory):
      Likewise.
      * src/xen/xend_internal.h (xenDaemonDomainGetMaxMemory):
      Likewise.
      * src/xen/xm_internal.c (xenXMDomainGetMaxMemory): Likewise.
      * src/xen/xm_internal.h (xenXMDomainGetMaxMemory): Likewise.
      * src/xen/xs_internal.c (xenStoreDomainGetMaxMemory): Likewise.
      * src/xen/xs_internal.h (xenStoreDomainGetMaxMemory): Likewise.
      * src/xenapi/xenapi_driver.c (xenapiDomainGetMaxMemory):
      Likewise.
      * src/esx/esx_driver.c (esxDomainGetMaxMemory): Likewise.
      * src/libxl/libxl_driver.c (libxlDomainGetMaxMemory): Likewise.
      * src/qemu/qemu_driver.c (qemudDomainGetMaxMemory): Likewise.
      * src/lxc/lxc_driver.c (lxcDomainGetMaxMemory): Likewise.
      * src/uml/uml_driver.c (umlDomainGetMaxMemory): Likewise.
      73b99771
  27. 28 2月, 2012 1 次提交
    • L
      libxl: eliminate memory leak in libxmlDomainModifyDeviceFlags · 3207de30
      Laine Stump 提交于
      This call to virDomainDeviceDefParse is both unnecessary (since
      it will again be called at the top of the immediately following if(),
      and if not there, then at the top of the if following that), but it
      also creates a leak of one virDomainDeviceDef and one [whatever type
      of device the DeviceDef is pointing to; probably a virDomainDiskDef]
      in the case that the function has been called with
      VIR_DOMAIN_DEVICE_MODIFY_CONFIG (the second parse will overwrite the
      devicedef that was just created).
      3207de30
  28. 25 2月, 2012 1 次提交
    • M
      Fixed URI parsing · 9f748277
      Martin Kletzander 提交于
      Function xmlParseURI does not remove square brackets around IPv6
      address when parsing. One of the solutions is making wrappers around
      functions working with xmlURI*. This assures that uri->server will be
      always properly assigned and it doesn't have to be changed when used
      on some new place in the code.
      For this purpose, functions virParseURI and virSaveURI were
      added. These function are wrappers around xmlParseURI and xmlSaveUri
      respectively.
      Also there is one new syntax check function to prohibit these functions
      anywhere else.
      
      File changes:
       - src/util/viruri.h        -- declaration
       - src/util/viruri.c        -- definition
       - src/libvirt_private.syms -- symbol export
       - src/Makefile.am          -- added source and header files
       - cfg.mk                   -- added sc_prohibit_xmlURI
       - all others               -- ID name and include fixes
      9f748277
  29. 04 2月, 2012 2 次提交
    • L
      util: refactor virFileOpenAs · 90e4d681
      Laine Stump 提交于
      virFileOpenAs previously would only try opening a file as the current
      user, or as a different user, but wouldn't try both methods in a
      single call. This made it cumbersome to use as a replacement for
      open(2). Additionally, it had a lot of historical baggage that led to
      it being difficult to understand.
      
      This patch refactors virFileOpenAs in the following ways:
      
      * reorganize the code so that everything dealing with both the parent
        and child sides of the "fork+setuid+setgid+open" method are in a
        separate function. This makes the public function easier to understand.
      
      * Allow a single call to virFileOpenAs() to first attempt the open as
        the current user, and if that fails to automatically re-try after
        doing fork+setuid (if deemed appropriate, i.e. errno indicates it
        would now be successful, and the file is on a networkFS). This makes
        it possible (in many, but possibly not all, cases) to drop-in
        virFileOpenAs() as a replacement for open(2).
      
        (NB: currently qemuOpenFile() calls virFileOpenAs() twice, once
        without forking, then again with forking. That unfortunately can't
        be changed without at least some discussion of the ramifications,
        because the requested file permissions are different in each case,
        which is something that a single call to virFileOpenAs() can't deal
        with.)
      
      * Add a flag so that any fchown() of the file to a different uid:gid
        is explicitly requested when the function is called, rather than it
        being implied by the presence of the O_CREAT flag. This just makes
        for less subtle surprises to consumers. (Commit
        b1643dc1 added the check for O_CREAT
        before forcing ownership. This patch just makes that restriction
        more explicit.)
      
      * If either the uid or gid is specified as "-1", virFileOpenAs will
        interpret this to mean "the current [gu]id".
      
      All current consumers of virFileOpenAs should retain their present
      behavior (after a few minor changes to their setup code and
      arguments).
      90e4d681
    • E
      build: prohibit raw malloc and free · a7cfd709
      Eric Blake 提交于
      Our HACKING discourages use of malloc and free, for at least
      a couple of years now.  But we weren't enforcing it, until now :)
      
      For now, I've exempted python and tests, and will clean those up
      in subsequent patches.  Examples should be permanently exempt,
      since anyone copying our examples won't have use of our
      internal-only memory.h via libvirt_util.la.
      
      * cfg.mk (sc_prohibit_raw_allocation): New rule.
      (exclude_file_name_regexp--sc_prohibit_raw_allocation): and
      exemptions.
      * src/cpu/cpu.c (cpuDataFree): Avoid false positive.
      * src/conf/network_conf.c (virNetworkDNSSrvDefParseXML): Fix
      offenders.
      * src/libxl/libxl_conf.c (libxlMakeDomBuildInfo, libxlMakeVfb)
      (libxlMakeDeviceModelInfo): Likewise.
      * src/rpc/virnetmessage.c (virNetMessageSaveError): Likewise.
      * tools/virsh.c (_vshMalloc, _vshCalloc): Likewise.
      a7cfd709
  30. 24 1月, 2012 1 次提交
    • D
      Add new virDomainShutdownFlags API · 0b7ddf9e
      Daniel P. Berrange 提交于
      Add a new API virDomainShutdownFlags and define:
      
          VIR_DOMAIN_SHUTDOWN_DEFAULT        = 0,
          VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN = (1 << 0),
          VIR_DOMAIN_SHUTDOWN_GUEST_AGENT    = (1 << 1),
      
      Also define some flags for the reboot API
      
          VIR_DOMAIN_REBOOT_DEFAULT        = 0,
          VIR_DOMAIN_REBOOT_ACPI_POWER_BTN = (1 << 0),
          VIR_DOMAIN_REBOOT_GUEST_AGENT    = (1 << 1),
      
      Although these two APIs currently have the same flags, using
      separate enums allows them to expand separately in the future.
      
      Add stub impls of the new API for all existing drivers
      0b7ddf9e
  31. 20 1月, 2012 1 次提交
    • E
      util: use new virTypedParameter helpers · 9e48c225
      Eric Blake 提交于
      Reusing common code makes things smaller; it also buys us some
      additional safety, such as now rejecting duplicate parameters
      during a set operation.
      
      * src/qemu/qemu_driver.c (qemuDomainSetBlkioParameters)
      (qemuDomainSetMemoryParameters, qemuDomainSetNumaParameters)
      (qemuSetSchedulerParametersFlags)
      (qemuDomainSetInterfaceParameters, qemuDomainSetBlockIoTune)
      (qemuDomainGetBlkioParameters, qemuDomainGetMemoryParameters)
      (qemuDomainGetNumaParameters, qemuGetSchedulerParametersFlags)
      (qemuDomainBlockStatsFlags, qemuDomainGetInterfaceParameters)
      (qemuDomainGetBlockIoTune): Use new helpers.
      * src/esx/esx_driver.c (esxDomainSetSchedulerParametersFlags)
      (esxDomainSetMemoryParameters)
      (esxDomainGetSchedulerParametersFlags)
      (esxDomainGetMemoryParameters): Likewise.
      * src/libxl/libxl_driver.c
      (libxlDomainSetSchedulerParametersFlags)
      (libxlDomainGetSchedulerParametersFlags): Likewise.
      * src/lxc/lxc_driver.c (lxcDomainSetMemoryParameters)
      (lxcSetSchedulerParametersFlags, lxcDomainSetBlkioParameters)
      (lxcDomainGetMemoryParameters, lxcGetSchedulerParametersFlags)
      (lxcDomainGetBlkioParameters): Likewise.
      * src/test/test_driver.c (testDomainSetSchedulerParamsFlags)
      (testDomainGetSchedulerParamsFlags): Likewise.
      * src/xen/xen_hypervisor.c (xenHypervisorSetSchedulerParameters)
      (xenHypervisorGetSchedulerParameters): Likewise.
      9e48c225
  32. 08 1月, 2012 1 次提交
    • L
      config: report error when script given for inappropriate interface type · 1734cdb9
      Laine Stump 提交于
      This fixes https://bugzilla.redhat.com/show_bug.cgi?id=638633
      
      Although scripts are not used by interfaces of type other than
      "ethernet" in qemu, due to the fact that the parser stores the script
      name in a union that is only valid when type is ethernet or bridge,
      there is no way for anyone except the parser itself to catch the
      problem of specifying an interface script for an inappropriate
      interface type (by the time the parsed data gets back to the code that
      called the parser, all evidence that a script was specified is
      forgotten).
      
      Since the parser itself should be agnostic to which type of interface
      allows scripts (an example of why: a script specified for an interface
      of type bridge is valid for xen domains, but not for qemu domains),
      the solution here is to move the script out of the union(s) in the
      DomainNetDef, always populate it when specified (regardless of
      interface type), and let the driver decide whether or not it is
      appropriate.
      
      Currently the qemu, xen, libxml, and uml drivers recognize the script
      parameter and do something with it (the uml driver only to report that
      it isn't supported). Those drivers have been updated to log a
      CONFIG_UNSUPPORTED error when a script is specified for an interface
      type that's inappropriate for that particular hypervisor.
      
      (NB: There was earlier discussion of solving this problem by adding a
      VALIDATE flag to all libvirt APIs that accept XML, which would cause
      the XML to be validated against the RNG files. One statement during
      that discussion was that the RNG shouldn't contain hypervisor-specific
      things, though, and a proper solution to this problem would require
      that (again, because a script for an interface of type "bridge" is
      accepted by xen, but not by qemu).
      1734cdb9
  33. 19 12月, 2011 1 次提交
    • D
      Only add the timer when a callback is registered · 707781fe
      Daniel P. Berrange 提交于
      The lifetime of the virDomainEventState object is tied to
      the lifetime of the driver, which in stateless drivers is
      tied to the lifetime of the virConnectPtr.
      
      If we add & remove a timer when allocating/freeing the
      virDomainEventState object, we can get a situation where
      the timer still triggers once after virDomainEventState
      has been freed. The timeout callback can't keep a ref
      on the event state though, since that would be a circular
      reference.
      
      The trick is to only register the timer when a callback
      is registered with the event state & remove the timer
      when the callback is unregistered.
      
      The demo for the bug is to run
      
        while true ; do date ; ../tools/virsh -q -c test:///default 'shutdown test; undefine test; dominfo test' ; done
      
      prior to this fix, it will frequently hang and / or
      crash, or corrupt memory
      707781fe