All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: john cooper <john.cooper@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH] Add serial number support for virtio_blk
Date: Mon, 22 Jun 2009 13:46:14 -0500	[thread overview]
Message-ID: <4A3FD176.4010600@codemonkey.ws> (raw)
In-Reply-To: <4A3FCCEB.1080603@redhat.com>

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

  reply	other threads:[~2009-06-22 18:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-22 18:26 [Qemu-devel] [PATCH] Add serial number support for virtio_blk john cooper
2009-06-22 18:46 ` Anthony Liguori [this message]
2009-06-23 12:42   ` [Qemu-devel] " john cooper
2009-06-22 19:05 ` Anthony Liguori
2009-06-22 19:30   ` Gleb Natapov
2009-06-22 20:28     ` Anthony Liguori
2009-06-22 20:38       ` Gleb Natapov
2009-06-22 20:42         ` Daniel P. Berrange
2009-06-23  8:22           ` Gleb Natapov
2009-06-23 12:44   ` john cooper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A3FD176.4010600@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=john.cooper@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.