Added VM.is_control_domain field.
authorEwan Mellor <ewan@xensource.com>
Tue, 30 Jan 2007 15:27:10 +0000 (15:27 +0000)
committerEwan Mellor <ewan@xensource.com>
Tue, 30 Jan 2007 15:27:10 +0000 (15:27 +0000)
Signed-off-by: Ewan Mellor <ewan@xensource.com>
docs/xen-api/xenapi-datamodel.tex
tools/libxen/include/xen_vm.h
tools/libxen/src/xen_vm.c
tools/python/xen/xend/XendAPI.py

index e9936df4b1d95c8c8ec014871481777ac1b60bbe..cde30247cd0ff4c0f3e48fb9dbe46078b6a6fb20 100644 (file)
@@ -1062,6 +1062,7 @@ $\mathit{RW}$ &  {\tt platform/enable\_audio} & bool & emulate audio \\
 $\mathit{RO}_\mathit{ins}$ &  {\tt PCI\_bus} & string & PCI bus path for pass-through devices \\
 $\mathit{RO}_\mathit{run}$ &  {\tt tools\_version} & (string $\rightarrow$ string) Map & versions of installed paravirtualised drivers \\
 $\mathit{RW}$ &  {\tt other\_config} & (string $\rightarrow$ string) Map & additional configuration \\
+$\mathit{RO}_\mathit{run}$ &  {\tt is\_control\_domain} & bool & true if this is a control domain (domain 0 or a driver domain) \\
 \hline
 \end{longtable}
 \subsection{Additional RPCs associated with class: VM}
@@ -3648,6 +3649,38 @@ void
 
 
 
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_is\_control\_domain}
+
+{\bf Overview:} 
+Get the is\_control\_domain field of the given VM.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} bool get_is_control_domain (session_id s, VM ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+bool
+}
+
+
+value of the field
 \vspace{0.3cm}
 \vspace{0.3cm}
 \vspace{0.3cm}
@@ -10019,7 +10052,6 @@ Quals & Field & Type & Description \\
 $\mathit{RO}_\mathit{run}$ &  {\tt uuid} & string & unique identifier/object reference \\
 $\mathit{RO}_\mathit{ins}$ &  {\tt VM} & VM ref & the virtual machine \\
 $\mathit{RO}_\mathit{ins}$ &  {\tt backend} & VM ref & the domain where the backend is located \\
-$\mathit{RO}_\mathit{ins}$ &  {\tt instance} & int & the instance number the virtual TPM represents \\
 \hline
 \end{longtable}
 \subsection{Additional RPCs associated with class: VTPM}
index 8cbd786d698ecc5f1af5a911f8cb4ee259a06212..f1d83f6f7e89037d73d3846a59fc7729c67376f8 100644 (file)
@@ -143,6 +143,7 @@ typedef struct xen_vm_record
     char *pci_bus;
     xen_string_string_map *tools_version;
     xen_string_string_map *other_config;
+    bool is_control_domain;
 } xen_vm_record;
 
 /**
@@ -541,6 +542,13 @@ extern bool
 xen_vm_get_other_config(xen_session *session, xen_string_string_map **result, xen_vm vm);
 
 
+/**
+ * Get the is_control_domain field of the given VM.
+ */
+extern bool
+xen_vm_get_is_control_domain(xen_session *session, bool *result, xen_vm vm);
+
+
 /**
  * Set the name/label field of the given VM.
  */
index ad295984cca66b09f59bacaa0371a0f3fa1cdab5..4a7787825f5cf10b0d29694d6e31fbd1da8868b0 100644 (file)
@@ -167,7 +167,10 @@ static const struct_member xen_vm_record_struct_members[] =
           .offset = offsetof(xen_vm_record, tools_version) },
         { .key = "other_config",
           .type = &abstract_type_string_string_map,
-          .offset = offsetof(xen_vm_record, other_config) }
+          .offset = offsetof(xen_vm_record, other_config) },
+        { .key = "is_control_domain",
+          .type = &abstract_type_bool,
+          .offset = offsetof(xen_vm_record, is_control_domain) }
     };
 
 const abstract_type xen_vm_record_abstract_type_ =
@@ -945,6 +948,22 @@ xen_vm_get_other_config(xen_session *session, xen_string_string_map **result, xe
 }
 
 
+bool
+xen_vm_get_is_control_domain(xen_session *session, bool *result, xen_vm vm)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = vm }
+        };
+
+    abstract_type result_type = abstract_type_bool;
+
+    XEN_CALL_("VM.get_is_control_domain");
+    return session->ok;
+}
+
+
 bool
 xen_vm_set_name_label(xen_session *session, xen_vm vm, char *label)
 {
index 0cb40e713320952d577229b8f13bd7dac2439733..1854f4aa19419cf04293d4ddc996857313ee2e9a 100644 (file)
@@ -941,6 +941,7 @@ class XendAPI(object):
                   'VTPMs',
                   'PCI_bus',
                   'tools_version',
+                  'is_control_domain',
                   ]
                   
     VM_attr_rw = ['name_label',
@@ -1175,6 +1176,11 @@ class XendAPI(object):
     def VM_get_other_config(self, session, vm_ref):
         return self.VM_get('otherconfig', session, vm_ref)        
 
+    def VM_get_is_control_domain(self, session, vm_ref):
+        xd = XendDomain.instance()
+        return xen_api_success(
+            xd.get_vm_by_uuid(vm_ref) == xd.privilegedDomain())
+
     def VM_set_name_label(self, session, vm_ref, label):
         dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
         dom.setName(label)
@@ -1346,6 +1352,7 @@ class XendAPI(object):
             'PCI_bus': xeninfo.get_pci_bus(),
             'tools_version': xeninfo.get_tools_version(),
             'other_config': xeninfo.info.get('otherconfig'),
+            'is_control_domain': xeninfo == xendom.privilegedDomain(),
         }
         return xen_api_success(record)