File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -366,6 +366,23 @@ def safety_check(self):
366366 not self .has_unknown_features )
367367
368368
369+ class QEDInspector (FileInspector ):
370+ def __init__ (self , tracing = False ):
371+ super ().__init__ (tracing )
372+ self .new_region ('header' , CaptureRegion (0 , 512 ))
373+
374+ @property
375+ def format_match (self ):
376+ if not self .region ('header' ).complete :
377+ return False
378+ return self .region ('header' ).data .startswith (b'QED\x00 ' )
379+
380+ def safety_check (self ):
381+ # QED format is not supported by anyone, but we want to detect it
382+ # and mark it as just always unsafe.
383+ return False
384+
385+
369386# The VHD (or VPC as QEMU calls it) format consists of a big-endian
370387# 512-byte "footer" at the beginning of the file with various
371388# information, most of which does not matter to us:
@@ -879,6 +896,7 @@ def get_inspector(format_name):
879896 'vhdx' : VHDXInspector ,
880897 'vmdk' : VMDKInspector ,
881898 'vdi' : VDIInspector ,
899+ 'qed' : QEDInspector ,
882900 }
883901
884902 return formats .get (format_name )
Original file line number Diff line number Diff line change @@ -179,6 +179,12 @@ def test_from_file_reads_minimum(self):
179179 # a local file.
180180 self .assertLess (fmt .actual_size , file_size )
181181
182+ def test_qed_always_unsafe (self ):
183+ img = self ._create_img ('qed' , 10 * units .Mi )
184+ fmt = format_inspector .get_inspector ('qed' ).from_file (img )
185+ self .assertTrue (fmt .format_match )
186+ self .assertFalse (fmt .safety_check ())
187+
182188 def _test_vmdk_bad_descriptor_offset (self , subformat = None ):
183189 format_name = 'vmdk'
184190 image_size = 10 * units .Mi
You can’t perform that action at this time.
0 commit comments