From patchwork Thu Apr 12 12:01:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 152062 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 89EA0B707C for ; Thu, 12 Apr 2012 23:21:55 +1000 (EST) Received: from localhost ([::1]:37412 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SIIkP-0006tc-7w for incoming@patchwork.ozlabs.org; Thu, 12 Apr 2012 08:03:33 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51121) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SIIjL-0005Ug-R6 for qemu-devel@nongnu.org; Thu, 12 Apr 2012 08:02:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SIIjG-0005w3-Bp for qemu-devel@nongnu.org; Thu, 12 Apr 2012 08:02:27 -0400 Received: from mail-pz0-f46.google.com ([209.85.210.46]:48160) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SIIjG-0005oO-1P for qemu-devel@nongnu.org; Thu, 12 Apr 2012 08:02:22 -0400 Received: by mail-pz0-f46.google.com with SMTP id z9so2767139dad.33 for ; Thu, 12 Apr 2012 05:02:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=Nww1s9c4bD3CcLP9ieaaFVBEQJfIxPCgKH9Dt1u8+OA=; b=q8DhBhCO2J+RvbINUEutDuR7oRKknvCW4m/T3M9Htxt2mmGpc1LkND8PQslxIrKK0G UDD/ThHe2vTXG1VQglTOznAQgBYaIle16PdgbZ7P3eeBVt6d1Ok1elDZmBZq7XpwPj8Q 6EGXtWaaC75OxFbyObznJXid18pdwzSgCufy76YxRVm6IFeCfyAuL/DiUEqLscmlbb6X sjrOp9w4AED2SgVyJyEIYXMWJUSa+LtFE6A3u6blwhhj8jy9QZv8ahy+/0cE/XNC2T8S WCRCbpWZSDXq6vIq1Nx0q0vl2WwK+XjewS57bMSjNVtEpIoPJijpdVhURvmQleDAe2xY fmZQ== Received: by 10.68.216.6 with SMTP id om6mr2551396pbc.117.1334232141134; Thu, 12 Apr 2012 05:02:21 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-182-16.ip50.fastwebnet.it. [93.34.182.16]) by mx.google.com with ESMTPS id qu5sm5515368pbc.45.2012.04.12.05.02.18 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 12 Apr 2012 05:02:20 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 12 Apr 2012 14:01:02 +0200 Message-Id: <1334232076-19018-13-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.9.3 In-Reply-To: <1334232076-19018-1-git-send-email-pbonzini@redhat.com> References: <1334232076-19018-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.210.46 Cc: kwolf@redhat.com, stefanha@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH 12/26] block: update in-memory backing file and format 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 These are needed to print "info block" output correctly. QCOW2 does this because it needs it to write the header, but QED does not, and common code is the right place to do it. Reviewed-by: Kevin Wolf Signed-off-by: Paolo Bonzini --- block.c | 11 +++++++++-- block/stream.c | 11 ----------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/block.c b/block.c index 91bdefe..3f5bc92 100644 --- a/block.c +++ b/block.c @@ -1426,6 +1426,7 @@ int bdrv_change_backing_file(BlockDriverState *bs, const char *backing_file, const char *backing_fmt) { BlockDriver *drv = bs->drv; + int ret; /* Backing file format doesn't make sense without a backing file */ if (backing_fmt && !backing_file) { @@ -1433,10 +1434,16 @@ int bdrv_change_backing_file(BlockDriverState *bs, } if (drv->bdrv_change_backing_file != NULL) { - return drv->bdrv_change_backing_file(bs, backing_file, backing_fmt); + ret = drv->bdrv_change_backing_file(bs, backing_file, backing_fmt); } else { - return -ENOTSUP; + ret = -ENOTSUP; + } + + if (ret == 0) { + pstrcpy(bs->backing_file, sizeof(bs->backing_file), backing_file ?: ""); + pstrcpy(bs->backing_format, sizeof(bs->backing_format), backing_fmt ?: ""); } + return ret; } static int bdrv_check_byte_request(BlockDriverState *bs, int64_t offset, diff --git a/block/stream.c b/block/stream.c index 0efe1ad..54f2b39 100644 --- a/block/stream.c +++ b/block/stream.c @@ -96,17 +96,6 @@ static void close_unused_images(BlockDriverState *top, BlockDriverState *base, bdrv_delete(unused); } top->backing_hd = base; - - pstrcpy(top->backing_file, sizeof(top->backing_file), ""); - pstrcpy(top->backing_format, sizeof(top->backing_format), ""); - if (base_id) { - pstrcpy(top->backing_file, sizeof(top->backing_file), base_id); - if (base->drv) { - pstrcpy(top->backing_format, sizeof(top->backing_format), - base->drv->format_name); - } - } - } /*