* [Qemu-devel] [PULL 0/3] Block patches for 2.9.0-rc4
@ 2017-04-11 13:44 Max Reitz
2017-04-11 13:44 ` [Qemu-devel] [PULL 1/3] block: pass the right options for BlockDriver.bdrv_open() Max Reitz
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Max Reitz @ 2017-04-11 13:44 UTC (permalink / raw)
To: qemu-block; +Cc: qemu-devel, Max Reitz, Peter Maydell
The following changes since commit aa388ddc36e8032f41cd17bef88cc3ebaeba77c9:
Merge remote-tracking branch 'remotes/famz/tags/block-pull-request' into staging (2017-04-11 13:27:05 +0100)
are available in the git repository at:
git://github.com/XanClic/qemu.git tags/pull-block-2017-04-11
for you to fetch changes up to 2ec9a782d159e2bc6655fc0b783deda197bbe0b7:
iscsi: Fix iscsi_create (2017-04-11 15:33:00 +0200)
----------------------------------------------------------------
Block patches for 2.9.0-rc4
----------------------------------------------------------------
Dong Jia Shi (1):
block: pass the right options for BlockDriver.bdrv_open()
Eric Blake (1):
throttle: Remove block from group on hot-unplug
Fam Zheng (1):
iscsi: Fix iscsi_create
block/block-backend.c | 3 +++
block/iscsi.c | 10 ++++++++--
block/snapshot.c | 26 +++++++++++++++++++++++---
3 files changed, 34 insertions(+), 5 deletions(-)
--
2.12.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PULL 1/3] block: pass the right options for BlockDriver.bdrv_open()
2017-04-11 13:44 [Qemu-devel] [PULL 0/3] Block patches for 2.9.0-rc4 Max Reitz
@ 2017-04-11 13:44 ` Max Reitz
2017-04-11 13:44 ` [Qemu-devel] [PULL 2/3] throttle: Remove block from group on hot-unplug Max Reitz
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Max Reitz @ 2017-04-11 13:44 UTC (permalink / raw)
To: qemu-block; +Cc: qemu-devel, Max Reitz, Peter Maydell
From: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
raw_open() expects the caller always passing in the right actual
@options parameter. But when trying to applying snapshot on a RBD
image, bdrv_snapshot_goto() calls raw_open() (by calling the
bdrv_open callback on the BlockDriver) with a NULL @options, and
that will result in a Segmentation fault.
For the other non-raw format drivers, it also makes sense to passing
in the actual options, althought they don't trigger the problem so
far.
Let's prepare a @options by adding the "file" key-value pair to a
copy of the actual options that were given for the node (i.e.
bs->options), and pass it to the callback.
BlockDriver.bdrv_open() expects bs->file to be NULL and just
overwrites it with the result from bdrv_open_child(). That means we
should actually make sure it's NULL because otherwise the child BDS
will have a reference count that is 1 too high. So we unconditionally
invoke bdrv_unref_child() before calling BlockDriver.bdrv_open(), and
we wrap everything in bdrv_ref()/bdrv_unref() so the BDS isn't
deleted in the meantime.
Suggested-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
Message-id: 20170405091909.36357-2-bjsdjshi@linux.vnet.ibm.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
block/snapshot.c | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/block/snapshot.c b/block/snapshot.c
index bf5c2ca5e1..06b1185d27 100644
--- a/block/snapshot.c
+++ b/block/snapshot.c
@@ -27,6 +27,7 @@
#include "block/block_int.h"
#include "qapi/error.h"
#include "qapi/qmp/qerror.h"
+#include "qapi/qmp/qstring.h"
QemuOptsList internal_snapshot_opts = {
.name = "snapshot",
@@ -189,14 +190,33 @@ int bdrv_snapshot_goto(BlockDriverState *bs,
}
if (bs->file) {
+ BlockDriverState *file;
+ QDict *options = qdict_clone_shallow(bs->options);
+ QDict *file_options;
+
+ file = bs->file->bs;
+ /* Prevent it from getting deleted when detached from bs */
+ bdrv_ref(file);
+
+ qdict_extract_subqdict(options, &file_options, "file.");
+ QDECREF(file_options);
+ qdict_put(options, "file", qstring_from_str(bdrv_get_node_name(file)));
+
drv->bdrv_close(bs);
- ret = bdrv_snapshot_goto(bs->file->bs, snapshot_id);
- open_ret = drv->bdrv_open(bs, NULL, bs->open_flags, NULL);
+ bdrv_unref_child(bs, bs->file);
+ bs->file = NULL;
+
+ ret = bdrv_snapshot_goto(file, snapshot_id);
+ open_ret = drv->bdrv_open(bs, options, bs->open_flags, NULL);
+ QDECREF(options);
if (open_ret < 0) {
- bdrv_unref(bs->file->bs);
+ bdrv_unref(file);
bs->drv = NULL;
return open_ret;
}
+
+ assert(bs->file->bs == file);
+ bdrv_unref(file);
return ret;
}
--
2.12.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PULL 2/3] throttle: Remove block from group on hot-unplug
2017-04-11 13:44 [Qemu-devel] [PULL 0/3] Block patches for 2.9.0-rc4 Max Reitz
2017-04-11 13:44 ` [Qemu-devel] [PULL 1/3] block: pass the right options for BlockDriver.bdrv_open() Max Reitz
@ 2017-04-11 13:44 ` Max Reitz
2017-04-11 13:44 ` [Qemu-devel] [PULL 3/3] iscsi: Fix iscsi_create Max Reitz
2017-04-11 15:46 ` [Qemu-devel] [PULL 0/3] Block patches for 2.9.0-rc4 Peter Maydell
3 siblings, 0 replies; 5+ messages in thread
From: Max Reitz @ 2017-04-11 13:44 UTC (permalink / raw)
To: qemu-block; +Cc: qemu-devel, Max Reitz, Peter Maydell
From: Eric Blake <eblake@redhat.com>
When a block device that is part of a throttle group is hot-unplugged,
we forgot to remove it from the throttle group. This leaves stale
memory around, and causes an easily reproducible crash:
$ ./x86_64-softmmu/qemu-system-x86_64 -nodefaults -nographic -qmp stdio \
-device virtio-scsi-pci,bus=pci.0 -drive \
id=drive_image2,if=none,format=raw,file=file2,bps=512000,iops=100,group=foo \
-device scsi-hd,id=image2,drive=drive_image2 -drive \
id=drive_image3,if=none,format=raw,file=file3,bps=512000,iops=100,group=foo \
-device scsi-hd,id=image3,drive=drive_image3
{'execute':'qmp_capabilities'}
{'execute':'device_del','arguments':{'id':'image3'}}
{'execute':'system_reset'}
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1428810
Suggested-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-id: 20170406190847.29347-1-eblake@redhat.com
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
block/block-backend.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/block/block-backend.c b/block/block-backend.c
index a8f2b3440f..7405024e08 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -231,6 +231,9 @@ static void blk_delete(BlockBackend *blk)
assert(!blk->refcnt);
assert(!blk->name);
assert(!blk->dev);
+ if (blk->public.throttle_state) {
+ blk_io_limits_disable(blk);
+ }
if (blk->root) {
blk_remove_bs(blk);
}
--
2.12.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PULL 3/3] iscsi: Fix iscsi_create
2017-04-11 13:44 [Qemu-devel] [PULL 0/3] Block patches for 2.9.0-rc4 Max Reitz
2017-04-11 13:44 ` [Qemu-devel] [PULL 1/3] block: pass the right options for BlockDriver.bdrv_open() Max Reitz
2017-04-11 13:44 ` [Qemu-devel] [PULL 2/3] throttle: Remove block from group on hot-unplug Max Reitz
@ 2017-04-11 13:44 ` Max Reitz
2017-04-11 15:46 ` [Qemu-devel] [PULL 0/3] Block patches for 2.9.0-rc4 Peter Maydell
3 siblings, 0 replies; 5+ messages in thread
From: Max Reitz @ 2017-04-11 13:44 UTC (permalink / raw)
To: qemu-block; +Cc: qemu-devel, Max Reitz, Peter Maydell
From: Fam Zheng <famz@redhat.com>
Since d5895fcb (iscsi: Split URL into individual options), creating
qcow2 image on an iscsi LUN fails:
qemu-img create -f qcow2 iscsi://$SERVER/$IQN/0 1G
qemu-img: iscsi://$SERVER/$IQN/0: Could not create image: Invalid
argument
The problem is iscsi_open now expects that transport_name, portal and
target are already parsed into structured options by
iscsi_parse_filename, but it is not called in iscsi_create.
Signed-off-by: Fam Zheng <famz@redhat.com>
Message-id: 20170410075451.21329-1-famz@redhat.com
Reviewed-by: Eric Blake <eblake@redhat.com>
[mreitz: Dropped now superfluous
qdict_put(bs_options, "filename", ...)]
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
block/iscsi.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/block/iscsi.c b/block/iscsi.c
index 716e74abba..42fb0b019c 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -2092,6 +2092,7 @@ static int iscsi_create(const char *filename, QemuOpts *opts, Error **errp)
BlockDriverState *bs;
IscsiLun *iscsilun = NULL;
QDict *bs_options;
+ Error *local_err = NULL;
bs = bdrv_new();
@@ -2102,8 +2103,13 @@ static int iscsi_create(const char *filename, QemuOpts *opts, Error **errp)
iscsilun = bs->opaque;
bs_options = qdict_new();
- qdict_put(bs_options, "filename", qstring_from_str(filename));
- ret = iscsi_open(bs, bs_options, 0, NULL);
+ iscsi_parse_filename(filename, bs_options, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ ret = -EINVAL;
+ } else {
+ ret = iscsi_open(bs, bs_options, 0, NULL);
+ }
QDECREF(bs_options);
if (ret != 0) {
--
2.12.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PULL 0/3] Block patches for 2.9.0-rc4
2017-04-11 13:44 [Qemu-devel] [PULL 0/3] Block patches for 2.9.0-rc4 Max Reitz
` (2 preceding siblings ...)
2017-04-11 13:44 ` [Qemu-devel] [PULL 3/3] iscsi: Fix iscsi_create Max Reitz
@ 2017-04-11 15:46 ` Peter Maydell
3 siblings, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2017-04-11 15:46 UTC (permalink / raw)
To: Max Reitz; +Cc: Qemu-block, QEMU Developers
On 11 April 2017 at 14:44, Max Reitz <mreitz@redhat.com> wrote:
> The following changes since commit aa388ddc36e8032f41cd17bef88cc3ebaeba77c9:
>
> Merge remote-tracking branch 'remotes/famz/tags/block-pull-request' into staging (2017-04-11 13:27:05 +0100)
>
> are available in the git repository at:
>
> git://github.com/XanClic/qemu.git tags/pull-block-2017-04-11
>
> for you to fetch changes up to 2ec9a782d159e2bc6655fc0b783deda197bbe0b7:
>
> iscsi: Fix iscsi_create (2017-04-11 15:33:00 +0200)
>
> ----------------------------------------------------------------
> Block patches for 2.9.0-rc4
>
> ----------------------------------------------------------------
> Dong Jia Shi (1):
> block: pass the right options for BlockDriver.bdrv_open()
>
> Eric Blake (1):
> throttle: Remove block from group on hot-unplug
>
> Fam Zheng (1):
> iscsi: Fix iscsi_create
>
> block/block-backend.c | 3 +++
> block/iscsi.c | 10 ++++++++--
> block/snapshot.c | 26 +++++++++++++++++++++++---
> 3 files changed, 34 insertions(+), 5 deletions(-)
Applied, thanks.
-- PMM
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-04-11 15:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-11 13:44 [Qemu-devel] [PULL 0/3] Block patches for 2.9.0-rc4 Max Reitz
2017-04-11 13:44 ` [Qemu-devel] [PULL 1/3] block: pass the right options for BlockDriver.bdrv_open() Max Reitz
2017-04-11 13:44 ` [Qemu-devel] [PULL 2/3] throttle: Remove block from group on hot-unplug Max Reitz
2017-04-11 13:44 ` [Qemu-devel] [PULL 3/3] iscsi: Fix iscsi_create Max Reitz
2017-04-11 15:46 ` [Qemu-devel] [PULL 0/3] Block patches for 2.9.0-rc4 Peter Maydell
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).