Remove the NIC from vlan on usb destroy.
authorbalrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162>
Thu, 17 Jul 2008 21:00:05 +0000 (21:00 +0000)
committerbalrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162>
Thu, 17 Jul 2008 21:00:05 +0000 (21:00 +0000)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4885 c046a42c-6fe2-441c-8c8c-71466251a162

hw/usb-net.c
net.h
vl.c

index 0f62f88..56210b5 100644 (file)
@@ -1418,7 +1418,8 @@ static void usb_net_handle_destroy(USBDevice *dev)
 {
     USBNetState *s = (USBNetState *) dev;
 
-    /* FIXME: delete the VLAN client and the nic */
+    /* TODO: remove the nd_table[] entry */
+    qemu_del_vlan_client(s->vc);
     rndis_clear_responsequeue(s);
     qemu_free(s);
 }
diff --git a/net.h b/net.h
index 2dfff8d..d00910f 100644 (file)
--- a/net.h
+++ b/net.h
@@ -28,6 +28,7 @@ VLANClientState *qemu_new_vlan_client(VLANState *vlan,
                                       IOReadHandler *fd_read,
                                       IOCanRWHandler *fd_can_read,
                                       void *opaque);
+void qemu_del_vlan_client(VLANClientState *vc);
 int qemu_can_send_packet(VLANClientState *vc);
 void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size);
 void qemu_handler_true(void *opaque);
diff --git a/vl.c b/vl.c
index 043e484..613fa84 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -3870,6 +3870,19 @@ VLANClientState *qemu_new_vlan_client(VLANState *vlan,
     return vc;
 }
 
+void qemu_del_vlan_client(VLANClientState *vc)
+{
+    VLANClientState **pvc = &vc->vlan->first_client;
+
+    while (*pvc != NULL)
+        if (*pvc == vc) {
+            *pvc = vc->next;
+            free(vc);
+            break;
+        } else
+            pvc = &(*pvc)->next;
+}
+
 int qemu_can_send_packet(VLANClientState *vc1)
 {
     VLANState *vlan = vc1->vlan;