← Back to team overview

curtin-dev team mailing list archive

[Merge] ~slyon/curtin:slyon/lp1895192 into curtin:master

 

Lukas Märdian has proposed merging ~slyon/curtin:slyon/lp1895192 into curtin:master.

Commit message:
curthooks:setup_zipl: use proper device path in root= parameter for the cmdline

Using root=UUID=... is not supported, according to https://wiki.ubuntu.com/FSTAB

Fixes LP: #1895192

Requested reviews:
  Michael Hudson-Doyle (mwhudson)
Related bugs:
  Bug #1895192 in curtin: "Optimistic approach of using zkey for encrypted installations on s390x not working"
  https://bugs.launchpad.net/curtin/+bug/1895192

For more details, see:
https://code.launchpad.net/~slyon/curtin/+git/curtin/+merge/406305

curthooks:setup_zipl: use proper device path in root= parameter for the cmdline

Using root=UUID=... is not supported, according to https://wiki.ubuntu.com/FSTAB

Fixes LP: #1895192
-- 
Your team curtin developers is subscribed to branch curtin:master.
diff --git a/curtin/commands/curthooks.py b/curtin/commands/curthooks.py
index eaeb9c4..1ab2431 100644
--- a/curtin/commands/curthooks.py
+++ b/curtin/commands/curthooks.py
@@ -177,14 +177,9 @@ def setup_zipl(cfg, target):
     # assuming that below gives the "/" rootfs
     target_dev = block.get_devices_for_mp(target)[0]
 
-    root_arg = None
-    # not mapped rootfs, use UUID
-    if 'mapper' in target_dev:
-        root_arg = target_dev
-    else:
-        uuid = block.get_volume_uuid(target_dev)
-        if uuid:
-            root_arg = "UUID=%s" % uuid
+    # get preferred device path, according to https://wiki.ubuntu.com/FSTAB
+    from curtin.commands.block_meta import get_volume_spec
+    root_arg = get_volume_spec(target_dev)
 
     if not root_arg:
         msg = "Failed to identify root= for %s at %s." % (target, target_dev)
diff --git a/tests/unittests/test_curthooks.py b/tests/unittests/test_curthooks.py
index ca0fc90..a4224a5 100644
--- a/tests/unittests/test_curthooks.py
+++ b/tests/unittests/test_curthooks.py
@@ -543,9 +543,39 @@ class TestSetupZipl(CiTestCase):
 
     @patch('curtin.block.get_devices_for_mp')
     @patch('platform.machine')
-    def test_setup_zipl_writes_etc_zipl_conf(self, m_machine, m_get_devices):
+    @patch('curtin.util.subp')
+    @patch('curtin.commands.block_meta._get_volume_type')
+    def test_setup_zipl_writes_etc_zipl_conf(self, m_get_volume_type, m_subp, m_machine, m_get_devices):
         m_machine.return_value = 's390x'
         m_get_devices.return_value = ['/dev/mapper/ubuntu--vg-root']
+        m_subp.return_value = ('''DEVPATH='/devices/virtual/block/dm-1'
+DEVNAME='/dev/dm-1'
+DEVTYPE='disk'
+MAJOR='253'
+MINOR='1'
+SUBSYSTEM='block'
+USEC_INITIALIZED='34095224'
+DM_UDEV_DISABLE_LIBRARY_FALLBACK_FLAG='1'
+DM_UDEV_PRIMARY_SOURCE_FLAG='1'
+DM_UDEV_RULES='1'
+DM_UDEV_RULES_VSN='2'
+DM_NAME='ubuntu--vg-root'
+DM_UUID='LVM-HNzpRb1VyhlJwt3nlvXsJH5KTpBUl2LpN08GkOLhEwDmN4an0K13rMAg7eJxxeBT'
+DM_SUSPENDED='0'
+DM_VG_NAME='ubuntu-vg'
+DM_LV_NAME='root'
+ID_FS_UUID='d1a2762f-133c-4297-af04-14f549376bda'
+ID_FS_UUID_ENC='d1a2762f-133c-4297-af04-14f549376bda'
+ID_FS_VERSION='1.0'
+ID_FS_TYPE='ext4'
+ID_FS_USAGE='filesystem'
+DM_TABLE_STATE='LIVE'
+DM_STATE='ACTIVE'
+DEVLINKS='/dev/disk/by-id/dm-name-ubuntu--vg-root /dev/mapper/ubuntu--vg-root /dev/ubuntu-vg/root /dev/disk/by-uuid/d1a2762f-133c-4297-af04-14f549376bda /dev/disk/by-id/dm-uuid-LVM-HNzpRb1VyhlJwt3nlvXsJH5KTpBUl2LpN08GkOLhEwDmN4an0K13rMAg7eJxxeBT'
+TAGS=':systemd:'
+CURRENT_TAGS=':systemd:'
+''', None)
+        m_get_volume_type.return_value = 'lvm'
         curthooks.setup_zipl(None, self.target)
         m_get_devices.assert_called_with(self.target)
         with open(os.path.join(self.target, 'etc', 'zipl.conf')) as stream:
@@ -553,6 +583,10 @@ class TestSetupZipl(CiTestCase):
         self.assertIn(
             '# This has been modified by the MAAS curtin installer',
             content)
+        # validate the root= parameter was properly set in the cmdline
+        self.assertIn(
+            'root=/dev/disk/by-id/dm-uuid-LVM-HNzpRb1VyhlJwt3nlvXsJH5KTpBUl2LpN08GkOLhEwDmN4an0K13rMAg7eJxxeBT',
+            content)
 
 
 class EfiOutput(object):

Follow ups