summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2013-06-28 10:37:33 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2013-06-28 10:37:34 -0500
commit36125631e79d53ffb9365740f43f386e2171d116 (patch)
tree746f03c20af92d86fc3ad03c64dc136092c565d1 /include
parentec3f8c9913c1eeab78a02711be7c2a803dfb4d62 (diff)
parent721da65c6eba9c053d73744ecaa882b0f7cd634a (diff)
downloadqemu-36125631e79d53ffb9365740f43f386e2171d116.tar.gz
Merge remote-tracking branch 'kwolf/for-anthony' into staging
# 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: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'include')
-rw-r--r--include/block/block.h1
-rw-r--r--include/block/block_int.h42
-rw-r--r--include/qemu/notify.h29
3 files changed, 71 insertions, 1 deletions
diff --git a/include/block/block.h b/include/block/block.h
index 2307f67b0e..dd8eca1be1 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -272,6 +272,7 @@ void bdrv_drain_all(void);
int bdrv_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors);
int bdrv_co_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors);
+int bdrv_has_zero_init_1(BlockDriverState *bs);
int bdrv_has_zero_init(BlockDriverState *bs);
int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
int *pnum);
diff --git a/include/block/block_int.h b/include/block/block_int.h
index ba52247c1a..c6ac871e21 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -59,7 +59,16 @@
#define BLOCK_OPT_LAZY_REFCOUNTS "lazy_refcounts"
#define BLOCK_OPT_ADAPTER_TYPE "adapter_type"
-typedef struct BdrvTrackedRequest BdrvTrackedRequest;
+typedef struct BdrvTrackedRequest {
+ BlockDriverState *bs;
+ int64_t sector_num;
+ int nb_sectors;
+ bool is_write;
+ QLIST_ENTRY(BdrvTrackedRequest) list;
+ Coroutine *co; /* owner, used for deadlock detection */
+ CoQueue wait_queue; /* coroutines blocked on this request */
+} BdrvTrackedRequest;
+
typedef struct BlockIOLimit {
int64_t bps[3];
@@ -248,6 +257,9 @@ struct BlockDriverState {
NotifierList close_notifiers;
+ /* Callback before write request is processed */
+ NotifierWithReturnList before_write_notifiers;
+
/* number of in-flight copy-on-read requests */
unsigned int copy_on_read_in_flight;
@@ -299,6 +311,15 @@ void bdrv_set_io_limits(BlockDriverState *bs,
BlockIOLimit *io_limits);
/**
+ * bdrv_add_before_write_notifier:
+ *
+ * Register a callback that is invoked before write requests are processed but
+ * after any throttling or waiting for overlapping requests.
+ */
+void bdrv_add_before_write_notifier(BlockDriverState *bs,
+ NotifierWithReturn *notifier);
+
+/**
* bdrv_get_aio_context:
*
* Returns: the currently bound #AioContext
@@ -378,4 +399,23 @@ void mirror_start(BlockDriverState *bs, BlockDriverState *target,
BlockDriverCompletionFunc *cb,
void *opaque, Error **errp);
+/*
+ * backup_start:
+ * @bs: Block device to operate on.
+ * @target: Block device to write to.
+ * @speed: The maximum speed, in bytes per second, or 0 for unlimited.
+ * @on_source_error: The action to take upon error reading from the source.
+ * @on_target_error: The action to take upon error writing to the target.
+ * @cb: Completion function for the job.
+ * @opaque: Opaque pointer value passed to @cb.
+ *
+ * Start a backup operation on @bs. Clusters in @bs are written to @target
+ * until the job is cancelled or manually completed.
+ */
+void backup_start(BlockDriverState *bs, BlockDriverState *target,
+ int64_t speed, BlockdevOnError on_source_error,
+ BlockdevOnError on_target_error,
+ BlockDriverCompletionFunc *cb, void *opaque,
+ Error **errp);
+
#endif /* BLOCK_INT_H */
diff --git a/include/qemu/notify.h b/include/qemu/notify.h
index 4e2e7f0ec4..a3d73e4bc7 100644
--- a/include/qemu/notify.h
+++ b/include/qemu/notify.h
@@ -40,4 +40,33 @@ void notifier_remove(Notifier *notifier);
void notifier_list_notify(NotifierList *list, void *data);
+/* Same as Notifier but allows .notify() to return errors */
+typedef struct NotifierWithReturn NotifierWithReturn;
+
+struct NotifierWithReturn {
+ /**
+ * Return 0 on success (next notifier will be invoked), otherwise
+ * notifier_with_return_list_notify() will stop and return the value.
+ */
+ int (*notify)(NotifierWithReturn *notifier, void *data);
+ QLIST_ENTRY(NotifierWithReturn) node;
+};
+
+typedef struct NotifierWithReturnList {
+ QLIST_HEAD(, NotifierWithReturn) notifiers;
+} NotifierWithReturnList;
+
+#define NOTIFIER_WITH_RETURN_LIST_INITIALIZER(head) \
+ { QLIST_HEAD_INITIALIZER((head).notifiers) }
+
+void notifier_with_return_list_init(NotifierWithReturnList *list);
+
+void notifier_with_return_list_add(NotifierWithReturnList *list,
+ NotifierWithReturn *notifier);
+
+void notifier_with_return_remove(NotifierWithReturn *notifier);
+
+int notifier_with_return_list_notify(NotifierWithReturnList *list,
+ void *data);
+
#endif