Re: [libvirt-users] deadlock on connection loosing

Александр
Mon, 08 Jul 2013 19:20:12 -0000

В письме от Понедельник, 08-июл-2013 14:39:57 Вы
написали:
> On 07.07.2013 01:53, Александр wrote:
> > В письме от Воскресенье, 30-июн-2013 03:41:37 пользователь Александр
написал:
> >> В письме от Вторник, 25-июн-2013 11:47:10 пользователь Michal
Privoznik
>
> ....
>
> > i have found source of problem, my code looks like this:
> >
> > int count = virConnectListAllDomains(connection, NULL, 0);
> > ....
> > domain = virDomainDefineXML(connection, d.write_to_string().c_str());
> >
> >
> > call to virConnectListAllDomains always cause libvirt deadlock.
> >
> > and another question, is here exists any other way to determinate
number
> > of
> > persistent domains ?
>
> This code is just a reproducer. Client shouldn't be able to deadlock
> libvirtd at all. Any API call should be deadlock safe (unless called
> from a callback). Which reminds me - do you use callbacks?
>
> Michal

yes, i using callbacks for errors, for now just copypasted example callback to
print errors



static void libvirt_error_handler(void *userdata, virErrorPtr err)
{
	fprintf(stderr, "Failure of libvirt library call:\n");
	fprintf(stderr, " Code: %d\n", err->code);
	fprintf(stderr, " Domain: %d\n", err->domain);
	fprintf(stderr, " Message: %s\n", err->message);
	fprintf(stderr, " Level: %d\n", err->level);
	fprintf(stderr, " str1: %s\n", err->str1);
	fprintf(stderr, " str2: %s\n", err->str2);
	fprintf(stderr, " str3: %s\n", err->str3);
	fprintf(stderr, " int1: %d\n", err->int1);
	fprintf(stderr, " int2: %d\n", err->int2);
}

int init_libvirt()
{
	virSetErrorFunc(NULL, libvirt_error_handler);
	libvirt_connection = virConnectOpen("qemu:///system");
.....


i will also check virConnectListAllDomains with correct pointer instead of
null later, now have some other work to do.