My problem as it said in title, i want to run a java or c program in guest machine, it can get hyper-v host machine info or the virtual machine actual cpu usage. The actual cpu usage can be construed as (guest_overall_cpu_usage / host_overall_cpu_usage). I know that can see the cpu usage in the hyper-v management tool, but i need to use program to get it. Any help will be appreciate.
1
votes
Programs in a virtual machine are not supposed to know they're running in a virtual machine.
- John Dvorak
What should the program do if it's not running in a virtual machine / is running in a virtual machine other than Hyper-V / running in a nested virtual machine?
- John Dvorak
I'm afraid the virtual machine has no access to its host.
- John Dvorak
there are host IP, admin_name, password, so have the permission to access host.
- RichardTao
Host IP, admin_name, password are network-based properties (regard the host as a different machine), aren't they? CPU is a hardware-based property (not normally available to other devices on the network).
- John Dvorak
1 Answers
0
votes
There is an example of how to get the guest VM's CPU load in the OpenStack Hyper-V driver. Notice that the code is written in Python, because an easy to use wrapper for accessing the WMI API was available. Keep this in mind if you're going to write the calls in Java or C