diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java index 127f648c92f..9fb63ce2425 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java @@ -76,7 +76,7 @@ public class LibvirtDomainXMLParser { def.defNetworkBasedDisk(diskPath, host, port, authUserName, poolUuid, diskLabel, DiskDef.diskBus.valueOf(bus.toUpperCase()), DiskDef.diskProtocol.valueOf(protocol.toUpperCase())); - def.setCacheMode(DiskDef.diskCacheMode.valueOf(diskCacheMode)); + def.setCacheMode(DiskDef.diskCacheMode.valueOf(diskCacheMode.toUpperCase())); } else { String diskFmtType = getAttrValue("driver", "type", disk); String diskCacheMode = getAttrValue("driver", "cache", disk); @@ -100,8 +100,8 @@ public class LibvirtDomainXMLParser { } else if (type.equalsIgnoreCase("block")) { def.defBlockBasedDisk(diskDev, diskLabel, DiskDef.diskBus.valueOf(bus.toUpperCase())); - def.setCacheMode(DiskDef.diskCacheMode.valueOf(diskCacheMode)); } + def.setCacheMode(DiskDef.diskCacheMode.valueOf(diskCacheMode.toUpperCase())); } NodeList iotune = disk.getElementsByTagName("iotune"); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java index 5aeacdafae0..1e900930492 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java @@ -585,6 +585,10 @@ public class LibvirtVMDef { return _diskLabel; } + public diskType getDiskType() { + return _diskType; + } + public deviceType getDeviceType() { return _deviceType; } @@ -597,6 +601,10 @@ public class LibvirtVMDef { return _bus; } + public diskFmtType getDiskFormatType() { + return _diskFmtType; + } + public int getDiskSeq() { char suffix = _diskLabel.charAt(_diskLabel.length() - 1); return suffix - 'a'; @@ -622,6 +630,10 @@ public class LibvirtVMDef { _diskCacheMode = cacheMode; } + public diskCacheMode getCacheMode() { + return _diskCacheMode; + } + @Override public String toString() { StringBuilder diskBuilder = new StringBuilder(); diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParserTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParserTest.java new file mode 100644 index 00000000000..bbe2f23fe88 --- /dev/null +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParserTest.java @@ -0,0 +1,184 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package com.cloud.hypervisor.kvm.resource; + +import junit.framework.TestCase; +import java.util.List; +import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef; + +public class LibvirtDomainXMLParserTest extends TestCase { + + public void testDomainXMLParser() { + int vncPort = 5900; + + DiskDef.diskBus diskBus = DiskDef.diskBus.VIRTIO; + DiskDef.diskType diskType = DiskDef.diskType.FILE; + DiskDef.deviceType deviceType = DiskDef.deviceType.DISK; + DiskDef.diskFmtType diskFormat = DiskDef.diskFmtType.QCOW2; + DiskDef.diskCacheMode diskCache = DiskDef.diskCacheMode.NONE; + + String diskLabel ="vda"; + String diskPath = "/var/lib/libvirt/images/my-test-image.qcow2"; + + String xml = "" + + "s-2970-VM" + + "4d2c1526-865d-4fc9-a1ac-dbd1801a22d0" + + "Debian GNU/Linux 6(64-bit)" + + "262144" + + "262144" + + "1" + + "" + + "250" + + "" + + "" + + "/machine" + + "" + + "" + + "hvm" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "destroy" + + "restart" + + "destroy" + + "" + + "/usr/bin/kvm-spice" + + "" + + "" + + "" + + "" + + "" + + "
" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "
" + + "" + + "" + + "" + + "
" + + "" + + "" + + "" + + "" + + "" + + "" + + "
" + + "" + + "" + + "" + + "
" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "
" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "
" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "
" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "
" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "
" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "