When client connects, emit the VMDUMP_INFO. Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com> --- qga/guest-agent-core.h | 2 ++ qga/channel-posix.c | 11 +++++++++++ qga/main.c | 13 +++++++++++++ Makefile | 7 ++++++- qga/Makefile.objs | 1 + qga/qapi-schema.json | 15 +++++++++++++++ 6 files changed, 48 insertions(+), 1 deletion(-)
diff --git a/qga/guest-agent-core.h b/qga/guest-agent-core.h index 3e8a4acff2..1880b0f0ac 100644 --- a/qga/guest-agent-core.h +++ b/qga/guest-agent-core.h @@ -46,3 +46,5 @@ int ga_parse_whence(GuestFileWhence *whence, Error **errp); #ifndef _WIN32 void reopen_fd_to_null(int fd); #endif + +void ga_client_added(void); diff --git a/qga/channel-posix.c b/qga/channel-posix.c index 3f34465159..5999df0684 100644 --- a/qga/channel-posix.c +++ b/qga/channel-posix.c @@ -3,6 +3,7 @@ #include "qapi/error.h" #include "qemu/sockets.h" #include "qga/channel.h" +#include "qga/guest-agent-core.h" #ifdef CONFIG_SOLARIS #include <stropts.h> @@ -98,6 +99,13 @@ static gboolean ga_channel_client_event(GIOChannel *channel, return true; } +static gboolean client_added_idle_cb(gpointer user_data) +{ + ga_client_added(); + + return false; +} + static int ga_channel_client_add(GAChannel *c, int fd) { GIOChannel *client_channel; @@ -115,6 +123,9 @@ static int ga_channel_client_add(GAChannel *c, int fd) g_io_add_watch(client_channel, G_IO_IN | G_IO_HUP, ga_channel_client_event, c); c->client_channel = client_channel; + + g_idle_add(client_added_idle_cb, NULL); + return 0; } diff --git a/qga/main.c b/qga/main.c index 8e852bd556..d2a874e67a 100644 --- a/qga/main.c +++ b/qga/main.c @@ -40,6 +40,7 @@ #endif #endif #include "qapi/qmp-event.h" +#include "qga-qapi-event.h" #ifndef _WIN32 #define QGA_VIRTIO_PATH_DEFAULT "/dev/virtio-ports/org.qemu.guest_agent.0" @@ -691,6 +692,18 @@ static gboolean channel_event_cb(GIOCondition condition, gpointer data) return true; } +void ga_client_added(void) +{ +#ifndef _WIN32 + GAState *s = ga_state; + + qapi_event_send_vmdump_info(s->vmdump.has_phys_base, s->vmdump.phys_base, + s->vmdump.has_text, s->vmdump.text, + s->vmdump.vmcoreinfo != NULL, + s->vmdump.vmcoreinfo, NULL); +#endif +} + static gboolean channel_init(GAState *s, const gchar *method, const gchar *path, int listen_fd) { diff --git a/Makefile b/Makefile index 1c4c04f6f2..fc7e321041 100644 --- a/Makefile +++ b/Makefile @@ -404,6 +404,11 @@ $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \ $(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \ "GEN","$@") +qga/qapi-generated/qga-qapi-event.c qga/qapi-generated/qga-qapi-event.h :\ +$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-event.py \ + $(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \ + "GEN","$@") qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \ $(SRC_PATH)/qapi/block.json $(SRC_PATH)/qapi/block-core.json \ @@ -437,7 +442,7 @@ $(qapi-modules) $(SRC_PATH)/scripts/qapi-introspect.py $(qapi-py) $(gen-out-type) -o "." $<, \ "GEN","$@") -QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h) +QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h qga-qapi-event.h) $(qga-obj-y) qemu-ga.o: $(QGALIB_GEN) qemu-ga$(EXESUF): $(qga-obj-y) $(COMMON_LDADDS) diff --git a/qga/Makefile.objs b/qga/Makefile.objs index 1c5986c0bb..d22977f0e1 100644 --- a/qga/Makefile.objs +++ b/qga/Makefile.objs @@ -4,5 +4,6 @@ qga-obj-$(CONFIG_WIN32) += commands-win32.o channel-win32.o service-win32.o qga-obj-$(CONFIG_WIN32) += vss-win32.o qga-obj-y += qapi-generated/qga-qapi-types.o qapi-generated/qga-qapi-visit.o qga-obj-y += qapi-generated/qga-qmp-marshal.o +qga-obj-y += qapi-generated/qga-qapi-event.o qga-vss-dll-obj-$(CONFIG_QGA_VSS) += vss-win32/ diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index d421609dcb..2a95af3399 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -48,6 +48,21 @@ 'returns': 'int' } ## +# @VMDUMP_INFO: +# +# Provides VM dump information details to qemu. +# +# @phys-base: base address +# +# @text: "_text" location +# +# @vmcoreinfo: the content of /sys/kernel/vmcoreinfo on Linux +# +## +{ 'event': 'VMDUMP_INFO', + 'data': { '*phys-base': 'uint64', '*text': 'uint64', '*vmcoreinfo': 'str' } } + +## # @guest-sync: # # Echo back a unique integer value -- 2.12.0.191.gc5d8de91d