spdkcli: virtio bdev management.

Change-Id: Iae6feaf9f51f32e20376a539e46700f07783419e
Signed-off-by: Karol Latecki <karol.latecki@intel.com>
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/417683
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Maciej Szwed <maciej.szwed@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Karol Latecki 2018-07-03 13:25:11 +02:00 committed by Jim Harris
parent 5e5cc5ac9c
commit ea03582d85
2 changed files with 88 additions and 0 deletions

View File

@ -58,6 +58,8 @@ class UIBdevs(UINode):
UIPmemBdev(self)
UIRbdBdev(self)
UIiSCSIBdev(self)
UIVirtioBlkBdev(self)
UIVirtioScsiBdev(self)
def ui_command_delete(self, name):
"""
@ -426,6 +428,60 @@ class UIiSCSIBdev(UIBdev):
self.refresh()
class UIVirtioBlkBdev(UIBdev):
def __init__(self, parent):
UIBdev.__init__(self, "virtioblk_disk", parent)
def ui_command_create(self, name, trtype, traddr,
vq_count=None, vq_size=None):
vq_count = self.ui_eval_param(vq_count, "number", None)
vq_size = self.ui_eval_param(vq_size, "number", None)
ret = self.get_root().create_virtio_dev(name=name,
trtype=trtype,
traddr=traddr,
dev_type="blk",
vq_count=vq_count,
vq_size=vq_size)
self.shell.log.info(ret)
self.get_root().refresh()
self.refresh()
class UIVirtioScsiBdev(UIBdev):
def __init__(self, parent):
UIBdev.__init__(self, "virtioscsi_disk", parent)
def refresh(self):
self._children = set([])
for bdev in self.get_root().get_virtio_scsi_devs():
UIVirtioScsiBdevObj(bdev, self)
def ui_command_create(self, name, trtype, traddr,
vq_count=None, vq_size=None):
vq_count = self.ui_eval_param(vq_count, "number", None)
vq_size = self.ui_eval_param(vq_size, "number", None)
ret = self.get_root().create_virtio_dev(name=name,
trtype=trtype,
traddr=traddr,
dev_type="scsi",
vq_count=vq_count,
vq_size=vq_size)
self.shell.log.info(ret)
self.get_root().refresh()
self.refresh()
def ui_command_delete(self, name):
self.get_root().remove_virtio_scsi_bdev(name=name)
self.get_root().refresh()
self.refresh()
class UIBdevObj(UINode):
def __init__(self, bdev, parent):
self.bdev = bdev
@ -460,6 +516,25 @@ class UIBdevObj(UINode):
return info, True
class UIVirtioScsiBdevObj(UIBdevObj):
def __init__(self, bdev, parent):
UIBdevObj.__init__(self, bdev, parent)
self.refresh()
def refresh(self):
self._children = set([])
for bdev in self.get_root().get_bdevs("virtio_scsi_disk"):
if self.bdev.name in bdev.name:
UIBdevObj(bdev, self)
def summary(self):
if "socket" in self.bdev.virtio.keys():
info = self.bdev.virtio["socket"]
if "pci_address" in self.bdev.virtio.keys():
info = self.bdev.virtio["pci_address"]
return info, True
class UILvsObj(UINode):
def __init__(self, lvs, parent):
UINode.__init__(self, lvs.name, parent)

View File

@ -123,6 +123,19 @@ class UIRoot(UINode):
response = rpc.bdev.construct_rbd_bdev(self.client, **kwargs)
return response
def create_virtio_dev(self, **kwargs):
response = rpc.vhost.construct_virtio_dev(self.client, **kwargs)
return self.print_array(response)
def remove_virtio_scsi_bdev(self, **kwargs):
response = rpc.vhost.remove_virtio_scsi_bdev(self.client, **kwargs)
return response
def get_virtio_scsi_devs(self):
for bdev in rpc.vhost.get_virtio_scsi_devs(self.client):
test = Bdev(bdev)
yield test
def list_vhost_ctrls(self):
self.current_vhost_ctrls = rpc.vhost.get_vhost_controllers(self.client)