mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Save vcpuinfo in status file
* 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
This commit is contained in:
@@ -3061,6 +3061,8 @@ static virDomainObjPtr virDomainObjParseXML(virConnectPtr conn,
|
|||||||
xmlNodePtr oldnode;
|
xmlNodePtr oldnode;
|
||||||
virDomainObjPtr obj;
|
virDomainObjPtr obj;
|
||||||
char *monitorpath;
|
char *monitorpath;
|
||||||
|
xmlNodePtr *nodes = NULL;
|
||||||
|
int n, i;
|
||||||
|
|
||||||
if (!(obj = virDomainObjNew(conn)))
|
if (!(obj = virDomainObjNew(conn)))
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -3133,9 +3135,32 @@ static virDomainObjPtr virDomainObjParseXML(virConnectPtr conn,
|
|||||||
break;
|
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;
|
return obj;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
VIR_FREE(nodes);
|
||||||
virDomainChrDefFree(obj->monitor_chr);
|
virDomainChrDefFree(obj->monitor_chr);
|
||||||
virDomainObjFree(obj);
|
virDomainObjFree(obj);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -4422,6 +4447,16 @@ char *virDomainObjFormat(virConnectPtr conn,
|
|||||||
virBufferVSprintf(&buf, " type='%s'/>\n",
|
virBufferVSprintf(&buf, " type='%s'/>\n",
|
||||||
virDomainChrTypeToString(obj->monitor_chr->type));
|
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,
|
if (!(config_xml = virDomainDefFormat(conn,
|
||||||
obj->def,
|
obj->def,
|
||||||
flags)))
|
flags)))
|
||||||
|
|||||||
@@ -336,10 +336,6 @@ qemuReconnectDomain(struct qemud_driver *driver,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemudDetectVcpuPIDs(NULL, obj) < 0) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (qemuUpdateActivePciHostdevs(driver, obj->def) < 0) {
|
if (qemuUpdateActivePciHostdevs(driver, obj->def) < 0) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@@ -2519,6 +2515,7 @@ qemudMonitorCommandWithHandler(const virDomainObjPtr vm,
|
|||||||
|
|
||||||
qemuMonitorDiscardPendingData(vm);
|
qemuMonitorDiscardPendingData(vm);
|
||||||
|
|
||||||
|
VIR_DEBUG("Send '%s'", cmd);
|
||||||
if (qemudMonitorSend(vm, cmd, scm_fd) < 0)
|
if (qemudMonitorSend(vm, cmd, scm_fd) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user