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