qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] Re: [PATCH 1/2] Add 'serial' attribute to virtio-blk device


From: john cooper
Subject: [Qemu-devel] Re: [PATCH 1/2] Add 'serial' attribute to virtio-blk devices
Date: Mon, 21 Jun 2010 23:40:50 -0400
User-agent: Thunderbird 2.0.0.9 (X11/20071115)

Rusty Russell wrote:
> On Tue, 22 Jun 2010 02:13:21 am Ryan Harper wrote:
>> * john cooper <address@hidden> [2010-06-21 01:11]:
>>> Rusty Russell wrote:
>>>>    /* id_str is not necessarily nul-terminated! */
>>>>    buf[VIRTIO_BLK_ID_BYTES] = '\0';
>>>>    return virtblk_get_id(disk, buf);
>>> The /sys file is rendered according to the length
>>> returned from this function and the trailing nul
>>> is not interpreted in this context.  In fact if a
>>> nul is added and included in the byte count of the
>>> string it will appear in the /sys file.
>> Yeah; I like the simplicity; but we do need to know how long the string
>> is so we can return that value. 
> 
> So we're looking at something like:
> 
>       /* id_str is not necessarily nul-terminated! */
>       buf[VIRTIO_BLK_ID_BYTES] = '\0';
>       err = virtblk_get_id(disk, buf);
>       if (!err)
>               return strlen(buf);
>       if (err == -EIO) /* Unsupported?  Make it empty. */     
>               return 0;
>       return err;

In my haste reading your prior mail, I'd glossed over
the fact you were copying direct to the sysfs buf.  So
in retrospect that (and the above) do make sense.

Thanks,

-john

-- 
address@hidden



reply via email to

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