get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 819453,
    "url": "http://patchwork.ozlabs.org/api/patches/819453/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/1506590409-28857-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": "<1506590409-28857-6-git-send-email-amarnath.valluri@intel.com>",
    "list_archive_url": null,
    "date": "2017-09-28T09:20:06",
    "name": "[v9,5/8] tmp backend: Add new api to read backend TpmInfo",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "96e9ca62d1a1d6a68977068912ab8348cd447c1a",
    "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/1506590409-28857-6-git-send-email-amarnath.valluri@intel.com/mbox/",
    "series": [
        {
            "id": 5516,
            "url": "http://patchwork.ozlabs.org/api/series/5516/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=5516",
            "date": "2017-09-28T09:20:02",
            "name": "Provide support for the software TPM",
            "version": 9,
            "mbox": "http://patchwork.ozlabs.org/series/5516/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/819453/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/819453/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 3y2q2Y0Z48z9t2c\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 28 Sep 2017 19:21:57 +1000 (AEST)",
            "from localhost ([::1]:58105 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 1dxV11-0002a4-3e\n\tfor incoming@patchwork.ozlabs.org; Thu, 28 Sep 2017 05:21:55 -0400",
            "from eggs.gnu.org ([2001:4830:134:3::10]:59219)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <amarnath.valluri@intel.com>) id 1dxUyL-0000sW-P7\n\tfor qemu-devel@nongnu.org; Thu, 28 Sep 2017 05:19:11 -0400",
            "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <amarnath.valluri@intel.com>) id 1dxUyI-0000q4-Gg\n\tfor qemu-devel@nongnu.org; Thu, 28 Sep 2017 05:19:09 -0400",
            "from mga11.intel.com ([192.55.52.93]:13925)\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 1dxUyI-0000bz-5R\n\tfor qemu-devel@nongnu.org; Thu, 28 Sep 2017 05:19:06 -0400",
            "from orsmga005.jf.intel.com ([10.7.209.41])\n\tby fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t28 Sep 2017 02:19:05 -0700",
            "from avallurigigabyte.fi.intel.com ([10.237.68.147])\n\tby orsmga005.jf.intel.com with ESMTP; 28 Sep 2017 02:19:04 -0700"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.42,449,1500966000\"; d=\"scan'208\";a=\"154306594\"",
        "From": "Amarnath Valluri <amarnath.valluri@intel.com>",
        "To": "qemu-devel@nongnu.org",
        "Date": "Thu, 28 Sep 2017 12:20:06 +0300",
        "Message-Id": "<1506590409-28857-6-git-send-email-amarnath.valluri@intel.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1506590409-28857-1-git-send-email-amarnath.valluri@intel.com>",
        "References": "<1506590409-28857-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": "192.55.52.93",
        "Subject": "[Qemu-devel] [PATCH v9 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\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               | 15 +++++++++++--\n hw/tpm/tpm_passthrough.c     | 51 +++++++++++++++++++++++++++-----------------\n include/sysemu/tpm_backend.h | 15 +++++++++++--\n tpm.c                        | 32 +--------------------------\n 4 files changed, 59 insertions(+), 54 deletions(-)",
    "diff": "diff --git a/backends/tpm.c b/backends/tpm.c\nindex 8911597..de313c9 100644\n--- a/backends/tpm.c\n+++ b/backends/tpm.c\n@@ -142,6 +142,19 @@ TPMVersion tpm_backend_get_tpm_version(TPMBackend *s)\n     return k->ops->get_tpm_version(s);\n }\n \n+TPMInfo *tpm_backend_query_tpm(TPMBackend *s)\n+{\n+    TPMInfo *info = g_new0(TPMInfo, 1);\n+    TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);\n+\n+    info->id = g_strdup(s->id);\n+    info->model = s->fe_model;\n+    info->options = k->ops->get_tpm_options ?\n+                    k->ops->get_tpm_options(s) : NULL;\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@@ -196,8 +209,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/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c\nindex 4c21e52..84fc49a 100644\n--- a/hw/tpm/tpm_passthrough.c\n+++ b/hw/tpm/tpm_passthrough.c\n@@ -30,6 +30,7 @@\n #include \"tpm_int.h\"\n #include \"hw/hw.h\"\n #include \"hw/i386/pc.h\"\n+#include \"qapi/clone-visitor.h\"\n #include \"tpm_tis.h\"\n #include \"tpm_util.h\"\n \n@@ -49,7 +50,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@@ -296,15 +298,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@@ -319,7 +320,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@@ -339,17 +340,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@@ -370,10 +372,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@@ -391,7 +391,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@@ -404,6 +404,17 @@ err_exit:\n     return NULL;\n }\n \n+static TpmTypeOptions *tpm_passthrough_get_tpm_options(TPMBackend *tb)\n+{\n+    TpmTypeOptions *options = g_new0(TpmTypeOptions, 1);\n+\n+    options->type = TPM_TYPE_OPTIONS_KIND_PASSTHROUGH;\n+    options->u.passthrough.data = QAPI_CLONE(TPMPassthroughOptions,\n+                                             TPM_PASSTHROUGH(tb)->options);\n+\n+    return options;\n+}\n+\n static const QemuOptDesc tpm_passthrough_cmdline_opts[] = {\n     TPM_STANDARD_CMDLINE_OPTS,\n     {\n@@ -430,12 +441,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@@ -448,7 +461,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 9ea7072..e96c191 100644\n--- a/include/sysemu/tpm_backend.h\n+++ b/include/sysemu/tpm_backend.h\n@@ -49,10 +49,9 @@ struct TPMBackend {\n     TPMRecvDataCB *recv_data_callback;\n     bool had_startup_error;\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@@ -96,6 +95,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@@ -214,6 +215,16 @@ void tpm_backend_open(TPMBackend *s, Error **errp);\n  */\n TPMVersion tpm_backend_get_tpm_version(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": [
        "v9",
        "5/8"
    ]
}