mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 21:34:54 +03:00
Define a QEMU specific API to attach to a running QEMU process
Introduce a new API in libvirt-qemu.so virDomainPtr virDomainQemuAttach(virConnectPtr domain, unsigned long long pid, unsigned int flags); This allows libvirtd to attach to an existing, externally launched QEMU process. This is useful for QEMU developers who prefer to launch QEMU themselves for debugging/devel reasons, but still want the benefit of libvirt based tools like virt-top, virt-viewer, etc * include/libvirt/libvirt-qemu.h: Define virDomainQemuAttach * src/driver.h, src/libvirt-qemu.c, src/libvirt_qemu.syms: Driver glue for virDomainQemuAttach
This commit is contained in:
parent
9c5b190017
commit
639f841346
@ -28,6 +28,10 @@ typedef enum {
|
||||
int virDomainQemuMonitorCommand(virDomainPtr domain, const char *cmd,
|
||||
char **result, unsigned int flags);
|
||||
|
||||
virDomainPtr virDomainQemuAttach(virConnectPtr domain,
|
||||
unsigned int pid,
|
||||
unsigned int flags);
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
|
@ -566,6 +566,11 @@ typedef int
|
||||
(*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,
|
||||
@ -786,6 +791,7 @@ struct _virDriver {
|
||||
virDrvDomainRevertToSnapshot domainRevertToSnapshot;
|
||||
virDrvDomainSnapshotDelete domainSnapshotDelete;
|
||||
virDrvDomainQemuMonitorCommand qemuDomainMonitorCommand;
|
||||
virDrvDomainQemuAttach qemuDomainAttach;
|
||||
virDrvDomainOpenConsole domainOpenConsole;
|
||||
virDrvDomainInjectNMI domainInjectNMI;
|
||||
virDrvDomainMigrateBegin3 domainMigrateBegin3;
|
||||
|
@ -79,3 +79,71 @@ error:
|
||||
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;
|
||||
}
|
||||
|
@ -14,3 +14,8 @@ LIBVIRT_QEMU_0.8.3 {
|
||||
global:
|
||||
virDomainQemuMonitorCommand;
|
||||
};
|
||||
|
||||
LIBVIRT_QEMU_0.9.4 {
|
||||
global:
|
||||
virDomainQemuAttach;
|
||||
} LIBVIRT_QEMU_0.8.3;
|
||||
|
Loading…
Reference in New Issue
Block a user