[libvirt] Small regression with domain refactoring

Chris Lalancette clalance at redhat.com
Wed Jul 30 07:26:53 UTC 2008


Hey,
     I've run into another regression when using a KVM guest with libvirt tip.
If I have a guest with some XML:

    <graphics type='vnc' port='-1' listen='127.0.0.1'/>

Then when I "virsh define" that guest, it ends up looking like:

    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'/>

So far, so good.  Now, when I actually "virsh start" the guest, it ends up like:

    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'/>

That is, there is no change to the XML when the domain is running.  What is
supposed to happen is that the "port" field should be filled in with the port
that libvirt ended up choosing for this guest.  This is important for tools like
virt-viewer, which parse this part of the XML to find out where to connect to.

Looking at the code, I believe the problem is in
src/domain_conf.c:virDomainGraphicsDefFormat().  It looks like:

    case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
        if (def->data.vnc.autoport)
            virBufferAddLit(buf, " port='-1'");
        else if (def->data.vnc.port)
            virBufferVSprintf(buf, " port='%d'",
                              def->data.vnc.port);

The problem is that we are missing some sort of "isActive" check in there, so
that it fills in the actual port it is using if the domain is running.
Unfortunately, from a quick perusal, I couldn't easily figure out how to do
this; does someone have a suggestion on how to fix this?

Thanks,
Chris Lalancette




More information about the libvir-list mailing list