Snap for 11124398 from 79453adb0238466fe5d0cee93bdfbb24de6c6ccd to 24Q1-release

Change-Id: Icb50eb6149177c904fbca814b0673e1d8c613093
diff --git a/Android.bp b/Android.bp
index 9930817..f76e01c 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,6 +1,6 @@
-// Autogenerated via gen_android_bp.sh
+// Autogenerated via gen_android_bp.py
 //
-// Copyright (C) 2019 The Android Open Source Project
+// Copyright (C) 2023 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.
@@ -97,6 +97,18 @@
   defaults: ["cuttlefish_host"],
   check_elf_files: false,
 }
+prebuilt_usr_share_host {
+  name: "x86_64_efi-virtio.rom_resource_for_qemu",
+  src: "qemu/x86_64-linux-gnu/usr/share/qemu/efi-virtio.rom",
+  filename: "efi-virtio.rom",
+  sub_dir: "qemu",
+}
+prebuilt_usr_share_host {
+  name: "x86_64_en-us_resource_for_qemu",
+  src: "qemu/x86_64-linux-gnu/usr/share/qemu/keymaps/en-us",
+  filename: "en-us",
+  sub_dir: "qemu/keymaps",
+}
 // Note: This is commented out to avoid a conflict with the binary built
 // from external/crosvm. This should be uncommented out when backporting to
 // older branches with just use the prebuilt and which do not build from
@@ -118,6 +130,13 @@
   check_elf_files: false,
 }
 cc_prebuilt_binary {
+  name: "x86_64_linux_gnu_libc++.so.1_binary_for_qemu",
+  srcs: ["qemu/x86_64-linux-gnu/bin/libc++.so.1"],
+  stem: "libc++.so.1",
+  defaults: ["cuttlefish_host"],
+  check_elf_files: false,
+}
+cc_prebuilt_binary {
   name: "x86_64_linux_gnu_libdrm.so.2_for_crosvm",
   srcs: ["x86_64-linux-gnu/bin/libdrm.so.2"],
   stem: "libdrm.so.2",
@@ -126,6 +145,13 @@
   check_elf_files: false,
 }
 cc_prebuilt_binary {
+  name: "x86_64_linux_gnu_libepoxy.so.0_binary_for_qemu",
+  srcs: ["qemu/x86_64-linux-gnu/bin/libepoxy.so.0"],
+  stem: "libepoxy.so.0",
+  defaults: ["cuttlefish_host"],
+  check_elf_files: false,
+}
+cc_prebuilt_binary {
   name: "x86_64_linux_gnu_libepoxy.so.0_for_crosvm",
   srcs: ["x86_64-linux-gnu/bin/libepoxy.so.0"],
   stem: "libepoxy.so.0",
@@ -150,6 +176,13 @@
   check_elf_files: false,
 }
 cc_prebuilt_binary {
+  name: "x86_64_linux_gnu_libgfxstream_backend.so.0_binary_for_qemu",
+  srcs: ["qemu/x86_64-linux-gnu/bin/libgfxstream_backend.so.0"],
+  stem: "libgfxstream_backend.so.0",
+  defaults: ["cuttlefish_host"],
+  check_elf_files: false,
+}
+cc_prebuilt_binary {
   name: "x86_64_linux_gnu_libgfxstream_backend.so_for_crosvm",
   srcs: ["x86_64-linux-gnu/bin/libgfxstream_backend.so"],
   stem: "libgfxstream_backend.so",
@@ -166,6 +199,20 @@
   check_elf_files: false,
 }
 cc_prebuilt_binary {
+  name: "x86_64_linux_gnu_librutabaga_gfx_ffi.so.0_binary_for_qemu",
+  srcs: ["qemu/x86_64-linux-gnu/bin/librutabaga_gfx_ffi.so.0"],
+  stem: "librutabaga_gfx_ffi.so.0",
+  defaults: ["cuttlefish_host"],
+  check_elf_files: false,
+}
+cc_prebuilt_binary {
+  name: "x86_64_linux_gnu_libvirglrenderer.so.1_binary_for_qemu",
+  srcs: ["qemu/x86_64-linux-gnu/bin/libvirglrenderer.so.1"],
+  stem: "libvirglrenderer.so.1",
+  defaults: ["cuttlefish_host"],
+  check_elf_files: false,
+}
+cc_prebuilt_binary {
   name: "x86_64_linux_gnu_libvirglrenderer.so.1_for_crosvm",
   srcs: ["x86_64-linux-gnu/bin/libvirglrenderer.so.1"],
   stem: "libvirglrenderer.so.1",
@@ -182,27 +229,6 @@
   check_elf_files: false,
 }
 cc_prebuilt_binary {
-  name: "x86_64_linux_gnu_libc++.so.1_binary_for_qemu",
-  srcs: ["qemu/x86_64-linux-gnu/bin/libc++.so.1"],
-  stem: "libc++.so.1",
-  defaults: ["cuttlefish_host"],
-  check_elf_files: false,
-}
-cc_prebuilt_binary {
-  name: "x86_64_linux_gnu_libgfxstream_backend.so.0_binary_for_qemu",
-  srcs: ["qemu/x86_64-linux-gnu/bin/libgfxstream_backend.so.0"],
-  stem: "libgfxstream_backend.so.0",
-  defaults: ["cuttlefish_host"],
-  check_elf_files: false,
-}
-cc_prebuilt_binary {
-  name: "x86_64_linux_gnu_librutabaga_gfx_ffi.so.0_binary_for_qemu",
-  srcs: ["qemu/x86_64-linux-gnu/bin/librutabaga_gfx_ffi.so.0"],
-  stem: "librutabaga_gfx_ffi.so.0",
-  defaults: ["cuttlefish_host"],
-  check_elf_files: false,
-}
-cc_prebuilt_binary {
   name: "x86_64_linux_gnu_libz.so.1_binary_for_qemu",
   srcs: ["qemu/x86_64-linux-gnu/bin/libz.so.1"],
   stem: "libz.so.1",
@@ -231,18 +257,6 @@
   check_elf_files: false,
 }
 prebuilt_usr_share_host {
-  name: "x86_64_efi-virtio.rom_resource_for_qemu",
-  src: "qemu/x86_64-linux-gnu/usr/share/qemu/efi-virtio.rom",
-  filename: "efi-virtio.rom",
-  sub_dir: "qemu",
-}
-prebuilt_usr_share_host {
-  name: "x86_64_en-us_resource_for_qemu",
-  src: "qemu/x86_64-linux-gnu/usr/share/qemu/keymaps/en-us",
-  filename: "en-us",
-  sub_dir: "qemu/keymaps",
-}
-prebuilt_usr_share_host {
   name: "x86_64_opensbi-riscv64-generic-fw_dynamic.bin_resource_for_qemu",
   src: "qemu/x86_64-linux-gnu/usr/share/qemu/opensbi-riscv64-generic-fw_dynamic.bin",
   filename: "opensbi-riscv64-generic-fw_dynamic.bin",
diff --git a/aarch64-linux-gnu/Android.bp b/aarch64-linux-gnu/Android.bp
index baaf57b..626a9ab 100644
--- a/aarch64-linux-gnu/Android.bp
+++ b/aarch64-linux-gnu/Android.bp
@@ -1,6 +1,6 @@
-// Autogenerated via gen_android_bp.sh
+// Autogenerated via gen_android_bp.py
 //
-// Copyright (C) 2019 The Android Open Source Project
+// Copyright (C) 2023 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.
@@ -117,18 +117,18 @@
   sub_dir: "cuttlefish/aarch64-linux-gnu/seccomp",
 }
 prebuilt_usr_share_host {
-  name: "serial_device.policy_at_aarch64",
-  src: "etc/seccomp/serial_device.policy",
-  filename: "serial_device.policy",
-  sub_dir: "cuttlefish/aarch64-linux-gnu/seccomp",
-}
-prebuilt_usr_share_host {
   name: "serial.policy_at_aarch64",
   src: "etc/seccomp/serial.policy",
   filename: "serial.policy",
   sub_dir: "cuttlefish/aarch64-linux-gnu/seccomp",
 }
 prebuilt_usr_share_host {
+  name: "serial_device.policy_at_aarch64",
+  src: "etc/seccomp/serial_device.policy",
+  filename: "serial_device.policy",
+  sub_dir: "cuttlefish/aarch64-linux-gnu/seccomp",
+}
+prebuilt_usr_share_host {
   name: "snd_cras_device.policy_at_aarch64",
   src: "etc/seccomp/snd_cras_device.policy",
   filename: "snd_cras_device.policy",
@@ -189,14 +189,14 @@
   sub_dir: "cuttlefish/aarch64-linux-gnu/seccomp",
 }
 prebuilt_usr_share_host {
-  name: "xhci_device.policy_at_aarch64",
-  src: "etc/seccomp/xhci_device.policy",
-  filename: "xhci_device.policy",
-  sub_dir: "cuttlefish/aarch64-linux-gnu/seccomp",
-}
-prebuilt_usr_share_host {
   name: "xhci.policy_at_aarch64",
   src: "etc/seccomp/xhci.policy",
   filename: "xhci.policy",
   sub_dir: "cuttlefish/aarch64-linux-gnu/seccomp",
 }
+prebuilt_usr_share_host {
+  name: "xhci_device.policy_at_aarch64",
+  src: "etc/seccomp/xhci_device.policy",
+  filename: "xhci_device.policy",
+  sub_dir: "cuttlefish/aarch64-linux-gnu/seccomp",
+}
diff --git a/gen_android_bp.py b/gen_android_bp.py
new file mode 100644
index 0000000..7c02aec
--- /dev/null
+++ b/gen_android_bp.py
@@ -0,0 +1,323 @@
+# Copyright (C) 2023 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.
+"""
+This script enumerates pre-built resources and updates Android.bp files:
+
+  - $ANDROID_BUILD_TOP/device/google/cuttlefish_vmm/Android.bp
+  - $ANDROID_BUILD_TOP/device/google/cuttlefish_vmm/$ARCH/Android.bp
+  - $ANDROID_BUILD_TOP/device/google/cuttlefish/Android.bp
+
+It is intended to be run manually:
+
+  python3 $ANDROID_BUILD_TOP/device/google/cuttlefish_vmm/gen_android_bp.py
+
+"""
+import datetime
+import os
+import re
+import sys
+import textwrap
+from dataclasses import dataclass
+from enum import auto
+from enum import Enum
+from pathlib import Path
+from typing import Dict
+from typing import List
+from typing import Iterator
+from typing import TypeAlias
+
+
+def tool_name() -> str:
+    """Returns a short name for this generation tool."""
+    return Path(__file__).name
+
+
+class Architecture(Enum):
+    """Host instruction set architectures."""
+
+    AARCH64 = auto()
+    X86_64 = auto()
+
+    def dir(self) -> Path:
+        "Returns the relative directory path to the specified architecture."
+        return Path(f"{self.name.lower()}-linux-gnu")
+
+
+# Android.bp variant value type.
+Value: TypeAlias = str | Path | bool | list["Value"]
+
+
+def value_to_bp(value: Value) -> str:
+    """Returns `bp` expression for the specified value"""
+    if isinstance(value, list):
+        if len(value) == 1:
+            return "[%s]" % value_to_bp(value[0])
+        return "[\n    %s,\n]" % ",\n    ".join(value_to_bp(e) for e in value)
+    elif isinstance(value, bool):
+        return str(value).lower()
+    elif isinstance(value, Path):
+        return value_to_bp(str(value))
+    else:
+        return f'"{value}"'
+
+
+@dataclass
+class Module:
+    """Android bp build rule."""
+
+    module_type: str
+    parameters: Dict[str, Value]
+
+    @property
+    def name(self) -> str:
+        assert isinstance(self.parameters.get("name"), str)
+        return self.parameters["name"]
+
+    def __str__(self) -> str:
+        """Returns a `.bp` string for this modules with its parameters."""
+        body = "\n  ".join(
+            f"{k}: {value_to_bp(v)}," for k, v in self.parameters.items()
+        )
+        return f"{self.module_type} {{\n  {body}\n}}\n"
+
+
+def update_generated_section(file_path: Path, tag: str, content: str):
+    """Reads a text file, matches and replaces the content between
+    a start beacon and an end beacon with the specified one, and
+    modifies the file in place.
+
+    The generated content is delimited by `// Start of generated` and
+    `// End of generated`. The specified content is indented the same
+    way as the start beacon is.
+
+    Args:
+      file_path: path to the text file to be modified.
+      tag: marks the beginning aned end of the string generated content.
+      content: text to replace the content between the start and end beacons with.
+    """
+    # Read the contents of the text file.
+    with open(file_path, "rt", encoding="utf-8") as f:
+        file_contents = f.read()
+
+    # Find the start and end beacon positions in the file contents.
+    start = f"// Start of generated {tag}\n"
+    end = f"// End of generated {tag}\n"
+
+    match = re.match(
+        f"^(?P<head>.*)^(?P<indent>[ \t]*){re.escape(start)}.*{re.escape(end)}(?P<tail>.*)$",
+        file_contents,
+        re.DOTALL | re.MULTILINE,
+    )
+    if not match:
+        raise ValueError(
+            f"Generated content beacons {(start, end)} not matched in file {file_path}"
+        )
+
+    with open(file_path, "wt", encoding="utf-8") as f:
+        f.write(f"{match.group('head')}{match.group('indent')}{start}")
+        f.write(f"{match.group('indent')}// Generated by {tool_name()}\n")
+        f.write(textwrap.indent(content, match.group("indent")))
+        f.write(f"{match.group('indent')}{end}{match.group('tail')}")
+
+
+def license() -> str:
+    """Returns a license header at the current date, with generation warning."""
+    current_year = datetime.datetime.now().year
+    return textwrap.dedent(
+        f"""\
+    // Autogenerated via {tool_name()}
+    //
+    // Copyright (C) {current_year} 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.
+
+    """
+    )
+
+
+def comment(text: str) -> str:
+    """Prefixes each lines with '/// ' and return the commented content."""
+    return re.sub("^(?!$)", "// ", text, flags=re.MULTILINE)
+
+
+def gen_android_bp4seccomp(path: Path, arch: Architecture):
+    """Regenerates the specified '.bp' file for the given architecture."""
+
+    with open(path, "wt") as out:
+        subdir = Path("etc/seccomp")
+        seccomp_dir = arch.dir() / subdir
+        where_in_etc_on_user_machine = "cuttlefish" / arch.dir() / "seccomp"
+        out.write(license())
+
+        for path in sorted(seccomp_dir.iterdir()):
+            module = Module(
+                "prebuilt_usr_share_host",
+                dict(
+                    name=f"{path.name}_at_{arch.name.lower()}",
+                    src=subdir / path.name,
+                    filename=path.name,
+                    sub_dir=where_in_etc_on_user_machine,
+                ),
+            )
+            out.write(str(module))
+
+
+def crosvm_binaries(arch: Architecture) -> Iterator[Path]:
+    """Lists crosvm binary paths."""
+    dir = arch.dir() / "bin"
+    yield dir / "crosvm"
+    yield dir / "gfxstream_graphics_detector"
+    yield dir / "libminijail.so"
+    yield dir / "libgfxstream_backend.so"
+    yield from dir.glob("*.so.?")
+
+
+def qemu_binaries(arch: Architecture) -> Iterator[Path]:
+    """Lists qemu binary paths."""
+    dir = Path("qemu/x86_64-linux-gnu/bin")
+    yield from dir.glob("*.so.?")
+    yield from dir.glob("qemu-system*")
+
+
+def gen_main_android_bp_modules() -> Iterator[Module]:
+    """Returns the Modules to write in the main 'Android.bp' file."""
+    for arch in Architecture:
+        for path in crosvm_binaries(arch):
+            name = re.sub("/bin/|/|-|_bin_", "_", str(path))
+            if path.stem != "crosvm":
+                name = f"{name}_for_crosvm"
+
+            yield Module(
+                "cc_prebuilt_binary",
+                dict(
+                    name=name,
+                    srcs=[path],
+                    stem=path.name,
+                    relative_install_path=arch.dir(),
+                    defaults=["cuttlefish_host"],
+                    check_elf_files=False,
+                ),
+            )
+
+    for binary_path in qemu_binaries(Architecture.X86_64):
+        yield Module(
+            "cc_prebuilt_binary",
+            dict(
+                name=f"x86_64_linux_gnu_{binary_path.name}_binary_for_qemu",
+                srcs=[binary_path],
+                stem=binary_path.name,
+                defaults=["cuttlefish_host"],
+                check_elf_files=False,
+            ),
+        )
+
+    resource_paths = [
+        Path("qemu/efi-virtio.rom"),
+        Path("qemu/keymaps/en-us"),
+        Path("qemu/opensbi-riscv64-generic-fw_dynamic.bin"),
+    ]
+
+    for resource_path in resource_paths:
+        base_name = resource_path.name
+        arch = "x86_64"
+        sub_dir = resource_path.parent
+        yield Module(
+            "prebuilt_usr_share_host",
+            dict(
+                name=f"{arch}_{base_name}_resource_for_qemu",
+                src=f"qemu/x86_64-linux-gnu/usr/share/{resource_path}",
+                filename=base_name,
+                sub_dir=sub_dir,
+            ),
+        )
+
+
+def gen_main_android_bp_file(android_bp_path: Path, modules: List[Module]):
+    """Writes the main 'Android.bp' file with the specified modules."""
+
+    disclamer = f"""\
+        // NOTE: Using cc_prebuilt_binary because cc_prebuilt_library will add
+        //       unwanted .so file extensions when installing shared libraries
+
+        """
+    crosvm_comment = """\
+        // Note: This is commented out to avoid a conflict with the binary built
+        // from external/crosvm. This should be uncommented out when backporting to
+        // older branches with just use the prebuilt and which do not build from
+        // source.
+        """
+
+    with open(android_bp_path, "wt") as out:
+        out.write(license())
+        out.write(textwrap.dedent(disclamer))
+
+        sort_key = lambda m: (
+            m.name,
+            m.parameters["name"].rsplit("_")[-1],
+            m.parameters["name"],
+        )
+        for module in sorted(modules, key=sort_key):
+            module_text = str(module)
+            if module.parameters["name"] == "x86_64_linux_gnu_crosvm":
+                out.write(textwrap.dedent(crosvm_comment))
+                module_text = comment(module_text)
+            out.write(module_text)
+
+
+def generate_all_cuttlefish_host_package_android_bp(path: Path, modules: list[Module]):
+    """Updates the list of module in 'device/google/cuttlefish/Android.bp'."""
+
+    qemu_binaries = [m for m in modules if m.name.endswith("_binary_for_qemu")]
+    qemu_resources = [m for m in modules if m.name.endswith("_resource_for_qemu")]
+
+    def update_list(list_name: str, modules:list[Module]):
+        names = sorted(m.parameters["name"] for m in modules)
+        text = f"{list_name} = {value_to_bp(names)}\n"
+        update_generated_section(path, list_name, text)
+
+    update_list("qemu_x86_64_linux_gnu_binary", qemu_binaries)
+    update_list("qemu_x86_64_linux_gnu_resource", qemu_resources)
+
+
+def main(argv):
+    if len(argv) != 1:
+        print(f"Usage error: {argv[0]} does not accept any argument.")
+        return 1
+
+    # Set the current directory to the script location.
+    os.chdir(Path(__file__).parent)
+
+    modules = list(gen_main_android_bp_modules())
+    gen_main_android_bp_file(Path("Android.bp"), modules)
+
+    generate_all_cuttlefish_host_package_android_bp(
+        Path("../cuttlefish/build/Android.bp"), modules
+    )
+
+    for arch in Architecture:
+        gen_android_bp4seccomp(arch.dir() / "Android.bp", arch)
+
+
+if __name__ == "__main__":
+    sys.exit(main(sys.argv))
diff --git a/gen_android_bp.sh b/gen_android_bp.sh
deleted file mode 100755
index 4e751d9..0000000
--- a/gen_android_bp.sh
+++ /dev/null
@@ -1,264 +0,0 @@
-#!/bin/bash
-#
-# This script generates Android.bp files for this and all subdirs of this
-#
-
-set -e
-
-readonly my_name=`basename $0`
-readonly seccomp_archs=("x86_64" "aarch64")
-# under get_arch_dir() in cuttlefish_vmm, where is seccomp?
-readonly subdir="etc/seccomp"
-
-# Replaces the generated section with content read from stdin.
-#
-# Args:
-#   path to the file to edit in place
-#   tag uniquely identifying the generated section.
-#     The generated content is delimited by two lines ending with
-#     "Start of generated ${tag}" and "End of generated ${tag}"
-function update_generated_section {
-  local -r file="$1"
-  local -r tag="$2"
-  local -r lead="^.*Start of generated ${tag}$"
-  local -r tail="^.*End of generated ${tag}$"
-  egrep --silent "${lead}" "${file}"
-  egrep --silent "${tail}" "${file}"
-  sed -i -e "
-    /$lead/,/$tail/{
-      /$lead/{
-        p;
-        a \    // Generated by device/google/cuttlefish_vmm/gen_android_bp.sh
-        r /dev/stdin
-      };
-      /$tail/p;
-      d
-    }" "${file}"""
-}
-
-function remove_trailing_slash {
-  if [[ $1 == "/" ]]; then
-    echo $i
-  else
-    echo ${1%/}
-  fi
-}
-
-# define arch dir pattern: e.g. ${ARCH}-linux-gnu
-function get_arch_dir() {
-  local suffix="-linux-gnu"
-  local arch=$1
-  echo ${arch}${suffix}
-}
-
-# take arch, return the path of the output Android.bp file
-function get_output_file() {
-  local blueprint_dir=$1
-  blueprint_dir="$(remove_trailing_slash ${blueprint_dir})"
-  echo "${blueprint_dir}/Android.bp"
-}
-
-# utility function to enumerate policy files
-#
-# 1: seccomp dir to scan
-function scan_policy_name() {
-  local seccomp_dir=$1
-  (
-    # pushd but no output to stdout/stderr
-    # the output is taken and used by the caller
-    pushd $seccomp_dir > /dev/null 2>&1
-    ls -1
-    popd > /dev/null 2>&1
-  )
-}
-
-# starting from old Android.bp
-function gen_license() {
-  local year=${1:-"2019"}
-cat <<EOF
-// Autogenerated via ${my_name}
-//
-// Copyright (C) ${year} 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.
-
-EOF
-}
-
-#
-# first two args are module type (e.g. prebuilt_usr_share_host)
-# and the whitespaces for indentation
-#
-# the rest must be in this form:
-#  --name=value
-#
-# then, it simply generates this line repeatedly:
-# <indent>name: value,
-#
-# e.g. --name="\"foo\"" will generate
-#   name: "foo",
-#
-function gen_module() {
-  local mod_name=$1  # e.g. prebuilt_usr_share_host
-  local indent="$2"
-  shift 2
-  local long_options=()
-  local long_opt=""
-  local OPTIND=1
-  while getopts ":-:" op; do
-    # a long opt like --srcs="some" is actually:
-    # - + - + "srcs=some"
-    # that's a short option '-' just like h, and
-    # the OPTARGS of the option '-' is srcs=some
-    if [[ "$op" != "-" ]]; then
-      >&2 echo "gen_module does take long options with = only"
-      exit 8
-    fi
-    long_op="${OPTARG%%=*}"
-    OPTARG="${OPTARG#$long_op}"
-    OPTARG="${OPTARG#=}"
-    long_options+=( "$long_op" )
-    declare local ${long_op}="${OPTARG}"
-  done
-
-  echo "$mod_name {"
-  for field in "${long_options[@]}"; do
-    eval local value=\$$field
-    echo "${indent}${field}: ${value},"
-  done
-  echo "}"
-}
-
-# Reads lines from the input stream and outputs them with a slashes
-# at the beginning of each line.
-function comment_out() {
-  # Internal Field Separator (IFS) cleared to preserve leading space.
-  # -r predisables backslashe interpretation.
-  while IFS= read -r line; do
-    echo "// ${line}"
-  done
-}
-
-function gen_android_bp4seccomp() {
-  local arch="$1"
-  local arch_dir="$(get_arch_dir ${arch})"
-  local seccomp_dir="${arch_dir}/${subdir}"
-  local where_in_etc_on_user_machine="cuttlefish/${arch_dir}/seccomp"
-  gen_license 2019
-  for i in $(scan_policy_name $seccomp_dir); do
-    # first two are: e.g. prebuilt_usr_share_host and whitespace for intentation
-    local base_name="$(basename $i)"
-    gen_module "prebuilt_usr_share_host" '  ' \
-      --name="\"${base_name}_at_${arch}\"" \
-      --src="\"${subdir}/${base_name}\"" \
-      --filename="\"${base_name}\"" \
-      --sub_dir="\"${where_in_etc_on_user_machine}\""
-  done
-}
-
-function gen_main_android_bp() {
-  gen_license 2019
-
-  cat <<EOF
-// NOTE: Using cc_prebuilt_binary because cc_prebuilt_library will add
-//       unwanted .so file extensions when installing shared libraries
-
-EOF
-
-for arch_dir in $(get_arch_dir aarch64) $(get_arch_dir x86_64); do
-  for i in $(echo $arch_dir/bin/{crosvm,gfxstream_graphics_detector,lib{minijail.so,gfxstream_backend.so,*.so{.0,.1,.2,.7}}} | xargs -n1 | sort); do
-    name="${i//\//_}"
-    name="${name//-/_}"
-    name="${name/_bin_/_}"
-    path="$(dirname $(dirname "$i"))"
-    stem="$(basename "$i")"
-
-
-    if [[ "crosvm" != "${stem}" ]]; then
-      name="${name}_for_crosvm"
-    fi
-
-    # Command used to process gen_module output.
-    comment_or_noop='cat'
-
-    if [[ "x86_64_linux_gnu_crosvm" == "${name}" ]]; then
-      echo '// Note: This is commented out to avoid a conflict with the binary built'
-      echo '// from external/crosvm. This should be uncommented out when backporting to'
-      echo '// older branches with just use the prebuilt and which do not build from'
-      echo '// source.'
-      comment_or_noop="comment_out"
-    fi
-
-    gen_module "cc_prebuilt_binary" '  ' \
-      --name="\"${name}\"" \
-      --srcs="[\"$i\"]" \
-      --stem="\"$stem"\" \
-      --relative_install_path="\"${path}\"" \
-      --defaults="[\"cuttlefish_host\"]" \
-      --check_elf_files="false" | "${comment_or_noop}"
-  done
-done
-
-  for binary_path in qemu/x86_64-linux-gnu/bin/*.so* qemu/x86_64-linux-gnu/bin/qemu-system*; do
-    gen_module "cc_prebuilt_binary" '  ' \
-      --name="\"x86_64_linux_gnu_$(basename "${binary_path}")_binary_for_qemu\"" \
-      --srcs="[\"${binary_path}\"]" \
-      --stem="\"$(basename "${binary_path}")"\" \
-      --defaults="[\"cuttlefish_host\"]" \
-      --check_elf_files="false"
-  done
-  resource_paths=(
-    qemu/efi-virtio.rom
-    qemu/keymaps/en-us
-    qemu/opensbi-riscv64-generic-fw_dynamic.bin
-  )
-
-  for resource_path in "${resource_paths[@]}"
-  do
-    local base_name="$(basename "${resource_path}")"
-    local arch='x86_64'
-    local arch_dir="$(get_arch_dir ${arch})"
-    local sub_dir="$(dirname "${resource_path}")"
-    gen_module "prebuilt_usr_share_host" '  ' \
-      --name="\"${arch}_${base_name}_resource_for_qemu\"" \
-      --src="\"qemu/x86_64-linux-gnu/usr/share/${resource_path}\"" \
-      --filename="\"${base_name}\"" \
-      --sub_dir="\"${sub_dir}\""
-  done
-}
-
-function generate_all_cuttlefish_host_package_android_bp() {
-  #TODO: Handle Crosvm prebuilts which are currently performed manually.
-  qemu_binaries="$(grep "_binary_for_qemu" Android.bp | sed 's/name: /  /g')"
-  qemu_resources="$(grep "_resource_for_qemu" Android.bp | sed 's/name: /  /g')"
-
-  local android_bp_file="../cuttlefish/build/Android.bp"
-  echo "${qemu_binaries}" | update_generated_section "${android_bp_file}" "qemu_x86_64_linux_gnu_binary"
-  echo "${qemu_resources}" | update_generated_section "${android_bp_file}" "qemu_x86_64_linux_gnu_resource"
-}
-
-
-# main
-
-# Set the current directory to the script location.
-cd "$(dirname "$0")"
-
-gen_main_android_bp > $(get_output_file .)
-generate_all_cuttlefish_host_package_android_bp
-
-
-for arch in ${seccomp_archs[@]}; do
-  arch_dir=$(get_arch_dir ${arch})
-  outfile="$(get_output_file ${arch_dir})"
-  gen_android_bp4seccomp $arch > $outfile
-done
diff --git a/qemu/README.md b/qemu/README.md
index 878bcd3..f03c984 100644
--- a/qemu/README.md
+++ b/qemu/README.md
@@ -46,13 +46,16 @@
 
 ```sh
 mkdir /tmp/qemu-build
-podman run --interactive --tty --name qemu-build \
-   --volume .:/src:O \
-   --volume /tmp/qemu-build:/out \
-   docker.io/debian:10-slim
+podman run --replace --pids-limit=-1 \
+  --interactive --tty \
+  --name qemu-build \
+  --volume .:/src:O \
+  --volume /tmp/qemu-build:/out \
+  docker.io/debian:10-slim
 apt-get update
-apt-get -qy install autoconf libtool texinfo
-/src/qemu/scripts/rebuild.sh --build-dir /out --run-tests
+apt-get -qy install autoconf libtool texinfo libgbm-dev
+
+/src/qemu/third_party/python/bin/python3 /src/qemu/scripts/rebuild.py --build-dir /out --run-tests
 ```
 
 Note: `/src` is mounted with a file overlay so that cargo can write
diff --git a/qemu/manifest.xml b/qemu/manifest.xml
index 4d12bee..f7a6e94 100644
--- a/qemu/manifest.xml
+++ b/qemu/manifest.xml
@@ -16,8 +16,10 @@
   <project path="qemu/third_party/flatbuffers" name="platform/external/flatbuffers" revision="baf9b3a15e291a0c76850a50f994c5947c3f5e5e" />
   <project path="qemu/third_party/gfxstream" name="platform/hardware/google/gfxstream" revision="ea8f75f109f79a281627c3dd928df6a44600ab24" />
   <project path="qemu/third_party/glib" name="platform/external/bluetooth/glib" revision="180713772f4e7bcdddf2c793f2f34a498184ed15" />
+  <project path="qemu/third_party/glib/subprojects/gvdb" name="platform/external/gvdb" revision="0854af0fdb6d527a8d1999835ac2c5059976c210" />
   <project path="qemu/third_party/googletest" name="platform/external/googletest" revision="276e32ec333e05bff6dc7d20218a8d9152623222" />
   <project path="qemu/third_party/libdrm" name="platform/external/libdrm" revision="ed0a0cde4ea44f6295786900a9f42afd78713677" />
+  <project path="qemu/third_party/libepoxy" name="platform/external/libepoxy" revision="2df68f811fc1a5f0a6d372ecdb887333ad3f540f" />
   <project path="qemu/third_party/libffi" name="platform/external/libffi" revision="a8011b453bea48ac68b8c37545b4f04aaf6a9ffc" />
   <project path="qemu/third_party/libpciaccess" name="platform/external/libpciaccess" revision="c716a921b7b970ff1fcd4ad34974877c29d103f0" />
   <project path="qemu/third_party/libslirp" name="trusty/external/qemu-libslirp" revision="3ad1710a96678fe79066b1469cead4058713a1d9" />
@@ -50,5 +52,6 @@
   <project path="qemu/third_party/rust/crates/unicode-ident" name="platform/external/rust/crates/unicode-ident" revision="2114a5cf0e82708cff6885a24be1995903c94738" />
   <project path="qemu/third_party/rust/crates/zerocopy" name="platform/external/rust/crates/zerocopy" revision="738d78f6696da049502fc4436a70ca8799e1569e" />
   <project path="qemu/third_party/rust/crates/zerocopy-derive" name="platform/external/rust/crates/zerocopy-derive" revision="e31ff4fde30f2bef09ae8f20b93d57b9040c7c1c" />
+  <project path="qemu/third_party/virglrenderer" name="platform/external/virglrenderer" revision="1b9067d7ba66296ce910441f66918edb50b00380" />
   <project path="qemu/third_party/zlib" name="platform/external/zlib" revision="81774276a9cbf47177a1b7555bb6e3ec73bdcd25" />
-</manifest>
+</manifest>
\ No newline at end of file
diff --git a/qemu/scripts/genrepo.py b/qemu/scripts/genrepo.py
index 099eeab..0884c0c 100644
--- a/qemu/scripts/genrepo.py
+++ b/qemu/scripts/genrepo.py
@@ -130,6 +130,12 @@
     "https://gitlab.gnome.org/GNOME/gvdb.git": (
         "https://android.googlesource.com/platform/external/gvdb"
     ),
+    "https://github.com/anholt/libepoxy.git": (
+        "https://android.googlesource.com/platform/external/libepoxy"
+    ),
+    "https://gitlab.freedesktop.org/virgl/virglrenderer.git": (
+        "https://android.googlesource.com/platform/external/virglrenderer"
+    ),
 }
 
 
diff --git a/qemu/scripts/rebuild.py b/qemu/scripts/rebuild.py
index 229965b..0a4eede 100755
--- a/qemu/scripts/rebuild.py
+++ b/qemu/scripts/rebuild.py
@@ -54,9 +54,9 @@
       "AR": f"{binprefix}llvm-ar",
       "NM": f"{binprefix}llvm-nm",
       "PKG_CONFIG_PATH": ":".join([
-          f"{install_dir}/usr/local/lib/pkgconfig",
           f"{install_dir}/usr/lib/x86_64-linux-gnu/pkgconfig",
           f"{install_dir}/usr/lib/pkgconfig",
+          f"{sysroot}/usr/lib/pkgconfig",
       ]),
       "PATH": f"{install_dir}/usr/bin:{path}",
       "LD_LIBRARY_PATH": ":".join([
@@ -108,10 +108,10 @@
   result = ""
   result_wrap = False
   if build_dir:
-    result += f"cd {build_dir} && "
+    result += f"cd {build_dir} && \\\n"
     result_wrap = True
   if environ:
-    result += " ".join(environ) + " "
+    result += " \\\n".join(environ) + " \\\n"
 
   result += " ".join(shlex.quote(c) for c in cmd_args)
   if result_wrap:
@@ -801,20 +801,29 @@
   )
 
 
+@project.task([])
+def build_task_for_egl(build: BuildConfig):
+  build.copy_dir(
+      build.third_party_dir / "egl" / "api" / "KHR",
+      build.sysroot_dir / "usr" / "include" / "KHR",
+  )
+  build.copy_dir(
+      build.third_party_dir / "egl" / "api" / "EGL",
+      build.sysroot_dir / "usr" / "include" / "EGL",
+  )
+
+
 @project.task([
     build_task_for_meson,
     build_task_for_aemu_base,
     build_task_for_flatbuffers,
+    build_task_for_egl,
     build_task_for_libdrm,
 ])
 def build_task_for_gfxstream(build: BuildConfig):
   dir_name = Path("gfxstream")
   src_dir = build.third_party_dir / dir_name
   build_dir = build.make_subdir(dir_name)
-  build.copy_dir(
-      build.third_party_dir / "egl" / "api" / "EGL",
-      build.sysroot_dir / "usr" / "include" / "EGL",
-  )
   build.run(
       [
           "meson",
@@ -889,6 +898,93 @@
   )
 
 
+@project.task([])
+def build_task_for_libgbm(build: BuildConfig):
+  # gbm is part of mesa which is a large project.
+  # The dependency is taken fron the system.
+  build.copy_file(
+      "/usr/lib/x86_64-linux-gnu/libgbm.so.1",
+      build.install_dir / "usr/lib/libgbm.so.1",
+  )
+  build.copy_file(
+      "/usr/lib/x86_64-linux-gnu/libgbm.so",
+      build.install_dir / "usr/lib/libgbm.so",
+  )
+  build.copy_file(
+      "/usr/lib/x86_64-linux-gnu/libgbm.so.1.0.0",
+      build.install_dir / "usr/lib/libgbm.so.1.0.0",
+  )
+  build.copy_file(
+      "/usr/lib/x86_64-linux-gnu/pkgconfig/gbm.pc",
+      build.install_dir / "usr/lib/pkgconfig/gbm.pc",
+  )
+  build.copy_file("/usr/include/gbm.h", build.install_dir / "usr/include/gbm.h")
+
+
+@project.task([
+    build_task_for_egl,
+    build_task_for_libgbm,
+    build_task_for_meson,
+    build_task_for_ninja,
+])
+def build_task_for_libepoxy(build: BuildConfig):
+  src_dir = build.third_party_dir / "libepoxy"
+  build_dir = build.make_subdir(Path("libepoxy"))
+  build.run(
+      [
+          "meson",
+          "setup",
+          "--prefix=%s/usr" % build.install_dir,
+          "--libdir=%s/usr/lib" % build.install_dir,
+          "-Dtests=false",
+          build_dir,
+          src_dir,
+      ],
+  )
+
+  build.run(["ninja", "install"], build_dir)
+  # There is a bug in`qemu/third_party/libepoxy/src/meson.build`
+  # that result in a corrupted line `Requires.private: x11,` in `epoxy.pc`.
+  # This is not valid and causes the failure:
+  # `Empty package name in Requires or Conflicts in file '[...]epoxy.pc'`
+  # This is because 'x11' is found as an implicit dependency and the
+  # pkgconfig specification in the meson file adds an empty element.
+  # Until a better solution is found, remove the dependency.
+  build.run([
+      "sed",
+      "-i",
+      "s/Requires.private: x11, $//g",
+      build.install_dir / "usr/lib/pkgconfig/epoxy.pc",
+  ])
+
+
+@project.task([
+    build_task_for_egl,
+    build_task_for_libdrm,
+    build_task_for_libepoxy,
+    build_task_for_libgbm,
+    build_task_for_meson,
+    build_task_for_ninja,
+])
+def build_task_for_virglrenderer(build: BuildConfig):
+  src_dir = build.third_party_dir / "virglrenderer"
+  build_dir = build.make_subdir(Path("virglrenderer"))
+  build.run(
+      [
+          "meson",
+          "setup",
+          "--prefix=%s/usr" % build.install_dir,
+          "--libdir=%s/usr/lib" % build.install_dir,
+          "-Dplatforms=egl",
+          "-Dtests=false",
+          build_dir,
+          src_dir,
+      ],
+  )
+
+  build.run(["ninja", "install"], build_dir)
+
+
 @project.task([
     build_task_for_make,
     build_task_for_libslirp,
@@ -898,6 +994,7 @@
     build_task_for_pkg_config,
     build_task_for_rutabaga,
     build_task_for_gfxstream,
+    build_task_for_virglrenderer,
 ])
 def build_task_for_qemu(build: BuildConfig):
   target_list = [
@@ -912,11 +1009,11 @@
       "--prefix=/usr",
       "--target-list=%s" % ",".join(target_list),
       "--disable-plugins",
+      "--enable-virglrenderer",
       # Cuttlefish is packaged in host archives that are assembled in
       # `$ANDROID_BUILD_TOP/out/host/linux-x86`.
       # Binaries are in `./bin` and resources are in `./usr/share` which is
       # different from QEMU default expectations. Details in b/296286524.
-
       # Move the binary directory up by one. This path is relative to
       # `--prefix` above.
       "-Dbindir=../bin",
@@ -946,6 +1043,8 @@
   bin_dir = package_dir / "bin"
   files = [
       "dest-install/usr/lib/libz.so.1",
+      "dest-install/usr/lib/libepoxy.so.0",
+      "dest-install/usr/lib/libvirglrenderer.so.1",
       "dest-install/usr/lib/librutabaga_gfx_ffi.so.0",
       "dest-install/usr/lib64/libc++.so.1",
   ]
diff --git a/qemu/scripts/rebuild_in_container.sh b/qemu/scripts/rebuild_in_container.sh
new file mode 100755
index 0000000..0643a11
--- /dev/null
+++ b/qemu/scripts/rebuild_in_container.sh
@@ -0,0 +1,70 @@
+#!/bin/sh
+# Starts an isolated build in a container
+set -e
+
+FROM_EXISTING_SOURCES=0
+
+while [[ $# -gt 0 ]]; do
+  case $1 in
+    --from_existing_sources)
+      FROM_EXISTING_SOURCES=1
+      shift
+      ;;
+    *)
+      echo "Build QEMU from sources in a container."
+      echo
+      echo "usage: $0 [--from_existing_sources]"
+      echo
+      echo "Options:"
+      echo "  --from_existing_sources: Do not checkout sources with repo,"
+      echo "    and do not copy the prebuild back to the source directory."
+      shift
+      exit 1
+      ;;
+  esac
+done
+
+readonly SCRIPT_DIR="$(realpath "$(dirname "$0")")"
+readonly GIT_ROOT="$(realpath "${SCRIPT_DIR}/../..")"
+readonly WORK_DIR="/tmp/qemu-build-output"
+
+echo "Clear the working directory: ${WORK_DIR}"
+rm -rf "${WORK_DIR}"
+mkdir -p "${WORK_DIR}"
+
+if [ "$FROM_EXISTING_SOURCES" -eq 0 ]; then
+  readonly SRC_DIR="${HOME}/qemu-build-checkout"
+  echo "Check out sources with repo at: ${SRC_DIR}"
+  rm -rf "${SRC_DIR}"
+  mkdir -p "${SRC_DIR}"
+  repo init --manifest-url "${GIT_ROOT}" \
+    --manifest-name=qemu/manifest.xml
+
+  repo sync
+else
+  echo "Reuse existing source checkout at: ${SRC_DIR}"
+  readonly SRC_DIR="$GIT_ROOT"
+fi
+
+readonly COMMAND="apt-get update && \
+apt-get -qy install autoconf libtool texinfo libgbm-dev && \
+/src/qemu/third_party/python/bin/python3 /src/qemu/scripts/rebuild.py --build-dir /out"
+
+podman run --name qemu-build \
+    --replace \
+    --pids-limit=-1 \
+    --volume "${SRC_DIR}:/src:O" \
+    --volume "${WORK_DIR}:/out" \
+    docker.io/debian:10-slim \
+    bash -c "${COMMAND}"
+
+if [ "$FROM_EXISTING_SOURCES" -eq 0 ]; then
+  readonly DEST="${GIT_ROOT}/qemu/x86_64-linux-gnu"
+  echo "Overwrite prebuild at: ${DEST}"
+  rm -rf "${DEST}/*"
+  tar -xvf "${WORK_DIR}/qemu-portable.tar.gz" -C "${DEST}"
+
+fi
+
+echo "Binary available at: ${WORK_DIR}/qemu-portable/bin"
+echo "Done."
\ No newline at end of file
diff --git a/qemu/x86_64-linux-gnu/bin/libepoxy.so.0 b/qemu/x86_64-linux-gnu/bin/libepoxy.so.0
new file mode 100755
index 0000000..a61cbc4
--- /dev/null
+++ b/qemu/x86_64-linux-gnu/bin/libepoxy.so.0
Binary files differ
diff --git a/qemu/x86_64-linux-gnu/bin/libgfxstream_backend.so.0 b/qemu/x86_64-linux-gnu/bin/libgfxstream_backend.so.0
index 44455ac..5e02864 100755
--- a/qemu/x86_64-linux-gnu/bin/libgfxstream_backend.so.0
+++ b/qemu/x86_64-linux-gnu/bin/libgfxstream_backend.so.0
Binary files differ
diff --git a/qemu/x86_64-linux-gnu/bin/librutabaga_gfx_ffi.so.0 b/qemu/x86_64-linux-gnu/bin/librutabaga_gfx_ffi.so.0
index 23f0eea..8d190b0 100755
--- a/qemu/x86_64-linux-gnu/bin/librutabaga_gfx_ffi.so.0
+++ b/qemu/x86_64-linux-gnu/bin/librutabaga_gfx_ffi.so.0
Binary files differ
diff --git a/qemu/x86_64-linux-gnu/bin/libvirglrenderer.so.1 b/qemu/x86_64-linux-gnu/bin/libvirglrenderer.so.1
new file mode 100755
index 0000000..591ce5d
--- /dev/null
+++ b/qemu/x86_64-linux-gnu/bin/libvirglrenderer.so.1
Binary files differ
diff --git a/qemu/x86_64-linux-gnu/bin/qemu-edid b/qemu/x86_64-linux-gnu/bin/qemu-edid
index 90eea7a..75a5648 100755
--- a/qemu/x86_64-linux-gnu/bin/qemu-edid
+++ b/qemu/x86_64-linux-gnu/bin/qemu-edid
Binary files differ
diff --git a/qemu/x86_64-linux-gnu/bin/qemu-ga b/qemu/x86_64-linux-gnu/bin/qemu-ga
index 7017208..080c1c1 100755
--- a/qemu/x86_64-linux-gnu/bin/qemu-ga
+++ b/qemu/x86_64-linux-gnu/bin/qemu-ga
Binary files differ
diff --git a/qemu/x86_64-linux-gnu/bin/qemu-img b/qemu/x86_64-linux-gnu/bin/qemu-img
index e63f737..937a248 100755
--- a/qemu/x86_64-linux-gnu/bin/qemu-img
+++ b/qemu/x86_64-linux-gnu/bin/qemu-img
Binary files differ
diff --git a/qemu/x86_64-linux-gnu/bin/qemu-io b/qemu/x86_64-linux-gnu/bin/qemu-io
index 3bbc40c..99780ae 100755
--- a/qemu/x86_64-linux-gnu/bin/qemu-io
+++ b/qemu/x86_64-linux-gnu/bin/qemu-io
Binary files differ
diff --git a/qemu/x86_64-linux-gnu/bin/qemu-nbd b/qemu/x86_64-linux-gnu/bin/qemu-nbd
index cb90a78..9f7c662 100755
--- a/qemu/x86_64-linux-gnu/bin/qemu-nbd
+++ b/qemu/x86_64-linux-gnu/bin/qemu-nbd
Binary files differ
diff --git a/qemu/x86_64-linux-gnu/bin/qemu-pr-helper b/qemu/x86_64-linux-gnu/bin/qemu-pr-helper
index 08c3f48..b820598 100755
--- a/qemu/x86_64-linux-gnu/bin/qemu-pr-helper
+++ b/qemu/x86_64-linux-gnu/bin/qemu-pr-helper
Binary files differ
diff --git a/qemu/x86_64-linux-gnu/bin/qemu-storage-daemon b/qemu/x86_64-linux-gnu/bin/qemu-storage-daemon
index d1d26da..540bd4e 100755
--- a/qemu/x86_64-linux-gnu/bin/qemu-storage-daemon
+++ b/qemu/x86_64-linux-gnu/bin/qemu-storage-daemon
Binary files differ
diff --git a/qemu/x86_64-linux-gnu/bin/qemu-system-aarch64 b/qemu/x86_64-linux-gnu/bin/qemu-system-aarch64
index c893ab5..c91c993 100755
--- a/qemu/x86_64-linux-gnu/bin/qemu-system-aarch64
+++ b/qemu/x86_64-linux-gnu/bin/qemu-system-aarch64
Binary files differ
diff --git a/qemu/x86_64-linux-gnu/bin/qemu-system-riscv64 b/qemu/x86_64-linux-gnu/bin/qemu-system-riscv64
index ecc1ae3..bf3940e 100755
--- a/qemu/x86_64-linux-gnu/bin/qemu-system-riscv64
+++ b/qemu/x86_64-linux-gnu/bin/qemu-system-riscv64
Binary files differ
diff --git a/qemu/x86_64-linux-gnu/bin/qemu-system-x86_64 b/qemu/x86_64-linux-gnu/bin/qemu-system-x86_64
index 26c7d18..f9e0d10 100755
--- a/qemu/x86_64-linux-gnu/bin/qemu-system-x86_64
+++ b/qemu/x86_64-linux-gnu/bin/qemu-system-x86_64
Binary files differ
diff --git a/qemu/x86_64-linux-gnu/usr/lib/x86_64-linux-gnu/libfdt.a b/qemu/x86_64-linux-gnu/usr/lib/libfdt.a
similarity index 70%
rename from qemu/x86_64-linux-gnu/usr/lib/x86_64-linux-gnu/libfdt.a
rename to qemu/x86_64-linux-gnu/usr/lib/libfdt.a
index 7059bc1..a61f710 100644
--- a/qemu/x86_64-linux-gnu/usr/lib/x86_64-linux-gnu/libfdt.a
+++ b/qemu/x86_64-linux-gnu/usr/lib/libfdt.a
Binary files differ
diff --git a/qemu/x86_64-linux-gnu/usr/lib/x86_64-linux-gnu/pkgconfig/libfdt.pc b/qemu/x86_64-linux-gnu/usr/lib/pkgconfig/libfdt.pc
similarity index 80%
rename from qemu/x86_64-linux-gnu/usr/lib/x86_64-linux-gnu/pkgconfig/libfdt.pc
rename to qemu/x86_64-linux-gnu/usr/lib/pkgconfig/libfdt.pc
index 8792615..ffdac5a 100644
--- a/qemu/x86_64-linux-gnu/usr/lib/x86_64-linux-gnu/pkgconfig/libfdt.pc
+++ b/qemu/x86_64-linux-gnu/usr/lib/pkgconfig/libfdt.pc
@@ -1,6 +1,6 @@
 prefix=/usr
 includedir=${prefix}/include
-libdir=${prefix}/lib/x86_64-linux-gnu
+libdir=${prefix}/lib
 
 Name: libfdt
 Description: Flat Device Tree manipulation
diff --git a/qemu/x86_64-linux-gnu/usr/libexec/qemu-bridge-helper b/qemu/x86_64-linux-gnu/usr/libexec/qemu-bridge-helper
index 4b63dd1..e4a86ea 100755
--- a/qemu/x86_64-linux-gnu/usr/libexec/qemu-bridge-helper
+++ b/qemu/x86_64-linux-gnu/usr/libexec/qemu-bridge-helper
Binary files differ
diff --git a/qemu/x86_64-linux-gnu/usr/libexec/vhost-user-gpu b/qemu/x86_64-linux-gnu/usr/libexec/vhost-user-gpu
new file mode 100755
index 0000000..18401db
--- /dev/null
+++ b/qemu/x86_64-linux-gnu/usr/libexec/vhost-user-gpu
Binary files differ
diff --git a/qemu/x86_64-linux-gnu/usr/share/qemu/vhost-user/50-qemu-gpu.json b/qemu/x86_64-linux-gnu/usr/share/qemu/vhost-user/50-qemu-gpu.json
new file mode 100644
index 0000000..284519f
--- /dev/null
+++ b/qemu/x86_64-linux-gnu/usr/share/qemu/vhost-user/50-qemu-gpu.json
@@ -0,0 +1,5 @@
+{
+  "description": "QEMU vhost-user-gpu",
+  "type": "gpu",
+  "binary": "/usr/libexec/vhost-user-gpu"
+}
diff --git a/x86_64-linux-gnu/Android.bp b/x86_64-linux-gnu/Android.bp
index 8de52b0..9968d58 100644
--- a/x86_64-linux-gnu/Android.bp
+++ b/x86_64-linux-gnu/Android.bp
@@ -1,6 +1,6 @@
-// Autogenerated via gen_android_bp.sh
+// Autogenerated via gen_android_bp.py
 //
-// Copyright (C) 2019 The Android Open Source Project
+// Copyright (C) 2023 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.
@@ -51,18 +51,18 @@
   sub_dir: "cuttlefish/x86_64-linux-gnu/seccomp",
 }
 prebuilt_usr_share_host {
-  name: "coiommu_device.policy_at_x86_64",
-  src: "etc/seccomp/coiommu_device.policy",
-  filename: "coiommu_device.policy",
-  sub_dir: "cuttlefish/x86_64-linux-gnu/seccomp",
-}
-prebuilt_usr_share_host {
   name: "coiommu.policy_at_x86_64",
   src: "etc/seccomp/coiommu.policy",
   filename: "coiommu.policy",
   sub_dir: "cuttlefish/x86_64-linux-gnu/seccomp",
 }
 prebuilt_usr_share_host {
+  name: "coiommu_device.policy_at_x86_64",
+  src: "etc/seccomp/coiommu_device.policy",
+  filename: "coiommu_device.policy",
+  sub_dir: "cuttlefish/x86_64-linux-gnu/seccomp",
+}
+prebuilt_usr_share_host {
   name: "common_device.policy_at_x86_64",
   src: "etc/seccomp/common_device.policy",
   filename: "common_device.policy",
@@ -159,6 +159,12 @@
   sub_dir: "cuttlefish/x86_64-linux-gnu/seccomp",
 }
 prebuilt_usr_share_host {
+  name: "serial.policy_at_x86_64",
+  src: "etc/seccomp/serial.policy",
+  filename: "serial.policy",
+  sub_dir: "cuttlefish/x86_64-linux-gnu/seccomp",
+}
+prebuilt_usr_share_host {
   name: "serial_device.policy_at_x86_64",
   src: "etc/seccomp/serial_device.policy",
   filename: "serial_device.policy",
@@ -177,12 +183,6 @@
   sub_dir: "cuttlefish/x86_64-linux-gnu/seccomp",
 }
 prebuilt_usr_share_host {
-  name: "serial.policy_at_x86_64",
-  src: "etc/seccomp/serial.policy",
-  filename: "serial.policy",
-  sub_dir: "cuttlefish/x86_64-linux-gnu/seccomp",
-}
-prebuilt_usr_share_host {
   name: "snd_cras_device.policy_at_x86_64",
   src: "etc/seccomp/snd_cras_device.policy",
   filename: "snd_cras_device.policy",
@@ -267,14 +267,14 @@
   sub_dir: "cuttlefish/x86_64-linux-gnu/seccomp",
 }
 prebuilt_usr_share_host {
-  name: "xhci_device.policy_at_x86_64",
-  src: "etc/seccomp/xhci_device.policy",
-  filename: "xhci_device.policy",
-  sub_dir: "cuttlefish/x86_64-linux-gnu/seccomp",
-}
-prebuilt_usr_share_host {
   name: "xhci.policy_at_x86_64",
   src: "etc/seccomp/xhci.policy",
   filename: "xhci.policy",
   sub_dir: "cuttlefish/x86_64-linux-gnu/seccomp",
 }
+prebuilt_usr_share_host {
+  name: "xhci_device.policy_at_x86_64",
+  src: "etc/seccomp/xhci_device.policy",
+  filename: "xhci_device.policy",
+  sub_dir: "cuttlefish/x86_64-linux-gnu/seccomp",
+}