Re: [libvirt] [PATCH 4/7] Add support for multiple consoles in LXC

2011-11-03 Thread Daniel P. Berrange
On Wed, Nov 02, 2011 at 02:46:50PM -0600, Eric Blake wrote:
> On 10/20/2011 08:47 AM, Daniel P. Berrange wrote:
> >From: "Daniel P. Berrange"
> >
> >Currently the LXC controller only supports setup of a single
> >text console. This is wired up to the container init's stdio,
> >as well as /dev/console and /dev/tty1. Extending support for
> >multiple consoles, means wiring up additional PTYs to /dev/tty2,
> >/dev/tty3, etc, etc. The LXC controller is passed multiple open
> >file handles, one for each console requested.
> >
> >* src/lxc/lxc_container.c, src/lxc/lxc_container.h: Wire up
> >   all the /dev/ttyN links required to symlink to /dev/pts/NN
> >* src/lxc/lxc_container.h: Open more container side /dev/pts/NN
> >   devices, and adapt event loop to handle I/O from all consoles
> >* src/lxc/lxc_driver.c: Setup multiple host side PTYs
> >---
> >  src/lxc/lxc_container.c  |   81 +++-
> >  src/lxc/lxc_container.h  |3 +-
> >  src/lxc/lxc_controller.c |  160 
> > +-
> >  src/lxc/lxc_driver.c |   62 +++---
> >  4 files changed, 191 insertions(+), 115 deletions(-)
> >
> 
> >@@ -891,10 +900,9 @@ cleanup:
> >  virMutexDestroy(&lock);
> >  signal(SIGCHLD, SIG_DFL);
> >  cleanup2:
> >-VIR_FORCE_CLOSE(console.hostFd);
> >-VIR_FORCE_CLOSE(console.contFd);
> >  VIR_FORCE_CLOSE(monitor.serverFd);
> >  VIR_FORCE_CLOSE(monitor.clientFd);
> >+VIR_FREE(consoles);
> 
> The old code was closing all fds; should the new code be iterating
> over consoles and freeing both fd members per consoles[i]?

These FDs were actually passed into this method, so I decided it
was better practice for the caller to close them instead, since
it opened them.

Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 4/7] Add support for multiple consoles in LXC

2011-11-02 Thread Eric Blake

On 10/20/2011 08:47 AM, Daniel P. Berrange wrote:

From: "Daniel P. Berrange"

Currently the LXC controller only supports setup of a single
text console. This is wired up to the container init's stdio,
as well as /dev/console and /dev/tty1. Extending support for
multiple consoles, means wiring up additional PTYs to /dev/tty2,
/dev/tty3, etc, etc. The LXC controller is passed multiple open
file handles, one for each console requested.

* src/lxc/lxc_container.c, src/lxc/lxc_container.h: Wire up
   all the /dev/ttyN links required to symlink to /dev/pts/NN
* src/lxc/lxc_container.h: Open more container side /dev/pts/NN
   devices, and adapt event loop to handle I/O from all consoles
* src/lxc/lxc_driver.c: Setup multiple host side PTYs
---
  src/lxc/lxc_container.c  |   81 +++-
  src/lxc/lxc_container.h  |3 +-
  src/lxc/lxc_controller.c |  160 +-
  src/lxc/lxc_driver.c |   62 +++---
  4 files changed, 191 insertions(+), 115 deletions(-)




@@ -891,10 +900,9 @@ cleanup:
  virMutexDestroy(&lock);
  signal(SIGCHLD, SIG_DFL);
  cleanup2:
-VIR_FORCE_CLOSE(console.hostFd);
-VIR_FORCE_CLOSE(console.contFd);
  VIR_FORCE_CLOSE(monitor.serverFd);
  VIR_FORCE_CLOSE(monitor.clientFd);
+VIR_FREE(consoles);


The old code was closing all fds; should the new code be iterating over 
consoles and freeing both fd members per consoles[i]?



@@ -1677,26 +1681,34 @@ static int lxcVmStart(virConnectPtr conn,
  return -1;
  }

-/* open parent tty */
-if (virFileOpenTty(&parentTty,&parentTtyPath, 1)<  0) {
-virReportSystemError(errno, "%s",
- _("Failed to allocate tty"));
+/* Here we open all the PTYs we need on the host OS side.
+ * The LXC controller will open the guest OS side PTYs
+ * forward I/O between them.


s/forward/and forward/

ACK with those points fixed.

--
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list