qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Liu Ping Fan <qemulist@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Blue Swirl" <blauwirbel@gmail.com>,
	"Jan Kiszka" <jan.kiszka@siemens.com>,
	"Andreas Färber" <afaerber@suse.de>,
	"Anthony Liguori" <anthony@codemonkey.ws>
Subject: [Qemu-devel] [PATCH 1/5] qdev: introduce qdev_create_kid(Object *parent, const char *type)
Date: Tue, 10 Jul 2012 14:16:03 +0800	[thread overview]
Message-ID: <1341900967-4344-2-git-send-email-qemulist@gmail.com> (raw)
In-Reply-To: <1341900967-4344-1-git-send-email-qemulist@gmail.com>

DeviceState can be created as kid of DeviceState/CPUState, not neccesary
attached to bus. This will be helpful to simulate the real hardware
submodule which sits inside package.

Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
---
 hw/qdev.c |   28 ++++++++++++++++++++++++++++
 hw/qdev.h |    1 +
 2 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/hw/qdev.c b/hw/qdev.c
index af54467..d2100a1 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -26,6 +26,7 @@
    this API directly.  */
 
 #include "net.h"
+#include "qemu/cpu.h"
 #include "qdev.h"
 #include "sysemu.h"
 #include "error.h"
@@ -145,6 +146,33 @@ DeviceState *qdev_try_create(BusState *bus, const char *type)
     return dev;
 }
 
+DeviceState *qdev_create_kid(Object *parent, const char *type)
+{
+    DeviceState *dev;
+    assert(parent);
+
+    if (object_class_by_name(type) == NULL) {
+        return NULL;
+    }
+
+    if (object_is_type_str(parent, TYPE_BUS)) {
+        return qdev_create(BUS(parent), type);
+    }
+
+    if (!object_is_type_str(parent, TYPE_DEVICE)
+        || !object_is_type_str(parent, TYPE_CPU)) {
+        return NULL;
+    }
+
+    dev = DEVICE(object_new(type));
+    if (!dev) {
+        return NULL;
+    }
+    object_property_add_child(OBJECT(parent), type, OBJECT(dev), NULL);
+
+    return dev;
+}
+
 /* Initialize a device.  Device properties should be set before calling
    this function.  IRQs and MMIO regions should be connected/mapped after
    calling this function.
diff --git a/hw/qdev.h b/hw/qdev.h
index f4683dc..aecc69e 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -154,6 +154,7 @@ typedef struct GlobalProperty {
 
 DeviceState *qdev_create(BusState *bus, const char *name);
 DeviceState *qdev_try_create(BusState *bus, const char *name);
+DeviceState *qdev_create_kid(Object *parent, const char *type);
 bool qdev_exists(const char *name);
 int qdev_device_help(QemuOpts *opts);
 DeviceState *qdev_device_add(QemuOpts *opts);
-- 
1.7.4.4

  reply	other threads:[~2012-07-10  6:16 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-10  6:16 [Qemu-devel] make apic hot-plugable Liu Ping Fan
2012-07-10  6:16 ` Liu Ping Fan [this message]
2012-07-10  8:12   ` [Qemu-devel] [PATCH 1/5] qdev: introduce qdev_create_kid(Object *parent, const char *type) Andreas Färber
2012-07-10  8:45   ` Paolo Bonzini
2012-07-11  1:17     ` liu ping fan
2012-07-11  7:01       ` Paolo Bonzini
2012-07-10  6:16 ` [Qemu-devel] [PATCH 2/5] qom: introduce object_is_type_str(), so we can judge its type Liu Ping Fan
2012-07-10  8:39   ` Paolo Bonzini
2012-07-11  1:17     ` liu ping fan
2012-07-10  6:16 ` [Qemu-devel] [PATCH 3/5] qdev: export the bus reset interface Liu Ping Fan
2012-07-10  8:40   ` Paolo Bonzini
2012-07-10  6:16 ` [Qemu-devel] [PATCH 4/5] qom-cpu: during cpu reset, it will reset its child Liu Ping Fan
2012-07-10  8:41   ` Paolo Bonzini
2012-07-10 10:12     ` Andreas Färber
2012-07-11  1:17       ` liu ping fan
2012-07-11 12:37         ` Igor Mammedov
2012-07-11  1:17     ` liu ping fan
2012-07-11  7:02       ` Paolo Bonzini
2012-07-10  6:16 ` [Qemu-devel] [PATCH 5/5] apic: create apic as a child of cpu, not system_bus any longer Liu Ping Fan
2012-07-10  8:45   ` Paolo Bonzini
2012-07-10 10:41     ` Andreas Färber
2012-07-11  8:41       ` Igor Mammedov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1341900967-4344-2-git-send-email-qemulist@gmail.com \
    --to=qemulist@gmail.com \
    --cc=afaerber@suse.de \
    --cc=anthony@codemonkey.ws \
    --cc=blauwirbel@gmail.com \
    --cc=jan.kiszka@siemens.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).