[libvirt PATCH 0/4] Support autostart for mediated devices

This is a short patch series based on an initial patch from Boris Fiuczynski that I massaged a little bit and added a few additional patches. This allows you to define mediated devices in libvirt which are started automatically at boot or parent device plugin. Boris Fiuczynski (1): nodedev: support auto-start property for mdevs Jonathon Jongsma (3): test: move nodedev xml2xml output to a separate dir tests: nodedevxml2xmltest: test more mdev files docs: nodedev: document mdev uuid property docs/formatnode.html.in | 14 ++++++++ docs/schemas/nodedev.rng | 11 +++++++ src/conf/node_device_conf.c | 20 ++++++++++- src/conf/node_device_conf.h | 12 +++++++ src/libvirt_private.syms | 2 ++ src/node_device/node_device_driver.c | 7 +++- .../mdevctl-list-multiple.out.xml | 4 +++ tests/nodedevschemadata/mdev_autostart.xml | 10 ++++++ tests/nodedevschemadata/mdev_manual.xml | 10 ++++++ tests/nodedevxml2xmlout/DVD_GCC_4247N.xml | 15 +++++++++ tests/nodedevxml2xmlout/DVD_with_media.xml | 18 ++++++++++ tests/nodedevxml2xmlout/ap_07_0038.xml | 9 +++++ tests/nodedevxml2xmlout/ap_card07.xml | 8 +++++ tests/nodedevxml2xmlout/ap_matrix.xml | 7 ++++ .../ap_matrix_mdev_types.xml | 14 ++++++++ tests/nodedevxml2xmlout/ccw_0_0_ffff.xml | 10 ++++++ tests/nodedevxml2xmlout/computer.xml | 16 +++++++++ .../css_0_0_fffe_mdev_types.xml | 17 ++++++++++ tests/nodedevxml2xmlout/css_0_0_ffff.xml | 10 ++++++ tests/nodedevxml2xmlout/drm_renderD129.xml | 10 ++++++ ...v_3627463d_b7f0_4fea_b468_f1da537d301b.xml | 9 +++++ tests/nodedevxml2xmlout/mdev_autostart.xml | 11 +++++++ ...v_d069d019_36ea_4111_8f0a_8c9a70e21366.xml | 10 ++++++ ...v_d2441d39_495e_4243_ad9f_beb3f14c23d9.xml | 11 +++++++ ...v_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad.xml | 10 ++++++ ...v_fedc4916_1ca8_49ac_b176_871d16c13076.xml | 10 ++++++ tests/nodedevxml2xmlout/mdev_manual.xml | 11 +++++++ .../net_00_13_02_b9_f9_d3.xml | 21 ++++++++++++ .../net_00_15_58_2f_e9_55.xml | 21 ++++++++++++ .../pci_0000_00_02_0_header_type.xml | 16 +++++++++ .../pci_0000_00_1c_0_header_type.xml | 21 ++++++++++++ .../pci_0000_02_10_7_mdev_types.xml | 33 +++++++++++++++++++ .../pci_0000_02_10_7_sriov.xml | 24 ++++++++++++++ .../pci_0000_02_10_7_sriov_pf_vfs_all.xml | 29 ++++++++++++++++ ...0_02_10_7_sriov_pf_vfs_all_header_type.xml | 31 +++++++++++++++++ .../pci_0000_02_10_7_sriov_vfs.xml | 27 +++++++++++++++ ..._0000_02_10_7_sriov_zero_vfs_max_count.xml | 22 +++++++++++++ tests/nodedevxml2xmlout/pci_1002_71c4.xml | 14 ++++++++ .../pci_8086_0c0c_snd_hda_intel.xml | 17 ++++++++++ .../pci_8086_10c9_sriov_pf.xml | 18 ++++++++++ .../pci_8086_27c5_scsi_host.xml | 7 ++++ .../pci_8086_27c5_scsi_host_0.xml | 7 ++++ .../pci_8086_27c5_scsi_host_0_unique_id.xml | 8 +++++ ...i_8086_27c5_scsi_host_scsi_device_lun0.xml | 11 +++++++ .../pci_8086_27c5_scsi_host_scsi_host.xml | 7 ++++ .../pci_8086_4238_pcie_wireless.xml | 27 +++++++++++++++ tests/nodedevxml2xmlout/scsi_target0_0_0.xml | 7 ++++ tests/nodedevxml2xmlout/scsi_target1_0_0.xml | 12 +++++++ ...rial_3600c0ff000d7a2a5d463ff4902000000.xml | 19 +++++++++++ ...al_SATA_HTS721010G9SA00_MPCZ12Y0GNGWSE.xml | 14 ++++++++ .../usb_device_1d6b_1_0000_00_1d_0.xml | 10 ++++++ .../usb_device_1d6b_1_0000_00_1d_0_if0.xml | 10 ++++++ tests/nodedevxml2xmltest.c | 17 +++++++--- 53 files changed, 739 insertions(+), 7 deletions(-) create mode 100644 tests/nodedevschemadata/mdev_autostart.xml create mode 100644 tests/nodedevschemadata/mdev_manual.xml create mode 100644 tests/nodedevxml2xmlout/DVD_GCC_4247N.xml create mode 100644 tests/nodedevxml2xmlout/DVD_with_media.xml create mode 100644 tests/nodedevxml2xmlout/ap_07_0038.xml create mode 100644 tests/nodedevxml2xmlout/ap_card07.xml create mode 100644 tests/nodedevxml2xmlout/ap_matrix.xml create mode 100644 tests/nodedevxml2xmlout/ap_matrix_mdev_types.xml create mode 100644 tests/nodedevxml2xmlout/ccw_0_0_ffff.xml create mode 100644 tests/nodedevxml2xmlout/computer.xml create mode 100644 tests/nodedevxml2xmlout/css_0_0_fffe_mdev_types.xml create mode 100644 tests/nodedevxml2xmlout/css_0_0_ffff.xml create mode 100644 tests/nodedevxml2xmlout/drm_renderD129.xml create mode 100644 tests/nodedevxml2xmlout/mdev_3627463d_b7f0_4fea_b468_f1da537d301b.xml create mode 100644 tests/nodedevxml2xmlout/mdev_autostart.xml create mode 100644 tests/nodedevxml2xmlout/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366.xml create mode 100644 tests/nodedevxml2xmlout/mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9.xml create mode 100644 tests/nodedevxml2xmlout/mdev_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad.xml create mode 100644 tests/nodedevxml2xmlout/mdev_fedc4916_1ca8_49ac_b176_871d16c13076.xml create mode 100644 tests/nodedevxml2xmlout/mdev_manual.xml create mode 100644 tests/nodedevxml2xmlout/net_00_13_02_b9_f9_d3.xml create mode 100644 tests/nodedevxml2xmlout/net_00_15_58_2f_e9_55.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_00_02_0_header_type.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_00_1c_0_header_type.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_02_10_7_mdev_types.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov_pf_vfs_all.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov_pf_vfs_all_header_type.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov_vfs.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov_zero_vfs_max_count.xml create mode 100644 tests/nodedevxml2xmlout/pci_1002_71c4.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_0c0c_snd_hda_intel.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_10c9_sriov_pf.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host_0.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host_0_unique_id.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host_scsi_device_lun0.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host_scsi_host.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_4238_pcie_wireless.xml create mode 100644 tests/nodedevxml2xmlout/scsi_target0_0_0.xml create mode 100644 tests/nodedevxml2xmlout/scsi_target1_0_0.xml create mode 100644 tests/nodedevxml2xmlout/storage_serial_3600c0ff000d7a2a5d463ff4902000000.xml create mode 100644 tests/nodedevxml2xmlout/storage_serial_SATA_HTS721010G9SA00_MPCZ12Y0GNGWSE.xml create mode 100644 tests/nodedevxml2xmlout/usb_device_1d6b_1_0000_00_1d_0.xml create mode 100644 tests/nodedevxml2xmlout/usb_device_1d6b_1_0000_00_1d_0_if0.xml -- 2.31.1

Currently, we're loading and parsing the xml from the input file, and then formatting it and then comparing it directly back to the input file. This works for now, but is severely limiting as it relies on the input file being fully-specified and in the exact order as the output xml format. If optional elements are ommitted in the input XML, the output xml may include default values for the ommitted elements and thus the output will not match the input. In order to allow more flexibility in testing, save the expected output to a seprate 'out' directory similar to what most of the other xml2xml tests are already doing. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- tests/nodedevxml2xmlout/DVD_GCC_4247N.xml | 15 +++++++++ tests/nodedevxml2xmlout/DVD_with_media.xml | 18 ++++++++++ tests/nodedevxml2xmlout/ap_07_0038.xml | 9 +++++ tests/nodedevxml2xmlout/ap_card07.xml | 8 +++++ tests/nodedevxml2xmlout/ap_matrix.xml | 7 ++++ .../ap_matrix_mdev_types.xml | 14 ++++++++ tests/nodedevxml2xmlout/ccw_0_0_ffff.xml | 10 ++++++ tests/nodedevxml2xmlout/computer.xml | 16 +++++++++ .../css_0_0_fffe_mdev_types.xml | 17 ++++++++++ tests/nodedevxml2xmlout/css_0_0_ffff.xml | 10 ++++++ tests/nodedevxml2xmlout/drm_renderD129.xml | 10 ++++++ ...v_3627463d_b7f0_4fea_b468_f1da537d301b.xml | 8 +++++ ...v_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad.xml | 9 +++++ .../net_00_13_02_b9_f9_d3.xml | 21 ++++++++++++ .../net_00_15_58_2f_e9_55.xml | 21 ++++++++++++ .../pci_0000_00_02_0_header_type.xml | 16 +++++++++ .../pci_0000_00_1c_0_header_type.xml | 21 ++++++++++++ .../pci_0000_02_10_7_mdev_types.xml | 33 +++++++++++++++++++ .../pci_0000_02_10_7_sriov.xml | 24 ++++++++++++++ .../pci_0000_02_10_7_sriov_pf_vfs_all.xml | 29 ++++++++++++++++ ...0_02_10_7_sriov_pf_vfs_all_header_type.xml | 31 +++++++++++++++++ .../pci_0000_02_10_7_sriov_vfs.xml | 27 +++++++++++++++ ..._0000_02_10_7_sriov_zero_vfs_max_count.xml | 22 +++++++++++++ tests/nodedevxml2xmlout/pci_1002_71c4.xml | 14 ++++++++ .../pci_8086_0c0c_snd_hda_intel.xml | 17 ++++++++++ .../pci_8086_10c9_sriov_pf.xml | 18 ++++++++++ .../pci_8086_27c5_scsi_host.xml | 7 ++++ .../pci_8086_27c5_scsi_host_0.xml | 7 ++++ .../pci_8086_27c5_scsi_host_0_unique_id.xml | 8 +++++ ...i_8086_27c5_scsi_host_scsi_device_lun0.xml | 11 +++++++ .../pci_8086_27c5_scsi_host_scsi_host.xml | 7 ++++ .../pci_8086_4238_pcie_wireless.xml | 27 +++++++++++++++ tests/nodedevxml2xmlout/scsi_target0_0_0.xml | 7 ++++ tests/nodedevxml2xmlout/scsi_target1_0_0.xml | 12 +++++++ ...rial_3600c0ff000d7a2a5d463ff4902000000.xml | 19 +++++++++++ ...al_SATA_HTS721010G9SA00_MPCZ12Y0GNGWSE.xml | 14 ++++++++ .../usb_device_1d6b_1_0000_00_1d_0.xml | 10 ++++++ .../usb_device_1d6b_1_0000_00_1d_0_if0.xml | 10 ++++++ tests/nodedevxml2xmltest.c | 12 ++++--- 39 files changed, 591 insertions(+), 5 deletions(-) create mode 100644 tests/nodedevxml2xmlout/DVD_GCC_4247N.xml create mode 100644 tests/nodedevxml2xmlout/DVD_with_media.xml create mode 100644 tests/nodedevxml2xmlout/ap_07_0038.xml create mode 100644 tests/nodedevxml2xmlout/ap_card07.xml create mode 100644 tests/nodedevxml2xmlout/ap_matrix.xml create mode 100644 tests/nodedevxml2xmlout/ap_matrix_mdev_types.xml create mode 100644 tests/nodedevxml2xmlout/ccw_0_0_ffff.xml create mode 100644 tests/nodedevxml2xmlout/computer.xml create mode 100644 tests/nodedevxml2xmlout/css_0_0_fffe_mdev_types.xml create mode 100644 tests/nodedevxml2xmlout/css_0_0_ffff.xml create mode 100644 tests/nodedevxml2xmlout/drm_renderD129.xml create mode 100644 tests/nodedevxml2xmlout/mdev_3627463d_b7f0_4fea_b468_f1da537d301b.xml create mode 100644 tests/nodedevxml2xmlout/mdev_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad.xml create mode 100644 tests/nodedevxml2xmlout/net_00_13_02_b9_f9_d3.xml create mode 100644 tests/nodedevxml2xmlout/net_00_15_58_2f_e9_55.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_00_02_0_header_type.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_00_1c_0_header_type.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_02_10_7_mdev_types.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov_pf_vfs_all.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov_pf_vfs_all_header_type.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov_vfs.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov_zero_vfs_max_count.xml create mode 100644 tests/nodedevxml2xmlout/pci_1002_71c4.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_0c0c_snd_hda_intel.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_10c9_sriov_pf.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host_0.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host_0_unique_id.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host_scsi_device_lun0.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host_scsi_host.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_4238_pcie_wireless.xml create mode 100644 tests/nodedevxml2xmlout/scsi_target0_0_0.xml create mode 100644 tests/nodedevxml2xmlout/scsi_target1_0_0.xml create mode 100644 tests/nodedevxml2xmlout/storage_serial_3600c0ff000d7a2a5d463ff4902000000.xml create mode 100644 tests/nodedevxml2xmlout/storage_serial_SATA_HTS721010G9SA00_MPCZ12Y0GNGWSE.xml create mode 100644 tests/nodedevxml2xmlout/usb_device_1d6b_1_0000_00_1d_0.xml create mode 100644 tests/nodedevxml2xmlout/usb_device_1d6b_1_0000_00_1d_0_if0.xml diff --git a/tests/nodedevxml2xmlout/DVD_GCC_4247N.xml b/tests/nodedevxml2xmlout/DVD_GCC_4247N.xml new file mode 100644 index 0000000000..aed787a6c3 --- /dev/null +++ b/tests/nodedevxml2xmlout/DVD_GCC_4247N.xml @@ -0,0 +1,15 @@ +<device> + <name>DVD_GCC_4247N</name> + <parent>pci_8086_27df_scsi_host_scsi_device_lun0</parent> + <capability type='storage'> + <block>/dev/sr0</block> + <bus>scsi</bus> + <drive_type>cdrom</drive_type> + <model>RW/DVD GCC-4247N</model> + <vendor>HL-DT-ST</vendor> + <capability type='removable'> + <media_available>0</media_available> + <media_size>0</media_size> + </capability> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/DVD_with_media.xml b/tests/nodedevxml2xmlout/DVD_with_media.xml new file mode 100644 index 0000000000..f169885eb1 --- /dev/null +++ b/tests/nodedevxml2xmlout/DVD_with_media.xml @@ -0,0 +1,18 @@ +<device> + <name>DVD_GCC_4247N</name> + <parent>pci_8086_27df_scsi_host_scsi_device_lun0</parent> + <capability type='storage'> + <block>/dev/sr0</block> + <bus>scsi</bus> + <drive_type>cdrom</drive_type> + <model>RW/DVD GCC-4247N</model> + <vendor>HL-DT-ST</vendor> + <capability type='removable'> + <media_available>1</media_available> + <media_size>12345678</media_size> + <media_label>Windows_XP_Label</media_label> + <logical_block_size>2048</logical_block_size> + <num_blocks>6028</num_blocks> + </capability> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/ap_07_0038.xml b/tests/nodedevxml2xmlout/ap_07_0038.xml new file mode 100644 index 0000000000..553c68f27b --- /dev/null +++ b/tests/nodedevxml2xmlout/ap_07_0038.xml @@ -0,0 +1,9 @@ +<device> + <name>ap_07_0038</name> + <path>/sys/devices/ap/card07/07.0038</path> + <parent>ap_card07</parent> + <capability type='ap_queue'> + <ap-adapter>0x07</ap-adapter> + <ap-domain>0x0038</ap-domain> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/ap_card07.xml b/tests/nodedevxml2xmlout/ap_card07.xml new file mode 100644 index 0000000000..14a845fd62 --- /dev/null +++ b/tests/nodedevxml2xmlout/ap_card07.xml @@ -0,0 +1,8 @@ +<device> + <name>ap_card07</name> + <path>/sys/devices/ap/card07</path> + <parent>computer</parent> + <capability type='ap_card'> + <ap-adapter>0x07</ap-adapter> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/ap_matrix.xml b/tests/nodedevxml2xmlout/ap_matrix.xml new file mode 100644 index 0000000000..30dab9cfc8 --- /dev/null +++ b/tests/nodedevxml2xmlout/ap_matrix.xml @@ -0,0 +1,7 @@ +<device> + <name>ap_matrix</name> + <path>/sys/devices/vfio_ap/matrix</path> + <parent>computer</parent> + <capability type='ap_matrix'> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/ap_matrix_mdev_types.xml b/tests/nodedevxml2xmlout/ap_matrix_mdev_types.xml new file mode 100644 index 0000000000..b3802e6d8b --- /dev/null +++ b/tests/nodedevxml2xmlout/ap_matrix_mdev_types.xml @@ -0,0 +1,14 @@ +<device> + <name>ap_matrix</name> + <path>/sys/devices/vfio_ap/matrix</path> + <parent>computer</parent> + <capability type='ap_matrix'> + <capability type='mdev_types'> + <type id='vfio_ap-passthrough'> + <name>VFIO AP Passthrough Device</name> + <deviceAPI>vfio-ap</deviceAPI> + <availableInstances>65536</availableInstances> + </type> + </capability> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/ccw_0_0_ffff.xml b/tests/nodedevxml2xmlout/ccw_0_0_ffff.xml new file mode 100644 index 0000000000..3b8ea46e37 --- /dev/null +++ b/tests/nodedevxml2xmlout/ccw_0_0_ffff.xml @@ -0,0 +1,10 @@ +<device> + <name>ccw_0_0_ffff</name> + <path>/sys/devices/css0/0.0.0070/0.0.ffff</path> + <parent>css_0_0_0070</parent> + <capability type='ccw'> + <cssid>0x0</cssid> + <ssid>0x0</ssid> + <devno>0xffff</devno> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/computer.xml b/tests/nodedevxml2xmlout/computer.xml new file mode 100644 index 0000000000..4e4b9188b3 --- /dev/null +++ b/tests/nodedevxml2xmlout/computer.xml @@ -0,0 +1,16 @@ +<device> + <name>computer</name> + <capability type='system'> + <hardware> + <vendor>LENOVO</vendor> + <version>ThinkPad T60p</version> + <serial>123123</serial> + <uuid>12345678-1234-1234-9596-a088b277d677</uuid> + </hardware> + <firmware> + <vendor>LENOVO</vendor> + <version>79ETE1WW (2.21 )</version> + <release_date>02/05/2008</release_date> + </firmware> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/css_0_0_fffe_mdev_types.xml b/tests/nodedevxml2xmlout/css_0_0_fffe_mdev_types.xml new file mode 100644 index 0000000000..5058b6434e --- /dev/null +++ b/tests/nodedevxml2xmlout/css_0_0_fffe_mdev_types.xml @@ -0,0 +1,17 @@ +<device> + <name>css_0_0_fffe</name> + <path>/sys/devices/css0/0.0.fffe</path> + <parent>computer</parent> + <capability type='css'> + <cssid>0x0</cssid> + <ssid>0x0</ssid> + <devno>0xfffe</devno> + <capability type='mdev_types'> + <type id='vfio_ccw-io'> + <name>I/O subchannel (Non-QDIO)</name> + <deviceAPI>vfio-ccw</deviceAPI> + <availableInstances>1</availableInstances> + </type> + </capability> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/css_0_0_ffff.xml b/tests/nodedevxml2xmlout/css_0_0_ffff.xml new file mode 100644 index 0000000000..312e07fe65 --- /dev/null +++ b/tests/nodedevxml2xmlout/css_0_0_ffff.xml @@ -0,0 +1,10 @@ +<device> + <name>css_0_0_ffff</name> + <path>/sys/devices/css0/0.0.ffff</path> + <parent>computer</parent> + <capability type='css'> + <cssid>0x0</cssid> + <ssid>0x0</ssid> + <devno>0xffff</devno> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/drm_renderD129.xml b/tests/nodedevxml2xmlout/drm_renderD129.xml new file mode 100644 index 0000000000..161481624f --- /dev/null +++ b/tests/nodedevxml2xmlout/drm_renderD129.xml @@ -0,0 +1,10 @@ +<device> + <name>drm_renderD129</name> + <path>/sys/devices/pci0000:00/0000:00:02.0/drm/renderD129</path> + <devnode type='dev'>/dev/dri/renderD129</devnode> + <devnode type='link'>/dev/dri/by-path/pci-0000:00:02.0-render</devnode> + <parent>pci_0000_00_02_0</parent> + <capability type='drm'> + <type>render</type> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/mdev_3627463d_b7f0_4fea_b468_f1da537d301b.xml b/tests/nodedevxml2xmlout/mdev_3627463d_b7f0_4fea_b468_f1da537d301b.xml new file mode 100644 index 0000000000..470e5917ec --- /dev/null +++ b/tests/nodedevxml2xmlout/mdev_3627463d_b7f0_4fea_b468_f1da537d301b.xml @@ -0,0 +1,8 @@ +<device> + <name>mdev_3627463d_b7f0_4fea_b468_f1da537d301b</name> + <parent>computer</parent> + <capability type='mdev'> + <type id='mtty-1'/> + <iommuGroup number='12'/> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/mdev_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad.xml b/tests/nodedevxml2xmlout/mdev_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad.xml new file mode 100644 index 0000000000..106f759333 --- /dev/null +++ b/tests/nodedevxml2xmlout/mdev_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad.xml @@ -0,0 +1,9 @@ +<device> + <name>mdev_ee0b88c4-f554-4dc1-809d-b2a01e8e48ad</name> + <path>/sys/devices/vfio_ap/matrix/mdev_ee0b88c4-f554-4dc1-809d-b2a01e8e48ad</path> + <parent>ap_matrix</parent> + <capability type='mdev'> + <type id='vfio_ap-passthrough'/> + <iommuGroup number='0'/> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/net_00_13_02_b9_f9_d3.xml b/tests/nodedevxml2xmlout/net_00_13_02_b9_f9_d3.xml new file mode 100644 index 0000000000..88252e6a4e --- /dev/null +++ b/tests/nodedevxml2xmlout/net_00_13_02_b9_f9_d3.xml @@ -0,0 +1,21 @@ +<device> + <name>net_00_13_02_b9_f9_d3</name> + <parent>pci_8086_4227</parent> + <capability type='net'> + <interface>eth0</interface> + <address>00:13:02:b9:f9:d3</address> + <feature name='rx'/> + <feature name='tx'/> + <feature name='sg'/> + <feature name='tso'/> + <feature name='gso'/> + <feature name='gro'/> + <feature name='rxvlan'/> + <feature name='txvlan'/> + <feature name='rxhash'/> + <feature name='rdma'/> + <feature name='txudptnl'/> + <feature name='switchdev'/> + <capability type='80211'/> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/net_00_15_58_2f_e9_55.xml b/tests/nodedevxml2xmlout/net_00_15_58_2f_e9_55.xml new file mode 100644 index 0000000000..f77dfcc3e0 --- /dev/null +++ b/tests/nodedevxml2xmlout/net_00_15_58_2f_e9_55.xml @@ -0,0 +1,21 @@ +<device> + <name>net_00_15_58_2f_e9_55</name> + <parent>pci_8086_109a</parent> + <capability type='net'> + <interface>eth1</interface> + <address>00:15:58:2f:e9:55</address> + <feature name='rx'/> + <feature name='tx'/> + <feature name='sg'/> + <feature name='tso'/> + <feature name='gso'/> + <feature name='gro'/> + <feature name='rxvlan'/> + <feature name='txvlan'/> + <feature name='rxhash'/> + <feature name='rdma'/> + <feature name='txudptnl'/> + <feature name='switchdev'/> + <capability type='80203'/> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/pci_0000_00_02_0_header_type.xml b/tests/nodedevxml2xmlout/pci_0000_00_02_0_header_type.xml new file mode 100644 index 0000000000..387fce7051 --- /dev/null +++ b/tests/nodedevxml2xmlout/pci_0000_00_02_0_header_type.xml @@ -0,0 +1,16 @@ +<device> + <name>pci_0000_00_02_0</name> + <parent>computer</parent> + <capability type='pci'> + <class>0xffffff</class> + <domain>0</domain> + <bus>0</bus> + <slot>2</slot> + <function>0</function> + <product id='0x0416'>4th Gen Core Processor Integrated Graphics Controller</product> + <vendor id='0x8086'>Intel Corporation</vendor> + <iommuGroup number='1'> + <address domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </iommuGroup> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/pci_0000_00_1c_0_header_type.xml b/tests/nodedevxml2xmlout/pci_0000_00_1c_0_header_type.xml new file mode 100644 index 0000000000..b07d14faa5 --- /dev/null +++ b/tests/nodedevxml2xmlout/pci_0000_00_1c_0_header_type.xml @@ -0,0 +1,21 @@ +<device> + <name>pci_0000_00_1c_0</name> + <parent>computer</parent> + <capability type='pci'> + <class>0xffffff</class> + <domain>0</domain> + <bus>0</bus> + <slot>28</slot> + <function>0</function> + <product id='0x8c10'>8 Series/C220 Series Chipset Family PCI Express Root Port #1</product> + <vendor id='0x8086'>Intel Corporation</vendor> + <capability type='pci-bridge'/> + <iommuGroup number='8'> + <address domain='0x0000' bus='0x00' slot='0x1c' function='0x0'/> + </iommuGroup> + <pci-express> + <link validity='cap' port='1' speed='5' width='1'/> + <link validity='sta' speed='2.5' width='1'/> + </pci-express> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/pci_0000_02_10_7_mdev_types.xml b/tests/nodedevxml2xmlout/pci_0000_02_10_7_mdev_types.xml new file mode 100644 index 0000000000..8e71e3f897 --- /dev/null +++ b/tests/nodedevxml2xmlout/pci_0000_02_10_7_mdev_types.xml @@ -0,0 +1,33 @@ +<device> + <name>pci_0000_02_10_7</name> + <parent>pci_0000_00_04_0</parent> + <capability type='pci'> + <class>0xffffff</class> + <domain>0</domain> + <bus>2</bus> + <slot>16</slot> + <function>7</function> + <product id='0x10ca'>82576 Virtual Function</product> + <vendor id='0x8086'>Intel Corporation</vendor> + <capability type='mdev_types'> + <type id='foo1'> + <name>bar1</name> + <deviceAPI>vfio-pci</deviceAPI> + <availableInstances>1</availableInstances> + </type> + <type id='foo2'> + <name>bar2</name> + <deviceAPI>vfio-pci</deviceAPI> + <availableInstances>2</availableInstances> + </type> + </capability> + <iommuGroup number='31'> + <address domain='0x0000' bus='0x02' slot='0x10' function='0x7'/> + </iommuGroup> + <numa node='0'/> + <pci-express> + <link validity='cap' port='0' speed='2.5' width='4'/> + <link validity='sta' width='0'/> + </pci-express> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov.xml b/tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov.xml new file mode 100644 index 0000000000..6fa2b406a5 --- /dev/null +++ b/tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov.xml @@ -0,0 +1,24 @@ +<device> + <name>pci_0000_02_10_7</name> + <parent>pci_0000_00_04_0</parent> + <capability type='pci'> + <class>0xffffff</class> + <domain>0</domain> + <bus>2</bus> + <slot>16</slot> + <function>7</function> + <product id='0x10ca'>82576 Virtual Function</product> + <vendor id='0x8086'>Intel Corporation</vendor> + <capability type='phys_function'> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x1'/> + </capability> + <iommuGroup number='31'> + <address domain='0x0000' bus='0x02' slot='0x10' function='0x7'/> + </iommuGroup> + <numa node='0'/> + <pci-express> + <link validity='cap' port='0' speed='2.5' width='4'/> + <link validity='sta' width='0'/> + </pci-express> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov_pf_vfs_all.xml b/tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov_pf_vfs_all.xml new file mode 100644 index 0000000000..9e8dace020 --- /dev/null +++ b/tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov_pf_vfs_all.xml @@ -0,0 +1,29 @@ +<device> + <name>pci_0000_02_10_7</name> + <parent>pci_0000_00_04_0</parent> + <capability type='pci'> + <domain>0</domain> + <bus>2</bus> + <slot>16</slot> + <function>7</function> + <product id='0x10ca'>82576 Virtual Function</product> + <vendor id='0x8086'>Intel Corporation</vendor> + <capability type='phys_function'> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x1'/> + </capability> + <capability type='virt_functions' maxCount='7'> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x2'/> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x3'/> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x4'/> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x5'/> + </capability> + <iommuGroup number='31'> + <address domain='0x0000' bus='0x02' slot='0x10' function='0x7'/> + </iommuGroup> + <numa node='0'/> + <pci-express> + <link validity='cap' port='0' speed='2.5' width='4'/> + <link validity='sta' width='0'/> + </pci-express> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov_pf_vfs_all_header_type.xml b/tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov_pf_vfs_all_header_type.xml new file mode 100644 index 0000000000..c30c0d0d2b --- /dev/null +++ b/tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov_pf_vfs_all_header_type.xml @@ -0,0 +1,31 @@ +<device> + <name>pci_0000_02_10_7</name> + <parent>pci_0000_00_04_0</parent> + <capability type='pci'> + <class>0xffffff</class> + <domain>0</domain> + <bus>2</bus> + <slot>16</slot> + <function>7</function> + <product id='0x10ca'>82576 Virtual Function</product> + <vendor id='0x8086'>Intel Corporation</vendor> + <capability type='phys_function'> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x1'/> + </capability> + <capability type='virt_functions' maxCount='7'> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x2'/> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x3'/> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x4'/> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x5'/> + </capability> + <capability type='pci-bridge'/> + <iommuGroup number='31'> + <address domain='0x0000' bus='0x02' slot='0x10' function='0x7'/> + </iommuGroup> + <numa node='0'/> + <pci-express> + <link validity='cap' port='0' speed='2.5' width='4'/> + <link validity='sta' width='0'/> + </pci-express> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov_vfs.xml b/tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov_vfs.xml new file mode 100644 index 0000000000..096055e2ae --- /dev/null +++ b/tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov_vfs.xml @@ -0,0 +1,27 @@ +<device> + <name>pci_0000_02_10_7</name> + <parent>pci_0000_00_04_0</parent> + <capability type='pci'> + <class>0xffffff</class> + <domain>0</domain> + <bus>2</bus> + <slot>16</slot> + <function>7</function> + <product id='0x10ca'>82576 Virtual Function</product> + <vendor id='0x8086'>Intel Corporation</vendor> + <capability type='virt_functions'> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x2'/> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x3'/> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x4'/> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x5'/> + </capability> + <iommuGroup number='31'> + <address domain='0x0000' bus='0x02' slot='0x10' function='0x7'/> + </iommuGroup> + <numa node='0'/> + <pci-express> + <link validity='cap' port='0' speed='2.5' width='4'/> + <link validity='sta' width='0'/> + </pci-express> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov_zero_vfs_max_count.xml b/tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov_zero_vfs_max_count.xml new file mode 100644 index 0000000000..8259cd059b --- /dev/null +++ b/tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov_zero_vfs_max_count.xml @@ -0,0 +1,22 @@ +<device> + <name>pci_0000_02_10_7</name> + <parent>pci_0000_00_04_0</parent> + <capability type='pci'> + <class>0xffffff</class> + <domain>0</domain> + <bus>2</bus> + <slot>16</slot> + <function>7</function> + <product id='0x10ca'>82576 Virtual Function</product> + <vendor id='0x8086'>Intel Corporation</vendor> + <capability type='virt_functions' maxCount='3'/> + <iommuGroup number='31'> + <address domain='0x0000' bus='0x02' slot='0x10' function='0x7'/> + </iommuGroup> + <numa node='0'/> + <pci-express> + <link validity='cap' port='0' speed='2.5' width='4'/> + <link validity='sta' width='0'/> + </pci-express> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/pci_1002_71c4.xml b/tests/nodedevxml2xmlout/pci_1002_71c4.xml new file mode 100644 index 0000000000..2039e2201f --- /dev/null +++ b/tests/nodedevxml2xmlout/pci_1002_71c4.xml @@ -0,0 +1,14 @@ +<device> + <name>pci_1002_71c4</name> + <parent>pci_8086_27a1</parent> + <capability type='pci'> + <class>0xffffff</class> + <domain>0</domain> + <bus>1</bus> + <slot>0</slot> + <function>0</function> + <product id='0x71c4'>M56GL [Mobility FireGL V5200]</product> + <vendor id='0x1002'>ATI Technologies Inc</vendor> + <numa node='1'/> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/pci_8086_0c0c_snd_hda_intel.xml b/tests/nodedevxml2xmlout/pci_8086_0c0c_snd_hda_intel.xml new file mode 100644 index 0000000000..3ffe53b8c9 --- /dev/null +++ b/tests/nodedevxml2xmlout/pci_8086_0c0c_snd_hda_intel.xml @@ -0,0 +1,17 @@ +<device> + <name>pci_0000_00_03_0</name> + <parent>computer</parent> + <capability type='pci'> + <class>0xffffff</class> + <domain>0</domain> + <bus>0</bus> + <slot>3</slot> + <function>0</function> + <product id='0x0c0c'>Xeon E3-1200 v3/4th Gen Core Processor HD Audio Controller</product> + <vendor id='0x8086'>Intel Corporation</vendor> + <iommuGroup number='2'> + <address domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </iommuGroup> + <pci-express/> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/pci_8086_10c9_sriov_pf.xml b/tests/nodedevxml2xmlout/pci_8086_10c9_sriov_pf.xml new file mode 100644 index 0000000000..6bd1292095 --- /dev/null +++ b/tests/nodedevxml2xmlout/pci_8086_10c9_sriov_pf.xml @@ -0,0 +1,18 @@ +<device> + <name>pci_0000_02_00_0</name> + <parent>pci_0000_00_04_0</parent> + <capability type='pci'> + <class>0xffffff</class> + <domain>0</domain> + <bus>2</bus> + <slot>0</slot> + <function>0</function> + <product id='0x10c9'>82576 Gigabit Network Connection</product> + <vendor id='0x8086'>Intel Corporation</vendor> + <iommuGroup number='12'> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x0'/> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x1'/> + </iommuGroup> + <numa node='0'/> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host.xml b/tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host.xml new file mode 100644 index 0000000000..3b377a383f --- /dev/null +++ b/tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host.xml @@ -0,0 +1,7 @@ +<device> + <name>pci_8086_27c5_scsi_host</name> + <parent>pci_8086_27c5</parent> + <capability type='scsi_host'> + <host>0</host> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host_0.xml b/tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host_0.xml new file mode 100644 index 0000000000..a160167824 --- /dev/null +++ b/tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host_0.xml @@ -0,0 +1,7 @@ +<device> + <name>pci_8086_27c5_scsi_host_0</name> + <parent>pci_8086_27c5</parent> + <capability type='scsi_host'> + <host>1</host> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host_0_unique_id.xml b/tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host_0_unique_id.xml new file mode 100644 index 0000000000..5428f59d17 --- /dev/null +++ b/tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host_0_unique_id.xml @@ -0,0 +1,8 @@ +<device> + <name>pci_8086_27c5_scsi_host_0</name> + <parent>pci_8086_27c5</parent> + <capability type='scsi_host'> + <host>1</host> + <unique_id>2</unique_id> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host_scsi_device_lun0.xml b/tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host_scsi_device_lun0.xml new file mode 100644 index 0000000000..5c2dff7b01 --- /dev/null +++ b/tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host_scsi_device_lun0.xml @@ -0,0 +1,11 @@ +<device> + <name>pci_8086_27c5_scsi_host_scsi_device_lun0</name> + <parent>pci_8086_27c5_scsi_host</parent> + <capability type='scsi'> + <host>0</host> + <bus>0</bus> + <target>0</target> + <lun>0</lun> + <type>disk</type> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host_scsi_host.xml b/tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host_scsi_host.xml new file mode 100644 index 0000000000..8ffb0a5bb8 --- /dev/null +++ b/tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host_scsi_host.xml @@ -0,0 +1,7 @@ +<device> + <name>pci_8086_27c5_scsi_host_scsi_host</name> + <parent>pci_8086_27c5_scsi_host</parent> + <capability type='scsi_host'> + <host>0</host> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/pci_8086_4238_pcie_wireless.xml b/tests/nodedevxml2xmlout/pci_8086_4238_pcie_wireless.xml new file mode 100644 index 0000000000..59f5ec8622 --- /dev/null +++ b/tests/nodedevxml2xmlout/pci_8086_4238_pcie_wireless.xml @@ -0,0 +1,27 @@ +<device> + <name>pci_0000_03_00_0</name> + <parent>pci_0000_00_1c_1</parent> + <capability type='pci'> + <class>0xffffff</class> + <domain>0</domain> + <bus>3</bus> + <slot>0</slot> + <function>0</function> + <product id='0x4238'>Centrino Ultimate-N 6300</product> + <vendor id='0x8086'>Intel Corporation</vendor> + <iommuGroup number='8'> + <address domain='0x0000' bus='0x00' slot='0x1c' function='0x0'/> + <address domain='0x0000' bus='0x00' slot='0x1c' function='0x1'/> + <address domain='0x0000' bus='0x00' slot='0x1c' function='0x3'/> + <address domain='0x0000' bus='0x00' slot='0x1c' function='0x4'/> + <address domain='0x0000' bus='0x03' slot='0x00' function='0x0'/> + <address domain='0x0000' bus='0x0d' slot='0x00' function='0x0'/> + <address domain='0x0000' bus='0x0d' slot='0x00' function='0x1'/> + <address domain='0x0000' bus='0x0d' slot='0x00' function='0x3'/> + </iommuGroup> + <pci-express> + <link validity='cap' port='1' speed='2.5' width='1'/> + <link validity='sta' speed='2.5' width='1'/> + </pci-express> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/scsi_target0_0_0.xml b/tests/nodedevxml2xmlout/scsi_target0_0_0.xml new file mode 100644 index 0000000000..b83c96dfda --- /dev/null +++ b/tests/nodedevxml2xmlout/scsi_target0_0_0.xml @@ -0,0 +1,7 @@ +<device> + <name>scsi_target0_0_0</name> + <parent>scsi_host0</parent> + <capability type='scsi_target'> + <target>target0:0:0</target> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/scsi_target1_0_0.xml b/tests/nodedevxml2xmlout/scsi_target1_0_0.xml new file mode 100644 index 0000000000..b783c54fea --- /dev/null +++ b/tests/nodedevxml2xmlout/scsi_target1_0_0.xml @@ -0,0 +1,12 @@ +<device> + <name>scsi_target1_0_0</name> + <path>/sys/devices/css0/0.0.0000/0.0.0000/host1/rport-1:0-0/target1:0:0</path> + <parent>scsi_host0</parent> + <capability type='scsi_target'> + <target>target1:0:0</target> + <capability type='fc_remote_port'> + <rport>rport-1:0-0</rport> + <wwpn>0x9d73bc45f0e21a86</wwpn> + </capability> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/storage_serial_3600c0ff000d7a2a5d463ff4902000000.xml b/tests/nodedevxml2xmlout/storage_serial_3600c0ff000d7a2a5d463ff4902000000.xml new file mode 100644 index 0000000000..5bdbb8ac95 --- /dev/null +++ b/tests/nodedevxml2xmlout/storage_serial_3600c0ff000d7a2a5d463ff4902000000.xml @@ -0,0 +1,19 @@ +<device> + <name>storage_serial_3600c0ff000d7a2a5d463ff4902000000</name> + <devnode type='dev'>/dev/sdb</devnode> + <devnode type='link'>/dev/disk/by-id/usb-SanDisk_Ultra_Fit_4C530001051009112405-0:0</devnode> + <devnode type='link'>/dev/disk/by-path/pci-0000:00:14.0-usb-0:1:1.0-scsi-0:0:0:0</devnode> + <devnode type='link'>/dev/disk/by-uuid/661A1A460111DA18</devnode> + <parent>pci_10df_fe00_scsi_host_scsi_device_lun8</parent> + <capability type='storage'> + <block>/dev/sdj</block> + <bus>pci</bus> + <drive_type>disk</drive_type> + <model>MSA2012fc</model> + <vendor>HP</vendor> + <serial>3600c0ff000d7a2a5d463ff4902000000</serial> + <size>15626928128</size> + <logical_block_size>512</logical_block_size> + <num_blocks>30521344</num_blocks> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/storage_serial_SATA_HTS721010G9SA00_MPCZ12Y0GNGWSE.xml b/tests/nodedevxml2xmlout/storage_serial_SATA_HTS721010G9SA00_MPCZ12Y0GNGWSE.xml new file mode 100644 index 0000000000..68dbf0be96 --- /dev/null +++ b/tests/nodedevxml2xmlout/storage_serial_SATA_HTS721010G9SA00_MPCZ12Y0GNGWSE.xml @@ -0,0 +1,14 @@ +<device> + <name>storage_serial_SATA_HTS721010G9SA00_MPCZ12Y0GNGWSE</name> + <parent>pci_8086_27c5_scsi_host_scsi_device_lun0</parent> + <capability type='storage'> + <block>/dev/sda</block> + <bus>scsi</bus> + <drive_type>disk</drive_type> + <model>HTS721010G9SA00</model> + <vendor>ATA</vendor> + <size>100030242816</size> + <logical_block_size>512</logical_block_size> + <num_blocks>195371568</num_blocks> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/usb_device_1d6b_1_0000_00_1d_0.xml b/tests/nodedevxml2xmlout/usb_device_1d6b_1_0000_00_1d_0.xml new file mode 100644 index 0000000000..29533e769b --- /dev/null +++ b/tests/nodedevxml2xmlout/usb_device_1d6b_1_0000_00_1d_0.xml @@ -0,0 +1,10 @@ +<device> + <name>usb_device_1d6b_1_0000_00_1d_0</name> + <parent>pci_8086_27c8</parent> + <capability type='usb_device'> + <bus>2</bus> + <device>1</device> + <product id='0x0001'>1.1 root hub</product> + <vendor id='0x1d6b'>Linux Foundation</vendor> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/usb_device_1d6b_1_0000_00_1d_0_if0.xml b/tests/nodedevxml2xmlout/usb_device_1d6b_1_0000_00_1d_0_if0.xml new file mode 100644 index 0000000000..9de35c7e8c --- /dev/null +++ b/tests/nodedevxml2xmlout/usb_device_1d6b_1_0000_00_1d_0_if0.xml @@ -0,0 +1,10 @@ +<device> + <name>usb_device_1d6b_1_0000_00_1d_0_if0</name> + <parent>usb_device_1d6b_1_0000_00_1d_0</parent> + <capability type='usb'> + <number>0</number> + <class>9</class> + <subclass>0</subclass> + <protocol>0</protocol> + </capability> +</device> diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c index 4ebd578ccc..04d238bbca 100644 --- a/tests/nodedevxml2xmltest.c +++ b/tests/nodedevxml2xmltest.c @@ -14,7 +14,7 @@ #define VIR_FROM_THIS VIR_FROM_NONE static int -testCompareXMLToXMLFiles(const char *xml) +testCompareXMLToXMLFiles(const char *xml, const char *outfile) { char *xmlData = NULL; char *actual = NULL; @@ -52,10 +52,8 @@ testCompareXMLToXMLFiles(const char *xml) if (!(actual = virNodeDeviceDefFormat(dev))) goto fail; - if (STRNEQ(xmlData, actual)) { - virTestDifferenceFull(stderr, xmlData, xml, actual, NULL); + if (virTestCompareToFile(actual, outfile) < 0) goto fail; - } ret = 0; @@ -71,11 +69,15 @@ testCompareXMLToXMLHelper(const void *data) { int result = -1; char *xml = NULL; + char *outfile = NULL; xml = g_strdup_printf("%s/nodedevschemadata/%s.xml", abs_srcdir, (const char *)data); - result = testCompareXMLToXMLFiles(xml); + outfile = g_strdup_printf("%s/nodedevxml2xmlout/%s.xml", abs_srcdir, + (const char *)data); + + result = testCompareXMLToXMLFiles(xml, outfile); VIR_FREE(xml); return result; -- 2.31.1

On Fri, May 14, 2021 at 04:28:58PM -0500, Jonathon Jongsma wrote:
Currently, we're loading and parsing the xml from the input file, and then formatting it and then comparing it directly back to the input file. This works for now, but is severely limiting as it relies on the input file being fully-specified and in the exact order as the output xml format.
If optional elements are ommitted in the input XML, the output xml may include default values for the ommitted elements and thus the output will not match the input.
In order to allow more flexibility in testing, save the expected output to a seprate 'out' directory similar to what most of the other xml2xml tests are already doing.
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- tests/nodedevxml2xmlout/DVD_GCC_4247N.xml | 15 +++++++++ tests/nodedevxml2xmlout/DVD_with_media.xml | 18 ++++++++++ tests/nodedevxml2xmlout/ap_07_0038.xml | 9 +++++ tests/nodedevxml2xmlout/ap_card07.xml | 8 +++++ tests/nodedevxml2xmlout/ap_matrix.xml | 7 ++++ .../ap_matrix_mdev_types.xml | 14 ++++++++ tests/nodedevxml2xmlout/ccw_0_0_ffff.xml | 10 ++++++ tests/nodedevxml2xmlout/computer.xml | 16 +++++++++ .../css_0_0_fffe_mdev_types.xml | 17 ++++++++++ tests/nodedevxml2xmlout/css_0_0_ffff.xml | 10 ++++++ tests/nodedevxml2xmlout/drm_renderD129.xml | 10 ++++++ ...v_3627463d_b7f0_4fea_b468_f1da537d301b.xml | 8 +++++ ...v_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad.xml | 9 +++++ .../net_00_13_02_b9_f9_d3.xml | 21 ++++++++++++ .../net_00_15_58_2f_e9_55.xml | 21 ++++++++++++ .../pci_0000_00_02_0_header_type.xml | 16 +++++++++ .../pci_0000_00_1c_0_header_type.xml | 21 ++++++++++++ .../pci_0000_02_10_7_mdev_types.xml | 33 +++++++++++++++++++ .../pci_0000_02_10_7_sriov.xml | 24 ++++++++++++++ .../pci_0000_02_10_7_sriov_pf_vfs_all.xml | 29 ++++++++++++++++ ...0_02_10_7_sriov_pf_vfs_all_header_type.xml | 31 +++++++++++++++++ .../pci_0000_02_10_7_sriov_vfs.xml | 27 +++++++++++++++ ..._0000_02_10_7_sriov_zero_vfs_max_count.xml | 22 +++++++++++++ tests/nodedevxml2xmlout/pci_1002_71c4.xml | 14 ++++++++ .../pci_8086_0c0c_snd_hda_intel.xml | 17 ++++++++++ .../pci_8086_10c9_sriov_pf.xml | 18 ++++++++++ .../pci_8086_27c5_scsi_host.xml | 7 ++++ .../pci_8086_27c5_scsi_host_0.xml | 7 ++++ .../pci_8086_27c5_scsi_host_0_unique_id.xml | 8 +++++ ...i_8086_27c5_scsi_host_scsi_device_lun0.xml | 11 +++++++ .../pci_8086_27c5_scsi_host_scsi_host.xml | 7 ++++ .../pci_8086_4238_pcie_wireless.xml | 27 +++++++++++++++ tests/nodedevxml2xmlout/scsi_target0_0_0.xml | 7 ++++ tests/nodedevxml2xmlout/scsi_target1_0_0.xml | 12 +++++++ ...rial_3600c0ff000d7a2a5d463ff4902000000.xml | 19 +++++++++++ ...al_SATA_HTS721010G9SA00_MPCZ12Y0GNGWSE.xml | 14 ++++++++ .../usb_device_1d6b_1_0000_00_1d_0.xml | 10 ++++++ .../usb_device_1d6b_1_0000_00_1d_0_if0.xml | 10 ++++++ tests/nodedevxml2xmltest.c | 12 ++++--- 39 files changed, 591 insertions(+), 5 deletions(-) create mode 100644 tests/nodedevxml2xmlout/DVD_GCC_4247N.xml create mode 100644 tests/nodedevxml2xmlout/DVD_with_media.xml create mode 100644 tests/nodedevxml2xmlout/ap_07_0038.xml create mode 100644 tests/nodedevxml2xmlout/ap_card07.xml create mode 100644 tests/nodedevxml2xmlout/ap_matrix.xml create mode 100644 tests/nodedevxml2xmlout/ap_matrix_mdev_types.xml create mode 100644 tests/nodedevxml2xmlout/ccw_0_0_ffff.xml create mode 100644 tests/nodedevxml2xmlout/computer.xml create mode 100644 tests/nodedevxml2xmlout/css_0_0_fffe_mdev_types.xml create mode 100644 tests/nodedevxml2xmlout/css_0_0_ffff.xml create mode 100644 tests/nodedevxml2xmlout/drm_renderD129.xml create mode 100644 tests/nodedevxml2xmlout/mdev_3627463d_b7f0_4fea_b468_f1da537d301b.xml create mode 100644 tests/nodedevxml2xmlout/mdev_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad.xml create mode 100644 tests/nodedevxml2xmlout/net_00_13_02_b9_f9_d3.xml create mode 100644 tests/nodedevxml2xmlout/net_00_15_58_2f_e9_55.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_00_02_0_header_type.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_00_1c_0_header_type.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_02_10_7_mdev_types.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov_pf_vfs_all.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov_pf_vfs_all_header_type.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov_vfs.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov_zero_vfs_max_count.xml create mode 100644 tests/nodedevxml2xmlout/pci_1002_71c4.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_0c0c_snd_hda_intel.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_10c9_sriov_pf.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host_0.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host_0_unique_id.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host_scsi_device_lun0.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host_scsi_host.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_4238_pcie_wireless.xml create mode 100644 tests/nodedevxml2xmlout/scsi_target0_0_0.xml create mode 100644 tests/nodedevxml2xmlout/scsi_target1_0_0.xml create mode 100644 tests/nodedevxml2xmlout/storage_serial_3600c0ff000d7a2a5d463ff4902000000.xml create mode 100644 tests/nodedevxml2xmlout/storage_serial_SATA_HTS721010G9SA00_MPCZ12Y0GNGWSE.xml create mode 100644 tests/nodedevxml2xmlout/usb_device_1d6b_1_0000_00_1d_0.xml create mode 100644 tests/nodedevxml2xmlout/usb_device_1d6b_1_0000_00_1d_0_if0.xml
[...]
diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c index 4ebd578ccc..04d238bbca 100644 --- a/tests/nodedevxml2xmltest.c +++ b/tests/nodedevxml2xmltest.c @@ -14,7 +14,7 @@ #define VIR_FROM_THIS VIR_FROM_NONE
static int -testCompareXMLToXMLFiles(const char *xml) +testCompareXMLToXMLFiles(const char *xml, const char *outfile) { char *xmlData = NULL; char *actual = NULL; @@ -52,10 +52,8 @@ testCompareXMLToXMLFiles(const char *xml) if (!(actual = virNodeDeviceDefFormat(dev))) goto fail;
- if (STRNEQ(xmlData, actual)) { - virTestDifferenceFull(stderr, xmlData, xml, actual, NULL); + if (virTestCompareToFile(actual, outfile) < 0) goto fail; - }
ret = 0;
@@ -71,11 +69,15 @@ testCompareXMLToXMLHelper(const void *data) { int result = -1; char *xml = NULL; + char *outfile = NULL;
xml = g_strdup_printf("%s/nodedevschemadata/%s.xml", abs_srcdir, (const char *)data);
- result = testCompareXMLToXMLFiles(xml); + outfile = g_strdup_printf("%s/nodedevxml2xmlout/%s.xml", abs_srcdir, + (const char *)data); + + result = testCompareXMLToXMLFiles(xml, outfile);
VIR_FREE(xml);
VIR_FREE(outfile);
return result;
Pavel

On 5/14/21 11:28 PM, Jonathon Jongsma wrote:
Currently, we're loading and parsing the xml from the input file, and then formatting it and then comparing it directly back to the input file. This works for now, but is severely limiting as it relies on the input file being fully-specified and in the exact order as the output xml format.
If optional elements are ommitted in the input XML, the output xml may include default values for the ommitted elements and thus the output will not match the input.
In order to allow more flexibility in testing, save the expected output to a seprate 'out' directory similar to what most of the other xml2xml tests are already doing.
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> ---
Fair enough - we have plenty of examples around, qemuxml2xmloutdata/ to name the biggest one. However, what we also do (to save disk space) is to turn those files where input XML is the same as output XML into symlinks. I've identified a few which could be just a symlink: tests/nodedevxml2xmlout $ for i in *; do if diff $i ../nodedevschemadata/$i >/dev/null ; then echo $i; fi; done DVD_GCC_4247N.xml DVD_with_media.xml ap_07_0038.xml ap_card07.xml ap_matrix.xml ap_matrix_mdev_types.xml .... I know you are modifying some of these files (mdev*), that's why I ran the command only after all your patches. For these patches we could make everything a symlink in 1/4 and then as we need to make changes (in 2/4 and 3/4) remove those symlinks and make regular copies. Do you think it's worth doing? If so, no need to resend, it's something I can fix before pushing. Plus marking @outfile variable in testCompareXMLToXMLHelper() as g_autofree (thanks to Pavel who noticed!). Patches look good otherwise. Michal

On Wed, 2021-05-19 at 10:46 +0200, Michal Prívozník wrote:
On 5/14/21 11:28 PM, Jonathon Jongsma wrote:
Currently, we're loading and parsing the xml from the input file, and then formatting it and then comparing it directly back to the input file. This works for now, but is severely limiting as it relies on the input file being fully-specified and in the exact order as the output xml format.
If optional elements are ommitted in the input XML, the output xml may include default values for the ommitted elements and thus the output will not match the input.
In order to allow more flexibility in testing, save the expected output to a seprate 'out' directory similar to what most of the other xml2xml tests are already doing.
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> ---
Fair enough - we have plenty of examples around, qemuxml2xmloutdata/ to name the biggest one. However, what we also do (to save disk space) is to turn those files where input XML is the same as output XML into symlinks. I've identified a few which could be just a symlink:
tests/nodedevxml2xmlout $ for i in *; do if diff $i ../nodedevschemadata/$i >/dev/null ; then echo $i; fi; done DVD_GCC_4247N.xml DVD_with_media.xml ap_07_0038.xml ap_card07.xml ap_matrix.xml ap_matrix_mdev_types.xml ....
I know you are modifying some of these files (mdev*), that's why I ran the command only after all your patches. For these patches we could make everything a symlink in 1/4 and then as we need to make changes (in 2/4 and 3/4) remove those symlinks and make regular copies.
Do you think it's worth doing? If so, no need to resend, it's something I can fix before pushing. Plus marking @outfile variable in testCompareXMLToXMLHelper() as g_autofree (thanks to Pavel who noticed!).
Sure, that's fine with me. The vast majority of these files are staying the same (which is why the tests currently pass -- the output is identical to the input). So symlinks should be fine for those. Thanks, Jonathon

On 5/19/21 6:09 PM, Jonathon Jongsma wrote:
On Wed, 2021-05-19 at 10:46 +0200, Michal Prívozník wrote:
On 5/14/21 11:28 PM, Jonathon Jongsma wrote:
Currently, we're loading and parsing the xml from the input file, and then formatting it and then comparing it directly back to the input file. This works for now, but is severely limiting as it relies on the input file being fully-specified and in the exact order as the output xml format.
If optional elements are ommitted in the input XML, the output xml may include default values for the ommitted elements and thus the output will not match the input.
In order to allow more flexibility in testing, save the expected output to a seprate 'out' directory similar to what most of the other xml2xml tests are already doing.
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> ---
Fair enough - we have plenty of examples around, qemuxml2xmloutdata/ to name the biggest one. However, what we also do (to save disk space) is to turn those files where input XML is the same as output XML into symlinks. I've identified a few which could be just a symlink:
tests/nodedevxml2xmlout $ for i in *; do if diff $i ../nodedevschemadata/$i >/dev/null ; then echo $i; fi; done DVD_GCC_4247N.xml DVD_with_media.xml ap_07_0038.xml ap_card07.xml ap_matrix.xml ap_matrix_mdev_types.xml ....
I know you are modifying some of these files (mdev*), that's why I ran the command only after all your patches. For these patches we could make everything a symlink in 1/4 and then as we need to make changes (in 2/4 and 3/4) remove those symlinks and make regular copies.
Do you think it's worth doing? If so, no need to resend, it's something I can fix before pushing. Plus marking @outfile variable in testCompareXMLToXMLHelper() as g_autofree (thanks to Pavel who noticed!).
Sure, that's fine with me. The vast majority of these files are staying the same (which is why the tests currently pass -- the output is identical to the input). So symlinks should be fine for those.
Awesome, I've fixed all those things we talked about and merged. For whole series: Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Michal

From: Boris Fiuczynski <fiuczy@linux.ibm.com> This adds a new element to the mdev capabilities xml schema that represents the start policy for a defined mediated device. The actual auto-start functionality is handled behind the scenes by mdevctl, but it wasn't yet hooked up in libvirt. Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- docs/formatnode.html.in | 10 ++++++++++ docs/schemas/nodedev.rng | 11 ++++++++++ src/conf/node_device_conf.c | 20 ++++++++++++++++++- src/conf/node_device_conf.h | 12 +++++++++++ src/libvirt_private.syms | 2 ++ src/node_device/node_device_driver.c | 7 ++++++- .../mdevctl-list-multiple.out.xml | 4 ++++ ...v_3627463d_b7f0_4fea_b468_f1da537d301b.xml | 1 + ...v_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad.xml | 1 + 9 files changed, 66 insertions(+), 2 deletions(-) diff --git a/docs/formatnode.html.in b/docs/formatnode.html.in index c58cd01395..3065570405 100644 --- a/docs/formatnode.html.in +++ b/docs/formatnode.html.in @@ -384,6 +384,16 @@ The order that they appear in the xml definition determines the order that they will be written to the device. </dd> + <dt><code>start</code></dt> + <dd> + This element represents the start policy for the device. It + has a required attribute <code>type</code>, which can have a + value of <code>auto</code> or <code>manual</code>. Mediated + devices with an <code>auto</code> start type will be started + automatically by the host when the parent device becomes + available (either on boot, or when the parent device is + attached). Otherwise the device must be started manually. + </dd> </dl> </dd> <dt><code>ccw</code></dt> diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng index 777227c38a..660cbda3be 100644 --- a/docs/schemas/nodedev.rng +++ b/docs/schemas/nodedev.rng @@ -622,6 +622,17 @@ </attribute> </element> </optional> + <optional> + <element name="start"> + <attribute name="type"> + <choice> + <value>manual</value> + <value>auto</value> + </choice> + </attribute> + <empty/> + </element> + </optional> <optional> <element name="uuid"> <ref name="UUID"/> diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 861f43f6c4..9c1192fe3b 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -85,6 +85,12 @@ VIR_ENUM_IMPL(virNodeDevDRM, "render", ); +VIR_ENUM_IMPL(virNodeDevMdevStart, + VIR_NODE_DEV_MDEV_START_LAST, + "manual", + "auto", +); + static int virNodeDevCapsDefParseString(const char *xpath, xmlXPathContextPtr ctxt, @@ -528,6 +534,8 @@ virNodeDeviceCapMdevDefFormat(virBuffer *buf, virBufferEscapeString(buf, "<type id='%s'/>\n", data->mdev.type); virBufferEscapeString(buf, "<uuid>%s</uuid>\n", data->mdev.uuid); + virBufferEscapeString(buf, "<start type='%s'/>\n", + virNodeDevMdevStartTypeToString(data->mdev.start)); virBufferAsprintf(buf, "<iommuGroup number='%u'/>\n", data->mdev.iommuGroupNumber); @@ -1149,7 +1157,6 @@ virNodeDevCapStorageParseXML(xmlXPathContextPtr ctxt, return -1; } storage->removable_media_size = val; - ctxt->node = orignode2; } else { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1923,6 +1930,7 @@ virNodeDevCapMdevParseXML(xmlXPathContextPtr ctxt, g_autofree xmlNodePtr *attrs = NULL; size_t i; g_autofree char *uuidstr = NULL; + g_autofree char *starttype = NULL; ctxt->node = node; @@ -1944,6 +1952,16 @@ virNodeDevCapMdevParseXML(xmlXPathContextPtr ctxt, virUUIDFormat(uuidbuf, mdev->uuid); } + if ((starttype = virXPathString("string(./start[1]/@type)", ctxt))) { + if ((mdev->start = virNodeDevMdevStartTypeFromString(starttype)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown mdev start type '%s' for '%s'"), starttype, def->name); + return -1; + } + } else { + mdev->start = VIR_NODE_DEV_MDEV_START_MANUAL; + } + /* 'iommuGroup' is optional, only report an error if the supplied value is * invalid (-2), not if it's missing (-1) */ if (virXPathUInt("number(./iommuGroup[1]/@number)", diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index a60562e4fe..1a31133c4c 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -124,6 +124,17 @@ typedef enum { VIR_ENUM_DECL(virNodeDevDRM); +typedef enum { + /* Keep in sync with VIR_ENUM_IMPL in node_device_conf.c */ + VIR_NODE_DEV_MDEV_START_MANUAL, + VIR_NODE_DEV_MDEV_START_AUTO, + + VIR_NODE_DEV_MDEV_START_LAST +} virNodeDevMdevStartType; + +VIR_ENUM_DECL(virNodeDevMdevStart); + + typedef struct _virNodeDevCapSystemHardware virNodeDevCapSystemHardware; struct _virNodeDevCapSystemHardware { char *vendor_name; @@ -151,6 +162,7 @@ struct _virNodeDevCapMdev { char *type; unsigned int iommuGroupNumber; char *uuid; + virNodeDevMdevStartType start; virMediatedDeviceAttr **attributes; size_t nattributes; }; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 1df4b8cfe8..7aae36de56 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -846,6 +846,8 @@ virNodeDeviceGetSCSIHostCaps; virNodeDeviceGetSCSITargetCaps; virNodeDeviceGetWWNs; virNodeDeviceUpdateCaps; +virNodeDevMdevStartTypeFromString; +virNodeDevMdevStartTypeToString; # conf/node_device_event.h diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c index 8a0a2c3847..a9f605715b 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -615,7 +615,8 @@ nodeDeviceDefToMdevctlConfig(virNodeDeviceDef *def, char **buf) if (virJSONValueObjectAppendString(json, "mdev_type", mdev->type) < 0) return -1; - if (virJSONValueObjectAppendString(json, "start", "manual") < 0) + if (virJSONValueObjectAppendString(json, "start", + virNodeDevMdevStartTypeToString(mdev->start)) < 0) return -1; if (mdev->attributes) { @@ -1014,6 +1015,8 @@ nodeDeviceParseMdevctlChildDevice(const char *parent, mdev->uuid = g_strdup(uuid); mdev->type = g_strdup(virJSONValueObjectGetString(props, "mdev_type")); + mdev->start = + virNodeDevMdevStartTypeFromString(virJSONValueObjectGetString(props, "start")); attrs = virJSONValueObjectGet(props, "attrs"); @@ -1683,6 +1686,8 @@ nodeDeviceDefCopyFromMdevctl(virNodeDeviceDef *dst, dstmdev->uuid = g_strdup(srcmdev->uuid); } + dstmdev->start = srcmdev->start; + if (virMediatedDeviceAttrsCopy(dstmdev, srcmdev)) ret = true; diff --git a/tests/nodedevmdevctldata/mdevctl-list-multiple.out.xml b/tests/nodedevmdevctldata/mdevctl-list-multiple.out.xml index cf7e966256..83a3010455 100644 --- a/tests/nodedevmdevctldata/mdevctl-list-multiple.out.xml +++ b/tests/nodedevmdevctldata/mdevctl-list-multiple.out.xml @@ -4,6 +4,7 @@ <capability type='mdev'> <type id='i915-GVTg_V5_4'/> <uuid>200f228a-c80a-4d50-bfb7-f5a0e4e34045</uuid> + <start type='manual'/> <iommuGroup number='0'/> </capability> </device> @@ -13,6 +14,7 @@ <capability type='mdev'> <type id='i915-GVTg_V5_4'/> <uuid>de807ffc-1923-4d5f-b6c9-b20ecebc6d4b</uuid> + <start type='auto'/> <iommuGroup number='0'/> </capability> </device> @@ -22,6 +24,7 @@ <capability type='mdev'> <type id='i915-GVTg_V5_8'/> <uuid>435722ea-5f43-468a-874f-da34f1217f13</uuid> + <start type='manual'/> <iommuGroup number='0'/> <attr name='testattr' value='42'/> </capability> @@ -32,6 +35,7 @@ <capability type='mdev'> <type id='vfio_ap-passthrough'/> <uuid>783e6dbb-ea0e-411f-94e2-717eaad438bf</uuid> + <start type='manual'/> <iommuGroup number='0'/> <attr name='assign_adapter' value='5'/> <attr name='assign_adapter' value='6'/> diff --git a/tests/nodedevxml2xmlout/mdev_3627463d_b7f0_4fea_b468_f1da537d301b.xml b/tests/nodedevxml2xmlout/mdev_3627463d_b7f0_4fea_b468_f1da537d301b.xml index 470e5917ec..30dda60e87 100644 --- a/tests/nodedevxml2xmlout/mdev_3627463d_b7f0_4fea_b468_f1da537d301b.xml +++ b/tests/nodedevxml2xmlout/mdev_3627463d_b7f0_4fea_b468_f1da537d301b.xml @@ -3,6 +3,7 @@ <parent>computer</parent> <capability type='mdev'> <type id='mtty-1'/> + <start type='manual'/> <iommuGroup number='12'/> </capability> </device> diff --git a/tests/nodedevxml2xmlout/mdev_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad.xml b/tests/nodedevxml2xmlout/mdev_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad.xml index 106f759333..1988ffa679 100644 --- a/tests/nodedevxml2xmlout/mdev_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad.xml +++ b/tests/nodedevxml2xmlout/mdev_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad.xml @@ -4,6 +4,7 @@ <parent>ap_matrix</parent> <capability type='mdev'> <type id='vfio_ap-passthrough'/> + <start type='manual'/> <iommuGroup number='0'/> </capability> </device> -- 2.31.1

On 5/14/21 11:28 PM, Jonathon Jongsma wrote:
From: Boris Fiuczynski <fiuczy@linux.ibm.com>
This adds a new element to the mdev capabilities xml schema that represents the start policy for a defined mediated device. The actual auto-start functionality is handled behind the scenes by mdevctl, but it wasn't yet hooked up in libvirt.
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- docs/formatnode.html.in | 10 ++++++++++ docs/schemas/nodedev.rng | 11 ++++++++++ src/conf/node_device_conf.c | 20 ++++++++++++++++++- src/conf/node_device_conf.h | 12 +++++++++++ src/libvirt_private.syms | 2 ++ src/node_device/node_device_driver.c | 7 ++++++- .../mdevctl-list-multiple.out.xml | 4 ++++ ...v_3627463d_b7f0_4fea_b468_f1da537d301b.xml | 1 + ...v_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad.xml | 1 + 9 files changed, 66 insertions(+), 2 deletions(-)
diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index a60562e4fe..1a31133c4c 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -124,6 +124,17 @@ typedef enum {
VIR_ENUM_DECL(virNodeDevDRM);
+typedef enum { + /* Keep in sync with VIR_ENUM_IMPL in node_device_conf.c */
I know you copied this from pre-existing code, but it shouldn't be there either. If this enum ever changes and corresponding VIR_ENUM_IMPL() is not updated, compiler throws an error. I admit it's very well hidden, but if you look at VIR_ENUM_IMPL() macro definition in src/util/virenum.h at the very end of it is a G_STATIC_ASSERT() which ensures that VIR_ENUM_IMPL() has as many items as the value of _LAST.
+ VIR_NODE_DEV_MDEV_START_MANUAL, + VIR_NODE_DEV_MDEV_START_AUTO, + + VIR_NODE_DEV_MDEV_START_LAST +} virNodeDevMdevStartType; + +VIR_ENUM_DECL(virNodeDevMdevStart); + + typedef struct _virNodeDevCapSystemHardware virNodeDevCapSystemHardware; struct _virNodeDevCapSystemHardware { char *vendor_name; @@ -151,6 +162,7 @@ struct _virNodeDevCapMdev { char *type; unsigned int iommuGroupNumber; char *uuid; + virNodeDevMdevStartType start; virMediatedDeviceAttr **attributes; size_t nattributes; };
Michal

On Fri, May 14, 2021 at 16:28:59 -0500, Jonathon Jongsma wrote:
From: Boris Fiuczynski <fiuczy@linux.ibm.com>
This adds a new element to the mdev capabilities xml schema that represents the start policy for a defined mediated device. The actual auto-start functionality is handled behind the scenes by mdevctl, but it wasn't yet hooked up in libvirt.
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- docs/formatnode.html.in | 10 ++++++++++ docs/schemas/nodedev.rng | 11 ++++++++++ src/conf/node_device_conf.c | 20 ++++++++++++++++++- src/conf/node_device_conf.h | 12 +++++++++++ src/libvirt_private.syms | 2 ++ src/node_device/node_device_driver.c | 7 ++++++- .../mdevctl-list-multiple.out.xml | 4 ++++ ...v_3627463d_b7f0_4fea_b468_f1da537d301b.xml | 1 + ...v_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad.xml | 1 + 9 files changed, 66 insertions(+), 2 deletions(-)
[...]
@@ -1944,6 +1952,16 @@ virNodeDevCapMdevParseXML(xmlXPathContextPtr ctxt, virUUIDFormat(uuidbuf, mdev->uuid); }
+ if ((starttype = virXPathString("string(./start[1]/@type)", ctxt))) { + if ((mdev->start = virNodeDevMdevStartTypeFromString(starttype)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown mdev start type '%s' for '%s'"), starttype, def->name); + return -1;
This broke the build: https://listman.redhat.com/archives/libvir-list/2021-May/msg00593.html Please make sure to compile your tree also with clang.
+ } + } else { + mdev->start = VIR_NODE_DEV_MDEV_START_MANUAL; + } +

Add the rest of the mdev xml files to the xml2xml test, and include 2 new test cases: one that explicitly specifies 'manual' start, and one that explicitly specifies 'auto' start. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- tests/nodedevschemadata/mdev_autostart.xml | 10 ++++++++++ tests/nodedevschemadata/mdev_manual.xml | 10 ++++++++++ tests/nodedevxml2xmlout/mdev_autostart.xml | 11 +++++++++++ .../mdev_d069d019_36ea_4111_8f0a_8c9a70e21366.xml | 10 ++++++++++ .../mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9.xml | 11 +++++++++++ .../mdev_fedc4916_1ca8_49ac_b176_871d16c13076.xml | 10 ++++++++++ tests/nodedevxml2xmlout/mdev_manual.xml | 11 +++++++++++ tests/nodedevxml2xmltest.c | 5 +++++ 8 files changed, 78 insertions(+) create mode 100644 tests/nodedevschemadata/mdev_autostart.xml create mode 100644 tests/nodedevschemadata/mdev_manual.xml create mode 100644 tests/nodedevxml2xmlout/mdev_autostart.xml create mode 100644 tests/nodedevxml2xmlout/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366.xml create mode 100644 tests/nodedevxml2xmlout/mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9.xml create mode 100644 tests/nodedevxml2xmlout/mdev_fedc4916_1ca8_49ac_b176_871d16c13076.xml create mode 100644 tests/nodedevxml2xmlout/mdev_manual.xml diff --git a/tests/nodedevschemadata/mdev_autostart.xml b/tests/nodedevschemadata/mdev_autostart.xml new file mode 100644 index 0000000000..7f2f341648 --- /dev/null +++ b/tests/nodedevschemadata/mdev_autostart.xml @@ -0,0 +1,10 @@ +<device> + <name>mdev_9c4954d2_fa39_4973_9d66_d61c6c4d0100</name> + <parent>pci_0000_00_02_0</parent> + <capability type='mdev'> + <type id='i915-GVTg_V5_8'/> + <attr name='example-attribute' value='attribute-value'/> + <start type='auto'/> + <uuid>9c4954d2-fa39-4973-9d66-d61c6c4d0100</uuid> + </capability> +</device> diff --git a/tests/nodedevschemadata/mdev_manual.xml b/tests/nodedevschemadata/mdev_manual.xml new file mode 100644 index 0000000000..9001588c24 --- /dev/null +++ b/tests/nodedevschemadata/mdev_manual.xml @@ -0,0 +1,10 @@ +<device> + <name>mdev_9c4954d2_fa39_4973_9d66_d61c6c4d0100</name> + <parent>pci_0000_00_02_0</parent> + <capability type='mdev'> + <type id='i915-GVTg_V5_8'/> + <attr name='example-attribute' value='attribute-value'/> + <start type='manual'/> + <uuid>9c4954d2-fa39-4973-9d66-d61c6c4d0100</uuid> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/mdev_autostart.xml b/tests/nodedevxml2xmlout/mdev_autostart.xml new file mode 100644 index 0000000000..4313c4a145 --- /dev/null +++ b/tests/nodedevxml2xmlout/mdev_autostart.xml @@ -0,0 +1,11 @@ +<device> + <name>mdev_9c4954d2_fa39_4973_9d66_d61c6c4d0100</name> + <parent>pci_0000_00_02_0</parent> + <capability type='mdev'> + <type id='i915-GVTg_V5_8'/> + <uuid>9c4954d2-fa39-4973-9d66-d61c6c4d0100</uuid> + <start type='auto'/> + <iommuGroup number='0'/> + <attr name='example-attribute' value='attribute-value'/> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366.xml b/tests/nodedevxml2xmlout/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366.xml new file mode 100644 index 0000000000..bff95b015b --- /dev/null +++ b/tests/nodedevxml2xmlout/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366.xml @@ -0,0 +1,10 @@ +<device> + <name>mdev_d069d019_36ea_4111_8f0a_8c9a70e21366</name> + <parent>pci_0000_00_02_0</parent> + <capability type='mdev'> + <type id='i915-GVTg_V5_8'/> + <uuid>d069d019-36ea-4111-8f0a-8c9a70e21366</uuid> + <start type='manual'/> + <iommuGroup number='0'/> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9.xml b/tests/nodedevxml2xmlout/mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9.xml new file mode 100644 index 0000000000..beb25b1989 --- /dev/null +++ b/tests/nodedevxml2xmlout/mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9.xml @@ -0,0 +1,11 @@ +<device> + <name>mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9</name> + <parent>pci_0000_00_02_0</parent> + <capability type='mdev'> + <type id='i915-GVTg_V5_8'/> + <start type='manual'/> + <iommuGroup number='0'/> + <attr name='example-attribute-1' value='attribute-value-1'/> + <attr name='example-attribute-2' value='attribute-value-2'/> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/mdev_fedc4916_1ca8_49ac_b176_871d16c13076.xml b/tests/nodedevxml2xmlout/mdev_fedc4916_1ca8_49ac_b176_871d16c13076.xml new file mode 100644 index 0000000000..1d6dbb6118 --- /dev/null +++ b/tests/nodedevxml2xmlout/mdev_fedc4916_1ca8_49ac_b176_871d16c13076.xml @@ -0,0 +1,10 @@ +<device> + <name>mdev_fedc4916_1ca8_49ac_b176_871d16c13076</name> + <parent>pci_0000_00_02_0</parent> + <capability type='mdev'> + <type id='i915-GVTg_V5_8'/> + <start type='manual'/> + <iommuGroup number='0'/> + <attr name='example-attribute' value='attribute-value'/> + </capability> +</device> diff --git a/tests/nodedevxml2xmlout/mdev_manual.xml b/tests/nodedevxml2xmlout/mdev_manual.xml new file mode 100644 index 0000000000..0735f29e1e --- /dev/null +++ b/tests/nodedevxml2xmlout/mdev_manual.xml @@ -0,0 +1,11 @@ +<device> + <name>mdev_9c4954d2_fa39_4973_9d66_d61c6c4d0100</name> + <parent>pci_0000_00_02_0</parent> + <capability type='mdev'> + <type id='i915-GVTg_V5_8'/> + <uuid>9c4954d2-fa39-4973-9d66-d61c6c4d0100</uuid> + <start type='manual'/> + <iommuGroup number='0'/> + <attr name='example-attribute' value='attribute-value'/> + </capability> +</device> diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c index 04d238bbca..cb8f254445 100644 --- a/tests/nodedevxml2xmltest.c +++ b/tests/nodedevxml2xmltest.c @@ -132,6 +132,11 @@ mymain(void) DO_TEST("ap_matrix"); DO_TEST("ap_matrix_mdev_types"); DO_TEST("mdev_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad"); + DO_TEST("mdev_d069d019_36ea_4111_8f0a_8c9a70e21366"); + DO_TEST("mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9"); + DO_TEST("mdev_fedc4916_1ca8_49ac_b176_871d16c13076"); + DO_TEST("mdev_autostart"); + DO_TEST("mdev_manual"); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } -- 2.31.1

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- docs/formatnode.html.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/formatnode.html.in b/docs/formatnode.html.in index 3065570405..9a505f0fe9 100644 --- a/docs/formatnode.html.in +++ b/docs/formatnode.html.in @@ -384,6 +384,10 @@ The order that they appear in the xml definition determines the order that they will be written to the device. </dd> + <dt><code>uuid</code></dt> + <dd> + This element represents the UUID of the mediated device. + </dd> <dt><code>start</code></dt> <dd> This element represents the start policy for the device. It -- 2.31.1

On 5/14/21 11:29 PM, Jonathon Jongsma wrote:
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- docs/formatnode.html.in | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/docs/formatnode.html.in b/docs/formatnode.html.in index 3065570405..9a505f0fe9 100644 --- a/docs/formatnode.html.in +++ b/docs/formatnode.html.in @@ -384,6 +384,10 @@ The order that they appear in the xml definition determines the order that they will be written to the device. </dd> + <dt><code>uuid</code></dt> + <dd> + This element represents the UUID of the mediated device. + </dd> <dt><code>start</code></dt> <dd> This element represents the start policy for the device. It
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> and pushed because this is independent of the rest. Michal

On Fri, May 14, 2021 at 04:28:57PM -0500, Jonathon Jongsma wrote:
This is a short patch series based on an initial patch from Boris Fiuczynski that I massaged a little bit and added a few additional patches.
This allows you to define mediated devices in libvirt which are started automatically at boot or parent device plugin.
Sorry I missed review of this series before it was merged, but I think this design aproach is seriously wrong. This is exposing autostart as an XML property, but in all other parts of libvirt we expose autostart as an explicit API. I think we need to make the implemnentation consistent with the rest of libvirt. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On Tue, 2021-05-25 at 11:20 +0100, Daniel P. Berrangé wrote:
On Fri, May 14, 2021 at 04:28:57PM -0500, Jonathon Jongsma wrote:
This is a short patch series based on an initial patch from Boris Fiuczynski that I massaged a little bit and added a few additional patches.
This allows you to define mediated devices in libvirt which are started automatically at boot or parent device plugin.
Sorry I missed review of this series before it was merged, but I think this design aproach is seriously wrong. This is exposing autostart as an XML property, but in all other parts of libvirt we expose autostart as an explicit API. I think we need to make the implemnentation consistent with the rest of libvirt.
Regards, Daniel
Hmm, you're right. Sorry I didn't catch that. Should we revert these patches for now then? I'll try to come up with a new implementation. Jonathon

On Tue, May 25, 2021 at 11:36:59AM -0500, Jonathon Jongsma wrote:
On Tue, 2021-05-25 at 11:20 +0100, Daniel P. Berrangé wrote:
On Fri, May 14, 2021 at 04:28:57PM -0500, Jonathon Jongsma wrote:
This is a short patch series based on an initial patch from Boris Fiuczynski that I massaged a little bit and added a few additional patches.
This allows you to define mediated devices in libvirt which are started automatically at boot or parent device plugin.
Sorry I missed review of this series before it was merged, but I think this design aproach is seriously wrong. This is exposing autostart as an XML property, but in all other parts of libvirt we expose autostart as an explicit API. I think we need to make the implemnentation consistent with the rest of libvirt.
Hmm, you're right. Sorry I didn't catch that. Should we revert these patches for now then? I'll try to come up with a new implementation.
Several of the patches are still useful. Only the 2nd patch and some files in the 3rd are impacted I think. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On 5/25/21 12:20 PM, Daniel P. Berrangé wrote:
On Fri, May 14, 2021 at 04:28:57PM -0500, Jonathon Jongsma wrote:
This is a short patch series based on an initial patch from Boris Fiuczynski that I massaged a little bit and added a few additional patches.
This allows you to define mediated devices in libvirt which are started automatically at boot or parent device plugin.
Sorry I missed review of this series before it was merged, but I think this design aproach is seriously wrong. This is exposing autostart as an XML property, but in all other parts of libvirt we expose autostart as an explicit API. I think we need to make the implemnentation consistent with the rest of libvirt.
Daniel, just wondering, if libvirt exposes this as an explicit API would the assumption be that when a user sets up the device to autostart via libvirt after a system reboot libvirt takes care of everything to bring the device back up again? mdevctl does not take care of device driver binding of alternative device drivers, e.g. vfio. Does that meet libvirt user expectations and be consistent with the rest of libvirt?
Regards, Daniel
-- Mit freundlichen Grüßen/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Gregor Pillen Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294

On Wed, Jun 09, 2021 at 11:25:26AM +0200, Boris Fiuczynski wrote:
On 5/25/21 12:20 PM, Daniel P. Berrangé wrote:
On Fri, May 14, 2021 at 04:28:57PM -0500, Jonathon Jongsma wrote:
This is a short patch series based on an initial patch from Boris Fiuczynski that I massaged a little bit and added a few additional patches.
This allows you to define mediated devices in libvirt which are started automatically at boot or parent device plugin.
Sorry I missed review of this series before it was merged, but I think this design aproach is seriously wrong. This is exposing autostart as an XML property, but in all other parts of libvirt we expose autostart as an explicit API. I think we need to make the implemnentation consistent with the rest of libvirt.
Daniel, just wondering, if libvirt exposes this as an explicit API would the assumption be that when a user sets up the device to autostart via libvirt after a system reboot libvirt takes care of everything to bring the device back up again?
mdevctl does not take care of device driver binding of alternative device drivers, e.g. vfio.
Does that meet libvirt user expectations and be consistent with the rest of libvirt?
Autostart merely means that the equivalent of virNodeDeviceCreate is done at startup. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
participants (6)
-
Boris Fiuczynski
-
Daniel P. Berrangé
-
Jonathon Jongsma
-
Michal Prívozník
-
Pavel Hrdina
-
Peter Krempa