-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unbind the dependency on each other for tcmu-runner and libtcmu. #432
base: main
Are you sure you want to change the base?
Conversation
Preparing to unbind the dependency on each other for tcmu-runner and libtcmu. Signed-off-by: Xiubo Li <[email protected]>
Rename it to tcmulib_backstore_handler. Signed-off-by: Xiubo Li <[email protected]>
3d81729
to
a93dd14
Compare
qemu-tcmu works properly with this patchset but need to define two different handler struct instances: tcmulib_backstore_handler and tcmulib_handler. Could we tune further to export just one handler or merge them? |
f44747e
to
5c94e68
Compare
Here tcmulib_backstore_handler will be exported out to the handlers and the tcmulib_handler will be exported to the daemon like tcmu-runner and qemu-tcmu. And the handlers and the daemon are different parts, so merge them is not a very good idea. Currently the qemu-tcmu have integrated the qemu handler and daemon process together, maybe we should separate the code as different components. |
Rename: alua.c --> libtcmu_alua.c alua.h --> libtcmu_alua.h tcmur_aio.c --> libtcmu_aio.c tcmur_aio.h --> libtcmu_aio.h tcmur_device.c --> libtcmu_device.c tcmur_device.h --> libtcmu_device.h target.c --> libtcmu_tpg.c target.h --> libtcmu_tpg.h Delete: tcmu-runner.h main-syms.txt Add SCSI helpers: libtcmu_scsi.c libtcmu_scsi.h Signed-off-by: Xiubo Li <[email protected]>
d1f3b46
to
64574a1
Compare
For the tcmulib_handler will remove the added and removed members, and move these two functions to libtcmu_device.c. And also make the ringbuffer process thread as opaqe for the users like tcmu-runner and qemu-tcmu, what they needs to do is to provide the handle_cmds() callback. Signed-off-by: Xiubo Li <[email protected]>
This reverts commit 8727a38. Signed-off-by: Xiubo Li <[email protected]> Signed-off-by: Yaowei Bai <[email protected]>
Revert "libtcmu: do not install headers and drop libtcmu stable API" This reverts commit a00cb71. Signed-off-by: Yaowei Bai <[email protected]> Signed-off-by: Xiubo Li <[email protected]>
Please help review, this is the first version of adding the libtcmu library back. |
Could you post a link to the current qemu-tcmu code? |
Yeah, please see: https://github.com/lxbsz/qemu/commits/qemu-tcmu, this code comes from @baihuahua. Thanks, |
Hi Mike, Does this change still make sense? What should we do to make libtcmu usable by both tcmu-runner and qemu-tcmu? @mikechristie |
Sorry. I am behind. I am trying to get to this this week. |
Here is some general questions/comments:
Are you trying to use the libtcmu scsi helper and so that is why the patches merged the tcmu-runner and libtcmu device/handler structs? For some reason I thought you guys were going to do the opposite.
|
Actually the plan of qemu-tcmu is to use SCSI code in QEMU in the end, but this QEMU SCSI code needs to tune for qemu-tcmu to use so for now qemu-tcum still uses SCSI helpers from litcmu/tcmu-runner. But if it's too hard to seperate tcmu-runner and libtcmu because of these SCSI helpers, qemu-tcmu can change to use SCSI code in QEMU or reimplement several necessary SCSI commands right now, so libtcmu shall just include DBUS registeration and TCMU protocol handling code, without SCSI helper code. By doing this libtcmu will be sharable between tcmu-runner and qemu-tcmu and tcmu-runner doesn't need to change too much. I think this should be more reasonable and more easier to achieve. What do you think Mike? |
@mikechristie
Currently, qemu-tcmu is only using some of the sync scsi helpers which are also called handle_sync_cmd(). And qemu-tcmu must use qemu's APIs to implement other scsi helpers to support some feature like the clone. And finally it will add it's own basic helpers of all the scsi commands and then switch to them. This should be the goal of qemu-tcmu. These days I was thinking to separate the sysfs/uio and the dbus helpers from the tcmu-runner into libtcmu.so. And finally the libtcmu.so will mainly include the following 3 parts:
For now the qemu-tcmu is also using daemon type too.
|
To be precise, much of these SCSI command helpers have implemented in QEMU as there's a requirement of full-functional SCSI disk emulation for QEMU.
Emmm..., yes, qemu-tcmu is still in RFC and we can change it as we need. But i'm afraid such changing qemu-tcmu to apply the model of tcmu-runner is not the right direction. Because the motivation of tcmu-runner and qemu-tcmu are different. One important feature/goal of tcmu-runner is to make it easy to develop various handlers like rbd,gluster so tcmu-runner has tcmulib_handler for a daemon and tcmulib_backstore_handler for the handlers. While qemu-tcmu doesn't have such a requirement as QEMU has already supported them so it's a bit weird for qemu-tcmu to have such two handlers. |
Hey @lxbsz @baihuahua I am not sure if you guys were waiting for me to comment on this or not. I was actually waiting for you guys to finish discussing it :) If you guys are waiting on me, my opinion would be:
It seems we all agree we need the lib to handle the very basics: uio, configfs, and netlink. So we can just take the libtcmu code that did this stuff and make it a lib.
So can we skip adding the SCSI api.c parts into the lib initially? You guys can then debate this later.
We can at least then start with a stable lib that supports enough to create, delete and config devices, and handle IO. |
@mikechristie
Yeah, this looks fine to me.
Yeah, currently the qemu-tcmu rfc code is only using very small part of the SCSI helpers. To simplify it, I agree to skip it firstly, and then debate this later. And we'd better reuse the SCSI part as possible as we can or we must recode tons of relevant same features that we have already running and test for a long time.
Will split the PRs into small ones. Thanks very much Mike. |
Hey, Attached could be the basis for the initial base lib functions we will support: 0001-libtcmu3-header-example.txt Note this patch requires this patch which drops some dbus stuff. So basically we move the functions listed in the headers in 0001-libtcmu3-header-example.txt and put them in new files: libtcmu3 files: Notes.
So we should move the tcmu_cmd_status stuff to tcmu-runner specific code.
|
I guess a funny/dumb thing on my part is my proposal above is just basically bringing back the old libtcmu minus the SCSI helpers. libtcmu3.c would be almost exactly the same as libtcmu.c and libtcmu_common3.h and libtcmu3.h in my patch are really similar to libtcmu_common.h/libtcmu.h So we probably do not need to rename them. We could just move the scsi and iovec stuff from libtcmu_common.h and libtcmu.h and related .c files to new files that only tcmu-runner uses and then just bump the lib version: set_target_properties(tcmu I can send a patch for this. |
That would be great. With commit 0618ad every daemon like tcmu-synthesizer and qemu-tcmu need to acquire the DBUS name "org.kernel.TCMUService1" on their own, right? |
Yeah, that looks good to me and please go ahead Mike. Thanks. |
I made a mistake linking that patch: to the libtcmu issue here and you can ignore it. They are not really related right now for the initial release. The dbus code being removed in that patch is just not used by anyone anymore. It was used by dbus users like targetcli to have the daemon load a handler dynamically. I think the problem was that it was added but we never fully maintained it due the only user not using it anymore. I think going forward it is a useful to have something like it in the lib, and I think we should add dbus helpers to the lib eventually. For the initial release though I think we can hold off unless you have a immediate need. |
Yeah, Agree with that. For the initial version let's make it as simple as possible,then push this forward. @mikechristie Will you send the initial version of the libtcmu3 these days ? |
Sorry i'm behind. If we decide to not include the dbus code into the initial release of new libtcmu, 0618ade should not be merged because qemu-tcmu need the code in that patch to register onto DBUS to cooperate with targetcli as a backstore. Tcmu-synthesizer should also be in this same situation. If we include dbus code into the initial release, that's okey to remove code in that patch as daemons could grab the dbus on their own. |
targetcli only uses dbus for check_config and to get a list of handlers.
That patch is not related to the discussion. It was an accident on my fault for referencing it. The patch just removes the ability to for something like targetcli (targetcli does not actually use it) to tell tcmu-runner to load a handler after the initial startup (when tcmu-runner starts it loads all the handlers in the lib/tcmu-runner dir). The problem is that it looks like it was implemented early on then never updated except for some security issues. It does not actually work like how you would want where you can load/unload handlers for something like a dynamic handler update or operation like that which we do need at some point in the future. |
OK, let's drop that patch out of the picture. What's your plan of this new initial libtcmu, Mike? That would be very great if we can see it soon. |
We are just finishing up QEing a release at work, so I hope to have it done by the end of the month. Let me know if you want to work on it. I thought you mentioned it above, but was not sure. If you want to make it it is ok with me. |
OK, i can make it. Will send PR ASAP. |
Preparing to unbind the dependency on each other for tcmu-runner and libtcmu.
1, Move handler register/unregister helpers from tcmu-runner to libtcmu.so to unbind the dependencies.
2, Move tcmur_handler struct from tcmu-runner to libtcmu.so
3, Rename tcmur_handler to tcmulib_backstore_handler.
4, Make libtcmu_priv.h only visible for libtcmu.so
5, Rename some files:
alua.c --> libtcmu_alua.c
alua.h --> libtcmu_alua.h
tcmur_aio.c --> libtcmu_aio.c
tcmur_aio.h --> libtcmu_aio.h
tcmur_device.c --> libtcmu_device.c
tcmur_device.h --> libtcmu_device.h
target.c --> libtcmu_tpg.c
target.h --> libtcmu_tpg.h
6, Delete some files:
tcmu-runner.h
main-syms.txt
7, Add SCSI helpers, and rename the SCSI helpers:
libtcmu_scsi.c
libtcmu_scsi.h
8, Revert "build: drop versionless libtcmu.so symlink"
9, libtcmu: install the headers and revert the old discarding commit: the headers include:
libtcmu.h libtcmu_common.h libtcmu_scsi.h and ccan/ccan/*