Skip to content

Commit

Permalink
internal/server/instance/drivers: Don't return an error if console lo…
Browse files Browse the repository at this point in the history
…g file doesn't exist

Right at VM creation, the ring buffer for the console is empty. If you
try to access an interactive console, such as by running a command like
`incus launch images:ubuntu/24.04 v1 --vm --console`, you'd get an error
that the log file doesn't exist when attempting to save off the ring
buffer contents prior to switching to the unix socket connection. We
shouldn't return an error, but rather an empty string in this case.

Signed-off-by: Mathias Gibbens <mathias.gibbens@futurfusion.io>
  • Loading branch information
gibmat committed Sep 23, 2024
1 parent 58bdbb5 commit f3b14f5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/server/instance/drivers/driver_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -9381,6 +9381,11 @@ func (d *qemu) ConsoleLog() (string, error) {
// Read and return the complete log for this instance.
fullLog, err := os.ReadFile(d.common.ConsoleBufferLogPath())
if err != nil {
if errors.Is(err, fs.ErrNotExist) {
// If there's no log file yet, such as right at VM creation, return an empty string.
return "", nil
}

return "", err
}

Expand Down

0 comments on commit f3b14f5

Please sign in to comment.