Merge commit '3d6176ad27301b189799cd2cd7d2feadaf248f13' into cros_sdk
Update chromiumos-overlay to CrOS version 14283.0.0
BUG=b/202788640
TEST=local BE run
RELEASE_NOTE=Updated ChromeOS base to ChromeOS version 14283.0.0.
Change-Id: I7837e0824b11daf6638694bd94b6b835cce3266f
diff --git a/PRESUBMIT.cfg b/PRESUBMIT.cfg
index bfd4996..4e43cea 100644
--- a/PRESUBMIT.cfg
+++ b/PRESUBMIT.cfg
@@ -12,6 +12,9 @@
# that live in this repository and are installed by packages.
long_line_check: false
+# Make sure RELEASE_NOTE field is present.
+release_note_field_check: true
+
[Hook Overrides Options]
# Ignore VERSION file and table file
cros_license_check:
diff --git a/app-emulation/qemu/Manifest b/app-emulation/qemu/Manifest
index 96bd155..2157b27 100644
--- a/app-emulation/qemu/Manifest
+++ b/app-emulation/qemu/Manifest
@@ -1,3 +1 @@
-DIST qemu-20200718-keycodemapdb.tar.gz 47598 BLAKE2B 8ffeb7afd4c2ccbdb686d61428dc106a98907a96bb4980e187eace15c1c2454196fd16cb7b48d1887db98ff9aea55089ab192479068eaec0ac04c9e632fe5e81 SHA512 0db43f9933b5837ff534415c7084777f939ed3db7523e73fbb046567b96d5c097cf81b7670368447b6da38d514c62e0ede9b4b872954c4f42078b0dc8431e66d
-DIST qemu-20200729-berkeley-testfloat-3.tar.gz 139221 BLAKE2B 7e4a0632224f8e8d5a11ae373bbe334adb3eaee9c0bc5626be1d6148cbb219b2311ce20bc7a8ff7d532f932c497fc8f3ead75ccf4a8d406fcc4e0fca15061c0a SHA512 98a8b1be0c2854e36f1eef9de0ea5609a30e35cf231da7bb63242d636a6139d61ff78f117e8e24e0d076a588abf12cbeea06dc8ba625b84feccc07e05cd365a3
-DIST qemu-20200729-slirp.tar.gz 126451 BLAKE2B cf139056b275b54aec11e708bc7832817b707c91adaaa830c5e73ca03f3283d699073d96cac0c64a2fe72abe60c35b8d7b5f777d70ba7d2aabce1f21b6b1b5e4 SHA512 09038eb718b01a67389d1a9db1b5a4db6e0195ea4365670b90dbb3a87e18b82b85e43c24f718eba3c4045a325469836c6da0286bd5d8952ca171e9eb7800d19f
+DIST qemu-5.2.0.tar.xz 106902800 BLAKE2B 4413d5591cbabf80faba5b0b7347ee7749ff0a71af44bdf7f64b1995e17ecf1f3df539fa8e63959e0d50cd0502a41a2921e60cc6d078ed8ab5b09ab4b86d4ed7 SHA512 bddd633ce111471ebc651e03080251515178808556b49a308a724909e55dac0be0cc0c79c536ac12d239678ae94c60100dc124be9b9d9538340c03a2f27177f3
diff --git a/app-emulation/qemu/files/qemu-2.11.1-capstone_include_path.patch b/app-emulation/qemu/files/qemu-2.11.1-capstone_include_path.patch
new file mode 100644
index 0000000..d79570e
--- /dev/null
+++ b/app-emulation/qemu/files/qemu-2.11.1-capstone_include_path.patch
@@ -0,0 +1,11 @@
+--- qemu-2.11.1/include/disas/capstone.h 2018-02-14 22:53:22.000000000 +0100
++++ qemu-2.11.1/include/disas/capstone.h 2018-02-17 20:12:12.754703951 +0100
+@@ -3,7 +3,7 @@
+
+ #ifdef CONFIG_CAPSTONE
+
+-#include <capstone.h>
++#include <capstone/capstone.h>
+
+ #else
+
diff --git a/app-emulation/qemu/files/qemu-5.2.0-cleaner-werror.patch b/app-emulation/qemu/files/qemu-5.2.0-cleaner-werror.patch
new file mode 100644
index 0000000..33115f1
--- /dev/null
+++ b/app-emulation/qemu/files/qemu-5.2.0-cleaner-werror.patch
@@ -0,0 +1,40 @@
+-Wall -Wextra compains about unused arguments,
+causes safe-stack to be mis-detected.
+--- a/configure
++++ b/configure
+@@ -2293,7 +2293,7 @@ fi
+ cat > $TMPC << EOF
+ #include <stdint.h>
+ #include <stdio.h>
+-int main(int argc, char *argv[]) {
++int main(void) {
+ return printf("%zu", SIZE_MAX);
+ }
+ EOF
+@@ -4911,7 +4911,7 @@ fi
+
+ if test "$safe_stack" = "yes"; then
+ cat > $TMPC << EOF
+-int main(int argc, char *argv[])
++int main(void)
+ {
+ #if ! __has_feature(safe_stack)
+ #error SafeStack Disabled
+@@ -4933,7 +4933,7 @@ EOF
+ fi
+ else
+ cat > $TMPC << EOF
+-int main(int argc, char *argv[])
++int main(void)
+ {
+ #if defined(__has_feature)
+ #if __has_feature(safe_stack)
+@@ -5283,7 +5283,7 @@ static const int Z = 1;
+ #define TAUT(X) ((X) == Z)
+ #define PAREN(X, Y) (X == Y)
+ #define ID(X) (X)
+-int main(int argc, char *argv[])
++int main(void)
+ {
+ int x = 0, y = 0;
+ x = ID(x);
diff --git a/app-emulation/qemu/files/qemu-5.2.0-disable-keymap.patch b/app-emulation/qemu/files/qemu-5.2.0-disable-keymap.patch
new file mode 100644
index 0000000..4b5676b
--- /dev/null
+++ b/app-emulation/qemu/files/qemu-5.2.0-disable-keymap.patch
@@ -0,0 +1,25 @@
+Do not use system's 'qemu-keymap' in native case.
+--- a/meson.build
++++ b/meson.build
+@@ -337,6 +337,8 @@ if 'CONFIG_LIBCAP_NG' in config_host
+ endif
+ if get_option('xkbcommon').auto() and not have_system and not have_tools
+ xkbcommon = not_found
++elif get_option('xkbcommon').disabled()
++ xkbcommon = not_found
+ else
+ xkbcommon = dependency('xkbcommon', required: get_option('xkbcommon'),
+ method: 'pkg-config', static: enable_static)
+--- a/pc-bios/keymaps/meson.build
++++ b/pc-bios/keymaps/meson.build
+@@ -33,7 +33,9 @@ keymaps = {
+ 'tr': '-l tr',
+ }
+
+-if meson.is_cross_build() or 'CONFIG_XKBCOMMON' not in config_host
++if meson.is_cross_build()
+ native_qemu_keymap = find_program('qemu-keymap', required: false, disabler: true)
++elif get_option('xkbcommon').disabled()
++ native_qemu_keymap = not_found
+ else
+ native_qemu_keymap = qemu_keymap
diff --git a/app-emulation/qemu/files/qemu-5.2.0-strings.patch b/app-emulation/qemu/files/qemu-5.2.0-strings.patch
new file mode 100644
index 0000000..0b3dcdc
--- /dev/null
+++ b/app-emulation/qemu/files/qemu-5.2.0-strings.patch
@@ -0,0 +1,23 @@
+https://bugs.gentoo.org/759310
+--- a/configure
++++ b/configure
+@@ -521,6 +521,7 @@ ld="${LD-${cross_prefix}ld}"
+ ranlib="${RANLIB-${cross_prefix}ranlib}"
+ nm="${NM-${cross_prefix}nm}"
+ strip="${STRIP-${cross_prefix}strip}"
++strings="${STRINGS-${cross_prefix}strings}"
+ windres="${WINDRES-${cross_prefix}windres}"
+ pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
+ query_pkg_config() {
+@@ -2265,9 +2266,9 @@ int main(int argc, char *argv[]) {
+ EOF
+
+ if compile_object ; then
+- if strings -a $TMPO | grep -q BiGeNdIaN ; then
++ if $strings -a $TMPO | grep -q BiGeNdIaN ; then
+ bigendian="yes"
+- elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
++ elif $strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
+ bigendian="no"
+ else
+ echo big/little test failed
diff --git a/app-emulation/qemu/metadata.xml b/app-emulation/qemu/metadata.xml
index 0c30c45..930ce27 100644
--- a/app-emulation/qemu/metadata.xml
+++ b/app-emulation/qemu/metadata.xml
@@ -29,6 +29,8 @@
<pkg>net-libs/libiscsi</pkg> instead of indirectly via the Linux
block layer that <pkg>sys-block/open-iscsi</pkg> does.</flag>
<flag name="io-uring">Enable efficient I/O via <pkg>sys-libs/liburing</pkg>.</flag>
+ <flag name="multipath">Enable multipath persistent reservation passthrough via
+ <pkg>sys-fs/multipath-tools</pkg>.</flag>
<flag name="ncurses">Enable the ncurses-based console</flag>
<flag name="nfs">Enable NFS support</flag>
<flag name="numa">Enable NUMA support</flag>
@@ -40,12 +42,12 @@
<flag name="rbd">Enable rados block device backend support, see http://ceph.newdream.net/wiki/QEMU-RBD</flag>
<flag name="sdl">Enable the SDL-based console</flag>
<flag name="sdl-image">SDL Image support for icons</flag>
+ <flag name="slirp">Enable TCP/IP in hypervisor via <pkg>net-libs/libslirp</pkg></flag>
<flag name="spice">Enable Spice protocol support via <pkg>app-emulation/spice</pkg></flag>
<flag name="ssh">Enable SSH based block device support via <pkg>net-libs/libssh2</pkg></flag>
<flag name="static-user">Build the User targets as static binaries</flag>
<flag name="static">Build the User and Software MMU (system) targets as well as tools as static binaries</flag>
<flag name="systemtap">Enable SystemTAP/DTrace tracing</flag>
- <flag name="tci">Enable the TCG Interpreter which can speed up or slowdown workloads depending on the host and guest CPUs being emulated. In the future it will be a runtime option but for now its compile time.</flag>
<flag name="jemalloc">Enable jemalloc allocator support</flag>
<flag name="jpeg">Enable jpeg image support for the VNC console server</flag>
<flag name="png">Enable png image support for the VNC console server</flag>
@@ -58,8 +60,7 @@
<flag name="virtfs">Enable VirtFS via virtio-9p-pci / fsdev. See http://wiki.qemu.org/Documentation/9psetup</flag>
<flag name="vte">Enable terminal support (<pkg>x11-libs/vte</pkg>) in the GTK+ interface</flag>
<flag name="xattr">Add support for getting and setting POSIX extended attributes, through
- <pkg>sys-apps/attr</pkg>. Requisite for the virtfs backend.
- </flag>
+ <pkg>sys-apps/attr</pkg>. Requisite for the virtfs backend.</flag>
<flag name="xen">Enables support for Xen backends</flag>
<flag name="xfs">Support xfsctl() notification and syncing for XFS backed
virtual disks.</flag>
diff --git a/app-emulation/qemu/qemu-5.2.0-r1.ebuild b/app-emulation/qemu/qemu-5.2.0-r1.ebuild
new file mode 120000
index 0000000..babb047
--- /dev/null
+++ b/app-emulation/qemu/qemu-5.2.0-r1.ebuild
@@ -0,0 +1 @@
+qemu-5.2.0.ebuild
\ No newline at end of file
diff --git a/app-emulation/qemu/qemu-5.2.0.ebuild b/app-emulation/qemu/qemu-5.2.0.ebuild
new file mode 100644
index 0000000..66da0a4
--- /dev/null
+++ b/app-emulation/qemu/qemu-5.2.0.ebuild
@@ -0,0 +1,857 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="7"
+
+PYTHON_COMPAT=( python3_{6,7,8,9} )
+PYTHON_REQ_USE="ncurses,readline"
+
+FIRMWARE_ABI_VERSION="4.0.0-r50"
+
+inherit eutils linux-info toolchain-funcs multilib python-r1 \
+ udev fcaps readme.gentoo-r1 pax-utils l10n xdg-utils
+
+if [[ ${PV} = *9999* ]]; then
+ EGIT_REPO_URI="https://git.qemu.org/git/qemu.git"
+ EGIT_SUBMODULES=(
+ meson
+ tests/fp/berkeley-softfloat-3
+ tests/fp/berkeley-testfloat-3
+ ui/keycodemapdb
+ )
+ inherit git-r3
+ SRC_URI=""
+else
+ SRC_URI="https://download.qemu.org/${P}.tar.xz"
+ KEYWORDS="*"
+fi
+
+DESCRIPTION="QEMU + Kernel-based Virtual Machine userland tools"
+HOMEPAGE="http://www.qemu.org http://www.linux-kvm.org"
+
+LICENSE="GPL-2 LGPL-2 BSD-2"
+SLOT="0"
+
+IUSE="accessibility +aio alsa bzip2 capstone +caps +curl debug doc
+ +fdt glusterfs gnutls gtk infiniband iscsi io-uring
+ jack jemalloc +jpeg kernel_linux
+ kernel_FreeBSD lzo multipath
+ ncurses nfs nls numa opengl +oss +pin-upstream-blobs
+ plugins +png pulseaudio python rbd sasl +seccomp sdl sdl-image selinux
+ +slirp
+ smartcard snappy spice ssh static static-user systemtap test udev usb
+ usbredir vde +vhost-net vhost-user-fs virgl virtfs +vnc vte xattr xen
+ xfs zstd"
+
+COMMON_TARGETS="aarch64 alpha arm cris hppa i386 m68k microblaze microblazeel
+ mips mips64 mips64el mipsel nios2 or1k ppc ppc64 riscv32 riscv64 s390x
+ sh4 sh4eb sparc sparc64 x86_64 xtensa xtensaeb"
+IUSE_SOFTMMU_TARGETS="${COMMON_TARGETS}
+ avr lm32 moxie rx tricore unicore32"
+IUSE_USER_TARGETS="${COMMON_TARGETS}
+ aarch64_be armeb mipsn32 mipsn32el ppc64abi32 ppc64le sparc32plus
+ tilegx"
+
+use_softmmu_targets=$(printf ' qemu_softmmu_targets_%s' ${IUSE_SOFTMMU_TARGETS})
+use_user_targets=$(printf ' qemu_user_targets_%s' ${IUSE_USER_TARGETS})
+IUSE+=" ${use_softmmu_targets} ${use_user_targets}"
+
+RESTRICT="!test? ( test )"
+# Allow no targets to be built so that people can get a tools-only build.
+# Block USE flag configurations known to not work.
+REQUIRED_USE="${PYTHON_REQUIRED_USE}
+ qemu_softmmu_targets_arm? ( fdt )
+ qemu_softmmu_targets_microblaze? ( fdt )
+ qemu_softmmu_targets_mips64el? ( fdt )
+ qemu_softmmu_targets_ppc64? ( fdt )
+ qemu_softmmu_targets_ppc? ( fdt )
+ qemu_softmmu_targets_riscv32? ( fdt )
+ qemu_softmmu_targets_riscv64? ( fdt )
+ static? ( static-user !alsa !gtk !jack !opengl !pulseaudio !plugins !rbd !snappy )
+ static-user? ( !plugins )
+ vhost-user-fs? ( caps seccomp )
+ virtfs? ( caps xattr )
+ vte? ( gtk )
+ multipath? ( udev )
+ plugins? ( !static !static-user )
+"
+
+# Dependencies required for qemu tools (qemu-nbd, qemu-img, qemu-io, ...)
+# and user/softmmu targets (qemu-*, qemu-system-*).
+#
+# Yep, you need both libcap and libcap-ng since virtfs only uses libcap.
+#
+# The attr lib isn't always linked in (although the USE flag is always
+# respected). This is because qemu supports using the C library's API
+# when available rather than always using the external library.
+ALL_DEPEND="
+ >=dev-libs/glib-2.0[static-libs(+)]
+ sys-libs/zlib[static-libs(+)]
+ python? ( ${PYTHON_DEPS} )
+ systemtap? ( dev-util/systemtap )
+ xattr? ( sys-apps/attr[static-libs(+)] )"
+
+# Dependencies required for qemu tools (qemu-nbd, qemu-img, qemu-io, ...)
+# softmmu targets (qemu-system-*).
+SOFTMMU_TOOLS_DEPEND="
+ dev-libs/libxml2[static-libs(+)]
+ >=x11-libs/pixman-0.28.0[static-libs(+)]
+ accessibility? (
+ app-accessibility/brltty[api]
+ app-accessibility/brltty[static-libs(+)]
+ )
+ aio? ( dev-libs/libaio[static-libs(+)] )
+ alsa? ( >=media-libs/alsa-lib-1.0.13 )
+ bzip2? ( app-arch/bzip2[static-libs(+)] )
+ capstone? ( dev-libs/capstone:= )
+ caps? ( sys-libs/libcap-ng[static-libs(+)] )
+ curl? ( >=net-misc/curl-7.15.4[static-libs(+)] )
+ fdt? ( >=sys-apps/dtc-1.5.0[static-libs(+)] )
+ glusterfs? ( >=sys-cluster/glusterfs-3.4.0[static-libs(+)] )
+ gnutls? (
+ dev-libs/nettle:=[static-libs(+)]
+ >=net-libs/gnutls-3.0:=[static-libs(+)]
+ )
+ gtk? (
+ x11-libs/gtk+:3
+ vte? ( x11-libs/vte:2.91 )
+ )
+ infiniband? (
+ sys-fabric/libibumad:=[static-libs(+)]
+ sys-fabric/libibverbs:=[static-libs(+)]
+ sys-fabric/librdmacm:=[static-libs(+)]
+ )
+ iscsi? ( net-libs/libiscsi )
+ io-uring? ( sys-libs/liburing:=[static-libs(+)] )
+ jack? ( virtual/jack )
+ jemalloc? ( dev-libs/jemalloc )
+ jpeg? ( virtual/jpeg:0=[static-libs(+)] )
+ lzo? ( dev-libs/lzo:2[static-libs(+)] )
+ multipath? ( sys-fs/multipath-tools )
+ ncurses? (
+ sys-libs/ncurses:0=[unicode]
+ sys-libs/ncurses:0=[static-libs(+)]
+ )
+ nfs? ( >=net-fs/libnfs-1.9.3:=[static-libs(+)] )
+ numa? ( sys-process/numactl[static-libs(+)] )
+ opengl? (
+ virtual/opengl
+ media-libs/libepoxy[static-libs(+)]
+ media-libs/mesa[static-libs(+)]
+ media-libs/mesa[egl,gbm]
+ )
+ png? ( media-libs/libpng:0=[static-libs(+)] )
+ pulseaudio? ( media-sound/pulseaudio )
+ rbd? ( sys-cluster/ceph )
+ sasl? ( dev-libs/cyrus-sasl[static-libs(+)] )
+ sdl? (
+ media-libs/libsdl2[video]
+ media-libs/libsdl2[static-libs(+)]
+ )
+ sdl-image? ( media-libs/sdl2-image[static-libs(+)] )
+ seccomp? ( >=sys-libs/libseccomp-2.1.0[static-libs(+)] )
+ slirp? ( net-libs/libslirp[static-libs(+)] )
+ smartcard? ( >=app-emulation/libcacard-2.5.0[static-libs(+)] )
+ snappy? ( app-arch/snappy:= )
+ spice? (
+ >=app-emulation/spice-protocol-0.12.3
+ >=app-emulation/spice-0.12.0[static-libs(+)]
+ )
+ ssh? ( >=net-libs/libssh-0.8.6[static-libs(+)] )
+ udev? ( virtual/libudev[static-libs(+)] )
+ usb? ( >=virtual/libusb-1-r2[static-libs(+)] )
+ usbredir? ( >=sys-apps/usbredir-0.6[static-libs(+)] )
+ vde? ( net-misc/vde[static-libs(+)] )
+ virgl? ( media-libs/virglrenderer[static-libs(+)] )
+ virtfs? ( sys-libs/libcap )
+ xen? ( app-emulation/xen-tools:= )
+ xfs? ( sys-fs/xfsprogs[static-libs(+)] )
+ zstd? ( >=app-arch/zstd-1.4.0[static-libs(+)] )
+"
+
+X86_FIRMWARE_DEPEND="
+ pin-upstream-blobs? (
+ ~sys-firmware/edk2-ovmf-201905[binary]
+ ~sys-firmware/ipxe-1.0.0_p20190728[binary,qemu]
+ ~sys-firmware/seabios-1.12.0[binary,seavgabios]
+ ~sys-firmware/sgabios-0.1_pre8[binary]
+ )
+ !pin-upstream-blobs? (
+ sys-firmware/edk2-ovmf
+ sys-firmware/ipxe[qemu]
+ >=sys-firmware/seabios-1.10.2[seavgabios]
+ sys-firmware/sgabios
+ )"
+PPC64_FIRMWARE_DEPEND="
+ pin-upstream-blobs? (
+ ~sys-firmware/seabios-1.12.0[binary,seavgabios]
+ )
+ !pin-upstream-blobs? (
+ >=sys-firmware/seabios-1.10.2[seavgabios]
+ )
+"
+
+BDEPEND="
+ $(python_gen_impl_dep)
+ dev-lang/perl
+ sys-apps/texinfo
+ virtual/pkgconfig
+ doc? ( dev-python/sphinx )
+ gtk? ( nls? ( sys-devel/gettext ) )
+ test? (
+ dev-libs/glib[utils]
+ sys-devel/bc
+ )
+"
+CDEPEND="
+ !static? (
+ ${ALL_DEPEND//\[static-libs(+)]}
+ ${SOFTMMU_TOOLS_DEPEND//\[static-libs(+)]}
+ )
+ qemu_softmmu_targets_i386? ( ${X86_FIRMWARE_DEPEND} )
+ qemu_softmmu_targets_x86_64? ( ${X86_FIRMWARE_DEPEND} )
+ qemu_softmmu_targets_ppc64? ( ${PPC64_FIRMWARE_DEPEND} )
+"
+DEPEND="${CDEPEND}
+ kernel_linux? ( >=sys-kernel/linux-headers-2.6.35 )
+ static? (
+ ${ALL_DEPEND}
+ ${SOFTMMU_TOOLS_DEPEND}
+ )
+ static-user? ( ${ALL_DEPEND} )"
+RDEPEND="${CDEPEND}
+ acct-group/kvm
+ selinux? ( sec-policy/selinux-qemu )"
+
+PATCHES=(
+ "${FILESDIR}"/${PN}-2.11.1-capstone_include_path.patch
+ "${FILESDIR}"/${PN}-5.2.0-cleaner-werror.patch
+ "${FILESDIR}"/${PN}-5.2.0-disable-keymap.patch
+ "${FILESDIR}"/${PN}-5.2.0-strings.patch
+)
+
+QA_PREBUILT="
+ usr/share/qemu/hppa-firmware.img
+ usr/share/qemu/openbios-ppc
+ usr/share/qemu/openbios-sparc64
+ usr/share/qemu/openbios-sparc32
+ usr/share/qemu/opensbi-riscv64-generic-fw_dynamic.elf
+ usr/share/qemu/opensbi-riscv32-generic-fw_dynamic.elf
+ usr/share/qemu/palcode-clipper
+ usr/share/qemu/s390-ccw.img
+ usr/share/qemu/s390-netboot.img
+ usr/share/qemu/u-boot.e500
+"
+
+QA_WX_LOAD="usr/bin/qemu-i386
+ usr/bin/qemu-x86_64
+ usr/bin/qemu-alpha
+ usr/bin/qemu-arm
+ usr/bin/qemu-cris
+ usr/bin/qemu-m68k
+ usr/bin/qemu-microblaze
+ usr/bin/qemu-microblazeel
+ usr/bin/qemu-mips
+ usr/bin/qemu-mipsel
+ usr/bin/qemu-or1k
+ usr/bin/qemu-ppc
+ usr/bin/qemu-ppc64
+ usr/bin/qemu-ppc64abi32
+ usr/bin/qemu-sh4
+ usr/bin/qemu-sh4eb
+ usr/bin/qemu-sparc
+ usr/bin/qemu-sparc64
+ usr/bin/qemu-armeb
+ usr/bin/qemu-sparc32plus
+ usr/bin/qemu-s390x
+ usr/bin/qemu-unicore32
+"
+
+DOC_CONTENTS="If you don't have kvm compiled into the kernel, make sure you have the
+kernel module loaded before running kvm. The easiest way to ensure that the
+kernel module is loaded is to load it on boot.
+ For AMD CPUs the module is called 'kvm-amd'.
+ For Intel CPUs the module is called 'kvm-intel'.
+Please review /etc/conf.d/modules for how to load these.
+
+Make sure your user is in the 'kvm' group. Just run
+ $ gpasswd -a <USER> kvm
+then have <USER> re-login.
+
+For brand new installs, the default permissions on /dev/kvm might not let
+you access it. You can tell udev to reset ownership/perms:
+ $ udevadm trigger -c add /dev/kvm
+
+If you want to register binfmt handlers for qemu user targets:
+For openrc:
+ # rc-update add qemu-binfmt
+For systemd:
+ # ln -s /usr/share/qemu/binfmt.d/qemu.conf /etc/binfmt.d/qemu.conf"
+
+pkg_pretend() {
+ if use kernel_linux && kernel_is lt 2 6 25; then
+ eerror "This version of KVM requires a host kernel of 2.6.25 or higher."
+ elif use kernel_linux; then
+ if ! linux_config_exists; then
+ eerror "Unable to check your kernel for KVM support"
+ else
+ CONFIG_CHECK="~KVM ~TUN ~BRIDGE"
+ ERROR_KVM="You must enable KVM in your kernel to continue"
+ ERROR_KVM_AMD="If you have an AMD CPU, you must enable KVM_AMD in"
+ ERROR_KVM_AMD+=" your kernel configuration."
+ ERROR_KVM_INTEL="If you have an Intel CPU, you must enable"
+ ERROR_KVM_INTEL+=" KVM_INTEL in your kernel configuration."
+ ERROR_TUN="You will need the Universal TUN/TAP driver compiled"
+ ERROR_TUN+=" into your kernel or loaded as a module to use the"
+ ERROR_TUN+=" virtual network device if using -net tap."
+ ERROR_BRIDGE="You will also need support for 802.1d"
+ ERROR_BRIDGE+=" Ethernet Bridging for some network configurations."
+ use vhost-net && CONFIG_CHECK+=" ~VHOST_NET"
+ ERROR_VHOST_NET="You must enable VHOST_NET to have vhost-net"
+ ERROR_VHOST_NET+=" support"
+
+ if use amd64 || use x86 || use amd64-linux || use x86-linux; then
+ if grep -q AuthenticAMD /proc/cpuinfo; then
+ CONFIG_CHECK+=" ~KVM_AMD"
+ elif grep -q GenuineIntel /proc/cpuinfo; then
+ CONFIG_CHECK+=" ~KVM_INTEL"
+ fi
+ fi
+
+ use python && CONFIG_CHECK+=" ~DEBUG_FS"
+ ERROR_DEBUG_FS="debugFS support required for kvm_stat"
+
+ # Now do the actual checks setup above
+ check_extra_config
+ fi
+ fi
+
+ if grep -qs '/usr/bin/qemu-kvm' "${EROOT}"/etc/libvirt/qemu/*.xml; then
+ eerror "The kvm/qemu-kvm wrappers no longer exist, but your libvirt"
+ eerror "instances are still pointing to it. Please update your"
+ eerror "configs in /etc/libvirt/qemu/ to use the -enable-kvm flag"
+ eerror "and the right system binary (e.g. qemu-system-x86_64)."
+ die "update your virt configs to not use qemu-kvm"
+ fi
+}
+
+# Sanity check to make sure target lists are kept up-to-date.
+check_targets() {
+ local var=$1 mak=$2
+ local detected sorted
+
+ pushd "${S}"/default-configs/targets/ >/dev/null || die
+
+ # Force C locale until glibc is updated. #564936
+ detected=$(echo $(printf '%s\n' *-${mak}.mak | sed "s:-${mak}.mak::" | LC_COLLATE=C sort -u))
+ sorted=$(echo $(printf '%s\n' ${!var} | LC_COLLATE=C sort -u))
+ if [[ ${sorted} != "${detected}" ]] ; then
+ eerror "The ebuild needs to be kept in sync."
+ eerror "${var}: ${sorted}"
+ eerror "$(printf '%-*s' ${#var} configure): ${detected}"
+ die "sync ${var} to the list of targets"
+ fi
+
+ popd >/dev/null
+}
+
+src_prepare() {
+ check_targets IUSE_SOFTMMU_TARGETS softmmu
+ check_targets IUSE_USER_TARGETS linux-user
+
+ default
+
+ # Use correct toolchain to fix cross-compiling
+ tc-export AR AS LD NM OBJCOPY PKG_CONFIG RANLIB STRINGS
+ export WINDRES=${CHOST}-windres
+
+ # Verbose builds
+ MAKEOPTS+=" V=1"
+
+ # Remove bundled copy of libfdt
+ rm -r dtc || die
+}
+
+##
+# configures qemu based on the build directory and the build type
+# we are using.
+#
+qemu_src_configure() {
+ debug-print-function ${FUNCNAME} "$@"
+
+ local buildtype=$1
+ local builddir="${S}/${buildtype}-build"
+
+ mkdir "${builddir}"
+
+ local conf_opts=(
+ --prefix=/usr
+ --sysconfdir=/etc
+ --bindir=/usr/bin
+ --libdir=/usr/$(get_libdir)
+ --datadir=/usr/share
+ --docdir=/usr/share/doc/${PF}/html
+ --mandir=/usr/share/man
+ --localstatedir=/var
+ --disable-bsd-user
+ --disable-containers # bug #732972
+ --disable-guest-agent
+ --disable-strip
+
+ # bug #746752: TCG interpreter has a few limitations:
+ # - it does not support FPU
+ # - it's generally slower on non-self-modifying code
+ # It's advantage is support for host architectures
+ # where native codegeneration is not implemented.
+ # Gentoo has qemu keyworded only on targets with
+ # native code generation available. Avoid the interpreter.
+ --disable-tcg-interpreter
+
+ --disable-werror
+ # We support gnutls/nettle for crypto operations. It is possible
+ # to use gcrypt when gnutls/nettle are disabled (but not when they
+ # are enabled), but it's not really worth the hassle. Disable it
+ # all the time to avoid automatically detecting it. #568856
+ --disable-gcrypt
+ --python="${PYTHON}"
+ --cc="$(tc-getCC)"
+ --cxx="$(tc-getCXX)"
+ --host-cc="$(tc-getBUILD_CC)"
+ $(use_enable debug debug-info)
+ $(use_enable debug debug-tcg)
+ $(use_enable doc docs)
+ $(use_enable nls gettext)
+ $(use_enable plugins)
+ $(use_enable xattr attr)
+ )
+
+ # Disable options not used by user targets. This simplifies building
+ # static user targets (USE=static-user) considerably.
+ conf_notuser() {
+ if [[ ${buildtype} == "user" ]] ; then
+ echo "--disable-${2:-$1}"
+ else
+ use_enable "$@"
+ fi
+ }
+ # Enable option only for softmmu build, but not 'user' or 'tools'
+ conf_softmmu() {
+ if [[ ${buildtype} == "softmmu" ]] ; then
+ use_enable "$@"
+ else
+ echo "--disable-${2:-$1}"
+ fi
+ }
+ # Enable option only for tools build, but not 'user' or 'softmmu'
+ conf_tools() {
+ if [[ ${buildtype} == "tools" ]] ; then
+ use_enable "$@"
+ else
+ echo "--disable-${2:-$1}"
+ fi
+ }
+ conf_opts+=(
+ $(conf_notuser accessibility brlapi)
+ $(conf_notuser aio linux-aio)
+ $(conf_notuser bzip2)
+ $(conf_notuser capstone)
+ $(conf_notuser caps cap-ng)
+ $(conf_notuser curl)
+ $(conf_notuser fdt)
+ $(conf_notuser glusterfs)
+ $(conf_notuser gnutls)
+ $(conf_notuser gnutls nettle)
+ $(conf_notuser gtk)
+ $(conf_notuser infiniband rdma)
+ $(conf_notuser iscsi libiscsi)
+ $(conf_notuser io-uring linux-io-uring)
+ $(conf_notuser jemalloc jemalloc)
+ $(conf_notuser jpeg vnc-jpeg)
+ $(conf_notuser kernel_linux kvm)
+ $(conf_notuser lzo)
+ $(conf_notuser multipath mpath)
+ $(conf_notuser ncurses curses)
+ $(conf_notuser nfs libnfs)
+ $(conf_notuser numa)
+ $(conf_notuser opengl)
+ $(conf_notuser png vnc-png)
+ $(conf_notuser rbd)
+ $(conf_notuser sasl vnc-sasl)
+ $(conf_notuser sdl)
+ $(conf_softmmu sdl-image)
+ $(conf_notuser seccomp)
+ $(conf_notuser slirp slirp system)
+ $(conf_notuser smartcard)
+ $(conf_notuser snappy)
+ $(conf_notuser spice)
+ $(conf_notuser ssh libssh)
+ $(conf_notuser udev libudev)
+ $(conf_notuser usb libusb)
+ $(conf_notuser usbredir usb-redir)
+ $(conf_notuser vde)
+ $(conf_notuser vhost-net)
+ $(conf_notuser vhost-user-fs)
+ $(conf_tools vhost-user-fs virtiofsd)
+ $(conf_notuser virgl virglrenderer)
+ $(conf_notuser virtfs)
+ $(conf_notuser vnc)
+ $(conf_notuser vte)
+ $(conf_notuser xen)
+ $(conf_notuser xen xen-pci-passthrough)
+ $(conf_notuser xfs xfsctl)
+ # use prebuilt keymaps, bug #759604
+ --disable-xkbcommon
+ $(conf_notuser zstd)
+ )
+
+ if [[ ${buildtype} == "user" ]] ; then
+ conf_opts+=( --disable-libxml2 )
+ else
+ conf_opts+=( --enable-libxml2 )
+ fi
+
+ if [[ ! ${buildtype} == "user" ]] ; then
+ # audio options
+ local audio_opts=(
+ # Note: backend order matters here: #716202
+ # We iterate from higher-level to lower level.
+ $(usex pulseaudio pa "")
+ $(usev jack)
+ $(usev sdl)
+ $(usev alsa)
+ $(usev oss)
+ )
+ conf_opts+=(
+ --audio-drv-list=$(printf "%s," "${audio_opts[@]}")
+ )
+ fi
+
+ case ${buildtype} in
+ user)
+ conf_opts+=(
+ --enable-linux-user
+ --disable-system
+ --disable-blobs
+ --disable-tools
+ )
+ local static_flag="static-user"
+ ;;
+ softmmu)
+ conf_opts+=(
+ --disable-linux-user
+ --enable-system
+ --disable-tools
+ )
+ local static_flag="static"
+ ;;
+ tools)
+ conf_opts+=(
+ --disable-linux-user
+ --disable-system
+ --disable-blobs
+ --enable-tools
+ )
+ local static_flag="static"
+ ;;
+ esac
+
+ local targets="${buildtype}_targets"
+ [[ -n ${targets} ]] && conf_opts+=( --target-list="${!targets}" )
+
+ # Add support for SystemTAP
+ use systemtap && conf_opts+=( --enable-trace-backend=dtrace )
+
+ # We always want to attempt to build with PIE support as it results
+ # in a more secure binary. But it doesn't work with static or if
+ # the current GCC doesn't have PIE support.
+ if use ${static_flag}; then
+ conf_opts+=( --static --disable-pie )
+ else
+ tc-enables-pie && conf_opts+=( --enable-pie )
+ fi
+
+ # Plumb through equivalent of EXTRA_ECONF to allow experiments
+ # like bug #747928.
+ conf_opts+=( ${EXTRA_CONF_QEMU} )
+
+ echo "../configure ${conf_opts[*]}"
+ cd "${builddir}"
+ ../configure "${conf_opts[@]}" || die "configure failed"
+
+ # FreeBSD's kernel does not support QEMU assigning/grabbing
+ # host USB devices yet
+ use kernel_FreeBSD && \
+ sed -i -E -e "s|^(HOST_USB=)bsd|\1stub|" "${S}"/config-host.mak
+}
+
+src_configure() {
+ local target
+
+ python_setup
+
+ softmmu_targets= softmmu_bins=()
+ user_targets= user_bins=()
+
+ for target in ${IUSE_SOFTMMU_TARGETS} ; do
+ if use "qemu_softmmu_targets_${target}"; then
+ softmmu_targets+=",${target}-softmmu"
+ softmmu_bins+=( "qemu-system-${target}" )
+ fi
+ done
+
+ for target in ${IUSE_USER_TARGETS} ; do
+ if use "qemu_user_targets_${target}"; then
+ user_targets+=",${target}-linux-user"
+ user_bins+=( "qemu-${target}" )
+ fi
+ done
+
+ softmmu_targets=${softmmu_targets#,}
+ user_targets=${user_targets#,}
+
+ [[ -n ${softmmu_targets} ]] && qemu_src_configure "softmmu"
+ [[ -n ${user_targets} ]] && qemu_src_configure "user"
+ qemu_src_configure "tools"
+}
+
+src_compile() {
+ if [[ -n ${user_targets} ]]; then
+ cd "${S}/user-build"
+ default
+ fi
+
+ if [[ -n ${softmmu_targets} ]]; then
+ cd "${S}/softmmu-build"
+ default
+ fi
+
+ cd "${S}/tools-build"
+ default
+}
+
+src_test() {
+ if [[ -n ${softmmu_targets} ]]; then
+ cd "${S}/softmmu-build"
+ pax-mark m */qemu-system-* #515550
+ emake check
+ fi
+}
+
+qemu_python_install() {
+ python_domodule "${S}/python/qemu"
+
+ python_doscript "${S}/scripts/kvm/vmxcap"
+ python_doscript "${S}/scripts/qmp/qmp-shell"
+ python_doscript "${S}/scripts/qmp/qemu-ga-client"
+}
+
+# Generate binfmt support files.
+# - /etc/init.d/qemu-binfmt script which registers the user handlers (openrc)
+# - /usr/share/qemu/binfmt.d/qemu.conf (for use with systemd-binfmt)
+generate_initd() {
+ local out="${T}/qemu-binfmt"
+ local out_systemd="${T}/qemu.conf"
+ local d="${T}/binfmt.d"
+
+ einfo "Generating qemu binfmt scripts and configuration files"
+
+ # Generate the debian fragments first.
+ mkdir -p "${d}"
+ "${S}"/scripts/qemu-binfmt-conf.sh \
+ --debian \
+ --exportdir "${d}" \
+ --qemu-path "${EPREFIX}/usr/bin" \
+ || die
+ # Then turn the fragments into a shell script we can source.
+ sed -E -i \
+ -e 's:^([^ ]+) (.*)$:\1="\2":' \
+ "${d}"/* || die
+
+ # Generate the init.d script by assembling the fragments from above.
+ local f qcpu package interpreter magic mask
+ cat "${FILESDIR}"/qemu-binfmt.initd.head >"${out}" || die
+ for f in "${d}"/qemu-* ; do
+ source "${f}"
+
+ # Normalize the cpu logic like we do in the init.d for the native cpu.
+ qcpu=${package#qemu-}
+ case ${qcpu} in
+ arm*) qcpu="arm";;
+ mips*) qcpu="mips";;
+ ppc*) qcpu="ppc";;
+ s390*) qcpu="s390";;
+ sh*) qcpu="sh";;
+ sparc*) qcpu="sparc";;
+ esac
+
+ # we use 'printf' here to be portable across 'sh'
+ # implementations: #679168
+ cat <<EOF >>"${out}"
+ if [ "\${cpu}" != "${qcpu}" -a -x "${interpreter}" ] ; then
+ printf '%s\n' ':${package}:M::${magic}:${mask}:${interpreter}:'"\${QEMU_BINFMT_FLAGS}" >/proc/sys/fs/binfmt_misc/register
+ fi
+EOF
+
+ echo ":${package}:M::${magic}:${mask}:${interpreter}:OC" >>"${out_systemd}"
+
+ done
+ cat "${FILESDIR}"/qemu-binfmt.initd.tail >>"${out}" || die
+}
+
+src_install() {
+ if [[ -n ${user_targets} ]]; then
+ cd "${S}/user-build"
+ emake DESTDIR="${ED}" install
+
+ # Install binfmt handler init script for user targets.
+ generate_initd
+ doinitd "${T}/qemu-binfmt"
+
+ # Install binfmt/qemu.conf.
+ insinto "/usr/share/qemu/binfmt.d"
+ doins "${T}/qemu.conf"
+ fi
+
+ if [[ -n ${softmmu_targets} ]]; then
+ cd "${S}/softmmu-build"
+ emake DESTDIR="${ED}" install
+
+ # This might not exist if the test failed. #512010
+ [[ -e check-report.html ]] && dodoc check-report.html
+
+ if use kernel_linux; then
+ udev_newrules "${FILESDIR}"/65-kvm.rules-r1 65-kvm.rules
+ fi
+
+ if use python; then
+ python_foreach_impl qemu_python_install
+ fi
+ fi
+
+ cd "${S}/tools-build"
+ emake DESTDIR="${ED}" install
+
+ # Disable mprotect on the qemu binaries as they use JITs to be fast #459348
+ pushd "${ED}"/usr/bin >/dev/null
+ pax-mark mr "${softmmu_bins[@]}" "${user_bins[@]}" # bug 575594
+ popd >/dev/null
+
+ # Install config file example for qemu-bridge-helper
+ insinto "/etc/qemu"
+ doins "${FILESDIR}/bridge.conf"
+
+ cd "${S}"
+ dodoc MAINTAINERS docs/specs/pci-ids.txt
+ newdoc pc-bios/README README.pc-bios
+
+ # Disallow stripping of prebuilt firmware files.
+ dostrip -x ${QA_PREBUILT}
+
+ if [[ -n ${softmmu_targets} ]]; then
+ # Remove SeaBIOS since we're using the SeaBIOS packaged one
+ rm "${ED}/usr/share/qemu/bios.bin"
+ rm "${ED}/usr/share/qemu/bios-256k.bin"
+ if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
+ dosym ../seabios/bios.bin /usr/share/qemu/bios.bin
+ dosym ../seabios/bios-256k.bin /usr/share/qemu/bios-256k.bin
+ fi
+
+ # Remove vgabios since we're using the seavgabios packaged one
+ rm "${ED}/usr/share/qemu/vgabios.bin"
+ rm "${ED}/usr/share/qemu/vgabios-cirrus.bin"
+ rm "${ED}/usr/share/qemu/vgabios-qxl.bin"
+ rm "${ED}/usr/share/qemu/vgabios-stdvga.bin"
+ rm "${ED}/usr/share/qemu/vgabios-virtio.bin"
+ rm "${ED}/usr/share/qemu/vgabios-vmware.bin"
+ # PPC64 loads vgabios-stdvga
+ if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386 || use qemu_softmmu_targets_ppc64; then
+ dosym ../seavgabios/vgabios-isavga.bin /usr/share/qemu/vgabios.bin
+ dosym ../seavgabios/vgabios-cirrus.bin /usr/share/qemu/vgabios-cirrus.bin
+ dosym ../seavgabios/vgabios-qxl.bin /usr/share/qemu/vgabios-qxl.bin
+ dosym ../seavgabios/vgabios-stdvga.bin /usr/share/qemu/vgabios-stdvga.bin
+ dosym ../seavgabios/vgabios-virtio.bin /usr/share/qemu/vgabios-virtio.bin
+ dosym ../seavgabios/vgabios-vmware.bin /usr/share/qemu/vgabios-vmware.bin
+ fi
+
+ # Remove sgabios since we're using the sgabios packaged one
+ rm "${ED}/usr/share/qemu/sgabios.bin"
+ if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
+ dosym ../sgabios/sgabios.bin /usr/share/qemu/sgabios.bin
+ fi
+
+ # Remove iPXE since we're using the iPXE packaged one
+ rm "${ED}"/usr/share/qemu/pxe-*.rom
+ if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
+ dosym ../ipxe/8086100e.rom /usr/share/qemu/pxe-e1000.rom
+ dosym ../ipxe/80861209.rom /usr/share/qemu/pxe-eepro100.rom
+ dosym ../ipxe/10500940.rom /usr/share/qemu/pxe-ne2k_pci.rom
+ dosym ../ipxe/10222000.rom /usr/share/qemu/pxe-pcnet.rom
+ dosym ../ipxe/10ec8139.rom /usr/share/qemu/pxe-rtl8139.rom
+ dosym ../ipxe/1af41000.rom /usr/share/qemu/pxe-virtio.rom
+ fi
+ fi
+
+ DISABLE_AUTOFORMATTING=true
+ readme.gentoo_create_doc
+}
+
+firmware_abi_change() {
+ local pv
+ for pv in ${REPLACING_VERSIONS}; do
+ if ver_test $pv -lt ${FIRMWARE_ABI_VERSION}; then
+ return 0
+ fi
+ done
+ return 1
+}
+
+pkg_postinst() {
+ if [[ -n ${softmmu_targets} ]] && use kernel_linux; then
+ udev_reload
+ fi
+
+ xdg_icon_cache_update
+
+ [[ -z ${EPREFIX} ]] && [[ -f ${EROOT}/usr/libexec/qemu-bridge-helper ]] && \
+ fcaps cap_net_admin ${EROOT}/usr/libexec/qemu-bridge-helper
+
+ DISABLE_AUTOFORMATTING=true
+ readme.gentoo_print_elog
+
+ if use pin-upstream-blobs && firmware_abi_change; then
+ ewarn "This version of qemu pins new versions of firmware blobs:"
+ ewarn " $(best_version sys-firmware/edk2-ovmf)"
+ ewarn " $(best_version sys-firmware/ipxe)"
+ ewarn " $(best_version sys-firmware/seabios)"
+ ewarn " $(best_version sys-firmware/sgabios)"
+ ewarn "This might break resume of hibernated guests (started with a different"
+ ewarn "firmware version) and live migration to/from qemu versions with different"
+ ewarn "firmware. Please (cold) restart all running guests. For functional"
+ ewarn "guest migration ensure that all"
+ ewarn "hosts run at least"
+ ewarn " app-emulation/qemu-${FIRMWARE_ABI_VERSION}."
+ fi
+}
+
+pkg_info() {
+ echo "Using:"
+ echo " $(best_version app-emulation/spice-protocol)"
+ echo " $(best_version sys-firmware/edk2-ovmf)"
+ if has_version 'sys-firmware/edk2-ovmf[binary]'; then
+ echo " USE=binary"
+ else
+ echo " USE=''"
+ fi
+ echo " $(best_version sys-firmware/ipxe)"
+ echo " $(best_version sys-firmware/seabios)"
+ if has_version 'sys-firmware/seabios[binary]'; then
+ echo " USE=binary"
+ else
+ echo " USE=''"
+ fi
+ echo " $(best_version sys-firmware/sgabios)"
+}
+
+pkg_postrm() {
+ xdg_icon_cache_update
+}
diff --git a/chromeos-base/crash-reporter/crash-reporter-0.0.1-r3651.ebuild b/chromeos-base/crash-reporter/crash-reporter-0.0.1-r3651.ebuild
index b6ca831..10414aa 100644
--- a/chromeos-base/crash-reporter/crash-reporter-0.0.1-r3651.ebuild
+++ b/chromeos-base/crash-reporter/crash-reporter-0.0.1-r3651.ebuild
@@ -51,6 +51,10 @@
)
"
+PATCHES="
+ ${FILESDIR}/0001-crash-reporter-Fix-anomaly_detector-build.patch
+"
+
src_configure() {
platform_src_configure
use arcpp && use_i686 && platform_src_configure_i686
diff --git a/chromeos-base/crash-reporter/crash-reporter-9999.ebuild b/chromeos-base/crash-reporter/crash-reporter-9999.ebuild
index df19079..14510a8 100644
--- a/chromeos-base/crash-reporter/crash-reporter-9999.ebuild
+++ b/chromeos-base/crash-reporter/crash-reporter-9999.ebuild
@@ -49,6 +49,10 @@
)
"
+PATCHES="
+ ${FILESDIR}/0001-crash-reporter-Fix-anomaly_detector-build.patch
+"
+
src_configure() {
platform_src_configure
use arcpp && use_i686 && platform_src_configure_i686
diff --git a/chromeos-base/crash-reporter/files/0001-crash-reporter-Fix-anomaly_detector-build.patch b/chromeos-base/crash-reporter/files/0001-crash-reporter-Fix-anomaly_detector-build.patch
new file mode 100644
index 0000000..8ec2d81
--- /dev/null
+++ b/chromeos-base/crash-reporter/files/0001-crash-reporter-Fix-anomaly_detector-build.patch
@@ -0,0 +1,33 @@
+From 3ec633564cca33cca76177d31b8d7cf6915cfdd4 Mon Sep 17 00:00:00 2001
+From: Robert Kolchmeyer <rkolchmeyer@google.com>
+Date: Wed, 20 Jan 2021 17:27:26 -0800
+Subject: [PATCH] crash-reporter: Fix anomaly_detector build
+
+libcrash depends on symbol VmSupport::Get, which is defined in
+libcrash_reporter. Let's add that dependency to BUILD.gn.
+
+BUG=b/177232752
+TEST=emerge-lakitu crash-reporter
+
+Change-Id: Ic9d30bf29511e92c2b1c4272dce9724dba17a520
+---
+ crash-reporter/BUILD.gn | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/BUILD.gn b/BUILD.gn
+index 0e6f0c2b21a..1c385b75556 100644
+--- a/BUILD.gn
++++ b/BUILD.gn
+@@ -49,6 +49,9 @@ static_library("libcrash") {
+ "paths.cc",
+ "util.cc",
+ ]
++ deps = [
++ ":libcrash_reporter",
++ ]
+ all_dependent_configs = [ ":libcrash_config" ]
+ defines = [ "USE_DIRENCRYPTION=${use.direncryption}" ]
+
+--
+2.30.0.296.g2bfb1c46d8-goog
+
diff --git a/chromeos-base/libbrillo/files/remove-glib-usage.patch b/chromeos-base/libbrillo/files/remove-glib-usage.patch
new file mode 100644
index 0000000..89ff35c
--- /dev/null
+++ b/chromeos-base/libbrillo/files/remove-glib-usage.patch
@@ -0,0 +1,1619 @@
+From e6cf7fb1960f544357925fed03e6c738e678f89b Mon Sep 17 00:00:00 2001
+From: Vaibhav Rustagi <vaibhavrustagi@google.com>
+Date: Tue, 21 Sep 2021 09:57:31 -0700
+Subject: [PATCH] libbrillo: remove glib usage
+
+We're ugprading glib to latest 2.68 which causes an API
+breakage and considering it is not used anymore in favor
+of libchrome, we drop glib support instead of fixing it.
+
+ChromeOS Reference: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/3103795/
+
+Change-Id: I357b04beb1a4042e3d369189c56e4ddcb536ec08
+---
+ BUILD.gn | 42 --
+ brillo/glib/README.md | 5 -
+ brillo/glib/abstract_dbus_service.cc | 33 --
+ brillo/glib/abstract_dbus_service.h | 50 --
+ brillo/glib/dbus.cc | 331 ------------
+ brillo/glib/dbus.h | 450 -----------------
+ brillo/glib/object.h | 469 ------------------
+ brillo/glib/object_test.cc | 132 -----
+ 8 files changed, 1512 deletions(-)
+ delete mode 100644 brillo/glib/README.md
+ delete mode 100644 brillo/glib/abstract_dbus_service.cc
+ delete mode 100644 brillo/glib/abstract_dbus_service.h
+ delete mode 100644 brillo/glib/dbus.cc
+ delete mode 100644 brillo/glib/dbus.h
+ delete mode 100644 brillo/glib/object.h
+ delete mode 100644 brillo/glib/object_test.cc
+
+diff --git a/BUILD.gn b/BUILD.gn
+index 7b2073b451..b263e02074 100644
+--- a/BUILD.gn
++++ b/BUILD.gn
+@@ -9,7 +9,6 @@ import("//common-mk/proto_library.gni")
+ group("all") {
+ deps = [
+ ":libbrillo",
+- ":libbrillo-glib",
+ ":libbrillo-test",
+ ":libinstallattributes",
+ ":libpolicy",
+@@ -392,45 +391,6 @@ shared_library("libpolicy") {
+ ]
+ }
+
+-libbrillo_glib_pkg_deps = [
+- "glib-2.0",
+- "gobject-2.0",
+-]
+-if (use.dbus) {
+- libbrillo_glib_pkg_deps += [
+- "dbus-1",
+- "dbus-glib-1",
+- ]
+-}
+-
+-generate_pkg_config("libbrillo-glib_pc") {
+- name = "libbrillo-glib"
+- output_name = "libbrillo-glib"
+- description = "brillo glib wrapper library"
+- version = libbase_ver
+- requires_private = libbrillo_glib_pkg_deps
+- libs = [ "-lbrillo-glib" ]
+-}
+-
+-shared_library("libbrillo-glib") {
+- configs += [ ":target_defaults" ]
+- cflags = [
+- # glib uses the deprecated "register" attribute in some header files.
+- "-Wno-deprecated-register",
+- ]
+- deps = [
+- ":libbrillo",
+- ":libbrillo-glib_pc",
+- ]
+- all_dependent_pkg_deps = libbrillo_glib_pkg_deps
+- if (use.dbus) {
+- sources = [
+- "brillo/glib/abstract_dbus_service.cc",
+- "brillo/glib/dbus.cc",
+- ]
+- }
+-}
+-
+ if (use.test) {
+ static_library("libbrillo_static") {
+ configs += [ ":target_defaults" ]
+@@ -469,7 +429,6 @@ if (use.test) {
+ "brillo/files/file_util_test.cc",
+ "brillo/files/safe_fd_test.cc",
+ "brillo/flag_helper_test.cc",
+- "brillo/glib/object_test.cc",
+ "brillo/http/http_connection_curl_test.cc",
+ "brillo/http/http_form_data_test.cc",
+ "brillo/http/http_request_test.cc",
+@@ -537,7 +496,6 @@ if (use.test) {
+ cflags = [ "-Wno-format-zero-length" ]
+ pkg_deps = [ "libchrome-test" ]
+ deps = [
+- ":libbrillo-glib",
+ ":libbrillo-test",
+ ":libbrillo_static",
+ ":libbrillo_tests_proto",
+diff --git a/brillo/glib/README.md b/brillo/glib/README.md
+deleted file mode 100644
+index ef9ec9ee85..0000000000
+--- a/brillo/glib/README.md
++++ /dev/null
+@@ -1,5 +0,0 @@
+-# libbrillo GLib support
+-
+-GLib is deprecated in Chrome OS. Use [libchrome] instead.
+-
+-[libchrome]: ../../../libchrome
+diff --git a/brillo/glib/abstract_dbus_service.cc b/brillo/glib/abstract_dbus_service.cc
+deleted file mode 100644
+index 4f3869715e..0000000000
+--- a/brillo/glib/abstract_dbus_service.cc
++++ /dev/null
+@@ -1,33 +0,0 @@
+-// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+-// Use of this source code is governed by a BSD-style license that can be
+-// found in the LICENSE file.
+-
+-#include <base/logging.h>
+-
+-#include "brillo/glib/abstract_dbus_service.h"
+-
+-namespace brillo {
+-namespace dbus {
+-
+-bool AbstractDbusService::Register(const brillo::dbus::BusConnection& conn) {
+- return RegisterExclusiveService(conn, service_interface(), service_name(),
+- service_path(), service_object());
+-}
+-
+-bool AbstractDbusService::Run() {
+- if (!main_loop()) {
+- LOG(ERROR) << "No run loop. Call Initialize before use.";
+- return false;
+- }
+- ::g_main_loop_run(main_loop());
+- DLOG(INFO) << "Run() completed";
+- return true;
+-}
+-
+-bool AbstractDbusService::Shutdown() {
+- ::g_main_loop_quit(main_loop());
+- return true;
+-}
+-
+-} // namespace dbus
+-} // namespace brillo
+diff --git a/brillo/glib/abstract_dbus_service.h b/brillo/glib/abstract_dbus_service.h
+deleted file mode 100644
+index 32725c71bf..0000000000
+--- a/brillo/glib/abstract_dbus_service.h
++++ /dev/null
+@@ -1,50 +0,0 @@
+-// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+-// Use of this source code is governed by a BSD-style license that can be
+-// found in the LICENSE file.
+-
+-#ifndef LIBBRILLO_BRILLO_GLIB_ABSTRACT_DBUS_SERVICE_H_
+-#define LIBBRILLO_BRILLO_GLIB_ABSTRACT_DBUS_SERVICE_H_
+-
+-// IMPORTANT: Do not use this in new code. Instead, use
+-// <brillo/daemons/dbus_daemon.h>. See https://goo.gl/EH3MmR for more details.
+-
+-#include <brillo/brillo_export.h>
+-#include <brillo/glib/dbus.h>
+-
+-namespace brillo {
+-
+-namespace dbus {
+-class BRILLO_EXPORT AbstractDbusService {
+- public:
+- virtual ~AbstractDbusService() {}
+-
+- // Setup the wrapped GObject and the GMainLoop
+- virtual bool Initialize() = 0;
+- virtual bool Reset() = 0;
+-
+- // Registers the GObject as a service with the system DBus
+- // TODO(wad) make this testable by making BusConn and Proxy
+- // subclassing friendly.
+- virtual bool Register(const brillo::dbus::BusConnection& conn);
+-
+- // Starts the run loop
+- virtual bool Run();
+-
+- // Stops the run loop
+- virtual bool Shutdown();
+-
+- // Used internally during registration to set the
+- // proper service information.
+- virtual const char* service_name() const = 0;
+- virtual const char* service_path() const = 0;
+- virtual const char* service_interface() const = 0;
+- virtual GObject* service_object() const = 0;
+-
+- protected:
+- virtual GMainLoop* main_loop() = 0;
+-};
+-
+-} // namespace dbus
+-} // namespace brillo
+-
+-#endif // LIBBRILLO_BRILLO_GLIB_ABSTRACT_DBUS_SERVICE_H_
+diff --git a/brillo/glib/dbus.cc b/brillo/glib/dbus.cc
+deleted file mode 100644
+index 7525adfdfa..0000000000
+--- a/brillo/glib/dbus.cc
++++ /dev/null
+@@ -1,331 +0,0 @@
+-// Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
+-// Use of this source code is governed by a BSD-style license that can be
+-// found in the LICENSE file.
+-
+-#include "brillo/glib/dbus.h"
+-
+-#include <base/check.h>
+-#include <dbus/dbus.h>
+-#include <dbus/dbus-glib-bindings.h>
+-#include <dbus/dbus-glib-lowlevel.h>
+-
+-#include <base/logging.h>
+-#include <base/strings/stringprintf.h>
+-
+-namespace brillo {
+-namespace dbus {
+-
+-bool CallPtrArray(const Proxy& proxy,
+- const char* method,
+- glib::ScopedPtrArray<const char*>* result) {
+- glib::ScopedError error;
+-
+- ::GType g_type_array =
+- ::dbus_g_type_get_collection("GPtrArray", DBUS_TYPE_G_OBJECT_PATH);
+-
+- if (!::dbus_g_proxy_call(proxy.gproxy(), method, &Resetter(&error).lvalue(),
+- G_TYPE_INVALID, g_type_array,
+- &Resetter(result).lvalue(), G_TYPE_INVALID)) {
+- LOG(WARNING) << "CallPtrArray failed: "
+- << (error->message ? error->message : "Unknown Error.");
+- return false;
+- }
+-
+- return true;
+-}
+-
+-BusConnection GetSystemBusConnection() {
+- glib::ScopedError error;
+- ::DBusGConnection* result =
+- ::dbus_g_bus_get(DBUS_BUS_SYSTEM, &Resetter(&error).lvalue());
+- if (!result) {
+- LOG(ERROR) << "dbus_g_bus_get(DBUS_BUS_SYSTEM) failed: "
+- << ((error.get() && error->message) ? error->message
+- : "Unknown Error");
+- return BusConnection(nullptr);
+- }
+- // Set to not exit when system bus is disconnected.
+- // This fixes the problem where when the dbus daemon is stopped, exit is
+- // called which kills Chrome.
+- ::dbus_connection_set_exit_on_disconnect(
+- ::dbus_g_connection_get_connection(result), FALSE);
+- return BusConnection(result);
+-}
+-
+-BusConnection GetPrivateBusConnection(const char* address) {
+- // Since dbus-glib does not have an API like dbus_g_connection_open_private(),
+- // we have to implement our own.
+-
+- // We have to call _dbus_g_value_types_init() to register standard marshalers
+- // just like as dbus_g_bus_get() and dbus_g_connection_open() do, but the
+- // function is not exported. So we call GetPrivateBusConnection() which calls
+- // dbus_g_bus_get() here instead. Note that if we don't call
+- // _dbus_g_value_types_init(), we might get "WARNING **: No demarshaller
+- // registered for type xxxxx" error and might not be able to handle incoming
+- // signals nor method calls.
+- {
+- BusConnection system_bus_connection = GetSystemBusConnection();
+- if (!system_bus_connection.HasConnection()) {
+- return system_bus_connection; // returns NULL connection.
+- }
+- }
+-
+- ::DBusError error;
+- ::dbus_error_init(&error);
+-
+- ::DBusGConnection* result = nullptr;
+- ::DBusConnection* raw_connection =
+- ::dbus_connection_open_private(address, &error);
+- if (!raw_connection) {
+- LOG(WARNING) << "dbus_connection_open_private failed: " << address;
+- return BusConnection(nullptr);
+- }
+-
+- if (!::dbus_bus_register(raw_connection, &error)) {
+- LOG(ERROR) << "dbus_bus_register failed: "
+- << (error.message ? error.message : "Unknown Error.");
+- ::dbus_error_free(&error);
+- // TODO(yusukes): We don't call dbus_connection_close() nor g_object_unref()
+- // here for now since these calls might interfere with IBusBus connections
+- // in libcros and Chrome. See the comment in ~InputMethodStatusConnection()
+- // function in platform/cros/chromeos_input_method.cc for details.
+- return BusConnection(nullptr);
+- }
+-
+- ::dbus_connection_setup_with_g_main(raw_connection,
+- nullptr /* default context */);
+-
+- // A reference count of |raw_connection| is transferred to |result|. You don't
+- // have to (and should not) unref the |raw_connection|.
+- result = ::dbus_connection_get_g_connection(raw_connection);
+- CHECK(result);
+-
+- ::dbus_connection_set_exit_on_disconnect(
+- ::dbus_g_connection_get_connection(result), FALSE);
+-
+- return BusConnection(result);
+-}
+-
+-bool RetrieveProperties(const Proxy& proxy,
+- const char* interface,
+- glib::ScopedHashTable* result) {
+- glib::ScopedError error;
+-
+- if (!::dbus_g_proxy_call(
+- proxy.gproxy(), "GetAll", &Resetter(&error).lvalue(), G_TYPE_STRING,
+- interface, G_TYPE_INVALID,
+- ::dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
+- &Resetter(result).lvalue(), G_TYPE_INVALID)) {
+- LOG(WARNING) << "RetrieveProperties failed: "
+- << (error->message ? error->message : "Unknown Error.");
+- return false;
+- }
+- return true;
+-}
+-
+-Proxy::Proxy() : object_(nullptr) {}
+-
+-// Set |connect_to_name_owner| true if you'd like to use
+-// dbus_g_proxy_new_for_name_owner() rather than dbus_g_proxy_new_for_name().
+-Proxy::Proxy(const BusConnection& connection,
+- const char* name,
+- const char* path,
+- const char* interface,
+- bool connect_to_name_owner)
+- : object_(GetGProxy(
+- connection, name, path, interface, connect_to_name_owner)) {}
+-
+-// Equivalent to Proxy(connection, name, path, interface, false).
+-Proxy::Proxy(const BusConnection& connection,
+- const char* name,
+- const char* path,
+- const char* interface)
+- : object_(GetGProxy(connection, name, path, interface, false)) {}
+-
+-// Creates a peer proxy using dbus_g_proxy_new_for_peer.
+-Proxy::Proxy(const BusConnection& connection,
+- const char* path,
+- const char* interface)
+- : object_(GetGPeerProxy(connection, path, interface)) {}
+-
+-Proxy::Proxy(const Proxy& x) : object_(x.object_) {
+- if (object_)
+- ::g_object_ref(object_);
+-}
+-
+-Proxy::~Proxy() {
+- if (object_)
+- ::g_object_unref(object_);
+-}
+-
+-/* static */
+-Proxy::value_type Proxy::GetGProxy(const BusConnection& connection,
+- const char* name,
+- const char* path,
+- const char* interface,
+- bool connect_to_name_owner) {
+- value_type result = nullptr;
+- if (connect_to_name_owner) {
+- glib::ScopedError error;
+- result = ::dbus_g_proxy_new_for_name_owner(
+- connection.object_, name, path, interface, &Resetter(&error).lvalue());
+- if (!result) {
+- DLOG(ERROR) << "Failed to construct proxy: "
+- << (error->message ? error->message : "Unknown Error") << ": "
+- << path;
+- }
+- } else {
+- result =
+- ::dbus_g_proxy_new_for_name(connection.object_, name, path, interface);
+- if (!result) {
+- LOG(ERROR) << "Failed to construct proxy: " << path;
+- }
+- }
+- return result;
+-}
+-
+-/* static */
+-Proxy::value_type Proxy::GetGPeerProxy(const BusConnection& connection,
+- const char* path,
+- const char* interface) {
+- value_type result =
+- ::dbus_g_proxy_new_for_peer(connection.object_, path, interface);
+- if (!result)
+- LOG(ERROR) << "Failed to construct peer proxy: " << path;
+-
+- return result;
+-}
+-
+-bool RegisterExclusiveService(const BusConnection& connection,
+- const char* interface_name,
+- const char* service_name,
+- const char* service_path,
+- GObject* object) {
+- CHECK(object);
+- CHECK(interface_name);
+- CHECK(service_name);
+- // Create a proxy to DBus itself so that we can request to become a
+- // service name owner and then register an object at the related service path.
+- Proxy proxy = brillo::dbus::Proxy(connection, DBUS_SERVICE_DBUS,
+- DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
+- // Exclusivity is determined by replacing any existing
+- // service, not queuing, and ensuring we are the primary
+- // owner after the name is ours.
+- glib::ScopedError err;
+- guint result = 0;
+- // TODO(wad) determine if we are moving away from using generated functions
+- if (!org_freedesktop_DBus_request_name(proxy.gproxy(), service_name, 0,
+- &result, &Resetter(&err).lvalue())) {
+- LOG(ERROR) << "Unable to request service name: "
+- << (err->message ? err->message : "Unknown Error.");
+- return false;
+- }
+-
+- // Handle the error codes, releasing the name if exclusivity conditions
+- // are not met.
+- bool needs_release = false;
+- if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
+- LOG(ERROR) << "Failed to become the primary owner. Releasing . . .";
+- needs_release = true;
+- }
+- if (result == DBUS_REQUEST_NAME_REPLY_EXISTS) {
+- LOG(ERROR) << "Service name exists: " << service_name;
+- return false;
+- } else if (result == DBUS_REQUEST_NAME_REPLY_IN_QUEUE) {
+- LOG(ERROR) << "Service name request enqueued despite our flags. Releasing";
+- needs_release = true;
+- }
+- LOG_IF(WARNING, result == DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER)
+- << "Service name already owned by this process";
+- if (needs_release) {
+- if (!org_freedesktop_DBus_release_name(proxy.gproxy(), service_name,
+- &result, &Resetter(&err).lvalue())) {
+- LOG(ERROR) << "Unabled to release service name: "
+- << (err->message ? err->message : "Unknown Error.");
+- }
+- DLOG(INFO) << "ReleaseName returned code " << result;
+- return false;
+- }
+-
+- // Determine a path from the service name and register the object.
+- dbus_g_connection_register_g_object(connection.g_connection(), service_path,
+- object);
+- return true;
+-}
+-
+-void CallMethodWithNoArguments(const char* service_name,
+- const char* path,
+- const char* interface_name,
+- const char* method_name) {
+- Proxy proxy(dbus::GetSystemBusConnection(), service_name, path,
+- interface_name);
+- ::dbus_g_proxy_call_no_reply(proxy.gproxy(), method_name, G_TYPE_INVALID);
+-}
+-
+-void SignalWatcher::StartMonitoring(const std::string& interface,
+- const std::string& signal) {
+- DCHECK(interface_.empty()) << "StartMonitoring() must be called only once";
+- interface_ = interface;
+- signal_ = signal;
+-
+- // Snoop on D-Bus messages so we can get notified about signals.
+- DBusConnection* dbus_conn =
+- dbus_g_connection_get_connection(GetSystemBusConnection().g_connection());
+- DCHECK(dbus_conn);
+-
+- DBusError error;
+- dbus_error_init(&error);
+- dbus_bus_add_match(dbus_conn, GetDBusMatchString().c_str(), &error);
+- if (dbus_error_is_set(&error)) {
+- LOG(DFATAL) << "Got error while adding D-Bus match rule: " << error.name
+- << " (" << error.message << ")";
+- }
+-
+- if (!dbus_connection_add_filter(dbus_conn, &SignalWatcher::FilterDBusMessage,
+- this, // user_data
+- nullptr)) { // free_data_function
+- LOG(DFATAL) << "Unable to add D-Bus filter";
+- }
+-}
+-
+-SignalWatcher::~SignalWatcher() {
+- if (interface_.empty())
+- return;
+-
+- DBusConnection* dbus_conn = dbus_g_connection_get_connection(
+- dbus::GetSystemBusConnection().g_connection());
+- DCHECK(dbus_conn);
+-
+- dbus_connection_remove_filter(dbus_conn, &SignalWatcher::FilterDBusMessage,
+- this);
+-
+- DBusError error;
+- dbus_error_init(&error);
+- dbus_bus_remove_match(dbus_conn, GetDBusMatchString().c_str(), &error);
+- if (dbus_error_is_set(&error)) {
+- LOG(DFATAL) << "Got error while removing D-Bus match rule: " << error.name
+- << " (" << error.message << ")";
+- }
+-}
+-
+-std::string SignalWatcher::GetDBusMatchString() const {
+- return base::StringPrintf("type='signal', interface='%s', member='%s'",
+- interface_.c_str(), signal_.c_str());
+-}
+-
+-/* static */
+-DBusHandlerResult SignalWatcher::FilterDBusMessage(DBusConnection* dbus_conn,
+- DBusMessage* message,
+- void* data) {
+- SignalWatcher* self = static_cast<SignalWatcher*>(data);
+- if (dbus_message_is_signal(message, self->interface_.c_str(),
+- self->signal_.c_str())) {
+- self->OnSignal(message);
+- return DBUS_HANDLER_RESULT_HANDLED;
+- } else {
+- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+- }
+-}
+-
+-} // namespace dbus
+-} // namespace brillo
+diff --git a/brillo/glib/dbus.h b/brillo/glib/dbus.h
+deleted file mode 100644
+index 299d65159e..0000000000
+--- a/brillo/glib/dbus.h
++++ /dev/null
+@@ -1,450 +0,0 @@
+-// Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
+-// Use of this source code is governed by a BSD-style license that can be
+-// found in the LICENSE file.
+-
+-#ifndef LIBBRILLO_BRILLO_GLIB_DBUS_H_
+-#define LIBBRILLO_BRILLO_GLIB_DBUS_H_
+-
+-// IMPORTANT: Do not use this in new code. Instead, use libchrome's D-Bus
+-// bindings. See https://goo.gl/EH3MmR for more details.
+-
+-#include <base/check.h>
+-#include <dbus/dbus-glib.h>
+-#include <glib-object.h>
+-
+-#include <algorithm>
+-#include <string>
+-#include <utility>
+-
+-#include "base/logging.h"
+-#include <brillo/brillo_export.h>
+-#include <brillo/glib/object.h>
+-
+-struct DBusMessage;
+-struct DBusConnection;
+-
+-namespace brillo {
+-
+-namespace dbus {
+-
+-// \brief BusConnection manages the ref-count for a ::DBusGConnection*.
+-//
+-// A BusConnection has reference semantics bound to a particular communication
+-// bus.
+-//
+-// \models Copyable, Assignable
+-// \related GetSystemBusConnection()
+-
+-class BRILLO_EXPORT BusConnection {
+- public:
+- typedef ::DBusGConnection* value_type;
+-
+- BusConnection(const BusConnection& x) : object_(x.object_) {
+- if (object_)
+- ::dbus_g_connection_ref(object_);
+- }
+-
+- ~BusConnection() {
+- if (object_)
+- ::dbus_g_connection_unref(object_);
+- }
+-
+- BusConnection& operator=(BusConnection x) {
+- swap(*this, x);
+- return *this;
+- }
+-
+- const value_type& g_connection() const {
+- DCHECK(object_) << "referencing an empty connection";
+- return object_;
+- }
+-
+- operator bool() const { return object_; }
+-
+- bool HasConnection() const { return object_; }
+-
+- private:
+- friend void swap(BusConnection& x, BusConnection& y);
+-
+- friend class Proxy;
+- friend BusConnection GetSystemBusConnection();
+- friend BusConnection GetPrivateBusConnection(const char* address);
+-
+- // Constructor takes ownership
+- BRILLO_PRIVATE explicit BusConnection(::DBusGConnection* x) : object_(x) {}
+-
+- value_type object_;
+-};
+-
+-inline void swap(BusConnection& x, BusConnection& y) {
+- std::swap(x.object_, y.object_);
+-}
+-
+-// \brief Proxy manages the ref-count for a ::DBusGProxy*.
+-//
+-// Proxy has reference semantics and represents a connection to on object on
+-// the bus. A proxy object is constructed with a connection to a bus, a name
+-// to an entity on the bus, a path to an object owned by the entity, and an
+-// interface protocol name used to communicate with the object.
+-
+-class BRILLO_EXPORT Proxy {
+- public:
+- typedef ::DBusGProxy* value_type;
+-
+- Proxy();
+-
+- // Set |connect_to_name_owner| true if you'd like to use
+- // dbus_g_proxy_new_for_name_owner() rather than dbus_g_proxy_new_for_name().
+- Proxy(const BusConnection& connection,
+- const char* name,
+- const char* path,
+- const char* interface,
+- bool connect_to_name_owner);
+-
+- // Equivalent to Proxy(connection, name, path, interface, false).
+- Proxy(const BusConnection& connection,
+- const char* name,
+- const char* path,
+- const char* interface);
+-
+- // Creates a peer proxy using dbus_g_proxy_new_for_peer.
+- Proxy(const BusConnection& connection,
+- const char* path,
+- const char* interface);
+-
+- Proxy(const Proxy& x);
+-
+- ~Proxy();
+-
+- Proxy& operator=(Proxy x) {
+- swap(*this, x);
+- return *this;
+- }
+-
+- const char* path() const {
+- DCHECK(object_) << "referencing an empty proxy";
+- return ::dbus_g_proxy_get_path(object_);
+- }
+-
+- // gproxy() returns a reference to the underlying ::DBusGProxy*. As this
+- // library evolves, the gproxy() will be moved to be private.
+-
+- const value_type& gproxy() const {
+- DCHECK(object_) << "referencing an empty proxy";
+- return object_;
+- }
+-
+- operator bool() const { return object_; }
+-
+- private:
+- BRILLO_PRIVATE static value_type GetGProxy(const BusConnection& connection,
+- const char* name,
+- const char* path,
+- const char* interface,
+- bool connect_to_name_owner);
+-
+- BRILLO_PRIVATE static value_type GetGPeerProxy(
+- const BusConnection& connection, const char* path, const char* interface);
+-
+- BRILLO_PRIVATE operator int() const; // for safe bool cast
+- friend void swap(Proxy& x, Proxy& y);
+-
+- value_type object_;
+-};
+-
+-inline void swap(Proxy& x, Proxy& y) {
+- std::swap(x.object_, y.object_);
+-}
+-
+-// \brief RegisterExclusiveService configures a GObject to run as a service on
+-// a supplied ::BusConnection.
+-//
+-// RegisterExclusiveService encapsulates the process of configuring the
+-// supplied \param object at \param service_path on the \param connection.
+-// Exclusivity is ensured by replacing any existing services at that named
+-// location and confirming that the connection is the primary owner.
+-//
+-// Type information for the \param object must be installed with
+-// dbus_g_object_type_install_info prior to use.
+-
+-BRILLO_EXPORT bool RegisterExclusiveService(const BusConnection& connection,
+- const char* interface_name,
+- const char* service_name,
+- const char* service_path,
+- GObject* object);
+-
+-template <typename F> // F is a function signature
+-class MonitorConnection;
+-
+-template <typename A1>
+-class MonitorConnection<void(A1)> {
+- public:
+- MonitorConnection(const Proxy& proxy,
+- const char* name,
+- void (*monitor)(void*, A1),
+- void* object)
+- : proxy_(proxy), name_(name), monitor_(monitor), object_(object) {}
+-
+- static void Run(::DBusGProxy*, A1 x, MonitorConnection* self) {
+- self->monitor_(self->object_, x);
+- }
+- const Proxy& proxy() const { return proxy_; }
+- const std::string& name() const { return name_; }
+-
+- private:
+- Proxy proxy_;
+- std::string name_;
+- void (*monitor_)(void*, A1);
+- void* object_;
+-};
+-
+-template <typename A1, typename A2>
+-class MonitorConnection<void(A1, A2)> {
+- public:
+- MonitorConnection(const Proxy& proxy,
+- const char* name,
+- void (*monitor)(void*, A1, A2),
+- void* object)
+- : proxy_(proxy), name_(name), monitor_(monitor), object_(object) {}
+-
+- static void Run(::DBusGProxy*, A1 x, A2 y, MonitorConnection* self) {
+- self->monitor_(self->object_, x, y);
+- }
+- const Proxy& proxy() const { return proxy_; }
+- const std::string& name() const { return name_; }
+-
+- private:
+- Proxy proxy_;
+- std::string name_;
+- void (*monitor_)(void*, A1, A2);
+- void* object_;
+-};
+-
+-template <typename A1, typename A2, typename A3>
+-class MonitorConnection<void(A1, A2, A3)> {
+- public:
+- MonitorConnection(const Proxy& proxy,
+- const char* name,
+- void (*monitor)(void*, A1, A2, A3),
+- void* object)
+- : proxy_(proxy), name_(name), monitor_(monitor), object_(object) {}
+-
+- static void Run(::DBusGProxy*, A1 x, A2 y, A3 z, MonitorConnection* self) {
+- self->monitor_(self->object_, x, y, z);
+- }
+- const Proxy& proxy() const { return proxy_; }
+- const std::string& name() const { return name_; }
+-
+- private:
+- Proxy proxy_;
+- std::string name_;
+- void (*monitor_)(void*, A1, A2, A3);
+- void* object_;
+-};
+-
+-template <typename A1, typename A2, typename A3, typename A4>
+-class MonitorConnection<void(A1, A2, A3, A4)> {
+- public:
+- MonitorConnection(const Proxy& proxy,
+- const char* name,
+- void (*monitor)(void*, A1, A2, A3, A4),
+- void* object)
+- : proxy_(proxy), name_(name), monitor_(monitor), object_(object) {}
+-
+- static void Run(
+- ::DBusGProxy*, A1 x, A2 y, A3 z, A4 w, MonitorConnection* self) {
+- self->monitor_(self->object_, x, y, z, w);
+- }
+- const Proxy& proxy() const { return proxy_; }
+- const std::string& name() const { return name_; }
+-
+- private:
+- Proxy proxy_;
+- std::string name_;
+- void (*monitor_)(void*, A1, A2, A3, A4);
+- void* object_;
+-};
+-
+-template <typename A1>
+-MonitorConnection<void(A1)>* Monitor(const Proxy& proxy,
+- const char* name,
+- void (*monitor)(void*, A1),
+- void* object) {
+- typedef MonitorConnection<void(A1)> ConnectionType;
+-
+- ConnectionType* result = new ConnectionType(proxy, name, monitor, object);
+-
+- ::dbus_g_proxy_add_signal(proxy.gproxy(), name, glib::type_to_gtypeid<A1>(),
+- G_TYPE_INVALID);
+- ::dbus_g_proxy_connect_signal(
+- proxy.gproxy(), name, G_CALLBACK(&ConnectionType::Run), result, nullptr);
+- return result;
+-}
+-
+-template <typename A1, typename A2>
+-MonitorConnection<void(A1, A2)>* Monitor(const Proxy& proxy,
+- const char* name,
+- void (*monitor)(void*, A1, A2),
+- void* object) {
+- typedef MonitorConnection<void(A1, A2)> ConnectionType;
+-
+- ConnectionType* result = new ConnectionType(proxy, name, monitor, object);
+-
+- ::dbus_g_proxy_add_signal(proxy.gproxy(), name, glib::type_to_gtypeid<A1>(),
+- glib::type_to_gtypeid<A2>(), G_TYPE_INVALID);
+- ::dbus_g_proxy_connect_signal(
+- proxy.gproxy(), name, G_CALLBACK(&ConnectionType::Run), result, nullptr);
+- return result;
+-}
+-
+-template <typename A1, typename A2, typename A3>
+-MonitorConnection<void(A1, A2, A3)>* Monitor(const Proxy& proxy,
+- const char* name,
+- void (*monitor)(void*, A1, A2, A3),
+- void* object) {
+- typedef MonitorConnection<void(A1, A2, A3)> ConnectionType;
+-
+- ConnectionType* result = new ConnectionType(proxy, name, monitor, object);
+-
+- ::dbus_g_proxy_add_signal(proxy.gproxy(), name, glib::type_to_gtypeid<A1>(),
+- glib::type_to_gtypeid<A2>(),
+- glib::type_to_gtypeid<A3>(), G_TYPE_INVALID);
+- ::dbus_g_proxy_connect_signal(
+- proxy.gproxy(), name, G_CALLBACK(&ConnectionType::Run), result, nullptr);
+- return result;
+-}
+-
+-template <typename A1, typename A2, typename A3, typename A4>
+-MonitorConnection<void(A1, A2, A3, A4)>* Monitor(
+- const Proxy& proxy,
+- const char* name,
+- void (*monitor)(void*, A1, A2, A3, A4),
+- void* object) {
+- typedef MonitorConnection<void(A1, A2, A3, A4)> ConnectionType;
+-
+- ConnectionType* result = new ConnectionType(proxy, name, monitor, object);
+-
+- ::dbus_g_proxy_add_signal(proxy.gproxy(), name, glib::type_to_gtypeid<A1>(),
+- glib::type_to_gtypeid<A2>(),
+- glib::type_to_gtypeid<A3>(),
+- glib::type_to_gtypeid<A4>(), G_TYPE_INVALID);
+- ::dbus_g_proxy_connect_signal(
+- proxy.gproxy(), name, G_CALLBACK(&ConnectionType::Run), result, nullptr);
+- return result;
+-}
+-
+-template <typename F>
+-void Disconnect(MonitorConnection<F>* connection) {
+- typedef MonitorConnection<F> ConnectionType;
+-
+- ::dbus_g_proxy_disconnect_signal(
+- connection->proxy().gproxy(), connection->name().c_str(),
+- G_CALLBACK(&ConnectionType::Run), connection);
+- delete connection;
+-}
+-
+-// \brief call_PtrArray() invokes a method on a proxy returning a
+-// glib::PtrArray.
+-//
+-// CallPtrArray is the first instance of what is likely to be a general
+-// way to make method calls to a proxy. It will likely be replaced with
+-// something like Call(proxy, method, arg1, arg2, ..., ResultType*) in the
+-// future. However, I don't yet have enough cases to generalize from.
+-
+-BRILLO_EXPORT bool CallPtrArray(const Proxy& proxy,
+- const char* method,
+- glib::ScopedPtrArray<const char*>* result);
+-
+-// \brief RetrieveProperty() retrieves a property of an object associated with a
+-// proxy.
+-//
+-// Given a proxy to an object supporting the org.freedesktop.DBus.Properties
+-// interface, the RetrieveProperty() call will retrieve a property of the
+-// specified interface on the object storing it in \param result and returning
+-// \true. If the dbus call fails or the object returned is not of type \param T,
+-// then \false is returned and \param result is unchanged.
+-//
+-// \example
+-// Proxy proxy(GetSystemBusConnection(),
+-// "org.freedesktop.DeviceKit.Power", // A named entity on the bus
+-// battery_name, // Path to a battery on the bus
+-// "org.freedesktop.DBus.Properties") // Properties interface
+-//
+-// double x;
+-// if (RetrieveProperty(proxy,
+-// "org.freedesktop.DeviceKit.Power.Device",
+-// "percentage")
+-// std::cout << "Battery charge is " << x << "% of capacity.";
+-// \end_example
+-
+-template <typename T>
+-inline bool RetrieveProperty(const Proxy& proxy,
+- const char* interface,
+- const char* property,
+- T* result) {
+- glib::ScopedError error;
+- glib::Value value;
+-
+- if (!::dbus_g_proxy_call(proxy.gproxy(), "Get", &Resetter(&error).lvalue(),
+- G_TYPE_STRING, interface, G_TYPE_STRING, property,
+- G_TYPE_INVALID, G_TYPE_VALUE, &value,
+- G_TYPE_INVALID)) {
+- LOG(ERROR) << "Getting property failed: "
+- << (error->message ? error->message : "Unknown Error.");
+- return false;
+- }
+- return glib::Retrieve(value, result);
+-}
+-
+-// \brief RetrieveProperties returns a HashTable of all properties for the
+-// specified interface.
+-
+-BRILLO_EXPORT bool RetrieveProperties(const Proxy& proxy,
+- const char* interface,
+- glib::ScopedHashTable* result);
+-
+-// \brief Returns a connection to the system bus.
+-
+-BRILLO_EXPORT BusConnection GetSystemBusConnection();
+-
+-// \brief Returns a private connection to a bus at |address|.
+-
+-BRILLO_EXPORT BusConnection GetPrivateBusConnection(const char* address);
+-
+-// \brief Calls a method |method_name| with no arguments per the given |path|
+-// and |interface_name|. Ignores return value.
+-
+-BRILLO_EXPORT void CallMethodWithNoArguments(const char* service_name,
+- const char* path,
+- const char* interface_name,
+- const char* method_name);
+-
+-// \brief Low-level signal monitor base class.
+-//
+-// Used when there is no definite named signal sender (that Proxy
+-// could be used for).
+-
+-class BRILLO_EXPORT SignalWatcher {
+- public:
+- SignalWatcher() {}
+- ~SignalWatcher();
+- void StartMonitoring(const std::string& interface, const std::string& signal);
+-
+- private:
+- // Callback invoked on the given signal arrival.
+- virtual void OnSignal(DBusMessage* message) = 0;
+-
+- // Returns a string matching the D-Bus messages that we want to listen for.
+- BRILLO_PRIVATE std::string GetDBusMatchString() const;
+-
+- // A D-Bus message filter to receive signals.
+- BRILLO_PRIVATE static DBusHandlerResult FilterDBusMessage(
+- DBusConnection* dbus_conn, DBusMessage* message, void* data);
+- std::string interface_;
+- std::string signal_;
+-};
+-
+-} // namespace dbus
+-} // namespace brillo
+-
+-#endif // LIBBRILLO_BRILLO_GLIB_DBUS_H_
+diff --git a/brillo/glib/object.h b/brillo/glib/object.h
+deleted file mode 100644
+index 87e5601648..0000000000
+--- a/brillo/glib/object.h
++++ /dev/null
+@@ -1,469 +0,0 @@
+-// Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
+-// Use of this source code is governed by a BSD-style license that can be
+-// found in the LICENSE file.
+-
+-#ifndef LIBBRILLO_BRILLO_GLIB_OBJECT_H_
+-#define LIBBRILLO_BRILLO_GLIB_OBJECT_H_
+-
+-#include <glib-object.h>
+-#include <stdint.h>
+-
+-#include <algorithm>
+-#include <cstddef>
+-#include <memory>
+-#include <string>
+-#include <utility>
+-
+-#include <base/check.h>
+-#include <base/logging.h>
+-#include <base/macros.h>
+-
+-namespace brillo {
+-
+-namespace details { // NOLINT
+-
+-// \brief ResetHelper is a private class for use with Resetter().
+-//
+-// ResetHelper passes ownership of a pointer to a scoped pointer type with reset
+-// on destruction.
+-
+-template <typename T> // T models ScopedPtr
+-class ResetHelper {
+- public:
+- typedef typename T::element_type element_type;
+-
+- explicit ResetHelper(T* x) : ptr_(nullptr), scoped_(x) {}
+- ~ResetHelper() { scoped_->reset(ptr_); }
+- element_type*& lvalue() { return ptr_; }
+-
+- private:
+- element_type* ptr_;
+- T* scoped_;
+-};
+-
+-} // namespace details
+-
+-// \brief Resetter() is a utility function for passing pointers to
+-// scoped pointers.
+-//
+-// The Resetter() function return a temporary object containing an lvalue of
+-// \code T::element_type which can be assigned to. When the temporary object
+-// destructs, the associated scoped pointer is reset with the lvalue. It is of
+-// general use when a pointer is returned as an out-argument.
+-//
+-// \example
+-// void function(int** x) {
+-// *x = new int(10);
+-// }
+-// ...
+-// std::unique_ptr<int> x;
+-// function(Resetter(x).lvalue());
+-//
+-// \end_example
+-
+-template <typename T> // T models ScopedPtr
+-details::ResetHelper<T> Resetter(T* x) {
+- return details::ResetHelper<T>(x);
+-}
+-
+-namespace glib {
+-
+-// \brief type_to_gtypeid is a type function mapping from a canonical type to
+-// the GType typeid for the associated GType (see type_to_gtype).
+-
+-template <typename T>
+-::GType type_to_gtypeid();
+-
+-template <>
+-inline ::GType type_to_gtypeid<const char*>() {
+- return G_TYPE_STRING;
+-}
+-template <>
+-inline ::GType type_to_gtypeid<char*>() {
+- return G_TYPE_STRING;
+-}
+-template <>
+-inline ::GType type_to_gtypeid< ::uint8_t>() {
+- return G_TYPE_UCHAR;
+-}
+-template <>
+-inline ::GType type_to_gtypeid<double>() {
+- return G_TYPE_DOUBLE;
+-}
+-template <>
+-inline ::GType type_to_gtypeid<bool>() {
+- return G_TYPE_BOOLEAN;
+-}
+-class Value;
+-template <>
+-inline ::GType type_to_gtypeid<const Value*>() {
+- return G_TYPE_VALUE;
+-}
+-
+-template <>
+-inline ::GType type_to_gtypeid< ::uint32_t>() {
+- // REVISIT (seanparent) : There currently isn't any G_TYPE_UINT32, this code
+- // assumes sizeof(guint) == sizeof(guint32). Need a static_assert to assert
+- // that.
+- return G_TYPE_UINT;
+-}
+-
+-template <>
+-inline ::GType type_to_gtypeid< ::int64_t>() {
+- return G_TYPE_INT64;
+-}
+-
+-template <>
+-inline ::GType type_to_gtypeid< ::int32_t>() {
+- return G_TYPE_INT;
+-}
+-
+-// \brief Value (and Retrieve) support using std::string as well as const char*
+-// by promoting from const char* to the string. promote_from provides a mapping
+-// for this promotion (and possibly others in the future).
+-
+-template <typename T>
+-struct promotes_from {
+- typedef T type;
+-};
+-template <>
+-struct promotes_from<std::string> {
+- typedef const char* type;
+-};
+-
+-// \brief RawCast converts from a GValue to a value of a canonical type.
+-//
+-// RawCast is a low level function. Generally, use Cast() instead.
+-//
+-// \precondition \param x contains a value of type \param T.
+-
+-template <typename T>
+-inline T RawCast(const ::GValue& x) {
+- // Use static_assert() to issue a meaningful compile-time error.
+- // To prevent this from happening for all references to RawCast, use sizeof(T)
+- // to make static_assert depend on type T and therefore prevent binding it
+- // unconditionally until the actual RawCast<T> instantiation happens.
+- static_assert(sizeof(T) == 0, "Using RawCast on unsupported type");
+- return T();
+-}
+-
+-template <>
+-inline const char* RawCast<const char*>(const ::GValue& x) {
+- return static_cast<const char*>(::g_value_get_string(&x));
+-}
+-template <>
+-inline double RawCast<double>(const ::GValue& x) {
+- return static_cast<double>(::g_value_get_double(&x));
+-}
+-template <>
+-inline bool RawCast<bool>(const ::GValue& x) {
+- return static_cast<bool>(::g_value_get_boolean(&x));
+-}
+-template <>
+-inline ::uint32_t RawCast< ::uint32_t>(const ::GValue& x) {
+- return static_cast< ::uint32_t>(::g_value_get_uint(&x));
+-}
+-template <>
+-inline ::uint8_t RawCast< ::uint8_t>(const ::GValue& x) {
+- return static_cast< ::uint8_t>(::g_value_get_uchar(&x));
+-}
+-template <>
+-inline ::int64_t RawCast< ::int64_t>(const ::GValue& x) {
+- return static_cast< ::int64_t>(::g_value_get_int64(&x));
+-}
+-template <>
+-inline ::int32_t RawCast< ::int32_t>(const ::GValue& x) {
+- return static_cast< ::int32_t>(::g_value_get_int(&x));
+-}
+-
+-inline void RawSet(GValue* x, const std::string& v) {
+- ::g_value_set_string(x, v.c_str());
+-}
+-inline void RawSet(GValue* x, const char* v) {
+- ::g_value_set_string(x, v);
+-}
+-inline void RawSet(GValue* x, double v) {
+- ::g_value_set_double(x, v);
+-}
+-inline void RawSet(GValue* x, bool v) {
+- ::g_value_set_boolean(x, v);
+-}
+-inline void RawSet(GValue* x, ::uint32_t v) {
+- ::g_value_set_uint(x, v);
+-}
+-inline void RawSet(GValue* x, ::uint8_t v) {
+- ::g_value_set_uchar(x, v);
+-}
+-inline void RawSet(GValue* x, ::int64_t v) {
+- ::g_value_set_int64(x, v);
+-}
+-inline void RawSet(GValue* x, ::int32_t v) {
+- ::g_value_set_int(x, v);
+-}
+-
+-// \brief Value is a data type for managing GValues.
+-//
+-// A Value is a polymorphic container holding at most a single value.
+-//
+-// The Value wrapper ensures proper initialization, copies, and assignment of
+-// GValues.
+-//
+-// \note GValues are equationally incomplete and so can't support proper
+-// equality. The semantics of copy are verified with equality of retrieved
+-// values.
+-
+-class Value : public ::GValue {
+- public:
+- Value() : GValue() {}
+- explicit Value(const ::GValue& x) : GValue() {
+- *this = *static_cast<const Value*>(&x);
+- }
+- template <typename T>
+- explicit Value(T x) : GValue() {
+- ::g_value_init(this, type_to_gtypeid<typename promotes_from<T>::type>());
+- RawSet(this, x);
+- }
+- Value(const Value& x) : GValue() {
+- if (x.empty())
+- return;
+- ::g_value_init(this, G_VALUE_TYPE(&x));
+- ::g_value_copy(&x, this);
+- }
+- ~Value() { clear(); }
+- Value& operator=(const Value& x) {
+- if (this == &x)
+- return *this;
+- clear();
+- if (x.empty())
+- return *this;
+- ::g_value_init(this, G_VALUE_TYPE(&x));
+- ::g_value_copy(&x, this);
+- return *this;
+- }
+- template <typename T>
+- Value& operator=(const T& x) {
+- clear();
+- ::g_value_init(this, type_to_gtypeid<typename promotes_from<T>::type>());
+- RawSet(this, x);
+- return *this;
+- }
+-
+- // Lower-case names to follow STL container conventions.
+-
+- void clear() {
+- if (!empty())
+- ::g_value_unset(this);
+- }
+-
+- bool empty() const { return G_VALUE_TYPE(this) == G_TYPE_INVALID; }
+-};
+-
+-template <>
+-inline const Value* RawCast<const Value*>(const ::GValue& x) {
+- return static_cast<const Value*>(&x);
+-}
+-
+-// \brief Retrieve gets a value from a GValue.
+-//
+-// \postcondition If \param x contains a value of type \param T, then the
+-// value is copied to \param result and \true is returned. Otherwise, \param
+-// result is unchanged and \false is returned.
+-//
+-// \precondition \param result is not \nullptr.
+-
+-template <typename T>
+-bool Retrieve(const ::GValue& x, T* result) {
+- if (!G_VALUE_HOLDS(&x, type_to_gtypeid<typename promotes_from<T>::type>())) {
+- LOG(WARNING) << "GValue retrieve failed. Expected: "
+- << g_type_name(
+- type_to_gtypeid<typename promotes_from<T>::type>())
+- << ", Found: " << g_type_name(G_VALUE_TYPE(&x));
+- return false;
+- }
+-
+- *result = RawCast<typename promotes_from<T>::type>(x);
+- return true;
+-}
+-
+-inline bool Retrieve(const ::GValue& x, Value* result) {
+- *result = Value(x);
+- return true;
+-}
+-
+-// \brief ScopedError holds a ::GError* and deletes it on destruction.
+-
+-struct FreeError {
+- void operator()(::GError* x) const {
+- if (x)
+- ::g_error_free(x);
+- }
+-};
+-
+-typedef std::unique_ptr< ::GError, FreeError> ScopedError;
+-
+-// \brief ScopedArray holds a ::GArray* and deletes both the container and the
+-// segment containing the elements on destruction.
+-
+-struct FreeArray {
+- void operator()(::GArray* x) const {
+- if (x)
+- ::g_array_free(x, TRUE);
+- }
+-};
+-
+-typedef std::unique_ptr< ::GArray, FreeArray> ScopedArray;
+-
+-// \brief ScopedPtrArray adapts ::GPtrArray* to conform to the standard
+-// container requirements.
+-//
+-// \note ScopedPtrArray is only partially implemented and is being fleshed out
+-// as needed.
+-//
+-// \models Random Access Container, Back Insertion Sequence, ScopedPtrArray is
+-// not copyable and equationally incomplete.
+-
+-template <typename T> // T models pointer
+-class ScopedPtrArray {
+- public:
+- typedef ::GPtrArray element_type;
+-
+- typedef T value_type;
+- typedef const value_type& const_reference;
+- typedef value_type* iterator;
+- typedef const value_type* const_iterator;
+-
+- ScopedPtrArray() : object_(0) {}
+-
+- explicit ScopedPtrArray(::GPtrArray* x) : object_(x) {}
+- ScopedPtrArray(const ScopedPtrArray&) = delete;
+- ScopedPtrArray& operator=(const ScopedPtrArray&) = delete;
+-
+- ~ScopedPtrArray() { clear(); }
+-
+- iterator begin() { return iterator(object_ ? object_->pdata : nullptr); }
+- iterator end() { return begin() + size(); }
+- const_iterator begin() const {
+- return const_iterator(object_ ? object_->pdata : nullptr);
+- }
+- const_iterator end() const { return begin() + size(); }
+-
+- // \precondition x is a pointer to an object allocated with g_new().
+-
+- void push_back(T x) {
+- if (!object_)
+- object_ = ::g_ptr_array_sized_new(1);
+- ::g_ptr_array_add(object_, ::gpointer(x));
+- }
+-
+- T& operator[](std::size_t n) {
+- DCHECK(!(size() < n)) << "ScopedPtrArray index out-of-bound.";
+- return *(begin() + n);
+- }
+-
+- std::size_t size() const { return object_ ? object_->len : 0; }
+-
+- void clear() {
+- if (object_) {
+- std::for_each(begin(), end(), FreeHelper());
+- ::g_ptr_array_free(object_, true);
+- object_ = nullptr;
+- }
+- }
+-
+- void reset(::GPtrArray* p = nullptr) {
+- if (p != object_) {
+- clear();
+- object_ = p;
+- }
+- }
+-
+- private:
+- struct FreeHelper {
+- void operator()(T x) const { ::g_free(::gpointer(x)); }
+- };
+-
+- template <typename U>
+- friend void swap(ScopedPtrArray<U>& x, ScopedPtrArray<U>& y);
+-
+- ::GPtrArray* object_;
+-};
+-
+-template <typename U>
+-inline void swap(ScopedPtrArray<U>& x, ScopedPtrArray<U>& y) {
+- std::swap(x.object_, y.object_);
+-}
+-
+-// \brief ScopedHashTable manages the lifetime of a ::GHashTable* with an
+-// interface compatibitle with a scoped ptr.
+-//
+-// The ScopedHashTable is also the start of an adaptor to model a standard
+-// Container. The standard for an associative container would have an iterator
+-// returning a key value pair. However, that isn't possible with
+-// ::GHashTable because there is no interface returning a reference to the
+-// key value pair, only to retrieve the keys and values and individual elements.
+-//
+-// So the standard interface of find() wouldn't work. I considered implementing
+-// operator[] and count() - operator []. So retrieving a value would look like:
+-//
+-// if (table.count(key))
+-// success = Retrieve(table[key], &value);
+-//
+-// But that requires hashing the key twice.
+-// For now I implemented a Retrieve member function to follow the pattern
+-// developed elsewhere in the code.
+-//
+-// bool success = Retrieve(key, &x);
+-//
+-// This is also a template to retrieve the corect type from the stored GValue
+-// type.
+-//
+-// I may revisit this and use scoped_ptr_malloc and a non-member function
+-// Retrieve() in the future. The Retrieve pattern is becoming common enough
+-// that I want to give some thought as to how to generalize it further.
+-
+-class ScopedHashTable {
+- public:
+- typedef ::GHashTable element_type;
+-
+- ScopedHashTable() : object_(nullptr) {}
+-
+- explicit ScopedHashTable(::GHashTable* p) : object_(p) {}
+-
+- ~ScopedHashTable() { clear(); }
+-
+- template <typename T>
+- bool Retrieve(const char* key, T* result) const {
+- DCHECK(object_) << "Retrieve on empty ScopedHashTable.";
+- if (!object_)
+- return false;
+-
+- ::gpointer ptr = ::g_hash_table_lookup(object_, key);
+- if (!ptr)
+- return false;
+- return glib::Retrieve(*static_cast< ::GValue*>(ptr), result);
+- }
+-
+- void clear() {
+- if (object_) {
+- ::g_hash_table_unref(object_);
+- object_ = nullptr;
+- }
+- }
+-
+- GHashTable* get() { return object_; }
+-
+- void reset(::GHashTable* p = nullptr) {
+- if (p != object_) {
+- clear();
+- object_ = p;
+- }
+- }
+-
+- private:
+- ::GHashTable* object_;
+-};
+-
+-} // namespace glib
+-} // namespace brillo
+-
+-#endif // LIBBRILLO_BRILLO_GLIB_OBJECT_H_
+diff --git a/brillo/glib/object_test.cc b/brillo/glib/object_test.cc
+deleted file mode 100644
+index 9381866b9f..0000000000
+--- a/brillo/glib/object_test.cc
++++ /dev/null
+@@ -1,132 +0,0 @@
+-// Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
+-// Use of this source code is governed by a BSD-style license that can be
+-// found in the LICENSE file.
+-
+-#include "brillo/glib/object.h"
+-
+-#include <gtest/gtest.h>
+-
+-#include <algorithm>
+-#include <cstring>
+-#include <iterator>
+-#include <string>
+-
+-using brillo::Resetter;
+-using brillo::glib::Retrieve;
+-using brillo::glib::ScopedError;
+-using brillo::glib::ScopedPtrArray;
+-using brillo::glib::Value;
+-
+-namespace { // NOLINT
+-
+-template <typename T>
+-void SetRetrieveTest(const T& x) {
+- Value tmp(x);
+- T result;
+- EXPECT_TRUE(Retrieve(tmp, &result));
+- EXPECT_EQ(result, x);
+-}
+-
+-void ModifyValue(Value* x) {
+- *x = 1.0 / 1231415926.0; // An unlikely value
+-}
+-
+-template <typename T, typename O>
+-void MutableRegularTestValue(const T& x, O modify) {
+- Value tmp(x);
+- Value y = tmp; // copy-construction
+- T result;
+- EXPECT_TRUE(Retrieve(y, &result));
+- EXPECT_EQ(result, x);
+- modify(&y);
+- LOG(INFO) << "Warning Expected.";
+- EXPECT_TRUE(!(Retrieve(y, &result) && result == x));
+- y = tmp; // assignment
+- EXPECT_TRUE(Retrieve(y, &result));
+- EXPECT_EQ(result, x);
+- modify(&y);
+- LOG(INFO) << "Warning Expected.";
+- EXPECT_TRUE(!(Retrieve(y, &result) && result == x));
+-}
+-
+-void OutArgument(int** x) {
+- *x = new int(10); // NOLINT
+-}
+-
+-} // namespace
+-
+-TEST(ResetterTest, All) {
+- std::unique_ptr<int> x;
+- OutArgument(&Resetter(&x).lvalue());
+- EXPECT_EQ(*x, 10);
+-}
+-
+-TEST(RetrieveTest, Types) {
+- SetRetrieveTest(std::string("Hello!"));
+- SetRetrieveTest(static_cast<uint32_t>(10));
+- SetRetrieveTest(10.5);
+- SetRetrieveTest(true);
+-}
+-
+-TEST(ValueTest, All) {
+- Value x; // default construction
+- Value y = x; // copy with default value
+- x = y; // assignment with default value
+- Value z(1.5);
+- x = z; // assignment to default value
+- MutableRegularTestValue(std::string("Hello!"), &ModifyValue);
+-}
+-
+-TEST(ScopedErrorTest, All) {
+- ScopedError a; // default construction
+- ScopedError b(::g_error_new(::g_quark_from_static_string("error"), -1,
+- "")); // constructor
+- ::GError* c = ::g_error_new(::g_quark_from_static_string("error"), -1, "");
+- ::GError* d = ::g_error_new(::g_quark_from_static_string("error"), -1, "");
+- a.reset(c); // reset form 1
+- (void)d;
+-}
+-
+-TEST(ScopedPtrArrayTest, Construction) {
+- const char item[] = "a string";
+- char* a = static_cast<char*>(::g_malloc(sizeof(item)));
+- std::strcpy(a, &item[0]); // NOLINT
+-
+- ::GPtrArray* array = ::g_ptr_array_new();
+- ::g_ptr_array_add(array, ::gpointer(a));
+-
+- ScopedPtrArray<const char*> x(array);
+- EXPECT_EQ(x.size(), 1);
+- EXPECT_EQ(x[0], a); // indexing
+-}
+-
+-TEST(ScopedPtrArrayTest, Reset) {
+- const char item[] = "a string";
+- char* a = static_cast<char*>(::g_malloc(sizeof(item)));
+- std::strcpy(a, &item[0]); // NOLINT
+-
+- ScopedPtrArray<const char*> x; // default construction
+- x.push_back(a);
+- EXPECT_EQ(x.size(), 1);
+- x.reset();
+- EXPECT_EQ(x.size(), 0);
+-
+- char* b = static_cast<char*>(::g_malloc(sizeof(item)));
+- std::strcpy(b, &item[0]); // NOLINT
+-
+- ::GPtrArray* array = ::g_ptr_array_new();
+- ::g_ptr_array_add(array, ::gpointer(b));
+-
+- x.reset(array);
+- EXPECT_EQ(x.size(), 1);
+-}
+-
+-TEST(ScopedPtrArrayTest, Iteration) {
+- char* a[] = {static_cast<char*>(::g_malloc(1)),
+- static_cast<char*>(::g_malloc(1)),
+- static_cast<char*>(::g_malloc(1))};
+-
+- ScopedPtrArray<const char*> x;
+- std::copy(&a[0], &a[3], std::back_inserter(x));
+- EXPECT_TRUE(std::equal(x.begin(), x.end(), &a[0]));
+-}
+--
+2.33.0.464.g1972c5931b-goog
+
diff --git a/chromeos/config/env/sys-fs/lvm2 b/chromeos/config/env/sys-fs/lvm2
deleted file mode 100644
index 656334c..0000000
--- a/chromeos/config/env/sys-fs/lvm2
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Remove files that will not be used from targets.
-# /etc/lvm/lvm.conf is added by chromeos-init.
-if [[ $(cros_target) != "cros_host" ]]; then
- lvm_mask="
- /etc/dmtab
- /etc/lvm/lvm.conf
- /etc/lvm/profile/*
- /lib*/liblvm2app.so*
- /lib/udev/rules.d/11-dm-lvm.rules
- /lib/udev/rules.d/69-dm-lvm-metad.rules
- /usr/lib*/liblvm2app.so*
- /usr/lib*/pkgconfig/lvm2app.pc
- /usr/lib/tmpfiles.d/lvm2.conf
- /usr/include/lvm2app.h
- /sbin/lvmetad
- /sbin/lvpolld
- "
-
- PKG_INSTALL_MASK+=" ${lvm_mask}"
- INSTALL_MASK+=" ${lvm_mask}"
- unset lvm_mask
-fi
diff --git a/chromeos/config/env/sys-libs/compiler-rt b/chromeos/config/env/sys-libs/compiler-rt
new file mode 100644
index 0000000..216c46b
--- /dev/null
+++ b/chromeos/config/env/sys-libs/compiler-rt
@@ -0,0 +1,5 @@
+# Copyright 2021 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+EGIT_MASTER="main"
diff --git a/chromeos/config/env/sys-libs/llvm-libunwind b/chromeos/config/env/sys-libs/llvm-libunwind
new file mode 100644
index 0000000..216c46b
--- /dev/null
+++ b/chromeos/config/env/sys-libs/llvm-libunwind
@@ -0,0 +1,5 @@
+# Copyright 2021 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+EGIT_MASTER="main"
diff --git a/chromeos/config/make.conf.sdk-chromeos b/chromeos/config/make.conf.sdk-chromeos
index 17695c3..959e930 100644
--- a/chromeos/config/make.conf.sdk-chromeos
+++ b/chromeos/config/make.conf.sdk-chromeos
@@ -8,7 +8,9 @@
# See "man 5 make.conf" and "man 5 portage" for the available options.
# TODO: Drop this!
-USE="${USE} internal"
+# lakitu: Do not set the internal USE flag, because we don't need it (our
+# chromeos-overlay is empty)
+# USE="${USE} internal"
# For internal builds, automatically accept the licenses needed to
# build Chrome OS. All Googlers have agreed to this.
diff --git a/dev-go/gcp-storage/Manifest b/dev-go/gcp-storage/Manifest
new file mode 100644
index 0000000..37f46e8
--- /dev/null
+++ b/dev-go/gcp-storage/Manifest
@@ -0,0 +1 @@
+DIST github.com-GoogleCloudPlatform-google-cloud-go-v0.18.0.tar.gz 1001983 BLAKE2B d6fe987db90840ea585d60a4d9e1529062d08b5edd1cfd39da8d6beab5fa88692d7c2800eb6ae75406e4a1ddd7de967038be1a582ea903f29f27d7acaa642bc5 SHA512 b7169e1851adc49d59b329d01a49bd9c12f0978f8066943627a37f9c30136c44e3eed45a3bf257cd1ea112674c47bb3135f165f1338a420f0aabf22053c5b471
diff --git a/dev-go/gcp-storage/gcp-storage-0.18.0-r1.ebuild b/dev-go/gcp-storage/gcp-storage-0.18.0-r1.ebuild
new file mode 120000
index 0000000..341b10c
--- /dev/null
+++ b/dev-go/gcp-storage/gcp-storage-0.18.0-r1.ebuild
@@ -0,0 +1 @@
+gcp-storage-0.18.0.ebuild
\ No newline at end of file
diff --git a/dev-go/gcp-storage/gcp-storage-0.18.0.ebuild b/dev-go/gcp-storage/gcp-storage-0.18.0.ebuild
new file mode 100644
index 0000000..b59d2d5
--- /dev/null
+++ b/dev-go/gcp-storage/gcp-storage-0.18.0.ebuild
@@ -0,0 +1,52 @@
+#
+# Copyright 2021 Google LLC
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# version 2 as published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+
+EAPI=7
+
+# The dev-go/gcp* packages are all built from this repo. They should
+# be updated together.
+CROS_GO_SOURCE="github.com/GoogleCloudPlatform/google-cloud-go:cloud.google.com/go v${PV}"
+
+CROS_GO_PACKAGES=(
+ "cloud.google.com/go/storage"
+)
+
+CROS_GO_TEST=(
+ "${CROS_GO_PACKAGES[@]}"
+)
+
+inherit cros-go
+
+DESCRIPTION="Google Cloud Client Libraries for Go"
+HOMEPAGE="https://code.googlesource.com/gocloud"
+SRC_URI="$(cros-go_src_uri)"
+
+LICENSE="BSD-Google"
+SLOT="0"
+KEYWORDS="*"
+IUSE=""
+RESTRICT="binchecks strip"
+
+DEPEND="
+ dev-go/cmp
+ dev-go/gcp-iam
+ dev-go/gapi-option
+ dev-go/gapi-transport
+ dev-go/gapi-storage
+ dev-go/gcp-internal
+ dev-go/genproto
+ dev-go/grpc
+ dev-go/net
+"
+RDEPEND="${DEPEND}"
+
diff --git a/eclass/cros-kernel2.eclass b/eclass/cros-kernel2.eclass
index 778c63f..0bfb6df 100644
--- a/eclass/cros-kernel2.eclass
+++ b/eclass/cros-kernel2.eclass
@@ -175,6 +175,7 @@
goldfish
highmem
hypervisor_guest
+ mellanox_eth
i2cdev
iioservice
irqsoff_tracer
@@ -235,6 +236,9 @@
wifi_diag
x32
xen_guest
+ hyperv_guest
+ ntfs_fs
+ cdrom
)
acpi_ac_desc="Enable ACPI AC"
@@ -439,6 +443,30 @@
CONFIG_ACPI_VIOT=y
"
+mellanox_eth_desc="Mellanox Ethernet Drivers"
+mellanox_eth_config="
+CONFIG_NET_VENDOR_MELLANOX=y
+CONFIG_MLX4_EN=m
+CONFIG_MLX4_CORE=m
+CONFIG_MLX4_DEBUG=y
+CONFIG_MLX4_CORE_GEN2=y
+CONFIG_MLX5_CORE=m
+CONFIG_MLX5_ACCEL=y
+CONFIG_MLX5_FPGA=y
+CONFIG_MLX5_CORE_EN=y
+CONFIG_MLX5_EN_ARFS=y
+CONFIG_MLX5_EN_RXNFC=y
+CONFIG_MLX5_MPFS=y
+# CONFIG_MLX5_CORE_IPOIB is not set
+CONFIG_MLX5_FPGA_IPSEC=y
+CONFIG_MLXSW_CORE=m
+CONFIG_MLXSW_CORE_THERMAL=y
+CONFIG_MLXSW_PCI=m
+CONFIG_MLXFW=m
+# CONFIG_MLX_WDT is not set
+CONFIG_MELLANOX_PLATFORM=y
+"
+
i2cdev_desc="I2C device interface"
i2cdev_config="
CONFIG_I2C_CHARDEV=y
@@ -982,6 +1010,31 @@
CONFIG_XEN_HAVE_VPMU=y
"
+hyperv_guest_desc="Microsoft Hyper-V guest support"
+hyperv_guest_config="
+CONFIG_HYPERV=y
+CONFIG_HYPERV_NET=y
+CONFIG_HYPERV_TSCPAGE=y
+CONFIG_HYPERV_KEYBOARD=y
+CONFIG_HYPERV_STORAGE=y
+CONFIG_HYPERV_BALLOON=y
+CONFIG_HYPERV_UTILS=y
+CONFIG_HYPERV_TIMER=y
+CONFIG_HYPERV_IOMMU=y
+CONFIG_FB_HYPERV=y
+CONFIG_PCI_HYPERV=y
+"
+
+ntfs_fs_desc="Microsoft NTFS support"
+ntfs_fs_config="
+CONFIG_NTFS_FS=m
+"
+
+cdrom_desc="CDROM support"
+cdrom_config="
+CONFIG_BLK_DEV_SR=y
+"
+
vtconsole_desc="VT console"
vtconsole_config="
CONFIG_VT=y
diff --git a/media-libs/libsync/libsync-0.0.1-r6.ebuild b/media-libs/libsync/libsync-0.0.1-r7.ebuild
similarity index 96%
rename from media-libs/libsync/libsync-0.0.1-r6.ebuild
rename to media-libs/libsync/libsync-0.0.1-r7.ebuild
index 8c08674..3f1a5d4 100644
--- a/media-libs/libsync/libsync-0.0.1-r6.ebuild
+++ b/media-libs/libsync/libsync-0.0.1-r7.ebuild
@@ -9,7 +9,7 @@
CROS_WORKON_TREE="6735ede3571072051f02df69fdf53bb239ebe6bd"
CROS_WORKON_PROJECT="aosp/platform/system/core/libsync"
CROS_WORKON_EGIT_BRANCH="master"
-CROS_WORKON_REPO="${CROS_GIT_AOSP_URL}"
+CROS_WORKON_REPO="${CROS_GIT_HOST_URL}"
CROS_WORKON_LOCALNAME="../aosp/system/libsync"
CROS_WORKON_MANUAL_UPREV="1"
diff --git a/media-libs/libsync/libsync-9999.ebuild b/media-libs/libsync/libsync-9999.ebuild
index 45c0adf..898de6c 100644
--- a/media-libs/libsync/libsync-9999.ebuild
+++ b/media-libs/libsync/libsync-9999.ebuild
@@ -7,7 +7,7 @@
CROS_WORKON_PROJECT="aosp/platform/system/core/libsync"
CROS_WORKON_EGIT_BRANCH="master"
-CROS_WORKON_REPO="${CROS_GIT_AOSP_URL}"
+CROS_WORKON_REPO="${CROS_GIT_HOST_URL}"
CROS_WORKON_LOCALNAME="../aosp/system/libsync"
CROS_WORKON_MANUAL_UPREV="1"
diff --git a/net-libs/libslirp/Manifest b/net-libs/libslirp/Manifest
new file mode 100644
index 0000000..b508e93
--- /dev/null
+++ b/net-libs/libslirp/Manifest
@@ -0,0 +1 @@
+DIST libslirp-4.3.1.tar.gz 127008 BLAKE2B de40980521a54367fda73b9a67a80159ff14e8ea073086d8df3b42028ffe778b62f0aabe2b3f0929e168c73c453a8eda3fe0bb866d22de5b0712775e9cece19f SHA512 fa38a5e508b00802538f8466b8b52fc4842d6f7f74caa399db1011c15bb37198678415147327a606e3f259fd5def9390012df1d4dc76e8869e9bb77ca6514005
diff --git a/net-libs/libslirp/files/libslirp-4.3.1-bug-756910-check-pkt_len.patch b/net-libs/libslirp/files/libslirp-4.3.1-bug-756910-check-pkt_len.patch
new file mode 100644
index 0000000..aef7f19
--- /dev/null
+++ b/net-libs/libslirp/files/libslirp-4.3.1-bug-756910-check-pkt_len.patch
@@ -0,0 +1,48 @@
+From: Prasad J Pandit <pjp@fedoraproject.org>
+Date: Thu, 26 Nov 2020 13:57:06 +0000
+Subject: [PATCH] slirp: check pkt_len before reading protocol header
+
+While processing ARP/NCSI packets in 'arp_input' or 'ncsi_input'
+routines, ensure that pkt_len is large enough to accommodate the
+respective protocol headers, lest it should do an OOB access.
+Add check to avoid it.
+
+Reported-by: Qiuhao Li @outlook.com;
+Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
+---
+ src/ncsi.c | 4 ++++
+ src/slirp.c | 4 ++++
+ 2 files changed, 8 insertions(+)
+
+diff --git a/src/ncsi.c b/src/ncsi.c
+index 3c1dfef..75dcc08 100644
+--- a/src/ncsi.c
++++ b/src/ncsi.c
+@@ -148,6 +148,10 @@ void ncsi_input(Slirp *slirp, const uint8_t *pkt, int pkt_len)
+ uint32_t checksum;
+ uint32_t *pchecksum;
+
++ if (pkt_len < ETH_HLEN + sizeof(struct ncsi_pkt_hdr)) {
++ return; /* packet too short */
++ }
++
+ memset(ncsi_reply, 0, sizeof(ncsi_reply));
+
+ memset(reh->h_dest, 0xff, ETH_ALEN);
+diff --git a/src/slirp.c b/src/slirp.c
+index 9bead0c..abb6f9a 100644
+--- a/src/slirp.c
++++ b/src/slirp.c
+@@ -860,6 +860,10 @@ static void arp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len)
+ return;
+ }
+
++ if (pkt_len < ETH_HLEN + sizeof(struct slirp_arphdr)) {
++ return; /* packet too short */
++ }
++
+ ar_op = ntohs(ah->ar_op);
+ switch (ar_op) {
+ case ARPOP_REQUEST:
+--
+2.28.0
diff --git a/net-libs/libslirp/libslirp-4.3.1-r1.ebuild b/net-libs/libslirp/libslirp-4.3.1-r1.ebuild
new file mode 100644
index 0000000..fef0fb7
--- /dev/null
+++ b/net-libs/libslirp/libslirp-4.3.1-r1.ebuild
@@ -0,0 +1,39 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit meson
+
+KEYWORDS="*"
+MY_P="${PN}-v${PV}"
+SRC_URI="https://gitlab.freedesktop.org/slirp/libslirp/-/archive/v${PV}/${MY_P}.tar.gz -> ${P}.tar.gz"
+DESCRIPTION="A general purpose TCP-IP emulator used by virtual machine hypervisors to provide virtual networking services."
+HOMEPAGE="https://gitlab.freedesktop.org/slirp/libslirp"
+
+LICENSE="BSD"
+SLOT="0"
+IUSE="static-libs"
+
+RDEPEND="dev-libs/glib:="
+
+DEPEND="${RDEPEND}"
+
+S=${WORKDIR}/${MY_P}
+
+PATCHES=(
+ "${FILESDIR}/libslirp-4.3.1-bug-756910-check-pkt_len.patch"
+)
+
+src_prepare() {
+ default
+ echo "${PV}" > .tarball-version || die
+ echo -e "#!${BASH}\necho -n \$(cat '${S}/.tarball-version')" > build-aux/git-version-gen || die
+}
+
+src_configure() {
+ local emesonargs=(
+ -Ddefault_library=$(usex static-libs both shared)
+ )
+ meson_src_configure
+}
diff --git a/net-libs/libslirp/metadata.xml b/net-libs/libslirp/metadata.xml
new file mode 100644
index 0000000..8830eef
--- /dev/null
+++ b/net-libs/libslirp/metadata.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="person">
+ <name>Zac Medico</name>
+ <email>zmedico@gentoo.org</email>
+ </maintainer>
+ <upstream>
+ <remote-id type="gitlab">gitlab.freedesktop.org/slirp/libslirp</remote-id>
+ </upstream>
+</pkgmetadata>
diff --git a/profiles/targets/sdk/package.mask b/profiles/targets/sdk/package.mask
new file mode 100644
index 0000000..e80fadb
--- /dev/null
+++ b/profiles/targets/sdk/package.mask
@@ -0,0 +1,9 @@
+# Mask sys-libs/ncurses versions above v5.9
+# This is done because certain binpkg in
+# sdk tarball has a dependency on ncurses-5.9
+# which was installed in Slot-0. Upgrade to
+# ncurses to a newer version creates a conflict
+# in create_sdk step due to multiple ncurses
+# version being tried to install into the same
+# SLOT.
+>sys-libs/ncurses-5.9
diff --git a/profiles/targets/sdk/package.use b/profiles/targets/sdk/package.use
index 2c74b7d..ccec829 100644
--- a/profiles/targets/sdk/package.use
+++ b/profiles/targets/sdk/package.use
@@ -29,6 +29,7 @@
dev-libs/glib static-libs
dev-libs/libpcre static-libs
net-libs/nghttp2 static-libs
+net-libs/libslirp static-libs
sys-apps/attr static-libs
# mksquashfs used in build_image requires lzo/lz4/zstd support.
@@ -87,7 +88,7 @@
# Build qemu's userland helpers statically so we can copy them into sysroots
# and run unittests standalone. Build qemu's softmmu helpers statically so
# we can run vms outside of the chroot.
-app-emulation/qemu -pin-upstream-blobs -seccomp static-user usb virtfs
+app-emulation/qemu -ncurses -pin-upstream-blobs -seccomp static-user usb virtfs
dev-libs/glib static-libs
dev-libs/libaio static-libs
dev-libs/libpcre static-libs
diff --git a/sys-boot/grub/files/0005-strip-interp-from-diskboot.patch b/sys-boot/grub/files/0005-strip-interp-from-diskboot.patch
new file mode 100644
index 0000000..492f468
--- /dev/null
+++ b/sys-boot/grub/files/0005-strip-interp-from-diskboot.patch
@@ -0,0 +1,20 @@
+--- grub-core/Makefile.core.def 2021-07-06 23:58:33.094383161 -0700
++++ grub-core/Makefile.core.def 2021-07-06 23:59:01.142164648 -0700
+@@ -372,7 +372,7 @@
+ sparc64_ieee1275_objcopyflags = '-O a.out-sunos-big';
+ sparc64_ieee1275_ldflags = ' -Wl,-Ttext=0x4000';
+
+- objcopyflags = '-O binary';
++ objcopyflags = '-R .interp -O binary';
+ enable = i386_pc;
+ enable = i386_qemu;
+ enable = sparc64_ieee1275;
+@@ -430,7 +430,7 @@
+ sparc64_ieee1275 = boot/sparc64/ieee1275/diskboot.S;
+ sparc64_ieee1275_ldflags = '-Wl,-Ttext=0x4200';
+
+- objcopyflags = '-O binary';
++ objcopyflags = '-R .interp -O binary';
+
+ enable = i386_pc;
+ enable = sparc64_ieee1275;
diff --git a/sys-boot/grub/grub-2.06.ebuild b/sys-boot/grub/grub-2.06.ebuild
index cf56305..b2fd296 100644
--- a/sys-boot/grub/grub-2.06.ebuild
+++ b/sys-boot/grub/grub-2.06.ebuild
@@ -24,6 +24,7 @@
src_prepare() {
epatch "${FILESDIR}/0001-Forward-port-ChromeOS-specific-GRUB-environment-vari.patch"
epatch "${FILESDIR}/0002-Forward-port-gptpriority-command-to-GRUB-2.00.patch"
+ epatch "${FILESDIR}/0005-strip-interp-from-diskboot.patch"
epatch "${FILESDIR}/b189992601-no-soft-float.patch"
bash autogen.sh || die