[PATCH 0 of 3] [TEST] bundles of LXC support

patch 1 includes all the helper function changes for LXC tc running patch 2 adds LXCXML class, you can use it to define a lxc domain, also you can add more functions in it to support more devices patch 3 changes ComputerSystem.01&03 and related lib to reflect the lxc changes Signed-off-by: Guolian Yun <yunguol@cn.ibm.com>

# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1210744666 25200 # Node ID 935b2c485f8857ddb396efd729d5fc7ff7b41614 # Parent 06c87ac466e374f7ca5b7e3dd1923ee32f1ef2ce [TEST] add helpers function for LXC support Signed-off-by: Guolian Yun <yunguol@cn.ibm.com> diff -r 06c87ac466e3 -r 935b2c485f88 lib/CimTest/Globals.py --- a/lib/CimTest/Globals.py Tue May 13 06:07:27 2008 -0700 +++ b/lib/CimTest/Globals.py Tue May 13 22:57:46 2008 -0700 @@ -49,7 +49,7 @@ CIM_IP = os.getenv("CIM_IP") CIM_IP = os.getenv("CIM_IP") CIM_PORT = "5988" NM = "TEST LOG" -platform_sup = ["Xen", "KVM", "XenFV"] +platform_sup = ["Xen", "KVM", "XenFV", "LXC"] logging.basicConfig(filename='/dev/null') logger = logging.getLogger(NM) logging.PRINT = logging.DEBUG + 50 @@ -67,7 +67,7 @@ parser.add_option("-i", "--ip", dest="ip help="IP address of machine to test, default: localhost") parser.add_option("-v", "--virt", dest="virt", type="choice", choices=platform_sup, default="Xen", - help="Virt type, select from: 'Xen' & 'KVM' & 'XenFV', default: Xen") + help="Virt type, select from: 'Xen' & 'KVM' & 'XenFV' & 'LXC', default: Xen") parser.add_option("-d", "--debug-output", action="store_true", dest="debug", help="Duplicate the output to stderr") diff -r 06c87ac466e3 -r 935b2c485f88 lib/VirtLib/utils.py --- a/lib/VirtLib/utils.py Tue May 13 06:07:27 2008 -0700 +++ b/lib/VirtLib/utils.py Tue May 13 22:57:46 2008 -0700 @@ -161,5 +161,7 @@ def virt2uri(virt): return "xen:///" if virt == "KVM": return "qemu:///system" + if virt == "LXC": + return "lxc:///system" return "" diff -r 06c87ac466e3 -r 935b2c485f88 suites/libvirt-cim/lib/XenKvmLib/classes.py --- a/suites/libvirt-cim/lib/XenKvmLib/classes.py Tue May 13 06:07:27 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/classes.py Tue May 13 22:57:46 2008 -0700 @@ -19,7 +19,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -virt_types = ['Xen', 'KVM', 'XenFV'] +virt_types = ['Xen', 'KVM', 'XenFV', 'LXC'] def get_typed_class(virt, basename): if virt not in virt_types: diff -r 06c87ac466e3 -r 935b2c485f88 suites/libvirt-cim/main.py --- a/suites/libvirt-cim/main.py Tue May 13 06:07:27 2008 -0700 +++ b/suites/libvirt-cim/main.py Tue May 13 22:57:46 2008 -0700 @@ -51,7 +51,7 @@ parser.add_option("-c", "--clean-log", help="Will remove existing log files before test run") parser.add_option("-v", "--virt", dest="virt", type="choice", choices=platform_sup, default="Xen", - help="Virt type, select from 'Xen' & 'KVM' & 'XenFV'(default: Xen). ") + help="Virt type, select from 'Xen' & 'KVM' & 'XenFV' & 'LXC'(default: Xen). ") parser.add_option("-d", "--debug-output", action="store_true", dest="debug", help="Duplicate the output to stderr")

# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1210745379 25200 # Node ID 6a8318103e42f7e1891011550d3a9f7d7f86839c # Parent 935b2c485f8857ddb396efd729d5fc7ff7b41614 [TEST] add LXCXML class to support LXC guest Signed-off-by: Guolian Yun <yunguol@cn.ibm.com> diff -r 935b2c485f88 -r 6a8318103e42 suites/libvirt-cim/lib/XenKvmLib/const.py --- a/suites/libvirt-cim/lib/XenKvmLib/const.py Tue May 13 22:57:46 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/const.py Tue May 13 23:09:39 2008 -0700 @@ -78,3 +78,9 @@ XenFV_default_disk_dev = 'hda' XenFV_default_disk_dev = 'hda' XenFV_default_mac = '00:16:3e:5d:c7:9e' XenFV_default_net_type = 'bridge' + +#vxml.LXCXML +LXC_init_path = os.path.join(_image_dir) +LXC_default_file_src = '/tmp' +LXC_default_file_tar = '/tmp' +LXC_default_tty = '/tmp' diff -r 935b2c485f88 -r 6a8318103e42 suites/libvirt-cim/lib/XenKvmLib/vxml.py --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Tue May 13 22:57:46 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Tue May 13 23:09:39 2008 -0700 @@ -141,6 +141,8 @@ class Virsh: self.vuri = 'xen:///' elif vir_type == 'kvm': self.vuri = 'qemu:///system' + elif vir_type == 'lxc': + self.vuri = 'lxc:///system' def run(self, ip, vcmd, param): file_arg_cmds = ['define', 'create', 'net-create'] @@ -246,7 +248,7 @@ class VirtXML(Virsh, XMLClass): raise NotImplementedError('virtual method, implement your own') def issubinstance(self): - return isinstance(self, (XenXML, KVMXML, XenFVXML)) + return isinstance(self, (XenXML, KVMXML, XenFVXML, LXCXML)) def set_memory(self, mem): self.set_cdata('/domain/memory', mem * 1024) @@ -593,6 +595,35 @@ class XenFVXML(VirtXML): def set_vbridge(self, ip): return self._set_vbridge(ip, 'XenFV') +class LXCXML(VirtXML): + + def __init__(self, test_dom=const.default_domname, + mem=const.default_memory, + vcpus=const.default_vcpus, + file_path_src=const.LXC_default_file_src, + file_path_tar=const.LXC_default_file_tar, + tty=const.LXC_default_tty): + if not os.path.exists(const.LXC_init_path): + logger.error('ERROR: init_path does not exist') + sys.exit(1) + VirtXML.__init__(self, 'lxc', test_dom, set_uuid(), mem, vcpus) + self._os(const.LXC_init_path) + self._devices(const.LXC_default_file_src, + const.LXC_default_file_tar, + const.LXC_default_tty) + + def _os(self, os_init): + os = self.get_node('/domain/os') + self.add_sub_node(os, 'init', os_init) + + def _devices(self, file_src, file_tar, tty): + devices = self.get_node('/domain/devices') + + disk = self.add_sub_node(devices, 'filesystem', type='mount') + self.add_sub_node(disk, 'source', dir=file_src) + self.add_sub_node(disk, 'target', dir=file_tar) + + interface = self.add_sub_node(devices, 'console', tty) def get_class(virt): if virt in virt_types:

Guo Lian Yun wrote:
# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1210745379 25200 # Node ID 6a8318103e42f7e1891011550d3a9f7d7f86839c # Parent 935b2c485f8857ddb396efd729d5fc7ff7b41614 [TEST] add LXCXML class to support LXC guest
Signed-off-by: Guolian Yun <yunguol@cn.ibm.com>
diff -r 935b2c485f88 -r 6a8318103e42 suites/libvirt-cim/lib/XenKvmLib/const.py --- a/suites/libvirt-cim/lib/XenKvmLib/const.py Tue May 13 22:57:46 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/const.py Tue May 13 23:09:39 2008 -0700 @@ -78,3 +78,9 @@ XenFV_default_disk_dev = 'hda' XenFV_default_disk_dev = 'hda' XenFV_default_mac = '00:16:3e:5d:c7:9e' XenFV_default_net_type = 'bridge' + +#vxml.LXCXML +LXC_init_path = os.path.join(_image_dir)
Containers don't boot from an image like Xen and KVM do. You can think of containers as a way of encapsulating a process or a group of processes. So the init_path for a container needs to be a process or a group of processes you can run inside the container. Something to try would be to create a script and run something like exec /bin/bash in the script.
+LXC_default_file_src = '/tmp' +LXC_default_file_tar = '/tmp'
All this does is mount the /tmp dir as /tmp within the container, which is redundant. I can't think of a good reason to use the filesystem tag for a test guest. Thoughts?
+LXC_default_tty = '/tmp'
/tmp isn't a valid value for the console. For this, you'd want to specify /dev/ptmx, which creates a pseudo terminal to use for the console. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

libvirt-cim-bounces@redhat.com wrote on 2008-05-15 06:35:27:
Guo Lian Yun wrote:
# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1210745379 25200 # Node ID 6a8318103e42f7e1891011550d3a9f7d7f86839c # Parent 935b2c485f8857ddb396efd729d5fc7ff7b41614 [TEST] add LXCXML class to support LXC guest
Signed-off-by: Guolian Yun <yunguol@cn.ibm.com>
diff -r 935b2c485f88 -r 6a8318103e42 suites/libvirt- cim/lib/XenKvmLib/const.py --- a/suites/libvirt-cim/lib/XenKvmLib/const.py Tue May 13 22: 57:46 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/const.py Tue May 13 23: 09:39 2008 -0700 @@ -78,3 +78,9 @@ XenFV_default_disk_dev = 'hda' XenFV_default_disk_dev = 'hda' XenFV_default_mac = '00:16:3e:5d:c7:9e' XenFV_default_net_type = 'bridge' + +#vxml.LXCXML +LXC_init_path = os.path.join(_image_dir)
Containers don't boot from an image like Xen and KVM do. You can think of containers as a way of encapsulating a process or a group of processes. So the init_path for a container needs to be a process or a group of processes you can run inside the container.
Something to try would be to create a script and run something like exec
/bin/bash in the script.
I'm not sure what to run inside the container. May I fill it optionally now?
+LXC_default_file_src = '/tmp' +LXC_default_file_tar = '/tmp'
All this does is mount the /tmp dir as /tmp within the container, which is redundant. I can't think of a good reason to use the filesystem tag for a test guest. Thoughts?
+LXC_default_tty = '/tmp'
/tmp isn't a valid value for the console. For this, you'd want to specify /dev/ptmx, which creates a pseudo terminal to use for the
console.
Then I would like to define lxc guest like below, any thoughts? <domain type='lxc'> <name>lxc</name> <os> <init>/home/dev/lxc/lxc_rcinit</init> </os> <memory>65536</memory> <devices> <console tty='/dev/ptmx'/> </devices> </domain>
-- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

+ +#vxml.LXCXML +LXC_init_path = os.path.join(_image_dir)
Containers don't boot from an image like Xen and KVM do. You can think of containers as a way of encapsulating a process or a group of processes. So the init_path for a container needs to be a process or a group of processes you can run inside the container.
Something to try would be to create a script and run something like exec /bin/bash in the script.
I'm not sure what to run inside the container. May I fill it optionally now?
It's fairly trivial to write a script that runs exec /bin/bash. You can then run that script within the container.
+LXC_default_file_src = '/tmp' +LXC_default_file_tar = '/tmp'
All this does is mount the /tmp dir as /tmp within the container, which is redundant. I can't think of a good reason to use the filesystem tag for a test guest. Thoughts?
+LXC_default_tty = '/tmp'
/tmp isn't a valid value for the console. For this, you'd want to specify /dev/ptmx, which creates a pseudo terminal to use for the
console.
Then I would like to define lxc guest like below, any thoughts?
<domain type='lxc'> <name>lxc</name> <os> <init>/home/dev/lxc/lxc_rcinit</init>
/home/dev/lxc is not a good path name. We can't guarantee that all of the systems will have this path. Instead, I'd recommend using /tmp as the path for your script. Also, what will the lxc_rcinit script do?
</os> <memory>65536</memory> <devices> <console tty='/dev/ptmx'/> </devices> </domain>
-- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

Containers don't boot from an image like Xen and KVM do. You can think of containers as a way of encapsulating a process or a group of processes. So the init_path for a container needs to be a process or a group of processes you can run inside the container.
Something to try would be to create a script and run something like exec /bin/bash in the script.
I'm not sure what to run inside the container. May I fill it optionally now?
If you're not sure how something is support to work, please ask questions instead of sending a patch. You should only send patches if you understand what the patch needs to do. If you aren't sure if a patch is correct, it's okay to send it as an RFC (RFC means "Request For Comments"). In this case, it sounds like you aren't sure how containers work. And that's alright. However, if you are confused about something, it's not a problem to send an e-mail (you can email me privately or send an e-mail to cimtest-devel@opensource.ibm.com). If you want, we can even set up a time to meet on IRC to discuss any questions you have. Thanks! -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1210745607 25200 # Node ID 4ebde2a615e2b2449d1334409f0374fdea26a279 # Parent 6a8318103e42f7e1891011550d3a9f7d7f86839c [TEST] update ComputerSystem.01&03 tc for LXC support Signed-off-by: Guolian Yun <yunguol@cn.ibm.com> diff -r 6a8318103e42 -r 4ebde2a615e2 suites/libvirt-cim/cimtest/ComputerSystem/01_enum.py --- a/suites/libvirt-cim/cimtest/ComputerSystem/01_enum.py Tue May 13 23:09:39 2008 -0700 +++ b/suites/libvirt-cim/cimtest/ComputerSystem/01_enum.py Tue May 13 23:13:27 2008 -0700 @@ -30,7 +30,7 @@ from CimTest import Globals from CimTest import Globals from CimTest.ReturnCodes import PASS, FAIL -SUPPORTED_TYPES = ['Xen', 'KVM', 'XenFV'] +SUPPORTED_TYPES = ['Xen', 'KVM', 'XenFV', 'LXC'] @do_main(SUPPORTED_TYPES) def main(): diff -r 6a8318103e42 -r 4ebde2a615e2 suites/libvirt-cim/cimtest/ComputerSystem/03_defineVS.py --- a/suites/libvirt-cim/cimtest/ComputerSystem/03_defineVS.py Tue May 13 23:09:39 2008 -0700 +++ b/suites/libvirt-cim/cimtest/ComputerSystem/03_defineVS.py Tue May 13 23:13:27 2008 -0700 @@ -35,7 +35,7 @@ from CimTest.Globals import do_main from CimTest.Globals import do_main from CimTest.ReturnCodes import PASS, FAIL -sup_types = ['Xen', 'KVM', 'XenFV'] +sup_types = ['Xen', 'KVM', 'XenFV', 'LXC'] test_dom = "domU1" @do_main(sup_types) diff -r 6a8318103e42 -r 4ebde2a615e2 suites/libvirt-cim/lib/XenKvmLib/computersystem.py --- a/suites/libvirt-cim/lib/XenKvmLib/computersystem.py Tue May 13 23:09:39 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/computersystem.py Tue May 13 23:13:27 2008 -0700 @@ -69,6 +69,9 @@ class KVM_ComputerSystem(CIM_System): class KVM_ComputerSystem(CIM_System): pass +class LXC_ComputerSystem(CIM_System): + pass + def get_cs_class(virt): if virt in virt_types: return eval(get_typed_class(virt, 'ComputerSystem'))
participants (2)
-
Guo Lian Yun
-
Kaitlin Rupert