All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Add serial number support for virtio_blk, V2
@ 2009-05-13 17:06 ` john cooper
  0 siblings, 0 replies; 12+ messages in thread
From: john cooper @ 2009-05-13 17:06 UTC (permalink / raw)
  To: KVM list, qemu-devel; +Cc: john.cooper

[-- Attachment #1: Type: text/plain, Size: 1008 bytes --]

[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.cooper@redhat.com


[-- Attachment #2: virtio_get_sn.c --]
[-- Type: text/x-csrc, Size: 851 bytes --]

/* 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);
}

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 0/2] Add serial number support for virtio_blk, V2
@ 2009-05-13 17:06 ` john cooper
  0 siblings, 0 replies; 12+ messages in thread
From: john cooper @ 2009-05-13 17:06 UTC (permalink / raw)
  To: KVM list, qemu-devel; +Cc: john.cooper

[-- Attachment #1: Type: text/plain, Size: 1008 bytes --]

[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.cooper@redhat.com


[-- Attachment #2: virtio_get_sn.c --]
[-- Type: text/x-csrc, Size: 851 bytes --]

/* 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);
}

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/2] Add serial number support for virtio_blk, V2
  2009-05-13 17:06 ` [Qemu-devel] " john cooper
@ 2009-05-18 12:13   ` Christoph Hellwig
  -1 siblings, 0 replies; 12+ messages in thread
From: Christoph Hellwig @ 2009-05-18 12:13 UTC (permalink / raw)
  To: john cooper; +Cc: KVM list, qemu-devel

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?


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Qemu-devel] Re: [PATCH 0/2] Add serial number support for virtio_blk, V2
@ 2009-05-18 12:13   ` Christoph Hellwig
  0 siblings, 0 replies; 12+ messages in thread
From: Christoph Hellwig @ 2009-05-18 12:13 UTC (permalink / raw)
  To: john cooper; +Cc: qemu-devel, KVM list

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?

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/2] Add serial number support for virtio_blk, V2
  2009-05-18 12:13   ` [Qemu-devel] " Christoph Hellwig
@ 2009-05-18 15:00     ` john cooper
  -1 siblings, 0 replies; 12+ messages in thread
From: john cooper @ 2009-05-18 15:00 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: KVM list, qemu-devel, 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.cooper@redhat.com


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Qemu-devel] Re: [PATCH 0/2] Add serial number support for virtio_blk, V2
@ 2009-05-18 15:00     ` john cooper
  0 siblings, 0 replies; 12+ messages in thread
From: john cooper @ 2009-05-18 15:00 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: john.cooper, qemu-devel, KVM list

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.cooper@redhat.com

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/2] Add serial number support for virtio_blk, V2
  2009-05-18 15:00     ` [Qemu-devel] " john cooper
@ 2009-05-20  7:31       ` Christoph Hellwig
  -1 siblings, 0 replies; 12+ messages in thread
From: Christoph Hellwig @ 2009-05-20  7:31 UTC (permalink / raw)
  To: john cooper; +Cc: Christoph Hellwig, KVM list, qemu-devel

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.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Qemu-devel] Re: [PATCH 0/2] Add serial number support for virtio_blk, V2
@ 2009-05-20  7:31       ` Christoph Hellwig
  0 siblings, 0 replies; 12+ messages in thread
From: Christoph Hellwig @ 2009-05-20  7:31 UTC (permalink / raw)
  To: john cooper; +Cc: Christoph Hellwig, qemu-devel, KVM list

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.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/2] Add serial number support for virtio_blk, V2
  2009-05-20  7:31       ` [Qemu-devel] " Christoph Hellwig
@ 2009-05-20  7:36         ` Gleb Natapov
  -1 siblings, 0 replies; 12+ messages in thread
From: Gleb Natapov @ 2009-05-20  7:36 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: john cooper, KVM list, qemu-devel

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.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Qemu-devel] Re: [PATCH 0/2] Add serial number support for virtio_blk, V2
@ 2009-05-20  7:36         ` Gleb Natapov
  0 siblings, 0 replies; 12+ messages in thread
From: Gleb Natapov @ 2009-05-20  7:36 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: john cooper, qemu-devel, KVM list

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.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/2] Add serial number support for virtio_blk, V2
  2009-05-20  7:31       ` [Qemu-devel] " Christoph Hellwig
@ 2009-05-27  0:26         ` john cooper
  -1 siblings, 0 replies; 12+ messages in thread
From: john cooper @ 2009-05-27  0:26 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: KVM list, qemu-devel, 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.cooper@redhat.com

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Qemu-devel] Re: [PATCH 0/2] Add serial number support for virtio_blk, V2
@ 2009-05-27  0:26         ` john cooper
  0 siblings, 0 replies; 12+ messages in thread
From: john cooper @ 2009-05-27  0:26 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: john.cooper, qemu-devel, KVM list

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.cooper@redhat.com

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2009-05-27  0:28 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-13 17:06 [PATCH 0/2] Add serial number support for virtio_blk, V2 john cooper
2009-05-13 17:06 ` [Qemu-devel] " john cooper
2009-05-18 12:13 ` Christoph Hellwig
2009-05-18 12:13   ` [Qemu-devel] " Christoph Hellwig
2009-05-18 15:00   ` john cooper
2009-05-18 15:00     ` [Qemu-devel] " john cooper
2009-05-20  7:31     ` Christoph Hellwig
2009-05-20  7:31       ` [Qemu-devel] " Christoph Hellwig
2009-05-20  7:36       ` Gleb Natapov
2009-05-20  7:36         ` [Qemu-devel] " Gleb Natapov
2009-05-27  0:26       ` john cooper
2009-05-27  0:26         ` [Qemu-devel] " john cooper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.