On 9/27/23 12:49, James Bottomley wrote:
From: James Bottomley <james.bottom...@hansenpartnership.com>

Instead of processing the tpmdev options using the old qemu options,
convert to the new visitor format which also allows the passing of
json on the command line.

Signed-off-by: James Bottomley <j...@linux.ibm.com>

---
v4: add TpmConfiOptions
v5: exit(0) for help
v7: adjust line lengths, free options
---
  backends/tpm/tpm_emulator.c    | 25 ++++------
  backends/tpm/tpm_passthrough.c | 23 +++------
  include/sysemu/tpm.h           |  4 +-
  include/sysemu/tpm_backend.h   |  2 +-
  qapi/tpm.json                  | 19 +++++++
  softmmu/tpm.c                  | 91 ++++++++++++++--------------------
  softmmu/vl.c                   | 19 +------
  7 files changed, 78 insertions(+), 105 deletions(-)

diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c
index 402a2d6312..833520e49a 100644
--- a/backends/tpm/tpm_emulator.c
+++ b/backends/tpm/tpm_emulator.c
@@ -583,33 +583,29 @@ err_exit:
      return -1;
  }
-static int tpm_emulator_handle_device_opts(TPMEmulator *tpm_emu, QemuOpts *opts)
+static int tpm_emulator_handle_device_opts(TPMEmulator *tpm_emu,
+                                           TpmCreateOptions *opts)
  {
-    const char *value;
      Error *err = NULL;
      Chardev *dev;
- value = qemu_opt_get(opts, "chardev");
-    if (!value) {
-        error_report("tpm-emulator: parameter 'chardev' is missing");
-        goto err;
-    }
+    tpm_emu->options = QAPI_CLONE(TPMEmulatorOptions, &opts->u.emulator);
+    tpm_emu->data_ioc = NULL;
- dev = qemu_chr_find(value);
+    dev = qemu_chr_find(opts->u.emulator.chardev);
      if (!dev) {
-        error_report("tpm-emulator: tpm chardev '%s' not found", value);
+        error_report("tpm-emulator: tpm chardev '%s' not found",
+                opts->u.emulator.chardev);

still, indentation.


--- a/qapi/tpm.json
+++ b/qapi/tpm.json
@@ -138,6 +138,25 @@
              'emulator': 'TPMEmulatorOptionsWrapper' },
    'if': 'CONFIG_TPM' }
+##
+# @TpmCreateOptions:
+#
+# A union referencing different TPM backend types' configuration options
+#   without the wrapper to be usable by visitors.
+#
+# @type: - 'passthrough' The configuration options for the TPM passthrough type
+#        - 'emulator' The configuration options for TPM emulator backend type
+#
+# Since: 7.2
+##'


Should probably be 8.2.


With the above fixed:

Tested-by: Stefan Berger <stef...@linux.ibm.com>

Reviewed-by: Stefan Berger <stef...@linux.ibm.com>



Reply via email to