Bug 509155 - test_list_partitions_0: extra elements returned from command
test_list_partitions_0: extra elements returned from command
Status: CLOSED UPSTREAM
Product: Virtualization Tools
Classification: Community
Component: libguestfs (Show other bugs)
unspecified
All Linux
low Severity medium
: ---
: ---
Assigned To: Richard W.M. Jones
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2009-07-01 11:20 EDT by Richard W.M. Jones
Modified: 2010-03-27 06:35 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2010-03-27 06:35:42 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Richard W.M. Jones 2009-07-01 11:20:20 EDT
Running 'make check' displays:

165/174 test_pvs_0
166/174 test_pvs_1
167/174 test_list_partitions_0
test_list_partitions_0: extra elements returned from command
	/dev/sda1
	/dev/vda2
	/dev/vda3
test_list_partitions_0 FAILED
168/174 test_list_partitions_1

This is an apparent race condition in the tests.  It appears
that the previous pvremove (from the previous test) completes
before the PV has actually been removed from the device.
This causes the 'sfdisk' at the beginning of test_list_partitions_0
to fail.

Change might be because of:

udev, which operates asynchronously

virtio_blk, which runs faster and therefore exposes race
conditions.
Comment 1 Richard W.M. Jones 2009-07-01 11:27:49 EDT
Here is the full sequence of events.  Note also that
sfdisk *isn't* returning an error when it fails.

---------------

/sbin/sfdisk /dev/vda
Checking that no-one is using this disk right now ...
 vda: unknown partition table
OK

Disk /dev/vda: 1015 cylinders, 16 heads, 63 sectors/track

sfdisk: ERROR: sector 0 does not have an msdos signature
 /dev/vda: unrecognized partition table type
Old situation:
No partitions found
New situation:
Units = cylinders of 516096 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/vda1          0+   1014    1015-    511559+  83  Linux
/dev/vda2          0       -       0          0    0  Empty
/dev/vda3          0       -       0          0    0  Empty
/dev/vda4          0       -       0          0    0  Empty
Warning: no primary partition is marked bootable (active)
This does not matter for LILO, but the DOS MBR will not boot this disk.
Successfully wrote the new partition table

Re-reading the partition table ...
 vda: vda1

If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes:  dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)
sock_read_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x1
sock_read_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x1
sock_write_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x2
sock_write_event: writing 44 bytes ...
sock_write_event: wrote 44 bytes
sock_write_event: done writing, calling send_cb
/sbin/lvm pvcreate /dev/vda1
sock_read_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x1
sock_read_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x1
sock_write_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x2
sock_write_event: writing 56 bytes ...
sock_write_event: wrote 56 bytes
sock_write_event: done writing, calling send_cb
/sbin/lvm vgcreate VG /dev/vda1
sock_read_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x1
sock_read_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x1
sock_write_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x2
sock_write_event: writing 48 bytes ...
sock_write_event: wrote 48 bytes
sock_write_event: done writing, calling send_cb
/sbin/lvm lvcreate -L 8 -n LV VG
sock_read_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x1
sock_read_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x1
sock_write_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x2
sock_write_event: writing 52 bytes ...
sock_write_event: wrote 52 bytes
sock_write_event: done writing, calling send_cb
/sbin/mkfs -t ext2 /dev/VG/LV
sock_read_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x1
sock_read_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x1
sock_write_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x2
sock_write_event: writing 52 bytes ...
sock_write_event: wrote 52 bytes
sock_write_event: done writing, calling send_cb
mount -o sync,noatime /dev/VG/LV /sysroot/
sock_read_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x1
sock_read_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x1
sock_write_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x2
sock_write_event: writing 28 bytes ...
sock_write_event: wrote 28 bytes
sock_write_event: done writing, calling send_cb
/sbin/lvm pvs -o pv_name --noheadings
sock_read_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x1
sock_read_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x1
166/174 test_pvs_1
sock_write_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x2
sock_write_event: writing 40 bytes ...
sock_write_event: wrote 40 bytes
sock_write_event: done writing, calling send_cb
/sbin/blockdev --setrw /dev/vda
sock_read_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x1
sock_read_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x1
sock_write_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x2
sock_write_event: writing 28 bytes ...
sock_write_event: wrote 28 bytes
sock_write_event: done writing, calling send_cb
mount
umount /sysroot
sock_read_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x1
sock_read_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x1
sock_write_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x2
sock_write_event: writing 28 bytes ...
sock_write_event: wrote 28 bytes
sock_write_event: done writing, calling send_cb
/sbin/lvm lvs -o vg_name,lv_name --noheadings --separator /
/sbin/lvm lvremove -f /dev/VG/LV
/sbin/lvm vgs -o vg_name --noheadings
/sbin/lvm vgremove -f VG
/sbin/lvm pvs -o pv_name --noheadings
/sbin/lvm pvremove -f /dev/vda1
sock_read_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x1
sock_read_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x1
sock_write_event: 0x8a8c008 g->state = 3, fd = 3, events = 0x2
sock_write_event: writing 80 bytes ...
sock_write_event: wrote 80 bytes
sock_write_event: done writing, calling send_cb
/sbin/sfdisk /dev/vda
Checking that no-one is using this disk right now ...
BLKRRPART: Device or resource busy

This disk is currently in use - repartitioning is probably a bad idea.
Umount all file systems, and swapoff all swap partitions on this disk.
Use the --no-reread flag to suppress this check.
Use the --force flag to overrule all checks.
Comment 2 Richard W.M. Jones 2009-07-01 11:38:25 EDT
The following commit fixes the buggy handling of
pclose, thus checking the return value from sfdisk
properly:

http://git.et.redhat.com/?p=libguestfs.git;a=commitdiff;h=fe27753ae5925cbe50042e47115364a57aadbbd7
Comment 3 Richard W.M. Jones 2009-07-01 12:46:13 EDT
This seems to be *mostly* fixed by calling udevadm settle
after some LVM operations:

http://git.et.redhat.com/?p=libguestfs.git;a=commitdiff;h=99e28249d52ca5495b636e14ae3e4387ee62c8fe

There are still some related races in VG creation though.
Comment 4 Richard W.M. Jones 2010-03-27 06:35:42 EDT
Long fixed upstream.

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