storage/reflink: tweak FICLONE definition

Get rid of an otherwise unused module-level variable (HOST_MACHINE), and
show the relevant file (reflink.py) in the error message:

Traceback (most recent call last):
  File "/usr/bin/qubesd", line 2, in <module>
    from qubes.tools.qubesd import main
  File "/usr/lib/python3.8/site-packages/qubes/__init__.py", line 801, in <module>
    from qubes.app import Qubes
  File "/usr/lib/python3.8/site-packages/qubes/app.py", line 64, in <module>
    import qubes.storage.reflink
  File "/usr/lib/python3.8/site-packages/qubes/storage/reflink.py", line 46, in <module>
    FICLONE = {
KeyError: 'armv7l'
qubesd.service: Main process exited, code=exited, status=1/FAILURE
This commit is contained in:
Rusty Bird 2021-02-15 14:10:44 +00:00
parent d1800f4960
commit c56f06166b
No known key found for this signature in database
GPG Key ID: 469D78F47AAF2ADF

View File

@ -30,28 +30,27 @@ import functools
import glob import glob
import logging import logging
import os import os
import platform
import subprocess import subprocess
import tempfile import tempfile
import platform
import sys
from contextlib import suppress from contextlib import suppress
import qubes.storage import qubes.storage
import qubes.utils import qubes.utils
HOST_MACHINE = platform.machine()
if HOST_MACHINE == "x86_64":
FICLONE = 0x40049409 # defined in <linux/fs.h>
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 <linux/loop.h>
LOGGER = logging.getLogger('qubes.storage.reflink') LOGGER = logging.getLogger('qubes.storage.reflink')
# defined in <linux/loop.h>
LOOP_SET_CAPACITY = 0x4C07
# defined in <linux/fs.h>
FICLONE = {
'x86_64': 0x40049409,
'ppc64le': 0x80049409,
}[platform.machine()]
def _coroutinized(function): def _coroutinized(function):
''' Wrap a synchronous function in a coroutine that runs the ''' Wrap a synchronous function in a coroutine that runs the
function via the event loop's ThreadPool-based default function via the event loop's ThreadPool-based default
@ -64,6 +63,7 @@ def _coroutinized(function):
None, functools.partial(function, *args, **kwargs))) None, functools.partial(function, *args, **kwargs)))
return wrapper return wrapper
class ReflinkPool(qubes.storage.Pool): class ReflinkPool(qubes.storage.Pool):
driver = 'file-reflink' driver = 'file-reflink'
_known_dir_path_prefixes = ['appvms', 'vm-templates'] _known_dir_path_prefixes = ['appvms', 'vm-templates']