xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* Help with reading from hvc console device on a PV guest
@ 2015-07-23 17:14 sainath grandhi
  2015-07-24  7:54 ` Wei Liu
  0 siblings, 1 reply; 4+ messages in thread
From: sainath grandhi @ 2015-07-23 17:14 UTC (permalink / raw)
  To: xen-devel

Hello,

    Please let me know if you have some information about issue below.

    I created a channel device for PV guest using

channel= ["connection=pty, name=xen.channel.0,
path=/var/lib/xen/ctl-socket","connection=socket, name=xen.channel.1,
path=/var/lib/xen/ctl-socket-data"]

   Xen toolstack uses qemu backend for additional consoles other than console 0.

/usr/local/lib/xen/bin/qemu-system-i386 -xen-domid 505 -chardev
socket,id=libxl-cmd,path=/var/run/xen/qmp-libxl-505,server,nowait
-no-shutdown -mon chardev=libxl-cmd,mode=control -chardev
socket,id=libxenstat-cmd,path=/var/run/xen/qmp-libxenstat-505,server,nowait
-mon chardev=libxenstat-cmd,mode=control -chardev
pty,id=libxl-channel0 -chardev
socket,id=libxl-channel1,path=/var/lib/xen/ctl-socket-data,server,nowait
-nodefaults -xen-attach -name ubuntupvhchannel -vnc none -display none
-nographic -machine xenpv -m 2048

   I see additional console devices in the guest under /dev/hvc1 and /dev/hvc2.

  I write to the other end of the channel i.e. from dom0,   but when I
read the console device /dev/hvc1 or /dev/hvc2, using cat or an
application using read(), I do not get the data out. But I could print
out the data using printk (the string I passed from dom0) inside the
hvc driver code where it reads from backend.

  Looks like I am missing something in the userspace creation of
device node or some flag for opening device file in the read system
call of my application. Any suggestions?

Application I wrote to read from console device:

  memset(buf, 0, sizeof(buf));

  fd=open("/dev/xenconsole/xen.channel.1", O_RDWR|O_NONBLOCK);

  if(fd < 0)

      printf("could not open dev hvc2\n");

  size = read(fd, (void *)buf, sizeof(buf));

  printf("size read %d\n",size);

Thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Help with reading from hvc console device on a PV guest
  2015-07-23 17:14 Help with reading from hvc console device on a PV guest sainath grandhi
@ 2015-07-24  7:54 ` Wei Liu
  2015-07-24 17:05   ` sainath grandhi
  0 siblings, 1 reply; 4+ messages in thread
From: Wei Liu @ 2015-07-24  7:54 UTC (permalink / raw)
  To: sainath grandhi; +Cc: wei.liu2, xen-devel

On Thu, Jul 23, 2015 at 10:14:57AM -0700, sainath grandhi wrote:
> Hello,
> 
>     Please let me know if you have some information about issue below.
> 
>     I created a channel device for PV guest using
> 
> channel= ["connection=pty, name=xen.channel.0,
> path=/var/lib/xen/ctl-socket","connection=socket, name=xen.channel.1,
> path=/var/lib/xen/ctl-socket-data"]
> 
>    Xen toolstack uses qemu backend for additional consoles other than console 0.
> 
> /usr/local/lib/xen/bin/qemu-system-i386 -xen-domid 505 -chardev
> socket,id=libxl-cmd,path=/var/run/xen/qmp-libxl-505,server,nowait
> -no-shutdown -mon chardev=libxl-cmd,mode=control -chardev
> socket,id=libxenstat-cmd,path=/var/run/xen/qmp-libxenstat-505,server,nowait
> -mon chardev=libxenstat-cmd,mode=control -chardev
> pty,id=libxl-channel0 -chardev
> socket,id=libxl-channel1,path=/var/lib/xen/ctl-socket-data,server,nowait
> -nodefaults -xen-attach -name ubuntupvhchannel -vnc none -display none
> -nographic -machine xenpv -m 2048
> 
>    I see additional console devices in the guest under /dev/hvc1 and /dev/hvc2.
> 
>   I write to the other end of the channel i.e. from dom0,   but when I
> read the console device /dev/hvc1 or /dev/hvc2, using cat or an
> application using read(), I do not get the data out. But I could print
> out the data using printk (the string I passed from dom0) inside the
> hvc driver code where it reads from backend.
> 
>   Looks like I am missing something in the userspace creation of
> device node or some flag for opening device file in the read system
> call of my application. Any suggestions?
> 
> Application I wrote to read from console device:
> 
>   memset(buf, 0, sizeof(buf));
> 
>   fd=open("/dev/xenconsole/xen.channel.1", O_RDWR|O_NONBLOCK);
> 

Have you checked if there is such device under the said directory?

You need to have udev rules in guest to create those devices for you.

See the discussion thread at

   <alpine.DEB.2.02.1506241241110.18681@kaball.uk.xensource.com>

>   if(fd < 0)
> 
>       printf("could not open dev hvc2\n");
> 

I'm confused because the code says hvc2 here but open() has another path
in it.

Wei.

>   size = read(fd, (void *)buf, sizeof(buf));
> 
>   printf("size read %d\n",size);
> 
> Thanks
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Help with reading from hvc console device on a PV guest
  2015-07-24  7:54 ` Wei Liu
@ 2015-07-24 17:05   ` sainath grandhi
  2015-07-28  9:06     ` Wei Liu
  0 siblings, 1 reply; 4+ messages in thread
From: sainath grandhi @ 2015-07-24 17:05 UTC (permalink / raw)
  To: Wei Liu; +Cc: xen-devel

Hi Wei,
   Thanks for your reply. Sorry I did not change the comment properly.
These are the two methods I tried separately.

First method:
     I see /dev/hvc1 and /dev/hvc2 being created when I give two
channels in the guest xl config file. So I wrote a program to open
hvc1 and read like below.
fd=open("/dev/hvc1", O_RDWR|O_NONBLOCK)


Second method:
     I also notice the devices are created under
/sys/bus/xen/devices/console-1 and console-2. And the corresponding
devices are in /dev/hvc1 and /dev/hvc2.
 So I manually created devices similar to following udev rules like
below for console 1.

HVC_MAJOR=229

NAME_PATH=device/console/1/name

NAME=$(xenstore-read $NAME_PATH)

mknod /dev/xenconsole/$NAME c $HVC_MAJOR 1

ln -s /dev/xenconsole/$NAME /dev/xenconsole/console-1

NAME in my case is xen.channel.1 Hence I tried to open and read using
fd=open("/dev/xenconsole/xen.channel.1", O_RDWR|O_NONBLOCK)


But both the attempts failed. And they do not read the contents I sent
from dom0. What I notice from the code review of hvc driver is that
any data that the hvc driver gets from the backend is used ONLY for
terminal consumption and not for file operations?

When I tried to create a console login on the hvc2, and do a socat on
the socket path from dom0, I am able to send commands like ls, pwd
etc. and receive responses fine.


Thanks
-Sainath

On Fri, Jul 24, 2015 at 12:54 AM, Wei Liu <wei.liu2@citrix.com> wrote:
> On Thu, Jul 23, 2015 at 10:14:57AM -0700, sainath grandhi wrote:
>> Hello,
>>
>>     Please let me know if you have some information about issue below.
>>
>>     I created a channel device for PV guest using
>>
>> channel= ["connection=pty, name=xen.channel.0,
>> path=/var/lib/xen/ctl-socket","connection=socket, name=xen.channel.1,
>> path=/var/lib/xen/ctl-socket-data"]
>>
>>    Xen toolstack uses qemu backend for additional consoles other than console 0.
>>
>> /usr/local/lib/xen/bin/qemu-system-i386 -xen-domid 505 -chardev
>> socket,id=libxl-cmd,path=/var/run/xen/qmp-libxl-505,server,nowait
>> -no-shutdown -mon chardev=libxl-cmd,mode=control -chardev
>> socket,id=libxenstat-cmd,path=/var/run/xen/qmp-libxenstat-505,server,nowait
>> -mon chardev=libxenstat-cmd,mode=control -chardev
>> pty,id=libxl-channel0 -chardev
>> socket,id=libxl-channel1,path=/var/lib/xen/ctl-socket-data,server,nowait
>> -nodefaults -xen-attach -name ubuntupvhchannel -vnc none -display none
>> -nographic -machine xenpv -m 2048
>>
>>    I see additional console devices in the guest under /dev/hvc1 and /dev/hvc2.
>>
>>   I write to the other end of the channel i.e. from dom0,   but when I
>> read the console device /dev/hvc1 or /dev/hvc2, using cat or an
>> application using read(), I do not get the data out. But I could print
>> out the data using printk (the string I passed from dom0) inside the
>> hvc driver code where it reads from backend.
>>
>>   Looks like I am missing something in the userspace creation of
>> device node or some flag for opening device file in the read system
>> call of my application. Any suggestions?
>>
>> Application I wrote to read from console device:
>>
>>   memset(buf, 0, sizeof(buf));
>>
>>   fd=open("/dev/xenconsole/xen.channel.1", O_RDWR|O_NONBLOCK);
>>
>
> Have you checked if there is such device under the said directory?
>
> You need to have udev rules in guest to create those devices for you.
>
> See the discussion thread at
>
>    <alpine.DEB.2.02.1506241241110.18681@kaball.uk.xensource.com>
>
>>   if(fd < 0)
>>
>>       printf("could not open dev hvc2\n");
>>
>
> I'm confused because the code says hvc2 here but open() has another path
> in it.
>
> Wei.
>
>>   size = read(fd, (void *)buf, sizeof(buf));
>>
>>   printf("size read %d\n",size);
>>
>> Thanks
>>
>> _______________________________________________
>> Xen-devel mailing list
>> Xen-devel@lists.xen.org
>> http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Help with reading from hvc console device on a PV guest
  2015-07-24 17:05   ` sainath grandhi
@ 2015-07-28  9:06     ` Wei Liu
  0 siblings, 0 replies; 4+ messages in thread
From: Wei Liu @ 2015-07-28  9:06 UTC (permalink / raw)
  To: sainath grandhi; +Cc: dave.scott, Wei Liu, xen-devel

Please don't top-post.

On Fri, Jul 24, 2015 at 10:05:20AM -0700, sainath grandhi wrote:
> Hi Wei,
>    Thanks for your reply. Sorry I did not change the comment properly.
> These are the two methods I tried separately.
> 
> First method:
>      I see /dev/hvc1 and /dev/hvc2 being created when I give two
> channels in the guest xl config file. So I wrote a program to open
> hvc1 and read like below.
> fd=open("/dev/hvc1", O_RDWR|O_NONBLOCK)
> 
> 
> Second method:
>      I also notice the devices are created under
> /sys/bus/xen/devices/console-1 and console-2. And the corresponding
> devices are in /dev/hvc1 and /dev/hvc2.
>  So I manually created devices similar to following udev rules like
> below for console 1.
> 
> HVC_MAJOR=229
> 
> NAME_PATH=device/console/1/name
> 
> NAME=$(xenstore-read $NAME_PATH)
> 
> mknod /dev/xenconsole/$NAME c $HVC_MAJOR 1
> 
> ln -s /dev/xenconsole/$NAME /dev/xenconsole/console-1
> 
> NAME in my case is xen.channel.1 Hence I tried to open and read using
> fd=open("/dev/xenconsole/xen.channel.1", O_RDWR|O_NONBLOCK)
> 

Looks like that you have all udev rules in place. Good.

> 
> But both the attempts failed. And they do not read the contents I sent
> from dom0. What I notice from the code review of hvc driver is that
> any data that the hvc driver gets from the backend is used ONLY for
> terminal consumption and not for file operations?
> 

Not sure, I've never used that myself.

I've CC'ed Dave Scott who might have better idea about how channel is
supposed to be used.

> When I tried to create a console login on the hvc2, and do a socat on
> the socket path from dom0, I am able to send commands like ls, pwd
> etc. and receive responses fine.
> 

This means the channel is created OK.

Wei.

> 
> Thanks
> -Sainath
> 
> On Fri, Jul 24, 2015 at 12:54 AM, Wei Liu <wei.liu2@citrix.com> wrote:
> > On Thu, Jul 23, 2015 at 10:14:57AM -0700, sainath grandhi wrote:
> >> Hello,
> >>
> >>     Please let me know if you have some information about issue below.
> >>
> >>     I created a channel device for PV guest using
> >>
> >> channel= ["connection=pty, name=xen.channel.0,
> >> path=/var/lib/xen/ctl-socket","connection=socket, name=xen.channel.1,
> >> path=/var/lib/xen/ctl-socket-data"]
> >>
> >>    Xen toolstack uses qemu backend for additional consoles other than console 0.
> >>
> >> /usr/local/lib/xen/bin/qemu-system-i386 -xen-domid 505 -chardev
> >> socket,id=libxl-cmd,path=/var/run/xen/qmp-libxl-505,server,nowait
> >> -no-shutdown -mon chardev=libxl-cmd,mode=control -chardev
> >> socket,id=libxenstat-cmd,path=/var/run/xen/qmp-libxenstat-505,server,nowait
> >> -mon chardev=libxenstat-cmd,mode=control -chardev
> >> pty,id=libxl-channel0 -chardev
> >> socket,id=libxl-channel1,path=/var/lib/xen/ctl-socket-data,server,nowait
> >> -nodefaults -xen-attach -name ubuntupvhchannel -vnc none -display none
> >> -nographic -machine xenpv -m 2048
> >>
> >>    I see additional console devices in the guest under /dev/hvc1 and /dev/hvc2.
> >>
> >>   I write to the other end of the channel i.e. from dom0,   but when I
> >> read the console device /dev/hvc1 or /dev/hvc2, using cat or an
> >> application using read(), I do not get the data out. But I could print
> >> out the data using printk (the string I passed from dom0) inside the
> >> hvc driver code where it reads from backend.
> >>
> >>   Looks like I am missing something in the userspace creation of
> >> device node or some flag for opening device file in the read system
> >> call of my application. Any suggestions?
> >>
> >> Application I wrote to read from console device:
> >>
> >>   memset(buf, 0, sizeof(buf));
> >>
> >>   fd=open("/dev/xenconsole/xen.channel.1", O_RDWR|O_NONBLOCK);
> >>
> >
> > Have you checked if there is such device under the said directory?
> >
> > You need to have udev rules in guest to create those devices for you.
> >
> > See the discussion thread at
> >
> >    <alpine.DEB.2.02.1506241241110.18681@kaball.uk.xensource.com>
> >
> >>   if(fd < 0)
> >>
> >>       printf("could not open dev hvc2\n");
> >>
> >
> > I'm confused because the code says hvc2 here but open() has another path
> > in it.
> >
> > Wei.
> >
> >>   size = read(fd, (void *)buf, sizeof(buf));
> >>
> >>   printf("size read %d\n",size);
> >>
> >> Thanks
> >>
> >> _______________________________________________
> >> Xen-devel mailing list
> >> Xen-devel@lists.xen.org
> >> http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-07-28  9:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-23 17:14 Help with reading from hvc console device on a PV guest sainath grandhi
2015-07-24  7:54 ` Wei Liu
2015-07-24 17:05   ` sainath grandhi
2015-07-28  9:06     ` Wei Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).