* [Qemu-devel] [PATCH] virtio-blk: Set default serial id
@ 2013-03-20 5:56 Asias He
2013-03-20 7:52 ` Stefan Hajnoczi
0 siblings, 1 reply; 4+ messages in thread
From: Asias He @ 2013-03-20 5:56 UTC (permalink / raw)
To: qemu-devel; +Cc: Paolo Bonzini, Asias He, kvm, Stefan Hajnoczi
If user does not specify a serial id, e.g.
-device virtio-blk-pci,serial="serial_id"
or
-drive serial="serial_id"
no serial id will be assigned.
Add a default serial id in this case to help identifying
the disk in guest.
Signed-off-by: Asias He <asias@redhat.com>
---
hw/virtio-blk.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index f2143fd..c016817 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -642,6 +642,13 @@ static int virtio_blk_device_init(VirtIODevice *vdev)
}
blkconf_serial(&blk->conf, &blk->serial);
+
+ if (!blk->serial) {
+ char serial[VIRTIO_BLK_ID_BYTES];
+ snprintf(serial, VIRTIO_BLK_ID_BYTES, "ID%05d", virtio_blk_id);
+ blk->serial = g_strdup(serial);
+ }
+
if (blkconf_geometry(&blk->conf, NULL, 65535, 255, 255) < 0) {
return -1;
}
--
1.8.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio-blk: Set default serial id
2013-03-20 5:56 [Qemu-devel] [PATCH] virtio-blk: Set default serial id Asias He
@ 2013-03-20 7:52 ` Stefan Hajnoczi
2013-03-20 8:34 ` Asias He
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Hajnoczi @ 2013-03-20 7:52 UTC (permalink / raw)
To: Asias He; +Cc: Paolo Bonzini, qemu-devel, kvm
On Wed, Mar 20, 2013 at 01:56:08PM +0800, Asias He wrote:
> If user does not specify a serial id, e.g.
>
> -device virtio-blk-pci,serial="serial_id"
> or
> -drive serial="serial_id"
>
> no serial id will be assigned.
>
> Add a default serial id in this case to help identifying
> the disk in guest.
>
> Signed-off-by: Asias He <asias@redhat.com>
> ---
> hw/virtio-blk.c | 7 +++++++
> 1 file changed, 7 insertions(+)
Autogenerated IDs have been proposed (for other devices?) before and I
think we should avoid them.
The serial in this patch depends on the internal counter we use for
savevm. It is not a well-defined value that guests can depend on
remaining the same.
It can change between QEMU invocations - due to internal changes in QEMU
or because the management tool reordered -device options.
Users will be confused and their guests may stop working if they depend
on an ID like this.
The solution is to do persistent naming either by really passing -device
virtio-blk-pci,serial= or with udev inside the guest using the bus
address (PCI devfn) like the new persistent network interface naming for
Linux.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio-blk: Set default serial id
2013-03-20 7:52 ` Stefan Hajnoczi
@ 2013-03-20 8:34 ` Asias He
2013-03-21 9:31 ` Paolo Bonzini
0 siblings, 1 reply; 4+ messages in thread
From: Asias He @ 2013-03-20 8:34 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: Paolo Bonzini, qemu-devel, kvm
On Wed, Mar 20, 2013 at 08:52:57AM +0100, Stefan Hajnoczi wrote:
> On Wed, Mar 20, 2013 at 01:56:08PM +0800, Asias He wrote:
> > If user does not specify a serial id, e.g.
> >
> > -device virtio-blk-pci,serial="serial_id"
> > or
> > -drive serial="serial_id"
> >
> > no serial id will be assigned.
> >
> > Add a default serial id in this case to help identifying
> > the disk in guest.
> >
> > Signed-off-by: Asias He <asias@redhat.com>
> > ---
> > hw/virtio-blk.c | 7 +++++++
> > 1 file changed, 7 insertions(+)
>
> Autogenerated IDs have been proposed (for other devices?) before and I
> think we should avoid them.
>
> The serial in this patch depends on the internal counter we use for
> savevm. It is not a well-defined value that guests can depend on
> remaining the same.
>
> It can change between QEMU invocations - due to internal changes in QEMU
> or because the management tool reordered -device options.
>
> Users will be confused and their guests may stop working if they depend
> on an ID like this.
So, no serial id forces user not to depend on the serial id. This is how it
works now.
Okay, let's leave it as it is, persistent id specified by user or no id
at all. This is not perfect but at least it does not break any thing.
> The solution is to do persistent naming either by really passing -device
> virtio-blk-pci,serial= or with udev inside the guest using the bus
> address (PCI devfn) like the new persistent network interface naming for
> Linux.
'-virtio-blk-pci,serial=' specified by user would be persistent, but pci
id might be changed as well.
> Stefan
--
Asias
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio-blk: Set default serial id
2013-03-20 8:34 ` Asias He
@ 2013-03-21 9:31 ` Paolo Bonzini
0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2013-03-21 9:31 UTC (permalink / raw)
To: Asias He; +Cc: qemu-devel, Stefan Hajnoczi, kvm
Il 20/03/2013 09:34, Asias He ha scritto:
>> The solution is to do persistent naming either by really passing -device
>> virtio-blk-pci,serial= or with udev inside the guest using the bus
>> address (PCI devfn) like the new persistent network interface naming for
>> Linux.
>
> '-virtio-blk-pci,serial=' specified by user would be persistent, but pci
> id might be changed as well.
Yes, but '-device virtio-blk-pci,addr=10.0' would be persistent too. :)
Also, management may try to keep addresses persistent (libvirt does).
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-03-21 9:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-20 5:56 [Qemu-devel] [PATCH] virtio-blk: Set default serial id Asias He
2013-03-20 7:52 ` Stefan Hajnoczi
2013-03-20 8:34 ` Asias He
2013-03-21 9:31 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).