Example #1
0
/**
 * @brief constructs a domain object
 * @param domain - domain pointer in libvirt
 * @param version - version of libvirt
 * @param parent - parent object
 *
 * Constructor that creates a domain object. The parameter parent
 * contains the parent object according to the Qt object definition.
 *
 * This constructor creates a domain object that represents the
 * domain referenced by the domain pointer given in the parameter
 * domain.
 *
 */
Domain::Domain(virDomainPtr domain, ulong version, QObject *parent) :
    QObject(parent),
    m_domain(domain),
    m_libVersion(version)
{
    virDomainRef(domain);
}
Example #2
0
/**
 * @brief constructs a domain object
 * @param domain - domain object to be copied
 *
 * Constructor that copies an existing domain object into
 * a new one. This constructor is needed in order to declare
 * this class a Qt Meta Object.
 */
Domain::Domain(const Domain &domain) :
    QObject(),
    m_domain(0),
    m_libVersion(0)
{
    setParent(domain.parent());
    this->m_domain = domain.m_domain;
    this->m_libVersion = domain.m_libVersion;
    virDomainRef(m_domain);
}
Example #3
0
int
myDomainEventCallback1(virConnectPtr conn,
		       virDomainPtr dom, int event, int detail, void *opaque)
{
	struct domain_info *dinfo = (struct domain_info *) opaque;

	if (event == VIR_DOMAIN_EVENT_STARTED ||
	    event == VIR_DOMAIN_EVENT_STOPPED) {
		virDomainRef(dom);
		dinfo->dom = dom;
		dinfo->event = event;
	} else {
		dinfo->event = VIR_DOMAIN_EVENT_UNDEFINED;
	}

	return 0;
}
Example #4
0
int
myDomainEventCallback1(virConnectPtr conn,
		       virDomainPtr dom, int event, int detail, void *opaque)
{
	struct event_args *args = (struct event_args *)opaque;

	if (event == VIR_DOMAIN_EVENT_STARTED ||
	    event == VIR_DOMAIN_EVENT_STOPPED) {
		virDomainRef(dom);
		if (event == VIR_DOMAIN_EVENT_STARTED) {
			domainStarted(dom, args->path, args->mode);
			virDomainFree(dom);
			write(args->wake_fd, "x", 1);
		} else if (event == VIR_DOMAIN_EVENT_STOPPED) {
			domainStopped(dom);
			virDomainFree(dom);
		}
	}

	return 0;
}