storage/lvm: use dd for importing volumes
...instead of manual copy in python. DD is much faster and when used with `conv=sparse` it will correctly preserve sparse image. QubesOS/qubes-issues#2256
This commit is contained in:
parent
8097da7cab
commit
9197bde76e
@ -141,19 +141,9 @@ class ThinPool(qubes.storage.Pool):
|
|||||||
else:
|
else:
|
||||||
dst_volume = self.create(dst_volume)
|
dst_volume = self.create(dst_volume)
|
||||||
|
|
||||||
cmd = ['sudo', 'qubes-lvm', 'import', dst_volume.vid]
|
cmd = ['sudo', 'dd', 'if=' + src_path, 'of=/dev/' + dst_volume.vid,
|
||||||
blk_size = 4096
|
'conv=sparse']
|
||||||
p = subprocess.Popen(cmd, stdin=subprocess.PIPE)
|
subprocess.check_call(cmd)
|
||||||
dst = p.stdin
|
|
||||||
with open(src_path, 'rb') as src:
|
|
||||||
while True:
|
|
||||||
tmp = src.read(blk_size)
|
|
||||||
if not tmp:
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
dst.write(tmp)
|
|
||||||
p.stdin.close()
|
|
||||||
p.wait()
|
|
||||||
reset_cache()
|
reset_cache()
|
||||||
return dst_volume
|
return dst_volume
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user