class ListAction(argparse.Action):
delimiter: str
+ deduplicate: bool = True
def __init__(self, *args: Any, choices: Optional[Iterable[Any]] = None, **kwargs: Any) -> None:
self.list_choices = choices
else:
ary.append(values)
- ary = remove_duplicates(ary)
+ if self.deduplicate:
+ ary = remove_duplicates(ary)
setattr(namespace, self.dest, ary)
delimiter = " "
+class RepeatableSpaceDelimitedListAction(SpaceDelimitedListAction):
+ deduplicate = False
+
+
class BooleanAction(argparse.Action):
"""Parse boolean command line arguments
)
group.add_argument(
"--qemu-args",
- action=SpaceDelimitedListAction,
+ action=RepeatableSpaceDelimitedListAction,
default=[],
# Suppress the command line option because it's already possible to pass qemu args as normal
# arguments.
is_eq = False
return is_eq
- def _append_list(self, ref_entry: str, new_args: Any, job_name: str = DEFAULT_JOB_NAME, separator: str = ",") -> None:
+ def _append_list(self, ref_entry: str, new_args: Any, job_name: str = DEFAULT_JOB_NAME, separator: str = ",", with_duplicates: bool = False) -> None:
"""Helper function handling comma separated list as supported by mkosi"""
args_list = []
if isinstance(new_args, str):
if isinstance(arg, str) and arg.startswith("!"):
if arg[1:] in self.reference_config[job_name][ref_entry]:
self.reference_config[job_name][ref_entry].remove(arg[1:])
- elif arg not in self.reference_config[job_name][ref_entry]:
+ elif with_duplicates or arg not in self.reference_config[job_name][ref_entry]:
self.reference_config[job_name][ref_entry].append(arg)
@staticmethod
self._append_list("extra_search_paths", mk_config_host["ExtraSearchPaths"], job_name, ":")
if "QemuHeadless" in mk_config_host:
self.reference_config[job_name]["qemu_headless"] = mk_config_host["QemuHeadless"]
+ if "QemuArgs" in mk_config_host:
+ self._append_list("qemu_args", mk_config_host["QemuArgs"], job_name, " ", with_duplicates=True)
if "Netdev" in mk_config_host:
self.reference_config[job_name]["netdev"] = mk_config_host["Netdev"]
if "Ephemeral" in mk_config_host:
"Host": {
"ExtraSearchPaths": "search/here:search/there",
"QemuHeadless": True,
+ "QemuArgs": "-vga none -device virtio-vga-gl",
"Netdev": True,
},
}
"Host": {
"ExtraSearchPaths": "search/ubu",
"QemuHeadless": True,
+ "QemuArgs": "-vga virtio -device usb-kbd -device usb-mouse",
"Netdev": True,
},
}
"Host": {
"ExtraSearchPaths": "search/debi",
"QemuHeadless": True,
+ "QemuArgs": "-nic user,model=virtio-net-pci",
"Netdev": True,
},
}