Virtualization

RSS for tag

Create hardware-accelerated virtual machines to run macOS and Linux-based operating systems.

Virtualization Documentation

Pinned Posts

Posts under Virtualization tag

59 Posts
Sort by:
Post not yet marked as solved
1 Replies
90 Views
i made a virtual machine with the help of the tutorial on the apple developer website running macos on my m2 macbook pro. I am wondering how I can integrate my mouse in the virtual machine instead of it being on top of the app.
Posted Last updated
.
Post marked as solved
2 Replies
259 Views
When using the sample code included on the Running macOS in a virtual machine on Apple silicon. I am adding the following changes to the swift files: Added to 'MacOSVirtualMachineConfigurationHelper' file: static func createAutomountSingleDirectoryShareDeviceConfiguration() -> VZVirtioFileSystemDeviceConfiguration { let sharedDirectory = VZSharedDirectory(url: directoryURL, readOnly: false) let singleDirectoryShare = VZSingleDirectoryShare(directory: sharedDirectory) // Assign the automount tag to this share. macOS shares automounted directories automatically under /Volumes in the guest. let sharingConfiguration = VZVirtioFileSystemDeviceConfiguration(tag: VZVirtioFileSystemDeviceConfiguration.macOSGuestAutomountTag) sharingConfiguration.share = singleDirectoryShare return sharingConfiguration } Added to 'path' file: let directoryURL = URL(fileURLWithPath: NSHomeDirectory() + "Projects") Added to the 'AppDelegate' file: virtualMachineConfiguration.directorySharingDevices = [MacOSVirtualMachineConfigurationHelper.createAutomountSingleDirectoryShareDeviceConfiguration()] When the above is added and the sample app is run, the following error is shown: macOSVirtualMachineSampleApp/AppDelegate.swift:95: Fatal error: Virtual machine failed to start with Error Domain=VZErrorDomain Code=2 "A directory sharing device configuration is invalid." UserInfo={NSLocalizedFailure=Invalid virtual machine configuration., NSLocalizedFailureReason=A directory sharing device configuration is invalid., NSUnderlyingError=0x600000c343c0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}} On the host device the directory that is being shared is ~/Projects and it does exist. What do I need to change to create the shared directory and have it work? Is there a sample code project for the same configuration that was shown in the demo?
Posted
by w8ster.
Last updated
.
Post marked as solved
1 Replies
257 Views
Hello, I have tried to create a VZVirtualMachine macOS virtual machine on an Apple Silicon Mac. I have installed Docker Desktop inside this virtual machine. Docker is not working: I get this error message: "Hyopervisor check failed". Is there a way to run Docker inside a VZVirtualMachine ? Thanks a lot
Posted Last updated
.
Post not yet marked as solved
1 Replies
171 Views
We have developing an app that uses Linux VM virtualization and com.apple.security.virtualization entitlement. Question: do we need any approval from Apple to release this app that uses com.apple.security.virtualization entitlement?
Posted Last updated
.
Post not yet marked as solved
4 Replies
1.1k Views
Filed as rdar://FB11975037 When macOS Ventura is run as a guest OS within the virtualization framework, the main menu bar items will not be displayed correctly if VZMacGraphicsDisplayConfiguration defines a large resolution. The menu bar titles appear to be using the same color as the menu bar itself. When the Appearance is set to Light, the menu bar items are effectively invisible. When the Appearance is set to Dark, the menu bar items are drawn in what looks like a disabled state. This only affects the menu bar item titles on the left-hand side. The date-time and menu bar icons on the right side are always displayed in the correct color. This appears to be a regression in macOS Ventura as this issue is not present in macOS 12 running as a guest. This bug can be easily reproduced using Apple's own Virtualization sample code titled: "Running macOS in a Virtual Machine on Apple Silicon Macs" Steps to reproduce: Follow the sample code instructions for building and installing a VM.bundle. Before running 'macOSVirtualMachineSampleApp', change the VZMacGraphicsDisplayConfiguration to use: width = 5120, height = 2880, ppi = 144. Run 'macOSVirtualMachineSampleApp' and notice that the menu bar titles on the left side of the screen are not correctly drawn in the guest instance. This has been tested on: Host: macOS 13.1 Guest: macOS 13.x (All versions) Hardware: MBP 14" M1 Pro 32GB/2TB Is there anything that can be done to resolve this issue?
Posted
by kennyc.
Last updated
.
Post not yet marked as solved
1 Replies
328 Views
Hi there, I have got a question but I don't know if this is the right place. I am using an M1 Mac mini and have installed Fedora Asahi Remix for certain developing Tasks next to MacOS. How is the fan speed controlled? Does Fedora turn on the fan when the CPU gets warm or does the hardware firmware set the fan speed? Thank you for your answers! Laurin
Posted
by rinuality.
Last updated
.
Post not yet marked as solved
4 Replies
626 Views
Hello, I am working on a macOS Virtualization framework project on Xcode. Is there a way to redirect an USB device connected to the host mac, to a virtual machine. I know this is possible with lower layers but i would like to do it with a VZVirtualMachine object. Is it possible ? Thanks
Posted Last updated
.
Post not yet marked as solved
9 Replies
837 Views
We are currently utilizing VZ with Lima (details: Lima VM and VZ) for our development environment. However, we're encountering a critical issue with the com.apple.Virtualization.VirtualMachine process leading to open file handle exhaustion. When mounting our programming languages dependency cache folder (Which can have a lot of files) into the VZ VM, we encounter an operating system error related to open file limits: /gomodcache/github.com/go-git/go-git/v5@v5.4.2/plumbing/object/patch.go:14:2: open /gomodcache/github.com/go-git/go-git/v5@v5.4.2/plumbing/format/diff/unified_encoder.go: too many open files in system Further investigation revealed an abnormally high number of open files associated with the com.apple.Virtualization.VirtualMachine process. A significant portion of these files are not actively used but remain open. Example Case: A file (/Users/rcurrah/test.txt) created on the Mac host and listed (ls) in the VM remains open even 20 minutes later, as evidenced by the following command output: ❯ lsof | grep 11208 | grep test.txt COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME com.apple 11208 rcurrah 4823r REG 1,13 0 46200882 /Users/rcurrah/test.txt Steps to Reproduce the Issue: To reproduce the file handle exhaustion follow the below steps. This process will create a large number of files on the Mac host, listing them on the VZ VM, and then verifying their open status using lsof. Setup the VZ Environment with Sharing: Create a VZ VM with your home directory shared to the VM. Create a Test Directory on the Mac Host: Create a new directory on your Mac host, e.g., mkdir ~/test-file-exhaustion. Generate a Large Number of Files: Navigate to the created directory: cd ~/test-file-exhaustion. Use a loop to create a large number of files, e.g., for i in {1..10000}; do touch "file_${i}.txt"; done. This will create 10,000 files named file_1.txt, file_2.txt, etc. List Files in the VM: Access the VZ VM shell. Navigate to the mounted directory and list the files using the ls command, e.g., ls /path/to/mounted/test-file-exhaustion. Check Open Files on Mac Host: Exit the VM and return to your Mac host terminal. Use the lsof command to check for open files related to the com.apple.Virtualization.VirtualMachine process: lsof | grep "$(pgrep com.apple.Virtualization.VirtualMachine)" | grep 'test-file-exhaustion' | wc -l. Document the Output: Record the output of the lsof command. Note the number of open files. Verify File Closure (or Lack Thereof): After a certain period, e.g., 20 minutes, repeat the lsof command to see if the files are still open, indicating that they haven’t been closed properly by the process. Given these observations, we have a couple of questions: Is this behavior of com.apple.Virtualization.VirtualMachine retaining open file handles a known issue or a bug? Should VZ be managing the closure of these file handles more efficiently, especially when they are no longer in use? This issue is impacting our development workflow significantly. Any guidance or insights on resolving this would be highly appreciated. Thank you for your attention to this matter. Best regards, Ryan
Posted Last updated
.
Post marked as solved
2 Replies
1.1k Views
I use UTM.app for virtualisation. I have full virtualise "Fedora 38-aarch64" in UTM.app with rosetta enabled. After upgrading Sonoma to 14.3 it stop properly virtualised shared memory. I have this test file: #include <stdio.h> #include <sys/shm.h> #include <sys/stat.h> int main () { int segment_id; char* shared_memory; struct shmid_ds shmbuffer; int segment_size; const int shared_segment_size = 0x6400; /* Allocate a shared memory segment. */ segment_id = shmget (IPC_PRIVATE, shared_segment_size, IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR); /* Attach the shared memory segment. */ shared_memory = (char*) shmat (segment_id, 0, 0); printf ("shared memory attached at address %p\n", shared_memory); /* Determine the segment's size. */ shmctl (segment_id, IPC_STAT, &shmbuffer); segment_size = shmbuffer.shm_segsz; printf ("segment size: %d\n", segment_size); /* Write a string to the shared memory segment. */ sprintf (shared_memory, "Hello, world."); /* Detach the shared memory segment. */ shmdt (shared_memory); /* Reattach the shared memory segment, at a different address. */ shared_memory = (char*) shmat (segment_id, (void*) 0x5000000, 0); printf ("shared memory reattached at address %p\n", shared_memory); /* Print out the string from shared memory. */ printf ("%s\n", shared_memory); /* Detach the shared memory segment. */ shmdt (shared_memory); /* Deallocate the shared memory segment. */ shmctl (segment_id, IPC_RMID, 0); return 0; } Command to compile it is gcc -Wall a.c && ./a.out When I compile it in virtualised Fedora work properly show this: shared memory attached address segment size: shared memory reattached address Hello, world. When I compile directly on M1 mac id it die shared memory attached address segment size: shared memory reattached address Segmentation fault: I'm try it also in docker x86 in virtualised fedora and also show error In "Fedora 38-aarch64 virtualised" run x86 docker "docker run -it --platform linux/amd64 oraclelinux:7.9 bash" Install gcc in docker shell "yum install -y gcc" After compile and run it die with shared memory attached address segment size: shared memory reattached address Hello, world. assertion failed [rem_idx != ]: Unable find existing allocation shared memory segment to unmap (VMAllocationTracker.cpp remove_shared_mem) Trace/breakpoint (core dumped) How can I fix it? On previous version of Sonoma works properly. Thank you
Posted
by ibujna.
Last updated
.
Post not yet marked as solved
0 Replies
296 Views
I am running on Sonoma 14.X and I need to download and install VM of older OS (Ventura). Whatever the value I change in deployment target it downloads VM of Sonoma OS. I am from QA and need older OS to test app compatibility. https://developer.apple.com/documentation/virtualization/running_macos_in_a_virtual_machine_on_apple_silicon_macs
Posted
by KiranRK.
Last updated
.
Post not yet marked as solved
1 Replies
361 Views
I've tried to implement the steps suggested for configuring code signing https://docs.github.com/en/actions/deployment/deploying-xcode-applications/installing-an-apple-certificate-on-macos-runners-for-xcode-development on runners However, I could not sign my app build when I was using Virtual Runner. Is it a limitation coming from the Apple virtualization framework restriction (for signing in with Apple ID), or did I miss some configuration for Xcode? I was trying both manual and automatic signing but never succeeded (
Posted
by viterkh.
Last updated
.
Post not yet marked as solved
1 Replies
606 Views
I used to run VirtualBox on macOS to run Windows guests for some reasons. Recently I bought a new Mac mini M1, now I have a problem - VB does not have a stable release for arm (yet). What other options do I have? BTW, I came across this doc article (https://developer.apple.com/documentation/virtualization/running_macos_in_a_virtual_machine_on_apple_silicon). I read thru it, but could not conclude if it offers the same functionalities as a full-blown VM suite; and more specifically I want to run Windows guests.
Posted
by imneo.
Last updated
.
Post not yet marked as solved
1 Replies
299 Views
With Apple Virtualization Framework, we can create virtual machines and run macOS and Linux-based operating systems and pass thru USB devices like mice and keyboards. Are there any plans to be able to pass thru bluetooth or bluetooth devices to the Virtual Machine so that the VM OS could connect to bluetooth devices? Related docs: https://developer.apple.com/documentation/virtualization
Posted Last updated
.
Post not yet marked as solved
1 Replies
371 Views
I'm trying to use the host camera from inside a virtual machine created using the Virtualization framework in Swift. I can't seem to figure out how to achieve this though, and unlike audio devices, keyboards, displays etc there doesn't seem to be a corresponding class and docs page for cameras or generic usb devices. Is there any way to connect a built in Apple camera to a mac virtual machine created with the Virtualization framework?
Posted Last updated
.
Post not yet marked as solved
0 Replies
282 Views
When I call either of VZVirtualMachineConfiguration.validateSaveRestoreSupport(..) VZVirtualMachine.saveMachineStateTo(URL) I get the error: NSLocalizedFailure=Invalid virtual machine configuration. NSLocalizedFailureReason=Unsupported graphics device in configuration For Linux there seems to be only vanilla size configuration (at least 1 scanout is required): let graphicsDevice = VZVirtioGraphicsDeviceConfiguration() graphicsDevice.scanouts = [ VZVirtioGraphicsScanoutConfiguration(widthInPixels: 1920, heightInPixels: 1080) ] I've tried valid sizes and aspect ratios. I've otherwise removed console and audio devices provoking similar errors, but I can't find an acceptable graphics configuration. I believe it should work because my code is substantially similar to the open-source tart application that supports suspend. I'm running Sonoma 14.2.1 on an M1 Studio with an HP24mh external monitor via a third-party HDMI/USB-C adapter. I see nothing in the Console (except some ...wakeups_resource.diag common to other applications). So I'm looking for help with How to get more information for this failure How to configure suspendable/resumable devices: graphics for sure, but also console, audio, keyboard, etc. Thanks! GUI Linux guest: https://developer.apple.com/documentation/virtualization/running_gui_linux_in_a_virtual_machine_on_a_mac macos guest: https://developer.apple.com/documentation/virtualization/running_macos_in_a_virtual_machine_on_apple_silicon wwdc-2022: https://developer.apple.com/videos/play/wwdc2022/10002/ wwdc-2023: https://developer.apple.com/videos/play/wwdc2023/10007/
Posted
by pde5i.
Last updated
.
Post not yet marked as solved
1 Replies
446 Views
Hi, everyone! I want to know whether I can check my app is running on a virtual machine or not. If so, how can I do that in C++ or Objective-C? The code needs to support both Intel processors and Apple Silicon. Thanks! Leo
Posted Last updated
.
Post not yet marked as solved
1 Replies
409 Views
I am following the Running Linux in a Virtual Machine guide on MacOS 14 w/ ARM. Fedora kernel and RAM disk images were acquired for aarch64. I opened LinuxVirtualMachine.xcodeproj from the example; selecting 'LinuxVirtualMachine' under 'Targets', and navigating to 'Signing and Capabilities', I linked my Personal Team (needed to connect my Apple ID) under 'Signing->Team'. Clicking 'run' outputs the following: Usage: /Users/shea/Library/Developer/Xcode/DerivedData/LinuxVirtualMachine-baalsbzvoxxbspgicozzllxbyqmh/Build/Products/Debug/LinuxVirtualMachine <kernel-path> <initial-ramdisk-path> Program ended with exit code: 64 So I execute the following in Terminal from a directory containing the two images from Fedora: % /Users/shea/Library/Developer/Xcode/DerivedData/LinuxVirtualMachine-baalsbzvoxxbspgicozzllxbyqmh/Build/Products/Debug/LinuxVirtualMachine ./vmlinuz ./initrd.img And receive the output: Failed to start the virtual machine. Error Domain=VZErrorDomain Code=1 "The virtual machine failed to start." UserInfo={NSLocalizedFailure=Internal Virtualization error., NSLocalizedFailureReason=The virtual machine failed to start.} An old thread seems to imply this may be because the kernel image used to be compressed but is no longer? Another commenter suggests it is because vmlinuzis a gz file and to extract it, but file vmlinuzoutputs vmlinuz: PE32+ executable (EFI application) Aarch64 (stripped to external PDB), for MS Windows and gzip won't work even with the .gz extension. Did I miss a step?
Posted
by noicest.
Last updated
.