WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] xend: Properly interpret vcpu_avail Long

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xend: Properly interpret vcpu_avail Long Integer in xc.hvm_build().
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 20 Jan 2010 01:40:13 -0800
Delivery-date: Wed, 20 Jan 2010 01:40:11 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1263980039 0
# Node ID 49a2c1069e140fb7f3f1a1c559fadeb0fd9b8af8
# Parent  07f95839e4313e3b59a4c9e1ea67b0643a096376
xend: Properly interpret vcpu_avail Long Integer in xc.hvm_build().

Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 tools/python/xen/lowlevel/xc/xc.c |   39 +++++++++++++++++++++++++++++++-------
 1 files changed, 32 insertions(+), 7 deletions(-)

diff -r 07f95839e431 -r 49a2c1069e14 tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Tue Jan 19 15:44:54 2010 +0000
+++ b/tools/python/xen/lowlevel/xc/xc.c Wed Jan 20 09:33:59 2010 +0000
@@ -911,19 +911,45 @@ static PyObject *pyxc_hvm_build(XcObject
 #if !defined(__ia64__)
     struct hvm_info_table *va_hvm;
     uint8_t *va_map, sum;
+#endif
     int i;
-#endif
     char *image;
     int memsize, target=-1, vcpus = 1, acpi = 0, apic = 1;
-    uint64_t vcpu_avail = 1;
+    PyObject *vcpu_avail_handle = NULL;
+    uint8_t vcpu_avail[HVM_MAX_VCPUS/8];
 
     static char *kwd_list[] = { "domid",
                                 "memsize", "image", "target", "vcpus", 
                                 "vcpu_avail", "acpi", "apic", NULL };
-    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|iilii", kwd_list,
+    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|iiOii", kwd_list,
                                       &dom, &memsize, &image, &target, &vcpus,
-                                      &vcpu_avail, &acpi, &apic) )
-        return NULL;
+                                      &vcpu_avail_handle, &acpi, &apic) )
+        return NULL;
+
+    memset(vcpu_avail, 0, sizeof(vcpu_avail));
+    vcpu_avail[0] = 1;
+    if ( vcpu_avail_handle != NULL )
+    {
+        if ( PyInt_Check(vcpu_avail_handle) )
+        {
+            unsigned long v = PyInt_AsLong(vcpu_avail_handle);
+            for ( i = 0; i < sizeof(long)/8; i++ )
+                vcpu_avail[i] = (uint8_t)(v>>(i*8));
+        }
+        else if ( PyLong_Check(vcpu_avail_handle) )
+        {
+            if ( _PyLong_AsByteArray((PyLongObject *)vcpu_avail_handle,
+                                     (unsigned char *)vcpu_avail,
+                                     sizeof(vcpu_avail), 1, 0) )
+                return NULL;
+        }
+        else
+        {
+            errno = EINVAL;
+            PyErr_SetFromErrno(xc_error_obj);
+            return NULL;
+        }
+    }
 
     if ( target == -1 )
         target = memsize;
@@ -943,8 +969,7 @@ static PyObject *pyxc_hvm_build(XcObject
     va_hvm->acpi_enabled = acpi;
     va_hvm->apic_mode    = apic;
     va_hvm->nr_vcpus     = vcpus;
-    ((uint64_t *)va_hvm->vcpu_online)[0] = vcpu_avail;
-    ((uint64_t *)va_hvm->vcpu_online)[1] = 0;    
+    memcpy(va_hvm->vcpu_online, vcpu_avail, sizeof(vcpu_avail));
     for ( i = 0, sum = 0; i < va_hvm->length; i++ )
         sum += ((uint8_t *)va_hvm)[i];
     va_hvm->checksum -= sum;

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xend: Properly interpret vcpu_avail Long Integer in xc.hvm_build()., Xen patchbot-unstable <=