arc: Add a new D-Bus service arcvm_data_migrator

This patch adds a skeleton D-Bus service for the virtio-blk /data
migration.
It has one method StartMigration which is called by Chrome to trigger
the migration, and it also sends out a signal DataMigrationProgress to
report the migration progress back to Chrome.
Currently, StartMigration does nothing but sending back the migration
completion signal to Chrome.

Chrome-side CL: CL:3932405
ebuild CL: CL:3932404

BUG=b:251764421
TEST=Manually build and test with CL:3932405.

Change-Id: I7aeb15df7f6b4cb935ff396cb6aba21e4b5bc000
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/3963808
Reviewed-by: Yusuke Sato <yusukes@chromium.org>
Tested-by: Momoko Hattori <momohatt@chromium.org>
Commit-Queue: Momoko Hattori <momohatt@chromium.org>
Reviewed-by: Eric Caruso <ejcaruso@chromium.org>
NOKEYCHECK=True
GitOrigin-RevId: 1ba2e265f0c907176ab1f06dd8b049ba9ac423b9
diff --git a/BUILD.gn b/BUILD.gn
index a69fb16..8e3c732 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -10,6 +10,7 @@
     ":system_api-anomaly_detector-protos",
     ":system_api-arc-goprotos",
     ":system_api-arc-protos",
+    ":system_api-arcvm_data_migrator-protos",
     ":system_api-attestation-goprotos",
     ":system_api-attestation-protos",
     ":system_api-authpolicy-protos",
@@ -668,3 +669,10 @@
   sources = [ "${proto_in_dir}/private_computing_service.proto" ]
   standalone = true
 }
+
+proto_library("system_api-arcvm_data_migrator-protos") {
+  proto_in_dir = "dbus/arcvm_data_migrator"
+  proto_out_dir = "include/arcvm_data_migrator/proto_bindings"
+  sources = [ "${proto_in_dir}/arcvm_data_migrator.proto" ]
+  standalone = true
+}
diff --git a/dbus/arcvm_data_migrator/arcvm_data_migrator.proto b/dbus/arcvm_data_migrator/arcvm_data_migrator.proto
new file mode 100644
index 0000000..76ed9fb
--- /dev/null
+++ b/dbus/arcvm_data_migrator/arcvm_data_migrator.proto
@@ -0,0 +1,37 @@
+// Copyright 2022 The ChromiumOS Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+syntax = "proto3";
+option optimize_for = LITE_RUNTIME;
+
+// This file defines messages used by arc::data_migrator.
+package arc.data_migrator;
+
+// The message that is sent from Chrome with StartMigration call.
+message StartMigrationRequest {}
+
+// Status code for the message DataMigrationProgress below.
+enum DataMigrationStatus {
+  // The migration completed successfully.
+  DATA_MIGRATION_SUCCESS = 0;
+  // The migration was terminated with a failure.
+  DATA_MIGRATION_FAILED = 1;
+  // The migration is in progress.
+  DATA_MIGRATION_IN_PROGRESS = 2;
+}
+
+// The message that comes with DataMigrationProgress signal.
+message DataMigrationProgress {
+  // The status of the migration.
+  DataMigrationStatus status = 1;
+
+  // The amount of bytes that we've migrated over. This field is
+  // undefined when |status| is not DATA_MIGRATION_IN_PROGRESS.
+  uint64 current_bytes = 2;
+
+  // The total amount of bytes that need to be migrated, including what
+  // has been migrated. This field is undefined when |status| is not
+  // DATA_MIGRATION_IN_PROGRESS.
+  uint64 total_bytes = 3;
+}
diff --git a/dbus/arcvm_data_migrator/dbus-constants.h b/dbus/arcvm_data_migrator/dbus-constants.h
new file mode 100644
index 0000000..fe74fed
--- /dev/null
+++ b/dbus/arcvm_data_migrator/dbus-constants.h
@@ -0,0 +1,24 @@
+// Copyright 2022 The ChromiumOS Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSTEM_API_DBUS_ARCVM_DATA_MIGRATOR_DBUS_CONSTANTS_H_
+#define SYSTEM_API_DBUS_ARCVM_DATA_MIGRATOR_DBUS_CONSTANTS_H_
+
+namespace arc::data_migrator {
+
+constexpr char kArcVmDataMigratorInterface[] = "org.chromium.ArcVmDataMigrator";
+constexpr char kArcVmDataMigratorServicePath[] =
+    "/org/chromium/ArcVmDataMigrator";
+constexpr char kArcVmDataMigratorServiceName[] =
+    "org.chromium.ArcVmDataMigrator";
+
+// Method names.
+constexpr char kStartMigrationMethod[] = "StartMigration";
+
+// Signal names.
+constexpr char kMigrationProgressSignal[] = "DataMigrationProgress";
+
+}  // namespace arc::data_migrator
+
+#endif  // SYSTEM_API_DBUS_ARCVM_DATA_MIGRATOR_DBUS_CONSTANTS_H_
diff --git a/dbus/service_constants.h b/dbus/service_constants.h
index e44c776..862ae0a 100644
--- a/dbus/service_constants.h
+++ b/dbus/service_constants.h
@@ -11,6 +11,7 @@
 // Chromium OS and Chromium environment.
 #include "anomaly_detector/dbus-constants.h"
 #include "arc-data-snapshotd/dbus-constants.h"
+#include "arcvm_data_migrator/dbus-constants.h"
 #include "audio/dbus-constants.h"
 #include "authpolicy/dbus-constants.h"
 #include "biod/dbus-constants.h"
diff --git a/system_api.pc b/system_api.pc
index 3f03c68..f006761 100644
--- a/system_api.pc
+++ b/system_api.pc
@@ -1,4 +1,4 @@
 Name: system_api
 Description: Protobuffers and headers shared by Chromium OS and Chromium.
 Version: 0.1
-Libs: -lsystem_api-hps-protos -lsystem_api-power_manager-protos -lsystem_api-authpolicy-protos -lsystem_api-biod-protos -lsystem_api-protos -lsystem_api-kerberos-protos -lsystem_api-login_manager-protos -lsystem_api-lorgnette-protos -lsystem_api-smbprovider-protos -lsystem_api-vm_concierge-protos -lsystem_api-vm_applications-protos -lsystem_api-vm_disk_management-protos -lsystem_api-vm_launch-protos -lsystem_api-vm_sk_forwarding-protos -lsystem_api-vm_cicerone-protos -lsystem_api-seneschal-protos -lsystem_api-oobe_config-protos -lsystem_api-runtime_probe-protos -lsystem_api-dlcservice-protos -lsystem_api-update_engine-protos -lsystem_api-vm_plugin_dispatcher-protos -lsystem_api-u2f-protos -lsystem_api-chunneld-protos -lsystem_api-system_proxy-protos -lsystem_api-vm_permission_service-protos -lsystem_api-anomaly_detector-protos -lsystem_api-minios-protos -lsystem_api-dlp-protos -lsystem_api-rmad-protos -lsystem_api-fusebox-protos -lsystem_api-privacy_screen-protos -lsystem_api-cdm_oemcrypto-protos -lsystem_api-ml-protos -lsystem_api-lvmd-protos -lsystem_api-shadercached-protos -lsystem_api-spaced-protos -lsystem_api-imageloader-protos -lsystem_api -lsystem_api-arc-protos -lsystem_api-private_computing-protos
+Libs: -lsystem_api-hps-protos -lsystem_api-power_manager-protos -lsystem_api-authpolicy-protos -lsystem_api-biod-protos -lsystem_api-protos -lsystem_api-kerberos-protos -lsystem_api-login_manager-protos -lsystem_api-lorgnette-protos -lsystem_api-smbprovider-protos -lsystem_api-vm_concierge-protos -lsystem_api-vm_applications-protos -lsystem_api-vm_disk_management-protos -lsystem_api-vm_launch-protos -lsystem_api-vm_sk_forwarding-protos -lsystem_api-vm_cicerone-protos -lsystem_api-seneschal-protos -lsystem_api-oobe_config-protos -lsystem_api-runtime_probe-protos -lsystem_api-dlcservice-protos -lsystem_api-update_engine-protos -lsystem_api-vm_plugin_dispatcher-protos -lsystem_api-u2f-protos -lsystem_api-chunneld-protos -lsystem_api-system_proxy-protos -lsystem_api-vm_permission_service-protos -lsystem_api-anomaly_detector-protos -lsystem_api-minios-protos -lsystem_api-dlp-protos -lsystem_api-rmad-protos -lsystem_api-fusebox-protos -lsystem_api-privacy_screen-protos -lsystem_api-cdm_oemcrypto-protos -lsystem_api-ml-protos -lsystem_api-lvmd-protos -lsystem_api-shadercached-protos -lsystem_api-spaced-protos -lsystem_api-imageloader-protos -lsystem_api -lsystem_api-arc-protos -lsystem_api-private_computing-protos -lsystem_api-arcvm_data_migrator-protos