1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

fix(virtsecrets): a secret in use is not deleted by its UUID in capitals

libvirt finds a secret by its UUID in capitals too, but its users were
looked up by the UUID as posted: a secret a VM's disk or a pool named
was deleted, and that VM or pool no longer started. They are now looked
up by the secret's own UUID.

A usage with a control character made the page fail (lxml refuses it in
XML text) and libvirt dropped a line break silently; the form refuses
both. An empty value set later showed libvirt's "value in
virSecretSetValue must not be NULL"; it is refused in words.
This commit is contained in:
catborise 2026-11-12 15:49:24 +03:00
parent 159049736d
commit b7724928fd
8 changed files with 104 additions and 49 deletions

View file

@ -101,6 +101,8 @@ class wvmSecrets(wvmConnect):
def set_secret_value(self, uuid, value):
"""value as typed on the page; its bytes follow the secret's usage
type (value_bytes)."""
if not value: # libvirt takes none
raise util.OperationError(gettext_noop("Type the secret's value"))
secret = self.wvm.secretLookupByUUIDString(uuid)
usage_type = etree.fromstring(secret.XMLDesc(0)).xpath("string(usage/@type)")
secret.setValue(value_bytes(usage_type, value))
@ -109,6 +111,7 @@ class wvmSecrets(wvmConnect):
"""Refused while a VM or a pool names it (get_users): without it that
VM or pool would no longer start."""
secret = self.wvm.secretLookupByUUIDString(uuid)
uuid = secret.UUIDString() # as its users name it: libvirt takes it in capitals too
if users := self.get_users(self.get_secrets_info()).get(uuid):
named = []
if users["vms"]: