towards a workable O_DIRECT outmigration to a file
Hello,
I'm currently looking into implementing a 'file:' uri for migration save in qemu. Ideally the solution will be O_DIRECT compatible. I'm aware of the branch https://gitlab.com/berrange/qemu/-/tree/mig-file. In the process of brainstorming how a solution would like the a couple of questions transpired that I think warrant wider discussion in the community.
First, implementing a solution which is self-contained within qemu would be easy enough( famous last words) but the gist is one has to only care about the format within qemu. However, I'm being told that what libvirt does is prepend its own custom header to the resulting saved file, then slipstreams the migration stream from qemu. Now with the solution that I envision I intend to keep all write-related logic inside qemu, this means there's no way to incorporate the logic of libvirt. The reason I'd like to keep the write process within qemu is to avoid an extra copy of data between the two processes (qemu outging migration and libvirt), with the current fd approach qemu is passed an fd, data is copied between qemu/libvirt and finally the libvirt_iohelper writes the data. So the question which remains to be answered is how would libvirt make use of this new functionality in qemu? I was thinking something along the lines of :
1. Qemu writes its migration stream to a file, ideally on a filesystem which supports reflink - xfs/btrfs
2. Libvirt writes it's header to a separate file 2.1 Reflinks the qemu's stream right after its header 2.2 Writes its trailer
3. Unlink() qemu's file, now only libvirt's file remains on-disk.
I wouldn't call this solution hacky though it definitely leaves some bitter aftertaste.
Another solution would be to extend the 'fd:' protocol to allow multiple descriptors (for multifd) support to be passed in. The reason dup() can't be used is because in order for multifd to be supported it's required to be able to write to multiple, non-overlapping regions of the file. And duplicated fd's share their offsets etc. But that really seems more or less hacky. Alternatively it's possible that pwrite() are used to write to non-overlapping regions in the file. Any feedback is welcomed.
Regards,
Nikolay
[adding Juan and David to cc as I had missed them. ]
Quoted 22 lines · Nikolay Borisov
Hello,
I'm currently looking into implementing a 'file:' uri for migration save in qemu. Ideally the solution will be
O_DIRECTcompatible. I'm aware of the branch https://gitlab.com/berrange/qemu/-/tree/mig-file. In the process of brainstorming how a solution would like the a couple of questions transpired that I think warrant wider discussion in the community.First, implementing a solution which is self-contained within qemu would be easy enough( famous last words) but the gist is one has to only care about the format within qemu. However, I'm being told that what libvirt does is prepend its own custom header to the resulting saved file, then slipstreams the migration stream from qemu. Now with the solution that I envision I intend to keep all write-related logic inside qemu, this means there's no way to incorporate the logic of libvirt. The reason I'd like to keep the write process within qemu is to avoid an extra copy of data between the two processes (qemu outging migration and libvirt), with the current fd approach qemu is passed an fd, data is copied between qemu/libvirt and finally the
libvirt_iohelperwrites the data. So the question which remains to be answered is how would libvirt make use of this new functionality in qemu? I was thinking something along the lines of :1. Qemu writes its migration stream to a file, ideally on a filesystem which supports reflink - xfs/btrfs
2. Libvirt writes it's header to a separate file 2.1 Reflinks the qemu's stream right after its header 2.2 Writes its trailer
3.
Unlink()qemu's file, now only libvirt's file remains on-disk.I wouldn't call this solution hacky though it definitely leaves some bitter aftertaste.
Another solution would be to extend the 'fd:' protocol to allow multiple descriptors (for multifd) support to be passed in. The reason
dup()can't be used is because in order for multifd to be supported it's required to be able to write to multiple, non-overlapping regions of the file. And duplicated fd's share their offsets etc. But that really seems more or less hacky. Alternatively it's possible thatpwrite()are used to write to non-overlapping regions in the file. Any feedback is welcomed.Regards,
Nikolay
Quoted 1 line · * Nikolay Borisov ([email protected]) wrote:
[adding Juan and David to cc as I had missed them. ]
Hi Nikolay,
Quoted 9 lines · Nikolay Borisov
Quoted 8 lines
Hello,
I'm currently looking into implementing a 'file:' uri for migration save in qemu. Ideally the solution will be
O_DIRECTcompatible. I'm aware of the branch https://gitlab.com/berrange/qemu/-/tree/mig-file. In the process of brainstorming how a solution would like the a couple of questions transpired that I think warrant wider discussion in the community.
OK, so this seems to be a continuation with Claudio and Daniel and co as of a few months back. I'd definitely be leaving libvirt sides of the question here to Dan, and so that also means definitely looking at that tree above.
Quoted 18 lines
Quoted 18 lines
First, implementing a solution which is self-contained within qemu would be easy enough( famous last words) but the gist is one has to only care about the format within qemu. However, I'm being told that what libvirt does is prepend its own custom header to the resulting saved file, then slipstreams the migration stream from qemu. Now with the solution that I envision I intend to keep all write-related logic inside qemu, this means there's no way to incorporate the logic of libvirt. The reason I'd like to keep the write process within qemu is to avoid an extra copy of data between the two processes (qemu outging migration and libvirt), with the current fd approach qemu is passed an fd, data is copied between qemu/libvirt and finally the
libvirt_iohelperwrites the data. So the question which remains to be answered is how would libvirt make use of this new functionality in qemu? I was thinking something along the lines of :1. Qemu writes its migration stream to a file, ideally on a filesystem which supports reflink - xfs/btrfs
Quoted 8 lines
Quoted 8 lines
2. Libvirt writes it's header to a separate file 2.1 Reflinks the qemu's stream right after its header 2.2 Writes its trailer
3.
Unlink()qemu's file, now only libvirt's file remains on-disk.I wouldn't call this solution hacky though it definitely leaves some bitter aftertaste.
Wouldn't it be simpler to tell libvirt to write it's header, then tell qemu to append everything?
Quoted 8 lines
Quoted 8 lines
Another solution would be to extend the 'fd:' protocol to allow multiple descriptors (for multifd) support to be passed in. The reason
dup()can't be used is because in order for multifd to be supported it's required to be able to write to multiple, non-overlapping regions of the file. And duplicated fd's share their offsets etc. But that really seems more or less hacky. Alternatively it's possible thatpwrite()are used to write to non-overlapping regions in the file. Any feedback is welcomed.
I do like the idea of letting fd: take multiple fd's.
Dave
Quoted 5 lines
Quoted 4 lines
Regards,
Nikolay
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 15 lines · Dr. David Alan Gilbert
Quoted 1 line · * Nikolay Borisov ([email protected]) wrote:
[adding Juan and David to cc as I had missed them. ]
Hi Nikolay,
Quoted 9 lines · Nikolay Borisov
Quoted 8 lines
Hello,
I'm currently looking into implementing a 'file:' uri for migration save in qemu. Ideally the solution will be
O_DIRECTcompatible. I'm aware of the branch https://gitlab.com/berrange/qemu/-/tree/mig-file. In the process of brainstorming how a solution would like the a couple of questions transpired that I think warrant wider discussion in the community.
Quoted 4 lines
OK, so this seems to be a continuation with Claudio and Daniel and co as of a few months back. I'd definitely be leaving libvirt sides of the question here to Dan, and so that also means definitely looking at that tree above.
Hi Dave, yes, Nikolai is trying to continue on the qemu side.
We have something working with libvirt for our short term needs which offers good performance, but it is clear that that simple solution is barred for upstream libvirt merging.
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
First, implementing a solution which is self-contained within qemu would be easy enough( famous last words) but the gist is one has to only care about the format within qemu. However, I'm being told that what libvirt does is prepend its own custom header to the resulting saved file, then slipstreams the migration stream from qemu. Now with the solution that I envision I intend to keep all write-related logic inside qemu, this means there's no way to incorporate the logic of libvirt. The reason I'd like to keep the write process within qemu is to avoid an extra copy of data between the two processes (qemu outging migration and libvirt), with the current fd approach qemu is passed an fd, data is copied between qemu/libvirt and finally the
libvirt_iohelperwrites the data. So the question which remains to be answered is how would libvirt make use of this new functionality in qemu? I was thinking something along the lines of :1. Qemu writes its migration stream to a file, ideally on a filesystem which supports reflink - xfs/btrfs
2. Libvirt writes it's header to a separate file 2.1 Reflinks the qemu's stream right after its header 2.2 Writes its trailer
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
3.
Unlink()qemu's file, now only libvirt's file remains on-disk.I wouldn't call this solution hacky though it definitely leaves some bitter aftertaste.
Wouldn't it be simpler to tell libvirt to write it's header, then tell qemu to append everything?
I would think so as well.
Quoted 11 lines
Quoted 9 lines
Quoted 9 lines
Another solution would be to extend the 'fd:' protocol to allow multiple descriptors (for multifd) support to be passed in. The reason
dup()can't be used is because in order for multifd to be supported it's required to be able to write to multiple, non-overlapping regions of the file. And duplicated fd's share their offsets etc. But that really seems more or less hacky. Alternatively it's possible thatpwrite()are used to write to non-overlapping regions in the file. Any feedback is welcomed.I do like the idea of letting fd: take multiple fd's.
Fine in my view, I think we will still need then a helper process in libvirt to merge the data into a single file, no?
In case the libvirt multifd to single file multithreaded helper I proposed before is helpful as a reference you could reuse/modify those patches.
Maybe this new way will be acceptable to libvirt,
ie avoiding the multifd code -> socket, but still merging the data from the multiple fds into a single file?
Quoted 3 lines
Dave
Thanks for your comments,
Claudio
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Regards,
Nikolay
Quoted 70 lines · * Claudio Fontana ([email protected]) wrote:
Quoted 15 lines · Dr. David Alan Gilbert
Quoted 1 line · * Nikolay Borisov ([email protected]) wrote:
[adding Juan and David to cc as I had missed them. ]
Hi Nikolay,
Quoted 9 lines · Nikolay Borisov
Quoted 8 lines
Hello,
I'm currently looking into implementing a 'file:' uri for migration save in qemu. Ideally the solution will be
O_DIRECTcompatible. I'm aware of the branch https://gitlab.com/berrange/qemu/-/tree/mig-file. In the process of brainstorming how a solution would like the a couple of questions transpired that I think warrant wider discussion in the community.Quoted 4 lines
OK, so this seems to be a continuation with Claudio and Daniel and co as of a few months back. I'd definitely be leaving libvirt sides of the question here to Dan, and so that also means definitely looking at that tree above.
Hi Dave, yes, Nikolai is trying to continue on the qemu side.
We have something working with libvirt for our short term needs which offers good performance, but it is clear that that simple solution is barred for upstream libvirt merging.
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
First, implementing a solution which is self-contained within qemu would be easy enough( famous last words) but the gist is one has to only care about the format within qemu. However, I'm being told that what libvirt does is prepend its own custom header to the resulting saved file, then slipstreams the migration stream from qemu. Now with the solution that I envision I intend to keep all write-related logic inside qemu, this means there's no way to incorporate the logic of libvirt. The reason I'd like to keep the write process within qemu is to avoid an extra copy of data between the two processes (qemu outging migration and libvirt), with the current fd approach qemu is passed an fd, data is copied between qemu/libvirt and finally the
libvirt_iohelperwrites the data. So the question which remains to be answered is how would libvirt make use of this new functionality in qemu? I was thinking something along the lines of :1. Qemu writes its migration stream to a file, ideally on a filesystem which supports reflink - xfs/btrfs
2. Libvirt writes it's header to a separate file 2.1 Reflinks the qemu's stream right after its header 2.2 Writes its trailer
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
3.
Unlink()qemu's file, now only libvirt's file remains on-disk.I wouldn't call this solution hacky though it definitely leaves some bitter aftertaste.
Wouldn't it be simpler to tell libvirt to write it's header, then tell qemu to append everything?
I would think so as well.
Quoted 10 lines
Quoted 9 lines
Quoted 9 lines
Another solution would be to extend the 'fd:' protocol to allow multiple descriptors (for multifd) support to be passed in. The reason
dup()can't be used is because in order for multifd to be supported it's required to be able to write to multiple, non-overlapping regions of the file. And duplicated fd's share their offsets etc. But that really seems more or less hacky. Alternatively it's possible thatpwrite()are used to write to non-overlapping regions in the file. Any feedback is welcomed.
Quoted 4 lines
Quoted 1 line
I do like the idea of letting fd: take multiple fd's.
Fine in my view, I think we will still need then a helper process in libvirt to merge the data into a single file, no?
In case the libvirt multifd to single file multithreaded helper I proposed before is helpful as a reference you could reuse/modify those patches.
Eww that's messy isn't it.
(You don't fancy a huge sparse file do you?)
Quoted 2 lines
Maybe this new way will be acceptable to libvirt,
ie avoiding the multifd code -> socket, but still merging the data from the multiple fds into a single file?
It feels to me like the problem here is really what we want is something closer to a dump than the migration code; you don't need all that overhead of the code to deal with live migration bitmaps and dirty pages that aren't going to happen.
Something that just does a nice single write(2) (for each memory region);
and then ties the device state on.
Dave
Quoted 13 lines
Quoted 3 lines
Dave
Thanks for your comments,
Claudio
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Regards,
Nikolay
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 71 lines · Dr. David Alan Gilbert
Quoted 70 lines · * Claudio Fontana ([email protected]) wrote:
Quoted 15 lines · Dr. David Alan Gilbert
Quoted 1 line · * Nikolay Borisov ([email protected]) wrote:
[adding Juan and David to cc as I had missed them. ]
Hi Nikolay,
Quoted 9 lines · Nikolay Borisov
Quoted 8 lines
Hello,
I'm currently looking into implementing a 'file:' uri for migration save in qemu. Ideally the solution will be
O_DIRECTcompatible. I'm aware of the branch https://gitlab.com/berrange/qemu/-/tree/mig-file. In the process of brainstorming how a solution would like the a couple of questions transpired that I think warrant wider discussion in the community.Quoted 4 lines
OK, so this seems to be a continuation with Claudio and Daniel and co as of a few months back. I'd definitely be leaving libvirt sides of the question here to Dan, and so that also means definitely looking at that tree above.
Hi Dave, yes, Nikolai is trying to continue on the qemu side.
We have something working with libvirt for our short term needs which offers good performance, but it is clear that that simple solution is barred for upstream libvirt merging.
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
First, implementing a solution which is self-contained within qemu would be easy enough( famous last words) but the gist is one has to only care about the format within qemu. However, I'm being told that what libvirt does is prepend its own custom header to the resulting saved file, then slipstreams the migration stream from qemu. Now with the solution that I envision I intend to keep all write-related logic inside qemu, this means there's no way to incorporate the logic of libvirt. The reason I'd like to keep the write process within qemu is to avoid an extra copy of data between the two processes (qemu outging migration and libvirt), with the current fd approach qemu is passed an fd, data is copied between qemu/libvirt and finally the
libvirt_iohelperwrites the data. So the question which remains to be answered is how would libvirt make use of this new functionality in qemu? I was thinking something along the lines of :1. Qemu writes its migration stream to a file, ideally on a filesystem which supports reflink - xfs/btrfs
2. Libvirt writes it's header to a separate file 2.1 Reflinks the qemu's stream right after its header 2.2 Writes its trailer
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
3.
Unlink()qemu's file, now only libvirt's file remains on-disk.I wouldn't call this solution hacky though it definitely leaves some bitter aftertaste.
Wouldn't it be simpler to tell libvirt to write it's header, then tell qemu to append everything?
I would think so as well.
Quoted 10 lines
Quoted 9 lines
Quoted 9 lines
Another solution would be to extend the 'fd:' protocol to allow multiple descriptors (for multifd) support to be passed in. The reason
dup()can't be used is because in order for multifd to be supported it's required to be able to write to multiple, non-overlapping regions of the file. And duplicated fd's share their offsets etc. But that really seems more or less hacky. Alternatively it's possible thatpwrite()are used to write to non-overlapping regions in the file. Any feedback is welcomed.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
I do like the idea of letting fd: take multiple fd's.
Fine in my view, I think we will still need then a helper process in libvirt to merge the data into a single file, no?
In case the libvirt multifd to single file multithreaded helper I proposed before is helpful as a reference you could reuse/modify those patches.Eww that's messy isn't it.
(You don't fancy a huge sparse file do you?)
Wait am I missing something obvious here?
Maybe we don't need any libvirt extra process.
why don't we open the _single_ file multiple times from libvirt,
Lets say the "main channel" fd is opened, we write the libvirt header,
then reopen again the same file multiple times,
and finally pass all fds to qemu, one fd for each parallel transfer channel we want to use (so we solve all the permissions, security labels issues etc).
And then from QEMU we can write to those fds at the right offsets for each separate channel,
which is easier from QEMU because we can know exactly how much data we need to transfer before starting the migration, so we have even less need for "holes", possibly only minor ones for single byte adjustments
for uneven division of the interleaved file.
What is wrong with this one, or does anyone see some other better approach?
Thanks,
C
Quoted 27 lines
Quoted 3 lines
Maybe this new way will be acceptable to libvirt,
ie avoiding the multifd code -> socket, but still merging the data from the multiple fds into a single file?It feels to me like the problem here is really what we want is something closer to a dump than the migration code; you don't need all that overhead of the code to deal with live migration bitmaps and dirty pages that aren't going to happen.
Something that just does a nice single write(2) (for each memory region);
and then ties the device state on.Dave
Quoted 13 lines
Quoted 3 lines
Dave
Thanks for your comments,
Claudio
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Regards,
Nikolay
Quoted 91 lines · Claudio Fontana
Quoted 71 lines · Dr. David Alan Gilbert
Quoted 70 lines · * Claudio Fontana ([email protected]) wrote:
Quoted 15 lines · Dr. David Alan Gilbert
Quoted 1 line · * Nikolay Borisov ([email protected]) wrote:
[adding Juan and David to cc as I had missed them. ]
Hi Nikolay,
Quoted 9 lines · Nikolay Borisov
Quoted 8 lines
Hello,
I'm currently looking into implementing a 'file:' uri for migration save in qemu. Ideally the solution will be
O_DIRECTcompatible. I'm aware of the branch https://gitlab.com/berrange/qemu/-/tree/mig-file. In the process of brainstorming how a solution would like the a couple of questions transpired that I think warrant wider discussion in the community.Quoted 4 lines
OK, so this seems to be a continuation with Claudio and Daniel and co as of a few months back. I'd definitely be leaving libvirt sides of the question here to Dan, and so that also means definitely looking at that tree above.
Hi Dave, yes, Nikolai is trying to continue on the qemu side.
We have something working with libvirt for our short term needs which offers good performance, but it is clear that that simple solution is barred for upstream libvirt merging.
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
First, implementing a solution which is self-contained within qemu would be easy enough( famous last words) but the gist is one has to only care about the format within qemu. However, I'm being told that what libvirt does is prepend its own custom header to the resulting saved file, then slipstreams the migration stream from qemu. Now with the solution that I envision I intend to keep all write-related logic inside qemu, this means there's no way to incorporate the logic of libvirt. The reason I'd like to keep the write process within qemu is to avoid an extra copy of data between the two processes (qemu outging migration and libvirt), with the current fd approach qemu is passed an fd, data is copied between qemu/libvirt and finally the
libvirt_iohelperwrites the data. So the question which remains to be answered is how would libvirt make use of this new functionality in qemu? I was thinking something along the lines of :1. Qemu writes its migration stream to a file, ideally on a filesystem which supports reflink - xfs/btrfs
2. Libvirt writes it's header to a separate file 2.1 Reflinks the qemu's stream right after its header 2.2 Writes its trailer
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
3.
Unlink()qemu's file, now only libvirt's file remains on-disk.I wouldn't call this solution hacky though it definitely leaves some bitter aftertaste.
Wouldn't it be simpler to tell libvirt to write it's header, then tell qemu to append everything?
I would think so as well.
Quoted 10 lines
Quoted 9 lines
Quoted 9 lines
Another solution would be to extend the 'fd:' protocol to allow multiple descriptors (for multifd) support to be passed in. The reason
dup()can't be used is because in order for multifd to be supported it's required to be able to write to multiple, non-overlapping regions of the file. And duplicated fd's share their offsets etc. But that really seems more or less hacky. Alternatively it's possible thatpwrite()are used to write to non-overlapping regions in the file. Any feedback is welcomed.Quoted 7 lines
Quoted 4 lines
Quoted 1 line
I do like the idea of letting fd: take multiple fd's.
Fine in my view, I think we will still need then a helper process in libvirt to merge the data into a single file, no?
In case the libvirt multifd to single file multithreaded helper I proposed before is helpful as a reference you could reuse/modify those patches.Eww that's messy isn't it.
(You don't fancy a huge sparse file do you?)Wait am I missing something obvious here?
Maybe we don't need any libvirt extra process.
why don't we open the _single_ file multiple times from libvirt,
Lets say the "main channel" fd is opened, we write the libvirt header,
then reopen again the same file multiple times,
and finally pass all fds to qemu, one fd for each parallel transfer channel we want to use (so we solve all the permissions, security labels issues etc).
Quoted 4 lines
And then from QEMU we can write to those fds at the right offsets for each separate channel,
which is easier from QEMU because we can know exactly how much data we need to transfer before starting the migration, so we have even less need for "holes", possibly only minor ones for single byte adjustments
for uneven division of the interleaved file.
Or even better, not pass multiple fds, but just _one_ fd,
and then from qemu write using multiple threads and pread / pwrite , so we don't have the additional complication of managing a bunch of fds.
Ciao,
CLaudio
Quoted 35 lines
What is wrong with this one, or does anyone see some other better approach?
Thanks,
C
Quoted 27 lines
Quoted 3 lines
Maybe this new way will be acceptable to libvirt,
ie avoiding the multifd code -> socket, but still merging the data from the multiple fds into a single file?It feels to me like the problem here is really what we want is something closer to a dump than the migration code; you don't need all that overhead of the code to deal with live migration bitmaps and dirty pages that aren't going to happen.
Something that just does a nice single write(2) (for each memory region);
and then ties the device state on.Dave
Quoted 13 lines
Quoted 3 lines
Dave
Thanks for your comments,
Claudio
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Regards,
Nikolay
Quoted 91 lines · * Claudio Fontana ([email protected]) wrote:
Quoted 71 lines · Dr. David Alan Gilbert
Quoted 70 lines · * Claudio Fontana ([email protected]) wrote:
Quoted 15 lines · Dr. David Alan Gilbert
Quoted 1 line · * Nikolay Borisov ([email protected]) wrote:
[adding Juan and David to cc as I had missed them. ]
Hi Nikolay,
Quoted 9 lines · Nikolay Borisov
Quoted 8 lines
Hello,
I'm currently looking into implementing a 'file:' uri for migration save in qemu. Ideally the solution will be
O_DIRECTcompatible. I'm aware of the branch https://gitlab.com/berrange/qemu/-/tree/mig-file. In the process of brainstorming how a solution would like the a couple of questions transpired that I think warrant wider discussion in the community.Quoted 4 lines
OK, so this seems to be a continuation with Claudio and Daniel and co as of a few months back. I'd definitely be leaving libvirt sides of the question here to Dan, and so that also means definitely looking at that tree above.
Hi Dave, yes, Nikolai is trying to continue on the qemu side.
We have something working with libvirt for our short term needs which offers good performance, but it is clear that that simple solution is barred for upstream libvirt merging.
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
First, implementing a solution which is self-contained within qemu would be easy enough( famous last words) but the gist is one has to only care about the format within qemu. However, I'm being told that what libvirt does is prepend its own custom header to the resulting saved file, then slipstreams the migration stream from qemu. Now with the solution that I envision I intend to keep all write-related logic inside qemu, this means there's no way to incorporate the logic of libvirt. The reason I'd like to keep the write process within qemu is to avoid an extra copy of data between the two processes (qemu outging migration and libvirt), with the current fd approach qemu is passed an fd, data is copied between qemu/libvirt and finally the
libvirt_iohelperwrites the data. So the question which remains to be answered is how would libvirt make use of this new functionality in qemu? I was thinking something along the lines of :1. Qemu writes its migration stream to a file, ideally on a filesystem which supports reflink - xfs/btrfs
2. Libvirt writes it's header to a separate file 2.1 Reflinks the qemu's stream right after its header 2.2 Writes its trailer
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
3.
Unlink()qemu's file, now only libvirt's file remains on-disk.I wouldn't call this solution hacky though it definitely leaves some bitter aftertaste.
Wouldn't it be simpler to tell libvirt to write it's header, then tell qemu to append everything?
I would think so as well.
Quoted 10 lines
Quoted 9 lines
Quoted 9 lines
Another solution would be to extend the 'fd:' protocol to allow multiple descriptors (for multifd) support to be passed in. The reason
dup()can't be used is because in order for multifd to be supported it's required to be able to write to multiple, non-overlapping regions of the file. And duplicated fd's share their offsets etc. But that really seems more or less hacky. Alternatively it's possible thatpwrite()are used to write to non-overlapping regions in the file. Any feedback is welcomed.Quoted 7 lines
Quoted 4 lines
Quoted 1 line
I do like the idea of letting fd: take multiple fd's.
Fine in my view, I think we will still need then a helper process in libvirt to merge the data into a single file, no?
In case the libvirt multifd to single file multithreaded helper I proposed before is helpful as a reference you could reuse/modify those patches.Eww that's messy isn't it.
(You don't fancy a huge sparse file do you?)Wait am I missing something obvious here?
Maybe we don't need any libvirt extra process.
why don't we open the _single_ file multiple times from libvirt,
Lets say the "main channel" fd is opened, we write the libvirt header,
then reopen again the same file multiple times,
and finally pass all fds to qemu, one fd for each parallel transfer channel we want to use (so we solve all the permissions, security labels issues etc).
Quoted 6 lines
And then from QEMU we can write to those fds at the right offsets for each separate channel,
which is easier from QEMU because we can know exactly how much data we need to transfer before starting the migration, so we have even less need for "holes", possibly only minor ones for single byte adjustments
for uneven division of the interleaved file.What is wrong with this one, or does anyone see some other better approach?
You'd have to know exactly how to space the channels position in the file, unless you somehow controlled it; the allocation across the multifd threads is load/scheduler/random I think, so you'd have to assume the worst case of everything going to one thread. I.e. a big sparse area and then something to tell you where they are.
Dave
Quoted 32 lines
Thanks,
C
Quoted 27 lines
Quoted 3 lines
Maybe this new way will be acceptable to libvirt,
ie avoiding the multifd code -> socket, but still merging the data from the multiple fds into a single file?It feels to me like the problem here is really what we want is something closer to a dump than the migration code; you don't need all that overhead of the code to deal with live migration bitmaps and dirty pages that aren't going to happen.
Something that just does a nice single write(2) (for each memory region);
and then ties the device state on.Dave
Quoted 13 lines
Quoted 3 lines
Dave
Thanks for your comments,
Claudio
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Regards,
Nikolay
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 97 lines · Dr. David Alan Gilbert
Quoted 96 lines · * Claudio Fontana ([email protected]) wrote:
Quoted 71 lines · Dr. David Alan Gilbert
Quoted 70 lines · * Claudio Fontana ([email protected]) wrote:
Quoted 15 lines · Dr. David Alan Gilbert
Quoted 1 line · * Nikolay Borisov ([email protected]) wrote:
[adding Juan and David to cc as I had missed them. ]
Hi Nikolay,
Quoted 9 lines · Nikolay Borisov
Quoted 8 lines
Hello,
I'm currently looking into implementing a 'file:' uri for migration save in qemu. Ideally the solution will be
O_DIRECTcompatible. I'm aware of the branch https://gitlab.com/berrange/qemu/-/tree/mig-file. In the process of brainstorming how a solution would like the a couple of questions transpired that I think warrant wider discussion in the community.Quoted 4 lines
OK, so this seems to be a continuation with Claudio and Daniel and co as of a few months back. I'd definitely be leaving libvirt sides of the question here to Dan, and so that also means definitely looking at that tree above.
Hi Dave, yes, Nikolai is trying to continue on the qemu side.
We have something working with libvirt for our short term needs which offers good performance, but it is clear that that simple solution is barred for upstream libvirt merging.
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
First, implementing a solution which is self-contained within qemu would be easy enough( famous last words) but the gist is one has to only care about the format within qemu. However, I'm being told that what libvirt does is prepend its own custom header to the resulting saved file, then slipstreams the migration stream from qemu. Now with the solution that I envision I intend to keep all write-related logic inside qemu, this means there's no way to incorporate the logic of libvirt. The reason I'd like to keep the write process within qemu is to avoid an extra copy of data between the two processes (qemu outging migration and libvirt), with the current fd approach qemu is passed an fd, data is copied between qemu/libvirt and finally the
libvirt_iohelperwrites the data. So the question which remains to be answered is how would libvirt make use of this new functionality in qemu? I was thinking something along the lines of :1. Qemu writes its migration stream to a file, ideally on a filesystem which supports reflink - xfs/btrfs
2. Libvirt writes it's header to a separate file 2.1 Reflinks the qemu's stream right after its header 2.2 Writes its trailer
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
3.
Unlink()qemu's file, now only libvirt's file remains on-disk.I wouldn't call this solution hacky though it definitely leaves some bitter aftertaste.
Wouldn't it be simpler to tell libvirt to write it's header, then tell qemu to append everything?
I would think so as well.
Quoted 10 lines
Quoted 9 lines
Quoted 9 lines
Another solution would be to extend the 'fd:' protocol to allow multiple descriptors (for multifd) support to be passed in. The reason
dup()can't be used is because in order for multifd to be supported it's required to be able to write to multiple, non-overlapping regions of the file. And duplicated fd's share their offsets etc. But that really seems more or less hacky. Alternatively it's possible thatpwrite()are used to write to non-overlapping regions in the file. Any feedback is welcomed.Quoted 7 lines
Quoted 4 lines
Quoted 1 line
I do like the idea of letting fd: take multiple fd's.
Fine in my view, I think we will still need then a helper process in libvirt to merge the data into a single file, no?
In case the libvirt multifd to single file multithreaded helper I proposed before is helpful as a reference you could reuse/modify those patches.Eww that's messy isn't it.
(You don't fancy a huge sparse file do you?)Wait am I missing something obvious here?
Maybe we don't need any libvirt extra process.
why don't we open the _single_ file multiple times from libvirt,
Lets say the "main channel" fd is opened, we write the libvirt header,
then reopen again the same file multiple times,
and finally pass all fds to qemu, one fd for each parallel transfer channel we want to use (so we solve all the permissions, security labels issues etc).And then from QEMU we can write to those fds at the right offsets for each separate channel,
which is easier from QEMU because we can know exactly how much data we need to transfer before starting the migration, so we have even less need for "holes", possibly only minor ones for single byte adjustments
for uneven division of the interleaved file.
Quoted 7 lines
Quoted 1 line
What is wrong with this one, or does anyone see some other better approach?
You'd have to know exactly how to space the channels position in the file, unless you somehow controlled it; the allocation across the multifd threads is load/scheduler/random I think, so you'd have to assume the worst case of everything going to one thread. I.e. a big sparse area and then something to tell you where they are.
No why, just split the work evenly between threads, with each one writing to interleaved areas depending on the thread index, pass the relevant parallel=n parameter from libvirt at save/restore time so qemu knows how to split the data.
Ciao,
C
Quoted 35 lines
Dave
Quoted 32 lines
Thanks,
C
Quoted 27 lines
Quoted 3 lines
Maybe this new way will be acceptable to libvirt,
ie avoiding the multifd code -> socket, but still merging the data from the multiple fds into a single file?It feels to me like the problem here is really what we want is something closer to a dump than the migration code; you don't need all that overhead of the code to deal with live migration bitmaps and dirty pages that aren't going to happen.
Something that just does a nice single write(2) (for each memory region);
and then ties the device state on.Dave
Quoted 13 lines
Quoted 3 lines
Dave
Thanks for your comments,
Claudio
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Regards,
Nikolay
Quoted 79 lines · Dr. David Alan Gilbert
Quoted 70 lines · * Claudio Fontana ([email protected]) wrote:
Quoted 15 lines · Dr. David Alan Gilbert
Quoted 1 line · * Nikolay Borisov ([email protected]) wrote:
[adding Juan and David to cc as I had missed them. ]
Hi Nikolay,
Quoted 9 lines · Nikolay Borisov
Quoted 8 lines
Hello,
I'm currently looking into implementing a 'file:' uri for migration save in qemu. Ideally the solution will be
O_DIRECTcompatible. I'm aware of the branch https://gitlab.com/berrange/qemu/-/tree/mig-file. In the process of brainstorming how a solution would like the a couple of questions transpired that I think warrant wider discussion in the community.Quoted 4 lines
OK, so this seems to be a continuation with Claudio and Daniel and co as of a few months back. I'd definitely be leaving libvirt sides of the question here to Dan, and so that also means definitely looking at that tree above.
Hi Dave, yes, Nikolai is trying to continue on the qemu side.
We have something working with libvirt for our short term needs which offers good performance, but it is clear that that simple solution is barred for upstream libvirt merging.
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
First, implementing a solution which is self-contained within qemu would be easy enough( famous last words) but the gist is one has to only care about the format within qemu. However, I'm being told that what libvirt does is prepend its own custom header to the resulting saved file, then slipstreams the migration stream from qemu. Now with the solution that I envision I intend to keep all write-related logic inside qemu, this means there's no way to incorporate the logic of libvirt. The reason I'd like to keep the write process within qemu is to avoid an extra copy of data between the two processes (qemu outging migration and libvirt), with the current fd approach qemu is passed an fd, data is copied between qemu/libvirt and finally the
libvirt_iohelperwrites the data. So the question which remains to be answered is how would libvirt make use of this new functionality in qemu? I was thinking something along the lines of :1. Qemu writes its migration stream to a file, ideally on a filesystem which supports reflink - xfs/btrfs
2. Libvirt writes it's header to a separate file 2.1 Reflinks the qemu's stream right after its header 2.2 Writes its trailer
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
3.
Unlink()qemu's file, now only libvirt's file remains on-disk.I wouldn't call this solution hacky though it definitely leaves some bitter aftertaste.
Wouldn't it be simpler to tell libvirt to write it's header, then tell qemu to append everything?
I would think so as well.
Quoted 10 lines
Quoted 9 lines
Quoted 9 lines
Another solution would be to extend the 'fd:' protocol to allow multiple descriptors (for multifd) support to be passed in. The reason
dup()can't be used is because in order for multifd to be supported it's required to be able to write to multiple, non-overlapping regions of the file. And duplicated fd's share their offsets etc. But that really seems more or less hacky. Alternatively it's possible thatpwrite()are used to write to non-overlapping regions in the file. Any feedback is welcomed.Quoted 4 lines
Quoted 1 line
I do like the idea of letting fd: take multiple fd's.
Fine in my view, I think we will still need then a helper process in libvirt to merge the data into a single file, no?
In case the libvirt multifd to single file multithreaded helper I proposed before is helpful as a reference you could reuse/modify those patches.Eww that's messy isn't it.
(You don't fancy a huge sparse file do you?)
Quoted 6 lines
Quoted 2 lines
Maybe this new way will be acceptable to libvirt,
ie avoiding the multifd code -> socket, but still merging the data from the multiple fds into a single file?It feels to me like the problem here is really what we want is something closer to a dump than the migration code; you don't need all that overhead of the code to deal with live migration bitmaps and dirty pages
well yes you are right, we don't care about live migration bitmaps and dirty pages,
but we don't incur in any of that anyway since (at least for what I have in mind, virsh save and restore), the VM is stopped.
Quoted 4 lines
that aren't going to happen.
Something that just does a nice single write(2) (for each memory region);
and then ties the device state on.
ultimately yes, it's the same thing though, whether we trigger it via migrate fd: or via another non-migration-related mechanism, any approach would work.
Ciao,
C
Quoted 16 lines
Dave
Quoted 13 lines
Quoted 3 lines
Dave
Thanks for your comments,
Claudio
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Regards,
Nikolay
PATCH 1/1 migration: support file: uri for source migration
In reply to Nikolay BorisovThis is a prototype of supporting a 'file:' based uri protocol for writing out the migration stream of qemu. Currently the code always opens the file in DIO mode and adheres to an alignment of 64k to be generic enough. However this comes with a problem - it requires copying all data that we are writing (qemu metadata + guest ram pages) to a bounce buffer so that we adhere to this alignment. With this code I get the following performance results:
DIO exec: cat > file virsh --bypass-cache
82 77 81
82 78 80
80 80 82
82 82 77
77 79 77AVG: 80.6 79.2 79.4
stddev: 1.959 1.720 2.05
All numbers are in seconds.
Those results are somewhat surprising to me as I'd expected doing the writeout directly within qemu and avoiding copying between qemu and virsh's iohelper process would result in a speed up. Clearly that's not the case, I attribute this to the fact that all memory pages have to be copied into the bounce buffer. There are more measurements/profiling work that I'd have to do in order to (dis)prove this hypotheses and will report back when I have the data.
However I'm sending the code now as I'd like to facilitate a discussion as to whether this is an approach that would be acceptable to upstream merging. Any ideas/comments would be much appreciated.
--- include/io/channel-file.h | 1 + include/io/channel.h | 1 + io/channel-file.c | 17 +++++++ migration/meson.build | 1 + migration/migration.c | 4 ++ migration/migration.h | 2 + migration/qemu-file.c | 104 +++++++++++++++++++++++++++++++++++++- 7 files changed, 129 insertions(+), 1 deletion(-)
include/io/channel-file.h +1 -0
@@ -89,4 +89,5 @@ qio_channel_file_new_path(const char *path,mode_t mode, Error **errp); +void qio_channel_file_disable_dio (QIOChannelFile *ioc);#endif /* QIO_CHANNEL_FILE_H */
include/io/channel.h +1 -0
@@ -41,6 +41,7 @@ enum QIOChannelFeature {QIO_CHANNEL_FEATURE_SHUTDOWN ,QIO_CHANNEL_FEATURE_LISTEN ,QIO_CHANNEL_FEATURE_WRITE_ZERO_COPY , + QIO_CHANNEL_FEATURE_DIO, };
io/channel-file.c +17 -0
@@ -59,6 +59,10 @@ qio_channel_file_new_path(const char *path,return NULL ; } +if (flags &O_DIRECT ) { +qio_channel_set_feature (QIO_CHANNEL (ioc),QIO_CHANNEL_FEATURE_DIO ); + } +trace_qio_channel_file_new_path (ioc, path, flags, mode, ioc->fd);return ioc;
@@ -109,6 +113,19 @@ static ssize_t qio_channel_file_readv(QIOChannel *ioc,return ret; } + +void qio_channel_file_disable_dio (QIOChannelFile *ioc) +{ +int flags =fcntl (ioc->fd,F_GETFL ); +if (flags ==-1 ) { +//handle failure + } + +if (fcntl (ioc->fd,F_SETFL , (flags & ~O_DIRECT )) ==-1 ) { +error_report ("Can't disable O_DIRECT" ); + } +} + static ssize_t qio_channel_file_writev(QIOChannel *ioc, const struct iovec *iov, size_t niov,
migration/meson.build +1 -0
@@ -17,6 +17,7 @@ softmmu_ss.add(files( 'colo.c', 'exec.c', 'fd.c', + 'file.c', 'global_state.c', 'migration.c', 'multifd.c',
migration/migration.c +4 -0
@@ -20,6 +20,7 @@#include "migration/blocker.h" #include "exec.h" #include "fd.h" +#include "file.h" #include "socket.h" #include "sysemu/runstate.h" #include "sysemu/sysemu.h"
@@ -2414,6 +2415,8 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,exec_start_outgoing_migration (s, p, &local_err); }else if (strstart (uri,"fd:" , &p)) {fd_start_outgoing_migration (s, p, &local_err); + }else if (strstart (uri,"file:" , &p)) { +file_start_outgoing_migration (s, p, &local_err); }else {if (!(has_resume && resume)) {yank_unregister_instance (MIGRATION_YANK_INSTANCE );
@@ -4307,6 +4310,7 @@ void migration_global_dump(Monitor *mon)static Property migration_properties[] = {DEFINE_PROP_BOOL ("store-global-state" , MigrationState, store_global_state, true), +DEFINE_PROP_BOOL ("use-direct" , MigrationState, use_dio, false),DEFINE_PROP_BOOL ("send-configuration" , MigrationState, send_configuration, true), DEFINE_PROP_BOOL("send-section-footer", MigrationState,
migration/migration.h +2 -0
@@ -336,6 +336,8 @@ struct MigrationState {*/ bool store_global_state; +bool use_dio; +/* Whether we send QEMU_VM_CONFIGURATION during migration */ bool send_configuration;/* Whether we send section footer during migration */
migration/qemu-file.c +103 -1
168 lines not on this page · raw message
--
2.25.1
Re: [PATCH] migration: support file: uri for source migration
Quoted 6 lines · Nikolay Borisov
This is a prototype of supporting a 'file:' based uri protocol for writing out the migration stream of qemu. Currently the code always opens the file in DIO mode and adheres to an alignment of 64k to be generic enough. However this comes with a problem - it requires copying all data that we are writing (qemu metadata + guest ram pages) to a bounce buffer so that we adhere to this alignment.
The adhoc device metadata clearly needs bounce buffers since it is splattered all over RAM with no concern of alignemnt. THe use of bounce buffers for this shouldn't be a performance issue though as metadata is small relative to the size of the snapshot as a whole.
The guest RAM pages should not need bounce buffers at all when using huge pages, as alignment will already be way larger than we required. Guests with huge pages are the ones which are likely to have huge RAM sizes and thus need the DIO mode, so we should be sorted for that.
When using small pages for guest RAM, if it is not already allocated with suitable alignment, I feel like we should be able to make it so that we allocate the RAM block with good alignemnt to avoid the need for bounce buffers. This would address the less common case of a guest with huge RAM size but not huge pages.
Thus if we assume guest RAM is suitably aligned, then we can avoid bounce buffers for RAM pages, while still using bounce buffers for the metadata.
Quoted 15 lines
With this code I get
the following performance results:DIO exec: cat > file virsh --bypass-cache 82 77 81 82 78 80 80 80 82 82 82 77 77 79 77AVG: 80.6 79.2 79.4
stddev: 1.959 1.720 2.05All numbers are in seconds.
Quoted 7 lines
Those results are somewhat surprising to me as I'd expected doing the writeout directly within qemu and avoiding copying between qemu and virsh's iohelper process would result in a speed up. Clearly that's not the case, I attribute this to the fact that all memory pages have to be copied into the bounce buffer. There are more measurements/profiling work that I'd have to do in order to (dis)prove this hypotheses and will report back when I have the data.
When using the libvirt iohelper we have mutliple CPUs involved. IOW the bounce buffer copy is taking place on a separate CPU from the QEMU migration loop. This ability to use multiple CPUs may well have balanced out any benefit from doing DIO on the QEMU side.
If you eliminate bounce buffers for guest RAM and write it directly to the fixed location on disk, then we should see the benefit - and if not then something is really wrong in our thoughts.
Quoted 3 lines
However I'm sending the code now as I'd like to facilitate a discussion as to whether this is an approach that would be acceptable to upstream merging. Any ideas/comments would be much appreciated.
AFAICT this impl is still using the existing on-disk format, where RAM pages are just written inline to the stream. For DIO benefit to be maximised we need the on-disk format to be changed, so that the guest RAM regions can be directly associated with fixed locations on disk. This also means that if guest dirties RAM while its saving, then we overwrite the existing content on disk, such that restore only ever needs to restore each RAM page once, instead of restoring every dirtied version.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH] migration: support file: uri for source migration
Quoted 8 lines · Daniel P. Berrangé
Quoted 6 lines · Nikolay Borisov
This is a prototype of supporting a 'file:' based uri protocol for writing out the migration stream of qemu. Currently the code always opens the file in DIO mode and adheres to an alignment of 64k to be generic enough. However this comes with a problem - it requires copying all data that we are writing (qemu metadata + guest ram pages) to a bounce buffer so that we adhere to this alignment.
Quoted 4 lines
The adhoc device metadata clearly needs bounce buffers since it is splattered all over RAM with no concern of alignemnt. THe use of bounce buffers for this shouldn't be a performance issue though as metadata is small relative to the size of the snapshot as a whole.
Bounce buffers can be eliminated altogether so long as we simply switch between buffered/DIO mode via fcntl.
Quoted 11 lines
The guest RAM pages should not need bounce buffers at all when using huge pages, as alignment will already be way larger than we required. Guests with huge pages are the ones which are likely to have huge RAM sizes and thus need the DIO mode, so we should be sorted for that.
When using small pages for guest RAM, if it is not already allocated with suitable alignment, I feel like we should be able to make it so that we allocate the RAM block with good alignemnt to avoid the need for bounce buffers. This would address the less common case of a guest with huge RAM size but not huge pages.
Ram blocks are generally allocated with good alignment due to them being mmaped(), however as I was toying with eliminating bounce buffers for ram I hit an issue where the page headers being written (8 bytes each) aren't aligned (naturally). Imo I think the on-disk format can be changed the following way:
<ramblock header, containing base address of ramblock>, each subsequent page is then written at an offset from the base address of the ramblock, that is it's index would be :
page_offset = page_addr - ramblock_base, Then the page is written at ramblock_base (in the file) + page_offset. This would eliminate the page headers altogether. This leaves aligning the initial ramblock header initially. However, this would lead to us potentially having to issue 1 lseek per page to write - to adjust the the file position, which might not be a problem in itself but who knows. How dooes that sound to you?
Quoted 53 lines
Thus if we assume guest RAM is suitably aligned, then we can avoid bounce buffers for RAM pages, while still using bounce buffers for the metadata.
Quoted 15 lines
With this code I get
the following performance results:DIO exec: cat > file virsh --bypass-cache 82 77 81 82 78 80 80 80 82 82 82 77 77 79 77AVG: 80.6 79.2 79.4
stddev: 1.959 1.720 2.05All numbers are in seconds.
Quoted 7 lines
Those results are somewhat surprising to me as I'd expected doing the writeout directly within qemu and avoiding copying between qemu and virsh's iohelper process would result in a speed up. Clearly that's not the case, I attribute this to the fact that all memory pages have to be copied into the bounce buffer. There are more measurements/profiling work that I'd have to do in order to (dis)prove this hypotheses and will report back when I have the data.
When using the libvirt iohelper we have mutliple CPUs involved. IOW the bounce buffer copy is taking place on a separate CPU from the QEMU migration loop. This ability to use multiple CPUs may well have balanced out any benefit from doing DIO on the QEMU side.
If you eliminate bounce buffers for guest RAM and write it directly to the fixed location on disk, then we should see the benefit - and if not then something is really wrong in our thoughts.
Quoted 3 lines
However I'm sending the code now as I'd like to facilitate a discussion as to whether this is an approach that would be acceptable to upstream merging. Any ideas/comments would be much appreciated.
AFAICT this impl is still using the existing on-disk format, where RAM pages are just written inline to the stream. For DIO benefit to be maximised we need the on-disk format to be changed, so that the guest RAM regions can be directly associated with fixed locations on disk. This also means that if guest dirties RAM while its saving, then we overwrite the existing content on disk, such that restore only ever needs to restore each RAM page once, instead of restoring every dirtied version.
With regards,
Daniel
Re: [PATCH] migration: support file: uri for source migration
Quoted 42 lines · Nikolay Borisov
Quoted 8 lines · Daniel P. Berrangé
Quoted 6 lines · Nikolay Borisov
This is a prototype of supporting a 'file:' based uri protocol for writing out the migration stream of qemu. Currently the code always opens the file in DIO mode and adheres to an alignment of 64k to be generic enough. However this comes with a problem - it requires copying all data that we are writing (qemu metadata + guest ram pages) to a bounce buffer so that we adhere to this alignment.
Quoted 4 lines
The adhoc device metadata clearly needs bounce buffers since it is splattered all over RAM with no concern of alignemnt. THe use of bounce buffers for this shouldn't be a performance issue though as metadata is small relative to the size of the snapshot as a whole.
Bounce buffers can be eliminated altogether so long as we simply switch between buffered/DIO mode via fcntl.
Quoted 11 lines
The guest RAM pages should not need bounce buffers at all when using huge pages, as alignment will already be way larger than we required. Guests with huge pages are the ones which are likely to have huge RAM sizes and thus need the DIO mode, so we should be sorted for that.
When using small pages for guest RAM, if it is not already allocated with suitable alignment, I feel like we should be able to make it so that we allocate the RAM block with good alignemnt to avoid the need for bounce buffers. This would address the less common case of a guest with huge RAM size but not huge pages.
Ram blocks are generally allocated with good alignment due to them being
mmaped(), however as I was toying with eliminating bounce buffers for ram I hit an issue where the page headers being written (8 bytes each) aren't aligned (naturally). Imo I think the on-disk format can be changed the following way:<ramblock header, containing base address of ramblock>, each subsequent page is then written at an offset from the base address of the ramblock, that is it's index would be :
Quoted 6 lines
page_offset=page_addr-ramblock_base, Then the page is written atramblock_base(in the file) +page_offset. This would eliminate the page headers altogether. This leaves aligning the initial ramblock header initially. However, this would lead to us potentially having to issue 1 lseek per page to write - to adjust the the file position, which might not be a problem in itself but who knows. How dooes that sound to you?
Yes, definitely. We don't want the headers on front of each page, just one single large block. Looking forward to multi-fd, we don't want to be using lseek at all, because that changes the file offset for all threads using the FD. Instead we need to be able to use pread/pwrite for writing the RAM blocks.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|