Re: [PATCH 03/10] Remove path argument from qemuMonitorJSONFindLinkPath

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

 




On 06/04/2015 09:58 AM, Ján Tomko wrote:
> All the callers use "/" anyway.
> ---
>  src/qemu/qemu_monitor.c      | 11 +++++------
>  src/qemu/qemu_monitor_json.c |  3 +--
>  src/qemu/qemu_monitor_json.h |  1 -
>  3 files changed, 6 insertions(+), 9 deletions(-)
> 

Originally (commit id 'ffdf82a9d'), qemuMonitorFindBalloonObjectPath was
recursive and would need to adjust the path argument when a "child<"
element was found in order to perform proper tree traversal.

Now that it's a couple levels deeper - we don't need curpath although
perhaps someone, some day could find a use for it. I'm not objecting to
removing, just pointing out we could keep it as perhaps "startpath"
which if NULL, would default to "/".  And yes, that could be left as an
exercise for such a future usage.

ACK to what's here, your call on whether to change the name/usage...

John
> diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
> index 4a5e13c..9add05c 100644
> --- a/src/qemu/qemu_monitor.c
> +++ b/src/qemu/qemu_monitor.c
> @@ -1085,8 +1085,7 @@ qemuMonitorSetOptions(qemuMonitorPtr mon, virJSONValuePtr options)
>   * NOTE: This assumes we have already called qemuDomainObjEnterMonitor()
>   */
>  static int
> -qemuMonitorFindBalloonObjectPath(qemuMonitorPtr mon,
> -                                 const char *curpath)
> +qemuMonitorFindBalloonObjectPath(qemuMonitorPtr mon)
>  {
>      ssize_t i, nprops = 0;
>      int ret = -1;
> @@ -1111,7 +1110,7 @@ qemuMonitorFindBalloonObjectPath(qemuMonitorPtr mon,
>          return -1;
>      }
>  
> -    if (qemuMonitorJSONFindLinkPath(mon, curpath, "virtio-balloon-pci", &path) < 0)
> +    if (qemuMonitorJSONFindLinkPath(mon, "virtio-balloon-pci", &path) < 0)
>          return -1;
>  
>      nprops = qemuMonitorJSONGetObjectListPaths(mon, path, &bprops);
> @@ -1160,7 +1159,7 @@ qemuMonitorUpdateVideoMemorySize(qemuMonitorPtr mon,
>      QEMU_CHECK_MONITOR(mon);
>  
>      if (mon->json) {
> -        ret = qemuMonitorJSONFindLinkPath(mon, "/", videoName, &path);
> +        ret = qemuMonitorJSONFindLinkPath(mon, videoName, &path);
>          if (ret < 0) {
>              if (ret == -2)
>                  virReportError(VIR_ERR_INTERNAL_ERROR,
> @@ -1643,7 +1642,7 @@ qemuMonitorGetMemoryStats(qemuMonitorPtr mon,
>      QEMU_CHECK_MONITOR(mon);
>  
>      if (mon->json) {
> -        ignore_value(qemuMonitorFindBalloonObjectPath(mon, "/"));
> +        ignore_value(qemuMonitorFindBalloonObjectPath(mon));
>          mon->ballooninit = true;
>          return qemuMonitorJSONGetMemoryStats(mon, mon->balloonpath,
>                                               stats, nr_stats);
> @@ -1676,7 +1675,7 @@ qemuMonitorSetMemoryStatsPeriod(qemuMonitorPtr mon,
>      if (period < 0)
>          return -1;
>  
> -    if (qemuMonitorFindBalloonObjectPath(mon, "/") == 0) {
> +    if (qemuMonitorFindBalloonObjectPath(mon) == 0) {
>          ret = qemuMonitorJSONSetMemoryStatsPeriod(mon, mon->balloonpath,
>                                                    period);
>  
> diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
> index 6fafe81..13c57d2 100644
> --- a/src/qemu/qemu_monitor_json.c
> +++ b/src/qemu/qemu_monitor_json.c
> @@ -6721,7 +6721,6 @@ qemuMonitorJSONFindObjectPath(qemuMonitorPtr mon,
>   */
>  int
>  qemuMonitorJSONFindLinkPath(qemuMonitorPtr mon,
> -                            const char *curpath,
>                              const char *name,
>                              char **path)
>  {
> @@ -6731,7 +6730,7 @@ qemuMonitorJSONFindLinkPath(qemuMonitorPtr mon,
>      if (virAsprintf(&linkname, "link<%s>", name) < 0)
>          return -1;
>  
> -    ret = qemuMonitorJSONFindObjectPath(mon, curpath, linkname, path);
> +    ret = qemuMonitorJSONFindObjectPath(mon, "/", linkname, path);
>      VIR_FREE(linkname);
>      return ret;
>  }
> diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
> index 953266c..ae8ef7c 100644
> --- a/src/qemu/qemu_monitor_json.h
> +++ b/src/qemu/qemu_monitor_json.h
> @@ -483,7 +483,6 @@ int qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitorPtr mon,
>      ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
>  
>  int qemuMonitorJSONFindLinkPath(qemuMonitorPtr mon,
> -                                const char *curpath,
>                                  const char *name,
>                                  char **path);
>  #endif /* QEMU_MONITOR_JSON_H */
> 

--
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]