From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:56566) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TPC6O-0003lY-1L for qemu-devel@nongnu.org; Fri, 19 Oct 2012 08:55:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TPC6I-0002hi-4Y for qemu-devel@nongnu.org; Fri, 19 Oct 2012 08:54:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39124) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TPC6H-0002hd-SC for qemu-devel@nongnu.org; Fri, 19 Oct 2012 08:54:54 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9JCsrH8000602 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 19 Oct 2012 08:54:53 -0400 Message-ID: <50814D98.8050408@redhat.com> Date: Fri, 19 Oct 2012 14:54:48 +0200 From: Kevin Wolf MIME-Version: 1.0 References: <1350571770-9836-1-git-send-email-pbonzini@redhat.com> <1350571770-9836-11-git-send-email-pbonzini@redhat.com> In-Reply-To: <1350571770-9836-11-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3 10/16] qmp: add drive-mirror command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org Am 18.10.2012 16:49, schrieb Paolo Bonzini: > This adds the monitor commands that start the mirroring job. > > Signed-off-by: Paolo Bonzini > --- > v2->v3: bdrv_is_inserted pulled before dereference of bs->drv > > blockdev.c | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ > hmp-commands.hx | 21 ++++++++++ > hmp.c | 28 +++++++++++++ > hmp.h | 1 + > qapi-schema.json | 34 +++++++++++++++ > qmp-commands.hx | 42 +++++++++++++++++++ > 6 file modificati, 250 inserzioni(+) > > diff --git a/blockdev.c b/blockdev.c > index 1068960..53f5c54 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -1180,6 +1180,130 @@ void qmp_block_commit(const char *device, > drive_get_ref(drive_get_by_blockdev(bs)); > } > > +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 (!bdrv_is_inserted(bs)) { > + error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, 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_in_use(bs)) { > + error_set(errp, QERR_DEVICE_IN_USE, device); > + return; > + } > + > + flags = bs->open_flags | BDRV_O_RDWR; > + source = bs->backing_hd; > + if (!source && sync == MIRROR_SYNC_MODE_TOP) { > + sync = MIRROR_SYNC_MODE_FULL; > + } > + > + proto_drv = bdrv_find_protocol(target); > + if (!proto_drv) { > + error_set(errp, QERR_INVALID_BLOCK_FORMAT, format); This error message is still not fixed, and totally confusing, pointing at the wrong cause. No matter what changes to the error reporting we do later, we should add a better error string right now. Kevin