(*virDrvDomainQemuMonitorCommand)(virDomainPtr domain, const char *cmd,
char **result, unsigned int flags);
+typedef virDomainPtr
+ (*virDrvDomainQemuAttach)(virConnectPtr conn,
+ unsigned int pid,
+ unsigned int flags);
+
typedef int
(*virDrvDomainOpenConsole)(virDomainPtr dom,
const char *devname,
virDrvDomainRevertToSnapshot domainRevertToSnapshot;
virDrvDomainSnapshotDelete domainSnapshotDelete;
virDrvDomainQemuMonitorCommand qemuDomainMonitorCommand;
+ virDrvDomainQemuAttach qemuDomainAttach;
virDrvDomainOpenConsole domainOpenConsole;
virDrvDomainInjectNMI domainInjectNMI;
virDrvDomainMigrateBegin3 domainMigrateBegin3;
virDispatchError(conn);
return -1;
}
+
+
+
+/**
+ * virDomainQemuAttach:
+ * @conn: pointer to a hypervisor connection
+ * @pid: the UNIX process ID of the external QEMU process
+ * @flags: optional flags, currently unused
+ *
+ * This API is QEMU specific, so 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 succcesfully
+ * 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)
+ *
+ * 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 honoured
+ *
+ * Returns a new domain object on success, NULL otherwise
+ */
+virDomainPtr
+virDomainQemuAttach(virConnectPtr conn,
+ unsigned pid,
+ unsigned int flags)
+{
+ VIR_DEBUG("conn=%p, pid=%u, flags=%u", conn, pid, flags);
+
+ virResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virDispatchError(NULL);
+ return NULL;
+ }
+
+ if (pid <= 1) {
+ virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->flags & VIR_CONNECT_RO) {
+ virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->driver->qemuDomainAttach) {
+ virDomainPtr ret;
+ ret = conn->driver->qemuDomainAttach(conn, pid, flags);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ virDispatchError(conn);
+ return NULL;
+}