From: Wenchao Xia <wenchaoqemu@gmail.com>
To: qemu-devel@nongnu.org
Cc: mdroth@linux.vnet.ibm.com, armbru@redhat.com,
Wenchao Xia <wenchaoqemu@gmail.com>,
lcapitulino@redhat.com
Subject: [Qemu-devel] [PATCH V5 24/28] qapi event: convert SPICE events
Date: Wed, 30 Apr 2014 21:26:58 -0700 [thread overview]
Message-ID: <1398918422-3019-25-git-send-email-wenchaoqemu@gmail.com> (raw)
In-Reply-To: <1398918422-3019-1-git-send-email-wenchaoqemu@gmail.com>
SPICE_INITIALIZED, SPICE_CONNECTED, SPICE_DISCONNECTED and
SPICE_MIGRATE_COMPLETED are converted. inet_strfamily is removed
since no more caller exist now.
Signed-off-by: Wenchao Xia <wenchaoqemu@gmail.com>
---
include/qemu/sockets.h | 1 -
ui/spice-core.c | 70 ++++++++++++++++++++++++-----------------------
util/qemu-sockets.c | 10 -------
3 files changed, 36 insertions(+), 45 deletions(-)
diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h
index af24669..fdbb196 100644
--- a/include/qemu/sockets.h
+++ b/include/qemu/sockets.h
@@ -61,7 +61,6 @@ int inet_nonblocking_connect(const char *str,
void *opaque, Error **errp);
int inet_dgram_opts(QemuOpts *opts, Error **errp);
-const char *inet_strfamily(int family);
NetworkAddressFamily inet_netfamily(int family);
int unix_listen_opts(QemuOpts *opts, Error **errp);
diff --git a/ui/spice-core.c b/ui/spice-core.c
index 387f0ab..f69cdc1 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -35,9 +35,9 @@
#include "qapi/qmp/qjson.h"
#include "qemu/notify.h"
#include "migration/migration.h"
-#include "monitor/monitor.h"
#include "hw/hw.h"
#include "ui/spice-display.h"
+#include "qapi-event.h"
/* core bits */
@@ -173,39 +173,34 @@ static void channel_list_del(SpiceChannelEventInfo *info)
}
}
-static void add_addr_info(QDict *dict, struct sockaddr *addr, int len)
+static void add_addr_info(SpiceBasicInfo *info, struct sockaddr *addr, int len)
{
char host[NI_MAXHOST], port[NI_MAXSERV];
- const char *family;
getnameinfo(addr, len, host, sizeof(host), port, sizeof(port),
NI_NUMERICHOST | NI_NUMERICSERV);
- family = inet_strfamily(addr->sa_family);
- qdict_put(dict, "host", qstring_from_str(host));
- qdict_put(dict, "port", qstring_from_str(port));
- qdict_put(dict, "family", qstring_from_str(family));
+ info->host = g_strdup(host);
+ info->port = g_strdup(port);
+ info->family = inet_netfamily(addr->sa_family);
}
-static void add_channel_info(QDict *dict, SpiceChannelEventInfo *info)
+static void add_channel_info(SpiceChannel *sc, SpiceChannelEventInfo *info)
{
int tls = info->flags & SPICE_CHANNEL_EVENT_FLAG_TLS;
- qdict_put(dict, "connection-id", qint_from_int(info->connection_id));
- qdict_put(dict, "channel-type", qint_from_int(info->type));
- qdict_put(dict, "channel-id", qint_from_int(info->id));
- qdict_put(dict, "tls", qbool_from_int(tls));
+ sc->connection_id = info->connection_id;
+ sc->channel_type = info->type;
+ sc->channel_id = info->id;
+ sc->tls = !!tls;
}
static void channel_event(int event, SpiceChannelEventInfo *info)
{
- static const int qevent[] = {
- [ SPICE_CHANNEL_EVENT_CONNECTED ] = QEVENT_SPICE_CONNECTED,
- [ SPICE_CHANNEL_EVENT_INITIALIZED ] = QEVENT_SPICE_INITIALIZED,
- [ SPICE_CHANNEL_EVENT_DISCONNECTED ] = QEVENT_SPICE_DISCONNECTED,
- };
- QDict *server, *client;
- QObject *data;
+ SpiceServerInfo *server = g_malloc0(sizeof(*server));
+ SpiceChannel *client = g_malloc0(sizeof(*client));
+ server->base = g_malloc0(sizeof(*server->base));
+ client->base = g_malloc0(sizeof(*client->base));
/*
* Spice server might have called us from spice worker thread
@@ -221,36 +216,43 @@ static void channel_event(int event, SpiceChannelEventInfo *info)
qemu_mutex_lock_iothread();
}
- client = qdict_new();
- server = qdict_new();
-
if (info->flags & SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT) {
- add_addr_info(client, (struct sockaddr *)&info->paddr_ext,
+ add_addr_info(client->base, (struct sockaddr *)&info->paddr_ext,
info->plen_ext);
- add_addr_info(server, (struct sockaddr *)&info->laddr_ext,
+ add_addr_info(server->base, (struct sockaddr *)&info->laddr_ext,
info->llen_ext);
} else {
error_report("spice: %s, extended address is expected",
__func__);
}
- if (event == SPICE_CHANNEL_EVENT_INITIALIZED) {
- qdict_put(server, "auth", qstring_from_str(auth));
+ switch (event) {
+ case SPICE_CHANNEL_EVENT_CONNECTED:
+ qapi_event_send_spice_connected(server->base, client->base, NULL);
+ break;
+ case SPICE_CHANNEL_EVENT_INITIALIZED:
+ if (auth) {
+ server->has_auth = true;
+ server->auth = g_strdup(auth);
+ }
add_channel_info(client, info);
channel_list_add(info);
- }
- if (event == SPICE_CHANNEL_EVENT_DISCONNECTED) {
+ qapi_event_send_spice_initialized(server, client, NULL);
+ break;
+ case SPICE_CHANNEL_EVENT_DISCONNECTED:
channel_list_del(info);
+ qapi_event_send_spice_disconnected(server->base, client->base, NULL);
+ break;
+ default:
+ break;
}
- data = qobject_from_jsonf("{ 'client': %p, 'server': %p }",
- QOBJECT(client), QOBJECT(server));
- monitor_protocol_event(qevent[event], data);
- qobject_decref(data);
-
if (need_lock) {
qemu_mutex_unlock_iothread();
}
+
+ qapi_free_SpiceServerInfo(server);
+ qapi_free_SpiceChannel(client);
}
static SpiceCoreInterface core_interface = {
@@ -304,7 +306,7 @@ static void migrate_connect_complete_cb(SpiceMigrateInstance *sin)
static void migrate_end_complete_cb(SpiceMigrateInstance *sin)
{
- monitor_protocol_event(QEVENT_SPICE_MIGRATE_COMPLETED, NULL);
+ qapi_event_send_spice_migrate_completed(NULL);
spice_migration_completed = true;
}
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 777aca2..9999c38 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -94,16 +94,6 @@ static void inet_setport(struct addrinfo *e, int port)
}
}
-const char *inet_strfamily(int family)
-{
- switch (family) {
- case PF_INET6: return "ipv6";
- case PF_INET: return "ipv4";
- case PF_UNIX: return "unix";
- }
- return "unknown";
-}
-
NetworkAddressFamily inet_netfamily(int family)
{
switch (family) {
--
1.7.1
next prev parent reply other threads:[~2014-05-01 4:29 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-01 4:26 [Qemu-devel] [PATCH V5 00/28] add direct support of event in qapi schema Wenchao Xia
2014-05-01 4:26 ` [Qemu-devel] [PATCH V5 01/28] os-posix: include sys/time.h Wenchao Xia
2014-05-01 4:26 ` [Qemu-devel] [PATCH V5 02/28] qapi: add event helper functions Wenchao Xia
2014-05-01 14:20 ` Eric Blake
2014-05-01 4:26 ` [Qemu-devel] [PATCH V5 03/28] qapi script: add event support Wenchao Xia
2014-05-01 22:05 ` Eric Blake
2014-05-02 7:54 ` Markus Armbruster
2014-05-01 4:26 ` [Qemu-devel] [PATCH V5 04/28] test: add test cases for qapi event Wenchao Xia
2014-05-01 14:38 ` Eric Blake
2014-05-01 4:26 ` [Qemu-devel] [PATCH V5 05/28] qapi: define events in qapi schema Wenchao Xia
2014-05-01 15:00 ` Eric Blake
2014-05-07 12:48 ` Wenchao Xia
2014-05-01 4:26 ` [Qemu-devel] [PATCH V5 06/28] monitor: change event functions as an implemention of new emit method Wenchao Xia
2014-05-01 22:09 ` Eric Blake
2014-05-07 12:53 ` Wenchao Xia
2014-05-01 4:26 ` [Qemu-devel] [PATCH V5 07/28] qapi event: convert SHUTDOWN Wenchao Xia
2014-05-01 14:44 ` Eric Blake
2014-05-07 12:55 ` Wenchao Xia
2014-05-01 4:26 ` [Qemu-devel] [PATCH V5 08/28] qapi event: convert POWERDOWN Wenchao Xia
2014-05-01 4:26 ` [Qemu-devel] [PATCH V5 09/28] qapi event: convert RESET Wenchao Xia
2014-05-01 4:26 ` [Qemu-devel] [PATCH V5 10/28] qapi event: convert STOP Wenchao Xia
2014-05-01 4:26 ` [Qemu-devel] [PATCH V5 11/28] qapi event: convert RESUME Wenchao Xia
2014-05-01 4:26 ` [Qemu-devel] [PATCH V5 12/28] qapi event: convert SUSPEND Wenchao Xia
2014-05-01 4:26 ` [Qemu-devel] [PATCH V5 13/28] qapi event: convert SUSPEND_DISK Wenchao Xia
2014-05-01 4:26 ` [Qemu-devel] [PATCH V5 14/28] qapi event: convert WAKEUP Wenchao Xia
2014-05-01 4:26 ` [Qemu-devel] [PATCH V5 15/28] qapi event: convert RTC_CHANGE Wenchao Xia
2014-05-01 4:26 ` [Qemu-devel] [PATCH V5 16/28] qapi event: convert WATCHDOG Wenchao Xia
2014-05-01 4:26 ` [Qemu-devel] [PATCH V5 17/28] qapi event: convert DEVICE_DELETED Wenchao Xia
2014-05-01 4:26 ` [Qemu-devel] [PATCH V5 18/28] qapi event: convert DEVICE_TRAY_MOVED Wenchao Xia
2014-05-01 4:26 ` [Qemu-devel] [PATCH V5 19/28] qapi event: convert BLOCK_IO_ERROR and BLOCK_JOB_ERROR Wenchao Xia
2014-05-01 4:26 ` [Qemu-devel] [PATCH V5 20/28] qapi event: convert BLOCK_IMAGE_CORRUPTED Wenchao Xia
2014-05-01 4:26 ` [Qemu-devel] [PATCH V5 21/28] qapi event: convert other BLOCK_JOB events Wenchao Xia
2014-05-01 4:26 ` [Qemu-devel] [PATCH V5 22/28] qapi event: convert NIC_RX_FILTER_CHANGED Wenchao Xia
2014-05-01 4:26 ` [Qemu-devel] [PATCH V5 23/28] qapi event: convert VNC events Wenchao Xia
2014-05-01 4:26 ` Wenchao Xia [this message]
2014-05-01 4:26 ` [Qemu-devel] [PATCH V5 25/28] qapi event: convert BALLOON_CHANGE Wenchao Xia
2014-05-01 4:27 ` [Qemu-devel] [PATCH V5 26/28] qapi event: convert GUEST_PANICKED Wenchao Xia
2014-05-01 4:27 ` [Qemu-devel] [PATCH V5 27/28] qapi event: convert QUORUM events Wenchao Xia
2014-05-01 4:27 ` [Qemu-devel] [PATCH V5 28/28] qapi event: clean up Wenchao Xia
2014-05-01 22:15 ` Eric Blake
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=1398918422-3019-25-git-send-email-wenchaoqemu@gmail.com \
--to=wenchaoqemu@gmail.com \
--cc=armbru@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=mdroth@linux.vnet.ibm.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).