From nobody Thu May 2 23:35:22 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522324314390298.2883473422763; Thu, 29 Mar 2018 04:51:54 -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 71BCBB162; Thu, 29 Mar 2018 11:51:22 +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 2E74260F81; Thu, 29 Mar 2018 11:51:21 +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 287394CA99; Thu, 29 Mar 2018 11:51:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2TBpH57016272 for ; Thu, 29 Mar 2018 07:51:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 534151102E2B; Thu, 29 Mar 2018 11:51:17 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id D1A761102E2C; Thu, 29 Mar 2018 11:51:16 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 29 Mar 2018 13:50:58 +0200 Message-Id: <1b22407d0d77fc40ad17a23095fccccc1b077a0d.1522323985.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 01/14] tests: utils: Tolerate NULL actual data in virTestCompareToFile 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 29 Mar 2018 11:51:22 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The function docs state that 'strcontent' may be NULL, but code added in 3506f1ecfde did not use the 'cmpcontent' variable which was fixed and dereferenced it. Signed-off-by: Peter Krempa --- tests/testutils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testutils.c b/tests/testutils.c index 040ef1d2f7..4bd1b63755 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -800,8 +800,8 @@ virTestCompareToFile(const char *strcontent, if (filecontentLen > 0 && filecontent[filecontentLen - 1] =3D=3D '\n' && - strcontent[strlen(strcontent) - 1] !=3D '\n') { - if (virAsprintf(&fixedcontent, "%s\n", strcontent) < 0) + cmpcontent[strlen(cmpcontent) - 1] !=3D '\n') { + if (virAsprintf(&fixedcontent, "%s\n", cmpcontent) < 0) goto failure; cmpcontent =3D fixedcontent; } --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 23:35:22 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522324314732607.5900596257768; Thu, 29 Mar 2018 04:51:54 -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 EF62A13AA1; Thu, 29 Mar 2018 11:51:22 +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 B578F5E9CF; Thu, 29 Mar 2018 11:51:22 +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 2E273181BA05; Thu, 29 Mar 2018 11:51:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2TBpIw6016277 for ; Thu, 29 Mar 2018 07:51:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0E77F10B00A0; Thu, 29 Mar 2018 11:51:18 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8CA1C10B00A2; Thu, 29 Mar 2018 11:51:17 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 29 Mar 2018 13:50:59 +0200 Message-Id: <778cb51ba78d511ec9864aab1c154966a217c022.1522323985.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 02/14] conf: Refactor/rename virDomainDiskDefSourceParse 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 29 Mar 2018 11:51:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Make the function more usable by returning the full disk definition and fix the only caller for the new semantics. The new name for the function is virDomainDiskDefParse. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 33 ++++++++++++--------------------- src/conf/domain_conf.h | 8 ++++---- src/libvirt_private.syms | 2 +- src/qemu/qemu_driver.c | 9 +++++++-- 4 files changed, 24 insertions(+), 28 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ae7c0d9b71..e2bad48cc8 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15864,44 +15864,35 @@ virDomainDeviceDefParse(const char *xmlStr, } -virStorageSourcePtr -virDomainDiskDefSourceParse(const char *xmlStr, - const virDomainDef *def, - virDomainXMLOptionPtr xmlopt, - unsigned int flags) +virDomainDiskDefPtr +virDomainDiskDefParse(const char *xmlStr, + const virDomainDef *def, + virDomainXMLOptionPtr xmlopt, + unsigned int flags) { xmlDocPtr xml; - xmlNodePtr node; xmlXPathContextPtr ctxt =3D NULL; virDomainDiskDefPtr disk =3D NULL; - virStorageSourcePtr ret =3D NULL; if (!(xml =3D virXMLParseStringCtxt(xmlStr, _("(disk_definition)"), &c= txt))) goto cleanup; - node =3D ctxt->node; - if (!virXMLNodeNameEqual(node, "disk")) { + if (!virXMLNodeNameEqual(ctxt->node, "disk")) { virReportError(VIR_ERR_XML_ERROR, _("expecting root element of 'disk', not '%s'"), - node->name); + ctxt->node->name); goto cleanup; } - flags |=3D VIR_DOMAIN_DEF_PARSE_DISK_SOURCE; - if (!(disk =3D virDomainDiskDefParseXML(xmlopt, node, ctxt, - NULL, def->seclabels, - def->nseclabels, - flags))) - goto cleanup; - - ret =3D disk->src; - disk->src =3D NULL; + disk =3D virDomainDiskDefParseXML(xmlopt, ctxt->node, ctxt, + NULL, def->seclabels, + def->nseclabels, + flags); cleanup: - virDomainDiskDefFree(disk); xmlFreeDoc(xml); xmlXPathFreeContext(ctxt); - return ret; + return disk; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 61379e50fe..650901c1f4 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2935,10 +2935,10 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(const= char *xmlStr, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, unsigned int flags); -virStorageSourcePtr virDomainDiskDefSourceParse(const char *xmlStr, - const virDomainDef *def, - virDomainXMLOptionPtr xmlo= pt, - unsigned int flags); +virDomainDiskDefPtr virDomainDiskDefParse(const char *xmlStr, + const virDomainDef *def, + virDomainXMLOptionPtr xmlopt, + unsigned int flags); virDomainDefPtr virDomainDefParseString(const char *xmlStr, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 03fe3b315f..96a0a6de52 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -315,7 +315,7 @@ virDomainDiskDefCheckDuplicateInfo; virDomainDiskDefForeachPath; virDomainDiskDefFree; virDomainDiskDefNew; -virDomainDiskDefSourceParse; +virDomainDiskDefParse; virDomainDiskDetectZeroesTypeFromString; virDomainDiskDetectZeroesTypeToString; virDomainDiskDeviceTypeToString; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 7bcc4936de..4e9add0ef7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17456,6 +17456,7 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *d= isk, const char *destxml, unsigned long long bandwidth =3D 0; unsigned int granularity =3D 0; unsigned long long buf_size =3D 0; + virDomainDiskDefPtr diskdef =3D NULL; virStorageSourcePtr dest =3D NULL; size_t i; @@ -17508,14 +17509,18 @@ qemuDomainBlockCopy(virDomainPtr dom, const char = *disk, const char *destxml, } } - if (!(dest =3D virDomainDiskDefSourceParse(destxml, vm->def, driver->x= mlopt, - VIR_DOMAIN_DEF_PARSE_INACTIVE= ))) + if (!(diskdef =3D virDomainDiskDefParse(destxml, vm->def, driver->xmlo= pt, + VIR_DOMAIN_DEF_PARSE_INACTIVE | + VIR_DOMAIN_DEF_PARSE_DISK_SOURCE= ))) goto cleanup; + VIR_STEAL_PTR(dest, diskdef->src); + ret =3D qemuDomainBlockCopyCommon(vm, dom->conn, disk, dest, bandwidth, granularity, buf_size, flags, false); cleanup: + virDomainDiskDefFree(diskdef); virDomainObjEndAPI(&vm); return ret; } --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 23:35:22 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522324322030632.6967092311631; Thu, 29 Mar 2018 04:52:02 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1F8D27FD42; Thu, 29 Mar 2018 11:51:30 +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 DE54D5D72E; Thu, 29 Mar 2018 11:51:29 +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 9E3C54CA9F; Thu, 29 Mar 2018 11:51:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2TBpINp016287 for ; Thu, 29 Mar 2018 07:51:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id BDA7C1102E2D; Thu, 29 Mar 2018 11:51:18 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 478A81102E2B; Thu, 29 Mar 2018 11:51:18 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 29 Mar 2018 13:51:00 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 03/14] conf: Don't require 'def' in virDomainDiskDefParse 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 29 Mar 2018 11:51:30 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In some use cases (mostly in tests) it is not required to check the seclabel definition validity. Add possibility to call virDomainDiskDefParse without the domain definition. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e2bad48cc8..ac3a3d9966 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15873,6 +15873,8 @@ virDomainDiskDefParse(const char *xmlStr, xmlDocPtr xml; xmlXPathContextPtr ctxt =3D NULL; virDomainDiskDefPtr disk =3D NULL; + virSecurityLabelDefPtr *seclabels =3D NULL; + size_t nseclabels =3D 0; if (!(xml =3D virXMLParseStringCtxt(xmlStr, _("(disk_definition)"), &c= txt))) goto cleanup; @@ -15884,10 +15886,13 @@ virDomainDiskDefParse(const char *xmlStr, goto cleanup; } + if (def) { + seclabels =3D def->seclabels; + nseclabels =3D def->nseclabels; + } + disk =3D virDomainDiskDefParseXML(xmlopt, ctxt->node, ctxt, - NULL, def->seclabels, - def->nseclabels, - flags); + NULL, seclabels, nseclabels, flags); cleanup: xmlFreeDoc(xml); --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 23:35:22 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522324321794888.4761766518907; Thu, 29 Mar 2018 04:52:01 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3B97D80E7D; Thu, 29 Mar 2018 11:51:30 +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 04C8F5D781; Thu, 29 Mar 2018 11:51:30 +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 B9D7C4CA9D; Thu, 29 Mar 2018 11:51:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2TBpJN7016293 for ; Thu, 29 Mar 2018 07:51:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 788E910B00A0; Thu, 29 Mar 2018 11:51:19 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 024D21102E2B; Thu, 29 Mar 2018 11:51:18 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 29 Mar 2018 13:51:01 +0200 Message-Id: <96a14bd19e44f2d06fe9a729b59d5258dbb9243f.1522323985.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 04/14] conf: Extract logic for updating 'detect_zeroes' mode 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 29 Mar 2018 11:51:30 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" For some reason we've decided to silently translate the disk detect_zeroes mode if it would be invalid. Extract the logic so that it does not need to be copypasta'd across the code base. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 22 ++++++++++++++++++++++ src/conf/domain_conf.h | 3 +++ src/libvirt_private.syms | 1 + src/qemu/qemu_command.c | 15 ++------------- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ac3a3d9966..ef16431aaf 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -29362,3 +29362,25 @@ virDomainDiskTranslateSourcePool(virDomainDiskDefP= tr def) virStoragePoolDefFree(pooldef); return ret; } + + +/** + * virDomainDiskGetDetectZeroesMode: + * @discard: disk/image sector discard setting + * @detect_zeroes: disk/image zero sector detection mode + * + * As a convenience syntax, if discards are ignored and zero detection is = set + * to 'unmap', then simply behave like zero detection is set to 'on'. But + * don't change it in the XML for easier adjustments. This behaviour is + * documented. + */ +int +virDomainDiskGetDetectZeroesMode(virDomainDiskDiscard discard, + virDomainDiskDetectZeroes detect_zeroes) +{ + if (discard !=3D VIR_DOMAIN_DISK_DISCARD_UNMAP && + detect_zeroes =3D=3D VIR_DOMAIN_DISK_DETECT_ZEROES_UNMAP) + return VIR_DOMAIN_DISK_DETECT_ZEROES_ON; + + return detect_zeroes; +} diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 650901c1f4..bd17bd99ae 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3528,5 +3528,8 @@ virDomainNetResolveActualType(virDomainNetDefPtr ifac= e) int virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def); +int +virDomainDiskGetDetectZeroesMode(virDomainDiskDiscard discard, + virDomainDiskDetectZeroes detect_zeroes); #endif /* __DOMAIN_CONF_H */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 96a0a6de52..8d5509a8a8 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -326,6 +326,7 @@ virDomainDiskErrorPolicyTypeToString; virDomainDiskFindByBusAndDst; virDomainDiskGeometryTransTypeFromString; virDomainDiskGeometryTransTypeToString; +virDomainDiskGetDetectZeroesMode; virDomainDiskGetDriver; virDomainDiskGetFormat; virDomainDiskGetSource; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 89fd08b642..6a13714eae 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1729,6 +1729,8 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, virQEMUCapsPtr qemuCaps) { virBuffer opt =3D VIR_BUFFER_INITIALIZER; + int detect_zeroes =3D virDomainDiskGetDetectZeroesMode(disk->discard, + disk->detect_zero= es); if (qemuBuildDriveSourceStr(disk, qemuCaps, &opt) < 0) goto error; @@ -1809,19 +1811,6 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, } if (disk->detect_zeroes) { - int detect_zeroes =3D disk->detect_zeroes; - - /* - * As a convenience syntax, if discards are ignored and - * zero detection is set to 'unmap', then simply behave - * like zero detection is set to 'on'. But don't change - * it in the XML for easier adjustments. This behaviour - * is documented. - */ - if (disk->discard !=3D VIR_DOMAIN_DISK_DISCARD_UNMAP && - detect_zeroes =3D=3D VIR_DOMAIN_DISK_DETECT_ZEROES_UNMAP) - detect_zeroes =3D VIR_DOMAIN_DISK_DETECT_ZEROES_ON; - virBufferAsprintf(&opt, ",detect-zeroes=3D%s", virDomainDiskDetectZeroesTypeToString(detect_zer= oes)); } --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 23:35:22 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522324295614557.2399997055828; Thu, 29 Mar 2018 04:51:35 -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 D8A107D4EB; Thu, 29 Mar 2018 11:51:33 +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 92C6F60F8C; Thu, 29 Mar 2018 11:51:33 +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 410904CAA6; Thu, 29 Mar 2018 11:51:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2TBpKSl016304 for ; Thu, 29 Mar 2018 07:51:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 325C51102E2C; Thu, 29 Mar 2018 11:51:20 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id B0EC31102E2B; Thu, 29 Mar 2018 11:51:19 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 29 Mar 2018 13:51:02 +0200 Message-Id: <4234aead212e63d7e5bd35100ce8cfe9baeed883.1522323985.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 05/14] qemu: domain: Add helper to initialize detected parts of the backing chain 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 29 Mar 2018 11:51:34 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" It will be necessary to initialize various aspects for the detected members of the backing chain. Add a function that will handle it and call it from qemuDomainPrepareDiskSource and qemuDomainDetermineDiskChain Signed-off-by: Peter Krempa --- src/qemu/qemu_domain.c | 48 ++++++++++++++++++++++++++++++++++++++++++----= -- src/qemu/qemu_domain.h | 6 ++++++ 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 580e0f830d..009fb9daf3 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7399,6 +7399,7 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver, { virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); virStorageSourcePtr src =3D disk->src; + qemuDomainObjPrivatePtr priv =3D vm->privateData; int ret =3D -1; uid_t uid; gid_t gid; @@ -7467,6 +7468,10 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver, report_broken) < 0) goto cleanup; + /* fill in data for the rest of the chain */ + if (qemuDomainPrepareDiskSourceChain(disk, src, cfg, priv->qemuCaps) <= 0) + goto cleanup; + ret =3D 0; cleanup: @@ -11803,6 +11808,41 @@ qemuDomainCheckMigrationCapabilities(virQEMUDriver= Ptr driver, } +/** + * qemuDomainPrepareDiskSourceChain: + * + * @disk: Disk config object + * @src: source to start from + * @cfg: qemu driver config object + * + * Prepares various aspects of the disk source and it's backing chain. This + * function should be also called for detected backing chains. If @src is = NULL + * the root source is used. + */ +int +qemuDomainPrepareDiskSourceChain(virDomainDiskDefPtr disk, + virStorageSourcePtr src, + virQEMUDriverConfigPtr cfg, + virQEMUCapsPtr qemuCaps) +{ + virStorageSourcePtr n; + + if (!src) + src =3D disk->src; + + for (n =3D src; virStorageSourceIsBacking(n); n =3D n->backingStore) { + if (n->type =3D=3D VIR_STORAGE_TYPE_NETWORK && + n->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_GLUSTER && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_GLUSTER_DEBUG_LEVEL)) { + n->debug =3D true; + n->debugLevel =3D cfg->glusterDebugLevel; + } + } + + return 0; +} + + int qemuDomainPrepareDiskSource(virDomainDiskDefPtr disk, qemuDomainObjPrivatePtr priv, @@ -11814,12 +11854,8 @@ qemuDomainPrepareDiskSource(virDomainDiskDefPtr di= sk, if (qemuDomainSecretDiskPrepare(priv, disk) < 0) return -1; - if (disk->src->type =3D=3D VIR_STORAGE_TYPE_NETWORK && - disk->src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_GLUSTER && - virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_GLUSTER_DEBUG_LEVEL)) { - disk->src->debug =3D true; - disk->src->debugLevel =3D cfg->glusterDebugLevel; - } + if (qemuDomainPrepareDiskSourceChain(disk, NULL, cfg, priv->qemuCaps) = < 0) + return -1; return 0; } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 63d9fb6d21..21e12f6594 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -991,6 +991,12 @@ int qemuDomainCheckMigrationCapabilities(virQEMUDriverPtr driver, virDomainObjPtr vm, qemuDomainAsyncJob asyncJob); +int +qemuDomainPrepareDiskSourceChain(virDomainDiskDefPtr disk, + virStorageSourcePtr src, + virQEMUDriverConfigPtr cfg, + virQEMUCapsPtr qemuCaps) + ATTRIBUTE_RETURN_CHECK; int qemuDomainPrepareDiskSource(virDomainDiskDefPtr disk, --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 23:35:22 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 152232429157725.47435500755637; Thu, 29 Mar 2018 04:51:31 -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 3363767EC1; Thu, 29 Mar 2018 11:51:30 +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 EA3F060F8C; Thu, 29 Mar 2018 11:51:29 +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 A2B074CAA0; Thu, 29 Mar 2018 11:51:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2TBpL8d016312 for ; Thu, 29 Mar 2018 07:51:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id E120910B00A0; Thu, 29 Mar 2018 11:51:20 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B84B10B00A2; Thu, 29 Mar 2018 11:51:20 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 29 Mar 2018 13:51:03 +0200 Message-Id: <83724c0c1a957b1923a8fdaf05855526c230605d.1522323985.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 06/14] qemu: domain: Forbid storage type 'cow' 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 29 Mar 2018 11:51:30 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" QEMU does not support it so save us hassle and forbid it right away. Signed-off-by: Peter Krempa --- src/qemu/qemu_domain.c | 23 +++++++++++++++++++++++ tests/qemuxml2argvdata/disk-drive-fmt-cow.xml | 27 +++++++++++++++++++++++= ++++ tests/qemuxml2argvtest.c | 1 + 3 files changed, 51 insertions(+) create mode 100644 tests/qemuxml2argvdata/disk-drive-fmt-cow.xml diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 009fb9daf3..960a78f082 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4108,9 +4108,24 @@ qemuDomainDeviceDefValidateVideo(const virDomainVide= oDef *video) } +static int +qemuDomainValidateStorageSource(virStorageSourcePtr src) +{ + if (src->format =3D=3D VIR_STORAGE_FILE_COW) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("'cow' storage format is not supported")); + return -1; + } + + return 0; +} + + static int qemuDomainDeviceDefValidateDisk(const virDomainDiskDef *disk) { + virStorageSourcePtr n; + if (disk->src->shared && !disk->src->readonly) { if (disk->src->format <=3D VIR_STORAGE_FILE_AUTO) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -4127,6 +4142,11 @@ qemuDomainDeviceDefValidateDisk(const virDomainDiskD= ef *disk) } } + for (n =3D disk->src; virStorageSourceIsBacking(n); n =3D n->backingSt= ore) { + if (qemuDomainValidateStorageSource(n) < 0) + return -1; + } + return 0; } @@ -11837,6 +11857,9 @@ qemuDomainPrepareDiskSourceChain(virDomainDiskDefPt= r disk, n->debug =3D true; n->debugLevel =3D cfg->glusterDebugLevel; } + + if (qemuDomainValidateStorageSource(n) < 0) + return -1; } return 0; diff --git a/tests/qemuxml2argvdata/disk-drive-fmt-cow.xml b/tests/qemuxml2= argvdata/disk-drive-fmt-cow.xml new file mode 100644 index 0000000000..91c62ea055 --- /dev/null +++ b/tests/qemuxml2argvdata/disk-drive-fmt-cow.xml @@ -0,0 +1,27 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + + /usr/bin/qemu-system-i686 + + + + +
+ + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 308d71f725..5d7f2e15ba 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -912,6 +912,7 @@ mymain(void) QEMU_CAPS_NODEFCONFIG); DO_TEST("disk-drive-fmt-qcow", QEMU_CAPS_DRIVE_BOOT); + DO_TEST_PARSE_ERROR("disk-drive-fmt-cow", QEMU_CAPS_DRIVE_BOOT); DO_TEST("disk-drive-shared", QEMU_CAPS_DRIVE_SERIAL); DO_TEST_PARSE_ERROR("disk-drive-shared-qcow", NONE); --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 23:35:22 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522324313342302.9349213704195; Thu, 29 Mar 2018 04:51:53 -0700 (PDT) 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 B4ED37FD68; Thu, 29 Mar 2018 11:51:33 +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 753CC60BE2; Thu, 29 Mar 2018 11:51:33 +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 20149180BAD3; Thu, 29 Mar 2018 11:51:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2TBpLI1016317 for ; Thu, 29 Mar 2018 07:51:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9BF4B1102E2D; Thu, 29 Mar 2018 11:51:21 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2626B1102E2B; Thu, 29 Mar 2018 11:51:21 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 29 Mar 2018 13:51:04 +0200 Message-Id: <554bdadbd6e24b23b9a6ee9f02a838b41e731bbc.1522323985.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 07/14] qemu: domain: Forbid VIR_STORAGE_FILE_DIR as a disk format 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.27]); Thu, 29 Mar 2018 11:51:34 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This is a storage driver type, which is not handled in qemu driver properly. For accessing directories, disk type 'dir' is used instead. Signed-off-by: Peter Krempa --- src/qemu/qemu_domain.c | 7 +++++++ tests/qemuxml2argvdata/disk-drive-fmt-dir.xml | 27 +++++++++++++++++++++++= ++++ tests/qemuxml2argvtest.c | 1 + 3 files changed, 35 insertions(+) create mode 100644 tests/qemuxml2argvdata/disk-drive-fmt-dir.xml diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 960a78f082..88b4653da5 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4117,6 +4117,13 @@ qemuDomainValidateStorageSource(virStorageSourcePtr = src) return -1; } + if (src->format =3D=3D VIR_STORAGE_FILE_DIR) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("'directory' storage format is not directly suppo= red by qemu, " + "use 'dir' disk type instead")); + return -1; + } + return 0; } diff --git a/tests/qemuxml2argvdata/disk-drive-fmt-dir.xml b/tests/qemuxml2= argvdata/disk-drive-fmt-dir.xml new file mode 100644 index 0000000000..ede3f8e186 --- /dev/null +++ b/tests/qemuxml2argvdata/disk-drive-fmt-dir.xml @@ -0,0 +1,27 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + + /usr/bin/qemu-system-i686 + + + + +
+ + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 5d7f2e15ba..711bd1b661 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -913,6 +913,7 @@ mymain(void) DO_TEST("disk-drive-fmt-qcow", QEMU_CAPS_DRIVE_BOOT); DO_TEST_PARSE_ERROR("disk-drive-fmt-cow", QEMU_CAPS_DRIVE_BOOT); + DO_TEST_PARSE_ERROR("disk-drive-fmt-dir", QEMU_CAPS_DRIVE_BOOT); DO_TEST("disk-drive-shared", QEMU_CAPS_DRIVE_SERIAL); DO_TEST_PARSE_ERROR("disk-drive-shared-qcow", NONE); --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 23:35:22 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522324313587351.5316645738926; Thu, 29 Mar 2018 04:51:53 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0589D7D4F1; Thu, 29 Mar 2018 11:51:37 +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 CF1B85D77D; Thu, 29 Mar 2018 11:51:36 +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 95C1F4CAA7; Thu, 29 Mar 2018 11:51:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2TBpMxw016322 for ; Thu, 29 Mar 2018 07:51:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 56BE610B00A0; Thu, 29 Mar 2018 11:51:22 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id D501F1102E2B; Thu, 29 Mar 2018 11:51:21 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 29 Mar 2018 13:51:05 +0200 Message-Id: <43ffb1379f7c28d89b77f7c2f16df08be2050b24.1522323985.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 08/14] qemu: domain: Forbid VIR_STORAGE_FILE_ISO as a disk format 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 29 Mar 2018 11:51:37 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This format is used by the storage driver and other hypervisors but qemu does not have nothion of the 'iso' format and libvirt does not translate it to anything useful, so it would not work anyways. Users should use 'raw' instead. Signed-off-by: Peter Krempa --- src/qemu/qemu_domain.c | 7 +++++++ tests/qemuxml2argvdata/disk-drive-fmt-iso.xml | 27 +++++++++++++++++++++++= ++++ tests/qemuxml2argvtest.c | 1 + 3 files changed, 35 insertions(+) create mode 100644 tests/qemuxml2argvdata/disk-drive-fmt-iso.xml diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 88b4653da5..e02da9e608 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4124,6 +4124,13 @@ qemuDomainValidateStorageSource(virStorageSourcePtr = src) return -1; } + if (src->format =3D=3D VIR_STORAGE_FILE_ISO) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("storage format 'iso' is not directly suppored by= qemu, " + "use 'raw' instead")); + return -1; + } + return 0; } diff --git a/tests/qemuxml2argvdata/disk-drive-fmt-iso.xml b/tests/qemuxml2= argvdata/disk-drive-fmt-iso.xml new file mode 100644 index 0000000000..ad2825bfb2 --- /dev/null +++ b/tests/qemuxml2argvdata/disk-drive-fmt-iso.xml @@ -0,0 +1,27 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + + /usr/bin/qemu-system-i686 + + + + +
+ + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 711bd1b661..3d278c4bc2 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -914,6 +914,7 @@ mymain(void) QEMU_CAPS_DRIVE_BOOT); DO_TEST_PARSE_ERROR("disk-drive-fmt-cow", QEMU_CAPS_DRIVE_BOOT); DO_TEST_PARSE_ERROR("disk-drive-fmt-dir", QEMU_CAPS_DRIVE_BOOT); + DO_TEST_PARSE_ERROR("disk-drive-fmt-iso", QEMU_CAPS_DRIVE_BOOT); DO_TEST("disk-drive-shared", QEMU_CAPS_DRIVE_SERIAL); DO_TEST_PARSE_ERROR("disk-drive-shared-qcow", NONE); --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 23:35:22 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522324313283120.56317111203475; Thu, 29 Mar 2018 04:51:53 -0700 (PDT) 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 EED637D0DF; Thu, 29 Mar 2018 11:51:36 +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 C0D8665AC5; Thu, 29 Mar 2018 11:51:36 +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 850594CAA9; Thu, 29 Mar 2018 11:51:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2TBpNOS016331 for ; Thu, 29 Mar 2018 07:51:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 12A141102E2D; Thu, 29 Mar 2018 11:51:23 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8FE101102E2B; Thu, 29 Mar 2018 11:51:22 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 29 Mar 2018 13:51:06 +0200 Message-Id: <6f9eed70025eb0099d5865656802cc4f78ae5010.1522323985.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 09/14] qemu: caps: Add capability for LUKS encrypted qcow2 image support 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.26]); Thu, 29 Mar 2018 11:51:37 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml | 1 + 11 files changed, 12 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index e54dde69ab..959c27f3bf 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -466,6 +466,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, /* 285 */ "virtio-mouse-ccw", "virtio-tablet-ccw", + "qcow2-luks", ); @@ -1849,6 +1850,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsQMPSc= hemaQueries[] =3D { { "blockdev-add/arg-type/+gluster/debug", QEMU_CAPS_GLUSTER_DEBUG_LEVE= L}, { "blockdev-add/arg-type/+vxhs", QEMU_CAPS_VXHS}, { "blockdev-add/arg-type/+iscsi/password-secret", QEMU_CAPS_ISCSI_PASS= WORD_SECRET }, + { "blockdev-add/arg-type/+qcow2/encrypt/+luks/key-secret", QEMU_CAPS_Q= COW2_LUKS }, }; struct virQEMUCapsObjectTypeProps { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 3f3c29f8fb..2203c28aa0 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -450,6 +450,7 @@ typedef enum { /* 285 */ QEMU_CAPS_DEVICE_VIRTIO_MOUSE_CCW, /* -device virtio-mouse-ccw */ QEMU_CAPS_DEVICE_VIRTIO_TABLET_CCW, /* -device virtio-tablet-ccw */ + QEMU_CAPS_QCOW2_LUKS, /* qcow2 format support LUKS encryption */ QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml b/tests/qem= ucapabilitiesdata/caps_2.10.0.aarch64.xml index 17d388e815..7585e02da2 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml @@ -186,6 +186,7 @@ + 2010000 0 303541 diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml b/tests/qemuc= apabilitiesdata/caps_2.10.0.ppc64.xml index 403b538628..153e199c41 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml @@ -185,6 +185,7 @@ + 2010000 0 382824 diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml b/tests/qemuc= apabilitiesdata/caps_2.10.0.s390x.xml index 1096495f00..c4be3fca51 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml @@ -146,6 +146,7 @@ + 2010000 0 303326 diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml b/tests/qemu= capabilitiesdata/caps_2.10.0.x86_64.xml index dacb5c4599..4dd5602014 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml @@ -229,6 +229,7 @@ + 2010000 0 344938 diff --git a/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml b/tests/qemuc= apabilitiesdata/caps_2.11.0.s390x.xml index 70a35ef507..cbd645ae93 100644 --- a/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml @@ -150,6 +150,7 @@ + 2011000 0 342058 diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml b/tests/qem= ucapabilitiesdata/caps_2.12.0.aarch64.xml index ff48293656..ec2eec17f4 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml @@ -187,6 +187,7 @@ + 2011090 0 342346 diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml b/tests/qemuc= apabilitiesdata/caps_2.12.0.ppc64.xml index ee7fb9e052..1122d6408b 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml @@ -185,6 +185,7 @@ + 2011090 0 419215 diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml b/tests/qemuc= apabilitiesdata/caps_2.12.0.s390x.xml index b5b6b5b3b1..191b1e0e37 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml @@ -150,6 +150,7 @@ + 2011090 0 0 diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml b/tests/qemu= capabilitiesdata/caps_2.12.0.x86_64.xml index 334296e213..aa5de811e1 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml @@ -225,6 +225,7 @@ + 2011090 0 390060 --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 23:35:22 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 152232430218623.013284229006445; Thu, 29 Mar 2018 04:51:42 -0700 (PDT) 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 910B9486B8; Thu, 29 Mar 2018 11:51:40 +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 5DF806A944; Thu, 29 Mar 2018 11:51:40 +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 DD91B181BA07; Thu, 29 Mar 2018 11:51:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2TBpN76016340 for ; Thu, 29 Mar 2018 07:51:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id C229B100F2EE; Thu, 29 Mar 2018 11:51:23 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C8E510B00A2; Thu, 29 Mar 2018 11:51:23 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 29 Mar 2018 13:51:07 +0200 Message-Id: <19d68fa611c2830620f864d50c64ffd38337cd43.1522323985.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 10/14] qemu: domain: Validate support for LUKS encryption of QCOW2 images 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.30]); Thu, 29 Mar 2018 11:51:41 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Reject configurations when qemu would not support the image. Signed-off-by: Peter Krempa --- src/qemu/qemu_domain.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e02da9e608..cbad7d0f4c 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4109,7 +4109,8 @@ qemuDomainDeviceDefValidateVideo(const virDomainVideo= Def *video) static int -qemuDomainValidateStorageSource(virStorageSourcePtr src) +qemuDomainValidateStorageSource(virStorageSourcePtr src, + virQEMUCapsPtr qemuCaps) { if (src->format =3D=3D VIR_STORAGE_FILE_COW) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -4131,12 +4132,22 @@ qemuDomainValidateStorageSource(virStorageSourcePtr= src) return -1; } + if (src->format =3D=3D VIR_STORAGE_FILE_QCOW2 && + src->encryption && + src->encryption->format =3D=3D VIR_STORAGE_ENCRYPTION_FORMAT_LUKS = && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_QCOW2_LUKS)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("LUKS encrypted QCOW2 images are not suppored by = this qemu")); + return -1; + } + return 0; } static int -qemuDomainDeviceDefValidateDisk(const virDomainDiskDef *disk) +qemuDomainDeviceDefValidateDisk(const virDomainDiskDef *disk, + virQEMUCapsPtr qemuCaps) { virStorageSourcePtr n; @@ -4157,7 +4168,7 @@ qemuDomainDeviceDefValidateDisk(const virDomainDiskDe= f *disk) } for (n =3D disk->src; virStorageSourceIsBacking(n); n =3D n->backingSt= ore) { - if (qemuDomainValidateStorageSource(n) < 0) + if (qemuDomainValidateStorageSource(n, qemuCaps) < 0) return -1; } @@ -4988,7 +4999,7 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef = *dev, break; case VIR_DOMAIN_DEVICE_DISK: - ret =3D qemuDomainDeviceDefValidateDisk(dev->data.disk); + ret =3D qemuDomainDeviceDefValidateDisk(dev->data.disk, qemuCaps); break; case VIR_DOMAIN_DEVICE_CONTROLLER: @@ -11872,7 +11883,7 @@ qemuDomainPrepareDiskSourceChain(virDomainDiskDefPt= r disk, n->debugLevel =3D cfg->glusterDebugLevel; } - if (qemuDomainValidateStorageSource(n) < 0) + if (qemuDomainValidateStorageSource(n, qemuCaps) < 0) return -1; } --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 23:35:22 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15223243060023.54473228812617; Thu, 29 Mar 2018 04:51:46 -0700 (PDT) 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 714AE7FDEA; Thu, 29 Mar 2018 11:51:44 +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 3D2B260BE2; Thu, 29 Mar 2018 11:51:44 +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 E017E181BA0A; Thu, 29 Mar 2018 11:51:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2TBpONW016349 for ; Thu, 29 Mar 2018 07:51:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7DAC81102E2D; Thu, 29 Mar 2018 11:51:24 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 077BE1102E2B; Thu, 29 Mar 2018 11:51:23 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 29 Mar 2018 13:51:08 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 11/14] qemu: command: Add support for qcow2 + luks 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.27]); Thu, 29 Mar 2018 11:51:45 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The old qcow2 encryption format was buggy, so the new approach is to use luks inside qcow2. As it turns out, it didn't require that many changes. It was necessary to fix the command line formatter to stop mangling the format when secrets are present and specify the encryption format and secret in correct format. Signed-off-by: Peter Krempa --- You can easily create a qcow2+luks disk image by: qemu-img create --object secret,id=3Dsec0,data=3Dasdf -f qcow2 \ -o encrypt.format=3Dluks,encrypt.key-secret=3Dsec0 luks.qcow2 10M src/qemu/qemu_command.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 6a13714eae..c1225591b3 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1525,6 +1525,7 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk, qemuDomainSecretInfoPtr encinfo =3D NULL; virJSONValuePtr srcprops =3D NULL; char *source =3D NULL; + bool rawluks =3D false; int ret =3D -1; if (srcpriv) { @@ -1598,14 +1599,21 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk, } virBufferAddLit(buf, ","); - if (encinfo) - virQEMUBuildLuksOpts(buf, &disk->src->encryption->encinfo, - encinfo->s.aes.alias); + if (encinfo) { + if (disk->src->format =3D=3D VIR_STORAGE_FILE_RAW) { + virBufferAsprintf(buf, "key-secret=3D%s,", encinfo->s.aes.alia= s); + rawluks =3D true; + } else if (disk->src->format =3D=3D VIR_STORAGE_FILE_QCOW2 && + disk->src->encryption->format =3D=3D VIR_STORAGE_ENCRYP= TION_FORMAT_LUKS) { + virBufferAddLit(buf, "encrypt.format=3Dluks,"); + virBufferAsprintf(buf, "encrypt.key-secret=3D%s,", encinfo->s.= aes.alias); + } + } if (disk->src->format > 0 && disk->src->type !=3D VIR_STORAGE_TYPE_DIR) { const char *qemuformat =3D virStorageFileFormatTypeToString(disk->= src->format); - if (qemuDomainDiskHasEncryptionSecret(disk->src)) + if (rawluks) qemuformat =3D "luks"; virBufferAsprintf(buf, "format=3D%s,", qemuformat); } --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 23:35:22 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522324309041895.0444911262665; Thu, 29 Mar 2018 04:51:49 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A79BA9D428; Thu, 29 Mar 2018 11:51:47 +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 82EC95D782; Thu, 29 Mar 2018 11:51:47 +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 3C488181BA0D; Thu, 29 Mar 2018 11:51:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2TBpPXP016390 for ; Thu, 29 Mar 2018 07:51:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 37ABE100F2EE; Thu, 29 Mar 2018 11:51:25 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id B64941102E2B; Thu, 29 Mar 2018 11:51:24 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 29 Mar 2018 13:51:09 +0200 Message-Id: <5a3fd81987e46b397605b61a465bf4bf39121fe6.1522323985.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 12/14] tests: qemu: Test QCOW2 + LUKS support 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 29 Mar 2018 11:51:48 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa --- .../qemuxml2argvdata/luks-disks-source-qcow2.args | 66 ++++++++++++++++++ tests/qemuxml2argvdata/luks-disks-source-qcow2.xml | 81 ++++++++++++++++++= ++++ tests/qemuxml2argvtest.c | 2 + 3 files changed, 149 insertions(+) create mode 100644 tests/qemuxml2argvdata/luks-disks-source-qcow2.args create mode 100644 tests/qemuxml2argvdata/luks-disks-source-qcow2.xml diff --git a/tests/qemuxml2argvdata/luks-disks-source-qcow2.args b/tests/qe= muxml2argvdata/luks-disks-source-qcow2.args new file mode 100644 index 0000000000..001fc659bc --- /dev/null +++ b/tests/qemuxml2argvdata/luks-disks-source-qcow2.args @@ -0,0 +1,66 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/home/test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-x86_64 \ +-name encryptdisk \ +-S \ +-object secret,id=3DmasterKey0,format=3Draw,\ +file=3D/tmp/lib/domain--1-encryptdisk/master-key.aes \ +-M pc-i440fx-2.1 \ +-m 1024 \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid 496898a6-e6ff-f7c8-5dc2-3cf410945ee9 \ +-nographic \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,\ +path=3D/tmp/lib/domain--1-encryptdisk/monitor.sock,server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dreadline \ +-no-acpi \ +-boot c \ +-usb \ +-object secret,id=3Dvirtio-disk0-luks-secret0,\ +data=3D9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,\ +keyid=3DmasterKey0,iv=3DAAECAwQFBgcICQoLDA0ODw=3D=3D,format=3Dbase64 \ +-drive file=3D/storage/guest_disks/encryptdisk,encrypt.format=3Dluks,\ +encrypt.key-secret=3Dvirtio-disk0-luks-secret0,format=3Dqcow2,if=3Dnone,\ +id=3Ddrive-virtio-disk0 \ +-device virtio-blk-pci,bus=3Dpci.0,addr=3D0x4,drive=3Ddrive-virtio-disk0,\ +id=3Dvirtio-disk0 \ +-object secret,id=3Dvirtio-disk1-luks-secret0,\ +data=3D9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,\ +keyid=3DmasterKey0,iv=3DAAECAwQFBgcICQoLDA0ODw=3D=3D,format=3Dbase64 \ +-drive file=3D/storage/guest_disks/encryptdisk2,encrypt.format=3Dluks,\ +encrypt.key-secret=3Dvirtio-disk1-luks-secret0,format=3Dqcow2,if=3Dnone,\ +id=3Ddrive-virtio-disk1 \ +-device virtio-blk-pci,bus=3Dpci.0,addr=3D0x5,drive=3Ddrive-virtio-disk1,\ +id=3Dvirtio-disk1 \ +-object secret,id=3Dvirtio-disk2-luks-secret0,\ +data=3D9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,\ +keyid=3DmasterKey0,iv=3DAAECAwQFBgcICQoLDA0ODw=3D=3D,format=3Dbase64 \ +-drive file=3Discsi://myname:AQCVn5hO6HzFAhAAq0NCv8jtJcIcE+HOBlMQ1A@exampl= e.org:\ +6000/iqn.1992-01.com.example%3Astorage/1,encrypt.format=3Dluks,\ +encrypt.key-secret=3Dvirtio-disk2-luks-secret0,format=3Dqcow2,if=3Dnone,\ +id=3Ddrive-virtio-disk2 \ +-device virtio-blk-pci,bus=3Dpci.0,addr=3D0x6,drive=3Ddrive-virtio-disk2,\ +id=3Dvirtio-disk2 \ +-object secret,id=3Dvirtio-disk3-luks-secret0,\ +data=3D9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,\ +keyid=3DmasterKey0,iv=3DAAECAwQFBgcICQoLDA0ODw=3D=3D,format=3Dbase64 \ +-drive file=3Discsi://iscsi.example.com:3260/demo-target/3,encrypt.format= =3Dluks,\ +encrypt.key-secret=3Dvirtio-disk3-luks-secret0,format=3Dqcow2,if=3Dnone,\ +id=3Ddrive-virtio-disk3 \ +-device virtio-blk-pci,bus=3Dpci.0,addr=3D0x7,drive=3Ddrive-virtio-disk3,\ +id=3Dvirtio-disk3 \ +-object secret,id=3Dvirtio-disk4-luks-secret0,\ +data=3D9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,\ +keyid=3DmasterKey0,iv=3DAAECAwQFBgcICQoLDA0ODw=3D=3D,format=3Dbase64 \ +-drive 'file=3Drbd:pool/image:auth_supported=3Dnone:mon_host=3Dmon1.exampl= e.org\:\ +6321\;mon2.example.org\:6322\;mon3.example.org\:6322,encrypt.format=3Dluks= ,\ +encrypt.key-secret=3Dvirtio-disk4-luks-secret0,format=3Dqcow2,if=3Dnone,\ +id=3Ddrive-virtio-disk4' \ +-device virtio-blk-pci,bus=3Dpci.0,addr=3D0x8,drive=3Ddrive-virtio-disk4,\ +id=3Dvirtio-disk4 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 diff --git a/tests/qemuxml2argvdata/luks-disks-source-qcow2.xml b/tests/qem= uxml2argvdata/luks-disks-source-qcow2.xml new file mode 100644 index 0000000000..92b31fb8bd --- /dev/null +++ b/tests/qemuxml2argvdata/luks-disks-source-qcow2.xml @@ -0,0 +1,81 @@ + + encryptdisk + 496898a6-e6ff-f7c8-5dc2-3cf410945ee9 + 1048576 + 524288 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + + + + + +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 3d278c4bc2..896d104593 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1700,6 +1700,8 @@ mymain(void) # ifdef HAVE_GNUTLS_CIPHER_ENCRYPT DO_TEST("luks-disks", QEMU_CAPS_OBJECT_SECRET); DO_TEST("luks-disks-source", QEMU_CAPS_OBJECT_SECRET); + DO_TEST_PARSE_ERROR("luks-disks-source-qcow2", QEMU_CAPS_OBJECT_SECRET= ); + DO_TEST("luks-disks-source-qcow2", QEMU_CAPS_OBJECT_SECRET, QEMU_CAPS_= QCOW2_LUKS); # else DO_TEST_FAILURE("luks-disks", QEMU_CAPS_OBJECT_SECRET); # endif --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 23:35:22 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522324313052853.3574355123391; Thu, 29 Mar 2018 04:51:53 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 774D3B179; Thu, 29 Mar 2018 11:51:51 +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 4050A5D730; Thu, 29 Mar 2018 11:51:51 +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 ED28B180BADB; Thu, 29 Mar 2018 11:51:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2TBpQEU016494 for ; Thu, 29 Mar 2018 07:51:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id E75F61102E2C; Thu, 29 Mar 2018 11:51:25 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 70D0A1102E2B; Thu, 29 Mar 2018 11:51:25 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 29 Mar 2018 13:51:10 +0200 Message-Id: <5c75377248e3b29b4710c6a36735251659e582db.1522323985.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 13/14] tests: qemuxml2argv: Allow testing of config processed at startup 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 29 Mar 2018 11:51:52 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add a new kind of XML output test for the files in qemuxml2argvtest where we can validate setup and defaults applied when starting up the VM. This is achieved by formatting of the definition processed by the qemuxml2argvtest into a XML and it's compared against files in qemuxml2startupxmloutdata. This test is automatically executed if the output file is present and it's skipped otherwise. The first example test case is created from 'disk-drive-shared' test case. Signed-off-by: Peter Krempa --- tests/Makefile.am | 1 + tests/qemuxml2argvtest.c | 42 +++++++++++++++- .../disk-drive-shared.xml | 56 ++++++++++++++++++= ++++ 3 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2startupxmloutdata/disk-drive-shared.xml diff --git a/tests/Makefile.am b/tests/Makefile.am index 289ef35bdd..f2f5caed4f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -127,6 +127,7 @@ EXTRA_DIST =3D \ qemuhotplugtestdomains \ qemumonitorjsondata \ qemuxml2argvdata \ + qemuxml2startupxmloutdata \ qemuxml2xmloutdata \ qemustatusxml2xmldata \ qemuqapischema.json \ diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 896d104593..7e7a937c8d 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -277,6 +277,7 @@ struct testInfo { unsigned int flags; unsigned int parseFlags; bool skipLegacyCPUs; + virDomainObjPtr vm; }; @@ -402,9 +403,39 @@ testUpdateQEMUCaps(const struct testInfo *info, static int -testCompareXMLToArgv(const void *data) +testCompareXMLToStartupXML(const void *data) { const struct testInfo *info =3D data; + unsigned int format_flags =3D VIR_DOMAIN_DEF_FORMAT_SECURE; + char *xml =3D NULL; + char *actual =3D NULL; + int ret =3D -1; + + if (virAsprintf(&xml, "%s/qemuxml2startupxmloutdata/%s.xml", + abs_srcdir, info->name) < 0) + goto cleanup; + + if (!virFileExists(xml)) { + ret =3D EXIT_AM_SKIP; + goto cleanup; + } + + if (!(actual =3D virDomainDefFormat(info->vm->def, NULL, format_flags)= )) + goto cleanup; + + ret =3D virTestCompareToFile(actual, xml); + + cleanup: + VIR_FREE(xml); + VIR_FREE(actual); + return ret; +} + + +static int +testCompareXMLToArgv(const void *data) +{ + struct testInfo *info =3D (void *) data; char *xml =3D NULL; char *args =3D NULL; char *migrateURI =3D NULL; @@ -532,6 +563,9 @@ testCompareXMLToArgv(const void *data) ret =3D 0; } + if (!(flags & FLAG_EXPECT_FAILURE) && ret =3D=3D 0) + VIR_STEAL_PTR(info->vm, vm); + cleanup: VIR_FREE(log); VIR_FREE(actualargv); @@ -625,7 +659,7 @@ mymain(void) do { \ static struct testInfo info =3D { \ name, NULL, migrateFrom, migrateFd, (flags), parseFlags, \ - false \ + false, NULL \ }; \ info.skipLegacyCPUs =3D skipLegacyCPUs; \ if (testInitQEMUCaps(&info, gic) < 0) \ @@ -634,7 +668,11 @@ mymain(void) if (virTestRun("QEMU XML-2-ARGV " name, \ testCompareXMLToArgv, &info) < 0) \ ret =3D -1; \ + if (info.vm && virTestRun("QEMU XML-2-startup-XML " name, \ + testCompareXMLToStartupXML, &info) < 0) \ + ret =3D -1; \ virObjectUnref(info.qemuCaps); \ + virObjectUnref(info.vm); \ } while (0) # define DO_TEST(name, ...) \ diff --git a/tests/qemuxml2startupxmloutdata/disk-drive-shared.xml b/tests/= qemuxml2startupxmloutdata/disk-drive-shared.xml new file mode 100644 index 0000000000..f4d2871ae7 --- /dev/null +++ b/tests/qemuxml2startupxmloutdata/disk-drive-shared.xml @@ -0,0 +1,56 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + XYZXYZXYZYXXYZYZYXYZY + +
+ + + + + + + +
+ + + +
+ + + +
+ + + + + + + + + + + + +
+ + + --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 23:35:22 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 152232431776248.23042509062634; Thu, 29 Mar 2018 04:51:57 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8199C9E608; Thu, 29 Mar 2018 11:51:40 +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 4997D5D781; Thu, 29 Mar 2018 11:51:40 +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 D85F64CAAF; Thu, 29 Mar 2018 11:51:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2TBpQVf016535 for ; Thu, 29 Mar 2018 07:51:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id A0D10100F2EE; Thu, 29 Mar 2018 11:51:26 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B6D910B00A2; Thu, 29 Mar 2018 11:51:26 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 29 Mar 2018 13:51:11 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 14/14] qemu: domain: Move initialization of disk cachemode for disks 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 29 Mar 2018 11:51:41 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The qemu command line generator code set disk caching of shareable disks to 'none' when formatting the command line silently. Move this code to a common place when preparing the domain definition for startup so that it does not have to be duplicated. The new test case shows that the actual cache mode will now be recorded in the live XML definition. Signed-off-by: Peter Krempa --- src/qemu/qemu_command.c | 2 -- src/qemu/qemu_domain.c | 11 +++++++++++ tests/qemuxml2startupxmloutdata/disk-drive-shared.xml | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c1225591b3..9e74ec64e9 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1804,8 +1804,6 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, if (disk->cachemode) { virBufferAsprintf(&opt, ",cache=3D%s", qemuDiskCacheV2TypeToString(disk->cachemode)); - } else if (disk->src->shared && !disk->src->readonly) { - virBufferAddLit(&opt, ",cache=3Dnone"); } if (disk->copy_on_read) { diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index cbad7d0f4c..d78a3cb255 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11891,11 +11891,22 @@ qemuDomainPrepareDiskSourceChain(virDomainDiskDef= Ptr disk, } +static void +qemuDomainPrepareDiskCachemode(virDomainDiskDefPtr disk) +{ + if (disk->cachemode =3D=3D VIR_DOMAIN_DISK_CACHE_DEFAULT && + disk->src->shared && !disk->src->readonly) + disk->cachemode =3D VIR_DOMAIN_DISK_CACHE_DISABLE; +} + + int qemuDomainPrepareDiskSource(virDomainDiskDefPtr disk, qemuDomainObjPrivatePtr priv, virQEMUDriverConfigPtr cfg) { + qemuDomainPrepareDiskCachemode(disk); + if (qemuDomainPrepareDiskSourceTLS(disk->src, cfg) < 0) return -1; diff --git a/tests/qemuxml2startupxmloutdata/disk-drive-shared.xml b/tests/= qemuxml2startupxmloutdata/disk-drive-shared.xml index f4d2871ae7..60b7eca788 100644 --- a/tests/qemuxml2startupxmloutdata/disk-drive-shared.xml +++ b/tests/qemuxml2startupxmloutdata/disk-drive-shared.xml @@ -15,7 +15,7 @@ /usr/bin/qemu-system-i686 - + --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list