From e9801c8535347a4a6289351dbc722335a4c3dbcc Mon Sep 17 00:00:00 2001 From: Ben Grande Date: Mon, 24 Jun 2024 11:14:31 +0200 Subject: [PATCH] feat: helper to show mgmt property information For: https://github.com/ben-grande/qusal/issues/69 --- .github/ISSUE_TEMPLATE/bug.md | 10 ++++-- docs/TROUBLESHOOT.md | 14 +++++++++ salt/dom0/files/bin/qvm-mgmt | 46 ++++++++++++++++++++++++++++ salt/dom0/files/bin/qvm-port-forward | 0 salt/dom0/helpers.sls | 9 ++++++ 5 files changed, 76 insertions(+), 3 deletions(-) create mode 100755 salt/dom0/files/bin/qvm-mgmt mode change 100644 => 100755 salt/dom0/files/bin/qvm-port-forward diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md index 8679087..7f02cc5 100644 --- a/.github/ISSUE_TEMPLATE/bug.md +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -29,8 +29,12 @@ invalid. ### Software version @@ -57,7 +61,7 @@ settings manually, this should also be mentioned. ### Expected behavior diff --git a/docs/TROUBLESHOOT.md b/docs/TROUBLESHOOT.md index 70b65c6..51bc054 100644 --- a/docs/TROUBLESHOOT.md +++ b/docs/TROUBLESHOOT.md @@ -7,6 +7,7 @@ Qusal troubleshooting guidelines. * [Detect if your issue was already opened](#detect-if-your-issue-was-already-opened) * [Qrexec client shows Request refused](#qrexec-client-shows-request-refused) * [Salt wrapper qubesctl command fails](#salt-wrapper-qubesctl-command-fails) +* [Get Salt management information](#get-salt-management-information) ## Detect if your issue was already opened @@ -69,3 +70,16 @@ Ending the Salt call with `-l debug` argument gives the most detailed output ``` sudo qubesctl state.apply pkg.uptodate -l debug ``` + +## Get Salt management information + +Depending on the operating system of the `management_dispvm`, Salt can fail. +Let's gather some information about it. + +Get information about the global `management_dispvm` and the same property of +a specific qube. In this example we use `tpl-qubes-builder`, substitute for +the qube being managed: +```sh +sudo qubesctl state.apply dom0.helpers +qvm-mgmt tpl-qubes-builder +``` diff --git a/salt/dom0/files/bin/qvm-mgmt b/salt/dom0/files/bin/qvm-mgmt new file mode 100755 index 0000000..eabf4ed --- /dev/null +++ b/salt/dom0/files/bin/qvm-mgmt @@ -0,0 +1,46 @@ +#!/bin/sh +## SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. +## +## SPDX-License-Identifier: AGPL-3.0-or-later + +set -eu + +usage(){ + echo "Usage: ${0##*/} QUBE" >&2 + exit "${1:-1}" +} + +get_qube_feat(){ + qube="${1}" + qvm-features "${qube}" \ + | grep -e os-distribution -e os-version -e template-release \ + -e template-release -e template-name +} + +case "${1-}" in + -h|--?help) usage 0;; + -*|"") usage 1;; + *) wanted_qube="${1}";; +esac + +mgmt="$(qubes-prefs management_dispvm)" +echo "Global management_dispvm qube: ${mgmt}" +tpl_mgmt="$(qvm-prefs "${mgmt}" template)" +echo "Global management_dispvm template: ${tpl_mgmt}" +echo "Global management_dispvm template features:" +get_qube_feat "${tpl_mgmt}" + +if ! qvm-check -q -- "${wanted_qube}"; then + echo "error: qube '${wanted_qube}' does not exist" >&2 + exit 1 +fi +echo "Wanted qube: ${wanted_qube}" +wanted_mgmt="$(qvm-prefs "${wanted_qube}" management_dispvm)" +echo "Global management_dispvm qube: ${wanted_mgmt}" +if test "${wanted_mgmt}" = "${mgmt}"; then + exit +fi +wanted_tpl_mgmt="$(qvm-prefs "${wanted_mgmt}" template)" +echo "Global management_dispvm template: ${wanted_tpl_mgmt}" +echo "Global management_dispvm template features:" +get_qube_feat "${wanted_tpl_mgmt}" diff --git a/salt/dom0/files/bin/qvm-port-forward b/salt/dom0/files/bin/qvm-port-forward old mode 100644 new mode 100755 diff --git a/salt/dom0/helpers.sls b/salt/dom0/helpers.sls index 098c739..1a6de1f 100644 --- a/salt/dom0/helpers.sls +++ b/salt/dom0/helpers.sls @@ -35,4 +35,13 @@ SPDX-License-Identifier: AGPL-3.0-or-later - group: root - makedirs: True +"{{ slsdotpath }}-mgmt-debug-helper": + file.managed: + - name: /usr/local/bin/qvm-mgmt + - source: salt://{{ slsdotpath }}/files/bin/qvm-mgmt + - mode: "0755" + - user: root + - group: root + - makedirs: True + {% endif -%}