Bug 1171582 - guest will disappear after set agent or smart card controller with a negative number after restart libvirtd
Summary: guest will disappear after set agent or smart card controller with a negative...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.1
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Michal Privoznik
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-12-08 06:56 UTC by Luyao Huang
Modified: 2015-11-19 05:57 UTC (History)
6 users (show)

Fixed In Version: libvirt-1.2.13-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-11-19 05:57:34 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:2202 0 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2015-11-19 08:17:58 UTC

Description Luyao Huang 2014-12-08 06:56:05 UTC
Description of problem:
guest will disappear after set agent or smart card controller with a negative number after restart libvirtd

Version-Release number of selected component (if applicable):
libvirt-1.2.8-10.el7.x86_64

How reproducible:
100%

1.prepare a guest with smartcard
# virsh dumpxml test3
   <smartcard mode='passthrough' type='spicevmc'>
      <address type='ccid' controller='0' slot='0'/>
    </smartcard>


2.try to edit it controller number to -1 and dumpxml:
# virsh edit test3
Domain test3 XML configuration edited.

# virsh dumpxml test3
 <controller type='ccid' index='4294967295'/>

    <smartcard mode='passthrough' type='spicevmc'>
      <address type='ccid' controller='-1' slot='0'/>
    </smartcard>

# service libvirtd restart

# virsh dumpxml test3
error: failed to get domain 'test3'
error: Domain not found: no domain with matching name 'test3'

4.Also found this issue with agent
# virsh dumpxml test3
    <controller type='virtio-serial' index='4294967295'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </controller>
...
    <channel type='unix'>
      <source mode='bind' path='/var/lib/libvirt/qemu/r6.agent'/>
      <target type='virtio' name='org.qemu.guest_agent.0'/>
      <address type='virtio-serial' controller='-1' bus='0' port='8'/>
    </channel>

# service libvirtd restart

# virsh dumpxml test3
error: failed to get domain 'test3'
error: Domain not found: no domain with matching name 'test3'


Actual results:
libvirt allow set a negative number to a smartcard controller and auto
create a controller(which cannot define like this) for the invalid smartcard
and this will make guest disappear after restart libvirtd.

Expected results:
output error when set it to -1

# virsh edit test3
error: internal error: Cannot parse <address> 'controller' attribute
Failed. Try again? [y,n,f,?]:

Comment 1 Michal Privoznik 2014-12-09 10:43:06 UTC
I've just pushed the patch upstream:

commit a23fefdf461c98c98e32e61440df96cf5dd43a51
Author:     Luyao Huang <lhuang@redhat.com>
AuthorDate: Mon Dec 8 16:27:26 2014 +0800
Commit:     Michal Privoznik <mprivozn@redhat.com>
CommitDate: Tue Dec 9 11:35:27 2014 +0100

    conf: forbid negative number in address(like controller, bus, slot...)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1171582
    
    When we edit a negative controller address number to a device,
    some of them will auto generate a controller with invalid index
    number. This will make guest disappear after restart libvirtd.
    Instead of allowing negative number for controller index, we
    should forbid negative number in these place (we did this before,
    but after f18c02ec, virStrToLong_ui changed to allow negative
    number). Therefore switch to virStrToLong_uip in these places.
    
    Signed-off-by: Luyao Huang <lhuang@redhat.com>
    Signed-off-by: Michal Privoznik <mprivozn@redhat.com>

v1.2.11-rc1-4-ga23fefd

Comment 3 Hu Jianwei 2015-05-07 06:54:43 UTC
Verified as below:

[root@localhost ~]# rpm -q libvirt
libvirt-1.2.15-1.el7.x86_64

Modified the controller value to "-1"

    <smartcard mode='passthrough' type='spicevmc'>
      <address type='ccid' controller='-1' slot='0'/>
    </smartcard>

[root@localhost ~]# virsh edit r71 --skip-validate
error: internal error: Cannot parse <address> 'controller' attribute
Failed. Try again? [y,n,i,f,?]: 

[root@localhost ~]# virsh edit r71 
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,?]: 
error: internal error: Cannot parse <address> 'controller' attribute
Failed. Try again? [y,n,f,?]: 

[root@localhost ~]# service libvirtd restart
Redirecting to /bin/systemctl restart  libvirtd.service
[root@localhost ~]# virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     r71                            shut off

[root@localhost ~]# virsh dumpxml r71  | grep "</smartcard>" -B2
    <smartcard mode='passthrough' type='spicevmc'>
      <address type='ccid' controller='0' slot='0'/>
    </smartcard>

Comment 5 errata-xmlrpc 2015-11-19 05:57:34 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-2202.html


Note You need to log in before you can comment on or make changes to this bug.