Conversation
dkbennett
left a comment
There was a problem hiding this comment.
Approve, but have a design question that I don't think should block the PR.
src/Services/ActivationService.cs
Outdated
There was a problem hiding this comment.
nit
| Log.Information("Disabling Hyper-V extension on ARM {Architecture}", arch); | |
| Log.Information($"Disabling Hyper-V extension on ARM {arch}"); |
src/Services/ActivationService.cs
Outdated
There was a problem hiding this comment.
Note: it may be possible to run x86 or x64 DevHome on ARM64EC devices. We don't install those architectures, but users could force it or architectures we build can change in the future. It would be more correct to check device architecture instead of running process architecture.
51b7043 to
4165e44
Compare
853b3de to
5268740
Compare
| var supportedOperations = ComputeSystemOperations.ApplyConfiguration; | ||
| var revertOperation = Guid.Empty.Equals(ParentCheckpointId) ? ComputeSystemOperations.None : ComputeSystemOperations.RevertSnapshot; | ||
|
|
||
| switch (GetState()) | ||
| { | ||
| case ComputeSystemState.Running: | ||
| // Supported operations when running | ||
| return ComputeSystemOperations.ShutDown | | ||
| supportedOperations = ComputeSystemOperations.ShutDown | | ||
| ComputeSystemOperations.Terminate | | ||
| ComputeSystemOperations.Save | | ||
| ComputeSystemOperations.Pause | | ||
| ComputeSystemOperations.CreateSnapshot | | ||
| ComputeSystemOperations.Restart | | ||
| ComputeSystemOperations.ApplyConfiguration | | ||
| revertOperation; | ||
| break; | ||
| case ComputeSystemState.Stopped: | ||
| // Supported operations when stopped | ||
| return ComputeSystemOperations.Start | | ||
| supportedOperations = ComputeSystemOperations.Start | | ||
| ComputeSystemOperations.CreateSnapshot | | ||
| ComputeSystemOperations.Delete | | ||
| ComputeSystemOperations.ApplyConfiguration; | ||
| break; | ||
| case ComputeSystemState.Saved: | ||
| // Supported operations when saved | ||
| return ComputeSystemOperations.Start | | ||
| supportedOperations = ComputeSystemOperations.Start | | ||
| ComputeSystemOperations.CreateSnapshot | | ||
| ComputeSystemOperations.Delete | | ||
| ComputeSystemOperations.ApplyConfiguration | | ||
| revertOperation; | ||
| break; | ||
| case ComputeSystemState.Paused: | ||
| // Supported operations when paused | ||
| return ComputeSystemOperations.Terminate | | ||
| supportedOperations = ComputeSystemOperations.Terminate | | ||
| ComputeSystemOperations.Save | | ||
| ComputeSystemOperations.Resume | | ||
| ComputeSystemOperations.CreateSnapshot | | ||
| ComputeSystemOperations.ApplyConfiguration | | ||
| revertOperation; | ||
| break; | ||
| } | ||
|
|
||
| // Before applying the configuration we start the VM. So we will allow the ApplyConfiguration to be the base supported operation | ||
| // for the VM. | ||
| return ComputeSystemOperations.ApplyConfiguration; | ||
| // Disable ApplyConfiguration for ARM | ||
| var arch = RuntimeInformation.ProcessArchitecture; | ||
| if (arch == Architecture.Arm64 || arch == Architecture.Arm || arch == Architecture.Armv6) | ||
| { | ||
| supportedOperations &= ~ComputeSystemOperations.ApplyConfiguration; | ||
| } | ||
|
|
||
| return supportedOperations; |
There was a problem hiding this comment.
Would it be simpler to just remove the ComputeSystemOperations.ApplyConfiguration from the switch statements and then add it at the end in line 150? This way you can just do return supportedOperations so something like this:
| var supportedOperations = ComputeSystemOperations.ApplyConfiguration; | |
| var revertOperation = Guid.Empty.Equals(ParentCheckpointId) ? ComputeSystemOperations.None : ComputeSystemOperations.RevertSnapshot; | |
| switch (GetState()) | |
| { | |
| case ComputeSystemState.Running: | |
| // Supported operations when running | |
| return ComputeSystemOperations.ShutDown | | |
| supportedOperations = ComputeSystemOperations.ShutDown | | |
| ComputeSystemOperations.Terminate | | |
| ComputeSystemOperations.Save | | |
| ComputeSystemOperations.Pause | | |
| ComputeSystemOperations.CreateSnapshot | | |
| ComputeSystemOperations.Restart | | |
| ComputeSystemOperations.ApplyConfiguration | | |
| revertOperation; | |
| break; | |
| case ComputeSystemState.Stopped: | |
| // Supported operations when stopped | |
| return ComputeSystemOperations.Start | | |
| supportedOperations = ComputeSystemOperations.Start | | |
| ComputeSystemOperations.CreateSnapshot | | |
| ComputeSystemOperations.Delete | | |
| ComputeSystemOperations.ApplyConfiguration; | |
| break; | |
| case ComputeSystemState.Saved: | |
| // Supported operations when saved | |
| return ComputeSystemOperations.Start | | |
| supportedOperations = ComputeSystemOperations.Start | | |
| ComputeSystemOperations.CreateSnapshot | | |
| ComputeSystemOperations.Delete | | |
| ComputeSystemOperations.ApplyConfiguration | | |
| revertOperation; | |
| break; | |
| case ComputeSystemState.Paused: | |
| // Supported operations when paused | |
| return ComputeSystemOperations.Terminate | | |
| supportedOperations = ComputeSystemOperations.Terminate | | |
| ComputeSystemOperations.Save | | |
| ComputeSystemOperations.Resume | | |
| ComputeSystemOperations.CreateSnapshot | | |
| ComputeSystemOperations.ApplyConfiguration | | |
| revertOperation; | |
| break; | |
| } | |
| // Before applying the configuration we start the VM. So we will allow the ApplyConfiguration to be the base supported operation | |
| // for the VM. | |
| return ComputeSystemOperations.ApplyConfiguration; | |
| // Disable ApplyConfiguration for ARM | |
| var arch = RuntimeInformation.ProcessArchitecture; | |
| if (arch == Architecture.Arm64 || arch == Architecture.Arm || arch == Architecture.Armv6) | |
| { | |
| supportedOperations &= ~ComputeSystemOperations.ApplyConfiguration; | |
| } | |
| return supportedOperations; | |
| var supportedOperations = ComputeSystemOperations.None; | |
| var revertOperation = Guid.Empty.Equals(ParentCheckpointId) ? ComputeSystemOperations.None : ComputeSystemOperations.RevertSnapshot; | |
| switch (GetState()) | |
| { | |
| case ComputeSystemState.Running: | |
| // Supported operations when running | |
| supportedOperations = ComputeSystemOperations.ShutDown | | |
| ComputeSystemOperations.Terminate | | |
| ComputeSystemOperations.Save | | |
| ComputeSystemOperations.Pause | | |
| ComputeSystemOperations.CreateSnapshot | | |
| ComputeSystemOperations.Restart | | |
| revertOperation; | |
| break; | |
| case ComputeSystemState.Stopped: | |
| // Supported operations when stopped | |
| supportedOperations = ComputeSystemOperations.Start | | |
| ComputeSystemOperations.CreateSnapshot | | |
| ComputeSystemOperations.Delete; | |
| break; | |
| case ComputeSystemState.Saved: | |
| // Supported operations when saved | |
| supportedOperations = ComputeSystemOperations.Start | | |
| ComputeSystemOperations.CreateSnapshot | | |
| ComputeSystemOperations.Delete | | |
| revertOperation; | |
| break; | |
| case ComputeSystemState.Paused: | |
| // Supported operations when paused | |
| supportedOperations = ComputeSystemOperations.Terminate | | |
| ComputeSystemOperations.Save | | |
| ComputeSystemOperations.Resume | | |
| ComputeSystemOperations.CreateSnapshot | | |
| revertOperation; | |
| break; | |
| } | |
| // Disable ApplyConfiguration for ARM | |
| var arch = RuntimeInformation.ProcessArchitecture; | |
| if (arch == Architecture.Arm64 || arch == Architecture.Arm || arch == Architecture.Armv6) | |
| { | |
| return supportedOperations; | |
| } | |
| return supportedOperations | ComputeSystemOperations.ApplyConfiguration; |
| { | ||
| // Disable the create operation for ARM devices. | ||
| var arch = RuntimeInformation.OSArchitecture; | ||
| if (arch == Architecture.Arm64 || arch == Architecture.Arm || arch == Architecture.Armv6) |
There was a problem hiding this comment.
Coding guidelines: "Use parentheses to make clauses in an expression apparent."
Summary of the pull request
Disable config and creation flow for Hyper-V extension on ARM.
Validation steps performed
Tested on an ARM machine
PR checklist