|
| 1 | +From 28d98401b965716b53f719d354f0ecbf5583601c Mon Sep 17 00:00:00 2001 |
| 2 | +From: Dan Smith <dansmith@redhat.com> |
| 3 | +Date: Mon, 13 Oct 2025 07:39:45 -0700 |
| 4 | +Subject: [PATCH] Handle images detected as ISO+GPT |
| 5 | + |
| 6 | +ISO images can have a system-specific bootloader prepended to them, |
| 7 | +which in the case of x86-64 would be a typical GPT/MBR boot sector, |
| 8 | +partition table, etc. These files are not uncommon amongst installer |
| 9 | +media and currently trigger and fail our format detection since they |
| 10 | +are identified as both ISO and GPT. This makes us allow these files |
| 11 | +if they are being uploaded with disk_format=iso as the target. No |
| 12 | +other multi-format combinations are allowed. |
| 13 | + |
| 14 | +Note that this only impacts the upload method and not import with |
| 15 | +format conversion. The latter is more complicated as we currently use |
| 16 | +oslo's detect_file_format() method which specifically disallows |
| 17 | +multiple formats. Converting from iso+gpt to anything else is not |
| 18 | +likely very useful and we already ignore it in the process (although |
| 19 | +after the inspection check). |
| 20 | + |
| 21 | +Closes-Bug: #2127789 |
| 22 | +Change-Id: I11a6872275568e874236ae78faf877db1bbfbb9a |
| 23 | +Signed-off-by: Dan Smith <dansmith@redhat.com> |
| 24 | +--- |
| 25 | + glance/location.py | 12 +++++++++++- |
| 26 | + 1 file changed, 11 insertions(+), 1 deletion(-) |
| 27 | + |
| 28 | +diff --git a/glance/location.py b/glance/location.py |
| 29 | +index b6d760cd38..d9a133b39a 100644 |
| 30 | +--- a/glance/location.py |
| 31 | ++++ b/glance/location.py |
| 32 | +@@ -605,7 +605,17 @@ class ImageProxy(glance.domain.proxy.Image): |
| 33 | + |
| 34 | + virtual_size = 0 |
| 35 | + try: |
| 36 | +- inspector = data.format |
| 37 | ++ matches = data.formats |
| 38 | ++ matched_formats = {str(i): i for i in matches} |
| 39 | ++ if matched_formats.keys() == {'iso', 'gpt'}: |
| 40 | ++ # If iso+gpt, we choose the iso because bootable-as-block ISOs |
| 41 | ++ # can legitimately have a GPT bootloader in front. |
| 42 | ++ LOG.debug('Detected format as ISO+GPT, allowing as ISO') |
| 43 | ++ inspector = matched_formats['iso'] |
| 44 | ++ else: |
| 45 | ++ # If multiple formats matched, but not exactly iso+gpt, |
| 46 | ++ # this will raise to disallow those combinations. |
| 47 | ++ inspector = data.format |
| 48 | + format = str(inspector) |
| 49 | + if format == self.image.disk_format: |
| 50 | + virtual_size = inspector.virtual_size |
| 51 | +-- |
| 52 | +2.34.1 |
0 commit comments