[PATCH] Fix QEMU migration cookie crash for guests with no graphics

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When generating a cookie for a guest with no data, the
QEMU_MIGRATION_COOKIE_GRAPHICS flag was set even if no
graphics data was added. Avoid setting the flag unless
it was needed, also add a safety check for mig->graphics
being non-NULL

* src/qemu/qemu_migration.c: Avoid cookie crash for guest
  with no graphics
---
 src/qemu/qemu_migration.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index fcf8f9c..4d7bc38 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -252,11 +252,12 @@ qemuMigrationCookieAddGraphics(qemuMigrationCookiePtr mig,
 
     if (dom->def->ngraphics == 1 &&
         (dom->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ||
-         dom->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) &&
-        !(mig->graphics = qemuMigrationCookieGraphicsAlloc(driver, dom->def->graphics[0])))
-        return -1;
-
-    mig->flags |= QEMU_MIGRATION_COOKIE_GRAPHICS;
+         dom->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE)) {
+        if (!(mig->graphics =
+              qemuMigrationCookieGraphicsAlloc(driver, dom->def->graphics[0])))
+            return -1;
+        mig->flags |= QEMU_MIGRATION_COOKIE_GRAPHICS;
+    }
 
     return 0;
 }
@@ -295,7 +296,8 @@ static void qemuMigrationCookieXMLFormat(virBufferPtr buf,
     virBufferEscapeString(buf, "  <hostname>%s</hostname>\n", mig->hostname);
     virBufferAsprintf(buf, "  <hostuuid>%s</hostuuid>\n", hostuuidstr);
 
-    if (mig->flags & QEMU_MIGRATION_COOKIE_GRAPHICS)
+    if ((mig->flags & QEMU_MIGRATION_COOKIE_GRAPHICS) &&
+        mig->graphics)
         qemuMigrationCookieGraphicsXMLFormat(buf, mig->graphics);
 
     virBufferAddLit(buf, "</qemu-migration>\n");
-- 
1.7.4.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]