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

Alon Levy alevy at redhat.com
Mon Dec 6 08:16:00 PST 2010


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

diff --git a/server/reds.c b/server/reds.c
index d71ecb1..517ac6d 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3463,6 +3463,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)
 {
@@ -3605,11 +3620,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.2



More information about the Spice-devel mailing list