get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 811140,
    "url": "http://patchwork.ozlabs.org/api/patches/811140/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170907201335.13956-4-david@redhat.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": "<20170907201335.13956-4-david@redhat.com>",
    "list_archive_url": null,
    "date": "2017-09-07T20:13:17",
    "name": "[v3,03/21] s390x: get rid of s390-virtio.c",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "9ec2bd7f7ddbcdceaad2e73e5b305da8bc5dbcae",
    "submitter": {
        "id": 70402,
        "url": "http://patchwork.ozlabs.org/api/people/70402/?format=api",
        "name": "David Hildenbrand",
        "email": "david@redhat.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170907201335.13956-4-david@redhat.com/mbox/",
    "series": [
        {
            "id": 2053,
            "url": "http://patchwork.ozlabs.org/api/series/2053/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=2053",
            "date": "2017-09-07T20:13:14",
            "name": "s390x cleanups and CPU hotplug via device_add",
            "version": 3,
            "mbox": "http://patchwork.ozlabs.org/series/2053/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/811140/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/811140/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>)",
            "ext-mx03.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com",
            "ext-mx03.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=david@redhat.com"
        ],
        "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 3xpBWf0xTBz9sBW\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  8 Sep 2017 06:14:54 +1000 (AEST)",
            "from localhost ([::1]:42095 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 1dq3CO-00045i-43\n\tfor incoming@patchwork.ozlabs.org; Thu, 07 Sep 2017 16:14:52 -0400",
            "from eggs.gnu.org ([2001:4830:134:3::10]:38819)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <david@redhat.com>) id 1dq3BV-00041Z-8x\n\tfor qemu-devel@nongnu.org; Thu, 07 Sep 2017 16:14:04 -0400",
            "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <david@redhat.com>) id 1dq3BP-00024k-N0\n\tfor qemu-devel@nongnu.org; Thu, 07 Sep 2017 16:13:57 -0400",
            "from mx1.redhat.com ([209.132.183.28]:60286)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <david@redhat.com>) id 1dq3BP-00024K-Eo\n\tfor qemu-devel@nongnu.org; Thu, 07 Sep 2017 16:13:51 -0400",
            "from smtp.corp.redhat.com\n\t(int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 8F7EC83F45;\n\tThu,  7 Sep 2017 20:13:50 +0000 (UTC)",
            "from t460s.redhat.com (ovpn-116-60.ams2.redhat.com [10.36.116.60])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 430C958842;\n\tThu,  7 Sep 2017 20:13:48 +0000 (UTC)"
        ],
        "DMARC-Filter": "OpenDMARC Filter v1.3.2 mx1.redhat.com 8F7EC83F45",
        "From": "David Hildenbrand <david@redhat.com>",
        "To": "qemu-devel@nongnu.org",
        "Date": "Thu,  7 Sep 2017 22:13:17 +0200",
        "Message-Id": "<20170907201335.13956-4-david@redhat.com>",
        "In-Reply-To": "<20170907201335.13956-1-david@redhat.com>",
        "References": "<20170907201335.13956-1-david@redhat.com>",
        "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.16",
        "X-Greylist": "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.27]);\n\tThu, 07 Sep 2017 20:13:50 +0000 (UTC)",
        "X-detected-operating-system": "by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]",
        "X-Received-From": "209.132.183.28",
        "Subject": "[Qemu-devel] [PATCH v3 03/21] s390x: get rid of s390-virtio.c",
        "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": "Matthew Rosato <mjrosato@linux.vnet.ibm.com>, thuth@redhat.com,\n\tEduardo Habkost <ehabkost@redhat.com>, david@redhat.com,\n\tcohuck@redhat.com, Richard Henderson <richard.henderson@linaro.org>,\n\tAlexander Graf <agraf@suse.de>, borntraeger@de.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": "It is a leftover from the days where we had still the !ccw virtio\nmachine. As this one is long gone, let's move everything to\ns390-virtio-ccw.c.\n\nSuggested-by: Cornelia Huck <cohuck@redhat.com>\nReviewed-by: Thomas Huth <thuth@redhat.com>\nAcked-by: Christian Borntraeger <borntraeger@de.ibm.com>\nSigned-off-by: David Hildenbrand <david@redhat.com>\n---\n hw/s390x/Makefile.objs     |   1 -\n hw/s390x/s390-virtio-ccw.c | 157 ++++++++++++++++++++++++++++++++++++++++++++-\n hw/s390x/s390-virtio.c     |  37 -----------\n hw/s390x/s390-virtio.h     |  15 -----\n 4 files changed, 156 insertions(+), 54 deletions(-)",
    "diff": "diff --git a/hw/s390x/Makefile.objs b/hw/s390x/Makefile.objs\nindex 7ee19d3abc..dc704b57d6 100644\n--- a/hw/s390x/Makefile.objs\n+++ b/hw/s390x/Makefile.objs\n@@ -1,4 +1,3 @@\n-obj-y += s390-virtio.o\n obj-y += s390-virtio-hcall.o\n obj-y += sclp.o\n obj-y += event-facility.o\ndiff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c\nindex dd504dd5ae..4c3a3e177b 100644\n--- a/hw/s390x/s390-virtio-ccw.c\n+++ b/hw/s390x/s390-virtio-ccw.c\n@@ -2,6 +2,7 @@\n  * virtio ccw machine\n  *\n  * Copyright 2012 IBM Corp.\n+ * Copyright (c) 2009 Alexander Graf <agraf@suse.de>\n  * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>\n  *\n  * This work is licensed under the terms of the GNU GPL, version 2 or (at\n@@ -31,6 +32,46 @@\n #include \"hw/s390x/css-bridge.h\"\n #include \"migration/register.h\"\n #include \"cpu_models.h\"\n+#include \"qapi/qmp/qerror.h\"\n+#include \"hw/nmi.h\"\n+\n+static S390CPU **cpu_states;\n+\n+S390CPU *s390_cpu_addr2state(uint16_t cpu_addr)\n+{\n+    if (cpu_addr >= max_cpus) {\n+        return NULL;\n+    }\n+\n+    /* Fast lookup via CPU ID */\n+    return cpu_states[cpu_addr];\n+}\n+\n+static void s390_init_cpus(MachineState *machine)\n+{\n+    int i;\n+    gchar *name;\n+\n+    if (machine->cpu_model == NULL) {\n+        machine->cpu_model = s390_default_cpu_model_name();\n+    }\n+\n+    cpu_states = g_new0(S390CPU *, max_cpus);\n+\n+    for (i = 0; i < max_cpus; i++) {\n+        name = g_strdup_printf(\"cpu[%i]\", i);\n+        object_property_add_link(OBJECT(machine), name, TYPE_S390_CPU,\n+                                 (Object **) &cpu_states[i],\n+                                 object_property_allow_set_link,\n+                                 OBJ_PROP_LINK_UNREF_ON_RELEASE,\n+                                 &error_abort);\n+        g_free(name);\n+    }\n+\n+    for (i = 0; i < smp_cpus; i++) {\n+        s390x_new_cpu(machine->cpu_model, i, &error_fatal);\n+    }\n+}\n \n static const char *const reset_dev_types[] = {\n     TYPE_VIRTUAL_CSS_BRIDGE,\n@@ -94,7 +135,7 @@ static void virtio_ccw_register_hcalls(void)\n                                    virtio_ccw_hcall_early_printk);\n }\n \n-void s390_memory_init(ram_addr_t mem_size)\n+static void s390_memory_init(ram_addr_t mem_size)\n {\n     MemoryRegion *sysmem = get_system_memory();\n     MemoryRegion *ram = g_new(MemoryRegion, 1);\n@@ -109,11 +150,103 @@ void s390_memory_init(ram_addr_t mem_size)\n     s390_stattrib_init();\n }\n \n+#define S390_TOD_CLOCK_VALUE_MISSING    0x00\n+#define S390_TOD_CLOCK_VALUE_PRESENT    0x01\n+\n+static void gtod_save(QEMUFile *f, void *opaque)\n+{\n+    uint64_t tod_low;\n+    uint8_t tod_high;\n+    int r;\n+\n+    r = s390_get_clock(&tod_high, &tod_low);\n+    if (r) {\n+        fprintf(stderr, \"WARNING: Unable to get guest clock for migration. \"\n+                        \"Error code %d. Guest clock will not be migrated \"\n+                        \"which could cause the guest to hang.\\n\", r);\n+        qemu_put_byte(f, S390_TOD_CLOCK_VALUE_MISSING);\n+        return;\n+    }\n+\n+    qemu_put_byte(f, S390_TOD_CLOCK_VALUE_PRESENT);\n+    qemu_put_byte(f, tod_high);\n+    qemu_put_be64(f, tod_low);\n+}\n+\n+static int gtod_load(QEMUFile *f, void *opaque, int version_id)\n+{\n+    uint64_t tod_low;\n+    uint8_t tod_high;\n+    int r;\n+\n+    if (qemu_get_byte(f) == S390_TOD_CLOCK_VALUE_MISSING) {\n+        fprintf(stderr, \"WARNING: Guest clock was not migrated. This could \"\n+                        \"cause the guest to hang.\\n\");\n+        return 0;\n+    }\n+\n+    tod_high = qemu_get_byte(f);\n+    tod_low = qemu_get_be64(f);\n+\n+    r = s390_set_clock(&tod_high, &tod_low);\n+    if (r) {\n+        fprintf(stderr, \"WARNING: Unable to set guest clock value. \"\n+                        \"s390_get_clock returned error %d. This could cause \"\n+                        \"the guest to hang.\\n\", r);\n+    }\n+\n+    return 0;\n+}\n+\n static SaveVMHandlers savevm_gtod = {\n     .save_state = gtod_save,\n     .load_state = gtod_load,\n };\n \n+static void s390_init_ipl_dev(const char *kernel_filename,\n+                              const char *kernel_cmdline,\n+                              const char *initrd_filename, const char *firmware,\n+                              const char *netboot_fw, bool enforce_bios)\n+{\n+    Object *new = object_new(TYPE_S390_IPL);\n+    DeviceState *dev = DEVICE(new);\n+\n+    if (kernel_filename) {\n+        qdev_prop_set_string(dev, \"kernel\", kernel_filename);\n+    }\n+    if (initrd_filename) {\n+        qdev_prop_set_string(dev, \"initrd\", initrd_filename);\n+    }\n+    qdev_prop_set_string(dev, \"cmdline\", kernel_cmdline);\n+    qdev_prop_set_string(dev, \"firmware\", firmware);\n+    qdev_prop_set_string(dev, \"netboot_fw\", netboot_fw);\n+    qdev_prop_set_bit(dev, \"enforce_bios\", enforce_bios);\n+    object_property_add_child(qdev_get_machine(), TYPE_S390_IPL,\n+                              new, NULL);\n+    object_unref(new);\n+    qdev_init_nofail(dev);\n+}\n+\n+static void s390_create_virtio_net(BusState *bus, const char *name)\n+{\n+    int i;\n+\n+    for (i = 0; i < nb_nics; i++) {\n+        NICInfo *nd = &nd_table[i];\n+        DeviceState *dev;\n+\n+        if (!nd->model) {\n+            nd->model = g_strdup(\"virtio\");\n+        }\n+\n+        qemu_check_nic_model(nd, \"virtio\");\n+\n+        dev = qdev_create(bus, name);\n+        qdev_set_nic_properties(dev, nd);\n+        qdev_init_nofail(dev);\n+    }\n+}\n+\n static void ccw_init(MachineState *machine)\n {\n     int ret;\n@@ -177,6 +310,19 @@ static void s390_cpu_plug(HotplugHandler *hotplug_dev,\n     g_free(name);\n }\n \n+static void s390_machine_reset(void)\n+{\n+    S390CPU *ipl_cpu = S390_CPU(qemu_get_cpu(0));\n+\n+    s390_cmma_reset();\n+    qemu_devices_reset();\n+    s390_crypto_reset();\n+\n+    /* all cpus are stopped - configure and start the ipl cpu only */\n+    s390_ipl_prepare_cpu(ipl_cpu);\n+    s390_cpu_set_state(CPU_STATE_OPERATING, ipl_cpu);\n+}\n+\n static void s390_machine_device_plug(HotplugHandler *hotplug_dev,\n                                      DeviceState *dev, Error **errp)\n {\n@@ -201,6 +347,15 @@ static void s390_hot_add_cpu(const int64_t id, Error **errp)\n     s390x_new_cpu(machine->cpu_model, id, errp);\n }\n \n+static void s390_nmi(NMIState *n, int cpu_index, Error **errp)\n+{\n+    CPUState *cs = qemu_get_cpu(cpu_index);\n+\n+    if (s390_cpu_restart(S390_CPU(cs))) {\n+        error_setg(errp, QERR_UNSUPPORTED);\n+    }\n+}\n+\n static void ccw_machine_class_init(ObjectClass *oc, void *data)\n {\n     MachineClass *mc = MACHINE_CLASS(oc);\ndiff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c\nindex da3f49e80e..9316be1cfc 100644\n--- a/hw/s390x/s390-virtio.c\n+++ b/hw/s390x/s390-virtio.c\n@@ -48,17 +48,6 @@\n #define S390_TOD_CLOCK_VALUE_MISSING    0x00\n #define S390_TOD_CLOCK_VALUE_PRESENT    0x01\n \n-static S390CPU **cpu_states;\n-\n-S390CPU *s390_cpu_addr2state(uint16_t cpu_addr)\n-{\n-    if (cpu_addr >= max_cpus) {\n-        return NULL;\n-    }\n-\n-    /* Fast lookup via CPU ID */\n-    return cpu_states[cpu_addr];\n-}\n \n void s390_init_ipl_dev(const char *kernel_filename,\n                        const char *kernel_cmdline,\n@@ -86,32 +75,6 @@ void s390_init_ipl_dev(const char *kernel_filename,\n     qdev_init_nofail(dev);\n }\n \n-void s390_init_cpus(MachineState *machine)\n-{\n-    int i;\n-    gchar *name;\n-\n-    if (machine->cpu_model == NULL) {\n-        machine->cpu_model = s390_default_cpu_model_name();\n-    }\n-\n-    cpu_states = g_new0(S390CPU *, max_cpus);\n-\n-    for (i = 0; i < max_cpus; i++) {\n-        name = g_strdup_printf(\"cpu[%i]\", i);\n-        object_property_add_link(OBJECT(machine), name, TYPE_S390_CPU,\n-                                 (Object **) &cpu_states[i],\n-                                 object_property_allow_set_link,\n-                                 OBJ_PROP_LINK_UNREF_ON_RELEASE,\n-                                 &error_abort);\n-        g_free(name);\n-    }\n-\n-    for (i = 0; i < smp_cpus; i++) {\n-        s390x_new_cpu(machine->cpu_model, i, &error_fatal);\n-    }\n-}\n-\n \n void s390_create_virtio_net(BusState *bus, const char *name)\n {\ndiff --git a/hw/s390x/s390-virtio.h b/hw/s390x/s390-virtio.h\nindex ca97fd6814..d984cd4115 100644\n--- a/hw/s390x/s390-virtio.h\n+++ b/hw/s390x/s390-virtio.h\n@@ -12,24 +12,9 @@\n #ifndef HW_S390_VIRTIO_H\n #define HW_S390_VIRTIO_H\n \n-#include \"hw/nmi.h\"\n #include \"standard-headers/asm-s390/kvm_virtio.h\"\n #include \"standard-headers/asm-s390/virtio-ccw.h\"\n \n typedef int (*s390_virtio_fn)(const uint64_t *args);\n void s390_register_virtio_hypercall(uint64_t code, s390_virtio_fn fn);\n-\n-void s390_init_cpus(MachineState *machine);\n-void s390_init_ipl_dev(const char *kernel_filename,\n-                       const char *kernel_cmdline,\n-                       const char *initrd_filename,\n-                       const char *firmware,\n-                       const char *netboot_fw,\n-                       bool enforce_bios);\n-void s390_create_virtio_net(BusState *bus, const char *name);\n-void s390_nmi(NMIState *n, int cpu_index, Error **errp);\n-void s390_machine_reset(void);\n-void s390_memory_init(ram_addr_t mem_size);\n-void gtod_save(QEMUFile *f, void *opaque);\n-int gtod_load(QEMUFile *f, void *opaque, int version_id);\n #endif\n",
    "prefixes": [
        "v3",
        "03/21"
    ]
}