diff mbox series

[1/2] runqemu: Enable snapshot mode by default

Message ID 20250725123811.1718097-1-lamine.rehahlia@smile.fr
State New
Headers show
Series [1/2] runqemu: Enable snapshot mode by default | expand

Commit Message

lamine.rehahlia@smile.fr July 25, 2025, 12:38 p.m. UTC
From: Lamine REHAHLIA <lamine.rehahlia@smile.fr>

When snapshot mode is enabled, all disk images are treated as read-only.
Any sectors that are written during the QEMU session are redirected to a
temporary file (usually in /tmp), and these changes are discarded when
QEMU exits.

This mode is particularly useful to:
- Avoid corruption of the original image
- Ensure repeatable and clean test runs

Signed-off-by: Lamine REHAHLIA <lamine.rehahlia@smile.fr>
---
 scripts/runqemu | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Bruce Ashfield July 25, 2025, 12:43 p.m. UTC | #1
On Fri, Jul 25, 2025 at 8:38 AM lamine.rehahlia via lists.openembedded.org
<lamine.rehahlia=smile.fr@lists.openembedded.org> wrote:

> From: Lamine REHAHLIA <lamine.rehahlia@smile.fr>
>
> When snapshot mode is enabled, all disk images are treated as read-only.
> Any sectors that are written during the QEMU session are redirected to a
> temporary file (usually in /tmp), and these changes are discarded when
> QEMU exits.
>
> This mode is particularly useful to:
> - Avoid corruption of the original image
> - Ensure repeatable and clean test runs
>

Except that qemu isn't only used for testing in that manner.

My main use case is persistent qemu runs where data persists for days and
even
weeks at a time while I test the deep container stacks in
meta-virtualization.

So unless I'm misunderstanding the patch, I'd be strongly against this being
the default. It has much more potential to surprise users than the chances
of
disk corruption causing problems.

If the default did change (and I'm understanding this correctly that it
would
impact all runqemu invocations), then there needs to be a large and obvious\
banner than any changes made during the run would be lost on exit.

Cheers,

Bruce



>
> Signed-off-by: Lamine REHAHLIA <lamine.rehahlia@smile.fr>
> ---
>  scripts/runqemu | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/runqemu b/scripts/runqemu
> index 3d77046972..6c263d6b2a 100755
> --- a/scripts/runqemu
> +++ b/scripts/runqemu
> @@ -196,7 +196,7 @@ class BaseConfig(object):
>          self.taplock_descriptor = None
>          self.portlocks = {}
>          self.bitbake_e = ''
> -        self.snapshot = False
> +        self.snapshot = True
>          self.wictypes = ('wic', 'wic.vmdk', 'wic.qcow2', 'wic.vdi',
> "wic.vhd", "wic.vhdx")
>          self.fstypes = ('ext2', 'ext3', 'ext4', 'jffs2', 'nfs', 'btrfs',
>                          'cpio.gz', 'cpio', 'ramfs', 'tar.bz2', 'tar.gz',
> --
> 2.43.0
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#220908):
> https://lists.openembedded.org/g/openembedded-core/message/220908
> Mute This Topic: https://lists.openembedded.org/mt/114336727/1050810
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> bruce.ashfield@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
Yoann Congal July 25, 2025, 12:56 p.m. UTC | #2
Le ven. 25 juil. 2025 à 14:43, Bruce Ashfield via lists.openembedded.org
<bruce.ashfield=gmail.com@lists.openembedded.org> a écrit :

>
>
> On Fri, Jul 25, 2025 at 8:38 AM lamine.rehahlia via lists.openembedded.org
> <lamine.rehahlia=smile.fr@lists.openembedded.org> wrote:
>
>> From: Lamine REHAHLIA <lamine.rehahlia@smile.fr>
>>
>> When snapshot mode is enabled, all disk images are treated as read-only.
>> Any sectors that are written during the QEMU session are redirected to a
>> temporary file (usually in /tmp), and these changes are discarded when
>> QEMU exits.
>>
>> This mode is particularly useful to:
>> - Avoid corruption of the original image
>> - Ensure repeatable and clean test runs
>>
>
> Except that qemu isn't only used for testing in that manner.
>

Hi Bruce!

That we did not take into account.


> My main use case is persistent qemu runs where data persists for days and
> even
> weeks at a time while I test the deep container stacks in
> meta-virtualization.
>
> So unless I'm misunderstanding the patch, I'd be strongly against this
> being
> the default. It has much more potential to surprise users than the chances
> of
> disk corruption causing problems.
>
> If the default did change (and I'm understanding this correctly that it
> would
> impact all runqemu invocations), then there needs to be a large and
> obvious\
> banner than any changes made during the run would be lost on exit.
>

Agreed.

What about :
* stay in non-snapshot by default
* only allow using compressed image in snapshot mode (in the next patch)
?

Looking back at the patch, it does not let a user return to the
non-snapshot mode... which is wrong, so it must not be accepted like this.

Thanks!


>
> Cheers,
>
> Bruce
>
>
>
>>
>> Signed-off-by: Lamine REHAHLIA <lamine.rehahlia@smile.fr>
>> ---
>>  scripts/runqemu | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/scripts/runqemu b/scripts/runqemu
>> index 3d77046972..6c263d6b2a 100755
>> --- a/scripts/runqemu
>> +++ b/scripts/runqemu
>> @@ -196,7 +196,7 @@ class BaseConfig(object):
>>          self.taplock_descriptor = None
>>          self.portlocks = {}
>>          self.bitbake_e = ''
>> -        self.snapshot = False
>> +        self.snapshot = True
>>          self.wictypes = ('wic', 'wic.vmdk', 'wic.qcow2', 'wic.vdi',
>> "wic.vhd", "wic.vhdx")
>>          self.fstypes = ('ext2', 'ext3', 'ext4', 'jffs2', 'nfs', 'btrfs',
>>                          'cpio.gz', 'cpio', 'ramfs', 'tar.bz2', 'tar.gz',
>> --
>> 2.43.0
>>
>>
>>
>>
>>
>
> --
> - Thou shalt not follow the NULL pointer, for chaos and madness await thee
> at its end
> - "Use the force Harry" - Gandalf, Star Trek II
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#220910):
> https://lists.openembedded.org/g/openembedded-core/message/220910
> Mute This Topic: https://lists.openembedded.org/mt/114336727/4316185
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> yoann.congal@smile.fr]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
Bruce Ashfield July 25, 2025, 1:10 p.m. UTC | #3
On Fri, Jul 25, 2025 at 8:56 AM Yoann Congal <yoann.congal@smile.fr> wrote:

>
>
> Le ven. 25 juil. 2025 à 14:43, Bruce Ashfield via lists.openembedded.org
> <bruce.ashfield=gmail.com@lists.openembedded.org> a écrit :
>
>>
>>
>> On Fri, Jul 25, 2025 at 8:38 AM lamine.rehahlia via
>> lists.openembedded.org <lamine.rehahlia=smile.fr@lists.openembedded.org>
>> wrote:
>>
>>> From: Lamine REHAHLIA <lamine.rehahlia@smile.fr>
>>>
>>> When snapshot mode is enabled, all disk images are treated as read-only.
>>> Any sectors that are written during the QEMU session are redirected to a
>>> temporary file (usually in /tmp), and these changes are discarded when
>>> QEMU exits.
>>>
>>> This mode is particularly useful to:
>>> - Avoid corruption of the original image
>>> - Ensure repeatable and clean test runs
>>>
>>
>> Except that qemu isn't only used for testing in that manner.
>>
>
> Hi Bruce!
>
> That we did not take into account.
>
>
>> My main use case is persistent qemu runs where data persists for days and
>> even
>> weeks at a time while I test the deep container stacks in
>> meta-virtualization.
>>
>> So unless I'm misunderstanding the patch, I'd be strongly against this
>> being
>> the default. It has much more potential to surprise users than the
>> chances of
>> disk corruption causing problems.
>>
>> If the default did change (and I'm understanding this correctly that it
>> would
>> impact all runqemu invocations), then there needs to be a large and
>> obvious\
>> banner than any changes made during the run would be lost on exit.
>>
>
> Agreed.
>
> What about :
> * stay in non-snapshot by default
> * only allow using compressed image in snapshot mode (in the next patch)
> ?
>
>
Since that is a new use case / feature that you are adding, then having a
different mode associated with it would likely not be surprising to a user.

I did look at your 2nd patch as well, and if I'm understanding it correctly
the compressed image is decompressed to a location (currently the
directory with the compressed image) and then executed.  With those
extra steps, it seems to make sense that the data is not persistent and
snapshot makes sense.

In either case, it may be a good idea to expose the snapshot (or not)
to the user via an environment variable or a command line option and
that way whatever default is picked can always be changed.

On that line of thought, it would also be good if that setting did appear
in the runqemu summary of settings, so it would be more obvious to the
user that it is in effect.

Cheers,

Bruce


> Looking back at the patch, it does not let a user return to the
> non-snapshot mode... which is wrong, so it must not be accepted like this.
>
> Thanks!
>
>
>>
>> Cheers,
>>
>> Bruce
>>
>>
>>
>>>
>>> Signed-off-by: Lamine REHAHLIA <lamine.rehahlia@smile.fr>
>>> ---
>>>  scripts/runqemu | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/scripts/runqemu b/scripts/runqemu
>>> index 3d77046972..6c263d6b2a 100755
>>> --- a/scripts/runqemu
>>> +++ b/scripts/runqemu
>>> @@ -196,7 +196,7 @@ class BaseConfig(object):
>>>          self.taplock_descriptor = None
>>>          self.portlocks = {}
>>>          self.bitbake_e = ''
>>> -        self.snapshot = False
>>> +        self.snapshot = True
>>>          self.wictypes = ('wic', 'wic.vmdk', 'wic.qcow2', 'wic.vdi',
>>> "wic.vhd", "wic.vhdx")
>>>          self.fstypes = ('ext2', 'ext3', 'ext4', 'jffs2', 'nfs', 'btrfs',
>>>                          'cpio.gz', 'cpio', 'ramfs', 'tar.bz2', 'tar.gz',
>>> --
>>> 2.43.0
>>>
>>>
>>>
>>>
>>>
>>
>> --
>> - Thou shalt not follow the NULL pointer, for chaos and madness await
>> thee at its end
>> - "Use the force Harry" - Gandalf, Star Trek II
>>
>>
>> -=-=-=-=-=-=-=-=-=-=-=-
>> Links: You receive all messages sent to this group.
>> View/Reply Online (#220910):
>> https://lists.openembedded.org/g/openembedded-core/message/220910
>> Mute This Topic: https://lists.openembedded.org/mt/114336727/4316185
>> Group Owner: openembedded-core+owner@lists.openembedded.org
>> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
>> yoann.congal@smile.fr]
>> -=-=-=-=-=-=-=-=-=-=-=-
>>
>>
>
> --
> Yoann Congal
> Smile ECS
>
Khem Raj July 26, 2025, 6:55 p.m. UTC | #4
On Fri, Jul 25, 2025 at 6:10 AM Bruce Ashfield via
lists.openembedded.org
<bruce.ashfield=gmail.com@lists.openembedded.org> wrote:
>
>
>
> On Fri, Jul 25, 2025 at 8:56 AM Yoann Congal <yoann.congal@smile.fr> wrote:
>>
>>
>>
>> Le ven. 25 juil. 2025 à 14:43, Bruce Ashfield via lists.openembedded.org <bruce.ashfield=gmail.com@lists.openembedded.org> a écrit :
>>>
>>>
>>>
>>> On Fri, Jul 25, 2025 at 8:38 AM lamine.rehahlia via lists.openembedded.org <lamine.rehahlia=smile.fr@lists.openembedded.org> wrote:
>>>>
>>>> From: Lamine REHAHLIA <lamine.rehahlia@smile.fr>
>>>>
>>>> When snapshot mode is enabled, all disk images are treated as read-only.
>>>> Any sectors that are written during the QEMU session are redirected to a
>>>> temporary file (usually in /tmp), and these changes are discarded when
>>>> QEMU exits.
>>>>
>>>> This mode is particularly useful to:
>>>> - Avoid corruption of the original image
>>>> - Ensure repeatable and clean test runs
>>>
>>>
>>> Except that qemu isn't only used for testing in that manner.
>>
>>
>> Hi Bruce!
>>
>> That we did not take into account.
>>
>>>
>>> My main use case is persistent qemu runs where data persists for days and even
>>> weeks at a time while I test the deep container stacks in meta-virtualization.
>>>
>>> So unless I'm misunderstanding the patch, I'd be strongly against this being
>>> the default. It has much more potential to surprise users than the chances of
>>> disk corruption causing problems.
>>>
>>> If the default did change (and I'm understanding this correctly that it would
>>> impact all runqemu invocations), then there needs to be a large and obvious\
>>> banner than any changes made during the run would be lost on exit.
>>
>>
>> Agreed.
>>
>> What about :
>> * stay in non-snapshot by default
>> * only allow using compressed image in snapshot mode (in the next patch)
>> ?
>>
>
> Since that is a new use case / feature that you are adding, then having a
> different mode associated with it would likely not be surprising to a user.
>
> I did look at your 2nd patch as well, and if I'm understanding it correctly
> the compressed image is decompressed to a location (currently the
> directory with the compressed image) and then executed.  With those
> extra steps, it seems to make sense that the data is not persistent and
> snapshot makes sense.
>
> In either case, it may be a good idea to expose the snapshot (or not)
> to the user via an environment variable or a command line option and
> that way whatever default is picked can always be changed.
>
> On that line of thought, it would also be good if that setting did appear
> in the runqemu summary of settings, so it would be more obvious to the
> user that it is in effect.

I agree with this, changing the default like this is perhaps less than ideal
. It would be better to make it an option that user can set and keep the
defaults as it is.

>
> Cheers,
>
> Bruce
>
>>
>> Looking back at the patch, it does not let a user return to the non-snapshot mode... which is wrong, so it must not be accepted like this.
>>
>> Thanks!
>>
>>>
>>>
>>> Cheers,
>>>
>>> Bruce
>>>
>>>
>>>>
>>>>
>>>> Signed-off-by: Lamine REHAHLIA <lamine.rehahlia@smile.fr>
>>>> ---
>>>>  scripts/runqemu | 2 +-
>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/scripts/runqemu b/scripts/runqemu
>>>> index 3d77046972..6c263d6b2a 100755
>>>> --- a/scripts/runqemu
>>>> +++ b/scripts/runqemu
>>>> @@ -196,7 +196,7 @@ class BaseConfig(object):
>>>>          self.taplock_descriptor = None
>>>>          self.portlocks = {}
>>>>          self.bitbake_e = ''
>>>> -        self.snapshot = False
>>>> +        self.snapshot = True
>>>>          self.wictypes = ('wic', 'wic.vmdk', 'wic.qcow2', 'wic.vdi', "wic.vhd", "wic.vhdx")
>>>>          self.fstypes = ('ext2', 'ext3', 'ext4', 'jffs2', 'nfs', 'btrfs',
>>>>                          'cpio.gz', 'cpio', 'ramfs', 'tar.bz2', 'tar.gz',
>>>> --
>>>> 2.43.0
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> - Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end
>>> - "Use the force Harry" - Gandalf, Star Trek II
>>>
>>>
>>>
>>>
>>
>>
>> --
>> Yoann Congal
>> Smile ECS
>
>
>
> --
> - Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end
> - "Use the force Harry" - Gandalf, Star Trek II
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#220913): https://lists.openembedded.org/g/openembedded-core/message/220913
> Mute This Topic: https://lists.openembedded.org/mt/114336727/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/scripts/runqemu b/scripts/runqemu
index 3d77046972..6c263d6b2a 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -196,7 +196,7 @@  class BaseConfig(object):
         self.taplock_descriptor = None
         self.portlocks = {}
         self.bitbake_e = ''
-        self.snapshot = False
+        self.snapshot = True
         self.wictypes = ('wic', 'wic.vmdk', 'wic.qcow2', 'wic.vdi', "wic.vhd", "wic.vhdx")
         self.fstypes = ('ext2', 'ext3', 'ext4', 'jffs2', 'nfs', 'btrfs',
                         'cpio.gz', 'cpio', 'ramfs', 'tar.bz2', 'tar.gz',