New XS_SET_TARGET

Stubdomains (and probably other domain disagregation elements too)
need to be able to tinker with another domain.  This adds
XS_SET_TARGET so that XenStore allows domains to have permissions on
files on which the "target" has permissions.  This also adds
xs_set_target, called by the domain builder when the 'target' option
is used in the configuration.

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
This commit is contained in:
Keir Fraser committed 2008-01-23 13:22:13 +00:00
1 parent 47fcfcb75b
commit f9f9329313
11 files changed
+151 -4

No files matched your search

+31
View File
@@ -619,6 +619,36 @@ static PyObject *xspy_introduce_domain(XsHandle *self, PyObject *args)
return none(result);
}
#define xspy_set_target_doc "\n" \
"Tell xenstore that a domain is targetting another one so it\n" \
"should let it tinker with it.\n" \
" dom [int] : domain id\n" \
" target [int] : domain id of the target\n" \
"\n" \
"Returns None on success.\n" \
"Raises xen.lowlevel.xs.Error on error.\n" \
"\n"
static PyObject *xspy_set_target(XsHandle *self, PyObject *args)
{
uint32_t dom;
uint32_t target;
struct xs_handle *xh = xshandle(self);
bool result = 0;
if (!xh)
return NULL;
if (!PyArg_ParseTuple(args, "ii", &dom, &target))
return NULL;
Py_BEGIN_ALLOW_THREADS
result = xs_set_target(xh, dom, target);
Py_END_ALLOW_THREADS
return none(result);
}
#define xspy_resume_domain_doc "\n" \
"Tell xenstore to clear its shutdown flag for a domain.\n" \
"This ensures that a subsequent shutdown will fire the\n" \
@@ -817,6 +847,7 @@ static PyMethodDef xshandle_methods[] = {
XSPY_METH(transaction_start, METH_NOARGS),
XSPY_METH(transaction_end, METH_VARARGS | METH_KEYWORDS),
XSPY_METH(introduce_domain, METH_VARARGS),
XSPY_METH(set_target, METH_VARARGS),
XSPY_METH(resume_domain, METH_VARARGS),
XSPY_METH(release_domain, METH_VARARGS),
XSPY_METH(close, METH_NOARGS),
+19 -1
View File
@@ -47,7 +47,7 @@ from xen.xend.XendError import XendError, VmError
from xen.xend.XendDevices import XendDevices
from xen.xend.XendTask import XendTask
from xen.xend.xenstore.xstransact import xstransact, complete
from xen.xend.xenstore.xsutil import GetDomainPath, IntroduceDomain, ResumeDomain
from xen.xend.xenstore.xsutil import GetDomainPath, IntroduceDomain, SetTarget, ResumeDomain
from xen.xend.xenstore.xswatch import xswatch
from xen.xend.XendConstants import *
from xen.xend.XendAPIConstants import *
@@ -883,6 +883,9 @@ class XendDomainInfo:
def storeVm(self, *args):
return xstransact.Store(self.vmpath, *args)
def permissionsVm(self, *args):
return xstransact.SetPermissions(self.vmpath, *args)
def _readVmTxn(self, transaction, *args):
paths = map(lambda x: self.vmpath + "/" + x, args)
@@ -904,6 +907,10 @@ class XendDomainInfo:
paths = map(lambda x: self.vmpath + "/" + x, args)
return transaction.store(*paths)
def permissionsVmTxn(self, transaction, *args):
paths = map(lambda x: self.vmpath + "/" + x, args)
return transaction.set_permissions(*paths)
#
# Function to update xenstore /dom/*
#
@@ -1692,6 +1699,15 @@ class XendDomainInfo:
except RuntimeError, exn:
raise XendError(str(exn))
def _setTarget(self, target):
assert self.domid is not None
try:
SetTarget(self.domid, target)
self.storeDom('target', target)
except RuntimeError, exn:
raise XendError(str(exn))
def _initDomain(self):
log.debug('XendDomainInfo.initDomain: %s %s',
@@ -1756,6 +1772,8 @@ class XendDomainInfo:
self.native_protocol = channel_details['native_protocol'];
self._introduceDomain()
if self.info.target():
self._setTarget(self.info.target())
self._createDevices()
+6
View File
@@ -222,6 +222,7 @@ class ImageHandler:
vncopts = ""
if passwd:
self.vm.storeVm("vncpasswd", passwd)
self.vm.permissionsVm("vncpasswd", { 'dom': self.vm.getDomid(), 'read': True } )
vncopts = vncopts + ",password"
log.debug("Stored a VNC password for vfb access")
else:
@@ -280,6 +281,9 @@ class ImageHandler:
env['XAUTHORITY'] = self.xauthority
if self.vncconsole:
args = args + ([ "-vncviewer" ])
xstransact.Mkdir("/local/domain/0/device-model/%i" % self.vm.getDomid())
xstransact.SetPermissions("/local/domain/0/device-model/%i" % self.vm.getDomid(),
{ 'dom': self.vm.getDomid(), 'read': True, 'write': True })
log.info("spawning device models: %s %s", self.device_model, args)
# keep track of pid and spawned options to kill it later
self.pid = os.spawnve(os.P_NOWAIT, self.device_model, args, env)
@@ -422,7 +426,9 @@ class HVMImageHandler(ImageHandler):
self.vm.storeVm(("image/dmargs", " ".join(self.dmargs)),
("image/device-model", self.device_model),
("image/display", self.display))
self.vm.permissionsVm("image/dmargs", { 'dom': self.vm.getDomid(), 'read': True } )
self.vm.storeVm(("rtc/timeoffset", rtc_timeoffset))
self.vm.permissionsVm("rtc/timeoffset", { 'dom': self.vm.getDomid(), 'read': True } )
self.apic = int(vmConfig['platform'].get('apic', 0))
self.acpi = int(vmConfig['platform'].get('acpi', 0))
+3
View File
@@ -22,6 +22,9 @@ def xshandle():
def IntroduceDomain(domid, page, port):
return xshandle().introduce_domain(domid, page, port)
def SetTarget(domid, target):
return xshandle().set_target(domid, target)
def GetDomainPath(domid):
return xshandle().get_domain_path(domid)
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.