mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-30 16:35:24 +00:00
virsh: fix event registration for single event
Allocate a larger 'data' array than strictly needed for simplicity and use 'ndata' as the index when filling it to put the single event at the first unused place, instead of at its index in the virshDomainEventCallbacks array. https://bugzilla.redhat.com/show_bug.cgi?id=2073887 Fixes: c6bb2746933bbe65877a5f8a8d60e100b0bf8a59 Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
c11fb2132f
commit
df757e88fd
@ -915,23 +915,20 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (eventName)
|
||||
data = g_new0(virshDomEventData, 1);
|
||||
else
|
||||
data = g_new0(virshDomEventData, G_N_ELEMENTS(virshDomainEventCallbacks));
|
||||
data = g_new0(virshDomEventData, G_N_ELEMENTS(virshDomainEventCallbacks));
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS(virshDomainEventCallbacks); i++) {
|
||||
if (eventName &&
|
||||
STRNEQ(eventName, virshDomainEventCallbacks[i].name))
|
||||
continue;
|
||||
|
||||
data[i].event = i;
|
||||
data[i].ctl = ctl;
|
||||
data[i].loop = loop;
|
||||
data[i].count = &count;
|
||||
data[i].timestamp = timestamp;
|
||||
data[i].cb = &virshDomainEventCallbacks[i];
|
||||
data[i].id = -1;
|
||||
data[ndata].event = i;
|
||||
data[ndata].ctl = ctl;
|
||||
data[ndata].loop = loop;
|
||||
data[ndata].count = &count;
|
||||
data[ndata].timestamp = timestamp;
|
||||
data[ndata].cb = &virshDomainEventCallbacks[i];
|
||||
data[ndata].id = -1;
|
||||
ndata++;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user