From patchwork Fri Jul 1 04:55:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Feiran Zheng X-Patchwork-Id: 102863 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9ABF2B6F5F for ; Fri, 1 Jul 2011 15:10:57 +1000 (EST) Received: from localhost ([::1]:39667 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QcW0D-0006OP-Ss for incoming@patchwork.ozlabs.org; Fri, 01 Jul 2011 01:10:53 -0400 Received: from eggs.gnu.org ([140.186.70.92]:44575) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QcVmP-0003dp-MG for qemu-devel@nongnu.org; Fri, 01 Jul 2011 00:56:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QcVmN-0002CS-Vm for qemu-devel@nongnu.org; Fri, 01 Jul 2011 00:56:37 -0400 Received: from mail-iw0-f173.google.com ([209.85.214.173]:39702) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QcVmN-00025U-KJ for qemu-devel@nongnu.org; Fri, 01 Jul 2011 00:56:35 -0400 Received: by mail-iw0-f173.google.com with SMTP id 3so2879766iwn.4 for ; Thu, 30 Jun 2011 21:56:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=TqoAMOJ37K90NERsAzgXQFKAu3lbFOPr9/0Pq/3FWOg=; b=NEt33//ngaZYAZO3QPXKruvwL8mEYpkY6jpSdE9ijaz6VJgZIq9i0zkhfIZJxsnwfG c+ZaAu7p2ovOGiRYSXhf9DB7QYG+x6XdUULuN2ccdLa/0NjZJLWUDZvaJB3enEQq02Om coOzB4BkE8upkPXkM/wKgOUH31Pa4FPwwBALI= Received: by 10.231.114.92 with SMTP id d28mr2367469ibq.167.1309496195240; Thu, 30 Jun 2011 21:56:35 -0700 (PDT) Received: from localhost.localdomain ([111.187.42.58]) by mx.google.com with ESMTPS id v16sm1638855ibe.0.2011.06.30.21.56.31 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 30 Jun 2011 21:56:34 -0700 (PDT) From: Fam Zheng To: qemu-devel@nongnu.org Date: Fri, 1 Jul 2011 12:55:37 +0800 Message-Id: <1309496142-14228-8-git-send-email-famcool@gmail.com> X-Mailer: git-send-email 1.7.6 In-Reply-To: <1309496142-14228-1-git-send-email-famcool@gmail.com> References: <1309496142-14228-1-git-send-email-famcool@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.214.173 Cc: kwolf@redhat.com, Fam Zheng , hch@lst.de, stefanha@gmail.com Subject: [Qemu-devel] [PATCH v6 07/12] VMDK: move 'static' cid_update flag to bs field 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 Cid_update is the flag for updating CID on first write after opening the image. This should be per image open rather than per program life cycle, so change it from static var of vmdk_write to a field in BDRVVmdkState. 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 0a09890..8783629 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; uint32_t parent_cid; VmdkExtent *extents; @@ -873,7 +874,6 @@ static int vmdk_write(BlockDriverState *bs, int64_t sector_num, int n; int64_t index_in_cluster; uint64_t cluster_offset; - static int cid_update = 0; VmdkMetaData m_data; if (sector_num > bs->total_sectors) { @@ -920,9 +920,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;