1. 03 5月, 2010 9 次提交
    • S
      qcow2: Implement bdrv_truncate() for growing images · 419b19d9
      Stefan Hajnoczi 提交于
      This patch adds the ability to grow qcow2 images in-place using
      bdrv_truncate().  This enables qemu-img resize command support for
      qcow2.
      
      Snapshots are not supported and bdrv_truncate() will return -ENOTSUP.
      The notion of resizing an image with snapshots could lead to confusion:
      users may expect snapshots to remain unchanged, but this is not possible
      with the current qcow2 on-disk format where the header.size field is
      global instead of per-snapshot.  Others may expect snapshots to change
      size along with the current image data.  I think it is safest to not
      support snapshots and perhaps add behavior later if there is a
      consensus.
      
      Backing images continue to work.  If the image is now larger than its
      backing image, zeroes are read when accessing beyond the end of the
      backing image.
      Signed-off-by: NStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      419b19d9
    • K
      qcow2: Remove abort on free_clusters failure · 003fad6e
      Kevin Wolf 提交于
      While it's true that during regular operation free_clusters failure would be a
      bug, an I/O error can always happen. There's no need to kill the VM, the worst
      thing that can happen (and it will) is that we leak some clusters.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      003fad6e
    • S
      raw-posix: Use pread/pwrite instead of lseek+read/write · 4899d10d
      Stefan Hajnoczi 提交于
      This patch combines the lseek+read/write calls to use pread/pwrite
      instead.  This will result in fewer system calls and is already used by
      AIO.
      
      Thanks to Jan Kiszka <jan.kiszka@siemens.com> for identifying excessive
      lseek and Christoph Hellwig <hch@lst.de> for confirming that this
      approach should work.
      Signed-off-by: NStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      4899d10d
    • S
      qcow2: Avoid shadowing variable in alloc_clusters_noref() · 508e0893
      Stefan Hajnoczi 提交于
      The i loop iterator is shadowed by the next free cluster index.  Both
      using the variable name 'i' makes the code harder to read.
      Signed-off-by: NStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      508e0893
    • K
      vmdk: Convert to bdrv_open · 6511ef77
      Kevin Wolf 提交于
      It's a format driver, so implement bdrv_open instead of bdrv_file_open.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      6511ef77
    • K
      vmdk: Clean up backing file handling · 9949f97e
      Kevin Wolf 提交于
      VMDK is doing interesting things when it needs to open a backing file. This
      patch changes that part to look more like in other drivers. The nice side
      effect is that the file name isn't needed any more in the open function.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      9949f97e
    • K
      vmdk: Fix COW · c336500d
      Kevin Wolf 提交于
      When trying to do COW, VMDK wrote the data back to the backing file. This
      problem was revealed by the patch that made backing files read-only. This patch
      does not only fix the problem, but also simplifies the VMDK code a bit.
      
      This fixes the backing file qemu-iotests cases for VMDK.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      c336500d
    • K
      block: Open the underlying image file in generic code · 66f82cee
      Kevin Wolf 提交于
      Format drivers shouldn't need to bother with things like file names, but rather
      just get an open BlockDriverState for the underlying protocol. This patch
      introduces this behaviour for bdrv_open implementation. For protocols which
      need to access the filename to open their file/device/connection/... a new
      callback bdrv_file_open is introduced which doesn't get an underlying file
      opened.
      
      For now, also some of the more obscure formats use bdrv_file_open because they
      open() the file themselves instead of using the block.c functions. They need to
      be fixed in later patches.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      66f82cee
    • C
      block: separate raw images from the file protocol · 84a12e66
      Christoph Hellwig 提交于
      We're running into various problems because the "raw" file access, which
      is used internally by the various image formats is entangled with the
      "raw" image format, which maps the VM view 1:1 to a file system.
      
      This patch renames the raw file backends to the file protocol which
      is treated like other protocols (e.g. nbd and http) and adds a new
      "raw" image format which is just a wrapper around calls to the underlying
      protocol.
      
      The patch is surprisingly simple, besides changing the probing logical
      in block.c to only look for image formats when using bdrv_open and
      renaming of the old raw protocols to file there's almost nothing in there.
      
      For creating images, a new bdrv_create_file is introduced which guesses the
      protocol to use. This allows using qemu-img create -f raw (or just using the
      default) for both files and host devices. Converting the other format drivers
      to use this function to create their images is left for later patches.
      
      The only issues still open are in the handling of the host devices.
      Firstly in current qemu we can specifiy the host* format names
      on various command line acceping images, but the new code can't
      do that without adding some translation.  Second the layering breaks
      the no_zero_init flag in the BlockDriver used by qemu-img.  I'm not
      happy how this is done per-driver instead of per-state so I'll
      prepare a separate patch to clean this up.
      
      There's some more cleanup opportunity after this patch, e.g. using
      separate lists and registration functions for image formats vs
      protocols and maybe even host drivers, but this can be done at a
      later stage.
      
      Also there's a check for protocol in bdrv_open for the BDRV_O_SNAPSHOT
      case that I don't quite understand, but which I fear won't work as
      expected - possibly even before this patch.
      
      Note that this patch requires various recent block patches from Kevin
      and me, which should all be in his block queue.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      84a12e66
  2. 25 4月, 2010 1 次提交
  3. 24 4月, 2010 1 次提交
  4. 23 4月, 2010 12 次提交
  5. 10 4月, 2010 3 次提交
  6. 27 3月, 2010 1 次提交
  7. 19 3月, 2010 1 次提交
  8. 13 3月, 2010 1 次提交
  9. 10 3月, 2010 7 次提交
  10. 24 2月, 2010 4 次提交
    • K
      qcow2: Fix image creation regression · 6f745bda
      Kevin Wolf 提交于
      When checking for errors, commit db89119d compares with the wrong values,
      failing image creation even when there was no error. Additionally, if an
      error has occured, we can't preallocate the image (it's likely broken).
      
      This unbreaks test 023 of qemu-iotests.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
      6f745bda
    • K
      qcow2: More checks for qemu-img check · 746c3cb5
      Kevin Wolf 提交于
      Implement some more refcount block related checks
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
      746c3cb5
    • K
      qcow2: Rewrite alloc_refcount_block/grow_refcount_table · 92dcb59f
      Kevin Wolf 提交于
      The current implementation of alloc_refcount_block and grow_refcount_table has
      fundamental problems regarding error handling. There are some places where an
      I/O error means that the image is going to be corrupted. I have found that the
      only way to fix this is to completely rewrite the thing.
      
      In detail, the problem is that the refcount blocks itself are allocated using
      alloc_refcount_noref (to avoid endless recursion when updating the refcount of
      the new refcount block, which migh access just the same refcount block but its
      allocation is not yet completed...). Only at the end of the refcount allocation
      the refcount of the refcount block is increased. If an error happens in
      between, the refcount block is in use, but has a refcount of zero and will
      likely be overwritten later.
      
      The new approach is explained in comments in the code. The trick is basically
      to let new refcount blocks describe their own refcount, so their refcount will
      be automatically changed when they are hooked up in the refcount table.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
      92dcb59f
    • K
      qcow2: Factor next_refcount_table_size out · 05121aed
      Kevin Wolf 提交于
      When the refcount table grows, it doesn't only grow by one entry but reserves
      some space for future refcount blocks. The algorithm to calculate the number of
      entries stays the same with the fixes, so factor it out before replacing the
      rest.
      
      As Juan suggested take the opportunity to simplify the code a bit.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
      05121aed