: Space-delimited list of additional arguments to pass when invoking
qemu.
-`Netdev=`, `--netdev`
-
-: When used with the boot or qemu verbs, this option creates a virtual
- ethernet link between the host and the container/VM. The host
- interface is automatically picked up by systemd-networkd as documented
- in systemd-nspawn's man page:
- https://www.freedesktop.org/software/systemd/man/systemd-nspawn.html#-n
-
`Ephemeral=`, `--ephemeral`
: When used with the `shell`, `boot`, or `qemu` verbs, this option
detect_distribution,
flatten,
format_rlimit,
- is_centos_variant,
is_dnf_distribution,
patch_file,
set_umask,
# arguments.
help=argparse.SUPPRESS,
)
- group.add_argument(
- "--network-veth", # Compatibility option
- dest="netdev",
- metavar="BOOL",
- action=BooleanAction,
- help=argparse.SUPPRESS,
- )
- group.add_argument(
- "--netdev",
- metavar="BOOL",
- action=BooleanAction,
- help="Create a virtual Ethernet link between the host and the container/VM",
- )
group.add_argument(
"--ephemeral",
metavar="BOOL",
if args.repo_dirs:
args.repo_dirs = [p.absolute() for p in args.repo_dirs]
- if args.netdev and is_centos_variant(args.distribution) and "epel" not in args.repositories:
- die("--netdev is only supported on EPEL centOS variants")
-
# If we are building a sysext we don't want to add base packages to the
# extension image, as they will already be in the base image.
if args.base_image is not None:
print(" Extra search paths:", line_join_list(config.extra_search_paths))
print(" QEMU Extra Arguments:", line_join_list(config.qemu_args))
- print(" Netdev:", yes_no(config.netdev))
def make_output_dir(state: MkosiState) -> None:
presetdir.joinpath("80-mkosi-ssh.preset").write_text("enable ssh.socket")
-def configure_netdev(state: MkosiState) -> None:
- if not state.config.netdev or state.for_cache:
- return
-
- with complete_step("Setting up netdevā¦"):
- network_file = state.root / "etc/systemd/network/80-mkosi-netdev.network"
- with open(network_file, "w") as f:
- # Adapted from https://github.com/systemd/systemd/blob/v247/network/80-container-host0.network
- f.write(
- dedent(
- """\
- [Match]
- Virtualization=!container
- Type=ether
- Driver=virtio_net
-
- [Network]
- DHCP=yes
- LinkLocalAddressing=yes
- LLDP=yes
- EmitLLDP=customer-bridge
-
- [DHCP]
- UseTimezone=yes
- """
- )
- )
-
- os.chmod(network_file, 0o644)
-
- run(["systemctl", "--root", state.root, "enable", "systemd-networkd"])
-
-
def configure_initrd(state: MkosiState) -> None:
if state.for_cache or not state.config.output_format == OutputFormat.cpio:
return
configure_root_password(state)
configure_autologin(state)
configure_dracut(state, cached)
- configure_netdev(state)
configure_initrd(state)
run_build_script(state)
install_build_dest(state)
if nspawn_knows_arg(console_arg):
cmdline += [console_arg]
- if config.netdev:
- cmdline += ["--network-veth"]
-
if config.ephemeral:
cmdline += ["--ephemeral"]
"rng-random,filename=/dev/urandom,id=rng0",
"-device",
"virtio-rng-pci,rng=rng0,id=rng-device0",
+ "-nic",
+ "user,model=virtio-net-pci",
]
try:
# -serial mon:stdio adds back the serial device removed by -nodefaults.
cmdline += ["-nographic", "-nodefaults", "-serial", "mon:stdio"]
- if config.netdev:
- cmdline += ["-nic", "user,model=virtio-net-pci"]
-
cmdline += ["-drive", f"if=pflash,format=raw,readonly=on,file={firmware}"]
for k, v in config.credentials.items():