From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:43088) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TC9GZ-0006h1-AK for qemu-devel@nongnu.org; Thu, 13 Sep 2012 09:15:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TC9GS-0008Cq-2S for qemu-devel@nongnu.org; Thu, 13 Sep 2012 09:15:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:27162) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TC9GR-0008Ck-PV for qemu-devel@nongnu.org; Thu, 13 Sep 2012 09:15:28 -0400 Message-ID: <5051DC6A.6040008@redhat.com> Date: Thu, 13 Sep 2012 15:15:22 +0200 From: Kevin Wolf MIME-Version: 1.0 References: <1343127865-16608-1-git-send-email-pbonzini@redhat.com> <1343127865-16608-29-git-send-email-pbonzini@redhat.com> In-Reply-To: <1343127865-16608-29-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 28/47] qmp: add drive-mirror command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: jcody@redhat.com, eblake@redhat.com, qemu-devel@nongnu.org, stefanha@linux.vnet.ibm.com Am 24.07.2012 13:04, schrieb Paolo Bonzini: > This adds the monitor commands that start the mirroring job. > > Signed-off-by: Paolo Bonzini > --- > 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