canonical / multipass

Multipass orchestrates virtual Ubuntu instances
https://multipass.run
GNU General Public License v3.0
7.76k stars 642 forks source link

Bridging on Linux QEMU #3463

Closed luis4a0 closed 2 months ago

luis4a0 commented 6 months ago

This PR implements the bridging feature on the QEMU backend on Linux.

codecov[bot] commented 6 months ago

Codecov Report

Attention: Patch coverage is 28.12500% with 23 lines in your changes are missing coverage. Please review.

Project coverage is 88.66%. Comparing base (2f4ac45) to head (04a9ddb).

Files Patch % Lines
...backends/qemu/linux/qemu_platform_detail_linux.cpp 26.92% 19 Missing :warning:
...orm/backends/qemu/qemu_virtual_machine_factory.cpp 0.00% 4 Missing :warning:
Additional details and impacted files ```diff @@ 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 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

luis4a0 commented 4 months ago

Hey @sharder996! Thanks for the review! I addressed all your comments, plus rebasing on the fix for get. Now the code should look better, so it's ready for another round of review. Thanks!

luis4a0 commented 4 months ago

Hey @sharder996! I addressed your two points. this is ready for another round of review. Thanks!

luis4a0 commented 4 months ago

@sharder996 I addressed the point I didn't address in the last round, so this is ready again for review. Thanks!

sharder996 commented 4 months ago

@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:

  1. If I take a snapshot of an instance before and after setting local.foo.bridged=true, then restore the first snapshot (before adding the bridge) and then restore the second snapshot (after adding the bridge), when I start the instance the bridge does not get initialized. Only after restarting the instance does the bridge come up.

  2. Also, since I recently moved I am on a different network and had to create a new bridge for that network. As such, I have an extra bridge in multipass networks which was for the old network and does nothing. Deleting the bridge with ip link will make it go away, but when I restart the Multipass daemon it comes back.

luis4a0 commented 4 months ago

Hey @sharder996, good to hear you have a working Linux again! Thanks for the new review, I'll answer your two points:

  1. The problem here comes from cloud-init configuration. The configuration at Multipass level worked and I don't think we can do better (maybe increasing the timeout is one option).
  2. This failure is not specific to QEMU, it's due to the way bridging on Linux works in Multipass. To avoid that child bridge being created, we need to remove from extra_interfaces the bridged interface entry. This will be trivial to do when we implement removing bridges (in the future, not on this PR). Thanks!