From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MIoXB-00077B-Bj for qemu-devel@nongnu.org; Mon, 22 Jun 2009 14:46:25 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MIoX6-000738-UJ for qemu-devel@nongnu.org; Mon, 22 Jun 2009 14:46:25 -0400 Received: from [199.232.76.173] (port=48456 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MIoX6-000734-No for qemu-devel@nongnu.org; Mon, 22 Jun 2009 14:46:20 -0400 Received: from mail-fx0-f209.google.com ([209.85.220.209]:56468) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MIoX6-0001m0-7z for qemu-devel@nongnu.org; Mon, 22 Jun 2009 14:46:20 -0400 Received: by fxm5 with SMTP id 5so3047923fxm.34 for ; Mon, 22 Jun 2009 11:46:19 -0700 (PDT) Message-ID: <4A3FD176.4010600@codemonkey.ws> Date: Mon, 22 Jun 2009 13:46:14 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <4A3FCCEB.1080603@redhat.com> In-Reply-To: <4A3FCCEB.1080603@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH] Add serial number support for virtio_blk List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: john cooper Cc: qemu-devel@nongnu.org john cooper wrote: > @@ -353,6 +403,7 @@ void *virtio_blk_init(PCIBus *bus, BlockDriverState *bs) > VirtIOBlock *s; > int cylinders, heads, secs; > static int virtio_blk_id; > + char *ps; > const char *ps; > > s = (VirtIOBlock *)virtio_init_pci(bus, "virtio-blk", > PCI_VENDOR_ID_REDHAT_QUMRANET, > @@ -369,6 +420,10 @@ void *virtio_blk_init(PCIBus *bus, BlockDriverState *bs) > s->vdev.reset = virtio_blk_reset; > s->bs = bs; > s->rq = NULL; > + if (strlen(ps = (char *)drive_get_serial(bs))) > + strncpy(s->serial_str, ps, sizeof(s->serial_str)); > + else > + snprintf(s->serial_str, sizeof(s->serial_str), "0"); > ps = drive_get_serial(bs); snprintf(s->serial_str, sizeof(s->serial_str), "%s", *ps ? ps : "0"); strncpy() doesn't do what you think it does. It doesn't always null terminate. Doesn't serial_str need to be saved in the savevm format? Regards, Anthony Liguori