if args.build_dir is not None:
root_home(args, root).joinpath("build").mkdir(0o755)
- if args.network_veth and not do_run_build_script:
+ if args.netdev and not do_run_build_script:
root.joinpath("etc/systemd").mkdir(mode=0o755)
root.joinpath("etc/systemd/network").mkdir(mode=0o755)
configure_dracut(args, packages, root)
if do_run_build_script:
packages.update(args.build_packages)
- if not do_run_build_script and args.network_veth:
+ if not do_run_build_script and args.netdev:
add_packages(args, packages, "systemd-networkd", conditional="systemd")
install_packages_dnf(args, root, packages, do_run_build_script)
add_packages(args, packages, "systemd-boot", "systemd-cryptsetup", conditional="systemd")
add_packages(args, packages, "kernel-release-server", "binutils", "dracut", "timezone")
configure_dracut(args, packages, root)
- if args.network_veth:
+ if args.netdev:
add_packages(args, packages, "systemd-networkd", conditional="systemd")
if do_run_build_script:
packages.update(args.build_packages)
if not do_run_build_script and args.distribution == Distribution.centos_epel:
- if args.network_veth:
+ if args.netdev:
add_packages(args, packages, "systemd-networkd", conditional="systemd")
if epel_release >= 9:
add_packages(args, packages, "systemd-boot", conditional="systemd")
if do_run_build_script:
packages.update(args.build_packages)
- if not do_run_build_script and args.distribution == Distribution.rocky_epel and args.network_veth:
+ if not do_run_build_script and args.distribution == Distribution.rocky_epel and args.netdev:
add_packages(args, packages, "systemd-networkd", conditional="systemd")
install_packages_dnf(args, root, packages, do_run_build_script)
if do_run_build_script:
packages.update(args.build_packages)
- if not do_run_build_script and args.distribution == Distribution.alma_epel and args.network_veth:
+ if not do_run_build_script and args.distribution == Distribution.alma_epel and args.netdev:
add_packages(args, packages, "systemd-networkd", conditional="systemd")
install_packages_dnf(args, root, packages, do_run_build_script)
group.add_argument("--qemu-mem", help="Configure guest's RAM size", metavar="MEM", default="1G")
group.add_argument(
"--network-veth",
+ dest="netdev",
+ action=BooleanAction,
+ help=argparse.SUPPRESS,
+ ) # Compatibility option
+ group.add_argument(
+ "--netdev",
action=BooleanAction,
help="Create a virtual Ethernet link between the host and the container/VM",
)
MkosiPrinter.info("\nHOST CONFIGURATION:")
MkosiPrinter.info(" Extra search paths: " + line_join_list(args.extra_search_paths))
MkosiPrinter.info(" QEMU Headless: " + yes_no(args.qemu_headless))
- MkosiPrinter.info(" Network Veth: " + yes_no(args.network_veth))
+ MkosiPrinter.info(" Netdev: " + yes_no(args.netdev))
def reuse_cache_tree(
return f
-def setup_network_veth(args: MkosiArgs, root: Path, do_run_build_script: bool, cached: bool) -> None:
- if do_run_build_script or cached or not args.network_veth:
+def setup_netdev(args: MkosiArgs, root: Path, do_run_build_script: bool, cached: bool) -> None:
+ if do_run_build_script or cached or not args.netdev:
return
- with complete_step("Setting up network veth…"):
- network_file = root / "etc/systemd/network/80-mkosi-network-veth.network"
+ with complete_step("Setting up netdev…"):
+ network_file = 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(
set_serial_terminal(args, root, do_run_build_script, cached_tree)
set_autologin(args, root, do_run_build_script, cached_tree)
sshkey = setup_ssh(args, root, do_run_build_script, for_cache, cached_tree)
- setup_network_veth(args, root, do_run_build_script, cached_tree)
+ setup_netdev(args, root, do_run_build_script, cached_tree)
run_postinst_script(args, root, loopdev, do_run_build_script, for_cache)
if cleanup:
def virt_name(args: MkosiArgs) -> str:
name = args.hostname or args.image_id or args.output.with_suffix("").name.partition("_")[0]
- # Shorten to 13 characters so we can prefix with ve- or vt- for the network veth ifname which is limited
+ # Shorten to 13 characters so we can prefix with ve- or vt- for the netdev ifname which is limited
# to 16 characters.
return name[:13]
if args.verb != Verb.ssh:
# Some programs will use 'mkosi ssh' with pexpect, so don't print warnings that will break
# them.
- warn("--network-veth requires systemd-networkd to be running to initialize the host interface "
- "of the veth link ('systemctl enable --now systemd-networkd')")
+ warn("--netdev requires systemd-networkd to be running to initialize the host interface "
+ "of the virtual link ('systemctl enable --now systemd-networkd')")
return False
if args.verb == Verb.qemu and not has_networkd_vm_vt():
warn(dedent(r"""\
mkosi didn't find 80-vm-vt.network. This is one of systemd's built-in
systemd-networkd config files which configures vt-* interfaces.
- mkosi needs this file in order for --network-veth to work properly for QEMU
+ mkosi needs this file in order for --netdev to work properly for QEMU
virtual machines. The file likely cannot be found because the systemd version
on the host is too old (< 246) and it isn't included yet.
if is_generated_root(args) or args.verity:
cmdline += ["--volatile=overlay"]
- if args.network_veth:
+ if args.netdev:
if ensure_networkd(args):
cmdline += ["--network-veth"]
if not args.qemu_headless or (args.qemu_headless and "bios" in args.boot_protocols):
cmdline += ["-vga", "virtio"]
- if args.network_veth:
+ if args.netdev:
if not ensure_networkd(args):
# Fall back to usermode networking if the host doesn't have networkd (eg: Debian)
fwd = f",hostfwd=tcp::{args.ssh_port}-:{args.ssh_port}" if args.ssh_port != 22 else ""
"qemu_headless": False,
"qemu_smp": "2",
"qemu_mem": "1G",
- "network_veth": False,
+ "netdev": False,
"ephemeral": False,
"with_unified_kernel_images": True,
"hostonly_initrd": False,
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 "NetworkVeth" in mk_config_host:
- self.reference_config[job_name]["network_veth"] = mk_config_host["NetworkVeth"]
+ if "Netdev" in mk_config_host:
+ self.reference_config[job_name]["netdev"] = mk_config_host["Netdev"]
if "Ephemeral" in mk_config_host:
self.reference_config[job_name]["ephemeral"] = mk_config_host["Ephemeral"]
if "Ssh" in mk_config_host:
"Host": {
"ExtraSearchPaths": "search/here:search/there",
"QemuHeadless": True,
- "NetworkVeth": True,
+ "Netdev": True,
},
}
self._prepare_mkosi_default(directory, mk_config)
"Host": {
"ExtraSearchPaths": "search/ubu",
"QemuHeadless": True,
- "NetworkVeth": True,
+ "Netdev": True,
},
}
self._prepare_mkosi_default_d(directory, mk_config, 1)
"Host": {
"ExtraSearchPaths": "search/debi",
"QemuHeadless": True,
- "NetworkVeth": True,
+ "Netdev": True,
},
}
self._prepare_mkosi_default_d(directory, mk_config, 2)