[PATCH] [TEST] #3 LXC support using DefineSystem & VSMS.01

# HG changeset patch # User Zhengang Li <lizg@cn.ibm.com> # Date 1212545171 -28800 # Node ID 277b821188f247baaa02f0668915a57f9e8c83b1 # Parent 5c77329cb53e6340cd6ddbf9c044462fb994eb88 [TEST] #3 LXC support using DefineSystem & VSMS.01 Updates: .2# add the missing address property .3# - Skip network and processor device - Use different values for mountpoint and source Signed-off-by: Zhengang Li <lizg@cn.ibm.com> diff -r 5c77329cb53e -r 277b821188f2 suites/libvirt-cim/cimtest/VirtualSystemManagementService/01_definesystem_name.py --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/01_definesystem_name.py Fri May 30 14:26:38 2008 +0800 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/01_definesystem_name.py Wed Jun 04 10:06:11 2008 +0800 @@ -30,7 +30,7 @@ from CimTest.Globals import do_main from CimTest.Globals import logger -SUPPORTED_TYPES = ['Xen', 'KVM', 'XenFV'] +SUPPORTED_TYPES = ['Xen', 'KVM', 'XenFV', 'LXC'] default_dom = 'test_domain' @do_main(SUPPORTED_TYPES) diff -r 5c77329cb53e -r 277b821188f2 suites/libvirt-cim/lib/XenKvmLib/const.py --- a/suites/libvirt-cim/lib/XenKvmLib/const.py Fri May 30 14:26:38 2008 +0800 +++ b/suites/libvirt-cim/lib/XenKvmLib/const.py Wed Jun 04 10:06:11 2008 +0800 @@ -85,3 +85,5 @@ #vxml.LXCXML LXC_init_path = os.path.join(_image_dir, 'cimtest_lxc_init') LXC_default_tty = '/dev/ptmx' +LXC_default_mp = '/tmp' +LXC_default_source = '/tmp/lxc_files' diff -r 5c77329cb53e -r 277b821188f2 suites/libvirt-cim/lib/XenKvmLib/vsms.py --- a/suites/libvirt-cim/lib/XenKvmLib/vsms.py Fri May 30 14:26:38 2008 +0800 +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms.py Wed Jun 04 10:06:11 2008 +0800 @@ -102,6 +102,8 @@ self.isFullVirt = (type == 'KVM' or virt == 'XenFV') if self.isFullVirt: self.BootDevice = 'hd' + elif type == 'LXC': + self.InitPath = const.LXC_init_path else: self.Bootloader = live.bootloader(Globals.CIM_IP, 0) self.BootloaderArgs = '' @@ -113,6 +115,9 @@ pass class KVM_VirtualSystemSettingData(CIM_VirtualSystemSettingData): + pass + +class LXC_VirtualSystemSettingData(CIM_VirtualSystemSettingData): pass @eval_cls('VirtualSystemSettingData') @@ -134,6 +139,12 @@ class KVM_DiskResourceAllocationSettingData(CIM_DiskResourceAllocationSettingData): pass + +class LXC_DiskResourceAllocationSettingData(CIMClassMOF): + def __init__(self, mountpoint, source, name): + self.MountPoint = mountpoint + self.Address = source + self.InstanceID = '%s/%s' % (name, mountpoint) @eval_cls('DiskResourceAllocationSettingData') def get_dasd_class(virt): @@ -157,6 +168,9 @@ class KVM_NetResourceAllocationSettingData(CIM_NetResourceAllocationSettingData): pass +class LXC_NetResourceAllocationSettingData(CIM_NetResourceAllocationSettingData): + pass + @eval_cls('NetResourceAllocationSettingData') def get_nasd_class(virt): pass @@ -175,6 +189,9 @@ pass class KVM_ProcResourceAllocationSettingData(CIM_ProcResourceAllocationSettingData): + pass + +class LXC_ProcResourceAllocationSettingData(CIM_ProcResourceAllocationSettingData): pass @eval_cls('ProcResourceAllocationSettingData') @@ -197,6 +214,9 @@ class KVM_MemResourceAllocationSettingData(CIM_MemResourceAllocationSettingData): pass +class LXC_MemResourceAllocationSettingData(CIM_MemResourceAllocationSettingData): + pass + @eval_cls('MemResourceAllocationSettingData') def get_masd_class(virt): pass @@ -212,17 +232,32 @@ class_vssd = get_vssd_class(virt) vssd = class_vssd(name=dom_name, virt=virt) - class_dasd = get_dasd_class(virt) - if virt == 'KVM': - disk_dev = 'hda' - disk_source = const.KVM_disk_path - elif virt == 'XenFV': - disk_dev = 'hda' - disk_source = const.XenFV_disk_path - d = class_dasd( - dev=disk_dev, - source=disk_source, + # LXC only takes disk and memory device for now. + # Only disk __init__ takes different params. + if virt == 'LXC': + d = LXC_DiskResourceAllocationSettingData( + mountpoint=const.LXC_default_mp, + source=const.LXC_default_source, name=dom_name) + else: + class_dasd = get_dasd_class(virt) + if virt == 'KVM': + disk_dev = 'hda' + disk_source = const.KVM_disk_path + elif virt == 'XenFV': + disk_dev = 'hda' + disk_source = const.XenFV_disk_path + d = class_dasd( + dev=disk_dev, + source=disk_source, + name=dom_name) + + class_masd = get_masd_class(virt) + m = class_masd( + megabytes=mem_mb, name=dom_name) + if virt == 'LXC': + return vssd.mof(), [d.mof(), m.mof()] + class_nasd = get_nasd_class(virt) if virt == 'KVM': net_mac= const.KVM_default_mac @@ -236,10 +271,6 @@ p = class_pasd( vcpu=proc_vcpu, name=dom_name) - class_masd = get_masd_class(virt) - m = class_masd( - megabytes=mem_mb, - name=dom_name) return vssd.mof(), [d.mof(), n.mof(), p.mof(), m.mof()]

zli@linux.vnet.ibm.com wrote:
diff -r 5c77329cb53e -r 277b821188f2 suites/libvirt-cim/lib/XenKvmLib/const.py --- a/suites/libvirt-cim/lib/XenKvmLib/const.py Fri May 30 14:26:38 2008 +0800 +++ b/suites/libvirt-cim/lib/XenKvmLib/const.py Wed Jun 04 10:06:11 2008 +0800 @@ -85,3 +85,5 @@ #vxml.LXCXML LXC_init_path = os.path.join(_image_dir, 'cimtest_lxc_init') LXC_default_tty = '/dev/ptmx' +LXC_default_mp = '/tmp' +LXC_default_source = '/tmp/lxc_files'
The LXC_init_path used to be created by 'create_lxc_files' in vxml.py. It's not created here. But somehow libvirt shows me a running container even if the init_path file doesn't exist. The same with LXC_default_source. It's a non-exist directory. I am inclined to move the init_path and default_source to the place where xen/kvm kernel image and disk image is created. Then we don't need to create a init_path upon every test case execution. Thoughts? -- - Zhengang

Zhengang Li wrote:
zli@linux.vnet.ibm.com wrote:
diff -r 5c77329cb53e -r 277b821188f2 suites/libvirt-cim/lib/XenKvmLib/const.py --- a/suites/libvirt-cim/lib/XenKvmLib/const.py Fri May 30 14:26:38 2008 +0800 +++ b/suites/libvirt-cim/lib/XenKvmLib/const.py Wed Jun 04 10:06:11 2008 +0800 @@ -85,3 +85,5 @@ #vxml.LXCXML LXC_init_path = os.path.join(_image_dir, 'cimtest_lxc_init') LXC_default_tty = '/dev/ptmx' +LXC_default_mp = '/tmp' +LXC_default_source = '/tmp/lxc_files'
The LXC_init_path used to be created by 'create_lxc_files' in vxml.py. It's not created here. But somehow libvirt shows me a running container even if the init_path file doesn't exist.
I believe this is a bug in the containers support in libvirt. The container attempts to execute the script, but the execution fails. The ID of the container is the pid of the process the container executes to run the script. If you no longer see the pid in the ps output, then the container is not actually running.
The same with LXC_default_source. It's a non-exist directory.
I am inclined to move the init_path and default_source to the place where xen/kvm kernel image and disk image is created. Then we don't need to create a init_path upon every test case execution.
Thoughts?
Initially, I thought it'd be a bad idea to leave the script lying around. However, all the script does is run bash, so I don't think it will be a problem to live it lying around in /tmp. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (3)
-
Kaitlin Rupert
-
Zhengang Li
-
zli@linux.vnet.ibm.com