Calling virDiskNameToIndex with a disk name > {sd,hd,xvd,vd}z, such as vdaa, generates a bogus index. Account for iterations through the loop.
Old behaviour: vda -> 0 vdz -> 25 vdaa -> 0 vdaz -> 25 New behaviour: vda -> 0 vdz -> 25 vdaa -> 26 vdaz -> 51 This was discovered by Sanjay Rao, thanks for the report. Signed-off-by: Chris Wright <[EMAIL PROTECTED]> Cc: Mark Wagner <[EMAIL PROTECTED]> Cc: Sanjay Rao <[EMAIL PROTECTED]> --- src/domain_conf.c | 2 +- src/util.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/domain_conf.c b/src/domain_conf.c index 6a35064..b5897a7 100644 --- a/src/domain_conf.c +++ b/src/domain_conf.c @@ -3395,7 +3395,7 @@ char *virDomainConfigFile(virConnectPtr conn, /* Translates a device name of the form (regex) "[fhv]d[a-z]+" into * the corresponding bus,index combination (e.g. sda => (0,0), sdi (1,1), - * hdd => (1,1), vdaa => (0,27)) + * hdd => (1,1), vdaa => (0,26)) * @param disk The disk device * @param busIdx parsed bus number * @param devIdx parsed device number diff --git a/src/util.c b/src/util.c index ca14be1..56390d7 100644 --- a/src/util.c +++ b/src/util.c @@ -1055,7 +1055,7 @@ const char *virEnumToString(const char *const*types, } /* Translates a device name of the form (regex) "[fhv]d[a-z]+" into - * the corresponding index (e.g. sda => 1, hdz => 26, vdaa => 27) + * the corresponding index (e.g. sda => 0, hdz => 25, vdaa => 26) * @param name The name of the device * @return name's index, or -1 on failure */ @@ -1075,8 +1075,8 @@ int virDiskNameToIndex(const char *name) { if (!ptr) return -1; - while (*ptr) { - idx = idx * 26; + for (i = 0; *ptr; i++) { + idx = (idx + i) * 26; if (!c_islower(*ptr)) return -1; -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list