]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Save vcpuinfo in status file
authorDaniel P. Berrange <berrange@redhat.com>
Fri, 11 Sep 2009 15:26:40 +0000 (16:26 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Mon, 14 Sep 2009 13:55:09 +0000 (14:55 +0100)
* src/qemu_driver.c: Don't trust monitor for vcpu PID info on
  restart
* src/domain_conf.c: Save and load vCPU PID info from domain
  status file

src/domain_conf.c
src/qemu_driver.c

index 050cf50aadea43080fd034a9680dccac61bb1033..5ae0775836440aee4b6e96b080283b3f7d1ce4d2 100644 (file)
@@ -3061,6 +3061,8 @@ static virDomainObjPtr virDomainObjParseXML(virConnectPtr conn,
     xmlNodePtr oldnode;
     virDomainObjPtr obj;
     char *monitorpath;
+    xmlNodePtr *nodes = NULL;
+    int n, i;
 
     if (!(obj = virDomainObjNew(conn)))
         return NULL;
@@ -3133,9 +3135,32 @@ static virDomainObjPtr virDomainObjParseXML(virConnectPtr conn,
         break;
     }
 
+    n = virXPathNodeSet(conn, "./vcpus/vcpu", ctxt, &nodes);
+    if (n < 0)
+        goto error;
+    if (n) {
+        obj->nvcpupids = n;
+        if (VIR_REALLOC_N(obj->vcpupids, obj->nvcpupids) < 0)
+            goto error;
+
+        for (i = 0 ; i < n ; i++) {
+            char *pidstr = virXMLPropString(nodes[i], "pid");
+            if (!pidstr)
+                goto error;
+
+            if (virStrToLong_i(pidstr, NULL, 10, &(obj->vcpupids[i])) < 0) {
+                VIR_FREE(pidstr);
+                goto error;
+            }
+            VIR_FREE(pidstr);
+        }
+        VIR_FREE(nodes);
+    }
+
     return obj;
 
 error:
+    VIR_FREE(nodes);
     virDomainChrDefFree(obj->monitor_chr);
     virDomainObjFree(obj);
     return NULL;
@@ -4422,6 +4447,16 @@ char *virDomainObjFormat(virConnectPtr conn,
     virBufferVSprintf(&buf, " type='%s'/>\n",
                       virDomainChrTypeToString(obj->monitor_chr->type));
 
+
+    if (obj->nvcpupids) {
+        int i;
+        virBufferAddLit(&buf, "  <vcpus>\n");
+        for (i = 0 ; i < obj->nvcpupids ; i++) {
+            virBufferVSprintf(&buf, "    <vcpu pid='%d'/>\n", obj->vcpupids[i]);
+        }
+        virBufferAddLit(&buf, "  </vcpus>\n");
+    }
+
     if (!(config_xml = virDomainDefFormat(conn,
                                           obj->def,
                                           flags)))
index 5a8a686ff4e46feb1a14f906311430b2f8c11d68..60f815ef7151d45ab46b52567758216ec4908fa1 100644 (file)
@@ -336,10 +336,6 @@ qemuReconnectDomain(struct qemud_driver *driver,
         goto error;
     }
 
-    if (qemudDetectVcpuPIDs(NULL, obj) < 0) {
-        goto error;
-    }
-
     if (qemuUpdateActivePciHostdevs(driver, obj->def) < 0) {
         goto error;
     }
@@ -2519,6 +2515,7 @@ qemudMonitorCommandWithHandler(const virDomainObjPtr vm,
 
     qemuMonitorDiscardPendingData(vm);
 
+    VIR_DEBUG("Send '%s'", cmd);
     if (qemudMonitorSend(vm, cmd, scm_fd) < 0)
         return -1;