[Kimchi-devel] [PATCH] Fix: filter unsupported source type from volume list

Aline Manera alinefm at linux.vnet.ibm.com
Fri Sep 19 15:04:02 UTC 2014


Sorry but I've just noticed the backend does not have this verification.
When adding a new CDROM or disk to a VM we should also check the right 
format data.
Please, do the backend changes beyond this one.

On 09/19/2014 06:05 AM, lvroyce at linux.vnet.ibm.com wrote:
> From: Royce Lv <lvroyce at linux.vnet.ibm.com>
>
> For disk attachment, isos should not be listed,
> and cdrom should just accept isos.
>
> Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
> ---
>   ui/js/src/kimchi.guest_storage_add.main.js | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/ui/js/src/kimchi.guest_storage_add.main.js b/ui/js/src/kimchi.guest_storage_add.main.js
> index a8c5acb..ca7f7cf 100644
> --- a/ui/js/src/kimchi.guest_storage_add.main.js
> +++ b/ui/js/src/kimchi.guest_storage_add.main.js
> @@ -33,11 +33,12 @@ kimchi.guest_storage_add_main = function() {
>       var pathTextbox = $('input[name="path"]', storageAddForm);
>       var poolTextbox = $('input[name="pool"]', storageAddForm);
>       var volTextbox = $('input[name="vol"]', storageAddForm);
> +    var selectType = $(typeTextbox).val();
>
>       typeTextbox.change(function() {
>           $('#guest-storage-bus').selectMenu();
>           var pathObject = {'cdrom': ".path-section", 'disk': '.volume-section'}
> -        var selectType = $(this).val();
> +        selectType = $(this).val();
>           $.each(pathObject, function(type, value) {
>               if(selectType == type){
>                   $(value).removeClass('hidden');
> @@ -75,11 +76,12 @@ kimchi.guest_storage_add_main = function() {
>       poolTextbox.change(function() {
>           var options = [];
>           kimchi.listStorageVolumes($(this).val(), function(result) {
> +            var validVolType = { cdrom: /iso/, disk: /^(raw|qcow|qcow2|bochs|qed|vmdk)$/};
>               $('#guest-disk').selectMenu();
>               if (result.length) {
>                   $.each(result, function(index, value) {
>                       // Only unused volume can be attached
> -                    if (value.ref_cnt == 0) {
> +                    if ((value.ref_cnt == 0) && (validVolType[selectType].test(value.format))) {
>                           options.push({
>                               label: value.name,
>                               value: value.name




More information about the Kimchi-devel mailing list