let error fmt = Logging.error "domains" fmt
let warn fmt = Logging.warn "domains" fmt
+let xc = Xenctrl.interface_open ()
+
type domains = {
eventchn: Event.t;
table: (Xenctrl.domid, Domain.t) Hashtbl.t;
| None -> ()
| Some x -> if x=dom then d := None) queue
-let cleanup xc doms =
+let cleanup doms =
let notify = ref false in
let dead_dom = ref [] in
let resume doms domid =
()
-let create xc doms domid mfn port =
+let create doms domid mfn port =
let interface = Xenctrl.map_foreign_range xc domid (Xenmmap.getpagesize()) mfn in
let dom = Domain.make domid mfn port interface doms.eventchn in
Hashtbl.add doms.table domid dom;
if Domains.exist domains domid then
Domains.find domains domid
else try
- let ndom = Xenctrl.with_intf (fun xc ->
- Domains.create xc domains domid mfn port) in
+ let ndom = Domains.create domains domid mfn port in
Connections.add_domain cons ndom;
Connections.fire_spec_watches cons "@introduceDomain";
ndom
let from_channel store cons doms chan =
(* don't let the permission get on our way, full perm ! *)
let op = Store.get_ops store Perms.Connection.full_rights in
- let xc = Xenctrl.interface_open () in
let domain_f domid mfn port =
let ndom =
if domid > 0 then
- Domains.create xc doms domid mfn port
+ Domains.create doms domid mfn port
else
Domains.create0 doms
in
op.Store.write path value;
op.Store.setperms path perms
in
- finally (fun () -> from_channel_f chan domain_f watch_f store_f)
- (fun () -> Xenctrl.interface_close xc)
+ from_channel_f chan domain_f watch_f store_f
let from_file store cons doms file =
let channel = open_in file in
(if cf.domain_init then [ Event.fd eventchn ] else [])
in
- let xc = Xenctrl.interface_open () in
-
let process_special_fds rset =
let accept_connection can_write fd =
let (cfd, addr) = Unix.accept fd in
debug "pending port %d" (Xeneventchn.to_int port);
finally (fun () ->
if Some port = eventchn.Event.virq_port then (
- let (notify, deaddom) = Domains.cleanup xc domains in
+ let (notify, deaddom) = Domains.cleanup domains in
List.iter (Connections.del_domain cons) deaddom;
if deaddom <> [] || notify then
Connections.fire_spec_watches cons "@releaseDomain"