qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

glib: use portable g_setenv()

We have a setenv() wrapper in os-win32.c that no one is actually using.
Drop it and change to g_setenv() uniformly.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <1576074210-52834-7-git-send-email-pbonzini@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>

authored by

Marc-André Lureau and committed by
Thomas Huth
e468ffdc e858e04d

+6 -30
-2
include/sysemu/os-win32.h
··· 67 67 # define EPROTONOSUPPORT EINVAL 68 68 #endif 69 69 70 - int setenv(const char *name, const char *value, int overwrite); 71 - 72 70 typedef struct { 73 71 long tv_sec; 74 72 long tv_usec;
-22
os-win32.c
··· 30 30 #include "qemu-options.h" 31 31 #include "sysemu/runstate.h" 32 32 33 - /***********************************************************/ 34 - /* Functions missing in mingw */ 35 - 36 - int setenv(const char *name, const char *value, int overwrite) 37 - { 38 - int result = 0; 39 - if (overwrite || !getenv(name)) { 40 - size_t length = strlen(name) + strlen(value) + 2; 41 - char *string = g_malloc(length); 42 - snprintf(string, length, "%s=%s", name, value); 43 - result = putenv(string); 44 - 45 - /* Windows takes a copy and does not continue to use our string. 46 - * Therefore it can be safely freed on this platform. POSIX code 47 - * typically has to leak the string because according to the spec it 48 - * becomes part of the environment. 49 - */ 50 - g_free(string); 51 - } 52 - return result; 53 - } 54 - 55 33 static BOOL WINAPI qemu_ctrl_handler(DWORD type) 56 34 { 57 35 qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_SIGNAL);
+1 -1
tests/libqtest.c
··· 254 254 s->expected_status = 0; 255 255 s->qemu_pid = fork(); 256 256 if (s->qemu_pid == 0) { 257 - setenv("QEMU_AUDIO_DRV", "none", true); 257 + g_setenv("QEMU_AUDIO_DRV", "none", true); 258 258 execlp("/bin/sh", "sh", "-c", command, NULL); 259 259 exit(1); 260 260 }
+1 -1
tests/test-crypto-tlscredsx509.c
··· 141 141 142 142 module_call_init(MODULE_INIT_QOM); 143 143 g_test_init(&argc, &argv, NULL); 144 - setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1); 144 + g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1); 145 145 146 146 mkdir(WORKDIR, 0700); 147 147
+1 -1
tests/test-crypto-tlssession.c
··· 398 398 399 399 module_call_init(MODULE_INIT_QOM); 400 400 g_test_init(&argc, &argv, NULL); 401 - setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1); 401 + g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1); 402 402 403 403 mkdir(WORKDIR, 0700); 404 404
+1 -1
tests/test-io-channel-tls.c
··· 273 273 274 274 module_call_init(MODULE_INIT_QOM); 275 275 g_test_init(&argc, &argv, NULL); 276 - setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1); 276 + g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1); 277 277 278 278 mkdir(WORKDIR, 0700); 279 279
+1 -1
tests/test-vmstate.c
··· 1325 1325 1326 1326 module_call_init(MODULE_INIT_QOM); 1327 1327 1328 - setenv("QTEST_SILENT_ERRORS", "1", 1); 1328 + g_setenv("QTEST_SILENT_ERRORS", "1", 1); 1329 1329 1330 1330 g_test_init(&argc, &argv, NULL); 1331 1331 g_test_add_func("/vmstate/simple/primitive", test_simple_primitive);
+1 -1
ui/sdl2.c
··· 772 772 * This is a bit hackish but saves us from bigger problem. 773 773 * Maybe it's a good idea to fix this in SDL instead. 774 774 */ 775 - setenv("SDL_VIDEODRIVER", "x11", 0); 775 + g_setenv("SDL_VIDEODRIVER", "x11", 0); 776 776 #endif 777 777 778 778 if (SDL_Init(SDL_INIT_VIDEO)) {