Am 24.07.2012 13:04, schrieb Paolo Bonzini: > This adds the monitor commands that start the mirroring job. > > Signed-off-by: Paolo Bonzini <pbonz...@redhat.com> > --- > blockdev.c | 133 > ++++++++++++++++++++++++++++++++++++++++++++++++++++-- > hmp-commands.hx | 21 +++++++++ > hmp.c | 28 ++++++++++++ > hmp.h | 1 + > qapi-schema.json | 35 ++++++++++++++ > qmp-commands.hx | 42 +++++++++++++++++ > trace-events | 2 +- > 7 files changed, 258 insertions(+), 4 deletions(-) > > diff --git a/blockdev.c b/blockdev.c > index 192a9db..4b4574a 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -21,6 +21,8 @@ > #include "trace.h" > #include "arch_init.h" > > +static void block_job_cb(void *opaque, int ret); > + > static QTAILQ_HEAD(drivelist, DriveInfo) drives = > QTAILQ_HEAD_INITIALIZER(drives); > > static const char *const if_name[IF_COUNT] = { > @@ -825,6 +827,131 @@ exit: > return; > } > > +void qmp_drive_mirror(const char *device, const char *target, > + bool has_format, const char *format, > + enum MirrorSyncMode sync, > + bool has_mode, enum NewImageMode mode, > + bool has_speed, int64_t speed, Error **errp) > +{ > + BlockDriverInfo bdi; > + BlockDriverState *bs; > + BlockDriverState *source, *target_bs; > + BlockDriver *proto_drv; > + BlockDriver *drv = NULL; > + Error *local_err = NULL; > + int flags; > + uint64_t size; > + int ret; > + > + if (!has_speed) { > + speed = 0; > + } > + if (!has_mode) { > + mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS; > + } > + > + bs = bdrv_find(device); > + if (!bs) { > + error_set(errp, QERR_DEVICE_NOT_FOUND, device); > + return; > + } > + > + if (!has_format) { > + format = mode == NEW_IMAGE_MODE_EXISTING ? NULL : > bs->drv->format_name; > + } > + if (format) { > + drv = bdrv_find_format(format); > + if (!drv) { > + error_set(errp, QERR_INVALID_BLOCK_FORMAT, format); > + return; > + } > + } > + > + if (!bdrv_is_inserted(bs)) { > + error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device); > + return; > + } > + > + if (bdrv_in_use(bs)) { > + error_set(errp, QERR_DEVICE_IN_USE, device); > + return; > + } > + > + flags = bs->open_flags | BDRV_O_RDWR;
Do we take care to make the image read-only again after completion? Kevin