Hello, I have a Java application from which I am invoking the "virsh console" command to access the console of a VM. I invoke the virsh command using ProcessBuilder.start(). However, I am unable to communicate with the stdin of the VMs console through the OutputStream of the Process object. When I invoke "virsh console" from within Java, I see the following messages on stderr: info : libvirt version: 0.9.8 error : vshRunConsole:318 : unable to get tty attributes: Inappropriate ioctl for device Does anybody know how I can workaround this? Thanks. -- Regards, Nagaraj
On 05/15/2014 11:34 AM, Nagaraj Mandya wrote:> Hello, > I have a Java application from which I am invoking the "virsh console" > command to access the console of a VM. I invoke the virsh command using > ProcessBuilder.start(). However, I am unable to communicate with the stdin > of the VMs console through the OutputStream of the Process object. > > When I invoke "virsh console" from within Java, I see the following > messages on stderr: > > info : libvirt version: 0.9.8 > error : vshRunConsole:318 : unable to get tty attributes: Inappropriate > ioctl for device > > Does anybody know how I can workaround this? Thanks.Why not just directly use the Java bindings from libvirt-java to access the console directly from your Java program, instead of trying to spawn a third-party application to do it on your behalf? Alas, I'm not familiar enough with the Java bindings to know how easy or hard this may be. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Daniel P. Berrange
2014-May-15 20:19 UTC
Re: [libvirt-users] Invoking virsh console from Java
On Thu, May 15, 2014 at 11:04:09PM +0530, Nagaraj Mandya wrote:> Hello, > I have a Java application from which I am invoking the "virsh console" > command to access the console of a VM. I invoke the virsh command using > ProcessBuilder.start(). However, I am unable to communicate with the stdin > of the VMs console through the OutputStream of the Process object. > > When I invoke "virsh console" from within Java, I see the following > messages on stderr: > > info : libvirt version: 0.9.8 > error : vshRunConsole:318 : unable to get tty attributes: Inappropriate > ioctl for device > > Does anybody know how I can workaround this? Thanks.It sounds like java spawned virsh with just a pipe used for stdio. You need to make sure that the process gets a tty connected to its stdio instead. Regards, 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 :|
Hi Eric, I did check the libvirt Java bindings, but I did not find any way to access the console through the Java API. Is anybody aware of how this can be done using the Java API? -- Regards, Nagaraj On Fri, May 16, 2014 at 1:35 AM, Eric Blake <eblake@redhat.com> wrote:> On 05/15/2014 11:34 AM, Nagaraj Mandya wrote: > > Hello, > > I have a Java application from which I am invoking the "virsh console" > > command to access the console of a VM. I invoke the virsh command using > > ProcessBuilder.start(). However, I am unable to communicate with the > stdin > > of the VMs console through the OutputStream of the Process object. > > > > When I invoke "virsh console" from within Java, I see the following > > messages on stderr: > > > > info : libvirt version: 0.9.8 > > error : vshRunConsole:318 : unable to get tty attributes: Inappropriate > > ioctl for device > > > > Does anybody know how I can workaround this? Thanks. > > Why not just directly use the Java bindings from libvirt-java to access > the console directly from your Java program, instead of trying to spawn > a third-party application to do it on your behalf? Alas, I'm not > familiar enough with the Java bindings to know how easy or hard this may > be. > > -- > Eric Blake eblake redhat com +1-919-301-3266 > Libvirt virtualization library http://libvirt.org > >