[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-API] [PATCH 16 of 21] CP-1807: do not allow assigning a VMPP to a Dom0 VM



 ocaml/idl/datamodel.ml           |  14 +++++++++++++-
 ocaml/xapi/message_forwarding.ml |   5 +++++
 ocaml/xapi/xapi_vm.ml            |   8 ++++++++
 ocaml/xapi/xapi_vm.mli           |   1 +
 4 files changed, 27 insertions(+), 1 deletions(-)


# HG changeset patch
# User Marcus Granado <marcus.granado@xxxxxxxxxx>
# Date 1282322886 -3600
# Node ID 28b0b783b5cde19abc2cac0c31440e8a7efad018
# Parent  53548b0dd1171f1ecdc2bc46c3c861c050aeaa47
CP-1807: do not allow assigning a VMPP to a Dom0 VM

Signed-off-by: Marcus Granado <marcus.granado@xxxxxxxxxxxxx>

diff -r 53548b0dd117 -r 28b0b783b5cd ocaml/idl/datamodel.ml
--- a/ocaml/idl/datamodel.ml
+++ b/ocaml/idl/datamodel.ml
@@ -1916,6 +1916,17 @@
   ~allowed_roles:_R_VM_ADMIN
   ()
 
+let vm_set_protection_policy = call
+  ~name:"set_protection_policy"
+  ~in_oss_since:None
+  ~in_product_since:rel_orlando
+  ~doc:"Set the value of the protection_policy field"
+  ~params:[Ref _vm, "self", "The VM";
+     Ref _vmpp, "value", "The value"]
+  ~flags:[`Session]
+  ~allowed_roles:_R_POOL_OP
+  ()
+
 (* 
------------------------------------------------------------------------------------------------------------
    Host Management
    
------------------------------------------------------------------------------------------------------------
 *)
@@ -5734,6 +5745,7 @@
                vm_update_snapshot_metadata;
                vm_retrieve_wlb_recommendations;
                vm_copy_bios_strings;
+    vm_set_protection_policy;
                ]
       ~contents:
       ([ uid _vm;
@@ -5795,7 +5807,7 @@
        field ~writer_roles:_R_VM_POWER_ADMIN ~qualifier:DynamicRO 
~in_product_since:rel_midnight_ride                                 ~ty:(Set 
(Ref _vm)) "children"     "List pointing to all the children of this VM";
 
        field ~qualifier:DynamicRO ~in_product_since:rel_midnight_ride 
~default_value:(Some (VMap [])) ~ty:(Map (String,String)) "bios_strings" "BIOS 
strings";
-  field ~writer_roles:_R_VM_POWER_ADMIN ~qualifier:RW 
~in_product_since:rel_cowley ~default_value:(Some (VRef (Ref.string_of 
Ref.null))) ~ty:(Ref _vmpp) "protection_policy" "Ref pointing to a protection 
policy for this VM";
+  field ~writer_roles:_R_VM_POWER_ADMIN ~qualifier:StaticRO 
~in_product_since:rel_cowley ~default_value:(Some (VRef (Ref.string_of 
Ref.null))) ~ty:(Ref _vmpp) "protection_policy" "Ref pointing to a protection 
policy for this VM";
   field ~writer_roles:_R_POOL_OP ~qualifier:StaticRO 
~in_product_since:rel_cowley ~default_value:(Some (VBool false)) ~ty:Bool 
"is_snapshot_from_vmpp" "true if this snapshot was created by the protection 
policy";
       ])
        ()
diff -r 53548b0dd117 -r 28b0b783b5cd ocaml/xapi/message_forwarding.ml
--- a/ocaml/xapi/message_forwarding.ml
+++ b/ocaml/xapi/message_forwarding.ml
@@ -1673,6 +1673,11 @@
        let copy_bios_strings ~__context ~vm ~host =
                info "VM.copy_bios_strings: VM = '%s'; host = '%s'" (vm_uuid 
~__context vm) (host_uuid ~__context host);
                Local.VM.copy_bios_strings ~__context ~vm ~host
+
+       let set_protection_policy ~__context ~self ~value =
+               info "VM.set_protection_policy: self = '%s'; " (vm_uuid 
~__context self);
+               Local.VM.set_protection_policy ~__context ~self ~value
+
   end
 
   module VM_metrics = struct
diff -r 53548b0dd117 -r 28b0b783b5cd ocaml/xapi/xapi_vm.ml
--- a/ocaml/xapi/xapi_vm.ml
+++ b/ocaml/xapi/xapi_vm.ml
@@ -1196,3 +1196,11 @@
                Db.VM.set_affinity ~__context ~self:vm ~value:host
        end
        
+let set_protection_policy ~__context ~self ~value = 
+  if Db.VM.get_is_control_domain ~__context ~self
+  then ( (* do not assign vmpps to the dom0 vm of any host in the pool *)
+    raise (Api_errors.Server_error(Api_errors.invalid_value, [Ref.string_of 
value]))
+  )
+  else (
+    Db.VM.set_protection_policy ~__context ~self ~value
+  )
diff -r 53548b0dd117 -r 28b0b783b5cd ocaml/xapi/xapi_vm.mli
--- a/ocaml/xapi/xapi_vm.mli
+++ b/ocaml/xapi/xapi_vm.mli
@@ -260,3 +260,4 @@
 (** Copy the BIOS strings from a host to the VM, unless the VM's BIOS strings
  *  had already been set. *)
 
+val set_protection_policy : __context:Context.t -> self:API.ref_VM -> 
value:API.ref_VMPP -> unit

Attachment: xen-api.hg-16.patch
Description: Text Data

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.