Rate This Document
Findability
Accuracy
Completeness
Readability

Testing the VM Cache

Before modifying the VM cache, the cache size displayed on the VM is the default size. After the cache configuration is modified, you can view the configured cache size on the VM.

  1. Start the VM.

    There are three methods for starting a VM. Generally, libvirt is used to start a VM.

    You can also run the QEMU command to start the VM or start the VM in device tree mode.

    • Use libvirt to start the VM.
      1
      virsh start <VM_name>
      
    • Optional: Run the following QEMU command to start the VM:
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      qemu-kvm \
      -blockdev '{"driver":"file","filename":"<EFI file_path>","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"}' \
      -blockdev '{"node-name":"libvirt-pflash0-format","read-only":true,"driver":"raw","file":"libvirt-pflash0-storage"}' \
      -blockdev '{"driver":"file","filename":"<nvram file>","node-name":"libvirt-pflash1-storage","auto-read-only":true,"discard":"unmap"}' \
      -blockdev '{"node-name":"libvirt-pflash1-format","read-only":false,"driver":"raw","file":"libvirt-pflash1-storage"}' \
      -machine virt,usb=off,dump-guest-core=off,gic-version=3,pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-format \
      -accel kvm \
      -cpu host \
      -m <Memory_size>\
      -smp <Number_of_vCPUs>\
      -drive file=<VM_drive_path>\
      -nographic
      
    • Optional: Run the following command to start the VM in device tree mode:
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      qemu-kvm \
      -kernel <Kernel_image>
      -smp <Number_of_vCPUs>\
      -m <Memory_size>\
      -accel kvm \
      -machine virt,gic-version=3,\
      -initrd <VM_image_file>\
      -cpu host \
      -nographic \
      -append "rdinit=init console=ttyAMA0 earlycon=pl011,0x90000000"
      
  2. Check the initial cache size of the VM.

    Run the following command on the VM:

    1
    lscpu
    

    The cache sizes of the VM displayed are the default values (L1d: 64 KiB, L1i: 64 KiB, L2: 512 KiB, L3: 32 MiB).

  3. Configure the cache sizes.

    Configure the cache sizes of the VM by referring to Configuring the VM Cache and restart the VM.

  4. Verify that the configurations have taken effect.
    1. Run the following command on the VM:
      1
      lscpu
      

      The cache sizes are the same as the configured sizes.

    2. Run the following command on the physical machine:
      1
      virsh dumpxml cachesize_test | grep cacheinfo
      

      The cache sizes in the XML file generated by the running VM are the same as the configured sizes.