mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-12-24 00:18:36 -07:00
Block layer patches
-----BEGIN PGP SIGNATURE----- iQEcBAABAgAGBQJZZPdkAAoJEPQH2wBh1c9A+9oIAInvmlySO/o/pXFI/CoHbZkU YxRDm2JNCpscmcTaS7T2KvFyypUTG3EW7olzK5Qb/aMHM78EEQHeciHbJ7Lpd5id sLnxg0mSMoTVaAG7s7aXRFc58gMfZPD1ngbaIkbpaAkDzGFTgKyWwemi/Ic/We1z 2ULK6YSVbinwP2b2T6v3N4TABxKKnvBtPo4CdQy87BV1mJF+Mv7F9TyVIsaH0B2I DIvLOitmbeahh0rwrj2ffWc2TAUlje8h0AN7/4YW/dA6HWT4tcB6ykzmN0Jo7Oe+ /2JUd/VjDpYyP4XTpiu4+TTWOKXs14vvefZeSNy7rLF/oRcB4L0CTXzTJFv3Epk= =o7Us -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2017-07-11' into staging Block layer patches # gpg: Signature made Tue 11 Jul 2017 17:05:56 BST # gpg: using RSA key 0xF407DB0061D5CF40 # gpg: Good signature from "Max Reitz <mreitz@redhat.com>" # Primary key fingerprint: 91BE B60A 30DB 3E88 57D1 1829 F407 DB00 61D5 CF40 * remotes/maxreitz/tags/pull-block-2017-07-11: (85 commits) iotests: Add preallocated growth test for qcow2 iotests: Add preallocated resize test for raw block/qcow2: falloc/full preallocating growth block/qcow2: Rename "fail_block" to just "fail" block/qcow2: Add qcow2_refcount_area() block/qcow2: Metadata preallocation for truncate block/qcow2: Lock s->lock in preallocate() block/qcow2: Generalize preallocate() block/file-posix: Preallocation for truncate block/file-posix: Generalize raw_regular_truncate block/file-posix: Extract raw_regular_truncate() block/file-posix: Small fixes in raw_create() qemu-img: Expose PreallocMode for resizing block: Add PreallocMode to blk_truncate() block: Add PreallocMode to bdrv_truncate() block: Add PreallocMode to BD.bdrv_truncate() iotests: add test 178 for qemu-img measure qemu-iotests: support per-format golden output files qemu-img: add measure subcommand qcow2: add bdrv_measure() support ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
76fba746ea
123 changed files with 7560 additions and 1651 deletions
|
|
@ -302,10 +302,13 @@ BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs,
|
|||
const char *backing_file);
|
||||
int bdrv_get_backing_file_depth(BlockDriverState *bs);
|
||||
void bdrv_refresh_filename(BlockDriverState *bs);
|
||||
int bdrv_truncate(BdrvChild *child, int64_t offset, Error **errp);
|
||||
int bdrv_truncate(BdrvChild *child, int64_t offset, PreallocMode prealloc,
|
||||
Error **errp);
|
||||
int64_t bdrv_nb_sectors(BlockDriverState *bs);
|
||||
int64_t bdrv_getlength(BlockDriverState *bs);
|
||||
int64_t bdrv_get_allocated_file_size(BlockDriverState *bs);
|
||||
BlockMeasureInfo *bdrv_measure(BlockDriver *drv, QemuOpts *opts,
|
||||
BlockDriverState *in_bs, Error **errp);
|
||||
void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr);
|
||||
void bdrv_refresh_limits(BlockDriverState *bs, Error **errp);
|
||||
int bdrv_commit(BlockDriverState *bs);
|
||||
|
|
@ -464,9 +467,6 @@ BlockDriverState *bdrv_next(BdrvNextIterator *it);
|
|||
|
||||
BlockDriverState *bdrv_next_monitor_owned(BlockDriverState *bs);
|
||||
bool bdrv_is_encrypted(BlockDriverState *bs);
|
||||
bool bdrv_key_required(BlockDriverState *bs);
|
||||
int bdrv_set_key(BlockDriverState *bs, const char *key);
|
||||
void bdrv_add_key(BlockDriverState *bs, const char *key, Error **errp);
|
||||
void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
|
||||
void *opaque);
|
||||
const char *bdrv_get_node_name(const BlockDriverState *bs);
|
||||
|
|
@ -620,4 +620,7 @@ void bdrv_add_child(BlockDriverState *parent, BlockDriverState *child,
|
|||
Error **errp);
|
||||
void bdrv_del_child(BlockDriverState *parent, BdrvChild *child, Error **errp);
|
||||
|
||||
bool bdrv_can_store_new_dirty_bitmap(BlockDriverState *bs, const char *name,
|
||||
uint32_t granularity, Error **errp);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -37,11 +37,11 @@
|
|||
#include "qemu/main-loop.h"
|
||||
#include "qemu/throttle.h"
|
||||
|
||||
#define BLOCK_FLAG_ENCRYPT 1
|
||||
#define BLOCK_FLAG_LAZY_REFCOUNTS 8
|
||||
|
||||
#define BLOCK_OPT_SIZE "size"
|
||||
#define BLOCK_OPT_ENCRYPT "encryption"
|
||||
#define BLOCK_OPT_ENCRYPT_FORMAT "encrypt.format"
|
||||
#define BLOCK_OPT_COMPAT6 "compat6"
|
||||
#define BLOCK_OPT_HWVERSION "hwversion"
|
||||
#define BLOCK_OPT_BACKING_FILE "backing_file"
|
||||
|
|
@ -204,11 +204,14 @@ struct BlockDriver {
|
|||
int coroutine_fn (*bdrv_co_flush_to_os)(BlockDriverState *bs);
|
||||
|
||||
const char *protocol_name;
|
||||
int (*bdrv_truncate)(BlockDriverState *bs, int64_t offset, Error **errp);
|
||||
int (*bdrv_truncate)(BlockDriverState *bs, int64_t offset,
|
||||
PreallocMode prealloc, Error **errp);
|
||||
|
||||
int64_t (*bdrv_getlength)(BlockDriverState *bs);
|
||||
bool has_variable_length;
|
||||
int64_t (*bdrv_get_allocated_file_size)(BlockDriverState *bs);
|
||||
BlockMeasureInfo *(*bdrv_measure)(QemuOpts *opts, BlockDriverState *in_bs,
|
||||
Error **errp);
|
||||
|
||||
int coroutine_fn (*bdrv_co_pwritev_compressed)(BlockDriverState *bs,
|
||||
uint64_t offset, uint64_t bytes, QEMUIOVector *qiov);
|
||||
|
|
@ -381,6 +384,20 @@ struct BlockDriver {
|
|||
uint64_t parent_perm, uint64_t parent_shared,
|
||||
uint64_t *nperm, uint64_t *nshared);
|
||||
|
||||
/**
|
||||
* Bitmaps should be marked as 'IN_USE' in the image on reopening image
|
||||
* as rw. This handler should realize it. It also should unset readonly
|
||||
* field of BlockDirtyBitmap's in case of success.
|
||||
*/
|
||||
int (*bdrv_reopen_bitmaps_rw)(BlockDriverState *bs, Error **errp);
|
||||
bool (*bdrv_can_store_new_dirty_bitmap)(BlockDriverState *bs,
|
||||
const char *name,
|
||||
uint32_t granularity,
|
||||
Error **errp);
|
||||
void (*bdrv_remove_persistent_dirty_bitmap)(BlockDriverState *bs,
|
||||
const char *name,
|
||||
Error **errp);
|
||||
|
||||
QLIST_ENTRY(BlockDriver) list;
|
||||
};
|
||||
|
||||
|
|
@ -529,7 +546,6 @@ struct BlockDriverState {
|
|||
int open_flags; /* flags used to open the file, re-used for re-open */
|
||||
bool read_only; /* if true, the media is read only */
|
||||
bool encrypted; /* if true, the media is encrypted */
|
||||
bool valid_key; /* if true, a valid encryption key has been set */
|
||||
bool sg; /* if true, the device is a /dev/sg* */
|
||||
bool probed; /* if true, format was probed rather than specified */
|
||||
bool force_share; /* if true, always allow all shared permissions */
|
||||
|
|
|
|||
|
|
@ -25,11 +25,15 @@ BdrvDirtyBitmap *bdrv_find_dirty_bitmap(BlockDriverState *bs,
|
|||
void bdrv_dirty_bitmap_make_anon(BdrvDirtyBitmap *bitmap);
|
||||
void bdrv_release_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap);
|
||||
void bdrv_release_named_dirty_bitmaps(BlockDriverState *bs);
|
||||
void bdrv_release_persistent_dirty_bitmaps(BlockDriverState *bs);
|
||||
void bdrv_remove_persistent_dirty_bitmap(BlockDriverState *bs,
|
||||
const char *name,
|
||||
Error **errp);
|
||||
void bdrv_disable_dirty_bitmap(BdrvDirtyBitmap *bitmap);
|
||||
void bdrv_enable_dirty_bitmap(BdrvDirtyBitmap *bitmap);
|
||||
BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs);
|
||||
uint32_t bdrv_get_default_bitmap_granularity(BlockDriverState *bs);
|
||||
uint32_t bdrv_dirty_bitmap_granularity(BdrvDirtyBitmap *bitmap);
|
||||
uint32_t bdrv_dirty_bitmap_granularity(const BdrvDirtyBitmap *bitmap);
|
||||
uint32_t bdrv_dirty_bitmap_meta_granularity(BdrvDirtyBitmap *bitmap);
|
||||
bool bdrv_dirty_bitmap_enabled(BdrvDirtyBitmap *bitmap);
|
||||
bool bdrv_dirty_bitmap_frozen(BdrvDirtyBitmap *bitmap);
|
||||
|
|
@ -66,8 +70,16 @@ void bdrv_dirty_bitmap_deserialize_part(BdrvDirtyBitmap *bitmap,
|
|||
void bdrv_dirty_bitmap_deserialize_zeroes(BdrvDirtyBitmap *bitmap,
|
||||
uint64_t start, uint64_t count,
|
||||
bool finish);
|
||||
void bdrv_dirty_bitmap_deserialize_ones(BdrvDirtyBitmap *bitmap,
|
||||
uint64_t start, uint64_t count,
|
||||
bool finish);
|
||||
void bdrv_dirty_bitmap_deserialize_finish(BdrvDirtyBitmap *bitmap);
|
||||
|
||||
void bdrv_dirty_bitmap_set_readonly(BdrvDirtyBitmap *bitmap, bool value);
|
||||
void bdrv_dirty_bitmap_set_autoload(BdrvDirtyBitmap *bitmap, bool autoload);
|
||||
void bdrv_dirty_bitmap_set_persistance(BdrvDirtyBitmap *bitmap,
|
||||
bool persistent);
|
||||
|
||||
/* Functions that require manual locking. */
|
||||
void bdrv_dirty_bitmap_lock(BdrvDirtyBitmap *bitmap);
|
||||
void bdrv_dirty_bitmap_unlock(BdrvDirtyBitmap *bitmap);
|
||||
|
|
@ -82,5 +94,13 @@ void bdrv_set_dirty_iter(BdrvDirtyBitmapIter *hbi, int64_t sector_num);
|
|||
int64_t bdrv_get_dirty_count(BdrvDirtyBitmap *bitmap);
|
||||
int64_t bdrv_get_meta_dirty_count(BdrvDirtyBitmap *bitmap);
|
||||
void bdrv_dirty_bitmap_truncate(BlockDriverState *bs);
|
||||
bool bdrv_dirty_bitmap_readonly(const BdrvDirtyBitmap *bitmap);
|
||||
bool bdrv_has_readonly_bitmaps(BlockDriverState *bs);
|
||||
bool bdrv_dirty_bitmap_get_autoload(const BdrvDirtyBitmap *bitmap);
|
||||
bool bdrv_dirty_bitmap_get_persistance(BdrvDirtyBitmap *bitmap);
|
||||
bool bdrv_has_changed_persistent_bitmaps(BlockDriverState *bs);
|
||||
BdrvDirtyBitmap *bdrv_dirty_bitmap_next(BlockDriverState *bs,
|
||||
BdrvDirtyBitmap *bitmap);
|
||||
char *bdrv_dirty_bitmap_sha256(const BdrvDirtyBitmap *bitmap, Error **errp);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ typedef enum {
|
|||
/**
|
||||
* qcrypto_block_open:
|
||||
* @options: the encryption options
|
||||
* @optprefix: name prefix for options
|
||||
* @readfunc: callback for reading data from the volume
|
||||
* @opaque: data to pass to @readfunc
|
||||
* @flags: bitmask of QCryptoBlockOpenFlags values
|
||||
|
|
@ -102,6 +103,7 @@ typedef enum {
|
|||
* Returns: a block encryption format, or NULL on error
|
||||
*/
|
||||
QCryptoBlock *qcrypto_block_open(QCryptoBlockOpenOptions *options,
|
||||
const char *optprefix,
|
||||
QCryptoBlockReadFunc readfunc,
|
||||
void *opaque,
|
||||
unsigned int flags,
|
||||
|
|
@ -109,7 +111,8 @@ QCryptoBlock *qcrypto_block_open(QCryptoBlockOpenOptions *options,
|
|||
|
||||
/**
|
||||
* qcrypto_block_create:
|
||||
* @format: the encryption format
|
||||
* @options: the encryption options
|
||||
* @optprefix: name prefix for options
|
||||
* @initfunc: callback for initializing volume header
|
||||
* @writefunc: callback for writing data to the volume header
|
||||
* @opaque: data to pass to @initfunc and @writefunc
|
||||
|
|
@ -133,6 +136,7 @@ QCryptoBlock *qcrypto_block_open(QCryptoBlockOpenOptions *options,
|
|||
* Returns: a block encryption format, or NULL on error
|
||||
*/
|
||||
QCryptoBlock *qcrypto_block_create(QCryptoBlockCreateOptions *options,
|
||||
const char *optprefix,
|
||||
QCryptoBlockInitFunc initfunc,
|
||||
QCryptoBlockWriteFunc writefunc,
|
||||
void *opaque,
|
||||
|
|
|
|||
|
|
@ -23,13 +23,6 @@ void monitor_cleanup(void);
|
|||
int monitor_suspend(Monitor *mon);
|
||||
void monitor_resume(Monitor *mon);
|
||||
|
||||
int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs,
|
||||
BlockCompletionFunc *completion_cb,
|
||||
void *opaque);
|
||||
int monitor_read_block_device_key(Monitor *mon, const char *device,
|
||||
BlockCompletionFunc *completion_cb,
|
||||
void *opaque);
|
||||
|
||||
int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp);
|
||||
int monitor_fd_param(Monitor *mon, const char *fdname, Error **errp);
|
||||
|
||||
|
|
|
|||
|
|
@ -125,7 +125,6 @@
|
|||
typedef enum ErrorClass {
|
||||
ERROR_CLASS_GENERIC_ERROR = QAPI_ERROR_CLASS_GENERICERROR,
|
||||
ERROR_CLASS_COMMAND_NOT_FOUND = QAPI_ERROR_CLASS_COMMANDNOTFOUND,
|
||||
ERROR_CLASS_DEVICE_ENCRYPTED = QAPI_ERROR_CLASS_DEVICEENCRYPTED,
|
||||
ERROR_CLASS_DEVICE_NOT_ACTIVE = QAPI_ERROR_CLASS_DEVICENOTACTIVE,
|
||||
ERROR_CLASS_DEVICE_NOT_FOUND = QAPI_ERROR_CLASS_DEVICENOTFOUND,
|
||||
ERROR_CLASS_KVM_MISSING_CAP = QAPI_ERROR_CLASS_KVMMISSINGCAP,
|
||||
|
|
|
|||
|
|
@ -228,6 +228,21 @@ void hbitmap_deserialize_part(HBitmap *hb, uint8_t *buf,
|
|||
void hbitmap_deserialize_zeroes(HBitmap *hb, uint64_t start, uint64_t count,
|
||||
bool finish);
|
||||
|
||||
/**
|
||||
* hbitmap_deserialize_ones
|
||||
* @hb: HBitmap to operate on.
|
||||
* @start: First bit to restore.
|
||||
* @count: Number of bits to restore.
|
||||
* @finish: Whether to call hbitmap_deserialize_finish automatically.
|
||||
*
|
||||
* Fills the bitmap with ones.
|
||||
*
|
||||
* If @finish is false, caller must call hbitmap_serialize_finish before using
|
||||
* the bitmap.
|
||||
*/
|
||||
void hbitmap_deserialize_ones(HBitmap *hb, uint64_t start, uint64_t count,
|
||||
bool finish);
|
||||
|
||||
/**
|
||||
* hbitmap_deserialize_finish
|
||||
* @hb: HBitmap to operate on.
|
||||
|
|
@ -237,6 +252,14 @@ void hbitmap_deserialize_zeroes(HBitmap *hb, uint64_t start, uint64_t count,
|
|||
*/
|
||||
void hbitmap_deserialize_finish(HBitmap *hb);
|
||||
|
||||
/**
|
||||
* hbitmap_sha256:
|
||||
* @bitmap: HBitmap to operate on.
|
||||
*
|
||||
* Returns SHA256 hash of the last level.
|
||||
*/
|
||||
char *hbitmap_sha256(const HBitmap *bitmap, Error **errp);
|
||||
|
||||
/**
|
||||
* hbitmap_free:
|
||||
* @hb: HBitmap to operate on.
|
||||
|
|
@ -256,10 +279,9 @@ void hbitmap_free(HBitmap *hb);
|
|||
* the lowest-numbered bit that is set in @hb, starting at @first.
|
||||
*
|
||||
* Concurrent setting of bits is acceptable, and will at worst cause the
|
||||
* iteration to miss some of those bits. Resetting bits before the current
|
||||
* position of the iterator is also okay. However, concurrent resetting of
|
||||
* bits can lead to unexpected behavior if the iterator has not yet reached
|
||||
* those bits.
|
||||
* iteration to miss some of those bits.
|
||||
*
|
||||
* The concurrent resetting of bits is OK.
|
||||
*/
|
||||
void hbitmap_iter_init(HBitmapIter *hbi, const HBitmap *hb, uint64_t first);
|
||||
|
||||
|
|
@ -298,24 +320,7 @@ void hbitmap_free_meta(HBitmap *hb);
|
|||
* Return the next bit that is set in @hbi's associated HBitmap,
|
||||
* or -1 if all remaining bits are zero.
|
||||
*/
|
||||
static inline int64_t hbitmap_iter_next(HBitmapIter *hbi)
|
||||
{
|
||||
unsigned long cur = hbi->cur[HBITMAP_LEVELS - 1];
|
||||
int64_t item;
|
||||
|
||||
if (cur == 0) {
|
||||
cur = hbitmap_iter_skip_words(hbi);
|
||||
if (cur == 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* The next call will resume work from the next bit. */
|
||||
hbi->cur[HBITMAP_LEVELS - 1] = cur & (cur - 1);
|
||||
item = ((uint64_t)hbi->pos << BITS_PER_LEVEL) + ctzl(cur);
|
||||
|
||||
return item << hbi->granularity;
|
||||
}
|
||||
int64_t hbitmap_iter_next(HBitmapIter *hbi);
|
||||
|
||||
/**
|
||||
* hbitmap_iter_next_word:
|
||||
|
|
|
|||
|
|
@ -457,8 +457,6 @@ void qemu_set_tty_echo(int fd, bool echo);
|
|||
void os_mem_prealloc(int fd, char *area, size_t sz, int smp_cpus,
|
||||
Error **errp);
|
||||
|
||||
int qemu_read_password(char *buf, int buf_size);
|
||||
|
||||
/**
|
||||
* qemu_get_pid_name:
|
||||
* @pid: pid of a process
|
||||
|
|
|
|||
|
|
@ -223,7 +223,8 @@ int coroutine_fn blk_co_pwrite_zeroes(BlockBackend *blk, int64_t offset,
|
|||
int bytes, BdrvRequestFlags flags);
|
||||
int blk_pwrite_compressed(BlockBackend *blk, int64_t offset, const void *buf,
|
||||
int bytes);
|
||||
int blk_truncate(BlockBackend *blk, int64_t offset, Error **errp);
|
||||
int blk_truncate(BlockBackend *blk, int64_t offset, PreallocMode prealloc,
|
||||
Error **errp);
|
||||
int blk_pdiscard(BlockBackend *blk, int64_t offset, int bytes);
|
||||
int blk_save_vmstate(BlockBackend *blk, const uint8_t *buf,
|
||||
int64_t pos, int size);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue