Add uvirtio for testing
Subsystems (2)
cover Add uvirtio for testing
This is a way to create virtio based devices from user space. This is the background for this patch:
We have some images works fine under qemu, we'd like to also run the same image on Google Cloud. Currently Google Cloud doesn't support virtio-vga. I had a patch to create a virtio-vga from kernel directly:
https://www.spinics.net/lists/dri-devel/msg248573.html
Then I got feedback from Gerd that maybe it's better to change that to something
like uvirtio. Since I really don't have other use cases for now, I just implemented the minimal stuff which work for my use case.
Lepton Wu (1):
virtio: Add uvirtio driver
drivers/virtio/Kconfig | 8 + drivers/virtio/Makefile | 1 + drivers/virtio/uvirtio.c | 405 ++++++++++++++++++++++++++++++++++ include/linux/uvirtio.h | 8 + include/uapi/linux/uvirtio.h | 69 ++++++ samples/uvirtio/Makefile | 9 + samples/uvirtio/uvirtio-vga.c | 63 ++++++ 7 files changed, 563 insertions(+) create mode 100644 drivers/virtio/uvirtio.c create mode 100644 include/linux/uvirtio.h create mode 100644 include/uapi/linux/uvirtio.h create mode 100644 samples/uvirtio/Makefile create mode 100644 samples/uvirtio/uvirtio-vga.c
Signature · 1 line
2.26.2.303.gf8c07b1a785-goog
PATCH 1/1 virtio: Add uvirtio driver
This is for testing purpose to create virtio devices from user space. uvirtio-vga.c shows how to create a virtio-vga device. Currently we don't have a use case which requires user/kernel communication so read/write api hasn't been implemented.
--- drivers/virtio/Kconfig | 8 + drivers/virtio/Makefile | 1 + drivers/virtio/uvirtio.c | 405 ++++++++++++++++++++++++++++++++++ include/linux/uvirtio.h | 8 + include/uapi/linux/uvirtio.h | 69 ++++++ samples/uvirtio/Makefile | 9 + samples/uvirtio/uvirtio-vga.c | 63 ++++++ 7 files changed, 563 insertions(+) create mode 100644 drivers/virtio/uvirtio.c create mode 100644 include/linux/uvirtio.h create mode 100644 include/uapi/linux/uvirtio.h create mode 100644 samples/uvirtio/Makefile create mode 100644 samples/uvirtio/uvirtio-vga.c
drivers/virtio/Kconfig +8 -0
@@ -109,4 +109,12 @@ config VIRTIO_MMIO_CMDLINE_DEVICES If unsure, say 'N'. +config UVIRTIO + tristate "UVirtio driver" + select VIRTIO + ---help--- + This driver supports create virtio devices from guest userspace. + + If unsure, say 'N'. + endif # VIRTIO_MENU
drivers/virtio/Makefile +1 -0
@@ -7,3 +7,4 @@ virtio_pci-$(CONFIG_VIRTIO_PCI_LEGACY) += virtio_pci_legacy.o obj-$(CONFIG_VIRTIO_BALLOON) += virtio_balloon.o obj-$(CONFIG_VIRTIO_INPUT) += virtio_input.o obj-$(CONFIG_VIRTIO_VDPA) += virtio_vdpa.o +obj-$(CONFIG_UVIRTIO) += uvirtio.o
drivers/virtio/uvirtio.c new file +405 -0
405 lines not on this page · raw message
include/linux/uvirtio.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef __UVIRTIO_H_ +#define __UVIRTIO_H_ + +#include <uapi/linux/uvirtio.h> + +enum uvirtio_state {UVST_NEW_DEVICE ,UVST_CREATED }; + +#endif /* __UVIRTIO_H_ */
include/uapi/linux/uvirtio.h new file +69 -0
69 lines not on this page · raw message
samples/uvirtio/Makefile new file +9 -0
@@ -0,0 +1,9 @@ +uvirtio-vga: uvirtio-vga.c uapi/linux/uvirtio.h linux/uvirtio.h + $(CC) -o $@ $^ -I. +uapi/linux/uvirtio.h: + mkdir -p uapi/linux && ln ../../../../include/uapi/linux/uvirtio.h uapi/linux -sf +linux/uvirtio.h: + mkdir -p linux && ln ../../../include/linux/uvirtio.h linux -sf +.PHONY: clean +clean: + rm -f uvirtio-vga
samples/uvirtio/uvirtio-vga.c new file +63 -0
63 lines not on this page · raw message
Signature · 1 line
2.26.2.303.gf8c07b1a785-goog
Quoted 10 lines · Lepton Wu
This is a way to create virtio based devices from user space. This is the background for this patch:
We have some images works fine under qemu, we'd like to also run the same image on Google Cloud. Currently Google Cloud doesn't support virtio-vga. I had a patch to create a virtio-vga from kernel directly:
https://www.spinics.net/lists/dri-devel/msg248573.htmlThen I got feedback from Gerd that maybe it's better to change that to something
like uvirtio. Since I really don't have other use cases for now, I just implemented the minimal stuff which work for my use case.
Interesting, several questions:
1) Are you aware of virtio vhost-user driver done by UM guys? (arch/um/drivers/virtio_uml.c) The memory part is tricky but overall both of you have similar target.
2) Patch 1 said it's userspace virtio driver, which I think it is actually "userspace virtio device"
3) Need to be verbose on how the vring processing work in the commit log of patch 1
4) I'm curious which testing you want to accomplish through this new transport, I guess you want to test a specific virtio driver?
5) You mentioned that you may want to develop communication between kernel and userspace, any more details on that?
Thanks
Quoted 12 lines
Lepton Wu (1):
virtio: Add uvirtio driverdrivers/virtio/Kconfig | 8 + drivers/virtio/Makefile | 1 + drivers/virtio/uvirtio.c | 405 ++++++++++++++++++++++++++++++++++ include/linux/uvirtio.h | 8 + include/uapi/linux/uvirtio.h | 69 ++++++ samples/uvirtio/Makefile | 9 + samples/uvirtio/uvirtio-vga.c | 63 ++++++ 7 files changed, 563 insertions(+)
Quoted 6 lines
create mode 100644
drivers/virtio/uvirtio.ccreate mode 100644include/linux/uvirtio.hcreate mode 100644include/uapi/linux/uvirtio.hcreate mode 100644samples/uvirtio/Makefilecreate mode 100644samples/uvirtio/uvirtio-vga.c
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Quoted 2 lines
3) Need to be verbose on how the vring processing work in the commit log of patch 1
Ecven better a file documenting the interface somewhere in Documentation/
take care,
Gerd
Quoted 6 lines · Gerd Hoffmann
Quoted 3 lines
3) Need to be verbose on how the vring processing work in the commit log of patch 1
Ecven better a file documenting the interface somewhere in
Documentation/
I put a uvirtio-vga.c under samples/uvirtio and hope this can serve the purpose of the document since currently that's the only tested use case. Maybe have a document later if this really get more use cases? Thanks.
Quoted 4 lines
take care,
Gerd
Quoted 10 lines · lepton
Quoted 6 lines · Gerd Hoffmann
Quoted 3 lines
3) Need to be verbose on how the vring processing work in the commit log of patch 1
Ecven better a file documenting the interface somewhere in
Documentation/I put a
uvirtio-vga.cundersamples/uvirtioand hope this can serve the purpose of the document since currently that's the only tested use case.
Sample code is good, but *commented* sample code would be better.
Quoted 1 line
Maybe have a document later if this really get more use cases?
Well, having good documentation right from the start would help getting more use cases ;)
take care,
Gerd
PATCH v3 1/1 virtio: Add uvirtio driver
This is for testing purpose to create virtio devices from user space. uvirtio-vga.c shows how to create a virtio-vga device.
For "simple" device like virtio 2d VGA, actually we only need to handle one virtio request which return the resolution of VGA. We provide a UV_DEV_EXPECT ioctl which set the expected virtio request and the prepared reply. This can eliminate user/kernel communication. We just handle this in the notify callback of the virtqueue.
Check samples/uvirtio/uvirtio-vga.c for example.
Currently we don't have a use case which requires user/kernel communication so read/write API hasn't been implemented.
---
v3:
* Add Documentation/misc-devices/uvirtio.rst
v2:
* Fix styles issues found by checkpatch.pl
* Update comments and commit log
--- Documentation/misc-devices/index.rst | 1 + Documentation/misc-devices/uvirtio.rst | 56 ++++ drivers/virtio/Kconfig | 11 + drivers/virtio/Makefile | 1 + drivers/virtio/uvirtio.c | 399 +++++++++++++++++++++++++ include/linux/uvirtio.h | 16 + include/uapi/linux/uvirtio.h | 50 ++++ samples/uvirtio/Makefile | 9 + samples/uvirtio/uvirtio-vga.c | 72 +++++ 9 files changed, 615 insertions(+) create mode 100644 Documentation/misc-devices/uvirtio.rst create mode 100644 drivers/virtio/uvirtio.c create mode 100644 include/linux/uvirtio.h create mode 100644 include/uapi/linux/uvirtio.h create mode 100644 samples/uvirtio/Makefile create mode 100644 samples/uvirtio/uvirtio-vga.c
Documentation/misc-devices/index.rst +1 -0
@@ -21,4 +21,5 @@ fit into other categories. lis3lv02d max6875 mic/index + uvirtio xilinx_sdfec
Documentation/misc-devices/uvirtio.rst new file +56 -0
56 lines not on this page · raw message
drivers/virtio/Kconfig +11 -0
@@ -109,4 +109,15 @@ config VIRTIO_MMIO_CMDLINE_DEVICES If unsure, say 'N'. +config UVIRTIO + tristate "UVirtio driver" + select VIRTIO + help + This driver supports creating virtio devices from userspace. + + This can be used to create virtio devices from user space without + supports from VMM. Check samples/uvirtio for examples. + + If unsure, say 'N'. + endif # VIRTIO_MENU
drivers/virtio/Makefile +1 -0
@@ -7,3 +7,4 @@ virtio_pci-$(CONFIG_VIRTIO_PCI_LEGACY) += virtio_pci_legacy.o obj-$(CONFIG_VIRTIO_BALLOON) += virtio_balloon.o obj-$(CONFIG_VIRTIO_INPUT) += virtio_input.o obj-$(CONFIG_VIRTIO_VDPA) += virtio_vdpa.o +obj-$(CONFIG_UVIRTIO) += uvirtio.o
drivers/virtio/uvirtio.c new file +399 -0
399 lines not on this page · raw message
include/linux/uvirtio.h new file +16 -0
@@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* +* User level device support for virtio subsystem +* +* Check samples/uvirtio for examples. +* +* Based on uinput.c by Aristeu Sergio Rozanski Filho +*/ +#ifndef __UVIRTIO_H_ +#define __UVIRTIO_H_ + +#include <uapi/linux/uvirtio.h> + +enum uvirtio_state {UVST_NEW_DEVICE ,UVST_CREATED }; + +#endif /* __UVIRTIO_H_ */
include/uapi/linux/uvirtio.h new file +50 -0
50 lines not on this page · raw message
samples/uvirtio/Makefile new file +9 -0
@@ -0,0 +1,9 @@ +uvirtio-vga: uvirtio-vga.c uapi/linux/uvirtio.h linux/uvirtio.h + $(CC) -o $@ $^ -I. +uapi/linux/uvirtio.h: + mkdir -p uapi/linux && ln ../../../../include/uapi/linux/uvirtio.h uapi/linux -sf +linux/uvirtio.h: + mkdir -p linux && ln ../../../include/linux/uvirtio.h linux -sf +.PHONY: clean +clean: + rm -f uvirtio-vga
samples/uvirtio/uvirtio-vga.c new file +72 -0
72 lines not on this page · raw message
Signature · 1 line
2.26.2.526.g744177e7f7-goog
Quoted 13 lines · Gerd Hoffmann
Quoted 10 lines · lepton
Quoted 6 lines · Gerd Hoffmann
Quoted 3 lines
3) Need to be verbose on how the vring processing work in the commit log of patch 1
Ecven better a file documenting the interface somewhere in
Documentation/I put a
uvirtio-vga.cundersamples/uvirtioand hope this can serve the purpose of the document since currently that's the only tested use case.
Quoted 6 lines
Sample code is good, but *commented* sample code would be better.
Quoted 1 line
Maybe have a document later if this really get more use cases?
Well, having good documentation right from the start would help getting more use cases ;)
Now I add document in V3.
Thanks. Regards
Quoted 4 lines
take care,
Gerd
PATCH v2 1/1 virtio: Add uvirtio driver
In reply to Jason WangThis is for testing purpose to create virtio devices from user space. uvirtio-vga.c shows how to create a virtio-vga device.
For "simple" device like virtio 2d VGA, actually we only need to handle one virtio request which return the resolution of VGA. We provide a UV_DEV_EXPECT ioctl which set the expected virtio request and the prepared reply. This can eliminate user/kernel communication. We just handle this in the notify callback of the virtqueue.
Check samples/uvirtio/uvirtio-vga.c for example.
Currently we don't have a use case which requires user/kernel communication so read/write api hasn't been implemented.
---
v2:
* Fix styles issues found by checkpatch.pl
* Update comments and commit log
--- drivers/virtio/Kconfig | 11 + drivers/virtio/Makefile | 1 + drivers/virtio/uvirtio.c | 399 ++++++++++++++++++++++++++++++++++ include/linux/uvirtio.h | 16 ++ include/uapi/linux/uvirtio.h | 50 +++++ samples/uvirtio/Makefile | 9 + samples/uvirtio/uvirtio-vga.c | 72 ++++++ 7 files changed, 558 insertions(+) create mode 100644 drivers/virtio/uvirtio.c create mode 100644 include/linux/uvirtio.h create mode 100644 include/uapi/linux/uvirtio.h create mode 100644 samples/uvirtio/Makefile create mode 100644 samples/uvirtio/uvirtio-vga.c
drivers/virtio/Kconfig +11 -0
@@ -109,4 +109,15 @@ config VIRTIO_MMIO_CMDLINE_DEVICES If unsure, say 'N'. +config UVIRTIO + tristate "UVirtio driver" + select VIRTIO + help + This driver supports creating virtio devices from userspace. + + This can be used to create virtio devices from user space without + supports from VMM. Check samples/uvirtio for examples. + + If unsure, say 'N'. + endif # VIRTIO_MENU
drivers/virtio/Makefile +1 -0
@@ -7,3 +7,4 @@ virtio_pci-$(CONFIG_VIRTIO_PCI_LEGACY) += virtio_pci_legacy.o obj-$(CONFIG_VIRTIO_BALLOON) += virtio_balloon.o obj-$(CONFIG_VIRTIO_INPUT) += virtio_input.o obj-$(CONFIG_VIRTIO_VDPA) += virtio_vdpa.o +obj-$(CONFIG_UVIRTIO) += uvirtio.o
drivers/virtio/uvirtio.c new file +399 -0
399 lines not on this page · raw message
include/linux/uvirtio.h new file +16 -0
@@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* +* User level device support for virtio subsystem +* +* Check samples/uvirtio for examples. +* +* Based on uinput.c by Aristeu Sergio Rozanski Filho +*/ +#ifndef __UVIRTIO_H_ +#define __UVIRTIO_H_ + +#include <uapi/linux/uvirtio.h> + +enum uvirtio_state {UVST_NEW_DEVICE ,UVST_CREATED }; + +#endif /* __UVIRTIO_H_ */
include/uapi/linux/uvirtio.h new file +50 -0
50 lines not on this page · raw message
samples/uvirtio/Makefile new file +9 -0
@@ -0,0 +1,9 @@ +uvirtio-vga: uvirtio-vga.c uapi/linux/uvirtio.h linux/uvirtio.h + $(CC) -o $@ $^ -I. +uapi/linux/uvirtio.h: + mkdir -p uapi/linux && ln ../../../../include/uapi/linux/uvirtio.h uapi/linux -sf +linux/uvirtio.h: + mkdir -p linux && ln ../../../include/linux/uvirtio.h linux -sf +.PHONY: clean +clean: + rm -f uvirtio-vga
samples/uvirtio/uvirtio-vga.c new file +72 -0
72 lines not on this page · raw message
Signature · 1 line
2.26.2.303.gf8c07b1a785-goog
Quoted 15 lines · Jason Wang
Quoted 10 lines · Lepton Wu
This is a way to create virtio based devices from user space. This is the background for this patch:
We have some images works fine under qemu, we'd like to also run the same image on Google Cloud. Currently Google Cloud doesn't support virtio-vga. I had a patch to create a virtio-vga from kernel directly:
https://www.spinics.net/lists/dri-devel/msg248573.htmlThen I got feedback from Gerd that maybe it's better to change that to something
like uvirtio. Since I really don't have other use cases for now, I just implemented the minimal stuff which work for my use case.
Quoted 5 lines
Interesting, several questions:
1) Are you aware of virtio vhost-user driver done by UM guys? (
arch/um/drivers/virtio_uml.c) The memory part is tricky but overall both of you have similar target.
Thanks for reminding me, I was not aware of it. The use case looks a little different: they are trying create virtio devices for user mode linux and it communicated with "host" side. My driver doesn't depends on any HOST/VMM side stuff. Basically we can use it to create virtio device from guest itself. Or even create virtio device on bare metal.
Quoted 2 lines
2) Patch 1 said it's userspace virtio driver, which I think it is actually "userspace virtio device"
Updated in version 2 of this patch.
Quoted 2 lines
3) Need to be verbose on how the vring processing work in the commit log of patch 1
Updated.
Quoted 2 lines
4) I'm curious which testing you want to accomplish through this new transport, I guess you want to test a specific virtio driver?
Here is the whole story: we want to test our custom linux image. In the past, we just test our custom linux image with qemu (and virtio vga), and run qemu session on Google Cloud. As you can see, this is nested virtualization and performance hurts. And more, we have another vm inside our custom linux image. So we want to remove the qemu layer, just run our custom linux image on Google Cloud directly. Then we need some kind of VGA. So a "dummy" virtio vga looks a good fit.
Quoted 2 lines
5) You mentioned that you may want to develop communication between kernel and userspace, any more details on that?
Currently, we don't have such use case. But maybe others can furthermore to extend uvirtio for this. For example, user space can use read/write to actually exchange data with kernel. Then that could be used for simulate more complex use case.
Quoted 23 lines
Thanks
Quoted 18 lines
Lepton Wu (1):
virtio: Add uvirtio driverdrivers/virtio/Kconfig | 8 + drivers/virtio/Makefile | 1 + drivers/virtio/uvirtio.c | 405 ++++++++++++++++++++++++++++++++++ include/linux/uvirtio.h | 8 + include/uapi/linux/uvirtio.h | 69 ++++++ samples/uvirtio/Makefile | 9 + samples/uvirtio/uvirtio-vga.c | 63 ++++++ 7 files changed, 563 insertions(+)create mode 100644
drivers/virtio/uvirtio.ccreate mode 100644include/linux/uvirtio.hcreate mode 100644include/uapi/linux/uvirtio.hcreate mode 100644samples/uvirtio/Makefilecreate mode 100644samples/uvirtio/uvirtio-vga.c
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Quoted 16 lines · lepton
Quoted 15 lines · Jason Wang
Quoted 10 lines · Lepton Wu
This is a way to create virtio based devices from user space. This is the background for this patch:
We have some images works fine under qemu, we'd like to also run the same image on Google Cloud. Currently Google Cloud doesn't support virtio-vga. I had a patch to create a virtio-vga from kernel directly:
https://www.spinics.net/lists/dri-devel/msg248573.htmlThen I got feedback from Gerd that maybe it's better to change that to something
like uvirtio. Since I really don't have other use cases for now, I just implemented the minimal stuff which work for my use case.Interesting, several questions:
Quoted 7 lines
Quoted 3 lines
1) Are you aware of virtio vhost-user driver done by UM guys? (
arch/um/drivers/virtio_uml.c) The memory part is tricky but overall both of you have similar target.Thanks for reminding me, I was not aware of it. The use case looks a little different: they are trying create virtio devices for user mode linux and it communicated with "host" side. My driver doesn't depends on any HOST/VMM side stuff.
Yes, but as I said. Except for the memory table part, the rest could be probably reused?
The only difference to me is that, you develop your own uABI while virtio_uml uses vhost-user.
Quoted 10 lines
Basically we can use it to create virtio
device from guest itself. Or even create virtio device on bare metal.Quoted 2 lines
2) Patch 1 said it's userspace virtio driver, which I think it is actually "userspace virtio device"
Updated in version 2 of this patch.
Quoted 2 lines
3) Need to be verbose on how the vring processing work in the commit log of patch 1
Updated.
Quoted 2 lines
4) I'm curious which testing you want to accomplish through this new transport, I guess you want to test a specific virtio driver?
Quoted 7 lines
Here is the whole story: we want to test our custom linux image. In the past, we just test our custom linux image with qemu (and virtio vga), and run qemu session on Google Cloud. As you can see, this is nested virtualization and performance hurts. And more, we have another vm inside our custom linux image. So we want to remove the qemu layer, just run our custom linux image on Google Cloud directly. Then we need some kind of VGA. So a "dummy" virtio vga looks a good fit.
Then it's better to mention this in the cover letter.
Quoted 6 lines
Quoted 2 lines
5) You mentioned that you may want to develop communication between kernel and userspace, any more details on that?
Currently, we don't have such use case. But maybe others can furthermore to extend uvirtio for this. For example, user space can use read/write to actually exchange data with kernel. Then that could be used for simulate more complex use case.
OK.
Thanks
Quoted 6 lines
Quoted 6 lines
Thanks
Quoted 3 lines
Lepton Wu (1):
virtio: Add uvirtio driver
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
drivers/virtio/Kconfig | 8 + drivers/virtio/Makefile | 1 + drivers/virtio/uvirtio.c | 405 ++++++++++++++++++++++++++++++++++ include/linux/uvirtio.h | 8 + include/uapi/linux/uvirtio.h | 69 ++++++ samples/uvirtio/Makefile | 9 +Quoted 8 lines
Quoted 8 lines
samples/uvirtio/uvirtio-vga.c | 63 ++++++ 7 files changed, 563 insertions(+)create mode 100644
drivers/virtio/uvirtio.ccreate mode 100644include/linux/uvirtio.hcreate mode 100644include/uapi/linux/uvirtio.hcreate mode 100644samples/uvirtio/Makefilecreate mode 100644samples/uvirtio/uvirtio-vga.c
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization