|
|
edecca |
From 56be87fe948f7534878880cb300f91550361c062 Mon Sep 17 00:00:00 2001
|
|
|
edecca |
Message-Id: <56be87fe948f7534878880cb300f91550361c062@dist-git>
|
|
|
edecca |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
edecca |
Date: Mon, 4 Feb 2019 12:53:38 +0100
|
|
|
edecca |
Subject: [PATCH] qemu: command: Don't skip 'readonly' and throttling info for
|
|
|
edecca |
empty drive
|
|
|
edecca |
MIME-Version: 1.0
|
|
|
edecca |
Content-Type: text/plain; charset=UTF-8
|
|
|
edecca |
Content-Transfer-Encoding: 8bit
|
|
|
edecca |
|
|
|
edecca |
In commit f80eae8c2ae I was too agresive in removing properties of
|
|
|
edecca |
-drive for empty drives. It turns out that qemu actually persists the
|
|
|
edecca |
state of 'readonly' and the throttling information even for the empty
|
|
|
edecca |
drive.
|
|
|
edecca |
|
|
|
edecca |
Removing 'readonly' thus made qemu open any subsequent images added via
|
|
|
edecca |
the 'change' command as RW which was forbidden by selinux thanks to the
|
|
|
edecca |
restrictive sVirt label for readonly media.
|
|
|
edecca |
|
|
|
edecca |
Fix this by formating the property again and bump the tests and leave a
|
|
|
edecca |
note detailing why the rest of the properties needs to be skipped.
|
|
|
edecca |
|
|
|
edecca |
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
edecca |
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
edecca |
(cherry picked from commit 6db0d033839807aec885e10b5a45748da016e261)
|
|
|
edecca |
|
|
|
edecca |
https://bugzilla.redhat.com/show_bug.cgi?id=1670337
|
|
|
edecca |
|
|
|
edecca |
Conflicts:
|
|
|
edecca |
src/qemu/qemu_command.c
|
|
|
edecca |
tests/qemuxml2argvdata/disk-cdrom.args
|
|
|
edecca |
- context: bootindex not yet assumed, 'boot=on' code still
|
|
|
edecca |
present
|
|
|
edecca |
tests/qemuxml2argvdata/disk-cdrom.x86_64-2.12.0.args
|
|
|
edecca |
tests/qemuxml2argvdata/disk-cdrom.x86_64-latest.args
|
|
|
edecca |
- missing refactor to capability file based tests
|
|
|
edecca |
|
|
|
edecca |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
edecca |
---
|
|
|
edecca |
src/qemu/qemu_command.c | 18 +++++++++++++-----
|
|
|
edecca |
tests/qemuxml2argvdata/disk-cdrom-empty.args | 2 +-
|
|
|
edecca |
tests/qemuxml2argvdata/disk-cdrom.args | 2 +-
|
|
|
edecca |
3 files changed, 15 insertions(+), 7 deletions(-)
|
|
|
edecca |
|
|
|
edecca |
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
|
|
edecca |
index e153c011f6..66abd3fe86 100644
|
|
|
edecca |
--- a/src/qemu/qemu_command.c
|
|
|
edecca |
+++ b/src/qemu/qemu_command.c
|
|
|
edecca |
@@ -1695,10 +1695,18 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
|
|
|
edecca |
disk->bus != VIR_DOMAIN_DISK_BUS_IDE)
|
|
|
edecca |
virBufferAddLit(&opt, ",boot=on");
|
|
|
edecca |
|
|
|
edecca |
- if (!virStorageSourceIsEmpty(disk->src)) {
|
|
|
edecca |
- if (disk->src->readonly)
|
|
|
edecca |
- virBufferAddLit(&opt, ",readonly=on");
|
|
|
edecca |
+ if (disk->src->readonly)
|
|
|
edecca |
+ virBufferAddLit(&opt, ",readonly=on");
|
|
|
edecca |
|
|
|
edecca |
+ /* qemu rejects some parameters for an empty -drive, so we need to skip
|
|
|
edecca |
+ * them in that case:
|
|
|
edecca |
+ * cache: modifies properties of the format driver which is not present
|
|
|
edecca |
+ * copy_on_read: really only works for floppies
|
|
|
edecca |
+ * discard: modifies properties of format driver
|
|
|
edecca |
+ * detect_zeroes: works but really depends on discard so it's useless
|
|
|
edecca |
+ * iomode: setting it to 'native' requires a specific cache mode
|
|
|
edecca |
+ */
|
|
|
edecca |
+ if (!virStorageSourceIsEmpty(disk->src)) {
|
|
|
edecca |
if (disk->cachemode) {
|
|
|
edecca |
virBufferAsprintf(&opt, ",cache=%s",
|
|
|
edecca |
qemuDiskCacheV2TypeToString(disk->cachemode));
|
|
|
edecca |
@@ -1723,10 +1731,10 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
|
|
|
edecca |
virBufferAsprintf(&opt, ",aio=%s",
|
|
|
edecca |
virDomainDiskIoTypeToString(disk->iomode));
|
|
|
edecca |
}
|
|
|
edecca |
-
|
|
|
edecca |
- qemuBuildDiskThrottling(disk, &opt;;
|
|
|
edecca |
}
|
|
|
edecca |
|
|
|
edecca |
+ qemuBuildDiskThrottling(disk, &opt;;
|
|
|
edecca |
+
|
|
|
edecca |
if (virBufferCheckError(&opt) < 0)
|
|
|
edecca |
goto error;
|
|
|
edecca |
|
|
|
edecca |
diff --git a/tests/qemuxml2argvdata/disk-cdrom-empty.args b/tests/qemuxml2argvdata/disk-cdrom-empty.args
|
|
|
edecca |
index b84bdda143..1cbc76ab86 100644
|
|
|
edecca |
--- a/tests/qemuxml2argvdata/disk-cdrom-empty.args
|
|
|
edecca |
+++ b/tests/qemuxml2argvdata/disk-cdrom-empty.args
|
|
|
edecca |
@@ -24,5 +24,5 @@ server,nowait \
|
|
|
edecca |
-usb \
|
|
|
edecca |
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
|
|
|
edecca |
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
|
|
|
edecca |
--drive if=none,id=drive-ide0-1-0,media=cdrom \
|
|
|
edecca |
+-drive if=none,id=drive-ide0-1-0,media=cdrom,readonly=on \
|
|
|
edecca |
-device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0
|
|
|
edecca |
diff --git a/tests/qemuxml2argvdata/disk-cdrom.args b/tests/qemuxml2argvdata/disk-cdrom.args
|
|
|
edecca |
index f519ea5236..973d8e9af1 100644
|
|
|
edecca |
--- a/tests/qemuxml2argvdata/disk-cdrom.args
|
|
|
edecca |
+++ b/tests/qemuxml2argvdata/disk-cdrom.args
|
|
|
edecca |
@@ -27,5 +27,5 @@ server,nowait \
|
|
|
edecca |
-drive file=/root/boot.iso,format=raw,if=none,id=drive-ide0-0-1,media=cdrom,\
|
|
|
edecca |
readonly=on \
|
|
|
edecca |
-device ide-drive,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 \
|
|
|
edecca |
--drive if=none,id=drive-ide0-1-0,media=cdrom \
|
|
|
edecca |
+-drive if=none,id=drive-ide0-1-0,media=cdrom,readonly=on \
|
|
|
edecca |
-device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0
|
|
|
edecca |
--
|
|
|
edecca |
2.20.1
|
|
|
edecca |
|