lxd icon indicating copy to clipboard operation
lxd copied to clipboard

Use shorter virtiofsd and swtpm socket paths

Open hamistao opened this issue 1 year ago • 7 comments

Fixes #12539. These changes generally include getting the file descriptor of the directory of a socket's file to use an alternative shorter path to the same socket. This same fix is applied during VM start (with disk virtiofsd sockets, qemu config virtiofsd sockets and the swtpm sockets), and when hotplugging a disk on a VM (with disk virtiofsd sockets)

hamistao avatar Apr 12 '24 03:04 hamistao

Has the idea of passing an FD been proved to work? Before we get too bogged down in code style etc?

tomponline avatar Apr 12 '24 08:04 tomponline

Has the idea of passing an FD been proved to work? Before we get too bogged down in code style etc?

No, it hasn't. For now I ask we focus our discussions in either understanding the problem with this approach or suggesting alternatives.

hamistao avatar Apr 12 '24 13:04 hamistao

Another thing you could try is experimenting with the server setting for the chardev as this is set to true by default and I am not sure if qemu isn't the client in this case?

See https://www.qemu.org/docs/master/interop/qemu-qmp-ref.html#qapidoc-1240.

roosterfish avatar Apr 12 '24 15:04 roosterfish

@hamistao once this is ready for review please can you mark it as ready for review and let me know. Thanks

tomponline avatar May 23 '24 10:05 tomponline

@tomponline I found that the same problem was ocurring in other situations(when attaching a device to a running instance and when adding a tpm device) so I changed back to draft to include those additional fixes, will be pushing the next version in a few minutes.

hamistao avatar May 23 '24 10:05 hamistao

@tomponline this is ready for review

hamistao avatar May 23 '24 17:05 hamistao

@roosterfish @tomponline this is ready when you are ready :)

hamistao avatar May 24 '24 15:05 hamistao

@hamistao ready for another review?

tomponline avatar Jun 04 '24 12:06 tomponline

@tomponline yes, it is

hamistao avatar Jun 04 '24 13:06 hamistao

How did you get on with this @hamistao ?

tomponline avatar Jun 07 '24 07:06 tomponline

@tomponline The approach of passing the file descriptor to QEMU works but is considerably more complicated than the current apporach so that part will remain the same. All the rest remains as discussed and I will be pushing the changes in a few minutes.

hamistao avatar Jun 10 '24 10:06 hamistao

The approach of passing the file descriptor to QEMU works but is considerably more complicated than the current apporach so that withh remain the same. All the rest remais as discussed and I will be pushing the changes in a few minutes.

Please can I have some more details on this, also specifically what are you referring to?

tomponline avatar Jun 10 '24 10:06 tomponline

@tomponline Sure! I tried passing a file descriptor to the socket file instead of the path when calling swtpm socket to make the code simpler and remove util.ShortenedSocketPath from TPM creation. But since the file descriptor that swtpm receives must be to a socket file, it is needed to open the socket before calling swtpm socket and thus util.ShortenedSocketPath is still needed. This is why I stuck to the current approach. If this wasn't clear enough please let me know.

hamistao avatar Jun 10 '24 10:06 hamistao

@hamistao i was just about to merge this and but you've pushed a change?

tomponline avatar Jun 10 '24 10:06 tomponline

@tomponline yes, the pushed changes just include the O_PATH approach and the switch from ShortenedSocketPath to ShornetedFilePath, as discussed.

hamistao avatar Jun 10 '24 10:06 hamistao

OK so ill re review again

tomponline avatar Jun 10 '24 10:06 tomponline

@tomponline Sorry if there was some confusion. If those changes aren't needed please let me know so I can remove them.

hamistao avatar Jun 10 '24 11:06 hamistao

@tomponline done!

hamistao avatar Jun 10 '24 11:06 hamistao

Thanks!

tomponline avatar Jun 10 '24 12:06 tomponline