Ensure disk names follow the disk name regex

Currently disk names do not follow the
(regex) /^[fhv]d[a-z]+[0-9]*$/ completely
and hence one can assign disk names like
vd2 etc. This patch ensures that the
disk names follow the regex mentioned.
This patch also adds a testcase.

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
This commit is contained in:
Nitesh Konkar 2017-02-15 16:44:58 +05:30 committed by Michal Privoznik
parent 2dc1cf19db
commit 5729746543
2 changed files with 3 additions and 2 deletions

View File

@ -563,7 +563,7 @@ int virDiskNameParse(const char *name, int *disk, int *partition)
}
}
if (!ptr)
if (!ptr || !c_islower(*ptr))
return -1;
for (i = 0; *ptr; i++) {

View File

@ -37,7 +37,8 @@ static struct testDiskName diskNamesPart[] = {
};
static const char* diskNamesInvalid[] = {
"sda00", "sda01", "sdb-1"
"sda00", "sda01", "sdb-1",
"vd2"
};
static int