On 04/14/2014 02:51 AM, Xu Wang wrote:
于 2014年04月05日 00:12, John Ferlan 写道:
> Add support to handle a controller device variantly based up on the
> libvirt-cim revision value
>
> Signed-off-by: John Ferlan <jferlan(a)redhat.com>
> ---
> suites/libvirt-cim/lib/XenKvmLib/devices.py | 6 ++++
> suites/libvirt-cim/lib/XenKvmLib/logicaldevices.py | 2 +-
> suites/libvirt-cim/lib/XenKvmLib/rasd.py | 25 ++++++++++++++
> suites/libvirt-cim/lib/XenKvmLib/vsms.py | 24 +++++++++++++
> suites/libvirt-cim/lib/XenKvmLib/vxml.py | 39 +++++++++++++++++-----
> 5 files changed, 86 insertions(+), 10 deletions(-)
>
> diff --git a/suites/libvirt-cim/lib/XenKvmLib/devices.py
b/suites/libvirt-cim/lib/XenKvmLib/devices.py
> index 0ddccbb..5f26fa9 100755
> --- a/suites/libvirt-cim/lib/XenKvmLib/devices.py
> +++ b/suites/libvirt-cim/lib/XenKvmLib/devices.py
> @@ -33,6 +33,7 @@ from XenKvmLib.enumclass import EnumInstances
>
> graphics_dev_rev = 725
> input_dev_rev = 745
> +controller_dev_rev = 1310
>
> def get_class(classname):
> return eval(classname)
> @@ -99,6 +100,8 @@ def dev_cn_to_rasd_cn(dev_cn, virt):
> return get_typed_class(virt,
"GraphicsResourceAllocationSettingData")
> elif dev_cn.find('PointingDevice') >= 0:
> return get_typed_class(virt,
"InputResourceAllocationSettingData")
> + elif dev_cn.find('Controller') >= 0:
> + return get_typed_class(virt,
"ControllerResourceAllocationSettingData")
> else:
> return None
>
> @@ -112,6 +115,9 @@ def enum_dev(virt, ip):
> if curr_cim_rev >= input_dev_rev:
> dev_list.append('PointingDevice')
>
> + if curr_cim_rev >= controller_dev_rev and virt == 'KVM':
> + dev_list.append('Controller')
> +
> dev_insts = {}
>
> try:
> diff --git a/suites/libvirt-cim/lib/XenKvmLib/logicaldevices.py
b/suites/libvirt-cim/lib/XenKvmLib/logicaldevices.py
> index 744e864..5db36ca 100644
> --- a/suites/libvirt-cim/lib/XenKvmLib/logicaldevices.py
> +++ b/suites/libvirt-cim/lib/XenKvmLib/logicaldevices.py
> @@ -57,7 +57,7 @@ def spec_err(fieldvalue, field_list, fieldname):
>
> def verify_device_values(assoc_info, list_values, virt='Xen'):
> dev_cnames = ['LogicalDisk', 'Memory', 'NetworkPort',
'Processor', \
> - 'DisplayController', 'PointingDevice']
> + 'DisplayController', 'PointingDevice',
'Controller']
> for i in range(len(dev_cnames)):
> dev_cnames[i] = get_typed_class(virt, dev_cnames[i])
>
> diff --git a/suites/libvirt-cim/lib/XenKvmLib/rasd.py
b/suites/libvirt-cim/lib/XenKvmLib/rasd.py
> index 4d4240a..21dd7e4 100644
> --- a/suites/libvirt-cim/lib/XenKvmLib/rasd.py
> +++ b/suites/libvirt-cim/lib/XenKvmLib/rasd.py
> @@ -40,6 +40,7 @@ dasd_cn = 'DiskResourceAllocationSettingData'
> masd_cn = 'MemResourceAllocationSettingData'
> dcrasd_cn = 'GraphicsResourceAllocationSettingData'
> irasd_cn = 'InputResourceAllocationSettingData'
> +ctlrasd_cn = 'ControllerResourceAllocationSettingData'
> dpasd_cn = 'DiskPoolResourceAllocationSettingData'
> npasd_cn = 'NetPoolResourceAllocationSettingData'
> svrasd_cn = 'StorageVolumeResourceAllocationSettingData'
> @@ -51,6 +52,7 @@ netcn = 'NetworkPort'
> diskcn = 'LogicalDisk'
> dccn = 'DisplayController'
> pdcn = 'PointingDevice'
> +ctlcn = 'Controller'
>
> libvirt_rasd_storagepool_changes = 934
>
> @@ -65,12 +67,14 @@ def rasd_init_list(vsxml, virt, t_disk, t_dom, t_mac, t_mem,
server):
> disk_cn = get_typed_class(virt, diskcn)
> dc_cn = get_typed_class(virt, dccn)
> pd_cn = get_typed_class(virt, pdcn)
> + ctl_cn = get_typed_class(virt, ctlcn)
>
> in_list = { 'proc' : proc_cn,
> 'mem' : mem_cn,
> 'net' : net_cn,
> 'disk' : disk_cn,
> 'display' : dc_cn,
> + 'controller' : ctl_cn,
> 'point' : pd_cn
> }
> try:
> @@ -113,6 +117,18 @@ def rasd_init_list(vsxml, virt, t_disk, t_dom, t_mac, t_mem,
server):
> dc_cn : {
> "InstanceID" : "%s/%s"
%(t_dom, "vnc")
> },
> + # There can be more than one controller defined for
> + # any system - usually there are 3, one each for usb,
> + # pci, and ide. The InstanceID is formatted using
> + # the string "controller" and the type/string of
the
> + # controller, and the index id found. That index can
> + # vary. Thus our verify_controllerrasd_values will
> + # just ensure the "base" is valid - that is the
> + # guest name and "controller" string.
> + ctl_cn : {
> + "InstanceID" : "%s/%s:" \
> + %(t_dom, "controller")
> + },
> pd_cn : {
> "InstanceID" : point_device
> }
> @@ -143,6 +159,15 @@ def InstId_err(assoc_info, list):
> logger.error("Returned %s instead of %s",
> assoc_info['InstanceID'], list['InstanceID'])
>
> +def verify_controllerrasd_values(assoc_info, controllerrasd_list):
> + status = PASS
> + print 'assoc', assoc_info['InstanceID']
> + print 'ctrlr', controllerrasd_list['InstanceID']
> + if controllerrasd_list['InstanceID'] not in
assoc_info['InstanceID']:
> + InstId_err(assoc_info, controllerrasd_list)
> + status = FAIL
> + return status
> +
> def verify_displayrasd_values(assoc_info, displayrasd_list):
> status = PASS
> if assoc_info['InstanceID'] != displayrasd_list['InstanceID']:
> diff --git a/suites/libvirt-cim/lib/XenKvmLib/vsms.py
b/suites/libvirt-cim/lib/XenKvmLib/vsms.py
> index d7f33f9..3da309c 100755
> --- a/suites/libvirt-cim/lib/XenKvmLib/vsms.py
> +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms.py
> @@ -36,6 +36,7 @@ RASD_TYPE_DISK = 17
> RASD_TYPE_GRAPHICS = 24
> RASD_TYPE_INPUT = 13
> RASD_TYPE_STOREVOL = 32768
> +RASD_TYPE_CONTROLLER = 32771
>
> VIRT_DISK_TYPE_DISK = 0
> VIRT_DISK_TYPE_CDROM = 1
> @@ -324,6 +325,29 @@ class
LXC_InputResourceAllocationSettingData(CIM_InputResourceAllocationSettingD
> def get_iasd_class(virt):
> pass
>
> +class CIM_ControllerResourceAllocationSettingData(CIMClassMOF):
> + def __init__(self, name, ctl_sub_type=None, ctl_index=-1, ctl_model=None):
> + self.InstanceID = '%s/controller:' % name
> + self.ResourceType = RASD_TYPE_CONTROLLER
> +
> + if ctl_sub_type is not None:
> + self.ResourceSubType = ctl_sub_type
> + self.InstanceID += '%s' % ctl_sub_type
> +
> + if ctl_index >= 0:
> + self.Index = ctl_index
> + self.InstanceID += ':%d' % ctl_index
> +
> + if ctl_model is not None:
> + self.Model = ctl_model
> +
> +class
KVM_ControllerResourceAllocationSettingData(CIM_ControllerResourceAllocationSettingData):
> + pass
> +
> +@eval_cls('ControllerResourceAllocationSettingData')
> +def get_ctlasd_class(virt):
> + pass
> +
> def default_vssd_rasd_str(dom_name='test_domain',
> disk_dev='xvda',
> disk_source=const.Xen_disk_path,
> diff --git a/suites/libvirt-cim/lib/XenKvmLib/vxml.py
b/suites/libvirt-cim/lib/XenKvmLib/vxml.py
> index 74c4f23..ad80aae 100644
> --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py
> +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py
> @@ -53,6 +53,8 @@ from XenKvmLib.const import get_provider_version
>
> vsms_graphics_sup = 763
> vsms_inputdev_sup = 771
> +vsms_controller_sup = 1310
> +
>
> class XMLClass:
> xml_string = ""
> @@ -598,7 +600,8 @@ class VirtCIM:
> def __init__(self, virt, dom_name, uuid, pae, acpi, apic, disk_dev,
> disk_source, net_type, net_name, net_mac, vcpus, mem,
> mem_allocunits, emu_type, grstype, ip,
> - is_ipv6_only, port_num, kmap, irstype, btype, vnc_passwd):
> + is_ipv6_only, port_num, kmap, irstype, btype, vnc_passwd,
> + ctltype, ctlindex, ctlmodel):
> self.virt = virt
> self.domain_name = dom_name
> self.err_rc = None
> @@ -629,6 +632,14 @@ class VirtCIM:
> self.iasd = vsms.get_iasd_class(virt)(name=dom_name,
> res_sub_type=irstype,
> bus_type=btype)
> + if virt == 'KVM':
> + self.ctlasd = vsms.get_ctlasd_class(virt)(name=dom_name,
> + ctl_sub_type=ctltype,
> + ctl_index=ctlindex,
> + ctl_model=ctlmodel)
> + else:
> + self.ctlasd = None
> +
> self.res_settings = []
>
> def cim_define(self, ip, ref_conf=None):
> @@ -658,6 +669,9 @@ class VirtCIM:
> if self.iasd is not None:
> res_settings.append(str(self.iasd))
>
> + if curr_cim_rev > vsms_controller_sup and self.ctlasd is not None:
> + res_settings.append(str(self.ctlasd))
> +
Here I got a similar error, curr_cim_rev=1309 but
vsms_controller_sup=1310. Hence
I got the following result,
# CIM_NS=root/virt CIM_USER=root CIM_PASS=****** ./runtests libvirt-cim
-i localhost -c -d -v KVM -g RASD -t 03_rasd_errs.py
Starting test suite: libvirt-cim
Cleaned log files.
Testing KVM hypervisor
--------------------------------------------------------------------
RASD - 03_rasd_errs.py: FAIL
ERROR - Expected 6 RASDs, got 7
--------------------------------------------------------------------
Do I need to update value of @curren_cim_rev and how to change it?
Thanks,
Xu Wang
That's probably the cause - my response in the controller patches stream
should help - but essentially it's running autoconfiscate.sh and then
rebuilding/reinstalling the repo
John
> if ref_conf is None:
> ref_conf = ' '
>
> @@ -849,7 +863,8 @@ class XenXML(VirtXML, VirtCIM):
> emu_type=None, grstype="vnc", address=None,
> is_ipv6_only=None,
> port_num='-1', keymap="en-us",
irstype="mouse",
> - btype="xen", vnc_passwd=None):
> + btype="xen", vnc_passwd=None,
> + ctltype=None, ctlindex=-1, ctlmodel=None):
> if not (os.path.exists(const.Xen_kernel_path) \
> and os.path.exists(const.Xen_init_path)):
> logger.error('ERROR: Either the kernel image '
> @@ -863,7 +878,7 @@ class XenXML(VirtXML, VirtCIM):
> disk_file_path, ntype, net_name, mac, vcpus, mem,
> mem_allocunits, emu_type, grstype, address,
> is_ipv6_only, port_num, keymap, irstype, btype,
> - vnc_passwd)
> + vnc_passwd, ctltype, ctlindex, ctlmodel)
>
> def _os(self, os_kernel, os_initrd):
> os = self.get_node('/domain/os')
> @@ -920,7 +935,10 @@ class KVMXML(VirtXML, VirtCIM):
> emu_type=None, grstype="vnc", address=None,
> is_ipv6_only=None,
> port_num='-1', keymap="en-us",
irstype="mouse",
> - btype="ps2", vnc_passwd=None):
> + btype="ps2", vnc_passwd=None,
> + ctltype="pci", ctlindex=0,
ctlmodel="pci-root"):
> + # Optionally the following works too:
> + #ctltype="usb", ctlindex=0, ctlmodel=None):
> if not os.path.exists(disk_file_path):
> logger.error('Error: Disk image %s does not exist',
disk_file_path)
> sys.exit(1)
> @@ -929,7 +947,7 @@ class KVMXML(VirtXML, VirtCIM):
> disk_file_path, ntype, net_name, mac, vcpus, mem,
> mem_allocunits, emu_type, grstype, address,
> is_ipv6_only, port_num, keymap, irstype, btype,
> - vnc_passwd)
> + vnc_passwd, ctltype, ctlindex, ctlmodel)
> self._os()
> self._devices(const.KVM_default_emulator, ntype,
> disk_file_path, disk, mac, net_name)
> @@ -983,7 +1001,8 @@ class XenFVXML(VirtXML, VirtCIM):
> emu_type=None, grstype="vnc",
> address=None, is_ipv6_only=None, port_num='-1',
> keymap="en-us",
> - irstype="mouse", btype="ps2",
vnc_passwd=None):
> + irstype="mouse", btype="ps2",
vnc_passwd=None,
> + ctltype=None, ctlindex=-1, ctlmodel=None):
> if not os.path.exists(disk_file_path):
> logger.error('Error: Disk image %s does not exist',
disk_file_path)
> sys.exit(1)
> @@ -992,7 +1011,8 @@ class XenFVXML(VirtXML, VirtCIM):
> disk_file_path, ntype, net_name, mac, vcpus, mem,
> mem_allocunits, emu_type, grstype, address,
> is_ipv6_only, port_num,
> - keymap, irstype, btype, vnc_passwd)
> + keymap, irstype, btype, vnc_passwd,
> + ctltype, ctlindex, ctlmodel)
> self._os(const.XenFV_default_loader)
> self._devices(const.XenFV_default_emulator,
> ntype, mac, net_name, disk_file_path, disk)
> @@ -1036,7 +1056,8 @@ class LXCXML(VirtXML, VirtCIM):
> tty=const.LXC_default_tty, grstype="vnc",
> address=None, is_ipv6_only=None, port_num='-1',
> keymap="en-us",
> - irstype="mouse", btype="usb",
vnc_passwd=None):
> + irstype="mouse", btype="usb",
vnc_passwd=None,
> + ctltype=None, ctlindex=-1, ctlmodel=None):
> VirtXML.__init__(self, 'lxc', test_dom, set_uuid(), mem, vcpus)
> # pae, acpi and apic parameters doesn't make sense here, so we
> # statically set them to False (a.k.a. ignore them)
> @@ -1045,7 +1066,7 @@ class LXCXML(VirtXML, VirtCIM):
> ntype, net_name, mac, vcpus, mem,
> const.default_mallocunits, None, grstype,
> address, is_ipv6_only, port_num, keymap, irstype,
> - btype, vnc_passwd)
> + btype, vnc_passwd, ctltype, ctlindex, ctlmodel)
> self._os(const.LXC_init_path)
> self._devices(const.LXC_default_emulator, mac, ntype, net_name,
const.LXC_default_tty)
> self.create_lxc_file(CIM_IP, const.LXC_init_path)
_______________________________________________
Libvirt-cim mailing list
Libvirt-cim(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvirt-cim