qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/2] block/drive-mirror: Check for NULL backing_hd
@ 2013-11-05  0:30 Max Reitz
  2013-11-05  0:33 ` Max Reitz
  0 siblings, 1 reply; 2+ messages in thread
From: Max Reitz @ 2013-11-05  0:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Stefan Hajnoczi, Max Reitz

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH 1/2] block/drive-mirror: Check for NULL backing_hd
  2013-11-05  0:30 [Qemu-devel] [PATCH 1/2] block/drive-mirror: Check for NULL backing_hd Max Reitz
@ 2013-11-05  0:33 ` Max Reitz
  0 siblings, 0 replies; 2+ messages in thread
From: Max Reitz @ 2013-11-05  0:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Stefan Hajnoczi, Max Reitz

On 05.11.2013 01:30, Max Reitz wrote:
> 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>
> ---

Sorry, forgot the cover letter, will send a v2.

Max

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-11-05  0:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-05  0:30 [Qemu-devel] [PATCH 1/2] block/drive-mirror: Check for NULL backing_hd Max Reitz
2013-11-05  0:33 ` Max Reitz

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).