# HG changeset patch # User Andre Przywara # Date 1243981771 -7200 # Node ID aef9bba654f1d2ce5c7b451da7a5f5c92408c42b # Parent 3c62e9afafc6a70cb897ea77a99d5da1f6b9652e allow empty QCOW images in blktap diff -r 3c62e9afafc6 -r aef9bba654f1 tools/blktap/drivers/block-qcow.c --- a/tools/blktap/drivers/block-qcow.c Wed Jun 03 00:25:25 2009 +0200 +++ b/tools/blktap/drivers/block-qcow.c Wed Jun 03 00:29:31 2009 +0200 @@ -824,7 +824,7 @@ l1_table_block = ROUNDUP(l1_table_block, 512); ret = posix_memalign((void **)&buf2, 4096, l1_table_block); if (ret != 0) goto fail; - if (read(fd, buf2, l1_table_block) != l1_table_block) + if (read(fd, buf2, l1_table_block) < l1_table_size + s->l1_table_offset) goto fail; memcpy(s->l1_table, buf2 + s->l1_table_offset, l1_table_size); @@ -878,7 +878,8 @@ memcpy(buf2 + s->l1_table_offset, s->l1_table, l1_table_size); lseek(fd, 0, SEEK_SET); - if (write(fd, buf2, l1_table_block) != l1_table_block) { + if (write(fd, buf2, l1_table_block) < + l1_table_size + s->l1_table_offset) { DPRINTF("qcow: Failed to write new L1 table\n"); goto fail; }