qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v5 14/14] qga-win: demystify namespace stripping


From: Tomáš Golembiovský
Subject: [Qemu-devel] [PATCH v5 14/14] qga-win: demystify namespace stripping
Date: Tue, 23 Oct 2018 13:23:23 +0200

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ý <address@hidden>
---
 qga/commands-win32.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 12aba8cc50..779c8ce1fa 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -507,13 +507,21 @@ 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;
+
     pci = g_malloc0(sizeof(*pci));
     pci->domain = -1;
     pci->slot = -1;
     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;
-- 
2.19.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]