where can i find the sourcecode from virDomainDestroy ?

Lentes, Bernd bernd.lentes at helmholtz-muenchen.de
Fri Oct 23 11:09:04 UTC 2020

----- On Oct 16, 2020, at 6:34 PM, Laine Stump laine at 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"))

    if (flags)
       result = virDomainDestroyFlags(dom, VIR_DOMAIN_DESTROY_GRACEFUL);
       result = virDomainDestroy(dom);  <=====================================

    if (result == 0) {
        vshPrintExtra(ctl, _("Domain %s destroyed\n"), name);
    } else {
        vshError(ctl, _("Failed to destroy domain %s"), name);
        ret = false;

    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.

Helmholtz Zentrum München

Helmholtz Zentrum Muenchen
Deutsches Forschungszentrum fuer Gesundheit und Umwelt (GmbH)
Ingolstaedter Landstr. 1
85764 Neuherberg
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

More information about the libvir-list mailing list