Skip to content

Commit

Permalink
hw/block/nvme: Convert to realize
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Mao Zhongyi authored and stefanhaRH committed Dec 19, 2017
1 parent 78f1d3d commit e01d6a4
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions hw/block/nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e01d6a4

Please sign in to comment.