Bug 1099292

Summary: sfdisk failed by "Device or resource busy" when using one command line
Product: Red Hat Enterprise Linux 6 Reporter: bfan
Component: libguestfsAssignee: Pino Toscano <ptoscano>
Status: CLOSED WONTFIX QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: low    
Version: 6.6CC: leiwang, linl, mbooth, ptoscano, rjones, wshi, xchen
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1099475 (view as bug list) Environment:
Last Closed: 2016-11-08 17:02:52 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1099475    
Bug Blocks: 1301844, 1359965    

Description bfan 2014-05-20 03:10:47 UTC
Description of problem:
When using one command line, sfdisk right after '-N fs', it will failed by "Device or resource busy".


Version-Release number of selected component (if applicable):
libguestfs-1.20.11-3.el6.x86_64


How reproducible:
100%


Steps to Reproduce:
# guestfish -x -v -N fs sfdisk /dev/sda 0 0 0 "1,100,83"
...
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.
guestfsd: error: sfdisk /dev/sda: external command failed


Actual results:
libguestfs: error: sfdisk: sfdisk /dev/sda: external command failed


Expected results:
Works well


Additional info:
Need give a sleep to make sfdisk passed.

guestfish -x -v -N fs sleep 1 : sfdisk /dev/sda 0 0 0 "1,100,83"

Comment 1 Richard W.M. Jones 2014-05-20 12:06:28 UTC
Easy to reproduce with this command (all on a single line):

while guestfish -v -x -N fs sfdisk /dev/sda 0 0 0 "1,100,83" > /tmp/log 2>&1; do echo -n . ; done

Comment 4 Xianghua Chen 2015-12-01 05:43:33 UTC
I cann't reproduce it in the following envrionment with this command:
 "while guestfish -v -x -N fs sfdisk /dev/sda 0 0 0 "1,100,83" > /tmp/log 2>&1; do echo -n . ; done"

Envrionment:
Red Hat Enterprise Linux Server release 6.7 (Santiago)
libguestfs-1.20.11-14.el6.x86_64

Then I downgrade to libguestfs-1.20.11-11.el6.x86_64 on the same os, the problem can be reproduced.

Does this bug has been fixed in libguestfs-1.20.11-14.el6.x86_64?

Comment 5 Richard W.M. Jones 2015-12-02 12:10:22 UTC
I don't see any change in the rhel-6.8 branch which could have
caused this fix.

Comment 6 Pino Toscano 2015-12-02 12:26:15 UTC
(In reply to Richard W.M. Jones from comment #5)
> I don't see any change in the rhel-6.8 branch which could have
> caused this fix.

You are right, nothing in libguestfs changed about that. A possible explanation could be that with supermin 4.x the appliance creation is done at build time, so embedding the packages available in buildroot at that time.

I'll check the logs on both the builds, since sadly there isn't a way to check from within the appliance the precise version of the packages used. (I'll write an upstream patch to do this.)

Comment 7 Xianghua Chen 2016-01-05 07:10:21 UTC

(In reply to Pino Toscano from comment #6)
> (In reply to Richard W.M. Jones from comment #5)
> > I don't see any change in the rhel-6.8 branch which could have
> > caused this fix.
> 
> You are right, nothing in libguestfs changed about that. A possible
> explanation could be that with supermin 4.x the appliance creation is done
> at build time, so embedding the packages available in buildroot at that time.
> 
> I'll check the logs on both the builds, since sadly there isn't a way to
> check from within the appliance the precise version of the packages used.
> (I'll write an upstream patch to do this.)

I reproduced this bug on:
Red Hat Enterprise Linux Server release 6.7 (Santiago)
libguestfs-1.20.11-16.el6.x86_64

Steps:
 "while guestfish -v -x -N fs sfdisk /dev/sda 0 0 0 "1,100,83" > /tmp/log 2>&1; do echo -n . ; done"

It failed as described. And then I downgrade to libguestfs-1.20.11-14.el6.x86_64, it also failed. I'm really confused because I really can not reproduce it before,it's a pity that the previous environment has gone.

Comment 8 Pino Toscano 2016-11-08 17:02:52 UTC
This is mostly an intermittent issue with udev and/or sfdisk, happening with a low frequency. Also, all the sfdisk* APIs are considered deprecated in favour of the parted-based part_add (and part_* APIs), in RHEL 6 already.

For this reason, this bug will not be investigated further.