Bug 1215803 - '/var/lib/random-seed: No such file or directory' with virt-tools on images with bind-mount of /var
Summary: '/var/lib/random-seed: No such file or directory' with virt-tools on images w...
Keywords:
Status: NEW
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libguestfs
Version: unspecified
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Richard W.M. Jones
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-04-27 19:05 UTC by Steve Mayo
Modified: 2018-07-18 14:38 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed:
Embargoed:


Attachments (Terms of Use)
virt-sysperp run that fails due to random seed missing (82.04 KB, text/plain)
2015-04-27 19:05 UTC, Steve Mayo
no flags Details

Description Steve Mayo 2015-04-27 19:05:17 UTC
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

Comment 1 Richard W.M. Jones 2015-04-27 19:20:39 UTC
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.

Comment 2 Richard W.M. Jones 2015-04-27 19:24:39 UTC
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

Comment 3 Richard W.M. Jones 2015-04-27 19:30:38 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.