Skip to content
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

instance/driver_qemu: properly calculate VHOST_VSOCK_SET_GUEST_CID #13519

Merged
merged 1 commit into from
May 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions lxd/instance/drivers/driver_qemu.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
package drivers

/*

#include <linux/types.h>
#include <sys/ioctl.h>
#include <stdint.h>

#define VHOST_VIRTIO 0xAF
#define VHOST_VSOCK_SET_GUEST_CID _IOW(VHOST_VIRTIO, 0x60, __u64)

*/
import "C"

import (
"bufio"
"bytes"
Expand Down Expand Up @@ -8093,8 +8105,7 @@ func (d *qemu) acquireVsockID(vsockID uint32) (*os.File, error) {
// The vsock Context ID cannot be supplied as type uint32.
vsockIDInt := uint64(vsockID)

// 0x4008AF60 = VHOST_VSOCK_SET_GUEST_CID = _IOW(VHOST_VIRTIO, 0x60, __u64)
_, _, errno := unix.Syscall(unix.SYS_IOCTL, vsockF.Fd(), 0x4008AF60, uintptr(unsafe.Pointer(&vsockIDInt)))
_, _, errno := unix.Syscall(unix.SYS_IOCTL, vsockF.Fd(), C.VHOST_VSOCK_SET_GUEST_CID, uintptr(unsafe.Pointer(&vsockIDInt)))
Copy link
Contributor

@roosterfish roosterfish May 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mihalicyn Nice to know! If I remember correctly I have copied the comment from https://github.com/canonical/lxd/blob/main/lxd/storage/drivers/driver_btrfs_utils.go#L64 back then.

So I guess we should update this line in the Btrfs driver too to get the right platform agnostic number?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, it is a good point, thanks, Julian! I think I need to fix this too.

cc @simondeziel Simon, do we have any options to test LXD on ppc64le?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mihalicyn, ssh ubuntu@10.245.71.25

ubuntu@P10d-LPAR03:~$ ssh-import-id lp:mihalicyn
2024-05-31 15:55:25,758 INFO Authorized key ['4096', 'SHA256:bwq1dun/CdBl0nXIvP5g+XoRtgj1DekD/0jBH3x6EsM', 'amikhalitsyn', '(RSA)']
2024-05-31 15:55:25,759 INFO [1] SSH keys [Authorized]

Courtesy of Sergio from the server team. We'll need to return it once done with it.

if errno != 0 {
if !errors.Is(errno, unix.EADDRINUSE) {
return nil, fmt.Errorf("Failed ioctl syscall to vhost socket: %q", errno.Error())
Expand Down
Loading