1. 15 6月, 2010 5 次提交
    • B
      block: fix a warning and possible truncation · 5ffbbc67
      Blue Swirl 提交于
      Fix a warning from OpenBSD gcc (3.3.5 (propolice)):
      /src/qemu/block.c: In function `bdrv_info_stats_bs':
      /src/qemu/block.c:1548: warning: long long int format, long unsigned
      int arg (arg 6)
      
      There may be also truncation effects.
      Signed-off-by: NBlue Swirl <blauwirbel@gmail.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      5ffbbc67
    • M
      block: New bdrv_next() · 2f399b0a
      Markus Armbruster 提交于
      This is a more flexible alternative to bdrv_iterate().
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      2f399b0a
    • M
      block: Decouple block device "commit all" from DriveInfo · 6ab4b5ab
      Markus Armbruster 提交于
      do_commit() and mux_proc_byte() iterate over the list of drives
      defined with drive_init().  This misses host block devices defined by
      other means.  Such means don't exist now, but will be introduced later
      in this series.
      
      Change them to use new bdrv_commit_all(), which iterates over all host
      block devices.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      6ab4b5ab
    • M
      block: Move error actions from DriveInfo to BlockDriverState · abd7f68d
      Markus Armbruster 提交于
      That's where they belong semantically (block device host part), even
      though the actions are actually executed by guest device code.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      abd7f68d
    • M
      savevm: Really verify if a drive supports snapshots · feeee5ac
      Miguel Di Ciurcio Filho 提交于
      Both bdrv_can_snapshot() and bdrv_has_snapshot() does not work as advertized.
      
      First issue: Their names implies different porpouses, but they do the same thing
      and have exactly the same code. Maybe copied and pasted and forgotten?
      bdrv_has_snapshot() is called in various places for actually checking if there
      is snapshots or not.
      
      Second issue: the way bdrv_can_snapshot() verifies if a block driver supports or
      not snapshots does not catch all cases. E.g.: a raw image.
      
      So when do_savevm() is called, first thing it does is to set a global
      BlockDriverState to save the VM memory state calling get_bs_snapshots().
      
      static BlockDriverState *get_bs_snapshots(void)
      {
          BlockDriverState *bs;
          DriveInfo *dinfo;
      
          if (bs_snapshots)
              return bs_snapshots;
          QTAILQ_FOREACH(dinfo, &drives, next) {
              bs = dinfo->bdrv;
              if (bdrv_can_snapshot(bs))
                  goto ok;
          }
          return NULL;
       ok:
          bs_snapshots = bs;
          return bs;
      }
      
      bdrv_can_snapshot() may return a BlockDriverState that does not support
      snapshots and do_savevm() goes on.
      
      Later on in do_savevm(), we find:
      
          QTAILQ_FOREACH(dinfo, &drives, next) {
              bs1 = dinfo->bdrv;
              if (bdrv_has_snapshot(bs1)) {
                  /* Write VM state size only to the image that contains the state */
                  sn->vm_state_size = (bs == bs1 ? vm_state_size : 0);
                  ret = bdrv_snapshot_create(bs1, sn);
                  if (ret < 0) {
                      monitor_printf(mon, "Error while creating snapshot on '%s'\n",
                                     bdrv_get_device_name(bs1));
                  }
              }
          }
      
      bdrv_has_snapshot(bs1) is not checking if the device does support or has
      snapshots as explained above. Only in bdrv_snapshot_create() the device is
      actually checked for snapshot support.
      
      So, in cases where the first device supports snapshots, and the second does not,
      the snapshot on the first will happen anyways. I believe this is not a good
      behavior. It should be an all or nothing process.
      
      This patch addresses these issues by making bdrv_can_snapshot() actually do
      what it must do and enforces better tests to avoid errors in the middle of
      do_savevm(). bdrv_has_snapshot() is removed and replaced by bdrv_can_snapshot()
      where appropriate.
      
      bdrv_can_snapshot() was moved from savevm.c to block.c. It makes more sense to me.
      
      The loadvm_state() function was updated too to enforce that when loading a VM at
      least all writable devices must support snapshots too.
      Signed-off-by: NMiguel Di Ciurcio Filho <miguel.filho@gmail.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      feeee5ac
  2. 04 6月, 2010 5 次提交
  3. 02 6月, 2010 1 次提交
  4. 28 5月, 2010 3 次提交
  5. 27 5月, 2010 1 次提交
    • A
      Add cache=unsafe parameter to -drive · 016f5cf6
      Alexander Graf 提交于
      Usually the guest can tell the host to flush data to disk. In some cases we
      don't want to flush though, but try to keep everything in cache.
      
      So let's add a new cache value to -drive that allows us to set the cache
      policy to most aggressive, disabling flushes. We call this mode "unsafe",
      as guest data is not guaranteed to survive host crashes anymore.
      
      This patch also adds a noop function for aio, so we can do nothing in AIO
      fashion.
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      Signed-off-by: NAurelien Jarno <aurelien@aurel32.net>
      016f5cf6
  6. 21 5月, 2010 3 次提交
  7. 17 5月, 2010 6 次提交
  8. 03 5月, 2010 9 次提交
    • J
      block: Release allocated options after bdrv_open · d748768c
      Jan Kiszka 提交于
      They aren't used afterwards nor supposed to be stored by a bdrv_create
      handler.
      Signed-off-by: NJan Kiszka <jan.kiszka@siemens.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      d748768c
    • 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
      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
      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
      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
  9. 23 4月, 2010 7 次提交