From nobody Thu May 15 06:32:07 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 1511348466518215.85352692006165; Wed, 22 Nov 2017 03:01:06 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D565F8553E; Wed, 22 Nov 2017 11:01:04 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AE787614EE; Wed, 22 Nov 2017 11:01:04 +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 73D551800BDF; Wed, 22 Nov 2017 11:01:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vAMAvXeQ013119 for ; Wed, 22 Nov 2017 05:57:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id C5FF75D971; Wed, 22 Nov 2017 10:57:33 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 204B15D970; Wed, 22 Nov 2017 10:57:32 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 22 Nov 2017 11:56:54 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH v2 11/11] qemu: command: Mark disks as such in qemu 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 22 Nov 2017 11:01:05 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Qemu has now an internal mechanism for locking images to fix specific cases of disk corruption. This requires libvirt to mark the image as shared so that qemu lifts certain restrictions. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1378242 --- src/qemu/qemu_command.c | 4 +++ .../qemuxml2argv-disk-drive-shared-locking.args | 32 +++++++++++++++++ .../qemuxml2argv-disk-drive-shared-locking.xml | 42 ++++++++++++++++++= ++++ tests/qemuxml2argvtest.c | 2 ++ 4 files changed, 80 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-l= ocking.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-l= ocking.xml diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 216a4bdfe0..f009b28254 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2126,6 +2126,10 @@ qemuBuildDriveDevStr(const virDomainDef *def, goto error; } + if (disk->src->shared && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_DISK_SHARE_RW)) + virBufferAddLit(&opt, ",share-rw=3Don"); + if (!(drivealias =3D qemuAliasFromDisk(disk))) goto error; virBufferAsprintf(&opt, ",drive=3D%s,id=3D%s", drivealias, disk->info.= alias); diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-locking.= args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-locking.args new file mode 100644 index 0000000000..cdf17f26d1 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-locking.args @@ -0,0 +1,32 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/home/test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-i686 \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-m 214 \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-QEMUGuest1/moni= tor.sock,\ +server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dreadline \ +-no-acpi \ +-boot c \ +-device virtio-scsi-pci,id=3Dscsi0,bus=3Dpci.0,addr=3D0x3 \ +-usb \ +-drive file=3D/dev/ide,format=3Draw,if=3Dnone,id=3Ddrive-ide0-0-0,cache=3D= none \ +-device ide-drive,bus=3Dide.0,unit=3D0,share-rw=3Don,drive=3Ddrive-ide0-0-= 0,\ +id=3Dide0-0-0 \ +-drive file=3D/dev/scsi,format=3Draw,if=3Dnone,id=3Ddrive-scsi0-0-0-0,cach= e=3Dnone \ +-device scsi-disk,bus=3Dscsi0.0,channel=3D0,scsi-id=3D0,lun=3D0,share-rw= =3Don,\ +drive=3Ddrive-scsi0-0-0-0,id=3Dscsi0-0-0-0 \ +-drive file=3D/dev/virtio,format=3Draw,if=3Dnone,id=3Ddrive-virtio-disk0,c= ache=3Dnone \ +-device virtio-blk-pci,bus=3Dpci.0,addr=3D0x4,share-rw=3Don,drive=3Ddrive-= virtio-disk0,\ +id=3Dvirtio-disk0 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x5 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-locking.= xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-locking.xml new file mode 100644 index 0000000000..dd48857a30 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-locking.xml @@ -0,0 +1,42 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + +
+ + + + + + +
+ + + + + + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index fdfc3c0b5e..fc6f2f10e1 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -909,6 +909,8 @@ mymain(void) DO_TEST("disk-drive-shared", QEMU_CAPS_DRIVE_SERIAL); DO_TEST_PARSE_ERROR("disk-drive-shared-qcow", NONE); + DO_TEST("disk-drive-shared-locking", + QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DISK_SHARE_RW); 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