CLOUDSTACK-8263: KVM - notify qemu process of resized volume for 
libvirt-resized storage

Change-Id: Iddd8bb068855d3565075d3ecf7c6c0f074d00e1a


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ed8184a5
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ed8184a5
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ed8184a5

Branch: refs/heads/hotfix/scp-exception
Commit: ed8184a5b2cf575e015581d6b4c08ea9118d34aa
Parents: e768d70
Author: Marcus Sorensen <marcus_soren...@apple.com>
Authored: Tue Feb 17 14:25:55 2015 -0800
Committer: Marcus Sorensen <marcus_soren...@apple.com>
Committed: Tue Feb 17 14:25:55 2015 -0800

----------------------------------------------------------------------
 .../kvm/resource/LibvirtComputingResource.java  | 27 ++++++++++++--------
 scripts/storage/qcow2/resizevolume.sh           |  3 +++
 2 files changed, 19 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ed8184a5/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------
diff --git 
a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
 
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index 6783079..c6603f5 100644
--- 
a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ 
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -1852,6 +1852,7 @@ public class LibvirtComputingResource extends 
ServerResourceBase implements Serv
         String vmInstanceName = cmd.getInstanceName();
         boolean shrinkOk = cmd.getShrinkOk();
         StorageFilerTO spool = cmd.getPool();
+        final String notifyOnlyType = "NOTIFYONLY";
 
         if ( currentSize == newSize) {
             // nothing to do
@@ -1893,21 +1894,25 @@ public class LibvirtComputingResource extends 
ServerResourceBase implements Serv
                     }
 
                     v.resize(newSize, flags);
+                    type = notifyOnlyType;
                 } catch (LibvirtException e) {
                     return new ResizeVolumeAnswer(cmd, false, e.toString());
                 }
-            } else {
-                s_logger.debug("Volume " + path + " is of the type LVM and can 
not be resized using libvirt. Invoking resize script.");
-                final Script resizecmd = new Script(_resizeVolumePath, 
_cmdsTimeout, s_logger);
-                resizecmd.add("-s", String.valueOf(newSize));
-                resizecmd.add("-c", String.valueOf(currentSize));
-                resizecmd.add("-p", path);
-                resizecmd.add("-t", type);
-                resizecmd.add("-r", String.valueOf(shrinkOk));
-                resizecmd.add("-v", vmInstanceName);
-                String result = resizecmd.execute();
+            }
+            s_logger.debug("Invoking resize script to handle type " + type);
+            final Script resizecmd = new Script(_resizeVolumePath, 
_cmdsTimeout, s_logger);
+            resizecmd.add("-s", String.valueOf(newSize));
+            resizecmd.add("-c", String.valueOf(currentSize));
+            resizecmd.add("-p", path);
+            resizecmd.add("-t", type);
+            resizecmd.add("-r", String.valueOf(shrinkOk));
+            resizecmd.add("-v", vmInstanceName);
+            String result = resizecmd.execute();
 
-                if (result != null) {
+            if (result != null) {
+                if(type.equals(notifyOnlyType)) {
+                    return new ResizeVolumeAnswer(cmd, true, "Resize 
succeeded, but need reboot to notify guest");
+                } else {
                     return new ResizeVolumeAnswer(cmd, false, result);
                 }
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ed8184a5/scripts/storage/qcow2/resizevolume.sh
----------------------------------------------------------------------
diff --git a/scripts/storage/qcow2/resizevolume.sh 
b/scripts/storage/qcow2/resizevolume.sh
index 6a5c91d..bc763d0 100755
--- a/scripts/storage/qcow2/resizevolume.sh
+++ b/scripts/storage/qcow2/resizevolume.sh
@@ -245,6 +245,9 @@ then
 elif [ "$ptype" == "QCOW2" ]
 then
   resizeqcow2
+elif [ "$ptype" == "NOTIFYONLY" ]
+then
+  notifyqemu
 else
   echo "unsupported type $ptype"
   exit 1;

Reply via email to