utmapp / UTM

Virtual machines for iOS and macOS
https://getutm.app
Apache License 2.0
26.5k stars 1.33k forks source link

utmctl list gives error: OSStatus error -1743 #5377

Open muzzah opened 1 year ago

muzzah commented 1 year ago

Describe the issue
This has been reported in a closed issue so Im creating a new ticket for this as I think its an important fix thats needed.

When using utmctl over ssh, the list command returns an error. This seems to be a gap in capability as I cannot now remotely manage the VMs.

5001 Is the original issue where this was reported.

[9:41:21] universe:bin $ sudo utmctl list
Error from event: The operation couldn’t be completed. (OSStatus error -600.)

Any known workaround would be appreciated since I am remote and cannot physically access my Mac Studio.

Configuration

muzzah commented 1 year ago

As a side note, I looked into the config.plist under the ~Library/Containers/com.utmapp.UTM/Data/Documents/[VM NAME] and even if I use the ID or Name of the VM with utmctl it still fails.

I used the key located under UUID below, if this is not correct, can you advise which UUID I should be using? Why does it not work with the name field?

<dict>
        <key>Icon</key>
        <string>linux</string>
        <key>IconCustom</key>
        <false/>
        <key>Name</key>
        <string>Dev Server</string>
        <key>UUID</key>
        <string>8EB11628-544C-44BF-9EDE-4A65A616BEE2</string>
    </dict>
antekone commented 1 year ago

I have the same problem, I'm not able to manipulate VMs by using utmctl from an SSH session, even if I'm logged in to GUI in another session.

utmctl from a Terminal app from GUI works fine.

matzuk commented 1 year ago

@osy hey! First of all, very thank you for your product! Could you help to answer here? This issue is very critical regarding the usage of UTM VMs in clouds and etc.

osy commented 1 year ago

This is unfortunately a limitation of how apple scripting bridge works. You must have the GUI launched or launchable in an interactive instance. I don’t think it works with SSH.

mitchblank commented 1 year ago

Probably UTMCtl.eventDidFail could print a more helpful error message in the case of errAEEventNotPermitted. Not sure how easy it is to get the numeric code from the Error object (I haven't written any Swift code)

nre-ableton commented 5 months ago

This is unfortunately a limitation of how apple scripting bridge works. You must have the GUI launched or launchable in an interactive instance. I don’t think it works with SSH.

This makes sense, thanks for the explanation. Is there no way to work around this? For example, by requiring the same user to be logged-in and having the UTM app running?

I was really hoping that our company could use UTM for Mac VMs, but unfortunately as we use Ansible for VM deployments (which runs over SSH), this limitation is a dealbreaker for us. However, our Ansible playbooks use osascript in other places (for example, osascript -e 'tell application "System Events" to keystroke RETURN to dismiss some system dialogs), so it seems like there should theoretically be a way to get this working. :thinking:

osy commented 5 months ago

I am open to suggestions. Not an expect at Apple script APIs so maybe there's some hidden option I'm not aware of.

nre-ableton commented 5 months ago

I am open to suggestions. Not an expect at Apple script APIs so maybe there's some hidden option I'm not aware of.

Sadly nor am I, but I'm willing to do a bit of research on the topic. I assume that "rewriting the CLI in another language" is not an acceptable solution? :sweat_smile:

On that note, why was AppleScript used for the CLI, just out of curiosity?

matzuk commented 5 months ago

The CLI should be done in the same manner as it is done in https://github.com/cirruslabs/tart. I mean, the CLI is just a tiny wrapper over Virtualization.Framework not over GUI.