From nobody Mon Feb 9 22:38:12 2026 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 1505743815234455.3532352452179; Mon, 18 Sep 2017 07:10:15 -0700 (PDT) Received: from localhost ([::1]:36848 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtwkY-0002An-A7 for importer@patchew.org; Mon, 18 Sep 2017 10:10:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42950) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtwiW-0000iH-IN for qemu-devel@nongnu.org; Mon, 18 Sep 2017 10:08:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtwiO-0006OU-C6 for qemu-devel@nongnu.org; Mon, 18 Sep 2017 10:08:08 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:20987 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtwiN-0006Nj-OF for qemu-devel@nongnu.org; Mon, 18 Sep 2017 10:08:00 -0400 Received: from localhost (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 18 Sep 2017 22:07:50 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id DC8F647ACDAF; Mon, 18 Sep 2017 22:07:46 +0800 (CST) Received: from maozy.g08.fujitsu.local (10.167.225.76) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.361.1; Mon, 18 Sep 2017 22:07:49 +0800 X-IronPort-AV: E=Sophos;i="5.42,413,1500912000"; d="scan'208";a="26773966" From: Mao Zhongyi To: Date: Mon, 18 Sep 2017 22:05:14 +0800 Message-ID: <87119b34f32e2acf7166165fb5d8e6fca787b3bc.1505737465.git.maozy.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.167.225.76] X-yoursite-MailScanner-ID: DC8F647ACDAF.A5887 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: 183.91.158.132 Subject: [Qemu-devel] [PATCH v3 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 ++++++++++++++++----------------- tests/qemu-iotests/172.out | 8 -------- 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/hw/block/fdc.c b/hw/block/fdc.c index db40e17..2853cdc 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; diff --git a/tests/qemu-iotests/172.out b/tests/qemu-iotests/172.out index 2732966..7abbe82 100644 --- a/tests/qemu-iotests/172.out +++ b/tests/qemu-iotests/172.out @@ -725,11 +725,9 @@ Testing: -fdb TEST_DIR/t.qcow2 -drive if=3Dnone,file= =3DTEST_DIR/t.qcow2.2 -device fl =20 Testing: -fda TEST_DIR/t.qcow2 -drive if=3Dnone,file=3DTEST_DIR/t.qcow2.2 = -device floppy,drive=3Dnone0,unit=3D0 QEMU_PROG: -device floppy,drive=3Dnone0,unit=3D0: Floppy unit 0 is in use -QEMU_PROG: -device floppy,drive=3Dnone0,unit=3D0: Device initialization fa= iled. =20 Testing: -fdb TEST_DIR/t.qcow2 -drive if=3Dnone,file=3DTEST_DIR/t.qcow2.2 = -device floppy,drive=3Dnone0,unit=3D1 QEMU_PROG: -device floppy,drive=3Dnone0,unit=3D1: Floppy unit 1 is in use -QEMU_PROG: -device floppy,drive=3Dnone0,unit=3D1: Device initialization fa= iled. =20 =20 =3D=3D=3D Mixing -drive and -device =3D=3D=3D @@ -812,7 +810,6 @@ Testing: -drive if=3Dfloppy,file=3DTEST_DIR/t.qcow2 -dr= ive if=3Dnone,file=3DTEST_DIR/t.q =20 Testing: -drive if=3Dfloppy,file=3DTEST_DIR/t.qcow2 -drive if=3Dnone,file= =3DTEST_DIR/t.qcow2.2 -device floppy,drive=3Dnone0,unit=3D0 QEMU_PROG: -device floppy,drive=3Dnone0,unit=3D0: Floppy unit 0 is in use -QEMU_PROG: -device floppy,drive=3Dnone0,unit=3D0: Device initialization fa= iled. =20 =20 =3D=3D=3D Mixing -global and -device =3D=3D=3D @@ -971,18 +968,15 @@ Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -dr= ive if=3Dnone,file=3DTEST_DIR/t.qco =20 Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -drive if=3Dnone,file=3D= TEST_DIR/t.qcow2.2 -global isa-fdc.driveA=3Dnone0 -device floppy,drive=3Dno= ne1,unit=3D0 QEMU_PROG: -device floppy,drive=3Dnone1,unit=3D0: Floppy unit 0 is in use -QEMU_PROG: -device floppy,drive=3Dnone1,unit=3D0: Device initialization fa= iled. =20 Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -drive if=3Dnone,file=3D= TEST_DIR/t.qcow2.2 -global isa-fdc.driveB=3Dnone0 -device floppy,drive=3Dno= ne1,unit=3D1 QEMU_PROG: -device floppy,drive=3Dnone1,unit=3D1: Floppy unit 1 is in use -QEMU_PROG: -device floppy,drive=3Dnone1,unit=3D1: Device initialization fa= iled. =20 =20 =3D=3D=3D Too many floppy drives =3D=3D=3D =20 Testing: -drive if=3Dfloppy,file=3DTEST_DIR/t.qcow2 -drive if=3Dnone,file= =3DTEST_DIR/t.qcow2.2 -drive if=3Dnone,file=3DTEST_DIR/t.qcow2.3 -global is= a-fdc.driveB=3Dnone0 -device floppy,drive=3Dnone1 QEMU_PROG: -device floppy,drive=3Dnone1: Can't create floppy unit 2, bus s= upports only 2 units -QEMU_PROG: -device floppy,drive=3Dnone1: Device initialization failed. =20 =20 =3D=3D=3D Creating an empty drive with anonymous BB =3D=3D=3D @@ -1211,11 +1205,9 @@ Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -d= evice floppy,drive=3Dnone0,physica =20 Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -device floppy,drive=3Dn= one0,logical_block_size=3D4096 QEMU_PROG: -device floppy,drive=3Dnone0,logical_block_size=3D4096: Physica= l and logical block size must be 512 for floppy -QEMU_PROG: -device floppy,drive=3Dnone0,logical_block_size=3D4096: Device = initialization failed. =20 Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -device floppy,drive=3Dn= one0,physical_block_size=3D1024 QEMU_PROG: -device floppy,drive=3Dnone0,physical_block_size=3D1024: Physic= al and logical block size must be 512 for floppy -QEMU_PROG: -device floppy,drive=3Dnone0,physical_block_size=3D1024: Device= initialization failed. =20 =20 =3D=3D=3D Writethrough caching =3D=3D=3D --=20 2.9.4