[libvirt] [PATCH] Fix the style of argument("cpumap") in op_pincpu()

Daniel Veillard veillard at redhat.com
Tue May 12 14:03:57 UTC 2009


On Tue, May 12, 2009 at 10:50:02AM +0200, Daniel Veillard wrote:
> On Fri, May 08, 2009 at 06:45:59PM +0900, Tatsuro Enokura wrote:
> > > >    Okay, but I'm still worrying.
> > > > The fact that we fail to detect the error NG1 is a bug, and that
> > > > bug should be fixed. Seems to me the change may just replace one error
> > > > by another one but in the end we should instead aim at fixing the NG1
> > > > problem with the old format, not substituing it with something else.
> > > >
> > > >    I would prefer if the patch did some checking about the current xend
> > > > version running, but unfortunately priv->xendConfigVersion won't be
> > > > precise enough.
> > > >
> > > >    Sorry I don't know how to handle this more correctly right now
> > 
> > I see.
> > priv->xendConfigVersion isn't appropriate for tracing the xend's
> > version. We should request to the xen community for new interface
> > of to get the xend's version.
> > 
> > On other hand,
> > the new xend and libvirt without the cpumap patch occur error(NG2).
> > Behavior of the old xend and libvirt with the cpumap patch is the same
> > behavior of libvirt without the cpumap patch.
> > Moreover, there is no work for libvirt of this issue any further at present.
> > 
> > I make the patch that added the foregoing content as TODO comment.
> > 
> > Signed-off-by: Tatsuro Enokura <fj2026af at aa.jp.fujitsu.com>
> 
>   Okay, here is my suggested patch to minimize impact on old xen setups
> maybe someone locally fixed the xend side, and we should at least try to
> not break it on old setups.
>   So I updated the comment
>   And activate the change only for version of xend >= 3 which  won't
> cover the full range but should still protect some of the older setups,

  Urgh, I wasn't fully awake, that one does compile :-\ !

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel at veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/
-------------- next part --------------
Index: src/xend_internal.c
===================================================================
RCS file: /data/cvs/libxen/src/xend_internal.c,v
retrieving revision 1.262
diff -u -r1.262 xend_internal.c
--- src/xend_internal.c	8 May 2009 09:58:46 -0000	1.262
+++ src/xend_internal.c	12 May 2009 14:00:48 -0000
@@ -3765,6 +3765,11 @@
  * @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
  */
@@ -3772,8 +3777,9 @@
 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))) {
@@ -3782,13 +3788,25 @@
         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));


More information about the libvir-list mailing list