qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Nile Geisinger <nile@dloo.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] Trivial (but useful) patch to save qemu pid to file
Date: Wed, 8 Dec 2004 00:07:27 +0000	[thread overview]
Message-ID: <200412080007.27542.nile@dloo.com> (raw)
In-Reply-To: <200412031605.10444.james@alentdesignsolutions.com>


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);
             }
         }
     }

  parent reply	other threads:[~2004-12-08  8:32 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-18  9:38 [Qemu-devel] Syscall 269 James Pellow
2004-11-18 13:03 ` Paul Brook
2004-11-18 18:24   ` James Pellow
2004-12-04  0:05   ` James Pellow
2004-12-04 15:09     ` Paul Brook
2004-12-06  1:16       ` James Pellow
2004-12-06  1:26         ` Paul Brook
2004-12-06  2:58           ` James Pellow
2004-12-08  0:07     ` Nile Geisinger [this message]
2004-12-08 18:12       ` [Qemu-devel] Trivial (but useful) patch to save qemu pid to file Felipe Sanchez
2004-12-08 22:01         ` Fabrice Bellard
2004-12-09  2:11           ` Tim
2004-12-13 13:20           ` Nile Geisinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200412080007.27542.nile@dloo.com \
    --to=nile@dloo.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).