[devmgr-launcher] Add bootdata vmo arg

devmgr_launcher::Args was changed to be move only, so callsites were
updated as necessary.

Tested: runtests -t driver-tests
Change-Id: Iccf9d422bb2186a221987d0bcff017fba9bda23c
diff --git a/system/ulib/devmgr-integration-test/include/lib/devmgr-integration-test/fixture.h b/system/ulib/devmgr-integration-test/include/lib/devmgr-integration-test/fixture.h
index b6237b8..b33cb04 100644
--- a/system/ulib/devmgr-integration-test/include/lib/devmgr-integration-test/fixture.h
+++ b/system/ulib/devmgr-integration-test/include/lib/devmgr-integration-test/fixture.h
@@ -25,7 +25,7 @@
 
     // Launch a new isolated devmgr.  The instance will be destroyed when
     // |*out|'s dtor runs.
-    static zx_status_t Create(const devmgr_launcher::Args& args,
+    static zx_status_t Create(devmgr_launcher::Args args,
                               fbl::unique_ptr<IsolatedDevmgr>* out);
 
     // Get a fd to the root of the isolate devmgr's devfs.  This fd
diff --git a/system/ulib/devmgr-integration-test/launcher.cpp b/system/ulib/devmgr-integration-test/launcher.cpp
index 7598488..bb5c9c1 100644
--- a/system/ulib/devmgr-integration-test/launcher.cpp
+++ b/system/ulib/devmgr-integration-test/launcher.cpp
@@ -33,12 +33,12 @@
     }
 }
 
-zx_status_t IsolatedDevmgr::Create(const devmgr_launcher::Args& args,
+zx_status_t IsolatedDevmgr::Create(devmgr_launcher::Args args,
                                    fbl::unique_ptr<IsolatedDevmgr>* out) {
     auto devmgr = fbl::make_unique<IsolatedDevmgr>();
 
     zx::channel devfs;
-    zx_status_t status = devmgr_launcher::Launch(args, &devmgr->job_, &devfs);
+    zx_status_t status = devmgr_launcher::Launch(std::move(args), &devmgr->job_, &devfs);
     if (status != ZX_OK) {
         return status;
     }
diff --git a/system/ulib/devmgr-launcher/include/lib/devmgr-launcher/launch.h b/system/ulib/devmgr-launcher/include/lib/devmgr-launcher/launch.h
index ac06dbd..c7655ff 100644
--- a/system/ulib/devmgr-launcher/include/lib/devmgr-launcher/launch.h
+++ b/system/ulib/devmgr-launcher/include/lib/devmgr-launcher/launch.h
@@ -7,6 +7,7 @@
 #include <fbl/vector.h>
 #include <lib/zx/channel.h>
 #include <lib/zx/job.h>
+#include <lib/zx/vmo.h>
 
 namespace devmgr_launcher {
 
@@ -23,12 +24,15 @@
     // should be bound to the sys_device (the top-level device for most
     // devices).  If nullptr, this uses devmgr's default.
     const char* sys_device_driver;
+    // VMO containing ZBI passed in from bootloader. Devmgr will simply
+    // forward this along to the sys_device as well as the fs_host.
+    zx::vmo bootdata;
 };
 
 // Launches an isolated devmgr, passing the given |args| to it.
 //
 // Returns its containing job and a channel to the root of its devfs.
 // To destroy the devmgr, issue |devmgr_job->kill()|.
-zx_status_t Launch(const Args& args, zx::job* devmgr_job, zx::channel* devfs_root);
+zx_status_t Launch(Args args, zx::job* devmgr_job, zx::channel* devfs_root);
 
 } // namespace devmgr_launcher
diff --git a/system/ulib/devmgr-launcher/launcher.cpp b/system/ulib/devmgr-launcher/launcher.cpp
index a90763f..287d2fd 100644
--- a/system/ulib/devmgr-launcher/launcher.cpp
+++ b/system/ulib/devmgr-launcher/launcher.cpp
@@ -28,7 +28,7 @@
 
 namespace devmgr_launcher {
 
-zx_status_t Launch(const Args& args, zx::job* devmgr_job, zx::channel* devfs_root) {
+zx_status_t Launch(Args args, zx::job* devmgr_job, zx::channel* devfs_root) {
     // Create containing job (and copy to send to devmgr)
     zx::job job, job_copy;
     zx_status_t status = zx::job::create(*zx::job::default_job(), 0, &job);
@@ -83,24 +83,29 @@
     }
     argv.push_back(nullptr);
 
-    fdio_spawn_action_t actions[] = {
-        {
-            .action = FDIO_SPAWN_ACTION_SET_NAME,
-            .name = { .data = "test-devmgr" },
-        },
-        {
+    fbl::Vector<fdio_spawn_action_t> actions;
+    actions.push_back(fdio_spawn_action_t{
+        .action = FDIO_SPAWN_ACTION_SET_NAME,
+        .name = { .data = "test-devmgr" },
+    });
+    actions.push_back(fdio_spawn_action_t{
+        .action = FDIO_SPAWN_ACTION_ADD_HANDLE,
+        .h = { .id = PA_HND(PA_JOB_DEFAULT, 0), .handle = job_copy.release() },
+    });
+    actions.push_back(fdio_spawn_action_t{
+        .action = FDIO_SPAWN_ACTION_ADD_HANDLE,
+        .h = { .id = DEVMGR_LAUNCHER_DEVFS_ROOT_HND, .handle = devfs_server.release() },
+    });
+    actions.push_back(fdio_spawn_action_t{
+        .action = FDIO_SPAWN_ACTION_ADD_NS_ENTRY,
+        .ns = { .prefix = "/boot", .handle = bootfs_client.release() },
+    });
+    if (args.bootdata) {
+        actions.push_back(fdio_spawn_action_t{
             .action = FDIO_SPAWN_ACTION_ADD_HANDLE,
-            .h = { .id = PA_HND(PA_JOB_DEFAULT, 0), .handle = job_copy.release() },
-        },
-        {
-            .action = FDIO_SPAWN_ACTION_ADD_HANDLE,
-            .h = { .id = DEVMGR_LAUNCHER_DEVFS_ROOT_HND, .handle = devfs_server.release() },
-        },
-        {
-            .action = FDIO_SPAWN_ACTION_ADD_NS_ENTRY,
-            .ns = { .prefix = "/boot", .handle = bootfs_client.release() },
-        },
-    };
+            .h = { .id = PA_HND(PA_VMO_BOOTDATA, 0), .handle = args.bootdata.release() },
+        });
+    }
 
     zx::process new_process;
     status = fdio_spawn_etc(job.get(),
@@ -108,8 +113,8 @@
                             kDevmgrPath,
                             argv.get(),
                             nullptr /* environ */,
-                            fbl::count_of(actions),
-                            actions,
+                            actions.size(),
+                            actions.get(),
                             new_process.reset_and_get_address(),
                             nullptr /* err_msg */);
     if (status != ZX_OK) {
diff --git a/system/utest/driver-tests/main.cpp b/system/utest/driver-tests/main.cpp
index 12592d7..a746e99 100644
--- a/system/utest/driver-tests/main.cpp
+++ b/system/utest/driver-tests/main.cpp
@@ -159,7 +159,7 @@
     auto args = IsolatedDevmgr::DefaultArgs();
 
     fbl::unique_ptr<IsolatedDevmgr> devmgr;
-    zx_status_t status = IsolatedDevmgr::Create(args, &devmgr);
+    zx_status_t status = IsolatedDevmgr::Create(std::move(args), &devmgr);
     if (status != ZX_OK) {
         printf("driver-tests: failed to create isolated devmgr\n");
         return -1;