[Libvir] [PATCH/RFC] remote driver uses already freed dom

Guido Günther agx at sigxcpu.org
Fri Mar 28 15:44:02 UTC 2008

when trying to undefine a running qemu domain the domain name gets

$  ./virsh undefine system1
Name: /�em1
libvir: QEMU error /�em1: internal error cannot delete active domain
error: Failed to undefine domain system1

the reaseon is that in qemud/remote.c the domain is freed after failure:

remoteDispatchDomainUndefine (struct qemud_server *server ATTRIBUTE_UNUSED,
    if (virDomainUndefine (dom) == -1) {
        return -1;

This doesn't work out since remoteDispatchClient accesses the dom
structure that was stored in the virtErrorPtr structure to report the
error back to the client (This is just an example and hits any error
path of functions in remote_dispatch_proc_switch.h that reference dom).
There are two possible solutions I see: move the virtDomainFree down to
the bottom of remoteDispatchClient or deep copy the dom structure in
virDefaultErrorFunc. A patch for the later is attached since similar
things seem to be possible in other drivers too.
 -- Guido

More information about the libvir-list mailing list