[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 0/3] Support --allocate and --shrink for vol-resize



https://bugzilla.redhat.com/show_bug.cgi?id=804516

Though the bug's title is about the document, but I prefer to implement
it instead of changing document. Those two flags were added long time
ago, but never implemented, it's not good to say they are not supported
now while they were already exposed outside.

A few examples of vol-resize with the patches:

1) Create 5M a parse vol
% dd of=/var/lib/libvirt/images/sparse.raw bs=1k seek=5120 count=0
0+0 records in
0+0 records out
0 bytes (0 B) copied, 7.904e-06 s, 0.0 kB/s

% ./tools/virsh pool-refresh default
Pool default refreshed

%s ./tools/virsh vol-info /var/lib/libvirt/images/sparse.raw
Name:           sparse.raw
Type:           file
Capacity:       5.00 MiB
Allocation:     0.00 B

2) Resize the vol to 6M with --allocate, I.E. The capacity (5M - 6M) is
   preallocated.
% ./tools/virsh vol-resize /var/lib/libvirt/images/sparse.raw 6M --allocate
Size of volume 'sparse.raw' successfully changed to 6M

% ./tools/virsh vol-info /var/lib/libvirt/images/sparse.raw
Name:           sparse.raw
Type:           file
Capacity:       6.00 MiB
Allocation:     1.00 MiB

3) Resize the vol to 7M without --allocate. I.E. The new 1M capacity
   (6M - 7M) is sparse.
% ./tools/virsh vol-resize /var/lib/libvirt/images/sparse.raw 7M
Size of volume 'sparse.raw' successfully changed to 7M

%s ./tools/virsh vol-info /var/lib/libvirt/images/sparse.raw
Name:           sparse.raw
Type:           file
Capacity:       7.00 MiB
Allocation:     1.00 MiB

3) Resize the vol to 8M with --allocate, I.E. The new 1 M capacity
   (7M - 8M) is preallocated

% ./tools/virsh vol-resize /var/lib/libvirt/images/sparse.raw 8M --allocate
Size of volume 'sparse.raw' successfully changed to 8M

% ./tools/virsh vol-info /var/lib/libvirt/images/sparse.raw
Name:           sparse.raw
Type:           file
Capacity:       8.00 MiB
Allocation:     2.00 MiB

======
  Now the parse file's allocation is like:

  0                             5           6         7           8
  -----------------------------------------------------------------
  |          zero               | allocated |   zero  | allocated |
  -----------------------------------------------------------------

%s ./tools/virsh vol-resize /var/lib/libvirt/images/sparse.raw 6M --shrink
Size of volume 'sparse.raw' successfully changed to 6M

%s ./tools/virsh vol-info /var/lib/libvirt/images/sparse.raw
Name:           sparse.raw
Type:           file
Capacity:       6.00 MiB
Allocation:     1.00 MiB

=====
  The vol still get 1M preallocate space kept, expected.

Osier Yang (3):
  storage: Support preallocate the new capacity for vol-resize
  storage: Forbid to shrink the vol's capacity if no --shrink is
    specified
  storage: Allow --shrink for raw type volume of fs pool

 src/storage/storage_backend_fs.c | 22 ++++++++++++++++++----
 src/storage/storage_driver.c     | 12 +++++++++++-
 src/util/virstoragefile.c        | 39 ++++++++++++++++++++++++++++++++++++---
 src/util/virstoragefile.h        |  6 +++++-
 4 files changed, 70 insertions(+), 9 deletions(-)

-- 
1.8.1.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]