Bug 1267256
Summary: | do not crash if a machine config in /etc/libvirt is missing a machine type | ||||||
---|---|---|---|---|---|---|---|
Product: | Red Hat Enterprise Linux 7 | Reporter: | Stefan Assmann <sassmann> | ||||
Component: | libvirt | Assignee: | Ján Tomko <jtomko> | ||||
Status: | CLOSED ERRATA | QA Contact: | Virtualization Bugs <virt-bugs> | ||||
Severity: | high | Docs Contact: | |||||
Priority: | unspecified | ||||||
Version: | 7.2 | CC: | bloch, cbuissar, dyuan, fjin, jsuchane, mzhan | ||||
Target Milestone: | rc | ||||||
Target Release: | --- | ||||||
Hardware: | x86_64 | ||||||
OS: | Linux | ||||||
Whiteboard: | |||||||
Fixed In Version: | libvirt-1.3.2-1.el7 | Doc Type: | Bug Fix | ||||
Doc Text: | Story Points: | --- | |||||
Clone Of: | Environment: | ||||||
Last Closed: | 2016-11-03 18:25:27 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
Stefan Assmann
2015-09-29 13:10:46 UTC
Created attachment 1078349 [details]
abrt report
Program terminated with signal 11, Segmentation fault. #0 0x00007f04f5434b07 in qemuDomainMachineIsI440FX (def=def@entry=0x7f04ec241ef0) at qemu/qemu_domain.c:3325 3325 return (STREQ(def->os.machine, "pc") || (gdb) p def->os.machine $1 = 0x0 It seems the machine type is empty. I see the problem now, this output redirection writes directly into libvirt's domain config directory: > /etc/libvirt/qemu/rhel7-64-kvm.xml Please do not mess with internal libvirt configuration and use libvirt's APIs to define new machines (virt-install should take care of that, as should virsh define) The following commit skipped checking the machine type completely: commit f1a89a8b6d1a1097e41a171a13b1984b06e8ab3e Author: Cole Robinson <crobinso> CommitDate: 2015-04-20 16:36:35 -0400 domain: conf: Don't validate VM ostype/arch at daemon startup When parsing XML, we validate the passed ostype + arch combo against the detected hypervisor capabilities. This has led to the following problem: - Define x86 qemu guest - qemu is inadvertently removed from the host - libvirtd is restarted. fails to parse VM config since arch is removed - 'virsh list --all' is now empty, user is wondering where their VMs went Add a new internal flag VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS. Use it when loading VM and snapshot configs from disk. https://bugzilla.redhat.com/show_bug.cgi?id=1043572 git describe: v1.2.14-230-gf1a89a8 contains: v1.2.15-rc1~109 However we can still check for the presence of a machine string and refuse to parse such invalid config, instead of crashing. Thanks Ján for the update. This worked for me on 7.0 and 7.1. Can you make a suggestion for an alternate set of commands to import the image? Removing --print-xml (and the redirection) should do the trick. If you don't want virt-install to open the console and just import the machine to libvirt, add --noautoconsole. Confirming that this work. Thanks again! *** Bug 1272364 has been marked as a duplicate of this bug. *** Reproduce steps: 0. Install libvirt # # rpm -q libvirt libvirt-1.2.17-11.el7.x86_64 1. Prepare a guest xml in directory /etc/libvirt/qemu/ : # cat /etc/libvirt/qemu/rhel7.2-released.xml .. <domain type='kvm'> ... <os> <type arch='x86_64'>hvm</type> ====> without machine type ... 2. Restart libvirtd 3. list domains: # virsh list --all Id Name State ---------------------------------------------------- - rhel7.2-released shut off 4. Try to start domain, libvirtd crashed: # virsh start rhel7.2-released error: Failed to start domain rhel7.2-released error: End of file while reading data: Input/output error Fixed upstream by: commit 55e6d8cd9eac7eb2aaa4d221585e9402cf7269d5 Author: Ján Tomko <jtomko> CommitDate: 2016-02-18 16:19:39 +0100 Error out on missing machine type in machine configs Commit f1a89a8 allowed parsing configs from /etc/libvirt without validating the emulator capabilities. Check for the presence of os->type.machine even if the VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS flag is set, otherwise the daemon can crash on carelessly crafted input in the config directory. https://bugzilla.redhat.com/show_bug.cgi?id=1267256 git describe: v1.3.1-307-g55e6d8c The patch breaks persistent LXC domains: https://www.redhat.com/archives/libvir-list/2016-February/msg01228.html New fix pushed: commit 21b316f4d351859d9ccbf8a20199f7e8707fd51d Author: Ján Tomko <jtomko> CommitDate: 2016-02-26 10:32:31 +0100 qemu: error out on missing machine type in configs Commit f1a89a8 allowed parsing configs from /etc/libvirt without validating the emulator capabilities. Check for the presence of a machine type in the qemu driver's post parse function instead of crashing. https://bugzilla.redhat.com/show_bug.cgi?id=1267256 git describe: v1.3.2-rc1-17-g21b316f Verify pass on build libvirt-1.3.3-1.el7.x86_64 Scenario 1: qemu guest 1. Prepare a guest xml in directory /etc/libvirt/qemu/ : # cat /etc/libvirt/qemu/rhel7.2-1030.xml .. <domain type='kvm'> <name>rhel7.2-1030</name> ... <os> <type arch='x86_64'>hvm</type> ====> without machine type ... <devices> <emulator>/usr/libexec/qemu-kvm</emulator> ... 2. Restart libvirtd 3. # virsh list --all Id Name State ---------------------------------------------------- (domain rhel7.2-1030 is not listed) 4. Check libvirtd.log: 2016-04-13 08:41:23.039+0000: 9959: error : qemuDomainDefPostParse:1431 : internal error: missing machine type Scenario 2: do regression test for lxc guest 0.Prepare a lxc guest xml: # cat lxc.xml <domain type='lxc'> <name>application</name> ... <os> <type arch='x86_64'>exe</type> ===>lxc guest has no machine type attribute <init>/bin/sh</init> </os> ... <devices> <emulator>/usr/libexec/libvirt_lxc</emulator> 1. # virsh -c lxc:/// Welcome to virsh, the virtualization interactive terminal. Type: 'help' for help with commands 'quit' to quit virsh # define /tmp/lxc.xml Domain application defined from /tmp/lxc.xml virsh # list --all Id Name State ---------------------------------------------------- - application shut off Continue of comment 15: Scenario 2: do regression test for lxc guest 2.After define a lxc guest, dumpxml: virsh # dumpxml application <domain type='lxc'> <name>application</name> ... <os> <type arch='x86_64'>exe</type> ===>lxc guest has no machine type attribute <init>/bin/sh</init> </os> 3. Restart libvirtd service 4. # virsh -c lxc:/// list --all Id Name State ---------------------------------------------------- - application shut off # virsh -c lxc:/// dumpxml application <domain type='lxc'> <name>application</name> ... <os> <type arch='x86_64'>exe</type> ===>lxc guest has no machine type attribute <init>/bin/sh</init> </os> Scenario 3: define a qemu guest from a xml without machine type # cat /tmp/rhel7.2-1030.xml <domain type='kvm'> <name>rhel7.2-1030</name> ... <os> <type arch='x86_64'>hvm</type> ... <devices> <emulator>/usr/libexec/qemu-kvm</emulator> # virsh define /tmp/rhel7.2-1030.xml # virsh list --all Id Name State ---------------------------------------------------- - rhel7.2-1030 shut off # virsh dumpxml rhel7.2-1030 <os> <type arch='x86_64' machine='pc-i440fx-rhel7.2.0'>hvm</type> ===> machine type is added automatically 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/RHSA-2016-2577.html |