1. 16 1月, 2014 4 次提交
    • C
      conf: Always use VIR_ERR_CONFIG_UNSUPPORTED on enumFromString() failures · 9b73290f
      Christophe Fergeau 提交于
      Currently, during XML parsing, when a call to a FromString() function to
      get an enum value fails, the error which is reported is either
      VIR_ERR_CONFIG_UNSUPPORTED, VIR_ERR_INTERNAL_ERROR or VIR_ERR_XML_ERROR.
      
      This commit makes such conversion failures consistently return
      VIR_ERR_CONFIG_UNSUPPORTED.
      9b73290f
    • 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: wire up RPC for server-side network event filtering · 8d9d098b
      Eric Blake 提交于
      We haven't had a release with network events yet, so we are free
      to fix the RPC so that it actually does what we want.  Doing
      client-side filtering of per-network events is inefficient if a
      connection is only interested in events on a single network out
      of hundreds available on the server.  But to do server-side
      per-network filtering, the server needs to know which network
      to filter on - so we need to pass an optional network over on
      registration.  Furthermore, it is possible to have a client with
      both a global and per-network filter; in the existing code, the
      server sends only one event and the client replicates to both
      callbacks.  But with server-side filtering, the server will send
      the event twice, so we need a way for the client to know which
      callbackID is sending an event, to ensure that the client can
      filter out events from a registration that does not match the
      callbackID from the server.  Likewise, the existing style of
      deregistering by eventID alone is fine; but in the new style,
      we have to remember which callbackID to delete.
      
      This patch fixes the RPC wire definition to contain all the
      needed pieces of information, and hooks into the server and
      client side improvements of the previous patches, in order to
      switch over to full server-side filtering of network events.
      Also, since we fixed this in time, all released versions of
      libvirtd that support network events also support per-network
      filtering, so we can hard-code that assumption into
      network_event.c.
      
      Converting domain events to server-side filtering will require
      the introduction of new RPC numbers, as well as a server
      feature bit that the client can use to tell whether to use
      old-style (server only supports global events) or new-style
      (server supports filtered events), so that is deferred to a
      later set of patches.
      
      * src/conf/network_event.c (virNetworkEventStateRegisterClient):
      Assume server-side filtering.
      * src/remote/remote_protocol.x
      (remote_connect_network_event_register_any_args): Add network
      argument.
      (remote_connect_network_event_register_any_ret): Return callbackID
      instead of count.
      (remote_connect_network_event_deregister_any_args): Pass
      callbackID instead of eventID.
      (remote_connect_network_event_deregister_any_ret): Drop unused
      type.
      (remote_network_event_lifecycle_msg): Add callbackID.
      * daemon/remote.c
      (remoteDispatchConnectNetworkEventDeregisterAny): Drop unused arg,
      and deal with callbackID from client.
      (remoteRelayNetworkEventLifecycle): Pass callbackID.
      (remoteDispatchConnectNetworkEventRegisterAny): Likewise, and
      recognize non-NULL network.
      * src/remote/remote_driver.c
      (remoteConnectNetworkEventRegisterAny): Pass network, and track
      server side id.
      (remoteConnectNetworkEventDeregisterAny): Deregister by callback id.
      (remoteNetworkBuildEventLifecycle): Pass remote id to event queue.
      * src/remote_protocol-structs: Regenerate.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      8d9d098b
    • 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. 11 1月, 2014 1 次提交
  3. 09 1月, 2014 1 次提交
    • E
      event: clean up client side RPC code · 6d8233fe
      Eric Blake 提交于
      Commit cfd62c1f was incomplete; I found more cases where error
      messages were being overwritten, and where the code between
      the three registration/deregistration APIs was not consistent.
      
      Since it is fairly easy to trigger an attempt to deregister an
      unregistered object through public API, I also changed the error
      message from VIR_ERR_INTERNAL_ERROR to VIR_ERR_INVALID_ARG.
      
      * src/conf/object_event.c (virObjectEventCallbackListEventID):
      Inline...
      (virObjectEventStateEventID): ...into lone caller, and report
      error on failure.
      (virObjectEventCallbackListAddID, virObjectEventStateCallbackID)
      (virObjectEventCallbackListRemoveID)
      (virObjectEventCallbackListMarkDeleteID): Tweak error category.
      * src/remote/remote_driver.c (remoteConnectDomainEventRegister):
      Don't leak registration on failure.
      (remoteConnectDomainEventDeregisterAny)
      (remoteConnectNetworkEventDeregisterAny): Don't overwrite error.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      6d8233fe
  4. 08 1月, 2014 7 次提交
    • M
      conf: trivial typo fix · 4a66ffad
      Martin Kletzander 提交于
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      4a66ffad
    • E
      event: make network events easier to use without casts · 36dd0bd8
      Eric Blake 提交于
      While comparing network and domain events, I noticed that the
      test driver had to do a cast in one place and not the other.
      For consistency, we should hide the necessary casting as low
      as possible in the stack, with everything else using saner
      types.
      
      * src/conf/network_event.h (virNetworkEventStateRegisterID): Alter
      type.
      * src/conf/network_event.c (virNetworkEventStateRegisterID): Hoist
      cast here.
      * src/test/test_driver.c (testConnectNetworkEventRegisterAny):
      Simplify callers.
      * src/remote/remote_driver.c
      (remoteConnectNetworkEventRegisterAny): Likewise.
      * src/network/bridge_driver.c
      (networkConnectNetworkEventRegisterAny): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      36dd0bd8
    • 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 allow mix of old- and new-style registration · 0cd02bca
      Eric Blake 提交于
      Consider these two calls, in either order:
      
      id1 = virConnectDomainEventRegisterAny(conn, NULL,
         VIR_DOMAIN_EVENT_ID_LIFECYCLE,
         VIR_DOMAIN_EVENT_CALLBACK(callback), NULL, NULL);
      virConnectDomainEventRegister(conn, callback, NULL, NULL);
      
      Right now, the second call fails, because under the hood, the
      old-style function registration is tightly coupled to the
      new style lifecycle eventID, and the two calls both try
      to register the same global eventID callback representation.
      
      We've alreay documented that users should avoid old-style
      registration and deregistration, so anyone heeding the advice
      won't run into this situation.  But it would be even nicer if
      we pretend the two interfaces are completely separate, and
      disallow any cross-linking.  That is, a call to old-style
      deregister should never remove a new-style callback even if it
      is the same function pointer, and a call to new-style callback
      using only callbackIDs obtained legitimately should never
      remove an old-style callback (of course, since our callback
      IDs are sequential, and there is still coupling under the
      hood, you can easily guess the callbackID of an old style
      registration and use new-style deregistration to nuke it - but
      that starts to be blatantly bad coding on your part rather
      than a surprising result on what looks like reasonable
      stand-alone API).
      
      With this patch, you can now register a global lifecycle event
      handler twice, by using both old and new APIs; if such an event
      occurs, your callback will be entered twice.  But that is not a
      problem in practice, since it is already possible to use the
      new API to register both a global and per-domain event handler
      using the same function, which will likewise fire your callback
      twice for that domain.  Duplicates are still prevented when
      using the same API with same parameters twice (old-style twice,
      new-style global twice, or new-style per-domain with same domain
      twice), and things are still bounded (it is not possible to
      register a single function pointer more than N+2 times per event
      id, where N is the number of domains available on the connection).
      Besides, it has always been possible to register as many
      separate function pointers on the same event id as desired,
      through either old or new style API, where the bound there is
      the physical limitation of writing a program with enough
      distinct function pointers.
      
      Adding another event registration in the testsuite is sufficient
      to cover this, where the test fails without the rest of the patch.
      
      * src/conf/object_event.c (_virObjectEventCallback): Add field.
      (virObjectEventCallbackLookup): Add argument.
      (virObjectEventCallbackListAddID, virObjectEventStateCallbackID):
      Adjust callers.
      * tests/objecteventtest.c (testDomainCreateXMLMixed): Enhance test.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      0cd02bca
    • E
      event: properly filter count of remaining events · 995b2eba
      Eric Blake 提交于
      On the surface, this sequence of API calls should succeed:
      
      id1 = virConnectDomainEventRegisterAny(..., VIR_DOMAIN_EVENT_ID_LIFECYCLE,...);
      id2 = virConnectDomainEventRegisterAny(..., VIR_DOMAIN_EVENT_ID_RTC_CHANGE,...);
      virConnectDomainEventDeregisterAny(id1);
      id1 = virConnectDomainEventRegisterAny(..., VIR_DOMAIN_EVENT_ID_LIFECYCLE,...);
      
      And for test:///default, it does.  But for qemu:///system, it fails:
      libvirt: XML-RPC error : internal error: domain event 0 already registered
      
      Looking closer, the bug is caused by miscommunication between
      the object event engine and the client side of the remote driver.
      In our implementation, we set up a single server-side event per
      eventID, then the client side replicates that one event to all
      callbacks that have been registered client side.  To know when
      to turn the server side eventID on or off, the client side must
      track how many events for the same eventID have been registered.
      But while our code was filtering by eventID on event registration,
      it did not filter on event deregistration.  So the above API calls
      resulted in the deregister returning 1 instead of 0, so no RPC
      deregister was issued, and the final register detects on the
      server side that the server is already handling eventID 0.
      
      Unfortunately, since the problem is only observable on remote
      connections, it's not possible to enhance objecteventtest to
      expose the semantics using only public API entry points.
      
      * src/conf/object_event.c (virObjectEventCallbackListCount): New
      function.
      (virObjectEventCallbackListAddID)
      (virObjectEventCallbackListRemoveID)
      (virObjectEventCallbackListMarkDeleteID): Use it.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      995b2eba
    • E
      event: tighten scope of object_event · 114aa075
      Eric Blake 提交于
      Tighten up scope after the previous patch avoided using
      internals.  This will also make it easier to change
      internal implementation without having to chase down quite
      as many impacted callers or worrying about two files getting
      implementations out of sync.
      
      * src/conf/object_event_private.h
      (virObjectEventCallbackListAddID, virObjectEventQueueClear)
      (virObjectEventStateLock, virObjectEventStateUnlock)
      (virObjectEventTimer): Drop prototype.
      (_virObjectEventCallbackList, _virObjectEventState)
      (_virObjectEventCallback): Move...
      * src/conf/object_event.c: ...here.
      (virObjectEventCallbackListAddID, virObjectEventQueueClear)
      (virObjectEventStateLock, virObjectEventStateUnlock)
      (virObjectEventTimer): Mark private.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      114aa075
    • 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
  5. 06 1月, 2014 2 次提交
    • E
      event: use newer array management macros · 94a26c7e
      Eric Blake 提交于
      We might as well take advantage of viralloc.h instead of open-coding
      array management ourselves.  While at it, I simplified several
      places that were doing repetitive pointer chasing to use an
      intermediate variable for legibility (some other places remain,
      but they will disapper in later refactoring patches).
      
      * src/conf/object_event_private.h (_virObjectEventCallbackList):
      Use size_t for count.
      * src/conf/object_event.c (_virObjectEventQueue): Likewise.
      (virObjectEventCallbackListRemoveID): Use VIR_DELETE_ELEMENT.
      (virObjectEventQueuePush, virObjectEventCallbackListAddID): Use
      VIR_APPEND_ELEMENT.
      (virObjectEventCallbackListEventID)
      (virObjectEventStateDispatchCallbacks): Simplify code.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      94a26c7e
    • 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
  6. 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
  7. 31 12月, 2013 1 次提交
    • L
      domain: don't try to interpret <driver> as virtio config for hostdev interfaces · 3337a98a
      Laine Stump 提交于
      This resolves:
      
        https://bugzilla.redhat.com/show_bug.cgi?id=1046337
      
      The <driver> name attribute of an interface is interpreted in two
      different ways depending on the <interface> type - if the interface is
      type='hostdev', then the driver name describes which backend to use
      for the hostdev device assignment (vfio or kvm), but if the interface
      is any emulated type *and* the model type is "virtio", then the driver
      name can be "vhost" or "qemu", telling which backend qemu should use
      to communicate with the emulated device.
      
      The problem comes when someone has defined a an interface like this
      (which is accepted by the parser as long as no <driver name='xxx'/> is
      specified):
      
          <interface type='hostdev'>
             ...
             <model type='virtio'/>
             ...
          </interface>
      
      As libvirt storing this definition in the domain's status, the driver
      name is automatically filled in with the backend that was
      automatically decided by libvirt, so it stores this in the status:
      
          <interface type='hostdev'>
             ...
             <driver name='vfio'/>
             ...
             <model type='virtio'/>
             ...
          </interface>
      
      This isn't noticed until the next time libvirtd is restarted - as it
      is reading the status of all domains, it encounters the above
      interface definition, logs an error:
      
        internal error: Unknown interface <driver name='vfio'> has been specified
      
      and fails to reload the domain status, so the domain is marked as
      inactive.
      
      The solution is to stop the parser from interpreting <driver>
      attributes as if the device was an emulated virtio device, when it is
      actually a hostdev.
      
      (Although the bug has existed since vfio support was added, it has
      just recently become more apparent because libvirt previously didn't
      automatically set the driver name for hostdev interfaces in the domain
      status to vfio/kvm as it does since commit f094aa, first appearing in
      v1.1.4.)
      3337a98a
  8. 23 12月, 2013 1 次提交
    • L
      qemu: re-add hostdev interfaces to hostdev array on libvirtd restart · 8700b878
      Laine Stump 提交于
      This resolves:
      
         https://bugzilla.redhat.com/show_bug.cgi?id=1045002
      
      If a domain has an <interface type='hostdev'> or an <interface
      type='network'> where the network itself is a pool of hostdev devices,
      then libvirt will internally keep that device on both the interface
      list *and* the hostdev list for the domain. One of the places this
      comes in handy is when a new device is being added and libvirt wants
      to find a unique "alias" name for it - it just scans through the
      hostdev array and makes sure it picks a name that doesn't match the
      alias of any device in that array.
      
      However, when libvirtd was restarted, if there was an <interface
      type='network'> with the network being a hostdev pool, the device
      would not be added to the reconstructed internal hostdev array, so its
      alias would not be found during a scan of the hostdev array, thus
      attempts to add a new hostdev (or <interface type='hostdev'> or
      <interface type='network'>) would result in a message like this:
      
      internal error: unable to execute QEMU command 'device_add':
                      Duplicate ID 'hostdev0' for device
      
      This patch simply fixes the existing code in the domain XML parser
      that fixes up the hostdev array in the case of <interface
      type='hostdev'> to do the same thing in the case of <interface
      type='network'> with a hostdev network.
      
      This bug has existed since the very first addition of hostdev networks
      to libvirt (0.10.0).
      8700b878
  9. 21 12月, 2013 1 次提交
    • J
      PanicCheckABIStability: Need to check for existence · d53c57b8
      John Ferlan 提交于
      Commit id '4313fead' added a call to virDomainPanicCheckABIStability()
      which did not check whether the panic device existed before making a call
      to virDomainDeviceInfoCheckABIStability() which ended up segfaulting:
      
      Thread 1 (Thread 0x7f5332837700 (LWP 10964)):
          (src=<optimized out>, dst=<optimized out>)
          at conf/domain_conf.c:13007
          (dst=<optimized out>, src=<optimized out>)
          at conf/domain_conf.c:13712
          (src=<optimized out>, dst=<optimized out>)
          at conf/domain_conf.c:14056
          (domain=domain@entry=0x7f53000057c0, vm=vm@entry=0x7f53000036d0,
           defptr=defptr@entry=0x7f5332836978, snap=snap@entry=0x7f5332836970,
           update_current=update_current@entry=0x7f5332836962, flags=flags@entry=1)
          at conf/snapshot_conf.c:1230
          (domain=0x7f53000057c0, xmlDesc=<optimized out>, flags=1)
          at qemu/qemu_driver.c:12719
          (domain=domain@entry=0x7f53000057c0, xmlDesc=0x7f53000081d0
           "<domainsnapshot>\n  <name>snap2</name>\n
           <description>new-desc</description>\n  <state>running</state>\n
           <parent>\n    <name>snap1</name>\n  </parent>\n
           <creationTime>1387487268</creationTime>\n  <memory s"..., flags=1)
          at libvirt.c:19695
      ...
      
      (gdb) up 3
      (gdb) print *other->def->dom
      $2 = {virtType = 2, id = -1, ..
      ...
        rng = 0x0, panic = 0x0, namespaceData = 0x0,...
      ...
      (gdb) print *def->dom
      $3 = {virtType = 2, id = -1, ...
      ...
        rng = 0x0, panic = 0x0, namespaceData = 0x0,...
      ...
      (gdb)
      
      Also seen using following sequence:
      
      virsh save $dom $file
      virsh save-image-edit $file
        add (or remove) a <panic/> line
        <devices>
        ...
          <panic>
            <address type='isa' iobase='0x505'/>
          </panic>
        ...
        </devices>
      d53c57b8
  10. 19 12月, 2013 1 次提交
    • P
      storage: Add gluster pool filter and fix virsh pool listing · b560946c
      Peter Krempa 提交于
      Recent addition of the gluster pool type omitted fixing the virsh and
      virConnectListAllStoragePool filters. A typecast of the converting
      function in virsh showed that also the sheepdog pool was omitted in the
      command parser.
      
      This patch adds gluster pool filtering support and fixes virsh to
      properly convert all supported storage pool types. The added typecast
      should avoid doing such mistakes in the future.
      b560946c
  11. 14 12月, 2013 5 次提交
  12. 13 12月, 2013 3 次提交
    • N
      Fix memory leak in virObjectEventCallbackListRemoveID() · 34d52b34
      Nehal J Wani 提交于
      While running objecteventtest, it was found that valgrind pointed out the
      following memory leak:
      
      ==13464== 5 bytes in 1 blocks are definitely lost in loss record 7 of 134
      ==13464==    at 0x4A0887C: malloc (vg_replace_malloc.c:270)
      ==13464==    by 0x341F485E21: strdup (strdup.c:42)
      ==13464==    by 0x4CAE28F: virStrdup (virstring.c:554)
      ==13464==    by 0x4CF3CBE: virObjectEventCallbackListAddID (object_event.c:286)
      ==13464==    by 0x4CF49CA: virObjectEventStateRegisterID (object_event.c:729)
      ==13464==    by 0x4CF73FE: virDomainEventStateRegisterID (domain_event.c:1424)
      ==13464==    by 0x4D7358F: testConnectDomainEventRegisterAny (test_driver.c:6032)
      ==13464==    by 0x4D600C8: virConnectDomainEventRegisterAny (libvirt.c:19128)
      ==13464==    by 0x402409: testDomainStartStopEvent (objecteventtest.c:232)
      ==13464==    by 0x403451: virtTestRun (testutils.c:138)
      ==13464==    by 0x402012: mymain (objecteventtest.c:395)
      ==13464==    by 0x403AF2: virtTestMain (testutils.c:593)
      ==13464==
      34d52b34
    • H
      conf: add support for panic device · 4313fead
      Hu Tao 提交于
      panic device is a device that enables libvirt to receive notification
      of guest panic event.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      4313fead
    • H
      conf: introduce generic ISA address · f1a039ef
      Hu Tao 提交于
      For example:
      <address type='isa' iobase='0x505' irq='0x1'/>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      f1a039ef
  13. 12 12月, 2013 3 次提交
  14. 11 12月, 2013 3 次提交
  15. 10 12月, 2013 5 次提交