hw/block/nvme: Convert to realize

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>
This commit is contained in:
Mao Zhongyi 2017-11-22 11:08:43 +08:00 committed by Stefan Hajnoczi
parent 78f1d3d6a6
commit e01d6a415b
1 changed files with 10 additions and 8 deletions

View File

@ -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;