Skip to content

Instantly share code, notes, and snippets.

@tomdaley92
Last active May 28, 2023 19:50
Embed
What would you like to do?
Proxmox - SPICE Client setup for MacOS

Proxmox - SPICE client setup for MacOS

  1. Install a working (and compiled) version of virt-viewer. You may view the homebrew package's upstream source on GitHub.

    brew tap jeffreywildman/homebrew-virt-manager
    brew install virt-viewer
  2. Once that's installed should be able make a call remote-viewer with a pve-spice.vv file downloaded from proxmox web interface

    remote-viewer pve-spice.vv

    Check out this useful script for debugging. There are also several other cli tools like this one on GitHub that can be used to test the same sort of thing.

Improving Quality of Life

We want remote-viewer to automatically start and open the session when we double click the VM entry in proxmox. To do that we need to first create a small helper application.

  1. Launch Automator and select Application from the dropdown list, when prompted.

    Screen Shot 2021-07-15 at 1 39 31 PM

  2. Search for shell and drag to the right. The contents:

    /usr/local/bin/remote-viewer "$@"

    Make sure to select as arguments for passing the input. Save as ~/Applications/pve-spice-launcher.app.

    Screen Shot 2021-07-15 at 2 13 01 PM

  3. Locate a pve-spice.vv file and right click, and go to Get Info -> Open With -> Change All, look for the .app file you just made.

    Screen Shot 2022-02-16 at 11 26 22 AM

  4. In Chrome, click on the small arrow on the list of downloads at the bottom, and select "Always open files of this type"

    Screen Shot 2021-07-15 at 2 02 46 PM

  5. If everything is set up correctly you should be able to double-click on the VM in the left pane of Proxmox and remote-viewer should start up and take care of the rest.

    Note: the pve-spice.vv files will be automatically deleted by remote-viewer

    Screen Shot 2021-07-15 at 2 05 57 PM

    Screen Shot 2021-07-15 at 4 42 21 PM

Enjoy!

#!/usr/bin/env bash
set -e
# needs pve-manager >= 3.1-44
usage() {
echo "Usage: $0 [-u <string>] [-p <string>] vmid [node [proxy]]"
echo
echo "-u username. Default root@pam"
echo "-p password. Default ''"
echo
echo "vmid: id for VM"
echo "node: Proxmox cluster node name"
echo "proxy: DNS or IP (use <node> as default)"
exit 1
}
PASSWORD=""
USERNAME=""
while getopts ":u:p:" o; do
case "${o}" in
u)
USERNAME="${OPTARG}"
;;
p)
PASSWORD="${OPTARG}"
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
if [[ -z "$PASSWORD" ]]; then
PASSWORD=""
fi
if [[ -z "$USERNAME" ]]; then
USERNAME='root@pam'
fi
DEFAULTHOST="$(hostname -f)"
# select VM
[[ -z "$1" ]] && usage
VMID="$1"
#[[ -z "$2" ]] && usage
NODE="${2:-$DEFAULTHOST}"
if [[ -z "$3" ]]; then
PROXY="$NODE"
else
PROXY="$3"
fi
NODE="${NODE%%\.*}"
DATA="$(curl -f -s -S -k --data-urlencode "username=$USERNAME" --data-urlencode "password=$PASSWORD" "https://$PROXY:8006/api2/json/access/ticket")"
echo "AUTH OK"
TICKET="${DATA//\"/}"
TICKET="${TICKET##*ticket:}"
TICKET="${TICKET%%,*}"
TICKET="${TICKET%%\}*}"
CSRF="${DATA//\"/}"
CSRF="${CSRF##*CSRFPreventionToken:}"
CSRF="${CSRF%%,*}"
CSRF="${CSRF%%\}*}"
curl -f -s -S -k -b "PVEAuthCookie=$TICKET" -H "CSRFPreventionToken: $CSRF" "https://$PROXY:8006/api2/spiceconfig/nodes/$NODE/qemu/$VMID/spiceproxy" -d "proxy=$PROXY" > $NODE-$VMID.vv
exec remote-viewer $NODE-$VMID.vv
@phocean
Copy link

phocean commented Jun 8, 2022

@tomdaley92 Thanks, but I don't understand what's going on. It worked for a while and stopped for some reason.
I think the issue is with Mac OS. Now I have a warning when I try to associate the files with the script :

Capture d’écran 2022-06-08 à 21 39 17

It complains that it does not have enough information to complete the association. If I proceed with it, it would associate the script only for that current file, but not the other files without extension...

EDIT : nevermind, I messed up with the script : I managed to get it work, at least in Firefox, not Mac OS

@mrl22
Copy link

mrl22 commented Aug 1, 2022

Thank you but I am struggling with a brew package issue

configure: error: Package requirements (spice-client-gtk-3.0 >= 0.35
                                     spice-client-glib-2.0 >= 0.35) were not met:

Package 'gobject-introspection-1.0', required by 'spice-client-glib-2.0', not found

@muse-sisay
Copy link

muse-sisay commented Aug 4, 2022

@tomdaley92 Is it possible to open multiple instances of the automator app/script?

i.e Is it possible to have two or more spice windows open at one time with the automator script? Currently, if you try to open a second remote spice connection while you have another session running; you have to quit the running spice session for it to open.

@picov
Copy link

picov commented Aug 14, 2022

Thank you but I am struggling with a brew package issue

configure: error: Package requirements (spice-client-gtk-3.0 >= 0.35
                                     spice-client-glib-2.0 >= 0.35) were not met:

Package 'gobject-introspection-1.0', required by 'spice-client-glib-2.0', not found

Same error here with both Intel and M1 Mac.
Th required package is already installed.

$ brew install gobject-introspection
Warning: gobject-introspection 1.72.0_1 is already installed and up-to-date.
To reinstall 1.72.0_1, run:
brew reinstall gobject-introspection

@rumochnaya
Copy link

Thank you but I am struggling with a brew package issue

configure: error: Package requirements (spice-client-gtk-3.0 >= 0.35
                                     spice-client-glib-2.0 >= 0.35) were not met:

Package 'gobject-introspection-1.0', required by 'spice-client-glib-2.0', not found

The same issue with MacBook Pro 2018 and macOS Monterey 12.4

@picov
Copy link

picov commented Aug 19, 2022

@leachimus
Copy link

Hello everyone!

I think the whole thing no longer works correctly under macOS Ventura. i get the following error:

==> Installing virt-viewer from jeffreywildman/virt-manager
Error: Your Command Line Tools (CLT) does not support macOS 13.
It is either outdated or was modified.
Please update your Command Line Tools (CLT) or delete it if no updates are available.
Update them from Software Update in System Preferences or run:
  softwareupdate --all --install --force

If that doesn't show you any updates, run:
  sudo rm -rf /Library/Developer/CommandLineTools
  sudo xcode-select --install

Alternatively, manually download them from:
  https://developer.apple.com/download/all/.
You should download the Command Line Tools for Xcode 14.1.

Have installed the latest Xcode. Can someone help me?

@leachimus
Copy link

OK, we are getting a little closer to the point now, but now I have this problem.

https://gist.github.com/tomdaley92/789688fc68e77477d468f7b9e59af51c?permalink_comment_id=4272624#gistcomment-4272624

@dedene
Copy link

dedene commented Nov 2, 2022

OK, we are getting a little closer to the point now, but now I have this problem.

https://gist.github.com/tomdaley92/789688fc68e77477d468f7b9e59af51c?permalink_comment_id=4272624#gistcomment-4272624

You can use https://github.com/Damenly/homebrew-virt-manager instead for virt-manager. Works fine under macOS Ventura using the latest Xcode 14.1

@bytemain
Copy link

bytemain commented Nov 9, 2022

use:

brew install damenly/virt-manager/virt-viewer

@TheDragon44
Copy link

I tried the instructions on this page first, and then brew install damenly/virt-manager/virt-viewer

Unfortunately both result in the same error -

Error: virt-viewer: Failed to download resource "virt-viewer"
Download failed: https://virt-manager.org/download/sources/virt-viewer/virt-viewer-11.0.tar.xz

Anyone know how to get around this?

@swhiteh4t
Copy link

I have the same error, the brew command is trying to fetch the package from this domain:
Download failed: https://virt-manager.org/download/sources/virt-viewer/virt-viewer-8.0.tar.gz
where the package is located at:
https://releases.pagure.org/virt-viewer/

I am gonna try an install it manually

@TheDragon44
Copy link

I have the same error, the brew command is trying to fetch the package from this domain: Download failed: https://virt-manager.org/download/sources/virt-viewer/virt-viewer-8.0.tar.gz where the package is located at: https://releases.pagure.org/virt-viewer/

I am gonna try an install it manually

Did you manage to get this working? If so any pointers would be much appreciated

@justinschuldt
Copy link

issue

Looks like the URIs of the virt-manager releases have changed, which has broken all the previously working brew scripts.

The virt-viewer package addresses in virt-viewer.rb now return 404s. They have changed to a new structure, from

https://virt-manager.org/download/sources/virt-viewer/...

to

https://releases.pagure.org/virt-viewer/...

fix

This updated virt-viewer.rb works for me on an M1 mac running macOS Ventura 13.1:

brew tap justinschuldt/homebrew-virt-manager
brew install virt-viewer

https://github.com/justinschuldt/homebrew-virt-manager

fyi @TheDragon44 @swhiteh4t

@fskale
Copy link

fskale commented Mar 4, 2023

Virt-{manager,viewer} and Remote are heavily dependend on various packages.
Remote viewer bottled and then rebuild from source always terminates when building TLS connection (spice and VNC).
I rebuild the whole toolchest from scratch using jhbuild but soon started over and compiled alle the packages using bleeding edge source code. (x86_64 build) There were a lot of bugs, and i patched the source heavily to get compiled under OSX 12.6.
The only thing that doesn't work is the autostart by using a .vv file.
The arguments won't be added to the ARGV so it won't start automatically, but will be added to the connection list: (open -a RemoteViewer.app --args console.vv works !)
I would appreciate to provide the DMG for testing !
It works with OSX 12.6 (X86_64).
The metal integration and multi screen integration works for me (tested using two monitors)
Here the screenshots !
Best Franz

Open with don't provide the ARGV
Bildschirmfoto 2023-03-04 um 14 58 46

Connection list
Bildschirmfoto 2023-03-04 um 14 59 18

Working connection
Bildschirmfoto 2023-03-04 um 15 00 28

@uamarchuan
Copy link

@fskale Hi Franz,
Can you share your DMG file with me for tests?
Thanks

@martibi
Copy link

martibi commented Apr 7, 2023

I'm facing a different sort of issue. Whenever I try to run the .vv file via remote-viewer it returns with this error: Unsupported graphics type 'spice' error. A quick search indicates that this is due to spice-gtk being excluded. I am using https://github.com/jeffreywildman/homebrew-virt-manager which already includes spice-gtk so not sure what is wrong. I am using macOS 12.6 Monterey on Intel Core.

$ sw_vers
ProductName:	macOS
ProductVersion:	12.6
BuildVersion:	21G115

$ remote-viewer --version
remote-viewer version 11.0
$ remote-viewer -v --debug Unknown-24
(remote-viewer:90666): virt-viewer-DEBUG: 11:29:10.442: keymap string is empty - nothing to do

(remote-viewer:90666): virt-viewer-WARNING **: 11:29:10.463: (../src/virt-viewer-window.c:831):accel_key_to_keys: runtime check failed: ((accel_mods & ~(GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)) == 0)

(remote-viewer:90666): virt-viewer-WARNING **: 11:29:10.463: (../src/virt-viewer-window.c:831):accel_key_to_keys: runtime check failed: ((accel_mods & ~(GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)) == 0)

(remote-viewer:90666): virt-viewer-WARNING **: 11:29:10.463: (../src/virt-viewer-window.c:831):accel_key_to_keys: runtime check failed: ((accel_mods & ~(GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)) == 0)

(remote-viewer:90666): virt-viewer-WARNING **: 11:29:10.463: (../src/virt-viewer-window.c:831):accel_key_to_keys: runtime check failed: ((accel_mods & ~(GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)) == 0)

(remote-viewer:90666): virt-viewer-WARNING **: 11:29:10.463: (../src/virt-viewer-window.c:831):accel_key_to_keys: runtime check failed: ((accel_mods & ~(GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)) == 0)

(remote-viewer:90666): virt-viewer-WARNING **: 11:29:10.463: (../src/virt-viewer-window.c:831):accel_key_to_keys: runtime check failed: ((accel_mods & ~(GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)) == 0)
(remote-viewer:90666): virt-viewer-DEBUG: 11:29:10.985: Opening display to Unknown-24
(remote-viewer:90666): virt-viewer-DEBUG: 11:29:10.986: Guest (null) has unsupported spice display type
Guest (null) has unsupported spice display type

@martibi
Copy link

martibi commented Apr 7, 2023

I'm facing a different sort of issue. Whenever I try to run the .vv file via remote-viewer it returns with this error: Unsupported graphics type 'spice' error. A quick search indicates that this is due to spice-gtk being excluded. I am using https://github.com/jeffreywildman/homebrew-virt-manager which already includes spice-gtk so not sure what is wrong. I am using macOS 12.6 Monterey on Intel Core.

This fixed the issue jeffreywildman/homebrew-virt-manager#200 (comment) basically depends_on "gobject-introspection" had to be added

@ted1735
Copy link

ted1735 commented May 11, 2023

Working perfectly!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment