Bug 1823636 - guest-fstrim command do not work for discard disk due to Permission denied
Summary: guest-fstrim command do not work for discard disk due to Permission denied
Keywords:
Status: CLOSED DUPLICATE of bug 1747960
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: qemu-kvm
Version: 8.2
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: 8.3
Assignee: Virtualization Maintenance
QA Contact: qing.wang
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-04-14 06:26 UTC by qing.wang
Modified: 2020-04-14 07:05 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-04-14 07:02:50 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description qing.wang 2020-04-14 06:26:04 UTC
Description of problem:

Execute guest agent command guest-fstrim do not work for discard disk.
It display failed to open: Permission denied

Version-Release number of selected component (if applicable):


Host:

4.18.0-193.el8.x86_64
qemu-kvm-core-4.2.0-17.module+el8.2.0+6141+0f540f16.x86_64

Guest:
4.18.0-193.el8.x86_64
qemu-guest-agent-2.12.0-99.module+el8.2.0+5827+8c39933c.x86_64

How reproducible:
100%

Steps to Reproduce:
1.create scsi_debug disk on host
modprobe -r scsi_debug; modprobe scsi_debug  lbpu=1 lbpws=1 lbprz=0

2.pass-through above disk in vm
/usr/libexec/qemu-kvm \
    -name 'avocado-vt-vm1'  \
    -sandbox on  \
    -machine q35 \
    -device pcie-root-port,id=pcie-root-port-0,multifunction=on,bus=pcie.0,addr=0x1,chassis=1 \
    -device pcie-pci-bridge,id=pcie-pci-bridge-0,addr=0x0,bus=pcie-root-port-0  \
    -nodefaults \
    -device VGA,bus=pcie.0,addr=0x2 \
    -m 2048  \
    -device pcie-root-port,id=pcie-root-port-1,port=0x1,addr=0x1.0x1,bus=pcie.0,chassis=2 \
    -device qemu-xhci,id=usb1,bus=pcie-root-port-1,addr=0x0 \
    -device usb-tablet,id=usb-tablet1,bus=usb1.0,port=1 \
    -device pcie-root-port,id=pcie-root-port-2,port=0x2,addr=0x1.0x2,bus=pcie.0,chassis=3 \
    -device virtio-scsi-pci,id=virtio_scsi_pci0,bus=pcie-root-port-2,addr=0x0 \
    -blockdev node-name=file_image1,driver=file,aio=threads,filename=/home/kvm_autotest_root/images/rhel821-64-virtio-scsi.qcow2,cache.direct=on,cache.no-flush=off \
    -blockdev node-name=drive_image1,driver=qcow2,cache.direct=on,cache.no-flush=off,file=file_image1 \
    -device scsi-hd,id=image1,drive=drive_image1,write-cache=on \
    -blockdev node-name=file_stg1,driver=host_device,aio=threads,filename=/dev/sdd,cache.direct=on,cache.no-flush=off,discard=unmap \
    -blockdev node-name=drive_stg1,driver=raw,cache.direct=on,cache.no-flush=off,file=file_stg1,discard=unmap \
    -device scsi-block,id=stg1,drive=drive_stg1 \
    -device pcie-root-port,id=pcie-root-port-3,port=0x3,addr=0x1.0x3,bus=pcie.0,chassis=4 \
    -device virtio-net-pci,mac=9a:5b:4f:9b:c3:b0,id=idg2bFqS,netdev=ida2LQKm,bus=pcie-root-port-3,addr=0x0  \
    -netdev tap,id=ida2LQKm,vhost=on  \
    -vnc :6  \
    -qmp tcp:0:5956,server,nowait  \
    -rtc base=utc,clock=host,driftfix=slew  \
    -boot menu=off,order=cdn,once=c,strict=off \
    -enable-kvm -monitor stdio \
    -device pcie-root-port,id=pcie_extra_root_port_0,multifunction=on,bus=pcie.0,addr=0x3,chassis=5 \
    -device virtio-serial-pci,disable-legacy=on,disable-modern=off,id=virtio-serial0 \
 -chardev socket,path=/tmp/qga.sock,server,nowait,id=qga0 \
 -device virtserialport,bus=virtio-serial0.0,nr=3,chardev=qga0,id=channel1,name=org.qemu.guest_agent.0 \

3.format disk in guest
mkfs.ext4 /dev/sdb

4.mount it in guest

mount /dev/sdb /home/test

5.execute guest-fstrim command on host

nc -U /tmp/qga.sock
{"execute":"guest-fstrim"}

 
Actual results:
{"return": {"paths": [{"path": "/home/test", "error": "failed to open: Permission denied"}, {"minimum": 4096, "path": "/boot", "trimmed": 910954496}, {"minimum": 4096, "path": "/", "trimmed": 13861388288}]}}

Expected results:
{"return": {"paths": [{"minimum": 512, "path": "/home/test", "trimmed": 6993920}, {"minimum": 0, "path": "/boot", "trimmed": 809025536}, {"minimum": 0, "path": "/", "trimmed": 14703882240}]}}

Additional info:

Comment 1 qing.wang 2020-04-14 06:32:08 UTC
fstrim command may works well in guest.

Comment 2 xiagao 2020-04-14 06:43:42 UTC
Did you try with selinux is permissive.

It seems a duplicate of the following one.
Bug 1747960 - selinux policy prevent guest-fstrim command executing

Comment 3 qing.wang 2020-04-14 07:02:50 UTC
Execute "setenforce 0" in guest ,this issue was gone.

{"return": {"paths": [{"minimum": 512, "path": "/home/test", "trimmed": 6993920}, {"minimum": 4096, "path": "/boot", "trimmed": 910954496}, {"minimum": 4096, "path": "/", "trimmed": 13862920192}]}}

*** This bug has been marked as a duplicate of bug 1747960 ***


Note You need to log in before you can comment on or make changes to this bug.