Bug 1726202

Summary: virt-install cannot determine disk type on remote host
Product: [Community] Virtualization Tools Reporter: Marko Todoric <maretodoric>
Component: virt-managerAssignee: Cole Robinson <crobinso>
Status: CLOSED NEXTRELEASE QA Contact:
Severity: low Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: berrange, crobinso, gscrivan, tburke
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-01-30 00:23:09 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:

Description Marko Todoric 2019-07-02 10:28:17 UTC
Description of problem:
When using virt-install to perform remote installation of VM using disk of a type block device (virt-install --connect=qemu+ssh://hostname/system --disk=/dev/mapper/mpatha,bus=virtio,cache=none ...) it will define a VM disk as a "file" instead of "block" type device, and will define "source" as "file" instead of "dev".

Example, it will create a disk like this:
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='none' io='native'/>
      <source file='/dev/mapper/mpatha'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </disk>

When it should be:
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw' cache='none' io='native'/>
      <source dev='/dev/mapper/mpatha'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </disk>

If using virt-install on local hypervisor, it will define disk just fine. We are using multipath devices (NetApp LUNs) that we are serving to VM as a disk.


Version-Release number of selected component (if applicable):
Tested on virt-install 1.5.0 and virt-install 2.1.0

How reproducible:
Every time it creates a VM on a remote hypervisor using virt-install --connect option

Steps to Reproduce:
1. virt-install --connect=qemu+ssh://hostname/system --name=test --hvm --graphics vnc --disk path=/dev/mapper/mpatha,bus=virtio,cache=none --vcpus=2 --memory=2048 --cdrom=/ISO/CentOS-7-x86_64-Minimal-1810.iso --boot hd,cdrom,menu=on --os-type=linux --os-variant=rhel7 --network bridge=br7,model=virtio --noreboot

Actual results:
It will create a disk defined in XML like this:
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='none' io='native'/>
      <source file='/dev/mapper/mpatha'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </disk>

Expected results:
It should create a disk defined in XML like this:
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw' cache='none' io='native'/>
      <source dev='/dev/mapper/mpatha'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </disk>

Additional info:
VM will seem to work fine but not sure if there could be any issues because disk is improperly defined.
And also cannot be migrated using virsh migrate without using --unsafe. If i edit XML and define it as "block", migrate works as expected.

Comment 1 Cole Robinson 2020-01-30 00:23:09 UTC
Thanks for the report. I changed upstream to treat remove /dev/* paths as 'block', if we can't inspect them with libvirt storage management to figure out for certain what type they are.

I also add --disk type=block|file|... option so there's a way to override this on the virt-install command line