Skip to contentSkip to conversation

New XEN_DOMCTL_set_target and IS_PRIV_FOR

PATCH In review Samuel Thibault 3 participants 8 messages Jan 23, 2008 Arm/actions semi architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 New XEN_DOMCTL_set_target and IS_PRIV_FOR

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.

tools/libxc/xc_domain.c +14 -0
diff -r bcae9d2cc2f8 tools/libxc/xc_domain.c
@@ -875,6 +875,20 @@
     return do_domctl(xc_handle, &domctl);
 }
 
+int xc_domain_set_target(
+    int xc_handle,
+    uint32_t domid,
+    uint32_t target)
+{
+    DECLARE_DOMCTL;
+
+    domctl.cmd = XEN_DOMCTL_set_target;
+    domctl.domain = domid;
+    domctl.u.set_target.target = target;
+
+    return do_domctl(xc_handle, &domctl);
+}
+
 /*
  * Local variables:
  * mode: C
tools/libxc/xenctrl.h +5 -0
@@ -952,4 +952,9 @@
                               uint32_t domid,
                               uint8_t machine_irq);
 
+/* Set the target domain */
+int xc_domain_set_target(int xc_handle,
+                         uint32_t domid,
+                         uint32_t target);
+
 #endif /* XENCTRL_H */
tools/python/xen/lowlevel/xc/xc.c +9 -4
@@ -96,17 +96,17 @@
                                     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 )
@@ -130,6 +130,11 @@
     if ( (ret = xc_domain_create(self->xc_handle, ssidref,
                                  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);
 
tools/python/xen/xend/XendConfig.py +6 -1
@@ -170,6 +170,7 @@
     'platform': dict,
     'tools_version': dict,
     'other_config': dict,
+    'target': int,
     'security_label': str,
     'pci': str,
 }
@@ -336,7 +337,8 @@
             'vbd_refs': [],
             'vtpm_refs': [],
             'other_config': {},
-            'platform': {}
+            'platform': {},
+            'target': 0,
         }
         
         return defaults
@@ -1585,6 +1587,9 @@
     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')
tools/python/xen/xend/XendDomainInfo.py +2 -1
@@ -1640,7 +1640,8 @@
                 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():
tools/python/xen/xm/create.py +5 -1
@@ -521,6 +521,10 @@
           - 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 @@
     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])
xen/arch/ia64/vmx/vmx_hypercall.c +13 -9
@@ -47,15 +47,16 @@
     if ( copy_from_guest(&op, uop, 1) )
         return -EFAULT;
 
-    if ( !IS_PRIV(current->domain) )
-        return -EPERM;
-
     if ( op.isa_irq > 15 )
         return -EINVAL;
 
     d = rcu_lock_domain_by_id(op.domid);
     if ( d == NULL )
         return -ESRCH;
+
+    rc = -EPERM;
+    if ( !IS_PRIV_FOR(current->domain, d) )
+        goto out;
 
     rc = -EINVAL;
     if ( !is_hvm_domain(d) )
@@ -79,15 +80,16 @@
     if ( copy_from_guest(&op, uop, 1) )
         return -EFAULT;
 
-    if ( !IS_PRIV(current->domain) )
-        return -EPERM;
-
     if ( (op.domain > 0) || (op.bus > 0) || (op.device > 31) || (op.intx > 3) )
         return -EINVAL;
 
     d = rcu_lock_domain_by_id(op.domid);
     if ( d == NULL )
         return -ESRCH;
+
+    rc = -EPERM;
+    if ( !IS_PRIV_FOR(current->domain, d) )
+        goto out;
 
     rc = -EINVAL;
     if ( !is_hvm_domain(d) )
@@ -124,13 +126,15 @@
         if (a.domid == DOMID_SELF) {
             d = rcu_lock_current_domain();
         }
-        else if (IS_PRIV(current->domain)) {
+        else {
             d = rcu_lock_domain_by_id(a.domid);
             if (d == NULL)
                 return -ESRCH;
+            if (!IS_PRIV_FOR(current->domain, d)) {
+                rcu_unlock_domain(d);
+                return -EPERM;
+            }
         }
-        else
-            return -EPERM;
 
         if (op == HVMOP_set_param) {
             struct vmx_ioreq_page *iorp;
xen/arch/ia64/xen/dom0_ops.c +42 -4

100 lines not on this page · raw message

xen/arch/ia64/xen/hypercall.c +5 -2
@@ -500,13 +500,15 @@
     struct domain *d;
     long ret = 0;
 
-    if (!IS_PRIV(current->domain))
-        return -EPERM;
     if (copy_from_guest(op, u_debug_op, 1))
         return -EFAULT;
     d = rcu_lock_domain_by_id(domain);
     if (d == NULL)
         return -ESRCH;
+    if (!IS_PRIV_FOR(current->domain, d)) {
+        ret = -EPERM;
+        goto out;
+    }
 
     switch (cmd) {
     case XEN_IA64_DEBUG_OP_SET_FLAGS:
@@ -520,6 +522,7 @@
     default:
         ret = -ENOSYS;
     }
+out:
     rcu_unlock_domain(d);
     return ret;
 }
xen/arch/ia64/xen/mm.c +8 -4
@@ -2787,10 +2787,14 @@
 
         if (xatp.domid == DOMID_SELF)
             d = rcu_lock_current_domain();
-        else if (!IS_PRIV(current->domain))
-            return -EPERM;
-        else if ((d = rcu_lock_domain_by_id(xatp.domid)) == NULL)
-            return -ESRCH;
+        else {
+            if ((d = rcu_lock_domain_by_id(xatp.domid)) == NULL)
+                return -ESRCH;
+            if (!IS_PRIV_FOR(current->domain,d)) {
+                rcu_lock_domain(d);
+                return -EPERM;
+            }
+        }
 
         /* This hypercall is used for VT-i domain only */
         if (!VMX_DOMAIN(d->vcpu[0])) {
xen/arch/ia64/xen/xensetup.c +1 -0
@@ -642,6 +642,7 @@
         panic("Cannot allocate dom0 vcpu 0\n");
 
     dom0->is_privileged = 1;
+    dom0->target = NULL;
 
     /*
      * We're going to setup domain0 using the module(s) that we stashed safely
xen/arch/powerpc/setup.c +1 -0
@@ -375,6 +375,7 @@
     dom0->vcpu[0]->cpu_affinity = cpumask_of_cpu(0);
 
     dom0->is_privileged = 1;
+    dom0->target = NULL;
 
     /* scrub_heap_pages() requires IRQs enabled, and we're post IRQ setup... */
     local_irq_enable();
xen/arch/x86/hvm/hvm.c +20 -14
@@ -1740,15 +1740,16 @@
     if ( copy_from_guest(&op, uop, 1) )
         return -EFAULT;
 
-    if ( !IS_PRIV(current->domain) )
-        return -EPERM;
-
     if ( (op.domain > 0) || (op.bus > 0) || (op.device > 31) || (op.intx > 3) )
         return -EINVAL;
 
     d = rcu_lock_domain_by_id(op.domid);
     if ( d == NULL )
         return -ESRCH;
+
+    rc = -EPERM;
+    if ( !IS_PRIV_FOR(current->domain, d) )
+        goto out;
 
     rc = -EINVAL;
     if ( !is_hvm_domain(d) )
@@ -1787,15 +1788,16 @@
     if ( copy_from_guest(&op, uop, 1) )
         return -EFAULT;
 
-    if ( !IS_PRIV(current->domain) )
-        return -EPERM;
-
     if ( op.isa_irq > 15 )
         return -EINVAL;
 
     d = rcu_lock_domain_by_id(op.domid);
     if ( d == NULL )
         return -ESRCH;
+
+    rc = -EPERM;
+    if ( !IS_PRIV_FOR(current->domain, d) )
+        goto out;
 
     rc = -EINVAL;
     if ( !is_hvm_domain(d) )
@@ -1834,15 +1836,16 @@
     if ( copy_from_guest(&op, uop, 1) )
         return -EFAULT;
 
-    if ( !IS_PRIV(current->domain) )
-        return -EPERM;
-
     if ( (op.link > 3) || (op.isa_irq > 15) )
         return -EINVAL;
 
     d = rcu_lock_domain_by_id(op.domid);
     if ( d == NULL )
         return -ESRCH;
+
+    rc = -EPERM;
+    if ( !IS_PRIV_FOR(current->domain, d) )
+        goto out;
 
     rc = -EINVAL;
     if ( !is_hvm_domain(d) )
@@ -1921,13 +1924,16 @@
 
         if ( a.domid == DOMID_SELF )
             d = rcu_lock_current_domain();
-        else if ( IS_PRIV(current->domain) )
+        else {
             d = rcu_lock_domain_by_id(a.domid);
-        else
-            return -EPERM;
+            if ( d == NULL )
+                return -ESRCH;
+            if ( !IS_PRIV_FOR(current->domain, d) ) {
+                rc = -EPERM;
+                goto param_fail;
+            }
+        }
 
-        if ( d == NULL )
-            return -ESRCH;
 
         rc = -EINVAL;
         if ( !is_hvm_domain(d) )
xen/arch/x86/mm.c +39 -35

106 lines not on this page · raw message

xen/arch/x86/mm/shadow/multi.c +2 -2
@@ -993,11 +993,11 @@
     // not own, we let it succeed anyway.
     //
     if ( unlikely(!res) &&
-         IS_PRIV(d) &&
          !shadow_mode_translate(d) &&
          mfn_valid(mfn = shadow_l1e_get_mfn(sl1e)) &&
          (owner = page_get_owner(mfn_to_page(mfn))) &&
-         (d != owner) )
+         (d != owner) &&
+         IS_PRIV_FOR(d, owner))
     {
         res = get_page_from_l1e(sl1e, owner);
         SHADOW_PRINTK("privileged domain %d installs map of mfn %05lx "
xen/arch/x86/setup.c +1 -0
@@ -959,6 +959,7 @@
         panic("Error creating domain 0\n");
 
     dom0->is_privileged = 1;
+    dom0->target = NULL;
 
     /* Grab the DOM0 command line. */
     cmdline = (char *)(mod[0].string ? __va(mod[0].string) : NULL);
xen/common/domain.c +3 -0
@@ -502,6 +502,9 @@
         if ( (v = d->vcpu[i]) != NULL )
             free_vcpu_struct(v);
 
+    if (d->target)
+        put_domain(d->target);
+
     free_domain(d);
 
     send_guest_global_virq(dom0, VIRQ_DOM_EXC);
xen/common/domctl.c +133 -40

326 lines not on this page · raw message

xen/common/event_channel.c +34 -24

103 lines not on this page · raw message

xen/common/grant_table.c +28 -26

86 lines not on this page · raw message

xen/common/memory.c +28 -12
@@ -232,12 +232,17 @@
         return -EFAULT;
 
     if ( op.domid == DOMID_SELF )
-        op.domid = current->domain->domain_id;
-    else if ( !IS_PRIV(current->domain) )
-        return -EPERM;
+        d = current->domain;
+    else {
+        d = rcu_lock_domain_by_id(op.domid);
+        if ( d == NULL )
+            return -ESRCH;
+        if ( !IS_PRIV_FOR(current->domain, d) ) {
+            rcu_unlock_domain(d);
+            return -EPERM;
+        }
+    }
 
-    if ( (d = rcu_lock_domain_by_id(op.domid)) == NULL )
-        return -ESRCH;
 
     if ( !paging_mode_translate(d) )
     {
@@ -535,9 +540,15 @@
 
         if ( likely(reservation.domid == DOMID_SELF) )
             d = current->domain;
-        else if ( !IS_PRIV(current->domain) ||
-                  ((d = rcu_lock_domain_by_id(reservation.domid)) == NULL) )
-            return start_extent;
+        else {
+            d = rcu_lock_domain_by_id(reservation.domid);
+            if ( d == NULL)
+                return start_extent;
+            if ( !IS_PRIV_FOR(current->domain, d) ) {
+                rcu_unlock_domain(d);
+                return start_extent;
+            }
+        }
         args.domain = d;
 
         rc = xsm_memory_adjust_reservation(current->domain, d);
@@ -589,10 +600,15 @@
 
         if ( likely(domid == DOMID_SELF) )
             d = current->domain;
-        else if ( !IS_PRIV(current->domain) )
-            return -EPERM;
-        else if ( (d = rcu_lock_domain_by_id(domid)) == NULL )
-            return -ESRCH;
+        else {
+            d = rcu_lock_domain_by_id(domid);
+            if ( d == NULL )
+                return -ESRCH;
+            if ( !IS_PRIV_FOR(current->domain, d) ) {
+                rcu_unlock_domain(d);
+                return -EPERM;
+            }
+        }
 
         rc = xsm_memory_stat_reservation(current->domain, d);
         if ( rc )
xen/common/schedule.c +6 -3
@@ -461,9 +461,6 @@
         struct domain *d;
         struct sched_remote_shutdown sched_remote_shutdown;
 
-        if ( !IS_PRIV(current->domain) )
-            return -EPERM;
-
         ret = -EFAULT;
         if ( copy_from_guest(&sched_remote_shutdown, arg, 1) )
             break;
@@ -472,6 +469,12 @@
         d = rcu_lock_domain_by_id(sched_remote_shutdown.domain_id);
         if ( d == NULL )
             break;
+
+        if ( !IS_PRIV_FOR(current->domain, d) )
+        {
+            rcu_unlock_domain(d);
+            return -EPERM;
+        }
 
         ret = xsm_schedop_shutdown(current->domain, d);
         if ( ret )
xen/include/public/domctl.h +12 -0
@@ -554,6 +554,17 @@
 typedef struct xen_domctl_set_opt_feature xen_domctl_set_opt_feature_t;
 DEFINE_XEN_GUEST_HANDLE(xen_domctl_set_opt_feature_t);
 
+/*
+ * Set the target domain for a domain
+ */
+#define XEN_DOMCTL_set_target    46
+struct xen_domctl_set_target {
+    domid_t target;
+};
+typedef struct xen_domctl_set_target xen_domctl_set_target_t;
+DEFINE_XEN_GUEST_HANDLE(xen_domctl_set_target_t);
+
+
 struct xen_domctl {
     uint32_t cmd;
     uint32_t interface_version; /* XEN_DOMCTL_INTERFACE_VERSION */
@@ -590,6 +601,7 @@
         struct xen_domctl_pin_mem_cacheattr pin_mem_cacheattr;
         struct xen_domctl_ext_vcpucontext   ext_vcpucontext;
         struct xen_domctl_set_opt_feature   set_opt_feature;
+        struct xen_domctl_set_target        set_target;
         uint8_t                             pad[128];
     } u;
 };
xen/include/xen/sched.h +3 -0
@@ -187,6 +187,8 @@
     bool_t           is_hvm;
     /* Is this guest fully privileged (aka dom0)? */
     bool_t           is_privileged;
+    /* Which guest this guest has privileges on */
+    struct domain   *target;
     /* Is this guest being debugged by dom0? */
     bool_t           debugger_attached;
     /* Are any VCPUs polling event channels (SCHEDOP_poll)? */
@@ -493,6 +495,7 @@
 }
 
 #define IS_PRIV(_d) ((_d)->is_privileged)
+#define IS_PRIV_FOR(_d, _t) (IS_PRIV(_d) || ((_d)->target && (_d)->target == (_t)))
 
 #ifndef IS_COMPAT
 #define IS_COMPAT(d) 0
xen/xsm/acm/acm_simple_type_enforcement_hooks.c +6 -4
@@ -817,17 +817,19 @@
         return ACM_ACCESS_PERMITTED;
     }
     atomic_inc(&ste_bin_pol.gt_eval_count);
+    subj = current->domain;
+    obj = rcu_lock_domain_by_id(id);
+
     /* a) check authorization (eventually use specific capabilities) */
-    if ( !IS_PRIV(current->domain) )
+    if ( obj && !IS_PRIV_FOR(current->domain, obj) )
     {
         printk("%s: Grant table management authorization denied ERROR!\n",
                __func__);
+        rcu_unlock_domain(obj);
         return ACM_ACCESS_DENIED;
     }
+
     /* b) check types */
-    subj = current->domain;
-    obj = rcu_lock_domain_by_id(id);
-
     if ( share_common_type(subj, obj) )
     {
         cache_result(subj, obj);
#1 lore raw
Quoted 1 line · Samuel Thibault

New XEN_DOMCTL_set_target

This is missing a change to docs/ChangeLog

regards
john

#2 lore raw

PATCH 1/1 New XS_SET_TARGET

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.

---
This patch depends on the previous "New XEN_DOMCTL_set_target and IS_PRIV_FOR" patch.

tools/python/xen/xend/XendDomainInfo.py +19 -1
diff -u b/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py
@@ -47,7 +47,7 @@
 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 @@
     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)
@@ -905,4 +908,8 @@
         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/*
@@ -1694,0 +1702,9 @@
+    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))
+
@@ -1756,6 +1772,8 @@
                 self.native_protocol = channel_details['native_protocol'];
 
             self._introduceDomain()
+            if self.info.target():
+                self._setTarget(self.info.target())
 
             self._createDevices()
 
tools/python/xen/lowlevel/xs/xs.c +31 -0
@@ -619,6 +619,36 @@
     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 @@
     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),
tools/python/xen/xend/image.py +6 -0
@@ -222,6 +222,7 @@
             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 @@
             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 @@
         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))

only in patch2:

tools/python/xen/xend/xenstore/xsutil.py +3 -0
@@ -22,6 +22,9 @@
 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)
 
tools/xenstore/xenstored_core.c +11 -2
@@ -119,6 +119,7 @@
 	case XS_ERROR: return "ERROR";
 	case XS_IS_DOMAIN_INTRODUCED: return "XS_IS_DOMAIN_INTRODUCED";
 	case XS_RESUME: return "RESUME";
+	case XS_SET_TARGET: return "SET_TARGET";
 	default:
 		return "**UNKNOWN**";
 	}
@@ -283,6 +284,8 @@
 				break;
 		close(conn->fd);
 	}
+        if (conn->target)
+                talloc_unlink(conn, conn->target);
 	list_del(&conn->list);
 	trace_destroy(conn, "connection");
 	return 0;
@@ -472,11 +475,13 @@
 		mask &= ~XS_PERM_WRITE;
 
 	/* Owners and tools get it all... */
-	if (!conn->id || perms[0].id == conn->id)
+	if (!conn->id || perms[0].id == conn->id
+                || (conn->target && perms[0].id == conn->target->id))
 		return (XS_PERM_READ|XS_PERM_WRITE|XS_PERM_OWNER) & mask;
 
 	for (i = 1; i < num; i++)
-		if (perms[i].id == conn->id)
+		if (perms[i].id == conn->id
+                        || (conn->target && perms[i].id == conn->target->id))
 			return perms[i].perms & mask;
 
 	return perms[0].perms & mask;
@@ -1245,6 +1250,10 @@
 		do_resume(conn, onearg(in));
 		break;
 
+	case XS_SET_TARGET:
+		do_set_target(conn, in);
+		break;
+
 	default:
 		eprintf("Client unknown operation %i", in->hdr.msg.type);
 		send_error(conn, ENOSYS);
tools/xenstore/xenstored_core.h +3 -0
@@ -84,6 +84,9 @@
 	/* The domain I'm associated with, if any. */
 	struct domain *domain;
 
+        /* The target of the domain I'm associated with. */
+        struct connection *target;
+
 	/* My watches. */
 	struct list_head watches;
 
tools/xenstore/xenstored_domain.c +45 -0

51 lines not on this page · raw message

tools/xenstore/xenstored_domain.h +3 -0
@@ -34,6 +34,9 @@
 /* domid */
 void do_resume(struct connection *conn, const char *domid_str);
 
+/* domid, target */
+void do_set_target(struct connection *conn, struct buffered_data *in);
+
 /* domid */
 void do_get_domain_path(struct connection *conn, const char *domid_str);
 
tools/xenstore/xs.c +19 -0
@@ -708,6 +708,25 @@
 				ARRAY_SIZE(iov), NULL));
 }
 
+bool xs_set_target(struct xs_handle *h,
+			 unsigned int domid, unsigned int target)
+{
+	char domid_str[MAX_STRLEN(domid)];
+	char target_str[MAX_STRLEN(target)];
+	struct iovec iov[2];
+
+	snprintf(domid_str, sizeof(domid_str), "%u", domid);
+	snprintf(target_str, sizeof(target_str), "%u", target);
+
+	iov[0].iov_base = domid_str;
+	iov[0].iov_len = strlen(domid_str) + 1;
+	iov[1].iov_base = target_str;
+	iov[1].iov_len = strlen(target_str) + 1;
+
+	return xs_bool(xs_talkv(h, XBT_NULL, XS_SET_TARGET, iov,
+				ARRAY_SIZE(iov), NULL));
+}
+
 static void * single_with_domid(struct xs_handle *h,
 				enum xsd_sockmsg_type type,
 				unsigned int domid)
tools/xenstore/xs.h +9 -0
@@ -132,6 +132,15 @@
 			 unsigned int domid,
 			 unsigned long mfn,
                          unsigned int eventchn); 
+
+/* Set the target of a domain
+ * This tells the store daemon that a domain is targetting another one, so
+ * it should let it tinker with it.
+ */
+bool xs_set_target(struct xs_handle *h,
+		   unsigned int domid,
+		   unsigned int target);
+
 /* Resume a domain.
  * Clear the shutdown flag for this domain in the store.
  */
xen/include/public/io/xs_wire.h +2 -1
@@ -46,7 +46,8 @@
     XS_WATCH_EVENT,
     XS_ERROR,
     XS_IS_DOMAIN_INTRODUCED,
-    XS_RESUME
+    XS_RESUME,
+    XS_SET_TARGET
 };
 
 #define XS_WRITE_NONE "NONE"
#3 lore raw

Re: [PATCH] New XS_SET_TARGET

Quoted 2 lines · Samuel Thibault

New XS_SET_TARGET
Stubdomains (and probably other domain disagregation elements too) need

This is missing a ChangeLog entry too

regards
john

#4 lore raw
Quoted 10 lines · John Levon, le Wed 23 Jan 2008 14:28:19 +0000, a écrit :
Quoted 1 line · Samuel Thibault

New XEN_DOMCTL_set_target

This is missing a change to docs/ChangeLog

Quoted 2 lines

New XS_SET_TARGET
Stubdomains (and probably other domain disagregation elements too) need

This is missing a ChangeLog entry too

Keir kindly did it for me.

Thanks for the reminder anyway,
Samuel

#5 lore raw

Re: [PATCH] New XS_SET_TARGET

In reply to John Levon

I've taken to documenting in a later changeset as that lets me put in a link to the xenbits web page. I did this already for these two interface changes.

-- Keir

Quoted 14 lines · John Levon
Quoted 2 lines · Samuel Thibault

New XS_SET_TARGET
Stubdomains (and probably other domain disagregation elements too) need

This is missing a ChangeLog entry too

regards
john

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#6 lore raw

Re: [PATCH] New XS_SET_TARGET

Quoted 2 lines · Keir Fraser

I've taken to documenting in a later changeset as that lets me put in a link to the xenbits web page. I did this already for these two interface changes.

OK. So what should people submitting patches do? Put the changelog entry as part of the email message?

cheers,
john

#7 lore raw

Re: [PATCH] New XS_SET_TARGET

Quoted 7 lines · John Levon
Quoted 2 lines · Keir Fraser

I've taken to documenting in a later changeset as that lets me put in a link to the xenbits web page. I did this already for these two interface changes.

OK. So what should people submitting patches do? Put the changelog entry as part of the email message?

It's helpful to at least point out that a changelog entry is needed. If they want to provide text that's great, otherwise it's not really hard to synthesize something appropriate from the patch comment.

-- Keir