How to unmount USB from virtual machine (Qrexec or...)?

Hello, how to send a command to dom0 from a virtual machine to unmount a USB?
I want to create a Systemd Unit to send commands to dom0 before shutting down the virtual machine:

qvm-usb detach storage sys-usb:3-9
qvm-block detach qube-mount storage:dm-0

Qrexec can link virtual machines together, but how can I make it send a command to unmount in dom0 or is there another way to do this ?

You don’t need to detach it yourself before shutting down the VM, it’ll be detached automatically on VM shutdown.

You can send commands from qubes to dom0 using qrexec as well if you configure qrexec policy for it.

I want to implement automatic mounting and unmounting of usb and block devices, for this I need to send a command from qubes to dom0 using Qrexec.
I read the Qrexec documentation:

But I didn’t find any example how to send a command from qubes to dom0 (examples of sending commands from Qubes-A to Qubes-B are described, but not to dom0), could you please provide a link with an example or briefly explain to me how to do this?
Thanks in advance.

Check how qubes.InputKeyboard works. Sys-usb will call qubes.InputKeyboard service and it’ll execute /etc/qubes-rpc/qubes.InputKeyboard in dom0 if it’s allowed by policy.