1. 16 1月, 2014 1 次提交
    • 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
  2. 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
  3. 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
  4. 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
  5. 14 12月, 2013 2 次提交
  6. 11 12月, 2013 1 次提交
  7. 10 12月, 2013 24 次提交
  8. 15 11月, 2013 1 次提交
  9. 24 7月, 2013 1 次提交
    • J
      domain_event: Resolve memory leak found by Valgrind · 33aef5db
      John Ferlan 提交于
      Commit id '4421e257' strdup'd devAlias, but didn't free
      
      Running qemuhotplugtest under valgrind resulted in the following:
      
      ==7375== 9 bytes in 1 blocks are definitely lost in loss record 11 of 70
      ==7375==    at 0x4A0887C: malloc (vg_replace_malloc.c:270)
      ==7375==    by 0x37C1085D71: strdup (strdup.c:42)
      ==7375==    by 0x4CBBD5F: virStrdup (virstring.c:554)
      ==7375==    by 0x4CFF9CB: virDomainEventDeviceRemovedNew (domain_event.c:1174)
      ==7375==    by 0x427791: qemuDomainRemoveChrDevice (qemu_hotplug.c:2508)
      ==7375==    by 0x42C65D: qemuDomainDetachChrDevice (qemu_hotplug.c:3357)
      ==7375==    by 0x41C94F: testQemuHotplug (qemuhotplugtest.c:115)
      ==7375==    by 0x41D817: virtTestRun (testutils.c:168)
      ==7375==    by 0x41C400: mymain (qemuhotplugtest.c:322)
      ==7375==    by 0x41DF3A: virtTestMain (testutils.c:764)
      ==7375==    by 0x37C1021A04: (below main) (libc-start.c:225)
      33aef5db
  10. 18 7月, 2013 1 次提交
  11. 11 7月, 2013 1 次提交
  12. 10 7月, 2013 1 次提交
  13. 23 5月, 2013 1 次提交
  14. 21 5月, 2013 1 次提交