As explained here yesterday you can also use these bindings from JRuby.
Tag Archives: libguestfs-1.12
libguestfs 1.12 has been released!
Read the release notes here:
With the forthcoming
virt-ls -lR option you will be able to extract the file metadata from a virtual machine easily. The output format is designed so that simple grep patterns can be used to detect interesting things in the output.
For example to display the names of all setuid and setgid files in the VM:
# virt-ls -lR -d guest / | grep '^- ' - 4755 12544 /bin/cgexec - - 4755 32448 /bin/fusermount - - 4755 78648 /bin/mount - - 4755 43160 /bin/ping - - 4755 47888 /bin/ping6 - - 4755 34904 /bin/su - - 4755 50432 /bin/umount - [...]
To display all public writable directories:
# virt-ls -lR -d guest / | grep '^d ...7' d 1777 12288 /tmp - d 1777 4096 /tmp/.ICE-unix - d 1777 4096 /tmp/.X11-unix - d 1777 4096 /var/tmp -
To display files larger than 10MB in home directories:
# virt-ls -lR -d guest /home | awk '$3 >= 10*1024*1024'
Find regular files modified in the last 24 hours:
# virt-ls -lR -d guest --time-days / | grep '^-' | awk '$6 < 1' [...] - 0600 138 0 0 0 /home/rjones/.Xauthority - 0600 69 0 0 0 /root/.xauthsdYvWC - 0444 11 0 0 0 /tmp/.X0-lock [...]
Also filesystem comparisons are made much simpler. So to display changes in files between a snapshot and the latest version of a VM you would simply do:
# virt-ls -lR -a snapshot.img / --uids --time-t --checksum > old # virt-ls -lR -a current.img / --uids --time-t --checksum > new # diff -u old new | less
$ guestfish -i -d Guest ><fs> write-append /etc/resolv.conf "nameserver 126.96.36.199\nnameserver 188.8.131.52\n"
If you follow the example in my Summit handout you can use virt-df to monitor your VMs’ disk usage over time. But what if your VMs migrate between hosts or get renamed? Previously you had to rely on the guest name being unique and not changing. In libguestfs 1.12 we have changed most of the virt tools so you can now use a UUID to specify guests instead of a name.
# virt-df -d 799ae7ca-23a2-f622-c691-48feebcddbe6 -h Filesystem Size Used Available Use% 799ae7ca-23a2-f622-c691-48feebcddbe6:/dev/sda1 484M 67M 393M 14% 799ae7ca-23a2-f622-c691-48feebcddbe6:/dev/vg_f13x64/lv_root 7.4G 4.3G 3.1G 58%
There are two ways to use this. You can either specify a User SID like:
virt-win-reg Windows 'HKEY_USERS\S-1-5-19\Software\Policies'
or (as a libguestfs extension) you can specify a local user name directly:
virt-win-reg Windows 'HKEY_USERS\rjones\Control Panel'
For many operating system types, virt-inspector can now provide an OS icon/logo. The icon is actually grabbed from inside the virtual machine during inspection. It’s done this way to avoid trademark issues.
You can display the icon from the XML using a great little tool called XML Starlet. Here’s how:
# virt-inspector -d FedoraGuest > fedora.xml # xmlstarlet sel -t -v '//icon' < fedora.xml | base64 -i -d | display -
Partly related to this: there’s a new display command in guestfish, which lets you display icons and images from any guest:
# guestfish --ro -i -d FedoraRawhidex64 ><fs> display /usr/share/icons/hicolor/256x256/apps/fedora-logo-icon.png