qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] Trivial (but useful) patch to save qemu pid to file


From: Nile Geisinger
Subject: [Qemu-devel] Trivial (but useful) patch to save qemu pid to file
Date: Wed, 8 Dec 2004 00:07:27 +0000
User-agent: KMail/1.6

Hi everyone,

Here's a very trivial patch that allows qemu's pid to be saved to a file. This 
is useful if you're using qemu as a service, instrumenting
it with other code, or doing other unixy things,

cheers,

Nile

---------------------------------------------------------------------------------------------------
diff -bur qemu-copy/vl.c qemu/vl.c
--- qemu-copy/vl.c      2004-12-07 22:11:54.898668344 -0500
+++ qemu/vl.c   2004-12-08 00:11:34.232243744 -0500
@@ -2549,6 +2549,7 @@
            "                (default is CL-GD5446 PCI VGA)\n"
 #endif
            "-loadvm file    start right away with a saved state (loadvm in 
monitor)\n"
+           "-pid file       save the qemu process id to a file\n"
            "\n"
            "During emulation, the following keys are useful:\n"
            "ctrl-alt-f      toggle full screen\n"
@@ -2619,6 +2620,7 @@
     QEMU_OPTION_prep,
     QEMU_OPTION_localtime,
     QEMU_OPTION_cirrusvga,
+    QEMU_OPTION_pid,
     QEMU_OPTION_g,
     QEMU_OPTION_std_vga,
     QEMU_OPTION_monitor,
@@ -2689,6 +2691,7 @@
     /* temporary options */
     { "pci", 0, QEMU_OPTION_pci },
     { "cirrusvga", 0, QEMU_OPTION_cirrusvga },
+    { "pid", HAS_ARG, QEMU_OPTION_pid },
     { NULL },
 };

@@ -2765,6 +2768,8 @@
     char serial_devices[MAX_SERIAL_PORTS][128];
     int serial_device_index;
     const char *loadvm = NULL;
+    int pid;
+    FILE * pid_file;

 #if !defined(CONFIG_SOFTMMU)
     /* we never want that malloc() uses mmap() */
@@ -3110,6 +3115,11 @@
             case QEMU_OPTION_full_screen:
                 full_screen = 1;
                 break;
+            case QEMU_OPTION_pid:
+               pid = getpid();
+               pid_file = fopen(optarg, "w");
+               fprintf(pid_file, "%d", pid);
+               fclose(pid_file);
             }
         }
     }




reply via email to

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