Re: [PATCH] esx: Improve VMX file name parsing and formatting

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

 



2010/8/11 Daniel Veillard <veillard@xxxxxxxxxx>:
> On Sat, Aug 07, 2010 at 09:54:34PM +0200, Matthias Bolte wrote:
>> 2010/8/7 Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx>:
>> > For parsing try to match by datastore mount path first, if that
>> > fails fallback to /vmfs/volumes/<datastore>/<path> parsing. This
>> > also fixes problems with GSX on Windows. Because GSX on Windows
>> > doesn't use /vmfs/volumes/ style file names.
>> >
>> > For formatting use the datastore mount path too, instead of using
>> > /vmfs/volumes/<datastore>/<path> as fixed format.
>> > ---
>> >  src/esx/esx_driver.c |  372 +++++++++++++++++++++++++++++++------------------
>> >  1 files changed, 235 insertions(+), 137 deletions(-)
>> >
>>
>> > +
>> > +    /* Strip trailing separators */
>> > +    length = strlen(hostMount->mountInfo->path);
>> > +
>> > +    if (length > 0) {
>> > +        tmp = hostMount->mountInfo->path + length - 1;
>> > +
>> > +        while (*tmp == separator && tmp > hostMount->mountInfo->path) {
>> > +            --tmp;
>> >         }
>>
>> [skip removed code]
>>
>> > +        length = tmp - hostMount->mountInfo->path;
>> > +    }
>> > +
>> > +    /* Format as <mount>[/<directory>]/<file> */
>> > +    virBufferAdd(&buffer, hostMount->mountInfo->path, length);
>> > +
>>
>> The trailing separators stripping it totally broken :(
>>
>> This incremental diff fixes that:
>>
>>
>> diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
>> index 322c588..4fb357b 100644
>> --- a/src/esx/esx_driver.c
>> +++ b/src/esx/esx_driver.c
>> @@ -286,14 +286,8 @@ esxFormatVMXFileName(const char *datastorePath,
>> void *opaque)
>>      /* Strip trailing separators */
>>      length = strlen(hostMount->mountInfo->path);
>>
>> -    if (length > 0) {
>> -        tmp = hostMount->mountInfo->path + length - 1;
>> -
>> -        while (*tmp == separator && tmp > hostMount->mountInfo->path) {
>> -            --tmp;
>> -        }
>> -
>> -        length = tmp - hostMount->mountInfo->path;
>> +    while (length > 0 && hostMount->mountInfo->path[length - 1] == separator) {
>> +        --length;
>>      }
>>
>>      /* Format as <mount>[/<directory>]/<file> */
>>
>
>  Okay, ACK :-)
>
> Daniel
>

Thanks, pushed.

Matthias

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