1. 18 Mar, 2016 1 commit
    • Eric Blake's avatar
      qapi: Don't special-case simple union wrappers · 32bafa8f
      Eric Blake authored
      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: 's avatarEric Blake <eblake@redhat.com>
      Message-Id: <1458254921-17042-13-git-send-email-eblake@redhat.com>
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      32bafa8f
  2. 04 Feb, 2016 1 commit
    • Peter Maydell's avatar
      all: Clean up includes · d38ea87a
      Peter Maydell authored
      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: 's avatarPeter Maydell <peter.maydell@linaro.org>
      Message-id: 1454089805-5470-16-git-send-email-peter.maydell@linaro.org
      d38ea87a
  3. 17 Dec, 2015 1 commit
    • Eric Blake's avatar
      qapi: Don't let implicit enum MAX member collide · 7fb1cf16
      Eric Blake authored
      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: 's avatarEric Blake <eblake@redhat.com>
      Message-Id: <1447836791-369-23-git-send-email-eblake@redhat.com>
      Reviewed-by: 's avatarJuan Quintela <quintela@redhat.com>
      [Rebased to current master, commit message tweaked]
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      7fb1cf16
  4. 02 Nov, 2015 1 commit
    • Eric Blake's avatar
      tpm: Convert to new qapi union layout · ce21131a
      Eric Blake authored
      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: 's avatarEric Blake <eblake@redhat.com>
      Message-Id: <1445898903-12082-22-git-send-email-eblake@redhat.com>
      [Commit message tweaked slightly]
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      ce21131a
  5. 22 Jun, 2015 5 commits
  6. 09 Jun, 2015 1 commit
  7. 08 Jun, 2015 1 commit
    • Markus Armbruster's avatar
      QemuOpts: Drop qemu_opts_foreach() parameter abort_on_failure · a4c7367f
      Markus Armbruster authored
      When the argument is non-zero, qemu_opts_foreach() stops on callback
      returning non-zero, and returns that value.
      
      When the argument is zero, it doesn't stop, and returns the bit-wise
      inclusive or of all the return values.  Funky :)
      
      The callers that pass zero could just as well pass one, because their
      callbacks can't return anything but zero:
      
      * qemu_add_globals()'s callback qdev_add_one_global()
      
      * qemu_config_write()'s callback config_write_opts()
      
      * main()'s callbacks default_driver_check(), drive_enable_snapshot(),
        vnc_init_func()
      
      Drop the parameter, and always stop.
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
      Acked-by: 's avatarKevin Wolf <kwolf@redhat.com>
      a4c7367f
  8. 10 Mar, 2015 1 commit
  9. 18 Feb, 2015 1 commit
  10. 17 Feb, 2014 1 commit
  11. 29 Jul, 2013 1 commit
    • Peter Maydell's avatar
      tpm.c: Don't try to put -1 in a variable of type TpmModel · 8cdd2e0a
      Peter Maydell authored
      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: 's avatarPeter Maydell <peter.maydell@linaro.org>
      Message-id: 1375096931-13842-1-git-send-email-peter.maydell@linaro.org
      Signed-off-by: 's avatarAnthony Liguori <aliguori@us.ibm.com>
      8cdd2e0a
  12. 23 Apr, 2013 1 commit
  13. 15 Apr, 2013 2 commits
  14. 02 Apr, 2013 1 commit
  15. 25 Mar, 2013 1 commit
  16. 12 Mar, 2013 2 commits
    • Stefan Berger's avatar
      Add a TPM Passthrough backend driver implementation · 4549a8b7
      Stefan Berger authored
      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: 's avatarAndreas Niederl <andreas.niederl@iaik.tugraz.at>
      Signed-off-by: 's avatarStefan Berger <stefanb@linux.vnet.ibm.com>
      Reviewed-by: 's avatarCorey Bryant <coreyb@linux.vnet.ibm.com>
      Reviewed-by: 's avatarJoel Schopp <jschopp@linux.vnet.ibm.com>
      Message-id: 1361987275-26289-6-git-send-email-stefanb@linux.vnet.ibm.com
      Signed-off-by: 's avatarAnthony Liguori <aliguori@us.ibm.com>
      4549a8b7
    • Stefan Berger's avatar
      Support for TPM command line options · d1a0cf73
      Stefan Berger authored
      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: 's avatarStefan Berger <stefanb@linux.vnet.ibm.com>
      Reviewed-by: 's avatarCorey Bryant <coreyb@linux.vnet.ibm.com>
      Reviewed-by: 's avatarJoel Schopp <jschopp@linux.vnet.ibm.com>
      Message-id: 1361987275-26289-2-git-send-email-stefanb@linux.vnet.ibm.com
      Signed-off-by: 's avatarAnthony Liguori <aliguori@us.ibm.com>
      d1a0cf73