From nobody Mon Apr 29 09:40:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501070890098605.3278063926724; Wed, 26 Jul 2017 05:08:10 -0700 (PDT) Received: from localhost ([::1]:37830 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daL6g-0004Hv-Ez for importer@patchew.org; Wed, 26 Jul 2017 08:08:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34265) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daL2q-0001QV-7F for qemu-devel@nongnu.org; Wed, 26 Jul 2017 08:04:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1daL2o-0000E7-Ev for qemu-devel@nongnu.org; Wed, 26 Jul 2017 08:04:04 -0400 Received: from [59.151.112.132] (port=41027 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daL2e-0008PX-R6; Wed, 26 Jul 2017 08:03:53 -0400 Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 26 Jul 2017 20:03:43 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id 39495402BB71; Wed, 26 Jul 2017 20:03:41 +0800 (CST) Received: from maozy.g08.fujitsu.local (10.167.225.76) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 26 Jul 2017 20:03:40 +0800 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="21843092" From: Mao Zhongyi To: , Date: Wed, 26 Jul 2017 20:02:50 +0800 Message-ID: <20170726120255.14292-2-maozy.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170726120255.14292-1-maozy.fnst@cn.fujitsu.com> References: <20170726120255.14292-1-maozy.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.225.76] X-yoursite-MailScanner-ID: 39495402BB71.ACE5B X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: maozy.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Subject: [Qemu-devel] [PATCH 1/6] hw/ide: Convert DeviceClass init to realize X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace init with realize in IDEDeviceClass, which has errp as a parameter. So all the implementations now use error_setg instead of error_report for reporting error. Cc: John Snow Cc: Markus Armbruster Signed-off-by: Mao Zhongyi --- hw/ide/core.c | 7 ++-- hw/ide/qdev.c | 86 +++++++++++++++++++++++--------------------= ---- include/hw/ide/internal.h | 5 +-- 3 files changed, 49 insertions(+), 49 deletions(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index 0b48b64..7c86fc7 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -34,6 +34,7 @@ #include "hw/block/block.h" #include "sysemu/block-backend.h" #include "qemu/cutils.h" +#include "qemu/error-report.h" =20 #include "hw/ide/internal.h" =20 @@ -2398,7 +2399,7 @@ int ide_init_drive(IDEState *s, BlockBackend *blk, ID= EDriveKind kind, const char *version, const char *serial, const char *mo= del, uint64_t wwn, uint32_t cylinders, uint32_t heads, uint32_t secs, - int chs_trans) + int chs_trans, Error **errp) { uint64_t nb_sectors; =20 @@ -2423,11 +2424,11 @@ int ide_init_drive(IDEState *s, BlockBackend *blk, = IDEDriveKind kind, blk_set_guest_block_size(blk, 2048); } else { if (!blk_is_inserted(s->blk)) { - error_report("Device needs media, but drive is empty"); + error_setg(errp, "Device needs media, but drive is empty"); return -1; } if (blk_is_read_only(blk)) { - error_report("Can't use a read-only drive"); + error_setg(errp, "Can't use a read-only drive"); return -1; } blk_set_dev_ops(blk, &ide_hd_block_ops, s); diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index cc2f5bd..d60ac25 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -80,7 +80,7 @@ static char *idebus_get_fw_dev_path(DeviceState *dev) return g_strdup(path); } =20 -static int ide_qdev_init(DeviceState *qdev) +static void ide_qdev_realize(DeviceState *qdev, Error **errp) { IDEDevice *dev =3D IDE_DEVICE(qdev); IDEDeviceClass *dc =3D IDE_DEVICE_GET_CLASS(dev); @@ -91,34 +91,31 @@ static int ide_qdev_init(DeviceState *qdev) } =20 if (dev->unit >=3D bus->max_units) { - error_report("Can't create IDE unit %d, bus supports only %d units= ", + error_setg(errp, "Can't create IDE unit %d, bus supports only %d u= nits", dev->unit, bus->max_units); - goto err; + return; } =20 switch (dev->unit) { case 0: if (bus->master) { - error_report("IDE unit %d is in use", dev->unit); - goto err; + error_setg(errp, "IDE unit %d is in use", dev->unit); + return; } bus->master =3D dev; break; case 1: if (bus->slave) { - error_report("IDE unit %d is in use", dev->unit); - goto err; + error_setg(errp, "IDE unit %d is in use", dev->unit); + return; } bus->slave =3D dev; break; default: - error_report("Invalid IDE unit %d", dev->unit); - goto err; + error_setg(errp, "Invalid IDE unit %d", dev->unit); + return; } - return dc->init(dev); - -err: - return -1; + dc->realize(dev, errp); } =20 IDEDevice *ide_create_drive(IDEBus *bus, int unit, DriveInfo *drive) @@ -159,7 +156,7 @@ typedef struct IDEDrive { IDEDevice dev; } IDEDrive; =20 -static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind) +static void ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind, Error **errp) { IDEBus *bus =3D DO_UPCAST(IDEBus, qbus, dev->qdev.parent_bus); IDEState *s =3D bus->ifs + dev->unit; @@ -168,8 +165,8 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind = kind) =20 if (!dev->conf.blk) { if (kind !=3D IDE_CD) { - error_report("No drive specified"); - return -1; + error_setg(errp, "No drive specified"); + return; } else { /* Anonymous BlockBackend for an empty drive */ dev->conf.blk =3D blk_new(0, BLK_PERM_ALL); @@ -182,36 +179,36 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKin= d kind) dev->conf.discard_granularity =3D 512; } else if (dev->conf.discard_granularity && dev->conf.discard_granularity !=3D 512) { - error_report("discard_granularity must be 512 for ide"); - return -1; + error_setg(errp, "discard_granularity must be 512 for ide"); + return; } =20 blkconf_blocksizes(&dev->conf); if (dev->conf.logical_block_size !=3D 512) { - error_report("logical_block_size must be 512 for IDE"); - return -1; + error_setg(errp, "logical_block_size must be 512 for IDE"); + return; } =20 blkconf_serial(&dev->conf, &dev->serial); if (kind !=3D IDE_CD) { blkconf_geometry(&dev->conf, &dev->chs_trans, 65535, 16, 255, &err= ); if (err) { - error_report_err(err); - return -1; + error_propagate(errp, err); + return; } } blkconf_apply_backend_options(&dev->conf, kind =3D=3D IDE_CD, kind != =3D IDE_CD, &err); if (err) { - error_report_err(err); - return -1; + error_propagate(errp, err); + return; } =20 if (ide_init_drive(s, dev->conf.blk, kind, dev->version, dev->serial, dev->model, dev->wwn, dev->conf.cyls, dev->conf.heads, dev->conf.secs, - dev->chs_trans) < 0) { - return -1; + dev->chs_trans, errp) < 0) { + return; } =20 if (!dev->version) { @@ -223,8 +220,6 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind = kind) =20 add_boot_device_path(dev->conf.bootindex, &dev->qdev, dev->unit ? "/disk@1" : "/disk@0"); - - return 0; } =20 static void ide_dev_get_bootindex(Object *obj, Visitor *v, const char *nam= e, @@ -270,17 +265,17 @@ static void ide_dev_instance_init(Object *obj) object_property_set_int(obj, -1, "bootindex", NULL); } =20 -static int ide_hd_initfn(IDEDevice *dev) +static void ide_hd_realize(IDEDevice *dev, Error **errp) { - return ide_dev_initfn(dev, IDE_HD); + ide_dev_initfn(dev, IDE_HD, errp); } =20 -static int ide_cd_initfn(IDEDevice *dev) +static void ide_cd_realize(IDEDevice *dev, Error **errp) { - return ide_dev_initfn(dev, IDE_CD); + ide_dev_initfn(dev, IDE_CD, errp); } =20 -static int ide_drive_initfn(IDEDevice *dev) +static void ide_drive_realize(IDEDevice *dev, Error **errp) { DriveInfo *dinfo =3D NULL; =20 @@ -288,7 +283,7 @@ static int ide_drive_initfn(IDEDevice *dev) dinfo =3D blk_legacy_dinfo(dev->conf.blk); } =20 - return ide_dev_initfn(dev, dinfo && dinfo->media_cd ? IDE_CD : IDE_HD); + ide_dev_initfn(dev, dinfo && dinfo->media_cd ? IDE_CD : IDE_HD, errp); } =20 #define DEFINE_IDE_DEV_PROPERTIES() \ @@ -311,10 +306,11 @@ static void ide_hd_class_init(ObjectClass *klass, voi= d *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); IDEDeviceClass *k =3D IDE_DEVICE_CLASS(klass); - k->init =3D ide_hd_initfn; + + k->realize =3D ide_hd_realize; dc->fw_name =3D "drive"; - dc->desc =3D "virtual IDE disk"; - dc->props =3D ide_hd_properties; + dc->desc =3D "virtual IDE disk"; + dc->props =3D ide_hd_properties; } =20 static const TypeInfo ide_hd_info =3D { @@ -333,10 +329,11 @@ static void ide_cd_class_init(ObjectClass *klass, voi= d *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); IDEDeviceClass *k =3D IDE_DEVICE_CLASS(klass); - k->init =3D ide_cd_initfn; + + k->realize =3D ide_cd_realize; dc->fw_name =3D "drive"; - dc->desc =3D "virtual IDE CD-ROM"; - dc->props =3D ide_cd_properties; + dc->desc =3D "virtual IDE CD-ROM"; + dc->props =3D ide_cd_properties; } =20 static const TypeInfo ide_cd_info =3D { @@ -355,10 +352,11 @@ static void ide_drive_class_init(ObjectClass *klass, = void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); IDEDeviceClass *k =3D IDE_DEVICE_CLASS(klass); - k->init =3D ide_drive_initfn; + + k->realize =3D ide_drive_realize; dc->fw_name =3D "drive"; - dc->desc =3D "virtual IDE disk or CD-ROM (legacy)"; - dc->props =3D ide_drive_properties; + dc->desc =3D "virtual IDE disk or CD-ROM (legacy)"; + dc->props =3D ide_drive_properties; } =20 static const TypeInfo ide_drive_info =3D { @@ -371,7 +369,7 @@ static const TypeInfo ide_drive_info =3D { static void ide_device_class_init(ObjectClass *klass, void *data) { DeviceClass *k =3D DEVICE_CLASS(klass); - k->init =3D ide_qdev_init; + k->realize =3D ide_qdev_realize; set_bit(DEVICE_CATEGORY_STORAGE, k->categories); k->bus_type =3D TYPE_IDE_BUS; k->props =3D ide_props; diff --git a/include/hw/ide/internal.h b/include/hw/ide/internal.h index 482a951..5ebb4c9 100644 --- a/include/hw/ide/internal.h +++ b/include/hw/ide/internal.h @@ -12,6 +12,7 @@ #include "sysemu/sysemu.h" #include "hw/block/block.h" #include "block/scsi.h" +#include "qapi/error.h" =20 /* debug IDE devices */ //#define DEBUG_IDE @@ -495,7 +496,7 @@ struct IDEBus { =20 typedef struct IDEDeviceClass { DeviceClass parent_class; - int (*init)(IDEDevice *dev); + void (*realize)(IDEDevice *dev, Error **errp); } IDEDeviceClass; =20 struct IDEDevice { @@ -605,7 +606,7 @@ int ide_init_drive(IDEState *s, BlockBackend *blk, IDED= riveKind kind, const char *version, const char *serial, const char *mo= del, uint64_t wwn, uint32_t cylinders, uint32_t heads, uint32_t secs, - int chs_trans); + int chs_trans, Error **errp); void ide_init2(IDEBus *bus, qemu_irq irq); void ide_exit(IDEState *s); void ide_init_ioport(IDEBus *bus, ISADevice *isa, int iobase, int iobase2); --=20 2.9.4 From nobody Mon Apr 29 09:40:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501070739063430.6313944674806; Wed, 26 Jul 2017 05:05:39 -0700 (PDT) Received: from localhost ([::1]:37809 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daL4I-0002Qj-Jo for importer@patchew.org; Wed, 26 Jul 2017 08:05:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34198) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daL2l-0001M8-UZ for qemu-devel@nongnu.org; Wed, 26 Jul 2017 08:04:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1daL2k-00007W-Tt for qemu-devel@nongnu.org; Wed, 26 Jul 2017 08:03:59 -0400 Received: from [59.151.112.132] (port=1336 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daL2d-0008RW-CF; Wed, 26 Jul 2017 08:03:52 -0400 Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 26 Jul 2017 20:03:43 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id E02F1402BB76; Wed, 26 Jul 2017 20:03:41 +0800 (CST) Received: from maozy.g08.fujitsu.local (10.167.225.76) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 26 Jul 2017 20:03:41 +0800 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="21843090" From: Mao Zhongyi To: , Date: Wed, 26 Jul 2017 20:02:51 +0800 Message-ID: <20170726120255.14292-3-maozy.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170726120255.14292-1-maozy.fnst@cn.fujitsu.com> References: <20170726120255.14292-1-maozy.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.225.76] X-yoursite-MailScanner-ID: E02F1402BB76.AEA0B X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: maozy.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Subject: [Qemu-devel] [PATCH 2/6] hw/block/fdc: Convert to realize X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , John Snow , Markus Armbruster , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Convert floppy_drive_init() to realize and rename it to floppy_drive_realize(). Cc: John Snow Cc: Kevin Wolf Cc: Max Reitz Cc: Markus Armbruster Signed-off-by: Mao Zhongyi --- hw/block/fdc.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/hw/block/fdc.c b/hw/block/fdc.c index 4011290..02f4a46 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -517,7 +517,7 @@ static Property floppy_drive_properties[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 -static int floppy_drive_init(DeviceState *qdev) +static void floppy_drive_realize(DeviceState *qdev, Error **errp) { FloppyDrive *dev =3D FLOPPY_DRIVE(qdev); FloppyBus *bus =3D FLOPPY_BUS(qdev->parent_bus); @@ -535,15 +535,15 @@ static int floppy_drive_init(DeviceState *qdev) } =20 if (dev->unit >=3D MAX_FD) { - error_report("Can't create floppy unit %d, bus supports only %d un= its", - dev->unit, MAX_FD); - return -1; + error_setg(errp, "Can't create floppy unit %d, bus supports " + "only %d units", dev->unit, MAX_FD); + return; } =20 drive =3D get_drv(bus->fdc, dev->unit); if (drive->blk) { - error_report("Floppy unit %d is in use", dev->unit); - return -1; + error_setg(errp, "Floppy unit %d is in use", dev->unit); + return; } =20 if (!dev->conf.blk) { @@ -557,8 +557,9 @@ static int floppy_drive_init(DeviceState *qdev) if (dev->conf.logical_block_size !=3D 512 || dev->conf.physical_block_size !=3D 512) { - error_report("Physical and logical block size must be 512 for flop= py"); - return -1; + error_setg(errp, "Physical and logical block size must " + "be 512 for floppy"); + return; } =20 /* rerror/werror aren't supported by fdc and therefore not even regist= ered @@ -570,20 +571,20 @@ static int floppy_drive_init(DeviceState *qdev) blkconf_apply_backend_options(&dev->conf, blk_is_read_only(dev->conf.b= lk), false, &local_err); if (local_err) { - error_report_err(local_err); - return -1; + error_propagate(errp, local_err); + return; } =20 /* 'enospc' is the default for -drive, 'report' is what blk_new() give= s us * for empty drives. */ if (blk_get_on_error(dev->conf.blk, 0) !=3D BLOCKDEV_ON_ERROR_ENOSPC && blk_get_on_error(dev->conf.blk, 0) !=3D BLOCKDEV_ON_ERROR_REPORT) { - error_report("fdc doesn't support drive option werror"); - return -1; + error_setg(errp, "fdc doesn't support drive option werror"); + return; } if (blk_get_on_error(dev->conf.blk, 1) !=3D BLOCKDEV_ON_ERROR_REPORT) { - error_report("fdc doesn't support drive option rerror"); - return -1; + error_setg(errp, "fdc doesn't support drive option rerror"); + return; } =20 drive->conf =3D &dev->conf; @@ -599,14 +600,12 @@ static int floppy_drive_init(DeviceState *qdev) dev->type =3D drive->drive; =20 fd_revalidate(drive); - - return 0; } =20 static void floppy_drive_class_init(ObjectClass *klass, void *data) { DeviceClass *k =3D DEVICE_CLASS(klass); - k->init =3D floppy_drive_init; + k->realize =3D floppy_drive_realize; set_bit(DEVICE_CATEGORY_STORAGE, k->categories); k->bus_type =3D TYPE_FLOPPY_BUS; k->props =3D floppy_drive_properties; --=20 2.9.4 From nobody Mon Apr 29 09:40:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501070729670583.1889845971903; Wed, 26 Jul 2017 05:05:29 -0700 (PDT) Received: from localhost ([::1]:37805 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daL4C-0002Gs-Ck for importer@patchew.org; Wed, 26 Jul 2017 08:05:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34123) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daL2i-0001It-Nj for qemu-devel@nongnu.org; Wed, 26 Jul 2017 08:03:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1daL2h-0008WC-Np for qemu-devel@nongnu.org; Wed, 26 Jul 2017 08:03:56 -0400 Received: from [59.151.112.132] (port=46332 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daL2d-0008RI-Cd; Wed, 26 Jul 2017 08:03:51 -0400 Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 26 Jul 2017 20:03:43 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id B386F402BB97; Wed, 26 Jul 2017 20:03:42 +0800 (CST) Received: from maozy.g08.fujitsu.local (10.167.225.76) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 26 Jul 2017 20:03:42 +0800 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="21843091" From: Mao Zhongyi To: , Date: Wed, 26 Jul 2017 20:02:52 +0800 Message-ID: <20170726120255.14292-4-maozy.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170726120255.14292-1-maozy.fnst@cn.fujitsu.com> References: <20170726120255.14292-1-maozy.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.225.76] X-yoursite-MailScanner-ID: B386F402BB97.AF77A X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: maozy.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Subject: [Qemu-devel] [PATCH 3/6] hw/block/nvme: Convert to realize X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keith Busch , Kevin Wolf , Markus Armbruster , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Convert nvme_init() to realize and rename it to nvme_realize(). Cc: Keith Busch Cc: Kevin Wolf Cc: Max Reitz Cc: Markus Armbruster Signed-off-by: Mao Zhongyi --- hw/block/nvme.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 6071dc1..43c60ab 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -920,7 +920,7 @@ static const MemoryRegionOps nvme_cmb_ops =3D { }, }; =20 -static int nvme_init(PCIDevice *pci_dev) +static void nvme_realize(PCIDevice *pci_dev, Error **errp) { NvmeCtrl *n =3D NVME(pci_dev); NvmeIdCtrl *id =3D &n->id_ctrl; @@ -931,24 +931,27 @@ static int nvme_init(PCIDevice *pci_dev) Error *local_err =3D NULL; =20 if (!n->conf.blk) { - return -1; + error_setg(errp, "drive property not set"); + return; } =20 bs_size =3D blk_getlength(n->conf.blk); if (bs_size < 0) { - return -1; + error_setg(errp, "could not get backing file size"); + return; } =20 blkconf_serial(&n->conf, &n->serial); if (!n->serial) { - return -1; + error_setg(errp, "serial property not set"); + return; } blkconf_blocksizes(&n->conf); blkconf_apply_backend_options(&n->conf, blk_is_read_only(n->conf.blk), false, &local_err); if (local_err) { - error_report_err(local_err); - return -1; + error_propagate(errp, local_err); + return; } =20 pci_conf =3D pci_dev->config; @@ -1046,7 +1049,6 @@ static int nvme_init(PCIDevice *pci_dev) cpu_to_le64(n->ns_size >> id_ns->lbaf[NVME_ID_NS_FLBAS_INDEX(ns->id_ns.flbas)].ds); } - return 0; } =20 static void nvme_exit(PCIDevice *pci_dev) @@ -1081,7 +1083,7 @@ static void nvme_class_init(ObjectClass *oc, void *da= ta) DeviceClass *dc =3D DEVICE_CLASS(oc); PCIDeviceClass *pc =3D PCI_DEVICE_CLASS(oc); =20 - pc->init =3D nvme_init; + pc->realize =3D nvme_realize; pc->exit =3D nvme_exit; pc->class_id =3D PCI_CLASS_STORAGE_EXPRESS; pc->vendor_id =3D PCI_VENDOR_ID_INTEL; --=20 2.9.4 From nobody Mon Apr 29 09:40:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501071174798597.4338328015583; Wed, 26 Jul 2017 05:12:54 -0700 (PDT) Received: from localhost ([::1]:37879 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daLBH-0000KZ-Mr for importer@patchew.org; Wed, 26 Jul 2017 08:12:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34267) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daL2q-0001QX-7t for qemu-devel@nongnu.org; Wed, 26 Jul 2017 08:04:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1daL2o-0000ER-TD for qemu-devel@nongnu.org; Wed, 26 Jul 2017 08:04:04 -0400 Received: from [59.151.112.132] (port=1336 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daL2f-0008RW-Ah; Wed, 26 Jul 2017 08:03:53 -0400 Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 26 Jul 2017 20:03:45 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id BF63240144EA; Wed, 26 Jul 2017 20:03:43 +0800 (CST) Received: from maozy.g08.fujitsu.local (10.167.225.76) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 26 Jul 2017 20:03:43 +0800 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="21843095" From: Mao Zhongyi To: , Date: Wed, 26 Jul 2017 20:02:53 +0800 Message-ID: <20170726120255.14292-5-maozy.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170726120255.14292-1-maozy.fnst@cn.fujitsu.com> References: <20170726120255.14292-1-maozy.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.225.76] X-yoursite-MailScanner-ID: BF63240144EA.A0042 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: maozy.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Subject: [Qemu-devel] [PATCH 4/6] hw/block: Fix the return type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , John Snow , Stefan Hajnoczi , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When the function no success value to transmit, it usually make the function return void. It has turned out not to be a success, because it means that the extra local_err variable and error_propagate() will be needed. It leads to cumbersome code, therefore, transmit success/ failure in the return value is worth. So fix the return type of blkconf_apply_backend_options(), blkconf_geometry() and virtio_blk_data_plane_create() to avoid it. Cc: John Snow Cc: Kevin Wolf Cc: Max Reitz Cc: Stefan Hajnoczi Signed-off-by: Mao Zhongyi --- hw/block/block.c | 21 ++++++++++++--------- hw/block/dataplane/virtio-blk.c | 16 +++++++++------- hw/block/dataplane/virtio-blk.h | 6 +++--- include/hw/block/block.h | 10 +++++----- 4 files changed, 29 insertions(+), 24 deletions(-) diff --git a/hw/block/block.c b/hw/block/block.c index 27878d0..717bd0e 100644 --- a/hw/block/block.c +++ b/hw/block/block.c @@ -51,8 +51,8 @@ void blkconf_blocksizes(BlockConf *conf) } } =20 -void blkconf_apply_backend_options(BlockConf *conf, bool readonly, - bool resizable, Error **errp) +int blkconf_apply_backend_options(BlockConf *conf, bool readonly, + bool resizable, Error **errp) { BlockBackend *blk =3D conf->blk; BlockdevOnError rerror, werror; @@ -76,7 +76,7 @@ void blkconf_apply_backend_options(BlockConf *conf, bool = readonly, =20 ret =3D blk_set_perm(blk, perm, shared_perm, errp); if (ret < 0) { - return; + return -1; } =20 switch (conf->wce) { @@ -99,11 +99,13 @@ void blkconf_apply_backend_options(BlockConf *conf, boo= l readonly, =20 blk_set_enable_write_cache(blk, wce); blk_set_on_error(blk, rerror, werror); + + return 0; } =20 -void blkconf_geometry(BlockConf *conf, int *ptrans, - unsigned cyls_max, unsigned heads_max, unsigned secs= _max, - Error **errp) +int blkconf_geometry(BlockConf *conf, int *ptrans, + unsigned cyls_max, unsigned heads_max, unsigned secs_= max, + Error **errp) { DriveInfo *dinfo; =20 @@ -129,15 +131,16 @@ void blkconf_geometry(BlockConf *conf, int *ptrans, if (conf->cyls || conf->heads || conf->secs) { if (conf->cyls < 1 || conf->cyls > cyls_max) { error_setg(errp, "cyls must be between 1 and %u", cyls_max); - return; + return -1; } if (conf->heads < 1 || conf->heads > heads_max) { error_setg(errp, "heads must be between 1 and %u", heads_max); - return; + return -1; } if (conf->secs < 1 || conf->secs > secs_max) { error_setg(errp, "secs must be between 1 and %u", secs_max); - return; + return -1; } } + return 0; } diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-bl= k.c index 5556f0e..619bc5e 100644 --- a/hw/block/dataplane/virtio-blk.c +++ b/hw/block/dataplane/virtio-blk.c @@ -76,9 +76,9 @@ static void notify_guest_bh(void *opaque) } =20 /* Context: QEMU global mutex held */ -void virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *conf, - VirtIOBlockDataPlane **dataplane, - Error **errp) +int virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *conf, + VirtIOBlockDataPlane **dataplane, + Error **errp) { VirtIOBlockDataPlane *s; BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); @@ -91,11 +91,11 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev, V= irtIOBlkConf *conf, error_setg(errp, "device is incompatible with iothread " "(transport does not support notifiers)"); - return; + return -1; } if (!virtio_device_ioeventfd_enabled(vdev)) { error_setg(errp, "ioeventfd is required for iothread"); - return; + return -1; } =20 /* If dataplane is (re-)enabled while the guest is running there c= ould @@ -103,12 +103,12 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev,= VirtIOBlkConf *conf, */ if (blk_op_is_blocked(conf->conf.blk, BLOCK_OP_TYPE_DATAPLANE, err= p)) { error_prepend(errp, "cannot start virtio-blk dataplane: "); - return; + return -1; } } /* Don't try if transport does not support notifiers. */ if (!virtio_device_ioeventfd_enabled(vdev)) { - return; + return -1; } =20 s =3D g_new0(VirtIOBlockDataPlane, 1); @@ -126,6 +126,8 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev, V= irtIOBlkConf *conf, s->batch_notify_vqs =3D bitmap_new(conf->num_queues); =20 *dataplane =3D s; + + return 0; } =20 /* Context: QEMU global mutex held */ diff --git a/hw/block/dataplane/virtio-blk.h b/hw/block/dataplane/virtio-bl= k.h index db3f47b..d25773d 100644 --- a/hw/block/dataplane/virtio-blk.h +++ b/hw/block/dataplane/virtio-blk.h @@ -19,9 +19,9 @@ =20 typedef struct VirtIOBlockDataPlane VirtIOBlockDataPlane; =20 -void virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *conf, - VirtIOBlockDataPlane **dataplane, - Error **errp); +int virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *conf, + VirtIOBlockDataPlane **dataplane, + Error **errp); void virtio_blk_data_plane_destroy(VirtIOBlockDataPlane *s); void virtio_blk_data_plane_notify(VirtIOBlockDataPlane *s, VirtQueue *vq); =20 diff --git a/include/hw/block/block.h b/include/hw/block/block.h index f3f6e8e..66117c6 100644 --- a/include/hw/block/block.h +++ b/include/hw/block/block.h @@ -72,12 +72,12 @@ static inline unsigned int get_physical_block_exp(Block= Conf *conf) /* Configuration helpers */ =20 void blkconf_serial(BlockConf *conf, char **serial); -void blkconf_geometry(BlockConf *conf, int *trans, - unsigned cyls_max, unsigned heads_max, unsigned secs= _max, - Error **errp); +int blkconf_geometry(BlockConf *conf, int *trans, + unsigned cyls_max, unsigned heads_max, unsigned secs_= max, + Error **errp); void blkconf_blocksizes(BlockConf *conf); -void blkconf_apply_backend_options(BlockConf *conf, bool readonly, - bool resizable, Error **errp); +int blkconf_apply_backend_options(BlockConf *conf, bool readonly, + bool resizable, Error **errp); =20 /* Hard disk geometry */ =20 --=20 2.9.4 From nobody Mon Apr 29 09:40:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501071041473739.3976887710882; Wed, 26 Jul 2017 05:10:41 -0700 (PDT) Received: from localhost ([::1]:37861 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daL9B-0006kb-Qw for importer@patchew.org; Wed, 26 Jul 2017 08:10:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34211) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daL2m-0001Ma-Gv for qemu-devel@nongnu.org; Wed, 26 Jul 2017 08:04:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1daL2k-00007g-US for qemu-devel@nongnu.org; Wed, 26 Jul 2017 08:04:00 -0400 Received: from [59.151.112.132] (port=41027 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daL2g-0008PX-TL; Wed, 26 Jul 2017 08:03:55 -0400 Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 26 Jul 2017 20:03:49 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id 76A5440144EA; Wed, 26 Jul 2017 20:03:45 +0800 (CST) Received: from maozy.g08.fujitsu.local (10.167.225.76) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 26 Jul 2017 20:03:44 +0800 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="21843100" From: Mao Zhongyi To: , Date: Wed, 26 Jul 2017 20:02:54 +0800 Message-ID: <20170726120255.14292-6-maozy.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170726120255.14292-1-maozy.fnst@cn.fujitsu.com> References: <20170726120255.14292-1-maozy.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.225.76] X-yoursite-MailScanner-ID: 76A5440144EA.A0AF9 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: maozy.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Subject: [Qemu-devel] [PATCH 5/6] hw/block: Use errp directly rather than local_err X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , "Michael S. Tsirkin" , Markus Armbruster , Max Reitz , Keith Busch , Gerd Hoffmann , Stefan Hajnoczi , Paolo Bonzini , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Pass the error message to errp directly rather than the local variable local_err and propagate it to errp via error_propagate(). Cc: John Snow Cc: Kevin Wolf Cc: Max Reitz Cc: Keith Busch Cc: Stefan Hajnoczi Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Cc: Gerd Hoffmann Cc: Markus Armbruster Signed-off-by: Mao Zhongyi --- hw/block/fdc.c | 17 ++++++----------- hw/block/nvme.c | 8 +++----- hw/block/virtio-blk.c | 17 +++++------------ hw/ide/qdev.c | 12 ++++-------- hw/scsi/scsi-disk.c | 13 ++++--------- hw/usb/dev-storage.c | 9 +++------ 6 files changed, 25 insertions(+), 51 deletions(-) diff --git a/hw/block/fdc.c b/hw/block/fdc.c index 02f4a46..e6398c3 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -473,16 +473,13 @@ static void fd_revalidate(FDrive *drv) static void fd_change_cb(void *opaque, bool load, Error **errp) { FDrive *drive =3D opaque; - Error *local_err =3D NULL; =20 if (!load) { blk_set_perm(drive->blk, 0, BLK_PERM_ALL, &error_abort); } else { - blkconf_apply_backend_options(drive->conf, - blk_is_read_only(drive->blk), false, - &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (blkconf_apply_backend_options(drive->conf, + blk_is_read_only(drive->blk), + false, errp) < 0) { return; } } @@ -522,7 +519,6 @@ static void floppy_drive_realize(DeviceState *qdev, Err= or **errp) FloppyDrive *dev =3D FLOPPY_DRIVE(qdev); FloppyBus *bus =3D FLOPPY_BUS(qdev->parent_bus); FDrive *drive; - Error *local_err =3D NULL; int ret; =20 if (dev->unit =3D=3D -1) { @@ -568,10 +564,9 @@ static void floppy_drive_realize(DeviceState *qdev, Er= ror **errp) dev->conf.rerror =3D BLOCKDEV_ON_ERROR_AUTO; dev->conf.werror =3D BLOCKDEV_ON_ERROR_AUTO; =20 - blkconf_apply_backend_options(&dev->conf, blk_is_read_only(dev->conf.b= lk), - false, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (blkconf_apply_backend_options(&dev->conf, + blk_is_read_only(dev->conf.blk), + false, errp) < 0) { return; } =20 diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 43c60ab..2a9d03b 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -928,7 +928,6 @@ static void nvme_realize(PCIDevice *pci_dev, Error **er= rp) int i; int64_t bs_size; uint8_t *pci_conf; - Error *local_err =3D NULL; =20 if (!n->conf.blk) { error_setg(errp, "drive property not set"); @@ -947,10 +946,9 @@ static void nvme_realize(PCIDevice *pci_dev, Error **e= rrp) return; } blkconf_blocksizes(&n->conf); - blkconf_apply_backend_options(&n->conf, blk_is_read_only(n->conf.blk), - false, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (blkconf_apply_backend_options(&n->conf, + blk_is_read_only(n->conf.blk), + false, errp) < 0) { return; } =20 diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index b750bd8..5a4e9d2 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -911,7 +911,6 @@ static void virtio_blk_device_realize(DeviceState *dev,= Error **errp) VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VirtIOBlock *s =3D VIRTIO_BLK(dev); VirtIOBlkConf *conf =3D &s->conf; - Error *err =3D NULL; unsigned i; =20 if (!conf->conf.blk) { @@ -928,17 +927,13 @@ static void virtio_blk_device_realize(DeviceState *de= v, Error **errp) } =20 blkconf_serial(&conf->conf, &conf->serial); - blkconf_apply_backend_options(&conf->conf, - blk_is_read_only(conf->conf.blk), true, - &err); - if (err) { - error_propagate(errp, err); + if (blkconf_apply_backend_options(&conf->conf, + blk_is_read_only(conf->conf.blk), + true, errp) < 0) { return; } s->original_wce =3D blk_enable_write_cache(conf->conf.blk); - blkconf_geometry(&conf->conf, NULL, 65535, 255, 255, &err); - if (err) { - error_propagate(errp, err); + if (blkconf_geometry(&conf->conf, NULL, 65535, 255, 255, errp) < 0) { return; } blkconf_blocksizes(&conf->conf); @@ -953,9 +948,7 @@ static void virtio_blk_device_realize(DeviceState *dev,= Error **errp) for (i =3D 0; i < conf->num_queues; i++) { virtio_add_queue(vdev, 128, virtio_blk_handle_output); } - virtio_blk_data_plane_create(vdev, conf, &s->dataplane, &err); - if (err !=3D NULL) { - error_propagate(errp, err); + if (virtio_blk_data_plane_create(vdev, conf, &s->dataplane, errp) < 0)= { virtio_cleanup(vdev); return; } diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index d60ac25..880b965 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -160,7 +160,6 @@ static void ide_dev_initfn(IDEDevice *dev, IDEDriveKind= kind, Error **errp) { IDEBus *bus =3D DO_UPCAST(IDEBus, qbus, dev->qdev.parent_bus); IDEState *s =3D bus->ifs + dev->unit; - Error *err =3D NULL; int ret; =20 if (!dev->conf.blk) { @@ -191,16 +190,13 @@ static void ide_dev_initfn(IDEDevice *dev, IDEDriveKi= nd kind, Error **errp) =20 blkconf_serial(&dev->conf, &dev->serial); if (kind !=3D IDE_CD) { - blkconf_geometry(&dev->conf, &dev->chs_trans, 65535, 16, 255, &err= ); - if (err) { - error_propagate(errp, err); + if (blkconf_geometry(&dev->conf, &dev->chs_trans, 65535, 16, 255, + errp) < 0) { return; } } - blkconf_apply_backend_options(&dev->conf, kind =3D=3D IDE_CD, kind != =3D IDE_CD, - &err); - if (err) { - error_propagate(errp, err); + if (blkconf_apply_backend_options(&dev->conf, kind =3D=3D IDE_CD, + kind !=3D IDE_CD, errp) < 0) { return; } =20 diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 5f1e5e8..6833819 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -2306,7 +2306,6 @@ static void scsi_disk_unit_attention_reported(SCSIDev= ice *dev) static void scsi_realize(SCSIDevice *dev, Error **errp) { SCSIDiskState *s =3D DO_UPCAST(SCSIDiskState, qdev, dev); - Error *err =3D NULL; =20 if (!s->qdev.conf.blk) { error_setg(errp, "drive property not set"); @@ -2322,17 +2321,13 @@ static void scsi_realize(SCSIDevice *dev, Error **e= rrp) blkconf_serial(&s->qdev.conf, &s->serial); blkconf_blocksizes(&s->qdev.conf); if (dev->type =3D=3D TYPE_DISK) { - blkconf_geometry(&dev->conf, NULL, 65535, 255, 255, &err); - if (err) { - error_propagate(errp, err); + if (blkconf_geometry(&dev->conf, NULL, 65535, 255, 255, errp) < 0)= { return; } } - blkconf_apply_backend_options(&dev->conf, - blk_is_read_only(s->qdev.conf.blk), - dev->type =3D=3D TYPE_DISK, &err); - if (err) { - error_propagate(errp, err); + if (blkconf_apply_backend_options(&dev->conf, + blk_is_read_only(s->qdev.conf.blk), + dev->type =3D=3D TYPE_DISK, errp) < = 0) { return; } =20 diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index 8a61ec9..bd88d6e 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -601,7 +601,6 @@ static void usb_msd_realize_storage(USBDevice *dev, Err= or **errp) MSDState *s =3D USB_STORAGE_DEV(dev); BlockBackend *blk =3D s->conf.blk; SCSIDevice *scsi_dev; - Error *err =3D NULL; =20 if (!blk) { error_setg(errp, "drive property not set"); @@ -610,9 +609,8 @@ static void usb_msd_realize_storage(USBDevice *dev, Err= or **errp) =20 blkconf_serial(&s->conf, &dev->serial); blkconf_blocksizes(&s->conf); - blkconf_apply_backend_options(&s->conf, blk_is_read_only(blk), true, &= err); - if (err) { - error_propagate(errp, err); + if (blkconf_apply_backend_options(&s->conf, blk_is_read_only(blk), + true, errp) < 0) { return; } =20 @@ -636,10 +634,9 @@ static void usb_msd_realize_storage(USBDevice *dev, Er= ror **errp) &usb_msd_scsi_info_storage, NULL); scsi_dev =3D scsi_bus_legacy_add_drive(&s->bus, blk, 0, !!s->removable, s->conf.bootindex, dev->serial, - &err); + errp); blk_unref(blk); if (!scsi_dev) { - error_propagate(errp, err); return; } usb_msd_handle_reset(dev); --=20 2.9.4 From nobody Mon Apr 29 09:40:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501071031151362.81109083951435; Wed, 26 Jul 2017 05:10:31 -0700 (PDT) Received: from localhost ([::1]:37856 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daL92-0006YP-LD for importer@patchew.org; Wed, 26 Jul 2017 08:10:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daL2o-0001Ob-Jz for qemu-devel@nongnu.org; Wed, 26 Jul 2017 08:04:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1daL2i-000059-Ms for qemu-devel@nongnu.org; Wed, 26 Jul 2017 08:04:02 -0400 Received: from [59.151.112.132] (port=46332 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daL2g-0008RI-87; Wed, 26 Jul 2017 08:03:54 -0400 Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 26 Jul 2017 20:03:49 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id 7913F40144EB; Wed, 26 Jul 2017 20:03:46 +0800 (CST) Received: from maozy.g08.fujitsu.local (10.167.225.76) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 26 Jul 2017 20:03:45 +0800 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="21843099" From: Mao Zhongyi To: , Date: Wed, 26 Jul 2017 20:02:55 +0800 Message-ID: <20170726120255.14292-7-maozy.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170726120255.14292-1-maozy.fnst@cn.fujitsu.com> References: <20170726120255.14292-1-maozy.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.225.76] X-yoursite-MailScanner-ID: 7913F40144EB.ACD04 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: maozy.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Subject: [Qemu-devel] [PATCH 6/6] dev-storage: Fix the unusual function name X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The function name of usb_msd_{realize,unrealize}_*, usb_msd_class_initfn_* are unusual. Rename it to usb_msd_*_{realize,unrealize}, usb_msd_class_*_initfn. Cc: Gerd Hoffmann Signed-off-by: Mao Zhongyi --- hw/usb/dev-storage.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index bd88d6e..599c536 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -596,7 +596,7 @@ static void usb_msd_unrealize_storage(USBDevice *dev, E= rror **errp) object_unref(OBJECT(&s->bus)); } =20 -static void usb_msd_realize_storage(USBDevice *dev, Error **errp) +static void usb_msd_storage_realize(USBDevice *dev, Error **errp) { MSDState *s =3D USB_STORAGE_DEV(dev); BlockBackend *blk =3D s->conf.blk; @@ -643,14 +643,14 @@ static void usb_msd_realize_storage(USBDevice *dev, E= rror **errp) s->scsi_dev =3D scsi_dev; } =20 -static void usb_msd_unrealize_bot(USBDevice *dev, Error **errp) +static void usb_msd_bot_unrealize(USBDevice *dev, Error **errp) { MSDState *s =3D USB_STORAGE_DEV(dev); =20 object_unref(OBJECT(&s->bus)); } =20 -static void usb_msd_realize_bot(USBDevice *dev, Error **errp) +static void usb_msd_bot_realize(USBDevice *dev, Error **errp) { MSDState *s =3D USB_STORAGE_DEV(dev); DeviceState *d =3D DEVICE(dev); @@ -764,12 +764,12 @@ static void usb_msd_class_initfn_common(ObjectClass *= klass, void *data) dc->vmsd =3D &vmstate_usb_msd; } =20 -static void usb_msd_class_initfn_storage(ObjectClass *klass, void *data) +static void usb_msd_class_storage_initfn(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); USBDeviceClass *uc =3D USB_DEVICE_CLASS(klass); =20 - uc->realize =3D usb_msd_realize_storage; + uc->realize =3D usb_msd_storage_realize; uc->unrealize =3D usb_msd_unrealize_storage; dc->props =3D msd_properties; } @@ -828,26 +828,26 @@ static void usb_msd_instance_init(Object *obj) object_property_set_int(obj, -1, "bootindex", NULL); } =20 -static void usb_msd_class_initfn_bot(ObjectClass *klass, void *data) +static void usb_msd_class_bot_initfn(ObjectClass *klass, void *data) { USBDeviceClass *uc =3D USB_DEVICE_CLASS(klass); =20 - uc->realize =3D usb_msd_realize_bot; - uc->unrealize =3D usb_msd_unrealize_bot; + uc->realize =3D usb_msd_bot_realize; + uc->unrealize =3D usb_msd_bot_unrealize; uc->attached_settable =3D true; } =20 static const TypeInfo msd_info =3D { .name =3D "usb-storage", .parent =3D TYPE_USB_STORAGE, - .class_init =3D usb_msd_class_initfn_storage, + .class_init =3D usb_msd_class_storage_initfn, .instance_init =3D usb_msd_instance_init, }; =20 static const TypeInfo bot_info =3D { .name =3D "usb-bot", .parent =3D TYPE_USB_STORAGE, - .class_init =3D usb_msd_class_initfn_bot, + .class_init =3D usb_msd_class_bot_initfn, }; =20 static void usb_msd_register_types(void) --=20 2.9.4