On 05/21/2012 02:19 PM, Corey Bryant wrote: > With this patch, when QEMU needs to "open" a file, it will first > check to see if a matching filename/fd pair were passed via the > -filefd command line option or the getfd_file monitor command. > If a match is found, QEMU will use the passed fd and will not > attempt to open the file. Otherwise, if a match is not found, > QEMU will attempt to open the file on it's own. > > Signed-off-by: Corey Bryant <coreyb@xxxxxxxxxxxxxxxxxx> > +int file_open(const char *filename, int flags, mode_t mode) > +{ > + int fd; > + > +#ifdef _WIN32 > + return qemu_open(filename, flags, mode); > +#else Would it be any easier to write: #ifndef _WIN32 qemu_get_fd_file() stuff #endif return qemu_open() so that you aren't repeating the return line? > + fd = qemu_get_fd_file(filename, false); > + if (fd != -1) { > + return dup(fd); Why are you dup'ing the fd? That just sounds like a way to leak fds. Remember, the existing 'getfd' monitor command doesn't dup things - it either gets consumed by a successful use of the named fd, or it remains open on failure and the user can close it by calling 'closefd'. Or, if you are intentionally allowing the user to reuse the fd for more than one qemu open instance, you need to document this point. What happens if qemu wants O_WRONLY or O_RDWR access, but the user passed in an fd with only O_RDONLY access? -- Eric Blake eblake@xxxxxxxxxx +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list