New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bridging on Linux QEMU #3463
base: fix-get-bridged
Are you sure you want to change the base?
Bridging on Linux QEMU #3463
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## fix-get-bridged #3463 +/- ##
===================================================
- Coverage 88.80% 88.66% -0.14%
===================================================
Files 254 254
Lines 14115 14139 +24
===================================================
+ Hits 12535 12537 +2
- Misses 1580 1602 +22 ☔ View full report in Codecov by Sentry. |
4c55b42
to
da6e35c
Compare
0cb2e99
to
15de003
Compare
837f43c
to
7c3919f
Compare
@@ -247,7 +238,7 @@ auto mp::LXDVirtualMachineFactory::networks() const -> std::vector<NetworkInterf | |||
ret.push_back(std::move(network)); | |||
|
|||
for (auto& net : ret) | |||
if (net.needs_authorization && find_bridge_with(ret, net.id) != ret.cend()) | |||
if (net.needs_authorization && MP_BACKEND.find_bridge_with(ret, net.id) != ret.cend()) | |||
net.needs_authorization = false; |
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.
Change this to match https://github.com/canonical/multipass/pull/3463/files#diff-77064bb2fbd2589b9a34679c3e6bde02dc7ad8b0b22931195d4d687e8aef2720R232? It makes it easier to see that the logic is the same in both places.
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.
Right, changed in the base branch.
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.
This still isn't changed
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.
Oh, sorry, I didn't get it. I changed it as you propose, but I used &=
instead of =
to maintain exactly the same logic (i.e., the same exact truth table).
src/platform/backends/qemu/linux/qemu_platform_detail_linux.cpp
Outdated
Show resolved
Hide resolved
src/platform/backends/qemu/linux/qemu_platform_detail_linux.cpp
Outdated
Show resolved
Hide resolved
|
||
std::string mp::QemuPlatformDetail::bridge_name_for(const std::string& iface_name) const | ||
{ | ||
return MP_BACKEND.bridge_name(iface_name); |
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 don't really understand what is going on here. This bridge_name_for
thing has become pretty complex. This is what I see:
- the daemon calls
VirtualMachineFactory::bridge_name_for
. This is implemented to:- return an empty string by default.
- this covers libvirt and VirtualBox, which have no specific implementation
- In LXD, it returns
mp::Backend::bridge_name()
. - In QEMU, it delegates on
QemuPlatform::bridge_name_for
, which:- returns an empty string by default (covers macOS, as there is no specific implementation there)
- again calls
mp::Backend::bridge_name()
on Linux
- On Hyper-V, it incorrectly returns a hardcoded "External Virtual Switch" string (bug we've discussed)
- return an empty string by default.
This complexity is complemented by tests and mocks. But the only functional bit here is mp::Backend::bridge_name()
, on Linux, where we create bridges. However, and this is the crucial part, IIANM this function shouldn't be used at all in the first place! The daemon should not be looking for the bridge based on the name at all, but based on its members, as we've established when we discussed the bug in Hyper-V.
Note that information on bridge members is readily available on our return from VirtualMachineFactory::networks()
. We just need to run a find that is the same for all backends. And this find is implemented. It's the one you just moved here.
So you could just replace this call [https://github.com/canonical/multipass/blob/main/src/daemon/daemon.cpp#L3523] with a call to find_bridge_with
. That would fix the behavior and get rid of all this code... Am I missing something??
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.
Hey @ricab, thanks! Well, what you are proposing is exactly what I am implementing as the fix to the Hyper-V bug here. What do you think in finishing that fix, merging and then rebasing this branch on top of that? That way, the history will reflect exactly what change does what and this PR will only add bridging to QEMU on Linux.
Otherwise, I can fix everything here. The resulting code will be the same but, you know, the change here can be seen as a drive-by change.
WDYT?
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.
Or, I can leave that here, merge this and fix later on the other PR. In any case, both PR's will go to 1.14 IIRC.
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.
Ah, I looked at that PR but did not see this. And since this one is adding to the bridge_name
stuff... But OK, yes, what you propose is perfectly fine! As long as it does the right thing and removes the obsolete code in the end.
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.
Of course, I'll let you know when I commit to the other PR. Thanks!
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.
Ok, this was all addressed in the other PR. I changed the base of this PR, so now it's on top of the get
fix.
This is not anymore needed because networks() is implemented in both Linux and macOS.
This commit removes expectations on throwing from add_network_interface() and networks() tests.
Hey @sharder996! Thanks for the review! I addressed all your comments, plus rebasing on the fix for |
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.
Ok, just a few more questions. Otherwise, the code looks good, but I am unable to functionally test since my laptop running Linux died and I haven't setup a replacement yet.
Hey @sharder996! I addressed your two points. this is ready for another round of review. Thanks! |
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.
Hey @luis4a0,
Just a couple of copyright things inline below. :) Thanks!
* QEMU Bridge Helper | ||
* | ||
* Copyright IBM, Corp. 2011 | ||
* |
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.
Please add a Copyright (C) Canonical, Ltd.
here.
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.
Right, added.
* Authors: | ||
* Anthony Liguori <aliguori@us.ibm.com> | ||
* Richa Marwaha <rmarwah@linux.vnet.ibm.com> | ||
* Corey Bryant <coreyb@linux.vnet.ibm.com> |
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.
Feel free to add your name here too, but up to you.
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.
Well, I didn't make functional changes. But I added it in order to blame someone if something goes wrong ;)
It is a stripped-down version of the QEMU bridge helper.
This was made to match the logic with the Linux QEMU factory.
@sharder996 I addressed the point I didn't address in the last round, so this is ready again for review. Thanks! |
@luis4a0 Got my PC up and dual-booting with Ubuntu so I did some more functional testing. There are a couple of things that I noticed that seem a bit odd:
|
This PR implements the bridging feature on the QEMU backend on Linux.