On 06/27/2018 05:39 AM, Cole Robinson wrote:
On 06/24/2018 11:46 PM, Lin Ma wrote:
Signed-off-by: Lin Ma <lma@xxxxxxxx>
---
virtManager/connection.py | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/virtManager/connection.py b/virtManager/connection.py
index 76e78c49..0b83bccf 100644
--- a/virtManager/connection.py
+++ b/virtManager/connection.py
@@ -763,6 +763,12 @@ class vmmConnection(vmmGObject):
else:
self.schedule_priority_tick(pollvm=True, force=True)
+ def _domain_agent_lifecycle_event(self, conn, domain, state, reason, userdata):
+
+ name = domain.name()
+ logging.debug("domain agent lifecycle event: domain=%s %s", name,
+ LibvirtEnumMap.domain_agent_lifecycle_str(state, reason))
+
I'm guessing pylint here warns about unused arguments?
ok, I'll add ignore = conn and ignore = userdata.
def _network_lifecycle_event(self, conn, network, state, reason, userdata):
ignore = conn
ignore = userdata
@@ -842,6 +848,10 @@ class vmmConnection(vmmGObject):
self.get_backend().domainEventRegisterAny(
None, libvirt.VIR_DOMAIN_EVENT_ID_LIFECYCLE,
self._domain_lifecycle_event, None))
+ self._domain_cb_ids.append(
+ self.get_backend().domainEventRegisterAny(
+ None, libvirt.VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE,
+ self._domain_agent_lifecycle_event, None))
self.using_domain_events = True
logging.debug("Using domain events")
except Exception as e:
I don't like that if we fail registering agent events, we will disable
domain events entirely. I'd rather have it work like the xml misc events
below, where we just log a message if it fails. In fact can this be
folded into the xml misc events somehow?
Due to the _domain_xml_misc_event don't parse the 'args', It can't
translate the 'state' code to string, it only output:
"DEBUG (connection:744) domain xmlmisc event: domain=sles15rc4
event=VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE args=[1, 2]"
So I want to make the changes as below, What do you think?
- def _add_domain_xml_event(eventname, eventval):
+ def _add_domain_xml_event(eventname, eventval, cb=None):
if not self.using_domain_events:
return
+ if not cb:
+ cb = self._domain_xml_misc_event
......
_add_domain_xml_event("VIR_DOMAIN_EVENT_ID_DEVICE_ADDED", 19)
+ _add_domain_xml_event("VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE", 18,
self._domain_agent_lifecycle_event)
Thanks,
Lin
_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list