1. 08 3月, 2016 1 次提交
    • J
      Introduce job completed event · f2893001
      Jiri Denemark 提交于
      The VIR_DOMAIN_EVENT_ID_JOB_COMPLETED event will be triggered once a job
      (such as migration) finishes and it will contain statistics for the job
      as one would get by calling virDomainGetJobStats. Thanks to this event
      it is now possible to get statistics of a completed migration of a
      transient domain on the source host.
      Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
      f2893001
  2. 21 1月, 2016 1 次提交
  3. 15 4月, 2015 1 次提交
  4. 03 12月, 2014 1 次提交
    • J
      Replace virDomainFree with virObjectUnref · 8fb3aee2
      John Ferlan 提交于
      Since virDomainFree will call virObjectUnref anyway, let's just use that
      directly so as to avoid the possibility that we inadvertently clear out
      a pending error message when using the public API.
      8fb3aee2
  5. 24 11月, 2014 1 次提交
    • P
      event: Add guest agent lifecycle event · 1a460910
      Peter Krempa 提交于
      As qemu is now able to notify us about change of the channel state used
      for communication with the guest agent we now can more precisely track
      the state of the guest agent.
      
      To allow notifying management apps this patch implements a new event
      that will be triggered on changes of the guest agent state.
      1a460910
  6. 26 9月, 2014 1 次提交
  7. 24 9月, 2014 1 次提交
    • P
      event: introduce new event for tunable values · e4267181
      Pavel Hrdina 提交于
      This new event will use typedParameters to expose what has been actually
      updated and the reason is that we can in the future extend any tunable
      values or add new tunable values. With typedParameters we don't have to
      worry about creating some other events, we will just use this universal
      event to inform user about updates.
      Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
      e4267181
  8. 19 6月, 2014 1 次提交
    • E
      blockjob: use stable disk string in job event · 1bfe73a1
      Eric Blake 提交于
      When the block job event was first added, it was for block pull,
      where the active layer of the disk remains the same name.  It was
      also in a day where we only cared about local files, and so we
      always had a canonical absolute file name.  But two things have
      changed since then: we now have network disks, where determining
      a single absolute string does not really make sense; and we have
      two-phase jobs (copy and active commit) where the name of the
      active layer changes between the first event (ready, on the old
      name) and second (complete, on the pivoted name).
      
      Adam Litke reported that having an unstable string between events
      makes life harder for clients.  Furthermore, all of our API that
      operate on a particular disk of a domain accept multiple strings:
      not only the absolute name of the active layer, but also the
      destination device name (such as 'vda').  As this latter name is
      stable, even for network sources, it serves as a better string
      to supply in block job events.
      
      But backwards-compatibility demands that we should not change the
      name handed to users unless they explicitly request it.  Therefore,
      this patch adds a new event, BLOCK_JOB_2 (alas, I couldn't think of
      any nicer name - but at least Migrate2 and Migrate3 are precedent
      for a number suffix).  We must double up on emitting both old-style
      and new-style events according to what clients have registered for
      (see also how IOError and IOErrorReason emits double events, but
      there the difference was a larger struct rather than changed
      meaning of one of the struct members).
      
      Unfortunately, adding a new event isn't something that can easily
      be broken into pieces, so the commit is rather large.
      
      * include/libvirt/libvirt.h.in (virDomainEventID): Add a new id
      for VIR_DOMAIN_EVENT_ID_BLOCK_JOB_2.
      (virConnectDomainEventBlockJobCallback): Document new semantics.
      * src/conf/domain_event.c (_virDomainEventBlockJob): Rename field,
      to ensure we catch all clients.
      (virDomainEventBlockJobNew): Add parameter.
      (virDomainEventBlockJobDispose)
      (virDomainEventBlockJobNewFromObj)
      (virDomainEventBlockJobNewFromDom)
      (virDomainEventDispatchDefaultFunc): Adjust clients.
      (virDomainEventBlockJob2NewFromObj)
      (virDomainEventBlockJob2NewFromDom): New functions.
      * src/conf/domain_event.h: Add new prototypes.
      * src/libvirt_private.syms (domain_event.h): Export new functions.
      * src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Generate two
      different events.
      * src/qemu/qemu_process.c (qemuProcessHandleBlockJob): Likewise.
      * src/remote/remote_protocol.x
      (remote_domain_event_block_job_2_msg): New struct.
      (REMOTE_PROC_DOMAIN_EVENT_BLOCK_JOB_2): New RPC.
      * src/remote/remote_driver.c
      (remoteDomainBuildEventBlockJob2): New handler.
      (remoteEvents): Register new event.
      * daemon/remote.c (remoteRelayDomainEventBlockJob2): New handler.
      (domainEventCallbacks): Register new event.
      * tools/virsh-domain.c (vshEventCallbacks): Likewise.
      (vshEventBlockJobPrint): Adjust client.
      * src/remote_protocol-structs: Regenerate.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      1bfe73a1
  9. 25 3月, 2014 1 次提交
  10. 21 3月, 2014 3 次提交
    • E
      qemu: allow filtering events by regex · 43b17dd4
      Eric Blake 提交于
      When listening for a subset of monitor events, it can be tedious
      to register for each event name in series; nicer is to register
      for multiple events in one go.  Implement a flag to use regex
      interpretation of the event filter.
      
      While at it, prove how much I hate the shift key, by adding a
      way to filter for 'shutdown' instead of 'SHUTDOWN'. :)
      
      * include/libvirt/libvirt-qemu.h
      (virConnectDomainQemuMonitorEventRegisterFlags): New enum.
      * src/libvirt-qemu.c (virConnectDomainQemuMonitorEventRegister):
      Document flags.
      * tools/virsh-domain.c (cmdQemuMonitorEvent): Expose them.
      * tools/virsh.pod (qemu-monitor-event): Document this.
      * src/conf/domain_event.c
      (virDomainQemuMonitorEventStateRegisterID): Add flags.
      (virDomainQemuMonitorEventFilter): Handle regex, and optimize
      client side.
      (virDomainQemuMonitorEventCleanup): Clean up regex.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      43b17dd4
    • E
      qemu: enable monitor event filtering by name · d0ba8dd7
      Eric Blake 提交于
      Filtering monitor events by name requires tracking the name for
      the duration of the filtering.  In order to free the name, I
      found it easiest to just piggyback on the user's freecb function,
      which gets called when the event is deregistered.
      
      For events without a name filter, we have the design of multiple
      client registrations sharing a common server registration, because
      the server side uses the same callback function and we reject
      duplicate use of the same function.  But with events in the mix,
      we want to be able to allow the same function pointer to be used
      with more than one event name.  The solution is to tweak the
      duplicate detection code to only act when there is no additional
      filtering; if name filtering is in use, there is exactly one
      client registration per server registration.  Yes, this means
      that there is no longer a bound on the number of server
      registrations possible, so a malicious client could repeatedly
      register for the same name event to exhaust server memory.  On
      the other hand, we already restricted monitor events to require
      write access (compared to normal events only needing read access),
      and separated it into the intentionally unsupported
      libvirt-qemu.so, with documentation that using this function is
      for debug purposes only; so it is not a security risk worth
      worrying about a client trying to abuse multiple registrations.
      
      * src/conf/domain_event.c (virDomainQemuMonitorEventData): New
      struct.
      (virDomainQemuMonitorEventFilter)
      (virDomainQemuMonitorEventCleanup): New functions.
      (virDomainQemuMonitorEventDispatchFunc)
      (virDomainQemuMonitorEventStateRegisterID): Use new struct.
      * src/conf/object_event.c (virObjectEventCallbackListCount)
      (virObjectEventCallbackListAddID)
      (virObjectEventCallbackListRemoveID)
      (virObjectEventCallbackListMarkDeleteID): Drop duplicate detection
      when filtering is in effect.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      d0ba8dd7
    • E
      qemu: create object for qemu monitor events · 8059afca
      Eric Blake 提交于
      Create qemu monitor events as a distinct class to normal domain
      events, because they will be filtered differently.  For ease of
      review, the logic for filtering by event name is saved for a later
      patch.
      
      * src/conf/domain_event.c (virDomainQemuMonitorEventClass): New
      class.
      (virDomainEventsOnceInit): Register it.
      (virDomainQemuMonitorEventDispose, virDomainQemuMonitorEventNew)
      (virDomainQemuMonitorEventDispatchFunc)
      (virDomainQemuMonitorEventStateRegisterID): New functions.
      * src/conf/domain_event.h (virDomainQemuMonitorEventNew)
      (virDomainQemuMonitorEventStateRegisterID): New prototypes.
      * src/libvirt_private.syms (conf/domain_conf.h): Export them.
      8059afca
  11. 18 3月, 2014 1 次提交
  12. 13 2月, 2014 2 次提交
    • E
      event: pass reason for PM events · 6831c1d3
      Eric Blake 提交于
      Commit 57ddcc23 (v0.9.11) introduced the pmwakeup event, with
      an optional 'reason' field reserved for possible future expansion.
      But it failed to wire the field through RPC, so even if we do
      add a reason in the future, we will be unable to get it back
      to the user.
      
      Worse, commit 7ba5defb (v1.0.0) repeated the same mistake with
      the pmsuspend_disk event.
      
      As long as we are adding new RPC calls, we might as well fix
      the events to actually match the signature so that we don't have
      to add yet another RPC in the future if we do decide to start
      using the reason field.
      
      * src/remote/remote_protocol.x
      (remote_domain_event_callback_pmwakeup_msg)
      (remote_domain_event_callback_pmsuspend_msg)
      (remote_domain_event_callback_pmsuspend_disk_msg): Add reason
      field.
      * daemon/remote.c (remoteRelayDomainEventPMWakeup)
      (remoteRelayDomainEventPMSuspend)
      (remoteRelayDomainEventPMSuspendDisk): Pass reason to client.
      * src/conf/domain_event.h (virDomainEventPMWakeupNewFromDom)
      (virDomainEventPMSuspendNewFromDom)
      (virDomainEventPMSuspendDiskNewFromDom): Require additional
      parameter.
      * src/conf/domain_event.c (virDomainEventPMClass): New class.
      (virDomainEventPMDispose): New function.
      (virDomainEventPMWakeupNew*, virDomainEventPMSuspendNew*)
      (virDomainEventPMSuspendDiskNew*)
      (virDomainEventDispatchDefaultFunc): Use new class.
      * src/remote/remote_driver.c (remoteDomainBuildEvent*PM*): Pass
      reason through.
      * src/remote_protocol-structs: Regenerate.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      6831c1d3
    • E
      event: prepare client to track domain callbackID · caaf6ba1
      Eric Blake 提交于
      We want to convert over to server-side events, even for older
      APIs.  To do that, the client side of the remote driver wants
      to distinguish between legacy virConnectDomainEventRegister and
      normal virConnectDomainEventRegisterAny, while knowing the
      client callbackID and the server's serverID for both types of
      registration.  The client also needs to probe whether the
      server supports server-side filtering.  However, for ease of
      review, we don't actually use the new RPCs until a later patch.
      
      * src/conf/object_event_private.h (virObjectEventStateCallbackID):
      Add parameter.
      * src/conf/object_event.c (virObjectEventCallbackListAddID)
      (virObjectEventStateRegisterID): Separate legacy from callbackID.
      (virObjectEventStateCallbackID): Pass through parameter.
      (virObjectEventCallbackLookup): Let legacy and global domain
      lifecycle events share a common remoteID.
      * src/conf/network_event.c (virNetworkEventStateRegisterID):
      Update caller.
      * src/conf/domain_event.c (virDomainEventStateRegister)
      (virDomainEventStateRegisterID, virDomainEventStateDeregister):
      Likewise.
      (virDomainEventStateRegisterClient)
      (virDomainEventStateCallbackID): Implement new functions.
      * src/conf/domain_event.h (virDomainEventStateRegisterClient)
      (virDomainEventStateCallbackID): New prototypes.
      * src/remote/remote_driver.c (private_data): Add field.
      (doRemoteOpen): Probe server feature.
      (remoteConnectDomainEventRegister)
      (remoteConnectDomainEventRegisterAny): Use new function.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      caaf6ba1
  13. 05 2月, 2014 1 次提交
    • E
      event: move event filtering to daemon (regression fix) · 11f20e43
      Eric Blake 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1058839
      
      Commit f9f56340 for CVE-2014-0028 almost had the right idea - we
      need to check the ACL rules to filter which events to send.  But
      it overlooked one thing: the event dispatch queue is running in
      the main loop thread, and therefore does not normally have a
      current virIdentityPtr.  But filter checks can be based on current
      identity, so when libvirtd.conf contains access_drivers=["polkit"],
      we ended up rejecting access for EVERY event due to failure to
      look up the current identity, even if it should have been allowed.
      
      Furthermore, even for events that are triggered by API calls, it
      is important to remember that the point of events is that they can
      be copied across multiple connections, which may have separate
      identities and permissions.  So even if events were dispatched
      from a context where we have an identity, we must change to the
      correct identity of the connection that will be receiving the
      event, rather than basing a decision on the context that triggered
      the event, when deciding whether to filter an event to a
      particular connection.
      
      If there were an easy way to get from virConnectPtr to the
      appropriate virIdentityPtr, then object_event.c could adjust the
      identity prior to checking whether to dispatch an event.  But
      setting up that back-reference is a bit invasive.  Instead, it
      is easier to delay the filtering check until lower down the
      stack, at the point where we have direct access to the RPC
      client object that owns an identity.  As such, this patch ends
      up reverting a large portion of the framework of commit f9f56340.
      We also have to teach 'make check' to special-case the fact that
      the event registration filtering is done at the point of dispatch,
      rather than the point of registration.  Note that even though we
      don't actually use virConnectDomainEventRegisterCheckACL (because
      the RegisterAny variant is sufficient), we still generate the
      function for the purposes of documenting that the filtering
      takes place.
      
      Also note that I did not entirely delete the notion of a filter
      from object_event.c; I still plan on using that for my upcoming
      patch series for qemu monitor events in libvirt-qemu.so.  In
      other words, while this patch changes ACL filtering to live in
      remote.c and therefore we have no current client of the filtering
      in object_event.c, the notion of filtering in object_event.c is
      still useful down the road.
      
      * src/check-aclrules.pl: Exempt event registration from having to
      pass checkACL filter down call stack.
      * daemon/remote.c (remoteRelayDomainEventCheckACL)
      (remoteRelayNetworkEventCheckACL): New functions.
      (remoteRelay*Event*): Use new functions.
      * src/conf/domain_event.h (virDomainEventStateRegister)
      (virDomainEventStateRegisterID): Drop unused parameter.
      * src/conf/network_event.h (virNetworkEventStateRegisterID):
      Likewise.
      * src/conf/domain_event.c (virDomainEventFilter): Delete unused
      function.
      * src/conf/network_event.c (virNetworkEventFilter): Likewise.
      * src/libxl/libxl_driver.c: Adjust caller.
      * src/lxc/lxc_driver.c: Likewise.
      * src/network/bridge_driver.c: Likewise.
      * src/qemu/qemu_driver.c: Likewise.
      * src/remote/remote_driver.c: Likewise.
      * src/test/test_driver.c: Likewise.
      * src/uml/uml_driver.c: Likewise.
      * src/vbox/vbox_tmpl.c: Likewise.
      * src/xen/xen_driver.c: Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      11f20e43
  14. 16 1月, 2014 2 次提交
    • E
      event: filter global events by domain:getattr ACL [CVE-2014-0028] · f9f56340
      Eric Blake 提交于
      Ever since ACL filtering was added in commit 76397360 (v1.1.1), a
      user could still use event registration to obtain access to a
      domain that they could not normally access via virDomainLookup*
      or virConnectListAllDomains and friends.  We already have the
      framework in the RPC generator for creating the filter, and
      previous cleanup patches got us to the point that we can now
      wire the filter through the entire object event stack.
      
      Furthermore, whether or not domain:getattr is honored, use of
      global events is a form of obtaining a list of networks, which
      is covered by connect:search_domains added in a93cd08f (v1.1.0).
      Ideally, we'd have a way to enforce connect:search_domains when
      doing global registrations while omitting that check on a
      per-domain registration.  But this patch just unconditionally
      requires connect:search_domains, even when no list could be
      obtained, based on the following observations:
      1. Administrators are unlikely to grant domain:getattr for one
      or all domains while still denying connect:search_domains - a
      user that is able to manage domains will want to be able to
      manage them efficiently, but efficient management includes being
      able to list the domains they can access.  The idea of denying
      connect:search_domains while still granting access to individual
      domains is therefore not adding any real security, but just
      serves as a layer of obscurity to annoy the end user.
      2. In the current implementation, domain events are filtered
      on the client; the server has no idea if a domain filter was
      requested, and must therefore assume that all domain event
      requests are global.  Even if we fix the RPC protocol to
      allow for server-side filtering for newer client/server combos,
      making the connect:serach_domains ACL check conditional on
      whether the domain argument was NULL won't benefit older clients.
      Therefore, we choose to document that connect:search_domains
      is a pre-requisite to any domain event management.
      
      Network events need the same treatment, with the obvious
      change of using connect:search_networks and network:getattr.
      
      * src/access/viraccessperm.h
      (VIR_ACCESS_PERM_CONNECT_SEARCH_DOMAINS)
      (VIR_ACCESS_PERM_CONNECT_SEARCH_NETWORKS): Document additional
      effect of the permission.
      * src/conf/domain_event.h (virDomainEventStateRegister)
      (virDomainEventStateRegisterID): Add new parameter.
      * src/conf/network_event.h (virNetworkEventStateRegisterID):
      Likewise.
      * src/conf/object_event_private.h (virObjectEventStateRegisterID):
      Likewise.
      * src/conf/object_event.c (_virObjectEventCallback): Track a filter.
      (virObjectEventDispatchMatchCallback): Use filter.
      (virObjectEventCallbackListAddID): Register filter.
      * src/conf/domain_event.c (virDomainEventFilter): New function.
      (virDomainEventStateRegister, virDomainEventStateRegisterID):
      Adjust callers.
      * src/conf/network_event.c (virNetworkEventFilter): New function.
      (virNetworkEventStateRegisterID): Adjust caller.
      * src/remote/remote_protocol.x
      (REMOTE_PROC_CONNECT_DOMAIN_EVENT_REGISTER)
      (REMOTE_PROC_CONNECT_DOMAIN_EVENT_REGISTER_ANY)
      (REMOTE_PROC_CONNECT_NETWORK_EVENT_REGISTER_ANY): Generate a
      filter, and require connect:search_domains instead of weaker
      connect:read.
      * src/test/test_driver.c (testConnectDomainEventRegister)
      (testConnectDomainEventRegisterAny)
      (testConnectNetworkEventRegisterAny): Update callers.
      * src/remote/remote_driver.c (remoteConnectDomainEventRegister)
      (remoteConnectDomainEventRegisterAny): Likewise.
      * src/xen/xen_driver.c (xenUnifiedConnectDomainEventRegister)
      (xenUnifiedConnectDomainEventRegisterAny): Likewise.
      * src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc): Likewise.
      * src/libxl/libxl_driver.c (libxlConnectDomainEventRegister)
      (libxlConnectDomainEventRegisterAny): Likewise.
      * src/qemu/qemu_driver.c (qemuConnectDomainEventRegister)
      (qemuConnectDomainEventRegisterAny): Likewise.
      * src/uml/uml_driver.c (umlConnectDomainEventRegister)
      (umlConnectDomainEventRegisterAny): Likewise.
      * src/network/bridge_driver.c
      (networkConnectNetworkEventRegisterAny): Likewise.
      * src/lxc/lxc_driver.c (lxcConnectDomainEventRegister)
      (lxcConnectDomainEventRegisterAny): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      f9f56340
    • E
      event: add notion of remoteID for filtering client network events · a59097e5
      Eric Blake 提交于
      In order to mirror a server with per-object filtering, the client
      needs to track which server callbackID is servicing the client
      callback.  This patch introduces the notion of a serverID, as
      well as the plumbing to use it for network events, although the
      actual complexity of using per-object filtering in the remote
      driver is deferred to a later patch.
      
      * src/conf/object_event.h (virObjectEventStateEventID): Add parameter.
      (virObjectEventStateQueueRemote, virObjectEventStateSetRemote):
      New prototypes.
      (virObjectEventStateRegisterID): Move...
      * src/conf/object_event_private.h: ...here, and add parameter.
      (_virObjectEvent): Add field.
      * src/conf/network_event.h (virNetworkEventStateRegisterClient): New
      prototype.
      * src/conf/object_event.c (_virObjectEventCallback): Add field.
      (virObjectEventStateSetRemote): New function.
      (virObjectEventStateQueue): Make wrapper around...
      (virObjectEventStateQueueRemote): New function.
      (virObjectEventCallbackListCount): Tweak return count when remote
      id matching is used.
      (virObjectEventCallbackLookup, virObjectEventStateRegisterID):
      Tweak registration when remote id matching will be used.
      (virObjectEventNew): Default to no remote id.
      (virObjectEventCallbackListAddID): Likewise, but set remote id
      when one is available.
      (virObjectEventCallbackListRemoveID)
      (virObjectEventCallbackListMarkDeleteID): Adjust return value when
      remote id was set.
      (virObjectEventStateEventID): Query existing id.
      (virObjectEventDispatchMatchCallback): Require matching event id.
      (virObjectEventStateCallbackID): Adjust caller.
      * src/conf/network_event.c (virNetworkEventStateRegisterClient): New
      function.
      (virNetworkEventStateRegisterID): Update caller.
      * src/conf/domain_event.c (virDomainEventStateRegister)
      (virDomainEventStateRegisterID): Update callers.
      * src/remote/remote_driver.c
      (remoteConnectNetworkEventRegisterAny)
      (remoteConnectNetworkEventDeregisterAny)
      (remoteConnectDomainEventDeregisterAny): Likewise.
      (remoteEventQueue): Hoist earlier to avoid forward declaration,
      and add parameter.  Adjust all callers.
      * src/libvirt_private.syms (conf/object_event.h): Drop function.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      a59097e5
  15. 08 1月, 2014 2 次提交
    • E
      event: don't turn offline domain into global event · e9568360
      Eric Blake 提交于
      If a user registers for a domain event filtered to a particular
      domain, but the persistent domain is offline at the time, then
      the code silently failed to set up the filter.  As a result,
      the event fires for all domains, rather than being filtered.
      Network events were immune, since they always passed an id
      0 argument.
      
      The key to this patch is realizing that
      virObjectEventDispatchMatchCallback() only cared about uuid;
      so refusing to create a meta for a negative id is pointless,
      and in fact, malloc'ing meta at all was overkill; instead,
      just directly store a uuid and a flag of whether to filter.
      
      Note that virObjectEventPtr still needs all fields of meta,
      because this is how we reconstruct a virDomainPtr inside the
      dispatch handler before calling the end user's callback
      pointer with the correct object, even though only the uuid
      portion of meta is used in deciding whether a callback
      matches the given event.  So while uuid is optional for
      callbacks, it is mandatory for events.
      
      The change to testDomainCreateXMLMixed is merely on the setup
      scenario (as you can't register for a domain unless it is either
      running or persistent).  I actually first wrote that test for
      this patch, then rebased it to also cover a prior patch (commit
      4221d64f), but had to adjust it for that patch to use Create
      instead of Define for setting up the domain long enough to
      register the event in order to work around this bug.  But while
      the setup is changed, the main body of the test is still about
      whether creation events fire as expected.
      
      * src/conf/object_event_private.h (_virObjectEventCallback):
      Replace meta with uuid and flag.
      (virObjectEventCallbackListAddID): Update signature.
      * src/conf/object_event.h (virObjectEventStateRegisterID):
      Likewise.
      * src/conf/object_event_private.h (virObjectEventNew): Document
      use of name and uuid in events.
      * src/conf/object_event.c (virObjectEventCallbackListAddID): Drop
      arguments that don't affect filtering.
      (virObjectEventCallbackListRemoveID)
      (virObjectEventDispatchMatchCallback)
      (virObjectEventStateRegisterID): Update clients.
      * src/conf/domain_event.c (virDomainEventCallbackListAdd)
      (virDomainEventStateRegisterID): Likewise.
      * src/conf/network_event.c (virNetworkEventStateRegisterID):
      Likewise.
      * tests/objecteventtest.c (testDomainCreateXMLMixed): Enhance test.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      e9568360
    • E
      event: don't let old-style events clobber per-domain events · 4221d64f
      Eric Blake 提交于
      Right now, the older virConnectDomainEventRegister (takes a
      function pointer, returns 0 on success) and the newer
      virConnectDomainEventRegisterID (takes an eventID, returns a
      callbackID) share the underlying implementation (the older
      API ends up consuming a callbackID for eventID 0 under the
      hood).  We implemented that by a lot of copy and pasted
      code between object_event.c and domain_event.c, according to
      whether we are dealing with a function pointer or an eventID.
      However, our copy and paste is not symmetric.  Consider this
      sequence:
      
      id1 = virConnectDomainEventRegisterAny(conn, dom,
         VIR_DOMAIN_EVENT_ID_LIFECYCLE,
         VIR_DOMAIN_EVENT_CALLBACK(callback), NULL, NULL);
      virConnectDomainEventRegister(conn, callback, NULL, NULL);
      virConnectDomainEventDeregister(conn, callback);
      virConnectDomainEventDeregsiterAny(conn, id1);
      
      the first three calls would succeed, but the third call ended
      up nuking the id1 callbackID (the per-domain new-style handler),
      then the fourth call failed with an error about an unknown
      callbackID, leaving us with the global handler (old-style) still
      live and receiving events.  It required another old-style
      deregister to clean up the mess.  Root cause was that
      virDomainEventCallbackList{Remove,MarkDelete} were only
      checking for function pointer match, rather than also checking
      for whether the registration was global.
      
      Rather than playing with the guts of object_event ourselves
      in domain_event, it is nicer to add a mapping function for the
      internal callback id, then share common code for event removal.
      For now, the function-to-id mapping is used only internally;
      I thought about whether a new public API to let a user learn
      the callback would be useful, but decided exposing this to the
      user is probably a disservice, since we already publicly
      document that they should avoid the old style, and since this
      patch already demonstrates that older libvirt versions have
      weird behavior when mixing old and new styles.
      
      And like all good bug fix patches, I enhanced the testsuite,
      validating that the changes in tests/ expose the failure
      without the rest of the patch.
      
      * src/conf/object_event.c (virObjectEventCallbackLookup)
      (virObjectEventStateCallbackID): New functions.
      (virObjectEventCallbackLookup): Use helper function.
      * src/conf/object_event_private.h (virObjectEventStateCallbackID):
      Declare new function.
      * src/conf/domain_event.c (virDomainEventStateRegister)
      (virDomainEventStateDeregister): Let common code handle the
      complexity.
      (virDomainEventCallbackListRemove)
      (virDomainEventCallbackListMarkDelete)
      (virDomainEventCallbackListAdd): Drop unused functions.
      * tests/objecteventtest.c (testDomainCreateXMLMixed): New test.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      4221d64f
  16. 06 1月, 2014 1 次提交
    • E
      event: use bool in more places · 22e82aa5
      Eric Blake 提交于
      No need to use an int that only ever stores 0 and 1.
      
      * src/conf/object_event_private.h (_virObjectEventCallback):
      Change deleted to bool.
      * src/conf/object_event.c (virObjectEventDispatchMatchCallback):
      Switch return type to bool.
      (virObjectEventCallbackListMarkDeleteID): Update client.
      * src/conf/domain_event.c (virDomainEventCallbackListMarkDelete):
      Likewise.
      22e82aa5
  17. 04 1月, 2014 2 次提交
    • E
      event: remove unneeded virObjectEventGetEventID · 344e1f51
      Eric Blake 提交于
      Any file with access to object_event_private.h also has access to
      the internals of virObjectEvent, without needing an accessor
      function.  Not to mention the accessor function was doing type
      checks that would always succeed.
      
      * src/conf/object_event_private.h (virObjectEventGetEventID): Drop.
      * src/conf/object_event.c (virObjectEventGetEventID): Drop.
      (virObjectEventDispatchMatchCallback): Simplify caller.
      * src/conf/domain_event.c (virDomainEventDispatchDefaultFunc):
      Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      344e1f51
    • E
      event: fix doc typos, and doc more public methods · 6742fb0b
      Eric Blake 提交于
      While working on events, I found a number of minor issues; I'm
      hoisting these to the front rather than doing it piecemeal in
      the patches where I first noticed bad or missing documentation.
      
      * src/conf/object_event.c: Fix grammar, document all parameters
      of public functions, wrap some long lines.
      * src/conf/object_event.h: Likewise.
      * src/conf/network_event.c: Likewise.
      * src/conf/domain_event.c: Likewise (except for the large number
      of event creation functions).
      * src/libvirt_private.cyms (conf/object_event.h): Split...
      (conf/network_event.h): ...to account for new file.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      6742fb0b
  18. 14 12月, 2013 2 次提交
  19. 11 12月, 2013 1 次提交
  20. 10 12月, 2013 14 次提交