1. 28 6月, 2013 22 次提交
    • A
      Merge remote-tracking branch 'kwolf/for-anthony' into staging · 36125631
      Anthony Liguori 提交于
      # By Stefan Hajnoczi (11) and others
      # Via Kevin Wolf
      * kwolf/for-anthony:
        cmd646: fix build when DEBUG_IDE is enabled.
        block: change default of .has_zero_init to 0
        vpc: Implement .bdrv_has_zero_init
        vmdk: remove wrong calculation of relative path
        gluster: Return bdrv_has_zero_init = 0
        block/ssh: Set bdrv_has_zero_init according to the file type.
        block: Make BlockJobTypes const
        qemu-iotests: add 055 drive-backup test case
        qemu-iotests: extract wait_until_completed() into iotests.py
        blockdev: add Abort transaction
        blockdev: add DriveBackup transaction
        blockdev: allow BdrvActionOps->commit() to be NULL
        blockdev: rename BlkTransactionStates to singular
        block: add drive-backup QMP command
        blockdev: use bdrv_getlength() in qmp_drive_mirror()
        blockdev: drop redundant proto_drv check
        block: add basic backup support to block driver
        block: add bdrv_add_before_write_notifier()
        notify: add NotiferWithReturn so notifier list can abort
        raw-posix: Fix /dev/cdrom magic on OS X
      
      Message-id: 1372429509-29642-1-git-send-email-kwolf@redhat.com
      Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
      36125631
    • M
      cmd646: fix build when DEBUG_IDE is enabled. · 721da65c
      Mark Cave-Ayland 提交于
      Make sure we use the correct TARGET/PRI macros in the debug statements.
      Signed-off-by: NMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
      CC: Kevin Wolf <kwolf@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      721da65c
    • P
      block: change default of .has_zero_init to 0 · 3ac21627
      Peter Lieven 提交于
      .has_zero_init defaults to 1 for all formats and protocols.
      
      this is a dangerous default since this means that all
      new added drivers need to manually overwrite it to 0 if
      they do not ensure that a device is zero initialized
      after bdrv_create().
      
      if a driver needs to explicitly set this value to
      1 its easier to verify the correctness in the review process.
      
      during review of the existing drivers it turned out
      that ssh and gluster had a wrong default of 1.
      both protocols support host_devices as backend
      which are not by default zero initialized. this
      wrong assumption will lead to possible corruption
      if qemu-img convert is used to write to such a backend.
      
      vpc and vmdk also defaulted to 1 altough they support
      fixed respectively flat extends. this has to be addresses
      in separate patches. both formats as well as the mentioned
      ssh and gluster are turned to the default of 0 with this
      patch for safety.
      
      a similar problem with the wrong default existed for
      iscsi most likely because the driver developer did
      oversee the default value of 1.
      Signed-off-by: NPeter Lieven <pl@kamp.de>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      3ac21627
    • K
      vpc: Implement .bdrv_has_zero_init · 72c6cc94
      Kevin Wolf 提交于
      Depending on the subformat, has_zero_init on VHD must behave like raw
      and query the underlying storage (fixed) or like other sparse formats
      that can always return 1 (dynamic, differencing).
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      72c6cc94
    • F
      vmdk: remove wrong calculation of relative path · 8ed610a1
      Fam Zheng 提交于
      When creating image with backing file, the driver tries to calculate the
      relative path from created image file to backing file, but the path
      computation is incorrect. e.g.:
      
          $ qemu-img create -f vmdk -b vmdk-data-disk.vmdk vmdk-data-snapshot1
          Formatting 'vmdk-data-snapshot1', fmt=vmdk size=10737418240
          backing_file='vmdk-data-disk.vmdk' compat6=off zeroed_grain=off
      
          $ qemu-img info vmdk-data-snapshot1
          image: vmdk-data-snapshot1
          file format: vmdk
          virtual size: 10G (10737418240 bytes)
          disk size: 12K
      ->  backing file: disk.vmdk
      
      The common part in file names, "vmdk-data-", is incorrectly forgotten by
      relative_path(). As the VMDK specification has no restriction on
      parentNameHint to be relative path, we simply remove this by using the
      backing_file option.
      
      Cc: qemu-stable@nongnu.org
      Signed-off-by: NFam Zheng <famz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      8ed610a1
    • K
      gluster: Return bdrv_has_zero_init = 0 · 8ab6feec
      Kevin Wolf 提交于
      GlusterFS volumes can be backed by block devices, in which case
      bdrv_create() doesn't make sure that the image is zeroed out. It is
      currently not possibly to detect whether a given image is backed by a
      file or a block device, and incorrectly assuming that it is zeroed
      corrupts images during qemu-img convert, so let's err on the side of
      caution and always return 0.
      
      Cc: qemu-stable@nongnu.org
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      8ab6feec
    • R
      block/ssh: Set bdrv_has_zero_init according to the file type. · 0b3f21e6
      Richard W.M. Jones 提交于
      If the remote is a regular file, set it to true (ie. reads of
      uninitialized areas in a newly created file will return zeroes).
      If we can't prove that, return false (a safe default).
      
      Tested by adding a debugging print statement [not part of this commit]
      and creating a remote file and a remote block device:
      
        $ ./qemu-img create ssh://localhost/tmp/new 100M
        Formatting 'ssh://localhost/tmp/new', fmt=raw size=104857600
        filename ssh://localhost/tmp/new: has_zero_init = 1
        $ sudo lvcreate -L 1G -n tmp /dev/fedora
          Logical volume "tmp" created
        $ ./qemu-img create ssh://localhost/dev/fedora/tmp 1G
        Formatting 'ssh://localhost/dev/fedora/tmp', fmt=raw size=1073741824
        filename ssh://localhost/dev/fedora/tmp: has_zero_init = 0
      
      Cc: Kevin Wolf <kwolf@redhat.com>
      Cc: qemu-stable@nongnu.org
      Signed-off-by: NRichard W.M. Jones <rjones@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      0b3f21e6
    • K
      block: Make BlockJobTypes const · f59fee8d
      Kevin Wolf 提交于
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      f59fee8d
    • S
      qemu-iotests: add 055 drive-backup test case · e5ca8fdd
      Stefan Hajnoczi 提交于
      Testing drive-backup is similar to image streaming and drive mirroring.
      This test case is based on 041.
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      e5ca8fdd
    • S
      qemu-iotests: extract wait_until_completed() into iotests.py · 0dbe8a1b
      Stefan Hajnoczi 提交于
      The 'drive-mirror' tests often issue 'block-job-complete' and wait for
      the QMP completion event.  Other types of block jobs also want to wait
      for completion but they may not need to issue 'block-job-complete'.
      
      Extract wait_until_completed() from 041 and put it into iotests.py.
      Return the QMP event object so the caller can make additional
      assertions, if necessary.
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      0dbe8a1b
    • S
      blockdev: add Abort transaction · 78b18b78
      Stefan Hajnoczi 提交于
      The Abort action can be used to test QMP 'transaction' failure.  Add it
      as the last action to exercise the .abort() and .cleanup() code paths
      for all previous actions.
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      78b18b78
    • S
      blockdev: add DriveBackup transaction · 3037f364
      Stefan Hajnoczi 提交于
      This patch adds a transactional version of the drive-backup QMP command.
      It allows atomic snapshots of multiple drives along with automatic
      cleanup if there is a failure to start one of the backup jobs.
      
      Note that QMP events are emitted for block job completion/cancellation
      and the block job will be listed by query-block-jobs.
      
      @device: the name of the device whose writes should be mirrored.
      
      @target: the target of the new image. If the file exists, or if it
               is a device, the existing file/device will be used as the new
               destination.  If it does not exist, a new file will be created.
      
      @format: #optional the format of the new destination, default is to
               probe if @mode is 'existing', else the format of the source
      
      @mode: #optional whether and how QEMU should create a new image, default is
             'absolute-paths'.
      
      @speed: #optional the maximum speed, in bytes per second
      
      @on-source-error: #optional the action to take on an error on the source,
                        default 'report'.  'stop' and 'enospc' can only be used
                        if the block device supports io-status (see BlockInfo).
      
      @on-target-error: #optional the action to take on an error on the target,
                        default 'report' (no limitations, since this applies to
                        a different block device than @device).
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      3037f364
    • S
      blockdev: allow BdrvActionOps->commit() to be NULL · f9ea81e8
      Stefan Hajnoczi 提交于
      Some QMP 'transaction' types don't need to do anything on .commit().
      Make .commit() optional just like .abort().
      
      The "drive-backup" action will take advantage of this, it only needs to
      cancel the block job on .abort().  Other block job actions will probably
      follow the same pattern, so allow .commit() to be NULL.
      Suggested-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      f9ea81e8
    • S
      blockdev: rename BlkTransactionStates to singular · ba5d6ab6
      Stefan Hajnoczi 提交于
      The QMP 'transaction' command keeps a list of in-flight transactions.
      The transaction state structure is called BlkTransactionStates even
      though it only deals with a single transaction.  The only plural thing
      is the linked list of transaction states.
      
      I find it confusing to call the single structure "States".  This patch
      renames it to "State", just like BlockDriverState is singular.
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      ba5d6ab6
    • S
      block: add drive-backup QMP command · 99a9addf
      Stefan Hajnoczi 提交于
      @drive-backup
      
      Start a point-in-time copy of a block device to a new destination.  The
      status of ongoing drive-backup operations can be checked with
      query-block-jobs where the BlockJobInfo.type field has the value 'backup'.
      The operation can be stopped before it has completed using the
      block-job-cancel command.
      
      @device: the name of the device which should be copied.
      
      @target: the target of the new image. If the file exists, or if it
               is a device, the existing file/device will be used as the new
               destination.  If it does not exist, a new file will be created.
      
      @format: #optional the format of the new destination, default is to
               probe if @mode is 'existing', else the format of the source
      
      @mode: #optional whether and how QEMU should create a new image, default is
             'absolute-paths'.
      
      @speed: #optional the maximum speed, in bytes per second
      
      @on-source-error: #optional the action to take on an error on the source,
                        default 'report'.  'stop' and 'enospc' can only be used
                        if the block device supports io-status (see BlockInfo).
      
      @on-target-error: #optional the action to take on an error on the target,
                        default 'report' (no limitations, since this applies to
                        a different block device than @device).
      
      Note that @on-source-error and @on-target-error only affect background I/O.
      If an error occurs during a guest write request, the device's rerror/werror
      actions will be used.
      
      Returns: nothing on success
               If @device is not a valid block device, DeviceNotFound
      
      Since 1.6
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      99a9addf
    • S
      blockdev: use bdrv_getlength() in qmp_drive_mirror() · ac3c5d83
      Stefan Hajnoczi 提交于
      Use bdrv_getlength() for its byte units and error return instead of
      bdrv_get_geometry().
      Reported-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      ac3c5d83
    • S
      blockdev: drop redundant proto_drv check · cb78466e
      Stefan Hajnoczi 提交于
      It is not necessary to check that we can find a protocol block driver
      since we create or open the image file.  This produces the error that we
      need anyway.
      
      Besides, the QERR_INVALID_BLOCK_FORMAT is inappropriate since the
      protocol is incorrect rather than the format.
      
      Also drop an empty line between bdrv_open() and checking its return
      value.  This may be due to copy-pasting from earlier code that performed
      other operations before handling errors.
      Reported-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NWenchao Xia <xiawenc@linux.vnet.ibm.com>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      cb78466e
    • D
      block: add basic backup support to block driver · 98d2c6f2
      Dietmar Maurer 提交于
      backup_start() creates a block job that copies a point-in-time snapshot
      of a block device to a target block device.
      
      We call backup_do_cow() for each write during backup. That function
      reads the original data from the block device before it gets
      overwritten.  The data is then written to the target device.
      
      Currently backup cluster size is hardcoded to 65536 bytes.
      
      [I made a number of changes to Dietmar's original patch and folded them
      in to make code review easy.  Here is the full list:
      
       * Drop BackupDumpFunc interface in favor of a target block device
       * Detect zero clusters with buffer_is_zero() and use bdrv_co_write_zeroes()
       * Use 0 delay instead of 1us, like other block jobs
       * Unify creation/start functions into backup_start()
       * Simplify cleanup, free bitmap in backup_run() instead of cb
       * function
       * Use HBitmap to avoid duplicating bitmap code
       * Use bdrv_getlength() instead of accessing ->total_sectors
       * directly
       * Delete the backup.h header file, it is no longer necessary
       * Move ./backup.c to block/backup.c
       * Remove #ifdefed out code
       * Coding style and whitespace cleanups
       * Use bdrv_add_before_write_notifier() instead of blockjob-specific hooks
       * Keep our own in-flight CowRequest list instead of using block.c
         tracked requests.  This means a little code duplication but is much
         simpler than trying to share the tracked requests list and use the
         backup block size.
       * Add on_source_error and on_target_error error handling.
       * Use trace events instead of DPRINTF()
      
      -- stefanha]
      Signed-off-by: NDietmar Maurer <dietmar@proxmox.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      98d2c6f2
    • S
      block: add bdrv_add_before_write_notifier() · d616b224
      Stefan Hajnoczi 提交于
      The bdrv_add_before_write_notifier() function installs a callback that
      is invoked before a write request is processed.  This will be used to
      implement copy-on-write point-in-time snapshots where we need to copy
      out old data before overwriting it.
      
      Note that BdrvTrackedRequest is moved to block_int.h since it is passed
      to .notify() functions.
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      d616b224
    • S
      notify: add NotiferWithReturn so notifier list can abort · 5dae8e5f
      Stefan Hajnoczi 提交于
      notifier_list_notify() has no return value.  This is fine when we just
      want to invoke side-effects.
      
      Sometimes it's useful for notifiers to produce a return value.  This
      allows notifiers to "veto" an operation and will be used by the block
      layer before-write notifier.
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      5dae8e5f
    • K
      raw-posix: Fix /dev/cdrom magic on OS X · a5c5ea3f
      Kevin Wolf 提交于
      The raw-posix driver has code to provide a /dev/cdrom on OS X even
      though it doesn't really exist. However, since commit c66a6157 the real
      filename is dismissed after finding it, so opening /dev/cdrom fails.
      Put the filename back into the options QDict to make this work again.
      
      Cc: qemu-stable@nongnu.org
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      a5c5ea3f
    • P
      linux-user: Fix compilation failure · ec3f8c99
      Peter Maydell 提交于
      Fix compilation failures for linux-user targets following recent
      migration related commits bd2fa51f and 43487c67.
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Message-id: 1372362818-4740-1-git-send-email-peter.maydell@linaro.org
      Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
      ec3f8c99
  2. 27 6月, 2013 13 次提交
  3. 26 6月, 2013 5 次提交