From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Mao Zhongyi <maozy.fnst@cn.fujitsu.com>,
John Snow <jsnow@redhat.com>, Keith Busch <keith.busch@intel.com>,
Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PULL 02/23] hw/block/nvme: Convert to realize
Date: Mon, 18 Dec 2017 14:35:09 +0000 [thread overview]
Message-ID: <20171218143530.12082-3-stefanha@redhat.com> (raw)
In-Reply-To: <20171218143530.12082-1-stefanha@redhat.com>
From: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
Convert nvme_init() to realize and rename it to nvme_realize().
Cc: John Snow <jsnow@redhat.com>
Cc: Keith Busch <keith.busch@intel.com>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Max Reitz <mreitz@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
Message-id: 2882e72d795e04cbe2120f569d551aef2467ac60.1511317952.git.maozy.fnst@cn.fujitsu.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
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 441e21ed1f..e530ba7a30 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -920,7 +920,7 @@ static const MemoryRegionOps nvme_cmb_ops = {
},
};
-static int nvme_init(PCIDevice *pci_dev)
+static void nvme_realize(PCIDevice *pci_dev, Error **errp)
{
NvmeCtrl *n = NVME(pci_dev);
NvmeIdCtrl *id = &n->id_ctrl;
@@ -931,24 +931,27 @@ static int nvme_init(PCIDevice *pci_dev)
Error *local_err = NULL;
if (!n->conf.blk) {
- return -1;
+ error_setg(errp, "drive property not set");
+ return;
}
bs_size = blk_getlength(n->conf.blk);
if (bs_size < 0) {
- return -1;
+ error_setg(errp, "could not get backing file size");
+ return;
}
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;
}
pci_conf = 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;
}
static void nvme_exit(PCIDevice *pci_dev)
@@ -1081,7 +1083,7 @@ static void nvme_class_init(ObjectClass *oc, void *data)
DeviceClass *dc = DEVICE_CLASS(oc);
PCIDeviceClass *pc = PCI_DEVICE_CLASS(oc);
- pc->init = nvme_init;
+ pc->realize = nvme_realize;
pc->exit = nvme_exit;
pc->class_id = PCI_CLASS_STORAGE_EXPRESS;
pc->vendor_id = PCI_VENDOR_ID_INTEL;
--
2.14.3
next prev parent reply other threads:[~2017-12-18 14:36 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-18 14:35 [Qemu-devel] [PULL 00/23] Block patches Stefan Hajnoczi
2017-12-18 14:35 ` [Qemu-devel] [PULL 01/23] coroutine: simplify co_aio_sleep_ns() prototype Stefan Hajnoczi
2017-12-18 14:35 ` Stefan Hajnoczi [this message]
2017-12-18 14:35 ` [Qemu-devel] [PULL 03/23] hw/block: Fix the return type Stefan Hajnoczi
2017-12-18 14:35 ` [Qemu-devel] [PULL 04/23] hw/block: Use errp directly rather than local_err Stefan Hajnoczi
2017-12-18 14:35 ` [Qemu-devel] [PULL 05/23] dev-storage: Fix the unusual function name Stefan Hajnoczi
2017-12-18 14:35 ` [Qemu-devel] [PULL 06/23] qdev: drop unused #include "sysemu/iothread.h" Stefan Hajnoczi
2017-12-18 14:35 ` [Qemu-devel] [PULL 07/23] blockdev: hold AioContext for bdrv_unref() in external_snapshot_clean() Stefan Hajnoczi
2017-12-18 14:35 ` [Qemu-devel] [PULL 08/23] block: don't keep AioContext acquired after external_snapshot_prepare() Stefan Hajnoczi
2017-12-18 14:35 ` [Qemu-devel] [PULL 09/23] block: don't keep AioContext acquired after drive_backup_prepare() Stefan Hajnoczi
2017-12-18 14:35 ` [Qemu-devel] [PULL 10/23] block: don't keep AioContext acquired after blockdev_backup_prepare() Stefan Hajnoczi
2017-12-18 14:35 ` [Qemu-devel] [PULL 11/23] block: don't keep AioContext acquired after internal_snapshot_prepare() Stefan Hajnoczi
2017-12-18 14:35 ` [Qemu-devel] [PULL 12/23] block: drop unused BlockDirtyBitmapState->aio_context field Stefan Hajnoczi
2017-12-18 14:35 ` [Qemu-devel] [PULL 13/23] iothread: add iothread_by_id() API Stefan Hajnoczi
2017-12-18 14:35 ` [Qemu-devel] [PULL 14/23] blockdev: add x-blockdev-set-iothread testing command Stefan Hajnoczi
2017-12-18 14:35 ` [Qemu-devel] [PULL 15/23] qemu-iotests: add 202 external snapshots IOThread test Stefan Hajnoczi
2017-12-18 14:35 ` [Qemu-devel] [PULL 16/23] virtio-blk: make queue size configurable Stefan Hajnoczi
2017-12-18 14:35 ` [Qemu-devel] [PULL 17/23] virtio-blk: reject configs with logical block size > physical block size Stefan Hajnoczi
2017-12-18 14:35 ` [Qemu-devel] [PULL 18/23] block: avoid recursive AioContext acquire in bdrv_inactivate_all() Stefan Hajnoczi
2017-12-18 14:35 ` [Qemu-devel] [PULL 19/23] docs: mark nested AioContext locking as a legacy API Stefan Hajnoczi
2017-12-18 14:35 ` [Qemu-devel] [PULL 20/23] blockdev: add x-blockdev-set-iothread force boolean Stefan Hajnoczi
2017-12-18 14:35 ` [Qemu-devel] [PULL 21/23] iotests: add VM.add_object() Stefan Hajnoczi
2017-12-18 14:35 ` [Qemu-devel] [PULL 22/23] iothread: fix iothread_stop() race condition Stefan Hajnoczi
2017-12-18 14:35 ` [Qemu-devel] [PULL 23/23] qemu-iotests: add 203 savevm with IOThreads test Stefan Hajnoczi
2017-12-19 0:15 ` [Qemu-devel] [PULL 00/23] Block patches Peter Maydell
2017-12-19 9:15 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171218143530.12082-3-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=armbru@redhat.com \
--cc=jsnow@redhat.com \
--cc=keith.busch@intel.com \
--cc=kwolf@redhat.com \
--cc=maozy.fnst@cn.fujitsu.com \
--cc=mreitz@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).