[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 01/42] ide: ide-cd without drive property for empty d
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 01/42] ide: ide-cd without drive property for empty drive |
Date: |
Mon, 5 Sep 2016 20:13:13 +0200 |
This allows the creation of an empty ide-cd device without manually
creating a BlockBackend.
Signed-off-by: Kevin Wolf <address@hidden>
Acked-by: Eric Blake <address@hidden>
---
hw/ide/qdev.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 67c76bf..2eb055a 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -75,10 +75,6 @@ static int ide_qdev_init(DeviceState *qdev)
IDEDeviceClass *dc = IDE_DEVICE_GET_CLASS(dev);
IDEBus *bus = DO_UPCAST(IDEBus, qbus, qdev->parent_bus);
- if (!dev->conf.blk) {
- error_report("No drive specified");
- goto err;
- }
if (dev->unit == -1) {
dev->unit = bus->master ? 1 : 0;
}
@@ -158,6 +154,16 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind
kind)
IDEState *s = bus->ifs + dev->unit;
Error *err = NULL;
+ if (!dev->conf.blk) {
+ if (kind != IDE_CD) {
+ error_report("No drive specified");
+ return -1;
+ } else {
+ /* Anonymous BlockBackend for an empty drive */
+ dev->conf.blk = blk_new();
+ }
+ }
+
if (dev->conf.discard_granularity == -1) {
dev->conf.discard_granularity = 512;
} else if (dev->conf.discard_granularity &&
@@ -257,7 +263,11 @@ static int ide_cd_initfn(IDEDevice *dev)
static int ide_drive_initfn(IDEDevice *dev)
{
- DriveInfo *dinfo = blk_legacy_dinfo(dev->conf.blk);
+ DriveInfo *dinfo = NULL;
+
+ if (dev->conf.blk) {
+ dinfo = blk_legacy_dinfo(dev->conf.blk);
+ }
return ide_dev_initfn(dev, dinfo && dinfo->media_cd ? IDE_CD : IDE_HD);
}
--
1.8.3.1
- [Qemu-devel] [PULL 00/42] Block layer patches, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 04/42] block: Accept node-name for block-commit, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 02/42] scsi: scsi-cd without drive property for empty drive, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 03/42] block: Accept node-name for block-stream, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 06/42] block: Accept node-name for blockdev-mirror, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 05/42] block: Accept node-name for blockdev-backup, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 01/42] ide: ide-cd without drive property for empty drive,
Kevin Wolf <=
- [Qemu-devel] [PULL 09/42] block: Accept node-name for change-backing-file, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 08/42] block: Accept node-name for blockdev-snapshot-internal-sync, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 12/42] nbd-server: Use a separate BlockBackend, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 07/42] block: Accept node-name for blockdev-snapshot-delete-internal-sync, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 15/42] block: Convert bdrv_pwrite_compressed() to BdrvChild, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 16/42] block/io: reuse bdrv_co_pwritev() for write compressed, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 19/42] vmdk: add vmdk_co_pwritev_compressed, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 13/42] nbd-server: Allow node name for nbd-server-add, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 14/42] block: switch blk_write_compressed() to byte-based interface, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 10/42] block: Accept node-name for drive-backup, Kevin Wolf, 2016/09/05