|
|
404507 |
From 378887595f3cbb937f6c3e88ed3828e5f6698e33 Mon Sep 17 00:00:00 2001
|
|
|
404507 |
Message-Id: <378887595f3cbb937f6c3e88ed3828e5f6698e33@dist-git>
|
|
|
404507 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
404507 |
Date: Thu, 23 Nov 2017 19:02:23 +0100
|
|
|
404507 |
Subject: [PATCH] qemu: command: Mark <shared/> disks as such in qemu
|
|
|
404507 |
|
|
|
404507 |
Qemu has now an internal mechanism for locking images to fix specific
|
|
|
404507 |
cases of disk corruption. This requires libvirt to mark the image as
|
|
|
404507 |
shared so that qemu lifts certain restrictions.
|
|
|
404507 |
|
|
|
404507 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1378242
|
|
|
404507 |
(cherry picked from commit 28907b0043fbf71085a798372ab9c816ba043b93)
|
|
|
404507 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
404507 |
---
|
|
|
404507 |
src/qemu/qemu_command.c | 4 +++
|
|
|
404507 |
.../qemuxml2argv-disk-drive-shared-locking.args | 32 +++++++++++++++++
|
|
|
404507 |
.../qemuxml2argv-disk-drive-shared-locking.xml | 42 ++++++++++++++++++++++
|
|
|
404507 |
tests/qemuxml2argvtest.c | 2 ++
|
|
|
404507 |
4 files changed, 80 insertions(+)
|
|
|
404507 |
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-locking.args
|
|
|
404507 |
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-locking.xml
|
|
|
404507 |
|
|
|
404507 |
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
|
|
404507 |
index dfacff4b12..fc7f54e81e 100644
|
|
|
404507 |
--- a/src/qemu/qemu_command.c
|
|
|
404507 |
+++ b/src/qemu/qemu_command.c
|
|
|
404507 |
@@ -2182,6 +2182,10 @@ qemuBuildDriveDevStr(const virDomainDef *def,
|
|
|
404507 |
goto error;
|
|
|
404507 |
}
|
|
|
404507 |
|
|
|
404507 |
+ if (disk->src->shared &&
|
|
|
404507 |
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_DISK_SHARE_RW))
|
|
|
404507 |
+ virBufferAddLit(&opt, ",share-rw=on");
|
|
|
404507 |
+
|
|
|
404507 |
if (!(drivealias = qemuAliasFromDisk(disk)))
|
|
|
404507 |
goto error;
|
|
|
404507 |
virBufferAsprintf(&opt, ",drive=%s,id=%s", drivealias, disk->info.alias);
|
|
|
404507 |
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-locking.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-locking.args
|
|
|
404507 |
new file mode 100644
|
|
|
404507 |
index 0000000000..cdf17f26d1
|
|
|
404507 |
--- /dev/null
|
|
|
404507 |
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-locking.args
|
|
|
404507 |
@@ -0,0 +1,32 @@
|
|
|
404507 |
+LC_ALL=C \
|
|
|
404507 |
+PATH=/bin \
|
|
|
404507 |
+HOME=/home/test \
|
|
|
404507 |
+USER=test \
|
|
|
404507 |
+LOGNAME=test \
|
|
|
404507 |
+QEMU_AUDIO_DRV=none \
|
|
|
404507 |
+/usr/bin/qemu-system-i686 \
|
|
|
404507 |
+-name QEMUGuest1 \
|
|
|
404507 |
+-S \
|
|
|
404507 |
+-M pc \
|
|
|
404507 |
+-m 214 \
|
|
|
404507 |
+-smp 1,sockets=1,cores=1,threads=1 \
|
|
|
404507 |
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
|
|
|
404507 |
+-nographic \
|
|
|
404507 |
+-nodefaults \
|
|
|
404507 |
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
|
|
|
404507 |
+server,nowait \
|
|
|
404507 |
+-mon chardev=charmonitor,id=monitor,mode=readline \
|
|
|
404507 |
+-no-acpi \
|
|
|
404507 |
+-boot c \
|
|
|
404507 |
+-device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x3 \
|
|
|
404507 |
+-usb \
|
|
|
404507 |
+-drive file=/dev/ide,format=raw,if=none,id=drive-ide0-0-0,cache=none \
|
|
|
404507 |
+-device ide-drive,bus=ide.0,unit=0,share-rw=on,drive=drive-ide0-0-0,\
|
|
|
404507 |
+id=ide0-0-0 \
|
|
|
404507 |
+-drive file=/dev/scsi,format=raw,if=none,id=drive-scsi0-0-0-0,cache=none \
|
|
|
404507 |
+-device scsi-disk,bus=scsi0.0,channel=0,scsi-id=0,lun=0,share-rw=on,\
|
|
|
404507 |
+drive=drive-scsi0-0-0-0,id=scsi0-0-0-0 \
|
|
|
404507 |
+-drive file=/dev/virtio,format=raw,if=none,id=drive-virtio-disk0,cache=none \
|
|
|
404507 |
+-device virtio-blk-pci,bus=pci.0,addr=0x4,share-rw=on,drive=drive-virtio-disk0,\
|
|
|
404507 |
+id=virtio-disk0 \
|
|
|
404507 |
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
|
|
|
404507 |
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-locking.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-locking.xml
|
|
|
404507 |
new file mode 100644
|
|
|
404507 |
index 0000000000..dd48857a30
|
|
|
404507 |
--- /dev/null
|
|
|
404507 |
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-locking.xml
|
|
|
404507 |
@@ -0,0 +1,42 @@
|
|
|
404507 |
+<domain type='qemu'>
|
|
|
404507 |
+ <name>QEMUGuest1</name>
|
|
|
404507 |
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
|
|
404507 |
+ <memory unit='KiB'>219136</memory>
|
|
|
404507 |
+ <currentMemory unit='KiB'>219136</currentMemory>
|
|
|
404507 |
+ <vcpu placement='static'>1</vcpu>
|
|
|
404507 |
+ <os>
|
|
|
404507 |
+ <type arch='i686' machine='pc'>hvm</type>
|
|
|
404507 |
+ <boot dev='hd'/>
|
|
|
404507 |
+ </os>
|
|
|
404507 |
+ <clock offset='utc'/>
|
|
|
404507 |
+ <on_poweroff>destroy</on_poweroff>
|
|
|
404507 |
+ <on_reboot>restart</on_reboot>
|
|
|
404507 |
+ <on_crash>destroy</on_crash>
|
|
|
404507 |
+ <devices>
|
|
|
404507 |
+ <emulator>/usr/bin/qemu-system-i686</emulator>
|
|
|
404507 |
+ <disk type='block' device='disk'>
|
|
|
404507 |
+ <driver name='qemu' type='raw'/>
|
|
|
404507 |
+ <source dev='/dev/ide'/>
|
|
|
404507 |
+ <target dev='hda' bus='ide'/>
|
|
|
404507 |
+ <shareable/>
|
|
|
404507 |
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
|
|
404507 |
+ </disk>
|
|
|
404507 |
+ <disk type='block' device='disk'>
|
|
|
404507 |
+ <driver name='qemu' type='raw'/>
|
|
|
404507 |
+ <source dev='/dev/scsi'/>
|
|
|
404507 |
+ <target dev='sda' bus='scsi'/>
|
|
|
404507 |
+ <shareable/>
|
|
|
404507 |
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
|
|
404507 |
+ </disk>
|
|
|
404507 |
+ <disk type='block' device='disk'>
|
|
|
404507 |
+ <driver name='qemu' type='raw'/>
|
|
|
404507 |
+ <source dev='/dev/virtio'/>
|
|
|
404507 |
+ <target dev='vda' bus='virtio'/>
|
|
|
404507 |
+ <shareable/>
|
|
|
404507 |
+ </disk>
|
|
|
404507 |
+ <controller type='usb' index='0'/>
|
|
|
404507 |
+ <controller type='ide' index='0'/>
|
|
|
404507 |
+ <controller type='scsi' index='0' model='virtio-scsi'/>
|
|
|
404507 |
+ <memballoon model='virtio'/>
|
|
|
404507 |
+ </devices>
|
|
|
404507 |
+</domain>
|
|
|
404507 |
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
|
|
|
404507 |
index 00110cae19..4e981c9fab 100644
|
|
|
404507 |
--- a/tests/qemuxml2argvtest.c
|
|
|
404507 |
+++ b/tests/qemuxml2argvtest.c
|
|
|
404507 |
@@ -909,6 +909,8 @@ mymain(void)
|
|
|
404507 |
DO_TEST("disk-drive-shared",
|
|
|
404507 |
QEMU_CAPS_DRIVE_SERIAL);
|
|
|
404507 |
DO_TEST_PARSE_ERROR("disk-drive-shared-qcow", NONE);
|
|
|
404507 |
+ DO_TEST("disk-drive-shared-locking",
|
|
|
404507 |
+ QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DISK_SHARE_RW);
|
|
|
404507 |
DO_TEST("disk-drive-error-policy-stop",
|
|
|
404507 |
QEMU_CAPS_MONITOR_JSON);
|
|
|
404507 |
DO_TEST("disk-drive-error-policy-enospace",
|
|
|
404507 |
--
|
|
|
404507 |
2.15.0
|
|
|
404507 |
|