From 7d463c443a21d9582ee2f9a8b8a0105e8c701c62 Mon Sep 17 00:00:00 2001 From: zouge666 <1615379639@qq.com> Date: Thu, 27 Aug 2026 23:43:12 +0200 Subject: [PATCH] vmspawn: reject .mstack machine images gracefully OCI pulls create .mstack machine images, which vmspawn can discover via -M. Since vmspawn only supports directory and disk images, this currently reaches assert_not_reached() and aborts. Return EOPNOTSUPP with a readable error instead. Fixes #41541 --- src/vmspawn/vmspawn.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/vmspawn/vmspawn.c b/src/vmspawn/vmspawn.c index a2b8f222b2..8fb7e10492 100644 --- a/src/vmspawn/vmspawn.c +++ b/src/vmspawn/vmspawn.c @@ -4079,12 +4079,23 @@ static int determine_names(void) { if (r < 0) return log_error_errno(r, "Failed to find image for machine '%s': %m", arg_machine); - if (IN_SET(i->type, IMAGE_RAW, IMAGE_BLOCK)) + switch (i->type) { + case IMAGE_RAW: + case IMAGE_BLOCK: r = free_and_strdup(&arg_image, i->path); - else if (IN_SET(i->type, IMAGE_DIRECTORY, IMAGE_SUBVOLUME)) + break; + + case IMAGE_DIRECTORY: + case IMAGE_SUBVOLUME: r = free_and_strdup(&arg_directory, i->path); - else - assert_not_reached(); + break; + + default: + return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), + "Image '%s' at '%s' has unsupported type '%s'. " + "Please use 'systemd-nspawn -M %s' instead.", + arg_machine, i->path, image_type_to_string(i->type), arg_machine); + } if (r < 0) return log_oom(); } else {