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
Virtualization
RSS for tagCreate hardware-accelerated virtual machines to run macOS and Linux-based operating systems.
Posts under Virtualization tag
61 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
Good day ,
thank you very much for the #virtualization article
I have now managed to create a linux(#debian 12/bookworm) virtual machine
I now have the following questions.
How can i increase the size of the GUI Linus VM.bundle from 68.72G to 150G?
Unable to obtain an IP V4 address to a bridge (have intall brige-utils package) - can get IP v6 address without any problem.
my #bridge setup is
auto br0
iface br0 inet dhcp
bridge_ports enp0s1
bridge-stp on
bridge-fd 0
Unable to ping the host from the virtual machine , but able to ping vms from the host - no firewalls are running, how can i enable icmp from vm to host and host to other containers.
my target is to run lxd/incus containers to test few of my applications in apple silicon
I am now able to run lxd/incus without any problem. however i am not able to access the application that are running in the containers, provided I am logged into the linux vm which beats the purpose of publishing the my apps, few of the services are IBM informix REST API / Nginx .
My #requirement is
1, increase the size of the vm image.(#GUI Linux vm.bundle)
2. Obtain #ip address V4 for br0
3. Run #lxd / #incus containers
4. #icmp comms between host / vm / containers
Please let me know if there are possibilities to achieve my requirement.
Thank you
I'm aware signing in to an Apple ID on a macOS Virtual Machine is not supported, unfortunately. But is there a way to download Xcode from within the VM? I know the developer website used to have links where you could directly download Xcode outside the Mac App Store but I can't seem to find it?
Hi,
I am running GUI Linux using Apple provided reference examples.I would like to know
if there is api which supports hot plug of devices and visible on my GUI Linux.
I see VZDiskBlockDeviceStorageDeviceAttachment in the docs, but here we need to provide the /dev/* to get it visible in the Linux system,
Would like to know the dynamic device detection capability api support if any.
Can you explain me why it is not possible to work with VZVirtualMachine on iOS ?
iPad is working with the same ARM chips than mac.
It would be great to create a Linux VM on an iPad pro for example...
I am tossing a bottle into the sea...
Thanks
Hello,
I am trying to understand how macOS virtualization framework and Virtualization products work on M1 chips.
I have tried Parallels Desktop. There are no third party kernel extensions (kext) installed with this product. When i plug an USB device on my mac, i get a popup asking me if i want to plug this device to my host mac or to the current Parallels virtual machine. How can this be possible without kext ? Device management is handled at kernel level... and there are no virtualization framework API for that...
I have create a Linux virtual machine with Virtualization framework (similar to GNULinuxVirtualMachineSampleApp project):
It works but I don't understand why i can't run Windows Virtual machines. Parallels Desktop seems to work with Virtualization framework too and this product can run ARM Windows Virtual Machine. How can they do that ?
Is there a way to simulate key sending with Virtualization framework ?
I have create a 64Gb disk (VZDiskImageStorageDeviceAttachment). I have a 64Gb file on my host mac, but i am using only 10Gb on the virtual machine at this moment. Is there a way to optimize the disk image file size ?
VZVirtualMachine provides a "pause" method. I don't understand where the virtual machine state (RAM memory, ...) is saved on the host.
Thanks a lot
I m trying to identify if my launched process is running on a local mac machine(desktop/laptop) or a virtual macOS X instance like AWS EC2, Azure, MacStadium etc.
I am using the below check for this:
1 . If running on native Apple hardware, the returned value contains the model name of the hardware:
$ sysctl -n hw.model
Macmini8,1
On virtualized hardware, the value may contain the hypervisor name:
$ sysctl -n hw.model
VMware7,0
If the command output doesn't contain the "Mac" substring, the malware considers that it is running in a virtual machine.
2. Checking USB device vendor names
The commands used:
ioreg -rd1 -c IOUSBHostDevice | grep "USB Vendor Name"
Sample output on native Apple hardware:
"USB Vendor Name" = "Apple Inc."
"USB Vendor Name" = "Apple Inc."
"USB Vendor Name" = "Apple, Inc."
On virtualized hardware, the value may contain the hypervisor name:
"USB Vendor Name" = "VirtualBox"
"USB Vendor Name" = "VirtualBox"
A virtual machine can be detected by checking if the command output contains a hypervisor name, for example "VirtualBox", "VMware", etc.
3 . Checking the "IOPlatformExpertDevice" registry class
The command used:
ioreg -rd1 -c IOPlatformExpertDevice
The following fields of the IOPlatformExpertDevice class can be checked in order to detect a virtual machine:
I wanted to know can a combination of these be used to identify a process running on a Cloud VM with certainity?
I installed Gentoo in virtual machine using Apple Virtualization framework. In linux then I installed avahi, configured the network in Bridge mode. Now I want to connect from this virtual machine to other computer in local network. I can see other computers on the local network, and connect with them using local IP address. But for some reason these are not detected using .local domain. I run avahi-browse -at|grep PS3 and it detected 4 entries for this computer:
IPV4 _ssh._tcp local
IPV6 _ssh._tcp local
IPV4 _sftp-ssh._tcp local
IPV6 _sftp-ssh._tcp local
Also avahi-resolve -n PS3.local correctly detects IPv6 address of this machine.
So why cannot I connect with the computer using PS3.local name?
I am following example on Apple docs: GUILinuxVirtualMachineSampleApp
I am able to create GUI VM first time but from second time onwards it throws error
Guest did stop virtual machine.
2023-10-01 20:45:08.991551+0530 GUILinuxVirtualMachineSampleApp[6417:1426889] [client] No error handler for XPC error: Connection invalid
Thought some permission error, app cannot access the VM bundle, tried giving all perms, but didn't help, also the error is not specific as to why did guest stop the VM.
Please let me know what might be the cause and how to move forward.
Deleting VM bundle and restarting works but that's not the solution I am looking forward too.
Im using VZVirtualMahcine with Linux guest system. Every once in a while, for no apparent reason, VM just freezes completely (screen just freezes at current state), and CPU usage of the process on host is using 100%. I need to force quit the app then. This happens even if guest os is just running doing nothing. Anyone else experienced this kind of behavior? It was like that on Ventura, and now also on Sonoma. Xcode 14 and 15.
I m trying to identify if my launched process is running on a local mac machine(desktop/laptop) or a virtual macOS X instance like AWS EC2, Azure, MacStadium etc.
I have followed this link which searched for its limited providers in the output, but I m not bound to any limited providers and looking for a general solution which is applicable to all the providers.
Is there some hardware/network/virtualization-related information that can be used to identify if the process is launched on a virtual MacOS instance?
OR is there some system Information that I can use to be sure that my process is running on a local machine?
I have a Mac OS virtual machine (VM) on my Macbook Pro with M1 Pro chip. The VM was set up using Xcode and Apple's sample code in https://developer.apple.com/documentation/virtualization. Both the host and the VM have Mac OS 14. The mouse and trackpad scroll direction is reverse to what I am used to so I need to change the natural scroll setting. However mouse and trackpad settings are missing in my VM. Usually, they are under Keyboard (host has them).
The pointing device was set up using the default in the sample code:
static func createPointingDeviceConfiguration() -> VZPointingDeviceConfiguration {
return VZMacTrackpadConfiguration()
}
I have been using this setup before without a problem. But now I am not able to change the scroll direction. Does anyone know what is going on? Any suggestion will be appreciated.
Hi,
I'm trying to implement macOS virtualization on the M1 Sonoma mac mini.
Configuration:
OS- Mac m1 sonoma
Build version- 23A5286i
ProductVersion- 14.0
Virtulization image- 13.5.2 bulild version
IPSW file - /UniversalMac_13.5.2_22G91_Restore.ipsw
I'm following the documentation - https://developer.apple.com/documentation/virtualization/running_macos_in_a_virtual_machine_on_apple_silicon?language=objc
Getting following error while reloading the restore image-
MacOSVirtualMachineInstaller.swift:32: Fatal error: The restore image failed to load. Unable to connect to installation service
Please help.
@eskimo Hi! I tried out this new download. I'd installed it on the Ventura host and in the Sonoma VM, but the Sonoma Beta 1 VM does not "see" Beta 2.
https://developer.apple.com/download/
How do we update our VM running macOS 14 beta 1 to beta 2? Thanks!
Device Support for macOS 14 beta 2
Install Device Support for macOS 14 beta 2 if installing the macOS Seed in a virtual Machine fails on a host Mac.
Released
June 21, 2023
Build
1700B21
Download Device Support Image
Device Support for macOS 14 beta 2
1700B21
I am trying to run an executable on Rosetta 2 that has been compiled to run on amd64.
My current setup is:
MacbookPro with M2 Pro chip.
Docker that is running an Ubuntu 20.04 container with the virtualization features enabled and the setting on for "Use Rosetta for x86/amd64 emulation on Apple Silicon" enabled.
When running the application, I was initially warned about missing libs. I have added these to the container in the relevant directories and the application now has no missing deps that I can see.
When running the executable, I am getting the error shown below and I'm unsure how I can get past this or if I have done something wrong in the steps I have mentioned.
*** stack smashing detected ***: terminated
Aborted
As a final attempt to get this to work, I made a very simple hello world C program, this also displayed the error shown above.
I think based on the error before all libs are present that Rosetta is being called correctly and that this is not an issue with my Rosetta install.
If anyone has any suggestions it would be greatly appreciated.
Hello,
When building and running the GUILinuxVirtualMachineSampleApp, I immediately get the error :
"Failed to retrieve the machine identifier data."
The app runs with a black window and an infinite loop icon without the file picker prompt as expected.
Hardware : MacBook Pro M2
OS : macOS 13.2.1
Can't understand what's causing it relatively to the VZGenericMachineIdentifier object.
Any insight or suggestion would be more than appreciated.
Thanks in advance :).
Sincerely,
hex0x40
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?
Is enabling nested virtualization on roadmap for MBP M2Pro/Max? Will this ever be a software setting on M2 that we could enable by toggling a button?
My device is MacBook Pro 13-inch, M1, 2020
Use source code provided by article https://developer.apple.com/documentation/virtualization/running_gui_linux_in_a_virtual_machine_on_a_mac
When installing Debian, Fedora or Ubuntu, installation process can stuck at any point and cause the installation failed.
Even if it is lucky enough to pass the installation phase, stuck could still happen at any time when the virtual machine is started.
It seems that there is some low level error that cause the Linux kernel panic, while during this process error seems to be accumulated--it starts with some user level application in Linux starts to behave weirdly, such as sudo does not authenticate a valid user, apt can not run properly, then Linux kernel panic. Sometimes it behaves like the VM get stuck where it is not sure what happened inside it.
I can't provide more detail as it happens randomly and the phenomenon differs each time. While generally it appears to be an accumulated error and eventually the VM get stuck.
Logging in with my Apple ID anywhere in the system (feedback assistant, Xcode, iCloud, etc.) fails when running under virtualization. Is this a known 'issue'? (networking in general is working fine)