Skip to content

Commit ed8184a

Browse files
author
Marcus Sorensen
committed
CLOUDSTACK-8263: KVM - notify qemu process of resized volume for libvirt-resized storage
Change-Id: Iddd8bb068855d3565075d3ecf7c6c0f074d00e1a
1 parent e768d70 commit ed8184a

2 files changed

Lines changed: 19 additions & 11 deletions

File tree

plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,6 +1852,7 @@ public Answer execute(ResizeVolumeCommand cmd) {
18521852
String vmInstanceName = cmd.getInstanceName();
18531853
boolean shrinkOk = cmd.getShrinkOk();
18541854
StorageFilerTO spool = cmd.getPool();
1855+
final String notifyOnlyType = "NOTIFYONLY";
18551856

18561857
if ( currentSize == newSize) {
18571858
// nothing to do
@@ -1893,21 +1894,25 @@ public Answer execute(ResizeVolumeCommand cmd) {
18931894
}
18941895

18951896
v.resize(newSize, flags);
1897+
type = notifyOnlyType;
18961898
} catch (LibvirtException e) {
18971899
return new ResizeVolumeAnswer(cmd, false, e.toString());
18981900
}
1899-
} else {
1900-
s_logger.debug("Volume " + path + " is of the type LVM and can not be resized using libvirt. Invoking resize script.");
1901-
final Script resizecmd = new Script(_resizeVolumePath, _cmdsTimeout, s_logger);
1902-
resizecmd.add("-s", String.valueOf(newSize));
1903-
resizecmd.add("-c", String.valueOf(currentSize));
1904-
resizecmd.add("-p", path);
1905-
resizecmd.add("-t", type);
1906-
resizecmd.add("-r", String.valueOf(shrinkOk));
1907-
resizecmd.add("-v", vmInstanceName);
1908-
String result = resizecmd.execute();
1901+
}
1902+
s_logger.debug("Invoking resize script to handle type " + type);
1903+
final Script resizecmd = new Script(_resizeVolumePath, _cmdsTimeout, s_logger);
1904+
resizecmd.add("-s", String.valueOf(newSize));
1905+
resizecmd.add("-c", String.valueOf(currentSize));
1906+
resizecmd.add("-p", path);
1907+
resizecmd.add("-t", type);
1908+
resizecmd.add("-r", String.valueOf(shrinkOk));
1909+
resizecmd.add("-v", vmInstanceName);
1910+
String result = resizecmd.execute();
19091911

1910-
if (result != null) {
1912+
if (result != null) {
1913+
if(type.equals(notifyOnlyType)) {
1914+
return new ResizeVolumeAnswer(cmd, true, "Resize succeeded, but need reboot to notify guest");
1915+
} else {
19111916
return new ResizeVolumeAnswer(cmd, false, result);
19121917
}
19131918
}

scripts/storage/qcow2/resizevolume.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ then
245245
elif [ "$ptype" == "QCOW2" ]
246246
then
247247
resizeqcow2
248+
elif [ "$ptype" == "NOTIFYONLY" ]
249+
then
250+
notifyqemu
248251
else
249252
echo "unsupported type $ptype"
250253
exit 1;

0 commit comments

Comments
 (0)