ia64/xen-unstable

changeset 14121:532a25342a30

Added a VM.domid field.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Sun Feb 25 22:31:43 2007 +0000 (2007-02-25)
parents 8c8d91a006ba
children cfd23ac1b32a
files docs/xen-api/xenapi-datamodel.tex tools/libxen/include/xen_vm.h tools/libxen/src/xen_vm.c tools/python/xen/xend/XendAPI.py
line diff
     1.1 --- a/docs/xen-api/xenapi-datamodel.tex	Sun Feb 25 22:02:12 2007 +0000
     1.2 +++ b/docs/xen-api/xenapi-datamodel.tex	Sun Feb 25 22:31:43 2007 +0000
     1.3 @@ -1100,6 +1100,7 @@ Quals & Field & Type & Description \\
     1.4  $\mathit{RO}_\mathit{ins}$ &  {\tt PCI\_bus} & string & PCI bus path for pass-through devices \\
     1.5  $\mathit{RO}_\mathit{run}$ &  {\tt tools\_version} & (string $\rightarrow$ string) Map & versions of installed paravirtualised drivers \\
     1.6  $\mathit{RW}$ &  {\tt other\_config} & (string $\rightarrow$ string) Map & additional configuration \\
     1.7 +$\mathit{RO}_\mathit{run}$ &  {\tt domid} & int & domain ID (if available, -1 otherwise) \\
     1.8  $\mathit{RO}_\mathit{run}$ &  {\tt is\_control\_domain} & bool & true if this is a control domain (domain 0 or a driver domain) \\
     1.9  $\mathit{RO}_\mathit{run}$ &  {\tt metrics} & VM\_metrics ref & metrics associated with this VM. \\
    1.10  \hline
    1.11 @@ -3969,6 +3970,38 @@ void
    1.12  \vspace{0.3cm}
    1.13  \vspace{0.3cm}
    1.14  \vspace{0.3cm}
    1.15 +\subsubsection{RPC name:~get\_domid}
    1.16 +
    1.17 +{\bf Overview:} 
    1.18 +Get the domid field of the given VM.
    1.19 +
    1.20 + \noindent {\bf Signature:} 
    1.21 +\begin{verbatim} int get_domid (session_id s, VM ref self)\end{verbatim}
    1.22 +
    1.23 +
    1.24 +\noindent{\bf Arguments:}
    1.25 +
    1.26 + 
    1.27 +\vspace{0.3cm}
    1.28 +\begin{tabular}{|c|c|p{7cm}|}
    1.29 + \hline
    1.30 +{\bf type} & {\bf name} & {\bf description} \\ \hline
    1.31 +{\tt VM ref } & self & reference to the object \\ \hline 
    1.32 +
    1.33 +\end{tabular}
    1.34 +
    1.35 +\vspace{0.3cm}
    1.36 +
    1.37 + \noindent {\bf Return Type:} 
    1.38 +{\tt 
    1.39 +int
    1.40 +}
    1.41 +
    1.42 +
    1.43 +value of the field
    1.44 +\vspace{0.3cm}
    1.45 +\vspace{0.3cm}
    1.46 +\vspace{0.3cm}
    1.47  \subsubsection{RPC name:~get\_is\_control\_domain}
    1.48  
    1.49  {\bf Overview:} 
     2.1 --- a/tools/libxen/include/xen_vm.h	Sun Feb 25 22:02:12 2007 +0000
     2.2 +++ b/tools/libxen/include/xen_vm.h	Sun Feb 25 22:31:43 2007 +0000
     2.3 @@ -146,6 +146,7 @@ typedef struct xen_vm_record
     2.4      char *pci_bus;
     2.5      xen_string_string_map *tools_version;
     2.6      xen_string_string_map *other_config;
     2.7 +    int64_t domid;
     2.8      bool is_control_domain;
     2.9      struct xen_vm_metrics_record_opt *metrics;
    2.10  } xen_vm_record;
    2.11 @@ -547,6 +548,13 @@ xen_vm_get_other_config(xen_session *ses
    2.12  
    2.13  
    2.14  /**
    2.15 + * Get the domid field of the given VM.
    2.16 + */
    2.17 +extern bool
    2.18 +xen_vm_get_domid(xen_session *session, int64_t *result, xen_vm vm);
    2.19 +
    2.20 +
    2.21 +/**
    2.22   * Get the is_control_domain field of the given VM.
    2.23   */
    2.24  extern bool
     3.1 --- a/tools/libxen/src/xen_vm.c	Sun Feb 25 22:02:12 2007 +0000
     3.2 +++ b/tools/libxen/src/xen_vm.c	Sun Feb 25 22:31:43 2007 +0000
     3.3 @@ -168,6 +168,9 @@ static const struct_member xen_vm_record
     3.4          { .key = "other_config",
     3.5            .type = &abstract_type_string_string_map,
     3.6            .offset = offsetof(xen_vm_record, other_config) },
     3.7 +        { .key = "domid",
     3.8 +          .type = &abstract_type_int,
     3.9 +          .offset = offsetof(xen_vm_record, domid) },
    3.10          { .key = "is_control_domain",
    3.11            .type = &abstract_type_bool,
    3.12            .offset = offsetof(xen_vm_record, is_control_domain) },
    3.13 @@ -953,6 +956,22 @@ xen_vm_get_other_config(xen_session *ses
    3.14  
    3.15  
    3.16  bool
    3.17 +xen_vm_get_domid(xen_session *session, int64_t *result, xen_vm vm)
    3.18 +{
    3.19 +    abstract_value param_values[] =
    3.20 +        {
    3.21 +            { .type = &abstract_type_string,
    3.22 +              .u.string_val = vm }
    3.23 +        };
    3.24 +
    3.25 +    abstract_type result_type = abstract_type_int;
    3.26 +
    3.27 +    XEN_CALL_("VM.get_domid");
    3.28 +    return session->ok;
    3.29 +}
    3.30 +
    3.31 +
    3.32 +bool
    3.33  xen_vm_get_is_control_domain(xen_session *session, bool *result, xen_vm vm)
    3.34  {
    3.35      abstract_value param_values[] =
     4.1 --- a/tools/python/xen/xend/XendAPI.py	Sun Feb 25 22:02:12 2007 +0000
     4.2 +++ b/tools/python/xen/xend/XendAPI.py	Sun Feb 25 22:31:43 2007 +0000
     4.3 @@ -1000,6 +1000,7 @@ class XendAPI(object):
     4.4                    'VTPMs',
     4.5                    'PCI_bus',
     4.6                    'tools_version',
     4.7 +                  'domid',
     4.8                    'is_control_domain',
     4.9                    ]
    4.10                    
    4.11 @@ -1240,6 +1241,10 @@ class XendAPI(object):
    4.12      def VM_get_other_config(self, session, vm_ref):
    4.13          return self.VM_get('other_config', session, vm_ref)        
    4.14  
    4.15 +    def VM_get_domid(self, _, ref):
    4.16 +        domid = XendDomain.instance().get_vm_by_uuid(ref).getDomid()
    4.17 +        return xen_api_success(domid is None and -1 or domid)
    4.18 +
    4.19      def VM_get_is_control_domain(self, session, vm_ref):
    4.20          xd = XendDomain.instance()
    4.21          return xen_api_success(
    4.22 @@ -1396,7 +1401,9 @@ class XendAPI(object):
    4.23          xeninfo = xendom.get_vm_by_uuid(vm_ref)
    4.24          if not xeninfo:
    4.25              return xen_api_error(['HANDLE_INVALID', 'VM', vm_ref])
    4.26 -        
    4.27 +
    4.28 +        domid = xeninfo.getDomid()
    4.29 +
    4.30          record = {
    4.31              'uuid': xeninfo.get_uuid(),
    4.32              'power_state': xeninfo.get_power_state(),
    4.33 @@ -1439,6 +1446,7 @@ class XendAPI(object):
    4.34              'PCI_bus': xeninfo.get_pci_bus(),
    4.35              'tools_version': xeninfo.get_tools_version(),
    4.36              'other_config': xeninfo.info.get('other_config', {}),
    4.37 +            'domid': domid is None and -1 or domid,
    4.38              'is_control_domain': xeninfo == xendom.privilegedDomain(),
    4.39          }
    4.40          return xen_api_success(record)