solo-io / unik

The Unikernel & MicroVM Compilation and Deployment Platform
Apache License 2.0
2.71k stars 191 forks source link

Failed to start unik daemon: failed to create boot volume from raw image on Windows #164

Closed hsluoyz closed 6 years ago

hsluoyz commented 6 years ago

After fixing a few issues when running unik daemon, I encountered a new issue:

Microsoft Windows [Version 10.0.17134.112]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\Users\luo>unik daemon --debug
time="2018-06-24T15:07:32+08:00" level=info msg="daemon started" config={{[] [] [] [{my-vbox vboxnet0 host_only}] [] [] [] [] []} 0.0.0}
time="2018-06-24T15:07:32+08:00" level=info msg="using container versions" versions=map[compilers-rump-java-xen:43365940a0dd610c compilers-rump-python3-xen:1496a60a071e79e1 compilers-rump-c-hw:1954dce79e407724 compilers-osv-dynamic:59ba07ca2f12ecaa compilers-mirage-ocaml-ukvm:2c35c23771682e9a boot-creator:d0665c8793b16c51 compilers-mirage-ocaml-xen:0cd46f5253c6ca8a compilers-rump-java-hw:e8c77dc577b288d9 compilers-rump-base-common:2eb72d1b386ce2a4 compilers-rump-python3-hw-no-stub:81a494acc94d7827 compilers-rump-base-hw:8cd85d4a7ee1009b compilers-rump-c-xen:65c2c7316ad6fc77 compilers-rump-base-xen:f841298dae4340f7 compilers-rump-python3-hw:22bc5378af6e099d compilers-rump-nodejs-hw:b5029ddcc8731a25 vsphere-client:a9538c7c242acbef compilers-rump-nodejs-xen:2fbc447253ba19b8 compilers-includeos-cpp-hw:694e22e023dbbbc8 rump-debugger-qemu:0a841d0bf71287e6 compilers-rump-go-xen:fe3335e71ed20510 compilers-rump-go-hw:d1bfbc13602e306d compilers-rump-nodejs-hw-no-stub:baebfe68f3283190 compilers-osv-java:14f2183e5cb49482 image-creator:fa560ac11cecae33 compilers-includeos-cpp-common:8de1311f7b1365d9 qemu-util:6f5922561bbb86e3]

... (a lot of logs here)

time="2018-06-24T15:08:19+08:00" level=debug msg="time=\"2018-06-24T07:08:19Z\" level=debug msg=\"writing boot template\" commandline=\"{\\\"rc\\\":[{\\\"bin\\\":\\\"program\\\",\\\"argv\\\":[\\\"-prefix\\\",\\\"unik_virtualbox\\\",\\\"-enablePersistence\\\"]}],\\\"net\\\":{\\\"if\\\":\\\"vioif0\\\",\\\"type\\\":\\\"inet\\\",\\\"method\\\":\\\"dhcp\\\"},\\\"net\\\":{\\\"if\\\":\\\"vioif1\\\",\\\"type\\\":\\\"inet\\\",\\\"method\\\":\\\"dhcp\\\"},\\\"blk\\\": {\\\"source\\\":\\\"dev\\\",\\\"path\\\":\\\"/dev/sd0e\\\",\\\"fstype\\\":\\\"blk\\\",\\\"mountpoint\\\":\\\"/bootpart\\\"},\\\"blk\\\": {\\\"source\\\":\\\"dev\\\",\\\"path\\\":\\\"/dev/sd1a\\\",\\\"fstype\\\":\\\"blk\\\",\\\"mountpoint\\\":\\\"/data\\\"}}\" fname=\"/tmp/stgr.mntpoint.583377675/boot/grub/grub.conf\" rootDrive=\"(hd0,0)\" "
time="2018-06-24T15:08:19+08:00" level=debug msg="time=\"2018-06-24T07:08:19Z\" level=debug msg=\"Writing device map\" device=\"/dev/unik-tmp059438940/hda\" file=\"/tmp/stgr.mntpoint.583377675/boot/grub/device.map\" "
time="2018-06-24T15:08:19+08:00" level=debug msg="time=\"2018-06-24T07:08:19Z\" level=debug msg=\"running grub-install\" args=[--no-floppy --root-directory=/tmp/stgr.mntpoint.583377675 /dev/unik-tmp059438940/hda] cmd=grub-install "
time="2018-06-24T15:08:20+08:00" level=debug msg="time=\"2018-06-24T07:08:20Z\" level=debug msg=\"running umount\" args=[/tmp/stgr.mntpoint.583377675] cmd=umount "
time="2018-06-24T15:08:20+08:00" level=debug msg="time=\"2018-06-24T07:08:20Z\" level=debug msg=\"running losetup\" args=[-d /dev/loop1] cmd=losetup "
time="2018-06-24T15:08:20+08:00" level=debug msg="time=\"2018-06-24T07:08:20Z\" level=debug msg=\"running losetup\" args=[-d /dev/loop0] cmd=losetup "
time="2018-06-24T15:08:21+08:00" level=debug msg="time=\"2018-06-24T07:08:21Z\" level=info msg=\"wrote 63963136 bytes to disk\" "
time="2018-06-24T15:08:22+08:00" level=info msg="staging new instance listener image"
time="2018-06-24T15:08:22+08:00" level=debug msg="making directory: C:\\Users\\luo\\.unik\\virtualbox\\images\\VboxUnikInstanceListener"
time="2018-06-24T15:08:22+08:00" level=info msg="creating boot volume from raw image" raw-image=&{C:\Users\luo\AppData\Local\Temp\boot-creator-result.img.182139160 {raw } {[{/ sd0} {/data sd1a}] 256 0 SCSI  }}
time="2018-06-24T15:08:22+08:00" level=debug msg="running command" command=[qemu-img convert -f raw -O vmdk -o compat6 C:\Users\luo\AppData\Local\Temp\boot-creator-result.img.182139160 C:\Users\luo\.unik\virtualbox\images\VboxUnikInstanceListener\convert.image.result.421747095]
time="2018-06-24T15:08:22+08:00" level=info msg="Build cmd for container projectunik/qemu-util:6f5922561bbb86e3" args=[run --rm -v C:\Users\luo\AppData\Local\Temp:C:\Users\luo\AppData\Local\Temp -v C:\Users\luo\.unik\virtualbox\images\VboxUnikInstanceListener:C:\Users\luo\.unik\virtualbox\images\VboxUnikInstanceListener --name=6fab86d3-be90-4dcf-9204-517662b443b0 projectunik/qemu-util:6f5922561bbb86e3 qemu-img convert -f raw -O vmdk -o compat6 C:\Users\luo\AppData\Local\Temp\boot-creator-result.img.182139160 C:\Users\luo\.unik\virtualbox\images\VboxUnikInstanceListener\convert.image.result.421747095]
time="2018-06-24T15:08:22+08:00" level=debug msg="running command" command=[docker run --rm -v C:\Users\luo\AppData\Local\Temp:C:\Users\luo\AppData\Local\Temp -v C:\Users\luo\.unik\virtualbox\images\VboxUnikInstanceListener:C:\Users\luo\.unik\virtualbox\images\VboxUnikInstanceListener --name=6fab86d3-be90-4dcf-9204-517662b443b0 projectunik/qemu-util:6f5922561bbb86e3 qemu-img convert -f raw -O vmdk -o compat6 C:\Users\luo\AppData\Local\Temp\boot-creator-result.img.182139160 C:\Users\luo\.unik\virtualbox\images\VboxUnikInstanceListener\convert.image.result.421747095]
time="2018-06-24T15:08:23+08:00" level=debug msg="docker: Error response from daemon: Mount denied:"
time="2018-06-24T15:08:23+08:00" level=debug msg="The source path \"C:/Users/luo/AppData/Local/Temp:C\""
time="2018-06-24T15:08:23+08:00" level=debug msg="doesn't exist and is not known to Docker."
time="2018-06-24T15:08:23+08:00" level=debug msg="See 'docker run --help'."
time="2018-06-24T15:08:23+08:00" level=error msg="running daemon failed: [cmd/daemon.go:86] daemon failed to initialize: {[daemon/daemon.go:107] initializing virtualbox provider: {[virtualbox/virtualbox_provider.go:49] deploying virtualbox instance listener: {[virtualbox/deploy_instance_listener.go:51] building bootable virtualbox image for instsance listener: {[virtualbox/stage.go:43] converting raw image to vmdk: {[common/qemu.go:45] failed converting raw image to vmdk: {exit status 125}}}}}}"

C:\Users\luo>

It seems that the volume mounting of the following docker run command generated by unik is wrong.

docker run --rm -v C:\Users\luo\AppData\Local\Temp:C:\Users\luo\AppData\Local\Temp -v C:\Users\luo\.unik\virtualbox\images\VboxUnikInstanceListener:C:\Users\luo\.unik\virtualbox\images\VboxUnikInstanceListener --name=6fab86d3-be90-4dcf-9204-517662b443b0 projectunik/qemu-util:6f5922561bbb86e3 qemu-img convert -f raw -O vmdk -o compat6 C:\Users\luo\AppData\Local\Temp\boot-creator-result.img.182139160 C:\Users\luo\.unik\virtualbox\images\VboxUnikInstanceListener\convert.image.result.421747095

The host path C:\Users\luo\AppData\Local\Temp is mounted to the container's exactly same path C:\Users\luo\AppData\Local\Temp. But the container is Linux, and the path won't exist. So unik should mount to another path on Windows, like hard-coding it to a custom path to do the image conversion.

hsluoyz commented 6 years ago

I think here's the problematic code.

https://github.com/solo-io/unik/blob/d063598a958dcb2a517b0ef9eab030d3aa8a4c31/pkg/providers/common/qemu.go#L25-L26