From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:60286) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrY80-0004R2-0t for qemu-devel@nongnu.org; Thu, 11 Aug 2011 12:29:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QrY7v-0005ui-JU for qemu-devel@nongnu.org; Thu, 11 Aug 2011 12:29:03 -0400 Received: from e2.ny.us.ibm.com ([32.97.182.142]:50996) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrY7v-0005uT-Gq for qemu-devel@nongnu.org; Thu, 11 Aug 2011 12:28:59 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e2.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p7BG7MEo004797 for ; Thu, 11 Aug 2011 12:07:22 -0400 Received: from d03av05.boulder.ibm.com (d03av05.boulder.ibm.com [9.17.195.85]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p7BGSvi3135964 for ; Thu, 11 Aug 2011 12:28:57 -0400 Received: from d03av05.boulder.ibm.com (loopback [127.0.0.1]) by d03av05.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p7BGSvHR019814 for ; Thu, 11 Aug 2011 10:28:57 -0600 Message-ID: <4E440348.7050508@linux.vnet.ibm.com> Date: Thu, 11 Aug 2011 12:28:56 -0400 From: Corey Bryant MIME-Version: 1.0 References: <1311684710-27074-1-git-send-email-coreyb@linux.vnet.ibm.com> In-Reply-To: <1311684710-27074-1-git-send-email-coreyb@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3] Add support for fd: protocol List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: libvir-list@redhat.com, aliguori@us.ibm.com, qemu-devel@nongnu.org, tchicks@us.ibm.com On 07/26/2011 08:51 AM, Corey Bryant wrote: > +static int raw_open_fd(BlockDriverState *bs, const char *filename, int flags) > +{ > + BDRVRawState *s = bs->opaque; > + const char *fd_str; > + int fd; > + > + /* extract the file descriptor - fail if it's not fd: */ > + if (!strstart(filename, "fd:",&fd_str)) { > + return -EINVAL; > + } > + > + if (!qemu_isdigit(fd_str[0])) { > + /* get fd from monitor */ > + fd = qemu_get_fd(fd_str); > + if (fd == -1) { > + return -EBADF; > + } > + } else { > + char *endptr = NULL; > + > + fd = strtol(fd_str,&endptr, 10); > + if (*endptr || (fd == 0&& fd_str == endptr)) { > + return -EBADF; > + } > + } > + > + s->fd = fd; > + s->type = FTYPE_FILE; > + > + return raw_open_common(bs, filename, flags, 0); > +} > + > +static BlockDriver bdrv_file_fd = { > + .format_name = "file", > + .protocol_name = "fd", > + .instance_size = sizeof(BDRVRawState), > + .bdrv_probe = NULL, /* no probe for protocols */ > + .bdrv_file_open = raw_open_fd, > + .bdrv_read = raw_read, > + .bdrv_write = raw_write, > + .bdrv_close = raw_close, > + .bdrv_flush = raw_flush, > + .bdrv_discard = raw_discard, > + > + .bdrv_aio_readv = raw_aio_readv, > + .bdrv_aio_writev = raw_aio_writev, > + .bdrv_aio_flush = raw_aio_flush, > + > + .bdrv_truncate = raw_truncate, > + .bdrv_getlength = raw_getlength, > + > + .create_options = raw_create_options, > +}; > + I'm a bit unsure of how to support CD-ROM with the fd: protocol. I don't think use of bdrv_file_fd is an option. For example, while raw_open_fd may work, there is no eject support. Another approach is to have 2 BlockDriver structs that support the fd protocol. For example, creating a new BlockDriver struct that mirrors bdrv_host_cdrom. So you would have bdrv_host_cdrom_fd with a corresponding cdrom_open_fd function. But that doesn't appear possible as it appears that the protocol must be unique among all BlockDriver structs. Do we need to introduce a similar protocol (maybe "cdfd") to support passing of CD-ROM file descriptors?