[libvirt] [PATCH v3] xml: introduce startupPolicy for chardev device

Eric Blake eblake at redhat.com
Thu Aug 15 13:01:23 UTC 2013


On 08/15/2013 03:36 AM, Ján Tomko wrote:

>> +        dev->source.data.file.path = strdup("/dev/null");
>> +
>> +        if (!(dev->source.data.file.path)) {
>> +            virReportOOMError();
>> +            return -1;
>> +        }
>> +
> 
> This can be reduced to:
> if (VIR_STRDUP(dev->source.data.file.path, "/dev/null") < 0)
>     return -1;

That, and 'make syntax-check' should have warned you that use of
strdup() is forbidden.

> 
>> +        if ((fd = open(dev->source.data.file.path,
>> +                       O_CREAT | O_APPEND, S_IRUSR|S_IWUSR)) < 0) {
>> +            virReportSystemError(errno,
>> +                                 _("Unable to pre-create chardev file '%s'"),
>> +                                 dev->source.data.file.path);
>> +            return -1;
>> +        }
>>      }
> 
> I think we can safely assume /dev/null to exist on any system where QEMU runs
> and there's no need to pre-create it.

Correct assumption.  (Even though we don't currently compile qemu
support on mingw, we use gnulib, which guarantees that open("/dev/null")
will do the right thing on mingw even though that is the one platform
likely to not have a /dev/null natively - so you should never need to
O_CREAT /dev/null.  Furthermore, O_CREAT is wrong - /dev/null MUST be a
char device, not a regular file, but if /dev/null is missing, you would
be creating a regular file instead of a char device).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130815/cad1278e/attachment-0001.sig>


More information about the libvir-list mailing list