-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
On Wed, Jun 03, 2020 at 07:02:01PM +0000, WillyPillow wrote:
> Hi.
Hi!
> The following is a draft design of the proposed template manager tool.
>
> Supported Operations
> ===
>
> - list available/installed templates (~= `dnf {info,list}`)
> - install template from repo/existing RPM (~= `dnf install`)
> - download template from repo (~= `--downloadonly`)
> - force upgrade/downgrade/reinstall template (~= `dnf
> {upgrade,downgrade,reinstall}`)
> - remove template (~= `dnf remove`)
Yes, the tool should have such option. But also, one of the goals of
this project is to un-break removing templates as any other VM (i.e.
normal qvm-remove should also work on template).
> - search for templates in repo (~= `dnf search`)
>
> Other Possibly Relevant DNF Operations
> ---
>
> It might be useful to have analogies of the following DNF operations:
>
> - `clean`: clean downloaded RPMs, repo metadata, ...etc
> - `repolist`: manage repos, e.g., `qubes-templates-community`
>
> Other Possible Features
> ---
>
> - use kernel in template (i.e., set to PVGrub by default)
> - ability to output information in machine-readable format (JSON?), as mentioned
> in <
https://github.com/QubesOS/qubes-issues/issues/2534>
> - ability to install templates in alternative pools, again mentioned in #2534
> - when removing templates, possibly remove associated AppVMs or have their templates
> set to `dummy`[^1])
> - set template of AppVMs (merge with current `qubes-template-manager`?) (low
> priority)
Yes, all good to have, but lets focus on core functionality first.
> [^1]: Similar to `qtm purge` mentioned
> [here](
https://github.com/QubesOS/qubes-issues/issues/2064).
>
> Design Discussions
> ===
>
> ### Package Format ###
>
> As previously discussed, it should be possible to directly use RPMs, extracting
> root images from there.
>
> For the file structure, it should suffice to place the images at the same
> locations as they are now, with the benefit of backward compatibility.
>
> (As a side note, is splitting the image files still needed?
> <
https://github.com/QubesOS/qubes-issues/issues/1326> seemed to indicate that it
> is okay to not do it on newer versions of Fedora?)
> (I'll probably experiment with this later.)
I think splitting is not needed, but internal I'd keep internal tar
archive, to preserve sparseness (should result in faster installation
and less temporary space needed if that would be used).
> There may be use cases in which custom metadata is required, e.g., whether to
> set PVGrub as the kernel. Unfortunately, AFAIK it is not possible to have custom
> attributes in the RPM header. As such, it may be desirable to have a separate
> file in the RPM containing the information, either in JSON or simply `KEY=VALUE`
> format.
Yes, I think separate file should be ok. The format should be easy to
parse without too complex tools - while it would be loaded after
signature verification, at some point we want to support more relaxed
approach for community templates, so the template parser should be
resilient against malicious metadata file.
`KEY=VALUE` sounds good.
Here is some attempt:
https://github.com/QubesOS/qubes-linux-template-builder/pull/15
As you can see in comments there, I don't like some parts, but maybe
it will give you some inspiration.
> Interacting with repos and dealing with RPMs should be doable with
> `python-{dnf,rpm}`. That being said, a preliminary search seems to show that
> they do not provide a straightforward way of verifying the signature of or
> extracting files from RPMs, so calling the CLI tools may still be needed.
Yes, that sounds correct. Most likely you'll need rpm2cpio and rpmkeys
tools.
> ### Metadata Storage ###
>
> The template manager needs to store metadata of installed templates such as
> version information. The current solution I have in mind is to store them as
> per-VM properties, basically similar to the current `installed_by_rpm` so that
> it is easier to keep things consistent when, e.g., `qvm-remove` is used.
> Besides, backups are also more easily handled this way.
>
> To keep things tidy, perhaps it is better to have the properties start with a
> common prefix, say `qtm_XXX`.
In fact, those don't need to be full properties, you can use "features"
(qvm-features), which is basically key-value store for each VM.
> (Care may still be needed when a template is renamed though. Would it be more
> intuitive for the user if a template is treated as non-RPM-installed once
> renamed?)
That's a tricky question, but I think we can indeed start with
this approach. But it may be good to save some information about
template origin in the vm features, even if only as a hint for the user.
> ### Permissions ###
>
> To achieve features such as `qtm purge`, the template manager needs to have
> corresponding AdminAPI access to change the templates of other AppVMs. However,
> one might wish for the management VM not to be able to see/control all VMs.
> Maybe more fine-grained rules can be created? (For instance, making the mgmtVM
> only able to change the templates of AppVMs that are based on templates managed
> by itself.)
We have very similar issue with GUI VM - basically GUI VM needs some
access to VMs connected to it. We do that by automatically adjusting
tags based on "guivm" property:
https://github.com/QubesOS/qubes-core-admin/blob/master/qubes/ext/gui.py#L55-L77
And then have a static policy that is based on those tags.
We can probably use similar approach here.
> (Alternatively, one can simply disable the functionality in such cases.)
>
> ### Naming ###
>
> > "There are two hard things in computer science: cache invalidation, naming
> > things, and off-by-one errors."
>
> Jokes aside, I think `qtm`, as proposed in #1326, is a reasonable name for the
> CLI tool.
What about qvm-template?
> - - -
>
> By the way, should I place this on, say, a Gist so that it's easier to see
> the latest revision?
Yes, that sounds like a good idea. But for discussion it would still be
useful to do that via email here.
- --
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
-----BEGIN PGP SIGNATURE-----
iQEzBAEBCAAdFiEEhrpukzGPukRmQqkK24/THMrX1ywFAl7ZX2EACgkQ24/THMrX
1yzDIgf9H4AS56i6FYTCtqlFtafVlpF1WH/MKGN6S880juvy0DeL62oXj7iGGkr3
c2FW9/GYVvwWX6fOsSha+IFJI+Stb5oKLWZghnfJle67sHYco2J59ev2I7v/iqIX
oU58k+cx8ji3uItE8lyPnG7Z14bhpEhnK5yeUApSBjeqVc6n6n61Lg5+WYxSmj41
n42AHbfAwAMxdh+w4YAs3kURGTwAm6WFe68SZfzJiyE4VJWRTmUevyQx6NBQrIzu
qHQHlPLcv/Y+vxiSadOpecm86Nxfk6wHb6wriJO3Yi5eXdYptnzkCkvf6PDi9Hzc
k/yxzL+KQ4GE2OuVJI4gttfUvMzqmw==
=bd6f
-----END PGP SIGNATURE-----