firecracker-microvm / firectl

firectl is a command-line tool to run Firecracker microVMs
Apache License 2.0
477 stars 72 forks source link

firectl does not pass socket options to firecracker process #22

Closed nmeyerhans closed 5 years ago

nmeyerhans commented 5 years ago

By default, firecracker uses an API socket at /tmp/firecracker.socket. Firectl attempts to override this default and create a unique socket path in a temp directory. From the --help output:

  -s, --socket-path=            path to use for firecracker socket, defaults to a unique file in in the first existing

However, the socket path does not seem to be getting passed to the firecracker process:

$ ./firectl --kernel=~/vmlinux --root-drive=~/image-debootstrap.img
INFO[0000] Called startVMM(), setting up a VMM on /home/admin/.firecracker.sock-35004-81 
2019-02-26T01:51:42.408071099 [anonymous-instance:ERROR:src/main.rs:49] Panic occurred: PanicInfo { payload: Any, message: Some(Cannot create VMM.: Kvm(Error(13))), location: Location { file: "libcore/result.rs", line: 1009, col: 5 } }
2019-02-26T01:51:42.427743984 [anonymous-instance:ERROR:src/main.rs:53] stack backtrace:
   0:           0x55268c - backtrace::backtrace::trace::h7636f2037a19752b
   1:           0x57d8b2 - firecracker::main::{{closure}}::h9c4455b40f8ff3d1
   2:           0x5542fb - std::panicking::rust_panic_with_hook::h7d39a7695d8da98f
                        at libstd/panicking.rs:481
   3:           0x55413d - std::panicking::continue_panic_fmt::ha287897123d4a956
                        at libstd/panicking.rs:391
   4:           0x5566b5 - rust_begin_unwind
                        at libstd/panicking.rs:326
   5:           0x56da9b - core::panicking::panic_fmt::h2155aa66b67fe83c
                        at libcore/panicking.rs:77
   6:           0x459a42 - core::result::unwrap_failed::hcc02818eb22281d3
   7:           0x451c44 - std::sys_common::backtrace::__rust_begin_short_backtrace::h3c840c9c993b2e45
   8:           0x45010d - <F as alloc::boxed::FnBox<A>>::call_box::h0f514b8e7e095144
   9:           0x556f91 - std::sys::unix::thread::Thread::new::thread_start::hbd34cf20156b5b37
                        at liballoc/boxed.rs:656
2019-02-26T01:51:42.427803140 [anonymous-instance:ERROR:src/main.rs:57] Failed to log metrics while panicking: Logger was not initialized.
WARN[0000] firecracker exited: signal: aborted          
INFO[0000] VMM logging and metrics disabled.            
ERRO[0000] PutMachineConfiguration returned [PUT /machine-config][204] putMachineConfigurationNoContent  
WARN[0000] Failed handler "fcinit.CreateMachine": Put http://localhost/machine-config: dial unix /home/admin/.firecracker.sock-35004-81: connect: no such file or directory 
FATA[0000] Failed to start machine: Put http://localhost/machine-config: dial unix /home/admin/.firecracker.sock-35004-81: connect: no such file or directory 

Note the last line indicating that firectl wasn't able to communicate with firecracker on /home/admin/.firecracker.sock-35004-81 due to that file not existing.

Investigating somewhat deeper reveals that firecracker is not being given the --socket-path option at all:

$ strace -f -e execve ./firectl --kernel=~/vmlinux --root-drive=~/image-debootstrap.img
...
[pid 35093] execve("/usr/local/bin/firecracker", ["firecracker"], [/* 24 vars */]) = 0
...
FATA[0000] Failed to start machine: Put http://localhost/machine-config: dial unix /home/admin/.firecracker.sock-35075-81: connect: no such file or directory

If we tell firectl to use a socket path that matches firecracker's default, then machine launch is successful:

$ ./firectl --kernel=~/vmlinux --root-drive=~/image-debootstrap.img -s /tmp/firecracker.socket
...
INFO[0000] startInstance successful: [PUT /actions][204] createSyncActionNoContent
...
nmeyerhans commented 5 years ago

Closed with PR #23