Re: [PATCH 6/7] Re-write virsh console to use streams

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Aug 19, 2010 at 03:09:45PM -0600, Eric Blake wrote:
> On 08/17/2010 11:02 AM, Daniel P. Berrange wrote:
> > This re-writes the 'virsh console' command so that it uses
> > the new streams API. This lets it run remotely and/or as a
> > non-root user. This requires that virsh be linked against
> > the simple event loop from libvirtd in daemon/event.c
> > As an added bonus, it can now connect to any console device,
> > not just the first one.
> > 
> > * tools/Makefile.am: Link to event.c
> > * tools/console.c, tools/console.h: Rewrite to use the
> >   virDomainOpenConsole() APIs with streams
> > * tools/virsh.c: Support choosing the console name
> >   via --devname $NAME


> > +static void
> > +virConsoleEventOnStdout(int watch ATTRIBUTE_UNUSED,
> > +                        int fd,
> > +                        int events,
> > +                        void *opaque)
> > +{
> > +    virConsolePtr con = opaque;
> > +
> > +    if (events & VIR_EVENT_HANDLE_WRITABLE &&
> > +        con->streamToTerminal.offset) {
> > +        ssize_t done;
> > +        size_t avail;
> > +        done = write(fd,
> > +                     con->streamToTerminal.data,
> > +                     con->streamToTerminal.offset);
> 
> Do we want to use safewrite here?

All I/O in this is now done non-blocking, so don't actually want to
block on writing the entire buffer. The code expect to see partial
writes & will handle those in a suitable manner, going back to sleep
in the event loop

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 :|

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


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]