Bug 1168849 - libvirt rejects virtio-scsi options when model is not specified
Summary: libvirt rejects virtio-scsi options when model is not specified
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.1
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Ján Tomko
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-11-28 08:57 UTC by Hu Jianwei
Modified: 2015-11-19 05:56 UTC (History)
5 users (show)

Fixed In Version: libvirt-1.2.13-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-11-19 05:56:46 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:2202 0 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2015-11-19 08:17:58 UTC

Description Hu Jianwei 2014-11-28 08:57:16 UTC
Description of problem:
Actual model should be assigned before checking its sub-element in qemuBuildControllerDevStr function

Version-Release number of selected component (if applicable):
libvirt-1.2.8-9.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
<1> Ignore "model" option, it should be set to "auto" automatically I think.
[root@ibm-x3850x5-06 images]# virsh dumpxml  r7| grep "<controller type='scsi' index='0'>" -b4
839:    <controller type='scsi' index='0'>
878-      <driver queues='5'/>
905-      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
987-    </controller>
[root@ibm-x3850x5-06 images]# virsh start r7
error: Failed to start domain r7
error: unsupported configuration: 'queues' is only supported by virtio-scsi controller

<2> Add "virtio-scsi" to controller's model
[root@ibm-x3850x5-06 images]# virsh dumpxml  r7| grep "<controller type='scsi' " -b4
839:    <controller type='scsi' index='0' model='virtio-scsi'>
898-      <driver queues='5'/>
925-      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
1007-    </controller>
[root@ibm-x3850x5-06 images]# virsh start r7
Domain r7 started

[root@ibm-x3850x5-06 images]# ps aux | grep qemu-kvm
qemu     29404  4.1  0.9 4377776 297216 ?      Sl   13:49   0:27 /usr/libexec/qemu-kvm -name r7 -S -machine pc-i440fx-rhel7.0.0,accel=kvm,usb=off -m 1024 -realtime mlock=off -smp 2,sockets=2,cores=1,threads=1 -uuid a70da21c-ffe1-4dca-b348-62e44035a6b6 -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/r7.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -boot strict=on -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -device virtio-scsi-pci,id=scsi0,num_queues=5,bus=pci.0,addr=0x7 ...


Actual results:
As shown above steps, for qemu-kvm just support virio-scsi-pci by now, so I think "auto" or ignore model option is equal to virio-scsi.

Expected results:
fix it

Additional info:
When ignoring model in <controller>, the qemuSetSCSIControllerModel() should be executed firstly in below function, then check those 3 options(queues/cmd_per_lun/max_sectors) using if sentence.

qemuBuildControllerDevStr(virDomainDefPtr domainDef,
                          virDomainControllerDefPtr def,
                          virQEMUCapsPtr qemuCaps,
                          int *nusbcontroller)
{
    virBuffer buf = VIR_BUFFER_INITIALIZER;
    int model;

    if (!(def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI &&
          def->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI)) {
        if (def->queues) {
            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                           _("'queues' is only supported by virtio-scsi controller"));
            return NULL;
        }
        if (def->cmd_per_lun) {
            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                           _("'cmd_per_lun' is only supported by virtio-scsi controller"));
            return NULL;
        }
        if (def->max_sectors) {
            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                           _("'max_sectors' is only supported by virtio-scsi controller"));
            return NULL;
        }
    }

    switch (def->type) {
    case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
        model = def->model;
        if ((qemuSetSCSIControllerModel(domainDef, qemuCaps, &model)) < 0)
            return NULL;

Comment 2 Ján Tomko 2015-02-18 14:16:15 UTC
Upstream patch:
https://www.redhat.com/archives/libvir-list/2015-February/msg00631.html

Comment 3 Ján Tomko 2015-02-25 09:17:17 UTC
Upstream patch:
commit 52a166f493970f0eb2b9c96ac3544904564e209b
Author:     Ján Tomko <jtomko@redhat.com>
CommitDate: 2015-02-25 10:04:58 +0100

    Assign default SCSI controller model before checking attribute validity
    
    If the qemu binary on x86 does not support lsi SCSI controller,
    but it supports virtio-scsi, we reject the virtio-specific attributes
    for no reason.
    
    Move the default controller assignment before the check.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1168849

git describe: v1.2.13-rc1-8-g52a166f

Comment 5 Hu Jianwei 2015-04-21 03:27:41 UTC
Verified as below:
[root@localhost ~]# rpm -q libvirt qemu-kvm-rhev
libvirt-1.2.14-1.el7.x86_64
qemu-kvm-rhev-2.2.0-8.el7.x86_64

<1> No model element
[root@localhost ~]# virsh dumpxml  r71| grep "<controller type='scsi' index='0'>" -b4
1095-      <source file='/var/lib/libvirt/images/r71_gpt.img'/>
1154-      <target dev='sda' bus='usb'/>
1190-      <address type='usb' bus='0' port='5'/>
1235-    </disk>
1247:    <controller type='scsi' index='0'>
1286-      <driver queues='5'/>
1313-      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
1395-    </controller>
1413-    <controller type='usb' index='0' model='ich9-ehci1'>
[root@localhost ~]# virsh start r71
Domain r71 started

[root@localhost ~]# ps aux | grep r71 | grep num_queues=5
qemu     12223 96.9  2.3 1694976 183540 ?      Sl   11:18   0:17 /usr/libexec/qemu-kvm -name r71 -S -machine pc-i440fx-rhel7.1.0,accel=kvm,usb=off -cpu SandyBridge -drive file=/usr/share/OVMF/OVMF_CODE.fd,if=pflash,format=raw,unit=0,readonly=on -drive file=/var/lib/libvirt/qemu/nvram/r71_VARS.fd,if=pflash,format=raw,unit=1 -m 1024 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid 1cc0e9e3-8383-42a8-a77d-9dbfa7d10fd7 -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/r71.monitor,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 virtio-scsi-pci,id=scsi0,num_queues=5,...

<2> when model = "auto":
[root@localhost ~]# virsh dumpxml  r71| grep "<controller type='scsi' index='0'" -b4
1095-      <source file='/var/lib/libvirt/images/r71_gpt.img'/>
1154-      <target dev='sda' bus='usb'/>
1190-      <address type='usb' bus='0' port='5'/>
1235-    </disk>
1247:    <controller type='scsi' index='0' model='auto'>
1299-      <driver queues='5'/>
1326-      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
1408-    </controller>
1426-    <controller type='usb' index='0' model='ich9-ehci1'>
[root@localhost ~]# virsh start r71
Domain r71 started

[root@localhost ~]# /usr/libexec/qemu-kvm -device -h^C
[root@localhost ~]# virsh dumpxml  r71| grep "<controller type='scsi' index='0'" -b4
1247-      <target dev='sda' bus='usb'/>
1283-      <alias name='usb-disk0'/>
1315-      <address type='usb' bus='0' port='5'/>
1360-    </disk>
1372:    <controller type='scsi' index='0' model='auto'>
1424-      <driver queues='5'/>
1451-      <alias name='scsi0'/>
1479-      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
1561-    </controller>
[root@localhost ~]# ps aux | grep r71 | grep num_queues=5
qemu     12415  102  2.3 1694976 183700 ?      Sl   11:22   0:17 /usr/libexec/qemu-kvm -name r71 -S -machine pc-i440fx-rhel7.1.0,accel=kvm,usb=off -cpu SandyBridge -drive file=/usr/share/OVMF/OVMF_CODE.fd,if=pflash,format=raw,unit=0,readonly=on -drive file=/var/lib/libvirt/qemu/nvram/r71_VARS.fd,if=pflash,format=raw,unit=1 -m 1024 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid 1cc0e9e3-8383-42a8-a77d-9dbfa7d10fd7 -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/r71.monitor,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 virtio-scsi-pci,id=scsi0,num_queues=5,...

<3> When model = "virtio-scsi":
[root@localhost ~]# virsh dumpxml  r71| grep "<controller type='scsi' index='0'" -b4
1095-      <source file='/var/lib/libvirt/images/r71_gpt.img'/>
1154-      <target dev='sda' bus='usb'/>
1190-      <address type='usb' bus='0' port='5'/>
1235-    </disk>
1247:    <controller type='scsi' index='0' model='virtio-scsi'>
1306-      <driver queues='5'/>
1333-      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
1415-    </controller>
1433-    <controller type='usb' index='0' model='ich9-ehci1'>
[root@localhost ~]# virsh start r71
Domain r71 started

[root@localhost ~]# ps aux | grep r71 | grep num_queues=5
qemu     12520 99.6  1.1 1694976 93232 ?       Sl   11:24   0:08 /usr/libexec/qemu-kvm -name r71 -S -machine pc-i440fx-rhel7.1.0,accel=kvm,usb=off -cpu SandyBridge -drive file=/usr/share/OVMF/OVMF_CODE.fd,if=pflash,format=raw,unit=0,readonly=on -drive file=/var/lib/libvirt/qemu/nvram/r71_VARS.fd,if=pflash,format=raw,unit=1 -m 1024 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid 1cc0e9e3-8383-42a8-a77d-9dbfa7d10fd7 -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/r71.monitor,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 virtio-scsi-pci,id=scsi0,num_queues=5,...


We can get expected results, moved to Verified.

Comment 8 errata-xmlrpc 2015-11-19 05:56:46 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-2202.html


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