From: Laszlo Ersek <lersek@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org, pbonzini@redhat.com,
mdroth@linux.vnet.ibm.com, lcapitulino@redhat.com
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 [thread overview]
Message-ID: <51369173.5060808@redhat.com> (raw)
In-Reply-To: <513681CB.9030306@redhat.com>
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
next prev parent reply other threads:[~2013-03-06 0:44 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-04 22:19 [Qemu-devel] [PATCH 0/3] qga/Linux: online/offline/query VCPUs via guest sysfs Laszlo Ersek
2013-03-04 22:19 ` [Qemu-devel] [PATCH 1/3] qga: introduce guest-get-vcpus / guest-set-vcpus with stubs Laszlo Ersek
2013-03-05 21:08 ` Eric Blake
2013-03-05 23:05 ` Laszlo Ersek
2013-03-05 23:12 ` Eric Blake
2013-03-05 23:32 ` Laszlo Ersek
2013-03-06 7:40 ` Andrew Jones
2013-03-06 13:49 ` Eric Blake
2013-03-06 16:37 ` Laszlo Ersek
2013-03-04 22:19 ` [Qemu-devel] [PATCH 2/3] qga: implement qmp_guest_get_vcpus() for Linux with sysfs Laszlo Ersek
2013-03-05 20:03 ` mdroth
2013-03-05 20:22 ` Eric Blake
2013-03-05 20:45 ` mdroth
2013-03-05 21:05 ` Laszlo Ersek
2013-03-05 20:25 ` Eric Blake
2013-03-05 21:34 ` Laszlo Ersek
2013-03-05 22:06 ` mdroth
2013-03-04 22:19 ` [Qemu-devel] [PATCH 3/3] qga: implement qmp_guest_set_vcpus() " Laszlo Ersek
2013-03-05 20:09 ` mdroth
2013-03-05 21:09 ` Laszlo Ersek
2013-03-05 21:19 ` Eric Blake
2013-03-05 23:23 ` Laszlo Ersek
2013-03-05 23:37 ` Eric Blake
2013-03-06 0:44 ` Laszlo Ersek [this message]
2013-03-06 9:57 ` Paolo Bonzini
2013-03-06 13:46 ` Eric Blake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51369173.5060808@redhat.com \
--to=lersek@redhat.com \
--cc=eblake@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).