[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] add support for refreshing vbds



ChangeSet 1.1419.1.2, 2005/04/01 14:36:05+01:00, vh249@xxxxxxxxxxxxxxxxxxxxxx

        add support for refreshing vbds
        
        Signed-off-by: Vincent Hanquez <vincent@xxxxxxxxxxxxx>



 xend/XendClient.py       |    6 ++++++
 xend/XendDomain.py       |   12 ++++++++++++
 xend/XendDomainInfo.py   |   23 +++++++++++++++++++++++
 xend/server/SrvDomain.py |    8 ++++++++
 xend/server/blkif.py     |    4 ++++
 xm/main.py               |   22 ++++++++++++++++++++++
 6 files changed, 75 insertions(+)


diff -Nru a/tools/python/xen/xend/XendClient.py 
b/tools/python/xen/xend/XendClient.py
--- a/tools/python/xen/xend/XendClient.py       2005-04-01 09:03:05 -05:00
+++ b/tools/python/xen/xend/XendClient.py       2005-04-01 09:03:05 -05:00
@@ -308,6 +308,12 @@
                              {'op'      : 'device_create',
                               'config'  : fileof(config) })
 
+    def xend_domain_device_refresh(self, id, type, idx):
+        return self.xendPost(self.domainurl(id),
+                             {'op'      : 'device_refresh',
+                              'type'    : type,
+                              'idx'     : idx })
+
     def xend_domain_device_destroy(self, id, type, idx):
         return self.xendPost(self.domainurl(id),
                              {'op'      : 'device_destroy',
diff -Nru a/tools/python/xen/xend/XendDomain.py 
b/tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py       2005-04-01 09:03:05 -05:00
+++ b/tools/python/xen/xend/XendDomain.py       2005-04-01 09:03:05 -05:00
@@ -687,6 +687,18 @@
         self.update_domain(dominfo.id)
         return val
     
+    def domain_device_refresh(self, id, type, idx):
+        """Refresh a device.
+
+        @param id:  domain id
+        @param idx:  device index
+        @param type: device type
+        """
+        dominfo = self.domain_lookup(id)
+        self.refresh_schedule()
+        val = dominfo.device_refresh(type, idx)
+        self.update_domain(dominfo.id)
+        return val
 
     def domain_device_destroy(self, id, type, idx):
         """Destroy a device.
diff -Nru a/tools/python/xen/xend/XendDomainInfo.py 
b/tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   2005-04-01 09:03:05 -05:00
+++ b/tools/python/xen/xend/XendDomainInfo.py   2005-04-01 09:03:05 -05:00
@@ -551,6 +551,16 @@
         dl.append(dev)
         self.devices[type] = dl
 
+    def refresh_device(self, type, dev):
+        """Refresh a device to a virtual machine.
+
+        @param type: device type
+        @param dev:  device
+        """
+        dl = self.devices.get(type, [])
+        if dev in dl:
+            dl.refresh(dev)
+
     def remove_device(self, type, dev):
         """Remove a device from a virtual machine.
 
@@ -912,6 +922,19 @@
         old_index = self.config.index(old_full_config)
         self.config[old_index] = new_full_config
         return new_config
+
+    def device_refresh(self, type, idx):
+        """Refresh a device.
+
+        @param type: device type
+        @param idx:  device index
+        """
+        dev = self.get_device_by_index(type, idx)
+        if not dev:
+            raise VmError('invalid device: %s %s' % (type, idx))
+        devs = self.devices.get(type)
+        dev.refresh()
+        #self.refresh_device(type, dev)
         
     def device_destroy(self, type, idx):
         """Destroy a device.
diff -Nru a/tools/python/xen/xend/server/SrvDomain.py 
b/tools/python/xen/xend/server/SrvDomain.py
--- a/tools/python/xen/xend/server/SrvDomain.py 2005-04-01 09:03:05 -05:00
+++ b/tools/python/xen/xend/server/SrvDomain.py 2005-04-01 09:03:05 -05:00
@@ -131,6 +131,14 @@
         d = fn(req.args, {'dom': self.dom.id})
         return d
 
+    def op_device_refresh(self, op, req):
+        fn = FormFn(self.xd.domain_device_refresh,
+                    [['dom', 'str'],
+                     ['type', 'str'],
+                     ['idx', 'str']])
+        val = fn(req.args, {'dom': self.dom.id})
+        return val
+
     def op_device_destroy(self, op, req):
         fn = FormFn(self.xd.domain_device_destroy,
                     [['dom', 'str'],
diff -Nru a/tools/python/xen/xend/server/blkif.py 
b/tools/python/xen/xend/server/blkif.py
--- a/tools/python/xen/xend/server/blkif.py     2005-04-01 09:03:05 -05:00
+++ b/tools/python/xen/xend/server/blkif.py     2005-04-01 09:03:05 -05:00
@@ -414,6 +414,10 @@
             val.append(['index', self.index])
         return val
 
+    def refresh(self):
+        log.debug("Refreshing vbd domain=%d idx=%s", self.controller.dom, 
self.idx)
+        self.interfaceChanged()
+
     def destroy(self, change=0):
         """Destroy the device. If 'change' is true notify the front-end 
interface.
 
diff -Nru a/tools/python/xen/xm/main.py b/tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       2005-04-01 09:03:05 -05:00
+++ b/tools/python/xen/xm/main.py       2005-04-01 09:03:05 -05:00
@@ -800,6 +800,28 @@
 
 xm.prog(ProgVbdCreate)
 
+class ProgVbdRefresh(Prog):
+    group = 'vbd'
+    name  = 'vbd-refresh'
+    info = """Refresh a virtual block device for a domain"""
+
+    def help(self, args):
+        print args[0], "DOM DEV"
+        print """
+Refresh a virtual block device for a domain.
+
+  DEV     - idx field in the device information
+"""
+
+    def main(self, args):
+        if len(args) != 3: self.err("%s: Invalid argument(s)" % args[0])
+        dom = args[1]
+        dev = args[2]
+        server.xend_domain_device_refresh(dom, 'vbd', dev)
+
+xm.prog(ProgVbdRefresh)
+
+
 class ProgVbdDestroy(Prog):
     group = 'vbd'
     name = 'vbd-destroy'

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.