[libvirt] [PATCH] mark mig->flags as QEMU_MIGRATION_COOKIE_GRAPHICS only when mig->graphics is not NULL

Steps to reproduce this problem: 1. remove all <graphics ...> from xml. 2. start the domain 3. migrate the domain to another host, and libvirtd on the target host will crash. The reason of this bug is that we mark mig->flags as QEMU_MIGRATION_COOKIE_GRAPHICS even if we have no graphics. We will use mig->graphics when mig->flgas is QEMU_MIGRATION_COOKIE_GRAPHICS in the function qemuMigrationCookieXMLFormat() --- src/qemu/qemu_migration.c | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index cb408ac..3def14b 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -252,11 +252,13 @@ 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)) { + mig->graphics = qemuMigrationCookieGraphicsAlloc(driver, + dom->def->graphics[0]); + if (mig->graphics == NULL) + return -1; + mig->flags |= QEMU_MIGRATION_COOKIE_GRAPHICS; + } return 0; } -- 1.7.1
participants (1)
-
Wen Congyang