Skip to contentSkip to conversation

VMDK: bugfix, change cid_update from static variable to bs field

PATCH Superseded Fam Zheng 1 participant 1 message Jun 4, 2011 Block layer

v1 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

PATCH 9/12 VMDK: bugfix, change cid_update from static variable to bs field

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.

---
 block/vmdk.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
block/vmdk.c +1 -0
index bbab68a..dd92377 100644
@@ -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;