From nobody Mon May 6 11:14:54 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=1571146522; cv=none; d=zoho.com; s=zohoarc; b=YKV9AGOaE/R93xs12Exug6aRoUeJOGbt/K9wBUJkPF4JmKQcmrWTYL9ojGqXR4sv2mD0/ugqTOfbt7RN7mrBDBGlLz6VYCzWvuvfMUdKOKtRc3nuoRJF6f8SxybyDufM0hVrUfvtjywEGPFQW5sQqnQ1ob6BLgWx6URR3Gx01WE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571146522; 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; bh=3JISkN4/g+hiCiCXvbB4BJ3Gpa0t7dAfknxRFjQvS20=; b=mB92z5+H+wg0PRDVH/8zElcbuEsDC8o3v2HYp2e3sL98DVfmR1eawwyFC8e1vqnoum/+383AScAWrMxHWrZnFHe/grWqYa1OZbXfIoguV3NLfbuZlNJ6dtqjPy61DkVuncPVludgcPV9TFHMH6q/sJiJWC/z1UNbg/T0bIsu2xo= 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 1571146522975493.7183320292929; Tue, 15 Oct 2019 06:35:22 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 06F577BDB0; Tue, 15 Oct 2019 13:35:21 +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 C6D951001DE0; Tue, 15 Oct 2019 13:35:20 +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 7923E18037CD; Tue, 15 Oct 2019 13:35:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9FDZ9wf018331 for ; Tue, 15 Oct 2019 09:35:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2C0881001E75; Tue, 15 Oct 2019 13:35:09 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id A8B661001DE4 for ; Tue, 15 Oct 2019 13:35:08 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 15 Oct 2019 15:35:03 +0200 Message-Id: <096b6834c866a6fbf2a3c9ca33b5c8d4751d8fcd.1571146430.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] conf: Reset disk type if element is completely missing 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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 15 Oct 2019 13:35:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The disk type is not part of source and thus it's parsed earlier. This bypasses the checks when parsing a disk type=3D'network' if it's completely missing the source. Since there are possible active users of this (it was reported as a problem with openstack) fix it by resetting the disk type to '_FILE' for an empty cdrom which is handled correctly. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 4 ++++ tests/qemuxml2xmloutdata/disk-source-pool.xml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c1705a07b6..399804dfbd 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10189,6 +10189,10 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xml= opt, } } + /* Reset def->src->type in case when 'source' was not present */ + if (!source) + def->src->type =3D VIR_STORAGE_TYPE_FILE; + /* Only CDROM and Floppy devices are allowed missing source path * to indicate no media present. LUN is for raw access CD-ROMs * that are not attached to a physical device presently */ diff --git a/tests/qemuxml2xmloutdata/disk-source-pool.xml b/tests/qemuxml2= xmloutdata/disk-source-pool.xml index 78e0449dfd..807d1099ed 100644 --- a/tests/qemuxml2xmloutdata/disk-source-pool.xml +++ b/tests/qemuxml2xmloutdata/disk-source-pool.xml @@ -25,7 +25,7 @@
- + --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 11:14:54 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=1571146515; cv=none; d=zoho.com; s=zohoarc; b=BXo9oIDM6q9X4D1ReKF85ChjcExIlC4NuRbnKtM2cCfc1mVPIaaAGIeQa7VyJQ57O/01xDPf4AfzKorLWDbxvWM7ovIdlrv9E5a7FNoXqK26C6R7ZxkaNZuWbJSJiH/bFmJvwqSJFuc/JqLL8vl0slUyk2l4Z4ejok+H6tkLFkA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571146515; 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; bh=xbGnvNvDK8v0yG8Kk/5a7hRgU2Uxgh3EENwGWRkB3ks=; b=Ob9fMU9eYMGgav3wsRHuBaQzjZRcQVxJlZWwVSt32dMf6kSvQon9HJBjDSX4TluU8KOpZGSkEJ7IdnJcLG9czUldPiXz9xcVCbC3ND0C+Esh0C+TmOmkQIJg0K7+lVOq90fL+AaJMV8gsWWL2hIESAPQ+uY8kyKSx0kUU0N/BAo= 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 1571146515205343.89059752466824; Tue, 15 Oct 2019 06:35:15 -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 1AE9880167C; Tue, 15 Oct 2019 13:35:13 +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 D464A60C63; Tue, 15 Oct 2019 13:35:12 +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 3A7F84EDA5; Tue, 15 Oct 2019 13:35:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9FDZA4U018339 for ; Tue, 15 Oct 2019 09:35:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id F1CC11001E91; Tue, 15 Oct 2019 13:35:09 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7995A10027A8 for ; Tue, 15 Oct 2019 13:35:09 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 15 Oct 2019 15:35:04 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] tests: Add test case for empty 'network' cdrom 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.67]); Tue, 15 Oct 2019 13:35:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" We don't allow such config in the schema but the code can handle that so add a test case supporting it. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- ...m-empty-network-invalid.x86_64-latest.args | 34 +++++++++++++++++++ .../disk-cdrom-empty-network-invalid.xml | 30 ++++++++++++++++ tests/qemuxml2argvtest.c | 1 + ...om-empty-network-invalid.x86_64-latest.xml | 34 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 5 files changed, 100 insertions(+) create mode 100644 tests/qemuxml2argvdata/disk-cdrom-empty-network-invalid= .x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/disk-cdrom-empty-network-invalid= .xml create mode 100644 tests/qemuxml2xmloutdata/disk-cdrom-empty-network-inval= id.x86_64-latest.xml diff --git a/tests/qemuxml2argvdata/disk-cdrom-empty-network-invalid.x86_64= -latest.args b/tests/qemuxml2argvdata/disk-cdrom-empty-network-invalid.x86_= 64-latest.args new file mode 100644 index 0000000000..1e43047459 --- /dev/null +++ b/tests/qemuxml2argvdata/disk-cdrom-empty-network-invalid.x86_64-latest= .args @@ -0,0 +1,34 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-QEMUGuest1 \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-i686 \ +-name guest=3DQEMUGuest1,debug-threads=3Don \ +-S \ +-object secret,id=3DmasterKey0,format=3Draw,\ +file=3D/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff \ +-m 214 \ +-overcommit mem-lock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-boot strict=3Don \ +-device piix3-usb-uhci,id=3Dusb,bus=3Dpci.0,addr=3D0x1.0x2 \ +-drive if=3Dnone,id=3Ddrive-ide0-1-1,readonly=3Don \ +-device ide-cd,bus=3Dide.1,unit=3D1,drive=3Ddrive-ide0-1-1,id=3Dide0-1-1 \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ +resourcecontrol=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/disk-cdrom-empty-network-invalid.xml b/= tests/qemuxml2argvdata/disk-cdrom-empty-network-invalid.xml new file mode 100644 index 0000000000..f593b33c91 --- /dev/null +++ b/tests/qemuxml2argvdata/disk-cdrom-empty-network-invalid.xml @@ -0,0 +1,30 @@ + + 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 834a289532..6b9da3b8ff 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1013,6 +1013,7 @@ mymain(void) DO_TEST("disk-cdrom", NONE); DO_TEST_CAPS_VER("disk-cdrom", "2.12.0"); DO_TEST_CAPS_LATEST("disk-cdrom"); + DO_TEST_CAPS_LATEST("disk-cdrom-empty-network-invalid"); DO_TEST_CAPS_LATEST("disk-cdrom-bus-other"); DO_TEST("disk-iscsi", NONE); DO_TEST("disk-cdrom-network", QEMU_CAPS_KVM); diff --git a/tests/qemuxml2xmloutdata/disk-cdrom-empty-network-invalid.x86_= 64-latest.xml b/tests/qemuxml2xmloutdata/disk-cdrom-empty-network-invalid.x= 86_64-latest.xml new file mode 100644 index 0000000000..f7772d832c --- /dev/null +++ b/tests/qemuxml2xmloutdata/disk-cdrom-empty-network-invalid.x86_64-late= st.xml @@ -0,0 +1,34 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + +
+ + +
+ + +
+ + + + + + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index b9364f942f..c3de13f64a 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -329,6 +329,7 @@ mymain(void) DO_TEST("qemu-ns-no-env", NONE); DO_TEST("disk-aio", NONE); DO_TEST("disk-cdrom", NONE); + DO_TEST_CAPS_LATEST("disk-cdrom-empty-network-invalid"); DO_TEST("disk-cdrom-bus-other", NONE); DO_TEST("disk-floppy", NONE); DO_TEST("disk-usb-device", NONE); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list