x86 vm kernel
diff --git a/kernel/x86_64/vm_kernel b/kernel/x86_64/vm_kernel new file mode 100644 index 0000000..60f764c --- /dev/null +++ b/kernel/x86_64/vm_kernel Binary files differ
diff --git a/vm_init/Android.bp b/vm_init/Android.bp new file mode 100644 index 0000000..63ba6cc --- /dev/null +++ b/vm_init/Android.bp
@@ -0,0 +1,21 @@ +// 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_host { + name: "kvm_guest_init", + static_executable: true, + srcs: [ + "init.c", + ] +}
diff --git a/vm_init/Android.mk b/vm_init/Android.mk new file mode 100644 index 0000000..b3e5446 --- /dev/null +++ b/vm_init/Android.mk
@@ -0,0 +1,46 @@ +## 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. + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) +LOCAL_MODULE := kvm_guest_kernel +LOCAL_MODULE_CLASS := ETC +LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/vm +LOCAL_MODULE_STEM := $(LOCAL_MODULE) +include $(BUILD_SYSTEM)/base_rules.mk +$(LOCAL_BUILT_MODULE): ./vm-api/kernel/$(TARGET_ARCH)/vm_kernel + cp $< $@ + +include $(CLEAR_VARS) +LOCAL_MODULE := kvm_guest_busybox +LOCAL_MODULE_CLASS := ETC +LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/vm +LOCAL_MODULE_STEM := $(LOCAL_MODULE) +include $(BUILD_SYSTEM)/base_rules.mk +$(LOCAL_BUILT_MODULE): ./vm-api/busybox.img + cp $< $@ + +include $(CLEAR_VARS) +LOCAL_MODULE := kvm_guest_ramdisk +LOCAL_MODULE_CLASS := ETC +LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/vm +LOCAL_MODULE_STEM := $(LOCAL_MODULE) +include $(BUILD_SYSTEM)/base_rules.mk +$(LOCAL_BUILT_MODULE): ROOTFS_DIR=$(TARGET_OUT_INTERMEDIATES)/$(LOCAL_MODULE_CLASS)/$(LOCAL_MODULE)/rootfs +$(LOCAL_BUILT_MODULE): $(MKBOOTFS) $(HOST_OUT_EXECUTABLES)/kvm_guest_init | $(MINIGZIP) + $(call pretty,"VM ram disk: $@") + $(hide) mkdir -p $(ROOTFS_DIR) + $(hide) cp $(HOST_OUT_EXECUTABLES)/kvm_guest_init $(ROOTFS_DIR)/init + $(hide) $(MKBOOTFS) $(ROOTFS_DIR) | $(MINIGZIP) > $@
diff --git a/vm_init/init.c b/vm_init/init.c new file mode 100644 index 0000000..199fc58 --- /dev/null +++ b/vm_init/init.c
@@ -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. + +#define _GNU_SOURCE +#include <stdio.h> +#include <sys/reboot.h> + +int main(void) +{ + printf("Hello World from a guest VM\n"); + + reboot(RB_AUTOBOOT); + return 0; +}