If the virDomainDefPtr object has an 'id' of -1, then forcably set the VIR_DOMAIN_XML_INACTIVE flag to ensure generated XML does not include any cruft from the previously running guest such as console PTY path, or VNC port. * src/conf/domain_conf.c: Set VIR_DOMAIN_XML_INACTIVE if def->id is -1. Replace checks for def->id == -1 with check against flags & VIR_DOMAIN_XML_INACTIVE. --- src/conf/domain_conf.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9e37452..c2c07ca 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4407,7 +4407,6 @@ virDomainInputDefFormat(virConnectPtr conn, static int virDomainGraphicsDefFormat(virConnectPtr conn, virBufferPtr buf, - virDomainDefPtr vm, virDomainGraphicsDefPtr def, int flags) { @@ -4424,7 +4423,7 @@ virDomainGraphicsDefFormat(virConnectPtr conn, switch (def->type) { case VIR_DOMAIN_GRAPHICS_TYPE_VNC: if (def->data.vnc.port && - (!def->data.vnc.autoport || vm->id != -1)) + (!def->data.vnc.autoport || !(flags & VIR_DOMAIN_XML_INACTIVE))) virBufferVSprintf(buf, " port='%d'", def->data.vnc.port); else if (def->data.vnc.autoport) @@ -4579,7 +4578,10 @@ char *virDomainDefFormat(virConnectPtr conn, goto cleanup; } - if (def->id >= 0) + if (def->id == -1) + flags |= VIR_DOMAIN_XML_INACTIVE; + + if (!(flags & VIR_DOMAIN_XML_INACTIVE)) virBufferVSprintf(&buf, "<domain type='%s' id='%d'>\n", type, def->id); else virBufferVSprintf(&buf, "<domain type='%s'>\n", type); @@ -4770,7 +4772,7 @@ char *virDomainDefFormat(virConnectPtr conn, goto cleanup; for (n = 0 ; n < def->ngraphics ; n++) - if (virDomainGraphicsDefFormat(conn, &buf, def, def->graphics[n], flags) < 0) + if (virDomainGraphicsDefFormat(conn, &buf, def->graphics[n], flags) < 0) goto cleanup; } -- 1.6.2.5 -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list