get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/817490/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 817490,
    "url": "http://patchwork.ozlabs.org/api/patches/817490/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/1506083624-20621-6-git-send-email-amarnath.valluri@intel.com/",
    "project": {
        "id": 14,
        "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api",
        "name": "QEMU Development",
        "link_name": "qemu-devel",
        "list_id": "qemu-devel.nongnu.org",
        "list_email": "qemu-devel@nongnu.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<1506083624-20621-6-git-send-email-amarnath.valluri@intel.com>",
    "list_archive_url": null,
    "date": "2017-09-22T12:33:41",
    "name": "[v7,5/8] tmp backend: Add new api to read backend TpmInfo",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "983c1debbc0200bffb7ce25830dc314babce0f0b",
    "submitter": {
        "id": 71320,
        "url": "http://patchwork.ozlabs.org/api/people/71320/?format=api",
        "name": "Valluri, Amarnath",
        "email": "amarnath.valluri@intel.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/1506083624-20621-6-git-send-email-amarnath.valluri@intel.com/mbox/",
    "series": [
        {
            "id": 4614,
            "url": "http://patchwork.ozlabs.org/api/series/4614/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=4614",
            "date": "2017-09-22T12:33:37",
            "name": "Provide support for the software TPM emulator",
            "version": 7,
            "mbox": "http://patchwork.ozlabs.org/series/4614/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/817490/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/817490/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org",
        "Authentication-Results": "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)",
        "Received": [
            "from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xzCr41s9bz9sRW\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 22 Sep 2017 22:45:24 +1000 (AEST)",
            "from localhost ([::1]:58683 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dvNKa-0002Zl-UE\n\tfor incoming@patchwork.ozlabs.org; Fri, 22 Sep 2017 08:45:20 -0400",
            "from eggs.gnu.org ([2001:4830:134:3::10]:56446)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <amarnath.valluri@intel.com>) id 1dvN8c-0000fI-E7\n\tfor qemu-devel@nongnu.org; Fri, 22 Sep 2017 08:33:05 -0400",
            "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <amarnath.valluri@intel.com>) id 1dvN8a-0005vS-L0\n\tfor qemu-devel@nongnu.org; Fri, 22 Sep 2017 08:32:58 -0400",
            "from mga07.intel.com ([134.134.136.100]:27337)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <amarnath.valluri@intel.com>)\n\tid 1dvN8a-0005pe-87\n\tfor qemu-devel@nongnu.org; Fri, 22 Sep 2017 08:32:56 -0400",
            "from fmsmga003.fm.intel.com ([10.253.24.29])\n\tby orsmga105.jf.intel.com with ESMTP; 22 Sep 2017 05:32:55 -0700",
            "from avallurigigabyte.fi.intel.com ([10.237.68.147])\n\tby FMSMGA003.fm.intel.com with ESMTP; 22 Sep 2017 05:32:54 -0700"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.42,427,1500966000\"; d=\"scan'208\";a=\"902897866\"",
        "From": "Amarnath Valluri <amarnath.valluri@intel.com>",
        "To": "qemu-devel@nongnu.org",
        "Date": "Fri, 22 Sep 2017 15:33:41 +0300",
        "Message-Id": "<1506083624-20621-6-git-send-email-amarnath.valluri@intel.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1506083624-20621-1-git-send-email-amarnath.valluri@intel.com>",
        "References": "<1506083624-20621-1-git-send-email-amarnath.valluri@intel.com>",
        "X-detected-operating-system": "by eggs.gnu.org: Genre and OS details not\n\trecognized.",
        "X-Received-From": "134.134.136.100",
        "Subject": "[Qemu-devel] [PATCH v7 5/8] tmp backend: Add new api to read\n\tbackend TpmInfo",
        "X-BeenThere": "qemu-devel@nongnu.org",
        "X-Mailman-Version": "2.1.21",
        "Precedence": "list",
        "List-Id": "<qemu-devel.nongnu.org>",
        "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.nongnu.org/archive/html/qemu-devel/>",
        "List-Post": "<mailto:qemu-devel@nongnu.org>",
        "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>",
        "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>",
        "Cc": "Amarnath Valluri <amarnath.valluri@intel.com>, =?utf-8?q?Marc-Andr?=\n\t=?utf-8?b?w6kgTHVyZWF1?= <marcandre.lureau@gmail.com>,\n\t\"Dr. David Alan Gilbert\" <dgilbert@redhat.com>, \n\tStefan Berger <stefanb@linux.vnet.ibm.com>",
        "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org",
        "Sender": "\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"
    },
    "content": "TPM configuration options are backend implementation details and shall not be\npart of base TPMBackend object, and these shall not be accessed directly outside\nof the class, hence added a new interface method, get_tpm_options() to\nTPMDriverOps., which shall be implemented by the derived classes to return\nconfigured tpm options.\n\nA new tpm backend api - tpm_backend_query_tpm() which uses _get_tpm_options() to\nprepare TpmInfo.\n\nSigned-off-by: Amarnath Valluri <amarnath.valluri@intel.com>\nReviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>\n---\n backends/tpm.c               | 22 +++++++++++++--\n hmp.c                        |  7 ++---\n hw/tpm/tpm_passthrough.c     | 64 +++++++++++++++++++++++++++++++-------------\n include/sysemu/tpm_backend.h | 25 +++++++++++++++--\n tpm.c                        | 32 +---------------------\n 5 files changed, 93 insertions(+), 57 deletions(-)",
    "diff": "diff --git a/backends/tpm.c b/backends/tpm.c\nindex c409a46..6ade9e4 100644\n--- a/backends/tpm.c\n+++ b/backends/tpm.c\n@@ -138,6 +138,26 @@ TPMVersion tpm_backend_get_tpm_version(TPMBackend *s)\n     return k->ops->get_tpm_version(s);\n }\n \n+TpmTypeOptions *tpm_backend_get_tpm_options(TPMBackend *s)\n+{\n+    TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);\n+\n+    assert(k->ops->get_tpm_options);\n+\n+    return k->ops->get_tpm_options(s);\n+}\n+\n+TPMInfo *tpm_backend_query_tpm(TPMBackend *s)\n+{\n+    TPMInfo *info = g_new0(TPMInfo, 1);\n+\n+    info->id = g_strdup(s->id);\n+    info->model = s->fe_model;\n+    info->options = tpm_backend_get_tpm_options(s);\n+\n+    return info;\n+}\n+\n static bool tpm_backend_prop_get_opened(Object *obj, Error **errp)\n {\n     TPMBackend *s = TPM_BACKEND(obj);\n@@ -192,8 +212,6 @@ static void tpm_backend_instance_finalize(Object *obj)\n     TPMBackend *s = TPM_BACKEND(obj);\n \n     g_free(s->id);\n-    g_free(s->path);\n-    g_free(s->cancel_path);\n     tpm_backend_thread_end(s);\n }\n \ndiff --git a/hmp.c b/hmp.c\nindex 0fb2bc7..cf62b2e 100644\n--- a/hmp.c\n+++ b/hmp.c\n@@ -31,6 +31,7 @@\n #include \"qapi/qmp/qerror.h\"\n #include \"qapi/string-input-visitor.h\"\n #include \"qapi/string-output-visitor.h\"\n+#include \"qapi/util.h\"\n #include \"qapi-visit.h\"\n #include \"qom/object_interfaces.h\"\n #include \"ui/console.h\"\n@@ -1012,10 +1013,10 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict)\n                        c, TpmModel_str(ti->model));\n \n         monitor_printf(mon, \"  \\\\ %s: type=%s\",\n-                       ti->id, TpmTypeOptionsKind_str(ti->options->type));\n+                       ti->id, TpmType_str(ti->options->type));\n \n         switch (ti->options->type) {\n-        case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH:\n+        case TPM_TYPE_PASSTHROUGH:\n             tpo = ti->options->u.passthrough.data;\n             monitor_printf(mon, \"%s%s%s%s\",\n                            tpo->has_path ? \",path=\" : \"\",\n@@ -1023,7 +1024,7 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict)\n                            tpo->has_cancel_path ? \",cancel-path=\" : \"\",\n                            tpo->has_cancel_path ? tpo->cancel_path : \"\");\n             break;\n-        case TPM_TYPE_OPTIONS_KIND__MAX:\n+        case TPM_TYPE__MAX:\n             break;\n         }\n         monitor_printf(mon, \"\\n\");\ndiff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c\nindex a0459a6..fb7dad8 100644\n--- a/hw/tpm/tpm_passthrough.c\n+++ b/hw/tpm/tpm_passthrough.c\n@@ -49,7 +49,8 @@\n struct TPMPassthruState {\n     TPMBackend parent;\n \n-    char *tpm_dev;\n+    TPMPassthroughOptions *options;\n+    const char *tpm_dev;\n     int tpm_fd;\n     bool tpm_executing;\n     bool tpm_op_canceled;\n@@ -308,15 +309,14 @@ static TPMVersion tpm_passthrough_get_tpm_version(TPMBackend *tb)\n  * in Documentation/ABI/stable/sysfs-class-tpm.\n  * From /dev/tpm0 create /sys/class/misc/tpm0/device/cancel\n  */\n-static int tpm_passthrough_open_sysfs_cancel(TPMBackend *tb)\n+static int tpm_passthrough_open_sysfs_cancel(TPMPassthruState *tpm_pt)\n {\n-    TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb);\n     int fd = -1;\n     char *dev;\n     char path[PATH_MAX];\n \n-    if (tb->cancel_path) {\n-        fd = qemu_open(tb->cancel_path, O_WRONLY);\n+    if (tpm_pt->options->cancel_path) {\n+        fd = qemu_open(tpm_pt->options->cancel_path, O_WRONLY);\n         if (fd < 0) {\n             error_report(\"Could not open TPM cancel path : %s\",\n                          strerror(errno));\n@@ -331,7 +331,7 @@ static int tpm_passthrough_open_sysfs_cancel(TPMBackend *tb)\n                      dev) < sizeof(path)) {\n             fd = qemu_open(path, O_WRONLY);\n             if (fd >= 0) {\n-                tb->cancel_path = g_strdup(path);\n+                tpm_pt->options->cancel_path = g_strdup(path);\n             } else {\n                 error_report(\"tpm_passthrough: Could not open TPM cancel \"\n                              \"path %s : %s\", path, strerror(errno));\n@@ -351,17 +351,18 @@ static int tpm_passthrough_handle_device_opts(QemuOpts *opts, TPMBackend *tb)\n     const char *value;\n \n     value = qemu_opt_get(opts, \"cancel-path\");\n-    tb->cancel_path = g_strdup(value);\n+    if (value) {\n+        tpm_pt->options->cancel_path = g_strdup(value);\n+        tpm_pt->options->has_cancel_path = true;\n+    }\n \n     value = qemu_opt_get(opts, \"path\");\n-    if (!value) {\n-        value = TPM_PASSTHROUGH_DEFAULT_DEVICE;\n+    if (value) {\n+        tpm_pt->options->has_path = true;\n+        tpm_pt->options->path = g_strdup(value);\n     }\n \n-    tpm_pt->tpm_dev = g_strdup(value);\n-\n-    tb->path = g_strdup(tpm_pt->tpm_dev);\n-\n+    tpm_pt->tpm_dev = value ? value : TPM_PASSTHROUGH_DEFAULT_DEVICE;\n     tpm_pt->tpm_fd = qemu_open(tpm_pt->tpm_dev, O_RDWR);\n     if (tpm_pt->tpm_fd < 0) {\n         error_report(\"Cannot access TPM device using '%s': %s\",\n@@ -382,10 +383,8 @@ static int tpm_passthrough_handle_device_opts(QemuOpts *opts, TPMBackend *tb)\n     tpm_pt->tpm_fd = -1;\n \n  err_free_parameters:\n-    g_free(tb->path);\n-    tb->path = NULL;\n-\n-    g_free(tpm_pt->tpm_dev);\n+    qapi_free_TPMPassthroughOptions(tpm_pt->options);\n+    tpm_pt->options = NULL;\n     tpm_pt->tpm_dev = NULL;\n \n     return 1;\n@@ -403,7 +402,7 @@ static TPMBackend *tpm_passthrough_create(QemuOpts *opts, const char *id)\n         goto err_exit;\n     }\n \n-    tpm_pt->cancel_fd = tpm_passthrough_open_sysfs_cancel(tb);\n+    tpm_pt->cancel_fd = tpm_passthrough_open_sysfs_cancel(tpm_pt);\n     if (tpm_pt->cancel_fd < 0) {\n         goto err_exit;\n     }\n@@ -416,6 +415,31 @@ err_exit:\n     return NULL;\n }\n \n+static TpmTypeOptions *tpm_passthrough_get_tpm_options(TPMBackend *tb)\n+{\n+    TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb);\n+    TpmTypeOptions *options = NULL;\n+    TPMPassthroughOptions *poptions = NULL;\n+\n+    poptions = g_new0(TPMPassthroughOptions, 1);\n+\n+    if (tpm_pt->options->has_path) {\n+        poptions->has_path = true;\n+        poptions->path = g_strdup(tpm_pt->options->path);\n+    }\n+\n+    if (tpm_pt->options->has_cancel_path) {\n+        poptions->has_cancel_path = true;\n+        poptions->cancel_path = g_strdup(tpm_pt->options->cancel_path);\n+    }\n+\n+    options = g_new0(TpmTypeOptions, 1);\n+    options->type = TPM_TYPE_PASSTHROUGH;\n+    options->u.passthrough.data = poptions;\n+\n+    return options;\n+}\n+\n static const QemuOptDesc tpm_passthrough_cmdline_opts[] = {\n     TPM_STANDARD_CMDLINE_OPTS,\n     {\n@@ -443,12 +467,14 @@ static const TPMDriverOps tpm_passthrough_driver = {\n     .get_tpm_established_flag = tpm_passthrough_get_tpm_established_flag,\n     .reset_tpm_established_flag = tpm_passthrough_reset_tpm_established_flag,\n     .get_tpm_version          = tpm_passthrough_get_tpm_version,\n+    .get_tpm_options          = tpm_passthrough_get_tpm_options,\n };\n \n static void tpm_passthrough_inst_init(Object *obj)\n {\n     TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(obj);\n \n+    tpm_pt->options = g_new0(TPMPassthroughOptions, 1);\n     tpm_pt->tpm_fd = -1;\n     tpm_pt->cancel_fd = -1;\n }\n@@ -461,7 +487,7 @@ static void tpm_passthrough_inst_finalize(Object *obj)\n \n     qemu_close(tpm_pt->tpm_fd);\n     qemu_close(tpm_pt->cancel_fd);\n-    g_free(tpm_pt->tpm_dev);\n+    qapi_free_TPMPassthroughOptions(tpm_pt->options);\n }\n \n static void tpm_passthrough_class_init(ObjectClass *klass, void *data)\ndiff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h\nindex 13311cf..809eec2 100644\n--- a/include/sysemu/tpm_backend.h\n+++ b/include/sysemu/tpm_backend.h\n@@ -48,10 +48,9 @@ struct TPMBackend {\n     GThreadPool *thread_pool;\n     TPMRecvDataCB *recv_data_callback;\n \n+    /* <public> */\n     char *id;\n     enum TpmModel fe_model;\n-    char *path;\n-    char *cancel_path;\n \n     QLIST_ENTRY(TPMBackend) list;\n };\n@@ -97,6 +96,8 @@ struct TPMDriverOps {\n     int (*reset_tpm_established_flag)(TPMBackend *t, uint8_t locty);\n \n     TPMVersion (*get_tpm_version)(TPMBackend *t);\n+\n+    TpmTypeOptions *(*get_tpm_options)(TPMBackend *t);\n };\n \n \n@@ -215,6 +216,26 @@ void tpm_backend_open(TPMBackend *s, Error **errp);\n  */\n TPMVersion tpm_backend_get_tpm_version(TPMBackend *s);\n \n+/**\n+ * tpm_backend_get_tpm_options:\n+ * @s: the backend\n+ *\n+ * Get the backend configuration options\n+ *\n+ * Returns newly allocated TpmTypeOptions\n+ */\n+TpmTypeOptions *tpm_backend_get_tpm_options(TPMBackend *s);\n+\n+/**\n+ * tpm_backend_query_tpm:\n+ * @s: the backend\n+ *\n+ * Query backend tpm info\n+ *\n+ * Returns newly allocated TPMInfo\n+ */\n+TPMInfo *tpm_backend_query_tpm(TPMBackend *s);\n+\n TPMBackend *qemu_find_tpm(const char *id);\n \n const TPMDriverOps *tpm_get_backend_driver(const char *type);\ndiff --git a/tpm.c b/tpm.c\nindex db14849..3b8c7ed 100644\n--- a/tpm.c\n+++ b/tpm.c\n@@ -202,36 +202,6 @@ static const TPMDriverOps *tpm_driver_find_by_type(enum TpmType type)\n     return be_drivers[type];\n }\n \n-static TPMInfo *qmp_query_tpm_inst(TPMBackend *drv)\n-{\n-    TPMInfo *res = g_new0(TPMInfo, 1);\n-    TPMPassthroughOptions *tpo;\n-\n-    res->id = g_strdup(drv->id);\n-    res->model = drv->fe_model;\n-    res->options = g_new0(TpmTypeOptions, 1);\n-\n-    switch (tpm_backend_get_type(drv)) {\n-    case TPM_TYPE_PASSTHROUGH:\n-        res->options->type = TPM_TYPE_OPTIONS_KIND_PASSTHROUGH;\n-        tpo = g_new0(TPMPassthroughOptions, 1);\n-        res->options->u.passthrough.data = tpo;\n-        if (drv->path) {\n-            tpo->path = g_strdup(drv->path);\n-            tpo->has_path = true;\n-        }\n-        if (drv->cancel_path) {\n-            tpo->cancel_path = g_strdup(drv->cancel_path);\n-            tpo->has_cancel_path = true;\n-        }\n-        break;\n-    case TPM_TYPE__MAX:\n-        break;\n-    }\n-\n-    return res;\n-}\n-\n /*\n  * Walk the list of active TPM backends and collect information about them\n  * following the schema description in qapi-schema.json.\n@@ -246,7 +216,7 @@ TPMInfoList *qmp_query_tpm(Error **errp)\n             continue;\n         }\n         info = g_new0(TPMInfoList, 1);\n-        info->value = qmp_query_tpm_inst(drv);\n+        info->value = tpm_backend_query_tpm(drv);\n \n         if (!cur_item) {\n             head = cur_item = info;\n",
    "prefixes": [
        "v7",
        "5/8"
    ]
}