Skip to contentSkip to conversation

qga/vss-win32/install: Remove _com_util::ConvertStringToBSTR()

PATCH In review Bernhard Beschow 3 participants 6 messages Nov 1, 2025 – Nov 3, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qga/vss-win32/install: Remove _com_util::ConvertStringToBSTR()

Now that MSYS2 provides an implementation of the function it clashes with QEMU's, resulting in a compilation error. Remove it since it doesn't seem to be used anyway.

---
 qga/vss-win32/install.cpp | 19 -------------------
 1 file changed, 19 deletions(-)
qga/vss-win32/install.cpp +0 -19
index 7b25d9098b..147bf387fd 100644
@@ -548,25 +548,6 @@ STDAPI DllUnregisterServer(void)
 }
 
 
-/* Support function to convert ASCII string into BSTR (used in _bstr_t) */
-namespace _com_util
-{
-    BSTR WINAPI ConvertStringToBSTR(const char *ascii) {
-        int len = strlen(ascii);
-        BSTR bstr = SysAllocStringLen(NULL, len);
-
-        if (!bstr) {
-            return NULL;
-        }
-
-        if (mbstowcs(bstr, ascii, len) == (size_t)-1) {
-            qga_debug("Failed to convert string '%s' into BSTR", ascii);
-            bstr[0] = 0;
-        }
-        return bstr;
-    }
-}
-
 /* Stop QGA VSS provider service using Winsvc API  */
 STDAPI StopService(void)
 {
Signature · 1 line
2.51.2
#1 lore raw
Quoted 4 lines · Bernhard Beschow

Now that MSYS2 provides an implementation of the function it clashes with QEMU's, resulting in a compilation error. Remove it since it doesn't seem to be used anyway.

The comment says it's used by _bstr_t, which presumably is in some Windows header or library that we're linking against. Our code seems to use _bstr_t a lot. Is this function definitely not required, or should we have something so we provide it only when MSYS2 does not?

thanks
-- PMM

#2 lore raw

Am 1. November 2025 13:13:26 UTC schrieb Peter Maydell <[email protected]>:

Quoted 11 lines · Bernhard Beschow
Quoted 4 lines

Now that MSYS2 provides an implementation of the function it clashes with QEMU's, resulting in a compilation error. Remove it since it doesn't seem to be used anyway.

The comment says it's used by _bstr_t, which presumably is in some Windows header or library that we're linking against. Our code seems to use _bstr_t a lot. Is this function definitely not required, or should we have something so we provide it only when MSYS2 does not?

I just grepped the code and it doesn't return any users. And searching the git history it never did. Maybe some library we're linking against needs an implementation but I can't reproduce this with my recent MSYS2 installation.

Best regards,
Bernhard

Quoted 3 lines

thanks
-- PMM

#3 lore raw
Quoted 10 lines · Bernhard Beschow

Am 1. November 2025 13:13:26 UTC schrieb Peter Maydell <[email protected]>:

Quoted 6 lines · Bernhard Beschow
Quoted 4 lines

Now that MSYS2 provides an implementation of the function it clashes with QEMU's, resulting in a compilation error. Remove it since it doesn't seem to be used anyway.

Quoted 8 lines
Quoted 5 lines

The comment says it's used by _bstr_t, which presumably is in some Windows header or library that we're linking against. Our code seems to use _bstr_t a lot. Is this function definitely not required, or should we have something so we provide it only when MSYS2 does not?

I just grepped the code and it doesn't return any users. And searching the git history it never did.

The comment suggests that the user would be in the MS headers we're including or the library we're linking against, not in our own code, though, so grep wouldn't find it.

-- PMM

#4 lore raw
In reply to Peter Maydell

This function is used inside Windows headers. You can find the following code in comutil.h in MinGW

inline _bstr_t::Data_t::Data_t(const char *s) : m_str(NULL),m_RefCount(1) { m_wstr = _com_util::ConvertStringToBSTR(s);
}

But MinGW does not implement ConvertStringToBSTR, so QEMU should implement this function.
We use _bstr_t in VSS-provided DLL, so this function is mandatory for us.

Best Regards,
Kostiantyn Kostiuk.

Quoted 16 lines · Peter Maydell
Quoted 4 lines · Bernhard Beschow

Now that MSYS2 provides an implementation of the function it clashes with QEMU's, resulting in a compilation error. Remove it since it doesn't seem to be used anyway.

The comment says it's used by _bstr_t, which presumably is in some Windows header or library that we're linking against. Our code seems to use _bstr_t a lot. Is this function definitely not required, or should we have something so we provide it only when MSYS2 does not?

thanks
-- PMM

#5 lore raw

CC @Yan Vugenfirer <[email protected]>

Best Regards,
Kostiantyn Kostiuk.

Quoted 39 lines · Kostiantyn Kostiuk

This function is used inside Windows headers. You can find the following code in comutil.h in MinGW

inline _bstr_t::Data_t::Data_t(const char *s) : m_str(NULL),m_RefCount(1) {
m_wstr = _com_util::ConvertStringToBSTR(s);
}

But MinGW does not implement ConvertStringToBSTR, so QEMU should implement this function.
We use _bstr_t in VSS-provided DLL, so this function is mandatory for us.

Best Regards,
Kostiantyn Kostiuk.

Quoted 18 lines · Peter Maydell
Quoted 2 lines · Bernhard Beschow

Now that MSYS2 provides an implementation of the function it clashes

with

Quoted 1 line

QEMU's, resulting in a compilation error. Remove it since it doesn't

seem

Quoted 1 line

to be used anyway.

The comment says it's used by _bstr_t, which presumably is in some Windows header or library that we're linking against. Our code seems to use _bstr_t a lot. Is this function definitely not required, or should we have something so we provide it only when MSYS2 does not?

thanks
-- PMM