aboutsummaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2010-03-17 17:37:03 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2010-03-19 15:27:39 -0500
commit3290c4aac5b97bb1e3b2b28d94669f2c611ce84a (patch)
tree461aa405e5d34abae51d1fb9faadd86fa2e0fb46 /vl.c
parentd49f626ed00cecc90fb1ff88da9bdf11e57094d1 (diff)
downloadqemu-3290c4aac5b97bb1e3b2b28d94669f2c611ce84a.zip
qemu-3290c4aac5b97bb1e3b2b28d94669f2c611ce84a.tar.gz
qemu-3290c4aac5b97bb1e3b2b28d94669f2c611ce84a.tar.bz2
Introduce a default qmp session
Basically, -qmp unix:%{home}/.qemu/qmp/%{uuid}.sock,server,nowait %{uuid} will be -uuid if it's specified, otherwise, if libuuid is available, we generate a uuid. If it's not available, we don't create one. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/vl.c b/vl.c
index e14f45e..5c62d97 100644
--- a/vl.c
+++ b/vl.c
@@ -93,6 +93,10 @@ extern int madvise(caddr_t, size_t, int);
#include <libvdeplug.h>
#endif
+#if defined(CONFIG_UUID)
+#include <uuid/uuid.h>
+#endif
+
#ifdef _WIN32
#include <windows.h>
#endif
@@ -3733,6 +3737,51 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
return popt;
}
+static void qmp_add_default(void)
+{
+ char buffer[4096];
+ const char *home;
+ static uint8_t null_uuid[16];
+ uint8_t uuid[16];
+
+ home = getenv("HOME");
+ if (!home) {
+ return;
+ }
+
+ if (memcmp(qemu_uuid, null_uuid, sizeof(null_uuid)) == 0) {
+#if defined(CONFIG_UUID)
+ uuid_generate(uuid);
+#else
+ return;
+#endif
+ } else {
+ memcpy(uuid, qemu_uuid, sizeof(qemu_uuid));
+ }
+
+ snprintf(buffer, sizeof(buffer), "%s/.qemu", home);
+ if (mkdir(buffer, 0755) == -1 && errno != EEXIST) {
+ fprintf(stderr, "could not open default QMP port\n");
+ return;
+ }
+
+ snprintf(buffer, sizeof(buffer), "%s/.qemu/qmp", home);
+ if (mkdir(buffer, 0755) == -1 && errno != EEXIST) {
+ fprintf(stderr, "could not open default QMP port\n");
+ return;
+ }
+
+ snprintf(buffer, sizeof(buffer),
+ "unix:%s/.qemu/qmp/" UUID_FMT ".sock,server,nowait",
+ home,
+ uuid[0], uuid[1], uuid[2], uuid[3],
+ uuid[4], uuid[5], uuid[6], uuid[7],
+ uuid[8], uuid[9], uuid[10], uuid[11],
+ uuid[12], uuid[13], uuid[14], uuid[15]);
+
+ monitor_parse(buffer, "control");
+}
+
int main(int argc, char **argv, char **envp)
{
const char *gdbstub_dev = NULL;
@@ -4659,6 +4708,9 @@ int main(int argc, char **argv, char **envp)
if (default_virtcon)
add_device_config(DEV_VIRTCON, "vc:80Cx24C");
}
+ if (default_qmp) {
+ qmp_add_default();
+ }
if (default_vga)
vga_interface_type = VGA_CIRRUS;