While we set up perf events for a shutoff domain and check the settings, All of perf events are reported as 'disabled', unless we add --config, This is redundant for a shutoff domain. # virsh domstate $GUEST shut off # virsh perf --domain $GUEST cmt : disabled mbmt : disabled mbml : disabled ...... # virsh perf --domain $GUEST --enable mbmt mbmt : enabled # virsh perf --domain $GUEST cmt : disabled mbmt : disabled mbml : disabled ...... Use virDomainObjGetOneDefState instead of virDomainObjGetOneDef to fix the issue. After patch, The perf event status of a shutoff domain is reported correctly: # virsh domstate $GUEST shut off # virsh perf --domain $GUEST cmt : disabled mbmt : disabled mbml : disabled ...... # virsh perf --domain $GUEST --enable mbmt mbmt : enabled # virsh perf --domain $GUEST cmt : disabled mbmt : enabled mbml : disabled ...... Signed-off-by: Lin Ma <lma@xxxxxxx> --- src/qemu/qemu_driver.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index bd287f259e..717afcd34d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -9109,6 +9109,7 @@ qemuDomainGetPerfEvents(virDomainPtr dom, int npar = 0; size_t i; int ret = -1; + bool live = false; virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG | @@ -9123,7 +9124,7 @@ qemuDomainGetPerfEvents(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) goto cleanup; - if (!(def = virDomainObjGetOneDef(vm, flags))) + if (!(def = virDomainObjGetOneDefState(vm, flags, &live))) goto endjob; priv = vm->privateData; @@ -9131,7 +9132,7 @@ qemuDomainGetPerfEvents(virDomainPtr dom, for (i = 0; i < VIR_PERF_EVENT_LAST; i++) { bool perf_enabled; - if (flags & VIR_DOMAIN_AFFECT_CONFIG) + if ((flags & VIR_DOMAIN_AFFECT_CONFIG) || !live) perf_enabled = def->perf.events[i] == VIR_TRISTATE_BOOL_YES; else perf_enabled = virPerfEventIsEnabled(priv->perf, i); -- 2.26.0