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

The changes made for #842299 do not seem to be entirely reliable: I still
sometimes get /dev/disk/by-partlabel/* pointing to /dev/vdb* (the read-only
copy of the base image) rather than the expected /dev/vda* (the read/write
overlay). This is problematic for an embedded Debian derivative that I'm
working on, which uses those symlinks.

I wonder whether this might be a result of not explicitly waiting for the
shell prompt to be issued after previous commands on ttyS1, such that when
we wait for a shell prompt to synchronize after doing udev things, we are
actually seeing the shell prompt from some previous command. I haven't had
a chance to try/debug that yet though.

Since the base image is rarely used and clearly rather subtle, I think a
pragmatic approach to this might be to make it optional, as with the
attached patch.

Regards,
    S

-- System Information:
Debian Release: 9.0
  APT prefers testing-proposed-updates
  APT policy: (500, 'testing-proposed-updates'), (500, 'stable-updates'), (500, 
'unstable'), (500, 'testing'), (500, 'stable'), (100, 'experimental')
Architecture: amd64
 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.9.0-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_GB.utf8, LC_CTYPE=en_GB.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages autopkgtest depends on:
ii  apt-utils       1.4.2
ii  libdpkg-perl    1.18.23
ii  procps          2:3.3.12-3
ii  python3         3.5.3-1
ii  python3-debian  0.1.30

Versions of packages autopkgtest recommends:
ii  autodep8  0.8

Versions of packages autopkgtest suggests:
pn  lxc          <none>
pn  lxd-client   <none>
ii  qemu-system  1:2.8+dfsg-4+b2
ii  qemu-utils   1:2.8+dfsg-4+b2
ii  schroot      1.6.10-3+b1

-- no debconf information
>From 886a33ef7d516945f9ff7dd730435ba59ffbacaf Mon Sep 17 00:00:00 2001
From: Simon McVittie <s...@collabora.com>
Date: Thu, 11 May 2017 17:26:36 +0100
Subject: [PATCH] Only set up base image device if requested

Adding a second virtual disk with the same UUIDs, partition labels,
filesystem labels etc. can interfere with anything that mounts filesystems
post-boot, and the attempts to address this in #842299 do not seem to
have been completely successful. Nested virtualization is a rare thing
to need, so let's make this opt-in.

Signed-off-by: Simon McVittie <s...@collabora.com>
---
 virt/autopkgtest-virt-qemu | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/virt/autopkgtest-virt-qemu b/virt/autopkgtest-virt-qemu
index eb3b162..5d55d2d 100755
--- a/virt/autopkgtest-virt-qemu
+++ b/virt/autopkgtest-virt-qemu
@@ -88,6 +88,11 @@ def parse_args():
                         help='Enable debugging output')
     parser.add_argument('--qemu-options',
                         help='Pass through arguments to QEMU command.')
+    parser.add_argument('--baseimage', action='store_true', default=False,
+                        help='Provide a read-only copy of the base image at /dev/baseimage')
+    parser.add_argument('--no-baseimage', dest='baseimage',
+                        action='store_false',
+                        help='Provide a read-only copy of the base image at /dev/baseimage')
     parser.add_argument('image', nargs='+',
                         help='disk image to add to the VM (in order)')
 
@@ -565,7 +570,8 @@ def hook_open():
             # files; let QEMU run with the deleted inode
             os.unlink(overlay)
         setup_shell()
-        setup_baseimage()
+        if args.baseimage:
+            setup_baseimage()
         setup_shared(shareddir)
         setup_config(shareddir)
         make_auxverb(shareddir)
@@ -604,11 +610,12 @@ def hook_cleanup():
 
 
 def hook_prepare_reboot():
-    # Remove baseimage drive again, so that it does not break the subsequent
-    # boot due to the duplicate UUID
-    monitor = VirtSubproc.get_unix_socket(os.path.join(workdir, 'monitor'))
-    monitor.send(b'device_del virtio-baseimage\n')
-    VirtSubproc.expect(monitor, b'(qemu)', 10)
+    if args.baseimage:
+        # Remove baseimage drive again, so that it does not break the subsequent
+        # boot due to the duplicate UUID
+        monitor = VirtSubproc.get_unix_socket(os.path.join(workdir, 'monitor'))
+        monitor.send(b'device_del virtio-baseimage\n')
+        VirtSubproc.expect(monitor, b'(qemu)', 10)
 
 
 def hook_wait_reboot():
@@ -618,7 +625,8 @@ def hook_wait_reboot():
     wait_boot()
     setup_shell()
     setup_shared(shareddir)
-    setup_baseimage()
+    if args.baseimage:
+        setup_baseimage()
 
 
 def hook_capabilities():
-- 
2.11.0

Reply via email to