[Spice-devel] [PATCH 07/12] server: add spice_server_char_device_remove_interface

Alon Levy alevy at redhat.com
Wed Oct 27 09:36:48 PDT 2010


---
 server/reds.c |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/server/reds.c b/server/reds.c
index 8b7b554..6e29c68 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3460,6 +3460,21 @@ static int spice_server_char_device_add_interface(SpiceServer *s,
     return 0;
 }
 
+static void spice_server_char_device_remove_interface(SpiceBaseInstance *sin)
+{
+    SpiceCharDeviceInstance* char_device =
+            SPICE_CONTAINEROF(sin, SpiceCharDeviceInstance, base);
+    SpiceCharDeviceInterface* sif;
+
+    sif = SPICE_CONTAINEROF(char_device->base.sif, SpiceCharDeviceInterface, base);
+    red_printf("remove CHAR_DEVICE %s", char_device->subtype);
+    if (strcmp(char_device->subtype, SUBTYPE_VDAGENT) == 0) {
+        if (vdagent) {
+            reds_agent_remove();
+        }
+    }
+}
+
 __visible__ int spice_server_add_interface(SpiceServer *s,
                                            SpiceBaseInstance *sin)
 {
@@ -3602,11 +3617,7 @@ __visible__ int spice_server_remove_interface(SpiceBaseInstance *sin)
         snd_detach_record(SPICE_CONTAINEROF(sin, SpiceRecordInstance, base));
 
     } else if (strcmp(interface->type, SPICE_INTERFACE_CHAR_DEVICE) == 0) {
-        red_printf("remove SPICE_INTERFACE_CHAR_DEVICE");
-        if (vdagent && sin == &vdagent->base) {
-            reds_agent_remove();
-        }
-
+        spice_server_char_device_remove_interface(sin);
     } else {
         red_error("VD_INTERFACE_REMOVING unsupported");
         return -1;
-- 
1.7.3.1



More information about the Spice-devel mailing list