qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v4 6/7] qmp: add pmemload command


From: Simon Ruderich
Subject: Re: [Qemu-devel] [PATCH v4 6/7] qmp: add pmemload command
Date: Fri, 17 Aug 2018 09:50:29 +0200
User-agent: Mutt/1.10.1 (2018-07-13)

On Thu, Aug 16, 2018 at 03:01:31PM -0500, Eric Blake wrote:
>> +    }
>> +    if (!has_size) {
>> +        struct stat s;
>> +        if (fstat(fd, &s)) {
>> +            error_setg_errno(errp, errno, "could not fstat fd to get size");
>> +            goto exit;
>> +        }
>> +        size = s.st_size;
>> +    }
>
> This works for regular files, but not for block devices.
>
> Do we have a helper function for easily determining the size of an arbitrary
> fd (whether file or block device)?  If not, should we?  As there are
> multiple spots in the code that grab this sort of information.

I found raw_getlength() in block/file-posix.c, but its static and
it takes a BlockDriverState* as argument. For most systems it
could be extracted without too much trouble, but some (e.g
__sun__ and BSD) are quite entangled with BlockDriverState code.

> Otherwise looks okay to me.

Should I check for S_ISCHR() and S_ISBLK() and abort with an
error? I don't think it's a common use case for pmemload anyway.

Regards
Simon
-- 
+ privacy is necessary
+ using gnupg http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9

Attachment: signature.asc
Description: PGP signature


reply via email to

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