[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 3/3] qga: implement qmp_guest_set_vcpus() for Li
From: |
Laszlo Ersek |
Subject: |
Re: [Qemu-devel] [PATCH 3/3] qga: implement qmp_guest_set_vcpus() for Linux with sysfs |
Date: |
Wed, 06 Mar 2013 01:44:35 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130216 Thunderbird/17.0.3 |
On 03/06/13 00:37, Eric Blake wrote:
> I guess I had in my mind %c instead of %u; still, I can't help but
> wonder if fprintf() and buffering is overkill, compared to just doing
> something like this:
> write(fd, &"01"[vcpu->online], 1);
>
> (okay, I hope you would favor readability over my compact
> representation, but you get the point).
I'd be crucified on qemu-devel if I tried to pull off something like the
above :)
> Oh, and I guess I didn't check
> whether a trailing newline is essential to the kernel interpreting the
> input, so maybe it would have to be more like:
>
> char buf[2] = { "01"[vcpu->online], '\n' };
> write(fd, buf, 2);
The newline is probably not important.
Anyway I'd prefer to avoid direct write()s with nbyte > 1 as I'd have to
handle partial transfers, if for nothing else than principle. (IIRC
avoiding that loop was my main motivation for stdio.)
I guess I'll use open(O_DIRECTORY) + openat("online") + read(..., 1) +
pwrite(..., 1, 0). RHEL-5 seems to support all of these (I can't find
O_SEARCH in the manual there, which is why I'll probably omit it from
open()). If people still complain then I can switch from open(directory)
+ openat("online") to lstat(directory) + open("/.../online").
Thanks
Laszlo
[Qemu-devel] [PATCH 1/3] qga: introduce guest-get-vcpus / guest-set-vcpus with stubs, Laszlo Ersek, 2013/03/04