From: Max Reitz <mreitz@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Max Reitz <mreitz@redhat.com>
Subject: [Qemu-devel] [PATCH v2 1/2] block/drive-mirror: Check for NULL backing_hd
Date: Tue, 5 Nov 2013 01:35:05 +0100 [thread overview]
Message-ID: <1383611706-22107-2-git-send-email-mreitz@redhat.com> (raw)
In-Reply-To: <1383611706-22107-1-git-send-email-mreitz@redhat.com>
It should be possible to execute the QMP "drive-mirror" command in
"none" sync mode and "absolute-paths" mode even for block devices
lacking a backing file.
"absolute-paths" does in fact not require a backing file to be present,
as can be seen from the "top" sync mode code path. "top" basically
states that the device should indeed have a backing file - however, the
current code catches the case if it doesn't and then simply treats it as
"full" sync mode, creating a target image without a backing file (in
"absolute-paths" mode). Thus, "absolute-paths" does not imply the target
file must indeed have a backing file.
Therefore, the target file may be left unbacked in case of "none" sync
mode as well, if the specified device is not backed either. Currently,
qemu will crash trying to dereference the backing file pointer since it
assumes that it will always be non-NULL in that case ("none" with
"absolute-paths").
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
blockdev.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index b260477..986e59d 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2038,8 +2038,8 @@ void qmp_drive_mirror(const char *device, const char *target,
case NEW_IMAGE_MODE_ABSOLUTE_PATHS:
/* create new image with backing file */
bdrv_img_create(target, format,
- source->filename,
- source->drv->format_name,
+ source ? source->filename : NULL,
+ source ? source->drv->format_name : NULL,
NULL, size, flags, &local_err, false);
break;
default:
--
1.8.4.2
next prev parent reply other threads:[~2013-11-05 0:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-05 0:35 [Qemu-devel] [PATCH v2 0/2] block/drive-mirror: Check for NULL backing_hd Max Reitz
2013-11-05 0:35 ` Max Reitz [this message]
2013-11-05 3:32 ` [Qemu-devel] [PATCH v2 1/2] " Fam Zheng
2013-11-05 19:06 ` Max Reitz
2013-11-05 0:35 ` [Qemu-devel] [PATCH v2 2/2] qemu-iotests: Add test for unbacked mirroring Max Reitz
2013-11-05 9:00 ` Wenchao Xia
2013-11-05 19:08 ` Max Reitz
2013-11-05 10:53 ` [Qemu-devel] [PATCH v2 0/2] block/drive-mirror: Check for NULL backing_hd Paolo Bonzini
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=1383611706-22107-2-git-send-email-mreitz@redhat.com \
--to=mreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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).