Re: [PATCH v2] xen: Remove PATH_MAX sized stack allocation from block stats code

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

 



2011/4/10 Daniel Veillard <veillard@xxxxxxxxxx>:
> On Sat, Apr 09, 2011 at 12:05:17PM +0200, Matthias Bolte wrote:
>> ---
>> Âsrc/xen/block_stats.c | Â 51 +++++++++++++++++++++++++------------------------
>> Â1 files changed, 26 insertions(+), 25 deletions(-)
>>
>> diff --git a/src/xen/block_stats.c b/src/xen/block_stats.c
>> index e7c80c9..1918257 100644
>> --- a/src/xen/block_stats.c
>> +++ b/src/xen/block_stats.c
>> @@ -113,34 +113,35 @@ read_stat (const char *path)
>> Â}
>>
>> Âstatic int64_t
>> -read_bd_stat (int device, int domid, const char *str)
>> +read_bd_stat(int device, int domid, const char *str)
>> Â{
>> - Â Âchar path[PATH_MAX];
>> + Â Âstatic const char *paths[] = {
>> + Â Â Â Â"/sys/bus/xen-backend/devices/vbd-%d-%d/statistics/%s",
>> + Â Â Â Â"/sys/bus/xen-backend/devices/tap-%d-%d/statistics/%s",
>> + Â Â Â Â"/sys/devices/xen-backend/vbd-%d-%d/statistics/%s",
>> + Â Â Â Â"/sys/devices/xen-backend/tap-%d-%d/statistics/%s"
>> + Â Â};
>> +
>> + Â Âint i;
>> + Â Âchar *path;
>> Â Â Âint64_t r;
>>
>> - Â Âsnprintf (path, sizeof path,
>> - Â Â Â Â Â Â Â"/sys/bus/xen-backend/devices/vbd-%d-%d/statistics/%s",
>> - Â Â Â Â Â Â Âdomid, device, str);
>> - Â Âr = read_stat (path);
>> - Â Âif (r >= 0) return r;
>> -
>> - Â Âsnprintf (path, sizeof path,
>> - Â Â Â Â Â Â Â"/sys/bus/xen-backend/devices/tap-%d-%d/statistics/%s",
>> - Â Â Â Â Â Â Âdomid, device, str);
>> - Â Âr = read_stat (path);
>> - Â Âif (r >= 0) return r;
>> -
>> - Â Âsnprintf (path, sizeof path,
>> - Â Â Â Â Â Â Â"/sys/devices/xen-backend/vbd-%d-%d/statistics/%s",
>> - Â Â Â Â Â Â Âdomid, device, str);
>> - Â Âr = read_stat (path);
>> - Â Âif (r >= 0) return r;
>> -
>> - Â Âsnprintf (path, sizeof path,
>> - Â Â Â Â Â Â Â"/sys/devices/xen-backend/tap-%d-%d/statistics/%s",
>> - Â Â Â Â Â Â Âdomid, device, str);
>> - Â Âr = read_stat (path);
>> - Â Âreturn r;
>> + Â Âfor (i = 0; i < ARRAY_CARDINALITY(paths); ++i) {
>> + Â Â Â Âif (virAsprintf(&path, paths[i], domid, device, str) < 0) {
>> + Â Â Â Â Â ÂvirReportOOMError();
>> + Â Â Â Â Â Âreturn -1;
>> + Â Â Â Â}
>> +
>> + Â Â Â Âr = read_stat(path);
>> +
>> + Â Â Â ÂVIR_FREE(path);
>> +
>> + Â Â Â Âif (r >= 0) {
>> + Â Â Â Â Â Âreturn r;
>> + Â Â Â Â}
>> + Â Â}
>> +
>> + Â Âreturn -1;
>> Â}
>>
>> Â/* In Xenstore, /local/domain/0/backend/vbd/<domid>/<device>/state,
>
> ÂACK, thanks !
>
> 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]