]> git.proxmox.com Git - qemu.git/blobdiff - spice-qemu-char.c
Merge remote-tracking branch 'awilliam/tags/vfio-pci-for-qemu-20130401.0' into staging
[qemu.git] / spice-qemu-char.c
index 8a9236d0a88600be02860a0363b47f00a0ca6839..535f955ca88abd2021697b4c7ff7645fd72f5524 100644 (file)
@@ -100,8 +100,8 @@ static void vmc_state(SpiceCharDeviceInstance *sin, int connected)
     }
 #endif
 
-    if ((scd->chr->opened && connected) ||
-        (!scd->chr->opened && !connected)) {
+    if ((scd->chr->be_open && connected) ||
+        (!scd->chr->be_open && !connected)) {
         return;
     }
 
@@ -149,7 +149,6 @@ static int spice_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
 {
     SpiceCharDriver *s = chr->opaque;
 
-    vmc_register_interface(s);
     assert(s->datalen == 0);
     if (s->bufsize < len) {
         s->bufsize = len;
@@ -176,16 +175,14 @@ static void spice_chr_close(struct CharDriverState *chr)
     g_free(s);
 }
 
-static void spice_chr_guest_open(struct CharDriverState *chr)
+static void spice_chr_set_fe_open(struct CharDriverState *chr, int fe_open)
 {
     SpiceCharDriver *s = chr->opaque;
-    vmc_register_interface(s);
-}
-
-static void spice_chr_guest_close(struct CharDriverState *chr)
-{
-    SpiceCharDriver *s = chr->opaque;
-    vmc_unregister_interface(s);
+    if (fe_open) {
+        vmc_register_interface(s);
+    } else {
+        vmc_unregister_interface(s);
+    }
 }
 
 static void print_allowed_subtypes(void)
@@ -218,8 +215,7 @@ static CharDriverState *chr_open(const char *subtype)
     chr->opaque = s;
     chr->chr_write = spice_chr_write;
     chr->chr_close = spice_chr_close;
-    chr->chr_guest_open = spice_chr_guest_open;
-    chr->chr_guest_close = spice_chr_guest_close;
+    chr->chr_set_fe_open = spice_chr_set_fe_open;
 
     QLIST_INSERT_HEAD(&spice_chars, s, next);