From patchwork Mon Mar 18 16:58:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 228704 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 642A72C009C for ; Tue, 19 Mar 2013 03:59:29 +1100 (EST) Received: from localhost ([::1]:43300 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHdPD-0003De-N9 for incoming@patchwork.ozlabs.org; Mon, 18 Mar 2013 12:59:27 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53897) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHdOq-0003Cn-UM for qemu-devel@nongnu.org; Mon, 18 Mar 2013 12:59:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UHdOn-0002db-L8 for qemu-devel@nongnu.org; Mon, 18 Mar 2013 12:59:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:61832) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHdOn-0002dW-DB for qemu-devel@nongnu.org; Mon, 18 Mar 2013 12:59:01 -0400 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 r2IGx0a7017826 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 18 Mar 2013 12:59:00 -0400 Received: from localhost (ovpn-112-20.ams2.redhat.com [10.36.112.20]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r2IGwxPF011149; Mon, 18 Mar 2013 12:59:00 -0400 From: Stefan Hajnoczi To: Date: Mon, 18 Mar 2013 17:58:53 +0100 Message-Id: <1363625934-13506-2-git-send-email-stefanha@redhat.com> In-Reply-To: <1363625934-13506-1-git-send-email-stefanha@redhat.com> References: <1363625934-13506-1-git-send-email-stefanha@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 , rjones@redhat.com, Stefan Hajnoczi Subject: [Qemu-devel] [PATCH v2 1/2] block: fix BDRV_O_SNAPSHOT protocol detection 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 realpath(3) is used to get an absolute path to the image file when creating a -drive snapshot=on temporary qcow2. This does not work for protocols since their filenames ("proto:foo:...") do not correspond to file system paths. Commit 7c96d46ec245d73fd76726588409f9abe4bd5dc1 ("Let snapshot work with protocols") skipped realpath(3) for protocols. Later on the "raw" format was introduced and broke the check. Use path_has_protocol(filename) to decide if this image uses a protocol or a filename. Reported-by: Richard Jones Signed-off-by: Stefan Hajnoczi --- block.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/block.c b/block.c index 037e15e..0a062c9 100644 --- a/block.c +++ b/block.c @@ -830,7 +830,6 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options, if (flags & BDRV_O_SNAPSHOT) { BlockDriverState *bs1; int64_t total_size; - int is_protocol = 0; BlockDriver *bdrv_qcow2; QEMUOptionParameter *options; char backing_filename[PATH_MAX]; @@ -847,9 +846,6 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options, } total_size = bdrv_getlength(bs1) & BDRV_SECTOR_MASK; - if (bs1->drv && bs1->drv->protocol_name) - is_protocol = 1; - bdrv_delete(bs1); ret = get_tmp_filename(tmp_filename, sizeof(tmp_filename)); @@ -858,7 +854,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options, } /* Real path is meaningless for protocols */ - if (is_protocol) { + if (path_has_protocol(filename)) { snprintf(backing_filename, sizeof(backing_filename), "%s", filename); } else if (!realpath(filename, backing_filename)) {