提交 03f88326 编写于 作者: D Daniel P. Berrange

Fix QEMU migration cookie crash for guests with no graphics

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
上级 2f3c6826
...@@ -252,11 +252,12 @@ qemuMigrationCookieAddGraphics(qemuMigrationCookiePtr mig, ...@@ -252,11 +252,12 @@ qemuMigrationCookieAddGraphics(qemuMigrationCookiePtr mig,
if (dom->def->ngraphics == 1 && if (dom->def->ngraphics == 1 &&
(dom->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC || (dom->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ||
dom->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) && dom->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE)) {
!(mig->graphics = qemuMigrationCookieGraphicsAlloc(driver, dom->def->graphics[0]))) if (!(mig->graphics =
return -1; qemuMigrationCookieGraphicsAlloc(driver, dom->def->graphics[0])))
return -1;
mig->flags |= QEMU_MIGRATION_COOKIE_GRAPHICS; mig->flags |= QEMU_MIGRATION_COOKIE_GRAPHICS;
}
return 0; return 0;
} }
...@@ -295,7 +296,8 @@ static void qemuMigrationCookieXMLFormat(virBufferPtr buf, ...@@ -295,7 +296,8 @@ static void qemuMigrationCookieXMLFormat(virBufferPtr buf,
virBufferEscapeString(buf, " <hostname>%s</hostname>\n", mig->hostname); virBufferEscapeString(buf, " <hostname>%s</hostname>\n", mig->hostname);
virBufferAsprintf(buf, " <hostuuid>%s</hostuuid>\n", hostuuidstr); 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); qemuMigrationCookieGraphicsXMLFormat(buf, mig->graphics);
virBufferAddLit(buf, "</qemu-migration>\n"); virBufferAddLit(buf, "</qemu-migration>\n");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册