Skip to content

Add preload disposable setting to global config#262

Merged
marmarek merged 2 commits intoQubesOS:mainfrom
ben-grande:preload-dispvm
Jul 30, 2025
Merged

Add preload disposable setting to global config#262
marmarek merged 2 commits intoQubesOS:mainfrom
ben-grande:preload-dispvm

Conversation

@ben-grande
Copy link
Copy Markdown

@ben-grande ben-grande commented May 22, 2025

@ben-grande
Copy link
Copy Markdown
Author

The current behavior of preloaded disposables when changing default_dispvm needs to be defined.

  1. Do not mess with the old default_dispvm preload-dispvm-max feature and set the new default_dispvm feature to the same as per the old one.
  2. Set old default_dispvm preload-dispvm-max feature to 0 and set the new default_dispvm feature to the same as per the old one.
    1. Marek recommended a dom0 feature default-dispvm-preload-max. I'd say that such feature must take precedence over the disposable template feature for the GUI to behave as expected by the user.

I am concerned option 1 as a user that only uses Global Config and not Qube Settings will have lingering qubes.

Option 2 seems more sane, but I don't like the last part of my proposition:

set the new default_dispvm feature to the same as per the old one

I prefer the current behavior, which is, when toggling between disposable templates, it fetches the current feature value so you can see it updating at runtime. If we consider that the selected disposable template that is being set already has preload-dispvm-max set to a number different than the default_dispvm feature, we would be modifying the value set by the user elsewhere (vm settings, qvm-features or API) to the value received from the default_dispvm, I don't think this part makes sense.

And after writing what the new value should behave like, makes me think that the old value should not be changed to 0, because the user may have set the value elsewhere.

Then, I think the default-disvpm-preload-max dom0 feature makes sense, it would avoid this problems. With this feature, I'd say that the best behavior would be:

  1. If the disposable template is the default_dispvm, than it must respect default-disvpm-preload-max.
  2. When changing default_dispvm:
    1. The old default_dispvm will have the preload event start triggered to adapt to only having the feature preload-dispvm-max
    2. The new default_dispvm will have the value the user sets for it at runtime without depending on the old default_dispvm feature value.

Or I make fetching current value code less dynamic from the current disposable template selected and enforce that it only reads and set the dom0 feature default-dispvm-preload-max.

I guess it will be easier to grasp the advantages and disadvantages when coding. Any takes?

@ben-grande ben-grande force-pushed the preload-dispvm branch 7 times, most recently from 6831449 to 41e9f2a Compare June 3, 2025 15:02
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 3, 2025

Codecov Report

❌ Patch coverage is 98.71795% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.99%. Comparing base (3a85bee) to head (26cdf14).
⚠️ Report is 20 commits behind head on main.

Files with missing lines Patch % Lines
qubes_config/global_config/basics_handler.py 97.18% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #262      +/-   ##
==========================================
- Coverage   92.99%   92.99%   -0.01%     
==========================================
  Files          64       64              
  Lines       13034    13217     +183     
==========================================
+ Hits        12121    12291     +170     
- Misses        913      926      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

ben-grande added a commit to ben-grande/qubes-core-admin-client that referenced this pull request Jun 3, 2025
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jun 4, 2025
ben-grande added a commit to ben-grande/qubes-core-admin-client that referenced this pull request Jun 4, 2025
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jun 4, 2025
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jun 5, 2025
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jun 5, 2025
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jun 6, 2025
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jun 6, 2025
@ben-grande ben-grande changed the title [WIP] Add preload disposable setting to global config Add preload disposable setting to global config Jun 6, 2025
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jun 6, 2025
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jun 6, 2025
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jun 7, 2025
@marmarta
Copy link
Copy Markdown
Member

marmarta commented Jul 7, 2025

There was somewhere a list of supported features - for each not set, it adds expected call returning feature not found exception.

It's the ALL_KNOWN_FEATURES global in mock_app.py

@ben-grande
Copy link
Copy Markdown
Author

ben-grande commented Jul 7, 2025

Depends on QubesOS/qubes-core-admin-client#369. Codecov/patch should be 100%, excluding the NotImplementedError.

Comment thread qubes_config/global_config.glade Outdated
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Number of disposable qubes to preload from the default disposable template. The feature is deleted if the value is 0.</property>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But now it lost the info it overrides template's own value...

Comment thread qubes_config/global_config.glade Outdated
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Number of disposable qubes to preload from the default disposable template. Takes precedence over the qube feature. The feature is deleted if the value is 0.</property>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this works. If someone set the feature manually (using qvm-features to 0), you'll get a super confusing situation where either pressing ok in config without changing anything will erase the feature or you can get 0 in two ways, one of which means something completely different from the other. If we want to have the possibility of turning this off, I think there should be a checkbox before this signifying if the feature exists or not.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Untitled

something like this (sorry for doing it in a photo-of-device way, the idea is to grey out / set sensitive to False on both label and number if checkbox is unchecked)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this works. If someone set the feature manually (using qvm-features to 0), you'll get a super confusing situation where either pressing ok in config without changing anything will erase the feature or you can get 0 in two ways, one of which means something completely different from the other. If we want to have the possibility of turning this off, I think there should be a checkbox before this signifying if the feature exists or not.

Setting to 0 or '' (empty) will make the feature be deleted when saving, yes. I thought it was better this way because the global setting is an override of the local setting. I can make the feature not be deleted if the value isn't the same... but yeah, will require a checkbox to make it understandable. The scope was set on #262 (comment)

About having the possibility to turn this off..., I don't known when it is useful to turn this off, can you give an example?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's useful to have the disposable template's own value respected again - if you have multiple disposable templates you use (for example for different purposes) it's confusing to have one of them configured in a different place.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, it might be also useful to add info in qube setting of default disposable template if its own value is overridden...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting to 0 or '' (empty) will make the feature be deleted when saving, yes. I thought it was better this way because the global setting is an override of the local setting. I can make the feature not be deleted if the value isn't the same... but yeah, will require a checkbox to make it understandable. The scope was set on #262 (comment)

About having the possibility to turn this off..., I don't known when it is useful to turn this off, can you give an example?

My issue is that: if the user sets the feature to 0 with qvm-features in dom0 CLI, and opens global config, with your proposal it will look the same as if the user deleted the feature.... but those two situations can lead to vastly different system behavior (if the feature is 0, no preloaded dispvms from default dvm template will be created, if it's deleted, the feature from the template will be used, which might be any number). Thus, using 0 as a magic value here is very confusing, and can lead to unpredictable behavior; as it's a feature so it might not be set, I think that having a checkbox (representing if the feature is set or not) and a value is the best way to display this sort of config.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The checkbox cannot be before the text because it will mess up the indentation compared to the other items. Do you prefer the checkbox before or after the spin button?

@ben-grande
Copy link
Copy Markdown
Author

Ready, besides the indentation...

@ben-grande
Copy link
Copy Markdown
Author

Reminder to self, when the text and no limit of this GUI is accepted, adapt on qubes-manger for qubes-vm-settings also.

Comment thread qubes_config/global_config.glade Outdated
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Start in the background up to the given number of disposable qubes based on the default disposable template. This makes request for disposable qubes faster at the expense of consuming RAM. Will only preload as much as your system can handle. Takes precedence over the qube feature as long as the box is checked.</property>
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrewdavidwong What do you think?

Copy link
Copy Markdown
Member

@andrewdavidwong andrewdavidwong Jul 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if I completely understand the context in which this will appear, but here's my suggested revision:

The maximum number of disposables that can be loaded in the background. This makes starting new disposables much faster, but each preloaded disposable will consume memory. Even if you set this number very high, Qubes OS will only ever preload as many disposables as your system can handle, so the actual number of preloaded disposables may be lower. When this setting is enabled, it takes precedence over the qube feature. All preloaded disposables will be based on the default disposable template.

What is "the qube feature"?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is "the qube feature"?

It is a literal qube feature, as set or shown by qvm-features.

2025-07-11-075954

About the context, it is on global config. I think a large text is already an outlier but I am having problems making it small.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the relationship between this and QubesOS/qubes-issues#1512 (comment)?

It is a literal qube feature, as set or shown by qvm-features.

Hmm... Okay, in that case, here's a slight tweak:

The maximum number of disposables that can be loaded in the background. This makes starting new disposables much faster, but each preloaded disposable will consume memory. Even if you set this number very high, Qubes OS will only ever preload as many disposables as your system can handle, so the actual number of preloaded disposables may be lower. All preloaded disposables will be based on the default disposable template. When this setting is enabled, it takes precedence over the qvm-features preloaded disposable setting.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the relationship between this and QubesOS/qubes-issues#1512 (comment)?

That is just an idea for future releases, it wasn't coded, it was drawed and probably won't be done too soon. This version is an MVP.

Thanks for the text revision! I will work with that.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the text a bit. Didn't mention qvm-features because I think it complicates for the GUI user, they don't know what qube features are so I just wrote setting.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the text a bit. Didn't mention qvm-features because I think it complicates for the GUI user, they don't know what qube features are so I just wrote setting.

Not sure if it helps to clarify, but perhaps something like, "When this global setting is enabled, it takes precedence over every individual qube's specific preloaded disposable setting, if any."

But now that I think about it, shouldn't it be the other way around? (I.e., shouldn't a a more specific setting take precedence over a more general one?)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the text a bit. Didn't mention qvm-features because I think it complicates for the GUI user, they don't know what qube features are so I just wrote setting.

Not sure if it helps to clarify, but perhaps something like, "When this global setting is enabled, it takes precedence over every individual qube's specific preloaded disposable setting, if any."

It only takes precedence over the disposable template.

But now that I think about it, shouldn't it be the other way around? (I.e., shouldn't a a more specific setting take precedence over a more general one?)

Normally, yes, but this global setting is not for every qube, is just for the qube that is the default_dispvm.

Copy link
Copy Markdown
Member

@andrewdavidwong andrewdavidwong Jul 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It only takes precedence over the disposable template.

Okay, then how about: "When this global setting is enabled, it takes precedence over the default disposable template's own preloaded disposable setting."

Normally, yes, but this global setting is not for every qube, is just for the qube that is the default_dispvm.

Okay.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@ben-grande
Copy link
Copy Markdown
Author

PipelineRetry

@ben-grande
Copy link
Copy Markdown
Author

PipelineRetryFailed

Comment thread qubes_config/global_config.glade Outdated
<property name="margin-start">5</property>
<property name="margin-bottom">5</property>
<property name="has-entry">True</property>
<child internal-child="entry">
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this added?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed, no idea if I misclicked this on glade...

Comment thread qubes_config/global_config.glade Outdated
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Preload disposables:</property>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want "Preload disposables", or maybe more explicitly "Preload disposable qubes"?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to the latter.

Comment thread qubes_config/global_config.glade Outdated
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">The maximum number of disposables that can be loaded in the background. This makes using new disposables much faster, but each preloaded disposable will consume memory. Even if you set this number very high, Qubes OS will only ever preload as many disposables as your system can handle, so the actual number of preloaded disposables may be lower. The preloaded disposables will be based on the default disposable template. When this setting is enabled, it takes precedence over the default disposable template's own preloaded disposable setting.</property>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<property name="label" translatable="yes">The maximum number of disposables that can be loaded in the background. This makes using new disposables much faster, but each preloaded disposable will consume memory. Even if you set this number very high, Qubes OS will only ever preload as many disposables as your system can handle, so the actual number of preloaded disposables may be lower. The preloaded disposables will be based on the default disposable template. When this setting is enabled, it takes precedence over the default disposable template's own preloaded disposable setting.</property>
<property name="label" translatable="yes">Maximum number of disposable qubes (based on default disposable template) that will be created in the background, waiting until they are needed. This improves disposable qube startup time at the cost of increased memory usage. The setting here takes precedence over individual settings of the default disposable template. </property>

This is really, really too long. I don't think the details about RAM usage are sensible here? If you think they are, please edit it down to one sentence about resource usage max.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used you version and cut it a bit also.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a Qubes user, I wouldn't know what The setting here takes precedence over individual settings of the default disposable template. means. "Which settings?" is what I'd be wondering.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same setting (preload) that is available to be changed via qubes-vm-settings?

This settings takes precedence over the default disposable template's preload setting.

Is this better?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same setting (preload) that is available to be changed via qubes-vm-settings?

This settings takes precedence over the default disposable template's preload setting.

Is this better?

Yes, but it sounds like the first "setting" should be singular.

Comment thread qubes_config/global_config.glade Outdated
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Maximum number of disposable qubes (based on default disposable template) that will be loaded in the background. This removes fresh disposable qube startup time at the cost of increased memory usage. The setting here takes precedence over the default disposable template's individual settings.</property>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love the sentence "This removes fresh disposable qube startup time at the cost of increased memory usage"; I think that we do not use the "fresh disposable qube startup time" anywhere in the docs, so it might be somewhat confusing. "This speeds up disposable qube startup at the cost of memory."?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"This speeds up disposable qube startup at the cost of memory."?

But it doesn't speed up startup time, the startup time remains the same. What it does, when requested, on the best case scenario (requesting after preload procedures have completed), is that it skips startup time.

Changed it to:

Reduces disposable qube use waiting time at the cost of increased memory usage.

What do you think? Used a similar phrase from the manual: https://github.com/QubesOS/qubes-core-admin-client/blob/68b2b3250c87ee18ed0e28b1b8e208e501d0faa9/doc/manpages/qvm-features.rst?plain=1#L450

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about something like, "Queues disposables in the background so they're available immediately, but each one uses memory."

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think:

Maximum number of disposable qubes (based on default disposable template) to queue in the background so they are available immediately, but each one reserves memory. This setting takes precedence over the default disposable template's individual settings.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested rewording:

The maximum number of disposable qubes to queue in the background. Preloaded disposables start instantly, but each one uses memory while queued. Preloaded disposables are always based on the default disposable template. This setting takes precedence over the default disposable template's preload setting.

If you need to make it shorter, I suggest dropping the last 1-2 sentences or moving them into a nearby "?" or "i" icon tooltip.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current text:

Maximum number of disposable qubes (based on default disposable template) to queue in the background so they are available immediately, but each one reserves memory. This setting takes precedence over the default disposable template's preload setting.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, the first sentence is awkward, because the clause after the "but" doesn't contrast with the entire clause before the "but." Also, "Maximum number of disposable qubes (based on default disposable template)" is ambiguous, since it could be interpreted to mean that the maximum number is somehow based on the default disposable template.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think:

Maximum number of disposable qubes (created from the default disposable template) to queue in the background. They are available immediately, but each one reserves memory. This setting takes precedence over the default disposable template's preload setting.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good 👍

@marmarta
Copy link
Copy Markdown
Member

But from user POV this is startup time: time between "I asked for a dispvm" and "I've received a dispvm".

@marmarek
Copy link
Copy Markdown
Member

When you enable preload, can you make the default to "1"? To save one click when enabling the feature.

defdispvm = self.defdispvm_model.get_selected()
preloadcheck = self.preload_dispvm_check.get_active()
if defdispvm and preloadcheck:
self.preload_dispvm_spin.set_value(self.get_current_value() or 1)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, but this will change explicit 0 into 1, no?

@ben-grande
Copy link
Copy Markdown
Author

ben-grande commented Jul 23, 2025 via email

@ben-grande
Copy link
Copy Markdown
Author

PipelineRetryFailed

2 similar comments
@ben-grande
Copy link
Copy Markdown
Author

PipelineRetryFailed

@ben-grande
Copy link
Copy Markdown
Author

PipelineRetryFailed

Other disposables may be starting and those notifications may cause
confusion as to why the user is seeing a disposable with a different
name than what was recently shown in a notification.

For: QubesOS/qubes-issues#1512
@ben-grande
Copy link
Copy Markdown
Author

Finally :) !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants