From nobody Mon Dec 15 03:26:39 2025 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1510836556393374.8459456821239; Thu, 16 Nov 2017 04:49:16 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0E43DFC7C0; Thu, 16 Nov 2017 12:49:15 +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 D9C605C888; Thu, 16 Nov 2017 12:49:14 +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 82C263D385; Thu, 16 Nov 2017 12:49:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vAGCmaVN004453 for ; Thu, 16 Nov 2017 07:48:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 76F9E176D3; Thu, 16 Nov 2017 12:48:36 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id C973D2C7CE; Thu, 16 Nov 2017 12:48:35 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 16 Nov 2017 13:48:00 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 07/11] qemu: domain: Reject shared disk access if backing format does not support it 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: , MIME-Version: 1.0 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 16 Nov 2017 12:49:15 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Certain disk format drivers in qemu don't allow concurrent acces at the level of the format driver since it would corrupt the metadata. Reject shared access for a disk if the format does not support it. Currently only RAW format supports it since it does not have any metadata. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1511480 --- src/qemu/qemu_domain.c | 19 +++++++++++++++ .../qemuxml2argv-disk-drive-shared-qcow.xml | 28 ++++++++++++++++++= ++++ .../qemuxml2argv-disk-drive-shared.args | 2 +- .../qemuxml2argv-disk-drive-shared.xml | 2 +- tests/qemuxml2argvtest.c | 1 + 5 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-q= cow.xml diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 29fdb49d1..fdbe6a4e3 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -25,6 +25,7 @@ #include "qemu_domain.h" #include "qemu_alias.h" +#include "qemu_block.h" #include "qemu_cgroup.h" #include "qemu_command.h" #include "qemu_process.h" @@ -3724,6 +3725,21 @@ qemuDomainDeviceDefValidateVideo(const virDomainVide= oDef *video) } +static int +qemuDomainDeviceDefValidateDisk(const virDomainDiskDef *disk) +{ + if (disk->src->shared && !disk->src->readonly && + !qemuBlockStorageSourceSupportsConcurrentAccess(disk->src)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("shared access for disk '%s' requires use of " + "supported storage format"), disk->dst); + return -1; + } + + return 0; +} + + static int qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, const virDomainDef *def, @@ -3765,6 +3781,9 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef = *dev, break; case VIR_DOMAIN_DEVICE_DISK: + ret =3D qemuDomainDeviceDefValidateDisk(dev->data.disk); + break; + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_INPUT: diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-qcow.xml= b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-qcow.xml new file mode 100644 index 000000000..ca88a944b --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-qcow.xml @@ -0,0 +1,28 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + +
+ + + + + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.args b/t= ests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.args index 502157bf8..326fde1b3 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.args @@ -19,7 +19,7 @@ server,nowait \ -no-acpi \ -boot c \ -usb \ --drive file=3D/dev/HostVG/QEMUGuest1,format=3Dqcow2,if=3Dnone,id=3Ddrive-i= de0-0-0,\ +-drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0,\ serial=3DXYZXYZXYZYXXYZYZYXYZY,cache=3Dnone \ -device ide-drive,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-= 0 \ -drive file=3D/dev/HostVG/QEMUGuest2,format=3Draw,if=3Dnone,media=3Dcdrom,\ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.xml b/te= sts/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.xml index 9f7472378..677c2b0b7 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.xml @@ -15,7 +15,7 @@ /usr/bin/qemu-system-i686 - + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 1bedc6874..bfced6dda 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -908,6 +908,7 @@ mymain(void) QEMU_CAPS_DRIVE_BOOT); DO_TEST("disk-drive-shared", QEMU_CAPS_DRIVE_SERIAL); + DO_TEST_PARSE_ERROR("disk-drive-shared-qcow", NONE); DO_TEST("disk-drive-error-policy-stop", QEMU_CAPS_MONITOR_JSON); DO_TEST("disk-drive-error-policy-enospace", --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list