Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JBZrr-0004ig-Ac for qemu-devel@nongnu.org; Sun, 06 Jan 2008 13:05:03 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JBZrp-0004i7-K7 for qemu-devel@nongnu.org; Sun, 06 Jan 2008 13:05:01 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JBZrp-0004hv-9X for qemu-devel@nongnu.org; Sun, 06 Jan 2008 13:05:01 -0500 Received: from ecfrec.frec.bull.fr ([129.183.4.8]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JBZro-00005r-PD for qemu-devel@nongnu.org; Sun, 06 Jan 2008 13:05:01 -0500 Received: from localhost (localhost [127.0.0.1]) by ecfrec.frec.bull.fr (Postfix) with ESMTP id 1973E19DE9B for ; Sun, 6 Jan 2008 19:04:32 +0100 (CET) Received: from ecfrec.frec.bull.fr ([127.0.0.1]) by localhost (ecfrec.frec.bull.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 26921-08 for ; Sun, 6 Jan 2008 19:04:28 +0100 (CET) Received: from ecn002.frec.bull.fr (ecn002.frec.bull.fr [129.183.4.6]) by ecfrec.frec.bull.fr (Postfix) with ESMTP id 850D419DE94 for ; Sun, 6 Jan 2008 19:04:28 +0100 (CET) Message-Id: From: Laurent Vivier Date: Sun, 06 Jan 2008 19:04:48 +0100 Subject: [Qemu-devel] [PATCH] SCSI passthrough: DVD support Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Laurent.Vivier@bull.net This patch allows to use SCSI passthrough to read movies from DVD. It has been tested with PowerDVD and XP. It also introduces some comments in block-raw-posix.c to explain behavior of negative offset and negative nb_sectors. It restores original value of aio_num and aio_threads. Laurent --- block-raw-posix.c | 7 +++++-- hw/scsi-generic.c | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) Index: qemu/hw/scsi-generic.c =================================================================== --- qemu.orig/hw/scsi-generic.c 2008-01-06 18:43:44.000000000 +0100 +++ qemu/hw/scsi-generic.c 2008-01-06 18:55:46.000000000 +0100 @@ -44,9 +44,12 @@ do { fprintf(stderr, "scsi-generic: " fm #include #include +#define BLANK 0xa1 +#define SEND_KEY 0xa3 +#define REPORT_KEY 0xa4 #define LOAD_UNLOAD 0xa6 +#define READ_DVD_STRUCTURE 0xad #define SET_CD_SPEED 0xbb -#define BLANK 0xa1 #define SCSI_CMD_BUF_SIZE 16 #define SCSI_SENSE_BUF_SIZE 32 @@ -166,7 +169,7 @@ static void scsi_command_complete(void * sense = s->sensebuf[2] & 0x0f; } - DPRINTF("Command complete 0x%p tag=0x%x sense=%d\n", r, r->tag, sense); + DPRINTF("Command complete %p tag=0x%x sense=%d\n", r, r->tag, sense); tag = r->tag; scsi_remove_request(r); s->completion(s->opaque, SCSI_REASON_DONE, tag, sense); @@ -427,6 +430,12 @@ static int scsi_length(uint8_t *cmd, int case READ_12: *len *= blocksize; break; + case READ_DVD_STRUCTURE: + case SEND_KEY: + case REPORT_KEY: + *len &= 0xffff; + break; + } return 0; } @@ -464,6 +473,7 @@ static int is_write(int command) case MEDIUM_SCAN: case SEND_VOLUME_TAG: case WRITE_LONG_2: + case SEND_KEY: return 1; } return 0; Index: qemu/block-raw-posix.c =================================================================== --- qemu.orig/block-raw-posix.c 2008-01-06 18:43:44.000000000 +0100 +++ qemu/block-raw-posix.c 2008-01-06 18:45:38.000000000 +0100 @@ -151,6 +151,8 @@ static int raw_pread(BlockDriverState *b if (ret < 0) return ret; + /* if offset < 0, we don't make lseek() */ + if (offset >= 0 && lseek(s->fd, offset, SEEK_SET) == (off_t)-1) { ++(s->lseek_err_cnt); if(s->lseek_err_cnt <= 10) { @@ -276,8 +278,8 @@ void qemu_aio_init(void) seems to fix the problem. */ struct aioinit ai; memset(&ai, 0, sizeof(ai)); - ai.aio_threads = 16; - ai.aio_num = 16; + ai.aio_threads = 1; + ai.aio_num = 1; ai.aio_idle_time = 365 * 100000; aio_init(&ai); } @@ -387,6 +389,7 @@ static RawAIOCB *raw_aio_setup(BlockDriv acb->aiocb.aio_sigevent.sigev_signo = aio_sig_num; acb->aiocb.aio_sigevent.sigev_notify = SIGEV_SIGNAL; acb->aiocb.aio_buf = buf; + /* if nb_sectors < 0, -nb_sectors is a number of bytes */ if (nb_sectors < 0) acb->aiocb.aio_nbytes = -nb_sectors; else