diff mbox

[v6,16/27] usb-net: add bootindex to qom property

Message ID 1409392827-9372-17-git-send-email-arei.gonglei@huawei.com
State New
Headers show

Commit Message

Gonglei (Arei) Aug. 30, 2014, 10 a.m. UTC
From: Gonglei <arei.gonglei@huawei.com>

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 <arei.gonglei@huawei.com>
---
 hw/usb/dev-network.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
diff mbox

Patch

diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c
index ea038ab..7a34368 100644
--- a/hw/usb/dev-network.c
+++ b/hw/usb/dev-network.c
@@ -1378,6 +1378,29 @@  static int usb_net_initfn(USBDevice *dev)
     return 0;
 }
 
+static void usb_net_get_bootindex(Object *obj, Visitor *v, void *opaque,
+                                  const char *name, Error **errp)
+{
+    USBNetState *s = DO_UPCAST(USBNetState, dev, USB_DEVICE(obj));
+
+    get_bootindex(&s->conf.bootindex, v, name, errp);
+}
+
+static void usb_net_set_bootindex(Object *obj, Visitor *v, void *opaque,
+                                  const char *name, Error **errp)
+{
+    USBNetState *s = DO_UPCAST(USBNetState, dev, USB_DEVICE(obj));
+
+    set_bootindex(&s->conf.bootindex, v, name, errp);
+}
+
+static void usb_net_instance_init(Object *obj)
+{
+    object_property_add(obj, "bootindex", "int",
+                        usb_net_get_bootindex,
+                        usb_net_set_bootindex, NULL, NULL, NULL);
+}
+
 static USBDevice *usb_net_init(USBBus *bus, const char *cmdline)
 {
     Error *local_err = NULL;
@@ -1441,6 +1464,7 @@  static const TypeInfo net_info = {
     .parent        = TYPE_USB_DEVICE,
     .instance_size = sizeof(USBNetState),
     .class_init    = usb_net_class_initfn,
+    .instance_init = usb_net_instance_init,
 };
 
 static void usb_net_register_types(void)