From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KeCqX-0004w2-2R for qemu-devel@nongnu.org; Fri, 12 Sep 2008 13:54:17 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KeCqV-0004uU-Hl for qemu-devel@nongnu.org; Fri, 12 Sep 2008 13:54:16 -0400 Received: from [199.232.76.173] (port=40860 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KeCqV-0004uQ-Ef for qemu-devel@nongnu.org; Fri, 12 Sep 2008 13:54:15 -0400 Received: from savannah.gnu.org ([199.232.41.3]:50749 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KeCqV-0008WH-M5 for qemu-devel@nongnu.org; Fri, 12 Sep 2008 13:54:15 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1KeCqU-0000Qp-DJ for qemu-devel@nongnu.org; Fri, 12 Sep 2008 17:54:14 +0000 Received: from aliguori by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1KeCqU-0000Qk-2P for qemu-devel@nongnu.org; Fri, 12 Sep 2008 17:54:14 +0000 MIME-Version: 1.0 Errors-To: aliguori Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anthony Liguori Message-Id: Date: Fri, 12 Sep 2008 17:54:14 +0000 Subject: [Qemu-devel] [5200] Let snapshot work with protocols Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 5200 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5200 Author: aliguori Date: 2008-09-12 17:54:13 +0000 (Fri, 12 Sep 2008) Log Message: ----------- Let snapshot work with protocols realpath will horribly mangle a protocol so avoid calling it if the backing file is a protocol. Modified Paths: -------------- trunk/block.c Modified: trunk/block.c =================================================================== --- trunk/block.c 2008-09-11 19:42:00 UTC (rev 5199) +++ trunk/block.c 2008-09-12 17:54:13 UTC (rev 5200) @@ -338,6 +338,7 @@ if (flags & BDRV_O_SNAPSHOT) { BlockDriverState *bs1; int64_t total_size; + int is_protocol = 0; /* if snapshot, we create a temporary backing file and open it instead of opening 'filename' directly */ @@ -352,10 +353,21 @@ return -1; } total_size = bdrv_getlength(bs1) >> SECTOR_BITS; + + if (bs1->drv && bs1->drv->protocol_name) + is_protocol = 1; + bdrv_delete(bs1); get_tmp_filename(tmp_filename, sizeof(tmp_filename)); - realpath(filename, backing_filename); + + /* Real path is meaningless for protocols */ + if (is_protocol) + snprintf(backing_filename, sizeof(backing_filename), + "%s", filename); + else + realpath(filename, backing_filename); + if (bdrv_create(&bdrv_qcow2, tmp_filename, total_size, backing_filename, 0) < 0) { return -1;