Index: new/blockdev.c
===================================================================
---- new.orig/blockdev.c 2013-12-05 13:39:59.000000000 +0100
-+++ new/blockdev.c 2013-12-06 06:59:11.000000000 +0100
-@@ -45,6 +45,7 @@
+--- new.orig/blockdev.c 2014-07-16 11:10:45.000000000 +0200
++++ new/blockdev.c 2014-07-16 11:25:41.000000000 +0200
+@@ -44,6 +44,7 @@
#include "qmp-commands.h"
#include "trace.h"
#include "sysemu/arch_init.h"
static QTAILQ_HEAD(drivelist, DriveInfo) drives = QTAILQ_HEAD_INITIALIZER(drives);
-@@ -1438,6 +1439,425 @@
+@@ -1546,7 +1547,6 @@
}
}
+-
+ static void eject_device(BlockDriverState *bs, int force, Error **errp)
+ {
+ if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_EJECT, errp)) {
+@@ -1871,6 +1871,437 @@
+ bdrv_put_ref_bh_schedule(bs);
+ }
+
+/* PVE backup related function */
+
+static struct PVEBackupState {
+
+static void pvebackup_cleanup(void)
+{
++ backup_state.end_time = time(NULL);
++
+ if (backup_state.vmaw) {
-+ backup_state.end_time = time(NULL);
+ Error *local_err = NULL;
+ vma_writer_close(backup_state.vmaw, &local_err);
+ error_propagate(&backup_state.error, local_err);
+ assert(backup_state.vmaw);
+
+ di->completed = true;
++
++ if (ret < 0 && !backup_state.error) {
++ error_setg(&backup_state.error, "job failed with err %d - %s",
++ ret, strerror(-ret));
++ }
++
++ BlockDriverState *bs = di->bs;
++
+ di->bs = NULL;
+
+ vma_writer_close_stream(backup_state.vmaw, di->dev_id);
+
++ block_job_cb(bs, ret);
++
+ if (!backup_state.cancel) {
+ pvebackup_run_next_job();
+ }
+ qemu_coroutine_enter(co, NULL);
+
+ while (backup_state.vmaw) {
-+ qemu_aio_wait();
++ /* vma writer use main aio context */
++ aio_poll(qemu_get_aio_context(), true);
+ }
+}
+
+ while (l) {
+ PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
+ l = g_list_next(l);
-+ if (bdrv_in_use(di->bs)) {
-+ error_set(errp, QERR_DEVICE_IN_USE, bdrv_get_device_name(di->bs));
++ if (bdrv_op_is_blocked(di->bs, BLOCK_OP_TYPE_BACKUP_SOURCE, errp)) {
+ goto err;
+ }
+
+
+ vmaw = vma_writer_create(backup_file, uuid, &local_err);
+ if (!vmaw) {
-+ if (error_is_set(&local_err)) {
++ if (local_err) {
+ error_propagate(errp, local_err);
+ }
+ goto err;
+
+ return info;
+}
-
- static void eject_device(BlockDriverState *bs, int force, Error **errp)
- {
++
+ void qmp_block_stream(const char *device,
+ bool has_base, const char *base,
+ bool has_backing_file, const char *backing_file,
Index: new/hmp-commands.hx
===================================================================
---- new.orig/hmp-commands.hx 2013-12-05 13:39:59.000000000 +0100
-+++ new/hmp-commands.hx 2013-12-05 13:40:07.000000000 +0100
-@@ -83,6 +83,35 @@
+--- new.orig/hmp-commands.hx 2014-07-16 10:22:25.000000000 +0200
++++ new/hmp-commands.hx 2014-07-16 11:17:01.000000000 +0200
+@@ -88,6 +88,35 @@
Copy data from a backing file into a block device.
ETEXI
{
.name = "block_job_set_speed",
.args_type = "device:B,speed:o",
-@@ -1692,6 +1721,8 @@
+@@ -1764,6 +1793,8 @@
show CPU statistics
@item info usernet
show user network stack connection states
@item info migrate_capabilities
Index: new/hmp.c
===================================================================
---- new.orig/hmp.c 2013-12-05 13:39:59.000000000 +0100
-+++ new/hmp.c 2013-12-06 07:25:28.000000000 +0100
-@@ -133,6 +133,44 @@
+--- new.orig/hmp.c 2014-07-16 10:22:25.000000000 +0200
++++ new/hmp.c 2014-07-16 11:17:01.000000000 +0200
+@@ -137,6 +137,44 @@
qapi_free_MouseInfoList(mice_list);
}
void hmp_info_migrate(Monitor *mon, const QDict *qdict)
{
MigrationInfo *info;
-@@ -1193,6 +1231,29 @@
+@@ -1210,6 +1248,29 @@
hmp_handle_error(mon, &error);
}
{
Index: new/hmp.h
===================================================================
---- new.orig/hmp.h 2013-12-05 13:39:59.000000000 +0100
-+++ new/hmp.h 2013-12-05 13:40:07.000000000 +0100
-@@ -28,6 +28,7 @@
+--- new.orig/hmp.h 2014-07-16 10:22:25.000000000 +0200
++++ new/hmp.h 2014-07-16 11:17:01.000000000 +0200
+@@ -29,6 +29,7 @@
void hmp_info_migrate(Monitor *mon, const QDict *qdict);
void hmp_info_migrate_capabilities(Monitor *mon, const QDict *qdict);
void hmp_info_migrate_cache_size(Monitor *mon, const QDict *qdict);
void hmp_info_cpus(Monitor *mon, const QDict *qdict);
void hmp_info_block(Monitor *mon, const QDict *qdict);
void hmp_info_blockstats(Monitor *mon, const QDict *qdict);
-@@ -69,6 +70,8 @@
+@@ -70,6 +71,8 @@
void hmp_change(Monitor *mon, const QDict *qdict);
void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict);
void hmp_block_stream(Monitor *mon, const QDict *qdict);
void hmp_block_job_pause(Monitor *mon, const QDict *qdict);
Index: new/monitor.c
===================================================================
---- new.orig/monitor.c 2013-12-05 13:39:59.000000000 +0100
-+++ new/monitor.c 2013-12-05 13:40:07.000000000 +0100
-@@ -2880,6 +2880,13 @@
+--- new.orig/monitor.c 2014-07-16 10:22:25.000000000 +0200
++++ new/monitor.c 2014-07-16 11:17:01.000000000 +0200
+@@ -2848,6 +2848,13 @@
},
#endif
{
.params = "",
Index: new/qapi-schema.json
===================================================================
---- new.orig/qapi-schema.json 2013-12-05 13:39:59.000000000 +0100
-+++ new/qapi-schema.json 2013-12-06 06:59:11.000000000 +0100
-@@ -547,6 +547,95 @@
+--- new.orig/qapi-schema.json 2014-07-16 10:22:25.000000000 +0200
++++ new/qapi-schema.json 2014-07-16 11:17:01.000000000 +0200
+@@ -349,6 +349,95 @@
##
{ 'command': 'query-events', 'returns': ['EventInfo'] }
#
Index: new/qmp-commands.hx
===================================================================
---- new.orig/qmp-commands.hx 2013-12-05 13:39:59.000000000 +0100
-+++ new/qmp-commands.hx 2013-12-05 13:40:07.000000000 +0100
-@@ -966,6 +966,24 @@
+--- new.orig/qmp-commands.hx 2014-07-16 10:22:25.000000000 +0200
++++ new/qmp-commands.hx 2014-07-16 11:17:01.000000000 +0200
+@@ -1098,6 +1098,24 @@
EQMP
{