kata-containers / govmm

Virtual Machine Manager for Go (govmm) is a suite of packages that provide Go APIs for creating and managing virtual machines.
Apache License 2.0
309 stars 93 forks source link

docs: LaunchCustomQemu + blocking #21

Closed pohly closed 6 years ago

pohly commented 6 years ago

https://godoc.org/github.com/intel/govmm/qemu#LaunchCustomQemu says:

The function will block until the launched qemu process exits.

This is a bit misleading, because it sounds like one has to call the function in goroutine to get continue working with the QEMU instance while it is running. But that's not true, because the function will return once QEMU is done with the virtual machine startup thanks to --daemonize.

pohly commented 6 years ago

Never mind. I just realized that the function works as described and the caller has to add --daemonize.

markdryan commented 6 years ago

The description is accurate. The function launches a qemu process and blocks until that process exits. When using this function the user needs to provide all the arguments to the qemu process including --daemonize, if they want this behaviour. If they don't provide --daemonize, and there's no obligation to do so, the function will block until the VM exits, and so in this case, the user may well choose to call this method inside a go routine.

pohly commented 6 years ago

@markdryan you are right, I realized that myself shortly after filing the issue and going back to the example.

But I'm now facing the issue that QEMU 2.12.0 rejects --daemonize when combined with --nographic. How are others dealing with this?

If I invoke LaunchCustomQemu in a goroutine, then getting the QMP connection established will become tricky: one has to wait for the socket to appear while monitoring the goroutine for a premature exit.

Currently I am using my own code for launching QEMU with github.com/digitalocean/go-qemu/qemu ass implementation for QMP. I'm trying to replace that with govmm. In my own code I run QMP over QEMU's stdin/stdout, which avoids these issues.

markdryan commented 6 years ago

@pohly In ccloudvm ( https://github.com/intel/ccloudvm/blob/master/ccvm/vm.go#L44 ) we use "-display none -vga none" in conjunction with -daemonize. This seems to work fine on xenial and bionic (which has 2.11.1). I realise display=none is not the same as nographic but it does prevent a display.