Skip to content
This repository has been archived by the owner on Jul 16, 2020. It is now read-only.

Networking: Add support for handling macvtap interfaces #1510

Merged
merged 1 commit into from
Oct 13, 2017

Conversation

mcastelino
Copy link
Contributor

Add support for macvtap interfaces. This also brings in support
for generic multiqueue support in virt containers.

Signed-off-by: Manohar Castelino [email protected]

@mcastelino mcastelino changed the title WIP: Networking: Add support for handling macvtap interfaces Networking: Add support for handling macvtap interfaces Oct 10, 2017
@mcastelino
Copy link
Contributor Author

@markdryan please can you review this

Copy link
Contributor

@markdryan markdryan left a 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))
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@markdryan
Copy link
Contributor

There are also some unit test failures.

@mcastelino
Copy link
Contributor Author

@markdryan this fd leak should be addressed now. Also fixed the test cases.
@amshinde can you review this PR and make sure it will also work for VFIO support.

@coveralls
Copy link

coveralls commented Oct 10, 2017

Coverage Status

Coverage decreased (-0.04%) to 65.789% when pulling 3469bf2 on mcastelino:topic/macvtap into cbd9f90 on ciao-project:master.

@coveralls
Copy link

coveralls commented Oct 10, 2017

Coverage Status

Coverage decreased (-0.04%) to 65.789% when pulling 0fabbbd on mcastelino:topic/macvtap into cbd9f90 on ciao-project:master.

Copy link
Contributor

@markdryan markdryan left a 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$

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")
Copy link
Contributor

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()

Copy link
Contributor Author

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.

@coveralls
Copy link

coveralls commented Oct 11, 2017

Coverage Status

Coverage decreased (-0.03%) to 65.844% when pulling b6c2894 on mcastelino:topic/macvtap into 66772b7 on ciao-project:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.06%) to 65.813% when pulling fc6d2a3 on mcastelino:topic/macvtap into 66772b7 on ciao-project:master.

@coveralls
Copy link

coveralls commented Oct 11, 2017

Coverage Status

Coverage decreased (-0.02%) to 65.849% when pulling fc6d2a3 on mcastelino:topic/macvtap into 66772b7 on ciao-project:master.

@mcastelino
Copy link
Contributor Author

@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())

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 "")?

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qemu/qemu.go Outdated
func (netdev NetDevice) QemuNetdevParams(config *Config) []string {
var netdevParams []string

netdevParams = append(netdevParams, netdev.Type.QemuNetdevParam())

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]>
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.02%) to 65.847% when pulling f6469f3 on mcastelino:topic/macvtap into 60525fb on ciao-project:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.02%) to 65.847% when pulling f6469f3 on mcastelino:topic/macvtap into 60525fb on ciao-project:master.

@coveralls
Copy link

coveralls commented Oct 12, 2017

Coverage Status

Coverage decreased (-0.02%) to 65.852% when pulling f6469f3 on mcastelino:topic/macvtap into 60525fb on ciao-project:master.

@coveralls
Copy link

coveralls commented Oct 12, 2017

Coverage Status

Coverage decreased (-0.03%) to 65.843% when pulling 113bcaf on mcastelino:topic/macvtap into 60525fb on ciao-project:master.

@markdryan markdryan merged commit 0fa9ee6 into ciao-project:master Oct 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants