From patchwork Mon Sep 9 02:58:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Xia X-Patchwork-Id: 273474 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 94B372C00E2 for ; Mon, 9 Sep 2013 13:01:04 +1000 (EST) Received: from localhost ([::1]:47403 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VIrio-0000aZ-PC for incoming@patchwork.ozlabs.org; Sun, 08 Sep 2013 23:01:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47947) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VIrgP-0005V0-QG for qemu-devel@nongnu.org; Sun, 08 Sep 2013 22:58:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VIrgE-0000ii-1U for qemu-devel@nongnu.org; Sun, 08 Sep 2013 22:58:33 -0400 Received: from e28smtp08.in.ibm.com ([122.248.162.8]:41861) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VIrgD-0000hw-GV for qemu-devel@nongnu.org; Sun, 08 Sep 2013 22:58:21 -0400 Received: from /spool/local by e28smtp08.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 9 Sep 2013 08:16:29 +0530 Received: from d28dlp03.in.ibm.com (9.184.220.128) by e28smtp08.in.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 9 Sep 2013 08:16:27 +0530 Received: from d28relay02.in.ibm.com (d28relay02.in.ibm.com [9.184.220.59]) by d28dlp03.in.ibm.com (Postfix) with ESMTP id E04641258043 for ; Mon, 9 Sep 2013 08:28:16 +0530 (IST) Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay02.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r8930E3639387326 for ; Mon, 9 Sep 2013 08:30:14 +0530 Received: from d28av02.in.ibm.com (localhost [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r892wFdO008044 for ; Mon, 9 Sep 2013 08:28:15 +0530 Received: from RH64wenchao ([9.181.129.59]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id r892w6do007807; Mon, 9 Sep 2013 08:28:14 +0530 From: Wenchao Xia To: qemu-devel@nongnu.org Date: Mon, 9 Sep 2013 10:58:01 +0800 Message-Id: <1378695482-29805-7-git-send-email-xiawenc@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1378695482-29805-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1378695482-29805-1-git-send-email-xiawenc@linux.vnet.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13090902-2000-0000-0000-00000DA48A4B X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 122.248.162.8 Cc: kwolf@redhat.com, pbonzini@redhat.com, mreitz@redhat.com, Wenchao Xia , stefanha@gmail.com Subject: [Qemu-devel] [PATCH V3 6/7] qcow2: print message for error path in snapshot creation 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 The message will be print out with a macro enabled, which can be used to check which error path is taken. Signed-off-by: Wenchao Xia --- block/qcow2-snapshot.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 46 insertions(+), 0 deletions(-) diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c index 92b87f8..7f24486 100644 --- a/block/qcow2-snapshot.c +++ b/block/qcow2-snapshot.c @@ -26,6 +26,8 @@ #include "block/block_int.h" #include "block/qcow2.h" +/* #define QCOW2_SNAPSHOT_PRINT_ERROR_PATH */ + typedef struct QEMU_PACKED QCowSnapshotHeader { /* header is 8 byte aligned */ uint64_t l1_table_offset; @@ -182,10 +184,16 @@ static int qcow2_write_snapshots(BlockDriverState *bs) snapshots_offset = qcow2_alloc_clusters(bs, snapshots_size); offset = snapshots_offset; if (offset < 0) { +#ifdef QCOW2_SNAPSHOT_PRINT_ERROR_PATH + printf("qcow2: Failed in allocation of snapshot list\n"); +#endif return offset; } ret = bdrv_flush(bs); if (ret < 0) { +#ifdef QCOW2_SNAPSHOT_PRINT_ERROR_PATH + printf("qcow2: Failed in flush after snapshot list allocation\n"); +#endif goto fail; } @@ -194,6 +202,9 @@ static int qcow2_write_snapshots(BlockDriverState *bs) ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_DEFAULT, offset, s->snapshots_size); if (ret < 0) { +#ifdef QCOW2_SNAPSHOT_PRINT_ERROR_PATH + printf("qcow2: Failed in overlap check before update snapshot list\n"); +#endif goto fail; } @@ -227,24 +238,36 @@ static int qcow2_write_snapshots(BlockDriverState *bs) ret = bdrv_pwrite(bs->file, offset, &h, sizeof(h)); if (ret < 0) { +#ifdef QCOW2_SNAPSHOT_PRINT_ERROR_PATH + printf("qcow2: Failed in update of snapshot header\n"); +#endif goto fail; } offset += sizeof(h); ret = bdrv_pwrite(bs->file, offset, &extra, sizeof(extra)); if (ret < 0) { +#ifdef QCOW2_SNAPSHOT_PRINT_ERROR_PATH + printf("qcow2: Failed in update of extra snapshot info\n"); +#endif goto fail; } offset += sizeof(extra); ret = bdrv_pwrite(bs->file, offset, sn->id_str, id_str_size); if (ret < 0) { +#ifdef QCOW2_SNAPSHOT_PRINT_ERROR_PATH + printf("qcow2: Failed in update of snapshot id\n"); +#endif goto fail; } offset += id_str_size; ret = bdrv_pwrite(bs->file, offset, sn->name, name_size); if (ret < 0) { +#ifdef QCOW2_SNAPSHOT_PRINT_ERROR_PATH + printf("qcow2: Failed in update of snapshot name\n"); +#endif goto fail; } offset += name_size; @@ -256,6 +279,9 @@ static int qcow2_write_snapshots(BlockDriverState *bs) */ ret = bdrv_flush(bs); if (ret < 0) { +#ifdef QCOW2_SNAPSHOT_PRINT_ERROR_PATH + printf("qcow2: Failed in flush after update snapshot list\n"); +#endif goto fail; } @@ -269,6 +295,9 @@ static int qcow2_write_snapshots(BlockDriverState *bs) ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, nb_snapshots), &header_data, sizeof(header_data)); if (ret < 0) { +#ifdef QCOW2_SNAPSHOT_PRINT_ERROR_PATH + printf("qcow2: Failed in update qcow2 header in snapshot creation\n"); +#endif goto fail; } @@ -366,6 +395,9 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) l1_table_offset = qcow2_alloc_clusters(bs, s->l1_size * sizeof(uint64_t)); if (l1_table_offset < 0) { ret = l1_table_offset; +#ifdef QCOW2_SNAPSHOT_PRINT_ERROR_PATH + printf("qcow2: Failed in allocation of L1 table for snapshot\n"); +#endif goto fail; } @@ -381,12 +413,20 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_DEFAULT, sn->l1_table_offset, s->l1_size * sizeof(uint64_t)); if (ret < 0) { +#ifdef QCOW2_SNAPSHOT_PRINT_ERROR_PATH + printf("qcow2: Failed in overlap check before update L1 table for " + "snapshot\n"); +#endif goto dealloc_cluster; } + BLKDBG_EVENT(bs->file, BLKDBG_SNAPSHOT_L1_UPDATE); ret = bdrv_pwrite(bs->file, sn->l1_table_offset, l1_table, s->l1_size * sizeof(uint64_t)); if (ret < 0) { +#ifdef QCOW2_SNAPSHOT_PRINT_ERROR_PATH + printf("qcow2: Failed in update of L1 table for snapshot\n"); +#endif goto dealloc_cluster; } @@ -400,6 +440,9 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) */ ret = qcow2_update_snapshot_refcount(bs, s->l1_table_offset, s->l1_size, 1); if (ret < 0) { +#ifdef QCOW2_SNAPSHOT_PRINT_ERROR_PATH + printf("qcow2: Failed in update refcount for snapshot\n"); +#endif goto dealloc_cluster; } @@ -419,6 +462,9 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) g_free(s->snapshots); s->snapshots = old_snapshot_list; s->nb_snapshots = old_snapshot_num; +#ifdef QCOW2_SNAPSHOT_PRINT_ERROR_PATH + printf("qcow2: Failed in update of snapshot list and header\n"); +#endif goto restore_refcount; }