提交 88a9b382 编写于 作者: D Daniel P. Berrange

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
上级 51269265
...@@ -2402,6 +2402,12 @@ int virNWFilterGetUUIDString (virNWFilterPtr nwfilter, ...@@ -2402,6 +2402,12 @@ int virNWFilterGetUUIDString (virNWFilterPtr nwfilter,
char * virNWFilterGetXMLDesc (virNWFilterPtr nwfilter, char * virNWFilterGetXMLDesc (virNWFilterPtr nwfilter,
int flags); int flags);
int virDomainOpenConsole(virDomainPtr dom,
const char *devname,
virStreamPtr st,
unsigned int flags);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -480,6 +480,11 @@ typedef int ...@@ -480,6 +480,11 @@ typedef int
(*virDrvQemuDomainMonitorCommand)(virDomainPtr domain, const char *cmd, (*virDrvQemuDomainMonitorCommand)(virDomainPtr domain, const char *cmd,
char **result, unsigned int flags); char **result, unsigned int flags);
typedef int
(*virDrvDomainOpenConsole)(virDomainPtr dom,
const char *devname,
virStreamPtr st,
unsigned int flags);
/** /**
...@@ -598,6 +603,7 @@ struct _virDriver { ...@@ -598,6 +603,7 @@ struct _virDriver {
virDrvQemuDomainMonitorCommand qemuDomainMonitorCommand; virDrvQemuDomainMonitorCommand qemuDomainMonitorCommand;
virDrvDomainSetMemoryParameters domainSetMemoryParameters; virDrvDomainSetMemoryParameters domainSetMemoryParameters;
virDrvDomainGetMemoryParameters domainGetMemoryParameters; virDrvDomainGetMemoryParameters domainGetMemoryParameters;
virDrvDomainOpenConsole domainOpenConsole;
}; };
typedef int typedef int
......
...@@ -4382,6 +4382,7 @@ static virDriver esxDriver = { ...@@ -4382,6 +4382,7 @@ static virDriver esxDriver = {
NULL, /* qemuDomainMonitorCommand */ NULL, /* qemuDomainMonitorCommand */
esxDomainSetMemoryParameters, /* domainSetMemoryParameters */ esxDomainSetMemoryParameters, /* domainSetMemoryParameters */
esxDomainGetMemoryParameters, /* domainGetMemoryParameters */ esxDomainGetMemoryParameters, /* domainGetMemoryParameters */
NULL, /* domainOpenConsole */
}; };
......
...@@ -13114,3 +13114,56 @@ virDomainSnapshotFree(virDomainSnapshotPtr snapshot) ...@@ -13114,3 +13114,56 @@ virDomainSnapshotFree(virDomainSnapshotPtr snapshot)
} }
return 0; 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 { ...@@ -413,4 +413,9 @@ LIBVIRT_0.8.5 {
virDomainSetVcpusFlags; virDomainSetVcpusFlags;
} LIBVIRT_0.8.2; } LIBVIRT_0.8.2;
LIBVIRT_0.8.6 {
global:
virDomainOpenConsole;
} LIBVIRT_0.8.5;
# .... define new API here using predicted next version number .... # .... define new API here using predicted next version number ....
...@@ -2836,6 +2836,7 @@ static virDriver lxcDriver = { ...@@ -2836,6 +2836,7 @@ static virDriver lxcDriver = {
NULL, /* qemuDomainMonitorCommand */ NULL, /* qemuDomainMonitorCommand */
lxcDomainSetMemoryParameters, /* domainSetMemoryParameters */ lxcDomainSetMemoryParameters, /* domainSetMemoryParameters */
lxcDomainGetMemoryParameters, /* domainGetMemoryParameters */ lxcDomainGetMemoryParameters, /* domainGetMemoryParameters */
NULL, /* domainOpenConsole */
}; };
static virStateDriver lxcStateDriver = { static virStateDriver lxcStateDriver = {
......
...@@ -822,6 +822,7 @@ static virDriver oneDriver = { ...@@ -822,6 +822,7 @@ static virDriver oneDriver = {
NULL, /* qemuDomainMonitorCommand */ NULL, /* qemuDomainMonitorCommand */
NULL, /* domainSetMemoryParameters */ NULL, /* domainSetMemoryParameters */
NULL, /* domainGetMemoryParameters */ NULL, /* domainGetMemoryParameters */
NULL, /* domainOpenConsole */
}; };
static virStateDriver oneStateDriver = { static virStateDriver oneStateDriver = {
......
...@@ -1691,6 +1691,7 @@ static virDriver openvzDriver = { ...@@ -1691,6 +1691,7 @@ static virDriver openvzDriver = {
NULL, /* qemuDomainMonitorCommand */ NULL, /* qemuDomainMonitorCommand */
NULL, /* domainSetMemoryParameters */ NULL, /* domainSetMemoryParameters */
NULL, /* domainGetMemoryParameters */ NULL, /* domainGetMemoryParameters */
NULL, /* domainOpenConsole */
}; };
int openvzRegister(void) { int openvzRegister(void) {
......
...@@ -4045,6 +4045,7 @@ static virDriver phypDriver = { ...@@ -4045,6 +4045,7 @@ static virDriver phypDriver = {
NULL, /* qemuMonitorCommand */ NULL, /* qemuMonitorCommand */
NULL, /* domainSetMemoryParameters */ NULL, /* domainSetMemoryParameters */
NULL, /* domainGetMemoryParameters */ NULL, /* domainGetMemoryParameters */
NULL, /* domainOpenConsole */
}; };
static virStorageDriver phypStorageDriver = { static virStorageDriver phypStorageDriver = {
......
...@@ -13428,6 +13428,7 @@ static virDriver qemuDriver = { ...@@ -13428,6 +13428,7 @@ static virDriver qemuDriver = {
qemuDomainMonitorCommand, /* qemuDomainMonitorCommand */ qemuDomainMonitorCommand, /* qemuDomainMonitorCommand */
qemuDomainSetMemoryParameters, /* domainSetMemoryParameters */ qemuDomainSetMemoryParameters, /* domainSetMemoryParameters */
qemuDomainGetMemoryParameters, /* domainGetMemoryParameters */ qemuDomainGetMemoryParameters, /* domainGetMemoryParameters */
NULL, /* domainOpenConsole */
}; };
......
...@@ -10691,6 +10691,7 @@ static virDriver remote_driver = { ...@@ -10691,6 +10691,7 @@ static virDriver remote_driver = {
remoteQemuDomainMonitorCommand, /* qemuDomainMonitorCommand */ remoteQemuDomainMonitorCommand, /* qemuDomainMonitorCommand */
remoteDomainSetMemoryParameters, /* domainSetMemoryParameters */ remoteDomainSetMemoryParameters, /* domainSetMemoryParameters */
remoteDomainGetMemoryParameters, /* domainGetMemoryParameters */ remoteDomainGetMemoryParameters, /* domainGetMemoryParameters */
NULL, /* domainOpenConsole */
}; };
static virNetworkDriver network_driver = { static virNetworkDriver network_driver = {
......
...@@ -5443,6 +5443,7 @@ static virDriver testDriver = { ...@@ -5443,6 +5443,7 @@ static virDriver testDriver = {
NULL, /* qemuDomainMonitorCommand */ NULL, /* qemuDomainMonitorCommand */
NULL, /* domainSetMemoryParameters */ NULL, /* domainSetMemoryParameters */
NULL, /* domainGetMemoryParameters */ NULL, /* domainGetMemoryParameters */
NULL, /* domainOpenConsole */
}; };
static virNetworkDriver testNetworkDriver = { static virNetworkDriver testNetworkDriver = {
......
...@@ -2200,6 +2200,7 @@ static virDriver umlDriver = { ...@@ -2200,6 +2200,7 @@ static virDriver umlDriver = {
NULL, /* qemuDomainMonitorCommand */ NULL, /* qemuDomainMonitorCommand */
NULL, /* domainSetMemoryParamters */ NULL, /* domainSetMemoryParamters */
NULL, /* domainGetMemoryParamters */ NULL, /* domainGetMemoryParamters */
NULL, /* domainOpenConsole */
}; };
static int static int
......
...@@ -8464,6 +8464,7 @@ virDriver NAME(Driver) = { ...@@ -8464,6 +8464,7 @@ virDriver NAME(Driver) = {
NULL, /* qemuDomainMonitorCommand */ NULL, /* qemuDomainMonitorCommand */
NULL, /* domainSetMemoryParameters */ NULL, /* domainSetMemoryParameters */
NULL, /* domainGetMemoryParameters */ NULL, /* domainGetMemoryParameters */
NULL, /* domainOpenConsole */
}; };
virNetworkDriver NAME(NetworkDriver) = { virNetworkDriver NAME(NetworkDriver) = {
......
...@@ -2035,6 +2035,7 @@ static virDriver xenUnifiedDriver = { ...@@ -2035,6 +2035,7 @@ static virDriver xenUnifiedDriver = {
NULL, /* qemuDomainMonitorCommand */ NULL, /* qemuDomainMonitorCommand */
NULL, /* domainSetMemoryParameters */ NULL, /* domainSetMemoryParameters */
NULL, /* domainGetMemoryParameters */ NULL, /* domainGetMemoryParameters */
NULL, /* domainOpenConsole */
}; };
/** /**
......
...@@ -1869,6 +1869,7 @@ static virDriver xenapiDriver = { ...@@ -1869,6 +1869,7 @@ static virDriver xenapiDriver = {
NULL, /* qemuDomainMonitorCommand */ NULL, /* qemuDomainMonitorCommand */
NULL, /* domainSetMemoryParameters */ NULL, /* domainSetMemoryParameters */
NULL, /* domainGetMemoryParameters */ NULL, /* domainGetMemoryParameters */
NULL, /* domainOpenConsole */
}; };
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册