Add QEMU into the monorepo
This adds QEMU and all its dependencies into the monorepo. Enough features are enabled that
this QEMU should be both usable for running tests for Metropolis as well as running customer VMs in
containers. Thus we can also get rid of the QEMU ambient dependency.
All dependencies have their includes fully rewritten as to be reusable without a huge effort. QEMU itself
relies on `includes` attributes since the patch would otherwise be enormous and it is a binary and thus
any include path madness ends there.
Overall though this is quite nice, the final QEMU build with full optimization is <10MiB and has no further
ambient dependencies. It also has full io_uring support, which works very well with our 5.10 kernel.
TPM support is also included.
This is not used anywhere, replacing the ambient dependency and shipping a container will be in an upcoming
revision.
Test Plan:
Manually tested to run a Ubuntu cloud image with io_uring and virtio. Automated tests will follow as
part of its roles in this repo.
X-Origin-Diff: phab/D712
GitOrigin-RevId: 9c2607d75c875b1d65346e3cdac1a5e08467ea33
diff --git a/third_party/qemu/external.bzl b/third_party/qemu/external.bzl
new file mode 100644
index 0000000..456aa23
--- /dev/null
+++ b/third_party/qemu/external.bzl
@@ -0,0 +1,36 @@
+# Copyright 2020 The Monogon Project Authors.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+# 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.
+
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+
+def qemu_external(name, version):
+ sums = {
+ "5.2.0": "cb18d889b628fbe637672b0326789d9b0e3b8027e0445b936537c78549df17bc",
+ }
+
+ http_archive(
+ name = name,
+ patch_args = ["-p1"],
+ patches = [
+ "//third_party/qemu/patches:fix_code_issues.patch",
+ "//third_party/qemu/patches:bazel_support.patch",
+ "//third_party/qemu/patches:pregenerated_config_files.patch",
+ "//third_party/qemu/patches:headers_fix.patch",
+ ],
+ sha256 = sums[version],
+ strip_prefix = "qemu-" + version,
+ urls = ["https://download.qemu.org/qemu-%s.tar.xz" % version],
+ )