From nobody Fri Apr 26 15:15:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1549040474290536.0516659522376; Fri, 1 Feb 2019 09:01:14 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7DC4D81DE1; Fri, 1 Feb 2019 17:01:11 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 65D9060C66; Fri, 1 Feb 2019 17:01:10 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 210563F7D5; Fri, 1 Feb 2019 17:01:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x11H0iFI027664 for ; Fri, 1 Feb 2019 12:00:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id 647D11048101; Fri, 1 Feb 2019 17:00:44 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id B6D301042A62; Fri, 1 Feb 2019 17:00:39 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 1 Feb 2019 18:00:37 +0100 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH] qemu: command: Don't skip 'readonly' and throttling info for empty drive X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 01 Feb 2019 17:01:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" In commit f80eae8c2ae I was too agresive in removing properties of -drive for empty drives. It turns out that qemu actually persists the state of 'readonly' and the throttling information even for the empty drive. Removing 'readonly' thus made qemu open any subsequent images added via the 'change' command as RW which was forbidden by selinux thanks to the restrictive sVirt label for readonly media. Fix this by formating the property again and bump the tests and leave a note detailing why the rest of the properties needs to be skipped. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_command.c | 18 +++++++++++++----- tests/qemuxml2argvdata/disk-cdrom.args | 4 ++-- .../disk-cdrom.x86_64-2.12.0.args | 4 ++-- .../disk-cdrom.x86_64-latest.args | 4 ++-- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index a59583fb75..6d3aa69569 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1764,10 +1764,18 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, } } + if (disk->src->readonly) + virBufferAddLit(&opt, ",readonly=3Don"); + + /* qemu rejects some parameters for an empty -drive, so we need to skip + * them in that case: + * cache: modifies properties of the format driver which is not present + * copy_on_read: really only works for floppies + * discard: modifies properties of format driver + * detect_zeroes: works but really depends on discard so it's useless + * iomode: setting it to 'native' requires a specific cache mode + */ if (!virStorageSourceIsEmpty(disk->src)) { - if (disk->src->readonly) - virBufferAddLit(&opt, ",readonly=3Don"); - if (disk->cachemode) { virBufferAsprintf(&opt, ",cache=3D%s", qemuDiskCacheV2TypeToString(disk->cachemode)= ); @@ -1792,10 +1800,10 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, virBufferAsprintf(&opt, ",aio=3D%s", virDomainDiskIoTypeToString(disk->iomode)); } - - qemuBuildDiskThrottling(disk, &opt); } + qemuBuildDiskThrottling(disk, &opt); + if (virBufferCheckError(&opt) < 0) goto error; diff --git a/tests/qemuxml2argvdata/disk-cdrom.args b/tests/qemuxml2argvdat= a/disk-cdrom.args index a9f60aa477..4823ae82de 100644 --- a/tests/qemuxml2argvdata/disk-cdrom.args +++ b/tests/qemuxml2argvdata/disk-cdrom.args @@ -27,7 +27,7 @@ bootindex=3D1 \ -drive file=3D/root/boot.iso,format=3Draw,if=3Dnone,id=3Ddrive-ide0-0-1,me= dia=3Dcdrom,\ readonly=3Don \ -device ide-drive,bus=3Dide.0,unit=3D1,drive=3Ddrive-ide0-0-1,id=3Dide0-0-= 1 \ --drive if=3Dnone,id=3Ddrive-ide0-1-0,media=3Dcdrom \ +-drive if=3Dnone,id=3Ddrive-ide0-1-0,media=3Dcdrom,readonly=3Don \ -device ide-drive,bus=3Dide.1,unit=3D0,drive=3Ddrive-ide0-1-0,id=3Dide0-1-= 0 \ --drive if=3Dnone,id=3Ddrive-ide0-1-1,media=3Dcdrom \ +-drive if=3Dnone,id=3Ddrive-ide0-1-1,media=3Dcdrom,readonly=3Don \ -device ide-drive,bus=3Dide.1,unit=3D1,drive=3Ddrive-ide0-1-1,id=3Dide0-1-1 diff --git a/tests/qemuxml2argvdata/disk-cdrom.x86_64-2.12.0.args b/tests/q= emuxml2argvdata/disk-cdrom.x86_64-2.12.0.args index a39d920f67..2fe84177b8 100644 --- a/tests/qemuxml2argvdata/disk-cdrom.x86_64-2.12.0.args +++ b/tests/qemuxml2argvdata/disk-cdrom.x86_64-2.12.0.args @@ -28,10 +28,10 @@ file=3D/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ -device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ -drive file=3D/root/boot.iso,format=3Draw,if=3Dnone,id=3Ddrive-ide0-0-1,re= adonly=3Don \ -device ide-cd,bus=3Dide.0,unit=3D1,drive=3Ddrive-ide0-0-1,id=3Dide0-0-1 \ --drive if=3Dnone,id=3Ddrive-ide0-1-0 \ +-drive if=3Dnone,id=3Ddrive-ide0-1-0,readonly=3Don \ -device ide-cd,bus=3Dide.1,unit=3D0,drive=3Ddrive-ide0-1-0,id=3Dide0-1-0,\ write-cache=3Don \ --drive if=3Dnone,id=3Ddrive-ide0-1-1 \ +-drive if=3Dnone,id=3Ddrive-ide0-1-1,readonly=3Don \ -device ide-cd,bus=3Dide.1,unit=3D1,drive=3Ddrive-ide0-1-1,id=3Dide0-1-1 \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ resourcecontrol=3Ddeny \ diff --git a/tests/qemuxml2argvdata/disk-cdrom.x86_64-latest.args b/tests/q= emuxml2argvdata/disk-cdrom.x86_64-latest.args index 029ae23dfa..9b9451f435 100644 --- a/tests/qemuxml2argvdata/disk-cdrom.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-cdrom.x86_64-latest.args @@ -28,10 +28,10 @@ file=3D/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ -device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ -drive file=3D/root/boot.iso,format=3Draw,if=3Dnone,id=3Ddrive-ide0-0-1,re= adonly=3Don \ -device ide-cd,bus=3Dide.0,unit=3D1,drive=3Ddrive-ide0-0-1,id=3Dide0-0-1 \ --drive if=3Dnone,id=3Ddrive-ide0-1-0 \ +-drive if=3Dnone,id=3Ddrive-ide0-1-0,readonly=3Don \ -device ide-cd,bus=3Dide.1,unit=3D0,drive=3Ddrive-ide0-1-0,id=3Dide0-1-0,\ write-cache=3Don \ --drive if=3Dnone,id=3Ddrive-ide0-1-1 \ +-drive if=3Dnone,id=3Ddrive-ide0-1-1,readonly=3Don \ -device ide-cd,bus=3Dide.1,unit=3D1,drive=3Ddrive-ide0-1-1,id=3Dide0-1-1 \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ resourcecontrol=3Ddeny \ --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list