qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v3 1/2] block/drive-mirror: Check for NULL backi


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v3 1/2] block/drive-mirror: Check for NULL backing_hd
Date: Wed, 06 Nov 2013 12:01:45 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0

On 11/06/2013 11:50 AM, 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 <address@hidden>
> ---
>  blockdev.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Reviewed-by: Eric Blake <address@hidden>

> 
> diff --git a/blockdev.c b/blockdev.c
> index b260477..1c426b0 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -2026,7 +2026,9 @@ void qmp_drive_mirror(const char *device, const char 
> *target,
>          return;
>      }
>  
> -    if (sync == MIRROR_SYNC_MODE_FULL && mode != NEW_IMAGE_MODE_EXISTING) {
> +    if ((sync == MIRROR_SYNC_MODE_FULL || !source)
> +        && mode != NEW_IMAGE_MODE_EXISTING)
> +    {
>          /* create new image w/o backing file */
>          assert(format && drv);
>          bdrv_img_create(target, format,
> 

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]