From: Kevin Wolf <kwolf@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: hch@lst.de, qemu-devel@nongnu.org, kraxel@redhat.com
Subject: [Qemu-devel] Re: [PATCH 09/12] savevm: Survive hot-unplug of snapshot device
Date: Wed, 30 Jun 2010 15:37:28 +0200 [thread overview]
Message-ID: <4C2B4898.8070602@redhat.com> (raw)
In-Reply-To: <1277484812-22012-10-git-send-email-armbru@redhat.com>
Am 25.06.2010 18:53, schrieb Markus Armbruster:
> savevm.c keeps a pointer to the snapshot block device. If you manage
> to get that device deleted, the pointer dangles, and the next snapshot
> operation will crash & burn. Unplugging a guest device that uses it
> does the trick:
>
> $ MALLOC_PERTURB_=234 qemu-system-x86_64 [...]
> QEMU 0.12.50 monitor - type 'help' for more information
> (qemu) info snapshots
> No available block device supports snapshots
> (qemu) drive_add auto if=none,file=tmp.qcow2
> OK
> (qemu) device_add usb-storage,id=foo,drive=none1
> (qemu) info snapshots
> Snapshot devices: none1
> Snapshot list (from none1):
> ID TAG VM SIZE DATE VM CLOCK
> (qemu) device_del foo
> (qemu) info snapshots
> Snapshot devices:
> Segmentation fault (core dumped)
>
> Move management of that pointer to block.c, and zap it when the device
> it points to goes away.
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
> block.c | 25 +++++++++++++++++++++++++
> block.h | 1 +
> savevm.c | 31 ++++---------------------------
> 3 files changed, 30 insertions(+), 27 deletions(-)
>
> diff --git a/block.c b/block.c
> index 5e0ffa0..34055e0 100644
> --- a/block.c
> +++ b/block.c
> @@ -63,6 +63,9 @@ static QTAILQ_HEAD(, BlockDriverState) bdrv_states =
> static QLIST_HEAD(, BlockDriver) bdrv_drivers =
> QLIST_HEAD_INITIALIZER(bdrv_drivers);
>
> +/* The device to use for VM snapshots */
> +static BlockDriverState *bs_snapshots;
> +
> /* If non-zero, use only whitelisted block drivers */
> static int use_bdrv_whitelist;
>
> @@ -660,6 +663,9 @@ void bdrv_close_all(void)
> void bdrv_delete(BlockDriverState *bs)
> {
> assert(!bs->peer);
> + if (bs == bs_snapshots) {
> + bs_snapshots = NULL;
> + }
This should probably be in bdrv_close() instead. A BlockDriverState can
be closed, but not deleted yet; it can't handle snapshots in this state,
though.
> /* remove from list, if necessary */
> if (bs->device_name[0] != '\0') {
> @@ -1772,6 +1778,25 @@ int bdrv_can_snapshot(BlockDriverState *bs)
> return 1;
> }
>
> +BlockDriverState *bdrv_snapshots(void)
> +{
> + BlockDriverState *bs;
> +
> + if (bs_snapshots)
> + return bs_snapshots;
I know that this function is just moved with no changes, but while we're
at it and you need to respin anyway, can we add braces here?
> +
> + bs = NULL;
> + while ((bs = bdrv_next(bs))) {
> + if (bdrv_can_snapshot(bs)) {
> + goto ok;
> + }
> + }
> + return NULL;
> + ok:
> + bs_snapshots = bs;
> + return bs;
> +}
And instead of a goto we could do the right thing directly in the if block.
Kevin
next prev parent reply other threads:[~2010-06-30 13:37 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-25 16:53 [Qemu-devel] [PATCH 00/12] More block-related fixes and cleanups Markus Armbruster
2010-06-25 16:53 ` [Qemu-devel] [PATCH 01/12] scsi: scsi_bus_legacy_handle_cmdline() can fail, fix callers Markus Armbruster
2010-06-25 19:39 ` [Qemu-devel] " Christoph Hellwig
2010-06-25 16:53 ` [Qemu-devel] [PATCH 02/12] ide: Make it explicit that ide_create_drive() can't fail Markus Armbruster
2010-06-25 19:40 ` [Qemu-devel] " Christoph Hellwig
2010-06-25 16:53 ` [Qemu-devel] [PATCH 03/12] blockdev: Remove drive_get_serial() Markus Armbruster
2010-06-25 19:41 ` [Qemu-devel] " Christoph Hellwig
2010-06-25 16:53 ` [Qemu-devel] [PATCH 04/12] blockdev: New drive_of_blockdev() Markus Armbruster
2010-06-25 19:42 ` [Qemu-devel] " Christoph Hellwig
2010-06-26 5:32 ` Markus Armbruster
2010-06-26 9:46 ` Christoph Hellwig
2010-06-26 14:46 ` Markus Armbruster
2010-06-27 9:36 ` Christoph Hellwig
2010-06-28 9:58 ` Paolo Bonzini
2010-06-29 8:57 ` Markus Armbruster
2010-06-25 16:53 ` [Qemu-devel] [PATCH 05/12] blockdev: Clean up automatic drive deletion Markus Armbruster
2010-06-26 9:48 ` [Qemu-devel] " Christoph Hellwig
2010-06-25 16:53 ` [Qemu-devel] [PATCH 06/12] qdev: Decouple qdev_prop_drive from DriveInfo Markus Armbruster
2010-06-26 10:09 ` [Qemu-devel] " Christoph Hellwig
2010-06-25 16:53 ` [Qemu-devel] [PATCH 07/12] blockdev: drive_get_by_id() is no longer used, remove Markus Armbruster
2010-06-26 10:09 ` [Qemu-devel] " Christoph Hellwig
2010-06-25 16:53 ` [Qemu-devel] [PATCH 08/12] block: Catch attempt to attach multiple devices to a blockdev Markus Armbruster
2010-06-26 10:11 ` [Qemu-devel] " Christoph Hellwig
2010-06-26 14:44 ` Markus Armbruster
2010-06-27 9:36 ` Christoph Hellwig
2010-06-28 8:24 ` Kevin Wolf
2010-06-28 10:16 ` Christoph Hellwig
2010-06-28 10:26 ` Kevin Wolf
2010-06-30 11:52 ` Markus Armbruster
2010-06-30 12:13 ` Kevin Wolf
2010-06-29 8:06 ` Gerd Hoffmann
2010-06-30 11:33 ` Markus Armbruster
2010-06-29 13:32 ` Kevin Wolf
2010-06-29 14:29 ` Markus Armbruster
2010-06-29 14:58 ` [Qemu-devel] [PATCH v2 " Markus Armbruster
2010-06-25 16:53 ` [Qemu-devel] [PATCH 09/12] savevm: Survive hot-unplug of snapshot device Markus Armbruster
2010-06-26 10:12 ` [Qemu-devel] " Christoph Hellwig
2010-06-30 11:28 ` Markus Armbruster
2010-06-30 13:37 ` Kevin Wolf [this message]
2010-06-30 16:34 ` Markus Armbruster
2010-06-25 16:53 ` [Qemu-devel] [PATCH 10/12] block: Fix virtual media change for if=none Markus Armbruster
2010-06-26 10:14 ` [Qemu-devel] " Christoph Hellwig
2010-06-25 16:53 ` [Qemu-devel] [PATCH 11/12] ide: Make PIIX and ISA IDE init functions return the qdev Markus Armbruster
2010-06-26 10:14 ` [Qemu-devel] " Christoph Hellwig
2010-06-25 16:53 ` [Qemu-devel] [PATCH 12/12] pc: Fix CMOS info for drives defined with -device Markus Armbruster
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=4C2B4898.8070602@redhat.com \
--to=kwolf@redhat.com \
--cc=armbru@redhat.com \
--cc=hch@lst.de \
--cc=kraxel@redhat.com \
--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).