Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,13 @@ public String getMemBalloonStatsPeriod() {
@Override
public String toString() {
StringBuilder memBalloonBuilder = new StringBuilder();
memBalloonBuilder.append("<memballoon model='" + memBalloonModel + "'>\n");
memBalloonBuilder.append("<memballoon model='" + memBalloonModel + "'");
/* Version integer format: major * 1,000,000 + minor * 1,000 + release.
* Require: libvirt 6.9.0, qemu 5.1.0 */
if (memBalloonModel != MemBalloonModel.NONE && s_qemuVersion >= 5001000 && s_libvirtVersion >= 6009000) {
Comment on lines +1343 to +1346
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bradh352, thanks for the PR, code looks good. Just one minor suggestion, could you extract this comment into a method's Javadoc string? For instance:

/**
* Updates the parent on the {@code checkpointXml} to {@code snapshotParent}. If {@code snapshotParent} is null, removes the parent.
* @param checkpointXml the checkpoint XML to be updated
* @param snapshotParent the snapshot parent. Inform null if no parent.
* */
private void updateParent(String snapshotParent, Document checkpointXml, XPath xPath) throws XPathExpressionException {

memBalloonBuilder.append(" autodeflate='on' freePageReporting='on'");
}
memBalloonBuilder.append(">\n");
if (StringUtils.isNotBlank(memBalloonStatsPeriod)) {
memBalloonBuilder.append("<stats period='" + memBalloonStatsPeriod +"'/>\n");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public void testDomainXMLParser() {
"<alias name='video0'/>" +
"<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>" +
"</video>" +
"<memballoon model='virtio'>" +
"<memballoon model='virtio' autodeflate='on' freePageReporting='on'>" +
"<stats period='60'/>" +
"<alias name='balloon0'/>" +
"<address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>" +
Expand Down Expand Up @@ -379,7 +379,7 @@ public void testDomainXMLParserWithoutModelName() {
" <redirdev bus='usb' type='spicevmc'>\n" +
" <address type='usb' bus='0' port='3'/>\n" +
" </redirdev>\n" +
" <memballoon model='virtio'>\n" +
" <memballoon model='virtio' autodeflate='on' freePageReporting='on'>\n" +
" <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>\n" +
" </memballoon>\n" +
" </devices>\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,21 @@ public void memBalloonDefTestNone() {

@Test
public void memBalloonDefTestVirtio() {
LibvirtVMDef.setGlobalQemuVersion(5001000L);
LibvirtVMDef.setGlobalLibvirtVersion(6009000L);
String expectedXml = "<memballoon model='virtio' autodeflate='on' freePageReporting='on'>\n<stats period='60'/>\n</memballoon>";
MemBalloonDef memBalloonDef = new MemBalloonDef();
memBalloonDef.defVirtioMemBalloon("60");

String xmlDef = memBalloonDef.toString();

assertEquals(expectedXml, xmlDef);
}

@Test
public void memBalloonDefTestVirtioOld() {
LibvirtVMDef.setGlobalQemuVersion(2006000L);
LibvirtVMDef.setGlobalLibvirtVersion(9008L);
String expectedXml = "<memballoon model='virtio'>\n<stats period='60'/>\n</memballoon>";
MemBalloonDef memBalloonDef = new MemBalloonDef();
memBalloonDef.defVirtioMemBalloon("60");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public class LibvirtMigrateVolumeCommandWrapperTest {
" <alias name='watchdog0'/>\n" +
" <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>\n" +
" </watchdog>\n" +
" <memballoon model='virtio'>\n" +
" <memballoon model='virtio' autodeflate='on' freePageReporting='on'>\n" +
" <alias name='balloon0'/>\n" +
" <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>\n" +
" </memballoon>\n" +
Expand Down
Loading