Skip to content

Commit e8e5820

Browse files
João JandreJoaoJandre
authored andcommitted
KNIB
1 parent 608345d commit e8e5820

File tree

183 files changed

+10425
-720
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

183 files changed

+10425
-720
lines changed

agent/conf/agent.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,3 +457,7 @@ iscsi.session.cleanup.enabled=false
457457

458458
# Instance conversion VIRT_V2V_TMPDIR env var
459459
#convert.instance.env.virtv2v.tmpdir=
460+
461+
# Timeout (in seconds) for QCOW2 delta merge operations, mainly used for classic volume snapshots, disk-only VM snapshots on file-based storage, and the KNIB plugin.
462+
# If a value of 0 or less is informed, the default will be used.
463+
# qcow2.delta.merge.timeout=259200

agent/src/main/java/com/cloud/agent/properties/AgentProperties.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ public class AgentProperties{
156156
public static final Property<Integer> CMDS_TIMEOUT = new Property<>("cmds.timeout", 7200);
157157

158158
/**
159-
* The timeout (in seconds) for the snapshot merge operation, mainly used for classic volume snapshots and disk-only VM snapshots on file-based storage.<br>
159+
* The timeout (in seconds) for QCOW2 delta merge operations, mainly used for classic volume snapshots, disk-only VM snapshots on file-based storage, and the KNIB plugin.
160+
* If a value of 0 or less is informed, the default will be used.<br>
160161
* This configuration is only considered if libvirt.events.enabled is also true. <br>
161162
* Data type: Integer.<br>
162163
* Default value: <code>259200</code>

api/src/main/java/com/cloud/agent/api/to/DataObjectType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@
1919
package com.cloud.agent.api.to;
2020

2121
public enum DataObjectType {
22-
VOLUME, SNAPSHOT, TEMPLATE, ARCHIVE
22+
VOLUME, SNAPSHOT, TEMPLATE, ARCHIVE, BACKUP
2323
}

api/src/main/java/com/cloud/hypervisor/HypervisorGuru.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.Map;
2121

2222
import org.apache.cloudstack.backup.Backup;
23+
import org.apache.cloudstack.backup.BackupProvider;
2324
import org.apache.cloudstack.framework.config.ConfigKey;
2425

2526
import com.cloud.agent.api.Command;
@@ -94,10 +95,10 @@ public interface HypervisorGuru extends Adapter {
9495
Map<String, String> getClusterSettings(long vmId);
9596

9697
VirtualMachine importVirtualMachineFromBackup(long zoneId, long domainId, long accountId, long userId,
97-
String vmInternalName, Backup backup) throws Exception;
98+
String vmInternalName, Backup backup, BackupProvider backupProvider) throws Exception;
9899

99100
boolean attachRestoredVolumeToVirtualMachine(long zoneId, String location, Backup.VolumeInfo volumeInfo,
100-
VirtualMachine vm, long poolId, Backup backup) throws Exception;
101+
VirtualMachine vm, long poolId, Backup backup, BackupProvider backupProvider) throws Exception;
101102
/**
102103
* Will generate commands to migrate a vm to a pool. For now this will only work for stopped VMs on Vmware.
103104
*

api/src/main/java/com/cloud/storage/Volume.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ enum State {
6060
UploadError(false, "Volume upload encountered some error"),
6161
UploadAbandoned(false, "Volume upload is abandoned since the upload was never initiated within a specified time"),
6262
Attaching(true, "The volume is attaching to a VM from Ready state."),
63-
Restoring(true, "The volume is being restored from backup.");
63+
Restoring(true, "The volume is being restored from backup."),
64+
Consolidating(true, "The volume is being flattened."),
65+
RestoreError(false, "The volume restore encountered an error.");
6466

6567
boolean _transitional;
6668

@@ -153,6 +155,10 @@ public String getDescription() {
153155
s_fsm.addTransition(new StateMachine2.Transition<State, Event>(Destroy, Event.RestoreRequested, Restoring, null));
154156
s_fsm.addTransition(new StateMachine2.Transition<State, Event>(Restoring, Event.RestoreSucceeded, Ready, null));
155157
s_fsm.addTransition(new StateMachine2.Transition<State, Event>(Restoring, Event.RestoreFailed, Ready, null));
158+
s_fsm.addTransition(new StateMachine2.Transition<>(Ready, Event.ConsolidationRequested, Consolidating, null));
159+
s_fsm.addTransition(new StateMachine2.Transition<>(Consolidating, Event.OperationSucceeded, Ready, null));
160+
s_fsm.addTransition(new StateMachine2.Transition<>(Consolidating, Event.OperationFailed, RestoreError, null));
161+
s_fsm.addTransition(new StateMachine2.Transition<>(RestoreError, Event.RestoreFailed, RestoreError, null));
156162
}
157163
}
158164

@@ -179,7 +185,8 @@ enum Event {
179185
OperationTimeout,
180186
RestoreRequested,
181187
RestoreSucceeded,
182-
RestoreFailed;
188+
RestoreFailed,
189+
ConsolidationRequested
183190
}
184191

185192
/**

api/src/main/java/com/cloud/storage/VolumeApiService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public interface VolumeApiService {
107107

108108
Volume attachVolumeToVM(AttachVolumeCmd command);
109109

110-
Volume attachVolumeToVM(Long vmId, Long volumeId, Long deviceId, Boolean allowAttachForSharedFS);
110+
Volume attachVolumeToVM(Long vmId, Long volumeId, Long deviceId, Boolean allowAttachForSharedFS, boolean allowAttachOnRestoring);
111111

112112
Volume detachVolumeViaDestroyVM(long vmId, long volumeId);
113113

api/src/main/java/com/cloud/vm/VirtualMachine.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ public enum State {
5858
Error(false, "VM is in error"),
5959
Unknown(false, "VM state is unknown."),
6060
Shutdown(false, "VM state is shutdown from inside"),
61-
Restoring(true, "VM is being restored from backup");
61+
Restoring(true, "VM is being restored from backup"),
62+
BackingUp(true, "VM is being backed up"),
63+
BackupError(false, "VM backup is in a inconsistent state. Operator should analyse the logs and restore the VM"),
64+
RestoreError(false, "VM restore left the VM in a inconsistent state. Operator should analyse the logs and restore the VM");
6265

6366
private final boolean _transitional;
6467
String _description;
@@ -131,6 +134,14 @@ public static StateMachine2<State, VirtualMachine.Event, VirtualMachine> getStat
131134
s_fsm.addTransition(new Transition<State, Event>(State.Destroyed, Event.RestoringRequested, State.Restoring, null));
132135
s_fsm.addTransition(new Transition<State, Event>(State.Restoring, Event.RestoringSuccess, State.Stopped, null));
133136
s_fsm.addTransition(new Transition<State, Event>(State.Restoring, Event.RestoringFailed, State.Stopped, null));
137+
s_fsm.addTransition(new Transition<>(State.Running, Event.BackupRequested, State.BackingUp, null));
138+
s_fsm.addTransition(new Transition<>(State.Stopped, Event.BackupRequested, State.BackingUp, null));
139+
s_fsm.addTransition(new Transition<>(State.BackingUp, Event.BackupSucceededRunning, State.Running, null));
140+
s_fsm.addTransition(new Transition<>(State.BackingUp, Event.BackupSucceededStopped, State.Stopped, null));
141+
s_fsm.addTransition(new Transition<>(State.BackingUp, Event.OperationFailedToError, State.BackupError, null));
142+
s_fsm.addTransition(new Transition<>(State.BackingUp, Event.OperationFailedToRunning, State.Running, null));
143+
s_fsm.addTransition(new Transition<>(State.BackingUp, Event.OperationFailedToStopped, State.Stopped, null));
144+
s_fsm.addTransition(new Transition<State, Event>(State.RestoreError, Event.RestoringFailed, State.RestoreError, null));
134145

135146
s_fsm.addTransition(new Transition<State, Event>(State.Starting, VirtualMachine.Event.FollowAgentPowerOnReport, State.Running, Arrays.asList(new Impact[]{Impact.USAGE})));
136147
s_fsm.addTransition(new Transition<State, Event>(State.Stopping, VirtualMachine.Event.FollowAgentPowerOnReport, State.Running, null));
@@ -209,6 +220,8 @@ public enum Event {
209220
ExpungeOperation,
210221
OperationSucceeded,
211222
OperationFailed,
223+
OperationFailedToRunning,
224+
OperationFailedToStopped,
212225
OperationFailedToError,
213226
OperationRetry,
214227
AgentReportShutdowned,
@@ -218,6 +231,9 @@ public enum Event {
218231
RestoringRequested,
219232
RestoringFailed,
220233
RestoringSuccess,
234+
BackupRequested,
235+
BackupSucceededStopped,
236+
BackupSucceededRunning,
221237

222238
// added for new VMSync logic
223239
FollowAgentPowerOnReport,

api/src/main/java/com/cloud/vm/VmDetailConstants.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,7 @@ public interface VmDetailConstants {
129129
String EXTERNAL_DETAIL_PREFIX = "External:";
130130
String CLOUDSTACK_VM_DETAILS = "cloudstack.vm.details";
131131
String CLOUDSTACK_VLAN = "cloudstack.vlan";
132+
133+
// KNIB specific
134+
String LINKED_VOLUMES_SECONDARY_STORAGE_UUIDS = "linkedVolumesSecondaryStorageUuids";
132135
}

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ public class ApiConstants {
518518
public static final String QUALIFIERS = "qualifiers";
519519
public static final String QUERY_FILTER = "queryfilter";
520520
public static final String QUIESCE_VM = "quiescevm";
521+
public static final String QUICK_RESTORE = "quickrestore";
521522
public static final String SCHEDULE = "schedule";
522523
public static final String SCHEDULE_ID = "scheduleid";
523524
public static final String SCOPE = "scope";
@@ -566,6 +567,7 @@ public class ApiConstants {
566567
public static final String STATE = "state";
567568
public static final String STATS = "stats";
568569
public static final String STATUS = "status";
570+
public static final String COMPRESSION_STATUS = "compressionstatus";
569571
public static final String STORAGE_TYPE = "storagetype";
570572
public static final String STORAGE_POLICY = "storagepolicy";
571573
public static final String STORAGE_MOTION_ENABLED = "storagemotionenabled";
@@ -657,6 +659,7 @@ public class ApiConstants {
657659
public static final String ETCD_SERVICE_OFFERING_NAME = "etcdofferingname";
658660
public static final String REMOVE_VLAN = "removevlan";
659661
public static final String VLAN_ID = "vlanid";
662+
public static final String ISOLATED = "isolated";
660663
public static final String ISOLATED_PVLAN = "isolatedpvlan";
661664
public static final String ISOLATED_PVLAN_TYPE = "isolatedpvlantype";
662665
public static final String ISOLATION_URI = "isolationuri";
@@ -1171,6 +1174,7 @@ public class ApiConstants {
11711174
public static final String CLEAN_UP_EXTRA_CONFIG = "cleanupextraconfig";
11721175
public static final String CLEAN_UP_PARAMETERS = "cleanupparameters";
11731176
public static final String VIRTUAL_SIZE = "virtualsize";
1177+
public static final String UNCOMPRESSED_SIZE = "uncompressedsize";
11741178
public static final String NETSCALER_CONTROLCENTER_ID = "netscalercontrolcenterid";
11751179
public static final String NETSCALER_SERVICEPACKAGE_ID = "netscalerservicepackageid";
11761180
public static final String FETCH_ROUTER_HEALTH_CHECK_RESULTS = "fetchhealthcheckresults";
@@ -1353,6 +1357,10 @@ public class ApiConstants {
13531357

13541358
public static final String VMWARE_DC = "vmwaredc";
13551359

1360+
public static final String PARAMETER_DESCRIPTION_ISOLATED_BACKUPS = "Whether the backup will be isolated, defaults to false. " +
1361+
"Isolated backups are always created as full backups in independent chains. Therefore, they will never depend on any existing backup chain " +
1362+
"and no backup chain will depend on them. Currently only supported for the KNIB provider.";
1363+
13561364
public static final String CSS = "css";
13571365

13581366
public static final String JSON_CONFIGURATION = "jsonconfiguration";
@@ -1373,6 +1381,24 @@ public class ApiConstants {
13731381
public static final String OBSOLETE_PARAMETERS = "obsoleteparameters";
13741382
public static final String EXCLUDED_PARAMETERS = "excludedparameters";
13751383

1384+
public static final String COMPRESS = "compress";
1385+
1386+
public static final String VALIDATE = "validate";
1387+
1388+
public static final String ALLOW_QUICK_RESTORE = "allowquickrestore";
1389+
1390+
public static final String ALLOW_EXTRACT_FILE = "allowextractfile";
1391+
1392+
public static final String BACKUP_CHAIN_SIZE = "backupchainsize";
1393+
1394+
public static final String COMPRESSION_LIBRARY = "compressionlibrary";
1395+
public static final String ATTEMPTS = "attempts";
1396+
1397+
public static final String EXECUTING = "executing";
1398+
1399+
public static final String SCHEDULED = "scheduled";
1400+
public static final String SCHEDULED_DATE = "scheduleddate";
1401+
13761402
/**
13771403
* This enum specifies IO Drivers, each option controls specific policies on I/O.
13781404
* Qemu guests support "threads" and "native" options Since 0.8.8 ; "io_uring" is supported Since 6.3.0 (QEMU 5.0).

api/src/main/java/org/apache/cloudstack/api/ResponseGenerator.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import java.util.Map;
2323
import java.util.Set;
2424

25+
import org.apache.cloudstack.api.response.NativeBackupOfferingResponse;
26+
import org.apache.cloudstack.backup.NativeBackupOffering;
2527
import org.apache.cloudstack.api.response.ConsoleSessionResponse;
2628
import org.apache.cloudstack.consoleproxy.ConsoleSession;
2729
import org.apache.cloudstack.affinity.AffinityGroup;
@@ -583,4 +585,6 @@ List<TemplateResponse> createTemplateResponses(ResponseView view, VirtualMachine
583585
GuiThemeResponse createGuiThemeResponse(GuiThemeJoin guiThemeJoin);
584586

585587
ConsoleSessionResponse createConsoleSessionResponse(ConsoleSession consoleSession, ResponseView responseView);
588+
589+
NativeBackupOfferingResponse createNativeBackupOfferingResponse(NativeBackupOffering offering);
586590
}

0 commit comments

Comments
 (0)