Open allencloud opened 7 years ago
Or we can remove the // +build linux
from https://github.com/hyperhq/runv/blob/master/lib/vsock/vsock.go#L1.
And this action will work as well.
The right fix is to add VsockCidAllocator to lib/vsock/vsock_unsupported.go. Would you like to update and fix it there?
Yes, It is another solution to this. I will carry that in this PR. But maybe in a couple of days. Thanks for your advice and feedback. @bergwolf
I just add the same interface definition into vsock_unsupported.go. And this will make darwin os report no compile error. PTAL @bergwolf
@allencloud Thanks for the quick update. I'm afraid the fix is not completed yet, e.g, NewDefaultVsockCidAllocator() is called in driverloader/driverloader_linux.go.
Please add a dummy implementation of the interface in vsock_unsupported.go. We'd like to get proper errors other than runtime failures when vsock is not supported. The dummy implementation will include NewDefaultVsockCidAllocator() and all the methods declared in VsockCidAllocator.
First, let me illustrate without
// +build linux
, what will code report?In Line https://github.com/hyperhq/runv/blob/master/hypervisor/driver.go#L67, we have code
And we can find
VsockCidAllocator
is an interface ONLY on Linux, since it is described in file https://github.com/hyperhq/runv/blob/master/lib/vsock/vsock.go#L1So if the file is compiled on other OS types, it will throw a compile error.
So I add a build os for file driver.go.
Signed-off-by: Allen Sun shlallen1990@gmail.com