[remoting] Implement host migration for Linux [chromium/src : main]

0 views
Skip to first unread message

Yuwei Huang (Gerrit)

unread,
Apr 22, 2026, 7:32:19 PM (2 days ago) Apr 22
to chromium...@chromium.org, chromotin...@chromium.org

Yuwei Huang added 17 comments

File remoting/host/linux/migrate_host_main.cc
Line 49, Patchset 2 (Latest):class HostType {
Yuwei Huang . unresolved

Can you move these new classes to `remoting/host/linux/host_types.h`, and maybe add some comments?

Line 57, Patchset 2 (Latest): std::cerr << " " << name << ": " << type->description() << "\n";
Yuwei Huang . unresolved

Please print in this style:

```
Supported host types:
gdm-managed
Blah blah blah blah...

single-process
Blah blah blah blah...
```
Line 69, Patchset 2 (Latest): std::string_view description() const override {
Yuwei Huang . unresolved

The description should have more details. The single-process host is run as the user, and supports X11.

Line 78, Patchset 2 (Latest): return "GDM-managed multi-process host";
Yuwei Huang . unresolved

It should have more details. Point out that it only supports GNOME 49+ in Wayland mode, and you will be presented the login screen for the first time you connect. Also, it doesn't support running multiple hosts for different users.

Line 88, Patchset 2 (Latest): {"single-process", new SingleProcessHostType()},
Yuwei Huang . unresolved

This will possibly trigger ASAN/TSAN errors in the trybots. You may need NoDestructors for these objects as well.

Line 94, Patchset 2 (Latest):int ControlService(const std::string& unit_name, bool enable) {
Yuwei Huang . unresolved

We never enable a service with this method, right? Can you unify this with `sudo_disable_cmd` below, and maybe introduce `int DisableService(unit_name)`, which decides whether sudo should be used depending on whether `getuid() == 0`.

Line 125, Patchset 2 (Latest): PairingRegistryDelegateLinux pairing_delegate;
Yuwei Huang . unresolved

Comment that the default constructor uses the multi-process pairing registry path because it is run as root.

Line 144, Patchset 2 (Latest):int MigrateHostMain(int argc, char** argv) {
Yuwei Huang . unresolved

This is a huge main function. Can you restructure the code a bit. Maybe introduce the following helper functions: `MigrateToMultiProcess`, `MigrateToSingleProcess`.

Do identify other chance for improving code structure.

Line 165, Patchset 2 (Latest): std::cerr << "Usage: migrate_host <host_type> [options]\n";
Yuwei Huang . unresolved

Print another `\n` to separate from the "Supported host types:" below.

Line 203, Patchset 2 (Latest): base::CommandLine sudo_command_line(base::FilePath("/usr/bin/sudo"));
Yuwei Huang . unresolved

Maybe it's easier to deal with the raw `argv()` then CommandLine.

Line 218, Patchset 2 (Latest): base::LaunchProcess(sudo_command_line, base::LaunchOptions());
Yuwei Huang . unresolved

Would it be easier to just run `execvp`?

Line 218, Patchset 2 (Latest): base::LaunchProcess(sudo_command_line, base::LaunchOptions());
Yuwei Huang . unresolved

You probably need `allow_new_privs` for sudo.

Line 234, Patchset 2 (Latest): struct passwd* pw = getpwnam(user_name.c_str());
Yuwei Huang . unresolved

Consider using remoting/base/passwd_utils.h.

Line 283, Patchset 2 (Latest): // Disable single-process service.
Yuwei Huang . unresolved

Comment that SetConfigAndStart() already stops the sing-process host (because systemd unit defines a Conflict) but it doesn't disable it, so we disable here to prevent it from running after reboot.

Line 349, Patchset 2 (Latest): // Disable multi-process service.
Yuwei Huang . unresolved

Ditto. Commend that the multi-process service was stopped but not disabled.

File remoting/host/setup/daemon_controller_delegate_linux_multi_process.cc
Line 29, Patchset 2 (Latest):// static
Yuwei Huang . unresolved

Please move these below the anonymous namespace.

File remoting/host/setup/daemon_controller_delegate_linux_single_process.cc
Line 54, Patchset 2 (Latest):base::FilePath DaemonControllerDelegateLinuxSingleProcess::GetConfigPath() {
Yuwei Huang . unresolved

Move this below the anonymous namespace?

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I0579043d898f5070aeeb7b713b4ecf8ec5c410b3
Gerrit-Change-Number: 7787730
Gerrit-PatchSet: 2
Gerrit-Owner: Yuwei Huang <yuw...@chromium.org>
Gerrit-Comment-Date: Wed, 22 Apr 2026 23:32:10 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Yuwei Huang (Gerrit)

unread,
Apr 22, 2026, 8:19:09 PM (2 days ago) Apr 22
to Chromium LUCI CQ, chromium...@chromium.org, chromotin...@chromium.org

Yuwei Huang added 22 comments

File remoting/host/linux/host_types.h
Line 34, Patchset 7 (Latest):class SingleProcessHostType : public HostType {
Yuwei Huang . unresolved

These can probably be in the .cc file.

File remoting/host/linux/migrate_host_main.cc
Line 49, Patchset 2:class HostType {
Yuwei Huang . resolved

Can you move these new classes to `remoting/host/linux/host_types.h`, and maybe add some comments?

Yuwei Huang

Done

Line 57, Patchset 2: std::cerr << " " << name << ": " << type->description() << "\n";
Yuwei Huang . resolved

Please print in this style:

```
Supported host types:
gdm-managed
Blah blah blah blah...

single-process
Blah blah blah blah...
```
Yuwei Huang

Done

Line 69, Patchset 2: std::string_view description() const override {
Yuwei Huang . resolved

The description should have more details. The single-process host is run as the user, and supports X11.

Yuwei Huang

Done

Line 78, Patchset 2: return "GDM-managed multi-process host";
Yuwei Huang . resolved

It should have more details. Point out that it only supports GNOME 49+ in Wayland mode, and you will be presented the login screen for the first time you connect. Also, it doesn't support running multiple hosts for different users.

Yuwei Huang

Done

Line 88, Patchset 2: {"single-process", new SingleProcessHostType()},
Yuwei Huang . resolved

This will possibly trigger ASAN/TSAN errors in the trybots. You may need NoDestructors for these objects as well.

Yuwei Huang

Done

Line 94, Patchset 2:int ControlService(const std::string& unit_name, bool enable) {
Yuwei Huang . resolved

We never enable a service with this method, right? Can you unify this with `sudo_disable_cmd` below, and maybe introduce `int DisableService(unit_name)`, which decides whether sudo should be used depending on whether `getuid() == 0`.

Yuwei Huang

Done

Line 111, Patchset 7 (Latest): argv.push_back(sudo_path.data());
Yuwei Huang . unresolved

Maybe just use `std::vector<const char*>`, push `"/usr/bin/sudo"` directly, then do a const_cast when calling `execvp`.

Line 114, Patchset 7 (Latest): for (size_t i = 0; i < original_argv.size(); ++i) {
argv.push_back(original_argv[i].data());
Yuwei Huang . unresolved

Please fix this WARNING reported by ClangTidy: check: modernize-loop-convert

use range-based for loop instead (https://clang.l...

check: modernize-loop-convert

use range-based for loop instead (https://clang.llvm.org/extra/clang-tidy/checks/modernize/loop-convert.html)

(Note: You can add `Skip-Clang-Tidy-Checks: modernize-loop-convert` footer to the CL description to skip the check)

(Lint observed on `linux-clang-tidy-rel`, but not on `android-clang-tidy-rel`)

Line 124, Patchset 7 (Latest):
Yuwei Huang . unresolved

Maybe comment that code below is run as root.

Line 125, Patchset 2: PairingRegistryDelegateLinux pairing_delegate;
Yuwei Huang . resolved

Comment that the default constructor uses the multi-process pairing registry path because it is run as root.

Yuwei Huang

Done

Line 144, Patchset 2:int MigrateHostMain(int argc, char** argv) {
Yuwei Huang . resolved

This is a huge main function. Can you restructure the code a bit. Maybe introduce the following helper functions: `MigrateToMultiProcess`, `MigrateToSingleProcess`.

Do identify other chance for improving code structure.

Yuwei Huang

Done

Line 165, Patchset 2: std::cerr << "Usage: migrate_host <host_type> [options]\n";
Yuwei Huang . resolved

Print another `\n` to separate from the "Supported host types:" below.

Yuwei Huang

Done

Line 171, Patchset 7 (Latest): std::move(*config), /*consent=*/true,
Yuwei Huang . unresolved

Comment that the `consent` parameter is not used in Linux, and the `usage_stats_consent` value in the host config is used instead.

Line 195, Patchset 7 (Latest): // Run sudo <this program> --get-multi-process-config
Yuwei Huang . unresolved

Explain that the privileged config files are only readable by root.

Line 203, Patchset 2: base::CommandLine sudo_command_line(base::FilePath("/usr/bin/sudo"));
Yuwei Huang . resolved

Maybe it's easier to deal with the raw `argv()` then CommandLine.

Yuwei Huang

Done

Line 218, Patchset 2: base::LaunchProcess(sudo_command_line, base::LaunchOptions());
Yuwei Huang . resolved

You probably need `allow_new_privs` for sudo.

Yuwei Huang

Done

Line 218, Patchset 2: base::LaunchProcess(sudo_command_line, base::LaunchOptions());
Yuwei Huang . resolved

Would it be easier to just run `execvp`?

Yuwei Huang

Done

Line 234, Patchset 2: struct passwd* pw = getpwnam(user_name.c_str());
Yuwei Huang . resolved

Consider using remoting/base/passwd_utils.h.

Yuwei Huang

Done

Line 237, Patchset 7 (Latest): host_config->Clone(), /*consent=*/true,
Yuwei Huang . unresolved

Comment that the `consent` parameter is not used in Linux, and the `usage_stats_consent` value in the host config is used instead.

Line 283, Patchset 2: // Disable single-process service.
Yuwei Huang . resolved

Comment that SetConfigAndStart() already stops the sing-process host (because systemd unit defines a Conflict) but it doesn't disable it, so we disable here to prevent it from running after reboot.

Yuwei Huang

Done

Line 349, Patchset 2: // Disable multi-process service.
Yuwei Huang . resolved

Ditto. Commend that the multi-process service was stopped but not disabled.

Yuwei Huang

Done

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I0579043d898f5070aeeb7b713b4ecf8ec5c410b3
Gerrit-Change-Number: 7787730
Gerrit-PatchSet: 7
Gerrit-Owner: Yuwei Huang <yuw...@chromium.org>
Gerrit-Reviewer: Yuwei Huang <yuw...@chromium.org>
Gerrit-Comment-Date: Thu, 23 Apr 2026 00:19:03 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Yuwei Huang <yuw...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Yuwei Huang (Gerrit)

unread,
Apr 22, 2026, 8:41:05 PM (2 days ago) Apr 22
to Chromium LUCI CQ, chromium...@chromium.org, chromotin...@chromium.org

Yuwei Huang voted and added 9 comments

Votes added by Yuwei Huang

Commit-Queue+1

9 comments

File remoting/host/linux/host_types.h
Line 34, Patchset 7:class SingleProcessHostType : public HostType {
Yuwei Huang . resolved

These can probably be in the .cc file.

Yuwei Huang

Done

File remoting/host/linux/migrate_host_main.cc
Line 111, Patchset 7: argv.push_back(sudo_path.data());
Yuwei Huang . resolved

Maybe just use `std::vector<const char*>`, push `"/usr/bin/sudo"` directly, then do a const_cast when calling `execvp`.

Yuwei Huang

Done

Line 114, Patchset 7: for (size_t i = 0; i < original_argv.size(); ++i) {
argv.push_back(original_argv[i].data());
Yuwei Huang . resolved

Please fix this WARNING reported by ClangTidy: check: modernize-loop-convert

use range-based for loop instead (https://clang.l...

check: modernize-loop-convert

use range-based for loop instead (https://clang.llvm.org/extra/clang-tidy/checks/modernize/loop-convert.html)

(Note: You can add `Skip-Clang-Tidy-Checks: modernize-loop-convert` footer to the CL description to skip the check)

(Lint observed on `linux-clang-tidy-rel`, but not on `android-clang-tidy-rel`)

Yuwei Huang

Done

Line 124, Patchset 7:
Yuwei Huang . resolved

Maybe comment that code below is run as root.

Yuwei Huang

Done

Line 171, Patchset 7: std::move(*config), /*consent=*/true,
Yuwei Huang . resolved

Comment that the `consent` parameter is not used in Linux, and the `usage_stats_consent` value in the host config is used instead.

Yuwei Huang

Done

Line 195, Patchset 7: // Run sudo <this program> --get-multi-process-config
Yuwei Huang . resolved

Explain that the privileged config files are only readable by root.

Yuwei Huang

Done

Line 237, Patchset 7: host_config->Clone(), /*consent=*/true,
Yuwei Huang . resolved

Comment that the `consent` parameter is not used in Linux, and the `usage_stats_consent` value in the host config is used instead.

Yuwei Huang

Done

File remoting/host/setup/daemon_controller_delegate_linux_multi_process.cc
Line 29, Patchset 2:// static
Yuwei Huang . resolved

Please move these below the anonymous namespace.

Yuwei Huang

Done

File remoting/host/setup/daemon_controller_delegate_linux_single_process.cc
Line 54, Patchset 2:base::FilePath DaemonControllerDelegateLinuxSingleProcess::GetConfigPath() {
Yuwei Huang . resolved

Move this below the anonymous namespace?

Yuwei Huang

Done

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I0579043d898f5070aeeb7b713b4ecf8ec5c410b3
    Gerrit-Change-Number: 7787730
    Gerrit-PatchSet: 10
    Gerrit-Owner: Yuwei Huang <yuw...@chromium.org>
    Gerrit-Reviewer: Yuwei Huang <yuw...@chromium.org>
    Gerrit-Comment-Date: Thu, 23 Apr 2026 00:40:59 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Yuwei Huang <yuw...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Yuwei Huang (Gerrit)

    unread,
    4:43 AM (1 hour ago) 4:43 AM
    to Chromium LUCI CQ, chromium...@chromium.org, chromotin...@chromium.org

    Yuwei Huang abandoned this change.

    View Change

    Abandoned

    Yuwei Huang abandoned this change

    Related details

    Attention set is empty
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: abandon
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I0579043d898f5070aeeb7b713b4ecf8ec5c410b3
    Gerrit-Change-Number: 7787730
    Gerrit-PatchSet: 12
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages