Bug 1429510

Summary: Handle empty <script path=""/> coming from guests generated on older Libvirt versions
Product: Red Hat Enterprise Linux 7 Reporter: Jaroslav Reznik <jreznik>
Component: libvirtAssignee: Michal Privoznik <mprivozn>
Status: CLOSED ERRATA QA Contact: yalzhang <yalzhang>
Severity: urgent Docs Contact:
Priority: high    
Version: 7.3CC: berrange, dyuan, jsuchane, knoel, mprivozn, pneedle, rbalakri, rhodain, sgordon, snagar, xuzhang
Target Milestone: rcKeywords: Reopened, ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-2.0.0-10.el7_3.6 Doc Type: Bug Fix
Doc Text:
Cause: Due to a rewrite of some parts of libvirt that is responsible for generating the qemu command line, a bug was introduced. Previously, the script path was just passed to qemu command line which (if empty) just ignores it. After the rewrite it's libvirt who is executing the script and as such fails if the script path is empty. Consequence: Domains with interfaces with empty script path fail to start. Fix: A fix consists of accepting empty string as a valid script path but not executing it. Result: Migrations from 7.2 to 7.3 now succeed.
Story Points: ---
Clone Of: 1412834 Environment:
Last Closed: 2017-05-25 15:36:26 UTC Type: ---
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: 1412834    
Bug Blocks:    

Description Jaroslav Reznik 2017-03-06 14:03:34 UTC
This bug has been copied from bug #1412834 and has been proposed
to be backported to 7.3 z-stream (EUS).

Comment 11 yalzhang@redhat.com 2017-04-01 08:44:26 UTC
Verify on libvirt-2.0.0-10.el7_3.6.x86_64, the result is as expected.
1. start a guest with empty <script path=""/>;
2. migrate vm libvirt-2.0.0-10.el7_3.6.x86_64 <-> libvirt-3.1.0-2.el7.x86_64
3. migrate vm libvirt-2.0.0-10.el7_3.6.x86_64 <-> libvirt-1.2.17-13.el7.x86_64(rhel7.2 release version)

---------------detail scenarios-------------------------
1. start a guest
1). create tap0 and connect to a bridge

# ip tuntap add dev tap0 mode tap; ifconfig tap0 up; brctl addif br0 tap0
# brctl show
bridge name	bridge id		STP enabled	interfaces
br0		8000.4437e66a7f29	no		eno1
							tap0

2) edit the xml to with "<script path=''/>", fail to validate the xml, only ignore can save this xml.

# virsh edit rhel7.3
...
   <interface type='ethernet'>
      <mac address='52:54:00:ac:64:90'/>
      <script path=''/>
      <target dev='tap0'/>
      <model type='virtio'/>
      <driver name='qemu'/>
    </interface>

error: XML document failed to validate against schema: Unable to validate doc against /usr/share/libvirt/schemas/domain.rng
Extra element devices in interleave
Element domain failed to validate content

Failed. Try again? [y,n,i,f,?]:  =====> press 'f'
error: XML document failed to validate against schema: Unable to validate doc against /usr/share/libvirt/schemas/domain.rng
Extra element devices in interleave
Element domain failed to validate content

Failed. Try again? [y,n,i,f,?]: ======> press 'i'

# virsh dumpxml rhel7.3 | grep /interface -B7
    <interface type='ethernet'>
      <mac address='52:54:00:ac:64:90'/>
      <script path=''/>
      <target dev='tap0'/>
      <model type='virtio'/>
      <driver name='qemu'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>

3) start the vm and check the network function works well

# virsh start rhel7.3
Domain rhel7.3 started

guest 
# ip link show
.....
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 52:54:00:ac:64:90 brd ff:ff:ff:ff:ff:ff
# ping www.baidu.com  -c 3
PING www.a.shifen.com (119.75.213.50) 56(84) bytes of data.
64 bytes from 119.75.213.50 (119.75.213.50): icmp_seq=1 ttl=48 time=2.99 ms
64 bytes from 119.75.213.50 (119.75.213.50): icmp_seq=2 ttl=48 time=2.94 ms
64 bytes from 119.75.213.50 (119.75.213.50): icmp_seq=3 ttl=48 time=2.99 ms

--- www.a.shifen.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 2.946/2.977/2.994/0.066 ms


2. migrate libvirt-2.0.0-10.el7_3.6.x86_64 <-> libvirt-3.1.0-2.el7.x86_64

1) prepare the env on both src and dst as scenario 1 step 1
src:
libvirt-2.0.0-10.el7_3.6.x86_64
qemu-kvm-rhev-2.6.0-28.el7_3.9.x86_64

dst:
libvirt-3.1.0-2.el7.x86_64
qemu-kvm-rhev-2.8.0-6.el7.x86_64

2) start a guest with os rhel7.3 with empty path on src host;

3) succeed to migrate src->dst, then migrate back dst->src;

3. migrate vm libvirt-1.2.17-13.el7.x86_64<->libvirt-2.0.0-10.el7_3.6.x86_64

1) set env
src(rhel7.2):
libvirt-1.2.17-13.el7.x86_64
qemu-kvm-rhev-2.3.0-31.el7_2.24.x86_64

dst(rhel7.3):
libvirt-2.0.0-10.el7_3.6.x86_64
qemu-kvm-rhev-2.6.0-28.el7_3.9.x86_64

2)start a rhel7.2 guest with empty path on 7.2 host
 
3)succeed to migrate src->dst

Comment 12 yalzhang@redhat.com 2017-04-01 10:44:55 UTC
scenario 3 
4)succeed to migrate back dst(rhel7.3)->src(rhel7.2) by
 # virsh migrate --live rhel7.2 qemu+ssh://10.66.70.x/system --verbose 
root.70.x's password: 
Migration: [100 %]

set this bug to be verified.

Comment 14 errata-xmlrpc 2017-05-25 15:36:26 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-2017:1304