mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
bitkeeper revision 1.1236.51.2 (424d4e45s3_LSUrubUDpgLTFNoQ2xw)
add support for refreshing vbds Signed-off-by: Vincent Hanquez <vincent@xensource.com>
This commit is contained in:
1 parent
7d2cb3e380
commit
4a0b5ba481
6 files changed
+75
No files matched your search
@@ -308,6 +308,12 @@ class Xend:
|
||||
{'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',
|
||||
|
||||
@@ -687,6 +687,18 @@ class XendDomain:
|
||||
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.
|
||||
|
||||
@@ -551,6 +551,16 @@ class XendDomainInfo:
|
||||
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 @@ class XendDomainInfo:
|
||||
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.
|
||||
|
||||
@@ -131,6 +131,14 @@ class SrvDomain(SrvDir):
|
||||
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'],
|
||||
|
||||
@@ -414,6 +414,10 @@ class BlkDev(controller.SplitDev):
|
||||
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.
|
||||
|
||||
|
||||
@@ -800,6 +800,28 @@ Create a virtual block device for a domain.
|
||||
|
||||
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'
|
||||
|
||||