1.. _acrn-dm_parameters-and-launch-script:
2
3Device Model Parameters and Launch Script
4#########################################
5
6The Device Model (DM) ``acrn-dm`` is a QEMU-like application in the Service
7VM responsible for creating a post-launched User VM and then performing device
8emulation based on command-line configurations, as introduced in
9the :ref:`hld-devicemodel`. The ACRN Configurator generates launch scripts for
10post-launched VMs that include a call to the ``acrn-dm`` command with
11parameter values that were set in the Configurator. Generally, you should not
12edit these launch scripts and change the parameters manually. Any edits you
13make would be overwritten if you run the Configurator again and save the
14configuration and launch scripts.
15
16The rest of this document provides details about the ``acrn-dm`` parameters as a
17reference, and should help you understand what the generated launch scripts
18are doing.  We also include information useful to ACRN contributors about how
19settings in the scenario file, created by the Configurator, are transformed
20into the launch script.
21
22.. _acrn-dm_parameters:
23
24Device Model Parameters
25***********************
26
27Here are descriptions for each of these ``acrn-dm`` command-line parameters:
28
29``-B``, ``--bootargs <bootargs>``
30   Set the User VM kernel command-line arguments. The maximum length is 1023
31   characters. The bootargs string will be passed to the kernel as its cmdline.
32
33   Example::
34
35      -B "loglevel=7"
36
37   to specify the kernel log level at 7.
38
39----
40
41``--debugexit``
42   Enable guest to write io port 0xf4 to exit guest. It's mainly used by guest
43   unit test.
44
45----
46
47``-E``, ``--elf_file <elf_image_path>``
48   Define a static ELF binary for the User VM.
49
50----
51
52``--enable_trusty``
53   Enable trusty for guest.  For an Android guest OS, ACRN provides a VM
54   environment with two worlds:  normal world and trusty world.  The Android
55   OS runs in the normal world.  The trusty OS and security sensitive
56   applications run in the trusty world.  The trusty world can see the memory
57   of the normal world but not vice versa.  See :ref:`trusty_tee` for more
58   information.
59
60   By default, the trusty world is disabled. Use this option to enable it.
61
62----
63
64``-h``, ``--help``
65   Show a summary of commands.
66
67----
68
69``--intr_monitor <intr_monitor_params>``
70   Enable an interrupt storm monitor for the User VM. Use this option to prevent
71   an interrupt storm from the User VM.
72
73   usage: ``--intr_monitor threshold/s probe-period(s) delay_time(ms) delay_duration(ms)``
74
75   Example::
76
77      --intr_monitor 10000,10,1,100
78
79   -  ``10000``: Interrupt rate larger than 10000/s will be treated as an
80      interrupt storm.
81   -  ``10``: Use the last 10s of interrupt data to detect an interrupt storm.
82   -  ``1``: When interrupts are identified as a storm, the next interrupt
83      will be delayed 1ms before being injected to the guest.
84   -  ``100``: After 100ms, cancel the interrupt injection delay and
85      restore to normal.
86
87----
88
89``-k``, ``--kernel <kernel_image_path>``
90   Set the kernel (full path) for the User VM kernel. The maximum path length
91   is 1023 characters. The DM supports bzImage image format.
92
93   usage: ``-k /path/to/your/kernel_image``
94
95----
96
97``-l``, ``--lpc <lpc_device_configuration>``
98
99----
100
101``-m``, ``--memsize <memory_size>``
102   Set the total memory size for the User VM.
103
104   memory_size format is: ``<size>{K/k, B/b, M/m, G/g}``, and size is an
105   integer.
106
107   Example::
108
109      -m 4g
110
111   to set the User VM memory to 4 gigabytes.
112
113----
114
115``-r``, ``--ramdisk <ramdisk_image_path>``
116   Set the RAM disk (full path) for the User VM. The maximum path length is 1023
117   characters. The supported RAM disk format depends on your User VM kernel
118   configuration.
119
120   usage: ``-r /path/to/your/ramdisk_image``
121
122----
123
124``-s``, ``--pci_slot <slot_config>``
125   Set the PCI device configuration.
126
127   slot_config format is::
128
129      <bus>:<slot>:<func>,<emul>[,<config>]
130      <slot>[:<func>],<emul>[,<config>]
131
132   Where:
133
134   -  ``slot`` is 0..31.
135   -  ``func`` is 0..7.
136   -  ``emul`` is a string describing the type of PCI device, e.g.,
137      virtio-net.
138   -  ``config`` is an optional device-dependent string, used for
139      configuration.
140
141   Examples::
142
143      -s 7,xhci,1-2,2-2
144
145   This configuration means the virtual xHCI will appear in PCI slot 7
146   in the User VM. Any physical USB device attached on 1-2 (bus 1, port 2) or
147   2-2 (bus 2, port 2) will be detected by the User VM and be used as expected.
148   To determine the bus and port of a USB device, run ``lsusb -t``
149   in the Service VM.
150
151   ::
152
153      -s 9,virtio-blk,/root/test.img
154
155   This example adds a virtual block in PCI slot 9 and uses ``/root/test.img``
156   as the disk image.
157
158
159   For more information about emulated device types, see :ref:`emul_config`.
160
161----
162
163``-v``, ``--version``
164   Show Device Model version.
165
166----
167
168``--ovmf [w,]<ovmf_file_path>`` ``--ovmf [w,]code=<ovmf_code_file>,vars=<ovmf_vars_file>``
169   Open Virtual Machine Firmware (OVMF) is an EDK II based project to enable
170   UEFI support for Virtual Machines.
171
172   ACRN does not support off-the-shelf OVMF builds targeted for QEMU and KVM.
173   Compatible OVMF images are included in the source tree, under
174   ``devicemodel/bios/``.
175
176   usage::
177
178      --ovmf /usr/share/acrn/bios/OVMF.fd
179
180   uses ``/usr/share/acrn/bios/OVMF.fd`` as the OVMF image.
181
182   ACRN also supports using OVMF split images; ``OVMF_CODE.fd`` contains
183   the OVMF firmware executable and ``OVMF_VARS.fd`` contains the NV
184   data store.
185
186   usage::
187
188      --ovmf code=/usr/share/acrn/bios/OVMF_CODE.fd,vars=/usr/share/acrn/bios/OVMF_VARS.fd
189
190   ACRN supports the option "w" for OVMF. To preserve all changes in OVMF's
191   NV data store section, use this option to enable writeback mode.
192
193   For OVMF split images, writeback mode is only enabled for the
194   ``OVMF_VARS.fd`` file, and the firmware executable (``OVMF_CODE.fd``) remains
195   read-only.
196
197   usage::
198
199      --ovmf w,/usr/share/acrn/bios/OVMF.fd
200
201----
202
203.. _cpu_affinity:
204
205``--cpu_affinity <list_of_lapic_ids>``
206   Comma-separated list of vCPUs assigned to this VM. Each CPU has a Local
207   Programmable Interrupt Controller (LAPIC). The unique ID of the LAPIC
208   (lapic_id) is used to identify the vCPU. The ``lapic_id`` for a vCPU can be
209   found in the Service VM file ``/proc/cpuinfo`` identified as ``apicid``.
210
211   Example::
212
213      --cpu_affinity 1,3
214
215   to assign vCPUs with lapic_id 1 and 3 to this VM.
216
217----
218
219``--virtio_poll <poll_interval>``
220   Enable virtio poll mode with poll interval in nanoseconds.
221
222   Example::
223
224      --virtio_poll 1000000
225
226   to enable virtio poll mode with poll interval of 1ms.
227
228----
229
230``--acpidev_pt <HID>[,<UID>]``
231   Enable ACPI device passthrough support. The ``HID`` is a
232   mandatory parameter and is the Hardware ID of the ACPI
233   device.
234
235   The ``UID`` is an option and used to specify an instance of the
236   HID device, the default is 00.
237
238   Example::
239
240      --acpidev_pt MSFT0101,00
241
242   to pass through a TPM (HID is MSFT0101 and UID is 00) ACPI device to
243   a User VM.
244
245----
246
247``--mmiodev_pt <MMIO_Region>``
248   Enable MMIO device passthrough support.  The
249   ``MMIO_Region`` is a mandatory parameter and is the MMIO
250   resource of the MMIO device.  The ``MMIO_Region`` needs to be the base
251   address followed by the length of the region, both separated by a comma.
252
253   Example::
254
255      --mmiodev_pt 0xFED40000,0x00005000
256
257   to pass through an MMIO device to a User VM.  The MMIO device has an MMIO
258   region.  The base address of this region is 0xFED40000 and the size of the
259   region is 0x00005000.
260
261----
262
263``--vtpm2 <sock_path>``
264   Enable virtual TPM support. The ``sock_path`` is a mandatory
265   parameter and is the path of the swtpm socket fd.
266
267----
268
269``--virtio_msi``
270   Force virtio to use single-vector MSI.  By default, a
271   virtio-based device uses MSI-X as its interrupt method.  If you want
272   to use single-vector MSI, you can do so using this option.
273
274----
275
276``--lapic_pt``
277   Create a VM with the local APIC (LAPIC) passed-through.
278   With this option, a VM is created with ``LAPIC_PASSTHROUGH`` and
279   ``IO_COMPLETION_POLLING`` mode. This option is typically used for hard
280   real-time scenarios.
281
282   By default, this option is not enabled.
283
284----
285
286``--rtvm``
287   Create a VM with real-time attributes.  With this
288   option, a VM is created with ``GUEST_FLAG_RT`` and
289   ``GUEST_FLAG_IO_COMPLETION_POLLING`` mode.  This kind of VM is generally
290   used for soft real-time scenarios (without ``--lapic_pt``) or hard
291   real-time scenarios (with ``--lapic_pt``).  With ``GUEST_FLAG_RT``, the
292   Service VM cannot interfere with this kind of VM when it is running.  It
293   can only be powered off from inside the VM itself.
294
295   By default, this option is not enabled.
296
297----
298
299``--logger_setting <console,level=4;disk,level=4;kmsg,level=3>``
300   Set the level of logging that is used for each log channel.
301   The general format of this option is ``<log channel>,level=<log level>``.
302   Different log channels are separated by a semi-colon (``;``). The various
303   log channels available are: ``console``, ``disk``, and ``kmsg``.  The log
304   level ranges from 1 (``error``) up to 5 (``debug``).
305
306   By default, the log severity level is set to 4 (``info``).
307
308----
309
310``--windows``
311   Run Windows User VMs. This option supports Oracle
312   ``virtio-blk``, ``virtio-net``, and ``virtio-input`` devices for Windows
313   guests with secure boot.
314
315   usage::
316
317      --windows
318
319   .. note::
320      This option is mandatory for running Windows in a User VM. If it is
321      not used, Windows will not recognize the virtual disk.
322
323----
324
325``--ssram``
326   Enable Software SRAM passthrough to the VM.
327
328   usage::
329
330      --ssram
331
332----
333
334``--iasl <iasl_compiler_path>``
335   Specify the path to the ``iasl`` compiler on the target machine.
336
337   If ``--iasl <iasl_compiler_path>`` is specified as the ``acrn-dm`` parameter,
338   acrn-dm uses ``<iasl_compiler_path>`` as the path to the ``iasl`` compiler;
339   otherwise, ``which iasl`` is used to detect where the ``iasl`` compiler is located.
340
341   usage::
342
343      --iasl /usr/local/bin/iasl
344
345   uses ``/usr/local/bin/iasl`` as the path to the ``iasl`` compiler.
346
347.. _emul_config:
348
349Emulated PCI Device Types
350****************************
351
352In the acrn-dm ``-s`` or ``--pci_slot`` command-line parameter, there is a
353``<slot_config>`` argument that contains a string describing the type of
354emulated PCI device, along with optional device-dependent arguments used for
355configuration.  Here is a table describing these emulated device types and
356arguments:
357
358.. list-table:: Emulated PCI Device Types
359   :header-rows: 1
360   :widths: 20 80
361
362   * - PCI Device Type String
363     - Description
364
365   * - ``xhci``
366     - USB controller used to support USB 3.0 devices (also supports USB 2.0
367       and USB 1.0 devices).  Parameter ``<bus number>-<port number>`` should be
368       added. The physical USB devices attached on the specified bus and port
369       will be detected by the User VM and used as expected, e.g., ``xhci,1-2,2-2``.
370
371   * - ``lpc``
372     - Low Pin Count (LPC) bus is used to connect low speed devices to the CPU,
373       for example, a serial port, keyboard, or mouse.
374
375   * - ``igd-lpc``
376     - Windows graphics driver requires this virtualized LPC device to operate
377       the display function.
378
379   * - ``ivshmem``
380     - Inter-VM shared memory (IVSHMEM) virtualized PCI device used specifically
381       for shared memory between VMs. Parameters should be added with the format
382       ``ivshmem,<shm_name>,<shm_size>``. ``<shm-name>`` specifies a shared memory
383       name, and must be listed in ``hv.FEATURES.IVSHMEM.IVSHMEM_REGION``
384       as configured using the ACRN Configurator UI, and needs to start
385       with a ``dm:/`` prefix.
386
387   * - ``ahci``
388     - Advanced Host Controller Interface provides advanced features to access
389       Serial ATA (SATA) storage devices, such as a hard disk. Parameter
390       ``<type:><filepath>*`` should be added: ``type`` could be
391       ``hd`` (hard disk) or ``cd`` (CD-ROM). ``<filepath>`` is the path for the
392       backend file and could be a partition name or a regular file, e.g.,
393       ``ahci,hd:/dev/sda``.
394
395   * - ``ahci-hd``
396     - This is an alias for ``ahci``.
397
398   * - ``ahci-cd``
399     - Advanced Host Controller Interface used to connect with an AT Attachment
400       Packet Interface device (for CD-ROM emulation). ``ahci-cd`` supports the
401       same parameters as ``ahci``.
402
403   * - ``hostbridge``
404     - Virtualized PCI host bridge, a hardware bridge between the CPU's
405       high-speed system local bus and the Peripheral Component Interconnect
406       (PCI) bus.
407
408   * - ``virtio-blk``
409     - Virtio block type device. A string could be appended with the format
410       ``virtio-blk,<filepath>[,options]``:
411
412       * ``<filepath>`` specifies the path of a file or disk partition. You can
413         also use ``nodisk`` to create a virtio-blk device with a dummy backend.
414         ``nodisk`` is used for hot-plugging a rootfs after the User VM has been
415         launched. It is achieved by triggering a rescan of the ``virtio-blk``
416         device by the User VM. The empty file will be updated to a valid file
417         after rescan.
418       * ``[,options]`` includes:
419
420         * ``writethru``: write operation is reported completed only when the data
421           has been written to physical storage.
422         * ``writeback``: write operation is reported completed when data is placed
423           in the page cache. Needs to be flushed to the physical storage.
424         * ``ro``: open file with read-only mode.
425         * ``sectorsize``: configured as either ``sectorsize=<sector
426           size>/<physical sector size>`` or ``sectorsize=<sector size>``. The
427           default values for sector size and physical sector size are 512.
428         * ``range``: configured as ``range=<start lba in file>/<sub file
429           size>`` meaning the virtio-blk will only access part of the file,
430           from the ``<start lba in file>`` to ``<start lba in file>`` + ``<sub
431           file size>``.
432
433   * - ``virtio-input``
434     - Virtio type device to emulate input device. ``evdev`` char device node
435       should be appended, e.g., ``-s
436       n,virtio-input,/dev/input/eventX[,serial]``. ``serial`` is an optional
437       string used as the unique identification code of the guest virtio input device.
438
439   * - ``virtio-console``
440     - Virtio console type device for data input and output.
441
442   * - ``virtio-heci``
443     - Virtio Host Embedded Controller Interface. Parameters should be appended
444       with the format ``<bus>:<device>:<function>,d<0~8>``. You can find the BDF
445       information from the Service VM.
446
447   * - ``virtio-i2c``
448     - Virtio I2C type device. Parameters format is:
449       ``<bus>[:<client_addr>[@<node>]][,<bus>[:<client_addr>[@<node>]]``
450
451       * ``<bus>`` specifies the bus number for the native I2C adapter, e.g.,
452         ``2`` means ``/dev/i2c-2``.
453       * ``<client_addr>`` specifies the address for the native client devices
454         such as ``1C`` or  ``2F``.
455       * ``@`` specifies the prefix for the ACPI node.
456       * ``<node>`` specifies the ACPI node name supported in the
457         ``acpi_node_table[]`` in the source code: only ``cam1``, ``cam2``, and
458         ``hdac`` are supported for APL platform and  are platform-specific.
459
460   * - ``virtio-gpio``
461     - Virtio GPIO type device. Parameters format is:
462       ``virtio-gpio,<@controller_name{offset|name[=mapping_name]:offset|name[=mapping_name]:...}@controller_name{...}...]>``
463
464       * ``controller_name``: use the command ``ls /sys/bus/gpio/devices`` to
465         check the native GPIO controller information.  Usually, the devices
466         represent the ``controller_name`` that you can use. You can also use
467         the command ``cat /sys/bus/gpio/device/XXX/dev`` to get the device ID
468         that can be used to match ``/dev/XXX``, and then use ``XXX`` as the
469         ``controller_name``. On Intel platforms, ``controller_name`` may be
470         ``gpiochip0``, ``gpiochip1``, ``gpiochip2``, and ``gpiochip3``.
471       * ``offset|name``: use GPIO offset or its name to locate one native GPIO
472         within the GPIO controller.
473       * ``mapping_name``: is optional. If you want to use a customized name for
474         a FE GPIO, you can set a new name here.
475
476   * - ``virtio-rnd``
477     - Virtio random generator type device. The VBSU virtio backend is used by
478       default.
479
480   * - ``virtio-rpmb``
481     - Virtio Replay Protected Memory Block (RPMB) type device, with
482       ``physical_rpmb`` to specify RPMB in physical mode;
483       otherwise, RPMB is in simulated mode.
484
485   * - ``virtio-net``
486     - Virtio network type device. Parameters should be appended with the
487       format:
488       ``virtio-net,<device_type>=<name>[,vhost][,mac=<XX:XX:XX:XX:XX:XX> | mac_seed=<seed_string>]``.
489
490       * ``device_type``: The only supported parameter is ``tap``.
491       * ``name``: Name of the TAP (or MacVTap) device.
492       * ``vhost``: Specifies the vhost backend; otherwise, the VBSU backend is
493         used.
494       * ``mac=<XX:XX:XX:XX:XX:XX> | mac_seed=<seed_string>``: The MAC address
495         or seed is optional. ``mac_seed=<seed_string>`` sets a platform-unique
496         string as a seed to generate the MAC address.  Each VM should have a
497         different ``seed_string``.  The ``seed_string`` can be generated by the
498         following method where ``$(vm_name)`` contains the name of the VM you
499         are going to launch.
500
501       .. code-block::
502
503          mac=$(cat /sys/class/net/e*/address)
504          seed_string=${mac:9:8}-${vm_name}
505
506       .. note::
507          ``mac`` and ``mac_seed`` are mutually exclusive. When both are set,
508          the latter is ignored and the MAC address is set to the ``mac`` value.
509          ``mac_seed`` will only be used when ``mac`` is not set.
510
511   * - ``virtio-gpu``
512     - Virtio GPU type device. Parameters format is:
513       ``virtio-gpu[,geometry=<width>x<height>+<x_off>+<y_off> | fullscreen]``
514
515       * ``geometry`` specifies the mode of virtual display, windowed or fullscreen.
516         If it is not set, the virtual display will use 1280x720 resolution in windowed mode.
517       * ``width`` specifies the width of the virtual display window in pixels.
518       * ``height`` specifies the height of the virtual display window in pixels.
519       * ``x_off`` specifies the x offset of the virtual display window from the
520         upper-left corner of the screen.
521       * ``y_off`` specifies the y offset of the virtual display window from the
522         upper-left corner of the screen.
523
524       For example: ``geometry=1280x720+100+50`` specifies a window 1280 pixels
525       wide by 720 high, with the top left corner 100 pixels right and 50 pixels
526       down from the top left corner of the screen.
527
528   * - ``passthru``
529     - Indicates a passthrough device. Use the parameter with the format
530       ``passthru,<bus>/<device>/<function>,<optional parameter>``.
531       Optional parameters include:
532
533       * ``keep_gsi``: keep vGSI for MSI capable passthrough device.
534       * ``no_reset``: passthrough PCI devices are reset by default when
535         assigning them to a post-launched VM. This parameter prevents this
536         reset for debugging purposes.
537       * ``d3hot_reset``: when launching a  Windows post-launched VM, this
538         parameter should be appended to enable a Windows UEFI ACPI bug fix.
539       * ``gpu``: create the dedicated ``igd-lpc`` on ``00:1f.0`` for IGD
540         passthrough.
541       * ``vmsix_on_msi,<bar_id>``: enable vMSI-X emulation based on MSI
542         capability.  The specific virtual bar will be allocated.
543       * ``enable_ptm``: enable PCIe precise time measurement mechanism for the
544         passthrough device.
545       * ``irq=<irq_number>``: when the passthrough PCI devices support legacy interrupt,
546         e.g. UART, SDIO controller, ``irq_number`` shall be specified.
547       * ``dsdt=<dsdt_file_dir>``: when the passthrough PCI devices support legacy interrupt
548         and customized ``dsdt_file`` are needed , e.g. SPI, ``dsdt_file_dir`` shall be specified.
549
550   * - ``uart``
551     - Emulated PCI UART. Use the parameter with the format
552       ``uart,vuart_idx:<0~9>`` to specify hypervisor-emulated PCI vUART index.
553
554   * - ``wdt-i6300esb``
555     - Emulated i6300ESB PCI Watch Dog Timer (WDT), which Intel processors use
556       to monitor User VMs.
557
558Launch Script
559*************
560
561A launch script is used to start a post-launched User VM from the Service VM
562command line. The ACRN Configurator creates the launch script according to
563several User VM settings. Normally, you should not manually edit these generated
564launch scripts or change ``acrn-dm`` command-line parameters. If you do so, your
565changes could be overwritten the next time you run the Configurator.
566
567In this section, we describe how settings in the scenario file,
568created by the Configurator, are transformed into the launch script.
569This information would be useful to ACRN contributors or developers
570interested in knowing how the launch scripts are created.
571
572Most Configurator settings for User VMs are used at launch time.
573When you exit the Configurator, these settings are saved in the
574``scenario.xml`` file and then processed by
575``misc/config_tools/launch_config/launch_cfg_gen.py``
576to add shell commands to create the launch script, according to the template
577``misc/config_tools/launch_config/launch_script_template.sh``.
578The template uses the following helper functions to do system settings or to
579generate an ``acrn-dm`` command-line parameter. For details about all
580``acrn-dm`` parameters, refer to the previous section.
581
582``probe_modules``
583    Install necessary modules before launching a post-launched VM. For
584    example, ``pci_stub`` is used to provide a stub PCI driver that does
585    nothing on attached PCI devices. Passthrough PCIe devices will be unbound
586    from their original driver and bound to the stub, so that they can be safely
587    controlled by the User VM.
588
589``offline_cpus <cpu_apicid>...``
590    This is called if we are launching an RTVM or VM whose scheduler is
591    ``SCHED_NOOP``. In both situations, CPU sharing between multiple VMs is
592    prevented.
593    This function will trigger taking a CPU offline (done by the Service VM
594    kernel), and then inform the hypervisor through the Hypervisor Service
595    Module (HSM). The hypervisor will offline the vCPU and freeze the vCPU
596    thread.
597
598``unbind_device <bdf>``
599    Unbind a PCIe device with specified BDF (bus, device, and function) number
600    from its original driver and re-bind it to the pci-stub driver. Then
601    the Service VM kernel will not operate on that device anymore and it can
602    be passed through to the User VM safely.
603
604``create_tap <tap>``
605    Create or reuse the tap interface that is attached to the ``acrn-br0``
606    bridge.
607    ``acrn-br0`` is registered to ``systemd-networkd.service`` after installing
608    the ACRN Debian package (``.deb``). You also need to enable and start the
609    service to create the bridge from the Service VM using::
610
611        sudo systemctl enable --now systemd-networkd
612
613    The bridge is used to add a ``virtio-net``
614    interface to a User VM. ``virtio-net`` interfaces for all User VMs are
615    virtually connected to a subnet behind the ACRN bridge.
616
617``mount_partition <partition>``
618    Mount the specified partition to a temporary directory created by
619    ``mktemp -d``,
620    and return the temporary directory for later unmount.
621    Typically this function is called to mount an image file in order to use an
622    inner rootfs file as a ``virtio-blk`` backend. For example, users could set
623    ``<imgfile>:/boot/initrd.img*`` in the ``virtio-blk`` input box in the ACRN
624    Configurator. After the ``acrn-dm`` instance exits, ``unmount_partition``
625    will be called to unmount the image file.
626
627``unmount_partition <dir>``
628    Unmount the partition from the specified directory.
629
630``add_cpus <cpu_apicid>...``
631    Return an ``acrn-dm`` command-line parameter fragment to set
632    ``cpu_affinity``. Refer to `cpu_affinity`_ for details.
633    ``offline_cpus`` is called if the User VM is an RTVM or its scheduler is
634    ``SCHED_NOOP``.
635
636``add_interrupt_storm_monitor <threshold_per_sec> <probe_period_in_sec> <inject_delay_in_ms> <delay_duration_in_ms>``
637    This is added if PCIe devices, other than an integrated GPU, are passed through to
638    the User VM to monitor if an interrupt storm occurred on those devices.
639    The function and parameters are not visible in the ACRN Configurator and
640    are handled by config scripts. The function returns ``acrn-dm``
641    command-line segment to set ``intr_monitor``.
642
643``add_logger_settings console=<n> kmsg=<n> disk=<n>``
644    Set the log level of each ``acrn-dm`` logging channel: console, kmsg, disk.
645    These settings are not exposed to users in the ACRN Configurator.
646
647``add_virtual_device <slot> <kind> <options>``
648    Add the specified kind of virtual device to the specified PCIe device slot.
649    Some devices need options to configure further behaviors. ``<slot>`` numbers
650    for virtual devices and passthrough devices are automatically allocated
651    by ``launch_cfg_gen.py``.
652
653    Typical use cases:
654
655    - ``hostbridge``
656        PCIe host bridge. ``<slot>`` must be 0.
657
658    - ``uart vuart_idx:<int>``
659        Add a PCIe vUART with specified index.
660
661    - ``xhci <bus>-<port>[:<bus>-<port>]...``
662        Configure a USB mediator. A list of USB ports each specified by
663        ``<bus>-<port>`` will be connected to the User VM.
664
665    - ``virtio-net tap=<tapname>[,vhost],mac_seed=<str>``
666        The TAP should already be created by ``create_tap``.
667
668    - ``virtio-blk <imgfile>[,writethru|writeback|ro]``
669        Add a virtio block device to the User VM. The backend is a raw image
670        file. Options can be specified to control access right.
671
672    For all types of virtual devices and options, refer to
673    :ref:`emul_config`.
674
675``add_passthrough_device <slot> <bus>/<device>/<function> <options>``
676    Passthrough a PCIe device to the User VM in the specified ``<slot>``.
677    Some kinds of devices may need extra ``<options>`` to control internal
678    behavior. Refer to the ``passthru`` section in :ref:`emul_config`.
679
680These functions in the template are copied to the target launch script. Then
681``launch_cfg_gen.py`` generates the following dynamic part. It first defines
682necessary variables such as ``vm_type`` and ``scheduler``, and uses the
683functions described above to construct the ``dm_params`` parameters per the
684user settings in ``scenario.xml``.
685Finally, ``acrn-dm`` is executed to launch a User VM with these parameters.
686