1. 03 May, 2010 12 commits
    • Stefan Hajnoczi's avatar
      block: Cache total_sectors to reduce bdrv_getlength calls · 51762288
      Stefan Hajnoczi authored
      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
      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
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    • Stefan Hajnoczi's avatar
      raw-posix: Use pread/pwrite instead of lseek+read/write · 4899d10d
      Stefan Hajnoczi authored
      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
      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: default avatarStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    • Stefan Hajnoczi's avatar
      qcow2: Avoid shadowing variable in alloc_clusters_noref() · 508e0893
      Stefan Hajnoczi authored
      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: default avatarStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    • Stefan Hajnoczi's avatar
      block: Set backing_hd to NULL after deleting it · 557df6ac
      Stefan Hajnoczi authored
      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: default avatarStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    • Kevin Wolf's avatar
      vmdk: Convert to bdrv_open · 6511ef77
      Kevin Wolf authored
      It's a format driver, so implement bdrv_open instead of bdrv_file_open.
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    • Kevin Wolf's avatar
      vmdk: Clean up backing file handling · 9949f97e
      Kevin Wolf authored
      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: default avatarKevin Wolf <kwolf@redhat.com>
    • Kevin Wolf's avatar
      vmdk: Fix COW · c336500d
      Kevin Wolf authored
      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: default avatarKevin Wolf <kwolf@redhat.com>
    • Kevin Wolf's avatar
      block: bdrv_has_zero_init · f2feebbd
      Kevin Wolf authored
      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: default avatarKevin Wolf <kwolf@redhat.com>
    • Kevin Wolf's avatar
      block: Open the underlying image file in generic code · 66f82cee
      Kevin Wolf authored
      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
      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: default avatarKevin Wolf <kwolf@redhat.com>
    • Kevin Wolf's avatar
      block: Avoid forward declaration of bdrv_open_common · 57915332
      Kevin Wolf authored
      Move bdrv_open_common so it's defined before its callers and remove the forward
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    • Kevin Wolf's avatar
      block: Split bdrv_open · b6ce07aa
      Kevin Wolf authored
      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: default avatarKevin Wolf <kwolf@redhat.com>
    • Christoph Hellwig's avatar
      block: separate raw images from the file protocol · 84a12e66
      Christoph Hellwig authored
      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
      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: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
  2. 02 May, 2010 1 commit
  3. 01 May, 2010 4 commits
  4. 28 Apr, 2010 17 commits
  5. 27 Apr, 2010 1 commit
    • Thomas Monjalon's avatar
      microblaze: fix custom fprintf · aacf4563
      Thomas Monjalon authored
      Using GCC-4.2.4-1ubuntu4, there is a warning:
      	microblaze-dis.c:792: warning: unused variable 'fprintf'
      Indeed, fprintf() is shadowed by a custom redefinition but is not used because
      of FORTIFY_SOURCE option which replace calls to fprintf() by fprintf_chk().
      So, fprintf refers to the libc implementation instead of the qemu one.
      It's a bug.
      It is fixed by renaming the variable to something different of "fprintf".
      It prevents from hazardous shadowing.
      Signed-off-by: default avatarThomas Monjalon <thomas@monjalon.net>
      Signed-off-by: default avatarBlue Swirl <blauwirbel@gmail.com>
  6. 26 Apr, 2010 5 commits