Support serial devices to resource API#2675
Conversation
|
@baconYao can you make sure that your commits include the required Signed-off-by line? (see CONTRIBUTING.md) |
|
@stgraber Roger that! |
|
@baconYao Unfortunately the You can do a test build of it with: That's why all the other resources only deal with a mix of /sys and /dev entries, lining up the two to put together the structs rather than being able to easily get data out of udev. There is an exception with the storage stuff where we really needed the udev data and so directly parse the udev database from /run/udev/data, but we generally try to avoid it when possible or at least make sure that you still get some useful base data without it as not all systems running Incus use udev. |
e1cbe68 to
f17def0
Compare
|
Thank you @stgraber! I will rewrite it without leveraging udev. |
|
Hi @stgraber The serial devices I emulate using QEMU are being recognized by Incus as USB devices. I’d like to ask if you have any thoughts on this issue? Below is the output produced by Below is the command I use to start QEMU. qemu-system-x86_64 \
-m 8192 -smp 6 -cpu qemu64 \
-hda ubuntu.qcow2 \
-device nec-usb-xhci,id=xhci \
-chardev ringbuf,id=ch0,size=65536 \
-device usb-serial,id=fake1,chardev=ch0 \
-chardev ringbuf,id=ch1,size=65536 \
-device usb-serial,id=fake2,chardev=ch1 \
-netdev user,id=net0,hostfwd=tcp::2222-:22 \
-device e1000,netdev=net0 \
-display default \
-accel tcgBelow is the udev info I see inside the VM (e.g., for /dev/ttyUSB0). P: /devices/pci0000:00/0000:00:03.0/usb1/1-1/1-1:1.0/ttyUSB0/tty/ttyUSB0
M: ttyUSB0
R: 0
U: tty
D: c 188:0
N: ttyUSB0
L: 0
S: serial/by-path/pci-0000:00:03.0-usb-0:1:1.0-port0
S: serial/by-path/pci-0000:00:03.0-usbv2-0:1:1.0-port0
S: serial/by-id/usb-QEMU_QEMU_USB_SERIAL_1-0000:00:03.0-1-if00-port0
E: DEVPATH=/devices/pci0000:00/0000:00:03.0/usb1/1-1/1-1:1.0/ttyUSB0/tty/ttyUSB0
E: DEVNAME=/dev/ttyUSB0
E: MAJOR=188
E: MINOR=0
E: SUBSYSTEM=tty
E: USEC_INITIALIZED=18082429
E: ID_BUS=usb
E: ID_MODEL=QEMU_USB_SERIAL
E: ID_MODEL_ENC=QEMU\x20USB\x20SERIAL
E: ID_MODEL_ID=6001
E: ID_SERIAL=QEMU_QEMU_USB_SERIAL_1-0000:00:03.0-1
E: ID_SERIAL_SHORT=1-0000:00:03.0-1
E: ID_VENDOR=QEMU
E: ID_VENDOR_ENC=QEMU
E: ID_VENDOR_ID=0403
E: ID_REVISION=0400
E: ID_TYPE=generic
E: ID_USB_MODEL=QEMU_USB_SERIAL
E: ID_USB_MODEL_ENC=QEMU\x20USB\x20SERIAL
E: ID_USB_MODEL_ID=6001
E: ID_USB_SERIAL=QEMU_QEMU_USB_SERIAL_1-0000:00:03.0-1
E: ID_USB_SERIAL_SHORT=1-0000:00:03.0-1
E: ID_USB_VENDOR=QEMU
E: ID_USB_VENDOR_ENC=QEMU
E: ID_USB_VENDOR_ID=0403
E: ID_USB_REVISION=0400
E: ID_USB_TYPE=generic
E: ID_USB_INTERFACES=:ffffff:
E: ID_USB_INTERFACE_NUM=00
E: ID_USB_DRIVER=ftdi_sio
E: ID_VENDOR_FROM_DATABASE=Future Technology Devices International, Ltd
E: ID_MODEL_FROM_DATABASE=FT232 Serial (UART) IC
E: ID_PATH_WITH_USB_REVISION=pci-0000:00:03.0-usbv2-0:1:1.0
E: ID_PATH=pci-0000:00:03.0-usb-0:1:1.0
E: ID_PATH_TAG=pci-0000_00_03_0-usb-0_1_1_0
E: ID_MM_CANDIDATE=1
E: DEVLINKS=/dev/serial/by-path/pci-0000:00:03.0-usb-0:1:1.0-port0 /dev/serial/by-path/pci-0000:00:03.0-usbv2-0:1:1.0-port0 /dev/serial/by-id/usb-QEMU_QEMU_USB_SERIAL_1-0000:00:03.0-1-if00-port0
E: TAGS=:systemd:
E: CURRENT_TAGS=:systemd:Below is the output produced by my implementation of the Serial API (the {
"devices": [
{
"id": "ttyUSB0",
"device": "188:0",
"device_id": "/dev/serial/by-id/usb-QEMU_QEMU_USB_SERIAL_1-0000:00:03.0-1-if00-port0",
"device_path": "/dev/serial/by-path/pci-0000:00:03.0-usbv2-0:1:1.0-port0",
"driver": "ftdi_sio",
"vendor": "Future Technology Devices International, Ltd",
"vendor_id": "0403",
"product": "FT232 Serial (UART) IC",
"product_id": "6001"
},
{
"id": "ttyUSB1",
"device": "188:1",
"device_id": "/dev/serial/by-id/usb-QEMU_QEMU_USB_SERIAL_1-0000:00:03.0-2-if00-port0",
"device_path": "/dev/serial/by-path/pci-0000:00:03.0-usbv2-0:2:1.0-port0",
"driver": "ftdi_sio",
"vendor": "Future Technology Devices International, Ltd",
"vendor_id": "0403",
"product": "FT232 Serial (UART) IC",
"product_id": "6001"
}
],
"total": 2
} |
|
Looking into this one now |
ec1ca8a to
6a620e0
Compare
Signed-off-by: Stéphane Graber <[email protected]>
Add ResourcesSerial and ResourcesSerialDevice types to expose serial device information in the resources API. Signed-off-by: baconyao <[email protected]>
Initialized GetSerial() function and integrate it into GetResources() to expose serial devices information through the resources API. Signed-off-by: baconyao <[email protected]>
Signed-off-by: baconyao <[email protected]>
Signed-off-by: baconyao <[email protected]>
Signed-off-by: Stéphane Graber <[email protected]>
Signed-off-by: Stéphane Graber <[email protected]>
Signed-off-by: Stéphane Graber <[email protected]>
6a620e0 to
30329e2
Compare
|
Thank you @stgraber |
Fixes: #2669