Revived GUEST_BASE support for usermode emulation targets [v5]
[qemu] / vl.c
diff --git a/vl.c b/vl.c
index 94027c0..3d213f3 100644 (file)
--- a/vl.c
+++ b/vl.c
 
 #ifdef CONFIG_SDL
 #ifdef __APPLE__
-#include <SDL/SDL.h>
+#include <SDL.h>
 int qemu_main(int argc, char **argv, char **envp);
 int main(int argc, char **argv)
 {
@@ -244,6 +244,7 @@ int smp_cpus = 1;
 const char *vnc_display;
 int acpi_enabled = 1;
 int no_hpet = 0;
+int no_virtio_balloon = 0;
 int fd_bootchk = 1;
 int no_reboot = 0;
 int no_shutdown = 0;
@@ -4378,6 +4379,7 @@ static int tcg_has_work(void)
 
 static int qemu_calculate_timeout(void)
 {
+#ifndef CONFIG_IOTHREAD
     int timeout;
 
     if (!vm_running)
@@ -4423,6 +4425,9 @@ static int qemu_calculate_timeout(void)
     }
 
     return timeout;
+#else /* CONFIG_IOTHREAD */
+    return 1000;
+#endif
 }
 
 static int vm_can_run(void)
@@ -4458,11 +4463,7 @@ static void main_loop(void)
 #ifdef CONFIG_PROFILER
             ti = profile_getclock();
 #endif
-#ifdef CONFIG_IOTHREAD
-            main_loop_wait(1000);
-#else
             main_loop_wait(qemu_calculate_timeout());
-#endif
 #ifdef CONFIG_PROFILER
             dev_time += profile_getclock() - ti;
 #endif
@@ -4805,7 +4806,7 @@ static char *find_datadir(const char *argv0)
 
     len = GetModuleFileName(NULL, buf, sizeof(buf) - 1);
     if (len == 0) {
-        return len;
+        return NULL;
     }
 
     buf[len] = 0;
@@ -4833,6 +4834,7 @@ static char *find_datadir(const char *argv0)
 #ifdef PATH_MAX
     char buf[PATH_MAX];
 #endif
+    size_t max_len;
 
 #if defined(__linux__)
     {
@@ -4867,11 +4869,12 @@ static char *find_datadir(const char *argv0)
     dir = dirname(p);
     dir = dirname(dir);
 
-    res = qemu_mallocz(strlen(dir) + 
-        MAX(strlen(SHARE_SUFFIX), strlen(BUILD_SUFFIX)) + 1);
-    sprintf(res, "%s%s", dir, SHARE_SUFFIX);
+    max_len = strlen(dir) +
+        MAX(strlen(SHARE_SUFFIX), strlen(BUILD_SUFFIX)) + 1;
+    res = qemu_mallocz(max_len);
+    snprintf(res, max_len, "%s%s", dir, SHARE_SUFFIX);
     if (access(res, R_OK)) {
-        sprintf(res, "%s%s", dir, BUILD_SUFFIX);
+        snprintf(res, max_len, "%s%s", dir, BUILD_SUFFIX);
         if (access(res, R_OK)) {
             qemu_free(res);
             res = NULL;
@@ -4909,7 +4912,7 @@ char *qemu_find_file(int type, const char *name)
     }
     len = strlen(data_dir) + strlen(name) + strlen(subdir) + 2;
     buf = qemu_mallocz(len);
-    sprintf(buf, "%s/%s%s", data_dir, subdir, name);
+    snprintf(buf, len, "%s/%s%s", data_dir, subdir, name);
     if (access(buf, R_OK)) {
         qemu_free(buf);
         return NULL;
@@ -5549,6 +5552,9 @@ int main(int argc, char **argv, char **envp)
             case QEMU_OPTION_no_hpet:
                 no_hpet = 1;
                 break;
+            case QEMU_OPTION_no_virtio_balloon:
+                no_virtio_balloon = 1;
+                break;
 #endif
             case QEMU_OPTION_no_reboot:
                 no_reboot = 1;