-
Notifications
You must be signed in to change notification settings - Fork 51
Networking: Add support for handling macvtap interfaces #1510
Conversation
@markdryan please can you review this |
cc4f0fc
to
eea6389
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there might be some issues with leaky file descriptors. Could you check?
qemu/qemu.go
Outdated
// Does not make sense to have more Queues that CPUs | ||
// Specify the maximum number of queues possible for the | ||
// current CPU configuration | ||
netdev.FDs, _ = createMacvtapFds(netdev.ID, int(config.SMP.CPUs)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these file descriptors are closed anywhere? In launcher we close them after the QEMU process has been launched or has failed to launch. I can see that the FDs aren't leaked but I can't see where they are closed. We can't expect the user to close them as he doesn't know about them.
Also, any FDs that he assigns to netdev.FDs will be overwritten by this line and will be leaked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I plan to remove this logic from QEMU. I initially put it here to handle the case where the caller did not do setup properly and we have no means to return error from this API call (which is a bit unfortunate). But now I feel it is not worth doing. Let the qemu launch fail and we can leave it to the user to recover.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@markdryan @sameo it may be worthwhile to provide a way to return error from a lot of these APIs. Yes, this will require changes to the consumers of these packages, but will have benefits in the future.
There are also some unit test failures. |
eea6389
to
3469bf2
Compare
@markdryan this fd leak should be addressed now. Also fixed the test cases. |
3469bf2
to
0fabbbd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are still some travis failures.
qemu/qemu.go:358:1:warning: comment on exported method NetDeviceType.QemuNetdevParam should be of the form "QemuNetdevParam ..." (golint)
qemu/qemu.go:379:1:warning: comment on exported method NetDeviceType.QemuDeviceParam should be of the form "QemuDeviceParam ..." (golint)
qemu/qemu.go:457::warning: cyclomatic complexity 16 of function (NetDevice).QemuParams() is high (> 15) (gocyclo)
The command "if [ $LINT_ONLY ]; then gometalinter.v1 --deadline=10m --tests --vendor --disable-all --enable=misspell --enable=vet --enable=ineffassign --enable=gofmt --enable=gocyclo --cyclo-over=15 --enable=golint --enable=deadcode --enable=varcheck --enable=structcheck --enable=unused ./...; fi" exited with 1.
0.01s$
qemu/qemu_test.go
Outdated
var deviceNetworkStringMq = "-netdev tap,id=tap0,vhost=on,fds=3:4 -device driver=virtio-net-pci,netdev=tap0,mac=01:02:de:ad:be:ef,disable-modern=true,mq=on,vectors=6" | ||
|
||
func TestAppendDeviceNetworkMq(t *testing.T) { | ||
foo, _ := ioutil.TempFile(os.TempDir(), "qemu-ciao-test") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, the QEMU package doesn't close any file descriptors. This is the responsibility of the caller. Is this correct? If so we should close the FDs in this test ( and others ). Currently, they're leaked, i.e., we're missing a foo.Close() and a bar.Close()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@markdryan good catch. This was existing code which I missed. Let me fix this.
0fabbbd
to
b6c2894
Compare
b6c2894
to
fc6d2a3
Compare
@markdryan hopefully at the issues are fixed now. |
qemu/qemu.go
Outdated
deviceParams = append(deviceParams, ",disable-modern=true") | ||
} | ||
deviceParams = append(deviceParams, "driver=") | ||
deviceParams = append(deviceParams, netdev.Type.QemuDeviceParam()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this generate an invalid cli in the case of VHOSTUSER
(where QemuDeviceParam()
returns ""
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jodh-intel great catch.. I have yet to add/test that path. But this a generic issue. I could always check if we have params to append to as this code will get even more complex when more use cases come in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@markdryan @jodh-intel fixed.
qemu/qemu.go
Outdated
func (netdev NetDevice) QemuNetdevParams(config *Config) []string { | ||
var netdevParams []string | ||
|
||
netdevParams = append(netdevParams, netdev.Type.QemuNetdevParam()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ibid.
Add support for macvtap interfaces. This also brings in support for generic multiqueue support in virt containers. Signed-off-by: Manohar Castelino <[email protected]>
fc6d2a3
to
f6469f3
Compare
1 similar comment
f6469f3
to
113bcaf
Compare
Add support for macvtap interfaces. This also brings in support
for generic multiqueue support in virt containers.
Signed-off-by: Manohar Castelino [email protected]