How to differentiate VM is loaded/installed with OS or not using command
Hi,
My requirement is to check whether VM is loaded/installed with OS are not using command line (i.e. python script).
"vdsClient -s 0 getAllVmStats | grep Status"
command is showing "UP" even if it not installed OS. SO how to differentiate VM is having OS or not.
and also I want command to check list of all VM's (i.e. both running and shutdown).
Please help us!!!
Responses
When a VM is shut down, I think the only way to determine if it has OS installed or not would be to read its system disk image to see if it contains valid partitions, GRUB bootloader and/or files of the OS. How to do that? It depends on how exactly your VMs and their disks are configured. So your script would have to parse the host-side VM configuration file, find the location of the VM system disk image from there, and then examine the VM system disk image using some tools as appropriate to the VM image format.
This would also work for running VMs, but you must be very careful not to write anything into the system disk image from outside the VM while the VM is running. For example, even if you're mounting an ext3 or ext4 filesystem in read-only mode, the mount operation will normally execute a journal replay if it detects the filesystem was not unmounted properly (which it won't be, if the filesystem is currently mounted inside the VM). So if you need to mount an ext3 or ext4 filesystem that belongs to a running VM's disk image, you should use the ro,noload mount options to prevent the journal replay.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
