Metamogul / UTM-Snapshot-Manager

A companion app for UTM to manage snapshots for existing virtual machines.
Apache License 2.0
100 stars 8 forks source link

Unable to create snapshot of macOS #5

Open AndrewBreyen opened 1 year ago

AndrewBreyen commented 1 year ago

Hello,

I am getting this error in the xcode console when I try to create a snapshot:

2023-07-30 11:24:27.690485-0500 UTM Snapshot-Manager[62137:786247] [default] CGSWindowShmemCreateWithPort failed on port 0

To reproduce:

  1. Run project using xcode
  2. Create new group
  3. Import vm
  4. click create snapshot button
  5. unable to add
Metamogul commented 1 year ago

Hey @AndrewBreyen! It's a bit unfortunate that the error message itself is not very specific while I couldn't reproduce the error. Can you provide more details on the context, especially the configuration of the VM:

AndrewBreyen commented 1 year ago

Hi there!

The VM is stored here: /Users/abreyen/Library/Containers/com.utmapp.UTM/Data/Documents/macOS.utm The image file is stored at: /Users/abreyen/Library/Containers/com.utmapp.UTM/Data/Documents/macOS.utm/Data/FBA0F9FA-A234-4CBC-B174-F627A9A8B6C8.img No unusual config, all the defaults were used

I am running the snapshot manager after successfully booting macOS and going through macOS setup.

It doesn't seem to do anything after asking for a tag name.

The only other thing I changed, was these settings (change team to Andrew Breyen (Personal Team) and change signing certificate to sign to run locally)

image

Thanks for any help you can provide!

Metamogul commented 1 year ago

Thanks for the follow up! I think the issue is related to the unsupported .img file format; only .qcow2 images support the snapshot functionality of QEMU this app uses. It seems I've forgotten to add that info to the README.md. However the app is filtering for .qcow2 files (FileManager.swift:12) and shouldn't be offering any other image formats for snapshots. I'll investigate the issue.

AndrewBreyen commented 1 year ago

hmm okay, I see,

How are you supposed to create a .qcow2 image?

In snapshot manager, I'm not selecting an .img file after clicking '+' from within a group, i'm selecting the .utm file. Is this incorrect?

Do you know if there's a way to create or convert the .img file? I don't see anything obvious in UTM, and the .img is the default option, seemingly with no way to choose differently

Metamogul commented 1 year ago

Hey Andrew! Thanks for the follow up :-) Sorry for the late reply, I just returned from vacation.

To address your question about creating a new .qcow2 image: Open the settings of any VM and use the "New" button in the pane on the left under the drives section to create a new image for that VM. Untick the "raw" checkbox, if it was previously ticked, to create an image in the .qcow2 format. For more information on drives, please refer to the official documentation at docs.getutm.app.

Regarding the conversion of .img files: Qemu provides some functionality within the qemu-img tool for handling images. Have a look at this question another user had asked for more details: https://github.com/Metamogul/UTM-Snapshot-Manager/discussions/4

Regarding the reproduction of the error I couldn't follow your description and unfortunately also wasn't able to reproduce the problem myself. Could your record a short video of what you're doing that leads to the error, upload it and post a link here? You'll find info on how to record your screen here.

outermosthouse commented 1 year ago

Hi, I'm running into the same issue. There is no "raw" option to uncheck when adding a new drive to the Mac vm:

Screenshot 2023-09-10 at 5 35 31 PM
outermosthouse commented 1 year ago

Fyi I converted the img file to qcow2, reimported the drive, and still seeing the same issue where I can't take a snapshot:

Screenshot 2023-09-10 at 5 56 27 PM
phil-chp commented 1 year ago

Hello! I had the exact same issue, clean install, the only config I changed was my Apple auth/signature, the steps:

  1. Created a group
  2. Added a VM that points to my .utm UTM VM file
  3. The vm is recognized successfully, and so is the .qcow2 image (I didn't have to go through a .img file, so I don't think the image extension is what @outermosthouse, @AndrewBreyen and I are experiencing)
    • Screenshot 2023-09-18 at 3 28 21 PM
  4. Creating a snapshot for the group throws the same error: 2023-09-18 15:25:38.435612+0200 UTM Snapshot-Manager[51846:939514] [default] CGSWindowShmemCreateWithPort failed on port 0

Versions

MacOS 13.3 (arm64) XCode Version 14.3.1 (14E300c)

phil-chp commented 1 year ago

This could be a deprecated error, but it's weird, you confirm in the README that XCode 14.2 works, I don't think they would make a breaking minor update.

By the way the QEMU snapshot implementation still works perfectly, it's like if it were a reloading/state error:

https://github.com/Metamogul/UTM-Snapshot-Manager/assets/72014356/0d426047-9f10-4624-bac9-fc1570475416

Then when I restart the App, with the existing snapshot, it can't find it. By the way the error message triggers on all three snapshot management buttons:

Screenshot 2023-09-18 at 4 16 59 PM
Metamogul commented 1 year ago

Hi, I'm running into the same issue. There is no "raw" option to uncheck when adding a new drive to the Mac vm:

Screenshot 2023-09-10 at 5 35 31 PM

Hey @outermosthouse, is it possible that your UTM version is not up to date? It would be helpful if you could provide the number of the release you're using.

Metamogul commented 1 year ago

This could be a deprecated error, but it's weird, you confirm in the README that XCode 14.2 works, I don't think they would make a breaking minor update.

By the way the QEMU snapshot implementation still works perfectly, it's like if it were a reloading/state error:

output.mp4

Then when I restart the App, with the existing snapshot, it can't find it. By the way the error message triggers on all three snapshot management buttons: Screenshot 2023-09-18 at 4 16 59 PM

Thanks for the video and the detailed description! I'm now able to reproduce the bug; however I'm not entirely sure what's causing it. Unfortunately I've got little time at the moment because my job takes a great amount of focus & time, but I'll try to follow up asap.

Edit: I finally could reproduce the problem when uninstalling qemu. At the moment the app just assumes that qemu-img is in place at /opt/homebrew/bin/qemu-img as listed in Dependencies; there are no checks or reports of a missing or non-functioning binary. Can everybody here with the bug confirm that package is installed? If yes, what's the version of it? @Philippe-cheype, you've already installed the qemu package, yet have the bug. Could you set a breakpoint in QemuImg.swift:150 and post the content of the let output in the previous line? Also, what version of the qemu package do you have installed?

phil-chp commented 1 year ago

No worries!

Qemu version:

❯ /opt/homebrew/bin/qemu-img --version
qemu-img version 8.1.0

output value:

Printing description of output:
"image: /Users/phil/Library/Containers/com.utmapp.UTM/Data/Documents/Kali Linux.utm/Data/14F7D390-B49E-470D-9EF3-54A11F4020B1.qcow2\nfile format: qcow2\nvirtual size: 32 GiB (34359738368 bytes)\ndisk size: 16 GiB\ncluster_size: 65536\nSnapshot list:\nID        TAG               VM SIZE                DATE     VM CLOCK     ICOUNT\n1         Clean_Install         0 B 2023-09-18 17:00:26 00:00:00.000          0\n2         Complete_Install      0 B 2023-09-18 22:06:31 00:00:00.000          0\n3         Complete_Install_2      0 B 2023-09-18 22:09:21 00:00:00.000          0\nFormat specific information:\n    compat: 1.1\n    compression type: zlib\n    lazy refcounts: false\n    refcount bits: 16\n    corrupt: false\n    extended l2: false\nChild node \'/file\':\n    filename: /Users/phil/Library/Containers/com.utmapp.UTM/Data/Documents/Kali Linux.utm/Data/14F7D390-B49E-470D-9EF3-54A11F4020B1.qcow2\n    protocol type: file\n    file length: 16 GiB (17202348032 bytes)\n    disk size: 16 GiB\n"
Metamogul commented 1 year ago

Hey Phil! It seems the message CGSWindowShmemCreateWithPort failed on port 0 is entirely unrelated to the issue. Actually now I'm seeing it too, popping up in the log every time now and then when I interact with the UI. However I manage to create and delete snapshots just as intended. I'll post a follow up when I manage to diagnose this. If you want to follow up on your own until then, you can try to set a breakpoint at the beginning of snapshotsForImageUrl in QemuImg.swift:30. This is the function responsible for parsing the string you just posted before into an array.

outermosthouse commented 12 months ago

Hi, I'm running into the same issue. There is no "raw" option to uncheck when adding a new drive to the Mac vm:

Screenshot 2023-09-10 at 5 35 31 PM

Hey @outermosthouse, is it possible that your UTM version is not up to date? It would be helpful if you could provide the number of the release you're using.

@Metamogul Using the latest v4.3.5 on Ventura 13.4.1.

/opt/homebrew/bin/qemu-img is also in the expected assumed location: qemu-img version 8.1.0

DrDonk commented 9 months ago

FYI UTM does not use QEMU when running Apple Silicon macOS guests it uses Apple's hypervisor framework (HVF) so no qcow2 files are used and hence cannot use QEMU snapshots. HVF uses raw img files stored using sparse files to minimise disk usage.

Metamogul commented 9 months ago

Thanks DrDonk! I've updated the README to make that more clear. @outermosthouse, does this explain why there's no raw option for you?