kvm: Handle the failures when setting up memory balloon stats period for KVM VMs (#8049)

This commit is contained in:
Harikrishna 2023-11-03 13:37:11 +05:30 committed by GitHub
parent 3b11663d87
commit 1e133d05c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 9 deletions

View File

@ -1313,8 +1313,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
}
s_logger.debug(String.format("The memory balloon stats period [%s] has been set successfully for the VM (Libvirt Domain) with ID [%s] and name [%s].",
currentVmBalloonStatsPeriod, vmId, dm.getName()));
} catch (final LibvirtException e) {
s_logger.warn("Failed to set up memory balloon stats period." + e.getMessage());
} catch (final Exception e) {
s_logger.warn(String.format("Failed to set up memory balloon stats period for the VM %s with exception %s", parser.getName(), e.getMessage()));
}
}
}

View File

@ -59,6 +59,8 @@ public class LibvirtDomainXMLParser {
private Integer vncPort;
private String desc;
private String name;
public boolean parseDomainXML(String domXML) {
DocumentBuilder builder;
try {
@ -71,6 +73,7 @@ public class LibvirtDomainXMLParser {
Element rootElement = doc.getDocumentElement();
desc = getTagValue("description", rootElement);
name = getTagValue("name", rootElement);
Element devices = (Element)rootElement.getElementsByTagName("devices").item(0);
NodeList disks = devices.getElementsByTagName("disk");
@ -303,15 +306,19 @@ public class LibvirtDomainXMLParser {
String path = getTagValue("backend", rng);
String bytes = getAttrValue("rate", "bytes", rng);
String period = getAttrValue("rate", "period", rng);
if (StringUtils.isEmpty(backendModel)) {
def = new RngDef(path, Integer.parseInt(bytes), Integer.parseInt(period));
if (StringUtils.isAnyEmpty(bytes, period)) {
s_logger.debug(String.format("Bytes and period in the rng section should not be null, please check the VM %s", name));
} else {
def = new RngDef(path, RngBackendModel.valueOf(backendModel.toUpperCase()),
Integer.parseInt(bytes), Integer.parseInt(period));
if (StringUtils.isEmpty(backendModel)) {
def = new RngDef(path, Integer.parseInt(bytes), Integer.parseInt(period));
} else {
def = new RngDef(path, RngBackendModel.valueOf(backendModel.toUpperCase()),
Integer.parseInt(bytes), Integer.parseInt(period));
}
}
if (def != null) {
rngDefs.add(def);
}
rngDefs.add(def);
}
NodeList watchDogs = devices.getElementsByTagName("watchdog");
@ -418,4 +425,8 @@ public class LibvirtDomainXMLParser {
public String getDescription() {
return desc;
}
public String getName() {
return name;
}
}