libvirt/tests/virsh-output.out
Peter Krempa 5c9fc43e69 virsh: cmdAttachDisk: Don't assume type='block' if file can't be examined
'virsh attach-disk' uses stat() to determine if the 'source' is a
regular file. If stat fails though it assumes that the file is block.

Since it's way more common to have regular files and the detection does
not work at all when accessing a remote host, modify the default to
assume type='file' by default.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-23 14:44:39 +01:00

409 lines
20 KiB
Plaintext

+ ./virsh attach-disk
error: command 'attach-disk' requires <domain> option
error: command 'attach-disk' requires <source> option
error: command 'attach-disk' requires <target> option
+ ./virsh attach-disk --print-xml --domain testdom --source ''
error: command 'attach-disk' requires <target> option
+ ./virsh attach-disk --print-xml --domain testdom --source '' --sourcetype file
error: command 'attach-disk' requires <target> option
+ ./virsh attach-disk --print-xml --domain testdom --source '' --sourcetype blah
error: command 'attach-disk' requires <target> option
+ attach_disk --target hda
+ ./virsh attach-disk --print-xml --domain testdom --target hda --source /nonexistent/file
<disk type='file'>
<source file='/nonexistent/file'/>
<target dev='hda'/>
</disk>
+ attach_disk --target hda --sourcetype file
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --source /nonexistent/file
<disk type='file'>
<source file='/nonexistent/file'/>
<target dev='hda'/>
</disk>
+ attach_disk --target hda --sourcetype block
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype block --source /nonexistent/file
<disk type='block'>
<source dev='/nonexistent/file'/>
<target dev='hda'/>
</disk>
+ attach_disk --target hda --sourcetype nothing
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype nothing --source /nonexistent/file
error: Unknown source type: 'nothing'
+ attach_disk --target hda --sourcetype file --type disk
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --source /nonexistent/file
<disk type='file' device='disk'>
<source file='/nonexistent/file'/>
<target dev='hda'/>
</disk>
+ attach_disk --target hda --sourcetype block --type disk
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype block --type disk --source /nonexistent/file
<disk type='block' device='disk'>
<source dev='/nonexistent/file'/>
<target dev='hda'/>
</disk>
+ attach_disk --target hda --sourcetype file --type cdrom
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type cdrom --source /nonexistent/file
<disk type='file' device='cdrom'>
<source file='/nonexistent/file'/>
<target dev='hda'/>
</disk>
+ attach_disk --target hda --sourcetype block --type cdrom
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype block --type cdrom --source /nonexistent/file
<disk type='block' device='cdrom'>
<source dev='/nonexistent/file'/>
<target dev='hda'/>
</disk>
+ attach_disk --target hda --sourcetype file --type blah
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type blah --source /nonexistent/file
<disk type='file' device='blah'>
<source file='/nonexistent/file'/>
<target dev='hda'/>
</disk>
+ attach_disk --target hda --sourcetype block --type blah
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype block --type blah --source /nonexistent/file
<disk type='block' device='blah'>
<source dev='/nonexistent/file'/>
<target dev='hda'/>
</disk>
+ attach_disk --target hda --sourcetype file --type disk --driver testdriver
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --driver testdriver --source /nonexistent/file
<disk type='file' device='disk'>
<driver name='testdriver'/>
<source file='/nonexistent/file'/>
<target dev='hda'/>
</disk>
+ attach_disk --target hda --sourcetype file --type disk --subdriver qcow2
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --subdriver qcow2 --source /nonexistent/file
<disk type='file' device='disk'>
<driver type='qcow2'/>
<source file='/nonexistent/file'/>
<target dev='hda'/>
</disk>
+ attach_disk --target hda --sourcetype file --type disk --subdriver raw
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --subdriver raw --source /nonexistent/file
<disk type='file' device='disk'>
<driver type='raw'/>
<source file='/nonexistent/file'/>
<target dev='hda'/>
</disk>
+ attach_disk --target hda --sourcetype file --type disk --cache none
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --cache none --source /nonexistent/file
<disk type='file' device='disk'>
<driver cache='none'/>
<source file='/nonexistent/file'/>
<target dev='hda'/>
</disk>
+ attach_disk --target hda --sourcetype file --type disk --subdriver qcow2 --cache none
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --subdriver qcow2 --cache none --source /nonexistent/file
<disk type='file' device='disk'>
<driver type='qcow2' cache='none'/>
<source file='/nonexistent/file'/>
<target dev='hda'/>
</disk>
+ attach_disk --target hda --sourcetype file --type disk --subdriver qcow2 --serial TEST_SERIAL
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --subdriver qcow2 --serial TEST_SERIAL --source /nonexistent/file
<disk type='file' device='disk'>
<driver type='qcow2'/>
<source file='/nonexistent/file'/>
<target dev='hda'/>
<serial>TEST_SERIAL</serial>
</disk>
+ attach_disk --target hda --sourcetype file --type disk --mode readonly
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --mode readonly --source /nonexistent/file
<disk type='file' device='disk'>
<source file='/nonexistent/file'/>
<target dev='hda'/>
<readonly/>
</disk>
+ attach_disk --target hda --sourcetype file --type disk --mode shareable
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --mode shareable --source /nonexistent/file
<disk type='file' device='disk'>
<source file='/nonexistent/file'/>
<target dev='hda'/>
<shareable/>
</disk>
+ attach_disk --target hda --sourcetype file --type disk --mode whatever
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --mode whatever --source /nonexistent/file
error: No support for whatever in command 'attach-disk'
+ attach_disk --target hda --sourcetype file --type disk --subdriver qcow2 --alias testalias
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --subdriver qcow2 --alias testalias --source /nonexistent/file
<disk type='file' device='disk'>
<driver type='qcow2'/>
<source file='/nonexistent/file'/>
<target dev='hda'/>
<alias name='testalias'/>
</disk>
+ attach_disk --target hda --sourcetype file --type disk --rawio
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --rawio --source /nonexistent/file
<disk type='file' device='disk' rawio='yes'>
<source file='/nonexistent/file'/>
<target dev='hda'/>
</disk>
+ attach_disk --target hda --sourcetype file --type disk --multifunction
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --multifunction --source /nonexistent/file
<disk type='file' device='disk'>
<source file='/nonexistent/file'/>
<target dev='hda'/>
</disk>
+ attach_disk --target hda --sourcetype file --type disk --subdriver qcow2 --alias testalias --iothread 3 --mode readonly --cache none --driver qemu
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --subdriver qcow2 --alias testalias --iothread 3 --mode readonly --cache none --driver qemu --source /nonexistent/file
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' iothread='3' cache='none'/>
<source file='/nonexistent/file'/>
<target dev='hda'/>
<readonly/>
<alias name='testalias'/>
</disk>
+ attach_disk --target hda --sourcetype file --type disk --address ide:1.2.3
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --address ide:1.2.3 --source /nonexistent/file
<disk type='file' device='disk'>
<source file='/nonexistent/file'/>
<target dev='hda'/>
<address type='drive' controller='1' bus='2' unit='3' />
</disk>
+ attach_disk --target hda --sourcetype file --type disk --address ide:1.2.4
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --address ide:1.2.4 --source /nonexistent/file
<disk type='file' device='disk'>
<source file='/nonexistent/file'/>
<target dev='hda'/>
<address type='drive' controller='1' bus='2' unit='4' />
</disk>
+ attach_disk --target hda --sourcetype file --type disk --address ide:1:2:5
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --address ide:1:2:5 --source /nonexistent/file
<disk type='file' device='disk'>
<source file='/nonexistent/file'/>
<target dev='hda'/>
<address type='drive' controller='1' bus='2' unit='5' />
</disk>
+ attach_disk --target sda --sourcetype file --type disk --address ide:1.2.3
+ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcetype file --type disk --address ide:1.2.3 --source /nonexistent/file
error: expecting a scsi:00.00.00 or usb:00.00 or sata:00.00.00 address.
+ attach_disk --target vda --sourcetype file --type disk --address ide:1.2.3
+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address ide:1.2.3 --source /nonexistent/file
error: expecting a pci:0000.00.00.00 or ccw:00.0.0000 address.
+ attach_disk --target sda --sourcetype file --type disk --address usb:12.34
+ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcetype file --type disk --address usb:12.34 --source /nonexistent/file
<disk type='file' device='disk'>
<source file='/nonexistent/file'/>
<target dev='sda'/>
<address type='usb' bus='12' port='34' />
</disk>
+ attach_disk --target sda --sourcetype file --type disk --address usb:12.3
+ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcetype file --type disk --address usb:12.3 --source /nonexistent/file
<disk type='file' device='disk'>
<source file='/nonexistent/file'/>
<target dev='sda'/>
<address type='usb' bus='12' port='3' />
</disk>
+ attach_disk --target sda --sourcetype file --type disk --address usb:12:34
+ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcetype file --type disk --address usb:12:34 --source /nonexistent/file
<disk type='file' device='disk'>
<source file='/nonexistent/file'/>
<target dev='sda'/>
<address type='usb' bus='12' port='34' />
</disk>
+ attach_disk --target vda --sourcetype file --type disk --address usb:12.34
+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address usb:12.34 --source /nonexistent/file
error: expecting a pci:0000.00.00.00 or ccw:00.0.0000 address.
+ attach_disk --target hda --sourcetype file --type disk --address usb:12.34
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --address usb:12.34 --source /nonexistent/file
error: expecting an ide:00.00.00 address.
+ attach_disk --target sda --sourcetype file --type disk --address scsi:1.2.3
+ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcetype file --type disk --address scsi:1.2.3 --source /nonexistent/file
<disk type='file' device='disk'>
<source file='/nonexistent/file'/>
<target dev='sda'/>
<address type='drive' controller='1' bus='2' unit='3' />
</disk>
+ attach_disk --target sda --sourcetype file --type disk --address scsi:1.2.4
+ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcetype file --type disk --address scsi:1.2.4 --source /nonexistent/file
<disk type='file' device='disk'>
<source file='/nonexistent/file'/>
<target dev='sda'/>
<address type='drive' controller='1' bus='2' unit='4' />
</disk>
+ attach_disk --target sda --sourcetype file --type disk --address scsi:1:2:5
+ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcetype file --type disk --address scsi:1:2:5 --source /nonexistent/file
<disk type='file' device='disk'>
<source file='/nonexistent/file'/>
<target dev='sda'/>
<address type='drive' controller='1' bus='2' unit='5' />
</disk>
+ attach_disk --target hda --sourcetype file --type disk --address scsi:1.2.3
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --address scsi:1.2.3 --source /nonexistent/file
error: expecting an ide:00.00.00 address.
+ attach_disk --target vda --sourcetype file --type disk --address scsi:1.2.3
+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address scsi:1.2.3 --source /nonexistent/file
error: expecting a pci:0000.00.00.00 or ccw:00.0.0000 address.
+ attach_disk --target sda --sourcetype file --type disk --address sata:1.2.3
+ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcetype file --type disk --address sata:1.2.3 --source /nonexistent/file
<disk type='file' device='disk'>
<source file='/nonexistent/file'/>
<target dev='sda'/>
<address type='drive' controller='1' bus='2' unit='3' />
</disk>
+ attach_disk --target sda --sourcetype file --type disk --address sata:1.2.4
+ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcetype file --type disk --address sata:1.2.4 --source /nonexistent/file
<disk type='file' device='disk'>
<source file='/nonexistent/file'/>
<target dev='sda'/>
<address type='drive' controller='1' bus='2' unit='4' />
</disk>
+ attach_disk --target sda --sourcetype file --type disk --address sata:1:2:5
+ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcetype file --type disk --address sata:1:2:5 --source /nonexistent/file
<disk type='file' device='disk'>
<source file='/nonexistent/file'/>
<target dev='sda'/>
<address type='drive' controller='1' bus='2' unit='5' />
</disk>
+ attach_disk --target hda --sourcetype file --type disk --address sata:1.2.3
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --address sata:1.2.3 --source /nonexistent/file
error: expecting an ide:00.00.00 address.
+ attach_disk --target vda --sourcetype file --type disk --address sata:1.2.3
+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address sata:1.2.3 --source /nonexistent/file
error: expecting a pci:0000.00.00.00 or ccw:00.0.0000 address.
+ attach_disk --target vda --sourcetype file --type disk --address pci:12.34.56.78
+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address pci:12.34.56.78 --source /nonexistent/file
<disk type='file' device='disk'>
<source file='/nonexistent/file'/>
<target dev='vda'/>
<address type='pci' domain='0x0012' bus ='0x34' slot='0x56' function='0x78'/>
</disk>
+ attach_disk --target vda --sourcetype file --type disk --address pci:12:34:56:78
+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address pci:12:34:56:78 --source /nonexistent/file
<disk type='file' device='disk'>
<source file='/nonexistent/file'/>
<target dev='vda'/>
<address type='pci' domain='0x0012' bus ='0x34' slot='0x56' function='0x78'/>
</disk>
+ attach_disk --target vda --sourcetype file --type disk --address pci:12.34.56.aa
+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address pci:12.34.56.aa --source /nonexistent/file
<disk type='file' device='disk'>
<source file='/nonexistent/file'/>
<target dev='vda'/>
<address type='pci' domain='0x0012' bus ='0x34' slot='0x56' function='0xaa'/>
</disk>
+ attach_disk --target hda --sourcetype file --type disk --address pci:12.34.56.aa
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --address pci:12.34.56.aa --source /nonexistent/file
error: expecting an ide:00.00.00 address.
+ attach_disk --target sda --sourcetype file --type disk --address pci:12.34.56.aa
+ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcetype file --type disk --address pci:12.34.56.aa --source /nonexistent/file
error: expecting a scsi:00.00.00 or usb:00.00 or sata:00.00.00 address.
+ attach_disk --target vda --sourcetype file --type disk --address pci:12.34.56.78 --multifunction
+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address pci:12.34.56.78 --multifunction --source /nonexistent/file
<disk type='file' device='disk'>
<source file='/nonexistent/file'/>
<target dev='vda'/>
<address type='pci' domain='0x0012' bus ='0x34' slot='0x56' function='0x78' multifunction='on'/>
</disk>
+ attach_disk --target vda --sourcetype file --type disk --address pci:12:34:56:78 --multifunction
+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address pci:12:34:56:78 --multifunction --source /nonexistent/file
<disk type='file' device='disk'>
<source file='/nonexistent/file'/>
<target dev='vda'/>
<address type='pci' domain='0x0012' bus ='0x34' slot='0x56' function='0x78' multifunction='on'/>
</disk>
+ attach_disk --target vda --sourcetype file --type disk --address pci:12.34.56.aa --multifunction
+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address pci:12.34.56.aa --multifunction --source /nonexistent/file
<disk type='file' device='disk'>
<source file='/nonexistent/file'/>
<target dev='vda'/>
<address type='pci' domain='0x0012' bus ='0x34' slot='0x56' function='0xaa' multifunction='on'/>
</disk>
+ attach_disk --target vda --sourcetype file --type disk --address ccw:12.34.56
+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address ccw:12.34.56 --source /nonexistent/file
<disk type='file' device='disk'>
<source file='/nonexistent/file'/>
<target dev='vda'/>
<address type='ccw' cssid='0x12' ssid='0x34' devno='0x0056' />
</disk>
+ attach_disk --target vda --sourcetype file --type disk --address ccw:12:34:56
+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address ccw:12:34:56 --source /nonexistent/file
<disk type='file' device='disk'>
<source file='/nonexistent/file'/>
<target dev='vda'/>
<address type='ccw' cssid='0x12' ssid='0x34' devno='0x0056' />
</disk>
+ attach_disk --target vda --sourcetype file --type disk --address ccw:12.34.56
+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address ccw:12.34.56 --source /nonexistent/file
<disk type='file' device='disk'>
<source file='/nonexistent/file'/>
<target dev='vda'/>
<address type='ccw' cssid='0x12' ssid='0x34' devno='0x0056' />
</disk>
+ attach_disk --target hda --sourcetype file --type disk --address ccw:12.34.56
+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcetype file --type disk --address ccw:12.34.56 --source /nonexistent/file
error: expecting an ide:00.00.00 address.
+ attach_disk --target sda --sourcetype file --type disk --address ccw:12.34.56
+ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcetype file --type disk --address ccw:12.34.56 --source /nonexistent/file
error: expecting a scsi:00.00.00 or usb:00.00 or sata:00.00.00 address.
+ attach_disk --target vda --sourcetype file --type disk --address test:12.34.56
+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address test:12.34.56 --source /nonexistent/file
error: Invalid address.
+ attach_disk --target vda --sourcetype file --type disk --address test:12:34:56
+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address test:12:34:56 --source /nonexistent/file
error: Invalid address.
+ attach_disk --target vda --sourcetype file --type disk --address test:12.34.56
+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcetype file --type disk --address test:12.34.56 --source /nonexistent/file
error: Invalid address.
end