Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-83015

Disk size of target raw image is full allocated when doing mirror with default discard value [rhel-9.7]

Linking RHIVOS CVEs to...Migration: Automation ...Sync from "Extern...XMLWordPrintable

    • qemu-kvm-9.1.0-24.el9
    • No
    • Moderate
    • 2
    • rhel-virt-storage
    • ssg_virtualization
    • 14
    • 14
    • 2
    • QE ack
    • False
    • False
    • Hide

      None

      Show
      None
    • Yes
    • Red Hat Enterprise Linux
    • virt-storage Sprint 4, virt-storage Sprint 6
    • Release Note Not Required
    • Hide
      Cause:
      Consequence:
      Workaround:
      Result:
      Show
      Cause: Consequence: Workaround: Result:
    • Proposed
    • Unspecified
    • Unspecified
    • Unspecified
    • x86_64
    • Unspecified
    • None

      What were you trying to do that didn't work?
      Target image size is full allocated when doing mirror with default discard value

      Please provide the package NVR for which bug is seen:
      kernel version:5.14.0-570.el9.x86_64
      kvm-qemu version:qemu-kvm-9.1.0-15.el9

      How reproducible:
      100%

      Steps to reproduce
      1. Start VM with qemu cmdline

      
      
      /usr/libexec/qemu-kvm \
      -name "mouse-vm" \
      -sandbox off \
      -machine q35,pflash0=drive_ovmf_code,pflash1=drive_ovmf_vars \
      -cpu Cascadelake-Server \
      -nodefaults \
      -vga std \
      -chardev socket,id=qmp_id_qmpmonitor1,path=/var/tmp/monitor-qmpmonitor1,server=on,wait=off \
      -chardev socket,id=qmp_id_catch_monitor,path=/var/tmp/monitor-catch_monitor,server=on,wait=off \
      -mon chardev=qmp_id_qmpmonitor1,mode=control \
      -mon chardev=qmp_id_catch_monitor,mode=control \
      -device '
      
      {"driver":"pcie-root-port","id":"root0","multifunction":true,"addr":"0x2","chassis":1,"port":16,"bus":"pcie.0"}
      
      ' \
      -device '
      
      {"driver":"pcie-root-port","id":"root1","addr":"0x2.0x1","chassis":2,"port":17,"bus":"pcie.0"}
      
      ' \
      -device '
      
      {"driver":"pcie-root-port","id":"root2","addr":"0x2.0x2","chassis":3,"port":18,"bus":"pcie.0"}
      
      ' \
      -device '
      
      {"driver":"pcie-root-port","id":"root3","addr":"0x2.0x3","chassis":4,"port":19,"bus":"pcie.0"}
      
      ' \
      -device '
      
      {"driver":"pcie-root-port","id":"root4","addr":"0x2.0x4","chassis":5,"port":20,"bus":"pcie.0"}
      
      ' \
      -device '
      
      {"driver":"pcie-root-port","id":"root5","addr":"0x2.0x5","chassis":6,"port":21,"bus":"pcie.0"}
      
      ' \
      -device '
      
      {"driver":"pcie-root-port","id":"root6","addr":"0x2.0x6","chassis":7,"port":22,"bus":"pcie.0"}
      
      ' \
      -device '
      
      {"driver":"pcie-root-port","id":"root7","addr":"0x2.0x7","chassis":8,"port":23,"bus":"pcie.0"}
      
      ' \
      -device '
      
      {"driver":"nec-usb-xhci","id":"usb1","bus":"root0"}
      
      ' \
      -device '
      
      {"driver":"virtio-scsi-pci","id":"virtio_scsi_pci0","bus":"root1"}
      
      ' \
      -device '
      
      {"driver":"scsi-hd","id":"image1","drive":"drive_image1","bus":"virtio_scsi_pci0.0","channel":0,"scsi-id":0,"lun":0,"bootindex":0}
      
      ' \
      -device '
      
      {"driver":"virtio-net-pci","mac":"52:54:20:f6:34:52","id":"net0","netdev":"tap0","bus":"root2","vectors":4}
      
      ' \
      -device '
      
      {"driver":"usb-tablet","id":"usb-tablet1","bus":"usb1.0","port":"1"}
      
      ' \
      -device '
      
      {"driver":"scsi-hd","id":"scsi-hd0","drive":"drive_data1","channel":0,"scsi-id":0,"lun":1}
      
      ' \
      -blockdev '{"driver":"file","cache":
      
      {"direct":true,"no-flush":false}
      
      ,"filename":"/mnt/rhel100-64-virtio-ovmf.raw","node-name":"drive_sys1"}' \
      -blockdev '
      
      {"driver":"raw","node-name":"drive_image1","file":"drive_sys1"}
      
      ' \
      -blockdev '{"driver":"file","cache":
      
      {"direct":true,"no-flush":false}
      
      ,"filename":"/mnt/data.raw","node-name":"file_data1"}' \
      -blockdev '
      
      {"driver":"raw","node-name":"drive_data1","file":"file_data1"}
      
      ' \
      -blockdev '
      
      {"node-name":"file_ovmf_code","driver":"file","filename":"/usr/share/OVMF/OVMF_CODE.secboot.fd","auto-read-only":true,"discard":"unmap"}
      
      ' \
      -blockdev '
      
      {"node-name":"drive_ovmf_code","driver":"raw","read-only":true,"file":"file_ovmf_code"}
      
      ' \
      -blockdev '
      
      {"node-name":"file_ovmf_vars","driver":"file","filename":"/mnt/rhel100-64-virtio-ovmf.raw_VARS.fd","auto-read-only":true,"discard":"unmap"}
      
      ' \
      -blockdev '
      
      {"node-name":"drive_ovmf_vars","driver":"raw","read-only":false,"file":"file_ovmf_vars"}
      
      ' \
      -netdev tap,id=tap0,vhost=on \
      -m 4096 \
      -object '
      
      {"qom-type":"memory-backend-ram","id":"mem-machine_mem","size":4294967296}
      
      ' \
      -smp 4,maxcpus=4,cores=2,threads=1,sockets=2 \
      -vnc :10 \
      -rtc base=utc,clock=host \
      -boot menu=off,strict=off,order=cdn,once=c \
      -enable-kvm \
      -qmp tcp:0:3333,server=on,wait=off \
      -qmp tcp:0:9999,server=on,wait=off \
      -qmp tcp:0:9888,server=on,wait=off \
      -serial tcp:0:4444,server=on,wait=off \
      -monitor stdio \
      
      

      2. In guest, dd a file on data disk

       

      (guest)# mkfs.ext4 /dev/sdb
             # mount /dev/sdb /mnt
             # dd if=/dev/urandom of=/mnt/test bs=1M count=10 oflag=direct

       

      3. Check data image info in src

       

      # qemu-img info data.raw
      image: data.raw
      file format: raw
      virtual size: 2 GiB (2147483648 bytes)
      disk size: 107 MiB
      Child node '/file':
          filename: data.raw
          protocol type: file
          file length: 2 GiB (2147483648 bytes)
          disk size: 107 MiB 

       

      4. Create a target raw image node and add it to the src.

       

      {"execute": "blockdev-create", "arguments": {"options": {"driver": "file", "filename": "/root/avocado/data/avocado-vt/dst1.raw", "size": 2147483648}, "job-id": "drive_dst1"}, "id": "lex1X2PU"}
      
      {"execute": "blockdev-add", "arguments": {"node-name": "drive_dst1", "driver": "file", "filename": "/root/avocado/data/avocado-vt/dst1.raw", "aio": "threads", "auto-read-only": true}, "id": "pKwMj3Yo"} 

       

      5. Do mirror from src to dst

       

      {"execute": "blockdev-mirror", "arguments": {"sync": "full", "auto-finalize": true, "auto-dismiss": true, "device": "drive_data1", "target": "drive_dst1", "job-id": "drive_src1_cSNn"}, "id": "tNK73gtr"} 

       

      Check mirror image info

       

      # qemu-img info dst1.raw 
      image: dst1.raw
      file format: raw
      virtual size: 2 GiB (2147483648 bytes)
      disk size: 2 GiB
      Child node '/file':
          filename: dst1.raw
          protocol type: file
          file length: 2 GiB (2147483648 bytes)
          disk size: 2 GiB
          Format specific information:
              extent size hint: 1048576 

       

      Expected results

      • disk size should less than 2G

      Actual results

      • disk size equals to 2G

       

      Additional info:

      • when target image is in qcow2 format, the issue doesn't exist.

       

      # qemu-img info /root/avocado/data/avocado-vt/dst1.qcow2 
      image: /root/avocado/data/avocado-vt/dst1.qcow2
      file format: qcow2
      virtual size: 2 GiB (2147483648 bytes)
      disk size: 109 MiB
      cluster_size: 65536
      Format specific information:
          compat: 1.1
          compression type: zlib
          lazy refcounts: false
          refcount bits: 16
          corrupt: false
          extended l2: false
      Child node '/file':
          filename: /root/avocado/data/avocado-vt/dst1.qcow2
          protocol type: file
          file length: 2 GiB (2147483648 bytes)
          disk size: 109 MiB
          Format specific information:
              extent size hint: 1048576 
      • When add target raw image with discard=unmap, the issue also doesn't exist.
      {"execute": "blockdev-add", "arguments": {"node-name": "drive_dst1", "driver": "file", "filename": "/root/avocado/data/avocado-vt/dst1.raw", "aio": "threads", "auto-read-only": true, "discard": "unmap"}, "id": "pKwMj3Yo"}
      
      # qemu-img info data.raw
      image: data.raw
      file format: raw
      virtual size: 2 GiB (2147483648 bytes)
      disk size: 107 MiB
      Child node '/file':
          filename: data.raw
          protocol type: file
          file length: 2 GiB (2147483648 bytes)
          disk size: 107 MiB 

      Will provide more info later for if it's a regression issue.

       

              eblake_redhat Eric Blake
              aliang@redhat.com Aihua Liang
              virt-maint virt-maint
              Aihua Liang Aihua Liang
              Jiří Herrmann Jiří Herrmann
              Votes:
              0 Vote for this issue
              Watchers:
              12 Start watching this issue

                Created:
                Updated: