Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS guest does not shut down via utmctl #5425

Closed
wAuner opened this issue Jul 5, 2023 · 10 comments
Closed

macOS guest does not shut down via utmctl #5425

wAuner opened this issue Jul 5, 2023 · 10 comments
Milestone

Comments

@wAuner
Copy link

wAuner commented Jul 5, 2023

BEFORE SUBMITTING YOUR ISSUE, PLEASE LOOK AT THE PINNED ISSUES AND USE THE SEARCH FUNCTION TO MAKE SURE IT IS NOT ALREADY REPORTED. ALWAYS COMMENT ON AN EXISTING ISSUE INSTEAD OF MAKING A NEW ONE.

Describe the issue
macOS guest (Ventura) does not shut down when requested via utmctl stop - ssh connection stays active.
I've started my macOS guest and ssh'ed into it. Then on the host, I use utmctl to shut down the VM. The UTM GUI indicates that the machine is shut down, but I'm still connected via SSH from the host and can perform operations - even things like the say command are still working.
I can even start a new SSH connection to a VM that was stopped via utmctl stop, so it's definitively not shut down.

Configuration

  • UTM Version: 4.2.5
  • macOS Version: 13.4.1
  • Mac Chip (Intel, M1, ...): M1

Crash log
App also crashed during my experiments
UTM-2023-07-05-194445.txt

@osy
Copy link
Contributor

osy commented Jul 10, 2023

Can you try utmctl stop --kill? The normal stop command just sends a request to the guest OS which can be ignored.

@wAuner
Copy link
Author

wAuner commented Jul 11, 2023

The --kill flag doesn't look like a clean shutdown to me. I've noticed w/o the kill flag UTM seems to be a bit too quick. The shutdown dialog appears, but it doesn't act on it. When I "restart" the VM the shutdown dialog is still there.
The utmctl stop really feels more like suspend/resume, rather than a stop/shutdown mechanism.
I have no idea how UTM works internally, but wouldn't it be possible to make utmctl stop execute shutdown -h now inside the VM?

@osy
Copy link
Contributor

osy commented Jul 11, 2023

Can you try on the latest beta?

@wAuner
Copy link
Author

wAuner commented Jul 11, 2023

Sure, here are my results: I've installed the Beta along the release UTM, I didn't uninstall it.
I first tried to start my existing via utmctl which failed:

UTM 2.app/Contents/MacOS
➜ ./utmctl start 4ADEEA96-1896-44FB-A563-E5E0A6A970C6
CleanShot 2023-07-11 at 17 05 25@2x
Exception Name: NSInternalInconsistencyException
Description: Invalid parameter not satisfying: [self canBecomeMainWindow]
User Info: {
    NSAssertFile = "NSWindow.m";
    NSAssertLine = 14356;
}

0   CoreFoundation                      0x0000000194ab3154 __exceptionPreprocess + 176
1   libobjc.A.dylib                     0x00000001945d24d4 objc_exception_throw + 60
2   Foundation                          0x0000000195a66a98 -[NSCalendarDate initWithCoder:] + 0
3   AppKit                              0x0000000197d66268 -[NSWindow _changeJustMain] + 372
4   UTM                                 0x00000001048937d8 UTM + 2750424
5   UTM                                 0x0000000104768c78 UTM + 1526904
6   UTM                                 0x000000010476e355 UTM + 1549141
7   UTM                                 0x000000010494b7c5 UTM + 3504069
8   UTM                                 0x000000010494fa71 UTM + 3521137
9   UTM                                 0x000000010468fa31 UTM + 637489
10  UTM                                 0x000000010494fa55 UTM + 3521109
11  libswift_Concurrency.dylib          0x0000000222002215 _ZL23completeTaskWithClosurePN5swift12AsyncContextEPNS_10SwiftErrorE + 1

When I then try to shutdown a manually via GUI started VM, I get this error:

UTM 2.app/Contents/MacOS
➜ ./utmctl stop 4ADEEA96-1896-44FB-A563-E5E0A6A970C6
Error from event: The operation couldn’t be completed. (OSStatus error -2700.)
The virtual machine is not running.

I probably need to delete the release first?

@wAuner
Copy link
Author

wAuner commented Jul 11, 2023

Ok I've just tried again and uninstalled the release version prior to my tests. However, the results regarding the shutdown behavior don't seem to be any different with 4.3.1 beta.

@osy osy modified the milestone: v4.3 Jul 11, 2023
@osy
Copy link
Contributor

osy commented Jul 17, 2023

I am unable to reproduce this issue on a macOS 13.0.1 guest and a macOS 13.4.1 host.

  1. Start VM with ./utmctl start C3C2CBBA-D16D-41FA-ABC4-EC295D8C9AFD
  2. SSH into VM and run while [ 1 ]; do echo ping; sleep 1; done
  3. Stop VM with ./utmctl stop C3C2CBBA-D16D-41FA-ABC4-EC295D8C9AFD
  4. Observe that 'ping' stops printing.

Make sure that no other versions of UTM is on your system (including Trash) and that you are using the same version of utmctl as in the UTM.app bundle.

@wAuner
Copy link
Author

wAuner commented Jul 17, 2023

You're right. I've deleted everything, installed the Beta again and now it works as you described. Is this a hard kill? It seems to happen so quick.

@osy
Copy link
Contributor

osy commented Jul 17, 2023

I believe the default is to hard kill. --request sends a shut down request.

@wAuner
Copy link
Author

wAuner commented Jul 17, 2023

The --request option still shows the same bug.

./utmctl stop --request 4ADEEA96-1896-44FB-A563-E5E0A6A970C6

This seems to stop the VM, but when I start it again, I see the shutdown dialog for a second, then the VM reboots.
But after a stop with request, I'm still able to ssh into the machine.

I'd much prefer an ordered shutdown as default for stop and only perform a kill if it is specifically requested. A hard kill with stop is quite unexpected to me.

@osy osy added this to the v4.3 milestone Jul 17, 2023
@osy
Copy link
Contributor

osy commented Jul 17, 2023

Apple only provides two ways of stopping: hard kill or request. To be consistent with the QEMU backend and the published APIs, we go with hard kill as default.

@osy osy closed this as completed in c20a909 Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants