Skip to content

Commit 2cb6cb4

Browse files
povikmarcan
authored andcommitted
tools/run_guest.py: Add -v option for attaching 9P virtio exports
Signed-off-by: Martin Povišer <[email protected]>
1 parent 93c20e9 commit 2cb6cb4

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

proxyclient/tools/run_guest.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
import argparse, pathlib
77
from io import BytesIO
88

9+
def volumespec(s):
10+
return tuple(s.split(":", 2))
11+
912
parser = argparse.ArgumentParser(description='Run a Mach-O payload under the hypervisor')
1013
parser.add_argument('-s', '--symbols', type=pathlib.Path)
1114
parser.add_argument('-m', '--script', type=pathlib.Path, action='append', default=[])
@@ -18,6 +21,10 @@
1821
parser.add_argument('-r', '--raw', action="store_true")
1922
parser.add_argument('-E', '--entry-point', action="store", type=int, help="Entry point for the raw image", default=0x800)
2023
parser.add_argument('-a', '--append-payload', type=pathlib.Path, action="append", default=[])
24+
parser.add_argument('-v', '--volume', type=volumespec, action='append',
25+
help='Attach a 9P virtio device for file export to the guest. The argument is a host path to the '
26+
'exported tree, joined by colon (\':\') with a tag under which the tree will be advertised '
27+
'on the guest side.')
2128
parser.add_argument('payload', type=pathlib.Path)
2229
parser.add_argument('boot_args', default=[], nargs="*")
2330
args = parser.parse_args()
@@ -27,6 +34,7 @@
2734
from m1n1.utils import *
2835
from m1n1.shell import run_shell
2936
from m1n1.hv import HV
37+
from m1n1.hv.virtio import Virtio9PTransport
3038
from m1n1.hw.pmu import PMU
3139

3240
iface = UartInterface()
@@ -55,6 +63,10 @@
5563
if args.debug_xnu:
5664
hv.adt["chosen"].debug_enabled = 1
5765

66+
if args.volume:
67+
for path, tag in args.volume:
68+
hv.attach_virtio(Virtio9PTransport(root=path, tag=tag))
69+
5870
if args.logfile:
5971
hv.set_logfile(args.logfile.open("w"))
6072

0 commit comments

Comments
 (0)