On Tue, Dec 16, 2008 at 04:34:15PM +0300, Anton Protopopov wrote:
2008/12/16 Daniel P. Berrange <berrange(a)redhat.com>
> On Tue, Dec 16, 2008 at 03:05:30PM +0300, Anton Protopopov wrote:
> > 2008/12/13 Ivan Vovk <ivovk(a)intermedia.net>
> You can't have one public
> driver API method, calling into another directly. openvzDomainSetVcpus()
> will attempt to lock the driver mutex, and the VM mutex, and then deadlock
> because openvzDomainCreateXML/openvzDomainDefineXML already hold the
> VM mutex.
>
> The way to address this is to move the backend logic out of the
> openvzDomainSetVcpus method, into a helper that is passed a pre-locked
> virDomainObjPtr instance. This helper can be called by public driver
> APIs openvzDomainSetVcpus and openvzDomainCreateXML and
> openvzDomainDefineXML.
>
> eg, the helper would look like
>
> static int openvzDomainSetVcpusInternal(virConnectPtr conn,
> virDomainObjPtr vm)
> char str_vcpus[32];
Thanks, this seems to work (see attached patch).
As a general rule the public virDomainPtr objects should not be passed
down into internal methods. Likewise, when creating / defining a VM,
the virGetDomain call should be the last one in the normal execution
path of the method.
Thus, just pass the 'virConnectPtr' instance to openvzDomainSetVcpusInternal
as suggested above, and keep the setVcpusInternal calls above the call
to virGetDomain.
Regards,
Daniel
--
|: Red Hat, Engineering, London -o-
http://people.redhat.com/berrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org -o-
http://ovirt.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|