diff -Nru autopkgtest-2.13.1/debian/changelog autopkgtest-2.14.1/debian/changelog --- autopkgtest-2.13.1/debian/changelog 2014-04-08 10:18:05.000000000 +0000 +++ autopkgtest-2.14.1/debian/changelog 2014-04-09 15:15:38.000000000 +0000 @@ -1,3 +1,19 @@ +autopkgtest (2.14.1) unstable; urgency=medium + + * tools/adt-buildvm-ubuntu-cloud: Enable ssh login with passwords. + + -- Martin Pitt Wed, 09 Apr 2014 17:15:29 +0200 + +autopkgtest (2.14) unstable; urgency=medium + + * lxc: Greatly simplify bind mounting of shared tmp dir using the + lxc-start -s option. + * adt-virt-qemu: Forward VM's ssh port 22 to the first free localhost port + starting from 10022. When finding one, suggest connecting to the VM with + an appropriate ssh command on --shell. + + -- Martin Pitt Wed, 09 Apr 2014 17:06:44 +0200 + autopkgtest (2.13.1) unstable; urgency=medium * Fix "--build-tree" typo in error message, and also add the missing diff -Nru autopkgtest-2.13.1/tools/adt-buildvm-ubuntu-cloud autopkgtest-2.14.1/tools/adt-buildvm-ubuntu-cloud --- autopkgtest-2.13.1/tools/adt-buildvm-ubuntu-cloud 2014-04-08 10:18:05.000000000 +0000 +++ autopkgtest-2.14.1/tools/adt-buildvm-ubuntu-cloud 2014-04-09 15:15:38.000000000 +0000 @@ -154,6 +154,7 @@ password: ubuntu chpasswd: { expire: False } +ssh_pwauth: True manage_etc_hosts: True apt_proxy: %(proxy)s apt_mirror: %(mirror)s diff -Nru autopkgtest-2.13.1/virt-subproc/adt-virt-lxc autopkgtest-2.14.1/virt-subproc/adt-virt-lxc --- autopkgtest-2.13.1/virt-subproc/adt-virt-lxc 2014-04-08 10:18:05.000000000 +0000 +++ autopkgtest-2.14.1/virt-subproc/adt-virt-lxc 2014-04-09 15:15:38.000000000 +0000 @@ -185,23 +185,9 @@ else: VirtSubproc.execute(sudoify('lxc-clone -n %s -o' % lxc_container_name), [lxc_template], downp=False, outp=True) - - # determine container path and create bind mount for our tmp dir in the - # clone - try: - lxc_dir = subprocess.check_output(sudoify(['lxc-config', 'lxc.lxcpath']), - universal_newlines=True).strip() - subprocess.check_call(sudoify( - ['sh', '-c', 'mkdir %(r)s/%(n)s/rootfs/%(d)s && ' - 'echo "lxc.mount.entry = %(d)s %(drel)s none bind 0 0" >> %(r)s/%(n)s/config' % - {'r': lxc_dir, 'n': lxc_container_name, 'd': shared_dir, 'drel': shared_dir[1:]}])) - except subprocess.CalledProcessError as e: - VirtSubproc.debug('unable to determine lxc path or set up bind mount, disabling shared downtmp: %s' % e) - shutil.rmtree(shared_dir) - shared_dir = None - - VirtSubproc.execute(sudoify('lxc-start -n %s -d' % lxc_container_name), - [], downp=False, outp=True) + subprocess.check_call(sudoify([ + 'lxc-start', '-n', lxc_container_name, '-d', + '-s', 'lxc.mount.entry=%s %s none bind,create=dir 0 0' % (shared_dir, shared_dir[1:])])) try: VirtSubproc.debug('waiting for lxc guest start') wait_booted(lxc_container_name) diff -Nru autopkgtest-2.13.1/virt-subproc/adt-virt-qemu autopkgtest-2.14.1/virt-subproc/adt-virt-qemu --- autopkgtest-2.13.1/virt-subproc/adt-virt-qemu 2014-04-08 10:18:05.000000000 +0000 +++ autopkgtest-2.14.1/virt-subproc/adt-virt-qemu 2014-04-09 15:15:38.000000000 +0000 @@ -33,6 +33,8 @@ import argparse import time import atexit +import socket +import errno try: our_base = os.environ['AUTOPKGTEST_BASE'] + '/lib' @@ -45,6 +47,7 @@ args = None workdir = None p_qemu = None +ssh_port = None def parse_args(): @@ -271,8 +274,29 @@ VirtSubproc.bomb('failed to connect to VM') +def find_free_port(start): + '''Find an unused port in the range [start, start+50)''' + + for p in range(start, start + 50): + VirtSubproc.debug('find_free_port: trying %i' % p) + try: + s = socket.create_connection(('127.0.0.1', p)) + # if that works, the port is taken + s.close() + continue + except socket.error as e: + if e.errno == errno.ECONNREFUSED: + VirtSubproc.debug('find_free_port: %i is free' % p) + return p + else: + pass + + VirtSubproc.debug('find_free_port: all ports are taken') + return None + + def hook_open(): - global workdir, p_qemu + global workdir, p_qemu, ssh_port workdir = tempfile.mkdtemp(prefix='adt-virt-qemu') os.chmod(workdir, 0o755) @@ -301,6 +325,13 @@ argv.append('-drive') argv.append('file=%s,if=virtio,index=%i,readonly' % (image, i + 1)) + # find free port to forward VM port 22 (for SSH access) + ssh_port = find_free_port(10022) + if ssh_port: + VirtSubproc.debug('Forwarding local port %i to VM ssh port 22' % ssh_port) + argv.append('-redir') + argv.append('tcp:%i::22' % ssh_port) + p_qemu = subprocess.Popen(argv) try: @@ -352,18 +383,27 @@ def hook_shell(stdin, stdout, stderr, dir): + global ssh_port + + if ssh_port: + user = args.user or '' + ssh = ' ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p %i %s@localhost\n' % ( + ssh_port, user) + else: + ssh = '' + with open(stdout, 'w') as f: f.write('''You can now log into the VM through the serial terminal. Depending on which terminal program you have installed, you can use one of - minicom -D unix#%(tty0)s +%(ssh)s minicom -D unix#%(tty0)s nc -U %(tty0)s socat - UNIX-CONNECT:%(tty0)s The tested source package is in %(dir)s Press Enter to resume adt-run. -''' % {'tty0': os.path.join(workdir, 'ttyS0'), 'dir': dir}) +''' % {'tty0': os.path.join(workdir, 'ttyS0'), 'dir': dir, 'ssh': ssh}) with open(stdin, 'r') as f: f.readline()