commit 9049b963b6023ef6d7bd3f8c81ef5ab1f3b43fd3
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date:   Wed Aug 11 16:27:43 2021 +0200

    libmachdev: Fix startup_dosync
    
    We do not actually want to shut everything down. For instance, we still have
    to be able to start the acpi translator to perform the actual shutdown.
    
    What we however have to do is syncing the disks.

diff --git a/libmachdev/ds_routines.c b/libmachdev/ds_routines.c
index c2de4b26..ac915166 100644
--- a/libmachdev/ds_routines.c
+++ b/libmachdev/ds_routines.c
@@ -315,13 +315,13 @@ void machdev_device_init()
     }
 }
 
-void machdev_device_shutdown(mach_port_t dosync_handle)
+void machdev_device_sync()
 {
   int i;
   for (i = 0; i < num_emul; i++)
     {
-      if (emulation_list[i]->shutdown)
-        emulation_list[i]->shutdown(dosync_handle);
+      if (emulation_list[i]->sync)
+        emulation_list[i]->sync();
     }
 }
 
diff --git a/libmachdev/machdev-device_emul.h b/libmachdev/machdev-device_emul.h
index 7748f37f..9f7b0b21 100644
--- a/libmachdev/machdev-device_emul.h
+++ b/libmachdev/machdev-device_emul.h
@@ -64,7 +64,7 @@ struct machdev_device_emulation_ops
 			     recnum_t, vm_offset_t, vm_size_t);
   io_return_t (*writev_trap) (void *, dev_mode_t,
 			      recnum_t, io_buf_vec_t *, vm_size_t);
-  void (*shutdown) (mach_port_t);
+  void (*sync) (void);
 };
 
 #endif /* _MACHDEV_DEVICE_EMUL_H_ */
diff --git a/libmachdev/machdev.h b/libmachdev/machdev.h
index 5d0eed02..7ac42eed 100644
--- a/libmachdev/machdev.h
+++ b/libmachdev/machdev.h
@@ -30,7 +30,7 @@
 void machdev_register (struct machdev_device_emulation_ops *ops);
 
 void machdev_device_init(void);
-void machdev_device_shutdown(mach_port_t dosync_handle);
+void machdev_device_sync(void);
 void * machdev_server(void *);
 error_t machdev_create_device_port (size_t size, void *result);
 int machdev_trivfs_init(int argc, char **argv, mach_port_t bootstrap_resume_task, const char *name, const char *path, mach_port_t *bootstrap);
diff --git a/libmachdev/trivfs_server.c b/libmachdev/trivfs_server.c
index 5d7a1300..029a8da7 100644
--- a/libmachdev/trivfs_server.c
+++ b/libmachdev/trivfs_server.c
@@ -490,7 +490,7 @@ machdev_trivfs_init(int argc, char **argv, mach_port_t bootstrap_resume_task,
   return 0;
 }
 
-/* The system is going down. Sync data, then call trivfs_goaway() */
+/* The system is going down, sync data.  */
 error_t
 S_startup_dosync (mach_port_t handle)
 {
@@ -502,10 +502,10 @@ S_startup_dosync (mach_port_t handle)
 
   ports_port_deref (inpi);
 
-  /* Sync and close device(s) */
-  machdev_device_shutdown (handle);
+  /* Sync device(s) */
+  machdev_device_sync ();
 
-  return trivfs_goaway (NULL, FSYS_GOAWAY_FORCE);
+  return 0;
 }
 
 error_t
diff --git a/pci-arbiter/main.c b/pci-arbiter/main.c
index d91500a1..ad9ccaa9 100644
--- a/pci-arbiter/main.c
+++ b/pci-arbiter/main.c
@@ -102,17 +102,6 @@ pci_device_close (void *d)
   return 0;
 }
 
-static void
-pci_device_shutdown (mach_port_t dosync_handle)
-{
-  // Free all libpciaccess resources
-  pci_system_cleanup ();
-
-  ports_destroy_right (&pci_control_port);
-
-  netfs_shutdown (FSYS_GOAWAY_FORCE);
-}
-
 static struct machdev_device_emulation_ops pci_arbiter_emulation_ops = {
   NULL,
   NULL,
@@ -131,7 +120,7 @@ static struct machdev_device_emulation_ops pci_arbiter_emulation_ops = {
   NULL,
   NULL,
   NULL,
-  pci_device_shutdown,
+  NULL,
 };
 
 int
diff --git a/rumpdisk/block-rump.c b/rumpdisk/block-rump.c
index 7f77fc81..80cdc350 100644
--- a/rumpdisk/block-rump.c
+++ b/rumpdisk/block-rump.c
@@ -195,19 +195,12 @@ rumpdisk_device_dealloc (void *d)
 }
 
 static void
-rumpdisk_device_shutdown (mach_port_t dosync_handle)
+rumpdisk_device_sync (void)
 {
-  struct block_data *bd = block_head;
-
   if (disabled)
     return;
 
-  while (bd)
-    {
-      rumpdisk_device_close((void *)bd);
-      bd = bd->next;
-    }
-  rump_sys_reboot (0, NULL);
+  rump_sys_sync ();
 }
 
 static io_return_t
@@ -419,7 +412,7 @@ static struct machdev_device_emulation_ops rump_block_emulation_ops = {
   NULL,
   NULL,
   NULL,
-  rumpdisk_device_shutdown
+  rumpdisk_device_sync
 };
 
 void
