qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 00/21] Block patches
@ 2010-05-14 17:10 Kevin Wolf
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 01/21] block: Remove semicolon in BDRV_SECTOR_MASK macro Kevin Wolf
                   ` (21 more replies)
  0 siblings, 22 replies; 28+ messages in thread
From: Kevin Wolf @ 2010-05-14 17:10 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel

The following changes since commit 14ac15d3ac8e0ef1c91204e2ac772b6412a6b99e:
  Anthony Liguori (1):
        Update SeaBIOS

are available in the git repository at:

  git://repo.or.cz/qemu/kevin.git block

Bruce Rogers (1):
      use qemu_free() instead of free()

Christoph Hellwig (9):
      cloop: use pread
      cloop: use qemu block API
      bochs: use pread
      bochs: use qemu block API
      parallels: use pread
      parallels: use qemu block API
      dmg: fix reading of uncompressed chunks
      dmg: use pread
      dmg: use qemu block API

Daniel P. Berrange (1):
      Fix docs for block stats monitor command

Kevin Wolf (5):
      ide: Fix ide_dma_cancel
      block: Avoid unchecked casts for AIOCBs
      block: Fix protocol detection for Windows devices
      block: Fix bdrv_commit
      block: Remove special case for vvfat

Ryota Ozaki (1):
      qemu-nbd: Improve error reporting

Stefan Hajnoczi (1):
      block: Remove semicolon in BDRV_SECTOR_MASK macro

Stefan Weil (3):
      block/vdi: Allow disk images of size 0
      block/vpc: Fix conversion from size to disk geometry
      block/vdi: Fix image opening and creation for odd disk sizes

 block.c           |   49 +++++++++++-------------
 block.h           |    2 +-
 block/blkdebug.c  |    4 +-
 block/bochs.c     |   81 +++++++++++----------------------------
 block/cloop.c     |   48 ++++++++++++------------
 block/dmg.c       |  109 +++++++++++++++++++++++++++++------------------------
 block/parallels.c |   51 +++++++------------------
 block/qcow.c      |    2 +-
 block/qcow2.c     |    2 +-
 block/vdi.c       |   34 ++++++++++++-----
 block/vpc.c       |   21 ++++++----
 hw/ide/core.c     |    8 ++--
 qemu-nbd.c        |   34 ++++++++++++-----
 13 files changed, 213 insertions(+), 232 deletions(-)

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

* [Qemu-devel] [PATCH 01/21] block: Remove semicolon in BDRV_SECTOR_MASK macro
  2010-05-14 17:10 [Qemu-devel] [PULL 00/21] Block patches Kevin Wolf
@ 2010-05-14 17:10 ` Kevin Wolf
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 02/21] qemu-nbd: Improve error reporting Kevin Wolf
                   ` (20 subsequent siblings)
  21 siblings, 0 replies; 28+ messages in thread
From: Kevin Wolf @ 2010-05-14 17:10 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel

From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/block.h b/block.h
index f87d24e..278259c 100644
--- a/block.h
+++ b/block.h
@@ -38,7 +38,7 @@ typedef struct QEMUSnapshotInfo {
 
 #define BDRV_SECTOR_BITS   9
 #define BDRV_SECTOR_SIZE   (1 << BDRV_SECTOR_BITS)
-#define BDRV_SECTOR_MASK   ~(BDRV_SECTOR_SIZE - 1);
+#define BDRV_SECTOR_MASK   ~(BDRV_SECTOR_SIZE - 1)
 
 typedef enum {
     BDRV_ACTION_REPORT, BDRV_ACTION_IGNORE, BDRV_ACTION_STOP
-- 
1.6.6.1

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

* [Qemu-devel] [PATCH 02/21] qemu-nbd: Improve error reporting
  2010-05-14 17:10 [Qemu-devel] [PULL 00/21] Block patches Kevin Wolf
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 01/21] block: Remove semicolon in BDRV_SECTOR_MASK macro Kevin Wolf
@ 2010-05-14 17:10 ` Kevin Wolf
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 03/21] cloop: use pread Kevin Wolf
                   ` (19 subsequent siblings)
  21 siblings, 0 replies; 28+ messages in thread
From: Kevin Wolf @ 2010-05-14 17:10 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel

From: Ryota Ozaki <ozaki.ryota@gmail.com>

- use err(3) instead of errx(3) if errno is available
  to report why failed
- let fail prior to daemon(3) if opening a nbd file
  is likely to fail after daemonizing to avoid silent
  failure exit
- add missing 'ret = 1' when unix_socket_outgoing failed

Signed-off-by: Ryota Ozaki <ozaki.ryota@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 qemu-nbd.c |   34 ++++++++++++++++++++++++----------
 1 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/qemu-nbd.c b/qemu-nbd.c
index 25aa913..4e607cf 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -112,9 +112,12 @@ static int find_partition(BlockDriverState *bs, int partition,
     uint8_t data[512];
     int i;
     int ext_partnum = 4;
+    int ret;
 
-    if (bdrv_read(bs, 0, data, 1))
-        errx(EXIT_FAILURE, "error while reading");
+    if ((ret = bdrv_read(bs, 0, data, 1)) < 0) {
+        errno = -ret;
+        err(EXIT_FAILURE, "error while reading");
+    }
 
     if (data[510] != 0x55 || data[511] != 0xaa) {
         errno = -EINVAL;
@@ -132,8 +135,10 @@ static int find_partition(BlockDriverState *bs, int partition,
             uint8_t data1[512];
             int j;
 
-            if (bdrv_read(bs, mbr[i].start_sector_abs, data1, 1))
-                errx(EXIT_FAILURE, "error while reading");
+            if ((ret = bdrv_read(bs, mbr[i].start_sector_abs, data1, 1)) < 0) {
+                errno = -ret;
+                err(EXIT_FAILURE, "error while reading");
+            }
 
             for (j = 0; j < 4; j++) {
                 read_partition(&data1[446 + 16 * j], &ext[j]);
@@ -316,7 +321,7 @@ int main(int argc, char **argv)
     if (disconnect) {
         fd = open(argv[optind], O_RDWR);
         if (fd == -1)
-            errx(EXIT_FAILURE, "Cannot open %s", argv[optind]);
+            err(EXIT_FAILURE, "Cannot open %s", argv[optind]);
 
         nbd_disconnect(fd);
 
@@ -333,23 +338,30 @@ int main(int argc, char **argv)
     if (bs == NULL)
         return 1;
 
-    if (bdrv_open(bs, argv[optind], flags, NULL) < 0)
-        return 1;
+    if ((ret = bdrv_open(bs, argv[optind], flags, NULL)) < 0) {
+        errno = -ret;
+        err(EXIT_FAILURE, "Failed to bdrv_open '%s'", argv[optind]);
+    }
 
     fd_size = bs->total_sectors * 512;
 
     if (partition != -1 &&
         find_partition(bs, partition, &dev_offset, &fd_size))
-        errx(EXIT_FAILURE, "Could not find partition %d", partition);
+        err(EXIT_FAILURE, "Could not find partition %d", partition);
 
     if (device) {
         pid_t pid;
         int sock;
 
+        /* want to fail before daemonizing */
+        if (access(device, R_OK|W_OK) == -1) {
+            err(EXIT_FAILURE, "Could not access '%s'", device);
+        }
+
         if (!verbose) {
             /* detach client and server */
             if (daemon(0, 0) == -1) {
-                errx(EXIT_FAILURE, "Failed to daemonize");
+                err(EXIT_FAILURE, "Failed to daemonize");
             }
         }
 
@@ -372,8 +384,10 @@ int main(int argc, char **argv)
             do {
                 sock = unix_socket_outgoing(socket);
                 if (sock == -1) {
-                    if (errno != ENOENT && errno != ECONNREFUSED)
+                    if (errno != ENOENT && errno != ECONNREFUSED) {
+                        ret = 1;
                         goto out;
+                    }
                     sleep(1);	/* wait children */
                 }
             } while (sock == -1);
-- 
1.6.6.1

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

* [Qemu-devel] [PATCH 03/21] cloop: use pread
  2010-05-14 17:10 [Qemu-devel] [PULL 00/21] Block patches Kevin Wolf
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 01/21] block: Remove semicolon in BDRV_SECTOR_MASK macro Kevin Wolf
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 02/21] qemu-nbd: Improve error reporting Kevin Wolf
@ 2010-05-14 17:10 ` Kevin Wolf
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 04/21] cloop: use qemu block API Kevin Wolf
                   ` (18 subsequent siblings)
  21 siblings, 0 replies; 28+ messages in thread
From: Kevin Wolf @ 2010-05-14 17:10 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel

From: Christoph Hellwig <hch@lst.de>

Use pread instead of lseek + read in preparation of using the qemu
block API.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/cloop.c |   32 +++++++++++++++++---------------
 1 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/block/cloop.c b/block/cloop.c
index e4f995b..9fe2a42 100644
--- a/block/cloop.c
+++ b/block/cloop.c
@@ -62,23 +62,22 @@ static int cloop_open(BlockDriverState *bs, const char *filename, int flags)
     bs->read_only = 1;
 
     /* read header */
-    if(lseek(s->fd,128,SEEK_SET)<0) {
-cloop_close:
-	close(s->fd);
-	return -1;
+    if (pread(s->fd, &s->block_size, 4, 128) < 4) {
+        goto cloop_close;
     }
-    if(read(s->fd,&s->block_size,4)<4)
-	goto cloop_close;
-    s->block_size=be32_to_cpu(s->block_size);
-    if(read(s->fd,&s->n_blocks,4)<4)
-	goto cloop_close;
-    s->n_blocks=be32_to_cpu(s->n_blocks);
+    s->block_size = be32_to_cpu(s->block_size);
+
+    if (pread(s->fd, &s->n_blocks, 4, 128 + 4) < 4) {
+        goto cloop_close;
+    }
+    s->n_blocks = be32_to_cpu(s->n_blocks);
 
     /* read offsets */
-    offsets_size=s->n_blocks*sizeof(uint64_t);
-    s->offsets=(uint64_t*)qemu_malloc(offsets_size);
-    if(read(s->fd,s->offsets,offsets_size)<offsets_size)
+    offsets_size = s->n_blocks * sizeof(uint64_t);
+    s->offsets = qemu_malloc(offsets_size);
+    if (pread(s->fd, s->offsets, offsets_size, 128 + 4 + 4) < offsets_size) {
 	goto cloop_close;
+    }
     for(i=0;i<s->n_blocks;i++) {
 	s->offsets[i]=be64_to_cpu(s->offsets[i]);
 	if(i>0) {
@@ -98,6 +97,10 @@ cloop_close:
     s->sectors_per_block = s->block_size/512;
     bs->total_sectors = s->n_blocks*s->sectors_per_block;
     return 0;
+
+cloop_close:
+    close(s->fd);
+    return -1;
 }
 
 static inline int cloop_read_block(BDRVCloopState *s,int block_num)
@@ -106,8 +109,7 @@ static inline int cloop_read_block(BDRVCloopState *s,int block_num)
 	int ret;
         uint32_t bytes = s->offsets[block_num+1]-s->offsets[block_num];
 
-	lseek(s->fd, s->offsets[block_num], SEEK_SET);
-        ret = read(s->fd, s->compressed_block, bytes);
+        ret = pread(s->fd, s->compressed_block, bytes, s->offsets[block_num]);
         if (ret != bytes)
             return -1;
 
-- 
1.6.6.1

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

* [Qemu-devel] [PATCH 04/21] cloop: use qemu block API
  2010-05-14 17:10 [Qemu-devel] [PULL 00/21] Block patches Kevin Wolf
                   ` (2 preceding siblings ...)
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 03/21] cloop: use pread Kevin Wolf
@ 2010-05-14 17:10 ` Kevin Wolf
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 05/21] ide: Fix ide_dma_cancel Kevin Wolf
                   ` (17 subsequent siblings)
  21 siblings, 0 replies; 28+ messages in thread
From: Kevin Wolf @ 2010-05-14 17:10 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel

From: Christoph Hellwig <hch@lst.de>

Use bdrv_pwrite to access the backing device instead of pread, and
convert the driver to implementing the bdrv_open method which gives
it an already opened BlockDriverState for the underlying device.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/cloop.c |   26 ++++++++++++--------------
 1 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/block/cloop.c b/block/cloop.c
index 9fe2a42..fe015c4 100644
--- a/block/cloop.c
+++ b/block/cloop.c
@@ -27,7 +27,6 @@
 #include <zlib.h>
 
 typedef struct BDRVCloopState {
-    int fd;
     uint32_t block_size;
     uint32_t n_blocks;
     uint64_t* offsets;
@@ -51,23 +50,20 @@ static int cloop_probe(const uint8_t *buf, int buf_size, const char *filename)
     return 0;
 }
 
-static int cloop_open(BlockDriverState *bs, const char *filename, int flags)
+static int cloop_open(BlockDriverState *bs, int flags)
 {
     BDRVCloopState *s = bs->opaque;
     uint32_t offsets_size,max_compressed_block_size=1,i;
 
-    s->fd = open(filename, O_RDONLY | O_BINARY);
-    if (s->fd < 0)
-        return -errno;
     bs->read_only = 1;
 
     /* read header */
-    if (pread(s->fd, &s->block_size, 4, 128) < 4) {
+    if (bdrv_pread(bs->file, 128, &s->block_size, 4) < 4) {
         goto cloop_close;
     }
     s->block_size = be32_to_cpu(s->block_size);
 
-    if (pread(s->fd, &s->n_blocks, 4, 128 + 4) < 4) {
+    if (bdrv_pread(bs->file, 128 + 4, &s->n_blocks, 4) < 4) {
         goto cloop_close;
     }
     s->n_blocks = be32_to_cpu(s->n_blocks);
@@ -75,7 +71,8 @@ static int cloop_open(BlockDriverState *bs, const char *filename, int flags)
     /* read offsets */
     offsets_size = s->n_blocks * sizeof(uint64_t);
     s->offsets = qemu_malloc(offsets_size);
-    if (pread(s->fd, s->offsets, offsets_size, 128 + 4 + 4) < offsets_size) {
+    if (bdrv_pread(bs->file, 128 + 4 + 4, s->offsets, offsets_size) <
+            offsets_size) {
 	goto cloop_close;
     }
     for(i=0;i<s->n_blocks;i++) {
@@ -99,17 +96,19 @@ static int cloop_open(BlockDriverState *bs, const char *filename, int flags)
     return 0;
 
 cloop_close:
-    close(s->fd);
     return -1;
 }
 
-static inline int cloop_read_block(BDRVCloopState *s,int block_num)
+static inline int cloop_read_block(BlockDriverState *bs, int block_num)
 {
+    BDRVCloopState *s = bs->opaque;
+
     if(s->current_block != block_num) {
 	int ret;
         uint32_t bytes = s->offsets[block_num+1]-s->offsets[block_num];
 
-        ret = pread(s->fd, s->compressed_block, bytes, s->offsets[block_num]);
+        ret = bdrv_pread(bs->file, s->offsets[block_num], s->compressed_block,
+                         bytes);
         if (ret != bytes)
             return -1;
 
@@ -138,7 +137,7 @@ static int cloop_read(BlockDriverState *bs, int64_t sector_num,
     for(i=0;i<nb_sectors;i++) {
 	uint32_t sector_offset_in_block=((sector_num+i)%s->sectors_per_block),
 	    block_num=(sector_num+i)/s->sectors_per_block;
-	if(cloop_read_block(s, block_num) != 0)
+	if(cloop_read_block(bs, block_num) != 0)
 	    return -1;
 	memcpy(buf+i*512,s->uncompressed_block+sector_offset_in_block*512,512);
     }
@@ -148,7 +147,6 @@ static int cloop_read(BlockDriverState *bs, int64_t sector_num,
 static void cloop_close(BlockDriverState *bs)
 {
     BDRVCloopState *s = bs->opaque;
-    close(s->fd);
     if(s->n_blocks>0)
 	free(s->offsets);
     free(s->compressed_block);
@@ -160,7 +158,7 @@ static BlockDriver bdrv_cloop = {
     .format_name	= "cloop",
     .instance_size	= sizeof(BDRVCloopState),
     .bdrv_probe		= cloop_probe,
-    .bdrv_file_open	= cloop_open,
+    .bdrv_open		= cloop_open,
     .bdrv_read		= cloop_read,
     .bdrv_close		= cloop_close,
 };
-- 
1.6.6.1

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

* [Qemu-devel] [PATCH 05/21] ide: Fix ide_dma_cancel
  2010-05-14 17:10 [Qemu-devel] [PULL 00/21] Block patches Kevin Wolf
                   ` (3 preceding siblings ...)
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 04/21] cloop: use qemu block API Kevin Wolf
@ 2010-05-14 17:10 ` Kevin Wolf
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 06/21] bochs: use pread Kevin Wolf
                   ` (16 subsequent siblings)
  21 siblings, 0 replies; 28+ messages in thread
From: Kevin Wolf @ 2010-05-14 17:10 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel

When cancelling a request, bdrv_aio_cancel may decide that it waits for
completion of a request rather than for cancellation. IDE therefore can't
abandon its DMA status before calling bdrv_aio_cancel; otherwise the callback
of a completed request would use invalid data.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 hw/ide/core.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/ide/core.c b/hw/ide/core.c
index 0757528..3cd55e3 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -2838,10 +2838,6 @@ static void ide_dma_restart(IDEState *s, int is_read)
 void ide_dma_cancel(BMDMAState *bm)
 {
     if (bm->status & BM_STATUS_DMAING) {
-        bm->status &= ~BM_STATUS_DMAING;
-        /* cancel DMA request */
-        bm->unit = -1;
-        bm->dma_cb = NULL;
         if (bm->aiocb) {
 #ifdef DEBUG_AIO
             printf("aio_cancel\n");
@@ -2849,6 +2845,10 @@ void ide_dma_cancel(BMDMAState *bm)
             bdrv_aio_cancel(bm->aiocb);
             bm->aiocb = NULL;
         }
+        bm->status &= ~BM_STATUS_DMAING;
+        /* cancel DMA request */
+        bm->unit = -1;
+        bm->dma_cb = NULL;
     }
 }
 
-- 
1.6.6.1

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

* [Qemu-devel] [PATCH 06/21] bochs: use pread
  2010-05-14 17:10 [Qemu-devel] [PULL 00/21] Block patches Kevin Wolf
                   ` (4 preceding siblings ...)
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 05/21] ide: Fix ide_dma_cancel Kevin Wolf
@ 2010-05-14 17:10 ` Kevin Wolf
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 07/21] bochs: use qemu block API Kevin Wolf
                   ` (15 subsequent siblings)
  21 siblings, 0 replies; 28+ messages in thread
From: Kevin Wolf @ 2010-05-14 17:10 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel

From: Christoph Hellwig <hch@lst.de>

Use pread instead of lseek + read in preparation of using the qemu
block API.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/bochs.c |   63 ++++++++++++++++++--------------------------------------
 1 files changed, 20 insertions(+), 43 deletions(-)

diff --git a/block/bochs.c b/block/bochs.c
index e952670..b54f54d 100644
--- a/block/bochs.c
+++ b/block/bochs.c
@@ -125,7 +125,7 @@ static int bochs_open(BlockDriverState *bs, const char *filename, int flags)
 
     s->fd = fd;
 
-    if (read(fd, &bochs, sizeof(bochs)) != sizeof(bochs)) {
+    if (pread(fd, &bochs, sizeof(bochs), 0) != sizeof(bochs)) {
         goto fail;
     }
 
@@ -144,14 +144,10 @@ static int bochs_open(BlockDriverState *bs, const char *filename, int flags)
       bs->total_sectors = le64_to_cpu(bochs.extra.redolog.disk) / 512;
     }
 
-    if (lseek(s->fd, le32_to_cpu(bochs.header), SEEK_SET) == (off_t)-1) {
-        goto fail;
-    }
-
     s->catalog_size = le32_to_cpu(bochs.extra.redolog.catalog);
     s->catalog_bitmap = qemu_malloc(s->catalog_size * 4);
-    if (read(s->fd, s->catalog_bitmap, s->catalog_size * 4) !=
-	s->catalog_size * 4)
+    if (pread(s->fd, s->catalog_bitmap, s->catalog_size * 4,
+              le32_to_cpu(bochs.header)) != s->catalog_size * 4)
 	goto fail;
     for (i = 0; i < s->catalog_size; i++)
 	le32_to_cpus(&s->catalog_bitmap[i]);
@@ -169,54 +165,35 @@ static int bochs_open(BlockDriverState *bs, const char *filename, int flags)
     return -1;
 }
 
-static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num)
+static int64_t seek_to_sector(BlockDriverState *bs, int64_t sector_num)
 {
     BDRVBochsState *s = bs->opaque;
     int64_t offset = sector_num * 512;
-    int64_t extent_index, extent_offset, bitmap_offset, block_offset;
+    int64_t extent_index, extent_offset, bitmap_offset;
     char bitmap_entry;
 
     // seek to sector
     extent_index = offset / s->extent_size;
     extent_offset = (offset % s->extent_size) / 512;
 
-    if (s->catalog_bitmap[extent_index] == 0xffffffff)
-    {
-//	fprintf(stderr, "page not allocated [%x - %x:%x]\n",
-//	    sector_num, extent_index, extent_offset);
-	return -1; // not allocated
+    if (s->catalog_bitmap[extent_index] == 0xffffffff) {
+	return -1; /* not allocated */
     }
 
     bitmap_offset = s->data_offset + (512 * s->catalog_bitmap[extent_index] *
 	(s->extent_blocks + s->bitmap_blocks));
-    block_offset = bitmap_offset + (512 * (s->bitmap_blocks + extent_offset));
-
-//    fprintf(stderr, "sect: %x [ext i: %x o: %x] -> %x bitmap: %x block: %x\n",
-//	sector_num, extent_index, extent_offset,
-//	le32_to_cpu(s->catalog_bitmap[extent_index]),
-//	bitmap_offset, block_offset);
-
-    // read in bitmap for current extent
-    if (lseek(s->fd, bitmap_offset + (extent_offset / 8), SEEK_SET) ==
-        (off_t)-1) {
-        return -1;
-    }
 
-    if (read(s->fd, &bitmap_entry, 1) != 1)
+    /* read in bitmap for current extent */
+    if (pread(s->fd, &bitmap_entry, 1, bitmap_offset + (extent_offset / 8))
+            != 1) {
         return -1;
-
-    if (!((bitmap_entry >> (extent_offset % 8)) & 1))
-    {
-//	fprintf(stderr, "sector (%x) in bitmap not allocated\n",
-//	    sector_num);
-	return -1; // not allocated
     }
 
-    if (lseek(s->fd, block_offset, SEEK_SET) == (off_t)-1) {
-        return -1;
+    if (!((bitmap_entry >> (extent_offset % 8)) & 1)) {
+	return -1; /* not allocated */
     }
 
-    return 0;
+    return bitmap_offset + (512 * (s->bitmap_blocks + extent_offset));
 }
 
 static int bochs_read(BlockDriverState *bs, int64_t sector_num,
@@ -226,13 +203,13 @@ static int bochs_read(BlockDriverState *bs, int64_t sector_num,
     int ret;
 
     while (nb_sectors > 0) {
-	if (!seek_to_sector(bs, sector_num))
-	{
-	    ret = read(s->fd, buf, 512);
-	    if (ret != 512)
-		return -1;
-	}
-	else
+        int64_t block_offset = seek_to_sector(bs, sector_num);
+        if (block_offset >= 0) {
+            ret = pread(s->fd, buf, 512, block_offset);
+            if (ret != 512) {
+                return -1;
+            }
+        } else
             memset(buf, 0, 512);
         nb_sectors--;
         sector_num++;
-- 
1.6.6.1

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

* [Qemu-devel] [PATCH 07/21] bochs: use qemu block API
  2010-05-14 17:10 [Qemu-devel] [PULL 00/21] Block patches Kevin Wolf
                   ` (5 preceding siblings ...)
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 06/21] bochs: use pread Kevin Wolf
@ 2010-05-14 17:10 ` Kevin Wolf
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 08/21] block: Avoid unchecked casts for AIOCBs Kevin Wolf
                   ` (14 subsequent siblings)
  21 siblings, 0 replies; 28+ messages in thread
From: Kevin Wolf @ 2010-05-14 17:10 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel

From: Christoph Hellwig <hch@lst.de>

Use bdrv_pwrite to access the backing device instead of pread, and
convert the driver to implementing the bdrv_open method which gives
it an already opened BlockDriverState for the underlying device.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/bochs.c |   30 +++++++++---------------------
 1 files changed, 9 insertions(+), 21 deletions(-)

diff --git a/block/bochs.c b/block/bochs.c
index b54f54d..5fe2fa3 100644
--- a/block/bochs.c
+++ b/block/bochs.c
@@ -80,8 +80,6 @@ struct bochs_header {
 };
 
 typedef struct BDRVBochsState {
-    int fd;
-
     uint32_t *catalog_bitmap;
     int catalog_size;
 
@@ -109,23 +107,16 @@ static int bochs_probe(const uint8_t *buf, int buf_size, const char *filename)
     return 0;
 }
 
-static int bochs_open(BlockDriverState *bs, const char *filename, int flags)
+static int bochs_open(BlockDriverState *bs, int flags)
 {
     BDRVBochsState *s = bs->opaque;
-    int fd, i;
+    int i;
     struct bochs_header bochs;
     struct bochs_header_v1 header_v1;
 
-    fd = open(filename, O_RDONLY | O_BINARY);
-    if (fd < 0) {
-        return -1;
-    }
-
     bs->read_only = 1; // no write support yet
 
-    s->fd = fd;
-
-    if (pread(fd, &bochs, sizeof(bochs), 0) != sizeof(bochs)) {
+    if (bdrv_pread(bs->file, 0, &bochs, sizeof(bochs)) != sizeof(bochs)) {
         goto fail;
     }
 
@@ -146,8 +137,8 @@ static int bochs_open(BlockDriverState *bs, const char *filename, int flags)
 
     s->catalog_size = le32_to_cpu(bochs.extra.redolog.catalog);
     s->catalog_bitmap = qemu_malloc(s->catalog_size * 4);
-    if (pread(s->fd, s->catalog_bitmap, s->catalog_size * 4,
-              le32_to_cpu(bochs.header)) != s->catalog_size * 4)
+    if (bdrv_pread(bs->file, le32_to_cpu(bochs.header), s->catalog_bitmap,
+                   s->catalog_size * 4) != s->catalog_size * 4)
 	goto fail;
     for (i = 0; i < s->catalog_size; i++)
 	le32_to_cpus(&s->catalog_bitmap[i]);
@@ -161,7 +152,6 @@ static int bochs_open(BlockDriverState *bs, const char *filename, int flags)
 
     return 0;
  fail:
-    close(fd);
     return -1;
 }
 
@@ -184,8 +174,8 @@ static int64_t seek_to_sector(BlockDriverState *bs, int64_t sector_num)
 	(s->extent_blocks + s->bitmap_blocks));
 
     /* read in bitmap for current extent */
-    if (pread(s->fd, &bitmap_entry, 1, bitmap_offset + (extent_offset / 8))
-            != 1) {
+    if (bdrv_pread(bs->file, bitmap_offset + (extent_offset / 8),
+                   &bitmap_entry, 1) != 1) {
         return -1;
     }
 
@@ -199,13 +189,12 @@ static int64_t seek_to_sector(BlockDriverState *bs, int64_t sector_num)
 static int bochs_read(BlockDriverState *bs, int64_t sector_num,
                     uint8_t *buf, int nb_sectors)
 {
-    BDRVBochsState *s = bs->opaque;
     int ret;
 
     while (nb_sectors > 0) {
         int64_t block_offset = seek_to_sector(bs, sector_num);
         if (block_offset >= 0) {
-            ret = pread(s->fd, buf, 512, block_offset);
+            ret = bdrv_pread(bs->file, block_offset, buf, 512);
             if (ret != 512) {
                 return -1;
             }
@@ -222,14 +211,13 @@ static void bochs_close(BlockDriverState *bs)
 {
     BDRVBochsState *s = bs->opaque;
     qemu_free(s->catalog_bitmap);
-    close(s->fd);
 }
 
 static BlockDriver bdrv_bochs = {
     .format_name	= "bochs",
     .instance_size	= sizeof(BDRVBochsState),
     .bdrv_probe		= bochs_probe,
-    .bdrv_file_open	= bochs_open,
+    .bdrv_open		= bochs_open,
     .bdrv_read		= bochs_read,
     .bdrv_close		= bochs_close,
 };
-- 
1.6.6.1

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

* [Qemu-devel] [PATCH 08/21] block: Avoid unchecked casts for AIOCBs
  2010-05-14 17:10 [Qemu-devel] [PULL 00/21] Block patches Kevin Wolf
                   ` (6 preceding siblings ...)
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 07/21] bochs: use qemu block API Kevin Wolf
@ 2010-05-14 17:10 ` Kevin Wolf
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 09/21] block: Fix protocol detection for Windows devices Kevin Wolf
                   ` (13 subsequent siblings)
  21 siblings, 0 replies; 28+ messages in thread
From: Kevin Wolf @ 2010-05-14 17:10 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel

Use container_of for one direction and &acb->common for the other one.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block.c          |    3 ++-
 block/blkdebug.c |    4 ++--
 block/qcow.c     |    2 +-
 block/qcow2.c    |    2 +-
 block/vdi.c      |    2 +-
 5 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/block.c b/block.c
index 48305b7..6345599 100644
--- a/block.c
+++ b/block.c
@@ -2108,7 +2108,8 @@ typedef struct BlockDriverAIOCBSync {
 
 static void bdrv_aio_cancel_em(BlockDriverAIOCB *blockacb)
 {
-    BlockDriverAIOCBSync *acb = (BlockDriverAIOCBSync *)blockacb;
+    BlockDriverAIOCBSync *acb =
+        container_of(blockacb, BlockDriverAIOCBSync, common);
     qemu_bh_delete(acb->bh);
     acb->bh = NULL;
     qemu_aio_release(acb);
diff --git a/block/blkdebug.c b/block/blkdebug.c
index bb4a91a..8325f75 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -320,7 +320,7 @@ static void error_callback_bh(void *opaque)
 
 static void blkdebug_aio_cancel(BlockDriverAIOCB *blockacb)
 {
-    BlkdebugAIOCB *acb = (BlkdebugAIOCB*) blockacb;
+    BlkdebugAIOCB *acb = container_of(blockacb, BlkdebugAIOCB, common);
     qemu_aio_release(acb);
 }
 
@@ -347,7 +347,7 @@ static BlockDriverAIOCB *inject_error(BlockDriverState *bs,
     acb->bh = bh;
     qemu_bh_schedule(bh);
 
-    return (BlockDriverAIOCB*) acb;
+    return &acb->common;
 }
 
 static BlockDriverAIOCB *blkdebug_aio_readv(BlockDriverState *bs,
diff --git a/block/qcow.c b/block/qcow.c
index 2883c40..449858f 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -502,7 +502,7 @@ typedef struct QCowAIOCB {
 
 static void qcow_aio_cancel(BlockDriverAIOCB *blockacb)
 {
-    QCowAIOCB *acb = (QCowAIOCB *)blockacb;
+    QCowAIOCB *acb = container_of(blockacb, QCowAIOCB, common);
     if (acb->hd_aiocb)
         bdrv_aio_cancel(acb->hd_aiocb);
     qemu_aio_release(acb);
diff --git a/block/qcow2.c b/block/qcow2.c
index ebad4e1..0ce7150 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -338,7 +338,7 @@ typedef struct QCowAIOCB {
 
 static void qcow_aio_cancel(BlockDriverAIOCB *blockacb)
 {
-    QCowAIOCB *acb = (QCowAIOCB *)blockacb;
+    QCowAIOCB *acb = container_of(blockacb, QCowAIOCB, common);
     if (acb->hd_aiocb)
         bdrv_aio_cancel(acb->hd_aiocb);
     qemu_aio_release(acb);
diff --git a/block/vdi.c b/block/vdi.c
index 1d257b4..2b4d2c2 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -469,7 +469,7 @@ static int vdi_is_allocated(BlockDriverState *bs, int64_t sector_num,
 static void vdi_aio_cancel(BlockDriverAIOCB *blockacb)
 {
     /* TODO: This code is untested. How can I get it executed? */
-    VdiAIOCB *acb = (VdiAIOCB *)blockacb;
+    VdiAIOCB *acb = container_of(blockacb, VdiAIOCB, common);
     logout("\n");
     if (acb->hd_aiocb) {
         bdrv_aio_cancel(acb->hd_aiocb);
-- 
1.6.6.1

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

* [Qemu-devel] [PATCH 09/21] block: Fix protocol detection for Windows devices
  2010-05-14 17:10 [Qemu-devel] [PULL 00/21] Block patches Kevin Wolf
                   ` (7 preceding siblings ...)
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 08/21] block: Avoid unchecked casts for AIOCBs Kevin Wolf
@ 2010-05-14 17:10 ` Kevin Wolf
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 10/21] block: Fix bdrv_commit Kevin Wolf
                   ` (12 subsequent siblings)
  21 siblings, 0 replies; 28+ messages in thread
From: Kevin Wolf @ 2010-05-14 17:10 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel

We can't assume the file protocol for Windows devices, they need the same
detection as other files for which an explicit protocol is not specified.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/block.c b/block.c
index 6345599..977d01f 100644
--- a/block.c
+++ b/block.c
@@ -287,16 +287,18 @@ static BlockDriver *find_protocol(const char *filename)
     char protocol[128];
     int len;
     const char *p;
+    int is_drive;
 
     /* TODO Drivers without bdrv_file_open must be specified explicitly */
 
 #ifdef _WIN32
-    if (is_windows_drive(filename) ||
-        is_windows_drive_prefix(filename))
-        return bdrv_find_format("file");
+    is_drive = is_windows_drive(filename) ||
+        is_windows_drive_prefix(filename);
+#else
+    is_drive = 0;
 #endif
     p = strchr(filename, ':');
-    if (!p) {
+    if (!p || is_drive) {
         drv1 = find_hdev_driver(filename);
         if (!drv1) {
             drv1 = bdrv_find_format("file");
-- 
1.6.6.1

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

* [Qemu-devel] [PATCH 10/21] block: Fix bdrv_commit
  2010-05-14 17:10 [Qemu-devel] [PULL 00/21] Block patches Kevin Wolf
                   ` (8 preceding siblings ...)
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 09/21] block: Fix protocol detection for Windows devices Kevin Wolf
@ 2010-05-14 17:10 ` Kevin Wolf
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 11/21] block/vdi: Allow disk images of size 0 Kevin Wolf
                   ` (11 subsequent siblings)
  21 siblings, 0 replies; 28+ messages in thread
From: Kevin Wolf @ 2010-05-14 17:10 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel

When reopening the image, don't guess the driver, but use the same driver as
was used before. This is important if the format=... option was used for that
image.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/block.c b/block.c
index 977d01f..c134c2b 100644
--- a/block.c
+++ b/block.c
@@ -701,12 +701,12 @@ int bdrv_commit(BlockDriverState *bs)
         bdrv_delete(bs->backing_hd);
         bs->backing_hd = NULL;
         bs_rw = bdrv_new("");
-        rw_ret = bdrv_open(bs_rw, filename, open_flags | BDRV_O_RDWR, NULL);
+        rw_ret = bdrv_open(bs_rw, filename, open_flags | BDRV_O_RDWR, drv);
         if (rw_ret < 0) {
             bdrv_delete(bs_rw);
             /* try to re-open read-only */
             bs_ro = bdrv_new("");
-            ret = bdrv_open(bs_ro, filename, open_flags & ~BDRV_O_RDWR, NULL);
+            ret = bdrv_open(bs_ro, filename, open_flags & ~BDRV_O_RDWR, drv);
             if (ret < 0) {
                 bdrv_delete(bs_ro);
                 /* drive not functional anymore */
@@ -758,7 +758,7 @@ ro_cleanup:
         bdrv_delete(bs->backing_hd);
         bs->backing_hd = NULL;
         bs_ro = bdrv_new("");
-        ret = bdrv_open(bs_ro, filename, open_flags & ~BDRV_O_RDWR, NULL);
+        ret = bdrv_open(bs_ro, filename, open_flags & ~BDRV_O_RDWR, drv);
         if (ret < 0) {
             bdrv_delete(bs_ro);
             /* drive not functional anymore */
-- 
1.6.6.1

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

* [Qemu-devel] [PATCH 11/21] block/vdi: Allow disk images of size 0
  2010-05-14 17:10 [Qemu-devel] [PULL 00/21] Block patches Kevin Wolf
                   ` (9 preceding siblings ...)
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 10/21] block: Fix bdrv_commit Kevin Wolf
@ 2010-05-14 17:10 ` Kevin Wolf
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 12/21] parallels: use pread Kevin Wolf
                   ` (10 subsequent siblings)
  21 siblings, 0 replies; 28+ messages in thread
From: Kevin Wolf @ 2010-05-14 17:10 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel

From: Stefan Weil <weil@mail.berlios.de>

Even it is not very useful, users may create images of size 0.

Without the special option CONFIG_ZERO_MALLOC, qemu_mallocz
aborts execution when it is told to allocate 0 bytes,
so avoid this kind of call.

Cc: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/vdi.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/block/vdi.c b/block/vdi.c
index 2b4d2c2..3ea4103 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -435,7 +435,9 @@ static int vdi_open(BlockDriverState *bs, int flags)
 
     bmap_size = header.blocks_in_image * sizeof(uint32_t);
     bmap_size = (bmap_size + SECTOR_SIZE - 1) / SECTOR_SIZE;
-    s->bmap = qemu_malloc(bmap_size * SECTOR_SIZE);
+    if (bmap_size > 0) {
+        s->bmap = qemu_malloc(bmap_size * SECTOR_SIZE);
+    }
     if (bdrv_read(bs->file, s->bmap_sector, (uint8_t *)s->bmap, bmap_size) < 0) {
         goto fail_free_bmap;
     }
@@ -857,7 +859,10 @@ static int vdi_create(const char *filename, QEMUOptionParameter *options)
         result = -errno;
     }
 
-    bmap = (uint32_t *)qemu_mallocz(bmap_size);
+    bmap = NULL;
+    if (bmap_size > 0) {
+        bmap = (uint32_t *)qemu_mallocz(bmap_size);
+    }
     for (i = 0; i < blocks; i++) {
         if (image_type == VDI_TYPE_STATIC) {
             bmap[i] = i;
-- 
1.6.6.1

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

* [Qemu-devel] [PATCH 12/21] parallels: use pread
  2010-05-14 17:10 [Qemu-devel] [PULL 00/21] Block patches Kevin Wolf
                   ` (10 preceding siblings ...)
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 11/21] block/vdi: Allow disk images of size 0 Kevin Wolf
@ 2010-05-14 17:10 ` Kevin Wolf
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 13/21] parallels: use qemu block API Kevin Wolf
                   ` (9 subsequent siblings)
  21 siblings, 0 replies; 28+ messages in thread
From: Kevin Wolf @ 2010-05-14 17:10 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel

From: Christoph Hellwig <hch@lst.de>

Use pread instead of lseek + read in preparation of using the qemu
block API.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/parallels.c |   33 +++++++++++----------------------
 1 files changed, 11 insertions(+), 22 deletions(-)

diff --git a/block/parallels.c b/block/parallels.c
index b217101..efb6d4d 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -83,7 +83,7 @@ static int parallels_open(BlockDriverState *bs, const char *filename, int flags)
 
     s->fd = fd;
 
-    if (read(fd, &ph, sizeof(ph)) != sizeof(ph))
+    if (pread(fd, &ph, sizeof(ph), 0) != sizeof(ph))
         goto fail;
 
     if (memcmp(ph.magic, HEADER_MAGIC, 16) ||
@@ -93,14 +93,11 @@ static int parallels_open(BlockDriverState *bs, const char *filename, int flags)
 
     bs->total_sectors = le32_to_cpu(ph.nb_sectors);
 
-    if (lseek(s->fd, 64, SEEK_SET) != 64)
-	goto fail;
-
     s->tracks = le32_to_cpu(ph.tracks);
 
     s->catalog_size = le32_to_cpu(ph.catalog_entries);
     s->catalog_bitmap = qemu_malloc(s->catalog_size * 4);
-    if (read(s->fd, s->catalog_bitmap, s->catalog_size * 4) !=
+    if (pread(s->fd, s->catalog_bitmap, s->catalog_size * 4, 64) !=
 	s->catalog_size * 4)
 	goto fail;
     for (i = 0; i < s->catalog_size; i++)
@@ -114,28 +111,18 @@ fail:
     return -1;
 }
 
-static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num)
+static int64_t seek_to_sector(BlockDriverState *bs, int64_t sector_num)
 {
     BDRVParallelsState *s = bs->opaque;
     uint32_t index, offset;
-    uint64_t position;
 
     index = sector_num / s->tracks;
     offset = sector_num % s->tracks;
 
-    // not allocated
+    /* not allocated */
     if ((index > s->catalog_size) || (s->catalog_bitmap[index] == 0))
 	return -1;
-
-    position = (uint64_t)(s->catalog_bitmap[index] + offset) * 512;
-
-//    fprintf(stderr, "sector: %llx index=%x offset=%x pointer=%x position=%x\n",
-//	sector_num, index, offset, s->catalog_bitmap[index], position);
-
-    if (lseek(s->fd, position, SEEK_SET) != position)
-	return -1;
-
-    return 0;
+    return (uint64_t)(s->catalog_bitmap[index] + offset) * 512;
 }
 
 static int parallels_read(BlockDriverState *bs, int64_t sector_num,
@@ -144,11 +131,13 @@ static int parallels_read(BlockDriverState *bs, int64_t sector_num,
     BDRVParallelsState *s = bs->opaque;
 
     while (nb_sectors > 0) {
-	if (!seek_to_sector(bs, sector_num)) {
-	    if (read(s->fd, buf, 512) != 512)
-		return -1;
-	} else
+        int64_t position = seek_to_sector(bs, sector_num);
+        if (position >= 0) {
+            if (pread(s->fd, buf, 512, position) != 512)
+                return -1;
+        } else {
             memset(buf, 0, 512);
+        }
         nb_sectors--;
         sector_num++;
         buf += 512;
-- 
1.6.6.1

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

* [Qemu-devel] [PATCH 13/21] parallels: use qemu block API
  2010-05-14 17:10 [Qemu-devel] [PULL 00/21] Block patches Kevin Wolf
                   ` (11 preceding siblings ...)
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 12/21] parallels: use pread Kevin Wolf
@ 2010-05-14 17:10 ` Kevin Wolf
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 14/21] block/vpc: Fix conversion from size to disk geometry Kevin Wolf
                   ` (8 subsequent siblings)
  21 siblings, 0 replies; 28+ messages in thread
From: Kevin Wolf @ 2010-05-14 17:10 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel

From: Christoph Hellwig <hch@lst.de>

Use bdrv_pwrite to access the backing device instead of pread, and
convert the driver to implementing the bdrv_open method which gives
it an already opened BlockDriverState for the underlying device.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/parallels.c |   24 ++++++------------------
 1 files changed, 6 insertions(+), 18 deletions(-)

diff --git a/block/parallels.c b/block/parallels.c
index efb6d4d..35a14aa 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -46,7 +46,6 @@ struct parallels_header {
 } __attribute__((packed));
 
 typedef struct BDRVParallelsState {
-    int fd;
 
     uint32_t *catalog_bitmap;
     int catalog_size;
@@ -68,22 +67,15 @@ static int parallels_probe(const uint8_t *buf, int buf_size, const char *filenam
     return 0;
 }
 
-static int parallels_open(BlockDriverState *bs, const char *filename, int flags)
+static int parallels_open(BlockDriverState *bs, int flags)
 {
     BDRVParallelsState *s = bs->opaque;
-    int fd, i;
+    int i;
     struct parallels_header ph;
 
-    fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
-    if (fd < 0) {
-        return -1;
-    }
-
     bs->read_only = 1; // no write support yet
 
-    s->fd = fd;
-
-    if (pread(fd, &ph, sizeof(ph), 0) != sizeof(ph))
+    if (bdrv_pread(bs->file, 0, &ph, sizeof(ph)) != sizeof(ph))
         goto fail;
 
     if (memcmp(ph.magic, HEADER_MAGIC, 16) ||
@@ -97,7 +89,7 @@ static int parallels_open(BlockDriverState *bs, const char *filename, int flags)
 
     s->catalog_size = le32_to_cpu(ph.catalog_entries);
     s->catalog_bitmap = qemu_malloc(s->catalog_size * 4);
-    if (pread(s->fd, s->catalog_bitmap, s->catalog_size * 4, 64) !=
+    if (bdrv_pread(bs->file, 64, s->catalog_bitmap, s->catalog_size * 4) !=
 	s->catalog_size * 4)
 	goto fail;
     for (i = 0; i < s->catalog_size; i++)
@@ -107,7 +99,6 @@ static int parallels_open(BlockDriverState *bs, const char *filename, int flags)
 fail:
     if (s->catalog_bitmap)
 	qemu_free(s->catalog_bitmap);
-    close(fd);
     return -1;
 }
 
@@ -128,12 +119,10 @@ static int64_t seek_to_sector(BlockDriverState *bs, int64_t sector_num)
 static int parallels_read(BlockDriverState *bs, int64_t sector_num,
                     uint8_t *buf, int nb_sectors)
 {
-    BDRVParallelsState *s = bs->opaque;
-
     while (nb_sectors > 0) {
         int64_t position = seek_to_sector(bs, sector_num);
         if (position >= 0) {
-            if (pread(s->fd, buf, 512, position) != 512)
+            if (bdrv_pread(bs->file, position, buf, 512) != 512)
                 return -1;
         } else {
             memset(buf, 0, 512);
@@ -149,14 +138,13 @@ static void parallels_close(BlockDriverState *bs)
 {
     BDRVParallelsState *s = bs->opaque;
     qemu_free(s->catalog_bitmap);
-    close(s->fd);
 }
 
 static BlockDriver bdrv_parallels = {
     .format_name	= "parallels",
     .instance_size	= sizeof(BDRVParallelsState),
     .bdrv_probe		= parallels_probe,
-    .bdrv_file_open	= parallels_open,
+    .bdrv_open		= parallels_open,
     .bdrv_read		= parallels_read,
     .bdrv_close		= parallels_close,
 };
-- 
1.6.6.1

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

* [Qemu-devel] [PATCH 14/21] block/vpc: Fix conversion from size to disk geometry
  2010-05-14 17:10 [Qemu-devel] [PULL 00/21] Block patches Kevin Wolf
                   ` (12 preceding siblings ...)
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 13/21] parallels: use qemu block API Kevin Wolf
@ 2010-05-14 17:10 ` Kevin Wolf
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 15/21] dmg: fix reading of uncompressed chunks Kevin Wolf
                   ` (7 subsequent siblings)
  21 siblings, 0 replies; 28+ messages in thread
From: Kevin Wolf @ 2010-05-14 17:10 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel

From: Stefan Weil <weil@mail.berlios.de>

The VHD algorithm calculates a disk geometry
which is usually smaller than the requested size.

QEMU tried to round up but failed for certain sizes:

qemu-img create -f vpc disk.vpc 9437184
would create an image with 9435136 bytes
(which is too small for qemu-img convert).

Instead of hacking the geometry algorithm, the patch
increases the number of sectors until we get enough
sectors.

Cc: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/vpc.c |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/block/vpc.c b/block/vpc.c
index f94e469..214e9d1 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -463,9 +463,7 @@ static int calculate_geometry(int64_t total_sectors, uint16_t* cyls,
         }
     }
 
-    // Note: Rounding up deviates from the Virtual PC behaviour
-    // However, we need this to avoid truncating images in qemu-img convert
-    *cyls = (cyls_times_heads + *heads - 1) / *heads;
+    *cyls = cyls_times_heads / *heads;
 
     return 0;
 }
@@ -477,9 +475,9 @@ static int vpc_create(const char *filename, QEMUOptionParameter *options)
     struct vhd_dyndisk_header* dyndisk_header =
         (struct vhd_dyndisk_header*) buf;
     int fd, i;
-    uint16_t cyls;
-    uint8_t heads;
-    uint8_t secs_per_cyl;
+    uint16_t cyls = 0;
+    uint8_t heads = 0;
+    uint8_t secs_per_cyl = 0;
     size_t block_size, num_bat_entries;
     int64_t total_sectors = 0;
 
@@ -496,9 +494,14 @@ static int vpc_create(const char *filename, QEMUOptionParameter *options)
     if (fd < 0)
         return -EIO;
 
-    // Calculate matching total_size and geometry
-    if (calculate_geometry(total_sectors, &cyls, &heads, &secs_per_cyl))
-        return -EFBIG;
+    /* Calculate matching total_size and geometry. Increase the number of
+       sectors requested until we get enough (or fail). */
+    for (i = 0; total_sectors > (int64_t)cyls * heads * secs_per_cyl; i++) {
+        if (calculate_geometry(total_sectors + i,
+                               &cyls, &heads, &secs_per_cyl)) {
+            return -EFBIG;
+        }
+    }
     total_sectors = (int64_t) cyls * heads * secs_per_cyl;
 
     // Prepare the Hard Disk Footer
-- 
1.6.6.1

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

* [Qemu-devel] [PATCH 15/21] dmg: fix reading of uncompressed chunks
  2010-05-14 17:10 [Qemu-devel] [PULL 00/21] Block patches Kevin Wolf
                   ` (13 preceding siblings ...)
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 14/21] block/vpc: Fix conversion from size to disk geometry Kevin Wolf
@ 2010-05-14 17:10 ` Kevin Wolf
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 16/21] dmg: use pread Kevin Wolf
                   ` (6 subsequent siblings)
  21 siblings, 0 replies; 28+ messages in thread
From: Kevin Wolf @ 2010-05-14 17:10 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel

From: Christoph Hellwig <hch@lst.de>

When dmg_read_chunk encounters an uncompressed chunk it currently
calls read without any previous adjustment of the file postion.

This seems very wrong, and the "reference" implementation in
dmg2img does a search to the same offset as done in the various
compression cases, so do the same here.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/dmg.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/block/dmg.c b/block/dmg.c
index d5c1a68..02a3d67 100644
--- a/block/dmg.c
+++ b/block/dmg.c
@@ -239,7 +239,8 @@ static inline int dmg_read_chunk(BDRVDMGState *s,int sector_num)
 		return -1;
 	    break; }
 	case 1: /* copy */
-	    ret = read(s->fd, s->uncompressed_chunk, s->lengths[chunk]);
+	    ret = pread(s->fd, s->uncompressed_chunk, s->lengths[chunk],
+                        s->offsets[chunk]);
 	    if (ret != s->lengths[chunk])
 		return -1;
 	    break;
-- 
1.6.6.1

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

* [Qemu-devel] [PATCH 16/21] dmg: use pread
  2010-05-14 17:10 [Qemu-devel] [PULL 00/21] Block patches Kevin Wolf
                   ` (14 preceding siblings ...)
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 15/21] dmg: fix reading of uncompressed chunks Kevin Wolf
@ 2010-05-14 17:10 ` Kevin Wolf
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 17/21] dmg: use qemu block API Kevin Wolf
                   ` (5 subsequent siblings)
  21 siblings, 0 replies; 28+ messages in thread
From: Kevin Wolf @ 2010-05-14 17:10 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel

From: Christoph Hellwig <hch@lst.de>

Use pread instead of lseek + read in preparation of using the qemu
block API.  Note that dmg actually uses the implicit file offset
a lot in dmg_open, and we had to replace it with an offset variable.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/dmg.c |   88 ++++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 51 insertions(+), 37 deletions(-)

diff --git a/block/dmg.c b/block/dmg.c
index 02a3d67..a0ba34f 100644
--- a/block/dmg.c
+++ b/block/dmg.c
@@ -58,18 +58,18 @@ static int dmg_probe(const uint8_t *buf, int buf_size, const char *filename)
     return 0;
 }
 
-static off_t read_off(int fd)
+static off_t read_off(int fd, int64_t offset)
 {
 	uint64_t buffer;
-	if(read(fd,&buffer,8)<8)
+	if (pread(fd, &buffer, 8, offset) < 8)
 		return 0;
 	return be64_to_cpu(buffer);
 }
 
-static off_t read_uint32(int fd)
+static off_t read_uint32(int fd, int64_t offset)
 {
 	uint32_t buffer;
-	if(read(fd,&buffer,4)<4)
+	if (pread(fd, &buffer, 4, offset) < 4)
 		return 0;
 	return be32_to_cpu(buffer);
 }
@@ -80,6 +80,7 @@ static int dmg_open(BlockDriverState *bs, const char *filename, int flags)
     off_t info_begin,info_end,last_in_offset,last_out_offset;
     uint32_t count;
     uint32_t max_compressed_size=1,max_sectors_per_chunk=1,i;
+    int64_t offset;
 
     s->fd = open(filename, O_RDONLY | O_BINARY);
     if (s->fd < 0)
@@ -89,38 +90,45 @@ static int dmg_open(BlockDriverState *bs, const char *filename, int flags)
     s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL;
 
     /* read offset of info blocks */
-    if(lseek(s->fd,-0x1d8,SEEK_END)<0) {
+    offset = lseek(s->fd, -0x1d8, SEEK_END);
+    if (offset < 0) {
         goto fail;
     }
 
-    info_begin=read_off(s->fd);
-    if(info_begin==0)
-	goto fail;
-    if(lseek(s->fd,info_begin,SEEK_SET)<0)
-	goto fail;
-    if(read_uint32(s->fd)!=0x100)
-	goto fail;
-    if((count = read_uint32(s->fd))==0)
-	goto fail;
-    info_end = info_begin+count;
-    if(lseek(s->fd,0xf8,SEEK_CUR)<0)
+    info_begin = read_off(s->fd, offset);
+    if (info_begin == 0) {
 	goto fail;
+    }
+
+    if (read_uint32(s->fd, info_begin) != 0x100) {
+        goto fail;
+    }
+
+    count = read_uint32(s->fd, info_begin + 4);
+    if (count == 0) {
+        goto fail;
+    }
+    info_end = info_begin + count;
+
+    offset = info_begin + 0x100;
 
     /* read offsets */
     last_in_offset = last_out_offset = 0;
-    while(lseek(s->fd,0,SEEK_CUR)<info_end) {
+    while (offset < info_end) {
         uint32_t type;
 
-	count = read_uint32(s->fd);
+	count = read_uint32(s->fd, offset);
 	if(count==0)
 	    goto fail;
-	type = read_uint32(s->fd);
-	if(type!=0x6d697368 || count<244)
-	    lseek(s->fd,count-4,SEEK_CUR);
-	else {
+        offset += 4;
+
+	type = read_uint32(s->fd, offset);
+	if (type == 0x6d697368 && count >= 244) {
 	    int new_size, chunk_count;
-	    if(lseek(s->fd,200,SEEK_CUR)<0)
-	        goto fail;
+
+            offset += 4;
+            offset += 200;
+
 	    chunk_count = (count-204)/40;
 	    new_size = sizeof(uint64_t) * (s->n_chunks + chunk_count);
 	    s->types = qemu_realloc(s->types, new_size/2);
@@ -130,7 +138,8 @@ static int dmg_open(BlockDriverState *bs, const char *filename, int flags)
 	    s->sectorcounts = qemu_realloc(s->sectorcounts, new_size);
 
 	    for(i=s->n_chunks;i<s->n_chunks+chunk_count;i++) {
-		s->types[i] = read_uint32(s->fd);
+		s->types[i] = read_uint32(s->fd, offset);
+		offset += 4;
 		if(s->types[i]!=0x80000005 && s->types[i]!=1 && s->types[i]!=2) {
 		    if(s->types[i]==0xffffffff) {
 			last_in_offset = s->offsets[i-1]+s->lengths[i-1];
@@ -138,15 +147,23 @@ static int dmg_open(BlockDriverState *bs, const char *filename, int flags)
 		    }
 		    chunk_count--;
 		    i--;
-		    if(lseek(s->fd,36,SEEK_CUR)<0)
-			goto fail;
+		    offset += 36;
 		    continue;
 		}
-		read_uint32(s->fd);
-		s->sectors[i] = last_out_offset+read_off(s->fd);
-		s->sectorcounts[i] = read_off(s->fd);
-		s->offsets[i] = last_in_offset+read_off(s->fd);
-		s->lengths[i] = read_off(s->fd);
+		offset += 4;
+
+		s->sectors[i] = last_out_offset+read_off(s->fd, offset);
+		offset += 8;
+
+		s->sectorcounts[i] = read_off(s->fd, offset);
+		offset += 8;
+
+		s->offsets[i] = last_in_offset+read_off(s->fd, offset);
+		offset += 8;
+
+		s->lengths[i] = read_off(s->fd, offset);
+		offset += 8;
+
 		if(s->lengths[i]>max_compressed_size)
 		    max_compressed_size = s->lengths[i];
 		if(s->sectorcounts[i]>max_sectors_per_chunk)
@@ -210,15 +227,12 @@ static inline int dmg_read_chunk(BDRVDMGState *s,int sector_num)
 	case 0x80000005: { /* zlib compressed */
 	    int i;
 
-	    ret = lseek(s->fd, s->offsets[chunk], SEEK_SET);
-	    if(ret<0)
-		return -1;
-
 	    /* we need to buffer, because only the chunk as whole can be
 	     * inflated. */
 	    i=0;
 	    do {
-		ret = read(s->fd, s->compressed_chunk+i, s->lengths[chunk]-i);
+		ret = pread(s->fd, s->compressed_chunk+i, s->lengths[chunk]-i,
+                            s->offsets[chunk] + i);
 		if(ret<0 && errno==EINTR)
 		    ret=0;
 		i+=ret;
-- 
1.6.6.1

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

* [Qemu-devel] [PATCH 17/21] dmg: use qemu block API
  2010-05-14 17:10 [Qemu-devel] [PULL 00/21] Block patches Kevin Wolf
                   ` (15 preceding siblings ...)
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 16/21] dmg: use pread Kevin Wolf
@ 2010-05-14 17:10 ` Kevin Wolf
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 18/21] block/vdi: Fix image opening and creation for odd disk sizes Kevin Wolf
                   ` (4 subsequent siblings)
  21 siblings, 0 replies; 28+ messages in thread
From: Kevin Wolf @ 2010-05-14 17:10 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel

From: Christoph Hellwig <hch@lst.de>

Use bdrv_pwrite to access the backing device instead of pread, and
convert the driver to implementing the bdrv_open method which gives
it an already opened BlockDriverState for the underlying device.

Dmg actually does an lseek to a negative offset in the open routine,
which we replace with offset arithmetics after doing a bdrv_getlength.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/dmg.c |   56 ++++++++++++++++++++++++++------------------------------
 1 files changed, 26 insertions(+), 30 deletions(-)

diff --git a/block/dmg.c b/block/dmg.c
index a0ba34f..a3c815b 100644
--- a/block/dmg.c
+++ b/block/dmg.c
@@ -28,8 +28,6 @@
 #include <zlib.h>
 
 typedef struct BDRVDMGState {
-    int fd;
-
     /* each chunk contains a certain number of sectors,
      * offsets[i] is the offset in the .dmg file,
      * lengths[i] is the length of the compressed chunk,
@@ -58,23 +56,23 @@ static int dmg_probe(const uint8_t *buf, int buf_size, const char *filename)
     return 0;
 }
 
-static off_t read_off(int fd, int64_t offset)
+static off_t read_off(BlockDriverState *bs, int64_t offset)
 {
 	uint64_t buffer;
-	if (pread(fd, &buffer, 8, offset) < 8)
+	if (bdrv_pread(bs->file, offset, &buffer, 8) < 8)
 		return 0;
 	return be64_to_cpu(buffer);
 }
 
-static off_t read_uint32(int fd, int64_t offset)
+static off_t read_uint32(BlockDriverState *bs, int64_t offset)
 {
 	uint32_t buffer;
-	if (pread(fd, &buffer, 4, offset) < 4)
+	if (bdrv_pread(bs->file, offset, &buffer, 4) < 4)
 		return 0;
 	return be32_to_cpu(buffer);
 }
 
-static int dmg_open(BlockDriverState *bs, const char *filename, int flags)
+static int dmg_open(BlockDriverState *bs, int flags)
 {
     BDRVDMGState *s = bs->opaque;
     off_t info_begin,info_end,last_in_offset,last_out_offset;
@@ -82,29 +80,27 @@ static int dmg_open(BlockDriverState *bs, const char *filename, int flags)
     uint32_t max_compressed_size=1,max_sectors_per_chunk=1,i;
     int64_t offset;
 
-    s->fd = open(filename, O_RDONLY | O_BINARY);
-    if (s->fd < 0)
-        return -errno;
     bs->read_only = 1;
     s->n_chunks = 0;
     s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL;
 
     /* read offset of info blocks */
-    offset = lseek(s->fd, -0x1d8, SEEK_END);
+    offset = bdrv_getlength(bs->file);
     if (offset < 0) {
         goto fail;
     }
+    offset -= 0x1d8;
 
-    info_begin = read_off(s->fd, offset);
+    info_begin = read_off(bs, offset);
     if (info_begin == 0) {
 	goto fail;
     }
 
-    if (read_uint32(s->fd, info_begin) != 0x100) {
+    if (read_uint32(bs, info_begin) != 0x100) {
         goto fail;
     }
 
-    count = read_uint32(s->fd, info_begin + 4);
+    count = read_uint32(bs, info_begin + 4);
     if (count == 0) {
         goto fail;
     }
@@ -117,12 +113,12 @@ static int dmg_open(BlockDriverState *bs, const char *filename, int flags)
     while (offset < info_end) {
         uint32_t type;
 
-	count = read_uint32(s->fd, offset);
+	count = read_uint32(bs, offset);
 	if(count==0)
 	    goto fail;
         offset += 4;
 
-	type = read_uint32(s->fd, offset);
+	type = read_uint32(bs, offset);
 	if (type == 0x6d697368 && count >= 244) {
 	    int new_size, chunk_count;
 
@@ -138,7 +134,7 @@ static int dmg_open(BlockDriverState *bs, const char *filename, int flags)
 	    s->sectorcounts = qemu_realloc(s->sectorcounts, new_size);
 
 	    for(i=s->n_chunks;i<s->n_chunks+chunk_count;i++) {
-		s->types[i] = read_uint32(s->fd, offset);
+		s->types[i] = read_uint32(bs, offset);
 		offset += 4;
 		if(s->types[i]!=0x80000005 && s->types[i]!=1 && s->types[i]!=2) {
 		    if(s->types[i]==0xffffffff) {
@@ -152,16 +148,16 @@ static int dmg_open(BlockDriverState *bs, const char *filename, int flags)
 		}
 		offset += 4;
 
-		s->sectors[i] = last_out_offset+read_off(s->fd, offset);
+		s->sectors[i] = last_out_offset+read_off(bs, offset);
 		offset += 8;
 
-		s->sectorcounts[i] = read_off(s->fd, offset);
+		s->sectorcounts[i] = read_off(bs, offset);
 		offset += 8;
 
-		s->offsets[i] = last_in_offset+read_off(s->fd, offset);
+		s->offsets[i] = last_in_offset+read_off(bs, offset);
 		offset += 8;
 
-		s->lengths[i] = read_off(s->fd, offset);
+		s->lengths[i] = read_off(bs, offset);
 		offset += 8;
 
 		if(s->lengths[i]>max_compressed_size)
@@ -183,7 +179,6 @@ static int dmg_open(BlockDriverState *bs, const char *filename, int flags)
 
     return 0;
 fail:
-    close(s->fd);
     return -1;
 }
 
@@ -213,8 +208,10 @@ static inline uint32_t search_chunk(BDRVDMGState* s,int sector_num)
     return s->n_chunks; /* error */
 }
 
-static inline int dmg_read_chunk(BDRVDMGState *s,int sector_num)
+static inline int dmg_read_chunk(BlockDriverState *bs, int sector_num)
 {
+    BDRVDMGState *s = bs->opaque;
+
     if(!is_sector_in_chunk(s,s->current_chunk,sector_num)) {
 	int ret;
 	uint32_t chunk = search_chunk(s,sector_num);
@@ -231,8 +228,8 @@ static inline int dmg_read_chunk(BDRVDMGState *s,int sector_num)
 	     * inflated. */
 	    i=0;
 	    do {
-		ret = pread(s->fd, s->compressed_chunk+i, s->lengths[chunk]-i,
-                            s->offsets[chunk] + i);
+                ret = bdrv_pread(bs->file, s->offsets[chunk] + i,
+                                 s->compressed_chunk+i, s->lengths[chunk]-i);
 		if(ret<0 && errno==EINTR)
 		    ret=0;
 		i+=ret;
@@ -253,8 +250,8 @@ static inline int dmg_read_chunk(BDRVDMGState *s,int sector_num)
 		return -1;
 	    break; }
 	case 1: /* copy */
-	    ret = pread(s->fd, s->uncompressed_chunk, s->lengths[chunk],
-                        s->offsets[chunk]);
+	    ret = bdrv_pread(bs->file, s->offsets[chunk],
+                             s->uncompressed_chunk, s->lengths[chunk]);
 	    if (ret != s->lengths[chunk])
 		return -1;
 	    break;
@@ -275,7 +272,7 @@ static int dmg_read(BlockDriverState *bs, int64_t sector_num,
 
     for(i=0;i<nb_sectors;i++) {
 	uint32_t sector_offset_in_chunk;
-	if(dmg_read_chunk(s, sector_num+i) != 0)
+	if(dmg_read_chunk(bs, sector_num+i) != 0)
 	    return -1;
 	sector_offset_in_chunk = sector_num+i-s->sectors[s->current_chunk];
 	memcpy(buf+i*512,s->uncompressed_chunk+sector_offset_in_chunk*512,512);
@@ -286,7 +283,6 @@ static int dmg_read(BlockDriverState *bs, int64_t sector_num,
 static void dmg_close(BlockDriverState *bs)
 {
     BDRVDMGState *s = bs->opaque;
-    close(s->fd);
     if(s->n_chunks>0) {
 	free(s->types);
 	free(s->offsets);
@@ -303,7 +299,7 @@ static BlockDriver bdrv_dmg = {
     .format_name	= "dmg",
     .instance_size	= sizeof(BDRVDMGState),
     .bdrv_probe		= dmg_probe,
-    .bdrv_file_open	= dmg_open,
+    .bdrv_open		= dmg_open,
     .bdrv_read		= dmg_read,
     .bdrv_close		= dmg_close,
 };
-- 
1.6.6.1

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

* [Qemu-devel] [PATCH 18/21] block/vdi: Fix image opening and creation for odd disk sizes
  2010-05-14 17:10 [Qemu-devel] [PULL 00/21] Block patches Kevin Wolf
                   ` (16 preceding siblings ...)
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 17/21] dmg: use qemu block API Kevin Wolf
@ 2010-05-14 17:10 ` Kevin Wolf
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 19/21] use qemu_free() instead of free() Kevin Wolf
                   ` (3 subsequent siblings)
  21 siblings, 0 replies; 28+ messages in thread
From: Kevin Wolf @ 2010-05-14 17:10 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel

From: Stefan Weil <weil@mail.berlios.de>

The fix is based on a patch from Kevin Wolf. Here his comment:

"The number of blocks needs to be rounded up to cover all of the virtual hard
disk. Without this fix, we can't even open our own images if their size is not
a multiple of the block size."

While Kevin's patch addressed vdi_create, my modification also fixes
vdi_open which now accepts images with odd disk sizes.

v3:
Don't allow reading of disk images with too large disk sizes.
Neither VBoxManage nor old versions of qemu-img read such images.
This change requires rounding of odd disk sizes before we do the checks.

Cc: Kevin Wolf <kwolf@redhat.com>
Cc: François Revol <revol@free.fr>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/vdi.c |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/block/vdi.c b/block/vdi.c
index 3ea4103..ee8cc7b 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -393,6 +393,15 @@ static int vdi_open(BlockDriverState *bs, int flags)
     vdi_header_print(&header);
 #endif
 
+    if (header.disk_size % SECTOR_SIZE != 0) {
+        /* 'VBoxManage convertfromraw' can create images with odd disk sizes.
+           We accept them but round the disk size to the next multiple of
+           SECTOR_SIZE. */
+        logout("odd disk size %" PRIu64 " B, round up\n", header.disk_size);
+        header.disk_size += SECTOR_SIZE - 1;
+        header.disk_size &= ~(SECTOR_SIZE - 1);
+    }
+
     if (header.version != VDI_VERSION_1_1) {
         logout("unsupported version %u.%u\n",
                header.version >> 16, header.version & 0xffff);
@@ -405,18 +414,15 @@ static int vdi_open(BlockDriverState *bs, int flags)
         /* We only support data blocks which start on a sector boundary. */
         logout("unsupported data offset 0x%x B\n", header.offset_data);
         goto fail;
-    } else if (header.disk_size % SECTOR_SIZE != 0) {
-        logout("unsupported disk size %" PRIu64 " B\n", header.disk_size);
-        goto fail;
     } else if (header.sector_size != SECTOR_SIZE) {
         logout("unsupported sector size %u B\n", header.sector_size);
         goto fail;
     } else if (header.block_size != 1 * MiB) {
         logout("unsupported block size %u B\n", header.block_size);
         goto fail;
-    } else if ((header.disk_size + header.block_size - 1) / header.block_size !=
-               (uint64_t)header.blocks_in_image) {
-        logout("unexpected block number %u B\n", header.blocks_in_image);
+    } else if (header.disk_size >
+               (uint64_t)header.blocks_in_image * header.block_size) {
+        logout("unsupported disk size %" PRIu64 " B\n", header.disk_size);
         goto fail;
     } else if (!uuid_is_null(header.uuid_link)) {
         logout("link uuid != 0, unsupported\n");
@@ -829,7 +835,10 @@ static int vdi_create(const char *filename, QEMUOptionParameter *options)
         return -errno;
     }
 
-    blocks = bytes / block_size;
+    /* We need enough blocks to store the given disk size,
+       so always round up. */
+    blocks = (bytes + block_size - 1) / block_size;
+
     bmap_size = blocks * sizeof(uint32_t);
     bmap_size = ((bmap_size + SECTOR_SIZE - 1) & ~(SECTOR_SIZE -1));
 
-- 
1.6.6.1

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

* [Qemu-devel] [PATCH 19/21] use qemu_free() instead of free()
  2010-05-14 17:10 [Qemu-devel] [PULL 00/21] Block patches Kevin Wolf
                   ` (17 preceding siblings ...)
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 18/21] block/vdi: Fix image opening and creation for odd disk sizes Kevin Wolf
@ 2010-05-14 17:10 ` Kevin Wolf
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 20/21] Fix docs for block stats monitor command Kevin Wolf
                   ` (2 subsequent siblings)
  21 siblings, 0 replies; 28+ messages in thread
From: Kevin Wolf @ 2010-05-14 17:10 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel

From: Bruce Rogers <brogers@novell.com>

There is a call to free() where qemu_free() should instead be used.

Signed-off-by: Bruce Rogers <brogers@novell.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/block.c b/block.c
index c134c2b..96ef1b1 100644
--- a/block.c
+++ b/block.c
@@ -2075,7 +2075,7 @@ int bdrv_aio_multiwrite(BlockDriverState *bs, BlockRequest *reqs, int num_reqs)
     return 0;
 
 fail:
-    free(mcb);
+    qemu_free(mcb);
     return -1;
 }
 
-- 
1.6.6.1

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

* [Qemu-devel] [PATCH 20/21] Fix docs for block stats monitor command
  2010-05-14 17:10 [Qemu-devel] [PULL 00/21] Block patches Kevin Wolf
                   ` (18 preceding siblings ...)
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 19/21] use qemu_free() instead of free() Kevin Wolf
@ 2010-05-14 17:10 ` Kevin Wolf
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 21/21] block: Remove special case for vvfat Kevin Wolf
  2010-05-17 18:22 ` [Qemu-devel] Re: [PULL 00/21] Block patches Anthony Liguori
  21 siblings, 0 replies; 28+ messages in thread
From: Kevin Wolf @ 2010-05-14 17:10 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel

From: Daniel P. Berrange <berrange@redhat.com>

The 'parent' field in the 'query-blockstats' monitor command is
part of the top level block device QDict, not part of the 2nd
level 'stats' QDict.

* block.c: Fix docs for 'parent' field in block stats monitor
  command output

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block.c |   23 +++++++++++------------
 1 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/block.c b/block.c
index 96ef1b1..7822580 100644
--- a/block.c
+++ b/block.c
@@ -1582,9 +1582,9 @@ static QObject* bdrv_info_stats_bs(BlockDriverState *bs)
  *     - "wr_operations": write operations
  *     - "wr_highest_offset": Highest offset of a sector written since the
  *       BlockDriverState has been opened
- *     - "parent": Contains recursively the statistics of the underlying
- *       protocol (e.g. the host file for a qcow2 image). If there is no
- *       underlying protocol, this field is omitted.
+ * - "parent": A QDict recursively holding the statistics of the underlying
+ *    protocol (e.g. the host file for a qcow2 image). If there is no
+ *    underlying protocol, this field is omitted.
  *
  * Example:
  *
@@ -1593,15 +1593,14 @@ static QObject* bdrv_info_stats_bs(BlockDriverState *bs)
  *                          "wr_bytes": 0,
  *                          "rd_operations": 1,
  *                          "wr_operations": 0,
- *                          "wr_highest_offset": 0,
- *                          "parent": {
- *                              "stats": { "rd_bytes": 1024,
- *                                         "wr_bytes": 0,
- *                                         "rd_operations": 2,
- *                                         "wr_operations": 0,
- *                                         "wr_highest_offset": 0,
- *                              }
- *                          } } },
+ *                          "wr_highest_offset": 0 },
+ *               "parent": {
+ *                      "stats": { "rd_bytes": 1024,
+ *                                 "wr_bytes": 0,
+ *                                 "rd_operations": 2,
+ *                                 "wr_operations": 0,
+ *                                 "wr_highest_offset": 0,
+ *                      } } },
  *   { "device": "ide1-cd0",
  *               "stats": { "rd_bytes": 0,
  *                          "wr_bytes": 0,
-- 
1.6.6.1

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

* [Qemu-devel] [PATCH 21/21] block: Remove special case for vvfat
  2010-05-14 17:10 [Qemu-devel] [PULL 00/21] Block patches Kevin Wolf
                   ` (19 preceding siblings ...)
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 20/21] Fix docs for block stats monitor command Kevin Wolf
@ 2010-05-14 17:10 ` Kevin Wolf
  2010-05-17 18:22 ` [Qemu-devel] Re: [PULL 00/21] Block patches Anthony Liguori
  21 siblings, 0 replies; 28+ messages in thread
From: Kevin Wolf @ 2010-05-14 17:10 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel

The special case doesn't really us buy anything. Without it vvfat works more
consistently as a protocol. We get raw on top of vvfat now, which works just
as well as using vvfat directly.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)

diff --git a/block.c b/block.c
index 7822580..bfe46e3 100644
--- a/block.c
+++ b/block.c
@@ -326,11 +326,6 @@ static BlockDriver *find_image_format(const char *filename)
     uint8_t buf[2048];
     BlockDriverState *bs;
 
-    drv = find_protocol(filename);
-    /* no need to test disk image formats for vvfat */
-    if (drv && strcmp(drv->format_name, "vvfat") == 0)
-        return drv;
-
     ret = bdrv_file_open(&bs, filename, 0);
     if (ret < 0)
         return NULL;
-- 
1.6.6.1

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

* [Qemu-devel] Re: [PULL 00/21] Block patches
  2010-05-14 17:10 [Qemu-devel] [PULL 00/21] Block patches Kevin Wolf
                   ` (20 preceding siblings ...)
  2010-05-14 17:10 ` [Qemu-devel] [PATCH 21/21] block: Remove special case for vvfat Kevin Wolf
@ 2010-05-17 18:22 ` Anthony Liguori
  21 siblings, 0 replies; 28+ messages in thread
From: Anthony Liguori @ 2010-05-17 18:22 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: qemu-devel

On 05/14/2010 12:10 PM, Kevin Wolf wrote:
> The following changes since commit 14ac15d3ac8e0ef1c91204e2ac772b6412a6b99e:
>    Anthony Liguori (1):
>          Update SeaBIOS
>
> are available in the git repository at:
>
>    git://repo.or.cz/qemu/kevin.git block
>    

Pulled, thanks.

Regards,

Anthony Liguori

> Bruce Rogers (1):
>        use qemu_free() instead of free()
>
> Christoph Hellwig (9):
>        cloop: use pread
>        cloop: use qemu block API
>        bochs: use pread
>        bochs: use qemu block API
>        parallels: use pread
>        parallels: use qemu block API
>        dmg: fix reading of uncompressed chunks
>        dmg: use pread
>        dmg: use qemu block API
>
> Daniel P. Berrange (1):
>        Fix docs for block stats monitor command
>
> Kevin Wolf (5):
>        ide: Fix ide_dma_cancel
>        block: Avoid unchecked casts for AIOCBs
>        block: Fix protocol detection for Windows devices
>        block: Fix bdrv_commit
>        block: Remove special case for vvfat
>
> Ryota Ozaki (1):
>        qemu-nbd: Improve error reporting
>
> Stefan Hajnoczi (1):
>        block: Remove semicolon in BDRV_SECTOR_MASK macro
>
> Stefan Weil (3):
>        block/vdi: Allow disk images of size 0
>        block/vpc: Fix conversion from size to disk geometry
>        block/vdi: Fix image opening and creation for odd disk sizes
>
>   block.c           |   49 +++++++++++-------------
>   block.h           |    2 +-
>   block/blkdebug.c  |    4 +-
>   block/bochs.c     |   81 +++++++++++----------------------------
>   block/cloop.c     |   48 ++++++++++++------------
>   block/dmg.c       |  109 +++++++++++++++++++++++++++++------------------------
>   block/parallels.c |   51 +++++++------------------
>   block/qcow.c      |    2 +-
>   block/qcow2.c     |    2 +-
>   block/vdi.c       |   34 ++++++++++++-----
>   block/vpc.c       |   21 ++++++----
>   hw/ide/core.c     |    8 ++--
>   qemu-nbd.c        |   34 ++++++++++++-----
>   13 files changed, 213 insertions(+), 232 deletions(-)
>    

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

* [Qemu-devel] [PULL 00/21] Block patches
@ 2011-07-19 10:15 Kevin Wolf
  0 siblings, 0 replies; 28+ messages in thread
From: Kevin Wolf @ 2011-07-19 10:15 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel

The following changes since commit 89b9ba661bd2d6155308f895ec075d813f0e129b:

  Fix signal handling of SIG_IPI when io-thread is enabled (2011-07-16 19:43:00 +0000)

are available in the git repository at:
  git://repo.or.cz/qemu/kevin.git for-anthony

Devin Nakamura (2):
      qemu-io: Fix formatting
      qemu-io: Fix if scoping bug

Fam Zheng (12):
      VMDK: introduce VmdkExtent
      VMDK: bugfix, align offset to cluster in get_whole_cluster
      VMDK: probe for monolithicFlat images
      VMDK: separate vmdk_open by format version
      VMDK: add field BDRVVmdkState.desc_offset
      VMDK: flush multiple extents
      VMDK: move 'static' cid_update flag to bs field
      VMDK: change get_cluster_offset return type
      VMDK: open/read/write for monolithicFlat image
      VMDK: create different subformats
      VMDK: fix coding style
      block: add bdrv_get_allocated_file_size() operation

Hannes Reinecke (4):
      iov: Update parameter usage in iov_(to|from)_buf()
      scsi: Add 'hba_private' to SCSIRequest
      scsi-disk: Fixup debugging statement
      scsi-disk: Mask out serial number EVPD

Luiz Capitulino (2):
      qemu-options.hx: Document missing -drive options
      qemu-config: Document -drive options

MORITA Kazutaka (1):
      sheepdog: add full data preallocation support

 block.c                |   19 +
 block.h                |    1 +
 block/raw-posix.c      |   21 +
 block/raw-win32.c      |   29 +
 block/sheepdog.c       |   71 ++-
 block/vmdk.c           | 1297 ++++++++++++++++--------
 block_int.h            |    2 +
 hw/esp.c               |    2 +-
 hw/lsi53c895a.c        |   22 +-
 hw/scsi-bus.c          |    9 +-
 hw/scsi-disk.c         |   21 +-
 hw/scsi-generic.c      |    5 +-
 hw/scsi.h              |   10 +-
 hw/spapr_vscsi.c       |   29 +-
 hw/usb-msd.c           |    9 +-
 hw/virtio-net.c        |    2 +-
 hw/virtio-serial-bus.c |    2 +-
 iov.c                  |   49 +-
 iov.h                  |   10 +-
 qemu-config.c          |    6 +
 qemu-img.c             |   31 +-
 qemu-io.c              | 2653 ++++++++++++++++++++++++------------------------
 qemu-options.hx        |    8 +
 23 files changed, 2462 insertions(+), 1846 deletions(-)

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

* [Qemu-devel] [PULL 00/21] Block patches
@ 2017-02-12  1:34 Max Reitz
  2017-02-13 10:54 ` Peter Maydell
  0 siblings, 1 reply; 28+ messages in thread
From: Max Reitz @ 2017-02-12  1:34 UTC (permalink / raw)
  To: qemu-block; +Cc: qemu-devel, Max Reitz, Peter Maydell

The following changes since commit 98b2faeaee96ab084d0b1669918688d8895c155f:

  Merge remote-tracking branch 'remotes/jnsnow/tags/ide-pull-request' into staging (2017-02-10 18:07:02 +0000)

are available in the git repository at:

  git://github.com/XanClic/qemu.git tags/pull-block-2017-02-12

for you to fetch changes up to 10d6eda1926804a09aa0710ca62933087813de0b:

  qemu-img: Avoid setting ret to unused value in img_convert() (2017-02-12 00:56:32 +0100)

----------------------------------------------------------------
Block patches

----------------------------------------------------------------
Alberto Garcia (2):
      qcow2: Optimize the refcount-block overlap check
      qemu-io: don't allow I/O operations larger than BDRV_REQUEST_MAX_BYTES

Daniel P. Berrange (1):
      iotests: record separate timings per format,protocol pair

Dou Liyang (2):
      block/qapi: reduce the coupling between the bdrv_query_stats and bdrv_query_bds_stats
      block/qapi: reduce the execution time of qmp_query_blockstats

Fam Zheng (2):
      qapi: Tweak error message of bdrv_query_image_info
      iotests: Fix reference output for 059

Jeff Cody (3):
      block: check full backing filename when searching protocol filenames
      qemu-iotests: Don't create fifos / pidfiles with protocol paths
      qemu-iotest: test to lookup protocol-based image with relative backing

Max Reitz (1):
      qemu-img: Improve commit invalid base message

Nir Soffer (3):
      qemu-io: Return non-zero exit code on failure
      qemu-iotests: Add _unsupported_fmt helper
      qemu-io: Add failure regression tests

Peter Lieven (2):
      block/nfs: fix NULL pointer dereference in URI parsing
      block/nfs: fix naming of runtime opts

Peter Maydell (2):
      qemu-img: Use qemu_strtoul() rather than raw strtoul()
      qemu-img: Avoid setting ret to unused value in img_convert()

QingFeng Hao (2):
      iotests: Fix a problem in common.filter
      block/vmdk: Fix the endian problem of buf_len and lba

Vladimir Sementsov-Ogievskiy (1):
      block: bdrv_invalidate_cache: invalidate children first

 tests/qemu-iotests/Makefile      |  2 +-
 block/qcow2.h                    |  1 +
 block.c                          | 24 +++++++---
 block/nfs.c                      | 49 ++++++++++----------
 block/qapi.c                     | 99 +++++++++++++++++-----------------------
 block/qcow2-refcount.c           | 24 +++++++++-
 block/qcow2.c                    |  1 +
 block/vmdk.c                     |  4 +-
 qemu-img.c                       | 44 +++++++++---------
 qemu-io-cmds.c                   | 20 +++++---
 qemu-io.c                        |  8 +++-
 tests/qemu-iotests/.gitignore    |  2 +-
 tests/qemu-iotests/059.out       |  5 +-
 tests/qemu-iotests/070.out       |  1 -
 tests/qemu-iotests/075.out       |  7 ---
 tests/qemu-iotests/076.out       |  3 --
 tests/qemu-iotests/078.out       |  6 ---
 tests/qemu-iotests/080.out       | 18 --------
 tests/qemu-iotests/083.out       | 17 -------
 tests/qemu-iotests/088.out       |  6 ---
 tests/qemu-iotests/092.out       | 12 -----
 tests/qemu-iotests/116.out       |  7 ---
 tests/qemu-iotests/131.out       |  1 -
 tests/qemu-iotests/140.out       |  1 -
 tests/qemu-iotests/173           | 97 +++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/173.out       | 12 +++++
 tests/qemu-iotests/174           | 59 ++++++++++++++++++++++++
 tests/qemu-iotests/174.out       |  7 +++
 tests/qemu-iotests/check         | 12 +++--
 tests/qemu-iotests/common.config |  6 ++-
 tests/qemu-iotests/common.filter |  2 +-
 tests/qemu-iotests/common.qemu   | 10 ++--
 tests/qemu-iotests/common.rc     | 17 +++++--
 tests/qemu-iotests/group         |  2 +
 34 files changed, 366 insertions(+), 220 deletions(-)
 create mode 100755 tests/qemu-iotests/173
 create mode 100644 tests/qemu-iotests/173.out
 create mode 100755 tests/qemu-iotests/174
 create mode 100644 tests/qemu-iotests/174.out

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

* Re: [Qemu-devel] [PULL 00/21] Block patches
  2017-02-12  1:34 Max Reitz
@ 2017-02-13 10:54 ` Peter Maydell
  0 siblings, 0 replies; 28+ messages in thread
From: Peter Maydell @ 2017-02-13 10:54 UTC (permalink / raw)
  To: Max Reitz; +Cc: Qemu-block, QEMU Developers

On 12 February 2017 at 01:34, Max Reitz <mreitz@redhat.com> wrote:
> The following changes since commit 98b2faeaee96ab084d0b1669918688d8895c155f:
>
>   Merge remote-tracking branch 'remotes/jnsnow/tags/ide-pull-request' into staging (2017-02-10 18:07:02 +0000)
>
> are available in the git repository at:
>
>   git://github.com/XanClic/qemu.git tags/pull-block-2017-02-12
>
> for you to fetch changes up to 10d6eda1926804a09aa0710ca62933087813de0b:
>
>   qemu-img: Avoid setting ret to unused value in img_convert() (2017-02-12 00:56:32 +0100)
>
> ----------------------------------------------------------------
> Block patches
>

Applied, thanks.

-- PMM

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

* [Qemu-devel] [PULL 00/21] Block patches
@ 2019-05-28 19:28 Max Reitz
  2019-05-30 11:09 ` Peter Maydell
  0 siblings, 1 reply; 28+ messages in thread
From: Max Reitz @ 2019-05-28 19:28 UTC (permalink / raw)
  To: qemu-block; +Cc: Kevin Wolf, Peter Maydell, qemu-devel, Max Reitz

The following changes since commit 8c1ecb590497b0349c550607db923972b37f6963:

  Merge remote-tracking branch 'remotes/stsquad/tags/pull-testing-next-280519-2' into staging (2019-05-28 17:38:32 +0100)

are available in the Git repository at:

  https://github.com/XanClic/qemu.git tags/pull-block-2019-05-28

for you to fetch changes up to a2d665c1bc3624a8375e2f9a7d569f7565cc1358:

  blockdev: loosen restrictions on drive-backup source node (2019-05-28 20:30:55 +0200)

----------------------------------------------------------------
Block patches:
- qcow2: Use threads for encrypted I/O
- qemu-img rebase: Optimizations
- backup job: Allow any source node, and some refactoring
- Some general simplifications in the block layer

----------------------------------------------------------------
Alberto Garcia (2):
  block: Use bdrv_unref_child() for all children in bdrv_close()
  block: Make bdrv_root_attach_child() unref child_bs on failure

Andrey Shinkevich (1):
  qcow2-bitmap: initialize bitmap directory alignment

Anton Nefedov (1):
  qcow2: skip writing zero buffers to empty COW areas

John Snow (1):
  blockdev: loosen restrictions on drive-backup source node

Sam Eiderman (3):
  qemu-img: rebase: Reuse parent BlockDriverState
  qemu-img: rebase: Reduce reads on in-chain rebase
  qemu-img: rebase: Reuse in-chain BlockDriverState

Vladimir Sementsov-Ogievskiy (13):
  qcow2.h: add missing include
  qcow2: add separate file for threaded data processing functions
  qcow2-threads: use thread_pool_submit_co
  qcow2-threads: qcow2_co_do_compress: protect queuing by mutex
  qcow2-threads: split out generic path
  qcow2: qcow2_co_preadv: improve locking
  qcow2: bdrv_co_pwritev: move encryption code out of the lock
  qcow2: do encryption in threads
  block/backup: simplify backup_incremental_init_copy_bitmap
  block/backup: move to copy_bitmap with granularity
  block/backup: refactor and tolerate unallocated cluster skipping
  block/backup: unify different modes code path
  block/backup: refactor: split out backup_calculate_cluster_size

 block/Makefile.objs         |   2 +-
 qapi/block-core.json        |   4 +-
 block/qcow2.h               |  26 ++-
 block.c                     |  46 +++---
 block/backup.c              | 243 ++++++++++++---------------
 block/block-backend.c       |   3 +-
 block/qcow2-bitmap.c        |   3 +-
 block/qcow2-cache.c         |   1 -
 block/qcow2-cluster.c       |  10 +-
 block/qcow2-refcount.c      |   1 -
 block/qcow2-snapshot.c      |   1 -
 block/qcow2-threads.c       | 268 ++++++++++++++++++++++++++++++
 block/qcow2.c               | 320 +++++++++++++-----------------------
 block/quorum.c              |   1 -
 blockdev.c                  |   7 +-
 blockjob.c                  |   2 +-
 qemu-img.c                  |  85 ++++++----
 tests/test-bdrv-drain.c     |   6 -
 tests/test-bdrv-graph-mod.c |   1 -
 block/trace-events          |   1 +
 tests/qemu-iotests/056      |   2 +-
 tests/qemu-iotests/060      |   7 +-
 tests/qemu-iotests/060.out  |   5 +-
 23 files changed, 615 insertions(+), 430 deletions(-)
 create mode 100644 block/qcow2-threads.c

-- 
2.21.0



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

* Re: [Qemu-devel] [PULL 00/21] Block patches
  2019-05-28 19:28 Max Reitz
@ 2019-05-30 11:09 ` Peter Maydell
  0 siblings, 0 replies; 28+ messages in thread
From: Peter Maydell @ 2019-05-30 11:09 UTC (permalink / raw)
  To: Max Reitz; +Cc: Kevin Wolf, QEMU Developers, Qemu-block

On Tue, 28 May 2019 at 20:28, Max Reitz <mreitz@redhat.com> wrote:
>
> The following changes since commit 8c1ecb590497b0349c550607db923972b37f6963:
>
>   Merge remote-tracking branch 'remotes/stsquad/tags/pull-testing-next-280519-2' into staging (2019-05-28 17:38:32 +0100)
>
> are available in the Git repository at:
>
>   https://github.com/XanClic/qemu.git tags/pull-block-2019-05-28
>
> for you to fetch changes up to a2d665c1bc3624a8375e2f9a7d569f7565cc1358:
>
>   blockdev: loosen restrictions on drive-backup source node (2019-05-28 20:30:55 +0200)
>
> ----------------------------------------------------------------
> Block patches:
> - qcow2: Use threads for encrypted I/O
> - qemu-img rebase: Optimizations
> - backup job: Allow any source node, and some refactoring
> - Some general simplifications in the block layer
>
> ----------------------------------------------------------------


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/4.1
for any user-visible changes.

-- PMM


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

end of thread, other threads:[~2019-05-30 11:11 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-14 17:10 [Qemu-devel] [PULL 00/21] Block patches Kevin Wolf
2010-05-14 17:10 ` [Qemu-devel] [PATCH 01/21] block: Remove semicolon in BDRV_SECTOR_MASK macro Kevin Wolf
2010-05-14 17:10 ` [Qemu-devel] [PATCH 02/21] qemu-nbd: Improve error reporting Kevin Wolf
2010-05-14 17:10 ` [Qemu-devel] [PATCH 03/21] cloop: use pread Kevin Wolf
2010-05-14 17:10 ` [Qemu-devel] [PATCH 04/21] cloop: use qemu block API Kevin Wolf
2010-05-14 17:10 ` [Qemu-devel] [PATCH 05/21] ide: Fix ide_dma_cancel Kevin Wolf
2010-05-14 17:10 ` [Qemu-devel] [PATCH 06/21] bochs: use pread Kevin Wolf
2010-05-14 17:10 ` [Qemu-devel] [PATCH 07/21] bochs: use qemu block API Kevin Wolf
2010-05-14 17:10 ` [Qemu-devel] [PATCH 08/21] block: Avoid unchecked casts for AIOCBs Kevin Wolf
2010-05-14 17:10 ` [Qemu-devel] [PATCH 09/21] block: Fix protocol detection for Windows devices Kevin Wolf
2010-05-14 17:10 ` [Qemu-devel] [PATCH 10/21] block: Fix bdrv_commit Kevin Wolf
2010-05-14 17:10 ` [Qemu-devel] [PATCH 11/21] block/vdi: Allow disk images of size 0 Kevin Wolf
2010-05-14 17:10 ` [Qemu-devel] [PATCH 12/21] parallels: use pread Kevin Wolf
2010-05-14 17:10 ` [Qemu-devel] [PATCH 13/21] parallels: use qemu block API Kevin Wolf
2010-05-14 17:10 ` [Qemu-devel] [PATCH 14/21] block/vpc: Fix conversion from size to disk geometry Kevin Wolf
2010-05-14 17:10 ` [Qemu-devel] [PATCH 15/21] dmg: fix reading of uncompressed chunks Kevin Wolf
2010-05-14 17:10 ` [Qemu-devel] [PATCH 16/21] dmg: use pread Kevin Wolf
2010-05-14 17:10 ` [Qemu-devel] [PATCH 17/21] dmg: use qemu block API Kevin Wolf
2010-05-14 17:10 ` [Qemu-devel] [PATCH 18/21] block/vdi: Fix image opening and creation for odd disk sizes Kevin Wolf
2010-05-14 17:10 ` [Qemu-devel] [PATCH 19/21] use qemu_free() instead of free() Kevin Wolf
2010-05-14 17:10 ` [Qemu-devel] [PATCH 20/21] Fix docs for block stats monitor command Kevin Wolf
2010-05-14 17:10 ` [Qemu-devel] [PATCH 21/21] block: Remove special case for vvfat Kevin Wolf
2010-05-17 18:22 ` [Qemu-devel] Re: [PULL 00/21] Block patches Anthony Liguori
  -- strict thread matches above, loose matches on Subject: below --
2011-07-19 10:15 [Qemu-devel] " Kevin Wolf
2017-02-12  1:34 Max Reitz
2017-02-13 10:54 ` Peter Maydell
2019-05-28 19:28 Max Reitz
2019-05-30 11:09 ` Peter Maydell

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).