mirror of
https://github.com/xen-project/xen.git
synced 2026-10-30 03:00:05 +01:00
New XEN_DOMCTL_set_target
Stubdomains (and probably other domain disagregation elements too) need to be able to tinker with another domain. This adds IS_PRIV_FOR that extends IS_PRIV by allowing domains to have privileges over a given "target" domain. XEN_DOMCTL_set_target permits to set this "target". A new 'target' configuration option makes the domain builder use it. Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
This commit is contained in:
1 parent
d352a2fb4d
commit
47fcfcb75b
25 files changed
+430
-190
No files matched your search
@@ -96,17 +96,17 @@ static PyObject *pyxc_domain_create(XcObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwds)
|
||||
{
|
||||
uint32_t dom = 0, ssidref = 0, flags = 0;
|
||||
uint32_t dom = 0, ssidref = 0, flags = 0, target = 0;
|
||||
int ret, i, hvm = 0;
|
||||
PyObject *pyhandle = NULL;
|
||||
xen_domain_handle_t handle = {
|
||||
0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef,
|
||||
0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef };
|
||||
|
||||
static char *kwd_list[] = { "domid", "ssidref", "handle", "hvm", NULL };
|
||||
static char *kwd_list[] = { "domid", "ssidref", "handle", "hvm", "target", NULL };
|
||||
|
||||
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|iiOi", kwd_list,
|
||||
&dom, &ssidref, &pyhandle, &hvm))
|
||||
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|iiOii", kwd_list,
|
||||
&dom, &ssidref, &pyhandle, &hvm, &target))
|
||||
return NULL;
|
||||
|
||||
if ( pyhandle != NULL )
|
||||
@@ -131,6 +131,11 @@ static PyObject *pyxc_domain_create(XcObject *self,
|
||||
handle, flags, &dom)) < 0 )
|
||||
return pyxc_error_to_exception();
|
||||
|
||||
if ( target )
|
||||
if ( (ret = xc_domain_set_target(self->xc_handle, dom, target)) < 0 )
|
||||
return pyxc_error_to_exception();
|
||||
|
||||
|
||||
return PyInt_FromLong(dom);
|
||||
|
||||
out_exception:
|
||||
|
||||
@@ -170,6 +170,7 @@ XENAPI_CFG_TYPES = {
|
||||
'platform': dict,
|
||||
'tools_version': dict,
|
||||
'other_config': dict,
|
||||
'target': int,
|
||||
'security_label': str,
|
||||
'pci': str,
|
||||
}
|
||||
@@ -336,7 +337,8 @@ class XendConfig(dict):
|
||||
'vbd_refs': [],
|
||||
'vtpm_refs': [],
|
||||
'other_config': {},
|
||||
'platform': {}
|
||||
'platform': {},
|
||||
'target': 0,
|
||||
}
|
||||
|
||||
return defaults
|
||||
@@ -1585,6 +1587,9 @@ class XendConfig(dict):
|
||||
def is_hvm(self):
|
||||
return self['HVM_boot_policy'] != ''
|
||||
|
||||
def target(self):
|
||||
return self['target']
|
||||
|
||||
def image_type(self):
|
||||
stored_type = self['platform'].get('image_type')
|
||||
return stored_type or (self.is_hvm() and 'hvm' or 'linux')
|
||||
@@ -1640,7 +1640,8 @@ class XendDomainInfo:
|
||||
domid = 0,
|
||||
ssidref = ssidref,
|
||||
handle = uuid.fromString(self.info['uuid']),
|
||||
hvm = int(hvm))
|
||||
hvm = int(hvm),
|
||||
target = self.info.target())
|
||||
except Exception, e:
|
||||
# may get here if due to ACM the operation is not permitted
|
||||
if security.on():
|
||||
|
||||
@@ -521,6 +521,10 @@ gopts.var('on_xend_stop', val='ignore|shutdown|suspend',
|
||||
- suspend: Domain is suspended;
|
||||
""")
|
||||
|
||||
gopts.var('target', val='TARGET',
|
||||
fn=set_int, default=0,
|
||||
use="Set domain target.")
|
||||
|
||||
def err(msg):
|
||||
"""Print an error to stderr and exit.
|
||||
"""
|
||||
@@ -748,7 +752,7 @@ def make_config(vals):
|
||||
map(add_conf, ['name', 'memory', 'maxmem', 'shadow_memory',
|
||||
'restart', 'on_poweroff',
|
||||
'on_reboot', 'on_crash', 'vcpus', 'vcpu_avail', 'features',
|
||||
'on_xend_start', 'on_xend_stop'])
|
||||
'on_xend_start', 'on_xend_stop', 'target'])
|
||||
|
||||
if vals.uuid is not None:
|
||||
config.append(['uuid', vals.uuid])
|
||||
|
||||