Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 919004

Summary: libvirtd crashed if do not specify a file to 'random' backend for virtio-rng
Product: Red Hat Enterprise Linux 7 Reporter: EricLee <bili>
Component: libvirtAssignee: Daniel Berrangé <berrange>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: high    
Version: 7.0CC: acathrow, berrange, cwei, dyuan, juzhang, michen, mzhan, pkrempa, ydu
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.0.4-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-06-13 12:35:10 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
crashed libvirtd log
none
garbled characters none

Description EricLee 2013-03-07 11:44:14 UTC
Created attachment 706535 [details]
crashed libvirtd log

Description of problem:
libvirtd crashed if do not specify a file to 'random' backend for virtio-rng

Version-Release number of selected component (if applicable):
# rpm -qa libvirt qemu-kvm kernel
kernel-3.7.0-0.36.el7.x86_64
libvirt-1.0.3-1.el7.x86_64
qemu-kvm-1.3.0-6.el7.x86_64

Reproduce steps:
1. # virsh edit guest
<devices>
  ...
  <rng model='virtio'>
    <backend model='random'/>
  </rng>
  ...

2. save and quit from virsh edit:
error: End of file while reading data: Input/output error
Failed. Try again? [y,n,f,?]:
error: Failed to reconnect to the hypervisor

# service libvirtd status
Redirecting to /bin/systemctl status  libvirtd.service
libvirtd.service - Virtualization daemon
          Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled)
          Active: failed (Result: core-dump) since Thu 2013-03-07 16:36:17 CST; 8s ago
         Process: 23447 ExecStart=/usr/sbin/libvirtd $LIBVIRTD_ARGS (code=dumped, signal=SEGV)
          CGroup: name=systemd:/system/libvirtd.service
                  └─3031 /sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf

Mar 07 16:35:23 intel-q9400-8-2.englab.nay.redhat.com systemd[1]: Started Virtualization daemon.
Mar 07 16:35:23 intel-q9400-8-2.englab.nay.redhat.com libvirtd[23447]: 2013-03-07 08:35:23.781+0000: 23447: info : libv...om)
Mar 07 16:35:23 intel-q9400-8-2.englab.nay.redhat.com libvirtd[23447]: 2013-03-07 08:35:23.781+0000: 23447: debug : vir...log
Mar 07 16:35:26 intel-q9400-8-2.englab.nay.redhat.com dnsmasq[3031]: read /etc/hosts - 2 addresses
Mar 07 16:35:26 intel-q9400-8-2.englab.nay.redhat.com dnsmasq[3031]: read /var/lib/libvirt/dnsmasq/default.addnhosts - ...ses
Mar 07 16:35:26 intel-q9400-8-2.englab.nay.redhat.com dnsmasq-dhcp[3031]: read /var/lib/libvirt/dnsmasq/default.hostsfile
Mar 07 16:36:17 intel-q9400-8-2.englab.nay.redhat.com systemd[1]: libvirtd.service: main process exited, code=dumped, s...EGV
Mar 07 16:36:17 intel-q9400-8-2.englab.nay.redhat.com systemd[1]: Unit libvirtd.service entered failed state

Actual results:
As steps.

Expected results:
Step 2 should give error like: we need a file for virtio-rng device backend.

Additional info:

Comment 1 EricLee 2013-03-07 11:45:06 UTC
Created attachment 706536 [details]
garbled characters

Comment 2 EricLee 2013-03-07 11:45:56 UTC
(In reply to comment #1)
> Created attachment 706536 [details]
> garbled characters

Sorry, wrong atachment.

Comment 3 Daniel Berrangé 2013-03-07 11:48:09 UTC
(gdb) bt
#0  __strcmp_ssse3 () at ../sysdeps/x86_64/strcmp.S:212
#1  0x0000003536c5a3de in virDomainRNGDefParseXML (node=0x7fcdd82ea6c0, 
    ctxt=ctxt@entry=0x7fcdd82ec250, flags=flags@entry=2)
    at conf/domain_conf.c:7426
#2  0x0000003536cba2fa in virDomainDefParseXML (
    caps=caps@entry=0x7fcdd820a240, xml=xml@entry=0x7fcdd82548d0, 
    root=root@entry=0x7fcdd8253d80, ctxt=ctxt@entry=0x7fcdd82ec250, 
    expectedVirtTypes=expectedVirtTypes@entry=15, flags=flags@entry=2)
    at conf/domain_conf.c:10649
#3  0x0000003536cbe8d4 in virDomainDefParseNode (
    caps=caps@entry=0x7fcdd820a240, xml=xml@entry=0x7fcdd82548d0, 
    root=0x7fcdd8253d80, expectedVirtTypes=expectedVirtTypes@entry=15, 
    flags=flags@entry=2) at conf/domain_conf.c:10987
#4  0x0000003536cbea1c in virDomainDefParse (
    xmlStr=xmlStr@entry=0x7fcdd82fb840 "<domain type='kvm'>\n  <name>vm1</name>\n  <uuid>c7b3edbd-edaf-9455-926a-d65c16db1800</uuid>\n  <memory unit='KiB'>219200</memory>\n  <currentMemory unit='KiB'>219136</currentMemory>\n  <vcpu placement='st"..., filename=filename@entry=0x0, caps=caps@entry=0x7fcdd820a240, 
    expectedVirtTypes=expectedVirtTypes@entry=15, flags=flags@entry=2)
    at conf/domain_conf.c:10934

Comment 4 Daniel Berrangé 2013-03-07 11:49:21 UTC
This is a flaw caused by this patch that was added to 1.0.3 right before release :-(

commit 4932ef4502bc515a7d33e09e763118b7d763cd69
Author: Eric Blake <eblake>
Date:   Mon Mar 4 15:42:07 2013 -0700

    rng: restrict passthrough names to known-good files

This code:
    
         def->source.file = virXPathString("string(./backend)", ctxt);
+        if (STRNEQ(def->source.file, "/dev/random") &&
+            STRNEQ(def->source.file, "/dev/hwrng")) {
+            virReportError(VIR_ERR_XML_ERROR,
+                           _("file '%s' is not a supported random source"),
+                           def->source.file);
+            goto error;
+        }

needs to first check if def->source.file is != NULL

Comment 5 Daniel Berrangé 2013-03-07 11:59:15 UTC
Fix posted upstream

https://www.redhat.com/archives/libvir-list/2013-March/msg00266.html

Comment 7 Peter Krempa 2013-03-19 10:18:55 UTC
Fixed upstream:

commit 75e656a363f649309fc5647c1fd402f852ef16dd
Author: Daniel P. Berrange <berrange>
Date:   Thu Mar 7 11:50:14 2013 +0000

    Fix crash parsing RNG device specification
    
    Code that validates the whitelist for the RNG device filename
    didn't account for fact that filename may be NULL. This led
    to a NULL reference crash. This wasn't caught since the test
    suite was not covering this XML syntax
    
    Signed-off-by: Daniel P. Berrange <berrange>

Comment 8 EricLee 2013-04-09 12:17:35 UTC
Verified pass this bug on libvirt-1.0.4-1.el7.x86_64:

# virsh edit r7
add xml(do not specify a file to 'random' backend):
    <rng model='virtio'>
      <backend model='random'/>
    </rng>
to guest xml,then save successfully.

Checking libvirtd status running not crash:
# service libvirtd status
Redirecting to /bin/systemctl status  libvirtd.service
libvirtd.service - Virtualization daemon
	  Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled)
	  Active: active (running) since Tue 2013-04-09 20:07:56 CST; 6min ago
	Main PID: 5259 (libvirtd)
	  CGroup: name=systemd:/system/libvirtd.service
		  ├─2889 /sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf
		  ├─5259 /usr/sbin/libvirtd
		  └─6762 /usr/libexec/qemu-kvm -name r7 -S -M pc-i440fx-1.4 -enable-kvm -m 1024 -smp 2,maxcpus=4,sockets=4...

Apr 09 20:07:56 intel-q9400-8-2.englab.nay.redhat.com systemd[1]: Started Virtualization daemon.
Apr 09 20:07:56 intel-q9400-8-2.englab.nay.redhat.com libvirtd[5259]: 2013-04-09 12:07:56.357+0000: 5259: info : libvir...om)
Apr 09 20:07:56 intel-q9400-8-2.englab.nay.redhat.com libvirtd[5259]: 2013-04-09 12:07:56.357+0000: 5259: debug : virLo...log
Apr 09 20:08:00 intel-q9400-8-2.englab.nay.redhat.com dnsmasq[2889]: read /etc/hosts - 5 addresses
Apr 09 20:08:00 intel-q9400-8-2.englab.nay.redhat.com dnsmasq[2889]: read /var/lib/libvirt/dnsmasq/default.addnhosts - ...ses
Apr 09 20:08:00 intel-q9400-8-2.englab.nay.redhat.com dnsmasq-dhcp[2889]: read /var/lib/libvirt/dnsmasq/default.hostsfile
Apr 09 20:12:44 intel-q9400-8-2.englab.nay.redhat.com dnsmasq-dhcp[2889]: DHCPDISCOVER(virbr0) 52:54:00:7c:90:09
Apr 09 20:12:44 intel-q9400-8-2.englab.nay.redhat.com dnsmasq-dhcp[2889]: DHCPOFFER(virbr0) 192.168.122.10 52:54:00:7c:90:09
Apr 09 20:12:44 intel-q9400-8-2.englab.nay.redhat.com dnsmasq-dhcp[2889]: DHCPREQUEST(virbr0) 192.168.122.10 52:54:00:7...:09
Apr 09 20:12:44 intel-q9400-8-2.englab.nay.redhat.com dnsmasq-dhcp[2889]: DHCPACK(virbr0) 192.168.122.10 52:54:00:7c:90:09

And guest can start up normally:
# virsh start r7
Domain r7 started

# ps aux | grep qemu
qemu      6762 93.5  1.0 1568700 79112 ?       Sl   20:12   0:07 /usr/libexec/qemu-kvm -name r7 -S -M pc-i440fx-1.4 -enable-kvm -m 1024 -smp 2,maxcpus=4,sockets=4,cores=1,threads=1 -uuid 613aec83-8fc4-da46-9b03-863d4a186e28 -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/r7.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -device lsi,id=scsi0,bus=pci.0,addr=0x8 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x5 -drive file=/var/lib/libvirt/images/rhel7.img,if=none,id=drive-virtio-disk0,format=raw -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x6,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -netdev tap,fd=23,id=hostnet0,vhost=on,vhostfd=24 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:7c:90:09,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -chardev socket,id=charchannel0,path=/var/lib/libvirt/qemu/r7.agent,server,nowait -device virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel0,id=channel0,name=org.qemu.guest_agent.0 -device usb-tablet,id=input0 -vnc 127.0.0.1:0 -vga cirrus -device i6300esb,id=watchdog0,bus=pci.0,addr=0x4 -watchdog-action pause -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x7 -object rng-random,id=rng0 -device virtio-rng-pci,rng=rng0,bus=pci.0,addr=0x9

So setting VERIFIED.

Comment 9 Ludek Smid 2014-06-13 12:35:10 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.