From nobody Mon Apr 29 12:43:53 2024 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569850874; cv=none; d=zoho.com; s=zohoarc; b=Ec7Fz6oy6h3hbalv53Zz7GQpM8IDKviT4QjS3nTchFVvFWugEdz+3m8ERxCxJQW2s1qQKFuNV5ADaZ5PNni6o/Ebyk0DStmF0u2MoMVRC7lboCk8gkRSQn88ZSrM46is7gKDVqDqMwzXvPBTy8HptcBnAoTFAfqwO2HcSSn3vH8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569850874; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=WLtDsz0eolYTF+KyTnOwQtzUX2pSF/XjDKx0Xaiv/4M=; b=HfX8k7jqLJyne3gmM+qUvZjgEo4I8iBKe7PYWJfku2KVN/E/x0TbDpaDar2ccKCZHBCTRuk/Rr7CS4FMOLcaAKZND8xokNYJPCoRyLXAoCnHDKI4/PuHReMEKJUKGIL1roLv2J4sQrWKM/QDwN5VKvq/Bm9Xxp2L3OaUtIq9YZU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1569850874215430.3437658020455; Mon, 30 Sep 2019 06:41:14 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 437A610C0938; Mon, 30 Sep 2019 13:41:12 +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 BF39160C63; Mon, 30 Sep 2019 13:41:11 +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 BB4C84A486; Mon, 30 Sep 2019 13:41:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8UDf7X4012799 for ; Mon, 30 Sep 2019 09:41:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4FBF760A9D; Mon, 30 Sep 2019 13:41:07 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id A528F60624; Mon, 30 Sep 2019 13:41:06 +0000 (UTC) From: Pavel Mores To: libvir-list@redhat.com, pmores@redhat.com Date: Mon, 30 Sep 2019 15:41:00 +0200 Message-Id: <20190930134101.25011-2-pmores@redhat.com> In-Reply-To: <20190930134101.25011-1-pmores@redhat.com> References: <20190930134101.25011-1-pmores@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 1/2] qemu: make attaching disk partition to VM illegal 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: , 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.66]); Mon, 30 Sep 2019 13:41:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The way in which the qemu driver generates aliases for disks involves ignoring the partition number part of a target dev name. This means that all partitions of a block device and the device itself all end up with the same alias. If multiple such disks are specified in XML, the resulting name clash makes qemu invocation fail. Since attaching partitions to qemu VMs doesn't seem to make much sense anyway, disallow partitions in target specifications altogether. https://bugzilla.redhat.com/show_bug.cgi?id=3D1346265 Signed-off-by: Pavel Mores Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_domain.c | 15 +++++++++++ .../disk-attaching-partition-nosupport.xml | 27 +++++++++++++++++++ tests/qemuxml2argvtest.c | 1 + 3 files changed, 43 insertions(+) create mode 100644 tests/qemuxml2argvdata/disk-attaching-partition-nosuppo= rt.xml diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e8e895d9aa..545c985f40 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5880,6 +5880,8 @@ qemuDomainDeviceDefValidateDisk(const virDomainDiskDe= f *disk, { const char *driverName =3D virDomainDiskGetDriver(disk); virStorageSourcePtr n; + int idx; + int partition; =20 if (disk->src->shared && !disk->src->readonly && !qemuBlockStorageSourceSupportsConcurrentAccess(disk->src)) { @@ -5948,6 +5950,19 @@ qemuDomainDeviceDefValidateDisk(const virDomainDiskD= ef *disk, return -1; } =20 + if (virDiskNameParse(disk->dst, &idx, &partition) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("invalid disk target '%s'"), disk->dst); + return -1; + } + + if (partition !=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("can't attach disk partition '%s', please attach = whole disk instead"), + disk->dst); + return -1; + } + for (n =3D disk->src; virStorageSourceIsBacking(n); n =3D n->backingSt= ore) { if (qemuDomainValidateStorageSource(n, qemuCaps) < 0) return -1; diff --git a/tests/qemuxml2argvdata/disk-attaching-partition-nosupport.xml = b/tests/qemuxml2argvdata/disk-attaching-partition-nosupport.xml new file mode 100644 index 0000000000..591819fbb6 --- /dev/null +++ b/tests/qemuxml2argvdata/disk-attaching-partition-nosupport.xml @@ -0,0 +1,27 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 5bbac1c8b8..058eee998f 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1097,6 +1097,7 @@ mymain(void) DO_TEST("disk-no-boot", NONE); DO_TEST_PARSE_ERROR("disk-device-lun-type-invalid", QEMU_CAPS_VIRTIO_SCSI); + DO_TEST_CAPS_LATEST_PARSE_ERROR("disk-attaching-partition-nosupport"); DO_TEST_FAILURE("disk-usb-nosupport", NONE); DO_TEST("disk-usb-device", QEMU_CAPS_DEVICE_USB_STORAGE); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 12:43:53 2024 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569850890; cv=none; d=zoho.com; s=zohoarc; b=cvbGwjfVDM1i5YUrOl8U8YNHYn9/gt1vJhNNdaepwwewNGZfIHegGIHu/9MwOs4Zni+8LZMYOgnXW0MdRJBjCeKbav2w6LB0y8CJfhZfizFUyHZjrIv9L0mGLP10R46ilDvWJKeVuHLBQSp7o+piXpyo1ScJgHrpeRHQSrjLN80= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569850890; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=5CPYb8v1PbNOlB9amyfICOi8Ky5niznU2FSpyjSy5WA=; b=isJvktej7n0CZEZFTkb/QBzn9rFWeyhbOYq0SPsT2ONT06G3DHog21cb51lju9T3tNA+XInJUIBRZbdg0DMMNxBZksUaae1JnJ0+Muy00KkXb/kgjqSDmvNvXdPKYZzasK35xbCOLXmI0IovH7NNtrjsz8TfiGpnvT//efRxYTc= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1569850890838347.32134541809455; Mon, 30 Sep 2019 06:41:30 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EBE1EA44AE7; Mon, 30 Sep 2019 13:41:28 +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 BA43A261B0; Mon, 30 Sep 2019 13:41:28 +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 2966D4E58C; Mon, 30 Sep 2019 13:41:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8UDf8Gs012806 for ; Mon, 30 Sep 2019 09:41:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 44EF360A9D; Mon, 30 Sep 2019 13:41:08 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9BC7C60624; Mon, 30 Sep 2019 13:41:07 +0000 (UTC) From: Pavel Mores To: libvir-list@redhat.com, pmores@redhat.com Date: Mon, 30 Sep 2019 15:41:01 +0200 Message-Id: <20190930134101.25011-3-pmores@redhat.com> In-Reply-To: <20190930134101.25011-1-pmores@redhat.com> References: <20190930134101.25011-1-pmores@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 2/2] remove a now redundant call to virDiskNameToIndex() 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.68]); Mon, 30 Sep 2019 13:41:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Parseability of disk name is now checked in qemuDomainDeviceDefValidateDisk= (). Signed-off-by: Pavel Mores Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_command.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 77470a6037..890d89b92c 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1290,12 +1290,6 @@ qemuCheckDiskConfig(virDomainDiskDefPtr disk, if (qemuCheckDiskConfigBlkdeviotune(disk, qemuCaps) < 0) return -1; =20 - if (virDiskNameToIndex(disk->dst) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unsupported disk type '%s'"), disk->dst); - return -1; - } - if (disk->wwn) { if ((disk->bus !=3D VIR_DOMAIN_DISK_BUS_IDE) && (disk->bus !=3D VIR_DOMAIN_DISK_BUS_SCSI)) { --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list