Serial Port from VM



  • Hello,

    for developing/debugging the XCP-ng PV-Driver it would be handy to have some sort of serial console in a windows VM.

    I tried the Howto there: https://xenserver.org/partners/developing-products-for-xenserver/18-sdk-development/135-xs-dev-windbg.html

    Example:
    xe vm-param-add uuid=<uuid> param-name=platform hvm_serial=tcp::7001,server,nodelay
    If I start the VM, it should listen on port 7001 in Dom0.

    Here is the process:

    [root@xen ~]# ps aux | cat | grep 7001
    root     11265  0.5  0.1 119996 11232 ?        Ssl  00:08   0:00 qemu-dm-1 -machine pc-0.10,accel=xen,max-ram-below-4g=4026531840,allow-unassigned=true,trad_compat=true -vnc unix:/var/run/xen/vnc-1,lock-key-sync=off -monitor null -xen-domid 1 -m size=6144 -boot order=dc -usb -device usb-tablet,port=2 -smp 2,maxcpus=2 -serial tcp::7001,server,nodelay -display none -nodefaults -trace enable=xen_platform_log -sandbox on,obsolete=deny,elevateprivileges=allow,spawn=deny,resourcecontrol=deny -S -global PIIX4_PM.revision_id=0x1 -global ide-hd.ver=0.10.2 -global piix3-ide-xen.subvendor_id=0x5853 -global piix3-ide-xen.subsystem_id=0x0001 -global piix3-usb-uhci.subvendor_id=0x5853 -global piix3-usb-uhci.subsystem_id=0x0001 -global rtl8139.subvendor_id=0x5853 -global rtl8139.subsystem_id=0x0001 -parallel null -qmp unix:/var/run/xen/qmp-libxl-1,server,nowait -qmp unix:/var/run/xen/qmp-event-1,server,nowait -device xen-platform,addr=3,device-id=0x0002,revision=0x2,class-id=0x0100,subvendor_id=0x5853,subsystem_id=0x0002 -device xen-pvdevice,device-id=0xc000,addr=5 -device rtl8139,netdev=tapnet0,mac=da:4b:ad:d5:d2:5e,addr=4 -netdev tap,id=tapnet0,fd=7 -drive file=/dev/sm/backend/49a0eaf4-dc9d-9ba7-f8e6-a7adba77826e/dfd4c71f-8509-47a4-9f3d-dd0ae61d4e10,if=ide,index=0,media=disk,format=raw,force-lba=on -drive file=,if=ide,index=3,media=cdrom,force-lba=off -device VGA,vgamem_mb=8,rombar=1,romfile=,subvendor_id=0x5853,subsystem_id=0x0001,addr=2,qemu-extended-regs=false -vnc-clipboard-socket-fd 4 -xen-domid-restrict -chroot /var/xen/qemu/root-1 -runas 65536.994
    

    Note the -serial tcp::7001,server,nodelay option!

    But according to netstatt there is no port 7001.

    [root@xen ~]# netstat -an | grep 7001
    [root@xen ~]#
    

    Has anyone a clue why?

    I also noted the -sandbox on,obsolete=deny,elevateprivileges=allow,spawn=deny,resourcecontrol=deny options.
    I have a feeling, that qemu runs in a sort of sandbox or enclosed environment and can not open the port.

    Thanks for any help or pointers!



  • Maybe @nhanlon got some experience on that 😄



  • ¯\(ツ)

    Just tried it out here and it seems to do it properly...

    Maybe check out /var/log/daemon.log? I see this in mine

    Nov 29 08:37:32 p4xcp1701 qemu-dm-7[406]: qemu-dm-7: -serial tcp::7001,server,nodelay: info: QEMU waiting for connection on: disconnected:tcp:0.0.0.0:7001,server

    [root@p4xcp1701 ~]# ps aux | grep [7]001
    root       406  0.0  0.3 137856 12336 ?        Sl   08:37   0:00 qemu-dm-7 -machine pc-0.10,accel=xen,max-ram-below-4g=4026531840,allow-unassigned=true,trad_compat=true -vnc unix:/var/run/xen/vnc-7,lock-key-sync=off -monitor null -xen-domid 7 -m size=18432 -boot order=c -usb -device usb-tablet,port=2 -smp 8,maxcpus=8 -serial tcp::7001,server,nodelay -display none -nodefaults -trace enable=xen_platform_log -sandbox on,obsolete=deny,elevateprivileges=allow,spawn=deny,resourcecontrol=deny -S -global PIIX4_PM.revision_id=0x1 -global ide-hd.ver=0.10.2 -global piix3-ide-xen.subvendor_id=0x5853 -global piix3-ide-xen.subsystem_id=0x0001 -global piix3-usb-uhci.subvendor_id=0x5853 -global piix3-usb-uhci.subsystem_id=0x0001 -global rtl8139.subvendor_id=0x5853 -global rtl8139.subsystem_id=0x0001 -parallel null -qmp unix:/var/run/xen/qmp-libxl-7,server,nowait -qmp unix:/var/run/xen/qmp-event-7,server,nowait -device xen-platform,addr=3,device-id=0x0001,revision=0x2,class-id=0x0100,subvendor_id=0x5853,subsystem_id=0x0001 -drive file=/dev/sm/backend/a6591e01-0f2b-7174-8d4c-34d0954b77d6/63c6875c-c6d8-4e46-9ddc-c35ad58b2dc4,if=ide,index=2,media=disk,force-lba=on,format=raw -drive file=/dev/sm/backend/a6591e01-0f2b-7174-8d4c-34d0954b77d6/4d10ccbf-3fa8-428f-8deb-c40cb8f4862a,if=ide,index=1,media=disk,force-lba=on,format=raw -drive file=/dev/sm/backend/a6591e01-0f2b-7174-8d4c-34d0954b77d6/0ba1d703-3c30-4b76-979b-927f92a1f86b,if=ide,index=0,media=disk,force-lba=on,format=raw -device rtl8139,netdev=tapnet0,mac=5e:9c:7e:4c:f6:62,addr=4 -netdev tap,id=tapnet0,fd=7 -device cirrus-vga,vgamem_mb=4,rombar=1,romfile=,subvendor_id=0x5853,subsystem_id=0x0001,addr=2 -vnc-clipboard-socket-fd 4 -xen-domid-restrict -chroot /var/xen/qemu/root-7 -runas 65542.1000
    [root@p4xcp1701 ~]# netstat -tulpn | grep 7001
    tcp        0      0 0.0.0.0:7001            0.0.0.0:*               LISTEN      406/qemu-dm-7     
    


  • @nhanlon hmm... weird. I just updated my testbox at home to XCP-ng 7.6 and now it works 😰



  • Wooohooooo !! We have a connection 🔌

    0_1543525292373_4649e57e-4925-46e0-8aa6-84789150df8c-grafik.png