o
    3bB                     @   sh  zd dl Z W n3 ey9 Z z'zd dlZ W n ey. Z zdeev r$eW Y dZ[ndZ[ww W Y dZ[ndZ[ww d dlZd dlmZm	Z	m
Z
 dejdejdededed	ed
e
eef defddZdejdeddfddZd!dejdejdede	ejejeeeeejgdf dejdedefddZdd Zdd Zdd ZdZdZdZdZdZd Zd Zd ZdZdS )"    NzNo module named)AnyCallableDictconndomeventsecondsmicrosdetailscbDatareturnc           	      C   s2   |d }|d }|| t j| |d||||| dS )zBDispatches events to python user qemu monitor event callbacks
    cbopaque_objr   )libvirt	virDomain)	r   r   r   r   r	   r
   r   r   r    r   ./usr/lib/python3/dist-packages/libvirt_qemu.py!_dispatchQemuMonitorEventCallback   s   r   
callbackIDc                 C   sD   zt | j|}|dkrtd| j|= W dS  ty!   Y dS w )ztRemoves a qemu monitor event callback. De-registering for a callback
       will disable delivery of this event typez3virConnectDomainQemuMonitorEventDeregister() failedN)libvirtmod_qemu*virConnectDomainQemuMonitorEventDeregister_or   libvirtErrorqemuMonitorEventCallbackIDAttributeError)r   r   retr   r   r   qemuMonitorEventDeregister)   s   
r   r   r   flagsc                 C   sp   t | dsi | _|| |d}|du rt| jd|||}nt| j|j|||}|dkr1td|| j|< |S )zpAdds a qemu monitor event callback. Registering for a monitor
       callback will enable delivery of the eventsr   )r   r   r   Nr   z1virConnectDomainQemuMonitorEventRegister() failed)hasattrr   r   (virConnectDomainQemuMonitorEventRegisterr   r   r   )r   r   r   r   r   r    r   r   r   r   r   qemuMonitorEventRegister5   s   


r#   c                 C   s(   t | j|||}|du rtd|S )z%Send a Guest Agent command to domain Nz"virDomainQemuAgentCommand() failed)r   virDomainQemuAgentCommandr   r   r   )domaincmdtimeoutr    r   r   r   r   qemuAgentCommandJ   s   
r(   c                 C   s4   t | j||}|du rtdtj| |d}|S )a  This API is QEMU specific, so it will only work with hypervisor
    connections to the QEMU driver.
    
    This API will attach to an externally launched QEMU process
    identified by @pid. There are several requirements to successfully
    attach to an external QEMU process:
    
      - It must have been started with a monitor socket using the UNIX
        domain socket protocol.
      - No device hotplug/unplug, or other configuration changes can
        have been made via the monitor since it started.
      - The '-name' and '-uuid' arguments should have been set (not
        mandatory, but strongly recommended)
    
    To date, the only platforms we know of where pid_t is larger than
    unsigned int (64-bit Windows) also lack UNIX sockets, so the choice
    of @pid_value as an unsigned int should not present any difficulties.
    
    If successful, then the guest will appear in the list of running
    domains for this connection, and other APIs should operate
    normally (provided the above requirements were honored). NzvirDomainQemuAttach() failedr   )r   virDomainQemuAttachr   r   r   r   )r   	pid_valuer    r   __tmpr   r   r   
qemuAttachQ   s
   
r,   c                 C   s&   t | j||}|du rtd|S )zASend an arbitrary monitor command through qemu monitor of domain Nz$virDomainQemuMonitorCommand() failed)r   virDomainQemuMonitorCommandr   r   r   )r%   r&   r    r   r   r   r   qemuMonitorCommandm   s   
r.         r   <   )r   )r   ImportErrorlib_ecygvirtmod_qemucyg_estrr   typingr   r   r   
virConnectr   intr   r   _Tr#   r(   r,   r.   4VIR_CONNECT_DOMAIN_QEMU_MONITOR_EVENT_REGISTER_REGEX5VIR_CONNECT_DOMAIN_QEMU_MONITOR_EVENT_REGISTER_NOCASE#VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK!VIR_DOMAIN_QEMU_AGENT_COMMAND_MIN%VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT$VIR_DOMAIN_QEMU_AGENT_COMMAND_NOWAIT&VIR_DOMAIN_QEMU_AGENT_COMMAND_SHUTDOWN'VIR_DOMAIN_QEMU_MONITOR_COMMAND_DEFAULT#VIR_DOMAIN_QEMU_MONITOR_COMMAND_HMPr   r   r   r   <module>   s<   6
J