From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=41441 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OJjsn-00022w-AH for qemu-devel@nongnu.org; Wed, 02 Jun 2010 05:05:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OJjsl-0004yr-Tb for qemu-devel@nongnu.org; Wed, 02 Jun 2010 05:05:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55700) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OJjsl-0004yg-NP for qemu-devel@nongnu.org; Wed, 02 Jun 2010 05:05:03 -0400 Date: Wed, 2 Jun 2010 12:00:50 +0300 From: "Michael S. Tsirkin" Message-ID: <20100602090050.GA19662@redhat.com> References: <20100602014854.GB16406@us.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100602014854.GB16406@us.ibm.com> Subject: [Qemu-devel] Re: [PATCH] virtio-blk: assign a default serial number if none provided List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ryan Harper Cc: john cooper , qemu-devel@nongnu.org On Tue, Jun 01, 2010 at 08:48:54PM -0500, Ryan Harper wrote: > This patch applies on-top of John's virtio-blk serial patches. > > Generate default serial numbers for virtio drives based on DriveInfo.unit which is > incremented for each additional virtio-blk device. This provides a > per-virtio-blk number to use in the default string: QM%05d that is used in > hw/ide/core.c. The resulting serial number looks like: QM00001, etc. > > Signed-off-by: Ryan Harper I think that there's a problem with this approach in that hot plug A, hot plug B, hot unplug A is not the same as hot plug B. So you might get guest boot failures and no easy way to figure out why. For guests that need S/N, I think they really must be persistent. > --- > hw/virtio-blk.c | 3 +++ > 1 files changed, 3 insertions(+), 0 deletions(-) > > diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c > index 98c62f2..e5c6e7c 100644 > --- a/hw/virtio-blk.c > +++ b/hw/virtio-blk.c > @@ -518,6 +518,9 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf) > bdrv_guess_geometry(s->bs, &cylinders, &heads, &secs); > > strncpy(s->sn, drive_get_serial(s->bs), sizeof (s->sn)); > + if (strlen(s->sn) == 0) { > + snprintf(s->sn, sizeof(s->sn), "QM%05d", conf->dinfo->unit); > + } > > s->vq = virtio_add_queue(&s->vdev, 128, virtio_blk_handle_output); > > -- > 1.6.3.3 > > > -- > Ryan Harper > Software Engineer; Linux Technology Center > IBM Corp., Austin, Tx > ryanh@us.ibm.com