summaryrefslogtreecommitdiffstats
path: root/src/VBox/Main/src-server/linux/PerformanceLinux.cpp
blob: 0d6441cb816d09d846ac1401a410797d1d29fde1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
/* $Id: PerformanceLinux.cpp $ */
/** @file
 * VBox Linux-specific Performance Classes implementation.
 */

/*
 * Copyright (C) 2008-2023 Oracle and/or its affiliates.
 *
 * This file is part of VirtualBox base platform packages, as
 * available from https://www.virtualbox.org.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation, in version 3 of the
 * License.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <https://www.gnu.org/licenses>.
 *
 * SPDX-License-Identifier: GPL-3.0-only
 */

#define LOG_GROUP LOG_GROUP_MAIN_PERFORMANCECOLLECTOR
#include <stdio.h>
#include <unistd.h>
#include <sys/statvfs.h>
#include <errno.h>
#include <mntent.h>
#include <iprt/alloc.h>
#include <iprt/cdefs.h>
#include <iprt/ctype.h>
#include <iprt/err.h>
#include <iprt/param.h>
#include <iprt/path.h>
#include <iprt/string.h>
#include <iprt/system.h>
#include <iprt/mp.h>
#include <iprt/linux/sysfs.h>

#include <map>
#include <vector>

#include "LoggingNew.h"
#include "Performance.h"

#define VBOXVOLINFO_NAME "VBoxVolInfo"

namespace pm {

class CollectorLinux : public CollectorHAL
{
public:
    CollectorLinux();
    virtual int preCollect(const CollectorHints& hints, uint64_t /* iTick */);
    virtual int getHostMemoryUsage(ULONG *total, ULONG *used, ULONG *available);
    virtual int getHostFilesystemUsage(const char *name, ULONG *total, ULONG *used, ULONG *available);
    virtual int getHostDiskSize(const char *name, uint64_t *size);
    virtual int getProcessMemoryUsage(RTPROCESS process, ULONG *used);

    virtual int getRawHostCpuLoad(uint64_t *user, uint64_t *kernel, uint64_t *idle);
    virtual int getRawHostNetworkLoad(const char *name, uint64_t *rx, uint64_t *tx);
    virtual int getRawHostDiskLoad(const char *name, uint64_t *disk_ms, uint64_t *total_ms);
    virtual int getRawProcessCpuLoad(RTPROCESS process, uint64_t *user, uint64_t *kernel, uint64_t *total);

    virtual int getDiskListByFs(const char *name, DiskList& listUsage, DiskList& listLoad);
private:
    virtual int _getRawHostCpuLoad();
    int getRawProcessStats(RTPROCESS process, uint64_t *cpuUser, uint64_t *cpuKernel, ULONG *memPagesUsed);
    void getDiskName(char *pszDiskName, size_t cbDiskName, const char *pszDevName, bool fTrimDigits);
    void addVolumeDependencies(const char *pcszVolume, DiskList& listDisks);
    void addRaidDisks(const char *pcszDevice, DiskList& listDisks);
    char *trimTrailingDigits(char *pszName);
    char *trimNewline(char *pszName);

    struct VMProcessStats
    {
        uint64_t cpuUser;
        uint64_t cpuKernel;
        ULONG    pagesUsed;
    };

    typedef std::map<RTPROCESS, VMProcessStats> VMProcessMap;

    VMProcessMap mProcessStats;
    uint64_t     mUser, mKernel, mIdle;
    uint64_t     mSingleUser, mSingleKernel, mSingleIdle;
    uint32_t     mHZ;
    ULONG        mTotalRAM;
};

CollectorHAL *createHAL()
{
    return new CollectorLinux();
}

// Collector HAL for Linux

CollectorLinux::CollectorLinux()
{
    long hz = sysconf(_SC_CLK_TCK);
    if (hz == -1)
    {
        LogRel(("CollectorLinux failed to obtain HZ from kernel, assuming 100.\n"));
        mHZ = 100;
    }
    else
        mHZ = (uint32_t)hz;
    LogFlowThisFunc(("mHZ=%u\n", mHZ));

    uint64_t cb;
    int vrc = RTSystemQueryTotalRam(&cb);
    if (RT_FAILURE(vrc))
        mTotalRAM = 0;
    else
        mTotalRAM = (ULONG)(cb / 1024);
}

int CollectorLinux::preCollect(const CollectorHints& hints, uint64_t /* iTick */)
{
    std::vector<RTPROCESS> processes;
    hints.getProcesses(processes);

    std::vector<RTPROCESS>::iterator it;
    for (it = processes.begin(); it != processes.end(); ++it)
    {
        VMProcessStats vmStats;
        int vrc = getRawProcessStats(*it, &vmStats.cpuUser, &vmStats.cpuKernel, &vmStats.pagesUsed);
        /* On failure, do NOT stop. Just skip the entry. Having the stats for
         * one (probably broken) process frozen/zero is a minor issue compared
         * to not updating many process stats and the host cpu stats. */
        if (RT_SUCCESS(vrc))
            mProcessStats[*it] = vmStats;
    }
    if (hints.isHostCpuLoadCollected() || !mProcessStats.empty())
    {
        _getRawHostCpuLoad();
    }
    return VINF_SUCCESS;
}

int CollectorLinux::_getRawHostCpuLoad()
{
    int vrc = VINF_SUCCESS;
    long long unsigned uUser, uNice, uKernel, uIdle, uIowait, uIrq, uSoftirq;
    FILE *f = fopen("/proc/stat", "r");

    if (f)
    {
        char szBuf[128];
        if (fgets(szBuf, sizeof(szBuf), f))
        {
            if (sscanf(szBuf, "cpu %llu %llu %llu %llu %llu %llu %llu",
                       &uUser, &uNice, &uKernel, &uIdle, &uIowait,
                       &uIrq, &uSoftirq) == 7)
            {
                mUser   = uUser + uNice;
                mKernel = uKernel + uIrq + uSoftirq;
                mIdle   = uIdle + uIowait;
            }
            /* Try to get single CPU stats. */
            if (fgets(szBuf, sizeof(szBuf), f))
            {
                if (sscanf(szBuf, "cpu0 %llu %llu %llu %llu %llu %llu %llu",
                           &uUser, &uNice, &uKernel, &uIdle, &uIowait,
                           &uIrq, &uSoftirq) == 7)
                {
                    mSingleUser   = uUser + uNice;
                    mSingleKernel = uKernel + uIrq + uSoftirq;
                    mSingleIdle   = uIdle + uIowait;
                }
                else
                {
                    /* Assume that this is not an SMP system. */
                    Assert(RTMpGetCount() == 1);
                    mSingleUser   = mUser;
                    mSingleKernel = mKernel;
                    mSingleIdle   = mIdle;
                }
            }
            else
                vrc = VERR_FILE_IO_ERROR;
        }
        else
            vrc = VERR_FILE_IO_ERROR;
        fclose(f);
    }
    else
        vrc = VERR_ACCESS_DENIED;

    return vrc;
}

int CollectorLinux::getRawHostCpuLoad(uint64_t *user, uint64_t *kernel, uint64_t *idle)
{
    *user   = mUser;
    *kernel = mKernel;
    *idle   = mIdle;
    return VINF_SUCCESS;
}

int CollectorLinux::getRawProcessCpuLoad(RTPROCESS process, uint64_t *user, uint64_t *kernel, uint64_t *total)
{
    VMProcessMap::const_iterator it = mProcessStats.find(process);

    if (it == mProcessStats.end())
    {
        Log (("No stats pre-collected for process %x\n", process));
        return VERR_INTERNAL_ERROR;
    }
    *user   = it->second.cpuUser;
    *kernel = it->second.cpuKernel;
    *total  = mUser + mKernel + mIdle;
    return VINF_SUCCESS;
}

int CollectorLinux::getHostMemoryUsage(ULONG *total, ULONG *used, ULONG *available)
{
    AssertReturn(mTotalRAM, VERR_INTERNAL_ERROR);
    uint64_t cb;
    int vrc = RTSystemQueryAvailableRam(&cb);
    if (RT_SUCCESS(vrc))
    {
        *total = mTotalRAM;
        *available = (ULONG)(cb / 1024);
        *used = *total - *available;
    }
    return vrc;
}

int CollectorLinux::getHostFilesystemUsage(const char *path, ULONG *total, ULONG *used, ULONG *available)
{
    struct statvfs stats;

    if (statvfs(path, &stats) == -1)
    {
        LogRel(("Failed to collect %s filesystem usage: errno=%d.\n", path, errno));
        return VERR_ACCESS_DENIED;
    }
    uint64_t cbBlock = stats.f_frsize ? stats.f_frsize : stats.f_bsize;
    *total = (ULONG)(cbBlock * stats.f_blocks / _1M);
    *used  = (ULONG)(cbBlock * (stats.f_blocks - stats.f_bfree) / _1M);
    *available = (ULONG)(cbBlock * stats.f_bavail / _1M);

    return VINF_SUCCESS;
}

int CollectorLinux::getHostDiskSize(const char *pszFile, uint64_t *size)
{
    char *pszPath = NULL;

    RTStrAPrintf(&pszPath, "/sys/block/%s/size", pszFile);
    Assert(pszPath);

    int vrc = VINF_SUCCESS;
    if (!RTLinuxSysFsExists(pszPath))
        vrc = VERR_FILE_NOT_FOUND;
    else
    {
        int64_t cSize = 0;
        vrc = RTLinuxSysFsReadIntFile(0, &cSize, pszPath);
        if (RT_SUCCESS(vrc))
            *size = cSize * 512;
    }
    RTStrFree(pszPath);
    return vrc;
}

int CollectorLinux::getProcessMemoryUsage(RTPROCESS process, ULONG *used)
{
    VMProcessMap::const_iterator it = mProcessStats.find(process);

    if (it == mProcessStats.end())
    {
        Log (("No stats pre-collected for process %x\n", process));
        return VERR_INTERNAL_ERROR;
    }
    *used = it->second.pagesUsed * (PAGE_SIZE / 1024);
    return VINF_SUCCESS;
}

int CollectorLinux::getRawProcessStats(RTPROCESS process, uint64_t *cpuUser, uint64_t *cpuKernel, ULONG *memPagesUsed)
{
    int vrc = VINF_SUCCESS;
    char *pszName;
    pid_t pid2;
    char c;
    int iTmp;
    long long unsigned int u64Tmp;
    unsigned uTmp;
    unsigned long ulTmp;
    signed long ilTmp;
    ULONG u32user, u32kernel;
    char buf[80]; /** @todo this should be tied to max allowed proc name. */

    RTStrAPrintf(&pszName, "/proc/%d/stat", process);
    FILE *f = fopen(pszName, "r");
    RTStrFree(pszName);

    if (f)
    {
        if (fscanf(f, "%d %79s %c %d %d %d %d %d %u %lu %lu %lu %lu %u %u "
                      "%ld %ld %ld %ld %ld %ld %llu %lu %u",
                   &pid2, buf, &c, &iTmp, &iTmp, &iTmp, &iTmp, &iTmp, &uTmp,
                   &ulTmp, &ulTmp, &ulTmp, &ulTmp, &u32user, &u32kernel,
                   &ilTmp, &ilTmp, &ilTmp, &ilTmp, &ilTmp, &ilTmp, &u64Tmp,
                   &ulTmp, memPagesUsed) == 24)
        {
            Assert((pid_t)process == pid2);
            *cpuUser   = u32user;
            *cpuKernel = u32kernel;
        }
        else
            vrc = VERR_FILE_IO_ERROR;
        fclose(f);
    }
    else
        vrc = VERR_ACCESS_DENIED;

    return vrc;
}

int CollectorLinux::getRawHostNetworkLoad(const char *pszFile, uint64_t *rx, uint64_t *tx)
{
    char szIfName[/*IFNAMSIZ*/ 16 + 36];

    RTStrPrintf(szIfName, sizeof(szIfName), "/sys/class/net/%s/statistics/rx_bytes", pszFile);
    if (!RTLinuxSysFsExists(szIfName))
        return VERR_FILE_NOT_FOUND;

    int64_t cSize = 0;
    int vrc = RTLinuxSysFsReadIntFile(0, &cSize, szIfName);
    if (RT_FAILURE(vrc))
        return vrc;

    *rx = cSize;

    RTStrPrintf(szIfName, sizeof(szIfName), "/sys/class/net/%s/statistics/tx_bytes", pszFile);
    if (!RTLinuxSysFsExists(szIfName))
        return VERR_FILE_NOT_FOUND;

    vrc = RTLinuxSysFsReadIntFile(0, &cSize, szIfName);
    if (RT_FAILURE(vrc))
        return vrc;

    *tx = cSize;
    return VINF_SUCCESS;
}

int CollectorLinux::getRawHostDiskLoad(const char *name, uint64_t *disk_ms, uint64_t *total_ms)
{
#if 0
    int vrc = VINF_SUCCESS;
    char szIfName[/*IFNAMSIZ*/ 16 + 36];
    long long unsigned int u64Busy, tmp;

    RTStrPrintf(szIfName, sizeof(szIfName), "/sys/class/block/%s/stat", name);
    FILE *f = fopen(szIfName, "r");
    if (f)
    {
        if (fscanf(f, "%llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu",
                   &tmp, &tmp, &tmp, &tmp, &tmp, &tmp, &tmp, &tmp, &tmp, &u64Busy, &tmp) == 11)
        {
            *disk_ms   = u64Busy;
            *total_ms  = (uint64_t)(mSingleUser + mSingleKernel + mSingleIdle) * 1000 / mHZ;
        }
        else
            vrc = VERR_FILE_IO_ERROR;
        fclose(f);
    }
    else
        vrc = VERR_ACCESS_DENIED;
#else
    int vrc = VERR_MISSING;
    FILE *f = fopen("/proc/diskstats", "r");
    if (f)
    {
        char szBuf[128];
        while (fgets(szBuf, sizeof(szBuf), f))
        {
            char *pszBufName = szBuf;
            while (*pszBufName == ' ')         ++pszBufName; /* Skip spaces */
            while (RT_C_IS_DIGIT(*pszBufName)) ++pszBufName; /* Skip major */
            while (*pszBufName == ' ')         ++pszBufName; /* Skip spaces */
            while (RT_C_IS_DIGIT(*pszBufName)) ++pszBufName; /* Skip minor */
            while (*pszBufName == ' ')         ++pszBufName; /* Skip spaces */

            char *pszBufData = strchr(pszBufName, ' ');
            if (!pszBufData)
            {
                LogRel(("CollectorLinux::getRawHostDiskLoad() failed to parse disk stats: %s\n", szBuf));
                continue;
            }
            *pszBufData++ = '\0';
            if (!strcmp(name, pszBufName))
            {
                long long unsigned int u64Busy, tmp;

                if (sscanf(pszBufData, "%llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu",
                           &tmp, &tmp, &tmp, &tmp, &tmp, &tmp, &tmp, &tmp, &tmp, &u64Busy, &tmp) == 11)
                {
                    *disk_ms   = u64Busy;
                    *total_ms  = (uint64_t)(mSingleUser + mSingleKernel + mSingleIdle) * 1000 / mHZ;
                    vrc = VINF_SUCCESS;
                }
                else
                    vrc = VERR_FILE_IO_ERROR;
                break;
            }
        }
        fclose(f);
    }
#endif

    return vrc;
}

char *CollectorLinux::trimNewline(char *pszName)
{
    size_t cbName = strlen(pszName);
    if (cbName == 0)
        return pszName;

    char *pszEnd = pszName + cbName - 1;
    while (pszEnd > pszName && *pszEnd == '\n')
        pszEnd--;
    pszEnd[1] = '\0';

    return pszName;
}

char *CollectorLinux::trimTrailingDigits(char *pszName)
{
    size_t cbName = strlen(pszName);
    if (cbName == 0)
        return pszName;

    char *pszEnd = pszName + cbName - 1;
    while (pszEnd > pszName && (RT_C_IS_DIGIT(*pszEnd) || *pszEnd == '\n'))
        pszEnd--;
    pszEnd[1] = '\0';

    return pszName;
}

/**
 * Use the partition name to get the name of the disk. Any path component is stripped.
 * if fTrimDigits is true, trailing digits are stripped as well, for example '/dev/sda5'
 * is converted to 'sda'.
 *
 * @param   pszDiskName     Where to store the name of the disk.
 * @param   cbDiskName      The size of the buffer pszDiskName points to.
 * @param   pszDevName      The device name used to get the disk name.
 * @param   fTrimDigits     Trim trailing digits (e.g. /dev/sda5)
 */
void CollectorLinux::getDiskName(char *pszDiskName, size_t cbDiskName, const char *pszDevName, bool fTrimDigits)
{
    unsigned cbName = 0;
    size_t cbDevName = strlen(pszDevName);
    const char *pszEnd = pszDevName + cbDevName - 1;
    if (fTrimDigits)
        while (pszEnd > pszDevName && RT_C_IS_DIGIT(*pszEnd))
            pszEnd--;
    while (pszEnd > pszDevName && *pszEnd != '/')
    {
        cbName++;
        pszEnd--;
    }
    RTStrCopy(pszDiskName, RT_MIN(cbName + 1, cbDiskName), pszEnd + 1);
}

void CollectorLinux::addRaidDisks(const char *pcszDevice, DiskList& listDisks)
{
    FILE *f = fopen("/proc/mdstat", "r");
    if (f)
    {
        char szBuf[128];
        while (fgets(szBuf, sizeof(szBuf), f))
        {
            char *pszBufName = szBuf;

            char *pszBufData = strchr(pszBufName, ' ');
            if (!pszBufData)
            {
                LogRel(("CollectorLinux::addRaidDisks() failed to parse disk stats: %s\n", szBuf));
                continue;
            }
            *pszBufData++ = '\0';
            if (!strcmp(pcszDevice, pszBufName))
            {
                while (*pszBufData == ':')         ++pszBufData; /* Skip delimiter */
                while (*pszBufData == ' ')         ++pszBufData; /* Skip spaces */
                while (RT_C_IS_ALNUM(*pszBufData)) ++pszBufData; /* Skip status */
                while (*pszBufData == ' ')         ++pszBufData; /* Skip spaces */
                while (RT_C_IS_ALNUM(*pszBufData)) ++pszBufData; /* Skip type */

                while (*pszBufData != '\0')
                {
                    while (*pszBufData == ' ') ++pszBufData; /* Skip spaces */
                    char *pszDisk = pszBufData;
                    while (RT_C_IS_ALPHA(*pszBufData))
                        ++pszBufData;
                    if (*pszBufData)
                    {
                        *pszBufData++ = '\0';
                        listDisks.push_back(RTCString(pszDisk));
                        while (*pszBufData != '\0' && *pszBufData != ' ')
                            ++pszBufData;
                    }
                    else
                        listDisks.push_back(RTCString(pszDisk));
                }
                break;
            }
        }
        fclose(f);
    }
}

void CollectorLinux::addVolumeDependencies(const char *pcszVolume, DiskList& listDisks)
{
    char szVolInfo[RTPATH_MAX];
    int vrc = RTPathAppPrivateArch(szVolInfo, sizeof(szVolInfo) - sizeof("/" VBOXVOLINFO_NAME " ") - strlen(pcszVolume));
    if (RT_FAILURE(vrc))
    {
        LogRel(("VolInfo: Failed to get program path, vrc=%Rrc\n", vrc));
        return;
    }
    strcat(szVolInfo, "/" VBOXVOLINFO_NAME " ");
    strcat(szVolInfo, pcszVolume);

    FILE *fp = popen(szVolInfo, "r");
    if (fp)
    {
        char szBuf[128];

        while (fgets(szBuf, sizeof(szBuf), fp))
            if (strncmp(szBuf, RT_STR_TUPLE("dm-")))
                listDisks.push_back(RTCString(trimTrailingDigits(szBuf)));
            else
                listDisks.push_back(RTCString(trimNewline(szBuf)));

        pclose(fp);
    }
    else
        listDisks.push_back(RTCString(pcszVolume));
}

int CollectorLinux::getDiskListByFs(const char *pszPath, DiskList& listUsage, DiskList& listLoad)
{
    FILE *mtab = setmntent("/etc/mtab", "r");
    if (mtab)
    {
        struct mntent *mntent;
        while ((mntent = getmntent(mtab)))
        {
            /* Skip rootfs entry, there must be another root mount. */
            if (strcmp(mntent->mnt_fsname, "rootfs") == 0)
                continue;
            if (strcmp(pszPath, mntent->mnt_dir) == 0)
            {
                char szDevName[128];
                char szFsName[1024];
                /* Try to resolve symbolic link if necessary. Yes, we access the file system here! */
                int vrc = RTPathReal(mntent->mnt_fsname, szFsName, sizeof(szFsName));
                if (RT_FAILURE(vrc))
                    continue; /* something got wrong, just ignore this path */
                /* check against the actual mtab entry, NOT the real path as /dev/mapper/xyz is
                 * often a symlink to something else */
                if (!strncmp(mntent->mnt_fsname, RT_STR_TUPLE("/dev/mapper")))
                {
                    /* LVM */
                    getDiskName(szDevName, sizeof(szDevName), mntent->mnt_fsname, false /*=fTrimDigits*/);
                    addVolumeDependencies(szDevName, listUsage);
                    listLoad = listUsage;
                }
                else if (!strncmp(szFsName, RT_STR_TUPLE("/dev/md")))
                {
                    /* Software RAID */
                    getDiskName(szDevName, sizeof(szDevName), szFsName, false /*=fTrimDigits*/);
                    listUsage.push_back(RTCString(szDevName));
                    addRaidDisks(szDevName, listLoad);
                }
                else
                {
                    /* Plain disk partition. Trim the trailing digits to get the drive name */
                    getDiskName(szDevName, sizeof(szDevName), szFsName, true /*=fTrimDigits*/);
                    listUsage.push_back(RTCString(szDevName));
                    listLoad.push_back(RTCString(szDevName));
                }
                if (listUsage.empty() || listLoad.empty())
                {
                    LogRel(("Failed to retrive disk info: getDiskName(%s) --> %s\n",
                           mntent->mnt_fsname, szDevName));
                }
                break;
            }
        }
        endmntent(mtab);
    }
    return VINF_SUCCESS;
}

}