From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:53678) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TNmoF-00067I-Qx for qemu-devel@nongnu.org; Mon, 15 Oct 2012 11:42:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TNmoE-0006hu-Ep for qemu-devel@nongnu.org; Mon, 15 Oct 2012 11:42:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64192) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TNmoE-0006hm-7B for qemu-devel@nongnu.org; Mon, 15 Oct 2012 11:42:26 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9FFgP8H006348 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 15 Oct 2012 11:42:25 -0400 Message-ID: <507C2EDD.8080906@redhat.com> Date: Mon, 15 Oct 2012 17:42:21 +0200 From: Kevin Wolf MIME-Version: 1.0 References: <1348675011-8794-1-git-send-email-pbonzini@redhat.com> <1348675011-8794-20-git-send-email-pbonzini@redhat.com> In-Reply-To: <1348675011-8794-20-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 19/45] block: add bdrv_query_info List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: jcody@redhat.com, qemu-devel@nongnu.org Am 26.09.2012 17:56, schrieb Paolo Bonzini: > Extract it out of the implementation of "info block". > > Signed-off-by: Paolo Bonzini > --- > v1->v2: moved bdrv_query_info close to qmp_query_block. > Fixed conflicts for the new field 'encryption_key_missing' > too. > > block.c | 104 +++++++++++++++++++++++++++++++--------------------------------- > block.h | 1 + > 2 file modificati, 52 inserzioni(+), 53 rimozioni(-) > > diff --git a/block.c b/block.c > index 83a695b..1d95a5d 100644 > --- a/block.c > +++ b/block.c > @@ -2653,69 +2653,67 @@ int coroutine_fn bdrv_co_is_allocated_above(BlockDriverState *top, > return 0; > } > > +BlockInfo *bdrv_query_info(BlockDriverState *bs) > +{ > + BlockInfo *info = g_malloc0(sizeof(*info)); > + info->device = g_strdup(bs->device_name); > + info->type = g_strdup("unknown"); > + info->locked = bdrv_dev_is_medium_locked(bs); > + info->removable = bdrv_dev_has_removable_media(bs); > + > + if (bdrv_dev_has_removable_media(bs)) { > + info->has_tray_open = true; > + info->tray_open = bdrv_dev_is_tray_open(bs); > + } > + > + if (bdrv_iostatus_is_enabled(bs)) { > + info->has_io_status = true; > + info->io_status = bs->iostatus; > + } > + > + if (bs->drv) { > + info->has_inserted = true; > + info->inserted = g_malloc0(sizeof(*info->inserted)); > + info->inserted->file = g_strdup(bs->filename); > + info->inserted->ro = bs->read_only; > + info->inserted->drv = g_strdup(bs->drv->format_name); > + info->inserted->encrypted = bs->encrypted; > + info->inserted->encryption_key_missing = bdrv_key_required(bs); > + > + if (bs->backing_file[0]) { > + info->inserted->has_backing_file = true; > + info->inserted->backing_file = g_strdup(bs->backing_file); > + } > + > + if (bs->io_limits_enabled) { > + info->inserted->bps = > + bs->io_limits.bps[BLOCK_IO_LIMIT_TOTAL]; > + info->inserted->bps_rd = > + bs->io_limits.bps[BLOCK_IO_LIMIT_READ]; > + info->inserted->bps_wr = > + bs->io_limits.bps[BLOCK_IO_LIMIT_WRITE]; > + info->inserted->iops = > + bs->io_limits.iops[BLOCK_IO_LIMIT_TOTAL]; > + info->inserted->iops_rd = > + bs->io_limits.iops[BLOCK_IO_LIMIT_READ]; > + info->inserted->iops_wr = > + bs->io_limits.iops[BLOCK_IO_LIMIT_WRITE]; > + } > + } > + return info; > +} > + > BlockInfoList *qmp_query_block(Error **errp) > { > - BlockInfoList *head = NULL, *cur_item = NULL; > + BlockInfoList *head = NULL, **p_next = &head; > BlockDriverState *bs; > > QTAILQ_FOREACH(bs, &bdrv_states, list) { > BlockInfoList *info = g_malloc0(sizeof(*info)); > + info->value = bdrv_query_info(bs); > > - info->value = g_malloc0(sizeof(*info->value)); > - info->value->device = g_strdup(bs->device_name); > - info->value->type = g_strdup("unknown"); > - info->value->locked = bdrv_dev_is_medium_locked(bs); > - info->value->removable = bdrv_dev_has_removable_media(bs); > - > - if (bdrv_dev_has_removable_media(bs)) { > - info->value->has_tray_open = true; > - info->value->tray_open = bdrv_dev_is_tray_open(bs); > - } > - > - if (bdrv_iostatus_is_enabled(bs)) { > - info->value->has_io_status = true; > - info->value->io_status = bs->iostatus; > - } > - > - if (bs->drv) { > - info->value->has_inserted = true; > - info->value->inserted = g_malloc0(sizeof(*info->value->inserted)); > - info->value->inserted->file = g_strdup(bs->filename); > - info->value->inserted->ro = bs->read_only; > - info->value->inserted->drv = g_strdup(bs->drv->format_name); > - info->value->inserted->encrypted = bs->encrypted; > - info->value->inserted->encryption_key_missing = bdrv_key_required(bs); > - if (bs->backing_file[0]) { > - info->value->inserted->has_backing_file = true; > - info->value->inserted->backing_file = g_strdup(bs->backing_file); > - } > - > - info->value->inserted->backing_file_depth = > - bdrv_get_backing_file_depth(bs); Mismerge: This part is missing from bdrv_query_info. Kevin