From patchwork Thu Sep 18 09:32:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gonglei (Arei)" X-Patchwork-Id: 390724 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 B31DE1401E7 for ; Thu, 18 Sep 2014 19:44:59 +1000 (EST) Received: from localhost ([::1]:49437 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUYGm-0000J9-J4 for incoming@patchwork.ozlabs.org; Thu, 18 Sep 2014 05:44:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49330) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUY69-0007ja-M6 for qemu-devel@nongnu.org; Thu, 18 Sep 2014 05:34:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XUY60-0002Ff-PL for qemu-devel@nongnu.org; Thu, 18 Sep 2014 05:33:56 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:60730) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUY5z-0002BW-V7 for qemu-devel@nongnu.org; Thu, 18 Sep 2014 05:33:48 -0400 Received: from 172.24.2.119 (EHLO szxeml407-hub.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id AUN51162; Thu, 18 Sep 2014 17:33:27 +0800 (CST) Received: from localhost (10.177.19.102) by szxeml407-hub.china.huawei.com (10.82.67.94) with Microsoft SMTP Server id 14.3.158.1; Thu, 18 Sep 2014 17:33:12 +0800 From: To: Date: Thu, 18 Sep 2014 17:32:48 +0800 Message-ID: <1411032780-10692-8-git-send-email-arei.gonglei@huawei.com> X-Mailer: git-send-email 1.7.3.1.msysgit.0 In-Reply-To: <1411032780-10692-1-git-send-email-arei.gonglei@huawei.com> References: <1411032780-10692-1-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.19.102] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.541AA6E8.00D2, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 864f3df94743766a6b7da9696e64193c X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.66 Cc: weidong.huang@huawei.com, luonengjun@huawei.com, peter.huangpeng@huawei.com, armbru@redhat.com, Gonglei , kraxel@redhat.com, pbonzini@redhat.com Subject: [Qemu-devel] [PATCH 07/19] dev-storage: convert init to realize 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 In this way, all the implementations now use error_setg instead of error_report for reporting error. Signed-off-by: Gonglei Reviewed-by: Paolo Bonzini --- hw/usb/dev-storage.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index a9f31f0..6dc5f47 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -595,7 +595,7 @@ static const struct SCSIBusInfo usb_msd_scsi_info_bot = { .load_request = usb_msd_load_request, }; -static int usb_msd_initfn_storage(USBDevice *dev) +static void usb_msd_realize_storage(USBDevice *dev, Error **errp) { MSDState *s = DO_UPCAST(MSDState, dev, dev); BlockDriverState *bs = s->conf.bs; @@ -603,8 +603,8 @@ static int usb_msd_initfn_storage(USBDevice *dev) Error *err = NULL; if (!bs) { - error_report("drive property not set"); - return -1; + error_setg(errp, "drive property not set"); + return; } blkconf_serial(&s->conf, &dev->serial); @@ -629,9 +629,8 @@ static int usb_msd_initfn_storage(USBDevice *dev) s->conf.bootindex, dev->serial, &err); if (!scsi_dev) { - error_report("%s", error_get_pretty(err)); - error_free(err); - return -1; + error_propagate(errp, err); + return; } s->bus.qbus.allow_hotplug = 0; usb_msd_handle_reset(dev); @@ -644,11 +643,9 @@ static int usb_msd_initfn_storage(USBDevice *dev) autostart = 0; } } - - return 0; } -static int usb_msd_initfn_bot(USBDevice *dev) +static void usb_msd_realize_bot(USBDevice *dev, Error **errp) { MSDState *s = DO_UPCAST(MSDState, dev, dev); @@ -658,8 +655,6 @@ static int usb_msd_initfn_bot(USBDevice *dev) &usb_msd_scsi_info_bot, NULL); s->bus.qbus.allow_hotplug = 0; usb_msd_handle_reset(dev); - - return 0; } static USBDevice *usb_msd_init(USBBus *bus, const char *filename) @@ -765,7 +760,7 @@ static void usb_msd_class_initfn_storage(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); USBDeviceClass *uc = USB_DEVICE_CLASS(klass); - uc->init = usb_msd_initfn_storage; + uc->realize = usb_msd_realize_storage; dc->props = msd_properties; usb_msd_class_initfn_common(klass); } @@ -774,7 +769,7 @@ static void usb_msd_class_initfn_bot(ObjectClass *klass, void *data) { USBDeviceClass *uc = USB_DEVICE_CLASS(klass); - uc->init = usb_msd_initfn_bot; + uc->realize = usb_msd_realize_bot; usb_msd_class_initfn_common(klass); }