1. 03 5月, 2010 17 次提交
    • K
      block: Add wr_highest_sector blockstat · 294cc35f
      Kevin Wolf 提交于
      This adds the wr_highest_sector blockstat which implements what is generally
      known as the high watermark. It is the highest offset of a sector written to
      the respective BlockDriverState since it has been opened.
      
      The query-blockstat QMP command is extended to add this value to the result,
      and also to add the statistics of the underlying protocol in a new "parent"
      field. Note that to get the "high watermark" of a qcow2 image, you need to look
      into the wr_highest_sector field of the parent (which can be a file, a
      host_device, ...). The wr_highest_sector of the qcow2 BlockDriverState itself
      is the highest offset on the _virtual_ disk that the guest has written to.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      294cc35f
    • 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
      qemu-img: Add 'resize' command to grow/shrink disk images · ae6b0ed6
      Stefan Hajnoczi 提交于
      This patch adds a 'resize' command to grow/shrink disk images.  This
      allows changing the size of disk images without copying to a new image
      file.  Currently only raw files support resize.
      Signed-off-by: NStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      ae6b0ed6
    • S
      block: Cache total_sectors to reduce bdrv_getlength calls · 51762288
      Stefan Hajnoczi 提交于
      The BlockDriver bdrv_getlength function is called from the I/O code path
      when checking that the request falls within the device.  Unfortunately
      this involves an lseek system call in the raw protocol; every read or
      write request will incur this lseek cost.
      
      Jan Kiszka <jan.kiszka@siemens.com> identified this issue and its
      latency overhead.  This patch caches device length in the existing
      total_sectors variable so lseek calls can be avoided for fixed size
      devices.
      
      Growable devices fall back to the full bdrv_getlength code path because
      I have not added logic to detect extending the size of the device in a
      write.
      Signed-off-by: NStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      51762288
    • 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
    • S
      block: Set backing_hd to NULL after deleting it · 557df6ac
      Stefan Hajnoczi 提交于
      It is safer to set backing_hd to NULL after deleting it so that any use
      after deletion is obvious during development.  Happy segfaulting!
      
      This patch should be applied after Kevin Wolf's "vmdk: Convert to
      bdrv_open" so that vmdk does not segfault on close.
      Signed-off-by: NStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      557df6ac
    • 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: bdrv_has_zero_init · f2feebbd
      Kevin Wolf 提交于
      This fixes the problem that qemu-img's use of no_zero_init only considered the
      no_zero_init flag of the format driver, but not of the underlying protocols.
      
      Between the raw/file split and this fix, converting to host devices is broken.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      f2feebbd
    • 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
    • K
      block: Avoid forward declaration of bdrv_open_common · 57915332
      Kevin Wolf 提交于
      Move bdrv_open_common so it's defined before its callers and remove the forward
      declaration.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      57915332
    • K
      block: Split bdrv_open · b6ce07aa
      Kevin Wolf 提交于
      bdrv_open contains quite some code that is only useful for opening images (as
      opposed to opening files by a protocol), for example snapshots.
      
      This patch splits the code so that we have bdrv_open_file() for files (uses
      protocols), bdrv_open() for images (uses format drivers) and bdrv_open_common()
      for the code common for opening both images and files.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      b6ce07aa
    • 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
    • B
      Fix missing '|' in '|=', spotted by clang analyzer · ace22f69
      Blue Swirl 提交于
      Signed-off-by: NBlue Swirl <blauwirbel@gmail.com>
      ace22f69
  2. 02 5月, 2010 4 次提交
  3. 28 4月, 2010 18 次提交
  4. 27 4月, 2010 1 次提交