Efficiet way to get all tags of all qubes

I searching for a efficient and general way to get all tags of all Qubes. The best thing I came up which is this ugly for loop.

for vm in $(qvm-ls --raw-list); do
   TAGS+=$"$(qvm-tags "${vm}")"
TAGS=$"$(printf '%s' "${TAGS}" | sort -u)"

Furthermore I noticed that qvm-ls --raw-data -O=tags produces unreadable output. So this falls flat for now too.

My current loop solution unfortunately takes rather log to compute. Is there a more efficient and general way to do this?

Using python and the admin API is probably more efficient


Something like this:


import qubesadmin

app = qubesadmin.Qubes()
for vm in app.domains:
    for tag in vm.tags:
        print(f"VM: {vm} TAG: {tag}")
1 Like

Thanks I will look into that.