[libvirt] [PATCH] Save vcpuinfo in status file

Daniel Veillard veillard at redhat.com
Fri Sep 11 15:34:06 UTC 2009


On Fri, Sep 11, 2009 at 04:27:48PM +0100, Daniel P. Berrange wrote:
> * 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 |   35 +++++++++++++++++++++++++++++++++++
>  src/qemu_driver.c |    5 +----
>  2 files changed, 36 insertions(+), 4 deletions(-)
> 
> diff --git a/src/domain_conf.c b/src/domain_conf.c
> index 050cf50..5ae0775 100644
> --- a/src/domain_conf.c
> +++ b/src/domain_conf.c
> @@ -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)))
> diff --git a/src/qemu_driver.c b/src/qemu_driver.c
> index 0e7d8d4..a65334f 100644
> --- a/src/qemu_driver.c
> +++ b/src/qemu_driver.c
> @@ -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;
>  

  Okay I think I understand the problem, ACK !

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/




More information about the libvir-list mailing list