Martin Betak has uploaded a new change for review.

Change subject: engine: Enable per-VM configuration of migration downtime
......................................................................

engine: Enable per-VM configuration of migration downtime

Added migration_downtime field to vm_static table and
Integer migrationDowntime property to VmBase representing
maximum number of milliseconds for downtime during live migration.

In case this value is null the new ConfigValue
DefaultMaximumMigrationDowntime value is used.

In case either the vm field or the aforementioned default value is "0"
(integer zero) no value will be sent to VDSM and effectively the default
VDSM behavior will be enacted.

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1055434
Change-Id: Ia16f66540497d20178efae6989710000110a81d6
Signed-off-by: Martin Betak <mbe...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBase.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmTemplate.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/ConfigurationValues.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/MigrateVDSCommandParameters.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/AbstractVmRowMapper.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAODbFacadeImpl.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmStaticDAODbFacadeImpl.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java
M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
M backend/manager/modules/dal/src/test/resources/fixtures.xml
M 
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfReader.java
M 
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfWriter.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/MigrateBrokerVDSCommand.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
M packaging/dbscripts/create_views.sql
A packaging/dbscripts/upgrade/03_04_0480_add_vm_migration_downtime.sql
M packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
M packaging/dbscripts/vm_templates_sp.sql
M packaging/dbscripts/vms_sp.sql
M packaging/etc/engine-config/engine-config.properties
24 files changed, 143 insertions(+), 27 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/33/23433/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java
index df710f9..938ee9e 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java
@@ -462,7 +462,8 @@
                         getParameters().getMasterVm().getDedicatedVmForVds(),
                         getParameters().getMasterVm().getMigrationSupport(),
                         
getParameters().getMasterVm().isAllowConsoleReconnect(),
-                        getParameters().getMasterVm().getIsoPath()));
+                        getParameters().getMasterVm().getIsoPath(),
+                        getParameters().getMasterVm().getMigrationDowntime()));
         DbFacade.getInstance().getVmTemplateDao().save(getVmTemplate());
         getCompensationContext().snapshotNewEntity(getVmTemplate());
         setActionReturnValue(getVmTemplate().getId());
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java
index ee07419..d51644e 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java
@@ -23,6 +23,8 @@
 import org.ovirt.engine.core.common.businessentities.network.InterfaceStatus;
 import org.ovirt.engine.core.common.businessentities.network.Network;
 import 
org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface;
+import org.ovirt.engine.core.common.config.Config;
+import org.ovirt.engine.core.common.config.ConfigValues;
 import org.ovirt.engine.core.common.errors.VdcBLLException;
 import org.ovirt.engine.core.common.errors.VdcBllErrors;
 import org.ovirt.engine.core.common.errors.VdcBllMessages;
@@ -166,7 +168,16 @@
                 getDestinationVds().getPort());
 
         return new MigrateVDSCommandParameters(getVdsId(), getVmId(), 
srcVdsHost, vdsDestinationId,
-                dstVdsHost, MigrationMethod.ONLINE, isTunnelMigrationUsed(), 
getMigrationNetworkIp(), getVds().getVdsGroupCompatibilityVersion());
+                dstVdsHost, MigrationMethod.ONLINE, isTunnelMigrationUsed(), 
getMigrationNetworkIp(), getVds().getVdsGroupCompatibilityVersion(),
+                getMaximumMigrationDowntime());
+    }
+
+    private int getMaximumMigrationDowntime() {
+        if (getVm().getMigrationDowntime() != null) {
+            return getVm().getMigrationDowntime();
+        }
+
+        return Config.getValue(ConfigValues.DefaultMaximumMigrationDowntime);
     }
 
     private boolean isTunnelMigrationUsed() {
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java
index 22fab64..51d885f 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java
@@ -1675,4 +1675,12 @@
         getDiskList().clear();
         getDiskMap().clear();
     }
+
+    public void setMigrationDowntime(Integer migrationDowntime) {
+        vmStatic.setMigrationDowntime(migrationDowntime);
+    }
+
+    public Integer getMigrationDowntime() {
+        return vmStatic.getMigrationDowntime();
+    }
 }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBase.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBase.java
index 6167007..b56f729 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBase.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBase.java
@@ -6,6 +6,7 @@
 import java.util.List;
 import java.util.Map;
 
+import javax.validation.constraints.Min;
 import javax.validation.constraints.Pattern;
 import javax.validation.constraints.Size;
 
@@ -181,6 +182,17 @@
     // not persisted to db
     private Date exportDate;
 
+    /**
+     * Maximum allowed downtime for live migration in milliseconds.
+     * Value of null indicates that the {@link 
ConfigValues.DefaultMaximumMigrationDowntime} value will be used.
+     *
+     * Special value of 0 for migration downtime specifies that no value will 
be sent to VDSM and the default
+     * VDSM behavior will be used.
+     */
+    @EditableField
+    @Min(value = 0, message = "VALIDATION.VM.MIGRATION_DOWNTIME_RANGE")
+    private Integer migrationDowntime;
+
     public VmBase() {
         name = "";
         interfaces = new ArrayList<VmNetworkInterface>();
@@ -286,7 +298,8 @@
                 vmBase.getMigrationSupport(),
                 vmBase.isAllowConsoleReconnect(),
                 vmBase.getDedicatedVmForVds(),
-                vmBase.getDefaultDisplayType());
+                vmBase.getDefaultDisplayType(),
+                vmBase.getMigrationDowntime());
     }
 
     public VmBase(
@@ -330,7 +343,8 @@
             MigrationSupport migrationSupport,
             boolean allowConsoleReconnect,
             Guid dedicatedVmForVds,
-            DisplayType defaultDisplayType) {
+            DisplayType defaultDisplayType,
+            Integer migrationDowntime) {
         this();
         this.name = name;
         this.id = id;
@@ -373,6 +387,7 @@
         this.migrationSupport = migrationSupport;
         this.allowConsoleReconnect = allowConsoleReconnect;
         this.dedicatedVmForVds = dedicatedVmForVds;
+        this.migrationDowntime = migrationDowntime;
     }
 
     public long getDbGeneration() {
@@ -716,6 +731,7 @@
         result = prime * result + ((vncKeyboardLayout == null) ? 0 : 
vncKeyboardLayout.hashCode());
         result = prime * result + ((createdByUserId == null) ? 0 : 
createdByUserId.hashCode());
         result = prime * result + ((defaultDisplayType == null) ? 0 : 
defaultDisplayType.hashCode());
+        result = prime * result + ((migrationDowntime == null) ? 0 : 
migrationDowntime.hashCode());
         return result;
     }
 
@@ -765,7 +781,8 @@
                 && ObjectUtils.objectsEqual(tunnelMigration, 
other.tunnelMigration)
                 && ObjectUtils.objectsEqual(vncKeyboardLayout, 
other.vncKeyboardLayout)
                 && ObjectUtils.objectsEqual(createdByUserId, 
other.createdByUserId)
-                && cpuShares == other.cpuShares);
+                && cpuShares == other.cpuShares
+                && ObjectUtils.objectsEqual(migrationDowntime, 
other.migrationDowntime));
     }
 
     public Guid getQuotaId() {
@@ -888,4 +905,12 @@
     public void setSsoMethod(SsoMethod ssoMethod) {
         this.ssoMethod = ssoMethod;
     }
+
+    public void setMigrationDowntime(Integer migrationDowntime) {
+        this.migrationDowntime = migrationDowntime;
+    }
+
+    public Integer getMigrationDowntime() {
+        return this.migrationDowntime;
+    }
 }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmTemplate.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmTemplate.java
index 81a2f39..3631348 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmTemplate.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmTemplate.java
@@ -64,7 +64,7 @@
             int minAllocatedMem, boolean stateless, boolean runAndPause, Guid 
createdByUserId, VmEntityType templateType,
             boolean autoStartup, int priority, DisplayType defaultDisplayType, 
String initrdUrl, String kernelUrl,
             String kernelParams, Guid quotaId, Guid dedicatedVmForVds, 
MigrationSupport migrationSupport,
-            boolean allowConsoleReconnect, String isoPath) {
+            boolean allowConsoleReconnect, String isoPath, Integer 
migrationDowntime) {
         super(name,
                 vmtGuid,
                 vdsGroupId,
@@ -105,7 +105,8 @@
                 migrationSupport,
                 allowConsoleReconnect,
                 dedicatedVmForVds,
-                defaultDisplayType);
+                defaultDisplayType,
+                migrationDowntime);
 
         diskTemplateMap = new HashMap<Guid, DiskImage>();
         diskImageMap = new HashMap<Guid, DiskImage>();
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
index 0a223c9..1aab2da 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
@@ -1606,5 +1606,14 @@
     @DefaultValueAttribute("10")
     MaxNumOfTriesToRunFailedAutoStartVm,
 
+    /**
+     * Value representing maximum number of milliseconds a VM can be down 
during live migration.
+     * Default value of 0 means this value will not be sent to VDSM at all and 
the currently configured value on
+     * the VDSM will be used.
+     */
+    @TypeConverterAttribute(Integer.class)
+    @DefaultValueAttribute("0")
+    DefaultMaximumMigrationDowntime,
+
     Invalid;
 }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/ConfigurationValues.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/ConfigurationValues.java
index cd8fdd0..50244f6 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/ConfigurationValues.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/ConfigurationValues.java
@@ -112,7 +112,8 @@
     SpeedOptimizationSchedulingThreshold,
     SchedulerAllowOverBooking,
     SchedulerOverBookingThreshold,
-    UserSessionTimeOutInterval(ConfigAuthType.User);
+    UserSessionTimeOutInterval(ConfigAuthType.User),
+    DefaultMaximumMigrationDowntime;
 
     public static enum ConfigAuthType {
         Admin,
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/MigrateVDSCommandParameters.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/MigrateVDSCommandParameters.java
index 49c4d85..a6254ee 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/MigrateVDSCommandParameters.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/MigrateVDSCommandParameters.java
@@ -12,9 +12,10 @@
     private boolean tunnelMigration;
     private String dstQemu;
     private Version clusterVersion;
+    private Integer migrationDowntime;
 
     public MigrateVDSCommandParameters(Guid vdsId, Guid vmId, String srcHost, 
Guid dstVdsId, String dstHost,
-            MigrationMethod migrationMethod, boolean tunnelMigration, String 
dstQemu, Version clusterVersion) {
+            MigrationMethod migrationMethod, boolean tunnelMigration, String 
dstQemu, Version clusterVersion, int migrationDowntime) {
         super(vdsId, vmId);
         _srcHost = srcHost;
         _dstVdsId = dstVdsId;
@@ -23,6 +24,7 @@
         this.tunnelMigration = tunnelMigration;
         this.dstQemu = dstQemu;
         this.clusterVersion = clusterVersion;
+        this.migrationDowntime = migrationDowntime;
     }
 
     public String getSrcHost() {
@@ -49,19 +51,24 @@
         return dstQemu;
     }
 
+    public int getMigrationDowntime() {
+        return migrationDowntime;
+    }
+
     public MigrateVDSCommandParameters() {
         _migrationMethod = MigrationMethod.OFFLINE;
     }
 
     @Override
     public String toString() {
-        return String.format("%s, srcHost=%s, dstVdsId=%s, dstHost=%s, 
migrationMethod=%s, tunnelMigration=%s",
+        return String.format("%s, srcHost=%s, dstVdsId=%s, dstHost=%s, 
migrationMethod=%s, tunnelMigration=%s, migrationDowntime=%s",
                 super.toString(),
                 getSrcHost(),
                 getDstVdsId(),
                 getDstHost(),
                 getMigrationMethod(),
-                isTunnelMigration());
+                isTunnelMigration(),
+                getMigrationDowntime());
     }
 
     public void setClusterVersion(Version clusterVersion) {
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/AbstractVmRowMapper.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/AbstractVmRowMapper.java
index bf110a6..a1b8076 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/AbstractVmRowMapper.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/AbstractVmRowMapper.java
@@ -48,6 +48,7 @@
         entity.setVncKeyboardLayout(rs.getString("vnc_keyboard_layout"));
         entity.setRunAndPause(rs.getBoolean("is_run_and_pause"));
         
entity.setCreatedByUserId(Guid.createGuidFromString(rs.getString("created_by_user_id")));
+        entity.setMigrationDowntime((Integer) 
rs.getObject("migration_downtime"));
     }
 
 }
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAODbFacadeImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAODbFacadeImpl.java
index 79ddf7b..15e897f 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAODbFacadeImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAODbFacadeImpl.java
@@ -408,6 +408,7 @@
             entity.setOriginalTemplateGuid(getGuid(rs, 
"original_template_id"));
             entity.setVmPoolSpiceProxy(rs.getString("vm_pool_spice_proxy"));
             
entity.setVdsGroupSpiceProxy(rs.getString("vds_group_spice_proxy"));
+            entity.setMigrationDowntime((Integer) 
rs.getObject("migration_downtime"));
             return entity;
         }
     }
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmStaticDAODbFacadeImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmStaticDAODbFacadeImpl.java
index c4779ad..cad46a9 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmStaticDAODbFacadeImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmStaticDAODbFacadeImpl.java
@@ -94,7 +94,8 @@
                 .addValue("instance_type_id", vm.getInstanceTypeId())
                 .addValue("image_type_id", vm.getImageTypeId())
                 .addValue("original_template_name", 
vm.getOriginalTemplateName())
-                .addValue("original_template_id", 
vm.getOriginalTemplateGuid());
+                .addValue("original_template_id", vm.getOriginalTemplateGuid())
+                .addValue("migration_downtime", vm.getMigrationDowntime());
     }
 
     @Override
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java
index 3904451..3f20185 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java
@@ -192,7 +192,8 @@
                 .addValue("min_allocated_mem", template.getMinAllocatedMem())
                 .addValue("is_run_and_pause", template.isRunAndPause())
                 .addValue("created_by_user_id", template.getCreatedByUserId())
-                .addValue("template_type", template.getTemplateType().name());
+                .addValue("template_type", template.getTemplateType().name())
+                .addValue("migration_downtime", 
template.getMigrationDowntime());
     }
 
     @Override
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
index 427b174..ede6ab1 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -772,6 +772,7 @@
 VALIDATION.REPETITIVE.IP.IN.VDS=Invalid list of interfaces, two or more 
network interfaces have the same IP.
 VALIDATION.VDS.PORT.RANGE=The Port number must be between 1 and 65535.
 VALIDATION.VM.INVALID_KEYBOARD_LAYOUT=Invalid keyboard layout
+VALIDATION.VM.MIGRATION_DOWNTIME_RANGE=Migration downtime must be between 0 
and 2147483647 milliseconds.
 ERROR_CANNOT_FIND_ISO_IMAGE_PATH=Invalid ISO image path
 ERROR_CANNOT_FIND_FLOPPY_IMAGE_PATH=Invalid Floppy image path
 VDS_ADD_STORAGE_SERVER_STATUS_MUST_BE_UP=Cannot add storage server connection 
when Host status is not up
diff --git a/backend/manager/modules/dal/src/test/resources/fixtures.xml 
b/backend/manager/modules/dal/src/test/resources/fixtures.xml
index f966c3a..5d62c7d 100644
--- a/backend/manager/modules/dal/src/test/resources/fixtures.xml
+++ b/backend/manager/modules/dal/src/test/resources/fixtures.xml
@@ -1525,6 +1525,7 @@
         <column>sso_method</column>
         <column>original_template_id</column>
         <column>original_template_name</column>
+        <column>migration_downtime</column>
         <!-- Templates -->
         <row>
             <value>00000000-0000-0000-0000-000000000000</value>
@@ -1576,6 +1577,7 @@
             <value>guest_agent</value>
             <null />
             <null />
+            <value>123</value>
         </row>
         <row>
             <value>1b85420c-b84c-4f29-997e-0eb674b40b79</value>
@@ -1627,6 +1629,7 @@
             <value>none</value>
             <null />
             <null />
+            <value>0</value>
         </row>
         <row>
             <value>1b85420c-b84c-4f29-997e-0eb674b40b80</value>
@@ -1676,6 +1679,7 @@
             <null />
             <null />
             <value>guest_agent</value>
+            <null />
             <null />
             <null />
         </row>
@@ -1729,6 +1733,7 @@
             <value>none</value>
             <null />
             <null />
+            <value>500</value>
         </row>
          <row>
             <value>1b85420c-b84c-4f29-997e-0eb674b40b82</value>
@@ -1778,6 +1783,7 @@
             <null />
             <null />
             <value>guest_agent</value>
+            <null />
             <null />
             <null />
         </row>
@@ -1831,6 +1837,7 @@
             <value>none</value>
             <null />
             <null />
+            <null />
         </row>
          <row>
             <value>5849b030-626e-47cb-ad90-3ce782d831b3</value>
@@ -1880,6 +1887,7 @@
             <null />
             <null />
             <value>none</value>
+            <null />
             <null />
             <null />
         </row>
@@ -1935,6 +1943,7 @@
             <value>none</value>
             <value>1b85420c-b84c-4f29-997e-0eb674b40b82</value>
             <value>someTemplateName</value>
+            <value>1234</value>
         </row>
         <row>
             <value>77296e00-0cad-4e5a-9299-008a7b6f4355</value>
@@ -1986,6 +1995,7 @@
             <value>none</value>
             <value>1b85420c-b84c-4f29-997e-0eb674b40b82</value>
             <value>someTemplateName</value>
+            <null />
         </row>
         <row>
             <value>77296e00-0cad-4e5a-9299-008a7b6f4356</value>
@@ -2037,6 +2047,7 @@
             <value>guest_agent</value>
             <value>1b85420c-b84c-4f29-997e-0eb674b40b82</value>
             <value>someTemplateName</value>
+            <null />
         </row>
         <row>
             <value>77296e00-0cad-4e5a-9299-008a7b6f4357</value>
@@ -2086,6 +2097,7 @@
             <null />
             <null />
             <value>none</value>
+            <null />
             <null />
             <null />
         </row>
@@ -2139,6 +2151,7 @@
             <value>none</value>
             <value>1b85420c-b84c-4f29-997e-0eb674b40b81</value>
             <value>otherTemplateName</value>
+            <null />
         </row>
         <row>
             <value>77296e00-0cad-4e5a-9299-008a7b6f4360</value>
diff --git 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfReader.java
 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfReader.java
index 690bb09..f1e4159 100644
--- 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfReader.java
+++ 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfReader.java
@@ -499,6 +499,13 @@
             }
         }
 
+        node = content.SelectSingleNode("MigrationDowntime");
+        if (node != null) {
+            if (StringUtils.isNotEmpty(node.innerText)) {
+                vmBase.setMigrationDowntime(Integer.parseInt(node.innerText));
+            }
+        }
+
         readGeneralData(content);
     }
 
diff --git 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfWriter.java
 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfWriter.java
index 80604d7..1ea9dda 100644
--- 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfWriter.java
+++ 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfWriter.java
@@ -281,6 +281,12 @@
             _writer.WriteRaw(String.valueOf(vmBase.getCreatedByUserId()));
             _writer.WriteEndElement();
         }
+
+        if (vmBase.getMigrationDowntime() != null) {
+            _writer.WriteStartElement("MigrationDowntime");
+            _writer.WriteRaw(String.valueOf(vmBase.getMigrationDowntime()));
+            _writer.WriteEndElement();
+        }
     }
 
     protected abstract void writeAppList();
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/MigrateBrokerVDSCommand.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/MigrateBrokerVDSCommand.java
index 6b27d20..3ad43a4 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/MigrateBrokerVDSCommand.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/MigrateBrokerVDSCommand.java
@@ -33,6 +33,10 @@
         if (Config.<Boolean> getValue(ConfigValues.AbortMigrationOnError, 
parameters.getClusterVersion().getValue())) {
             migrationInfo.put("abortOnError", Boolean.TRUE.toString());
         }
+
+        if (parameters.getMigrationDowntime() != 0) {
+            migrationInfo.put(VdsProperties.MIGRATION_DOWNTIME, 
Integer.toString(parameters.getMigrationDowntime()));
+        }
     }
 
     @Override
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
index 5560cfe..423e9bc 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
@@ -291,6 +291,7 @@
     public static final String hooks = "hooks";
     public static final String TUNNELED = "tunneled";
     public static final String DST_QEMU = "dstqemu";
+    public static final String MIGRATION_DOWNTIME = "downtime";
 
     // storage domains
     public static final String code = "code";
diff --git a/packaging/dbscripts/create_views.sql 
b/packaging/dbscripts/create_views.sql
index 92f82fc..cc77956 100644
--- a/packaging/dbscripts/create_views.sql
+++ b/packaging/dbscripts/create_views.sql
@@ -405,6 +405,7 @@
        vm_templates.is_run_and_pause as is_run_and_pause,
        vm_templates.created_by_user_id as created_by_user_id,
        vm_templates.entity_type,
+       vm_templates.migration_downtime as migration_downtime,
        vds_groups.architecture as architecture
 FROM       vm_static AS vm_templates  INNER JOIN
 vds_groups ON vm_templates.vds_group_id = vds_groups.vds_group_id
@@ -437,6 +438,7 @@
                          vm_templates.is_stateless, vm_templates.iso_path, 
vm_templates.origin, vm_templates.initrd_url, vm_templates.kernel_url,
                          vm_templates.kernel_params, 
image_storage_domain_map.storage_domain_id AS storage_id,
                     quota.quota_name as quota_name, vm_templates.is_disabled, 
vm_templates.min_allocated_mem, vm_templates.is_run_and_pause, 
vm_templates.created_by_user_id,
+                    vm_templates.migration_downtime,
                     vm_templates.entity_type, vds_groups.architecture
 FROM                  vm_static AS vm_templates INNER JOIN
                          vds_groups ON vm_templates.vds_group_id = 
vds_groups.vds_group_id LEFT OUTER JOIN
@@ -458,6 +460,7 @@
                       vm_templates_1.initrd_url, vm_templates_1.kernel_url, 
vm_templates_1.kernel_params,
                       image_storage_domain_map.storage_domain_id AS storage_id,
                       quota.quota_name as quota_name, 
vm_templates_1.is_disabled, vm_templates_1.min_allocated_mem, 
vm_templates_1.is_run_and_pause, vm_templates_1.created_by_user_id,
+                      vm_templates_1.migration_downtime,
                       vm_templates_1.entity_type, vds_groups_1.architecture
 FROM                  vm_static AS vm_templates_1 INNER JOIN
                       vds_groups AS vds_groups_1 ON 
vm_templates_1.vds_group_id = vds_groups_1.vds_group_id LEFT OUTER JOIN
@@ -599,7 +602,8 @@
                       vm_static.initrd_url as initrd_url, vm_static.kernel_url 
as kernel_url, vm_static.kernel_params as kernel_params, 
vm_dynamic.pause_status as pause_status, vm_dynamic.exit_message as 
exit_message, vm_dynamic.exit_status as exit_status,vm_static.migration_support 
as migration_support,vm_static.predefined_properties as 
predefined_properties,vm_static.userdefined_properties as 
userdefined_properties,vm_static.min_allocated_mem as min_allocated_mem,  
vm_dynamic.hash as hash, vm_static.cpu_pinning as cpu_pinning, 
vm_static.db_generation as db_generation, vm_static.host_cpu_flags as 
host_cpu_flags,
                       vm_static.tunnel_migration as tunnel_migration, 
vm_static.vnc_keyboard_layout as vnc_keyboard_layout, 
vm_static.is_run_and_pause as is_run_and_pause, vm_static.created_by_user_id as 
created_by_user_id,
                       vm_dynamic.last_watchdog_event as last_watchdog_event, 
vm_dynamic.last_watchdog_action as last_watchdog_action, vm_dynamic.is_run_once 
as is_run_once, vm_dynamic.vm_fqdn as vm_fqdn, vm_dynamic.cpu_name as cpu_name,
-                      vm_static.instance_type_id as instance_type_id, 
vm_static.image_type_id as image_type_id, vds_groups.architecture as 
architecture, vm_static.original_template_id as original_template_id, 
vm_static.original_template_name as original_template_name, 
vm_dynamic.last_stop_time as last_stop_time
+                      vm_static.instance_type_id as instance_type_id, 
vm_static.image_type_id as image_type_id, vds_groups.architecture as 
architecture, vm_static.original_template_id as original_template_id, 
vm_static.original_template_name as original_template_name, 
vm_dynamic.last_stop_time as last_stop_time,
+                      vm_static.migration_downtime as migration_downtime
 FROM         vm_static INNER JOIN
 vm_dynamic ON vm_static.vm_guid = vm_dynamic.vm_guid INNER JOIN
 vm_static AS vm_templates ON vm_static.vmt_guid = vm_templates.vm_guid INNER 
JOIN
@@ -638,7 +642,8 @@
             vms.quota_id as quota_id, vms.quota_name as quota_name, 
vms.tunnel_migration as tunnel_migration,
             vms.vnc_keyboard_layout as vnc_keyboard_layout, 
vms.is_run_and_pause as is_run_and_pause, vms.created_by_user_id as 
created_by_user_id, vms.vm_fqdn, vms.cpu_name as cpu_name,
             vms.vm_pool_spice_proxy as vm_pool_spice_proxy, 
vms.vds_group_spice_proxy as vds_group_spice_proxy,
-            vms.instance_type_id as instance_type_id, vms.image_type_id as 
image_type_id, vms.architecture as architecture, vms.original_template_id as 
original_template_id, vms.original_template_name as original_template_name
+            vms.instance_type_id as instance_type_id, vms.image_type_id as 
image_type_id, vms.architecture as architecture, vms.original_template_id as 
original_template_id, vms.original_template_name as original_template_name,
+            vms.migration_downtime as migration_downtime
 FROM        vms LEFT OUTER JOIN
             tags_vm_map_view ON vms.vm_guid = tags_vm_map_view.vm_id LEFT 
OUTER JOIN
             vm_device ON vm_device.vm_id = vms.vm_guid LEFT OUTER JOIN
diff --git 
a/packaging/dbscripts/upgrade/03_04_0480_add_vm_migration_downtime.sql 
b/packaging/dbscripts/upgrade/03_04_0480_add_vm_migration_downtime.sql
new file mode 100644
index 0000000..1b056c7
--- /dev/null
+++ b/packaging/dbscripts/upgrade/03_04_0480_add_vm_migration_downtime.sql
@@ -0,0 +1 @@
+select fn_db_add_column('vm_static', 'migration_downtime', 'integer default 
null');
diff --git a/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql 
b/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
index 531e7f7..5d85222 100644
--- a/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
+++ b/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
@@ -608,6 +608,8 @@
 select fn_db_add_config_value('EnableVdsHaReservation','true','general');
 select 
fn_db_add_config_value('VdsHaReservationIntervalInMinutes','5','general');
 
+select fn_db_add_config_value('DefaultMaximumMigrationDowntime','0','general');
+
 
------------------------------------------------------------------------------------
 --                  Update with override section
 
------------------------------------------------------------------------------------
diff --git a/packaging/dbscripts/vm_templates_sp.sql 
b/packaging/dbscripts/vm_templates_sp.sql
index 87b555d..ae99c98 100644
--- a/packaging/dbscripts/vm_templates_sp.sql
+++ b/packaging/dbscripts/vm_templates_sp.sql
@@ -51,7 +51,8 @@
  v_min_allocated_mem INTEGER,
  v_is_run_and_pause BOOLEAN,
  v_created_by_user_id UUID,
- v_template_type VARCHAR(40))
+ v_template_type VARCHAR(40),
+ v_migration_downtime INTEGER)
 
 RETURNS VOID
    AS $procedure$
@@ -103,7 +104,8 @@
     vnc_keyboard_layout,
     min_allocated_mem,
     is_run_and_pause,
-    created_by_user_id)
+    created_by_user_id,
+    migration_downtime)
 VALUES(
     -- This field is meaningless for templates for the time being, however we 
want to keep it not null for VMs.
     -- Thus, since templates are top level elements they "point" to the 
'Blank' template.
@@ -152,7 +154,8 @@
     v_vnc_keyboard_layout,
     v_min_allocated_mem,
     v_is_run_and_pause,
-    v_created_by_user_id);
+    v_created_by_user_id,
+    v_migration_downtime);
 -- perform deletion from vm_ovf_generations to ensure that no record exists 
when performing insert to avoid PK violation.
 DELETE FROM vm_ovf_generations gen WHERE gen.vm_guid = v_vmt_guid;
 INSERT INTO vm_ovf_generations(vm_guid, storage_pool_id)
@@ -210,7 +213,8 @@
  v_min_allocated_mem INTEGER,
  v_is_run_and_pause BOOLEAN,
  v_created_by_user_id UUID,
- v_template_type VARCHAR(40))
+ v_template_type VARCHAR(40),
+ v_migration_downtime INTEGER)
 RETURNS VOID
 
        --The [vm_templates] table doesn't have a timestamp column. Optimistic 
concurrency logic cannot be generated
@@ -233,7 +237,8 @@
       kernel_url = v_kernel_url,kernel_params = v_kernel_params, _update_date 
= CURRENT_TIMESTAMP, quota_id = v_quota_id,
       migration_support = v_migration_support, dedicated_vm_for_vds = 
v_dedicated_vm_for_vds, is_smartcard_enabled = v_is_smartcard_enabled,
       is_delete_protected = v_is_delete_protected, sso_method = v_sso_method, 
is_disabled = v_is_disabled, tunnel_migration = v_tunnel_migration,
-      vnc_keyboard_layout = v_vnc_keyboard_layout, min_allocated_mem = 
v_min_allocated_mem, is_run_and_pause = v_is_run_and_pause, created_by_user_id 
= v_created_by_user_id
+      vnc_keyboard_layout = v_vnc_keyboard_layout, min_allocated_mem = 
v_min_allocated_mem, is_run_and_pause = v_is_run_and_pause, created_by_user_id 
= v_created_by_user_id,
+      migration_downtime = v_migration_downtime
       WHERE vm_guid = v_vmt_guid
       AND   entity_type = v_template_type;
 END; $procedure$
diff --git a/packaging/dbscripts/vms_sp.sql b/packaging/dbscripts/vms_sp.sql
index 8ec1d02..3a3ac67 100644
--- a/packaging/dbscripts/vms_sp.sql
+++ b/packaging/dbscripts/vms_sp.sql
@@ -451,12 +451,13 @@
     v_instance_type_id UUID,
     v_image_type_id UUID,
     v_original_template_id UUID,
-    v_original_template_name VARCHAR(255))
+    v_original_template_name VARCHAR(255),
+    v_migration_downtime INTEGER)
 RETURNS VOID
    AS $procedure$
 BEGIN
-INSERT INTO vm_static(description, free_text_comment, mem_size_mb, os, 
vds_group_id, vm_guid, VM_NAME, vmt_guid,domain,creation_date,num_of_monitors, 
single_qxl_pci, 
allow_console_reconnect,is_initialized,num_of_sockets,cpu_per_socket,usb_policy,
 time_zone,auto_startup,is_stateless,dedicated_vm_for_vds, fail_back, 
default_boot_sequence, vm_type, nice_level, cpu_shares, default_display_type, 
priority,iso_path,origin,initrd_url,kernel_url,kernel_params,migration_support,predefined_properties,userdefined_properties,min_allocated_mem,
 entity_type, quota_id, cpu_pinning, is_smartcard_enabled,is_delete_protected, 
sso_method, host_cpu_flags, tunnel_migration, vnc_keyboard_layout, 
is_run_and_pause, created_by_user_id, instance_type_id, image_type_id, 
original_template_id, original_template_name)
-       VALUES(v_description, v_free_text_comment, v_mem_size_mb, v_os, 
v_vds_group_id, v_vm_guid, v_vm_name, v_vmt_guid, v_domain, v_creation_date, 
v_num_of_monitors,v_single_qxl_pci, v_allow_console_reconnect, 
v_is_initialized, v_num_of_sockets, v_cpu_per_socket, v_usb_policy, 
v_time_zone, v_auto_startup,v_is_stateless,v_dedicated_vm_for_vds,v_fail_back, 
v_default_boot_sequence, v_vm_type, v_nice_level, v_cpu_shares, 
v_default_display_type, 
v_priority,v_iso_path,v_origin,v_initrd_url,v_kernel_url,v_kernel_params,v_migration_support,v_predefined_properties,v_userdefined_properties,v_min_allocated_mem,
 'VM', v_quota_id, v_cpu_pinning, v_is_smartcard_enabled,v_is_delete_protected, 
v_sso_method, v_host_cpu_flags, v_tunnel_migration, v_vnc_keyboard_layout, 
v_is_run_and_pause, v_created_by_user_id, v_instance_type_id, v_image_type_id, 
v_original_template_id, v_original_template_name);
+INSERT INTO vm_static(description, free_text_comment, mem_size_mb, os, 
vds_group_id, vm_guid, VM_NAME, vmt_guid,domain,creation_date,num_of_monitors, 
single_qxl_pci, 
allow_console_reconnect,is_initialized,num_of_sockets,cpu_per_socket,usb_policy,
 time_zone,auto_startup,is_stateless,dedicated_vm_for_vds, fail_back, 
default_boot_sequence, vm_type, nice_level, cpu_shares, default_display_type, 
priority,iso_path,origin,initrd_url,kernel_url,kernel_params,migration_support,predefined_properties,userdefined_properties,min_allocated_mem,
 entity_type, quota_id, cpu_pinning, is_smartcard_enabled,is_delete_protected, 
sso_method, host_cpu_flags, tunnel_migration, vnc_keyboard_layout, 
is_run_and_pause, created_by_user_id, instance_type_id, image_type_id, 
original_template_id, original_template_name, migration_downtime)
+       VALUES(v_description, v_free_text_comment, v_mem_size_mb, v_os, 
v_vds_group_id, v_vm_guid, v_vm_name, v_vmt_guid, v_domain, v_creation_date, 
v_num_of_monitors,v_single_qxl_pci, v_allow_console_reconnect, 
v_is_initialized, v_num_of_sockets, v_cpu_per_socket, v_usb_policy, 
v_time_zone, v_auto_startup,v_is_stateless,v_dedicated_vm_for_vds,v_fail_back, 
v_default_boot_sequence, v_vm_type, v_nice_level, v_cpu_shares, 
v_default_display_type, 
v_priority,v_iso_path,v_origin,v_initrd_url,v_kernel_url,v_kernel_params,v_migration_support,v_predefined_properties,v_userdefined_properties,v_min_allocated_mem,
 'VM', v_quota_id, v_cpu_pinning, v_is_smartcard_enabled,v_is_delete_protected, 
v_sso_method, v_host_cpu_flags, v_tunnel_migration, v_vnc_keyboard_layout, 
v_is_run_and_pause, v_created_by_user_id, v_instance_type_id, v_image_type_id, 
v_original_template_id, v_original_template_name, v_migration_downtime);
 -- perform deletion from vm_ovf_generations to ensure that no record exists 
when performing insert to avoid PK violation.
 DELETE FROM vm_ovf_generations gen WHERE gen.vm_guid = v_vm_guid;
 INSERT INTO vm_ovf_generations(vm_guid, storage_pool_id) VALUES (v_vm_guid, 
(SELECT storage_pool_id FROM vds_groups vg WHERE vg.vds_group_id = 
v_vds_group_id));
@@ -575,8 +576,8 @@
 v_instance_type_id UUID,
 v_image_type_id UUID,
 v_original_template_id UUID,
-v_original_template_name VARCHAR(255))
-
+v_original_template_name VARCHAR(255),
+v_migration_downtime INTEGER)
 RETURNS VOID
 
        --The [vm_static] table doesn't have a timestamp column. Optimistic 
concurrency logic cannot be generated
@@ -604,7 +605,8 @@
       is_delete_protected = v_is_delete_protected, sso_method = v_sso_method, 
host_cpu_flags = v_host_cpu_flags, tunnel_migration = v_tunnel_migration,
       vnc_keyboard_layout = v_vnc_keyboard_layout, is_run_and_pause = 
v_is_run_and_pause, created_by_user_id = v_created_by_user_id,
       instance_type_id = v_instance_type_id, image_type_id = v_image_type_id, 
original_template_id = v_original_template_id,
-      original_template_name = v_original_template_name
+      original_template_name = v_original_template_name,
+      migration_downtime = v_migration_downtime
       WHERE vm_guid = v_vm_guid
       AND   entity_type = 'VM';
 END; $procedure$
diff --git a/packaging/etc/engine-config/engine-config.properties 
b/packaging/etc/engine-config/engine-config.properties
index 414d839..0db499f 100644
--- a/packaging/etc/engine-config/engine-config.properties
+++ b/packaging/etc/engine-config/engine-config.properties
@@ -369,4 +369,6 @@
 HostsInReserve.type=Integer
 EnableAutomaticHostPowerManagement.description=Enable (true) or disable 
(false) automatic host power management
 EnableAutomaticHostPowerManagement.type=String
-
+DefaultMaximumMigrationDowntime.description="Maximum number of milliseconds 
the VM can be down during live migration. Value of 0 means that VDSM default 
will be used."
+DefaultMaximumMigrationDowntime.type=Integer
+DefaultMaximumMigrationDowntime.validValues=0..2147483647


-- 
To view, visit http://gerrit.ovirt.org/23433
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia16f66540497d20178efae6989710000110a81d6
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.4
Gerrit-Owner: Martin Betak <mbe...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to