[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Remove memory and cpu parameters from DOM0_CREATEDOMAIN, and remove



ChangeSet 1.1367, 2005/04/22 17:10:53+01:00, kaf24@xxxxxxxxxxxxxxxxxxxx

        Remove memory and cpu parameters from DOM0_CREATEDOMAIN, and remove
        DOM0_SETINITIALMEM. You can get the same effect via PINCPU, 
        SETMAXMEM, and do_mem_op(increase_reservation).
        Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>



 tools/libxc/xc.h              |    4 -
 tools/libxc/xc_domain.c       |   46 +++++++++++++---------
 tools/libxc/xc_private.h      |   53 ++++++++++++++------------
 xen/arch/ia64/dom0_ops.c      |    2 
 xen/arch/x86/dom0_ops.c       |    2 
 xen/common/dom0_ops.c         |   85 +++++++++++++-----------------------------
 xen/common/dom_mem_ops.c      |   10 ++--
 xen/common/domain.c           |   25 ------------
 xen/include/asm-ia64/mm.h     |    1 
 xen/include/public/dom0_ops.h |   16 -------
 10 files changed, 90 insertions(+), 154 deletions(-)


diff -Nru a/tools/libxc/xc.h b/tools/libxc/xc.h
--- a/tools/libxc/xc.h  2005-04-22 13:03:49 -04:00
+++ b/tools/libxc/xc.h  2005-04-22 13:03:49 -04:00
@@ -353,10 +353,6 @@
 int xc_sched_id(int xc_handle,
                 int *sched_id);
 
-int xc_domain_setinitialmem(int xc_handle,
-                            u32 domid, 
-                            unsigned int initial_memkb);
-
 int xc_domain_setmaxmem(int xc_handle,
                         u32 domid, 
                         unsigned int max_memkb);
diff -Nru a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c
--- a/tools/libxc/xc_domain.c   2005-04-22 13:03:49 -04:00
+++ b/tools/libxc/xc_domain.c   2005-04-22 13:03:49 -04:00
@@ -14,22 +14,42 @@
                      float cpu_weight,
                      u32 *pdomid)
 {
-    int err;
+    int err, errno_saved;
     dom0_op_t op;
 
     op.cmd = DOM0_CREATEDOMAIN;
     op.u.createdomain.domain = (domid_t)*pdomid;
-    op.u.createdomain.memory_kb = mem_kb;
-    op.u.createdomain.cpu = cpu;
+    if ( (err = do_dom0_op(xc_handle, &op)) != 0 )
+        return err;
 
-    if ( (err = do_dom0_op(xc_handle, &op)) == 0 )
+    *pdomid = (u16)op.u.createdomain.domain;
+
+    if ( (cpu != -1) &&
+         ((err = xc_domain_pincpu(xc_handle, *pdomid, cpu)) != 0) )
+        goto fail;
+
+    if ( (err = xc_domain_setcpuweight(xc_handle, *pdomid, cpu_weight)) != 0 )
+        goto fail;
+
+    if ( (err = xc_domain_setmaxmem(xc_handle, *pdomid, mem_kb)) != 0 )
+        goto fail;
+
+    if ( (err = do_dom_mem_op(xc_handle, MEMOP_increase_reservation,
+                              NULL, mem_kb/4, 0, *pdomid)) != (mem_kb/4) )
     {
-        *pdomid = (u16)op.u.createdomain.domain;
-        
-         err = xc_domain_setcpuweight(xc_handle, *pdomid, cpu_weight);
+        if ( err > 0 )
+            errno = ENOMEM;
+        err = -1;
+        goto fail;
     }
 
     return err;
+
+ fail:
+    errno_saved = errno;
+    (void)xc_domain_destroy(xc_handle, *pdomid);
+    errno = errno_saved;
+    return err;
 }    
 
 
@@ -211,18 +231,6 @@
     }
 
     return ret;
-}
-
-
-int xc_domain_setinitialmem(int xc_handle,
-                            u32 domid, 
-                            unsigned int initial_memkb)
-{
-    dom0_op_t op;
-    op.cmd = DOM0_SETDOMAININITIALMEM;
-    op.u.setdomaininitialmem.domain = (domid_t)domid;
-    op.u.setdomaininitialmem.initial_memkb = initial_memkb;
-    return do_dom0_op(xc_handle, &op);
 }
 
 int xc_domain_setmaxmem(int xc_handle,
diff -Nru a/tools/libxc/xc_private.h b/tools/libxc/xc_private.h
--- a/tools/libxc/xc_private.h  2005-04-22 13:03:49 -04:00
+++ b/tools/libxc/xc_private.h  2005-04-22 13:03:49 -04:00
@@ -72,7 +72,7 @@
 
 static inline int do_dom0_op(int xc_handle, dom0_op_t *op)
 {
-    int ret = -1, retries = 0;
+    int ret = -1, errno_saved;
     privcmd_hypercall_t hypercall;
 
     op->interface_version = DOM0_INTERFACE_VERSION;
@@ -86,26 +86,19 @@
         goto out1;
     }
 
- again:
     if ( (ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 )
     {
-        if ( (errno == EAGAIN) && (retries++ < 10) )
-        {
-            /*
-             * This was added for memory allocation, where we can get EAGAIN
-             * if memory is unavailable because it is on the scrub list.
-             */
-            sleep(1);
-            goto again;
-        }
         if ( errno == EACCES )
             fprintf(stderr, "Dom0 operation failed -- need to"
                     " rebuild the user-space tool set?\n");
-        goto out2;
     }
 
- out2: (void)munlock(op, sizeof(*op));
- out1: return ret;
+    errno_saved = errno;
+    (void)munlock(op, sizeof(*op));
+    errno = errno_saved;
+
+ out1:
+    return ret;
 }
 
 static inline int do_dom_mem_op(int            xc_handle,
@@ -117,7 +110,8 @@
 {
     privcmd_hypercall_t hypercall;
     long ret = -EINVAL;
-       
+    int errno_saved;
+
     hypercall.op     = __HYPERVISOR_dom_mem_op;
     hypercall.arg[0] = (unsigned long)memop;
     hypercall.arg[1] = (unsigned long)extent_list;
@@ -125,7 +119,8 @@
     hypercall.arg[3] = (unsigned long)extent_order;
     hypercall.arg[4] = (unsigned long)domid;
 
-    if ( mlock(extent_list, nr_extents*sizeof(unsigned long)) != 0 )
+    if ( (extent_list != NULL) && 
+         (mlock(extent_list, nr_extents*sizeof(unsigned long)) != 0) )
     {
         PERROR("Could not lock memory for Xen hypercall");
         goto out1;
@@ -134,12 +129,18 @@
     if ( (ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 )
     {
        fprintf(stderr, "Dom_mem operation failed (rc=%ld errno=%d)-- need to"
-                    " rebuild the user-space tool set?\n",ret,errno);
-        goto out2;
+                " rebuild the user-space tool set?\n",ret,errno);
+    }
+
+    if ( extent_list != NULL )
+    {
+        errno_saved = errno;
+        (void)munlock(extent_list, nr_extents*sizeof(unsigned long));
+        errno = errno_saved;
     }
 
- out2: (void)munlock(extent_list, nr_extents*sizeof(unsigned long));
- out1: return ret;
+ out1:
+    return ret;
 }    
 
 static inline int do_mmuext_op(
@@ -150,7 +151,8 @@
 {
     privcmd_hypercall_t hypercall;
     long ret = -EINVAL;
-       
+    int errno_saved;
+
     hypercall.op     = __HYPERVISOR_mmuext_op;
     hypercall.arg[0] = (unsigned long)op;
     hypercall.arg[1] = (unsigned long)nr_ops;
@@ -167,11 +169,14 @@
     {
        fprintf(stderr, "Dom_mem operation failed (rc=%ld errno=%d)-- need to"
                     " rebuild the user-space tool set?\n",ret,errno);
-        goto out2;
     }
 
- out2: (void)munlock(op, nr_ops*sizeof(*op));
- out1: return ret;
+    errno_saved = errno;
+    (void)munlock(op, nr_ops*sizeof(*op));
+    errno = errno_saved;
+
+ out1:
+    return ret;
 }    
 
 
diff -Nru a/xen/arch/ia64/dom0_ops.c b/xen/arch/ia64/dom0_ops.c
--- a/xen/arch/ia64/dom0_ops.c  2005-04-22 13:03:49 -04:00
+++ b/xen/arch/ia64/dom0_ops.c  2005-04-22 13:03:49 -04:00
@@ -24,8 +24,6 @@
 #define TRC_DOM0OP_ENTER_BASE  0x00020000
 #define TRC_DOM0OP_LEAVE_BASE  0x00030000
 
-extern unsigned int alloc_new_dom_mem(struct domain *, unsigned int);
-
 static int msr_cpu_mask;
 static unsigned long msr_addr;
 static unsigned long msr_lo;
diff -Nru a/xen/arch/x86/dom0_ops.c b/xen/arch/x86/dom0_ops.c
--- a/xen/arch/x86/dom0_ops.c   2005-04-22 13:03:49 -04:00
+++ b/xen/arch/x86/dom0_ops.c   2005-04-22 13:03:49 -04:00
@@ -26,8 +26,6 @@
 #define TRC_DOM0OP_ENTER_BASE  0x00020000
 #define TRC_DOM0OP_LEAVE_BASE  0x00030000
 
-extern unsigned int alloc_new_dom_mem(struct domain *, unsigned int);
-
 static int msr_cpu_mask;
 static unsigned long msr_addr;
 static unsigned long msr_lo;
diff -Nru a/xen/common/dom0_ops.c b/xen/common/dom0_ops.c
--- a/xen/common/dom0_ops.c     2005-04-22 13:03:49 -04:00
+++ b/xen/common/dom0_ops.c     2005-04-22 13:03:49 -04:00
@@ -19,7 +19,6 @@
 #include <xen/physdev.h>
 #include <public/sched_ctl.h>
 
-extern unsigned int alloc_new_dom_mem(struct domain *, unsigned int);
 extern long arch_do_dom0_op(dom0_op_t *op, dom0_op_t *u_dom0_op);
 extern void arch_getdomaininfo_ctxt(
     struct exec_domain *, full_execution_context_t *);
@@ -153,9 +152,12 @@
 
     case DOM0_CREATEDOMAIN:
     {
-        struct domain *d;
-        unsigned int   pro;
-        domid_t        dom;
+        struct domain      *d;
+        unsigned int        pro;
+        domid_t             dom;
+        struct exec_domain *ed;
+        unsigned int        i, ht, cnt[NR_CPUS] = { 0 };
+

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.