Add init process for test guest VMs
Guest VMs need an init process to be invoked by the GKI kernel. This
process needs to do two things:
1) load vendor kernel modules
For example, GKI does not come with vsock-virtio built in. The ramdisk
will contain vsock-virtio as a kernel module and it is the init's job to
load it.
2) execute a test binary
The init process is given parameters from the kernel command line
(/proc/cmdline). We will use these parameters to invoke a test binary
packaged in the ramdisk, eg. /bin/vsock_server. When init is done with
everything else, it calls execve() to run the specified binary and
passes remaining arguments to it.
This CL adds an init process as a static C++ binary. C++ was chosen
because of dependency on libmodprobe for loading kernel modules.
Test: m virt_hostside_tests_guest_init
(may not work until later in the series due to path depth limits)
Change-Id: I7b461504850174c435b0e4d666117b97836dff4f
diff --git a/tests/hostside/native/init/Android.bp b/tests/hostside/native/init/Android.bp
new file mode 100644
index 0000000..a98948b
--- /dev/null
+++ b/tests/hostside/native/init/Android.bp
@@ -0,0 +1,25 @@
+// Copyright (C) 2020 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+cc_binary {
+ name: "virt_hostside_tests_guest_init",
+ srcs: ["main.cc"],
+ static_executable: true,
+ installable: false,
+ static_libs: [
+ "libbase",
+ "liblog",
+ "libmodprobe",
+ ],
+}