Received: from eggs.gnu.org ([2001:4830:134:3::10]:34168) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLxeF-0005U1-O6 for qemu-devel@nongnu.org; Fri, 07 Mar 2014 11:29:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WLxe4-0004K7-6k for qemu-devel@nongnu.org; Fri, 07 Mar 2014 11:29:23 -0500 Received: from e9.ny.us.ibm.com ([32.97.182.139]:34357) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLxe4-0004Jx-3I for qemu-devel@nongnu.org; Fri, 07 Mar 2014 11:29:12 -0500 Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 7 Mar 2014 11:29:11 -0500 Received: from b01cxnp23033.gho.pok.ibm.com (b01cxnp23033.gho.pok.ibm.com [9.57.198.28]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id A4CC738C803B for ; Fri, 7 Mar 2014 11:29:08 -0500 (EST) Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by b01cxnp23033.gho.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s27GT8Jf9503220 for ; Fri, 7 Mar 2014 16:29:08 GMT Received: from d01av04.pok.ibm.com (localhost [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s27GT8b8002348 for ; Fri, 7 Mar 2014 11:29:08 -0500 From: "Jason J. Herne" Date: Fri, 7 Mar 2014 11:29:06 -0500 Message-Id: <1394209746-30824-2-git-send-email-jjherne@us.ibm.com> In-Reply-To: <1394209746-30824-1-git-send-email-jjherne@us.ibm.com> References: <1394209746-30824-1-git-send-email-jjherne@us.ibm.com> Subject: [Qemu-devel] [PATCH 1/1] s390-cpu: qom interface for S390 cpu states array List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: afaerber@suse.de, borntraeger@de.ibm.com, agraf@suse.de, qemu-devel@nongnu.org Cc: "Jason J. Herne" From: "Jason J. Herne" Rename the S390 ipi_states array to cpu_states to better reflect its contents. Create machine/cpu[cpu_addr] links within the qom tree when creating a new cpu. Encapsulate the qom tree linking process and the management of the cpu_states array into helper functions. Signed-off-by: Jason J. Herne --- hw/s390x/s390-virtio.c | 30 ++++++++++++++++++++++++------ target-s390x/cpu.h | 1 + 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c index 9eeda97..82411e7 100644 --- a/hw/s390x/s390-virtio.c +++ b/hw/s390x/s390-virtio.c @@ -52,15 +52,33 @@ #define ZIPL_FILENAME "s390-zipl.rom" static VirtIOS390Bus *s390_bus; -static S390CPU **ipi_states; +static S390CPU **cpu_states; S390CPU *s390_cpu_addr2state(uint16_t cpu_addr) { + gchar *name; + Object *cpu; + if (cpu_addr >= smp_cpus) { return NULL; } - return ipi_states[cpu_addr]; + name = g_strdup_printf("cpu[%i]", cpu_addr); + cpu = object_property_get_link(qdev_get_machine(), name, NULL); + + g_free(name); + return S390_CPU(cpu); +} + +void s390_cpu_set_cpustate(uint16_t cpu_addr, S390CPU *state) +{ + gchar *name; + + cpu_states[cpu_addr] = state; + name = g_strdup_printf("cpu[%i]", cpu_addr); + object_property_add_link(qdev_get_machine(), name, TYPE_S390_CPU, + (Object **) &cpu_states[cpu_addr], NULL); + g_free(name); } static int s390_virtio_hcall_notify(const uint64_t *args) @@ -184,16 +202,16 @@ void s390_init_cpus(const char *cpu_model, uint8_t *storage_keys) cpu_model = "host"; } - ipi_states = g_malloc(sizeof(S390CPU *) * smp_cpus); + cpu_states = g_malloc(sizeof(S390CPU *) * smp_cpus); for (i = 0; i < smp_cpus; i++) { - S390CPU *cpu; + S390CPU* cpu; CPUState *cs; cpu = cpu_s390x_init(cpu_model); - cs = CPU(cpu); + s390_cpu_set_cpustate(i, cpu); - ipi_states[i] = cpu; + cs = CPU(cpu_states[i]); cs->halted = 1; cpu->env.exception_index = EXCP_HLT; cpu->env.storage_keys = storage_keys; diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h index 96c2b4a..6ce3b64 100644 --- a/target-s390x/cpu.h +++ b/target-s390x/cpu.h @@ -370,6 +370,7 @@ static inline void kvm_s390_interrupt_internal(S390CPU *cpu, int type, } #endif S390CPU *s390_cpu_addr2state(uint16_t cpu_addr); +void s390_cpu_set_cpustate(uint16_t cpu_addr, S390CPU *state); void s390_add_running_cpu(S390CPU *cpu); unsigned s390_del_running_cpu(S390CPU *cpu); -- 1.8.3.2