Bug 1564863

Summary: Fail to force clone an empty cdrom device
Product: Red Hat Enterprise Linux 7 Reporter: Xiaodai Wang <xiaodwan>
Component: virt-managerAssignee: Pavel Hrdina <phrdina>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: low    
Version: 7.5CC: juzhou, mxie, mzhan, tzheng
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: virt-manager-1.5.0-2.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1690685 (view as bug list) Environment:
Last Closed: 2019-08-06 13:07:59 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:
Bug Depends On:    
Bug Blocks: 1690685    
Attachments:
Description Flags
virt-manager debug log none

Description Xiaodai Wang 2018-04-08 10:59:48 UTC
Description of problem:
Fail to force clone an empty cdrom device

Version-Release number of selected component (if applicable):
virt-manager-1.4.3-3.el7.noarch

How reproducible:
100%

Steps to Reproduce:
1. Prepare a guest which has a cdrom disk and no path is set to the cdrom.
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
2. Force copy the cdrom device during virt-clone.
# virt-clone  -o test -n test-clone --auto-clone --force-copy hdc


Actual results:
Traceback (most recent call last):
  File "/usr/share/virt-manager/virt-clone", line 221, in <module>
    sys.exit(main())
  File "/usr/share/virt-manager/virt-clone", line 204, in main
    not options.preserve, options.auto_clone)
  File "/usr/share/virt-manager/virt-clone", line 85, in get_clone_diskfile
    newpath = design.generate_clone_disk_path(origpath)
  File "/usr/share/virt-manager/virtinst/cloner.py", line 505, in generate_clone_disk_path
    if origpath.count(".") and len(origpath.rsplit(".", 1)[1]) <= 7:
AttributeError: 'NoneType' object has no attribute 'count'

Expected results:
virt-clone should success.

Additional info:

Comment 1 Xiaodai Wang 2018-04-08 11:00:52 UTC
Created attachment 1418875 [details]
virt-manager debug log

Comment 3 Pavel Hrdina 2019-02-28 17:48:00 UTC
Upstream commit:

commit 57db41854c86704af331d283810db0d86786825a
Author: Pavel Hrdina <phrdina>
Date:   Thu Feb 28 17:53:58 2019 +0100

    virt-clone: fix force-copy of empty cdrom or floppy disk

Comment 6 ysu@redhat.com 2019-04-30 06:27:21 UTC
I can reproduce this issue with package:
virt-manager-1.4.3-3.el7.noarch

Then try to verify this bug with new build:
virt-manager-1.5.0-3.el7.noarch
virt-install-1.5.0-3.el7.noarch
libvirt-4.5.0-12.el7.x86_64
qemu-kvm-rhev-2.12.0-26.el7.x86_64
libvirt-python-4.5.0-1.el7.x86_64

Steps:
Sceneria-1
1. Prepare a guest which has a cdrom disk and no path is set to the cdrom.

<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<target dev='hda' bus='ide'/>
<readonly/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>

2.Force copy the cdrom device during virt-clone.
2.1 #virt-clone -o rhel7.6 -n test-clone --auto-clone --force-copy hda

Allocating 'rhel7.6-clone.qcow2'                          | 7.0 GB  03:45     
Clone 'test-clone' created successfully.

2.2 #virsh dumpxml test-clone | grep disk
<disk type='file' device='cdrom'>
      <driver name='qemu'/>
      <target dev='hda' bus='ide'/>
      <readonly/>
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>

Results:Clone is success with the empty cdrom device and new guest can start successfully.

Sceneria-2
1.Prepare a guest which has a floppy disk and no path is set to the floppy disk.

<disk type='file' device='floppy'>
      <driver name='qemu' type='raw'/>
      <target dev='fda' bus='fdc'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>

2.Force copy the floppy device during virt-clone.
2.1 #virt-clone -o rhel7.6 -n test-clone --auto-clone --force-copy fda
Allocating 'rhel7.6-clone.qcow2'                                                   | 7.0 GB  00:03:39     
Clone 'test-clone' created successfully.

2.2#virsh dumpxml test-clone | grep disk
<disk type='file' device='floppy'>
      <driver name='qemu' type='raw'/>
      <target dev='fda' bus='fdc'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>

Result:Clone is success with the floppy device and new guest can start successfully.

So based on above testing, i move this bug from ON_QA to VERIFIED.

Comment 8 errata-xmlrpc 2019-08-06 13:07:59 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://access.redhat.com/errata/RHBA-2019:2232