qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [PATCH] Add serial number support for virtio_blk


From: Anthony Liguori
Subject: [Qemu-devel] Re: [PATCH] Add serial number support for virtio_blk
Date: Mon, 22 Jun 2009 13:46:14 -0500
User-agent: Thunderbird 2.0.0.21 (X11/20090320)

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 via email to

[Prev in Thread] Current Thread [Next in Thread]