Re: [PATCH] Emit graphics events when a SPICE client connects/disconnects

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

 



On 03/14/2012 01:45 PM, Laine Stump wrote:
Wire up the domain graphics event notifications for SPICE. Adapted
from a RHEL-only patch written by Dan Berrange that used custom
__com.redhat_SPICE events - equivalent events are now available in
upstream QEMU (including a SPICE_CONNECTED event, which was missing in
the __COM.redhat_SPICE version).

* src/qemu/qemu_monitor_json.c: Wire up SPICE graphics events
---
  src/qemu/qemu_monitor_json.c |   56 +++++++++++++++++++++++++++++++++++++++---
  1 files changed, 52 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 1a0ee94..a5ef1d4 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -59,6 +59,9 @@ static void qemuMonitorJSONHandleVNCConnect(qemuMonitorPtr mon, virJSONValuePtr
  static void qemuMonitorJSONHandleVNCInitialize(qemuMonitorPtr mon, virJSONValuePtr data);
  static void qemuMonitorJSONHandleVNCDisconnect(qemuMonitorPtr mon, virJSONValuePtr data);
  static void qemuMonitorJSONHandleBlockJob(qemuMonitorPtr mon, virJSONValuePtr data);
+static void qemuMonitorJSONHandleSPICEConnect(qemuMonitorPtr mon, virJSONValuePtr data);
+static void qemuMonitorJSONHandleSPICEInitialize(qemuMonitorPtr mon, virJSONValuePtr data);
+static void qemuMonitorJSONHandleSPICEDisconnect(qemuMonitorPtr mon, virJSONValuePtr data);

  static struct {
      const char *type;
@@ -75,6 +78,9 @@ static struct {
      { "VNC_INITIALIZED", qemuMonitorJSONHandleVNCInitialize, },
      { "VNC_DISCONNECTED", qemuMonitorJSONHandleVNCDisconnect, },
      { "BLOCK_JOB_COMPLETED", qemuMonitorJSONHandleBlockJob, },
+    { "SPICE_CONNECTED", qemuMonitorJSONHandleSPICEConnect, },
+    { "SPICE_INITIALIZED", qemuMonitorJSONHandleSPICEInitialize, },
+    { "SPICE_DISCONNECTED", qemuMonitorJSONHandleSPICEDisconnect, },
  };


@@ -624,7 +630,7 @@ VIR_ENUM_IMPL(qemuMonitorGraphicsAddressFamily,
                VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_LAST,
                "ipv4", "ipv6", "unix");

-static void qemuMonitorJSONHandleVNC(qemuMonitorPtr mon, virJSONValuePtr data, int phase)
+static void qemuMonitorJSONHandleGraphics(qemuMonitorPtr mon, virJSONValuePtr data, int phase)
  {
      const char *localNode, *localService, *localFamily;
      const char *remoteNode, *remoteService, *remoteFamily;
@@ -643,14 +649,38 @@ static void qemuMonitorJSONHandleVNC(qemuMonitorPtr mon, virJSONValuePtr data, i
      }

      authScheme = virJSONValueObjectGetString(server, "auth");
+    if (!authScheme) {
+        VIR_WARN("missing auth scheme in graphics event");
+        return;
+    }

      localFamily = virJSONValueObjectGetString(server, "family");
+    if (!authScheme) {

s/authScheme/localFamily/

+        VIR_WARN("missing local address family in graphics event");
+        return;
+    }
      localNode = virJSONValueObjectGetString(server, "host");
+    if (!authScheme) {

likewise

+        VIR_WARN("missing local hostname in graphics event");
+        return;
+    }
      localService = virJSONValueObjectGetString(server, "service");
+    if (!localService)
+        localService = ""; /* Spice has multiple ports, so this isn't provided */

      remoteFamily = virJSONValueObjectGetString(client, "family");
+    if (!authScheme) {

likewise

+        VIR_WARN("missing remote address family in graphics event");
+        return;
+    }
      remoteNode = virJSONValueObjectGetString(client, "host");
+    if (!authScheme) {

likewise

+        VIR_WARN("missing remote hostname in graphics event");
+        return;
+    }
      remoteService = virJSONValueObjectGetString(client, "service");
+    if (!remoteService)
+        remoteService = ""; /* Spice has multiple ports, so this isn't provided */

Will we want to parse the specific parameters of spice events? e.g

<snip>
  - "port": port number (json-string)
  - "family": address family (json-string, "ipv4" or "ipv6")
  - "connection-id": spice connection id.  All channels with the same id
                     belong to the same spice session (json-int)
- "channel-type": channel type. "1" is the main control channel, filter for this one if you want track spice sessions only (json-int)
  - "channel-id": channel id.  Usually "0", might be different needed when
multiple channels of the same type exist, such as multiple
                  display channels in a multihead setup (json-int)
  - "tls": whevener the channel is encrypted (json-bool)
</snip>

Osier

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]