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@xxxxxxxxxxxxxxxxxx> --- src/util/virutil.c | 2 +- tests/utiltest.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/util/virutil.c b/src/util/virutil.c index 91178d1..2796671 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -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++) { diff --git a/tests/utiltest.c b/tests/utiltest.c index 9b7a4a3..bd55d44 100644 --- a/tests/utiltest.c +++ b/tests/utiltest.c @@ -37,7 +37,8 @@ static struct testDiskName diskNamesPart[] = { }; static const char* diskNamesInvalid[] = { - "sda00", "sda01", "sdb-1" + "sda00", "sda01", "sdb-1", + "vd2" }; static int -- 1.9.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list