]> xenbits.xensource.com Git - libvirt.git/commitdiff
cputune: Support cputune for xend driver
authorOsier Yang <jyang@redhat.com>
Tue, 29 Mar 2011 13:43:41 +0000 (21:43 +0800)
committerOsier Yang <jyang@redhat.com>
Tue, 29 Mar 2011 14:13:46 +0000 (22:13 +0800)
Not sure if it's the correct way to add cputune xml for xend driver,
and besides, seems "xm driver" and "xen hypervisor" also support
vcpu affinity, do we need to add support for them too?

src/xen/xend_internal.c

index bfaed6515bec953e51d9c786ac64df8c1c124d4c..8859373fcc72717110fc62825c199208764abfca 100644 (file)
@@ -2233,11 +2233,12 @@ xenDaemonDomainSetVcpusFlags(virDomainPtr domain, unsigned int vcpus,
  */
 int
 xenDaemonDomainPinVcpu(virDomainPtr domain, unsigned int vcpu,
-                     unsigned char *cpumap, int maplen)
+                       unsigned char *cpumap, int maplen)
 {
     char buf[VIR_UUID_BUFLEN], mapstr[sizeof(cpumap_t) * 64];
-    int i, j;
+    int i, j, ret;
     xenUnifiedPrivatePtr priv;
+    virDomainDefPtr def = NULL;
 
     if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)
      || (cpumap == NULL) || (maplen < 1) || (maplen > (int)sizeof(cpumap_t))) {
@@ -2265,8 +2266,29 @@ xenDaemonDomainPinVcpu(virDomainPtr domain, unsigned int vcpu,
         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));
+
+    ret = xend_op(domain->conn, domain->name, "op", "pincpu", "vcpu", buf,
+                  "cpumap", mapstr, NULL);
+
+    if (!(def = xenDaemonDomainFetch(domain->conn,
+                                     domain->id,
+                                     domain->name,
+                                     NULL)))
+        goto cleanup;
+
+    if (ret == 0) {
+        if (virDomainVcpupinAdd(def, cpumap, maplen, vcpu) < 0) {
+            virXendError(VIR_ERR_INTERNAL_ERROR,
+                         "%s", _("failed to add vcpupin xml entry"));
+            return (-1);
+        }
+    }
+
+    return ret;
+
+cleanup:
+    virDomainDefFree(def);
+    return -1;
 }
 
 /**