mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 09:17:52 +03:00
Introduce a virDomainOpenConsole API
To enable virsh console (or equivalent) to be used remotely it is necessary to provide remote access to the /dev/pts/XXX pseudo-TTY associated with the console/serial/parallel device in the guest. The virStream API provide a bi-directional I/O stream capability that can be used for this purpose. This patch thus introduces a virDomainOpenConsole API that uses the stream APIs. * src/libvirt.c, src/libvirt_public.syms, include/libvirt/libvirt.h.in, src/driver.h: Define the new virDomainOpenConsole API * src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/opennebula/one_driver.c, src/openvz/openvz_driver.c, src/phyp/phyp_driver.c, src/qemu/qemu_driver.c, src/remote/remote_driver.c, src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c, src/xen/xen_driver.c, src/xenapi/xenapi_driver.c: Stub API entry point
This commit is contained in:
parent
5126926548
commit
88a9b382c6
@ -2402,6 +2402,12 @@ int virNWFilterGetUUIDString (virNWFilterPtr nwfilter,
|
||||
char * virNWFilterGetXMLDesc (virNWFilterPtr nwfilter,
|
||||
int flags);
|
||||
|
||||
|
||||
int virDomainOpenConsole(virDomainPtr dom,
|
||||
const char *devname,
|
||||
virStreamPtr st,
|
||||
unsigned int flags);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -480,6 +480,11 @@ typedef int
|
||||
(*virDrvQemuDomainMonitorCommand)(virDomainPtr domain, const char *cmd,
|
||||
char **result, unsigned int flags);
|
||||
|
||||
typedef int
|
||||
(*virDrvDomainOpenConsole)(virDomainPtr dom,
|
||||
const char *devname,
|
||||
virStreamPtr st,
|
||||
unsigned int flags);
|
||||
|
||||
|
||||
/**
|
||||
@ -598,6 +603,7 @@ struct _virDriver {
|
||||
virDrvQemuDomainMonitorCommand qemuDomainMonitorCommand;
|
||||
virDrvDomainSetMemoryParameters domainSetMemoryParameters;
|
||||
virDrvDomainGetMemoryParameters domainGetMemoryParameters;
|
||||
virDrvDomainOpenConsole domainOpenConsole;
|
||||
};
|
||||
|
||||
typedef int
|
||||
|
@ -4382,6 +4382,7 @@ static virDriver esxDriver = {
|
||||
NULL, /* qemuDomainMonitorCommand */
|
||||
esxDomainSetMemoryParameters, /* domainSetMemoryParameters */
|
||||
esxDomainGetMemoryParameters, /* domainGetMemoryParameters */
|
||||
NULL, /* domainOpenConsole */
|
||||
};
|
||||
|
||||
|
||||
|
@ -13114,3 +13114,56 @@ virDomainSnapshotFree(virDomainSnapshotPtr snapshot)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* virDomainOpenConsole:
|
||||
* @dom: a domain object
|
||||
* @devname: the console, serial or parallel port device alias, or NULL
|
||||
* @st: a stream to associate with the console
|
||||
* @flags: unused, pass 0
|
||||
*
|
||||
* This opens the backend associated with a console, serial or
|
||||
* parallel port device on a guest, if the backend is supported.
|
||||
* If the @devname is omitted, then the first console or serial
|
||||
* device is opened. The console is associated with the passed
|
||||
* in @st stream, which should have been opened in non-blocking
|
||||
* mode for bi-directional I/O.
|
||||
*
|
||||
* returns 0 if the console was opened, -1 on error
|
||||
*/
|
||||
int virDomainOpenConsole(virDomainPtr dom,
|
||||
const char *devname,
|
||||
virStreamPtr st,
|
||||
unsigned int flags)
|
||||
{
|
||||
virConnectPtr conn;
|
||||
DEBUG("dom=%p devname=%s, st=%p flags=%u", dom, NULLSTR(devname), st, flags);
|
||||
|
||||
virResetLastError();
|
||||
|
||||
if (!VIR_IS_DOMAIN(dom)) {
|
||||
virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
|
||||
virDispatchError(NULL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
conn = dom->conn;
|
||||
if (conn->flags & VIR_CONNECT_RO) {
|
||||
virLibDomainError(dom, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (conn->driver->domainOpenConsole) {
|
||||
int ret;
|
||||
ret = conn->driver->domainOpenConsole(dom, devname, st, flags);
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
return ret;
|
||||
}
|
||||
|
||||
virLibConnError(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
|
||||
error:
|
||||
virDispatchError(conn);
|
||||
return -1;
|
||||
}
|
||||
|
@ -413,4 +413,9 @@ LIBVIRT_0.8.5 {
|
||||
virDomainSetVcpusFlags;
|
||||
} LIBVIRT_0.8.2;
|
||||
|
||||
LIBVIRT_0.8.6 {
|
||||
global:
|
||||
virDomainOpenConsole;
|
||||
} LIBVIRT_0.8.5;
|
||||
|
||||
# .... define new API here using predicted next version number ....
|
||||
|
@ -2836,6 +2836,7 @@ static virDriver lxcDriver = {
|
||||
NULL, /* qemuDomainMonitorCommand */
|
||||
lxcDomainSetMemoryParameters, /* domainSetMemoryParameters */
|
||||
lxcDomainGetMemoryParameters, /* domainGetMemoryParameters */
|
||||
NULL, /* domainOpenConsole */
|
||||
};
|
||||
|
||||
static virStateDriver lxcStateDriver = {
|
||||
|
@ -822,6 +822,7 @@ static virDriver oneDriver = {
|
||||
NULL, /* qemuDomainMonitorCommand */
|
||||
NULL, /* domainSetMemoryParameters */
|
||||
NULL, /* domainGetMemoryParameters */
|
||||
NULL, /* domainOpenConsole */
|
||||
};
|
||||
|
||||
static virStateDriver oneStateDriver = {
|
||||
|
@ -1691,6 +1691,7 @@ static virDriver openvzDriver = {
|
||||
NULL, /* qemuDomainMonitorCommand */
|
||||
NULL, /* domainSetMemoryParameters */
|
||||
NULL, /* domainGetMemoryParameters */
|
||||
NULL, /* domainOpenConsole */
|
||||
};
|
||||
|
||||
int openvzRegister(void) {
|
||||
|
@ -4045,6 +4045,7 @@ static virDriver phypDriver = {
|
||||
NULL, /* qemuMonitorCommand */
|
||||
NULL, /* domainSetMemoryParameters */
|
||||
NULL, /* domainGetMemoryParameters */
|
||||
NULL, /* domainOpenConsole */
|
||||
};
|
||||
|
||||
static virStorageDriver phypStorageDriver = {
|
||||
|
@ -13428,6 +13428,7 @@ static virDriver qemuDriver = {
|
||||
qemuDomainMonitorCommand, /* qemuDomainMonitorCommand */
|
||||
qemuDomainSetMemoryParameters, /* domainSetMemoryParameters */
|
||||
qemuDomainGetMemoryParameters, /* domainGetMemoryParameters */
|
||||
NULL, /* domainOpenConsole */
|
||||
};
|
||||
|
||||
|
||||
|
@ -10691,6 +10691,7 @@ static virDriver remote_driver = {
|
||||
remoteQemuDomainMonitorCommand, /* qemuDomainMonitorCommand */
|
||||
remoteDomainSetMemoryParameters, /* domainSetMemoryParameters */
|
||||
remoteDomainGetMemoryParameters, /* domainGetMemoryParameters */
|
||||
NULL, /* domainOpenConsole */
|
||||
};
|
||||
|
||||
static virNetworkDriver network_driver = {
|
||||
|
@ -5443,6 +5443,7 @@ static virDriver testDriver = {
|
||||
NULL, /* qemuDomainMonitorCommand */
|
||||
NULL, /* domainSetMemoryParameters */
|
||||
NULL, /* domainGetMemoryParameters */
|
||||
NULL, /* domainOpenConsole */
|
||||
};
|
||||
|
||||
static virNetworkDriver testNetworkDriver = {
|
||||
|
@ -2200,6 +2200,7 @@ static virDriver umlDriver = {
|
||||
NULL, /* qemuDomainMonitorCommand */
|
||||
NULL, /* domainSetMemoryParamters */
|
||||
NULL, /* domainGetMemoryParamters */
|
||||
NULL, /* domainOpenConsole */
|
||||
};
|
||||
|
||||
static int
|
||||
|
@ -8464,6 +8464,7 @@ virDriver NAME(Driver) = {
|
||||
NULL, /* qemuDomainMonitorCommand */
|
||||
NULL, /* domainSetMemoryParameters */
|
||||
NULL, /* domainGetMemoryParameters */
|
||||
NULL, /* domainOpenConsole */
|
||||
};
|
||||
|
||||
virNetworkDriver NAME(NetworkDriver) = {
|
||||
|
@ -2035,6 +2035,7 @@ static virDriver xenUnifiedDriver = {
|
||||
NULL, /* qemuDomainMonitorCommand */
|
||||
NULL, /* domainSetMemoryParameters */
|
||||
NULL, /* domainGetMemoryParameters */
|
||||
NULL, /* domainOpenConsole */
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1869,6 +1869,7 @@ static virDriver xenapiDriver = {
|
||||
NULL, /* qemuDomainMonitorCommand */
|
||||
NULL, /* domainSetMemoryParameters */
|
||||
NULL, /* domainGetMemoryParameters */
|
||||
NULL, /* domainOpenConsole */
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user