where can i find the sourcecode from virDomainDestroy ?

Hi, i have some questions concerning the destroying of domains, and i hope i'm right here. If not sorry for the disturbance. I'm running a two node HA cluster with pacemaker and KVM domains as resources.
From time to time when i try to stop a domain with the cluster manager that does not work, so the domain is destroyed. That's ok. But seldom and irregular also destroy does not work, so the node this domain is running on is fenced. That's ugly. Fencing is the worst which can happen to a cluster and i try to avoid it. Maybe destroy does not work because of heavy load, i'm currently examing that.
I installed the source package from libvirt-4.0.0, i have a SLES 12 SP4. I found a virsh-domain.c which i assume is responsible for the domains. Right ? I found a function called "virDomainDestroy", which i believe has the purpose to destroy the domain. Right ? But i don't find the source for that function. I greped the whole source code for it, but didn't find it. I'd like to know what this function returns in success or failure. Could you please help me ? Thanks. Bernd -- Bernd Lentes Systemadministration Institute for Metabolism and Cell Death (MCD) Building 25 - office 122 HelmholtzZentrum München bernd.lentes@helmholtz-muenchen.de phone: +49 89 3187 1241 phone: +49 89 3187 3827 fax: +49 89 3187 2294 http://www.helmholtz-muenchen.de/mcd stay healthy Helmholtz Zentrum München Helmholtz Zentrum München

On 10/16/20 11:37 AM, Lentes, Bernd wrote:
Hi,
i have some questions concerning the destroying of domains, and i hope i'm right here. If not sorry for the disturbance. I'm running a two node HA cluster with pacemaker and KVM domains as resources.
From time to time when i try to stop a domain with the cluster manager that does not work, so the domain is destroyed. That's ok. But seldom and irregular also destroy does not work, so the node this domain is running on is fenced. That's ugly. Fencing is the worst which can happen to a cluster and i try to avoid it. Maybe destroy does not work because of heavy load, i'm currently examing that.
I installed the source package from libvirt-4.0.0, i have a SLES 12 SP4.
The first thing to try, if there is any possibility, is to upgrade your libvirt version. 4.0.0 is nearly 3 years out of date at this time, and *a lot* has changed since then. If you actually are experiencing a libvirt bug, then it's very likely it was identified and fixed during this time. (Even though you are running and older version of SLES, it's likely someone somewhere has built a newer version and has a pre-built package available)
I found a virsh-domain.c which i assume is responsible for the domains. Right ?
virsh-domain.c contains the functions that correspond to domain-related commands of the virsh utility. They gather input from the commandline, then call libvirt's public API. So you won't find much there.
I found a function called "virDomainDestroy", which i believe has the purpose to destroy the domain. Right ?
That is the top-level public API (what is called by user programs like virsh or virt-manager). It looks into the virConnect object that was previously opened by said user program, and calls the domainDestroy() function for whichever hypervisor driver you're using. So for example, if you are using the QEMU driver, it will end up calling qemuDomainDestroy(), or if you're using xen (libxl), it will call libxlDomainDestroy() (you can get a list of all these functions by searching for "domainDestroy" in the source - each hypervisor will initialize the .domainDestroy member of its virHypervisorDriver object with a pointer to its domainDestroy function.) From there, you can search for the appropriate function for the hypervisor you're using. For example, qemuDomainDestroy is in src/qemu/qemu_driver.c, and libxlDomainDestroy is in src/libxl/libxl_driver.c
But i don't find the source for that function. I greped the whole source code for it, but didn't find it.
If you grep'ed all the source you have for virDomainDestroy and didn't find it, then either you don't have all the source, or there was a mistake in your grep command :-). virDomainDestroy is in src/libvirt-domain.c (but as I detailed above, that's not actually the function you're looking for, only a switch-point in the long linkage of the journey from application to hypervisor driver). In the end, while I don't want to discourage looking into the source in general, since it's always enlightening and leads to a better understanding, this may not be the most efficient path to a solution; you may get better, faster results by upgrading to as new a version of libvirt as possible, then if the error continues, come back to the list with a detailed description of the error (or if you think direct interaction could lead to a quicker resolution, point an IRC client at irc.oftc.net, join the #virt channel, and ask away - several libvirt developers are there during weekday normal worktime (mostly in Europe, plus a few in the U.S.), and we try our best to be helpful and polite :-) Good luck!
I'd like to know what this function returns in success or failure.
Could you please help me ?
Thanks.
Bernd

----- On Oct 16, 2020, at 6:34 PM, Laine Stump laine@redhat.com wrote: I installed the source package from libvirt-4.0.0, i have a SLES 12 SP4.
The first thing to try, if there is any possibility, is to upgrade your libvirt version. 4.0.0 is nearly 3 years out of date at this time, and *a lot* has changed since then. If you actually are experiencing a libvirt bug, then it's very likely it was identified and fixed during this time. (Even though you are running and older version of SLES, it's likely someone somewhere has built a newer version and has a pre-built package available)
Yes, but installing a more recent version not from the official SLES repository makes me loose my support.
I found a virsh-domain.c which i assume is responsible for the domains. Right ?
virsh-domain.c contains the functions that correspond to domain-related commands of the virsh utility. They gather input from the commandline, then call libvirt's public API. So you won't find much there.
This is the part i want to keep an eye on (virsh-domain.c) : static bool cmdDestroy(vshControl *ctl, const vshCmd *cmd) { virDomainPtr dom; bool ret = true; const char *name; unsigned int flags = 0; int result; if (!(dom = virshCommandOptDomain(ctl, cmd, &name))) return false; if (vshCommandOptBool(cmd, "graceful")) flags |= VIR_DOMAIN_DESTROY_GRACEFUL; if (flags) result = virDomainDestroyFlags(dom, VIR_DOMAIN_DESTROY_GRACEFUL); else result = virDomainDestroy(dom); <===================================== if (result == 0) { vshPrintExtra(ctl, _("Domain %s destroyed\n"), name); } else { vshError(ctl, _("Failed to destroy domain %s"), name); ret = false; } virshDomainFree(dom); return ret; } Does that mean that virsh itself returns a true and write "Domain %s destroyed\n" if it successfully destroyed the domain and otherwise returns a false and writes "Domain %s destroyed\n" ?
I found a function called "virDomainDestroy", which i believe has the purpose to destroy the domain. Right ?
That is the top-level public API (what is called by user programs like virsh or virt-manager). It looks into the virConnect object that was ...
If i want to check success or not with virsh then the top-level API is enough for me. Bernd Helmholtz Zentrum München Helmholtz Zentrum Muenchen Deutsches Forschungszentrum fuer Gesundheit und Umwelt (GmbH) Ingolstaedter Landstr. 1 85764 Neuherberg www.helmholtz-muenchen.de Aufsichtsratsvorsitzende: MinDir.in Prof. Dr. Veronika von Messling Geschaeftsfuehrung: Prof. Dr. med. Dr. h.c. Matthias Tschoep, Kerstin Guenther Registergericht: Amtsgericht Muenchen HRB 6466 USt-IdNr: DE 129521671

On 10/16/20 9:37 AM, Lentes, Bernd wrote:
Hi,
i have some questions concerning the destroying of domains, and i hope i'm right here. If not sorry for the disturbance.
Laine already answered your questions about code navigation. I'll provide a few random comments.
I'm running a two node HA cluster with pacemaker and KVM domains as resources.
From time to time when i try to stop a domain with the cluster manager that does not work, so the domain is destroyed. That's ok. But seldom and irregular also destroy does not work, so the node this domain is running on is fenced.
Have you investigated why the associated qemu process is not responding to SIGKILL? Is it blocked on uninterruptible I/O? E.g. are there any hints in /proc/<qemu-pid>/stack or /proc/<qemu-pid>/wchan?
That's ugly. Fencing is the worst which can happen to a cluster and i try to avoid it. Maybe destroy does not work because of heavy load, i'm currently examing that.
I installed the source package from libvirt-4.0.0, i have a SLES 12 SP4.
Laine mentioned trying a new libvirt. While that is possible, it can be difficult in practice due to missing or insufficient build dependencies. E.g. SLES12 SP4 does not have meson. Creating a SLE12 SP5 based build container with all dependencies to build upstream libvirt is on my todo list. ATM I was only considering doing this for the latest SLE12 service pack. Regards, Jim
participants (3)
-
Jim Fehlig
-
Laine Stump
-
Lentes, Bernd