diff --git a/build.sh b/build.sh index cde9934..6332b40 100755 --- a/build.sh +++ b/build.sh @@ -32,8 +32,8 @@ pacman-key --init pacman-key --populate archlinux pacman -Syu --noconfirm -pacman -S --noconfirm base linux linux-firmware mkinitcpio openssh kitty-terminfo -systemctl enable sshd +pacman -S --noconfirm base linux linux-firmware mkinitcpio openssh kitty-terminfo dhcpcd +systemctl enable sshd dhcpcd # Standard Archlinux Setup ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime diff --git a/network.sh b/network.sh index f2d57dc..899a2cc 100644 --- a/network.sh +++ b/network.sh @@ -1,4 +1,4 @@ ip address add 10.0.2.15/24 broadcast + dev ens3 ip link set dev ens3 up ip route add 10.0.2.0/24 dev ens3 -ip route add default via 10.0.2.2 dev ens3 +ip route add default via 10.0.2.2 dev ens3 \ No newline at end of file diff --git a/nim/README.md b/nim/README.md new file mode 100644 index 0000000..9bd25b2 --- /dev/null +++ b/nim/README.md @@ -0,0 +1 @@ +nim rewrite, wip diff --git a/nim/commands/qemu.nim b/nim/commands/qemu.nim index 3976ace..09aa8df 100644 --- a/nim/commands/qemu.nim +++ b/nim/commands/qemu.nim @@ -15,8 +15,9 @@ proc mount(source: cstring, target: cstring, filesystemtype: cstring, mountflags: culong, data: pointer): cint {.importc, header:""} const - GID_MAP = "/proc/self/gid_map" UID_MAP = "/proc/self/uid_map" + GID_MAP = "/proc/self/gid_map" + SETGROUPS = "/proc/self/setgroups" proc virtiofsd(paths: seq[string]): Pid = let uid = getuid() @@ -36,6 +37,7 @@ proc virtiofsd(paths: seq[string]): Pid = # map our uid to root writeFile(UID_MAP, &"0 {uid} 1") + writeFile(SETGROUPS, "deny") writeFile(GID_MAP, &"0 {gid} 1") # create a tmpfs in /var/run so virtiofsd can write there @@ -61,29 +63,35 @@ proc virtiofsd(paths: seq[string]): Pid = for process in procs: discard waitForExit(process) + quit(0) + proc qemu*(args: OptParser) = let childPid = virtiofsd(@["/tmp", "/home"]) + let args = @[ + "-enable-kvm", "-cpu", "host", "-m", "512m", "-smp", "2", + "-kernel", "/home/martin/code/qemu/build-image/image/vmlinuz-linux", + "-append", "earlyprintk=ttyS0 console=ttyS0 root=/dev/vda rw quiet", + "-initrd" , "/home/martin/code/qemu/build-image/image/initramfs-linux-custom.img", + "-m", "4G", "-object", "memory-backend-file,id=mem,size=4G,mem-path=/dev/shm,share=on", "-numa", "node,memdev=mem", + "-device", "virtio-rng-pci", + "-bios", "/usr/share/qemu/qboot.rom", + "-drive", "if=virtio,file=/home/martin/code/qemu/build-image/image/image.qcow2", + "-netdev", "user,id=net0,hostfwd=tcp::2222-:22", + "-device", "virtio-net-pci,netdev=net0", + "-nodefaults", "-no-user-config", "-nographic", + "-chardev", "socket,id=share.1,path=/tmp/mount.0.sock", + "-device", "vhost-user-fs-pci,queue-size=1024,chardev=share.1,tag=share.1", + "-serial", "stdio" + ] + let qemu = startProcess( command = "qemu-system-x86_64", options = {poParentStreams, poUsePath}, - args = @[ - "-enable-kvm", "-cpu", "host", "-m", "512m", "-smp", "2", - "-kernel", "/home/martin/code/qemu/build-image/image/vmlinuz-linux", - "-append", "earlyprintk=ttyS0 console=ttyS0 root=/dev/vda rw quiet", - "-initrd" , "/home/martin/code/qemu/build-image/image/initramfs-linux-custom.img", - "-m", "4G", "-object", "memory-backend-file,id=mem,size=4G,mem-path=/dev/shm,share=on", "-numa", "node,memdev=mem", - "-device", "virtio-rng-pci", - "-bios", "/usr/share/qemu/qboot.rom", - "-drive", "if=virtio,file=/home/martin/code/qemu/build-image/image/image.qcow2", - "-netdev", "user,id=net0,hostfwd=tcp::2222-:22", - "-device", "virtio-net-pci,netdev=net0", - "-nodefaults", "-no-user-config", "-nographic", - "-serial", "stdio" - ] + args = args ) discard waitForExit(qemu) - #discard kill(childPid, SIGTERM) - #discard waitPid(childPid,cast[var cint](nil),0) + discard kill(childPid, SIGTERM) + discard waitPid(childPid,cast[var cint](nil),0)