Skip to content

Add virtio disk identification support

john cooper qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 11 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4Add virtio disk identification supporthw/virtio-blk.c hw/virtio-blk.h+14 -03 replies
2/4Add virtio disk identification supportvl.c+1 -12 replies
3/4Add virtio disk identification supportdrivers/block/virtio_blk.c include/linux/virtio_blk.h+36 -00 replies
4/4Add virtio disk identification supportdrivers/block/virtio_blk.c+15 -02 replies

Reviews trailers per patch

None of the 4 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchRyan Harper
SeriesA-b
1/4
2/4
3/4
4/4

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [Qemu-devel] [PATCH 0/4] Add virtio disk identification support

This series adds the minimal support to qemu and virtio_blk to support passing of a virtio_blk serial id string from qemu through the guest driver and to the guest userland.

This is derived in part from a patch set posted by Rusty some time ago, but has been minimized to remove support for prior versions which attempted to provide the same functionality via pci config/io space. This version rather uses a virtio request as proposed in Rusty's example.

Also removed is the packaging of the serial/id string within the glorious bag of bits returned by the ATA_IDENTIFY command. Here we transfer only the 20 bytes of serial/id string from qemu to the guest userland. In the proposed interface, this is made available by an ioctl() into the virtio_blk driver however other interfaces (eg: /sys) have also been proposed. A code snippet is attached below as an example of ioctl usage.

The resulting code is quite minimal and I believe it addresses all concerns raised in prior versions.

-john

#include <stdio.h>
#include <strings.h>
#include <sys/types.h>
#include <fcntl.h>
#include <linux/hdreg.h>

#define IOCTL_CMD 'VBID'

main()

{
	int fd, rv;
	char buf[512];

	bzero(buf, sizeof (buf));
	if ((fd = open("/dev/vda", O_RDONLY)) < 0)
		perror("open");
	else if (ioctl(fd, IOCTL_CMD, buf) < 0)
		perror("ioctl");
	else
		printf("[%s]\n", buf);
}
Signature · 1 line
[email protected]