I have some thoughts about splitting up targets/ublksrv_tct.cpp
but it looks to be quite hairy to do this in a nice way so want to see what others think.
The first thing is that ublksrv_tgt contains a new-we API for managing the jsob blobs
compared to the public lib/ublksrv_json.cpp code.
The new api is much nicer since it it is threads safe and also hides the jbuf implementation and makes it automatically adjust the buffer size.
The only in-tree consumers of the old api are the demo_*.c examples.
I propose to convert the demo* examples over to use the new API,
the document the old API in the public headers as deprecated
and move the json functions from targets/ublksrv_tgt.cpp to lib/ublksrv_json.cpp and make them the new non-deprecated API.
After migrating the json API out of ublksrv_tgt.cpp, the (almost) only thing remaning in
ublksrv_tgt.cpp will now be ublksrv_tgt_cmd_main() and all the code that it depends on.
While a lot of code it is pretty much just boilerplate for creating/recovering a target with all target-specific code is passed in via the ublksrv_tgt_type pointer.
So let's move it all into the public library and make ublksrv_tgt_cmd_main() a public symbol that all ublk.<type> targets can use.