Commit 96e6ff28 authored by Pino Toscano's avatar Pino Toscano Committed by Richard W.M. Jones

Add Domain.get_xml_desc_flags

Much like Domain.get_xml_desc with the possibility to specify flags for
the XML description.  The function is marked with a [`W] phantom because
some of the flags (e.g. XmlSecure) require a read/write connection.
parent ccf637fb
......@@ -640,6 +640,12 @@ struct
params : typed_param array;
}
type xml_desc_flag =
| XmlSecure
| XmlInactive
| XmlUpdateCPU
| XmlMigratable
(* The maximum size for Domain.memory_peek and Domain.block_peek
* supported by libvirt. This may change with different versions
* of libvirt in the future, hence it's a function.
......@@ -673,6 +679,7 @@ struct
external set_memory : [>`W] t -> int64 -> unit = "ocaml_libvirt_domain_set_memory"
external get_info : [>`R] t -> info = "ocaml_libvirt_domain_get_info"
external get_xml_desc : [>`R] t -> xml = "ocaml_libvirt_domain_get_xml_desc"
external get_xml_desc_flags : [>`W] t -> xml_desc_flag list -> xml = "ocaml_libvirt_domain_get_xml_desc_flags"
external get_scheduler_type : [>`R] t -> string * int = "ocaml_libvirt_domain_get_scheduler_type"
external get_scheduler_parameters : [>`R] t -> int -> sched_param array = "ocaml_libvirt_domain_get_scheduler_parameters"
external set_scheduler_parameters : [>`W] t -> sched_param array -> unit = "ocaml_libvirt_domain_set_scheduler_parameters"
......
......@@ -534,6 +534,12 @@ sig
params : typed_param array;
}
type xml_desc_flag =
| XmlSecure (* dump security sensitive information too *)
| XmlInactive (* dump inactive domain information *)
| XmlUpdateCPU (* update guest CPU requirements according to host CPU *)
| XmlMigratable (* dump XML suitable for migration *)
val max_peek : [>`R] t -> int
(** Maximum size supported by the {!block_peek} and {!memory_peek}
functions. If you want to peek more than this then you must
......@@ -598,6 +604,9 @@ sig
(** Get information about a domain. *)
val get_xml_desc : [>`R] t -> xml
(** Get the XML description of a domain. *)
val get_xml_desc_flags : [>`W] t -> xml_desc_flag list -> xml
(** Get the XML description of a domain, with the possibility
to specify flags. *)
val get_scheduler_type : [>`R] t -> string * int
(** Get the scheduler type. *)
val get_scheduler_parameters : [>`R] t -> int -> sched_param array
......
......@@ -977,6 +977,37 @@ ocaml_libvirt_domain_memory_peek_bytecode (value *argv, int argn)
argv[3], argv[4], argv[5]);
}
CAMLprim value
ocaml_libvirt_domain_get_xml_desc_flags (value domv, value flagsv)
{
CAMLparam2 (domv, flagsv);
CAMLlocal2 (rv, flagv);
virDomainPtr dom = Domain_val (domv);
int flags = 0;
char *r;
/* Do flags. */
for (; flagsv != Val_int (0); flagsv = Field (flagsv, 1))
{
flagv = Field (flagsv, 0);
if (flagv == Val_int (0))
flags |= VIR_DOMAIN_XML_SECURE;
else if (flagv == Val_int (1))
flags |= VIR_DOMAIN_XML_INACTIVE;
else if (flagv == Val_int (2))
flags |= VIR_DOMAIN_XML_UPDATE_CPU;
else if (flagv == Val_int (3))
flags |= VIR_DOMAIN_XML_MIGRATABLE;
}
NONBLOCKING (r = virDomainGetXMLDesc (dom, flags));
CHECK_ERROR (!r, "virDomainGetXMLDesc");
rv = caml_copy_string (r);
free (r);
CAMLreturn (rv);
}
/*----------------------------------------------------------------------*/
/* Domain events */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment