From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:40025) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QSexc-00014G-6v for qemu-devel@nongnu.org; Fri, 03 Jun 2011 20:43:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QSexa-0002Pc-O9 for qemu-devel@nongnu.org; Fri, 03 Jun 2011 20:43:27 -0400 Received: from mail-px0-f174.google.com ([209.85.212.174]:62361) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QSexa-0002PR-C5 for qemu-devel@nongnu.org; Fri, 03 Jun 2011 20:43:26 -0400 Received: by pxi15 with SMTP id 15so1604639pxi.33 for ; Fri, 03 Jun 2011 17:43:25 -0700 (PDT) MIME-Version: 1.0 From: Fam Zheng Date: Sat, 4 Jun 2011 08:43:05 +0800 Message-ID: Content-Type: text/plain; charset=UTF-8 Subject: [Qemu-devel] [PATCH 09/12] VMDK: bugfix, change cid_update from static variable to bs field List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi , Christoph Hellwig Cid_update is a flag to update image cid on the first write after each image open. Using a static may suppress the cid update of second opened image. Signed-off-by: Fam Zheng --- block/vmdk.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index bbab68a..dd92377 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -82,6 +82,7 @@ typedef struct VmdkExtent { typedef struct BDRVVmdkState { int desc_offset; + bool cid_updated; int num_extents; VmdkExtent *extents; } BDRVVmdkState; @@ -884,7 +885,6 @@ static int vmdk_write(BlockDriverState *bs, int64_t sector_num, int ext_idx = 0; int n, index_in_cluster; uint64_t cluster_offset; - static int cid_update = 0; VmdkMetaData m_data; if (sector_num > bs->total_sectors) { @@ -925,9 +925,9 @@ static int vmdk_write(BlockDriverState *bs, int64_t sector_num, buf += n * 512; // update CID on the first write every time the virtual disk is opened - if (!cid_update) { + if (!s->cid_updated) { vmdk_write_cid(bs, time(NULL)); - cid_update++; + s->cid_updated = true; } } return 0;