Merge changes from topic "vt_enable" into main am: bb216f44d5
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Virtualization/+/3133196
Change-Id: I64b99be360597537056405fea1e4094b5935ba30
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/java/service/src/com/android/system/virtualmachine/VirtualizationSystemService.java b/java/service/src/com/android/system/virtualmachine/VirtualizationSystemService.java
index 8f24a02..f1d89d9 100644
--- a/java/service/src/com/android/system/virtualmachine/VirtualizationSystemService.java
+++ b/java/service/src/com/android/system/virtualmachine/VirtualizationSystemService.java
@@ -159,13 +159,14 @@
}
private final class TetheringService extends IVmTethering.Stub {
+ private final TetheringManager tm = getContext().getSystemService(TetheringManager.class);
+
@Override
public void enableVmTethering() {
final TetheringRequest tr =
new TetheringRequest.Builder(TetheringManager.TETHERING_VIRTUAL)
.setConnectivityScope(TetheringManager.CONNECTIVITY_SCOPE_GLOBAL)
.build();
- final TetheringManager tm = getContext().getSystemService(TetheringManager.class);
StartTetheringCallback startTetheringCallback =
new StartTetheringCallback() {
@@ -184,5 +185,10 @@
};
tm.startTethering(tr, c -> c.run() /* executor */, startTetheringCallback);
}
+
+ @Override
+ public void disableVmTethering() {
+ tm.stopTethering(TetheringManager.TETHERING_VIRTUAL);
+ }
}
}
diff --git a/virtualizationservice/aidl/android/system/vmtethering/IVmTethering.aidl b/virtualizationservice/aidl/android/system/vmtethering/IVmTethering.aidl
index 732a515..0743ffa 100644
--- a/virtualizationservice/aidl/android/system/vmtethering/IVmTethering.aidl
+++ b/virtualizationservice/aidl/android/system/vmtethering/IVmTethering.aidl
@@ -21,4 +21,9 @@
* Start VM tethering to provide external network to VM.
*/
void enableVmTethering();
+
+ /**
+ * Terminate VM tethering that providing external network to VM.
+ */
+ void disableVmTethering();
}
diff --git a/virtualizationservice/src/aidl.rs b/virtualizationservice/src/aidl.rs
index aae97fd..af80998 100644
--- a/virtualizationservice/src/aidl.rs
+++ b/virtualizationservice/src/aidl.rs
@@ -550,6 +550,10 @@
))
.with_log();
}
+
+ // TODO(340377643): Disabling tethering should be for bridge interface, not TAP interface.
+ TETHERING_SERVICE.disableVmTethering()?;
+
NETWORK_SERVICE.deleteTapInterface(tap_fd)
}
}