Created attachment 1019414 [details] virt-sysperp run that fails due to random seed missing With virt-tools some operations fail if /var is bind-mounted within the VM. Version-Release number of selected component (if applicable): 1.20.11 (cent6) 1.28.1 (cent7) Details: The error occurs because it tries to update a non-existant random seed on the root volume which doesn't exist because its been bind-mounted. For example 'enable-operations' with virt-sysprep succeed but I cannot upload a file onto the vm image. Same is true of other virt-tools. I was able to verify this is the case by booting up a live-cd in the vm, then mounting root and creating a random seed by dd'ing from dev/random. Since the random seed existed 'under' the bind mount then virt-tools was able to proceed. Unfortunately I couldn't find a way to make virt-sysprep skip the random-seed step, that would have been very helpful. Steps to Reproduce: Step#1 - bind mounted /var within vmware image Bind-mounted fstab # /etc/fstab LABEL=root_volume / ext4 defaults 1 1 LABEL=boot_volume /boot ext3 defaults 1 2 LABEL=appliance_vol /appliance xfs defaults 1 1 ## bind mounts for the appliance folder /appliance/var /var none bind 1 1 Step#2 - operation against vmware image. virt-sysprep -a some-appliance-flat.vmdk --upload our-app.rpm:/tmp Debug output #################################################################### guestfsd: main_loop: proc 38 (is_dir) took 0.00 seconds guestfsd: main_loop: new request, len 0x44 guestfsd: main_loop: proc 37 (is_file) took 0.00 seconds guestfsd: main_loop: new request, len 0x4c guestfsd: main_loop: proc 37 (is_file) took 0.00 seconds guestfsd: main_loop: new request, len 0x4c guestfsd: main_loop: proc 37 (is_file) took 0.00 seconds guestfsd: main_loop: new request, len 0x4c guestfsd: main_loop: proc 37 (is_file) took 0.00 seconds guestfsd: main_loop: new request, len 0x44 guestfsd: main_loop: proc 37 (is_file) took 0.00 seconds guestfsd: main_loop: new request, len 0x244 guestfsd: error: open: /var/lib/random-seed: No such file or directory guestfsd: main_loop: proc 246 (internal_write) took 0.00 seconds virt-sysprep: error: libguestfs error: internal_write: open: /var/lib/random-seed: No such file or directory If reporting bugs, run virt-sysprep with debugging enabled and include the complete output: virt-sysprep -v -x [...] libguestfs: closing guestfs handle 0x1f6cac0 (state 2) guestfsd: main_loop: new request, len 0x28
Yup there are definitely two bugs here. Firstly that inspection doesn't handle bind-mounting properly, and secondly that there ought to be a way to skip the random seed step. And possibly a third one which is the random seed step shouldn't fail so badly.
Quick reproducer: $ virt-builder fedora-21 --delete /var $ virt-sysprep -a fedora-21.img [ 0.0] Examining the guest ... ... [ 3.0] Setting a random seed virt-sysprep: error: libguestfs error: internal_write: open: /var/lib/random-seed: No such file or directory
I pushed: https://github.com/libguestfs/libguestfs/commit/b70aec11c649b3c5ff22bc0f6a64e794ca3e7515 which is a partial workaround that will at least stop the error message. Instead you will see this warning: virt-sysprep: warning: random seed could not be set for this type of guest However as this is not a full fix for this bug, I am going to leave this bug open.