1. 04 9月, 2017 3 次提交
    • M
      qapi: Generate FOO_str() macro for QAPI enum FOO · 5b5f825d
      Markus Armbruster 提交于
      The next commit will put it to use.  May look pointless now, but we're
      going to change the FOO_lookup's type, and then it'll help.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <1503564371-26090-13-git-send-email-armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      5b5f825d
    • M
      tpm: Clean up model registration & lookup · 00bbf50a
      Markus Armbruster 提交于
      We have a strict separation between enum TpmModel and tpm_models[]:
      
      * TpmModel may have any number of members.  It just happens to have one.
      
      * tpm_register_model() uses the first empty slot in tpm_models[].
      
        If you register more than tpm_models[] has space,
        tpn_register_model() fails.  Its caller silently ignores the
        failure.
      
        Register the same TpmModel more than once has no effect other than
        wasting tpm_models[] slots: tpm_model_is_registered() is happy with
        the first one it finds.
      
      Since we only ever register one model, and tpm_models[] has space for
      just that one, this contraption even works.
      
      Turn tpm_models[] into a straight map from enum TpmType to bool.  Much
      simpler.
      
      Cc: Stefan Berger <stefanb@us.ibm.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <1503564371-26090-5-git-send-email-armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      [Commit message typo fixed]
      00bbf50a
    • M
      tpm: Clean up driver registration & lookup · a9a72aee
      Marc-André Lureau 提交于
      We have a strict separation between enum TpmType and be_drivers[]:
      
      * TpmType may have any number of members.  It just happens to have one.
      
      * tpm_register_driver() uses the first empty slot in be_drivers[].
      
        If you register more than tpm_models[] has space,
        tpm_register_driver() fails.  Its caller silently ignores the
        failure.
      
        If you register more than one with a given TpmType,
        tpm_display_backend_drivers() will shows all of them, but
        tpm_driver_find_by_type() and tpm_get_backend_driver() will find
        only the one one that registered first.
      
      Since we only ever register one driver, and be_drivers[] has space for
      just that one, this contraption even works.
      
      Turn be_drivers[] into a straight map from enum TpmType to driver.
      Much simpler, and has a decent chance to actually work should we ever
      acquire additional drivers.
      
      While there, use qapi_enum_parse() in tpm_get_backend_driver().
      Signed-off-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <20170822132255.23945-8-marcandre.lureau@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      [Rebased, superfluous initializer dropped, commit message rewritten]
      Cc: Stefan Berger <stefanb@us.ibm.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <1503564371-26090-4-git-send-email-armbru@redhat.com>
      a9a72aee
  2. 18 3月, 2016 1 次提交
    • E
      qapi: Don't special-case simple union wrappers · 32bafa8f
      Eric Blake 提交于
      Simple unions were carrying a special case that hid their 'data'
      QMP member from the resulting C struct, via the hack method
      QAPISchemaObjectTypeVariant.simple_union_type().  But by using
      the work we started by unboxing flat union and alternate
      branches, coupled with the ability to visit the members of an
      implicit type, we can now expose the simple union's implicit
      type in qapi-types.h:
      
      | struct q_obj_ImageInfoSpecificQCow2_wrapper {
      |     ImageInfoSpecificQCow2 *data;
      | };
      |
      | struct q_obj_ImageInfoSpecificVmdk_wrapper {
      |     ImageInfoSpecificVmdk *data;
      | };
      ...
      | struct ImageInfoSpecific {
      |     ImageInfoSpecificKind type;
      |     union { /* union tag is @type */
      |         void *data;
      |-        ImageInfoSpecificQCow2 *qcow2;
      |-        ImageInfoSpecificVmdk *vmdk;
      |+        q_obj_ImageInfoSpecificQCow2_wrapper qcow2;
      |+        q_obj_ImageInfoSpecificVmdk_wrapper vmdk;
      |     } u;
      | };
      
      Doing this removes asymmetry between QAPI's QMP side and its
      C side (both sides now expose 'data'), and means that the
      treatment of a simple union as sugar for a flat union is now
      equivalent in both languages (previously the two approaches used
      a different layer of dereferencing, where the simple union could
      be converted to a flat union with equivalent C layout but
      different {} on the wire, or to an equivalent QMP wire form
      but with different C representation).  Using the implicit type
      also lets us get rid of the simple_union_type() hack.
      
      Of course, now all clients of simple unions have to adjust from
      using su->u.member to using su->u.member.data; while this touches
      a number of files in the tree, some earlier cleanup patches
      helped minimize the change to the initialization of a temporary
      variable rather than every single member access.  The generated
      qapi-visit.c code is also affected by the layout change:
      
      |@@ -7393,10 +7393,10 @@ void visit_type_ImageInfoSpecific_member
      |     }
      |     switch (obj->type) {
      |     case IMAGE_INFO_SPECIFIC_KIND_QCOW2:
      |-        visit_type_ImageInfoSpecificQCow2(v, "data", &obj->u.qcow2, &err);
      |+        visit_type_q_obj_ImageInfoSpecificQCow2_wrapper_members(v, &obj->u.qcow2, &err);
      |         break;
      |     case IMAGE_INFO_SPECIFIC_KIND_VMDK:
      |-        visit_type_ImageInfoSpecificVmdk(v, "data", &obj->u.vmdk, &err);
      |+        visit_type_q_obj_ImageInfoSpecificVmdk_wrapper_members(v, &obj->u.vmdk, &err);
      |         break;
      |     default:
      |         abort();
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1458254921-17042-13-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      32bafa8f
  3. 05 2月, 2016 1 次提交
    • P
      all: Clean up includes · d38ea87a
      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: 1454089805-5470-16-git-send-email-peter.maydell@linaro.org
      d38ea87a
  4. 17 12月, 2015 1 次提交
    • E
      qapi: Don't let implicit enum MAX member collide · 7fb1cf16
      Eric Blake 提交于
      Now that we guarantee the user doesn't have any enum values
      beginning with a single underscore, we can use that for our
      own purposes.  Renaming ENUM_MAX to ENUM__MAX makes it obvious
      that the sentinel is generated.
      
      This patch was mostly generated by applying a temporary patch:
      
      |diff --git a/scripts/qapi.py b/scripts/qapi.py
      |index e6d014b..b862ec9 100644
      |--- a/scripts/qapi.py
      |+++ b/scripts/qapi.py
      |@@ -1570,6 +1570,7 @@ const char *const %(c_name)s_lookup[] = {
      |     max_index = c_enum_const(name, 'MAX', prefix)
      |     ret += mcgen('''
      |     [%(max_index)s] = NULL,
      |+// %(max_index)s
      | };
      | ''',
      |                max_index=max_index)
      
      then running:
      
      $ cat qapi-{types,event}.c tests/test-qapi-types.c |
          sed -n 's,^// \(.*\)MAX,s|\1MAX|\1_MAX|g,p' > list
      $ git grep -l _MAX | xargs sed -i -f list
      
      The only things not generated are the changes in scripts/qapi.py.
      
      Rejecting enum members named 'MAX' is now useless, and will be dropped
      in the next patch.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1447836791-369-23-git-send-email-eblake@redhat.com>
      Reviewed-by: NJuan Quintela <quintela@redhat.com>
      [Rebased to current master, commit message tweaked]
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      7fb1cf16
  5. 02 11月, 2015 1 次提交
    • E
      tpm: Convert to new qapi union layout · ce21131a
      Eric Blake 提交于
      We have two issues with our qapi union layout:
      1) Even though the QMP wire format spells the tag 'type', the
      C code spells it 'kind', requiring some hacks in the generator.
      2) The C struct uses an anonymous union, which places all tag
      values in the same namespace as all non-variant members. This
      leads to spurious collisions if a tag value matches a non-variant
      member's name.
      
      Make the conversion to the new layout for TPM-related code.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1445898903-12082-22-git-send-email-eblake@redhat.com>
      [Commit message tweaked slightly]
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      ce21131a
  6. 23 6月, 2015 5 次提交
  7. 09 6月, 2015 2 次提交
  8. 10 3月, 2015 1 次提交
  9. 18 2月, 2015 1 次提交
  10. 18 2月, 2014 1 次提交
  11. 29 7月, 2013 1 次提交
    • P
      tpm.c: Don't try to put -1 in a variable of type TpmModel · 8cdd2e0a
      Peter Maydell 提交于
      The TpmModel type is an enum (valid values 0 and 1), which means
      the compiler can legitimately decide that comparisons like
      'tpm_models[i] == -1' are never true. (For example it could
      pick 'unsigned char' as its type for representing the enum.)
      
      Avoid this issue by using TPM_MODEL_MAX to mark entries in
      the tpm_models[] array which aren't filled in, instead of -1.
      
      This silences a clang warning:
      
       tpm.c:43:27: error: comparison of constant -1 with expression of type
            'enum TpmModel' is always false [-Werror,-Wtautological-constant-out-of-range-compare]
              if (tpm_models[i] == -1) {
                  ~~~~~~~~~~~~~ ^  ~~
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Message-id: 1375096931-13842-1-git-send-email-peter.maydell@linaro.org
      Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
      8cdd2e0a
  12. 23 4月, 2013 1 次提交
  13. 16 4月, 2013 2 次提交
  14. 02 4月, 2013 1 次提交
  15. 26 3月, 2013 1 次提交
  16. 13 3月, 2013 2 次提交
    • S
      Add a TPM Passthrough backend driver implementation · 4549a8b7
      Stefan Berger 提交于
      This patch is based of off version 9 of Stefan Berger's patch series
        "QEMU Trusted Platform Module (TPM) integration"
      and adds a new backend driver for it.
      
      This patch adds a passthrough backend driver for passing commands sent to the
      emulated TPM device directly to a TPM device opened on the host machine.
      Thus it is possible to use a hardware TPM device in a system running on QEMU,
      providing the ability to access a TPM in a special state (e.g. after a Trusted
      Boot).
      
      This functionality is being used in the acTvSM Trusted Virtualization Platform
      which is available on [1].
      
      Usage example:
        qemu-system-x86_64 -tpmdev passthrough,id=tpm0,path=/dev/tpm0 \
                           -device tpm-tis,tpmdev=tpm0 \
                           -cdrom test.iso -boot d
      
      Some notes about the host TPM:
      The TPM needs to be enabled and activated. If that's not the case one
      has to go through the BIOS/UEFI and enable and activate that TPM for TPM
      commands to work as expected.
      It may be necessary to boot the kernel using tpm_tis.force=1 in the boot
      command line or 'modprobe tpm_tis force=1' in case of using it as a module.
      
      Regards,
      Andreas Niederl, Stefan Berger
      
      [1] http://trustedjava.sourceforge.net/Signed-off-by: NAndreas Niederl <andreas.niederl@iaik.tugraz.at>
      Signed-off-by: NStefan Berger <stefanb@linux.vnet.ibm.com>
      Reviewed-by: NCorey Bryant <coreyb@linux.vnet.ibm.com>
      Reviewed-by: NJoel Schopp <jschopp@linux.vnet.ibm.com>
      Message-id: 1361987275-26289-6-git-send-email-stefanb@linux.vnet.ibm.com
      Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
      4549a8b7
    • S
      Support for TPM command line options · d1a0cf73
      Stefan Berger 提交于
      This patch adds support for TPM command line options.
      The command line options supported here are
      
      ./qemu-... -tpmdev passthrough,path=<path to TPM device>,id=<id>
                 -device tpm-tis,tpmdev=<id>,id=<other id>
      
      and
      
      ./qemu-... -tpmdev help
      
      where the latter works similar to -soundhw help and shows a list of
      available TPM backends (for example 'passthrough').
      
      Using the type parameter, the backend is chosen, i.e., 'passthrough' for the
      passthrough driver. The interpretation of the other parameters along
      with determining whether enough parameters were provided is pushed into
      the backend driver, which needs to implement the interface function
      'create' and return a TPMDriverOpts structure if the VM can be started or
      'NULL' if not enough or bad parameters were provided.
      
      Monitor support for 'info tpm' has been added. It for example prints the
      following:
      
      (qemu) info tpm
      TPM devices:
       tpm0: model=tpm-tis
        \ tpm0: type=passthrough,path=/dev/tpm0,cancel-path=/sys/devices/pnp0/00:09/cancel
      Signed-off-by: NStefan Berger <stefanb@linux.vnet.ibm.com>
      Reviewed-by: NCorey Bryant <coreyb@linux.vnet.ibm.com>
      Reviewed-by: NJoel Schopp <jschopp@linux.vnet.ibm.com>
      Message-id: 1361987275-26289-2-git-send-email-stefanb@linux.vnet.ibm.com
      Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
      d1a0cf73