Possible bug with salt/qvm.prefs

It appears that the salt state qvm.prefs has a bug in it, or maybe I just don’t know what I am doing.

The docs, here: qubes-mgmt-salt-dom0-qvm/README.rst at master · QubesOS/qubes-mgmt-salt-dom0-qvm · GitHub

indicate that if you want to set any pref to its default value, then specify ‘default’

However this doesn’t seem to work if you are trying to set the default_dispvm property to its default.

Workaround: issue a qvm-prefs command with qvm.cmd, using --default.

Yes, you cant use that “–default” setting.

So is this a bona fide bug, or does the documentation need to be changed to indicate that default_dispvm cannot be set to ‘default’ in qvm.prefs? (Right now it says you can set a property to ‘default’, with the implication being that it can be any property. )

I know it’s true in many cases, but I haven’t checked all possibilities. I wouldn’t be surprised if the rule is that ‘default’ is allowed except for properties that are the names of VMs. Incidentally the error message indicated that ‘none’ also isn’t allowed, but in this particular case, it is. ‘none’ certainly should be forbidden for the template property!

This is less of a problem if creating a qube de novo, because simply not setting the property at all will leave it as the default. It’s more of an issue if trying to modify an existing VM that has the property set to something (even something that happens to match the default, for the moment). At that point it’s hard to tell it; “use whatever the default is” though of course there is the rather clunky work-around.

This may sound like a contrived example, but I ran into it when rebuilding the actual default dispvm template. It’s easy enough to just set the global default to something else temporarily while deleting-and-rebuilding-and-configuring, but if some VM explicitly names that qube as its default dispvm there will be trouble (or a lot of work looping through every qube to change its default-dispvm then switch it back afterwards).

It’s not a bug, and the documentation is correct - you need to set the
value to default : you can’t use ‘–default’ .
Like this:

set_default_pref:
  qvm.prefs:
    - name: qube
    - default_dispvm: '*default*'
I never presume to speak for the Qubes team. When I comment in the Forum or in the mailing lists I speak for myself.

WHOA…

No, I wasn’t using --default. (That’s what you have to do on the command line qvm-prefs, but I wasn’t trying to do that in the qvm.prefs salt state.) The docs said I had to use default without the double dash in salt, and that’s exactly what I did. It threw an error, telling me I wasn’t allowed to use either default or none. (In fact, it will let me use none.)

I had no idea until I read what you wrote, that I was supposed to use *default* with asterisks. And the doc doesn’t say that I should, it simply says ‘default.’

Anyhow, the ‘with asterisks’ works (and I don’t need the single quotes).

My previous reply didn’t show as a reply TO YOU, so I am repeating it here, with a correction:

WHOA…

No, I wasn’t using --default. (That’s what you have to do on the command line qvm-prefs, but I wasn’t trying to do that in the qvm.prefs salt state.) The docs said I had to use default without the double dash in salt, and that’s exactly what I did. It threw an error, telling me I wasn’t allowed to use either default or none. (In fact, it will let me use none.)

I had no idea until I read what you wrote, that I was supposed to use *default* with asterisks. And the doc doesn’t say that I should, it simply says ‘default.’

Correction, I DO need the single quotes. So to set to default, don’t use default but rather '*default*'

OK, sorry yet another correction.

The text of the doc shows default (but without single quotes) but the actual example salt code does not show asterisks in the one place default is used (nor does it use the single quotes).

I think he used asterisks just to highlight the word default.

[deleted]

No, he didn’t. That was my first thought. You actually do need the asterisks.

You’re right. I’ve just checked the doc that you’ve linked in OP and it’s stated there that you need to use asterisks:

qvm.prefs

Set vmname preferences. Use *default* special value to reset property to its default value.

In fact, you need single quotes around it. Unman indicates this, the docs do not.

Also the example in the docs doesn’t have either asterisks or single quotes, around the one “default” it shows. I was reading that thinking it was correct and perhaps thought the asterisks in the text were for emphasis (just like you thought Unman’s were). Or maybe I never noticed them at all; it was a few days ago and I don’t remember. Either way, I think the docs could stand some clarification.

I suggest that right after '*default*' in the text, it should state “(note that the asterisks and single quotes are required)” and of course put the asterisks and single quotes into the example.