From patchwork Sat Aug 30 10:00:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gonglei (Arei)" X-Patchwork-Id: 384462 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 7459014012B for ; Sat, 30 Aug 2014 20:11:40 +1000 (EST) Received: from localhost ([::1]:45970 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNfdC-0001oB-GD for incoming@patchwork.ozlabs.org; Sat, 30 Aug 2014 06:11:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47339) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNfTb-0000DC-EH for qemu-devel@nongnu.org; Sat, 30 Aug 2014 06:01:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XNfTW-0002xh-0H for qemu-devel@nongnu.org; Sat, 30 Aug 2014 06:01:43 -0400 Received: from szxga01-in.huawei.com ([119.145.14.64]:44320) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNfTU-0002vw-T1 for qemu-devel@nongnu.org; Sat, 30 Aug 2014 06:01:37 -0400 Received: from 172.24.2.119 (EHLO szxeml418-hub.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CAZ63771; Sat, 30 Aug 2014 18:01:00 +0800 (CST) Received: from localhost (10.177.19.102) by szxeml418-hub.china.huawei.com (10.82.67.157) with Microsoft SMTP Server id 14.3.158.1; Sat, 30 Aug 2014 18:00:49 +0800 From: To: Date: Sat, 30 Aug 2014 18:00:16 +0800 Message-ID: <1409392827-9372-17-git-send-email-arei.gonglei@huawei.com> X-Mailer: git-send-email 1.7.3.1.msysgit.0 In-Reply-To: <1409392827-9372-1-git-send-email-arei.gonglei@huawei.com> References: <1409392827-9372-1-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.19.102] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.64 Cc: chenliang88@huawei.com, weidong.huang@huawei.com, mst@redhat.com, aik@ozlabs.ru, hutao@cn.fujitsu.com, armbru@redhat.com, kraxel@redhat.com, akong@redhat.com, agraf@suse.de, Gonglei , aliguori@amazon.com, ehabkost@redhat.com, luonengjun@huawei.com, peter.huangpeng@huawei.com, hani@linux.com, stefanha@redhat.com, pbonzini@redhat.com, lcapitulino@redhat.com, kwolf@redhat.com, peter.crosthwaite@xilinx.com, imammedo@redhat.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH v6 16/27] usb-net: add bootindex to qom property 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 From: Gonglei 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 --- hw/usb/dev-network.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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)