-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/16337/
-----------------------------------------------------------

(Updated Dec. 25, 2013, 1:47 a.m.)


Review request for cloudstack, Wei Zhou and Wido den Hollander.


Bugs: CLOUDSTACK-5526
    https://issues.apache.org/jira/browse/CLOUDSTACK-5526


Repository: cloudstack-git


Description
-------

When using LibvirtDomainXMLParser parser xml from Domain.
The attribute diskCacheMode not always have value , and will be empty string

 String diskCacheMode = getAttrValue("driver", "cache", disk);

when the code go to here valueOf

} else if (type.equalsIgnoreCase("block")) {
                        def.defBlockBasedDisk(diskDev, diskLabel,
                            DiskDef.diskBus.valueOf(bus.toUpperCase()));
                        
def.setCacheMode(DiskDef.diskCacheMode.valueOf(diskCacheMode));
}

There will be cause IllegalArgumentException at
at java.lang.Enum.valueOf(Enum.java:196)

I suggest we may check if diskCacheMode is empty string , such as

if (diskCacheMode == null || diskCacheMode.isEmpty()) {
def.setCacheMode(DiskDef.diskCacheMode.NONE);
} else {

def.setCacheMode(DiskDef.diskCacheMode.valueOf(diskCacheMode));

}


Diffs
-----

  
plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java
 127f648 

Diff: https://reviews.apache.org/r/16337/diff/


Testing
-------


Thanks,

Howie YU

Reply via email to