Commit graph

81990 commits

Author SHA1 Message Date
David Anderson
9b306bab11 Merge changes Ib33dc593,I6550682f,Ic0681cbf,Iaaf96a37,I89b15492 into main am: 9c525ff0ed
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2695350

Change-Id: I309c8307fe7515011ed16890480f00998bf87181
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-08 20:31:37 +00:00
David Anderson
9c525ff0ed Merge changes Ib33dc593,I6550682f,Ic0681cbf,Iaaf96a37,I89b15492 into main
* changes:
  snapuserd: Factor a base class out of tests.
  snapuserd: Add error propagation to tests.
  snapuserd: Add diagnostics for debugging races.
  snapuserd: Fix race condition in HandleManager shutdown.
  snapuserd: Remove test dependence on LoopDevice.
2023-08-08 19:46:53 +00:00
David Anderson
891671852c Merge changes Ifddb5cb8,I8735ef6c,Ifd33c28e into main am: 1cf0e90409
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2693470

Change-Id: I1f97c22cb28f4a0850630e010a1e8e06f23d26ff
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-08 17:53:33 +00:00
David Anderson
dbda1300ae snapuserd: Factor a base class out of tests.
This factors a lighter weight class out of SnapuserdTest, so we can
construct tests without needing a HandlerManager/daemon.

Bug: 288273605
Test: snapuserd_test
Change-Id: Ib33dc593a5b3d3df86853e73f245918ef36fd9fa
2023-08-08 10:41:56 -07:00
David Anderson
9fb4fc307c snapuserd: Add error propagation to tests.
snapuserd_test in general doesn't propagate errors, which means the
first failure will cascade into many failures. This can make it harder
to figure out what's going on.

Unfortunately error propagation is difficult with gtest, since bool
returns don't work with ASSERT_EQ and Android doesn't use exceptions.

Use ASSERT_NO_FATAL_FAILURE for now, since that is the least invasive
change.

Bug: 288273605
Test: snapuserd_test
Change-Id: I6550682fd63602bc15649f705def2915f6329357
2023-08-08 10:41:56 -07:00
David Anderson
9aa4218246 snapuserd: Add diagnostics for debugging races.
Adds calls to pthread_setname_np for each thread.

Clarify error messages from io_uring calls that return -errno.

Add log messages for some failure paths that didn't have any.

Add an ostream overload for MERGE_IO_TRANSITION, and add an INVALID
state for initialization.

Bug: 288273605
Test: builds
Change-Id: Ic0681cbf0017af67bcf52b98db184a9b48752faf
2023-08-08 10:41:55 -07:00
David Anderson
02191dbfac snapuserd: Fix race condition in HandleManager shutdown.
When HandlerManager shuts down, the monitor thread is left detached. The
monitor thread does not hold a shared_ptr reference to the
HandlerManager, so the pointer can be left dangling.

Fix this by not detaching the monitor merge thread.

This patch also changes the test harness to destroy
SnapshotHandlerManager on "shutdown", to avoid state leaking into the
next instance of snapuserd.

Bug: 288273605
Test: snapuserd_test
Change-Id: Iaaf96a37657c85cff4d2a8b15ccfde4aa03d3220
2023-08-08 10:40:32 -07:00
David Anderson
db70cbf78a snapuserd: Remove test dependence on LoopDevice.
LoopDevice requires root, which is an obstacle to running this test in
automation. The test also requires memfd which is not available in our
included glibc. Create an IBackingDevice layer so we can use temporary
files instead on host tests, while keeping the block-device code for
on-device tests, which more closely matches how snapuserd runs.

Bug: 288273605
Test: snapuserd_test
Change-Id: I89b154921b6bbcf8fe213ef7f5c4da4d48322909
2023-08-08 10:40:32 -07:00
David Anderson
1cf0e90409 Merge changes Ifddb5cb8,I8735ef6c,Ifd33c28e into main
* changes:
  snapuserd: Factor setpriority/settid calls into a helper.
  snapuserd: Add a harness to run tests without dm-user specific code.
  snapuserd: Add an IBlockServerFactory abstraction.
2023-08-08 17:12:12 +00:00
David Anderson
84e0aebfc5 Merge "snapuserd: Remove ambiguous BufferSink in workers." into main am: 0c0745e627
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2695177

Change-Id: I3539b3972daa0dcad7998dc434f66d01dd62fcc0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-08 03:48:28 +00:00
David Anderson
0c0745e627 Merge "snapuserd: Remove ambiguous BufferSink in workers." into main 2023-08-08 02:53:35 +00:00
David Anderson
52b30ba261 Merge changes Ie9a781e4,I060788c9,Ie75e9440 into main am: a49b8d22f4
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2640839

Change-Id: I7734cf2a08aec3c9e8409ccc803de19e77afd87a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-07 23:19:46 +00:00
David Anderson
a49b8d22f4 Merge changes Ie9a781e4,I060788c9,Ie75e9440 into main
* changes:
  snapuserd: Remove dm-user specific code from ReadWorker.
  snapuserd: Add an IBlockServer abstraction around dm-user.
  snapuserd: Rename snapuserd_merge to merge_worker.
2023-08-07 22:31:34 +00:00
David Anderson
dba77ad737 snapuserd: Factor setpriority/settid calls into a helper.
This allows disabling the code in host builds, since settid() isn't
available in the glibc prebuilt.

Bug: 288273605
Test: snapuserd_test
Change-Id: Ifddb5cb8b04484a1ab0a29794d65c9839759a919
2023-08-07 13:37:47 -07:00
David Anderson
fe032d0391 snapuserd: Add a harness to run tests without dm-user specific code.
This patch adds an abstraction layer around Tempdevice (which wraps
device-mapper), and a layer to replace hardcoding of DmUserBlockServer.

The only implementation of the new layer, currently, is for dm-user.
However this will allow the harness to run with a backend chosen at
runtime, making testing on the host or of ublk much easier.

Bug: 288273605
Test: snapuserd_test
Change-Id: I8735ef6c373f3e5c5cdf3df461668ddd8e551f63
2023-08-07 13:37:47 -07:00
Treehugger Robot
c24da1fca4 Merge "Add snapuserd_ramdisk execute permission" into main am: a28b62e0c7
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2685487

Change-Id: Iba8c4a27c628b0bb4b56acd63cf53b2ce93c27f1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-07 19:51:21 +00:00
David Anderson
384b22ce58 snapuserd: Add an IBlockServerFactory abstraction.
To avoid SnapshotHandler hardcoding specifics about dm-user, this patch
adds a factory interface, responsible for providing IBlockServerOpener
objects.

The test harness will use this to facilitate dm-user-less testing on
host devices.

Bug: 288273605
Test: snapuserd_test
Change-Id: Ifd33c28ee7076f30a8a90f745353893188f97a08
2023-08-07 12:01:24 -07:00
David Anderson
2cffe186ad snapuserd: Remove ambiguous BufferSink in workers.
BufferSink is not needed/used in all worker types, so move it explicitly
to MergeWorker. This also moves the sizeof(dm_user_header) computation
to BufferSink::Initialize.

Bug: 288273605
Test: snapuserd_test
Change-Id: I8fcea6f0e587ca6d8672df5ec58c4d4d14d4b72e
2023-08-07 12:01:03 -07:00
Treehugger Robot
a28b62e0c7 Merge "Add snapuserd_ramdisk execute permission" into main 2023-08-07 18:46:33 +00:00
David Anderson
a392fa3c78 snapuserd: Remove dm-user specific code from ReadWorker.
This uses the new IBlockServer abstraction layer instead.

Bug: 288273605
Test: snapuserd_test
Change-Id: Ie9a781e44da7447426706d4874644aabf1be1946
2023-08-07 11:25:55 -07:00
David Anderson
e9277f91f8 snapuserd: Add an IBlockServer abstraction around dm-user.
This adds the planned interface that will abstract around dm-user (for
now), and later ublk at which point it can be adjusted as needed.

This declares the interface and implements it, but does not yet switch
snapuserd to use it. The implementation is copied from read_worker.cpp.

Bug: 288273605
Test: snapuserd_test
Change-Id: I060788c91dba78e52d315b5616b84b37eaf4040f
2023-08-07 11:25:54 -07:00
David Anderson
76094b499c snapuserd: Rename snapuserd_merge to merge_worker.
This follows the recently added names read_worker and worker.

Bug: 288273605
Test: builds
Change-Id: Ie75e94405a018dd0068aa24aefd268adb1aee17e
2023-08-07 11:01:39 -07:00
Treehugger Robot
787fc16b90 Merge "core: fastboot: Fix data not being wiped on do_update" into main am: 405cbee131
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2696070

Change-Id: I95b2a59ebf48ec0d1fe10cf58c7e1996a75a3543
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-07 17:21:24 +00:00
Treehugger Robot
4f921a2253 Merge "Remove gettid declaration from cutils" into main am: 5d0aeaafb7
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2675701

Change-Id: Ia9aca9dc80182db04a6a94bec9838e18eed6b982
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-07 17:20:58 +00:00
Treehugger Robot
405cbee131 Merge "core: fastboot: Fix data not being wiped on do_update" into main 2023-08-07 17:11:03 +00:00
Treehugger Robot
5d0aeaafb7 Merge "Remove gettid declaration from cutils" into main 2023-08-07 16:23:30 +00:00
David Anderson
43b64966ae Merge "snapuserd: Move GetNumSectors call to snapuserd_server." into main am: bcb34d2c54
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2647683

Change-Id: I0b1dd13376a1de431d64ef7ef6fc25129533b69d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-07 15:49:56 +00:00
David Anderson
bcb34d2c54 Merge "snapuserd: Move GetNumSectors call to snapuserd_server." into main 2023-08-07 15:12:20 +00:00
Snehal Koukuntla
64f76a4460 Merge changes from topic "coverage-build" into main am: 6ac2c1693d
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2646884

Change-Id: I3f4d984e88a7698be1738d0e6793e54fb09c2d6f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-07 11:46:19 +00:00
Snehal Koukuntla
6ac2c1693d Merge changes from topic "coverage-build" into main
* changes:
  Add Coverage controller
  Coverage library on the NS side for the coverage controller
2023-08-07 10:53:44 +00:00
David Anderson
76f3af72a3 Merge "snapuserd: Split Tempdevice into a separate file." into main am: 1d8e349cce
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2640541

Change-Id: I413ad10511f86143d20b65932d5941b4e067196a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-07 03:40:12 +00:00
David Anderson
1d8e349cce Merge "snapuserd: Split Tempdevice into a separate file." into main 2023-08-07 02:55:24 +00:00
Alexander Koskovich
6367e8953a core: fastboot: Fix data not being wiped on do_update
* With platform-tools-34.0.4 if you try to wipe data
   as apart of the fastboot update command it will not
   work, will just reboot to userspace without running
   the wipe task.

Test: fastboot -w update image.zip, observe that data
      gets wiped. Also verified 'fastboot update image.zip'
      does *not* wipe data.
Change-Id: I57a2c64029fd4f78968324bdf60251e1e962b3fd
2023-08-05 00:39:10 -04:00
David Anderson
ee91991f25 Merge changes from topic "libsnapuserd_client" into main am: babf3a9874
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2647522

Change-Id: I6176a6477fcb23ac1ad65b5375fb54ba5adf83bb
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-04 21:06:51 +00:00
David Anderson
45798edba6 snapuserd: Rename libsnapshot_snapuserd to libsnapuserd_client. am: 75c5deed52
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2647521

Change-Id: I917ad3980532ea488c6bcbe9f0af8f9726a4dc96
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-04 21:06:47 +00:00
David Anderson
babf3a9874 Merge changes from topic "libsnapuserd_client" into main
* changes:
  snapuserd: Remove dependence on libfs_mgr.
  snapuserd: Rename libsnapshot_snapuserd to libsnapuserd_client.
2023-08-04 20:14:54 +00:00
Snehal
806e70bb94 Add Coverage controller
Bug: 289523068

Change-Id: I5b36c274acc7da4e2d6b9cf91409a7b1af5f0d34
2023-08-04 08:54:52 +00:00
Snehal
ed34b6e232 Coverage library on the NS side for the coverage controller
Bug: 289520358

Change-Id: I6c2c0e5db9e8d9a0edec93d2fb123d185c7c4416
2023-08-04 08:54:32 +00:00
Yi-Yo Chiang
207951385a Merge "libfstab: Optimize out C++ object copy" into main am: 656e28174b
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2688928

Change-Id: I0742d12929f78d9a436d0bdd67313563682e82ad
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-04 06:17:49 +00:00
Yi-Yo Chiang
656e28174b Merge "libfstab: Optimize out C++ object copy" into main 2023-08-04 05:29:48 +00:00
Yi-Yo Chiang
3cffba1bed Merge "init: Use libfs_mgr kernel cmdline parser" into main am: 63a3f34e4c
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2687407

Change-Id: I774523069e97413b11d23bb28491f907e7ec6c48
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-04 04:22:42 +00:00
Yi-Yo Chiang
18cea8df37 Merge "remount: Replace ServiceManager::getService with checkService" into main am: 4131a3afd1
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2690886

Change-Id: I0edade2adc78401e6f5291d1a2a579ac102d2087
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-04 04:22:27 +00:00
Yi-Yo Chiang
63a3f34e4c Merge "init: Use libfs_mgr kernel cmdline parser" into main 2023-08-04 03:46:07 +00:00
Yi-Yo Chiang
4131a3afd1 Merge "remount: Replace ServiceManager::getService with checkService" into main 2023-08-04 03:31:33 +00:00
David Anderson
48d1c39da7 snapuserd: Move GetNumSectors call to snapuserd_server.
Calling this in snapuserd_core fails when the base path is a regular
file. Since the value is only read once, just call it from
snapuserd_server instead, which also means we don't have to add an
S_ISBLK check here.

Bug: 288273605
Test: snapuserd_test
Change-Id: Ic26bf807b24611f2d97829d1b4eb1d0ede2feb6a
2023-08-03 16:24:26 -07:00
David Anderson
95f46b0758 snapuserd: Split Tempdevice into a separate file.
Bug: 288273605
Test: snapuserd_test
Change-Id: I3f1b01de8986d22de03bb31355ec09fe48c9204b
2023-08-03 16:15:37 -07:00
David Anderson
c132bf80ae snapuserd: Remove dependence on libfs_mgr.
The only function we use from libfs_mgr is WaitForFile, so factor that
out into libfs_mgr_file_wait. libfs_mgr has too much dependence on AOSP
internals to build on the host.

Bug: 288273605
Test: builds
Change-Id: I8e5eb4075ae01b9ca64074422171a487179e7943
2023-08-03 16:15:34 -07:00
David Anderson
75c5deed52 snapuserd: Rename libsnapshot_snapuserd to libsnapuserd_client.
We don't need this on the host, since the host will not be running
snapuserd as a server. Rename it for clarity and remove it where we can.

Bug: 288273605
Test: snapuserd_test
Change-Id: I679ef668a89411c670fea8d3b758bde589623548
2023-08-03 16:15:33 -07:00
Tomasz Wasilczyk
21a0716613 Remove gettid declaration from cutils
Bug: 289414897
Test: it builds
Change-Id: I22d93406cf065c0e3c7d94e800763974d228ee21
2023-08-03 22:16:12 +00:00
David Anderson
c7b9ece0c4 Merge "libsnapshot: Fix missing return keyword in error path." into main am: c8ce6347db
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2691212

Change-Id: I223ac6defc12d300f9cee99cdb6c46831487343f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-03 19:52:25 +00:00