Have tested the code changes. here are the logs. Please review the patch sent in another mail.
Really appreciate the efforts to make the code very efficient.
test logs:
imran@imran-VirtualBox:~/programming/libvirt$
imran@imran-VirtualBox:~/programming/libvirt$
imran@imran-VirtualBox:~/programming/libvirt$ sudo ./run ./tools/virsh -c lxc:/// create ../lxc/cn-02.xml
Domain cn02 created from ../lxc/cn-02.xml
imran@imran-VirtualBox:~/programming/libvirt$
imran@imran-VirtualBox:~/programming/libvirt$
imran@imran-VirtualBox:~/programming/libvirt$ cat ../lxc/share_lxc.xml | grep -A 3 -B 3 share
<type>exe</type>
</os>
<lxc:namespace>
<lxc:sharenet type='name' value='cn02'/>
</lxc:namespace>
<vcpu>1</vcpu>
<clock offset='utc'/>
imran@imran-VirtualBox:~/programming/libvirt$
imran@imran-VirtualBox:~/programming/libvirt$
imran@imran-VirtualBox:~/programming/libvirt$ sudo ./run ./tools/virsh -c lxc:/// list
Id Name State
----------------------------------------------------
6828 cn02 running
imran@imran-VirtualBox:~/programming/libvirt$
imran@imran-VirtualBox:~/programming/libvirt$
imran@imran-VirtualBox:~/programming/libvirt$ sudo ./run ./tools/virsh -c lxc:/// create ../lxc/share_lxc.xml Domain cn-03 created from ../lxc/share_lxc.xml
imran@imran-VirtualBox:~/programming/libvirt$ sudo ./run ./tools/virsh -c lxc:/// list
Id Name State
----------------------------------------------------
6828 cn02 running
8774 cn-03 running
imran@imran-VirtualBox:~/programming/libvirt$ sudo ./run ./tools/virsh -c lxc:/// lxc-enter-namespace cn02 --noseclabel /sbin/ifconfig eth0
eth0 Link encap:Ethernet HWaddr 52:54:00:a7:e5:3d
inet addr:192.168.122.183 Bcast:192.168.122.255 Mask:255.255.255.0
inet6 addr: fe80::5054:ff:fea7:e53d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:105 errors:0 dropped:2 overruns:0 frame:0
TX packets:58 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:14169 (14.1 KB) TX bytes:32554 (32.5 KB)
imran@imran-VirtualBox:~/programming/libvirt$
imran@imran-VirtualBox:~/programming/libvirt$
imran@imran-VirtualBox:~/programming/libvirt$ sudo ./run ./tools/virsh -c lxc:/// lxc-enter-namespace cn-03 --noseclabel /sbin/ifconfig eth0
eth0 Link encap:Ethernet HWaddr 52:54:00:a7:e5:3d
inet addr:192.168.122.183 Bcast:192.168.122.255 Mask:255.255.255.0
inet6 addr: fe80::5054:ff:fea7:e53d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:114 errors:0 dropped:2 overruns:0 frame:0
TX packets:64 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:15289 (15.2 KB) TX bytes:40891 (40.8 KB)
imran@imran-VirtualBox:~/programming/libvirt$
imran@imran-VirtualBox:~/programming/libvirt$ sudo ./run ./tools/virsh -c lxc:/// destroy cn02
Domain cn02 destroyed
imran@imran-VirtualBox:~/programming/libvirt$ sudo ./run ./tools/virsh -c lxc:/// lxc-enter-namespace cn-03 --noseclabel /sbin/ifconfig eth0
eth0: error fetching interface information: Device not found
error: internal error: Child process (10238) unexpected exit status 1
imran@imran-VirtualBox:~/programming/libvirt$
imran@imran-VirtualBox:~/programming/libvirt$ sudo ip netns exec red ifconfig
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:32 errors:0 dropped:0 overruns:0 frame:0
TX packets:32 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2528 (2.5 KB) TX bytes:2528 (2.5 KB)
imran@imran-VirtualBox:~/programming/libvirt$
imran@imran-VirtualBox:~/programming/libvirt$
imran@imran-VirtualBox:~/programming/libvirt$ sudo ./run ./tools/virsh -c lxc:/// list
Id Name State
----------------------------------------------------
8774 cn-03 running
imran@imran-VirtualBox:~/programming/libvirt$ sudo ./run ./tools/virsh -c lxc:/// destroy cn-03
Domain cn-03 destroyed
imran@imran-VirtualBox:~/programming/libvirt$
imran@imran-VirtualBox:~/programming/libvirt$ cat ../lxc/share_lxc.xml | grep -A 3 -B 3 share
<type>exe</type>
</os>
<lxc:namespace>
<lxc:sharenet type='netns' value='red'/>
</lxc:namespace>
<vcpu>1</vcpu>
<clock offset='utc'/>
imran@imran-VirtualBox:~/programming/libvirt$
imran@imran-VirtualBox:~/programming/libvirt$ sudo ./run ./tools/virsh -c lxc:/// create ../lxc/share_lxc.xml
Domain cn-03 created from ../lxc/share_lxc.xml
imran@imran-VirtualBox:~/programming/libvirt$ sudo ./run ./tools/virsh -c lxc:/// lxc-enter-namespace cn-03 --noseclabel /sbin/ifconfig
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:48 errors:0 dropped:0 overruns:0 frame:0
TX packets:48 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3792 (3.7 KB) TX bytes:3792 (3.7 KB)
imran@imran-VirtualBox:~/programming/libvirt$ sudo ./run ./tools/virsh -c lxc:/// destroy cn-03Domain cn-03 destroyed
imran@imran-VirtualBox:~/programming/libvirt$
imran@imran-VirtualBox:~/programming/libvirt$
imran@imran-VirtualBox:~/programming/libvirt$ sudo ip netns exec red ifconfig lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:48 errors:0 dropped:0 overruns:0 frame:0
TX packets:48 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3792 (3.7 KB) TX bytes:3792 (3.7 KB)
imran@imran-VirtualBox:~/programming/libvirt$ cat ../lxc/share_lxc.xml | grep -A 3 -B 3 share<type>exe</type>
</os>
<lxc:namespace>
<lxc:sharenet type='pid' value='1'/>
</lxc:namespace>
<vcpu>1</vcpu>
<clock offset='utc'/>
imran@imran-VirtualBox:~/programming/libvirt$ sudo ./run ./tools/virsh -c lxc:/// create ../lxc/share_lxc.xml Domain cn-03 created from ../lxc/share_lxc.xml
imran@imran-VirtualBox:~/programming/libvirt$ ifconfig eth0
eth0 Link encap:Ethernet HWaddr 08:00:27:a8:fd:bf
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fea8:fdbf/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:178204 errors:13 dropped:0 overruns:0 frame:0
TX packets:88943 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:251962232 (251.9 MB) TX bytes:4930611 (4.9 MB)
Interrupt:19 Base address:0xd020
imran@imran-VirtualBox:~/programming/libvirt$ sudo ./run ./tools/virsh -c lxc:/// lxc-enter-namespace cn-03 --noseclabel /sbin/ifconfig eth0
eth0 Link encap:Ethernet HWaddr 08:00:27:a8:fd:bf
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fea8:fdbf/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:178204 errors:13 dropped:0 overruns:0 frame:0
TX packets:88943 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:251962232 (251.9 MB) TX bytes:4930611 (4.9 MB)
Interrupt:19 Base address:0xd020
imran@imran-VirtualBox:~/programming/libvirt$ sudo ./run ./tools/virsh -c lxc:/// destroy cn-03
Domain cn-03 destroyed
imran@imran-VirtualBox:~/programming/libvirt$ ifconfig eth0
eth0 Link encap:Ethernet HWaddr 08:00:27:a8:fd:bf
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fea8:fdbf/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:178204 errors:13 dropped:0 overruns:0 frame:0
TX packets:88943 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:251962232 (251.9 MB) TX bytes:4930611 (4.9 MB)
Interrupt:19 Base address:0xd020
imran@imran-VirtualBox:~/programming/libvirt$