[libvirt] [PATCH v2] bhyve: add console support through nmdm device
by Roman Bogorodskiy
Changes from v1:
Switch over from implicit slave device path, i.e. guessing
from <source path='/dev/nmdm0A'/> that the slave is '/dev/nmdm0B', to
explicit master and slave device specification using
<source master='/dev/nmdm0A' slave='/dev/nmdm0B'/>.
Roman Bogorodskiy (1):
bhyve: add console support through nmdm device
src/bhyve/bhyve_command.c | 34 +++++++++++++++++++++++++
src/bhyve/bhyve_driver.c | 45 +++++++++++++++++++++++++++++++++
src/conf/domain_audit.c | 1 +
src/conf/domain_conf.c | 59 +++++++++++++++++++++++++++++++++++++++++++-
src/conf/domain_conf.h | 5 ++++
src/qemu/qemu_command.c | 1 +
src/qemu/qemu_monitor_json.c | 1 +
7 files changed, 145 insertions(+), 1 deletion(-)
--
1.8.4.2
10 years, 8 months
[libvirt] [PATCH] bhyve: add domainCreateWithFlags support
by Roman Bogorodskiy
The only supported flag for now is 'autodestroy'. In order to
support 'autodestroy', add support for close callbacks.
---
src/bhyve/bhyve_driver.c | 28 +++++++++++++++++++++++++---
src/bhyve/bhyve_process.c | 29 ++++++++++++++++++++++++++++-
src/bhyve/bhyve_process.h | 7 ++++++-
src/bhyve/bhyve_utils.h | 3 +++
4 files changed, 62 insertions(+), 5 deletions(-)
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index ff9ac0d..3d7b7ce 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -176,6 +176,9 @@ bhyveConnectOpen(virConnectPtr conn,
static int
bhyveConnectClose(virConnectPtr conn)
{
+ bhyveConnPtr privconn = conn->privateData;
+
+ virCloseCallbacksRun(privconn->closeCallbacks, conn, privconn->domains, privconn);
conn->privateData = NULL;
return 0;
@@ -528,16 +531,23 @@ cleanup:
}
static int
-bhyveDomainCreate(virDomainPtr dom)
+bhyveDomainCreateWithFlags(virDomainPtr dom,
+ unsigned int flags)
{
bhyveConnPtr privconn = dom->conn->privateData;
virDomainObjPtr vm;
+ unsigned int start_flags = 0;
int ret = -1;
+ virCheckFlags(VIR_DOMAIN_START_AUTODESTROY, -1);
+
+ if (flags & VIR_DOMAIN_START_AUTODESTROY)
+ start_flags |= VIR_BHYVE_PROCESS_START_AUTODESTROY;
+
if (!(vm = bhyveDomObjFromDomain(dom)))
goto cleanup;
- if (virDomainCreateEnsureACL(dom->conn, vm->def) < 0)
+ if (virDomainCreateWithFlagsEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
if (virDomainObjIsActive(vm)) {
@@ -547,7 +557,8 @@ bhyveDomainCreate(virDomainPtr dom)
}
ret = virBhyveProcessStart(dom->conn, privconn, vm,
- VIR_DOMAIN_RUNNING_BOOTED);
+ VIR_DOMAIN_RUNNING_BOOTED,
+ start_flags);
cleanup:
virObjectUnlock(vm);
@@ -555,6 +566,12 @@ cleanup:
}
static int
+bhyveDomainCreate(virDomainPtr dom)
+{
+ return bhyveDomainCreateWithFlags(dom, 0);
+}
+
+static int
bhyveDomainDestroy(virDomainPtr dom)
{
bhyveConnPtr privconn = dom->conn->privateData;
@@ -627,6 +644,7 @@ bhyveStateCleanup(void)
virObjectUnref(bhyve_driver->domains);
virObjectUnref(bhyve_driver->caps);
virObjectUnref(bhyve_driver->xmlopt);
+ virObjectUnref(bhyve_driver->closeCallbacks);
virMutexDestroy(&bhyve_driver->lock);
VIR_FREE(bhyve_driver);
@@ -653,6 +671,9 @@ bhyveStateInitialize(bool priveleged ATTRIBUTE_UNUSED,
return -1;
}
+ if (!(bhyve_driver->closeCallbacks = virCloseCallbacksNew()))
+ goto cleanup;
+
if (!(bhyve_driver->caps = bhyveBuildCapabilities()))
goto cleanup;
@@ -709,6 +730,7 @@ static virDriver bhyveDriver = {
.connectListDefinedDomains = bhyveConnectListDefinedDomains, /* 1.2.2 */
.connectNumOfDefinedDomains = bhyveConnectNumOfDefinedDomains, /* 1.2.2 */
.domainCreate = bhyveDomainCreate, /* 1.2.2 */
+ .domainCreateWithFlags = bhyveDomainCreateWithFlags, /* 1.2.3 */
.domainDestroy = bhyveDomainDestroy, /* 1.2.2 */
.domainLookupByUUID = bhyveDomainLookupByUUID, /* 1.2.2 */
.domainLookupByName = bhyveDomainLookupByName, /* 1.2.2 */
diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c
index ee85680..05bfe15 100644
--- a/src/bhyve/bhyve_process.c
+++ b/src/bhyve/bhyve_process.c
@@ -44,11 +44,29 @@
#define VIR_FROM_THIS VIR_FROM_BHYVE
+static virDomainObjPtr
+bhyveProcessAutoDestroy(virDomainObjPtr vm,
+ virConnectPtr conn ATTRIBUTE_UNUSED,
+ void *opaque)
+{
+ bhyveConnPtr driver = opaque;
+
+ virBhyveProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED);
+
+ if (!vm->persistent) {
+ virDomainObjListRemove(driver->domains, vm);
+ vm = NULL;
+ }
+
+ return vm;
+}
+
int
virBhyveProcessStart(virConnectPtr conn,
bhyveConnPtr driver,
virDomainObjPtr vm,
- virDomainRunningReason reason)
+ virDomainRunningReason reason,
+ unsigned int flags)
{
char *logfile = NULL;
int logfd = -1;
@@ -130,6 +148,12 @@ virBhyveProcessStart(virConnectPtr conn,
vm->def->id = vm->pid;
virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, reason);
+
+ if (flags & VIR_BHYVE_PROCESS_START_AUTODESTROY &&
+ virCloseCallbacksSet(driver->closeCallbacks, vm,
+ conn, bhyveProcessAutoDestroy) < 0)
+ goto cleanup;
+
} else {
goto cleanup;
}
@@ -201,6 +225,9 @@ virBhyveProcessStop(bhyveConnPtr driver,
ret = 0;
+ virCloseCallbacksUnset(driver->closeCallbacks, vm,
+ bhyveProcessAutoDestroy);
+
virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, reason);
vm->pid = -1;
vm->def->id = -1;
diff --git a/src/bhyve/bhyve_process.h b/src/bhyve/bhyve_process.h
index 66548ae..f91504e 100644
--- a/src/bhyve/bhyve_process.h
+++ b/src/bhyve/bhyve_process.h
@@ -27,10 +27,15 @@
int virBhyveProcessStart(virConnectPtr conn,
bhyveConnPtr driver,
virDomainObjPtr vm,
- virDomainRunningReason reason);
+ virDomainRunningReason reason,
+ unsigned int flags);
int virBhyveProcessStop(bhyveConnPtr driver,
virDomainObjPtr vm,
virDomainShutoffReason reason);
+typedef enum {
+ VIR_BHYVE_PROCESS_START_AUTODESTROY = 1 << 0,
+} bhyveProcessStartFlags;
+
#endif /* __BHYVE_PROCESS_H__ */
diff --git a/src/bhyve/bhyve_utils.h b/src/bhyve/bhyve_utils.h
index 0810caa..6c76770 100644
--- a/src/bhyve/bhyve_utils.h
+++ b/src/bhyve/bhyve_utils.h
@@ -26,6 +26,7 @@
# include "domain_conf.h"
# include "configmake.h"
# include "virthread.h"
+# include "virclosecallbacks.h"
# define BHYVE_AUTOSTART_DIR SYSCONFDIR "/libvirt/bhyve/autostart"
# define BHYVE_CONFIG_DIR SYSCONFDIR "/libvirt/bhyve"
@@ -38,6 +39,8 @@ struct _bhyveConn {
virCapsPtr caps;
virDomainXMLOptionPtr xmlopt;
char *pidfile;
+
+ virCloseCallbacksPtr closeCallbacks;
};
typedef struct _bhyveConn bhyveConn;
--
1.8.4.3
10 years, 8 months
[libvirt] [PATCH v8 0/4] support dumping guest memory in compressed format
by qiaonuohan@cn.fujitsu.com
dumping guest's memory is introduced without compression supported, but now
qemu can dump guest's memory in kdump-compressed format. This patchset is used
to add support in libvirt side to let qemu do the dump in compressed format and
please refer the following address to see implementation of the qemu side, the
lastest version of qemu side is v9.
http://lists.nongnu.org/archive/html/qemu-devel/2014-02/msg03016.html
ChangLog:
Changes from v7 to v8:
1. add test for qemuMonitorGetDumpGuestMemoryCapability
2. fix a bug when dumping a elf core with the an older version of qemu
Changes from v6 to v7:
1. revert changing dumpformat of virDomainCoreDumpWithFormat back to an enum
Changes from v5 to v6:
1. add qemuMonitorGetDumpGuestMemoryCapability API to check the available dump
format
Changes from v4 to v5:
1. modify some restriction check
Changes from v3 to v4:
1. dropping patch "add dump_memory_format in qemu.conf"
2. fix to follow some conventions
Changes from v2 to v3:
1. address Jiri Denemark's comment about adding a new public API instead of
changing an old one.
Changes from v1 to v2:
1. address Daniel P. Berrange's comment about using a new parameter to replace
flags like VIR_DUMP_COMPRESS_ZLIB.
qiaonuohan (4):
add new virDomainCoreDumpWithFormat API
qemu: add qemuMonitorGetDumpGuestMemoryCapability
qemu: add support for virDomainCoreDumpWithFormat API
allow "virsh dump --memory-only" specify dump format
include/libvirt/libvirt.h.in | 31 ++++++++++++++
src/driver.h | 7 ++++
src/libvirt.c | 98 ++++++++++++++++++++++++++++++++++++++++++++
src/libvirt_public.syms | 5 +++
src/qemu/qemu_driver.c | 75 ++++++++++++++++++++++++++++-----
src/qemu/qemu_monitor.c | 27 ++++++++++--
src/qemu/qemu_monitor.h | 6 ++-
src/qemu/qemu_monitor_json.c | 85 +++++++++++++++++++++++++++++++++++---
src/qemu/qemu_monitor_json.h | 6 ++-
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 15 ++++++-
src/remote_protocol-structs | 7 ++++
src/test/test_driver.c | 22 ++++++++--
tests/qemumonitorjsontest.c | 45 +++++++++++++++++++-
tools/virsh-domain.c | 47 +++++++++++++++++++--
tools/virsh.pod | 6 +++
16 files changed, 454 insertions(+), 29 deletions(-)
--
1.8.5.3
10 years, 8 months
[libvirt] ANNOUNCE: virt-manager 1.0.1 released
by Cole Robinson
I'm happy to announce the release of virt-manager 1.0.1!
virt-manager is a desktop application for managing KVM, Xen, and LXC
virtualization via libvirt.
The release can be downloaded from:
http://virt-manager.org/download/
The direct download links are:
http://virt-manager.org/download/sources/virt-manager/virt-manager-1.0.1....
This release includes:
- virt-install/virt-xml: New --memorybacking option (Chen Hanxiao)
- virt-install/virt-xml: New --memtune option (Chen Hanxiao)
- virt-manager: UI for LXC <idmap> (Chen Hanxiao)
- virt-manager: gsettings key to disable keygrab (Kjö Hansi Glaz)
- virt-manager: Show domain state reason in the UI (Giuseppe Scrivano)
- Fix a number of bugs found since the 1.0.0 release
Thanks to everyone who has contributed to this release through testing,
bug reporting, submitting patches, and otherwise sending in feedback!
Thanks,
Cole
10 years, 8 months
[libvirt] RFE: Make saveDir/cacheDir/snapshotDir/dumpDir configurable and allow per-domain paths
by Till Maas
Hi,
I would like to separate all data of libvirt domains so that each domain
can easily be deleted securely. However libvirt by default uses static
directories to store data from domains such as snapshots, current states
and dumps. Also a cache dir is used for reasons unknown to me. To
separate the data, I would like to use different directories for each
domain. For this these paths need to be configurable e.g. in qemu.conf
and it needs to be possible to for example specify a placeholder in the
path that is substituted by the domain's name, so that e.g.:
/srv/{name}/save/
can be specified to use
/srv/dom1/save/dom1.save
as save path.
This change should have low impact on regular users, because the
defaults can be set to match the current behaviour. What is your opinion
on this?
Do you have any ideas about how to do the name substitution best?
Kind regards
Till
P.S.: I am not subscribed to the list so please CC me.
10 years, 8 months
[libvirt] [python PATCH] maint: ignore .pyc files
by Eric Blake
* .gitignore: Add exemption.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Not sure what created it, but I noticed a tests/test_conn.pyc
had crept into my source tree. It's easy enough to ignore
compiled python code, so I'm pushing under the trivial rule.
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index 44e1656..f47e786 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@ MANIFEST
*~
*#*#
*.#*#
+*.pyc
--
1.8.5.3
10 years, 8 months
[libvirt] More java bindings functions
by Pasquale Dir
Hello,
I just added, because I needed them, two new bindings for java apis:
Connection.getCpuStats(int, long)
and
Domain.getCpuStats(int, long)
these two functions act like python's counterpart.
I give you the .jar with sources so that, after you review it (it works but
I am not entirely sure it is bug free), you could publish it thus helping
java programmers who needed a cpu indicator too.
Regards,
Pasquale Di Rienzo
10 years, 8 months
[libvirt] [PATCH][RFC] Add a rule for indenting labels
by Ján Tomko
Indent labels by one space.
Add the rule to HACKING and enforce it by syntax-check.
---
Adding a space helps git's function context detection, but the fallout
patch is over 800K.
My reasoning for also indenting labels in nested code is that
vim's cinoptions don't have a separate option for these labels
(or I haven't searched hard enough?).
Inspired by this thread:
https://www.redhat.com/archives/libvir-list/2014-March/msg01310.html
cfg.mk | 7 +++++++
docs/hacking.html.in | 18 +++++++++++++++++-
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/cfg.mk b/cfg.mk
index 559f719..1512fb2 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -898,6 +898,13 @@ sc_prohibit_virConnectOpen_in_virsh:
halt='Use vshConnect() in virsh instead of virConnectOpen*' \
$(_sc_search_regexp)
+sc_require_space_before_label:
+ @prohibit='^(( {2})*|( {3})*)([_a-zA-Z0-9]+):$$' \
+ exclude='( {4})*default:$$' \
+ in_vc_files='\.[ch]$$' \
+ halt="Labels should be indented by 4*n + 1 spaces" \
+ $(_sc_search_regexp)
+
sc_curly_braces_style:
@files=$$($(VC_LIST_EXCEPT) | grep '\.[ch]$$'); \
$(GREP) -nHP \
diff --git a/docs/hacking.html.in b/docs/hacking.html.in
index 0febee2..b2b158a 100644
--- a/docs/hacking.html.in
+++ b/docs/hacking.html.in
@@ -303,7 +303,7 @@
set tabstop=8
set shiftwidth=4
set expandtab
- set cinoptions=(0,:0,l1,t0
+ set cinoptions=(0,:0,l1,t0,L3
filetype plugin indent on
au FileType make setlocal noexpandtab
au BufRead,BufNewFile *.am setlocal noexpandtab
@@ -1139,6 +1139,22 @@
retry: If needing to jump upwards (e.g., retry on EINTR)
</pre>
+ <p>
+ Labels should be indented by one space (putting them on the beginning
+ of the line confuses function context detection in emacs and git):
+ </p>
+
+<pre>
+int foo()
+{
+ if (wizz) {
+ retry:
+ goto retry;
+ }
+ cleanup:
+}
+</pre>
+
<h2><a name="committers">Libvirt committer guidelines</a></h2>
--
1.8.3.2
10 years, 8 months
[libvirt] [PATCH] libxl_driver.c: cleanup code
by Chunyan Liu
Following Jim's comments about "add pci passthrough to libxl" patch:
https://www.redhat.com/archives/libvir-list/2014-March/msg00170.html
Signed-off-by: Chunyan Liu <cyliu(a)suse.com>
---
src/libxl/libxl_driver.c | 47 +++++++++++++++++++----------------------------
1 file changed, 19 insertions(+), 28 deletions(-)
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index a6ba10a..4d22fb7 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -3357,10 +3357,10 @@ libxlDomainAttachHostPCIDevice(libxlDriverPrivatePtr driver,
if (virHostdevPreparePCIDevices(hostdev_mgr, LIBXL_DRIVER_NAME,
vm->def->name, vm->def->uuid,
&hostdev, 1, 0) < 0)
- goto cleanup;
+ return -1;
if (libxlMakePci(hostdev, &pcidev) < 0)
- goto reattach_hostdev;
+ goto error;
if (libxl_device_pci_add(priv->ctx, vm->def->id, &pcidev, 0) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -3369,17 +3369,15 @@ libxlDomainAttachHostPCIDevice(libxlDriverPrivatePtr driver,
hostdev->source.subsys.u.pci.addr.bus,
hostdev->source.subsys.u.pci.addr.slot,
hostdev->source.subsys.u.pci.addr.function);
- goto reattach_hostdev;
+ goto error;
}
vm->def->hostdevs[vm->def->nhostdevs++] = hostdev;
return 0;
-reattach_hostdev:
+error:
virHostdevReAttachPCIDevices(hostdev_mgr, LIBXL_DRIVER_NAME,
vm->def->name, &hostdev, 1, NULL);
-
-cleanup:
return -1;
}
@@ -3401,20 +3399,17 @@ libxlDomainAttachHostDevice(libxlDriverPrivatePtr driver,
switch (hostdev->source.subsys.type) {
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
if (libxlDomainAttachHostPCIDevice(driver, priv, vm, hostdev) < 0)
- goto error;
+ return -1;
break;
default:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("hostdev subsys type '%s' not supported"),
virDomainHostdevSubsysTypeToString(hostdev->source.subsys.type));
- goto error;
+ return -1;
}
return 0;
-
-error:
- return -1;
}
static int
@@ -3608,14 +3603,14 @@ libxlDomainDetachHostPCIDevice(libxlDriverPrivatePtr driver,
_("cannot hot unplug multifunction PCI device: %.4x:%.2x:%.2x.%.1x"),
subsys->u.pci.addr.domain, subsys->u.pci.addr.bus,
subsys->u.pci.addr.slot, subsys->u.pci.addr.function);
- goto cleanup;
+ goto error;
}
libxl_device_pci_init(&pcidev);
if (libxlMakePci(detach, &pcidev) < 0)
- goto cleanup;
+ goto error;
if (libxl_device_pci_remove(priv->ctx, vm->def->id, &pcidev, 0) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -3623,7 +3618,7 @@ libxlDomainDetachHostPCIDevice(libxlDriverPrivatePtr driver,
%.4x:%.2x:%.2x.%.1x"),
subsys->u.pci.addr.domain, subsys->u.pci.addr.bus,
subsys->u.pci.addr.slot, subsys->u.pci.addr.function);
- goto cleanup;
+ goto error;
}
libxl_device_pci_dispose(&pcidev);
@@ -3635,7 +3630,7 @@ libxlDomainDetachHostPCIDevice(libxlDriverPrivatePtr driver,
return 0;
-cleanup:
+error:
virDomainHostdevDefFree(detach);
return -1;
}
@@ -4897,7 +4892,6 @@ libxlNodeDeviceGetPCIInfo(virNodeDeviceDefPtr def,
unsigned *function)
{
virNodeDevCapsDefPtr cap;
- int ret = -1;
cap = def->caps;
while (cap) {
@@ -4915,12 +4909,10 @@ libxlNodeDeviceGetPCIInfo(virNodeDeviceDefPtr def,
if (!cap) {
virReportError(VIR_ERR_INVALID_ARG,
_("device %s is not a PCI device"), def->name);
- goto out;
+ return -1;
}
- ret = 0;
-out:
- return ret;
+ return 0;
}
static int
@@ -5012,12 +5004,12 @@ libxlNodeDeviceReAttach(virNodeDevicePtr dev)
goto cleanup;
if (virHostdevPCINodeDeviceReAttach(hostdev_mgr, pci) < 0)
- goto out;
+ goto cleanup;
ret = 0;
-out:
- virPCIDeviceFree(pci);
+
cleanup:
+ virPCIDeviceFree(pci);
virNodeDeviceDefFree(def);
VIR_FREE(xml);
return ret;
@@ -5026,7 +5018,7 @@ cleanup:
static int
libxlNodeDeviceReset(virNodeDevicePtr dev)
{
- virPCIDevicePtr pci;
+ virPCIDevicePtr pci = NULL;
unsigned domain = 0, bus = 0, slot = 0, function = 0;
int ret = -1;
virNodeDeviceDefPtr def = NULL;
@@ -5053,18 +5045,17 @@ libxlNodeDeviceReset(virNodeDevicePtr dev)
goto cleanup;
if (virHostdevPCINodeDeviceReset(hostdev_mgr, pci) < 0)
- goto out;
+ goto cleanup;
ret = 0;
-out:
- virPCIDeviceFree(pci);
+
cleanup:
+ virPCIDeviceFree(pci);
virNodeDeviceDefFree(def);
VIR_FREE(xml);
return ret;
}
-
static virDriver libxlDriver = {
.no = VIR_DRV_LIBXL,
.name = LIBXL_DRIVER_NAME,
--
1.7.12.4
10 years, 8 months
[libvirt] [PATCH] Introduce virFDStreamOpenPTY
by Roman Bogorodskiy
Add virFDStreamOpenPTY() function which is a wrapper around
virFDStreamOpenFileInternal() with putting the device it opens into a
raw mode.
Make virChrdevOpen() use virFDStreamOpenPTY() for
VIR_DOMAIN_CHR_TYPE_PTY devices.
This fixes mangled console output when libvirt runs on FreeBSD as it
requires device it opens to be placed into a raw mode explicitly.
---
src/conf/virchrdev.c | 2 +-
src/fdstream.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++
src/fdstream.h | 5 +++++
3 files changed, 59 insertions(+), 1 deletion(-)
diff --git a/src/conf/virchrdev.c b/src/conf/virchrdev.c
index 3e6beaa..2fd9a6c 100644
--- a/src/conf/virchrdev.c
+++ b/src/conf/virchrdev.c
@@ -408,7 +408,7 @@ int virChrdevOpen(virChrdevsPtr devs,
/* open the character device */
switch (source->type) {
case VIR_DOMAIN_CHR_TYPE_PTY:
- if (virFDStreamOpenFile(st, path, 0, 0, O_RDWR) < 0)
+ if (virFDStreamOpenPTY(st, path, 0, 0, O_RDWR) < 0)
goto error;
break;
case VIR_DOMAIN_CHR_TYPE_UNIX:
diff --git a/src/fdstream.c b/src/fdstream.c
index 04d62b8..39d58e0 100644
--- a/src/fdstream.c
+++ b/src/fdstream.c
@@ -31,6 +31,7 @@
# include <sys/un.h>
#endif
#include <netinet/in.h>
+#include <termios.h>
#include "fdstream.h"
#include "virerror.h"
@@ -714,6 +715,58 @@ int virFDStreamCreateFile(virStreamPtr st,
oflags | O_CREAT, mode);
}
+#ifdef HAVE_CFMAKERAW
+int virFDStreamOpenPTY(virStreamPtr st,
+ const char *path,
+ unsigned long long offset,
+ unsigned long long length,
+ int oflags)
+{
+ struct virFDStreamData *fdst = NULL;
+ struct termios rawattr;
+
+ if (virFDStreamOpenFileInternal(st, path,
+ offset, length,
+ oflags | O_CREAT, 0) < 0)
+ return -1;
+
+ fdst = st->privateData;
+
+ if (tcgetattr(fdst->fd, &rawattr) < 0) {
+ virReportSystemError(errno,
+ _("unable to get tty attributes: %s"),
+ path);
+ goto cleanup;
+ }
+
+ cfmakeraw(&rawattr);
+
+ if (tcsetattr(fdst->fd, TCSANOW, &rawattr) < 0) {
+ virReportSystemError(errno,
+ _("unable to set tty attributes: %s"),
+ path);
+ goto cleanup;
+ }
+
+ return 0;
+
+cleanup:
+ virFDStreamClose(st);
+ return -1;
+}
+#else /* !HAVE_CFMAKERAW */
+int virFDStreamOpenPTY(virStreamPtr st,
+ const char *path,
+ unsigned long long offset,
+ unsigned long long length,
+ int oflags)
+{
+ return virFDStreamOpenFileInternal(st, path,
+ offset, length,
+ oflags | O_CREAT, 0);
+}
+#endif /* !HAVE_CFMAKERAW */
+
int virFDStreamSetInternalCloseCb(virStreamPtr st,
virFDStreamInternalCloseCb cb,
void *opaque,
diff --git a/src/fdstream.h b/src/fdstream.h
index 3ca6256..9c7295d 100644
--- a/src/fdstream.h
+++ b/src/fdstream.h
@@ -54,6 +54,11 @@ int virFDStreamCreateFile(virStreamPtr st,
unsigned long long length,
int oflags,
mode_t mode);
+int virFDStreamOpenPTY(virStreamPtr st,
+ const char *path,
+ unsigned long long offset,
+ unsigned long long length,
+ int oflags);
int virFDStreamSetInternalCloseCb(virStreamPtr st,
virFDStreamInternalCloseCb cb,
--
1.8.4.2
10 years, 8 months