qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v6 12/27] pcnet: add bootindex to qom property


From: arei.gonglei
Subject: [Qemu-devel] [PATCH v6 12/27] pcnet: add bootindex to qom property
Date: Sat, 30 Aug 2014 18:00:12 +0800

From: Gonglei <address@hidden>

Add a qom property with the same name 'bootindex',
when we remove it form qdev property, things will
continue to work just fine, and we can use qom features
which are not supported by qdev property.

Signed-off-by: Gonglei <address@hidden>
---
 hw/net/lance.c     | 26 ++++++++++++++++++++++++++
 hw/net/pcnet-pci.c | 27 +++++++++++++++++++++++++++
 hw/net/pcnet.c     | 12 ++++++++++++
 hw/net/pcnet.h     |  4 ++++
 4 files changed, 69 insertions(+)

diff --git a/hw/net/lance.c b/hw/net/lance.c
index 3d921b0..3071b3f 100644
--- a/hw/net/lance.c
+++ b/hw/net/lance.c
@@ -145,6 +145,31 @@ static void lance_reset(DeviceState *dev)
     pcnet_common_reset(dev, s);
 }
 
+static void lance_get_bootindex(Object *obj, Visitor *v, void *opaque,
+                                const char *name, Error **errp)
+{
+    SysBusPCNetState *d = SYSBUS_PCNET(obj);
+    PCNetState *s = &d->state;
+
+    pcnet_common_set_bootindex(s, v, name, errp);
+}
+
+static void lance_set_bootindex(Object *obj, Visitor *v, void *opaque,
+                                const char *name, Error **errp)
+{
+    SysBusPCNetState *d = SYSBUS_PCNET(dev);
+    PCNetState *s = &d->state;
+
+    pcnet_common_set_bootindex(s, v, name, errp);
+}
+
+static void lance_instance_init(Object *obj)
+{
+    object_property_add(obj, "bootindex", "int",
+                        lance_get_bootindex,
+                        lance_set_bootindex, NULL, NULL, NULL);
+}
+
 static Property lance_properties[] = {
     DEFINE_PROP_PTR("dma", SysBusPCNetState, state.dma_opaque),
     DEFINE_NIC_PROPERTIES(SysBusPCNetState, state.conf),
@@ -171,6 +196,7 @@ static const TypeInfo lance_info = {
     .parent        = TYPE_SYS_BUS_DEVICE,
     .instance_size = sizeof(SysBusPCNetState),
     .class_init    = lance_class_init,
+    .instance_init = lance_instance_init,
 };
 
 static void lance_register_types(void)
diff --git a/hw/net/pcnet-pci.c b/hw/net/pcnet-pci.c
index e90344e..ca744c8 100644
--- a/hw/net/pcnet-pci.c
+++ b/hw/net/pcnet-pci.c
@@ -33,6 +33,7 @@
 #include "qemu/timer.h"
 #include "sysemu/dma.h"
 
+
 #include "pcnet.h"
 
 //#define PCNET_DEBUG
@@ -347,6 +348,31 @@ static void pci_reset(DeviceState *dev)
     pcnet_common_reset(dev, s);
 }
 
+static void pcnet_get_bootindex(Object *obj, Visitor *v, void *opaque,
+                                const char *name, Error **errp)
+{
+    PCIPCNetState *d = PCI_PCNET(obj);
+    PCNetState *s = &d->state;
+
+    pcnet_common_set_bootindex(s, v, name, errp);
+}
+
+static void pcnet_set_bootindex(Object *obj, Visitor *v, void *opaque,
+                                const char *name, Error **errp)
+{
+    PCIPCNetState *d = PCI_PCNET(obj);
+    PCNetState *s = &d->state;
+
+    pcnet_common_set_bootindex(s, v, name, errp);
+}
+
+static void pcnet_instance_init(Object *obj)
+{
+    object_property_add(obj, "bootindex", "int",
+                        pcnet_get_bootindex,
+                        pcnet_set_bootindex, NULL, NULL, NULL);
+}
+
 static Property pcnet_properties[] = {
     DEFINE_NIC_PROPERTIES(PCIPCNetState, state.conf),
     DEFINE_PROP_END_OF_LIST(),
@@ -375,6 +401,7 @@ static const TypeInfo pcnet_info = {
     .parent        = TYPE_PCI_DEVICE,
     .instance_size = sizeof(PCIPCNetState),
     .class_init    = pcnet_class_init,
+    .instance_init = pcnet_instance_init,
 };
 
 static void pci_pcnet_register_types(void)
diff --git a/hw/net/pcnet.c b/hw/net/pcnet.c
index 4fd2e52..6273abc 100644
--- a/hw/net/pcnet.c
+++ b/hw/net/pcnet.c
@@ -1771,3 +1771,15 @@ void pcnet_common_reset(DeviceState *dev, PCNetState *s)
 {
     add_boot_device_path(s->conf.bootindex, dev, "/address@hidden");
 }
+
+void pcnet_common_get_bootindex(PCNetState *s, Visitor *v,
+                                const char *name, Error **errp)
+{
+    get_bootindex(&s->conf.bootindex, v, name, errp);
+}
+
+void pcnet_common_set_bootindex(PCNetState *s, Visitor *v,
+                                const char *name, Error **errp)
+{
+    set_bootindex(&s->conf.bootindex, v, name, errp);
+}
diff --git a/hw/net/pcnet.h b/hw/net/pcnet.h
index ce9b9cb..6c2baf8 100644
--- a/hw/net/pcnet.h
+++ b/hw/net/pcnet.h
@@ -66,6 +66,10 @@ void pcnet_set_link_status(NetClientState *nc);
 void pcnet_common_cleanup(PCNetState *d);
 int pcnet_common_init(DeviceState *dev, PCNetState *s, NetClientInfo *info);
 void pcnet_common_reset(DeviceState *dev, PCNetState *s);
+void pcnet_common_get_bootindex(PCNetState *s, Visitor *v,
+                                const char *name, Error **errp);
+void pcnet_common_set_bootindex(PCNetState *s, Visitor *v,
+                                const char *name, Error **errp);
 extern const VMStateDescription vmstate_pcnet;
 
 #endif
-- 
1.7.12.4





reply via email to

[Prev in Thread] Current Thread [Next in Thread]