Bug 587484 - lvresize can't reduce size of a volumn
Summary: lvresize can't reduce size of a volumn
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libguestfs
Version: unspecified
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Richard W.M. Jones
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-04-30 02:04 UTC by Jinxin Zheng
Modified: 2010-05-12 12:28 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2010-05-12 12:28:25 UTC
Embargoed:


Attachments (Terms of Use)
verbose output of guestfish (28.72 KB, text/plain)
2010-04-30 02:04 UTC, Jinxin Zheng
no flags Details
output of libguestfs-test-tool (26.94 KB, text/plain)
2010-04-30 02:06 UTC, Jinxin Zheng
no flags Details

Description Jinxin Zheng 2010-04-30 02:04:49 UTC
Created attachment 410288 [details]
verbose output of guestfish

Description of problem:
guestfish sub command 'lvresize' does not work when shrinking a logical volumn 
on my fedora 12, while extending works fine.

Version-Release number of selected component (if applicable):
$ cat /etc/redhat-release 
Fedora release 12 (Constantine)
$ uname -a
Linux localhost 2.6.32.9-70.fc12.x86_64 #1 SMP Wed Mar 3 04:40:41 UTC 2010 x86_64 x86_64 x86_64 GNU/Linux
$ qemu-kvm -version
QEMU PC emulator version 0.11.0 (qemu-kvm-0.11.0), Copyright (c) 2003-2008 Fabrice Bellard
$ guestfish version
major: 1
minor: 3
release: 8
extra: 


How reproducible:
always

Steps to Reproduce:
1. I use qemu-img to create a raw image file.
$ qemu-img create tmp.img 10G
Formatting 'tmp.img', fmt=raw size=10737418240 
2. launch guestfish adding the image, and perform the following operations.
$ guestfish -a tmp.img 
><fs> run
><fs> part-disk /dev/vda mbr
><fs> pvcreate /dev/vda1
><fs> vgcreate vg1 /dev/vda1 
><fs> lvcreate lv1 vg1 8000
><fs> lvs-full 
[0] = {
  lv_name: lv1
  lv_uuid: mzxBJ9Ef1HwR1ODOwBStVezIdPZOC02c
  lv_attr: -wi-a-
  lv_major: -1
  lv_minor: -1
  lv_kernel_major: 253
  lv_kernel_minor: 0
  lv_size: 8388608000
  seg_count: 1
  origin: 
  snap_percent: 
  copy_percent: 
  move_pv: 
  lv_tags: 
  mirror_log: 
  modules: 
}
><fs> lvresize /dev/vg1/lv1 6000
libguestfs: error: lvresize: File descriptor 3 (socket:[7977]) leaked on lvm invocation. Parent PID 1: guestfsd
  WARNING: Reducing active logical volume to 5.86 GB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
  Command failed with status code 5.
><fs> lvs-full 
[0] = {
  lv_name: lv1
  lv_uuid: mzxBJ9Ef1HwR1ODOwBStVezIdPZOC02c
  lv_attr: -wi-a-
  lv_major: -1
  lv_minor: -1
  lv_kernel_major: 253
  lv_kernel_minor: 0
  lv_size: 8388608000
  seg_count: 1
  origin: 
  snap_percent: 
  copy_percent: 
  move_pv: 
  lv_tags: 
  mirror_log: 
  modules: 
}


Actual results:
lvresize returns with an error, and the volumn size is not changed.

Expected results:
The logical volumn lv1 should be succesffully resized.


Additional info:
extending a volumn works fine, with the lvm built in the example:
...
><fs> lvs-full 
[0] = {
  lv_name: lv1
  lv_uuid: 9ym65Hy2LH0qJMf7kLZR6MxyqWu08IfM
  lv_attr: -wi-a-
  lv_major: -1
  lv_minor: -1
  lv_kernel_major: 253
  lv_kernel_minor: 0
  lv_size: 8388608000
  seg_count: 1
  origin: 
  snap_percent: 
  copy_percent: 
  move_pv: 
  lv_tags: 
  mirror_log: 
  modules: 
}
><fs> lvresize /dev/vg1/lv1 9000
><fs> lvs_full
[0] = {
  lv_name: lv1
  lv_uuid: LbQWclvXlvj4yY3G3155MicHdt4ASEY5
  lv_attr: -wi-a-
  lv_major: -1
  lv_minor: -1
  lv_kernel_major: 253
  lv_kernel_minor: 0
  lv_size: 9437184000
  seg_count: 1
  origin: 
  snap_percent: 
  copy_percent: 
  move_pv: 
  lv_tags: 
  mirror_log: 
  modules: 
}

Comment 1 Jinxin Zheng 2010-04-30 02:06:34 UTC
Created attachment 410289 [details]
output of libguestfs-test-tool

Comment 2 Jinxin Zheng 2010-04-30 03:40:22 UTC
The lvresize command line tool asks the user for an confirmation input [y/n] when the user is trying to reduce the size of a logical volumn.
However, it seems that guestfish does not feed anything to the lvresize's input, which breaks the input pipe of the command.
I thinks this may be where the problem is.

Comment 3 Richard W.M. Jones 2010-04-30 07:24:45 UTC
Yes, there are several related bugs with reducing the size
of objects.  See also bug 585221 bug 585222 bug 585223.

Comment 4 Richard W.M. Jones 2010-04-30 09:53:01 UTC
This change fixes the lvresize problem for me:

http://git.annexia.org/?p=libguestfs.git;a=commitdiff;h=c24de46d06cc3ecccf00bfaaffb06172659cdd0a

Comment 5 Jinxin Zheng 2010-04-30 10:09:42 UTC
also works for me :)


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