{"id":807820,"url":"http://patchwork.ozlabs.org/api/1.0/patches/807820/?format=json","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.0/projects/14/?format=json","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":""},"msgid":"<20170830170601.15855-4-david@redhat.com>","date":"2017-08-30T17:05:53","name":"[v1,03/11] s390x: store cpu states inside machine state","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"57ad84ce0235b79a1794f5f7c958c7ced1f4714b","submitter":{"id":70402,"url":"http://patchwork.ozlabs.org/api/1.0/people/70402/?format=json","name":"David Hildenbrand","email":"david@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20170830170601.15855-4-david@redhat.com/mbox/","series":[{"id":666,"url":"http://patchwork.ozlabs.org/api/1.0/series/666/?format=json","date":"2017-08-30T17:06:00","name":"next round of s390x cleanups","version":1,"mbox":"http://patchwork.ozlabs.org/series/666/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/807820/checks/","tags":{},"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-mx07.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx07.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 3xjChm0MsHz9sN7\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 31 Aug 2017 03:50:32 +1000 (AEST)","from localhost ([::1]:51915 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 1dn78H-00042Q-RS\n\tfor incoming@patchwork.ozlabs.org; Wed, 30 Aug 2017 13:50:29 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:33354)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <david@redhat.com>) id 1dn6Rd-0005dC-Pr\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 13:06:27 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <david@redhat.com>) id 1dn6RZ-0002Jm-PZ\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 13:06:25 -0400","from mx1.redhat.com ([209.132.183.28]:41654)\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 1dn6RZ-0002JT-Gx\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 13:06:21 -0400","from smtp.corp.redhat.com\n\t(int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12])\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 839E8C047B64;\n\tWed, 30 Aug 2017 17:06:20 +0000 (UTC)","from t460s.redhat.com (ovpn-116-98.ams2.redhat.com [10.36.116.98])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 292869B51A;\n\tWed, 30 Aug 2017 17:06:09 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 839E8C047B64","From":"David Hildenbrand <david@redhat.com>","To":"qemu-devel@nongnu.org","Date":"Wed, 30 Aug 2017 19:05:53 +0200","Message-Id":"<20170830170601.15855-4-david@redhat.com>","In-Reply-To":"<20170830170601.15855-1-david@redhat.com>","References":"<20170830170601.15855-1-david@redhat.com>","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.12","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.31]);\n\tWed, 30 Aug 2017 17:06:20 +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 v1 03/11] s390x: store cpu states inside\n\tmachine state","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":"thuth@redhat.com, david@redhat.com, cohuck@redhat.com,\n\tRichard Henderson <richard.henderson@linaro.org>,\n\tAlexander Graf <agraf@suse.de>, borntraeger@de.ibm.com,\n\tAurelien Jarno <aurelien@aurel32.net>","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":"Let's avoid global variables. While at it, move both functions using it,\nso we won't have to temporarily add includes (we'll be getting rid of\ns390-virtio.c soon).\n\nSigned-off-by: David Hildenbrand <david@redhat.com>\n---\n hw/s390x/s390-virtio-ccw.c         | 39 ++++++++++++++++++++++++++++++++++++++\n hw/s390x/s390-virtio.c             | 38 -------------------------------------\n hw/s390x/s390-virtio.h             |  1 -\n include/hw/s390x/s390-virtio-ccw.h |  3 +++\n 4 files changed, 42 insertions(+), 39 deletions(-)","diff":"diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c\nindex dd504dd5ae..ffd56af834 100644\n--- a/hw/s390x/s390-virtio-ccw.c\n+++ b/hw/s390x/s390-virtio-ccw.c\n@@ -32,6 +32,45 @@\n #include \"migration/register.h\"\n #include \"cpu_models.h\"\n \n+S390CPU *s390_cpu_addr2state(uint16_t cpu_addr)\n+{\n+    S390CcwMachineState *ms = S390_CCW_MACHINE(qdev_get_machine());\n+\n+    if (cpu_addr >= max_cpus) {\n+        return NULL;\n+    }\n+\n+    /* Fast lookup via CPU ID */\n+    return ms->cpus[cpu_addr];\n+}\n+\n+static void s390_init_cpus(MachineState *machine)\n+{\n+    S390CcwMachineState *ms = S390_CCW_MACHINE(machine);\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+    ms->cpus = 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 **) &ms->cpus[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     \"s390-sclp-event-facility\",\ndiff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c\nindex da3f49e80e..464b5c71f8 100644\n--- a/hw/s390x/s390-virtio.c\n+++ b/hw/s390x/s390-virtio.c\n@@ -48,18 +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                        const char *initrd_filename,\n@@ -86,32 +74,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..b6660e3ae9 100644\n--- a/hw/s390x/s390-virtio.h\n+++ b/hw/s390x/s390-virtio.h\n@@ -19,7 +19,6 @@\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,\ndiff --git a/include/hw/s390x/s390-virtio-ccw.h b/include/hw/s390x/s390-virtio-ccw.h\nindex 41a9d2862b..4bef28ec39 100644\n--- a/include/hw/s390x/s390-virtio-ccw.h\n+++ b/include/hw/s390x/s390-virtio-ccw.h\n@@ -21,11 +21,14 @@\n #define S390_MACHINE_CLASS(klass) \\\n     OBJECT_CLASS_CHECK(S390CcwMachineClass, (klass), TYPE_S390_CCW_MACHINE)\n \n+struct S390CPU;\n+\n typedef struct S390CcwMachineState {\n     /*< private >*/\n     MachineState parent_obj;\n \n     /*< public >*/\n+    S390CPU **cpus;\n     bool aes_key_wrap;\n     bool dea_key_wrap;\n     uint8_t loadparm[8];\n","prefixes":["v1","03/11"]}