Skip to content

Commit a433454

Browse files
committed
vng: support both --blk-disk and --disk in the vng CLI
This is a behavioral change (although one that brings the behavior _in line_ with the documentation). Previously, `vng --disk` was converted to `virtme-run --blk-disk` internally, contrary to the `vng` help which is saying that `--disk` adds a virtio-scsi disk. Support both `vng --disk` (which is converted to `virtme-run --disk`) and `vng --blk-disk` (which is converted to `virtme-run --blk-disk`). Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name>
1 parent 83a661f commit a433454

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

virtme_ng/run.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,13 @@ def make_parser():
433433
help="Add a file as virtio-scsi disk (can be used multiple times)",
434434
)
435435

436+
parser.add_argument(
437+
"--blk-disk",
438+
action="append",
439+
metavar="PATH",
440+
help="Add a file as virtio-blk disk (can be used multiple times)",
441+
)
442+
436443
parser.add_argument(
437444
"--exec",
438445
"-e",
@@ -1161,13 +1168,24 @@ def _get_virtme_remote_cmd(self, args):
11611168
self.virtme_param["remote_cmd"] = ""
11621169

11631170
def _get_virtme_disk(self, args):
1171+
disk_str = ""
1172+
1173+
def ensure_name(dsk: str) -> str:
1174+
if "=" not in dsk:
1175+
return f"{dsk}={dsk}"
1176+
return dsk
1177+
11641178
if args.disk is not None:
1165-
disk_str = ""
11661179
for dsk in args.disk:
1167-
disk_str += f"--blk-disk {dsk}={dsk} "
1168-
self.virtme_param["disk"] = disk_str
1169-
else:
1170-
self.virtme_param["disk"] = ""
1180+
dsk = ensure_name(dsk)
1181+
disk_str += f"--disk {shlex.quote(dsk)} "
1182+
1183+
if args.blk_disk is not None:
1184+
for dsk in args.blk_disk:
1185+
dsk = ensure_name(dsk)
1186+
disk_str += f"--blk-disk {shlex.quote(dsk)} "
1187+
1188+
self.virtme_param["disk"] = disk_str
11711189

11721190
def _get_virtme_sound(self, args):
11731191
if args.sound:

0 commit comments

Comments
 (0)