Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1326264

Summary: scsi-block reports whole device size when passing through a partition
Product: Red Hat Enterprise Linux 7 Reporter: aihua liang <aliang>
Component: qemu-kvm-rhevAssignee: Fam Zheng <famz>
Status: CLOSED WONTFIX QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.3CC: aliang, knoel, meyang, ngu, pingl, shuang, virt-maint, xutian
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-06-01 02:00:13 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Seabios log
none
VM create xml none

Description aihua liang 2016-04-12 09:42:52 UTC
Created attachment 1146298 [details]
Seabios log

Description of problem:
   Wrong disk size caculated when install VM on a passthrough scsi block image
   seabios-1.7.5-11.el7.x86_64 also have this problem.

Version-Release number of selected component (if applicable):
   Host kernel version:3.10.0-371.el7.x86_64
   seabios version:seabios-1.9.1-2.el7.x86_64
   guest kernel version:3.10.0-363.el7.x86_64(installed from cdrom ISO)


How reproducible:
100%

Steps to Reproduce:
1.Login to iscsi target on iscsi server.
   commands: 
         iscsiadm -m discovery -t st -p <iscsi server ip>
         iscsiadm -m node -T <inicator> -p <iscsi server ip> -l
                  
2.check the iscsi disk using command:fdisk -l /dev/sd* 
      size of /dev/sdb is 40G.

3.Create a new partation /dev/sdb1 (disk size=10G) on iscsi disk and format it, then check the disk img size using command: qemu-img info /dev/sdb1.
     qemu-img report virtual size of /dev/sdb1 is 10G.

4.Install VM on the passthru iscsi disk "/dev/sdb1".
  
/usr/libexec/qemu-kvm -name rhel7.1-4 \
-S \
-machine pc-i440fx-rhel7.2.0,accel=kvm,usb=off,vmport=off \
-cpu SandyBridge -m 4096 -smp 8,sockets=8,cores=1,threads=1 \
-uuid 1534fa42-4818-4493-9f67-eee5ba758385 -no-user-config -nodefaults \
-chardev socket,id=qmp_id_catch_monitor,path=/var/tmp/test1,server,nowait \
-mon chardev=qmp_id_catch_monitor,id=monitor,mode=control \
-boot strict=on,menu=on,splash-time=12000 \
-drive file=/home/kvm_autotest_root/iso/linux/RHEL-7.2-20151030.0-Server-x86_64-dvd1.iso,if=none,id=drive-ide0-0-0,readonly=on,format=raw \
-device ide-cd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x5 \
-drive file=/dev/sdb1,if=none,id=drive-scsi0-0-0-0,format=raw,cache=none,aio=native,snapshot=off,media=disk \
-device scsi-block,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0 \
-spice port=3001,ipv4,disable-ticketing \
-vga qxl \
-enable-kvm \
-chardev socket,id=seabioslog_id_20160406-154254-IFn4waYv,path=/tmp/seabios-20160406-154254-IFn4waYv,server,nowait \
-device isa-debugcon,chardev=seabioslog_id_20160406-154254-IFn4waYv,iobase=0x402 \
-monitor stdio

Actual results:
  Guest os report disk size is 40G.


Expected results:
 Guest os report disk size should be 10G.
 


Additional info:
  seabios log,please see the attachment.

Comment 2 Fam Zheng 2016-04-14 01:11:54 UTC
It doesn't make much sense to pass a block partition as scsi-block device. The host happens to accept SG ioctl on both a sdX block device or on its partition, which can be told by running sg_readcap(8).

A "fix", if any, would be detect this case in QEMU and refuse to start the guest. But I'm not sure if that is doable, though.

Is this reproducible with libvirt?

Comment 3 aihua liang 2016-04-14 06:58:06 UTC
(In reply to Fam Zheng from comment #2)
> It doesn't make much sense to pass a block partition as scsi-block device.
> The host happens to accept SG ioctl on both a sdX block device or on its
> partition, which can be told by running sg_readcap(8).
> 
> A "fix", if any, would be detect this case in QEMU and refuse to start the
> guest. But I'm not sure if that is doable, though.
> 
> Is this reproducible with libvirt?

As you said that libvirt prevent to create VM disk from a scsi partition; libvirt report error like:

internal error: process exited while connecting to monitor: 2016-04-14T06:53:34.599155Z qemu-kvm: -device scsi-block,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,bootindex=1: INQUIRY failed

see our xml file in attachment.

Comment 4 aihua liang 2016-04-14 06:58:55 UTC
Created attachment 1147051 [details]
VM create xml

Comment 5 Fam Zheng 2016-04-14 07:05:21 UTC
I'm confused. Why does the command line in comment 0 run, but not the one in comment 3? What is the difference? Can you post the full command line executed by libvirt?

Comment 6 aihua liang 2016-04-14 08:28:28 UTC
(In reply to Fam Zheng from comment #5)
> I'm confused. Why does the command line in comment 0 run, but not the one in
> comment 3? What is the difference? Can you post the full command line
> executed by libvirt?

Commands as bellow:
/usr/libexec/qemu-kvm -name rhel7.1 -S \
-machine pc-i440fx-rhel7.2.0,accel=kvm,usb=off,vmport=off \
-cpu SandyBridge -m 1024 -realtime mlock=off \
-smp 1,sockets=1,cores=1,threads=1 \
-uuid da3ad4b0-71ae-469a-b912-33f2c8c3658e -no-user-config -nodefaults \
-chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/domain-rhel7.1/monitor.sock,server,nowait \
-mon chardev=charmonitor,id=monitor,mode=control \
-rtc base=utc,driftfix=slew -global kvm-pit.lost_tick_policy=discard -no-hpet \
-no-shutdown -global PIIX4_PM.disable_s3=1 -global PIIX4_PM.disable_s4=1 \
-boot strict=on \
-device ich9-usb-ehci1,id=usb,bus=pci.0,addr=0x6.0x7 \
-device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x6 \
-device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x6.0x1 \ -device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x6.0x2 \
-device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x5 \
-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x7 \
-drive file=/dev/sdb1,if=none,id=drive-scsi0-0-0-0,format=raw,cache=none -device scsi-block,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,bootindex=1 \
-netdev tap,fd=23,id=hostnet0 \
-device rtl8139,netdev=hostnet0,id=net0,mac=52:54:00:99:8c:cd,bus=pci.0,addr=0x3 \
-chardev pty,id=charserial0 \
-device isa-serial,chardev=charserial0,id=serial0 \
-chardev socket,id=charchannel0,path=/var/lib/libvirt/qemu/channel/target/domain-rhel7.1/org.qemu.guest_agent.0,server,nowait \
-device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=org.qemu.guest_agent.0 \
-chardev spicevmc,id=charchannel1,name=vdagent \
-device virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel1,id=channel1,name=com.redhat.spice.0 \
-device usb-tablet,id=input0 -spice port=5900,addr=127.0.0.1,disable-ticketing,image-compression=off,seamless-migration=on \
-device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,vgamem_mb=16,bus=pci.0,addr=0x2 \
-device intel-hda,id=sound0,bus=pci.0,addr=0x4 -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 \
-chardev spicevmc,id=charredir0,name=usbredir \
-device usb-redir,chardev=charredir0,id=redir0 \
-chardev spicevmc,id=charredir1,name=usbredir \
-device usb-redir,chardev=charredir1,id=redir1 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x8 \
-msg timestamp=on

Comment 7 Fam Zheng 2016-06-01 02:00:13 UTC
It's clear enough that this is not a qemu-kvm problem.