From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, mreitz@redhat.com, eblake@redhat.com,
jsnow@redhat.com, pbonzini@redhat.com, armbru@redhat.com,
qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v2 7/9] scsi-disk: bdrv_attach_dev() for empty CD-ROM
Date: Thu, 13 Jul 2017 13:41:33 +0200 [thread overview]
Message-ID: <1499946095-8224-8-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1499946095-8224-1-git-send-email-kwolf@redhat.com>
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().
This fixes at least a segfault when unplugging such devices, the bug
that they didn't show up in query-block, and probably some more
problems.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
hw/scsi/scsi-disk.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index a53f058..5f1e5e8 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;
--
1.8.3.1
next prev parent reply other threads:[~2017-07-13 11:42 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-13 11:41 [Qemu-devel] [PATCH v2 0/9] block: -device drive=<node-name> fixes Kevin Wolf
2017-07-13 11:41 ` [Qemu-devel] [PATCH v2 1/9] block: Make blk_get_attached_dev_id() public Kevin Wolf
2017-07-13 11:41 ` [Qemu-devel] [PATCH v2 2/9] block/qapi: Add qdev device name to query-block Kevin Wolf
2017-07-13 11:41 ` [Qemu-devel] [PATCH v2 3/9] block: Make blk_all_next() public Kevin Wolf
2017-07-13 11:41 ` [Qemu-devel] [PATCH v2 4/9] block/qapi: Use blk_all_next() for query-block Kevin Wolf
2017-07-13 11:41 ` [Qemu-devel] [PATCH v2 5/9] block: List anonymous device BBs in query-block Kevin Wolf
2017-07-13 11:41 ` [Qemu-devel] [PATCH v2 6/9] ide: bdrv_attach_dev() for empty CD-ROM Kevin Wolf
2017-07-13 11:41 ` Kevin Wolf [this message]
2017-07-13 11:41 ` [Qemu-devel] [PATCH v2 8/9] qemu-iotests: Test 'info block' Kevin Wolf
2017-07-13 11:41 ` [Qemu-devel] [PATCH v2 9/9] qemu-iotests: Test unplug of -device without drive Kevin Wolf
2017-07-13 21:34 ` [Qemu-devel] [PATCH v2 0/9] block: -device drive=<node-name> fixes John Snow
2017-07-17 11:31 ` Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1499946095-8224-8-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=jsnow@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).