diff options
Diffstat (limited to 'tools/xenmgr/lib/server')
-rwxr-xr-x | tools/xenmgr/lib/server/blkif.py | 28 | ||||
-rwxr-xr-x | tools/xenmgr/lib/server/netif.py | 13 |
2 files changed, 29 insertions, 12 deletions
diff --git a/tools/xenmgr/lib/server/blkif.py b/tools/xenmgr/lib/server/blkif.py index ae2736da43..7ffa35179d 100755 --- a/tools/xenmgr/lib/server/blkif.py +++ b/tools/xenmgr/lib/server/blkif.py @@ -34,9 +34,9 @@ class BlkifControllerFactory(controller.ControllerFactory): return d def setControlDomain(self, dom): - if self.channel: - self.deregisterChannel() - self.attached = 0 + if self.dom == dom: return + self.deregisterChannel() + self.attached = 0 self.dom = dom self.registerChannel() # @@ -44,6 +44,9 @@ class BlkifControllerFactory(controller.ControllerFactory): # xend.blkif.recovery = True #xend.blkif.be_port = xend.main.port_from_dom(dom) + def getControlDomain(self): + return self.dom + def recv_be_create(self, msg, req): #print 'recv_be_create>' val = unpackMsg('blkif_be_create_t', msg) @@ -81,15 +84,20 @@ class BlkifControllerFactory(controller.ControllerFactory): blkif = self.getInstanceByDom(dom) if blkif: blkif.reattach_device(vdev) + self.attached = self.devices_attached() + if self.attached: + self.reattached() + + def devices_attached(self): + """Check if all devices are attached. + """ attached = 1 for blkif in self.getInstances(): if not blkif.attached: attached = 0 break - self.attached = attached - if self.attached: - self.reattached() - + return attached + def reattached(self): for blkif in self.getInstances(): blkif.reattached() @@ -149,12 +157,16 @@ class BlkifController(controller.Controller): return self.factory.addDeferred() def detach(self): + """Detach all devices, when the back-end control domain has changed. + """ self.attached = 0 for dev in self.devices.values(): dev.attached = 0 self.send_be_vbd_create(vdev) def reattach_device(self, vdev): + """Reattach a device, when the back-end control domain has changed. + """ dev = self.devices[vdev] dev.attached = 1 attached = 1 @@ -166,6 +178,8 @@ class BlkifController(controller.Controller): return self.attached def reattached(self): + """All devices have been reattached after the back-end control domain has changed. + """ msg = packMsg('blkif_fe_interface_status_changed_t', { 'handle' : 0, 'status' : BLKIF_INTERFACE_STATUS_DISCONNECTED}) diff --git a/tools/xenmgr/lib/server/netif.py b/tools/xenmgr/lib/server/netif.py index 7403054409..13bdd96486 100755 --- a/tools/xenmgr/lib/server/netif.py +++ b/tools/xenmgr/lib/server/netif.py @@ -35,6 +35,7 @@ class NetifControllerFactory(controller.ControllerFactory): def setControlDomain(self, dom): """Set the 'back-end' device driver domain. """ + if self.dom == dom: return self.deregisterChannel() self.attached = 0 self.dom = dom @@ -44,7 +45,9 @@ class NetifControllerFactory(controller.ControllerFactory): # xend.netif.recovery = True # xend.netif.be_port = xend.main.port_from_dom(dom) # - pass + + def getControlDomain(self): + return self.dom def recv_be_create(self, msg, req): self.callDeferred(0) @@ -64,6 +67,8 @@ class NetifControllerFactory(controller.ControllerFactory): val = unpackMsg('netif_be_driver_status_changed_t', msg) status = val['status'] if status == NETIF_DRIVER_STATUS_UP and not self.attached: + # If we are not attached the driver domain was changed, and + # this signals the new driver domain is ready. for netif in self.getInstances(): netif.reattach_devices() self.attached = 1 @@ -149,6 +154,8 @@ class NetifController(controller.Controller): return d def reattach_devices(self): + """Reattach all devices when the back-end control domain has changed. + """ d = self.factory.addDeferred() self.send_be_create(vif) self.attach_fe_devices(0) @@ -182,10 +189,6 @@ class NetifController(controller.Controller): 'rx_shmem_frame' : val['rx_shmem_frame'] }) self.factory.writeRequest(msg) - #def recv_fe_interface_status_changed(self): - # print 'recv_fe_interface_status_changed>' - # pass - def send_interface_connected(self, vif): dev = self.devices[vif] msg = packMsg('netif_fe_interface_status_changed_t', |