On Thu, Jan 15, 2026 at 12:03:02 -0000, [email protected] 
wrote:
> Hi Peter,
> First of all: Thank you for your very elaborate answer! There’s a lot to 
> digest here, and I want to discuss internally with my colleagues how we 
> proceed. I’m pretty sure we will reach out again after we thought through 
> more of the details.
> 
> Peter Krempa wrote:
> > On Mon, Jan 12, 2026 at 14:28:02 -0000,
> > [email protected] wrote:
> > > 2)> If we attach a device  `A` with `--live` and a second device `B` with
> > > `--persistent`, then `A` will not be present in the persistent domain
> > > XML. Still, we expect that `B` is added to both live and persistent
> > > definitions, using the same PCI bus address. By doing so, we would
> > No if you use only --persistent you *must not* touch the live config.
> > This is just a cold-plug request.
> 
> This is one point I would like to discuss further, nevertheless. Your 
> statement leaves me a bit confused. The virsh documentation[0] says: “For 
> compatibility purposes, --persistent behaves like --config for an offline 
> domain, and like --live --config for a running domain. ” So wouldn’t it be 
> right, that we *must not* touch the live config if the domain is offline, 
> while we *should* indeed touch it when it’s online? Or is the documentation 
> outdated here? I would really appreciate it if you could clarify.

So firstly to clarify. The API flags which influence this are named:

 VIR_DOMAIN_AFFECT_CURRENT
 VIR_DOMAIN_AFFECT_CONFIG
 VIR_DOMAIN_AFFECT_LIVE

Technically _CURRENT is 0 and they are bitwise-or'd together so
currentis basically the default behaviour if you don't specify any flag.

Now in virsh VIR_DOMAIN_AFFECT_CONFIG is usually translated to --config
and VIR_DOMAIN_AFFECT_LIVE is --live.

--persistent is a virsh-only thing which effectively does (the actual
code is a bit more verbose including interlocking)

    if (persistent) {
        flags |= VIR_DOMAIN_AFFECT_CONFIG;

        if (virDomainIsActive(dom) == 1)
            flags |= VIR_DOMAIN_AFFECT_LIVE;
    }

So your actual driver impl should not concern you because you'll get
only ever one of the two flags. The only thing that differs is if the VM
is live, but we have a helper for that:

 virDomainObjUpdateModificationImpact()

which if neither of the non-zero flags above is asserted looks at the
state and asserts the appropriate one.

There's also virDomainObjGetDefs() which fills the arguments with
pointers to the appropriate definition based on liveness and flags which
helps in selecting what to actually do in a simple way.

Reply via email to