[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 4/6] block: Acquire the AioContext in nvme_realize()
From: |
Alberto Garcia |
Subject: |
[Qemu-devel] [PATCH 4/6] block: Acquire the AioContext in nvme_realize() |
Date: |
Thu, 10 Jan 2019 17:03:38 +0200 |
Signed-off-by: Alberto Garcia <address@hidden>
---
hw/block/nvme.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 7c8c63e8f5..72e94aff86 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -1203,6 +1203,7 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp)
{
NvmeCtrl *n = NVME(pci_dev);
NvmeIdCtrl *id = &n->id_ctrl;
+ AioContext *ctx;
int i;
int64_t bs_size;
@@ -1213,20 +1214,23 @@ static void nvme_realize(PCIDevice *pci_dev, Error
**errp)
return;
}
+ ctx = blk_get_aio_context(n->conf.blk);
+ aio_context_acquire(ctx);
+
bs_size = blk_getlength(n->conf.blk);
if (bs_size < 0) {
error_setg(errp, "could not get backing file size");
- return;
+ goto out;
}
if (!n->serial) {
error_setg(errp, "serial property not set");
- return;
+ goto out;
}
blkconf_blocksizes(&n->conf);
if (!blkconf_apply_backend_options(&n->conf, blk_is_read_only(n->conf.blk),
false, errp)) {
- return;
+ goto out;
}
pci_conf = pci_dev->config;
@@ -1323,6 +1327,9 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp)
cpu_to_le64(n->ns_size >>
id_ns->lbaf[NVME_ID_NS_FLBAS_INDEX(ns->id_ns.flbas)].ds);
}
+
+out:
+ aio_context_release(ctx);
}
static void nvme_exit(PCIDevice *pci_dev)
--
2.11.0
- [Qemu-devel] [PATCH 0/6] Acquire the AioContext during _realize(), Alberto Garcia, 2019/01/10
- [Qemu-devel] [PATCH 5/6] block: Acquire the AioContext in ide_dev_initfn(), Alberto Garcia, 2019/01/10
- [Qemu-devel] [PATCH 1/6] block: Acquire the AioContext in virtio_blk_device_realize(), Alberto Garcia, 2019/01/10
- Re: [Qemu-devel] [PATCH 0/6] Acquire the AioContext during _realize(), Markus Armbruster, 2019/01/11
- Re: [Qemu-devel] [PATCH 0/6] Acquire the AioContext during _realize(), Kevin Wolf, 2019/01/11