From patchwork Sun Nov 27 01:56:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 699588 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tRCxB2Z90z9t2T for ; Sun, 27 Nov 2016 13:11:58 +1100 (AEDT) Received: from localhost ([::1]:52462 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cAowd-0005XO-BM for incoming@patchwork.ozlabs.org; Sat, 26 Nov 2016 21:11:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42931) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cAoi4-0001wz-4F for qemu-devel@nongnu.org; Sat, 26 Nov 2016 20:56:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cAoi3-0006pd-EO for qemu-devel@nongnu.org; Sat, 26 Nov 2016 20:56:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35068) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cAohz-0006oc-84; Sat, 26 Nov 2016 20:56:47 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 56A9181239; Sun, 27 Nov 2016 01:56:46 +0000 (UTC) Received: from localhost (ovpn-116-37.phx2.redhat.com [10.3.116.37]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uAR1uiw3018021 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 26 Nov 2016 20:56:45 -0500 From: Max Reitz To: qemu-block@nongnu.org Date: Sun, 27 Nov 2016 02:56:06 +0100 Message-Id: <20161127015622.24105-9-mreitz@redhat.com> In-Reply-To: <20161127015622.24105-1-mreitz@redhat.com> References: <20161127015622.24105-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Sun, 27 Nov 2016 01:56:46 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 08/24] block: Add bdrv_make_absolute_filename() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This is a general function for making a filename that is relative to a certain BDS absolute. It calls bdrv_get_full_backing_filename_from_filename() for now, but that will be changed in a follow-up patch. Signed-off-by: Max Reitz --- block.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/block.c b/block.c index d6b3a5a..a384e28 100644 --- a/block.c +++ b/block.c @@ -220,15 +220,22 @@ char *bdrv_get_full_backing_filename_from_filename(const char *backed, } } -char *bdrv_get_full_backing_filename(BlockDriverState *bs, Error **errp) +static char *bdrv_make_absolute_filename(BlockDriverState *relative_to, + const char *filename, Error **errp) { - char *backed = bs->exact_filename[0] ? bs->exact_filename : bs->filename; + char *bs_filename = relative_to->exact_filename[0] + ? relative_to->exact_filename + : relative_to->filename; - return bdrv_get_full_backing_filename_from_filename(backed, - bs->backing_file, + return bdrv_get_full_backing_filename_from_filename(bs_filename, filename, errp); } +char *bdrv_get_full_backing_filename(BlockDriverState *bs, Error **errp) +{ + return bdrv_make_absolute_filename(bs, bs->backing_file, errp); +} + void bdrv_register(BlockDriver *bdrv) { QLIST_INSERT_HEAD(&bdrv_drivers, bdrv, list);