migration: fix live migration failure with compression
PATCH 1/1 migration: fix live migration failure with compression
Because of commit 11808bb0c422, which remove some condition checks of 'f->ops->writev_buffer', 'qemu_put_qemu_file' should be enhanced to clear the 'f_src->iovcnt', or 'f_src->iovcnt' may exceed the MAX_IOV_SIZE which will break live migration. This should be fixed.
--- migration/qemu-file.c | 1 + 1 file changed, 1 insertion(+)
migration/qemu-file.c +1 -0
@@ -668,6 +668,7 @@ int qemu_put_qemu_file(QEMUFile *f_des, QEMUFile *f_src) len = f_src->buf_index;qemu_put_buffer (f_des, f_src->buf, f_src->buf_index); f_src->buf_index =0 ; + f_src->iovcnt =0 ; }return len; }
Signature · 1 line
1.9.1
Quoted 16 lines · * Liang Li ([email protected]) wrote:
Because of commit
11808bb0c422, which remove some condition checks of 'f->ops->writev_buffer', 'qemu_put_qemu_file' should be enhanced to clear the 'f_src->iovcnt', or 'f_src->iovcnt' may exceed theMAX_IOV_SIZEwhich will break live migration. This should be fixed.Signed-off-by Liang Li <[email protected]>Reported-by Jinshi Zhang <[email protected]>--- migration/qemu-file.c | 1 + 1 file changed, 1 insertion(+)migration/qemu-file.c +0
-0
migration/qemu-file.c int qemu_put_qemu_file(QEMUFile *f_des, QEMUFile *f_src) · line 672
Quoted 5 lines
migration/qemu-file.c +1
-0@@ -668,6 +668,7 @@ int qemu_put_qemu_file(QEMUFile *f_des, QEMUFile *f_src) len = f_src->buf_index;qemu_put_buffer (f_des, f_src->buf, f_src->buf_index); f_src->buf_index =0 ; + f_src->iovcnt =0 ; }
If you're just using the buf[] in the src, how does it end up incrementing the iovcnt?
Dave
Quoted 5 lines
migration/qemu-file.c +0
-0return len; }Signature · 1 line
1.9.1
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 26 lines
Subject: Re: [PATCH] migration: fix live migration failure with compression
migration/qemu-file.c int qemu_put_qemu_file(QEMUFile *f_des,
Quoted 16 lines · * Liang Li ([email protected]) wrote:
Because of commit
11808bb0c422, which remove some condition checks of 'f->ops->writev_buffer', 'qemu_put_qemu_file' should be enhanced to clear the 'f_src->iovcnt', or 'f_src->iovcnt' may exceed theMAX_IOV_SIZEwhich will break live migration. This should be fixed.Signed-off-by Liang Li <[email protected]>Reported-by Jinshi Zhang <[email protected]>--- migration/qemu-file.c | 1 + 1 file changed, 1 insertion(+)migration/qemu-file.c index renamed from migration/qemu-file.c +0
-0bbc565e..e9fae31 100644
migration/qemu-file.c +0
-0@@ -668,6 +668,7 @@ int qemu_put_qemu_file(QEMUFile *f_des,QEMUFile
*f_src)migration/qemu-file.c int qemu_put_qemu_file(QEMUFile *f_des, QEMUFile *f_src) · line 672
Quoted 5 lines
migration/qemu-file.c +1
-0len = f_src->buf_index;qemu_put_buffer (f_des, f_src->buf, f_src->buf_index); f_src->buf_index =0 ; + f_src->iovcnt =0 ; }
Quoted 7 lines
If you're just using the buf[] in the src, how does it end up incrementing the iovcnt?
Dave
Quoted 2 lines
migration/qemu-file.c +0
-0return len; }
'qemu_put_be32' is used to put some data to an allocated 'f_src'. Before the 11808bb0c422, this operation won't increase the 'f_src->iovcnt', there is no issue.
Commit 11808bb0c422 remove the checking of 'f->ops->writev_buffer',
now 'qemu_put_be32' will increase 'f_src->iovcnt' and set 'f_src->iov []', once the 'f_src->iovcnt' reach to MAX_IOV_SIZE, 'qemu_fflush' will be trigged. Beacause 'f_src' is not writeable, 'qemu_fflsh' will return without wrapping around 'f_src->iovcnt' , the following 'qemu_put_be32' on 'f_src' will increase 'f_src->iovcnt' and make it exceed MAX_IOV_SIZE, then set 'f_src->iov[]' will corrupt memory.
Liang
Quoted 34 lines · * Li, Liang Z ([email protected]) wrote:
Quoted 26 lines
Subject: Re: [PATCH] migration: fix live migration failure with compression
migration/qemu-file.c int qemu_put_qemu_file(QEMUFile *f_des,
Quoted 16 lines · * Liang Li ([email protected]) wrote:
Because of commit
11808bb0c422, which remove some condition checks of 'f->ops->writev_buffer', 'qemu_put_qemu_file' should be enhanced to clear the 'f_src->iovcnt', or 'f_src->iovcnt' may exceed theMAX_IOV_SIZEwhich will break live migration. This should be fixed.Signed-off-by Liang Li <[email protected]>Reported-by Jinshi Zhang <[email protected]>--- migration/qemu-file.c | 1 + 1 file changed, 1 insertion(+)migration/qemu-file.c index renamed from migration/qemu-file.c +0
-0bbc565e..e9fae31 100644
migration/qemu-file.c +0
-0@@ -668,6 +668,7 @@ int qemu_put_qemu_file(QEMUFile *f_des,QEMUFile
*f_src)migration/qemu-file.c int qemu_put_qemu_file(QEMUFile *f_des, QEMUFile *f_src) · line 672
Quoted 5 lines
migration/qemu-file.c +1
-0len = f_src->buf_index;qemu_put_buffer (f_des, f_src->buf, f_src->buf_index); f_src->buf_index =0 ; + f_src->iovcnt =0 ; }Quoted 7 lines
If you're just using the buf[] in the src, how does it end up incrementing the iovcnt?
Dave
Quoted 2 lines
migration/qemu-file.c +0
-0return len; }
Quoted 7 lines
'
qemu_put_be32' is used to put some data to an allocated 'f_src'. Before the11808bb0c422, this operation won't increase the 'f_src->iovcnt', there is no issue.
Commit11808bb0c422remove the checking of 'f->ops->writev_buffer',
now 'qemu_put_be32' will increase 'f_src->iovcnt' and set 'f_src->iov[]', once the 'f_src->iovcnt' reach toMAX_IOV_SIZE, 'qemu_fflush' will be trigged. Beacause 'f_src' is not writeable, 'qemu_fflsh' will return without wrapping around 'f_src->iovcnt' , the following 'qemu_put_be32' on 'f_src' will increase 'f_src->iovcnt' and make it exceedMAX_IOV_SIZE, then set 'f_src->iov[]' will corrupt memory.
OK, thanks
Amit, Peter: I think this is one for 2.7 because I think that's a regression given that the 11808bb0c422 referenced is after 2.6.
Dave
Quoted 2 lines
Liang
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 43 lines · Dr. David Alan Gilbert
Quoted 34 lines · * Li, Liang Z ([email protected]) wrote:
Quoted 26 lines
Subject: Re: [PATCH] migration: fix live migration failure with compression
migration/qemu-file.c int qemu_put_qemu_file(QEMUFile *f_des,
Quoted 16 lines · * Liang Li ([email protected]) wrote:
Because of commit
11808bb0c422, which remove some condition checks of 'f->ops->writev_buffer', 'qemu_put_qemu_file' should be enhanced to clear the 'f_src->iovcnt', or 'f_src->iovcnt' may exceed theMAX_IOV_SIZEwhich will break live migration. This should be fixed.Signed-off-by Liang Li <[email protected]>Reported-by Jinshi Zhang <[email protected]>--- migration/qemu-file.c | 1 + 1 file changed, 1 insertion(+)migration/qemu-file.c index renamed from migration/qemu-file.c +0
-0bbc565e..e9fae31 100644
migration/qemu-file.c +0
-0@@ -668,6 +668,7 @@ int qemu_put_qemu_file(QEMUFile *f_des,QEMUFile
*f_src)migration/qemu-file.c int qemu_put_qemu_file(QEMUFile *f_des, QEMUFile *f_src) · line 672
Quoted 5 lines
migration/qemu-file.c +1
-0len = f_src->buf_index;qemu_put_buffer (f_des, f_src->buf, f_src->buf_index); f_src->buf_index =0 ; + f_src->iovcnt =0 ; }Quoted 7 lines
If you're just using the buf[] in the src, how does it end up incrementing the iovcnt?
Dave
Quoted 2 lines
migration/qemu-file.c +0
-0return len; }Quoted 7 lines
'
qemu_put_be32' is used to put some data to an allocated 'f_src'. Before the11808bb0c422, this operation won't increase the 'f_src->iovcnt', there is no issue.
Commit11808bb0c422remove the checking of 'f->ops->writev_buffer',
now 'qemu_put_be32' will increase 'f_src->iovcnt' and set 'f_src->iov[]', once the 'f_src->iovcnt' reach toMAX_IOV_SIZE, 'qemu_fflush' will be trigged. Beacause 'f_src' is not writeable, 'qemu_fflsh' will return without wrapping around 'f_src->iovcnt' , the following 'qemu_put_be32' on 'f_src' will increase 'f_src->iovcnt' and make it exceedMAX_IOV_SIZE, then set 'f_src->iov[]' will corrupt memory.
Quoted 3 lines
OK, thanks
Signed-off-by Dr. David Alan Gilbert <[email protected]>
Did you mean to Reviewed-by?
Quoted 2 lines
Amit, Peter: I think this is one for 2.7 because I think that's a regression given that the
11808bb0c422referenced is after 2.6.
I'll send it out, thanks.
Amit
Dr. David Alan Gilbert
Reviewed-byQuoted 44 lines · * Amit Shah ([email protected]) wrote:
Quoted 43 lines · Dr. David Alan Gilbert
Quoted 41 lines · * Li, Liang Z ([email protected]) wrote:
Quoted 26 lines
Subject: Re: [PATCH] migration: fix live migration failure with compression
migration/qemu-file.c int qemu_put_qemu_file(QEMUFile *f_des,
Quoted 16 lines · * Liang Li ([email protected]) wrote:
Because of commit
11808bb0c422, which remove some condition checks of 'f->ops->writev_buffer', 'qemu_put_qemu_file' should be enhanced to clear the 'f_src->iovcnt', or 'f_src->iovcnt' may exceed theMAX_IOV_SIZEwhich will break live migration. This should be fixed.Signed-off-by Liang Li <[email protected]>Reported-by Jinshi Zhang <[email protected]>--- migration/qemu-file.c | 1 + 1 file changed, 1 insertion(+)migration/qemu-file.c index renamed from migration/qemu-file.c +0
-0bbc565e..e9fae31 100644
migration/qemu-file.c +0
-0@@ -668,6 +668,7 @@ int qemu_put_qemu_file(QEMUFile *f_des,QEMUFile
*f_src)migration/qemu-file.c int qemu_put_qemu_file(QEMUFile *f_des, QEMUFile *f_src) · line 672
Quoted 5 lines
migration/qemu-file.c +1
-0len = f_src->buf_index;qemu_put_buffer (f_des, f_src->buf, f_src->buf_index); f_src->buf_index =0 ; + f_src->iovcnt =0 ; }Quoted 7 lines
If you're just using the buf[] in the src, how does it end up incrementing the iovcnt?
Dave
Quoted 2 lines
migration/qemu-file.c +0
-0return len; }'
qemu_put_be32' is used to put some data to an allocated 'f_src'. Before the11808bb0c422, this operation won't increase the 'f_src->iovcnt', there is no issue.
Commit11808bb0c422remove the checking of 'f->ops->writev_buffer',
now 'qemu_put_be32' will increase 'f_src->iovcnt' and set 'f_src->iov[]', once the 'f_src->iovcnt' reach toMAX_IOV_SIZE, 'qemu_fflush' will be trigged. Beacause 'f_src' is not writeable, 'qemu_fflsh' will return without wrapping around 'f_src->iovcnt' , the following 'qemu_put_be32' on 'f_src' will increase 'f_src->iovcnt' and make it exceedMAX_IOV_SIZE, then set 'f_src->iov[]' will corrupt memory.
Quoted 5 lines
Quoted 3 lines
OK, thanks
Signed-off-by Dr. David Alan Gilbert <[email protected]>Did you mean to Reviewed-by?
Oops! Yes,
Quoted 7 lines
Quoted 2 lines
Amit, Peter: I think this is one for 2.7 because I think that's a regression given that the
11808bb0c422referenced is after 2.6.I'll send it out, thanks.
Amit
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK