Package: autopkgtest
Version: 5.5
Severity: normal
Tags: patch

When I test packages on Debian jessie with autopkgtest-virt-qemu (actually
a jessie derivative, but I'm fairly sure real jessie would be the same),
rebooting the VM fails with:

    systemd-run: unrecognized option '--no-block'

This appears to have been caused by fixing ci-team/autopkgtest!16 in
5.5: jessie's systemd-run didn't have the --no-block option. It can be
addressed by reverting to the non-systemd mechanism if systemd doesn't
work, as in the attached patch. I'll send a merge request when I have
a bug number for it.

Thanks,
    smcv

-- System Information:
Debian Release: buster/sid
  APT prefers buildd-unstable
  APT policy: (500, 'buildd-unstable'), (500, 'unstable'), (500, 'testing'), 
(500, 'stable'), (1, 'buildd-experimental'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.17.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_GB.utf8, LC_CTYPE=en_GB.utf8 (charmap=UTF-8), LANGUAGE=en_GB:en 
(charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages autopkgtest depends on:
ii  apt-utils       1.6.3
ii  libdpkg-perl    1.19.0.5
ii  procps          2:3.3.15-2
ii  python3         3.6.6-1
ii  python3-debian  0.1.32

Versions of packages autopkgtest recommends:
ii  autodep8  0.13

Versions of packages autopkgtest suggests:
pn  lxc               <none>
pn  lxd-client        <none>
ii  ovmf              0~20180803.dd4cae4d-1
ii  qemu-efi-aarch64  0~20180803.dd4cae4d-1
pn  qemu-efi-arm      <none>
ii  qemu-system       1:2.12+dfsg-3
ii  qemu-utils        1:2.12+dfsg-3
ii  schroot           1.6.10-5

-- no debconf information
>From 5f99fb2c2b55acda2dee285f9bc3d135b477a1a0 Mon Sep 17 00:00:00 2001
From: Simon McVittie <[email protected]>
Date: Wed, 15 Aug 2018 16:21:52 +0100
Subject: [PATCH] Restore ability to boot pre-stretch systemd systems

The systemctl in Debian jessie didn't support the --no-block option.

Signed-off-by: Simon McVittie <[email protected]>
---
 lib/VirtSubproc.py | 32 ++++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/lib/VirtSubproc.py b/lib/VirtSubproc.py
index 671a21d..847eac8 100644
--- a/lib/VirtSubproc.py
+++ b/lib/VirtSubproc.py
@@ -309,6 +309,27 @@ def cmd_revert(c, ce):
     return [downtmp]
 
 
+def reboot_testbed():
+    (systemd_check, out, err) = execute_timeout(
+        None, 10, auxverb + ['test', '-d', '/run/systemd/system'],
+        stdout=subprocess.PIPE, stderr=subprocess.PIPE
+    )
+    if systemd_check == 0:
+        reboot_cmd = ['systemd-run', '--no-block', '--quiet', 'sh', '-c', 'sleep 3; reboot']
+        adtlog.debug('rebooting with command: %s' % reboot_cmd)
+        status, out, err = execute_timeout(None, 30, auxverb + reboot_cmd)
+
+        if status == 0:
+            return
+        else:
+            adtlog.debug(
+                'Cannot reboot with %s, trying something else' % reboot_cmd)
+
+    reboot_cmd = ['sh', '-c', '(sleep 3; reboot) >/dev/null 2>&1 &']
+    adtlog.debug('rebooting with command: %s' % reboot_cmd)
+    status, out, err = execute_timeout(None, 30, auxverb + reboot_cmd)
+
+
 def cmd_reboot(c, ce):
     global downtmp
     cmdnumargs(c, ce, 0, 1)
@@ -337,17 +358,8 @@ def cmd_reboot(c, ce):
     if len(c) > 1 and c[1] == 'prepare-only':
         adtlog.info('state saved, waiting for testbed to reboot...')
     else:
-        (systemd_check, out, err) = execute_timeout(
-            None, 10, auxverb + ['test', '-d', '/run/systemd/system'],
-            stdout=subprocess.PIPE, stderr=subprocess.PIPE
-        )
-        if systemd_check == 0:
-            reboot_cmd = ['systemd-run', '--no-block', '--quiet', 'sh', '-c', 'sleep 3; reboot']
-        else:
-            reboot_cmd = ['sh', '-c', '(sleep 3; reboot) >/dev/null 2>&1 &']
+        reboot_testbed()
 
-        adtlog.debug('rebooting with command: %s' % reboot_cmd)
-        execute_timeout(None, 30, auxverb + reboot_cmd)
     caller.hook_wait_reboot()
 
     # restore downtmp
-- 
2.18.0

Reply via email to