1818
1919MAX_QCOW_CHAIN_LENGTH : Final = 30
2020
21- QCOW2_DEFAULT_CLUSTER_SIZE : Final = 64 * 1024 # 64 KiB
21+ QCOW2_DEFAULT_CLUSTER_SIZE : Final = 16 * 1024 # 16 KiB
2222
2323MIN_QCOW_SIZE : Final = QCOW2_DEFAULT_CLUSTER_SIZE
2424
@@ -775,11 +775,12 @@ def coalesce(self, path: str) -> int:
775775
776776 @override
777777 def create (self , path : str , size : int , static : bool , msize : int = 0 , block_size : Optional [int ] = None ) -> None :
778- cmd = [QEMU_IMG , "create" , "-f" , QCOW2_TYPE , path , str (size )]
778+ cmd = [QEMU_IMG , "create" , "-f" , QCOW2_TYPE , path , str (size ), "-o" , "extended_l2=on" ]
779779 if static :
780780 cmd .extend (["-o" , "preallocation=full" ])
781- if block_size :
782- cmd .extend (["-o" , f"cluster_size={ str (block_size )} " ])
781+ if not block_size :
782+ block_size = QCOW2_DEFAULT_CLUSTER_SIZE
783+ cmd .extend (["-o" , f"cluster_size={ str (block_size )} " ])
783784 self ._ioretry (cmd )
784785 self .setHidden (path , False ) #We add hidden header at creation
785786
@@ -799,7 +800,7 @@ def snapshot(
799800 parent_type = QCOW2_TYPE
800801 parent_cluster_size = self .getBlockSize (parent )
801802
802- cmd = [QEMU_IMG , "create" , "-f" , QCOW2_TYPE , "-b" , parent , "-F" , parent_type , "-o" , f"cluster_size={ parent_cluster_size } " , path ]
803+ cmd = [QEMU_IMG , "create" , "-f" , QCOW2_TYPE , "-b" , parent , "-F" , parent_type , "-o" , f"extended_l2=on, cluster_size={ parent_cluster_size } " , path ]
803804 self ._ioretry (cmd )
804805 self .setHidden (path , False ) #We add hidden header at creation
805806
@@ -856,4 +857,4 @@ def setKey(self, path: str, key_hash: str) -> None:
856857
857858 @override
858859 def isCoalesceableOnRemote (self ) -> bool :
859- return True
860+ return True
0 commit comments