only supported on images that contain a boot loader, i.e. those
built with `Bootable=yes` (see below). This command must be executed
as `root` unless the image already exists and `-f` is not specified.
- Some qemu arguments (such as those set by `Netdev=yes`) may also
- prevent qemu from starting when this command is executed by a
- non-root user.
`ssh`
cmdline += ["-vga", "virtio"]
if args.netdev:
- if not ensure_networkd(args):
- # Fall back to usermode networking if the host doesn't have networkd (eg: Debian)
+ if not ensure_networkd(args) or os.getuid() != 0:
+ # Fall back to usermode networking if the host doesn't have networkd (eg: Debian).
+ # Also fall back if running as an unprivileged user, which likely can't set up the tap interface.
fwd = f",hostfwd=tcp::{args.ssh_port}-:{args.ssh_port}" if args.ssh_port != 22 else ""
cmdline += ["-nic", f"user,model=virtio-net-pci{fwd}"]
else: