trusty: launch_args and `acloud pull` support

- support launch_args
- support retrieving log file with `acloud pull`

Bug: 401710433
Test: acloud-dev create --avd-type trusty
      --trusty-build-id=P81247753 --local-image
      --launch-args "--extra-linux-args trusty-log.log_to_dmesg=always"
Change-Id: Ib10bdc3052df2921c4a88b9c1fedad31d3ff9db0
diff --git a/public/actions/remote_instance_trusty_device_factory.py b/public/actions/remote_instance_trusty_device_factory.py
index 9e412a0..4698c7a 100644
--- a/public/actions/remote_instance_trusty_device_factory.py
+++ b/public/actions/remote_instance_trusty_device_factory.py
@@ -35,14 +35,24 @@
 
 logger = logging.getLogger(__name__)
 _CONFIG_JSON_FILENAME = "config.json"
-_REMOTE_STDOUT_PATH = "kernel.log"
-_REMOTE_STDERR_PATH = "qemu_trusty_err.log"
+
+# log files under REMOTE_LOG_FOLDER in order to
+# enable `acloud pull` to retrieve them
+_REMOTE_LOG_FOLDER = constants.REMOTE_LOG_FOLDER
+_REMOTE_STDOUT_PATH = f"{_REMOTE_LOG_FOLDER}/kernel.log"
+_REMOTE_STDERR_PATH = f"{_REMOTE_LOG_FOLDER}/qemu_trusty_err.log"
+
+# below Trusty image archive is generated by
+# branch:aosp-trusty-main / target: qemu_generic_arm64_gicv3* targets
 _TRUSTY_IMAGE_PACKAGE = "trusty_image_package.tar.gz"
+
+# below Host tools archive is generated by:
+# branch: git_main-throttled-nightly / target: qemu_trusty_arm64
 _TRUSTY_HOST_PACKAGE_DIR = "trusty-host_package"
 _TRUSTY_HOST_TARBALL = "trusty-host_package.tar.gz"
 
 # Default Trusty image build. This does not depend on the android branch.
-_DEFAULT_TRUSTY_BUILD_BRANCH = "aosp-trusty-master"
+_DEFAULT_TRUSTY_BUILD_BRANCH = "aosp-trusty-main"
 _DEFAULT_TRUSTY_BUILD_TARGET = "qemu_generic_arm64_test_debug"
 
 
@@ -239,14 +249,17 @@
     @utils.TimeExecute(function_description="Starting Trusty")
     def _StartTrusty(self):
         """Start the model on the GCE instance."""
+        self._ssh.Run(f"mkdir -p {_REMOTE_LOG_FOLDER}")
 
         # We use an explicit subshell so we can run this command in the
         # background.
         cmd = "-- sh -c " + shlex.quote(
             shlex.quote(
                 f"{cvd_utils.GCE_BASE_DIR}/run.py "
-                f"--config={_CONFIG_JSON_FILENAME} "
-                f"> {_REMOTE_STDOUT_PATH} 2> {_REMOTE_STDERR_PATH} &"
+                f"--verbose --config={_CONFIG_JSON_FILENAME} "
+                f"{self._avd_spec.launch_args} "
+                f"> {_REMOTE_STDOUT_PATH} "
+                f"2> {_REMOTE_STDERR_PATH} &"
             )
         )
         self._ssh.Run(cmd, self._avd_spec.boot_timeout_secs or 30, retry=0)
diff --git a/public/actions/remote_instance_trusty_device_factory_test.py b/public/actions/remote_instance_trusty_device_factory_test.py
index d61804d..4889fba 100644
--- a/public/actions/remote_instance_trusty_device_factory_test.py
+++ b/public/actions/remote_instance_trusty_device_factory_test.py
@@ -170,7 +170,6 @@
             ]
         )
 
-
     @mock.patch.object(remote_instance_trusty_device_factory.RemoteInstanceDeviceFactory,
                        "CreateGceInstance")
     @mock.patch("acloud.public.actions.remote_instance_trusty_device_factory."
@@ -201,11 +200,14 @@
         factory.CreateInstance()
         mock_create_gce_instance.assert_called_once()
         mock_cvd_utils.UploadArtifacts.assert_called_once()
-        # First call is unpacking image archive
-        self.assertEqual(mock_ssh.Run.call_count, 2)
+        # First call is unpacking host package
+        # then unpacking image archive
+        # and finally run
+        self.assertEqual(mock_ssh.Run.call_count, 3)
         self.assertIn(
-            "gce_base_dir/run.py --config=config.json",
-            mock_ssh.Run.call_args[0][0])
+            "gce_base_dir/run.py --verbose --config=config.json",
+            mock_ssh.Run.call_args[0][0],
+        )
 
         self.assertEqual(3, len(factory.GetLogs().get("instance")))