From a6abcf0d59f203ae7062bfed10a1cd52cc7d95a7 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 1 Nov 2006 16:57:03 +0000 Subject: [PATCH] adt-virt-xenlvm more or less done; needing testing --- virt-subproc/VirtSubproc.py | 2 ++ virt-subproc/adt-virt-chroot | 17 +++++++++----- virt-subproc/adt-virt-xenlvm | 43 ++++++++++++++++++++++++------------ 3 files changed, 43 insertions(+), 19 deletions(-) diff --git a/virt-subproc/VirtSubproc.py b/virt-subproc/VirtSubproc.py index e30a5fb..833cb5d 100644 --- a/virt-subproc/VirtSubproc.py +++ b/virt-subproc/VirtSubproc.py @@ -53,6 +53,7 @@ def cmdnumargs(c, ce, nargs=0): def cmd_capabilities(c, ce): cmdnumargs(c, ce) + return caller.hook_capabilities() def cmd_quit(c, ce): cmdnumargs(c, ce) @@ -311,6 +312,7 @@ def mainloop(): sys.exit(16) def main(): + debug("down = %s" % string.join(down)) ok() prepare() mainloop() diff --git a/virt-subproc/adt-virt-chroot b/virt-subproc/adt-virt-chroot index e5651e1..ffcc39b 100755 --- a/virt-subproc/adt-virt-chroot +++ b/virt-subproc/adt-virt-chroot @@ -24,19 +24,20 @@ import sys import os +import string +from optparse import OptionParser try: our_base = os.environ['AUTOPKGTEST_BASE'] except KeyError: our_base = '/usr/share/autopkgtest'; sys.path.insert(1, our_base+'/python') -import string -from optparse import OptionParser import VirtSubproc as vsp +capabilities = [] def parse_args(): global down, debuglevel - usage = "%prog [options] =|/path/to/chroot" + usage = "%prog [] =|/path/to/chroot" parser = OptionParser(usage=usage) pa = parser.add_option pe = parser.error @@ -57,9 +58,12 @@ def parse_args(): elif chroot_arg[0] == '/': down = ['chroot',chroot_arg,'--'] else: pe("chroot spec must be =[DCHROOT] or /PATH/TO/CHROOT") - if opts.gain_root != None: down = opts.gain_root.split() + down + if opts.gain_root != None: + down = opts.gain_root.split() + down + + if opts.gain_root or os.getuid()==0: + capabilities.append('root-on-testbed') - vsp.debug("down = %s" % string.join(down)) vsp.down = down def hook_open(): @@ -75,5 +79,8 @@ def hook_stop(): def hook_cleanup(): vsp.execute('rm -rf --', [downtmp], downp=True) +def hook_capabilities(): + return capabilities + parse_args() vsp.main() diff --git a/virt-subproc/adt-virt-xenlvm b/virt-subproc/adt-virt-xenlvm index 366bcbc..870afb1 100755 --- a/virt-subproc/adt-virt-xenlvm +++ b/virt-subproc/adt-virt-xenlvm @@ -24,39 +24,51 @@ import sys import os +import re as regexp +import string +from optparse import OptionParser try: our_base = os.environ['AUTOPKGTEST_BASE'] except KeyError: our_base = '/usr/share/autopkgtest'; sys.path.insert(1, our_base+'/python') -import string -from optparse import OptionParser import VirtSubproc as vsp witholder = None def parse_args(): - global down, debuglevel, xlargs + global debuglevel, xlargs, gain_root + + usage = "%prog [-- ]" + parser = OptionParser(usage=usage) + pa = parser.add_option + pe = parser.error + + pa('-r', '--gain-root', type='string', dest='gain_root'); + pa('-d', '--debug', action='store_true', dest='debug'); - usage = "%prog []" - for a in + (opts,xlargs) = parser.parse_args() + vsp.debuglevel = opts.debug - fixme must check args fit --= as expected by adt-xenlvm - fixme then put set of args into global xlargs - fixme fix these next two lines: - vsp.debug("down = %s" % string.join(down)) - vsp.down = down + if opts.gain_root = None: gain_root = [] + else: gain_root = opts.gain_root.split() + vsp.down = gain_root + ['adt-xenlvm-on-testbed'] + xlargs + ['--'] def hook_open(): hook_cleanup() withholder = subprocess.Popen( - ['adt-xenlvm-with-testbed'] + xlargs + + gain_root + ['adt-xenlvm-with-testbed'] + xlargs + ['--','sh','-ec','echo y; exec cat'], stdin=subprocess.PIPE, stdout=subprocess.PIPE ) l = withholder.stdout.readline(2) rc = withholder.poll() - if rc is not None: bomb("with-testbed failed, code %d" % rc) - if l != "y\n": bomb("with-testbed sh gave wrong output `%s', not `l'" + if rc is not None: + withholder.stdin.close() + withholder.stdout.close() + withholder = None + bomb("with-testbed failed, code %d" % rc) + if l != "y\n": + bomb("with-testbed sh gave wrong output `%s', not `l'" % l.rstrip("\n")) downtmp = '/root/adt-downtmp' vsp.execute('mkdir %s' % downtmp, downp=True) @@ -77,6 +89,9 @@ def hook_cleanup(): withholder = None if rc: print >>sys.stderr, ( "with-testbed failed during cleanup, code %d" % rc) - + +def hook_capabilities(): + return ('revert','root-on-testbed','suggest-normal-user=adtxenu') + parse_args() vsp.main() -- 2.30.2