[libvirt] [PATCH 14/18] conf: use disk source accessors in vmware/

Laine Stump laine at laine.org
Fri Mar 21 21:01:06 UTC 2014


On 03/19/2014 11:20 AM, Eric Blake wrote:
> Part of a series of cleanups to use new accessor methods.
>
> While writing this, I also discovered that conversion from XML
> to vmware modified the disk source in place; if the same code
> is reached twice, the second call behaves differently because
> the first call didn't clean up its mess.
>
> * src/vmware/vmware_conf.c (vmwareVmxPath): Use accessors.
> (vmwareParsePath): Avoid munging input string.
> * src/vmware/vmware_conf.h (vmwareParsePath): Make static.
>
> Signed-off-by: Eric Blake <eblake at redhat.com>
> ---
>  src/vmware/vmware_conf.c | 18 ++++++++++--------
>  src/vmware/vmware_conf.h |  6 +++---
>  2 files changed, 13 insertions(+), 11 deletions(-)
>
> diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c
> index c96bd62..2de24a7 100644
> --- a/src/vmware/vmware_conf.c
> +++ b/src/vmware/vmware_conf.c
> @@ -331,15 +331,15 @@ vmwareDomainConfigDisplay(vmwareDomainPtr pDomain, virDomainDefPtr def)
>      }
>  }
>
> -int
> -vmwareParsePath(char *path, char **directory, char **filename)
> +static int
> +vmwareParsePath(const char *path, char **directory, char **filename)
>  {
>      char *separator;
>
>      separator = strrchr(path, '/');
>
>      if (separator != NULL) {
> -        *separator++ = '\0';
> +        separator++;
>
>          if (*separator == '\0') {
>              virReportError(VIR_ERR_INTERNAL_ERROR,
> @@ -347,7 +347,7 @@ vmwareParsePath(char *path, char **directory, char **filename)
>              return -1;
>          }
>
> -        if (VIR_STRDUP(*directory, path) < 0)
> +        if (VIR_STRNDUP(*directory, path, separator - path - 1) < 0)

So this fixes the bug you mentioned in the log message. Might be better
if it was a different patch. (No need to resend though) (BTW, you
haven't seen any ACKs yet because I'm going to give one for the whole
series to reduce clutter :-)




More information about the libvir-list mailing list