aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2017-07-19 10:48:31 +0100
committerPeter Maydell <peter.maydell@linaro.org>2017-07-19 10:48:31 +0100
commitf1a46e888515c6b49f3d43f938a9c17acac831f5 (patch)
tree59634db84fc7e9c7c616b26401a8afb8175c0353 /hw
parent63cb55783c5e8f783b1dcebd3a2935941f872d44 (diff)
parent6e6e55f5c2e5b520d6506c2716287ba3b5d1bbc8 (diff)
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Block layer patches # gpg: Signature made Tue 18 Jul 2017 14:29:59 BST # gpg: using RSA key 0x7F09B272C88F2FD6 # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" # Primary key fingerprint: DC3D EB15 9A9A F95D 3D74 56FE 7F09 B272 C88F 2FD6 * remotes/kevin/tags/for-upstream: (21 commits) qemu-img: Check for backing image if specified during create blockdev: move BDRV_O_NO_BACKING option forward block/vvfat: Fix compiler warning with gcc 7 vvfat: initialize memory after allocating it vvfat: correctly parse non-ASCII short and long file names vvfat: add a constant for bootsector name vvfat: add constants for special values of name[0] qemu-iotests: Test unplug of -device without drive qemu-iotests: Test 'info block' scsi-disk: bdrv_attach_dev() for empty CD-ROM ide: bdrv_attach_dev() for empty CD-ROM block: List anonymous device BBs in query-block block/qapi: Use blk_all_next() for query-block block: Make blk_all_next() public block/qapi: Add qdev device name to query-block block: Make blk_get_attached_dev_id() public block/vpc.c: Handle write failures in get_image_offset() block/vmdk: Report failures in vmdk_read_cid() block: remove timer canceling in throttle_config() block: add clock_type field to ThrottleGroup ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw')
-rw-r--r--hw/ide/qdev.c3
-rw-r--r--hw/scsi/scsi-disk.c5
2 files changed, 8 insertions, 0 deletions
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 299e592fa2..cc2f5bd280 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);
}
}
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index a53f058621..5f1e5e8070 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -2384,9 +2384,14 @@ static void scsi_hd_realize(SCSIDevice *dev, Error **errp)
static void scsi_cd_realize(SCSIDevice *dev, Error **errp)
{
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev);
+ int ret;
if (!dev->conf.blk) {
+ /* Anonymous BlockBackend for an empty drive. As we put it into
+ * dev->conf, qdev takes care of detaching on unplug. */
dev->conf.blk = blk_new(0, BLK_PERM_ALL);
+ ret = blk_attach_dev(dev->conf.blk, &dev->qdev);
+ assert(ret == 0);
}
s->qdev.blocksize = 2048;