Update qemu_edu to new Driver start arg fdf_dispatcher_t,

Also roll new SDK.

Fixed: 99549

Change-Id: Ib6dbded01e98326c1a018c9d7d14a375cb1b5853
Reviewed-on: https://fuchsia-review.googlesource.com/c/sdk-samples/drivers/+/674523
Reviewed-by: Renato Mangini Dias <mangini@google.com>
Reviewed-by: Suraj Malhotra <surajmalhotra@google.com>
Commit-Queue: Renato Mangini Dias <mangini@google.com>
diff --git a/README.md b/README.md
index b973729..84ad6e4 100644
--- a/README.md
+++ b/README.md
@@ -47,21 +47,8 @@
    tools/ffx product-bundle get workstation.qemu-x64
    ```
 
-   Note: drivers can only be loaded on demand if a specific kernel command line
-   argument is used. Ideally, the development images should have this set, but
-   until they do, please issue the following command to add the missing argument
-   to the emulator invocation line:
-
    ```
-   f=~/.local/share/Fuchsia/ffx/pbms/$(tools/ffx sdk version)/workstation.qemu-x64/images/obj/build/images/emulator_flags.json.template \
-     grep -q "devmgr.enable-ephemeral=true" $f || \
-     sed -i'' '/^\s*"kernel_args": \[/a "devmgr.enable-ephemeral=true",' $f
-   ```
-
-   Now you can start the emulator:
-
-   ```
-   tools/ffx emu start -H workstation.qemu-x64
+   tools/ffx emu start -H workstation.qemu-x64 -c devmgr.enable-ephemeral=true
    ```
 
    The product bundle comes with on-demand packages in a separate repository.
diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel
index df1c27b..4077c90 100644
--- a/WORKSPACE.bazel
+++ b/WORKSPACE.bazel
@@ -34,12 +34,12 @@
 
 fuchsia_sdk_repository(
     name = "fuchsia_sdk",
-    cipd_tag = "version:8.20220427.0.1",
+    cipd_tag = "version:8.20220504.2.1",
     sha256 = {
-        "linux": "31f1b8d69e4266408f1d6b250b5bb1afc11ab03c4dbe1a93159e928394080329",
-	"mac": "d0175724a54a7e3850c50a3fd4d1b664dde0271ebd2e8d47518ced2289dfe73c",
-        "linux_experimental": "7fd6da0fe33d9a13e6a1666e0b1cd604ddaa06f8f604708dc17ec36af73f9431",
-        "mac_experimental": "b88f7592908717a3ebc6d49828ba28a2d1a8b31ea934634dd5663da0b73454bb",
+        "linux": "ccc01f86ff36e95468c07a107d9b20d9d79cc3e7da8db306bb33156d401fc2fe",
+        "mac": "283e1499b3bd6b77ca0e0b755ef1d987dd05851c3b7f475c0e1c59be1855d634",
+        "linux_experimental": "e44d0d1c6ae07eb21cd40ddcb446c0275b1e55ffaa0d2cdf419851c13d595b51",
+        "mac_experimental": "a4f2beb76e15c8b5316e95e4c609487e8d19e7309794dc577bc3bbcca11b5e19",
     },
     use_experimental = True,
 )
diff --git a/scripts/smoke_test.sh b/scripts/smoke_test.sh
index 465707e..3361a59 100755
--- a/scripts/smoke_test.sh
+++ b/scripts/smoke_test.sh
@@ -38,33 +38,6 @@
   echo
 }
 
-modify_emulator_config() {
-  local new_template="$(mktemp)"
-
-  {
-    # this is a hack: there is no way to know the product bundle config file
-    # location unless if the emulator is running, so we start a new emulator:
-    $ffx_full emu start workstation.qemu-x64 --headless --name $emu_name
-
-    # now we get the template name
-    local emu_template="$($ffx_full emu show $emu_name | grep template | cut -f2 -d\")"
-
-    # and stop it right away
-    $ffx_full emu stop $emu_name
-
-    cp "$emu_template" "$new_template"
-
-    # enable ephemeral driver loading
-    sed -i'' '/^\s*"kernel_args": \[/a "devmgr.enable-ephemeral=true",' $new_template
-
-    # enable driver framework v2
-    sed -i'' '/^\s*"kernel_args": \[/a "driver_manager.use_driver_framework_v2=true",' $new_template
-    sed -i'' '/^\s*"kernel_args": \[/a "driver_manager.root-driver=fuchsia-boot:///#meta/platform-bus.cm",' $new_template
-
-  } > /dev/null
-  echo $new_template
-}
-
 bootstrap_ssh() {
   mkdir -p .ssh
   [[ -f "$HOME/.ssh/fuchsia_ed25519" ]] || ssh-keygen -P "" -t ed25519 -f "$HOME/.ssh/fuchsia_ed25519" 
@@ -107,14 +80,17 @@
   
   bootstrap_ssh
 
+  print_and_run ffx doctor --restart-daemon
+
   # fetch an emulator image of workstation and start an emulator
   print_and_run ffx product-bundle get workstation.qemu-x64
 
   stop_emu
 
-  local new_emu_config="$(modify_emulator_config)"
-
-  print_and_run ffx emu start workstation.qemu-x64 --headless --name $emu_name --config $new_emu_config
+  print_and_run ffx emu start workstation.qemu-x64 --headless --name $emu_name \
+      --kernel-args "devmgr.enable-ephemeral=true" \
+      --kernel-args "driver_manager.use_driver_framework_v2=true" \
+      --kernel-args "driver_manager.root-driver=fuchsia-boot:///#meta/platform-bus.cm"
 
   if [[ $keep_emu -eq 0 ]]; then
     trap "stop_emu" EXIT
diff --git a/src/qemu_edu/BUILD.bazel b/src/qemu_edu/BUILD.bazel
index 075698c..e2cebcb 100644
--- a/src/qemu_edu/BUILD.bazel
+++ b/src/qemu_edu/BUILD.bazel
@@ -49,6 +49,7 @@
         "@fuchsia_sdk//fidl/fuchsia.driver.compat:fuchsia.driver.compat_llcpp_cc",
         "@fuchsia_sdk//fidl/zx:zx_cc",
         "@fuchsia_sdk//pkg/driver2-llcpp",
+        "@fuchsia_sdk//pkg/driver_runtime_cpp",
         "@fuchsia_sdk//pkg/fidl-llcpp-experimental-driver-only",
         "@fuchsia_sdk//pkg/sys_component_llcpp",
         "@fuchsia_sdk//pkg/zx-experimental-driver-only",
diff --git a/src/qemu_edu/qemu_edu.cc b/src/qemu_edu/qemu_edu.cc
index 8f0a796..c1efd9f 100644
--- a/src/qemu_edu/qemu_edu.cc
+++ b/src/qemu_edu/qemu_edu.cc
@@ -6,7 +6,9 @@
 
 #include <fidl/fuchsia.driver.compat/cpp/wire.h>
 
-namespace fdf = fuchsia_driver_framework;
+namespace fdf {
+using namespace fuchsia_driver_framework;
+}  // namespace fdf
 
 namespace qemu_edu {
 
@@ -25,12 +27,12 @@
 
 // static
 zx::status<std::unique_ptr<QemuEduDriver>> QemuEduDriver::Start(
-    fdf::wire::DriverStartArgs& start_args, async_dispatcher_t* dispatcher,
+    fdf::wire::DriverStartArgs& start_args, fdf::UnownedDispatcher dispatcher,
     fidl::WireSharedClient<fdf::Node> node, driver::Namespace ns,
     driver::Logger logger) {
   auto driver = std::make_unique<QemuEduDriver>(
-      dispatcher, std::move(node), std::move(ns), std::move(logger));
-  auto result = driver->Run(dispatcher, std::move(start_args.outgoing_dir()));
+      dispatcher->async_dispatcher(), std::move(node), std::move(ns), std::move(logger));
+  auto result = driver->Run(dispatcher->async_dispatcher(), std::move(start_args.outgoing_dir()));
   if (result.is_error()) {
     return result.take_error();
   }
diff --git a/src/qemu_edu/qemu_edu.h b/src/qemu_edu/qemu_edu.h
index 34ad003..73b838a 100644
--- a/src/qemu_edu/qemu_edu.h
+++ b/src/qemu_edu/qemu_edu.h
@@ -12,6 +12,7 @@
 #include <lib/driver2/namespace.h>
 #include <lib/driver2/record_cpp.h>
 #include <lib/driver2/structured_logger.h>
+#include <lib/fdf/cpp/dispatcher.h>
 #include <lib/sys/component/llcpp/outgoing_directory.h>
 #include <lib/zx/status.h>
 
@@ -36,7 +37,7 @@
 
   static zx::status<std::unique_ptr<QemuEduDriver>> Start(
       fuchsia_driver_framework::wire::DriverStartArgs& start_args,
-      async_dispatcher_t* dispatcher,
+      fdf::UnownedDispatcher dispatcher,
       fidl::WireSharedClient<fuchsia_driver_framework::Node> node,
       driver::Namespace ns, driver::Logger logger);
 
diff --git a/third_party/sdk-integration b/third_party/sdk-integration
index d6052d9..fb52d48 160000
--- a/third_party/sdk-integration
+++ b/third_party/sdk-integration
@@ -1 +1 @@
-Subproject commit d6052d933479b6746bef0d24afb2209f0f1b7a5e
+Subproject commit fb52d487efbc3bb3558ea750d3ada51908bcf5a8
diff --git a/tools/fssh b/tools/fssh
new file mode 120000
index 0000000..bff5489
--- /dev/null
+++ b/tools/fssh
@@ -0,0 +1 @@
+../bazel-drivers/external/fuchsia_sdk/tools/x64/fssh
\ No newline at end of file
diff --git a/update_dependencies.md b/update_dependencies.md
index a8b760c..302f115 100644
--- a/update_dependencies.md
+++ b/update_dependencies.md
@@ -9,8 +9,22 @@
 
 This document provides simple instructions on how to update these dependencies to newer versions.
 
+## How to update - easy version
+
+There is an update script the performs all the manual steps below and sends a
+CL. Please use it and report if you encounter any error.
+
+```
+cd `mktemp -d`
+curl -s https://fuchsia.googlesource.com/sdk-integration/+/refs/heads/main/scripts/upgrade_repo.sh?format=TEXT  |
+    base64 --decode > upgrade_repo.sh &&
+    source ./upgrade_repo.sh drivers
+```
+
 ## How to update
 
+If for some reason the script above doesn't work as expected, the manual instructions can be followed.
+
 ### Fuchsia Bazel SDK (sdk-integration)
 
 > **When to update**: As frequent as possible, ideally daily.