From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:42407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaqBm-0000dL-DK for qemu-devel@nongnu.org; Wed, 14 Dec 2011 09:52:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RaqBg-0001N9-I6 for qemu-devel@nongnu.org; Wed, 14 Dec 2011 09:52:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:15403) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaqBg-0001N0-7q for qemu-devel@nongnu.org; Wed, 14 Dec 2011 09:52:04 -0500 Message-ID: <4EE8B8BC.2040804@redhat.com> Date: Wed, 14 Dec 2011 15:54:52 +0100 From: Kevin Wolf MIME-Version: 1.0 References: <1323784351-25531-1-git-send-email-stefanha@linux.vnet.ibm.com> <1323784351-25531-9-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1323784351-25531-9-git-send-email-stefanha@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3 8/9] qmp: add query-block-jobs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Marcelo Tosatti , qemu-devel@nongnu.org, Luiz Capitulino Am 13.12.2011 14:52, schrieb Stefan Hajnoczi: > Add query-block-jobs, which shows the progress of ongoing block device > operations. > > Signed-off-by: Stefan Hajnoczi > --- > blockdev.c | 33 +++++++++++++++++++++++++++++++++ > hmp.c | 40 ++++++++++++++++++++++++++++++++++++++++ > hmp.h | 1 + > monitor.c | 7 +++++++ > qapi-schema.json | 32 ++++++++++++++++++++++++++++++++ > qmp-commands.hx | 39 +++++++++++++++++++++++++++++++++++++++ > 6 files changed, 152 insertions(+), 0 deletions(-) > > diff --git a/blockdev.c b/blockdev.c > index b276b2f..5b2b128 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -997,3 +997,36 @@ void qmp_block_job_cancel(const char *device, Error **errp) > trace_qmp_block_job_cancel(job); > block_job_cancel(job); > } > + > +static void do_qmp_query_block_jobs_one(void *opaque, BlockDriverState *bs) > +{ > + BlockJobInfoList **prev = opaque; > + BlockJob *job = bs->job; > + > + if (job) { > + BlockJobInfoList *elem; > + BlockJobInfo *info = g_new(BlockJobInfo, 1); > + *info = (BlockJobInfo){ > + .type = g_strdup(job->job_type->job_type), > + .device = g_strdup(bdrv_get_device_name(bs)), > + .len = job->len, > + .offset = job->offset, > + .speed = job->speed, > + }; Some spaces to align it nicely? > + > + elem = g_new0(BlockJobInfoList, 1); > + elem->value = info; > + > + (*prev)->next = elem; > + *prev = elem; I hate these open-coded lists. But not your fault... > + } > +} > + > +BlockJobInfoList *qmp_query_block_jobs(Error **errp) > +{ > + /* Dummy is a fake list element for holding the head pointer */ > + BlockJobInfoList dummy = {}; > + BlockJobInfoList *prev = &dummy; > + bdrv_iterate(do_qmp_query_block_jobs_one, &prev); > + return dummy.next; > +} > diff --git a/hmp.c b/hmp.c > index 66d9d0f..c16d6a1 100644 > --- a/hmp.c > +++ b/hmp.c > @@ -499,6 +499,46 @@ void hmp_info_pci(Monitor *mon) > qapi_free_PciInfoList(info); > } > > +void hmp_info_block_jobs(Monitor *mon) > +{ > + BlockJobInfoList *list; > + Error *err = NULL; > + > + list = qmp_query_block_jobs(&err); > + assert(!err); > + > + if (!list) { > + monitor_printf(mon, "No active jobs\n"); > + return; > + } > + > + while (list) { > + /* The HMP output for streaming jobs is special because historically it > + * was different from other job types so applications may depend on the > + * exact string. > + */ Er, what? This is new code. What HMP clients use this string? I know that libvirt already got support for this before we implemented it, but shouldn't that be QMP only? Kevin