]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: support windows paths in virDomainDiskByName()
authorJonathon Jongsma <jjongsma@redhat.com>
Fri, 6 Feb 2026 22:08:37 +0000 (16:08 -0600)
committerJonathon Jongsma <jjongsma@redhat.com>
Mon, 23 Feb 2026 18:08:13 +0000 (12:08 -0600)
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 <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/domain_conf.c

index 453e3010412d2b2b004868b9af6ca89535f4a876..a77670ea8d41773cbd91f3e5c247938f41ee0386 100644 (file)
@@ -15459,10 +15459,12 @@ virDomainDiskIndexByName(virDomainDef *def, const char *name,
     /* We prefer the <target dev='name'/> name (it's shorter, required
      * for all disks, and should be unambiguous), but also support
      * <source file='name'/> (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)) {