Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/bouyer-xen2]: src/sys/arch/xen/xen When a virtual device is destroyed (e...
details: https://anonhg.NetBSD.org/src/rev/432a91efaf3d
branches: bouyer-xen2
changeset: 571903:432a91efaf3d
user: bouyer <bouyer%NetBSD.org@localhost>
date: Tue Mar 08 19:33:01 2005 +0000
description:
When a virtual device is destroyed (e.g. because a domain is destroyed),
properly free ressources and unregister callbacks.
diffstat:
sys/arch/xen/xen/xbdback.c | 26 +++++++++++++++++++++++---
sys/arch/xen/xen/xennetback.c | 17 +++++++++++++++--
2 files changed, 38 insertions(+), 5 deletions(-)
diffs (102 lines):
diff -r 780651fd0372 -r 432a91efaf3d sys/arch/xen/xen/xbdback.c
--- a/sys/arch/xen/xen/xbdback.c Tue Mar 08 19:31:39 2005 +0000
+++ b/sys/arch/xen/xen/xbdback.c Tue Mar 08 19:33:01 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xbdback.c,v 1.1.2.1 2005/02/16 13:58:30 bouyer Exp $ */
+/* $NetBSD: xbdback.c,v 1.1.2.2 2005/03/08 19:33:01 bouyer Exp $ */
/*
* Copyright (c) 2005 Manuel Bouyer.
@@ -279,6 +279,8 @@
{
blkif_be_disconnect_t *req =
(blkif_be_disconnect_t *)&msg->msg[0];
+ vaddr_t ring_addr;
+
if (msg->length != sizeof(blkif_be_disconnect_t))
goto error;
xbdi = xbdif_lookup(req->domid, req->blkif_handle);
@@ -286,7 +288,13 @@
req->status = BLKIF_BE_STATUS_INTERFACE_NOT_FOUND;
goto end;
}
- req->status = BLKIF_BE_STATUS_ERROR;
+ hypervisor_disable_irq(xbdi->irq);
+ event_remove_handler(xbdi->irq, xbdback_evthandler, xbdi);
+ unbind_evtchn_to_irq(xbdi->evtchn);
+ ring_addr = (vaddr_t)xbdi->blk_ring;
+ pmap_remove(pmap_kernel(), ring_addr, ring_addr + PAGE_SIZE);
+ uvm_km_free(kernel_map, ring_addr, PAGE_SIZE);
+ req->status = BLKIF_BE_STATUS_OKAY;
break;
}
case CMSG_BLKIF_BE_VBD_CREATE:
@@ -330,6 +338,14 @@
req->status = BLKIF_BE_STATUS_VBD_NOT_FOUND;
goto end;
}
+ if (vbd->size) {
+ printf("xbd backend: detach device %s%d%c "
+ "for domain %d\n", devsw_blk2name(major(vbd->dev)),
+ DISKUNIT(vbd->dev), DISKPART(vbd->dev) + 'a',
+ xbdi->domid);
+ vbd->start = vbd->size = vbd->dev = 0;
+ vn_close(vbd->vp, FREAD, NOCRED, NULL);
+ }
SLIST_REMOVE(&xbdi->vbds, vbd, xbd_vbd, next);
free(vbd, M_DEVBUF);
@@ -428,10 +444,14 @@
req->status = BLKIF_BE_STATUS_VBD_NOT_FOUND;
goto end;
}
- if (vbd->size != 0) {
+ if (vbd->size == 0) {
req->status = BLKIF_BE_STATUS_VBD_NOT_FOUND;
goto end;
}
+ printf("xbd backend: detach device %s%d%c "
+ "for domain %d\n", devsw_blk2name(major(vbd->dev)),
+ DISKUNIT(vbd->dev), DISKPART(vbd->dev) + 'a',
+ xbdi->domid);
vbd->start = vbd->size = vbd->dev = 0;
vn_close(vbd->vp, FREAD, NOCRED, NULL);
req->status = BLKIF_BE_STATUS_OKAY;
diff -r 780651fd0372 -r 432a91efaf3d sys/arch/xen/xen/xennetback.c
--- a/sys/arch/xen/xen/xennetback.c Tue Mar 08 19:31:39 2005 +0000
+++ b/sys/arch/xen/xen/xennetback.c Tue Mar 08 19:33:01 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xennetback.c,v 1.1.2.2 2005/02/18 18:37:17 bouyer Exp $ */
+/* $NetBSD: xennetback.c,v 1.1.2.3 2005/03/08 19:33:01 bouyer Exp $ */
/*
* Copyright (c) 2005 Manuel Bouyer.
@@ -351,6 +351,8 @@
{
netif_be_disconnect_t *req =
(netif_be_disconnect_t *)&msg->msg[0];
+ vaddr_t ring_addr;
+
if (msg->length != sizeof(netif_be_disconnect_t))
goto error;
xneti = xnetif_lookup(req->domid, req->netif_handle);
@@ -358,7 +360,18 @@
req->status = NETIF_BE_STATUS_INTERFACE_NOT_FOUND;
goto end;
}
- req->status = NETIF_BE_STATUS_ERROR;
+ hypervisor_disable_irq(xneti->xni_irq);
+ event_remove_handler(xneti->xni_irq,
+ xennetback_evthandler, xneti);
+ unbind_evtchn_to_irq(xneti->xni_evtchn);
+ ring_addr = (vaddr_t)xneti->xni_rxring;
+ pmap_remove(pmap_kernel(), ring_addr, ring_addr + PAGE_SIZE);
+ uvm_km_free(kernel_map, ring_addr, PAGE_SIZE);
+ ring_addr = (vaddr_t)xneti->xni_txring;
+ pmap_remove(pmap_kernel(), ring_addr, ring_addr + PAGE_SIZE);
+ uvm_km_free(kernel_map, ring_addr, PAGE_SIZE);
+
+ req->status = NETIF_BE_STATUS_OKAY;
break;
}
default:
Home |
Main Index |
Thread Index |
Old Index