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):
366
366
not self .has_unknown_features )
367
367
368
368
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
+
369
386
# The VHD (or VPC as QEMU calls it) format consists of a big-endian
370
387
# 512-byte "footer" at the beginning of the file with various
371
388
# information, most of which does not matter to us:
@@ -879,6 +896,7 @@ def get_inspector(format_name):
879
896
'vhdx' : VHDXInspector ,
880
897
'vmdk' : VMDKInspector ,
881
898
'vdi' : VDIInspector ,
899
+ 'qed' : QEDInspector ,
882
900
}
883
901
884
902
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):
179
179
# a local file.
180
180
self .assertLess (fmt .actual_size , file_size )
181
181
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
+
182
188
def _test_vmdk_bad_descriptor_offset (self , subformat = None ):
183
189
format_name = 'vmdk'
184
190
image_size = 10 * units .Mi
You can’t perform that action at this time.
0 commit comments