From patchwork Thu Jan 30 14:47:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcel Apfelbaum X-Patchwork-Id: 315376 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B3F282C00D2 for ; Fri, 31 Jan 2014 01:48:14 +1100 (EST) Received: from localhost ([::1]:50594 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8sua-0005mG-LT for incoming@patchwork.ozlabs.org; Thu, 30 Jan 2014 09:48:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38674) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8su4-00052T-3N for qemu-devel@nongnu.org; Thu, 30 Jan 2014 09:47:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8stx-0004x8-Ux for qemu-devel@nongnu.org; Thu, 30 Jan 2014 09:47:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60904) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8stx-0004x1-ML for qemu-devel@nongnu.org; Thu, 30 Jan 2014 09:47:33 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0UElRLt014297 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 30 Jan 2014 09:47:28 -0500 Received: from localhost.localdomain.com (vpn-201-167.tlv.redhat.com [10.35.201.167]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s0UElKUb015983; Thu, 30 Jan 2014 09:47:25 -0500 From: Marcel Apfelbaum To: qemu-devel@nongnu.org Date: Thu, 30 Jan 2014 16:47:21 +0200 Message-Id: <1391093245-14277-2-git-send-email-marcel.a@redhat.com> In-Reply-To: <1391093245-14277-1-git-send-email-marcel.a@redhat.com> References: <1391093245-14277-1-git-send-email-marcel.a@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: peter.maydell@linaro.org, mst@redhat.com, armbru@redhat.com, lcapitulino@redhat.com, blauwirbel@gmail.com, aliguori@amazon.com, pbonzini@redhat.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH RFC 1/5] hw/core: introduced qemu machine as QOM object X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The main functionality change is to convert QEMUMachine into QemuMachineClass and QEMUMachineInitArgs into QemuMachineState, instance of QemuMachineClass. As a first step, in order to make possible an incremental developement, both QEMUMachine and QEMUMachineInitArgs are being embeded into the new types. Signed-off-by: Marcel Apfelbaum --- hw/core/Makefile.objs | 2 +- hw/core/machine.c | 38 ++++++++++++++++++++++++++++++++++++++ include/hw/boards.h | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 hw/core/machine.c diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs index 950146c..aabd1ef 100644 --- a/hw/core/Makefile.objs +++ b/hw/core/Makefile.objs @@ -10,4 +10,4 @@ common-obj-$(CONFIG_SOFTMMU) += sysbus.o common-obj-$(CONFIG_SOFTMMU) += null-machine.o common-obj-$(CONFIG_SOFTMMU) += loader.o common-obj-$(CONFIG_SOFTMMU) += qdev-properties-system.o - +common-obj-$(CONFIG_SOFTMMU) += machine.o diff --git a/hw/core/machine.c b/hw/core/machine.c new file mode 100644 index 0000000..2c6e1a3 --- /dev/null +++ b/hw/core/machine.c @@ -0,0 +1,38 @@ +/* + * QEMU Machine + * + * Copyright (C) 2013 Red Hat Inc + * + * Authors: + * Marcel Apfelbaum + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "hw/boards.h" + +static void qemu_machine_initfn(Object *obj) +{ +} + +static void qemu_machine_class_init(ObjectClass *oc, void *data) +{ +} + +static const TypeInfo qemu_machine_info = { + .name = TYPE_QEMU_MACHINE, + .parent = TYPE_OBJECT, + .abstract = true, + .class_size = sizeof(QemuMachineClass), + .class_init = qemu_machine_class_init, + .instance_size = sizeof(QemuMachineState), + .instance_init = qemu_machine_initfn, +}; + +static void register_types(void) +{ + type_register_static(&qemu_machine_info); +} + +type_init(register_types); diff --git a/include/hw/boards.h b/include/hw/boards.h index 2151460..682cd7f 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -5,6 +5,7 @@ #include "sysemu/blockdev.h" #include "hw/qdev.h" +#include "qom/object.h" typedef struct QEMUMachine QEMUMachine; @@ -53,4 +54,39 @@ QEMUMachine *find_default_machine(void); extern QEMUMachine *current_machine; +#define TYPE_QEMU_MACHINE "machine" +#define QEMU_MACHINE(obj) \ + OBJECT_CHECK(QemuMachineState, (obj), TYPE_QEMU_MACHINE) +#define QEMU_MACHINE_GET_CLASS(obj) \ + OBJECT_GET_CLASS(QemuMachineClass, (obj), TYPE_QEMU_MACHINE) +#define QEMU_MACHINE_CLASS(klass) \ + OBJECT_CLASS_CHECK(QemuMachineClass, (klass), TYPE_QEMU_MACHINE) + +typedef struct QemuMachineState QemuMachineState; +typedef struct QemuMachineClass QemuMachineClass; + +/** + * @QemuMachineClass + * + * @parent_class: opaque parent class container + */ +struct QemuMachineClass { + ObjectClass parent_class; + + QEMUMachine *qemu_machine; +}; + +/** + * @QemuMachineState + * + * @parent: opaque parent object container + */ +struct QemuMachineState { + /* private */ + Object parent; + /* public */ + + QEMUMachineInitArgs *init_args; +}; + #endif