[libvirt] [PATCH 1/2] qemu: Remove need for qemuDomainParseIOThreadAlias

Peter Krempa pkrempa at redhat.com
Tue Apr 28 08:40:40 UTC 2015


On Mon, Apr 27, 2015 at 14:51:04 -0400, John Ferlan wrote:
> Rather than have a separate routine to parse the alias of an iothread
> returned from qemu in order to get the iothread_id value, parse the alias
> when returning and just return the iothread_id in qemuMonitorIOThreadInfoPtr
> 
> This set of patches removes the function, changes the "char *name" to
> "unsigned int" and handles all the fallout.
> 
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
>  src/qemu/qemu_command.c      | 17 -----------------
>  src/qemu/qemu_command.h      |  3 ---
>  src/qemu/qemu_driver.c       |  9 ++-------
>  src/qemu/qemu_monitor.c      |  1 -
>  src/qemu/qemu_monitor.h      |  2 +-
>  src/qemu/qemu_monitor_json.c |  7 ++++++-
>  src/qemu/qemu_process.c      | 11 ++++-------
>  tests/qemumonitorjsontest.c  | 12 ++++++------
>  8 files changed, 19 insertions(+), 43 deletions(-)
> 

...

> diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
> index 1e7d2ef..48bfeb0 100644
> --- a/src/qemu/qemu_monitor.c
> +++ b/src/qemu/qemu_monitor.c
> @@ -3818,7 +3818,6 @@ qemuMonitorIOThreadInfoFree(qemuMonitorIOThreadInfoPtr iothread)
>  {
>      if (!iothread)
>          return;
> -    VIR_FREE(iothread->name);
>      VIR_FREE(iothread);

Looks like this function can be killed and replaced with VIR_FREE().


>  }
>  

...

> diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
> index 3af319c..76687ff 100644
> --- a/src/qemu/qemu_monitor_json.c
> +++ b/src/qemu/qemu_monitor_json.c
> @@ -6492,8 +6492,13 @@ qemuMonitorJSONGetIOThreads(qemuMonitorPtr mon,
>              goto cleanup;
>          }
>  
> -        if (VIR_STRDUP(info->name, tmp) < 0)
> +        if (virStrToLong_ui(tmp + strlen("iothread"),

You shouldn't assume that the returned thread will begin with iothread.
The code should make sure that the STRPREFIX is "iothread" before moving
the pointer. If the alias will be shorter it will crash.

> +                            NULL, 10, &info->iothread_id) < 0) {
> +            virReportError(VIR_ERR_INTERNAL_ERROR,
> +                           _("failed to find iothread id for '%s'"),
> +                           tmp);
>              goto cleanup;
> +        }
>  
>          if (virJSONValueObjectGetNumberInt(child, "thread-id",
>                                             &info->thread_id) < 0) {

Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150428/07bb07c0/attachment-0001.sig>


More information about the libvir-list mailing list