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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
> ---
>  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

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]