Skip to contentSkip to conversation

Misc QGA changes to allow building with Windows Clang

PATCH Applied Kostiantyn Kostiuk 2 participants 11 messages Mar 30 – Jun 17 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover Misc QGA changes to allow building with Windows Clang

Kostiantyn Kostiuk (7):
qga/win: Use swprintf instead of snwprintf
qga/meson: Remove unused lib stdc++
qga/meson: Use windows.compile_resources instead of custom_target qga/meson: Allow to use MSVC message compiler 'mc' qga/vss: Use MAX_PATH instead of PATH_MAX
qga/vss: Remove unused undefs
qga/vss: Drop unused define uuid(x)

 qga/commands-win32.c        |  2 +-
 qga/meson.build             | 12 +++++-------
 qga/vss-win32/requester.cpp |  2 +-
 qga/vss-win32/vss-common.h  | 15 ---------------
 4 files changed, 7 insertions(+), 24 deletions(-)

--
2.52.0

#1 lore raw

PATCH 1/7 qga/win: Use swprintf instead of snwprintf

snwprintf is a Microsoft extension, and according to the MSVC spec, it is called _snwprintf. MinGW defines both snwprintf and _snwprintf, while MSVC defines only _snwprintf.

We can also use swprintf here. The only difference between the two is the return value, and we are not using it. So change the function to support MSVC build env.

---
 qga/commands-win32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qga/commands-win32.c +1 -1
index c0bf3467bd..2bf5581aaa 100644
@@ -1590,7 +1590,7 @@ static DWORD get_interface_index(const char *guid)
     ULONG index;
     DWORD status;
     wchar_t wbuf[INTERFACE_PATH_BUF_SZ];
-    snwprintf(wbuf, INTERFACE_PATH_BUF_SZ, L"\\device\\tcpip_%s", guid);
+    swprintf(wbuf, INTERFACE_PATH_BUF_SZ, L"\\device\\tcpip_%s", guid);
     wbuf[INTERFACE_PATH_BUF_SZ - 1] = 0;
     status = GetAdapterIndex (wbuf, &index);
     if (status != NO_ERROR) {

--
2.52.0

#2 lore raw

PATCH 2/7 qga/meson: Remove unused lib stdc++

In reply to Kostiantyn Kostiuk

qga_libs are libraries for guest agent linking. Guest Agent is a pure C-language application and doesn't need any C++ libs. VSS linking dependencies are placed in a separate file.

---
 qga/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qga/meson.build +1 -1
index 89a4a8f713..1c6433ef25 100644
@@ -97,7 +97,7 @@ if host_os == 'windows'
   qga_libs += ['-lws2_32', '-lwinmm', '-lpowrprof', '-lwtsapi32', '-lwininet', '-liphlpapi', '-lnetapi32',
                '-lsetupapi', '-lcfgmgr32', '-luserenv', '-lpdh' ]
   if have_qga_vss
-    qga_libs += ['-lole32', '-loleaut32', '-lshlwapi', '-lstdc++', '-Wl,--enable-stdcall-fixup']
+    qga_libs += ['-lole32', '-loleaut32', '-lshlwapi', '-Wl,--enable-stdcall-fixup']
     subdir('vss-win32')
   endif
 endif
Signature · 1 line
2.52.0
#3 lore raw

PATCH 3/7 qga/meson: Use windows.compile_resources instead of custom_target

In reply to Kostiantyn Kostiuk

windows.compile_resources supports more compiles and works in both MinGW and MSVC environment. While 'windres' is a MinGW specific tool.

---
 qga/meson.build | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
qga/meson.build +3 -5
index 1c6433ef25..85bdacf7e2 100644
@@ -105,16 +105,14 @@ endif
 qga_objs = []
 if host_os == 'windows'
   windmc = find_program('windmc', required: true)
-  windres = find_program('windres', required: true)
 
   msgrc = custom_target('messages-win32.rc',
                         input: 'messages-win32.mc',
                         output: ['messages-win32.rc', 'MSG00409.bin', 'messages-win32.h'],
                         command: [windmc, '-h', '@OUTDIR@', '-r', '@OUTDIR@', '@INPUT@'])
-  msgobj = custom_target('messages-win32.o',
-                         input: msgrc[0],
-                         output: 'messages-win32.o',
-                         command: [windres, '-I', '@OUTDIR@', '-o', '@OUTPUT@', '@INPUT@'])
+
+  windows = import('windows')
+  msgobj = windows.compile_resources(msgrc[0])
 
   qga_objs = [msgobj]
 endif
Signature · 1 line
2.52.0
#4 lore raw

PATCH 4/7 qga/meson: Allow to use MSVC message compiler 'mc'

In reply to Kostiantyn Kostiuk
---
 qga/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qga/meson.build +1 -1
index 85bdacf7e2..cfa2157efb 100644
@@ -104,7 +104,7 @@ endif
 
 qga_objs = []
 if host_os == 'windows'
-  windmc = find_program('windmc', required: true)
+  windmc = find_program('windmc', 'mc', required: true)
 
   msgrc = custom_target('messages-win32.rc',
                         input: 'messages-win32.mc',
Signature · 1 line
2.52.0
#5 lore raw

PATCH 5/7 qga/vss: Use MAX_PATH instead of PATH_MAX

In reply to Kostiantyn Kostiuk

MAX_PATH defined in windows.h
This is more correct way for Windows.

---
 qga/vss-win32/requester.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qga/vss-win32/requester.cpp +1 -1
index 626d6ab1ff..493ecd5717 100644
@@ -444,7 +444,7 @@ void requester_freeze(int *num_vols, void *mountpoints, ErrorSet *errset)
                 hr = vss_ctx.pVssbc->AddToSnapshotSet(short_volume_name,
                                                       g_gProviderId, &pid);
                 if (FAILED(hr)) {
-                    WCHAR volume_path_name[PATH_MAX];
+                    WCHAR volume_path_name[MAX_PATH];
                     if (GetVolumePathNamesForVolumeNameW(
                             short_volume_name, volume_path_name,
                             sizeof(volume_path_name), NULL) &&
Signature · 1 line
2.52.0
#6 lore raw

PATCH 6/7 qga/vss: Remove unused undefs

In reply to Kostiantyn Kostiuk

We don't include any headers that provides VSS_E*, so no need to undefine it before including vss.h

---
 qga/vss-win32/vss-common.h | 13 -------------
 1 file changed, 13 deletions(-)
qga/vss-win32/vss-common.h +0 -13
index 0e67e7822c..db849127c2 100644
@@ -33,19 +33,6 @@
 #undef uuid
 #define uuid(x)
 
-/* Undef some duplicated error codes redefined in vss.h */
-#undef VSS_E_BAD_STATE
-#undef VSS_E_PROVIDER_NOT_REGISTERED
-#undef VSS_E_PROVIDER_VETO
-#undef VSS_E_OBJECT_NOT_FOUND
-#undef VSS_E_VOLUME_NOT_SUPPORTED
-#undef VSS_E_VOLUME_NOT_SUPPORTED_BY_PROVIDER
-#undef VSS_E_OBJECT_ALREADY_EXISTS
-#undef VSS_E_UNEXPECTED_PROVIDER_ERROR
-#undef VSS_E_INVALID_XML_DOCUMENT
-#undef VSS_E_MAXIMUM_NUMBER_OF_VOLUMES_REACHED
-#undef VSS_E_MAXIMUM_NUMBER_OF_SNAPSHOTS_REACHED
-
 #include <vss.h>
 #include "vss-handles.h"
 
Signature · 1 line
2.52.0
#7 lore raw

PATCH 7/7 qga/vss: Drop unused define uuid(x)

In reply to Kostiantyn Kostiuk

There is no place in code where we use uuid(x), at the same time MSVC vss.h use it and this define broke compilation.

---
 qga/vss-win32/vss-common.h | 2 --
 1 file changed, 2 deletions(-)
qga/vss-win32/vss-common.h +0 -2
index db849127c2..5e993f9eda 100644
@@ -30,8 +30,6 @@
 #define __RPC__out_ecount_part(x, y)
 #endif
 #define _declspec(x)
-#undef uuid
-#define uuid(x)
 
 #include <vss.h>
 #include "vss-handles.h"
Signature · 1 line
2.52.0
#8 lore raw
In reply to Kostiantyn Kostiuk
Quoted 8 lines · Kostiantyn Kostiuk

Kostiantyn Kostiuk (7):
qga/win: Use swprintf instead of snwprintf
qga/meson: Remove unused lib stdc++
qga/meson: Use windows.compile_resources instead of custom_target qga/meson: Allow to use MSVC message compiler 'mc' qga/vss: Use MAX_PATH instead of PATH_MAX
qga/vss: Remove unused undefs
qga/vss: Drop unused define uuid(x)

What is missing after these?

Thanks,

Paolo

#9 lore raw
Quoted 10 lines · Paolo Bonzini
Quoted 8 lines · Kostiantyn Kostiuk

Kostiantyn Kostiuk (7):
qga/win: Use swprintf instead of snwprintf
qga/meson: Remove unused lib stdc++
qga/meson: Use windows.compile_resources instead of custom_target qga/meson: Allow to use MSVC message compiler 'mc' qga/vss: Use MAX_PATH instead of PATH_MAX
qga/vss: Remove unused undefs
qga/vss: Drop unused define uuid(x)

Quoted 3 lines

What is missing after these?

If I am not mistaken, the next patches

- Remove getopt from qga
- support clang-cl and lld-link with 128bit
- use __try1 only if it is defined
- add compatibility header with missing types/includes

Thanks,

Quoted 4 lines

Paolo