
On Mon, Aug 23, 2010 at 12:19:51PM +0200, Soren Hansen wrote:
Like the comment suggested, we just open the file and pass the file descriptor to uml. The input "stream" is set to "null", since I couldn't find any useful way to actually use a file for input for a chardev and this also mimics what e.g. QEmu does internally.
Signed-off-by: Soren Hansen <soren@linux2go.dk> --- src/uml/uml_conf.c | 31 ++++++++++++++++++++++++++----- src/uml/uml_conf.h | 1 + src/uml/uml_driver.c | 12 +++++++++++- 3 files changed, 38 insertions(+), 6 deletions(-)
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 9cad7f1..e926a9f 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -811,6 +811,7 @@ static int umlStartVMDaemon(virConnectPtr conn, char *logfile; int logfd = -1; struct stat sb; + int openmax; fd_set keepfd; char ebuf[1024]; umlDomainObjPrivatePtr priv = vm->privateData; @@ -869,7 +870,7 @@ static int umlStartVMDaemon(virConnectPtr conn, return -1; }
- if (umlBuildCommandLine(conn, driver, vm, + if (umlBuildCommandLine(conn, driver, vm, &keepfd, &argv, &progenv) < 0) { close(logfd); umlCleanupTapDevices(conn, vm); @@ -908,6 +909,15 @@ static int umlStartVMDaemon(virConnectPtr conn, NULL, NULL, NULL); close(logfd);
+ /* + * At the moment, the only thing that populates keepfd is + * umlBuildCommandLineChr. We want to close every fd it opens. + */ + openmax = sysconf (_SC_OPEN_MAX); + for (i = 0; i < openmax; i++) + if (FD_ISSET(i, &keepfd)) + close(i); +
Unfortunately fdset is one of those limited types that can't represent all possible values. So you need to use FD_SETSIZE instead of _SC_OPEN_MAX here Regards, Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|