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/uring/patches/BUILD b/third_party/uring/patches/BUILD
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/third_party/uring/patches/BUILD
diff --git a/third_party/uring/patches/bazel_cc_fix.patch b/third_party/uring/patches/bazel_cc_fix.patch
new file mode 100644
index 0000000..daad089
--- /dev/null
+++ b/third_party/uring/patches/bazel_cc_fix.patch
@@ -0,0 +1,98 @@
+Copyright 2020 The Monogon Project Authors.
+
+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.
+
+
+From 84404c50db8db114834d51be8cd5e706dcdb02ad Mon Sep 17 00:00:00 2001
+From: Lorenz Brun <lorenz@nexantic.com>
+Date: Tue, 9 Mar 2021 13:35:42 +0100
+Subject: [PATCH] bazel_cc_fix patch
+
+---
+ src/queue.c | 8 ++++----
+ src/register.c | 6 +++---
+ src/setup.c | 6 +++---
+ src/syscall.c | 4 ++--
+ 4 files changed, 12 insertions(+), 12 deletions(-)
+
+diff --git a/src/queue.c b/src/queue.c
+index 4bd4c48..e81a492 100644
+--- a/src/queue.c
++++ b/src/queue.c
+@@ -9,10 +9,10 @@
+ #include <string.h>
+ #include <stdbool.h>
+
+-#include "liburing/compat.h"
+-#include "liburing/io_uring.h"
+-#include "liburing.h"
+-#include "liburing/barrier.h"
++#include "src/include/liburing/compat.h"
++#include "src/include/liburing/io_uring.h"
++#include "src/include/liburing.h"
++#include "src/include/liburing/barrier.h"
+
+ #include "syscall.h"
+
+diff --git a/src/register.c b/src/register.c
+index 994aaff..87564f3 100644
+--- a/src/register.c
++++ b/src/register.c
+@@ -8,9 +8,9 @@
+ #include <errno.h>
+ #include <string.h>
+
+-#include "liburing/compat.h"
+-#include "liburing/io_uring.h"
+-#include "liburing.h"
++#include "src/include/liburing/compat.h"
++#include "src/include/liburing/io_uring.h"
++#include "src/include/liburing.h"
+
+ #include "syscall.h"
+
+diff --git a/src/setup.c b/src/setup.c
+index 062eaa0..decd4f0 100644
+--- a/src/setup.c
++++ b/src/setup.c
+@@ -10,9 +10,9 @@
+ #include <stdlib.h>
+ #include <signal.h>
+
+-#include "liburing/compat.h"
+-#include "liburing/io_uring.h"
+-#include "liburing.h"
++#include "src/include/liburing/compat.h"
++#include "src/include/liburing/io_uring.h"
++#include "src/include/liburing.h"
+
+ #include "syscall.h"
+
+diff --git a/src/syscall.c b/src/syscall.c
+index 2fd3dd4..3f57273 100644
+--- a/src/syscall.c
++++ b/src/syscall.c
+@@ -7,8 +7,8 @@
+ #include <unistd.h>
+ #include <sys/syscall.h>
+ #include <sys/uio.h>
+-#include "liburing/compat.h"
+-#include "liburing/io_uring.h"
++#include "src/include/liburing/compat.h"
++#include "src/include/liburing/io_uring.h"
+ #include "syscall.h"
+
+ #ifdef __alpha__
+--
+2.25.1
+
diff --git a/third_party/uring/patches/include-compat-h.patch b/third_party/uring/patches/include-compat-h.patch
new file mode 100644
index 0000000..ed53e37
--- /dev/null
+++ b/third_party/uring/patches/include-compat-h.patch
@@ -0,0 +1,49 @@
+Copyright 2020 The Monogon Project Authors.
+
+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.
+
+
+From 99f3ba25f42ee1ec31bcbb27c4813f4589d6fd89 Mon Sep 17 00:00:00 2001
+From: Lorenz Brun <lorenz@nexantic.com>
+Date: Tue, 9 Mar 2021 13:42:50 +0100
+Subject: [PATCH] include compat.h
+
+---
+ src/include/liburing/compat.h | 15 +++++++++++++++
+ 1 file changed, 15 insertions(+)
+ create mode 100644 src/include/liburing/compat.h
+
+diff --git a/src/include/liburing/compat.h b/src/include/liburing/compat.h
+new file mode 100644
+index 0000000..2e46c5f
+--- /dev/null
++++ b/src/include/liburing/compat.h
+@@ -0,0 +1,15 @@
++/* SPDX-License-Identifier: MIT */
++#ifndef LIBURING_COMPAT_H
++#define LIBURING_COMPAT_H
++
++#include <linux/time_types.h>
++
++#include <inttypes.h>
++
++struct open_how {
++ uint64_t flags;
++ uint64_t mode;
++ uint64_t resolve;
++};
++
++#endif
+--
+2.25.1
+