guix system reports an error when uuid is used in menu-entry

DoneSubmitted by tiantian.
Details
3 participants
  • Josselin Poiret
  • Marius Bakke
  • tiantian
Owner
unassigned
Severity
normal
T
T
tiantian wrote on 20 Aug 12:08 +0200
(address . bug-guix@gnu.org)
tencent_D8459481524DC143BF10352342BC0906A606@qq.com
I want to add an menu-entry in bootloader-configuration. I use uuid to
specify the partition in device field of menu-entry , because my
partition has no label. But when I use 'guix system reconfigure', guix
system reports an error: "guix system: error: #<<uuid> type: dce bv:
#vu8(109 91 19 212 96 146 70 208 139 228 7 61 192 116 19 204)>: invalid
G-expression input"
After asking friends in #guixcn, I still can't get more error messages.
It's the only error message. I can't find its reason.
To find the problem, I also simplified my configuration file and tried
to use ‘git bisect’ to find it, but I failed. I couldn't find a good
commit. I rolled back to c1719a0 commit in git repository, but I still
got the error message after building and using './pre-inst-env guix
system build ./config-test.scm'. I had to give up solving it and just
send an email to report the bug.
My English is poor. I use translation software. If the grammar is wrong,
please forgive me.
Attachment: file
(use-modules (gnu) (gnu system nss) (gnu system linux-initrd) (gnu bootloader grub) (guix gexp) (guix channels) (guix inferior) (srfi srfi-1)) (use-service-modules desktop xorg mail nix networking sddm docker) (use-package-modules certs gnome fonts xfce linux) (operating-system (host-name "guix-pc") (timezone "Asia/Shanghai") (locale "zh_CN.utf8") (keyboard-layout (keyboard-layout "cn")) (bootloader (bootloader-configuration (bootloader grub-efi-bootloader) (target "/boot/efi") (menu-entries (list ;; (menu-entry ;; (label "archlinux") ;; (device (uuid "1C31-A17C" 'fat)) ;; (chain-loader "/EFI/ArchLinux/grubx64.efi")) (menu-entry (label "test") (device (uuid "6d5b13d4-6092-46d0-8be4-073dc07413cc")) (linux "/rootfs/gnu/store/7rbmca2wcgsbxhdh4w1whmz7q6rndmlm-linux-5.18.14/bzImage") (initrd "/rootfs/gnu/store/22zfdzd6c7blr2k009armbdwgji20a4b-raw-initrd/initrd.cpio.gz")))) (keyboard-layout keyboard-layout))) (file-systems (cons* (file-system (device (file-system-label "guix-root")) (mount-point "/") (type "btrfs") (options "subvol=rootfs,ssd,discard,compress")) (file-system (device (file-system-label "Linux_home")) (mount-point "/home") (type "ext4")) (file-system (device (uuid "1C31-A17C" 'fat)) (mount-point "/boot/efi") (type "vfat")) %base-file-systems)) )
Attachment: OpenPGP_signature
J
J
Josselin Poiret wrote on 21 Aug 10:39 +0200
87sflquh1o.fsf@jpoiret.xyz
Hi,

tiantian <typ22@foxmail.com> writes:

Toggle quote (7 lines)
> I want to add an menu-entry in bootloader-configuration. I use uuid to
> specify the partition in device field of menu-entry , because my
> partition has no label. But when I use 'guix system reconfigure', guix
> system reports an error: "guix system: error: #<<uuid> type: dce bv:
> #vu8(109 91 19 212 96 146 70 208 139 228 7 61 192 116 19 204)>: invalid
> G-expression input"

Right, this is an issue with how we translate the menu-entries to sexps
through `menu-entry->sexp`, which then get embedded into a g-exp via
`operating-system-boot-parameters-file`! We didn't take into account
non-string devices there. The following two patches should fix the
issue and introduce some tests for it.

Best,
--
Josselin Poiret
J
J
Josselin Poiret wrote on 21 Aug 10:41 +0200
[PATCH 1/2] bootloader: Convert device in menu-entry to proper sexp.
890dac3c17576de37837ba96a4d45d8be68eecdf.1661070933.git.dev@jpoiret.xyz
Previously, menu-entry->sexp didn't try to convert `device` to a
proper sexp, which was inserted directly into the boot parameters
G-exp, leading to a G-exp input error. Now convert both uuid and
file-system-label possibilities to sexps, and add parsing code to
sexp->menu-entry. This fixes #57307.

* gnu/bootloader.scm (menu-entry->sexp, sexp->menu-entry): Take
non-string devices into account.
---
gnu/bootloader.scm | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)

Toggle diff (79 lines)
diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm
index 9cf5457873..1f08ab170e 100644
--- a/gnu/bootloader.scm
+++ b/gnu/bootloader.scm
@@ -21,6 +21,8 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu bootloader)
+  #:use-module (gnu system file-systems)
+  #:use-module (gnu system uuid)
   #:use-module (guix discovery)
   #:use-module (guix gexp)
   #:use-module (guix profiles)
@@ -105,12 +107,19 @@ (define-record-type* <menu-entry>
 
 (define (menu-entry->sexp entry)
   "Return ENTRY serialized as an sexp."
+  (define (device->sexp device)
+    (match device
+      ((? uuid? uuid)
+       `(uuid ,(uuid-type uuid) ,(uuid->string uuid)))
+      ((? file-system-label? label)
+       `(label ,(file-system-label->string label)))
+      (_ device)))
   (match entry
     (($ <menu-entry> label device mount-point linux linux-arguments initrd #f
                      ())
      `(menu-entry (version 0)
                   (label ,label)
-                  (device ,device)
+                  (device ,(device->sexp device))
                   (device-mount-point ,mount-point)
                   (linux ,linux)
                   (linux-arguments ,linux-arguments)
@@ -119,7 +128,7 @@ (define (menu-entry->sexp entry)
                      multiboot-kernel multiboot-arguments multiboot-modules)
      `(menu-entry (version 0)
                   (label ,label)
-                  (device ,device)
+                  (device ,(device->sexp device))
                   (device-mount-point ,mount-point)
                   (multiboot-kernel ,multiboot-kernel)
                   (multiboot-arguments ,multiboot-arguments)
@@ -128,6 +137,13 @@ (define (menu-entry->sexp entry)
 (define (sexp->menu-entry sexp)
   "Turn SEXP, an sexp as returned by 'menu-entry->sexp', into a <menu-entry>
 record."
+  (define (sexp->device device-sexp)
+    (match device-sexp
+      (('uuid type uuid-string)
+       (uuid uuid-string type))
+      (('label label)
+       (file-system-label label))
+      (_ device-sexp)))
   (match sexp
     (('menu-entry ('version 0)
                   ('label label) ('device device)
@@ -136,7 +152,7 @@ (define (sexp->menu-entry sexp)
                   ('initrd initrd) _ ...)
      (menu-entry
       (label label)
-      (device device)
+      (device (sexp->device device))
       (device-mount-point mount-point)
       (linux linux)
       (linux-arguments linux-arguments)
@@ -149,7 +165,7 @@ (define (sexp->menu-entry sexp)
                   ('multiboot-modules multiboot-modules) _ ...)
      (menu-entry
       (label label)
-      (device device)
+      (device (sexp->device device))
       (device-mount-point mount-point)
       (multiboot-kernel multiboot-kernel)
       (multiboot-arguments multiboot-arguments)

base-commit: b8f2eb286ec52c97048e23d326d94ae5772797e8
-- 
2.37.1
J
J
Josselin Poiret wrote on 21 Aug 10:41 +0200
[PATCH 2/2] tests: Add test for menu-entry roundtrips as sexps.
fd9865596fd75213c4b6bc2595300ba1294b1a81.1661070933.git.dev@jpoiret.xyz
* tests/boot-parameters.scm (%uuid-menu-entry,
%file-system-label-menu-entry): New variables.
("menu-entry roundtrip, uuid", "menu-entry roundtrip,
file-system-label"): New tests.
---
tests/boot-parameters.scm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)

Toggle diff (33 lines)
diff --git a/tests/boot-parameters.scm b/tests/boot-parameters.scm
index 8e48e1775e..811ecffd75 100644
--- a/tests/boot-parameters.scm
+++ b/tests/boot-parameters.scm
@@ -303,4 +303,26 @@ (define operating-system-boot-parameters
    (operating-system-boot-parameters %default-operating-system
                                      %default-root-device)))
 
+(define %uuid-menu-entry
+  (menu-entry
+   (label "test")
+   (device (uuid "6d5b13d4-6092-46d0-8be4-073dc07413cc"))
+   (linux "/boot/bzImage")
+   (initrd "/boot/initrd.cpio.gz")))
+
+(define %file-system-label-menu-entry
+  (menu-entry
+   (label "test")
+   (device (file-system-label "test-label"))
+   (linux "/boot/bzImage")
+   (initrd "/boot/initrd.cpio.gz")))
+
+(test-equal "menu-entry roundtrip, uuid"
+  %uuid-menu-entry
+  (sexp->menu-entry (menu-entry->sexp %uuid-menu-entry)))
+
+(test-equal "menu-entry roundtrip, file-system-label"
+  %file-system-label-menu-entry
+  (sexp->menu-entry (menu-entry->sexp %file-system-label-menu-entry)))
+
 (test-end "boot-parameters")
-- 
2.37.1
J
J
Josselin Poiret wrote on 21 Aug 15:03 +0200
Re: bug#57307: guix system reports an error when uuid is used in menu-entry
87k071vjd5.fsf@jpoiret.xyz
Hi again,

tiantian <typ22@foxmail.com> writes:

Toggle quote (2 lines)
> Should I close this bug now?

Let's wait for a maintainer to push the fix first, they will most likely
close the bug themselves.

I'm glad this fix worked and that you were able to figure out your other
issue! See you around.

Best,
--
Josselin Poiret
M
M
Marius Bakke wrote on 28 Aug 23:46 +0200
87tu5wdosl.fsf@gnu.org
Josselin Poiret via Bug reports for GNU Guix <bug-guix@gnu.org> skriver:

Toggle quote (17 lines)
> Hi,
>
> tiantian <typ22@foxmail.com> writes:
>
>> I want to add an menu-entry in bootloader-configuration. I use uuid to
>> specify the partition in device field of menu-entry , because my
>> partition has no label. But when I use 'guix system reconfigure', guix
>> system reports an error: "guix system: error: #<<uuid> type: dce bv:
>> #vu8(109 91 19 212 96 146 70 208 139 228 7 61 192 116 19 204)>: invalid
>> G-expression input"
>
> Right, this is an issue with how we translate the menu-entries to sexps
> through `menu-entry->sexp`, which then get embedded into a g-exp via
> `operating-system-boot-parameters-file`! We didn't take into account
> non-string devices there. The following two patches should fix the
> issue and introduce some tests for it.

Pushed in:

3294fa2ba4 tests: Add test for menu-entry roundtrips as sexps.
0811d2cb8d bootloader: Convert device in menu-entry to proper sexp.

Thanks!
-----BEGIN PGP SIGNATURE-----

iIUEARYKAC0WIQRNTknu3zbaMQ2ddzTocYulkRQQdwUCYwviOw8cbWFyaXVzQGdu
dS5vcmcACgkQ6HGLpZEUEHfOLQD9HgakL3M7bY73Y96Mwy3Z6QJHAikFH3tvjJJp
V1+0llsA/AvrO2hKLuZ3BNS5EKnS0DxmzxH7V5GfV9sWxwUBR20M
=e9S/
-----END PGP SIGNATURE-----

Closed
?
Your comment

This issue is archived.

To comment on this conversation send email to 57307@debbugs.gnu.org