diff --git a/qubes/storage/reflink.py b/qubes/storage/reflink.py index 3a550a9f..4189b5a0 100644 --- a/qubes/storage/reflink.py +++ b/qubes/storage/reflink.py @@ -30,28 +30,27 @@ import functools import glob import logging import os +import platform import subprocess import tempfile -import platform -import sys from contextlib import suppress import qubes.storage import qubes.utils -HOST_MACHINE = platform.machine() -if HOST_MACHINE == "x86_64": - FICLONE = 0x40049409 # defined in -elif HOST_MACHINE == "ppc64le": - FICLONE = 0x80049409 -else: - print("Missing IOCTL definitions for platform {}".format(HOST_MACHINE)) - sys.exit(1) - -LOOP_SET_CAPACITY = 0x4C07 # defined in LOGGER = logging.getLogger('qubes.storage.reflink') +# defined in +LOOP_SET_CAPACITY = 0x4C07 + +# defined in +FICLONE = { + 'x86_64': 0x40049409, + 'ppc64le': 0x80049409, +}[platform.machine()] + + def _coroutinized(function): ''' Wrap a synchronous function in a coroutine that runs the function via the event loop's ThreadPool-based default @@ -64,6 +63,7 @@ def _coroutinized(function): None, functools.partial(function, *args, **kwargs))) return wrapper + class ReflinkPool(qubes.storage.Pool): driver = 'file-reflink' _known_dir_path_prefixes = ['appvms', 'vm-templates']