[PATCH 0/2] Add serial number support for virtio_blk, V4

2009-05-28 Thread john cooper
[Rework of earlier patch to provide additional
information in the response to an ATA identify
request -- virtio_blk treats the data as opaque,
content created by qemu's virtio-blk.  Comments
from Christoph also incorporated.]

This patch allows passing of a virtio_blk drive
serial number from qemu into a guest's virtio_blk
driver, and provides a means to access the serial
number from a guest's userspace.

Equivalent functionality currently exists for IDE
and SCSI, however it is not yet implemented for
virtio.  Scenarios exist where guest code relies
on a unique drive serial number to correctly
identify the machine environment in which it
exists.

The following two patches implement the above:

  qemu-vblk-serial-4.patch

which provides the qemu missing bits to interpret
a '-drive .. serial=XYZ ..' flag, and:

  virtio_blk-serial-4.patch

which extracts this information and makes it
available to guest userspace via an HDIO_GET_IDENTITY
ioctl, eg: 'hdparm -i /dev/vda'.

The above patches are relative to qemu-kvm.git and
2.6.29.3 respectively.

-john

-- 
john.coo...@redhat.com



--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/2] Add serial number support for virtio_blk, V2

2009-05-26 Thread john cooper

Christoph Hellwig wrote:

On Mon, May 18, 2009 at 11:00:41AM -0400, john cooper wrote:

Christoph Hellwig wrote:

So why can't we re-use the existing interfaces instead of inventing a
new one?

I'm unclear to what specifically you're referring -- the
ioctl() used to retrieve the serial number in the guest?


Well, there's not specific ioctl to get a serial number for scsi, but
given that we now have SG_IO passthrough in virtio-blk it should be easy
enough to provide inquiry data and the device identification VPD page
by that way.  Not sure how it's handled for ide, maybe that way
is even easier.


Yea, I'm hardly in enamored with the IDE/ATA
diatribe.  But in this case displacing the new
ioctl with HDIO_GET_IDENTITY seemed the most
straightforward means to provide access within
an existing interface.  Updated patch follows.

-john


--
john.coo...@redhat.com
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/2] Add serial number support for virtio_blk, V2

2009-05-20 Thread Christoph Hellwig
On Mon, May 18, 2009 at 11:00:41AM -0400, john cooper wrote:
 Christoph Hellwig wrote:
 On Wed, May 13, 2009 at 01:06:57PM -0400, john cooper wrote:
 [Resend of earlier patch: 1/2 rebased to qemu-kvm,
 2/2 minor tweak]

 patch 1/2 seems to be missing.
 It is in the kvm and qemu-devel list archives:

 http://www.spinics.net/lists/kvm/maillist.html
 http://lists.gnu.org/archive/html/qemu-devel/2009-05/msg00661.html

Ah, it got posted as reply to the previous submission, not with this
one.

 So why can't we re-use the existing interfaces instead of inventing a
 new one?
 I'm unclear to what specifically you're referring -- the
 ioctl() used to retrieve the serial number in the guest?

Well, there's not specific ioctl to get a serial number for scsi, but
given that we now have SG_IO passthrough in virtio-blk it should be easy
enough to provide inquiry data and the device identification VPD page
by that way.  Not sure how it's handled for ide, maybe that way
is even easier.

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/2] Add serial number support for virtio_blk, V2

2009-05-20 Thread Gleb Natapov
On Wed, May 20, 2009 at 03:31:29AM -0400, Christoph Hellwig wrote:
 On Mon, May 18, 2009 at 11:00:41AM -0400, john cooper wrote:
  Christoph Hellwig wrote:
  On Wed, May 13, 2009 at 01:06:57PM -0400, john cooper wrote:
  [Resend of earlier patch: 1/2 rebased to qemu-kvm,
  2/2 minor tweak]
 
  patch 1/2 seems to be missing.
  It is in the kvm and qemu-devel list archives:
 
  http://www.spinics.net/lists/kvm/maillist.html
  http://lists.gnu.org/archive/html/qemu-devel/2009-05/msg00661.html
 
 Ah, it got posted as reply to the previous submission, not with this
 one.
 
  So why can't we re-use the existing interfaces instead of inventing a
  new one?
  I'm unclear to what specifically you're referring -- the
  ioctl() used to retrieve the serial number in the guest?
 
 Well, there's not specific ioctl to get a serial number for scsi, but
 given that we now have SG_IO passthrough in virtio-blk it should be easy
 enough to provide inquiry data and the device identification VPD page
 by that way.  Not sure how it's handled for ide, maybe that way
 is even easier.
 
IDE has identify command which return various info including 20 byte
serial number.

--
Gleb.
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/2] Add serial number support for virtio_blk, V2

2009-05-18 Thread Christoph Hellwig
On Wed, May 13, 2009 at 01:06:57PM -0400, john cooper wrote:
 [Resend of earlier patch: 1/2 rebased to qemu-kvm,
 2/2 minor tweak]

patch 1/2 seems to be missing.

 Equivalent functionality currently exists for IDE
 and SCSI, however it is not yet implemented for
 virtio.

So why can't we re-use the existing interfaces instead of inventing a
new one?

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/2] Add serial number support for virtio_blk, V2

2009-05-18 Thread john cooper

Christoph Hellwig wrote:

On Wed, May 13, 2009 at 01:06:57PM -0400, john cooper wrote:

[Resend of earlier patch: 1/2 rebased to qemu-kvm,
2/2 minor tweak]


patch 1/2 seems to be missing.

It is in the kvm and qemu-devel list archives:

http://www.spinics.net/lists/kvm/maillist.html
http://lists.gnu.org/archive/html/qemu-devel/2009-05/msg00661.html



Equivalent functionality currently exists for IDE
and SCSI, however it is not yet implemented for
virtio.


So why can't we re-use the existing interfaces instead of inventing a
new one?

I'm unclear to what specifically you're referring -- the
ioctl() used to retrieve the serial number in the guest?

-john

--
john.coo...@redhat.com

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] Add serial number support for virtio_blk, V2

2009-05-13 Thread john cooper

[Resend of earlier patch: 1/2 rebased to qemu-kvm,
2/2 minor tweak]

This patch allows passing of a virtio_blk drive
serial number from qemu into a guest's virtio_blk
driver, and provides a means to access the serial
number from a guest's userspace.

Equivalent functionality currently exists for IDE
and SCSI, however it is not yet implemented for
virtio.  Scenarios exist where guest code relies
on a unique drive serial number to correctly
identify the machine environment in which it
exists.

The following two patches implement the above:

   qemu-vblk-serial-2.patch

which provides the qemu missing bits to interpret
a '-drive .. serial=XYZ ..' flag, and:

   virtio_blk-serial-2.patch

which extracts this information and makes it
available to guest userspace via ioctl.

Attached to this patch header is a trivial example
program which retrieves the serial number from
guest userspace.

The above patches are relative to qemu-kvm.git and
2.6.29.3 respectively.

-john

--
john.coo...@redhat.com

/* example: retrieve serial number from virtio block device
 */
#include stdio.h
#include fcntl.h
#include stdlib.h
#include linux/virtio_blk.h

#define iswhite(c)	(!('!' = (c)  (c) = '~'))

#ifndef VBLK_GET_SN
#define VBLK_GET_SN ((unsigned int)('V'  24 | 'B'  16 | 'L'  8 | 'K'))
#endif

/* get virtblk drive serial#
 */
int main(int ac, char ***av)
{
	int fd, nb, i;
	unsigned char sn[30];
	unsigned char *p;

	sn[0] = sizeof (sn);
	if ((fd = open(/dev/vda, O_RDONLY))  0)
		perror(can't open device), exit(1);
	else if ((nb = ioctl(fd, VBLK_GET_SN, sn))  0)
		perror(can't ioctl device), exit(1);
	printf(returned %d bytes:\n, nb);
	for (p = sn, i = nb; 0 = --i; ++p)
		printf(%02x%c, *p, i ? ' ' : '\t');
	for (p = sn, i = nb; 0 = --i; ++p)
		printf(%c%s, iswhite(*p) ? '.' : *p, i ?  : \n);
	return (0);
}


[PATCH 0/2] Add serial number support for virtio_blk

2009-04-29 Thread john cooper

This patch allows passing of a virtio_blk drive
serial number from qemu into a guest's virtio_blk
driver, and provides a means to access the serial
number from a guest's userspace.

Equivalent functionality currently exists for IDE
and SCSI, however it is not yet implemented for
virtio.  Scenarios exist where guest code relies
on a unique drive serial number to correctly
identify the machine environment in which it
exists.

The following two patches implement the above

qemu-vblk-serial.patch

which provides the qemu missing bits to interpret
a '-drive .. serial=XYZ ..' flag, and

virtio_blk-serial.patch

which extracts this information and make it
available to guest userspace via ioctl.

Attached to this patch header is a trivial example
program which retrieves the serial number from
guest userspace.

The above patches are relative to kvm-84 and
2.6.28 respectively.

-john


--
john.coo...@third-harmonic.com
/* example: retrieve serial number from virtio block device
 */
#include stdio.h
#include fcntl.h
#include stdlib.h
#include linux/virtio_blk.h

#define iswhite(c)	(!('!' = (c)  (c) = '~'))

#ifndef VBLK_GET_SN
#define VBLK_GET_SN ((unsigned int)('V'  24 | 'B'  16 | 'L'  8 | 'K'))
#endif

/* get virtblk drive serial#
 */
int main(int ac, char ***av)
{
	int fd, nb, i;
	unsigned char sn[30];
	unsigned char *p;

	sn[0] = sizeof (sn);
	if ((fd = open(/dev/vda, O_RDONLY))  0)
		perror(can't open device), exit(1);
	else if ((nb = ioctl(fd, VBLK_GET_SN, sn))  0)
		perror(can't ioctl device), exit(1);
	printf(returned %d bytes:\n, nb);
	for (p = sn, i = nb; 0 = --i; ++p)
		printf(%02x%c, *p, i ? ' ' : '\t');
	for (p = sn, i = nb; 0 = --i; ++p)
		printf(%c%s, iswhite(*p) ? '.' : *p, i ?  : \n);
	return (0);
}