From 6b41b0b9673873e4caec288c0284aafeecebe68c Mon Sep 17 00:00:00 2001 From: Naphtali Sprei <nsprei@redhat.com> Date: Thu, 15 Apr 2010 11:56:48 -0300 Subject: [PATCH 12/12] read-only: allow read-only CDROM with any interface RH-Author: Naphtali Sprei <nsprei@redhat.com> Message-id: <1271332608-5243-12-git-send-email-nsprei@redhat.com> Patchwork-id: 8659 O-Subject: [RHEL 5.6 kvm PATCH v4 11/11] read-only: allow read-only CDROM with any interface Bugzilla: 510630 RH-Acked-by: Christoph Hellwig <chellwig@redhat.com> RH-Acked-by: Juan Quintela <quintela@redhat.com> RH-Acked-by: Kevin Wolf <kwolf@redhat.com> no upstream commit Signed-off-by: Naphtali Sprei <nsprei@redhat.com> --- qemu/vl.c | 32 +++++++++++++++----------------- 1 files changed, 15 insertions(+), 17 deletions(-) Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- qemu/vl.c | 32 +++++++++++++++----------------- 1 files changed, 15 insertions(+), 17 deletions(-) diff --git a/qemu/vl.c b/qemu/vl.c index 96a581a..db68da9 100644 --- a/qemu/vl.c +++ b/qemu/vl.c @@ -2740,27 +2740,25 @@ int drive_init(struct drive_opt *arg, int snapshot, bdrv_flags |= BDRV_O_CACHE_DEF; ro = 0; - if (get_param_value(buf, sizeof(buf), "readonly", str)) { - if (!strcmp(buf, "off")) { - ro = 0; - } else if (!strcmp(buf, "on")) { - if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY) { - fprintf(stderr, "qemu: readonly flag not supported for drive of this interface\n"); + if (media == MEDIA_CDROM) { + /* mark CDROM as read-only. CDROM is fine for any interface, don't check */ + ro = 1; + } else { + if (get_param_value(buf, sizeof(buf), "readonly", str)) { + if (!strcmp(buf, "off")) { + ro = 0; + } else if (!strcmp(buf, "on")) { + if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY) { + fprintf(stderr, "qemu: readonly flag not supported for drive of this interface\n"); + return -1; + } + ro = 1; + } else { + fprintf(stderr, "qemu: '%s' invalid readonly option (valid values: [on|off] )\n", buf); return -1; } - ro = 1; - } else { - fprintf(stderr, "qemu: '%s' invalid readonly option (valid values: [on|off] )\n", buf); - return -1; } } - /* - * cdrom is read-only. Set it now, after above interface checking - * since readonly attribute not explicitly required, so no error. - */ - if (media == MEDIA_CDROM) { - ro = 1; - } if (!ro) { bdrv_flags |= BDRV_O_RDWR; -- 1.7.0.3