Bug 1141723

Summary: virt-v2v: error: disk sda has no defined format shows when converting xen hvm guest
Product: Red Hat Enterprise Linux 7 Reporter: tingting zheng <tzheng>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: codong, dyuan, juzhou, mbooth, mzhan, ptoscano, rjones
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: V2V
Fixed In Version: libguestfs-1.27.47-1.1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-03-05 13:44:50 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
Detailed log file none

Description tingting zheng 2014-09-15 10:22:58 UTC
Created attachment 937546 [details]
Detailed log file

Description
virt-v2v: error: disk sda has no defined format shows when converting xen hvm guest.

Version:
libguestfs-1.27.43-1.1.el7.x86_64
virt-v2v-1.27.43-1.1.el7.x86_64
libvirt-1.2.8-2.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.Prepare a xen hvm guest.

2.Use virt-v2v to convert guest from xen.
# virt-v2v -ic xen+ssh://10.66.106.64 -os default rhel6.6-i386-hvm
[   0.0] Opening the source -i libvirt -ic xen+ssh://10.66.106.64 rhel6.6-i386-hvm
libvirt: Remote Driver error : unknown procedure: 212
[  16.0] Creating an overlay to protect the source from being modified
[  30.0] Opening the overlay
[  52.0] Initializing the target -o libvirt -os default
virt-v2v: error: disk sda (json: { "file.driver" : "ssh", "file.path" :
"/var/lib/xen/images/rhel6.6-i386-hvm.img", "file.host" : "10.66.106.64",
"file.host_key_check" : "no" }) has no defined format, you have to either
define the original format in the source metadata, or use the '-of' option
to force the output format

If reporting bugs, run virt-v2v with debugging enabled and include the
complete output:

  virt-v2v -v -x [...]


# virsh dumpxml rhel6.6-i386-hvm
    <disk type='file' device='disk'>
      <driver name='file'/>
      <source file='/var/lib/xen/images/rhel6.6-i386-hvm.img'/>
      <target dev='hda' bus='ide'/>
    </disk>

 # qemu-img info rhel6.6-i386-hvm.img
   image: rhel6.6-i386-hvm.img
   file format: raw
   virtual size: 7.8G (8388608000 bytes)
   disk size: 7.8G

Actual results:
As described.

Expected results:
The default format of xen guest image is raw,virt-v2v can convert xen hvm guest successfully.

Additional info:
For xen pv guest,there is also no disk format defined in guest xml,bug xen pv guest can be converted successfully.
# virsh dumpxml xen-pv-rhel4.8-i386
    <disk type='file' device='disk'>
      <driver name='tap' type='aio'/>
      <source file='/var/lib/xen/images/xen/xen-pv/xen-pv-rhel4.8-i386.img'/>
      <target dev='xvda' bus='xen'/>
    </disk>

Comment 2 Richard W.M. Jones 2014-09-15 10:36:25 UTC
The error message is correct: the input  XML doesn't define the
disk format, and so we have to guess.

I have changed the error message to hopefully make it clearer.
In libguestfs >= 1.27.47 it will say instead:

  virt-v2v: error: disk sda (...) has no defined format.

  The input metadata did not define the disk format (eg. raw/qcow2/etc)
  of this disk, and so virt-v2v will try to autodetect the format when
  reading it.

  However because the input format was not defined, we do not know what
  output format you want to use.  You have two choices: either define
  the original format in the source metadata, or use the '-of' option
  to force the output format

https://github.com/libguestfs/libguestfs/commit/77b371b18b6a7ad37105a595931514f542a04396

(In reply to tingting zheng from comment #0)
> Additional info:
> For xen pv guest,there is also no disk format defined in guest xml,bug xen
> pv guest can be converted successfully.
> # virsh dumpxml xen-pv-rhel4.8-i386
>     <disk type='file' device='disk'>
>       <driver name='tap' type='aio'/>
>       <source file='/var/lib/xen/images/xen/xen-pv/xen-pv-rhel4.8-i386.img'/>
>       <target dev='xvda' bus='xen'/>
>     </disk>

Not true!  It's not very obvious, but "aio" == "raw" for bizarre
historical reasons.

I previously added a commit to virt-v2v which maps aio to raw:

https://github.com/libguestfs/libguestfs/commit/0c295c8e23a90d3a3f5efcfa0452ecde7317e122

Comment 4 tingting zheng 2014-09-17 05:08:06 UTC
Tested with:
libguestfs-1.27.47-1.1.el7.x86_64
virt-v2v-1.27.47-1.1.el7.x86_64

# virt-v2v -ic xen+ssh://10.66.106.64 -os default rhel6.6-i386-hvm
[   0.0] Opening the source -i libvirt -ic xen+ssh://10.66.106.64 rhel6.6-i386-hvm
[  16.0] Creating an overlay to protect the source from being modified
[  30.0] Opening the overlay
[  52.0] Initializing the target -o libvirt -os default
virt-v2v: error: disk sda (json: { "file.driver" : "ssh", "file.path" : 
"/var/lib/xen/images/rhel6.6-i386-hvm.img", "file.host" : "10.66.106.64", 
"file.host_key_check" : "no" }) has no defined format.

The input metadata did not define the disk format (eg. raw/qcow2/etc) of 
this disk, and so virt-v2v will try to autodetect the format when reading 
it.

However because the input format was not defined, we do not know what 
output format you want to use.  You have two choices: either define the 
original format in the source metadata, or use the '-of' option to force 
the output format

If reporting bugs, run virt-v2v with debugging enabled and include the 
complete output:

  virt-v2v -v -x [...]

The error info mentioned in comment 2 has showed,so move the bug to VERIFIED.

Comment 6 errata-xmlrpc 2015-03-05 13:44:50 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-0303.html