summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
9ca8cb1)
do not use the result of virsh domid to determine <pid> as this would point at the lxc driver
we need to use its - expected single - child process, that instead corresponds to the VM init/systemd instance
try:
cmd = '/usr/bin/virsh --connect lxc:/// domid %s'%slice_name
pidnum = int(os.popen(cmd).read().rstrip())
try:
cmd = '/usr/bin/virsh --connect lxc:/// domid %s'%slice_name
pidnum = int(os.popen(cmd).read().rstrip())
+ # locate the pid for the - expected - single child, that would be the init for that VM
+ child_pid = open("/proc/%s/task/%s/children"%(pidnum,pidnum)).read().strip()
+
except:
print "Domain %s not found"%slice_name
exit(1)
pid = '%s'%pidnum
except:
print "Domain %s not found"%slice_name
exit(1)
pid = '%s'%pidnum
- if debug: print "Found pidnum",pidnum
+ if debug: print "Found pidnum",pidnum,'child_pid=',child_pid
cmdline = open('/proc/%s/cmdline'%pidnum).read().rstrip('\n\x00')
arch = getarch('/proc/%s/exe'%pid)
cmdline = open('/proc/%s/cmdline'%pidnum).read().rstrip('\n\x00')
arch = getarch('/proc/%s/exe'%pid)
print 'WARNING - setns(%s)=>%s (ignored)'%(path,retcod)
return retcod
print 'WARNING - setns(%s)=>%s (ignored)'%(path,retcod)
return retcod
- chcontext('/proc/%s/ns/uts'%pid)
- chcontext('/proc/%s/ns/ipc'%pid)
+ # Use child_pid and not pid to locate reference namespaces
+ ref_ns = "/proc/%s/ns/"%child_pid
+ chcontext(ref_ns+'uts')
+ chcontext(ref_ns+'ipc')
- chcontext('/proc/%s/ns/pid'%pid)
+ chcontext(ref_ns+'pid')
- chcontext('/proc/%s/ns/net'%pid)
+ chcontext(ref_ns+'net')
- chcontext('/proc/%s/ns/mnt'%pid)
+ chcontext(ref_ns+'mnt')
proc_mounted = False
if (not os.access('/proc/self',0)):
proc_mounted = False
if (not os.access('/proc/self',0)):