From patchwork Tue Nov 5 00:35:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 288350 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0944E2C008A for ; Tue, 5 Nov 2013 11:39:59 +1100 (EST) Received: from localhost ([::1]:52659 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VdUdh-0004g6-Ho for incoming@patchwork.ozlabs.org; Mon, 04 Nov 2013 19:37:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46274) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VdUc4-00039S-3B for qemu-devel@nongnu.org; Mon, 04 Nov 2013 19:35:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VdUbw-0000BA-Ka for qemu-devel@nongnu.org; Mon, 04 Nov 2013 19:35:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37339) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VdUbw-0000B0-Az for qemu-devel@nongnu.org; Mon, 04 Nov 2013 19:35:12 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rA50ZB06026262 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 4 Nov 2013 19:35:11 -0500 Received: from localhost (ovpn-116-30.ams2.redhat.com [10.36.116.30]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id rA50Z9jN026686 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Mon, 4 Nov 2013 19:35:11 -0500 From: Max Reitz To: qemu-devel@nongnu.org Date: Tue, 5 Nov 2013 01:35:05 +0100 Message-Id: <1383611706-22107-2-git-send-email-mreitz@redhat.com> In-Reply-To: <1383611706-22107-1-git-send-email-mreitz@redhat.com> References: <1383611706-22107-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Stefan Hajnoczi , Max Reitz Subject: [Qemu-devel] [PATCH v2 1/2] block/drive-mirror: Check for NULL backing_hd X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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: