* QEMU policy for real file tests
@ 2020-09-17 8:50 Christian Schoenebeck
2020-09-17 9:26 ` Alex Bennée
0 siblings, 1 reply; 10+ messages in thread
From: Christian Schoenebeck @ 2020-09-17 8:50 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Kevin Wolf, Max Reitz, Thomas Huth, Laurent Vivier,
Greg Kurz
Hi,
is there a QEMU policy for test cases that create/write/read/delete real files
and directories? E.g. should they be situated at a certain location and is any
measure of sandboxing required?
Best regards,
Christian Schoenebeck
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: QEMU policy for real file tests
2020-09-17 8:50 QEMU policy for real file tests Christian Schoenebeck
@ 2020-09-17 9:26 ` Alex Bennée
2020-09-17 9:37 ` Daniel P. Berrangé
0 siblings, 1 reply; 10+ messages in thread
From: Alex Bennée @ 2020-09-17 9:26 UTC (permalink / raw)
To: Christian Schoenebeck
Cc: Kevin Wolf, Peter Maydell, Thomas Huth, qemu-devel,
Laurent Vivier, Greg Kurz, Max Reitz
Christian Schoenebeck <qemu_oss@crudebyte.com> writes:
> Hi,
>
> is there a QEMU policy for test cases that create/write/read/delete real files
> and directories? E.g. should they be situated at a certain location and is any
> measure of sandboxing required?
I don't think we have a hard and fast policy. It also depends on what
you are doing the test in - but ideally you should use a secure mktempd
(that can't clash) and clean-up after you are finished. This is a bit
easier in python than shell I think.
For example iotests end up in $BUILD_DIR/scratch (driven by TEST_DIR
being set somewhere) whereas the gdb stub tests use socket_dir =
TemporaryDirectory("qemu-gdbstub") which get auto-cleaned when it
finishes.
--
Alex Bennée
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: QEMU policy for real file tests
2020-09-17 9:26 ` Alex Bennée
@ 2020-09-17 9:37 ` Daniel P. Berrangé
2020-09-17 9:55 ` Thomas Huth
0 siblings, 1 reply; 10+ messages in thread
From: Daniel P. Berrangé @ 2020-09-17 9:37 UTC (permalink / raw)
To: Alex Bennée
Cc: Kevin Wolf, Peter Maydell, Thomas Huth, Laurent Vivier,
Christian Schoenebeck, qemu-devel, Greg Kurz, Max Reitz
On Thu, Sep 17, 2020 at 10:26:36AM +0100, Alex Bennée wrote:
>
> Christian Schoenebeck <qemu_oss@crudebyte.com> writes:
>
> > Hi,
> >
> > is there a QEMU policy for test cases that create/write/read/delete real files
> > and directories? E.g. should they be situated at a certain location and is any
> > measure of sandboxing required?
>
> I don't think we have a hard and fast policy. It also depends on what
> you are doing the test in - but ideally you should use a secure mktempd
> (that can't clash) and clean-up after you are finished. This is a bit
> easier in python than shell I think.
mktempd will end up on /tmp usually which can be tmpfs and size limited,
so be mindful of the size of files you create. Don't assume you can
create multi-GB sized files ! Creating a temp dir underneath the build
dir (effectively CWD of the test) is a reasonable alternative.
> For example iotests end up in $BUILD_DIR/scratch (driven by TEST_DIR
> being set somewhere) whereas the gdb stub tests use socket_dir =
> TemporaryDirectory("qemu-gdbstub") which get auto-cleaned when it
> finishes.
Regards,
Daniel
--
|: 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 :|
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: QEMU policy for real file tests
2020-09-17 9:37 ` Daniel P. Berrangé
@ 2020-09-17 9:55 ` Thomas Huth
2020-09-17 12:06 ` Christian Schoenebeck
0 siblings, 1 reply; 10+ messages in thread
From: Thomas Huth @ 2020-09-17 9:55 UTC (permalink / raw)
To: Daniel P. Berrangé, Alex Bennée
Cc: Kevin Wolf, Peter Maydell, Laurent Vivier, Christian Schoenebeck,
qemu-devel, Greg Kurz, Max Reitz
On 17/09/2020 11.37, Daniel P. Berrangé wrote:
> On Thu, Sep 17, 2020 at 10:26:36AM +0100, Alex Bennée wrote:
>>
>> Christian Schoenebeck <qemu_oss@crudebyte.com> writes:
>>
>>> Hi,
>>>
>>> is there a QEMU policy for test cases that create/write/read/delete real files
>>> and directories? E.g. should they be situated at a certain location and is any
>>> measure of sandboxing required?
>>
>> I don't think we have a hard and fast policy. It also depends on what
>> you are doing the test in - but ideally you should use a secure mktempd
>> (that can't clash) and clean-up after you are finished. This is a bit
>> easier in python than shell I think.
>
> mktempd will end up on /tmp usually which can be tmpfs and size limited,
> so be mindful of the size of files you create. Don't assume you can
> create multi-GB sized files ! Creating a temp dir underneath the build
> dir (effectively CWD of the test) is a reasonable alternative.
Another thing to consider: If you want to create Unix sockets in your
tests, make sure that the file name does not get too long, since there
are limits on certain systems - i.e. socket files should be created in a
/tmp subdirectory, indeed.
Thomas
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: QEMU policy for real file tests
2020-09-17 9:55 ` Thomas Huth
@ 2020-09-17 12:06 ` Christian Schoenebeck
2020-09-17 12:24 ` Daniel P. Berrangé
2020-09-17 13:04 ` Thomas Huth
0 siblings, 2 replies; 10+ messages in thread
From: Christian Schoenebeck @ 2020-09-17 12:06 UTC (permalink / raw)
To: qemu-devel
Cc: Thomas Huth, Daniel P. Berrangé, Alex Bennée,
Kevin Wolf, Peter Maydell, Laurent Vivier, Greg Kurz, Max Reitz
On Donnerstag, 17. September 2020 11:55:00 CEST Thomas Huth wrote:
> On 17/09/2020 11.37, Daniel P. Berrangé wrote:
> > On Thu, Sep 17, 2020 at 10:26:36AM +0100, Alex Bennée wrote:
> >> Christian Schoenebeck <qemu_oss@crudebyte.com> writes:
> >>> Hi,
> >>>
> >>> is there a QEMU policy for test cases that create/write/read/delete real
> >>> files and directories? E.g. should they be situated at a certain
> >>> location and is any measure of sandboxing required?
> >>
> >> I don't think we have a hard and fast policy. It also depends on what
> >> you are doing the test in - but ideally you should use a secure mktempd
> >> (that can't clash) and clean-up after you are finished. This is a bit
> >> easier in python than shell I think.
> >
> > mktempd will end up on /tmp usually which can be tmpfs and size limited,
> > so be mindful of the size of files you create. Don't assume you can
> > create multi-GB sized files ! Creating a temp dir underneath the build
> > dir (effectively CWD of the test) is a reasonable alternative.
>
> Another thing to consider: If you want to create Unix sockets in your
> tests, make sure that the file name does not get too long, since there
> are limits on certain systems - i.e. socket files should be created in a
> /tmp subdirectory, indeed.
>
> Thomas
These answers already cover everything I need right now. Thanks!
Final question: if at some later point one large file needs to be created for
some test case, is there some approximate size limit to stay below for not
causing issues with free CI cloud services?
Best regards,
Christian Schoenebeck
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: QEMU policy for real file tests
2020-09-17 12:06 ` Christian Schoenebeck
@ 2020-09-17 12:24 ` Daniel P. Berrangé
2020-09-17 12:40 ` Peter Maydell
2020-09-17 13:04 ` Thomas Huth
1 sibling, 1 reply; 10+ messages in thread
From: Daniel P. Berrangé @ 2020-09-17 12:24 UTC (permalink / raw)
To: Christian Schoenebeck
Cc: Kevin Wolf, Peter Maydell, Thomas Huth, Laurent Vivier,
qemu-devel, Greg Kurz, Max Reitz, Alex Bennée
On Thu, Sep 17, 2020 at 02:06:33PM +0200, Christian Schoenebeck wrote:
> On Donnerstag, 17. September 2020 11:55:00 CEST Thomas Huth wrote:
> > On 17/09/2020 11.37, Daniel P. Berrangé wrote:
> > > On Thu, Sep 17, 2020 at 10:26:36AM +0100, Alex Bennée wrote:
> > >> Christian Schoenebeck <qemu_oss@crudebyte.com> writes:
> > >>> Hi,
> > >>>
> > >>> is there a QEMU policy for test cases that create/write/read/delete real
> > >>> files and directories? E.g. should they be situated at a certain
> > >>> location and is any measure of sandboxing required?
> > >>
> > >> I don't think we have a hard and fast policy. It also depends on what
> > >> you are doing the test in - but ideally you should use a secure mktempd
> > >> (that can't clash) and clean-up after you are finished. This is a bit
> > >> easier in python than shell I think.
> > >
> > > mktempd will end up on /tmp usually which can be tmpfs and size limited,
> > > so be mindful of the size of files you create. Don't assume you can
> > > create multi-GB sized files ! Creating a temp dir underneath the build
> > > dir (effectively CWD of the test) is a reasonable alternative.
> >
> > Another thing to consider: If you want to create Unix sockets in your
> > tests, make sure that the file name does not get too long, since there
> > are limits on certain systems - i.e. socket files should be created in a
> > /tmp subdirectory, indeed.
> >
> > Thomas
>
> These answers already cover everything I need right now. Thanks!
>
> Final question: if at some later point one large file needs to be created for
> some test case, is there some approximate size limit to stay below for not
> causing issues with free CI cloud services?
A GIT source tree checkout of QEMU is approx 1 GB in size right now.
A build with just one target enable takes another 1 GB.
So if creating files in the source tree, or a build tree then, I'd
suggest a rule of thumb is to stay below that level as a rough
order of magnitude.
If creating in /tmp then stay below 100 MB, as it can be surprisingly
space constrained in some cases.
Regards,
Daniel
--
|: 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 :|
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: QEMU policy for real file tests
2020-09-17 12:24 ` Daniel P. Berrangé
@ 2020-09-17 12:40 ` Peter Maydell
0 siblings, 0 replies; 10+ messages in thread
From: Peter Maydell @ 2020-09-17 12:40 UTC (permalink / raw)
To: Daniel P. Berrangé
Cc: Kevin Wolf, Laurent Vivier, Thomas Huth, Christian Schoenebeck,
QEMU Developers, Greg Kurz, Max Reitz, Alex Bennée
On Thu, 17 Sep 2020 at 13:24, Daniel P. Berrangé <berrange@redhat.com> wrote:
> If creating in /tmp then stay below 100 MB, as it can be surprisingly
> space constrained in some cases.
Also if creating in /tmp/ it's nice to use an obviously qemu-testing
related filename. If a 'make check' run falls over partway through it
is prone to leaving files un-cleaned-up in /tmp/ and it's much easier
to know you can just delete them if they're named 'qtest*' rather
than just 'tmp*'...
(Ideally we'd put in some more consistent framework for temp files
used by tests to put them all in a single subdir or something, for
convenience in cleaning up afterwards.)
thanks
-- PMM
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: QEMU policy for real file tests
2020-09-17 12:06 ` Christian Schoenebeck
2020-09-17 12:24 ` Daniel P. Berrangé
@ 2020-09-17 13:04 ` Thomas Huth
2020-09-17 13:11 ` Peter Maydell
1 sibling, 1 reply; 10+ messages in thread
From: Thomas Huth @ 2020-09-17 13:04 UTC (permalink / raw)
To: Christian Schoenebeck, qemu-devel
Cc: Kevin Wolf, Laurent Vivier, Daniel P. Berrangé,
Peter Maydell, Greg Kurz, Max Reitz, Alex Bennée
On 17/09/2020 14.06, Christian Schoenebeck wrote:
[...]
> Final question: if at some later point one large file needs to be created for
> some test case, is there some approximate size limit to stay below for not
> causing issues with free CI cloud services?
FWIW, I know that 4G is already too big for some containers on Travis,
see commit 178d383f10e15f5e5a7.
Thomas
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: QEMU policy for real file tests
2020-09-17 13:04 ` Thomas Huth
@ 2020-09-17 13:11 ` Peter Maydell
2020-09-17 14:04 ` Christian Schoenebeck
0 siblings, 1 reply; 10+ messages in thread
From: Peter Maydell @ 2020-09-17 13:11 UTC (permalink / raw)
To: Thomas Huth
Cc: Laurent Vivier, Kevin Wolf, Daniel P. Berrangé,
Christian Schoenebeck, QEMU Developers, Greg Kurz, Max Reitz,
Alex Bennée
On Thu, 17 Sep 2020 at 14:04, Thomas Huth <thuth@redhat.com> wrote:
>
> On 17/09/2020 14.06, Christian Schoenebeck wrote:
> [...]
> > Final question: if at some later point one large file needs to be created for
> > some test case, is there some approximate size limit to stay below for not
> > causing issues with free CI cloud services?
>
> FWIW, I know that 4G is already too big for some containers on Travis,
> see commit 178d383f10e15f5e5a7.
Yes. Also "it's sparse" doesn't always help -- eg on OSX there is
no sparse-file support so a 4GB file really does take 4GB even
if it's mostly zeroes...
thanks
-- PMM
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: QEMU policy for real file tests
2020-09-17 13:11 ` Peter Maydell
@ 2020-09-17 14:04 ` Christian Schoenebeck
0 siblings, 0 replies; 10+ messages in thread
From: Christian Schoenebeck @ 2020-09-17 14:04 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Thomas Huth, Laurent Vivier, Kevin Wolf,
Daniel P. Berrangé, Greg Kurz, Max Reitz, Alex Bennée
On Donnerstag, 17. September 2020 14:40:42 CEST Peter Maydell wrote:
> (Ideally we'd put in some more consistent framework for temp files
> used by tests to put them all in a single subdir or something, for
> convenience in cleaning up afterwards.)
Yes, a unified interface for creating and auto wiping these, as well as
communicating limits for them would be nice to allow test cases adapting to
low quota vs. generous environments automatically.
For now I take Thomas' advice of 4GB as very rough barrier to stay away from.
On Donnerstag, 17. September 2020 15:11:18 CEST Peter Maydell wrote:
> On Thu, 17 Sep 2020 at 14:04, Thomas Huth <thuth@redhat.com> wrote:
> > On 17/09/2020 14.06, Christian Schoenebeck wrote:
> > [...]
> >
> > > Final question: if at some later point one large file needs to be
> > > created for some test case, is there some approximate size limit to
> > > stay below for not causing issues with free CI cloud services?
> >
> > FWIW, I know that 4G is already too big for some containers on Travis,
> > see commit 178d383f10e15f5e5a7.
>
> Yes. Also "it's sparse" doesn't always help -- eg on OSX there is
> no sparse-file support so a 4GB file really does take 4GB even
> if it's mostly zeroes...
While I agree not using sparse files for test cases, as many environments
don't support them; as a side note though: macOS actually supports sparse
files for a long time, both on APFS and HPFS+ volumes. There is F_PUNCHHOLE
and F_PREALLOCATE for that purpose and st_size reflects the logical file size,
whereas st_blocks*S_BLKSIZE returns the actual allocated physical file size.
Best regards,
Christian Schoenebeck
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2020-09-17 14:25 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-17 8:50 QEMU policy for real file tests Christian Schoenebeck
2020-09-17 9:26 ` Alex Bennée
2020-09-17 9:37 ` Daniel P. Berrangé
2020-09-17 9:55 ` Thomas Huth
2020-09-17 12:06 ` Christian Schoenebeck
2020-09-17 12:24 ` Daniel P. Berrangé
2020-09-17 12:40 ` Peter Maydell
2020-09-17 13:04 ` Thomas Huth
2020-09-17 13:11 ` Peter Maydell
2020-09-17 14:04 ` Christian Schoenebeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).