From patchwork Tue Jun 28 01:32:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Feiran Zheng X-Patchwork-Id: 102310 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 B5E18B6F71 for ; Tue, 28 Jun 2011 12:14:51 +1000 (EST) Received: from localhost ([::1]:40893 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QbNp8-0003C9-QO for incoming@patchwork.ozlabs.org; Mon, 27 Jun 2011 22:14:47 -0400 Received: from eggs.gnu.org ([140.186.70.92]:57706) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QbNBX-0003D1-8L for qemu-devel@nongnu.org; Mon, 27 Jun 2011 21:33:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QbNBV-0004Ou-8f for qemu-devel@nongnu.org; Mon, 27 Jun 2011 21:33:51 -0400 Received: from mail-iy0-f173.google.com ([209.85.210.173]:37108) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QbNBU-0004Jh-W4 for qemu-devel@nongnu.org; Mon, 27 Jun 2011 21:33:49 -0400 Received: by mail-iy0-f173.google.com with SMTP id 3so5589872iyb.4 for ; Mon, 27 Jun 2011 18:33:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=/3845Ee9zvNb/jvdKqKPMsoZrTABoDyEthTTtV9LZ3s=; b=eFfJUgIgj6HF6xM4K0eWGiIW69GDoueG+/DfkiWe9yrFqZYfkrHEsmj4bCTvpDyw51 PRCYGNDgi32koq9eSJiuYv+H8MAniMtRJmIaspNnwGM7plUAtBhDcfnXW9bmfeLMlxl5 LEjZx3bCQ8aUKdL6yI48cYc6bN0zxhYAoxYYM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=p1S62bjyzoh8Btzc56p2qfjTYTackYjoxXWaXz5PDhoi45Ow6YSW4rDvkvFnMPAKqM zDNyLQdoT21tdm0W8Zm5tiZiv0N+DBj+8ffI4kXfHqMdySRh6aXrQ3xBukfE/atr2Oy0 XEGFeafB3JX78wmIEy6R9p4cM5bMMKIp7Q7zU= Received: by 10.42.39.210 with SMTP id i18mr8179767ice.53.1309224828392; Mon, 27 Jun 2011 18:33:48 -0700 (PDT) Received: from localhost.localdomain ([111.187.42.58]) by mx.google.com with ESMTPS id p15sm3341784ibh.12.2011.06.27.18.33.45 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 27 Jun 2011 18:33:47 -0700 (PDT) From: Fam Zheng To: qemu-devel@nongnu.org Date: Tue, 28 Jun 2011 09:32:52 +0800 Message-Id: <1309224777-31024-8-git-send-email-famcool@gmail.com> X-Mailer: git-send-email 1.7.5.2 In-Reply-To: <1309224777-31024-1-git-send-email-famcool@gmail.com> References: <1309224777-31024-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.210.173 Cc: kwolf@redhat.com, Fam Zheng , hch@lst.de, stefanha@gmail.com Subject: [Qemu-devel] [PATCH v5 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 cf7370f..10a8a9a 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; @@ -857,7 +858,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) { @@ -904,9 +904,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;