+1 for me =)
Best,
Regards
Daisy (运国莲)
VSM Team, China Systems & Technology Labs (CSTL)
E-mail: yunguol(a)cn.ibm.com
TEL: (86)-21-60922403
Building 10, 399 Ke Yuan Rd, Pudong Shanghai, 201203
Kaitlin Rupert <kaitlin(a)linux.vnet.ibm.com>
Sent by: libvirt-cim-bounces(a)redhat.com
2008-10-09 03:59
Please respond to
List for discussion and development of libvirt CIM
<libvirt-cim(a)redhat.com>
To
libvirt-cim(a)redhat.com
cc
Subject
[Libvirt-cim] [PATCH] [TEST] Add NETNS toggle to const.py; update LXC
define system bits
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1223495957 25200
# Node ID c2c64b0ee95d55ac09375f0a3518d60fd569ee7d
# Parent 98c505b354576e9150943b9f7f1bfd4a70347dab
[TEST] Add NETNS toggle to const.py; update LXC define system bits.
Added LXC_netns_support to const.py - right now, this is hardcoded to
False. In the future, this will dynamically detect whether the kernel
supports NETNS (which is needed to create containers guests with network
support).
Cleanup default_vssd_rasd_str() so that class_dasd() is used to create a
Disk RASD for LXC guests, as well as KVM/Xen.
On undefine/destroy of LXC guests, don't remove the file at LXC_init_path
Extend LXCXML to subclass VirtCIM - this allows cim_define() to be called
for LXC guests.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 98c505b35457 -r c2c64b0ee95d
suites/libvirt-cim/lib/XenKvmLib/const.py
--- a/suites/libvirt-cim/lib/XenKvmLib/const.py Tue Oct 07
02:42:02 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/const.py Wed Oct 08
12:59:17 2008 -0700
@@ -85,6 +85,7 @@
LXC_default_mp = '/tmp'
LXC_default_source = '/tmp/lxc_files'
LXC_default_mac = '11:22:33:aa:bb:cc'
+LXC_netns_support = False
parser = OptionParser()
parser.add_option("-i", "--ip", dest="ip",
default="localhost",
diff -r 98c505b35457 -r c2c64b0ee95d
suites/libvirt-cim/lib/XenKvmLib/vsms.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vsms.py Tue Oct 07
02:42:02 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/vsms.py Wed Oct 08
12:59:17 2008 -0700
@@ -241,30 +241,25 @@
class_vssd = get_vssd_class(virt)
vssd = class_vssd(name=dom_name, virt=virt)
- # 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_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
+ elif virt == 'LXC':
+ disk_dev = const.LXC_default_mp
+ disk_source = const.LXC_default_source
+ d = class_dasd(disk_dev, disk_source, dom_name)
class_masd = get_masd_class(virt)
m = class_masd(
megabytes=mem_mb,
mallocunits=malloc_units,
name=dom_name)
+
+ # LXC only takes disk and memory device for now.
if virt == 'LXC':
return vssd.mof(), [d.mof(), m.mof()]
diff -r 98c505b35457 -r c2c64b0ee95d
suites/libvirt-cim/lib/XenKvmLib/vxml.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Tue Oct 07
02:42:02 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Oct 08
12:59:17 2008 -0700
@@ -328,8 +328,6 @@
return self.run(ip, 'define', self.xml_string)
def undefine(self, ip):
- if os.path.exists(const.LXC_init_path):
- os.remove(const.LXC_init_path)
return self.run(ip, 'undefine', self.dname)
def start(self, ip):
@@ -339,8 +337,6 @@
return self.run(ip, 'stop', self.dname)
def destroy(self, ip):
- if os.path.exists(const.LXC_init_path):
- os.remove(const.LXC_init_path)
return self.run(ip, 'destroy', self.dname)
def create(self, ip):
@@ -471,9 +467,7 @@
self.virt = virt
self.domain_name = dom_name
self.vssd = vsms.get_vssd_class(virt)(name=dom_name, virt=virt)
- self.dasd = vsms.get_dasd_class(virt)(dev=disk_dev,
- source=disk_source,
- name=dom_name)
+ self.dasd = vsms.get_dasd_class(virt)(disk_dev, disk_source,
dom_name)
self.nasd = vsms.get_nasd_class(virt)(type=net_type,
mac=net_mac,
name=dom_name,
@@ -487,8 +481,11 @@
def cim_define(self, ip, ref_conf=None):
service = vsms.get_vsms_class(self.virt)(ip)
sys_settings = str(self.vssd)
- res_settings = [str(self.dasd), str(self.nasd),
- str(self.pasd), str(self.masd)]
+ if self.virt == 'LXC' and const.LXC_netns_support is False:
+ res_settings = [str(self.dasd), str(self.pasd),
str(self.masd)]
+ else:
+ res_settings = [str(self.dasd), str(self.nasd),
+ str(self.pasd), str(self.masd)]
if ref_conf is None:
ref_conf = ' '
@@ -683,7 +680,7 @@
def set_vbridge(self, ip, net_name):
return self._set_vbridge(ip, 'XenFV', net_name)
-class LXCXML(VirtXML):
+class LXCXML(VirtXML, VirtCIM):
def __init__(self, test_dom=const.default_domname,
mem=const.default_memory,
@@ -693,6 +690,9 @@
net_name=const.default_network_name,
tty=const.LXC_default_tty):
VirtXML.__init__(self, 'lxc', test_dom, set_uuid(), mem, vcpus)
+ VirtCIM.__init__(self, 'LXC', test_dom, const.LXC_default_mp,
+ const.LXC_default_source, ntype, net_name, mac,
vcpus,
+ mem, const.default_mallocunits)
self._os(const.LXC_init_path)
self._devices(mac, ntype, net_name, const.LXC_default_tty)
self.create_lxc_file(CIM_IP, const.LXC_init_path)
@@ -704,8 +704,12 @@
def _devices(self, net_mac, net_type, net_name, tty_set):
devices = self.get_node('/domain/devices')
- self.set_interface_details(devices, net_mac, net_type, net_name,
'LXC')
- interface = self.add_sub_node(devices, 'console', tty = tty_set)
+
+ if const.LXC_netns_support is True:
+ self.set_interface_details(devices, net_mac, net_type,
+ net_name, 'LXC')
+
+ self.add_sub_node(devices, 'console', tty = tty_set)
def create_lxc_file(self, ip, lxc_file):
try:
_______________________________________________
Libvirt-cim mailing list
Libvirt-cim(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvirt-cim