]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
qga-win: demystify namespace stripping
authorTomáš Golembiovský <tgolembi@redhat.com>
Tue, 23 Oct 2018 11:23:23 +0000 (13:23 +0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Wed, 31 Oct 2018 14:04:20 +0000 (09:04 -0500)
It was not obvious what exactly the cryptic string copying does to the
GUID. This change makes the intent clearer.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
qga/commands-win32.c

index 30d6c639c3e73ee0088dddbd3de45c67a1ab32da..a1b7512d462c26be5b3ecee728f16676332fa309 100644 (file)
@@ -521,7 +521,7 @@ static GuestPCIAddress *get_pci_info(char *guid, Error **errp)
     char dev_name[MAX_PATH];
     char *buffer = NULL;
     GuestPCIAddress *pci = NULL;
-    char *name = g_strdup(&guid[4]);
+    char *name = NULL;
     bool partial_pci = false;
     pci = g_malloc0(sizeof(*pci));
     pci->domain = -1;
@@ -529,6 +529,13 @@ static GuestPCIAddress *get_pci_info(char *guid, Error **errp)
     pci->function = -1;
     pci->bus = -1;
 
+    if (g_str_has_prefix(guid, "\\\\.\\") ||
+        g_str_has_prefix(guid, "\\\\?\\")) {
+        name = g_strdup(guid + 4);
+    } else {
+        name = g_strdup(guid);
+    }
+
     if (!QueryDosDevice(name, dev_name, ARRAY_SIZE(dev_name))) {
         error_setg_win32(errp, GetLastError(), "failed to get dos device name");
         goto out;