Re: [PATCH 1/3] qemu: hot-plug: Fix broken SCSI disk hot-plug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jun 27, 2016 at 04:43:46PM +0200, Marc Hartmayer wrote:
> The commit "qemu: hot-plug: Assume support for -device in
> qemuDomainAttachSCSIDisk" dropped the code for the automatic SCSI
> controller creation used in SCSI disk hot-plugging. If we are
> hot-plugging a SCSI disk to a domain and there is no proper SCSI
> controller defined, it results in an "error: internal error: Could not
> find scsi controller with index X required for device" error.
> 
> For that reason reverting a hunk of the commit
> d4d32005d6e8b2cc0a2f26b483ca1de10171db6d.
> 
> This patch also adds an extra comment to the code to clarify the
> loop.
> 
> Reviewed-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxxxxxxx>
> Reviewed-by: Bjoern Walk <bwalk@xxxxxxxxxxxxxxxxxx>
> Signed-off-by: Marc Hartmayer <mhartmay@xxxxxxxxxxxxxxxxxx>
> ---

I just tested with the attached trivial script, which hot-plugs two SCSI
disks on the _second_ controller.  With your patch, controlle 2, and all
the smaller ones below it (1, 0) are auto-generated:

    $ sudo ./run ./tools/virsh start cvm1
    $ sudo ./run ./tools/virsh list
     Id    Name                           State
    ----------------------------------------------------
     6     cvm1                           running
    
    $ sudo ./run ./tools/virsh domblklist cvm1
    Target     Source
    ------------------------------------------------
    vda        /export/vmimages/sn1.qcow2
    
    $ sudo ./run ./tools/virsh dumpxml cvm1 | grep controller.*scsi
    $ echo $?
    1
    
    $ ./attach-scsi-device.bash
    
    $ sudo ./run ./tools/virsh domblklist cvm1
    Target     Source
    ------------------------------------------------
    vda        /export/vmimages/sn1.qcow2
    sdb        /export/vmimages/b.raw
    sdc        /export/vmimages/c.raw
    
    $ sudo ./run ./tools/virsh dumpxml cvm1 | grep controller.*scsi
        <controller type='scsi' index='0'>
        <controller type='scsi' index='1'>
        <controller type='scsi' index='2'>
    
    $ sudo ./run ./tools/virsh dumpxml cvm1 | grep scsi
          <target dev='sdb' bus='scsi'/>
          <alias name='scsi2-0-2'/>
          <target dev='sdc' bus='scsi'/>
          <alias name='scsi2-0-3'/>
        <controller type='scsi' index='0'>
          <alias name='scsi0'/>
        <controller type='scsi' index='1'>
          <alias name='scsi1'/>
        <controller type='scsi' index='2'>
          <alias name='scsi2'/>


So:

    Tested-by: Kashyap Chamarthy <kchamart@xxxxxxxxxx>

[...]

-- 
/kashyap
#!/bin/bash

set -x

# Create three raw disk images
function create_disk() {
    for i in {b..c}; 
        do 
            qemu-img create -f raw $i.raw 512M; 
        done
}

# This is incrementing the 'unit' (a "2-digit unit number on a bus")
# attribute, for the 'address' sub-element, which describes where the
# device is placed on the virtual bus presented to the guest.
# http://libvirt.org/formatdomain.html#elementsAddress
j=1

# Construct a guest XML by attaching 10 disks to a single Virtio SCSI
# controller by manually incrementing the 'unit' number

function attach_device() {
    for i in {b..c}; do
        j=$(expr $j + 1)
        cat << EOF > disk-$i.xml
<disk type='file' device='disk'>
  <source file='/export/vmimages/$i.raw'/>
  <target dev='sd$i' bus='scsi'/>
  <address type='drive' controller='2' model='virtio-scsi' bus='0' target='0' unit='$j'/>
</disk>
EOF

        # Attach the device; it takes effect on next boot
        sudo ./run tools/virsh attach-device cvm1 disk-$i.xml  --live

    done
}

create_disk
attach_device
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]