mirror of https://github.com/xemu-project/xemu.git
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:
parent
78f1d3d6a6
commit
e01d6a415b
|
@ -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);
|
NvmeCtrl *n = NVME(pci_dev);
|
||||||
NvmeIdCtrl *id = &n->id_ctrl;
|
NvmeIdCtrl *id = &n->id_ctrl;
|
||||||
|
@ -931,24 +931,27 @@ static int nvme_init(PCIDevice *pci_dev)
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
|
|
||||||
if (!n->conf.blk) {
|
if (!n->conf.blk) {
|
||||||
return -1;
|
error_setg(errp, "drive property not set");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bs_size = blk_getlength(n->conf.blk);
|
bs_size = blk_getlength(n->conf.blk);
|
||||||
if (bs_size < 0) {
|
if (bs_size < 0) {
|
||||||
return -1;
|
error_setg(errp, "could not get backing file size");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
blkconf_serial(&n->conf, &n->serial);
|
blkconf_serial(&n->conf, &n->serial);
|
||||||
if (!n->serial) {
|
if (!n->serial) {
|
||||||
return -1;
|
error_setg(errp, "serial property not set");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
blkconf_blocksizes(&n->conf);
|
blkconf_blocksizes(&n->conf);
|
||||||
blkconf_apply_backend_options(&n->conf, blk_is_read_only(n->conf.blk),
|
blkconf_apply_backend_options(&n->conf, blk_is_read_only(n->conf.blk),
|
||||||
false, &local_err);
|
false, &local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
error_report_err(local_err);
|
error_propagate(errp, local_err);
|
||||||
return -1;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pci_conf = pci_dev->config;
|
pci_conf = pci_dev->config;
|
||||||
|
@ -1046,7 +1049,6 @@ static int nvme_init(PCIDevice *pci_dev)
|
||||||
cpu_to_le64(n->ns_size >>
|
cpu_to_le64(n->ns_size >>
|
||||||
id_ns->lbaf[NVME_ID_NS_FLBAS_INDEX(ns->id_ns.flbas)].ds);
|
id_ns->lbaf[NVME_ID_NS_FLBAS_INDEX(ns->id_ns.flbas)].ds);
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nvme_exit(PCIDevice *pci_dev)
|
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);
|
DeviceClass *dc = DEVICE_CLASS(oc);
|
||||||
PCIDeviceClass *pc = PCI_DEVICE_CLASS(oc);
|
PCIDeviceClass *pc = PCI_DEVICE_CLASS(oc);
|
||||||
|
|
||||||
pc->init = nvme_init;
|
pc->realize = nvme_realize;
|
||||||
pc->exit = nvme_exit;
|
pc->exit = nvme_exit;
|
||||||
pc->class_id = PCI_CLASS_STORAGE_EXPRESS;
|
pc->class_id = PCI_CLASS_STORAGE_EXPRESS;
|
||||||
pc->vendor_id = PCI_VENDOR_ID_INTEL;
|
pc->vendor_id = PCI_VENDOR_ID_INTEL;
|
||||||
|
|
Loading…
Reference in New Issue