Configure SCSI3-Persistent Reservation for virtual machines

By using SCSI3-Persistent Reservation (S3-PR), multiple virtual machines (VMs) can coordinate access to shared storage devices. This is required for Linux clustering solutions, such as Pacemaker, and for Windows Server Failover Clustering.

Before you begin

About this task

With S3-PR, VMs can register and manage persistent reservations on storage devices to prevent conflicts when multiple VMs access the same storage.

You can configure S3-PR for both singlepath and multipath devices in VMs running on a RHEL host by modifying their XML configuration files.

Procedure

  1. Open the XML configuration of the VM:
    # virsh edit <vm_name>
  2. In the <devices> section, add a line for the VirtIO-SCSI controller if it is not present already:
    <controller type='scsi' model='virtio-scsi' index='0'/>
  3. Edit the VM configuration to enable S3-PR support. The configuration depends on whether you are using singlepath or multipath vDisks:
    • For multipath devices, add the reservations element with managed='yes' to the multipathed disk device:
      <disk type='block' device='lun'>
        <driver name='qemu' type='raw' cache='none'/>
        <source dev='/dev/mapper/mpatha'>
          <reservations managed='yes'/>
        </source>
        <target dev='sda' bus='scsi'/>
        <address type='drive' controller='0' bus='0' target='0' unit='0'/>
      </disk>

      In this example, the multipathed device /dev/mapper/mpatha is configured with S3-PR support:

      • device='lun': Indicates that this is a SCSI Logical Unit Number (LUN) device, which is required for S3-PR support with block devices.
      • reservations managed='yes': Enables S3-PR support and allows libvirt to manage the persistent reservation helper.
    • For singlepath devices, add the reservations element with managed='yes' to the disk device that requires S3-PR support:
      <disk type='block' device='lun'>
        <driver name='qemu' type='raw' cache='none'/>
        <source dev='/dev/sdb'>
          <reservations managed='yes'/>
        </source>
        <target dev='sda' bus='scsi'/>
        <address type='drive' controller='0' bus='0' target='0' unit='0'/>
      </disk>

      In this example:

      • type='block': Specifies that the device is a block device.
      • device='lun': Indicates that this is a SCSI Logical Unit Number (LUN) device, which is required for S3-PR support with block devices.
      • <source dev='/dev/sdb'/>: Specifies the host block device path. You can use device nodes, for example /dev/sdb, directly or use /dev/disk/by-path/ entries for better persistence across reboots.
      • <driver name='qemu' type='raw' cache='none'/>: Specifies the QEMU driver with raw format for direct device access.
      • reservations managed='yes': Enables S3-PR support and allows libvirt to manage the persistent reservation helper.
      • The disk uses the VirtIO-SCSI bus, which is required for S3-PR support.
  4. Save the XML configuration and start the VM.
    # virsh start <vm_name>

Results

  • You can verify the configuration on the host by displaying the XML configuration of the running VM.
    # virsh dumpxml <vm_name>

    Look for the reservations managed='yes' element in the disk device configuration.

  • In RHEL VMs, you can also use the sg3_utils package to check the persistent reservation capabilities of the SCSI device:
    1. Install the sg3_utils package in the RHEL VM:
      # dnf install sg3_utils
    2. Check the SCSI device’s persistent reservation capabilities:
      # sg_persist --in --report-capabilities /dev/sda

      If the device supports S3-PR, the output looks similar to the following:

      LBP-2: 0
      PTPL_C: 0
      TMC: 0
      [PTPL_A: 1]
      [PR_TYPE: 1, 3, 5]

      In this example, PTPL_A: 1 indicates that the device supports persistent reservations, and PR_TYPE: 1, 3, 5 shows the supported reservation types.