cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Howie YU" <howie...@gmail.com>
Subject Review Request 16337: [CLOUDSTACK-5526] Fix LibvirtDomainXMLParser error when diskCacheMode is empty string
Date Wed, 18 Dec 2013 01:33:54 GMT

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

Review request for cloudstack 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


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message