{"id":814953,"url":"http://patchwork.ozlabs.org/api/patches/814953/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/87119b34f32e2acf7166165fb5d8e6fca787b3bc.1505737465.git.maozy.fnst@cn.fujitsu.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<87119b34f32e2acf7166165fb5d8e6fca787b3bc.1505737465.git.maozy.fnst@cn.fujitsu.com>","list_archive_url":null,"date":"2017-09-18T14:05:14","name":"[v3,2/6] hw/block/fdc: Convert to realize","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"c519d1b35c406d3e6e41e57d58131a51e26be116","submitter":{"id":71231,"url":"http://patchwork.ozlabs.org/api/people/71231/?format=json","name":"Mao Zhongyi","email":"maozy.fnst@cn.fujitsu.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/87119b34f32e2acf7166165fb5d8e6fca787b3bc.1505737465.git.maozy.fnst@cn.fujitsu.com/mbox/","series":[{"id":3655,"url":"http://patchwork.ozlabs.org/api/series/3655/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=3655","date":"2017-09-18T14:05:14","name":"Convert to realize and improve error handling","version":3,"mbox":"http://patchwork.ozlabs.org/series/3655/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/814953/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/814953/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xwntW5CKlz9s7G\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 19 Sep 2017 00:09:06 +1000 (AEST)","from localhost ([::1]:36838 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dtwjQ-0000ps-Al\n\tfor incoming@patchwork.ozlabs.org; Mon, 18 Sep 2017 10:09:04 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:42950)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <maozy.fnst@cn.fujitsu.com>) id 1dtwiW-0000iH-IN\n\tfor qemu-devel@nongnu.org; Mon, 18 Sep 2017 10:08:11 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <maozy.fnst@cn.fujitsu.com>) id 1dtwiO-0006OU-C6\n\tfor qemu-devel@nongnu.org; Mon, 18 Sep 2017 10:08:08 -0400","from mail.cn.fujitsu.com ([183.91.158.132]:20987\n\thelo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <maozy.fnst@cn.fujitsu.com>) id 1dtwiN-0006Nj-OF\n\tfor qemu-devel@nongnu.org; Mon, 18 Sep 2017 10:08:00 -0400","from localhost (HELO cn.fujitsu.com) ([10.167.33.5])\n\tby heian.cn.fujitsu.com with ESMTP; 18 Sep 2017 22:07:50 +0800","from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85])\n\tby cn.fujitsu.com (Postfix) with ESMTP id DC8F647ACDAF;\n\tMon, 18 Sep 2017 22:07:46 +0800 (CST)","from maozy.g08.fujitsu.local (10.167.225.76) by\n\tG08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP\n\tServer (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 <maozy.fnst@cn.fujitsu.com>","To":"<qemu-devel@nongnu.org>","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":"<cover.1505737465.git.maozy.fnst@cn.fujitsu.com>","References":"<cover.1505737465.git.maozy.fnst@cn.fujitsu.com>","MIME-Version":"1.0","Content-Type":"text/plain","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\n\trecognized.","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":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Kevin Wolf <kwolf@redhat.com>, John Snow <jsnow@redhat.com>,\n\tMarkus Armbruster <armbru@redhat.com>, Max Reitz <mreitz@redhat.com>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"},"content":"Convert floppy_drive_init() to realize and rename it to\nfloppy_drive_realize().\n\nCc: John Snow <jsnow@redhat.com>\nCc: Kevin Wolf <kwolf@redhat.com>\nCc: Max Reitz <mreitz@redhat.com>\nCc: Markus Armbruster <armbru@redhat.com>\n\nSigned-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>\n---\n hw/block/fdc.c             | 33 ++++++++++++++++-----------------\n tests/qemu-iotests/172.out |  8 --------\n 2 files changed, 16 insertions(+), 25 deletions(-)","diff":"diff --git a/hw/block/fdc.c b/hw/block/fdc.c\nindex db40e17..2853cdc 100644\n--- a/hw/block/fdc.c\n+++ b/hw/block/fdc.c\n@@ -517,7 +517,7 @@ static Property floppy_drive_properties[] = {\n     DEFINE_PROP_END_OF_LIST(),\n };\n \n-static int floppy_drive_init(DeviceState *qdev)\n+static void floppy_drive_realize(DeviceState *qdev, Error **errp)\n {\n     FloppyDrive *dev = FLOPPY_DRIVE(qdev);\n     FloppyBus *bus = FLOPPY_BUS(qdev->parent_bus);\n@@ -535,15 +535,15 @@ static int floppy_drive_init(DeviceState *qdev)\n     }\n \n     if (dev->unit >= MAX_FD) {\n-        error_report(\"Can't create floppy unit %d, bus supports only %d units\",\n-                     dev->unit, MAX_FD);\n-        return -1;\n+        error_setg(errp, \"Can't create floppy unit %d, bus supports \"\n+                   \"only %d units\", dev->unit, MAX_FD);\n+        return;\n     }\n \n     drive = get_drv(bus->fdc, dev->unit);\n     if (drive->blk) {\n-        error_report(\"Floppy unit %d is in use\", dev->unit);\n-        return -1;\n+        error_setg(errp, \"Floppy unit %d is in use\", dev->unit);\n+        return;\n     }\n \n     if (!dev->conf.blk) {\n@@ -557,8 +557,9 @@ static int floppy_drive_init(DeviceState *qdev)\n     if (dev->conf.logical_block_size != 512 ||\n         dev->conf.physical_block_size != 512)\n     {\n-        error_report(\"Physical and logical block size must be 512 for floppy\");\n-        return -1;\n+        error_setg(errp, \"Physical and logical block size must \"\n+                   \"be 512 for floppy\");\n+        return;\n     }\n \n     /* rerror/werror aren't supported by fdc and therefore not even registered\n@@ -570,20 +571,20 @@ static int floppy_drive_init(DeviceState *qdev)\n     blkconf_apply_backend_options(&dev->conf, blk_is_read_only(dev->conf.blk),\n                                   false, &local_err);\n     if (local_err) {\n-        error_report_err(local_err);\n-        return -1;\n+        error_propagate(errp, local_err);\n+        return;\n     }\n \n     /* 'enospc' is the default for -drive, 'report' is what blk_new() gives us\n      * for empty drives. */\n     if (blk_get_on_error(dev->conf.blk, 0) != BLOCKDEV_ON_ERROR_ENOSPC &&\n         blk_get_on_error(dev->conf.blk, 0) != BLOCKDEV_ON_ERROR_REPORT) {\n-        error_report(\"fdc doesn't support drive option werror\");\n-        return -1;\n+        error_setg(errp, \"fdc doesn't support drive option werror\");\n+        return;\n     }\n     if (blk_get_on_error(dev->conf.blk, 1) != BLOCKDEV_ON_ERROR_REPORT) {\n-        error_report(\"fdc doesn't support drive option rerror\");\n-        return -1;\n+        error_setg(errp, \"fdc doesn't support drive option rerror\");\n+        return;\n     }\n \n     drive->conf = &dev->conf;\n@@ -599,14 +600,12 @@ static int floppy_drive_init(DeviceState *qdev)\n     dev->type = drive->drive;\n \n     fd_revalidate(drive);\n-\n-    return 0;\n }\n \n static void floppy_drive_class_init(ObjectClass *klass, void *data)\n {\n     DeviceClass *k = DEVICE_CLASS(klass);\n-    k->init = floppy_drive_init;\n+    k->realize = floppy_drive_realize;\n     set_bit(DEVICE_CATEGORY_STORAGE, k->categories);\n     k->bus_type = TYPE_FLOPPY_BUS;\n     k->props = floppy_drive_properties;\ndiff --git a/tests/qemu-iotests/172.out b/tests/qemu-iotests/172.out\nindex 2732966..7abbe82 100644\n--- a/tests/qemu-iotests/172.out\n+++ b/tests/qemu-iotests/172.out\n@@ -725,11 +725,9 @@ Testing: -fdb TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl\n \n Testing: -fda TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device floppy,drive=none0,unit=0\n QEMU_PROG: -device floppy,drive=none0,unit=0: Floppy unit 0 is in use\n-QEMU_PROG: -device floppy,drive=none0,unit=0: Device initialization failed.\n \n Testing: -fdb TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device floppy,drive=none0,unit=1\n QEMU_PROG: -device floppy,drive=none0,unit=1: Floppy unit 1 is in use\n-QEMU_PROG: -device floppy,drive=none0,unit=1: Device initialization failed.\n \n \n === Mixing -drive and -device ===\n@@ -812,7 +810,6 @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.q\n \n Testing: -drive if=floppy,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device floppy,drive=none0,unit=0\n QEMU_PROG: -device floppy,drive=none0,unit=0: Floppy unit 0 is in use\n-QEMU_PROG: -device floppy,drive=none0,unit=0: Device initialization failed.\n \n \n === Mixing -global and -device ===\n@@ -971,18 +968,15 @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qco\n \n Testing: -drive if=none,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -global isa-fdc.driveA=none0 -device floppy,drive=none1,unit=0\n QEMU_PROG: -device floppy,drive=none1,unit=0: Floppy unit 0 is in use\n-QEMU_PROG: -device floppy,drive=none1,unit=0: Device initialization failed.\n \n Testing: -drive if=none,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -global isa-fdc.driveB=none0 -device floppy,drive=none1,unit=1\n QEMU_PROG: -device floppy,drive=none1,unit=1: Floppy unit 1 is in use\n-QEMU_PROG: -device floppy,drive=none1,unit=1: Device initialization failed.\n \n \n === Too many floppy drives ===\n \n Testing: -drive if=floppy,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -drive if=none,file=TEST_DIR/t.qcow2.3 -global isa-fdc.driveB=none0 -device floppy,drive=none1\n QEMU_PROG: -device floppy,drive=none1: Can't create floppy unit 2, bus supports only 2 units\n-QEMU_PROG: -device floppy,drive=none1: Device initialization failed.\n \n \n === Creating an empty drive with anonymous BB ===\n@@ -1211,11 +1205,9 @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0,physica\n \n Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0,logical_block_size=4096\n QEMU_PROG: -device floppy,drive=none0,logical_block_size=4096: Physical and logical block size must be 512 for floppy\n-QEMU_PROG: -device floppy,drive=none0,logical_block_size=4096: Device initialization failed.\n \n Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0,physical_block_size=1024\n QEMU_PROG: -device floppy,drive=none0,physical_block_size=1024: Physical and logical block size must be 512 for floppy\n-QEMU_PROG: -device floppy,drive=none0,physical_block_size=1024: Device initialization failed.\n \n \n === Writethrough caching ===\n","prefixes":["v3","2/6"]}