From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:45529) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwYNi-0004pi-3C for qemu-devel@nongnu.org; Wed, 01 Aug 2012 08:50:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SwYNc-0006Fz-AA for qemu-devel@nongnu.org; Wed, 01 Aug 2012 08:50:30 -0400 Received: from e5.ny.us.ibm.com ([32.97.182.145]:57064) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwYNc-0006FZ-6M for qemu-devel@nongnu.org; Wed, 01 Aug 2012 08:50:24 -0400 Received: from /spool/local by e5.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 1 Aug 2012 08:50:22 -0400 Received: from d01relay03.pok.ibm.com (d01relay03.pok.ibm.com [9.56.227.235]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id ECD2C6E803F for ; Wed, 1 Aug 2012 08:49:37 -0400 (EDT) Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay03.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q71CnZMi248646 for ; Wed, 1 Aug 2012 08:49:35 -0400 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q71CnVfW019490 for ; Wed, 1 Aug 2012 08:49:31 -0400 From: Anthony Liguori In-Reply-To: <877gtivlav.fsf@blackfin.pond.sub.org> References: <1343424728-22461-1-git-send-email-lcapitulino@redhat.com> <1343424728-22461-13-git-send-email-lcapitulino@redhat.com> <877gtivlav.fsf@blackfin.pond.sub.org> Date: Wed, 01 Aug 2012 07:49:27 -0500 Message-ID: <87mx2ezsiw.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH 12/27] hmp: hmp_change(): don't use error_get_field() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , Luiz Capitulino Cc: kwolf@redhat.com, pbonzini@redhat.com, eblake@redhat.com, qemu-devel@nongnu.org Markus Armbruster writes: > Luiz Capitulino writes: > >> Use the 'device' passed by the user and call qmp_query_block() to >> get the 'filename' info. >> >> error_get_field() is going to be dropped by a future commit. >> >> Signed-off-by: Luiz Capitulino >> --- >> hmp.c | 37 ++++++++++++++++++++++++++++--------- >> 1 file changed, 28 insertions(+), 9 deletions(-) >> >> diff --git a/hmp.c b/hmp.c >> index a906f8a..435c9cd 100644 >> --- a/hmp.c >> +++ b/hmp.c >> @@ -783,17 +783,35 @@ static void hmp_change_read_arg(Monitor *mon, const char *password, >> static void cb_hmp_change_bdrv_pwd(Monitor *mon, const char *password, >> void *opaque) >> { >> - Error *encryption_err = opaque; >> + char *device = opaque; >> Error *err = NULL; >> - const char *device; >> - >> - device = error_get_field(encryption_err, "device"); >> >> qmp_block_passwd(device, password, &err); >> hmp_handle_error(mon, &err); >> - error_free(encryption_err); >> >> monitor_read_command(mon, 1); >> + g_free(device); >> +} >> + >> +static char *get_device_file(const char *device) >> +{ >> + BlockInfoList *bdev_list, *bdev; >> + char *ret; >> + >> + bdev_list = qmp_query_block(NULL); >> + for (bdev = bdev_list; bdev; bdev = bdev->next) { >> + if (!strcmp(bdev->value->device, device)) { >> + break; >> + } >> + } >> + >> + assert(bdev); >> + assert(bdev->value->has_inserted); >> + >> + ret = g_strdup(bdev->value->inserted->file); >> + qapi_free_BlockInfoList(bdev_list); >> + >> + return ret; >> } >> >> void hmp_change(Monitor *mon, const QDict *qdict) >> @@ -814,9 +832,9 @@ void hmp_change(Monitor *mon, const QDict *qdict) >> >> qmp_change(device, target, !!arg, arg, &err); >> if (error_is_type(err, QERR_DEVICE_ENCRYPTED)) { >> - monitor_printf(mon, "%s (%s) is encrypted.\n", >> - error_get_field(err, "device"), >> - error_get_field(err, "filename")); >> + char *filename = get_device_file(device); > > Elsewhere, we use bdrv_get_encrypted_filename(), which does the right > thing for encrypted backing files. Why is that not necessary here? > > Why not simply bdrv_get_encrypted_filename(bdrv_find(device))? Those are not QMP functions. hmp.c is only allowed to use QMP interfaces. Regards, Anthony Liguori