qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Race condition in VMDK (QCOW*) formats.
@ 2007-01-16 13:59 Igor Lvovsky
  2007-01-16 19:35 ` Fabrice Bellard
  2007-01-16 19:35 ` Fabrice Bellard
  0 siblings, 2 replies; 8+ messages in thread
From: Igor Lvovsky @ 2007-01-16 13:59 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1602 bytes --]

 Hi all,

I have doubt about the race condition during the write operation on snapshot.

I think the problem exists in VMDK and QCOW* formats (I didn't checked the others). 

 

The example from the block_vmdk.c.

 

static int vmdk_write(BlockDriverState *bs, int64_t sector_num, 

                     const uint8_t *buf, int nb_sectors)

{

    BDRVVmdkState *s = bs->opaque;

    int ret, index_in_cluster, n;

    uint64_t cluster_offset;

 

    while (nb_sectors > 0) {

        index_in_cluster = sector_num & (s->cluster_sectors - 1);

        n = s->cluster_sectors - index_in_cluster;

        if (n > nb_sectors)

            n = nb_sectors;

        cluster_offset = get_cluster_offset(bs, sector_num << 9, 1);

        if (!cluster_offset)

            return -1;

        lseek(s->fd, cluster_offset + index_in_cluster * 512, SEEK_SET);

        ret = write(s->fd, buf, n * 512);

        if (ret != n * 512)

            return -1;

        nb_sectors -= n;

        sector_num += n;

        buf += n * 512;

    }

    return 0;

}

 

The get_cluster_offset(…) routine update the L2 table of the metadata and return the cluster_offset.

After that the vmdk_write(…) routine actually write the grain at right place.

So, we have timing hole here.

 

Assume, VM that perform write operation will be destroyed at this moment.

So, we have corrupted image (with updated L2 table, but without the grain itself).

 

            Regards,

                        Igor Lvovsky

 

 

 

 

 


[-- Attachment #2: Type: text/html, Size: 9018 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-05-20 11:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-16 13:59 [Qemu-devel] Race condition in VMDK (QCOW*) formats Igor Lvovsky
2007-01-16 19:35 ` Fabrice Bellard
2007-01-16 19:35 ` Fabrice Bellard
2007-05-13 11:13   ` [Qemu-devel] [PATCH] Fix a race condition and non-leaf images growing in VMDK chains Igor Lvovsky
2007-05-17 13:54     ` Igor Lvovsky
2007-05-19 21:39       ` Thiemo Seufer
2007-05-19 21:42         ` Thiemo Seufer
2007-05-20 11:40           ` Igor Lvovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).