Bug 835300

Summary: virsh migrate --live --copy-storage-all --persistent ... --xml dest-domain.xml saves wrong XML at destination
Product: [Community] Virtualization Tools Reporter: Need Real Name <karlcz>
Component: libvirtAssignee: Jiri Denemark <jdenemar>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: bugs, crobinso, cwei, dyuan, fjin, laine, libvirt-maint, mzhan, rbalakri, tm, weizhan, zpeng
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-22 20:36:40 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:

Description Need Real Name 2012-06-25 21:43:20 UTC
Description of problem:

Using "virsh migrate --live --copy-storage-all ... --xml dest-domain.xml" persists the source-specific domain XML rather than the destination-specific XML.

This happens even though the correct destination-specific XML is used to write the storage copy and create the live-migrated VM at the destination.  The VM will fail later when it tries to use the persisted XML which doesn't match the host storage.

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1. create a VM on a source host
2. create an appropriate empty disk image on destination host, e.g. with different backing storage name
3. perform virsh live migration with destination-specific domain XML file and the --persistent flag
Actual results:

The persistent domain XML at the destination matches the source XML rather than the XML of the running domain after migration, which came from the --xml argument to the migrate command.

Expected results:

The persistent domain XML at the destination should match the XML of the running domain after migration.

Additional info:

I observe this on a plain CentOS 6.2 install but thought you might like to know about the bug...

Comment 2 Malte Starostik 2014-02-19 10:10:48 UTC
Me Too™
I first came accross this issue with --copy-storage-all, too.  But after some further migrations at our site I can add that storage copy has nothing to do with this.  The same issue applies with shared storage when modifying just anything in the XML for migration - network attachments, direct kernel boot paths, etc.
So basically, what's passed via virsh migrate's --xml option is applied to the running VM at the destination while the persistent definition will be a copy of the source's persistent definition without the modifications.
And it still happens with 1.2.1

Workaround: virsh edit on the destination will then show the persistent version.  Replacing that with the live one commits the correct XML to disk.

Comment 3 Tiziano Müller 2014-11-21 09:58:25 UTC
As it is, this bug is still present in 1.2.8 and I can confirm Malte's analysis: the XML provided during the migration is only used for starting the VM, the inactive XML is directly copied from the source host if the VIR_MIGRATE_PERSIST_DEST is present.

Comment 4 Cole Robinson 2016-04-20 13:29:17 UTC
Note this seems to have just been fixed with an extra migration flag:

commit b028e9d7c2f0f7713ba102d01aece13ee72136a1
Author: Dmitry Andreev <dandreev@virtuozzo.com>
Date:   Thu Mar 17 19:31:45 2016 +0300

    qemu: migration: new migration param for persistent destination XML
    Migration API allows to specify a destination domain configuration.
    Offline domain has only inactive XML and it is replaced by configuration
    specified using VIR_MIGRATE_PARAM_DEST_XML param. In case of live
    migration VIR_MIGRATE_PARAM_DEST_XML param is applied for active XML.
    This commit introduces the new VIR_MIGRATE_PARAM_PERSIST_XML param
    that can be used within live migration to replace persistent/inactive
    Required for: https://bugzilla.redhat.com/show_bug.cgi?id=835300

It should probably be wired up in virsh too though...

Comment 5 Jiri Denemark 2016-11-22 20:36:40 UTC
Finally fixed by

commit 38f7f297c84dc41cf3e7d2ae5a8f25273f674f13
Refs: v2.4.0-184-g38f7f297c
Author:     Jiri Denemark <jdenemar@redhat.com>
AuthorDate: Tue Nov 22 14:06:43 2016 +0100
Commit:     Jiri Denemark <jdenemar@redhat.com>
CommitDate: Tue Nov 22 21:24:55 2016 +0100

    virsh: Add support for VIR_MIGRATE_PARAM_PERSIST_XML

    Commit v1.3.3-181-gb028e9d7c implmented support for
    VIR_MIGRATE_PARAM_PERSIST_XML migration parameter, but forgot to update


    Signed-off-by: Jiri Denemark <jdenemar@redhat.com>