qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Corey Bryant <coreyb@linux.vnet.ibm.com>
To: Eric Blake <eblake@redhat.com>
Cc: kwolf@redhat.com, aliguori@us.ibm.com,
	stefanha@linux.vnet.ibm.com, libvir-list@redhat.com,
	qemu-devel@nongnu.org, lcapitulino@redhat.com,
	pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH v9 2/7] qapi: Introduce add-fd, remove-fd, query-fdsets
Date: Mon, 13 Aug 2012 09:44:05 -0400	[thread overview]
Message-ID: <502904A5.7060807@linux.vnet.ibm.com> (raw)
In-Reply-To: <50266938.7000003@redhat.com>

I'll send a new version shortly with these updates.

-- 
Regards,
Corey

On 08/11/2012 10:16 AM, Eric Blake wrote:
> On 08/11/2012 07:14 AM, Corey Bryant wrote:
>> This patch adds support that enables passing of file descriptors
>> to the QEMU monitor where they will be stored in specified file
>> descriptor sets.
>>
>
>>
>> v9:
>>   -Use fdset-id rather than fdset_id. (eblake@redhat.com)
>>   -Update example for query-fdsets. (eblake@redhat.com)
>>   -Close fd immediately on remove-fd.
>>    (kwolf@redhat.com, eblake@redhat.com)
>>   -Drop fdset refcount, and check dup_fds instead (in a later patch).
>>    (eblake@redhat.com)
>>   -Move mon_refcount code to a later patch. (kwolf@redhat.com)
>>
>
>> +AddfdInfo *qmp_add_fd(bool has_fdset_id, int64_t fdset_id, bool has_opaque,
>> +                      const char *opaque, Error **errp)
>> +{
>> +    int fd;
>> +    Monitor *mon = cur_mon;
>> +    MonFdset *mon_fdset;
>> +    MonFdsetFd *mon_fdset_fd;
>> +    AddfdInfo *fdinfo;
>> +
>> +    fd = qemu_chr_fe_get_msgfd(mon->chr);
>> +    if (fd == -1) {
>> +        error_set(errp, QERR_FD_NOT_SUPPLIED);
>> +        goto error;
>> +    }
>> +
>> +    if (has_fdset_id) {
>> +        QLIST_FOREACH(mon_fdset, &mon_fdsets, next) {
>> +            if (mon_fdset->id == fdset_id) {
>> +                break;
>> +            }
>> +        }
>> +        if (mon_fdset == NULL) {
>> +            error_set(errp, QERR_INVALID_PARAMETER_VALUE, "fdset-id",
>> +                      "an existing fdset-id or no fdset-id");
>
> The 'no fdset-id' portion of this error message doesn't make sense - it
> can only be reached if has_fdset_id was true.
>
>> +
>> +void qmp_remove_fd(int64_t fdset_id, bool has_fd, int64_t fd, Error **errp)
>> +{
>> +    MonFdset *mon_fdset;
>> +    MonFdsetFd *mon_fdset_fd;
>> +    char fd_str[60];
>> +
>> +    QLIST_FOREACH(mon_fdset, &mon_fdsets, next) {
> ...
>
>> +    }
>> +
>> +error:
>> +    snprintf(fd_str, sizeof(fd_str),
>> +             "fdset-id:%" PRId64 ", fd:%" PRId64, fdset_id, fd);
>
> Oops - fd is uninitialized if has_fd is false and the outer loop failed
> to find fdset_id.  You need two separate error messages here, based on
> whether fd was provided.
>
>> +-> { "execute": "query-fdsets" }
>> +<- { "return": [
>> +       {
>> +         "fds": [
>> +           {
>> +             "fd": 30,
>> +             "opaque": "rdonly:/path/to/file"
>> +           },
>> +           {
>> +             "fd": 24,
>> +             "opaque": "rdwr:/path/to/file"
>> +           }
>> +         ],
>> +         "fdset-id": 1
>> +       },
>> +       {
>> +         "fds": [
>> +           {
>> +             "fd": 28
>> +           },
>> +           {
>> +             "fd": 29
>> +           }
>> +         ],
>> +         "fdset-id": 0
>> +       },
>
> No trailing comma here.
>

  reply	other threads:[~2012-08-13 13:44 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-11 13:14 [Qemu-devel] [PATCH v9 0/7] file descriptor passing using fd sets Corey Bryant
2012-08-11 13:14 ` [Qemu-devel] [PATCH v9 1/7] qemu-char: Add MSG_CMSG_CLOEXEC flag to recvmsg Corey Bryant
2012-08-11 13:14 ` [Qemu-devel] [PATCH v9 2/7] qapi: Introduce add-fd, remove-fd, query-fdsets Corey Bryant
2012-08-11 14:16   ` Eric Blake
2012-08-13 13:44     ` Corey Bryant [this message]
2012-08-13 13:44     ` Corey Bryant
2012-08-11 13:14 ` [Qemu-devel] [PATCH v9 3/7] block: Prevent detection of /dev/fdset/ as floppy Corey Bryant
2012-08-11 13:14 ` [Qemu-devel] [PATCH v9 4/7] block: Convert open calls to qemu_open Corey Bryant
2012-08-11 13:14 ` [Qemu-devel] [PATCH v9 5/7] block: Convert close calls to qemu_close Corey Bryant
2012-08-11 13:22   ` Blue Swirl
2012-08-13 13:43     ` Corey Bryant
2012-08-11 13:14 ` [Qemu-devel] [PATCH v9 6/7] block: Enable qemu_open/close to work with fd sets Corey Bryant
2012-08-11 14:28   ` Eric Blake
2012-08-13 13:44     ` Corey Bryant
2012-08-13 16:16       ` Eric Blake
2012-08-13 16:33         ` Corey Bryant
2012-08-13 17:13           ` Eric Blake
2012-08-13 17:32             ` Corey Bryant
2012-08-11 13:14 ` [Qemu-devel] [PATCH v9 7/7] monitor: Clean up fd sets on monitor disconnect Corey Bryant

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=502904A5.7060807@linux.vnet.ibm.com \
    --to=coreyb@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=libvir-list@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@linux.vnet.ibm.com \
    /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).