From: Jonathon Jongsma Date: Fri, 6 Feb 2026 22:08:37 +0000 (-0600) Subject: conf: support windows paths in virDomainDiskByName() X-Git-Tag: v12.1.0-rc1~54 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=331a392b967fd2e6684a0299ca2fd6e107bf2090;p=thirdparty%2Flibvirt.git conf: support windows paths in virDomainDiskByName() With the hyperv driver, disks might have windows paths like "c:\path\to\disk.vhdx". Currently, this function supports paths, but only if they're in unix format. Signed-off-by: Jonathon Jongsma Reviewed-by: Michal Privoznik --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 453e301041..a77670ea8d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15459,10 +15459,12 @@ virDomainDiskIndexByName(virDomainDef *def, const char *name, /* We prefer the name (it's shorter, required * for all disks, and should be unambiguous), but also support * (if unambiguous). Assume dst if there is - * no leading slash, source name otherwise. */ + * no leading slash (Unix path) or drive letter (Windows path like C:\), + * source name otherwise. */ for (i = 0; i < def->ndisks; i++) { vdisk = def->disks[i]; - if (*name != '/') { + if (*name != '/' && + !(g_ascii_isalpha(name[0]) && name[1] == ':')) { if (STREQ(vdisk->dst, name)) return i; } else if (STREQ_NULLABLE(virDomainDiskGetSource(vdisk), name)) {