Bug 1343858

Summary: Guest image owner changes to root:root if kill source libvirtd in migration confirm phase.
Product: Red Hat Enterprise Linux 7 Reporter: Fangge Jin <fjin>
Component: libvirtAssignee: Jiri Denemark <jdenemar>
Status: CLOSED ERRATA QA Contact: yafu <yafu>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3CC: dyuan, mzhan, rbalakri, xuzhang, yafu, zpeng
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-2.5.0-1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 17:09:12 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:
Embargoed:
Attachments:
Description Flags
libvirtd and qemu log on both source host and target host. none

Description Fangge Jin 2016-06-08 07:47:58 UTC
Created attachment 1165856 [details]
libvirtd and qemu log on both source host and target host.

Description of problem:
Migrate a guest, and kill source libvirtd in migration confirm phase, the guest image owner will be changed to root:root. Guest is running on target host, but can't access disk, and guest is destroyed on source host.

Version-Release number of selected component (if applicable):
libvirt-1.3.5-1.el7.x86_64

How reproducible:
100% Bug it's hard to catch the point, because confirm phase is very short.

Steps to Reproduce:
1. # virsh start rhel7.2-min
Domain rhel7.2-min started

2. # virsh migrate-setspeed rhel7.2-min 10

3. Do migration, and do "pkill -9 libvirtd" on source host in confirm phase ( after memory is migration is 100% completed)

# virsh migrate rhel7.2-min qemu+ssh://hp-dl385g7-05.lab.eng.pek2.redhat.com/system --live --verbose 
Migration: [100 %]2016-06-08 07:23:02.007+0000: 16006: info : libvirt version: 1.3.5, package: 1.el7 (Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>, 2016-06-07-09:10:22, x86-034.build.eng.bos.redhat.com)
2016-06-08 07:23:02.007+0000: 16006: info : hostname: hp-dl385g7-06.lab.eng.pek2.redhat.com
2016-06-08 07:23:02.007+0000: 16006: warning : virDomainMigrateVersion3Full:3253 : Guest rhel7.2-min probably left in 'paused' state on source
error: Disconnected from qemu:///system due to I/O error
Migration: [100 %]

4. On source host
# virsh list
 Id    Name                           State
----------------------------------------------------

5. On target host
# virsh list
 Id    Name                           State
----------------------------------------------------
 8    rhel7.2-min                    running


# ll /90121/fjin/rhel7.2-min.qcow2 
-rw-------. 1 root root 9665380352 6月   8 2016 /90121/fjin/rhel7.2-min.qcow2


Actual results:
As step 5 shows, guest image owner is changed to root:root

Expected results:
Guest image owner is qemu:qemu

Additional info:

Comment 2 Jiri Denemark 2016-11-29 11:40:39 UTC
This is now fixed upstream by

commit 0355de2e77fa8a11419fde5b0eb68458a7fb62ca
Refs: v2.5.0-rc1-2-g0355de2e7
Author:     Jiri Denemark <jdenemar>
AuthorDate: Wed Nov 23 14:07:53 2016 +0100
Commit:     Jiri Denemark <jdenemar>
CommitDate: Tue Nov 29 12:37:04 2016 +0100

    qemuProcessReconnect: Avoid relabeling images after migration

    Restarting libvirtd on the source host at the end of migration when a
    domain is already running on the destination would cause image labels to
    be reset effectively killing the domain. Commit e8d0166e1d fixed similar
    issue on the destination host, but kept the source always resetting the
    labels, which was mostly correct except for the specific case handled by
    this patch.

    https://bugzilla.redhat.com/show_bug.cgi?id=1343858

    Signed-off-by: Jiri Denemark <jdenemar>

Comment 4 yafu 2017-03-01 08:14:05 UTC
Reproduce the bug with libvirt-2.0.0-10.el7.x86_64:
steps:
1.gdb -p `pidof libvirtd`
(gdb) br qemuMigrationConfirmPhase
Breakpoint 1 at 0x7f60739a0f30: file qemu/qemu_migration.c, line 4173.
(gdb) c
Continuing.
[Switching to Thread 0x7f60b7be9700 (LWP 7881)]

Breakpoint 1, qemuMigrationConfirmPhase (driver=driver@entry=0x7f605417a150, conn=conn@entry=0x7f60a8001330, vm=0x7f60542ad210, 
    cookiein=cookiein@entry=0x7f60a80040b0 "<qemu-migration>\n  <name>rhel7.3-min</name>\n  <uuid>1b3268d6-b59c-406b-a14c-33b000b15b6c</uuid>\n  <hostname>dhcp-66-71-81.eng.nay.redhat.com</hostname>\n  <hostuuid>8b6f1788-6105-11e4-b60b-2248c3061500"..., cookieinlen=cookieinlen@entry=1128, flags=flags@entry=769, retcode=retcode@entry=0)
    at qemu/qemu_migration.c:4173
4173	{
(gdb) c

2.virsh migrate rhel7.3-min qemu+ssh://10.66.5.14/system --live --verbose

3.After step2 reached confirm phase, check the output in the step1 and kill libvirtd process on source host;
...

Breakpoint 1, qemuMigrationConfirmPhase (driver=driver@entry=0x7f09d8119440, 
    conn=conn@entry=0x7f0a30027700, vm=0x7f09d81e7b00, 
    cookiein=cookiein@entry=0x7f0a20005a50 "<qemu-migration>\n  <name>rhel7.3-min</name>\n  <uuid>1b3268d6-b59c-406b-a14c-33b000b15b6c</uuid>\n  <hostname>dhcp-66-71-81.eng.nay.redhat.com</hostname>\n  <hostuuid>8b6f1788-6105-11e4-b60b-2248c3061500"..., cookieinlen=cookieinlen@entry=1130, 
    flags=flags@entry=769, retcode=retcode@entry=0) at qemu/qemu_migration.c:4202
4202	{
(gdb) 
...

#pkill -9 libvirtd

4.Check the guest on source host:
# virsh list
 Id    Name                           State
----------------------------------------------------

5. Check the guest on target host
# virsh list
 Id    Name                           State
----------------------------------------------------
 8    rhel7.2-min                    running

6.Check the image owner on target host

# ll /nfs-images/yafu/rhel7.2.qcow2 
-rwxrwxrwx. 1 root root 12887130112 Mar  1  2017 /nfs-images/yafu/rhel7.2.qcow2

Verify the bug with libvirt-3.0.0-2.el7.x86_64.
steps:
1.Excute the step1-5 in the reproduce steps;
2.Check the image owner on target host:
# ll /nfs-images/yafu/rhel7*
-rwxrwxrwx. 1 qemu qemu 12887130112 Mar  2  2017 /nfs-images/yafu/rhel7.2.qcow2

As the result of step2 shows, the guest image owner did not change to root:root if kill source libvirtd in migration confirm phase.

Comment 5 errata-xmlrpc 2017-08-01 17:09:12 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2017:1846

Comment 6 errata-xmlrpc 2017-08-01 23:51:16 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2017:1846