File xend-cpumaps.patch of Package libvirt

commit fa1ceca23214373e947452e6fe95771a4e467744
Author: Daniel Veillard <veillard@redhat.com>
Date:   Thu May 14 10:31:11 2009 +0000

    * src/xend_internal.c: remove [] around cpumaps for recent xend
      patch by Tatsuro Enokura
    daniel

Index: libvirt-0.4.6/src/xend_internal.c
===================================================================
--- libvirt-0.4.6.orig/src/xend_internal.c
+++ libvirt-0.4.6/src/xend_internal.c
@@ -3693,6 +3693,11 @@ xenDaemonDomainSetVcpus(virDomainPtr dom
  * @maplen: length of cpumap in bytes
  *
  * Dynamically change the real CPUs which can be allocated to a virtual CPU.
+ * NOTE: The XenD cpu affinity map format changed from "[0,1,2]" to
+ *       "0,1,2"
+ *       the XenD cpu affinity works only after cset 19579.
+ *       there is no fine grained xend version detection possible, so we
+ *       use the old format for anything before version 3
  *
  * Returns 0 for success; -1 (with errno) on error
  */
@@ -3700,8 +3705,9 @@ int
 xenDaemonDomainPinVcpu(virDomainPtr domain, unsigned int vcpu,
                      unsigned char *cpumap, int maplen)
 {
-    char buf[VIR_UUID_BUFLEN], mapstr[sizeof(cpumap_t) * 64] = "[";
+    char buf[VIR_UUID_BUFLEN], mapstr[sizeof(cpumap_t) * 64];
     int i, j;
+    xenUnifiedPrivatePtr priv;
 
     if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)
      || (cpumap == NULL) || (maplen < 1) || (maplen > (int)sizeof(cpumap_t))) {
@@ -3710,13 +3716,25 @@ xenDaemonDomainPinVcpu(virDomainPtr doma
         return (-1);
     }
 
+    priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
+    if (priv->xendConfigVersion < 3) {
+        buf[0] = ']';
+        buf[1] = 0;
+    } else {
+        buf[0] = 0;
+    }
+
     /* from bit map, build character string of mapped CPU numbers */
     for (i = 0; i < maplen; i++) for (j = 0; j < 8; j++)
      if (cpumap[i] & (1 << j)) {
         snprintf(buf, sizeof(buf), "%d,", (8 * i) + j);
         strcat(mapstr, buf);
     }
-    mapstr[strlen(mapstr) - 1] = ']';
+    if (priv->xendConfigVersion < 3)
+        mapstr[strlen(mapstr) - 1] = ']';
+    else
+        mapstr[strlen(mapstr) - 1] = 0;
+
     snprintf(buf, sizeof(buf), "%d", vcpu);
     return(xend_op(domain->conn, domain->name, "op", "pincpu", "vcpu", buf,
                   "cpumap", mapstr, NULL));
openSUSE Build Service is sponsored by