0

I'd like to print out of a VM (KVM/QEMU via virt-manager). For the VM to host connection there is an emulated parallel port in the VM that should be connected to a Unix Socket. I tried to create a listen socket with socat, which should then be redirected to a cups printer by typing socat unix-listen:/tmp/kvmpr localhost:631/printers/pdf which didn't work.

Now that I didn't have time to tinker around more because my customer wanted his machine back, I tried emulating the same thing by setting up a unix listen port that prints to a cups PDF printer, and letting another cups printer (dummy) print to port 9100 who redirects to the created socket. When i do that i get following errors on the one side:

socat -d -d tcp4-listen:9100 /tmp/kvmpr
2021/01/20 17:01:43 socat[5523] N listening on AF=2 0.0.0.0:9100
2021/01/20 17:02:11 socat[5523] N accepting connection from AF=2 127.0.0.1:36160 on AF=2 127.0.0.1:9100
2021/01/20 17:02:11 socat[5523] N opening connection to AF=1 "/tmp/kvmpr"
2021/01/20 17:02:11 socat[5523] N successfully connected from local address AF=1 "\x7E\x@D\xB9U"
2021/01/20 17:02:11 socat[5523] N successfully connected via <anon>
2021/01/20 17:02:11 socat[5523] N starting data transfer loop with FDs [6,6] and [5,5]
2021/01/20 17:02:11 socat[5523] N socket 2 (fd 5) is at EOF
2021/01/20 17:02:11 socat[5523] N socket 2 (fd 5) is at EOF
2021/01/20 17:02:11 socat[5523] E write(5, 0x55c9ae7f46b0, 3763): Broken pipe
2021/01/20 17:02:11 socat[5523] N exit(1)

and this one on the other:

socat unix-listen:/tmp/kvmpr TCP:127.0.0.1:631/printers/PDF
2021/01/20 17:02:11 socat[5513] E write(5, 0x55d5325f2930, 8192): Broken pipe

I don't know what to do, I can't find anything related to how I send data to cups via something like socat.

A "quick and dirty" solution from my side was letting the parallel port print into a file and then use a script utilizing ghostpdl to output a pdf, but that is just too complicated for the user to execute.

I'd be very happy if someone could help me with my problem, thanks in advance for answering!

1 Answer 1

0

I have encountered almost the exact issue when dealing with CUPS.

2021/02/01 19:19:22 socat[645] E write(6, 0x557e0b9735a0, 8192): Broken pipe

My solution is to double the block size of socat each time and test. My situation ends up with socat -b 65536 ....

socat -b 16384 ...
...
socat -b 65536 ...
1
  • Oh i forgot to reply I'm sorry. although using cups would be the most logic thing to do i ditched it after the headaches it gave me and instead created a systemd service via a script which calls GhostPDL to convert from PCL to PDF. I am kind of a noob to Linux with printing so I used a method that i could wrap my head around more easily. Thanks for the answer regardless!
    – paulhersch
    Commented Feb 26, 2021 at 12:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .