From nobody Sat May 4 02:16:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1588858035; cv=none; d=zohomail.com; s=zohoarc; b=nlgNj7pTmVjj6ujvk4E6oXIOEdwtvjiC/0dZPh8FKVhni1Ye42Alog6YAsd2gQ7x3X5w1OBFALKZP+pAc5yscIXd3OzPUmvsEpfq3ie78cP6SJ1U7+0Bca3sRZ8n+LytQx4Gv1OAACuJ1GBrIYSBFqz5GRqif2LERWcMQfTEqHU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588858035; 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=1ufVVxku8abCa111OQmcx9Cwfcgt0rV1qgK/Wyg+5Pg=; b=gtfIgNLQKUYA8ayoOI1gD8pe24uOVkX3UWjKQQLZpgv6yA4b6LAUMEUbNP4do17hsGy1jhWzm+lyJdDC/DpBUI4JahV+RLthfUlomBF5OwLMzKux3sDXPtR8sQId/RPiqtlxtUMY0BV65gdtWJ0amJpKGtQ2ExnYbCavfqqHoTo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1588858035903919.3988300738625; Thu, 7 May 2020 06:27:15 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-364-3LJsqM-DNUGkyJs2h5AFoQ-1; Thu, 07 May 2020 09:27:11 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 24E9D800687; Thu, 7 May 2020 13:27:06 +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 A679C62A9F; Thu, 7 May 2020 13:27:05 +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 EDFA71809543; Thu, 7 May 2020 13:27:03 +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 047DR2w2023324 for ; Thu, 7 May 2020 09:27:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0CA1E10016EB; Thu, 7 May 2020 13:27:02 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E23E10013BD for ; Thu, 7 May 2020 13:27:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588858034; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=1ufVVxku8abCa111OQmcx9Cwfcgt0rV1qgK/Wyg+5Pg=; b=SE74MEZC9eh+SeZsG1PCdC5paNb5WcGJIzxUPmFkguNQEuANPGgR4uyTjmTmYBHRV+PhC/ nlt04nK7eM12VCRZZRgX3t2OjQ+luQ6RCFreBPY3LSBblILlYRkkAu4YeoDrNhjj/2BAUT 3EDVwB9sEiWLXqssupmstZ00c99gyDI= X-MC-Unique: 3LJsqM-DNUGkyJs2h5AFoQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/2] conf: Sanitize handling of and placement for disks Date: Thu, 7 May 2020 15:26:54 +0200 Message-Id: <505716cd483e64a9f6339dfa2e54b039dcf5b7e7.1588857971.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 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: , 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Modern way to store and of a is under . This was added to mirror how handles these and in fact they are relevant to the source rather than to any other part of the disk. Historically we allowed them to be directly under and we need to keep compatibility. This wasn't a problem until introduction of -blockdev in qemu using of or plainly wouldn't work with backing chains. Now that it works in backing chains and can be moved back and forth using snapshots/block-commit we need to ensure that the original placement is properly kept even if the source changes. To achieve the above semantics we need to store the preferred placement with the disk definition rather than the storage source definitions and also ensure that the modern way is chosen when the VM started with only in the backing store. https://bugzilla.redhat.com/show_bug.cgi?id=3D1822878 Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/backup_conf.c | 3 +- src/conf/domain_conf.c | 97 ++++++++++++++++----------------------- src/conf/domain_conf.h | 6 ++- src/conf/snapshot_conf.c | 4 +- src/qemu/qemu_domain.c | 6 ++- src/util/virstoragefile.c | 1 - src/util/virstoragefile.h | 2 - tests/qemublocktest.c | 4 +- tests/virstoragetest.c | 3 +- 9 files changed, 57 insertions(+), 69 deletions(-) diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c index c5677cdb05..c0c6f25d10 100644 --- a/src/conf/backup_conf.c +++ b/src/conf/backup_conf.c @@ -349,7 +349,8 @@ virDomainBackupDiskDefFormat(virBufferPtr buf, virStorageFileFormatTypeToString(disk->s= tore->format)); if (virDomainDiskSourceFormat(&childBuf, disk->store, sourcename, - 0, false, storageSourceFormatFlags, = true, NULL) < 0) + 0, false, storageSourceFormatFlags, + false, false, NULL) < 0) return -1; } diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 83748354b0..84eadb5659 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10469,31 +10469,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xml= opt, if (virDomainStorageSourceParse(cur, ctxt, def->src, flags, xm= lopt) < 0) goto error; - /* If we've already found an as a child of and - * we find one as a child of , then force an error to - * avoid ambiguity */ - if (authdef && def->src->auth) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("an definition already found for " - "the definition")); - goto error; - } - - if (def->src->auth) - def->src->authInherited =3D true; - - /* Similarly for - it's a child of too - * and we cannot find in both places */ - if (encryption && def->src->encryption) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("an definition already found= for " - "the definition")); - goto error; - } - - if (def->src->encryption) - def->src->encryptionInherited =3D true; - source =3D true; startupPolicy =3D virXMLPropString(cur, "startupPolicy"); @@ -10558,17 +10533,9 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xml= opt, goto error; } else if (!authdef && virXMLNodeNameEqual(cur, "auth")) { - /* If we've already parsed and found an child, - * then generate an error to avoid ambiguity */ - if (def->src->authInherited) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("an definition already found for " - "disk source")); - goto error; - } - if (!(authdef =3D virStorageAuthDefParse(cur, ctxt))) goto error; + def->diskElementAuth =3D true; } else if (virXMLNodeNameEqual(cur, "iotune")) { if (virDomainDiskDefIotuneParse(def, ctxt) < 0) goto error; @@ -10580,17 +10547,11 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xm= lopt, def->transient =3D true; } else if (!encryption && virXMLNodeNameEqual(cur, "encryption")) { - /* If we've already parsed and found an = child, - * then generate an error to avoid ambiguity */ - if (def->src->encryptionInherited) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("an definition already found= for " - "disk source")); - goto error; - } - if (!(encryption =3D virStorageEncryptionParseNode(cur, ctxt))) goto error; + + def->diskElementEnc =3D true; + } else if (!serial && virXMLNodeNameEqual(cur, "serial")) { serial =3D (char *)xmlNodeGetContent(cur); @@ -10783,10 +10744,31 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xm= lopt, } def->dst =3D g_steal_pointer(&target); - if (authdef) + if (authdef) { + /* If we've already parsed and found an child, + * then generate an error to avoid ambiguity */ + if (def->src->auth) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("an definition already found for " + "disk source")); + goto error; + } + def->src->auth =3D g_steal_pointer(&authdef); - if (encryption) + } + + if (encryption) { + /* If we've already parsed and found an = child, + * then generate an error to avoid ambiguity */ + if (def->src->encryption) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("an definition already found= for " + "disk source")); + goto error; + } + def->src->encryption =3D g_steal_pointer(&encryption); + } def->domain_name =3D g_steal_pointer(&domain_name); def->serial =3D g_steal_pointer(&serial); def->wwn =3D g_steal_pointer(&wwn); @@ -25044,7 +25026,8 @@ virDomainDiskSourceFormatSlices(virBufferPtr buf, * @policy: startup policy attribute value, if necessary * @attrIndex: the 'index' attribute of is formatted if true * @flags: XML formatter flags - * @formatsecrets: Force formatting of and under + * @skipAuth: Skip formatting of + * @skipEnc: Skip formatting of * regardless of the original definition state * @xmlopt: XML formatter callbacks * @@ -25058,7 +25041,8 @@ virDomainDiskSourceFormat(virBufferPtr buf, int policy, bool attrIndex, unsigned int flags, - bool formatsecrets, + bool skipAuth, + bool skipEnc, virDomainXMLOptionPtr xmlopt) { g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; @@ -25117,13 +25101,10 @@ virDomainDiskSourceFormat(virBufferPtr buf, * for a volume source type. The information is * kept in the storage pool and would be overwritten anyway. * So avoid formatting it for volumes. */ - if (src->auth && (src->authInherited || formatsecrets) && - src->type !=3D VIR_STORAGE_TYPE_VOLUME) + if (src->auth && !skipAuth && src->type !=3D VIR_STORAGE_TYPE_VOLUME) virStorageAuthDefFormat(&childBuf, src->auth); - /* If we found encryption as a child of , then format it - * as we found it. */ - if (src->encryption && (src->encryptionInherited || formatsecrets) && + if (src->encryption && !skipEnc && virStorageEncryptionFormat(&childBuf, src->encryption) < 0) return -1; @@ -25184,7 +25165,7 @@ virDomainDiskBackingStoreFormat(virBufferPtr buf, virBufferAsprintf(&childBuf, "\n", virStorageFileFormatTypeToString(backingStore->forma= t)); if (virDomainDiskSourceFormat(&childBuf, backingStore, "source", 0, fa= lse, - flags, true, xmlopt) < 0) + flags, false, false, xmlopt) < 0) return -1; if (virDomainDiskBackingStoreFormat(&childBuf, backingStore, xmlopt, f= lags) < 0) @@ -25346,7 +25327,7 @@ virDomainDiskDefFormatMirror(virBufferPtr buf, virBufferEscapeString(&childBuf, "\n", formatStr); if (virDomainDiskSourceFormat(&childBuf, disk->mirror, "source", 0, tr= ue, - flags, true, xmlopt) < 0) + flags, false, false, xmlopt) < 0) return -1; if (virDomainDiskBackingStoreFormat(&childBuf, disk->mirror, xmlopt, f= lags) < 0) @@ -25441,11 +25422,13 @@ virDomainDiskDefFormat(virBufferPtr buf, /* Format as child of if defined there; otherwise, * if defined as child of , then format later */ - if (def->src->auth && !def->src->authInherited) + if (def->src->auth && def->diskElementAuth) virStorageAuthDefFormat(buf, def->src->auth); if (virDomainDiskSourceFormat(buf, def->src, "source", def->startupPol= icy, - true, flags, false, xmlopt) < 0) + true, flags, + def->diskElementAuth, def->diskElementEn= c, + xmlopt) < 0) return -1; /* Don't format backingStore to inactive XMLs until the code for @@ -25491,7 +25474,7 @@ virDomainDiskDefFormat(virBufferPtr buf, /* If originally found as a child of , then format thusly; * otherwise, will be formatted as child of */ - if (def->src->encryption && !def->src->encryptionInherited && + if (def->src->encryption && def->diskElementEnc && virStorageEncryptionFormat(buf, def->src->encryption) < 0) return -1; if (virDomainDeviceInfoFormat(buf, &def->info, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 4afd8f04bc..ddc75d8de2 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -579,6 +579,9 @@ struct _virDomainDiskDef { unsigned int queues; int model; /* enum virDomainDiskModel */ virDomainVirtioOptionsPtr virtio; + + bool diskElementAuth; + bool diskElementEnc; }; @@ -3233,7 +3236,8 @@ int virDomainDiskSourceFormat(virBufferPtr buf, int policy, bool attrIndex, unsigned int flags, - bool formatsecrets, + bool skipAuth, + bool skipEnc, virDomainXMLOptionPtr xmlopt); int diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 37b5c2fdf7..98c296b276 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -818,8 +818,8 @@ virDomainSnapshotDiskDefFormat(virBufferPtr buf, if (disk->src->format > 0) virBufferEscapeString(buf, "\n", virStorageFileFormatTypeToString(disk->src->= format)); - if (virDomainDiskSourceFormat(buf, disk->src, "source", 0, false, 0, t= rue, - xmlopt) < 0) + if (virDomainDiskSourceFormat(buf, disk->src, "source", 0, false, 0, + false, false, xmlopt) < 0) return -1; virBufferAdjustIndent(buf, -2); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 9c629c31a3..a22cb4ed30 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2603,7 +2603,8 @@ qemuDomainObjPrivateXMLFormatBlockjobFormatSource(vir= BufferPtr buf, virStorageTypeToString(src->type), virStorageFileFormatTypeToString(src->format)); - if (virDomainDiskSourceFormat(&childBuf, src, "source", 0, true, xmlfl= ags, true, xmlopt) < 0) + if (virDomainDiskSourceFormat(&childBuf, src, "source", 0, true, xmlfl= ags, + false, false, xmlopt) < 0) return -1; if (chain && @@ -2823,7 +2824,8 @@ qemuDomainObjPrivateXMLFormatNBDMigrationSource(virBu= fferPtr buf, virStorageFileFormatTypeToString(src->format)); if (virDomainDiskSourceFormat(&childBuf, src, "source", 0, false, - VIR_DOMAIN_DEF_FORMAT_STATUS, true, xmlo= pt) < 0) + VIR_DOMAIN_DEF_FORMAT_STATUS, + false, false, xmlopt) < 0) return -1; virXMLFormatElement(buf, "migrationSource", &attrBuf, &childBuf); diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index ff9a6c6663..535a94e239 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2999,7 +2999,6 @@ virStorageSourceParseRBDColonString(const char *rbdst= r, authdef->secrettype =3D g_strdup(virSecretUsageTypeToString(VI= R_SECRET_USAGE_TYPE_CEPH)); src->auth =3D g_steal_pointer(&authdef); - src->authInherited =3D true; /* Cannot formulate a secretType (eg, usage or uuid) given * what is provided. diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index d56d5c45e3..c68bdc9680 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -291,9 +291,7 @@ struct _virStorageSource { virStorageNetCookieDefPtr *cookies; virStorageSourcePoolDefPtr srcpool; virStorageAuthDefPtr auth; - bool authInherited; virStorageEncryptionPtr encryption; - bool encryptionInherited; virStoragePRDefPtr pr; virTristateBool sslverify; /* both values below have 0 as default value */ diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 8001807552..9ac506c78b 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -111,8 +111,8 @@ testBackingXMLjsonXML(const void *args) return -1; } - if (virDomainDiskSourceFormat(&buf, jsonsrc, "source", 0, false, 0, tr= ue, - NULL) < 0 || + if (virDomainDiskSourceFormat(&buf, jsonsrc, "source", 0, false, 0, + false, false, NULL) < 0 || !(actualxml =3D virBufferContentAndReset(&buf))) { fprintf(stderr, "failed to format disk source xml\n"); return -1; diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index ac1480de4e..98f47f0e41 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -614,7 +614,8 @@ testBackingParse(const void *args) return -1; } - if (virDomainDiskSourceFormat(&buf, src, "source", 0, false, xmlformat= flags, true, NULL) < 0 || + if (virDomainDiskSourceFormat(&buf, src, "source", 0, false, xmlformat= flags, + false, false, NULL) < 0 || !(xml =3D virBufferContentAndReset(&buf))) { fprintf(stderr, "failed to format disk source xml\n"); return -1; --=20 2.26.2 From nobody Sat May 4 02:16:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1588858042; cv=none; d=zohomail.com; s=zohoarc; b=V/Th23cNcXFTdpnQCP8c6RtcKqPfRgqHLGDXDDSP744PBCIUU/jZjwedHvlvTsrRODU8T802gtdd19Jkr4y84ptzHMqBLJxiL7+6h1Egf1awmUnMF1Jd0y6z/MZRR+uJS2T22nCGm3oiFyfHCWWdg3zh2ELunPDjfAQieK6Aq6g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588858042; 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=RiKZzD47fpwRM3ns7MTSp96dalRJsw962Rx0w3YzClA=; b=WGw+OQ6XpFZbL9gKWiZXrEMaLX/YsacCqJQISrzH8BH3cOZg6u0DI4OuLMMqad/zrMRYrcdE9qk4734N2cuR5M4jEyxJXzpu0EgHWB4DJ+ehRJoRje2MPG/1RBzZxA/dPx7pR7apC4IyLnfVu3rURKgUC9w4zRQ8tuR9u6XVcRE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1588858042978860.73810100194; Thu, 7 May 2020 06:27:22 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-507-KNZMSD_jNtCbYdYRRzwSRA-1; Thu, 07 May 2020 09:27:19 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 20C7F81A3FF; Thu, 7 May 2020 13:27:14 +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 EF8837055D; Thu, 7 May 2020 13:27:13 +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 AD9734CAA0; Thu, 7 May 2020 13:27:13 +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 047DR3F3023332 for ; Thu, 7 May 2020 09:27:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0220010016EB; Thu, 7 May 2020 13:27:03 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 68B1D10013BD for ; Thu, 7 May 2020 13:27:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588858041; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=RiKZzD47fpwRM3ns7MTSp96dalRJsw962Rx0w3YzClA=; b=QDat8C0gh/zBW1aLF6SkvYVXpehCfJAFpK5vwiXZahwLADjxqIpeR+s5C5KM7blm7rtPDF cgfq3J7PgZZUpj3ozgKDzxWHVpIcwQRGlsV4ifDFERrBG9pIQpU9+avQl9UpQb6hQVq6vg sVAWaZryX7qOq4qN19ra6/4s9LaqGEU= X-MC-Unique: KNZMSD_jNtCbYdYRRzwSRA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/2] conf: Store 'diskElementAuth' and 'diskElementEnc' properties in status XML Date: Thu, 7 May 2020 15:26:55 +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 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: , 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Remember the preferred placement of and for a disk source across libvirtd restarts. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 20 ++++++++++++++++++++ tests/qemustatusxml2xmldata/modern-in.xml | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 84eadb5659..c201fc901d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10593,6 +10593,13 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xml= opt, } } else if (virXMLNodeNameEqual(cur, "boot")) { /* boot is parsed as part of virDomainDeviceInfoParseXML */ + } else if ((flags & VIR_DOMAIN_DEF_PARSE_STATUS) && + virXMLNodeNameEqual(cur, "diskSecretsPlacement")) { + g_autofree char *secretAuth =3D virXMLPropString(cur, "auth"); + g_autofree char *secretEnc =3D virXMLPropString(cur, "enc"); + + def->diskElementAuth =3D !!secretAuth; + def->diskElementEnc =3D !!secretEnc; } } @@ -25485,6 +25492,19 @@ virDomainDiskDefFormat(virBufferPtr buf, if (virDomainDiskDefFormatPrivateData(buf, def, flags, xmlopt) < 0) return -1; + /* format diskElementAuth and diskElementEnc into status XML to preser= ve + * formatting */ + if (flags & VIR_DOMAIN_DEF_FORMAT_STATUS) { + g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + + if (def->diskElementAuth) + virBufferAddLit(&attrBuf, " auth=3D'true'"); + if (def->diskElementEnc) + virBufferAddLit(&attrBuf, " enc=3D'true'"); + + virXMLFormatElement(buf, "diskSecretsPlacement", &attrBuf, NULL); + } + virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); return 0; diff --git a/tests/qemustatusxml2xmldata/modern-in.xml b/tests/qemustatusxm= l2xmldata/modern-in.xml index cb56cdcef9..64d42200e4 100644 --- a/tests/qemustatusxml2xmldata/modern-in.xml +++ b/tests/qemustatusxml2xmldata/modern-in.xml @@ -308,6 +308,9 @@ /usr/bin/qemu-system-x86_64 + + + @@ -348,6 +351,7 @@ + --=20 2.26.2