WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

[Xen-API] [PATCH]add strict check to VCPUs-params param-key

To: xen-api@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-API] [PATCH]add strict check to VCPUs-params param-key
From: Yang Hongyang <yanghy@xxxxxxxxxxxxxx>
Date: Mon, 19 Apr 2010 17:22:15 +0800
Cc:
Delivery-date: Mon, 19 Apr 2010 02:20:17 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.23 (X11/20090817)
Add strict check to VCPUs-params param-key,according to Xen Cloud Platform
Administrator's Guide,there's only 'weight','cap' or 'mask' param-key available.

current:
# xe vm-param-set VCPUs-params:test=33 uuid=b7ca170b-c017-046e-116c-8d4c4d778195
# xe vm-list params=VCPUs-params uuid=b7ca170b-c017-046e-116c-8d4c4d778195
VCPUs-params (MRW)    : test: 33

after patch:
# xe vm-param-set VCPUs-params:test=33 
uuid=b7ca170b-c017-046e-116c-8d4c4d778195 
Error: Failed to add parameter 'test': expecting 'weight','cap' or 'mask'
# xe vm-list params=VCPUs-params uuid=b7ca170b-c017-046e-116c-8d4c4d778195
VCPUs-params (MRW)    :

Signed-off-by: Yang Hongyang <yanghy@xxxxxxxxxxxxxx>

diff -r ad754527bddd ocaml/client_records/records.ml
--- a/ocaml/client_records/records.ml   Fri Apr 16 11:44:32 2010 +0100
+++ b/ocaml/client_records/records.ml   Mon Apr 19 11:53:48 2010 -0400
@@ -619,7 +619,9 @@ let vm_record rpc session_id vm =
                                ~get:(fun () -> get_uuid_from_ref (x 
()).API.vM_suspend_VDI) ();
                        make_field ~name:"VCPUs-params"
                                ~get:(fun () -> Record_util.s2sm_to_string "; " 
(x ()).API.vM_VCPUs_params)
-                               ~add_to_map:(fun k v -> 
Client.VM.add_to_VCPUs_params rpc session_id vm k v)
+                               ~add_to_map:(fun k v -> match k with
+                                               | "weight" | "cap" | "mask" -> 
Client.VM.add_to_VCPUs_params rpc session_id vm k v
+                                               | _ -> raise 
(Record_util.Record_failure ("Failed to add parameter '"^k^"': expecting 
'weight','cap' or 'mask'")))
                                ~remove_from_map:(fun k -> 
Client.VM.remove_from_VCPUs_params rpc session_id vm k) 
                                ~get_map:(fun () -> (x ()).API.vM_VCPUs_params) 
();
                        make_field ~name:"VCPUs-max"

-- 
Regards
Yang Hongyang
diff -r ad754527bddd ocaml/client_records/records.ml
--- a/ocaml/client_records/records.ml   Fri Apr 16 11:44:32 2010 +0100
+++ b/ocaml/client_records/records.ml   Mon Apr 19 11:53:48 2010 -0400
@@ -619,7 +619,9 @@ let vm_record rpc session_id vm =
                                ~get:(fun () -> get_uuid_from_ref (x 
()).API.vM_suspend_VDI) ();
                        make_field ~name:"VCPUs-params"
                                ~get:(fun () -> Record_util.s2sm_to_string "; " 
(x ()).API.vM_VCPUs_params)
-                               ~add_to_map:(fun k v -> 
Client.VM.add_to_VCPUs_params rpc session_id vm k v)
+                               ~add_to_map:(fun k v -> match k with
+                                               | "weight" | "cap" | "mask" -> 
Client.VM.add_to_VCPUs_params rpc session_id vm k v
+                                               | _ -> raise 
(Record_util.Record_failure ("Failed to add parameter '"^k^"': expecting 
'weight','cap' or 'mask'")))
                                ~remove_from_map:(fun k -> 
Client.VM.remove_from_VCPUs_params rpc session_id vm k) 
                                ~get_map:(fun () -> (x ()).API.vM_VCPUs_params) 
();
                        make_field ~name:"VCPUs-max"
_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
<Prev in Thread] Current Thread [Next in Thread>