1. 06 7月, 2016 1 次提交
    • E
      qapi: Add parameter to visit_end_* · 1158bb2a
      Eric Blake 提交于
      Rather than making the dealloc visitor track of stack of pointers
      remembered during visit_start_* in order to free them during
      visit_end_*, it's a lot easier to just make all callers pass the
      same pointer to visit_end_*.  The generated code has access to the
      same pointer, while all other users are doing virtual walks and
      can pass NULL.  The dealloc visitor is then greatly simplified.
      
      All three visit_end_*() functions intentionally take a void**,
      even though the visit_start_*() functions differ between void**,
      GenericList**, and GenericAlternate**.  This is done for several
      reasons: when doing a virtual walk, passing NULL doesn't care
      what the type is, but when doing a generated walk, we already
      have to cast the caller's specific FOO* to call visit_start,
      while using void** lets us use visit_end without a cast. Also,
      an upcoming patch will add a clone visitor that wants to use
      the same implementation for all three visit_end callbacks,
      which is made easier if all three share the same signature.
      
      For visitors with already track per-object state (the QMP visitors
      via a stack, and the string visitors which do not allow nesting),
      add an assertion that the caller is indeed passing the same
      pointer to paired calls.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1465490926-28625-4-git-send-email-eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      1158bb2a
  2. 17 6月, 2016 1 次提交
  3. 12 5月, 2016 3 次提交
    • E
      qapi: Simplify semantics of visit_next_list() · d9f62dde
      Eric Blake 提交于
      The semantics of the list visit are somewhat baroque, with the
      following pseudocode when FooList is used:
      
      start()
      for (prev = head; cur = next(prev); prev = &cur) {
          visit(&cur->value)
      }
      
      Note that these semantics (advance before visit) requires that
      the first call to next() return the list head, while all other
      calls return the next element of the list; that is, every visitor
      implementation is required to track extra state to decide whether
      to return the input as-is, or to advance.  It also requires an
      argument of 'GenericList **' to next(), solely because the first
      iteration might need to modify the caller's GenericList head, so
      that all other calls have to do a layer of dereferencing.
      
      Thankfully, we only have two uses of list visits in the entire
      code base: one in spapr_drc (which completely avoids
      visit_next_list(), feeding in integers from a different source
      than uint8List), and one in qapi-visit.py.  That is, all other
      list visitors are generated in qapi-visit.c, and share the same
      paradigm based on a qapi FooList type, so we can refactor how
      lists are laid out with minimal churn among clients.
      
      We can greatly simplify things by hoisting the special case
      into the start() routine, and flipping the order in the loop
      to visit before advance:
      
      start(head)
      for (tail = *head; tail; tail = next(tail)) {
          visit(&tail->value)
      }
      
      With the simpler semantics, visitors have less state to track,
      the argument to next() is reduced to 'GenericList *', and it
      also becomes obvious whether an input visitor is allocating a
      FooList during visit_start_list() (rather than the old way of
      not knowing if an allocation happened until the first
      visit_next_list()).  As a minor drawback, we now allocate in
      two functions instead of one, and have to pass the size to
      both functions (unless we were to tweak the input visitors to
      cache the size to start_list for reuse during next_list, but
      that defeats the goal of less visitor state).
      
      The signature of visit_start_list() is chosen to match
      visit_start_struct(), with the new parameters after 'name'.
      
      The spapr_drc case is a virtual visit, done by passing NULL for
      list, similarly to how NULL is passed to visit_start_struct()
      when a qapi type is not used in those visits.  It was easy to
      provide these semantics for qmp-output and dealloc visitors,
      and a bit harder for qmp-input (several prerequisite patches
      refactored things to make this patch straightforward).  But it
      turned out that the string and opts visitors munge enough other
      state during visit_next_list() to make it easier to just
      document and require a GenericList visit for now; an assertion
      will remind us to adjust things if we need the semantics in the
      future.
      
      Several pre-requisite cleanup patches made the reshuffling of
      the various visitors easier; particularly the qmp input visitor.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1461879932-9020-24-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      d9f62dde
    • E
      qapi: Split visit_end_struct() into pieces · 15c2f669
      Eric Blake 提交于
      As mentioned in previous patches, we want to call visit_end_struct()
      functions unconditionally, so that visitors can release resources
      tied up since the matching visit_start_struct() without also having
      to worry about error priority if more than one error occurs.
      
      Even though error_propagate() can be safely used to ignore a second
      error during cleanup caused by a first error, it is simpler if the
      cleanup cannot set an error.  So, split out the error checking
      portion (basically, input visitors checking for unvisited keys) into
      a new function visit_check_struct(), which can be safely skipped if
      any earlier errors are encountered, and leave the cleanup portion
      (which never fails, but must be called unconditionally if
      visit_start_struct() succeeded) in visit_end_struct().
      
      Generated code in qapi-visit.c has diffs resembling:
      
      |@@ -59,10 +59,12 @@ void visit_type_ACPIOSTInfo(Visitor *v,
      |         goto out_obj;
      |     }
      |     visit_type_ACPIOSTInfo_members(v, obj, &err);
      |-    error_propagate(errp, err);
      |-    err = NULL;
      |+    if (err) {
      |+        goto out_obj;
      |+    }
      |+    visit_check_struct(v, &err);
      | out_obj:
      |-    visit_end_struct(v, &err);
      |+    visit_end_struct(v);
      | out:
      
      and in qapi-event.c:
      
      @@ -47,7 +47,10 @@ void qapi_event_send_acpi_device_ost(ACP
      |         goto out;
      |     }
      |     visit_type_q_obj_ACPI_DEVICE_OST_arg_members(v, &param, &err);
      |-    visit_end_struct(v, err ? NULL : &err);
      |+    if (!err) {
      |+        visit_check_struct(v, &err);
      |+    }
      |+    visit_end_struct(v);
      |     if (err) {
      |         goto out;
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1461879932-9020-20-git-send-email-eblake@redhat.com>
      [Conflict with a doc fixup resolved]
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      15c2f669
    • E
      spapr_drc: Expose 'null' in qom-get when there is no fdt · a543a554
      Eric Blake 提交于
      Now that the QMP output visitor supports an explicit null
      output, we should utilize it to make it easier to diagnose
      the difference between a missing fdt ('null') vs. a
      present-but-empty one ('{}').
      
      (Note that this reverts the behavior of commit ab8bf1d7, taking
      us back to the behavior of commit 6c2f9a15 [which in turn
      stemmed from a crash fix in 1d10b445]; but that this time,
      the change is intentional and not an accidental side-effect.)
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Acked-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Message-Id: <1461879932-9020-17-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      a543a554
  4. 26 4月, 2016 1 次提交
    • M
      spapr_drc: fix aborts during DRC-count based hotplug · df18b2db
      Michael Roth 提交于
      CPU/memory resources can be signalled en-masse via
      spapr_hotplug_req_add_by_count(), and when doing so, actually change
      the meaning of the 'drc' parameter passed to
      spapr_hotplug_req_event() to be a count rather than an index.
      
      f40eb921 added a hook in spapr_hotplug_req_event() to record when a
      device had been 'signalled' to the guest, but that code assumes that
      drc is always an index. In cases where it's a count, such as memory
      hotplug, the DRC lookup will fail, leading to an assert.
      
      Fix this by only explicitly setting the signalled state for cases where
      we are doing PCI hotplug.
      
      For other resources types, since we cannot selectively track whether a
      resource has been signalled in cases where we signal attach as a count,
      set the 'signalled' state to true immediately upon making the
      resource available via drck->attach().
      Reported-by: NBharata B Rao <bharata@linux.vnet.ibm.com>
      Cc: Bharata B Rao <bharata@linux.vnet.ibm.com>
      Cc: david@gibson.dropbear.id.au
      Cc: qemu-ppc@nongnu.org
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      df18b2db
  5. 05 4月, 2016 1 次提交
    • M
      spapr_drc: enable immediate detach for unsignalled devices · f40eb921
      Michael Roth 提交于
      Currently spapr doesn't support "aborting" hotplug of PCI
      devices by allowing device_del to immediately remove the
      device if we haven't signalled the presence of the device
      to the guest.
      
      In the past this wasn't an issue, since we always immediately
      signalled device attach and simply relied on full guest-aware
      add->remove path for device removal. However, as of 788d2599,
      we now defer signalling for PCI functions until function 0
      is attached, so now we need to deal with these "abort" operations
      for cases where a user hotplugs a non-0 function, then opts to
      remove it prior hotplugging function 0. Currently they'd have to
      reboot before the unplug completed. PCIe multifunction hotplug
      does not have this requirement however, so from a management
      implementation perspective it would be good to address this within
      the same release as 788d2599.
      
      We accomplish this by simply adding a 'signalled' flag to track
      whether a device hotplug event has been sent to the guest. If it
      hasn't, we allow immediate removal under the assumption that the
      guest will not be using the device. Devices present at boot/reset
      time are also assumed to be 'signalled'.
      
      For CPU/memory/etc, signalling will still happen immediately
      as part of device_add, so only PCI functions should be affected.
      
      Cc: bharata@linux.vnet.ibm.com
      Cc: david@gibson.dropbear.id.au
      Cc: sbhat@linux.vnet.ibm.com
      Cc: qemu-ppc@nongnu.org
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      [dwg: This fixes a regression where an incorrect hot-add of a non-zero
            function can no longer be backed out until function 0 is added]
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      f40eb921
  6. 23 3月, 2016 3 次提交
    • V
      util: move declarations out of qemu-common.h · f348b6d1
      Veronia Bahaa 提交于
      Move declarations out of qemu-common.h for functions declared in
      utils/ files: e.g. include/qemu/path.h for utils/path.c.
      Move inline functions out of qemu-common.h and into new files (e.g.
      include/qemu/bcd.h)
      Signed-off-by: NVeronia Bahaa <veroniabahaa@gmail.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      f348b6d1
    • P
      hw: explicitly include qemu-common.h and cpu.h · 4771d756
      Paolo Bonzini 提交于
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      4771d756
    • M
      include/qemu/osdep.h: Don't include qapi/error.h · da34e65c
      Markus Armbruster 提交于
      Commit 57cb38b3 included qapi/error.h into qemu/osdep.h to get the
      Error typedef.  Since then, we've moved to include qemu/osdep.h
      everywhere.  Its file comment explains: "To avoid getting into
      possible circular include dependencies, this file should not include
      any other QEMU headers, with the exceptions of config-host.h,
      compiler.h, os-posix.h and os-win32.h, all of which are doing a
      similar job to this file and are under similar constraints."
      qapi/error.h doesn't do a similar job, and it doesn't adhere to
      similar constraints: it includes qapi-types.h.  That's in excess of
      100KiB of crap most .c files don't actually need.
      
      Add the typedef to qemu/typedefs.h, and include that instead of
      qapi/error.h.  Include qapi/error.h in .c files that need it and don't
      get it now.  Include qapi-types.h in qom/object.h for uint16List.
      
      Update scripts/clean-includes accordingly.  Update it further to match
      reality: replace config.h by config-target.h, add sysemu/os-posix.h,
      sysemu/os-win32.h.  Update the list of includes in the qemu/osdep.h
      comment quoted above similarly.
      
      This reduces the number of objects depending on qapi/error.h from "all
      of them" to less than a third.  Unfortunately, the number depending on
      qapi-types.h shrinks only a little.  More work is needed for that one.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      [Fix compilation without the spice devel packages. - Paolo]
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      da34e65c
  7. 09 2月, 2016 4 次提交
    • E
      qapi: Drop unused error argument for list and implicit struct · 08f9541d
      Eric Blake 提交于
      No backend was setting an error when ending the visit of a list or
      implicit struct, or when moving to the next list node.  Make the
      callers a bit easier to follow by making this a part of the contract,
      and removing the errp argument - callers can then unconditionally end
      an object as part of cleanup without having to think about whether a
      second error is dominated by a first, because there is no second
      error.
      
      A later patch will then tackle the larger task of splitting
      visit_end_struct(), which can indeed set an error.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1454075341-13658-24-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      08f9541d
    • E
      qapi: Drop unused 'kind' for struct/enum visit · 337283df
      Eric Blake 提交于
      visit_start_struct() and visit_type_enum() had a 'kind' argument
      that was usually set to either the stringized version of the
      corresponding qapi type name, or to NULL (although some clients
      didn't even get that right).  But nothing ever used the argument.
      It's even hard to argue that it would be useful in a debugger,
      as a stack backtrace also tells which type is being visited.
      
      Therefore, drop the 'kind' argument as dead.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1454075341-13658-22-git-send-email-eblake@redhat.com>
      [Harmless rebase mistake cleaned up]
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      337283df
    • E
      qom: Swap 'name' next to visitor in ObjectPropertyAccessor · d7bce999
      Eric Blake 提交于
      Similar to the previous patch, it's nice to have all functions
      in the tree that involve a visitor and a name for conversion to
      or from QAPI to consistently stick the 'name' parameter next
      to the Visitor parameter.
      
      Done by manually changing include/qom/object.h and qom/object.c,
      then running this Coccinelle script and touching up the fallout
      (Coccinelle insisted on adding some trailing whitespace).
      
          @ rule1 @
          identifier fn;
          typedef Object, Visitor, Error;
          identifier obj, v, opaque, name, errp;
          @@
           void fn
          - (Object *obj, Visitor *v, void *opaque, const char *name,
          + (Object *obj, Visitor *v, const char *name, void *opaque,
             Error **errp) { ... }
      
          @@
          identifier rule1.fn;
          expression obj, v, opaque, name, errp;
          @@
           fn(obj, v,
          -   opaque, name,
          +   name, opaque,
              errp)
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1454075341-13658-20-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      d7bce999
    • E
      qapi: Swap visit_* arguments for consistent 'name' placement · 51e72bc1
      Eric Blake 提交于
      JSON uses "name":value, but many of our visitor interfaces were
      called with visit_type_FOO(v, &value, name, errp).  This can be
      a bit confusing to have to mentally swap the parameter order to
      match JSON order.  It's particularly bad for visit_start_struct(),
      where the 'name' parameter is smack in the middle of the
      otherwise-related group of 'obj, kind, size' parameters! It's
      time to do a global swap of the parameter ordering, so that the
      'name' parameter is always immediately after the Visitor argument.
      
      Additional reason in favor of the swap: the existing include/qjson.h
      prefers listing 'name' first in json_prop_*(), and I have plans to
      unify that file with the qapi visitors; listing 'name' first in
      qapi will minimize churn to the (admittedly few) qjson.h clients.
      
      Later patches will then fix docs, object.h, visitor-impl.h, and
      those clients to match.
      
      Done by first patching scripts/qapi*.py by hand to make generated
      files do what I want, then by running the following Coccinelle
      script to affect the rest of the code base:
       $ spatch --sp-file script `git grep -l '\bvisit_' -- '**/*.[ch]'`
      I then had to apply some touchups (Coccinelle insisted on TAB
      indentation in visitor.h, and botched the signature of
      visit_type_enum() by rewriting 'const char *const strings[]' to
      the syntactically invalid 'const char*const[] strings').  The
      movement of parameters is sufficient to provoke compiler errors
      if any callers were missed.
      
          // Part 1: Swap declaration order
          @@
          type TV, TErr, TObj, T1, T2;
          identifier OBJ, ARG1, ARG2;
          @@
           void visit_start_struct
          -(TV v, TObj OBJ, T1 ARG1, const char *name, T2 ARG2, TErr errp)
          +(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
           { ... }
      
          @@
          type bool, TV, T1;
          identifier ARG1;
          @@
           bool visit_optional
          -(TV v, T1 ARG1, const char *name)
          +(TV v, const char *name, T1 ARG1)
           { ... }
      
          @@
          type TV, TErr, TObj, T1;
          identifier OBJ, ARG1;
          @@
           void visit_get_next_type
          -(TV v, TObj OBJ, T1 ARG1, const char *name, TErr errp)
          +(TV v, const char *name, TObj OBJ, T1 ARG1, TErr errp)
           { ... }
      
          @@
          type TV, TErr, TObj, T1, T2;
          identifier OBJ, ARG1, ARG2;
          @@
           void visit_type_enum
          -(TV v, TObj OBJ, T1 ARG1, T2 ARG2, const char *name, TErr errp)
          +(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
           { ... }
      
          @@
          type TV, TErr, TObj;
          identifier OBJ;
          identifier VISIT_TYPE =~ "^visit_type_";
          @@
           void VISIT_TYPE
          -(TV v, TObj OBJ, const char *name, TErr errp)
          +(TV v, const char *name, TObj OBJ, TErr errp)
           { ... }
      
          // Part 2: swap caller order
          @@
          expression V, NAME, OBJ, ARG1, ARG2, ERR;
          identifier VISIT_TYPE =~ "^visit_type_";
          @@
          (
          -visit_start_struct(V, OBJ, ARG1, NAME, ARG2, ERR)
          +visit_start_struct(V, NAME, OBJ, ARG1, ARG2, ERR)
          |
          -visit_optional(V, ARG1, NAME)
          +visit_optional(V, NAME, ARG1)
          |
          -visit_get_next_type(V, OBJ, ARG1, NAME, ERR)
          +visit_get_next_type(V, NAME, OBJ, ARG1, ERR)
          |
          -visit_type_enum(V, OBJ, ARG1, ARG2, NAME, ERR)
          +visit_type_enum(V, NAME, OBJ, ARG1, ARG2, ERR)
          |
          -VISIT_TYPE(V, OBJ, NAME, ERR)
          +VISIT_TYPE(V, NAME, OBJ, ERR)
          )
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1454075341-13658-19-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      51e72bc1
  8. 29 1月, 2016 1 次提交
    • P
      ppc: Clean up includes · 0d75590d
      Peter Maydell 提交于
      Clean up includes so that osdep.h is included first and headers
      which it implies are not included manually.
      
      This commit was created with scripts/clean-includes.
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Message-id: 1453832250-766-6-git-send-email-peter.maydell@linaro.org
      0d75590d
  9. 19 1月, 2016 1 次提交
    • D
      qom: Change object property iterator API contract · 7746abd8
      Daniel P. Berrange 提交于
      Currently the ObjectProperty iterator API works as follows:
      
        ObjectPropertyIterator *iter;
      
        iter = object_property_iter_init(obj);
        while ((prop = object_property_iter_next(iter))) {
           ...
        }
        object_property_iter_free(iter);
      
      This has the benefit that the ObjectPropertyIterator struct
      can be opaque, but has the downside that callers need to
      explicitly call a free function. It is also not in keeping
      with iterator style used elsewhere in QEMU/GLib2.
      
      This patch changes the API to use stack allocation instead:
      
        ObjectPropertyIterator iter;
      
        object_property_iter_init(&iter, obj);
        while ((prop = object_property_iter_next(&iter))) {
           ...
        }
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      [AF: Fused ObjectPropertyIterator struct with typedef]
      Signed-off-by: NAndreas Färber <afaerber@suse.de>
      7746abd8
  10. 13 1月, 2016 1 次提交
  11. 04 12月, 2015 3 次提交
  12. 19 11月, 2015 1 次提交
  13. 23 9月, 2015 5 次提交
    • D
      spapr: Don't use QOM [*] syntax for DR connectors. · 94649d42
      David Gibson 提交于
      The dynamic reconfiguration (hotplug) code for the pseries machine type
      uses a "DR connector" QOM object for each resource it will be possible
      to hotplug.  Each of these is added to its owner using
          object_property_add_child(owner, "dr-connector[*], ...);
      
      That works ok, mostly, but it means that the property indices are
      arbitrary, depending on the order in which the connectors are constructed.
      That might line up to something useful, but it doesn't have to.
      
      It will get worse once we add hotplug RAM support.  That will add a DR
      connector object for every 256MB of potential memory.  So if maxmem=2T,
      for example, there are 8192 objects under the same parent.
      
      The QOM interfaces aren't really designed for this.  In particular
      object_property_add() with [*] has O(n^2) time complexity (in the number of
      existing children): first it has a linear search through array indices to
      find a free slot, each of which is attempted to a recursive call to
      object_property_add() with a specific [N].  Those calls are O(n) because
      there's a linear search through all properties to check for duplicates.
      
      By using a meaningful index value, which we already know is unique we can
      avoid the [*] special behaviour.  That lets us reduce the total time for
      creating the DR objects from O(n^3) to O(n^2).
      
      O(n^2) is still kind of crappy, but it's enough to reduce the startup time
      of qemu (with in-progress memory hotplug support) with maxmem=2T from ~20
      minutes to ~4 seconds.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Cc: Bharata B Rao <bharata@linux.vnet.ibm.com>
      Tested-by: NBharata B Rao <bharata@linux.vnet.ibm.com>
      Reviewed-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      94649d42
    • M
      spapr_drc: use RTAS return codes for methods called by RTAS · 0cb688d2
      Michael Roth 提交于
      Certain methods in sPAPRDRConnector objects are only ever called by
      RTAS and in many cases are responsible for the logic that determines
      the RTAS return codes.
      
      Rather than having a level of indirection requiring RTAS code to
      re-interpret return values from such methods to determine the
      appropriate return code, just pass them through directly.
      
      This requires changing method return types to uint32_t to match the
      type of values currently passed to RTAS helpers.
      
      In the case of read accesses like drc->entity_sense() where we weren't
      previously reporting any errors, just the read value, we modify the
      function to return RTAS return code, and pass the read value back via
      reference.
      Suggested-by: NBharata B Rao <bharata@linux.vnet.ibm.com>
      Suggested-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Cc: Bharata B Rao <bharata@linux.vnet.ibm.com>
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      0cb688d2
    • M
      spapr_drc: don't allow 'empty' DRCs to be unisolated or allocated · 9d1852ce
      Michael Roth 提交于
      Logical resources start with allocation-state:UNUSABLE /
      isolation-state:ISOLATED. During hotplug, guests will transition
      them to allocation-state:USABLE, and then to
      isolation-state:UNISOLATED.
      
      For cases where we cannot transition to allocation-state:USABLE,
      in this case due to no device/resource being association with
      the logical DRC, we should return an error -3.
      
      For physical DRCs, we default to allocation-state:USABLE and stay
      there, so in this case we should report an error -3 when the guest
      attempts to make the isolation-state:ISOLATED transition for a DRC
      with no device associated.
      
      These are as documented in PAPR 2.7, 13.5.3.4.
      
      We also ensure allocation-state:USABLE when the guest attempts
      transition to isolation-state:UNISOLATED to deal with misbehaving
      guests attempting to bring online an unallocated logical resource.
      
      This is as documented in PAPR 2.7, 13.7.
      
      Currently we implement no such error logic. Fix this by handling
      these error cases as PAPR defines.
      
      Cc: Bharata B Rao <bharata@linux.vnet.ibm.com>
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      9d1852ce
    • L
      pseries: define coldplugged devices as "configured" · 785652dc
      Laurent Vivier 提交于
      When a device is hotplugged, attach() sets "configured" to
      false, waiting an action from the OS to configure it and then
      to call ibm,configure-connector. On ibm,configure-connector,
      the hypervisor sets "configured" to true.
      
      In case of coldplugged device, attach() sets "configured" to
      false, but firmware and OS never call the ibm,configure-connector
      in this case, so it remains set to false.
      
      It could be harmless, but when we unplug a device, hypervisor
      waits the device becomes configured because for it, a not configured
      device is a device being configured, so it waits the end of configuration
      to unplug it... and it never happens, so it is never unplugged.
      
      This patch set by default coldplugged device to "configured=true",
      hotplugged device to "configured=false".
      Signed-off-by: NLaurent Vivier <lvivier@redhat.com>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      785652dc
    • D
      spapr_drc: Fix potential undefined behaviour · 627c2ef7
      David Gibson 提交于
      The DRC_INDEX_ID_MASK macro does a left shift on ~0, which is a signed
      quantity, and therefore undefined behaviour according to the C spec.  In
      particular this causes warnings from the clang sanitizer.
      
      This fixes it by calculating the same mask without using ~0 (I think the
      new method is a more common idiom for generating masks anyway).  For good
      measure I also use 1ULL to force the expression's type to unsigned long
      long, which should be good for assigning to anything we're going to want
      to.
      Reported-by: NPeter Maydell <peter.maydell@linaro.org>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      627c2ef7
  14. 17 7月, 2015 1 次提交
  15. 04 6月, 2015 2 次提交
    • M
      spapr_drc: add spapr_drc_populate_dt() · e4b798bb
      Michael Roth 提交于
      This function handles generation of ibm,drc-* array device tree
      properties to describe DRC topology to guests. This will by used
      by the guest to direct RTAS calls to manage any dynamic resources
      we associate with a particular DR Connector as part of
      hotplug/unplug.
      
      Since general management of boot-time device trees are handled
      outside of sPAPRDRConnector, we insert these values blindly given
      an FDT and offset. A mask of sPAPRDRConnector types is given to
      instruct us on what types of connectors entries should be generated
      for, since descriptions for different connectors may live in
      different parts of the device tree.
      
      Based on code originally written by Nathan Fontenot.
      Signed-off-by: NNathan Fontenot <nfont@linux.vnet.ibm.com>
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      e4b798bb
    • M
      spapr_drc: initial implementation of sPAPRDRConnector device · bbf5c878
      Michael Roth 提交于
      This device emulates a firmware abstraction used by pSeries guests to
      manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
      memory, and CPUs. It is conceptually similar to an SHPC device,
      complete with LED indicators to identify individual slots to physical
      physical users and indicate when it is safe to remove a device. In
      some cases it is also used to manage virtualized resources, such a
      memory, CPUs, and physical-host bridges, which in the case of pSeries
      guests are virtualized resources where the physical components are
      managed by the host.
      
      Guests communicate with these DR Connectors using RTAS calls,
      generally by addressing the unique DRC index associated with a
      particular connector for a particular resource. For introspection
      purposes we expose this state initially as QOM properties, and
      in subsequent patches will introduce the RTAS calls that make use of
      it. This constitutes to the 'guest' interface.
      
      On the QEMU side we provide an attach/detach interface to associate
      or cleanup a DeviceState with a particular sPAPRDRConnector in
      response to hotplug/unplug, respectively. This constitutes the
      'physical' interface to the DR Connector.
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      bbf5c878