On 05/22/2012 08:15 PM, Richard W.M. Jones wrote:
On Tue, May 22, 2012 at 08:01:50PM +0800, Wanlong Gao wrote:
So, you means we can use virt-ls to list the different files list, and then use virt-cat to see the different between two single files?
Yes, this is what I usually do.
For example:
$ qemu-img create -f qcow2 -b /dev/vg_pin/F16x64 cloned-f16.img Formatting 'cloned-f16.img', fmt=qcow2 size=21474836480 backing_file='/dev/vg_pin/F16x64' encryption=off cluster_size=65536
$ qemu-kvm -hda cloned-f16.img -m 1024 [boot it, shut it down]
$ virt-ls -lR -a /dev/vg_pin/F16x64 / > original.files # * $ virt-ls -lR -a cloned-f16.img / > modified.files
$ diff -u original.files modified.files --- original.files 2012-05-22 13:11:00.949456251 +0100 +++ modified.files 2012-05-22 13:11:38.248133406 +0100 @@ -1651,7 +1651,7 @@ - 0644 373 /etc/rearj.cfg l 0777 14 /etc/redhat-release -> fedora-release - 0644 1787 /etc/request-key.conf -- 0644 79 /etc/resolv.conf +- 0644 74 /etc/resolv.conf l 0777 11 /etc/rmt -> ../sbin/rmt - 0644 1615 /etc/rpc d 0755 4096 /etc/rpm @@ -32090,6 +32090,7 @@ d 0775 4096 /sys d 1777 4096 /tmp d 1777 4096 /tmp/.ICE-unix +s 0777 0 /tmp/.ICE-unix/1061 s 0777 0 /tmp/.ICE-unix/1085 d 1777 4096 /tmp/.Test-unix d 1777 4096 /tmp/.X11-unix @@ -207760,7 +207761,7 @@ - 0644 28 /var/lib/AccountsService/users/rjones d 0755 4096 /var/lib/NetworkManager - 0644 87 /var/lib/NetworkManager/NetworkManager.state -- 0644 1454 /var/lib/NetworkManager/timestamps +- 0644 1502 /var/lib/NetworkManager/timestamps d 0755 4096 /var/lib/PackageKit - 0644 9216 /var/lib/PackageKit/transactions.db d 0755 4096 /var/lib/alsa
[etc etc]
However there are some shortcomings. It won't find differences in:
- filesystem metadata - bootloaders or other information outside the regular filesystem - inside the Windows Registry (it'll just say the two binary blobs are different)
Rich.
* You don't need the --checksum option unless files are modified but keep the same size, in which case you have to examine the complete content of each file. Using --checksum is much slower. 'virt-ls' has other options that you may want to look at.
Hi Rich, Kame gave me a very good detail about the use case of virt-diff example, now quoted them for you,
Anyway, in above scheme, we cannot compare the files of the same size. For example
In guest 01: # cat /etc/sysconfig/network NETWORKING=yes HOSTNAME=guest01 GATEWAY=10.124.196.1
In guest02: # cat /etc/sysconfig/network NETWORKING=yes HOSTNAME=guest02 GATEWAY=10.124.196.1
You need to diff even if you have file lists.
BTW, what we'd like to compare is the contents of file, not meta-data.
In another point of view....
In your example in mailing list, you compares 2 files.
But, now, I _think_ what users really want is a command like following.
Following command is comparing guest's file of Guest01...Guest04 with Guest00.
# virt-diff -seed Guest00 -name Guest01 -name Guest02 -name Guest03 -name Guest04 /etc/hogehoge Guest03:/etc/hogehoge is differ. diff result...
In this case, only Guest03 has a different contents of the file.
For system-admin, this means... - Guest00,01,02,04 are correct and 03 is wrong or - Guest03 is correct and Guest00,01,02,04 are wrong. or - Guest03 has different settings intentionally and he confirmed that.
This command will be very good for system-admin.
Then, any thoughts about this tool ? and more thoughts about implementing this ? We should implement a "diff" wrapper in the guestfsd, and use this API when implementing this tool or any other methods? Thanks, Wanlong Gao