From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59719) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUYlV-0002a4-7D for qemu-devel@nongnu.org; Thu, 18 Sep 2014 06:16:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XUYlQ-0006of-DY for qemu-devel@nongnu.org; Thu, 18 Sep 2014 06:16:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54879) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUYlP-0006nD-Ty for qemu-devel@nongnu.org; Thu, 18 Sep 2014 06:16:36 -0400 Message-ID: <541AB0F7.6050905@redhat.com> Date: Thu, 18 Sep 2014 12:16:23 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1411032780-10692-1-git-send-email-arei.gonglei@huawei.com> <1411032780-10692-18-git-send-email-arei.gonglei@huawei.com> In-Reply-To: <1411032780-10692-18-git-send-email-arei.gonglei@huawei.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 17/19] usb-redir: convert init to realize List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: arei.gonglei@huawei.com, qemu-devel@nongnu.org Cc: luonengjun@huawei.com, peter.huangpeng@huawei.com, weidong.huang@huawei.com, kraxel@redhat.com, armbru@redhat.com Il 18/09/2014 11:32, arei.gonglei@huawei.com ha scritto: > From: Gonglei > > In this way, all the implementations now use > error_setg instead of qerror_report for reporting error. > > Signed-off-by: Gonglei > --- > hw/usb/redirect.c | 15 +++++++-------- > 1 file changed, 7 insertions(+), 8 deletions(-) > > diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c > index 95158b3..e2c9896 100644 > --- a/hw/usb/redirect.c > +++ b/hw/usb/redirect.c > @@ -1361,14 +1361,14 @@ static void usbredir_init_endpoints(USBRedirDevice *dev) > } > } > > -static int usbredir_initfn(USBDevice *udev) > +static void usbredir_realize(USBDevice *udev, Error **errp) > { > USBRedirDevice *dev = DO_UPCAST(USBRedirDevice, dev, udev); > int i; > > if (dev->cs == NULL) { > - qerror_report(QERR_MISSING_PARAMETER, "chardev"); > - return -1; > + error_set(errp, QERR_MISSING_PARAMETER, "chardev"); > + return; > } > > if (dev->filter_str) { > @@ -1376,9 +1376,9 @@ static int usbredir_initfn(USBDevice *udev) > &dev->filter_rules, > &dev->filter_rules_count); > if (i) { > - qerror_report(QERR_INVALID_PARAMETER_VALUE, "filter", > - "a usb device filter string"); > - return -1; > + error_set(errp, QERR_INVALID_PARAMETER_VALUE, "filter", > + "a usb device filter string"); > + return; > } > } > > @@ -1402,7 +1402,6 @@ static int usbredir_initfn(USBDevice *udev) > > qemu_add_vm_change_state_handler(usbredir_vm_state_change, dev); > add_boot_device_path(dev->bootindex, &udev->qdev, NULL); > - return 0; > } > > static void usbredir_cleanup_device_queues(USBRedirDevice *dev) > @@ -2481,7 +2480,7 @@ static void usbredir_class_initfn(ObjectClass *klass, void *data) > USBDeviceClass *uc = USB_DEVICE_CLASS(klass); > DeviceClass *dc = DEVICE_CLASS(klass); > > - uc->init = usbredir_initfn; > + uc->realize = usbredir_realize; > uc->product_desc = "USB Redirection Device"; > uc->handle_destroy = usbredir_handle_destroy; > uc->cancel_packet = usbredir_cancel_packet; > Reviewed-by: Paolo Bonzini