[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH 6/9] ide: bdrv_attach_dev() for empty CD-ROM
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PATCH 6/9] ide: bdrv_attach_dev() for empty CD-ROM |
Date: |
Wed, 12 Jul 2017 14:57:26 +0200 |
If no drive=... option is passed (for an empty drive), we don't only
lack the BlockBackend normally created by parse_drive(), but we also
need to manually call blk_attach_dev().
IDE does not support hot unplug, but if it did, qdev would take care to
call the matching blk_detach_dev() on unplug.
This fixes at least the bug that such devices didn't show up in
query-block, and probably some more problems.
Signed-off-by: Kevin Wolf <address@hidden>
---
hw/ide/qdev.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 299e592..cc2f5bd 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -164,6 +164,7 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
IDEBus *bus = DO_UPCAST(IDEBus, qbus, dev->qdev.parent_bus);
IDEState *s = bus->ifs + dev->unit;
Error *err = NULL;
+ int ret;
if (!dev->conf.blk) {
if (kind != IDE_CD) {
@@ -172,6 +173,8 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
} else {
/* Anonymous BlockBackend for an empty drive */
dev->conf.blk = blk_new(0, BLK_PERM_ALL);
+ ret = blk_attach_dev(dev->conf.blk, &dev->qdev);
+ assert(ret == 0);
}
}
--
1.8.3.1
- Re: [Qemu-block] [PATCH 1/9] block: Make blk_get_attached_dev_id() public, (continued)
- [Qemu-block] [PATCH 3/9] block: Make blk_all_next() public, Kevin Wolf, 2017/07/12
- [Qemu-block] [PATCH 2/9] block/qapi: Add qdev device name to query-block, Kevin Wolf, 2017/07/12
- [Qemu-block] [PATCH 4/9] block/qapi: Use blk_all_next() for query-block, Kevin Wolf, 2017/07/12
- [Qemu-block] [PATCH 5/9] block: List anonymous device BBs in query-block, Kevin Wolf, 2017/07/12
- [Qemu-block] [PATCH 6/9] ide: bdrv_attach_dev() for empty CD-ROM,
Kevin Wolf <=
- [Qemu-block] [PATCH 7/9] scsi-disk: bdrv_attach_dev() for empty CD-ROM, Kevin Wolf, 2017/07/12
- [Qemu-block] [PATCH 8/9] qemu-iotests: Test 'info block', Kevin Wolf, 2017/07/12
- [Qemu-block] [PATCH 9/9] qemu-iotests: Test unplug of -device without drive, Kevin Wolf, 2017/07/12