hwdb: fix screen rotation for EXO Wings 2in1 w1125 (#36283)
[systemd.io.git] / test / TEST-64-UDEV-STORAGE / nvme_subsystem.configure
blobed8b39ac5ff94171abeb2ef72dfa3c4caed1d198
1 #!/usr/bin/python3
2 # SPDX-License-Identifier: LGPL-2.1-or-later
4 import json
5 import os
6 import shutil
7 import subprocess
8 import sys
11 config = json.load(sys.stdin)
13 qemu = shutil.which("/usr/libexec/qemu-kvm") or f"qemu-system-{os.environ['QEMU_ARCHITECTURE']}"
14 result = subprocess.run([qemu, "-device", "help"], check=True, text=True, stdout=subprocess.PIPE)
15 if 'name "nvme"' not in result.stdout:
16     print("nvme device driver is not available, skipping test...", file=sys.stderr)
17     exit(77)
19 for id in ("nvme0", "nvme1"):
20     config["Drives"] += [
21         {
22             "Id": id,
23             "Size": "1M",
24             "Options": "cache=unsafe",
25         }
27     ]
29 config["QemuArgs"] += [
30     # Create an NVM Subsystem Device
31     "-device", "nvme-subsys,id=nvme-subsys-64,nqn=subsys64",
32     # Attach two NVM controllers to it
33     "-device", "nvme,subsys=nvme-subsys-64,serial=deadbeef",
34     "-device", "nvme,subsys=nvme-subsys-64,serial=deadbeef",
35     # And create two shared namespaces attached to both controllers
36     "-device", "nvme-ns,drive=nvme0,nsid=16,shared=on",
37     "-device", "nvme-ns,drive=nvme1,nsid=17,shared=on",
40 json.dump(config, sys.stdout)