c401cc
From 43d145082f832619cbfe220c16a4442507e9feaf Mon Sep 17 00:00:00 2001
c401cc
Message-Id: <43d145082f832619cbfe220c16a4442507e9feaf.1389183250.git.jdenemar@redhat.com>
c401cc
From: John Ferlan <jferlan@redhat.com>
c401cc
Date: Tue, 7 Jan 2014 14:18:28 -0700
c401cc
Subject: [PATCH] PanicCheckABIStability: Need to check for existence
c401cc
c401cc
https://bugzilla.redhat.com/show_bug.cgi?id=996520
c401cc
c401cc
Commit id '4313fead' added a call to virDomainPanicCheckABIStability()
c401cc
which did not check whether the panic device existed before making a call
c401cc
to virDomainDeviceInfoCheckABIStability() which ended up segfaulting:
c401cc
c401cc
Thread 1 (Thread 0x7f5332837700 (LWP 10964)):
c401cc
    (src=<optimized out>, dst=<optimized out>)
c401cc
    at conf/domain_conf.c:13007
c401cc
    (dst=<optimized out>, src=<optimized out>)
c401cc
    at conf/domain_conf.c:13712
c401cc
    (src=<optimized out>, dst=<optimized out>)
c401cc
    at conf/domain_conf.c:14056
c401cc
    (domain=domain@entry=0x7f53000057c0, vm=vm@entry=0x7f53000036d0,
c401cc
     defptr=defptr@entry=0x7f5332836978, snap=snap@entry=0x7f5332836970,
c401cc
     update_current=update_current@entry=0x7f5332836962, flags=flags@entry=1)
c401cc
    at conf/snapshot_conf.c:1230
c401cc
    (domain=0x7f53000057c0, xmlDesc=<optimized out>, flags=1)
c401cc
    at qemu/qemu_driver.c:12719
c401cc
    (domain=domain@entry=0x7f53000057c0, xmlDesc=0x7f53000081d0
c401cc
     "<domainsnapshot>\n  <name>snap2</name>\n
c401cc
     <description>new-desc</description>\n  <state>running</state>\n
c401cc
     <parent>\n    <name>snap1</name>\n  </parent>\n
c401cc
     <creationTime>1387487268</creationTime>\n  
c401cc
    at libvirt.c:19695
c401cc
...
c401cc
c401cc
(gdb) up 3
c401cc
(gdb) print *other->def->dom
c401cc
$2 = {virtType = 2, id = -1, ..
c401cc
...
c401cc
  rng = 0x0, panic = 0x0, namespaceData = 0x0,...
c401cc
...
c401cc
(gdb) print *def->dom
c401cc
$3 = {virtType = 2, id = -1, ...
c401cc
...
c401cc
  rng = 0x0, panic = 0x0, namespaceData = 0x0,...
c401cc
...
c401cc
(gdb)
c401cc
c401cc
Also seen using following sequence:
c401cc
c401cc
virsh save $dom $file
c401cc
virsh save-image-edit $file
c401cc
  add (or remove) a <panic/> line
c401cc
  <devices>
c401cc
  ...
c401cc
    <panic>
c401cc
      <address type='isa' iobase='0x505'/>
c401cc
    </panic>
c401cc
  ...
c401cc
  </devices>
c401cc
c401cc
(cherry picked from commit d53c57b806b94adaed650b7ff10893905ff2fa1f)
c401cc
c401cc
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c401cc
---
c401cc
 src/conf/domain_conf.c | 11 +++++++++++
c401cc
 1 file changed, 11 insertions(+)
c401cc
c401cc
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
c401cc
index bc53a89..06ec82d 100644
c401cc
--- a/src/conf/domain_conf.c
c401cc
+++ b/src/conf/domain_conf.c
c401cc
@@ -13539,6 +13539,17 @@ static bool
c401cc
 virDomainPanicCheckABIStability(virDomainPanicDefPtr src,
c401cc
                                 virDomainPanicDefPtr dst)
c401cc
 {
c401cc
+    if (!src && !dst)
c401cc
+        return true;
c401cc
+
c401cc
+    if (!src || !dst) {
c401cc
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
c401cc
+                       _("Target domain panic device count '%d' "
c401cc
+                         "does not match source count '%d'"),
c401cc
+                       src ? 1 : 0, dst ? 1 : 0);
c401cc
+        return false;
c401cc
+    }
c401cc
+
c401cc
     return virDomainDeviceInfoCheckABIStability(&src->info, &dst->info);
c401cc
 }
c401cc
 
c401cc
-- 
c401cc
1.8.5.2
c401cc