Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.4k
CLOUDSTACK-9397: Add Watchdog timer to KVM Instance#1707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -133,6 +133,9 @@ | ||
| import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.VideoDef; | ||
| import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.RngDef; | ||
| import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.RngDef.RngBackendModel; | ||
| import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.WatchDogDef; | ||
| import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.WatchDogDef.WatchDogModel; | ||
| import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.WatchDogDef.WatchDogAction; | ||
| import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper; | ||
| import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtUtilitiesHelper; | ||
| import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk; | ||
| @@ -274,6 +277,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv | ||
| private File _qemuSocketsPath; | ||
| private final String _qemuGuestAgentSocketName = "org.qemu.guest_agent.0"; | ||
| private long _totalMemory; | ||
| protected WatchDogAction _watchDogAction = WatchDogAction.NONE; | ||
| protected WatchDogModel _watchDogModel = WatchDogModel.I6300ESB; | ||
| private final Map <String, String> _pifs = new HashMap<String, String>(); | ||
| private final Map<String, VmStats> _vmStats = new ConcurrentHashMap<String, VmStats>(); | ||
| @@ -870,6 +875,16 @@ public boolean configure(final String name, final Map<String, Object> params) th | ||
| _rngRatePeriod = NumbersUtil.parseInt(value, new Integer(_rngRatePeriod)); | ||
| } | ||
| value = (String) params.get("vm.watchdog.model"); | ||
| if (!Strings.isNullOrEmpty(value)) { | ||
| _watchDogModel = WatchDogModel.valueOf(value.toUpperCase()); | ||
| } | ||
| value = (String) params.get("vm.watchdog.action"); | ||
| if (!Strings.isNullOrEmpty(value)) { | ||
| _watchDogAction = WatchDogAction.valueOf(value.toUpperCase()); | ||
| } | ||
| LibvirtConnection.initialize(_hypervisorURI); | ||
| Connect conn = null; | ||
| try { | ||
| @@ -2066,6 +2081,8 @@ So if getMinSpeed() returns null we fall back to getSpeed(). | ||
| devices.addDevice(new ChannelDef(_qemuGuestAgentSocketName, ChannelDef.ChannelType.UNIX, | ||
| new File(_qemuSocketsPath + "/" + vmTO.getName() + "." + _qemuGuestAgentSocketName))); | ||
| devices.addDevice(new WatchDogDef(_watchDogAction, _watchDogModel)); | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @wido the default action ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as I know that's not pissible @rhtyd These models are always available in Qemu | ||
| final VideoDef videoCard = new VideoDef(_videoHw, _videoRam); | ||
| devices.addDevice(videoCard); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -43,13 +43,17 @@ | ||
| import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef.NicModel; | ||
| import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.RngDef; | ||
| import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.RngDef.RngBackendModel; | ||
| import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.WatchDogDef; | ||
| import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.WatchDogDef.WatchDogModel; | ||
| import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.WatchDogDef.WatchDogAction; | ||
| public class LibvirtDomainXMLParser { | ||
| private static final Logger s_logger = Logger.getLogger(LibvirtDomainXMLParser.class); | ||
| private final List<InterfaceDef> interfaces = new ArrayList<InterfaceDef>(); | ||
| private final List<DiskDef> diskDefs = new ArrayList<DiskDef>(); | ||
| private final List<RngDef> rngDefs = new ArrayList<RngDef>(); | ||
| private final List<ChannelDef> channels = new ArrayList<ChannelDef>(); | ||
| private final List<WatchDogDef> watchDogDefs = new ArrayList<WatchDogDef>(); | ||
| private Integer vncPort; | ||
| private String desc; | ||
| @@ -237,6 +241,27 @@ public boolean parseDomainXML(String domXML) { | ||
| rngDefs.add(def); | ||
| } | ||
| NodeList watchDogs = devices.getElementsByTagName("watchdog"); | ||
| for (int i = 0; i < watchDogs.getLength(); i++) { | ||
| WatchDogDef def = null; | ||
| Element watchDog = (Element)watchDogs.item(i); | ||
| String action = watchDog.getAttribute("action"); | ||
| String model = watchDog.getAttribute("model"); | ||
| if (Strings.isNullOrEmpty(model)) { | ||
| continue; | ||
| } | ||
| if (Strings.isNullOrEmpty(action)) { | ||
| def = new WatchDogDef(WatchDogModel.valueOf(model.toUpperCase())); | ||
| } else { | ||
| def = new WatchDogDef(WatchDogAction.valueOf(action.toUpperCase()), | ||
| WatchDogModel.valueOf(model.toUpperCase())); | ||
| } | ||
| watchDogDefs.add(def); | ||
| } | ||
| ||
| return true; | ||
| } catch (ParserConfigurationException e) { | ||
| s_logger.debug(e.toString()); | ||
| @@ -290,6 +315,10 @@ public List<ChannelDef> getChannels() { | ||
| return Collections.unmodifiableList(channels); | ||
| } | ||
| public List<WatchDogDef> getWatchDogs() { | ||
| return watchDogDefs; | ||
| } | ||
| public String getDescription() { | ||
| return desc; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wido what about replace 'Strings.isNullOrEmpty' with 'StringUtils.isBlank'? It returns true in case of a null, empty, or blank String. However, I am not sure if a blank string is possible when getting the param.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GabrielBrascher I think using
isNullOrEmptyis alright