From nobody Sun May 5 23:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.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 207.211.31.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=1575469326; cv=none; d=zohomail.com; s=zohoarc; b=BEZB04xuCKJ4X+OMMVb/aKmRC/JKmLVelpOr7e6kxeypqH8lu1OwLBw9hF0yMlWhsD9kb0jF2vFbNi88AMv30xOirJrog98rGabVzaAoXNmUI4vBou7mbs0lWSyezpZvEXFu4Eruo7pIe36aFCgcTm+Adn3g0TnLDJqz2QeIzKk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469326; 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=nO98ljpb8ucs9/JKfk+Ka5zKAcewbNt2TveexYAN2ew=; b=f2tshdx1FO2tCTFnn4JhU1zie+bPDft5OTkQoUD+0lk4l5xHmctHGAujtZ8FggQTQ6LqRQk+6AVZWylr5x6VkQ3FdXaQVsz6wqY3VbHHAFQ6iU7hUXmnoYEHPJ+P7377hUxHPOaGVmSaeBOwZ1K/cVFczFGXn0XzmCGuTmRAN08= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.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 [207.211.31.120]) by mx.zohomail.com with SMTPS id 1575469326206153.64037033758882; Wed, 4 Dec 2019 06:22:06 -0800 (PST) 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-207-_YPJyPwXOCGvnVTAxoNxdg-1; Wed, 04 Dec 2019 09:21:44 -0500 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 263068D0936; Wed, 4 Dec 2019 14:21: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 F01665D6AE; Wed, 4 Dec 2019 14:21:35 +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 A2A2E5BC12; Wed, 4 Dec 2019 14:21:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4ELKtq008062 for ; Wed, 4 Dec 2019 09:21:20 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0B39B691A7; Wed, 4 Dec 2019 14:21:20 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id E88DA691A2; Wed, 4 Dec 2019 14:21:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469325; 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=nO98ljpb8ucs9/JKfk+Ka5zKAcewbNt2TveexYAN2ew=; b=R00qaSsc2MtzxlvhXLWFiuEnO6wLVx2qHv2bbvWOQICk5/UsXhzE+kKjeeb04XIv3JKaP/ 1qHDp2Ojps0oVVQwgwg7yDnopUjG2YThYYBw/hSvHIaPsEOhAUi4AL0s96BMqYjFF4N/TV IFSNyAcSdHMkcHv3CuBbb19XjPX0SnY= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:20:44 +0000 Message-Id: <20191204142113.2961028-2-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 01/30] qemu: cache host arch separately from virCapsPtr 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-MC-Unique: _YPJyPwXOCGvnVTAxoNxdg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) As part of a goal to eliminate the need to use virCapsPtr for anything other than the virConnectGetCapabilies() API impl, cache the host arch against the QEMU driver struct and use that field directly. In the tests we move virArchFromHost() globally in testutils.c so that every test runs with a fixed default architecture reported. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/qemu/qemu_capabilities.c | 20 ++++++++++---------- src/qemu/qemu_capabilities.h | 6 +++--- src/qemu/qemu_command.c | 6 +----- src/qemu/qemu_conf.c | 6 +----- src/qemu/qemu_conf.h | 3 +++ src/qemu/qemu_domain.c | 8 ++++---- src/qemu/qemu_driver.c | 3 ++- src/qemu/qemu_process.c | 14 +++++++------- tests/domaincapstest.c | 2 +- tests/qemumemlocktest.c | 4 ++-- tests/qemuxml2argvtest.c | 16 ++++++++-------- tests/testutils.c | 9 +++++++++ tests/testutils.h | 2 ++ tests/testutilsqemu.c | 11 ++++++++--- tests/testutilsqemu.h | 4 ++-- 15 files changed, 63 insertions(+), 51 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index edb128c881..cfc16ba63e 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2096,7 +2096,7 @@ virQEMUCapsSetHostModel(virQEMUCapsPtr qemuCaps, =20 bool virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps, - virCapsPtr caps, + virArch hostarch, virDomainVirtType type, virCPUMode mode) { @@ -2105,7 +2105,7 @@ virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps, switch (mode) { case VIR_CPU_MODE_HOST_PASSTHROUGH: return type =3D=3D VIR_DOMAIN_VIRT_KVM && - virQEMUCapsGuestIsNative(caps->host.arch, qemuCaps->arch); + virQEMUCapsGuestIsNative(hostarch, qemuCaps->arch); =20 case VIR_CPU_MODE_HOST_MODEL: return !!virQEMUCapsGetHostModel(qemuCaps, type, @@ -5412,22 +5412,22 @@ virQEMUCapsFillDomainOSCaps(virDomainCapsOSPtr os, =20 =20 static void -virQEMUCapsFillDomainCPUCaps(virCapsPtr caps, - virQEMUCapsPtr qemuCaps, +virQEMUCapsFillDomainCPUCaps(virQEMUCapsPtr qemuCaps, + virArch hostarch, virDomainCapsPtr domCaps) { - if (virQEMUCapsIsCPUModeSupported(qemuCaps, caps, domCaps->virttype, + if (virQEMUCapsIsCPUModeSupported(qemuCaps, hostarch, domCaps->virttyp= e, VIR_CPU_MODE_HOST_PASSTHROUGH)) domCaps->cpu.hostPassthrough =3D true; =20 - if (virQEMUCapsIsCPUModeSupported(qemuCaps, caps, domCaps->virttype, + if (virQEMUCapsIsCPUModeSupported(qemuCaps, hostarch, domCaps->virttyp= e, VIR_CPU_MODE_HOST_MODEL)) { virCPUDefPtr cpu =3D virQEMUCapsGetHostModel(qemuCaps, domCaps->vi= rttype, VIR_QEMU_CAPS_HOST_CPU_= REPORTED); domCaps->cpu.hostModel =3D virCPUDefCopy(cpu); } =20 - if (virQEMUCapsIsCPUModeSupported(qemuCaps, caps, domCaps->virttype, + if (virQEMUCapsIsCPUModeSupported(qemuCaps, hostarch, domCaps->virttyp= e, VIR_CPU_MODE_CUSTOM)) { const char *blacklist[] =3D { "host", NULL }; VIR_AUTOSTRINGLIST models =3D NULL; @@ -5746,9 +5746,9 @@ virQEMUCapsFillDomainFeatureSEVCaps(virQEMUCapsPtr qe= muCaps, =20 =20 int -virQEMUCapsFillDomainCaps(virCapsPtr caps, +virQEMUCapsFillDomainCaps(virQEMUCapsPtr qemuCaps, + virArch hostarch, virDomainCapsPtr domCaps, - virQEMUCapsPtr qemuCaps, bool privileged, virFirmwarePtr *firmwares, size_t nfirmwares) @@ -5781,7 +5781,7 @@ virQEMUCapsFillDomainCaps(virCapsPtr caps, firmwares, nfirmwares) < 0) return -1; =20 - virQEMUCapsFillDomainCPUCaps(caps, qemuCaps, domCaps); + virQEMUCapsFillDomainCPUCaps(qemuCaps, hostarch, domCaps); virQEMUCapsFillDomainDeviceDiskCaps(qemuCaps, domCaps->machine, disk); virQEMUCapsFillDomainDeviceGraphicsCaps(qemuCaps, graphics); virQEMUCapsFillDomainDeviceVideoCaps(qemuCaps, video); diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 4d7d836e8c..399496796d 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -604,7 +604,7 @@ int virQEMUCapsGetCPUFeatures(virQEMUCapsPtr qemuCaps, char ***features); =20 bool virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps, - virCapsPtr caps, + virArch hostarch, virDomainVirtType type, virCPUMode mode); const char *virQEMUCapsGetCanonicalMachine(virQEMUCapsPtr qemuCaps, @@ -665,9 +665,9 @@ int virQEMUCapsInitGuestFromBinary(virCapsPtr caps, virQEMUCapsPtr qemuCaps, virArch guestarch); =20 -int virQEMUCapsFillDomainCaps(virCapsPtr caps, +int virQEMUCapsFillDomainCaps(virQEMUCapsPtr qemuCaps, + virArch hostarch, virDomainCapsPtr domCaps, - virQEMUCapsPtr qemuCaps, bool privileged, virFirmwarePtr *firmwares, size_t nfirmwares); diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3465d28b84..49a0dad8d4 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6657,18 +6657,14 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver, virQEMUCapsPtr qemuCaps) { size_t i; - g_autoptr(virCaps) caps =3D NULL; virCPUDefPtr cpu =3D def->cpu; =20 - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - return -1; - switch ((virCPUMode) cpu->mode) { case VIR_CPU_MODE_HOST_PASSTHROUGH: virBufferAddLit(buf, "host"); =20 if (def->os.arch =3D=3D VIR_ARCH_ARMV7L && - caps->host.arch =3D=3D VIR_ARCH_AARCH64) { + driver->hostarch =3D=3D VIR_ARCH_AARCH64) { if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CPU_AARCH64_OFF)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("QEMU binary does not support CPU " diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 30637b21ac..53658c80e8 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1341,7 +1341,6 @@ virQEMUDriverGetDomainCapabilities(virQEMUDriverPtr d= river, virDomainVirtType virttype) { g_autoptr(virDomainCaps) domCaps =3D NULL; - g_autoptr(virCaps) caps =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); virHashTablePtr domCapsCache =3D virQEMUCapsGetDomainCapsCache(qemuCap= s); struct virQEMUDriverSearchDomcapsData data =3D { @@ -1351,9 +1350,6 @@ virQEMUDriverGetDomainCapabilities(virQEMUDriverPtr d= river, .virttype =3D virttype, }; =20 - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - return NULL; - domCaps =3D virHashSearch(domCapsCache, virQEMUDriverSearchDomcaps, &data, NULL); if (!domCaps) { @@ -1364,7 +1360,7 @@ virQEMUDriverGetDomainCapabilities(virQEMUDriverPtr d= river, data.arch, data.virttype))) return NULL; =20 - if (virQEMUCapsFillDomainCaps(caps, domCaps, qemuCaps, + if (virQEMUCapsFillDomainCaps(qemuCaps, driver->hostarch, domCaps, driver->privileged, cfg->firmwares, cfg->nfirmwares) < 0) return NULL; diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 95b33a1093..7c56226b8c 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -262,6 +262,9 @@ struct _virQEMUDriver { */ virCapsPtr caps; =20 + /* Immutable value */ + virArch hostarch; + /* Immutable pointer, Immutable object */ virDomainXMLOptionPtr xmlopt; =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 470d342afc..939e6fc01c 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4446,7 +4446,7 @@ qemuDomainDefVcpusPostParse(virDomainDefPtr def) =20 static int qemuDomainDefSetDefaultCPU(virDomainDefPtr def, - virCapsPtr caps, + virArch hostarch, virQEMUCapsPtr qemuCaps) { const char *model; @@ -4484,7 +4484,7 @@ qemuDomainDefSetDefaultCPU(virDomainDefPtr def, =20 if (STREQ(model, "host")) { if (ARCH_IS_S390(def->os.arch) && - virQEMUCapsIsCPUModeSupported(qemuCaps, caps, def->virtType, + virQEMUCapsIsCPUModeSupported(qemuCaps, hostarch, def->virtTyp= e, VIR_CPU_MODE_HOST_MODEL)) { def->cpu->mode =3D VIR_CPU_MODE_HOST_MODEL; } else { @@ -4691,7 +4691,7 @@ qemuDomainDefPostParseBasic(virDomainDefPtr def, =20 static int qemuDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags, void *opaque, void *parseOpaque) @@ -4723,7 +4723,7 @@ qemuDomainDefPostParse(virDomainDefPtr def, if (qemuCanonicalizeMachine(def, qemuCaps) < 0) return -1; =20 - if (qemuDomainDefSetDefaultCPU(def, caps, qemuCaps) < 0) + if (qemuDomainDefSetDefaultCPU(def, driver->hostarch, qemuCaps) < 0) return -1; =20 qemuDomainDefEnableDefaultFeatures(def, qemuCaps); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 1911073f3e..594b683b80 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -673,6 +673,7 @@ qemuStateInitialize(bool privileged, qemu_driver->inhibitOpaque =3D opaque; =20 qemu_driver->privileged =3D privileged; + qemu_driver->hostarch =3D virArchFromHost(); =20 if (!(qemu_driver->domains =3D virDomainObjListNew())) goto error; @@ -13418,7 +13419,7 @@ qemuConnectCompareCPU(virConnectPtr conn, if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) return VIR_CPU_COMPARE_ERROR; =20 - return virCPUCompareXML(caps->host.arch, caps->host.cpu, + return virCPUCompareXML(driver->hostarch, caps->host.cpu, xmlDesc, failIncompatible); } =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 75ee3893c6..480fcd075d 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6047,7 +6047,7 @@ qemuProcessDropUnknownCPUFeatures(const char *name, static int qemuProcessUpdateGuestCPU(virDomainDefPtr def, virQEMUCapsPtr qemuCaps, - virCapsPtr caps, + virArch hostarch, unsigned int flags) { if (!def->cpu) @@ -6069,7 +6069,7 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def, def->cpu->mode =3D VIR_CPU_MODE_CUSTOM; } =20 - if (!virQEMUCapsIsCPUModeSupported(qemuCaps, caps, def->virtType, + if (!virQEMUCapsIsCPUModeSupported(qemuCaps, hostarch, def->virtType, def->cpu->mode)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("CPU mode '%s' for %s %s domain on %s host is not= " @@ -6077,11 +6077,11 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def, virCPUModeTypeToString(def->cpu->mode), virArchToString(def->os.arch), virDomainVirtTypeToString(def->virtType), - virArchToString(caps->host.arch)); + virArchToString(hostarch)); return -1; } =20 - if (virCPUConvertLegacy(caps->host.arch, def->cpu) < 0) + if (virCPUConvertLegacy(hostarch, def->cpu) < 0) return -1; =20 /* nothing to update for host-passthrough */ @@ -6089,7 +6089,7 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def, g_autoptr(virDomainCapsCPUModels) cpuModels =3D NULL; =20 if (def->cpu->check =3D=3D VIR_CPU_CHECK_PARTIAL && - virCPUCompare(caps->host.arch, + virCPUCompare(hostarch, virQEMUCapsGetHostModel(qemuCaps, def->virtType, VIR_QEMU_CAPS_HOST_CPU_F= ULL), def->cpu, true) < 0) @@ -6351,7 +6351,7 @@ qemuProcessPrepareDomain(virQEMUDriverPtr driver, priv->pausedReason =3D VIR_DOMAIN_PAUSED_UNKNOWN; =20 VIR_DEBUG("Updating guest CPU definition"); - if (qemuProcessUpdateGuestCPU(vm->def, priv->qemuCaps, caps, flags) < = 0) + if (qemuProcessUpdateGuestCPU(vm->def, priv->qemuCaps, driver->hostarc= h, flags) < 0) goto cleanup; =20 for (i =3D 0; i < vm->def->nshmems; i++) @@ -7825,7 +7825,7 @@ qemuProcessRefreshCPU(virQEMUDriverPtr driver, if (!caps) return -1; =20 - if (!virQEMUCapsGuestIsNative(caps->host.arch, vm->def->os.arch) || + if (!virQEMUCapsGuestIsNative(driver->hostarch, vm->def->os.arch) || !caps->host.cpu || !vm->def->cpu) { ret =3D 0; diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index c6700f7e78..94e5831706 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -106,7 +106,7 @@ fillQemuCaps(virDomainCapsPtr domCaps, if (!domCaps->machine) domCaps->machine =3D g_strdup(virQEMUCapsGetPreferredMachine(qemuC= aps, virtType)); =20 - if (virQEMUCapsFillDomainCaps(caps, domCaps, qemuCaps, + if (virQEMUCapsFillDomainCaps(qemuCaps, caps->host.arch, domCaps, false, cfg->firmwares, cfg->nfirmwares) < 0) diff --git a/tests/qemumemlocktest.c b/tests/qemumemlocktest.c index ef3bfa0345..55f65dcb6a 100644 --- a/tests/qemumemlocktest.c +++ b/tests/qemumemlocktest.c @@ -101,7 +101,7 @@ mymain(void) * ensure settings are prioritized as expected. */ =20 - qemuTestSetHostArch(driver.caps, VIR_ARCH_X86_64); + qemuTestSetHostArch(&driver, VIR_ARCH_X86_64); =20 DO_TEST("pc-kvm", 0); DO_TEST("pc-tcg", 0); @@ -115,7 +115,7 @@ mymain(void) DO_TEST("pc-hardlimit+locked+hostdev", 2147483648); DO_TEST("pc-locked+hostdev", VIR_DOMAIN_MEMORY_PARAM_UNLIMITED); =20 - qemuTestSetHostArch(driver.caps, VIR_ARCH_PPC64); + qemuTestSetHostArch(&driver, VIR_ARCH_PPC64); if (!(qemuCaps =3D virQEMUCapsNew())) { ret =3D -1; goto cleanup; diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 86b8899921..546cdae245 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -413,7 +413,7 @@ testCompareXMLToArgv(const void *data) qemuDomainObjPrivatePtr priv =3D NULL; =20 if (info->arch !=3D VIR_ARCH_NONE && info->arch !=3D VIR_ARCH_X86_64) - qemuTestSetHostArch(driver.caps, info->arch); + qemuTestSetHostArch(&driver, info->arch); =20 memset(&monitor_chr, 0, sizeof(monitor_chr)); =20 @@ -584,7 +584,7 @@ testCompareXMLToArgv(const void *data) virObjectUnref(conn); VIR_FREE(migrateURI); if (info->arch !=3D VIR_ARCH_NONE && info->arch !=3D VIR_ARCH_X86_64) - qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE); + qemuTestSetHostArch(&driver, VIR_ARCH_NONE); =20 return ret; } @@ -1724,11 +1724,11 @@ mymain(void) DO_TEST("cpu-host-passthrough", QEMU_CAPS_KVM); DO_TEST_FAILURE("cpu-qemu-host-passthrough", QEMU_CAPS_KVM); =20 - qemuTestSetHostArch(driver.caps, VIR_ARCH_S390X); + qemuTestSetHostArch(&driver, VIR_ARCH_S390X); DO_TEST("cpu-s390-zEC12", QEMU_CAPS_KVM, QEMU_CAPS_CCW, QEMU_CAPS_VIRT= IO_S390); DO_TEST("cpu-s390-features", QEMU_CAPS_KVM, QEMU_CAPS_QUERY_CPU_MODEL_= EXPANSION); DO_TEST_FAILURE("cpu-s390-features", QEMU_CAPS_KVM); - qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE); + qemuTestSetHostArch(&driver, VIR_ARCH_NONE); =20 qemuTestSetHostCPU(driver.caps, cpuHaswell); DO_TEST("cpu-Haswell", QEMU_CAPS_KVM); @@ -1855,7 +1855,7 @@ mymain(void) QEMU_CAPS_DEVICE_SPAPR_VTY); DO_TEST_PARSE_ERROR("pseries-no-parallel", NONE); =20 - qemuTestSetHostArch(driver.caps, VIR_ARCH_PPC64); + qemuTestSetHostArch(&driver, VIR_ARCH_PPC64); DO_TEST("pseries-cpu-compat", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE, QEMU_CAPS_DEVICE_SPAPR_VTY); @@ -1877,7 +1877,7 @@ mymain(void) QEMU_CAPS_DEVICE_SPAPR_VTY); qemuTestSetHostCPU(driver.caps, NULL); =20 - qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE); + qemuTestSetHostArch(&driver, VIR_ARCH_NONE); =20 DO_TEST("pseries-panic-missing", QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE, @@ -2552,7 +2552,7 @@ mymain(void) QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM); DO_TEST("aarch64-virt-default-nic", QEMU_CAPS_DEVICE_VIRTIO_MMIO); - qemuTestSetHostArch(driver.caps, VIR_ARCH_AARCH64); + qemuTestSetHostArch(&driver, VIR_ARCH_AARCH64); DO_TEST("aarch64-cpu-passthrough", QEMU_CAPS_DEVICE_VIRTIO_MMIO, QEMU_CAPS_KVM); @@ -2668,7 +2668,7 @@ mymain(void) /* SVE aarch64 CPU features work on modern QEMU */ DO_TEST_CAPS_ARCH_LATEST("aarch64-features-sve", "aarch64"); =20 - qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE); + qemuTestSetHostArch(&driver, VIR_ARCH_NONE); =20 DO_TEST("kvm-pit-delay", QEMU_CAPS_KVM_PIT_TICK_POLICY); DO_TEST("kvm-pit-discard", QEMU_CAPS_KVM_PIT_TICK_POLICY); diff --git a/tests/testutils.c b/tests/testutils.c index d9c0d5abbe..387ba55908 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -60,6 +60,15 @@ static virBitmapPtr testBitmap; char *progname; static char *perl; =20 +virArch virTestHostArch =3D VIR_ARCH_X86_64; + +virArch +virArchFromHost(void) +{ + return virTestHostArch; +} + + static int virTestUseTerminalColors(void) { return isatty(STDOUT_FILENO); diff --git a/tests/testutils.h b/tests/testutils.h index 76090c5522..c3f2cee85f 100644 --- a/tests/testutils.h +++ b/tests/testutils.h @@ -43,6 +43,8 @@ extern char *progname; # error Fix Makefile.am #endif =20 +extern virArch virTestHostArch; + int virTestRun(const char *title, int (*body)(const void *data), const void *data); diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 4cb128559a..97f63e7d5d 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -576,13 +576,16 @@ virCapsPtr testQemuCapsInit(void) =20 =20 void -qemuTestSetHostArch(virCapsPtr caps, +qemuTestSetHostArch(virQEMUDriverPtr driver, virArch arch) { if (arch =3D=3D VIR_ARCH_NONE) arch =3D VIR_ARCH_X86_64; - caps->host.arch =3D arch; - qemuTestSetHostCPU(caps, NULL); + + virTestHostArch =3D arch; + driver->hostarch =3D virArchFromHost(); + driver->caps->host.arch =3D virArchFromHost(); + qemuTestSetHostCPU(driver->caps, NULL); } =20 =20 @@ -694,6 +697,8 @@ int qemuTestDriverInit(virQEMUDriver *driver) if (virMutexInit(&driver->lock) < 0) return -1; =20 + driver->hostarch =3D virArchFromHost(); + driver->config =3D virQEMUDriverConfigNew(false); if (!driver->config) goto error; diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h index da3bf3ab7a..8dcc930ac3 100644 --- a/tests/testutilsqemu.h +++ b/tests/testutilsqemu.h @@ -80,8 +80,8 @@ extern virCPUDefPtr cpuHaswell; extern virCPUDefPtr cpuPower8; extern virCPUDefPtr cpuPower9; =20 -void qemuTestSetHostArch(virCapsPtr caps, - virArch arch); +void qemuTestSetHostArch(virQEMUDriverPtr driver, + virArch arch); void qemuTestSetHostCPU(virCapsPtr caps, virCPUDefPtr cpu); =20 --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 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=1575469310; cv=none; d=zohomail.com; s=zohoarc; b=b4dLAi5I1iK4sPE8IrU0iUd7+n6y6faOKmdkshBNbgc1pQlcjkUzE3x2Yh9tiN4FKgepiyCTNuUe+2EwQbtAqHN2HEG6O2wT6RjzPawIzr+/aWiwm6sA+lH5i6tJNxQ2IU3EUL8Zq7Tm33fDbZXp8HWmIDs79+RLN41iXWidDCA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469310; 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=Vroki0Tb3z2fUhMJOdvAPkCAwPRrWSanpbQLbZnClKY=; b=lCWDbPP3aNCPBZT6BMlGE81Gt+e5meoSjE1M+yHs0ngXe0pGK59BiLjnBxvsIiSxOzPQ/X6/5DOHLPsoaOgL7BjS9jdEGmadRGfFx8oky9MDtzpQN2A4fUCHktm51AzZA+50IBcb2+wNeYk76Z03CbmrpRJCH240FsERTPcp5xw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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 [205.139.110.61]) by mx.zohomail.com with SMTPS id 15754693106791020.0542546134308; Wed, 4 Dec 2019 06:21:50 -0800 (PST) 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-370-ptoOGfecPzuAcs7PNrQT3w-1; Wed, 04 Dec 2019 09:21:47 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id E257CDBB7; Wed, 4 Dec 2019 14:21:39 +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 B5E7360FC1; Wed, 4 Dec 2019 14:21:39 +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 660FE18089C8; Wed, 4 Dec 2019 14:21:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4ELLOK008075 for ; Wed, 4 Dec 2019 09:21:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9D6A767E62; Wed, 4 Dec 2019 14:21:21 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id A2201608F7; Wed, 4 Dec 2019 14:21:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469309; 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=Vroki0Tb3z2fUhMJOdvAPkCAwPRrWSanpbQLbZnClKY=; b=iLlvgZw8qm8h7z9rnRwvAfiC9e/Bb6NuoHMEJuVIBPIYqYo76xE10ThO0r+UWg4BcrxR9s qMUY36fwcdLlg5MBRV+DvI1GyrE9sOe9vpHKJ3Qo584I4wWVenz743VOXvtoX745n6477v ZbLBabhWeV78qt3SBOuJlONssLE6whs= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:20:45 +0000 Message-Id: <20191204142113.2961028-3-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 02/30] qemu: add machines & arch to fake test capabilities cache 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.12 X-MC-Unique: ptoOGfecPzuAcs7PNrQT3w-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Currently the virQEMUCapsPtr objects are just empty. Future patches are going to expect them to contain real data. Start off by populating the machine types and arch information. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/qemu/qemu_capabilities.c | 70 +++-- src/qemu/qemu_capspriv.h | 10 + tests/qemuxml2argvtest.c | 9 +- tests/testutilsqemu.c | 594 ++++++++--------------------------- 4 files changed, 190 insertions(+), 493 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index cfc16ba63e..c02ff5b941 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2434,49 +2434,72 @@ static const char *preferredMachines[] =3D verify(G_N_ELEMENTS(preferredMachines) =3D=3D VIR_ARCH_LAST); =20 =20 +void +virQEMUCapsAddMachine(virQEMUCapsPtr qemuCaps, + virDomainVirtType virtType, + const char *name, + const char *alias, + const char *defaultCPU, + int maxCpus, + bool hotplugCpus, + bool isDefault) +{ + virQEMUCapsAccelPtr accel =3D virQEMUCapsGetAccel(qemuCaps, virtType); + virQEMUCapsMachineTypePtr mach; + + accel->machineTypes =3D g_renew(virQEMUCapsMachineType, + accel->machineTypes, + ++accel->nmachineTypes); + + mach =3D &(accel->machineTypes[accel->nmachineTypes - 1]); + + mach->alias =3D g_strdup(alias); + mach->name =3D g_strdup(name); + mach->defaultCPU =3D g_strdup(defaultCPU); + + mach->maxCpus =3D maxCpus; + mach->hotplugCpus =3D hotplugCpus; + + mach->qemuDefault =3D isDefault; +} + static int virQEMUCapsProbeQMPMachineTypes(virQEMUCapsPtr qemuCaps, - virQEMUCapsAccelPtr accel, + virDomainVirtType virtType, qemuMonitorPtr mon) { qemuMonitorMachineInfoPtr *machines =3D NULL; int nmachines =3D 0; - int ret =3D -1; size_t i; ssize_t defIdx =3D -1; ssize_t preferredIdx =3D -1; const char *preferredMachine =3D preferredMachines[qemuCaps->arch]; + virQEMUCapsAccelPtr accel =3D virQEMUCapsGetAccel(qemuCaps, virtType); =20 if ((nmachines =3D qemuMonitorGetMachines(mon, &machines)) < 0) return -1; =20 - if (VIR_ALLOC_N(accel->machineTypes, nmachines) < 0) - goto cleanup; - for (i =3D 0; i < nmachines; i++) { - virQEMUCapsMachineTypePtr mach; if (STREQ(machines[i]->name, "none")) continue; =20 - mach =3D &(accel->machineTypes[accel->nmachineTypes++]); - - mach->alias =3D g_strdup(machines[i]->alias); - mach->name =3D g_strdup(machines[i]->name); - mach->defaultCPU =3D g_strdup(machines[i]->defaultCPU); - - mach->maxCpus =3D machines[i]->maxCpus; - mach->hotplugCpus =3D machines[i]->hotplugCpus; + virQEMUCapsAddMachine(qemuCaps, + virtType, + machines[i]->name, + machines[i]->alias, + machines[i]->defaultCPU, + machines[i]->maxCpus, + machines[i]->hotplugCpus, + machines[i]->isDefault); =20 if (preferredMachine && - (STREQ_NULLABLE(mach->alias, preferredMachine) || - STREQ(mach->name, preferredMachine))) { + (STREQ_NULLABLE(machines[i]->alias, preferredMachine) || + STREQ(machines[i]->name, preferredMachine))) { preferredIdx =3D accel->nmachineTypes - 1; } =20 - if (machines[i]->isDefault) { - mach->qemuDefault =3D true; + if (machines[i]->isDefault) defIdx =3D accel->nmachineTypes - 1; - } } =20 /* @@ -2493,13 +2516,10 @@ virQEMUCapsProbeQMPMachineTypes(virQEMUCapsPtr qemu= Caps, if (preferredIdx !=3D -1) virQEMUCapsSetDefaultMachine(accel, preferredIdx); =20 - ret =3D 0; - - cleanup: for (i =3D 0; i < nmachines; i++) qemuMonitorMachineInfoFree(machines[i]); VIR_FREE(machines); - return ret; + return 0; } =20 =20 @@ -4745,7 +4765,7 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, return -1; if (virQEMUCapsProbeQMPDevices(qemuCaps, mon) < 0) return -1; - if (virQEMUCapsProbeQMPMachineTypes(qemuCaps, accel, mon) < 0) + if (virQEMUCapsProbeQMPMachineTypes(qemuCaps, type, mon) < 0) return -1; if (virQEMUCapsProbeQMPMachineProps(qemuCaps, type, mon) < 0) return -1; @@ -4788,7 +4808,7 @@ virQEMUCapsInitQMPMonitorTCG(virQEMUCapsPtr qemuCaps, if (virQEMUCapsProbeQMPHostCPU(qemuCaps, accel, mon, VIR_DOMAIN_VIRT_Q= EMU) < 0) return -1; =20 - if (virQEMUCapsProbeQMPMachineTypes(qemuCaps, accel, mon) < 0) + if (virQEMUCapsProbeQMPMachineTypes(qemuCaps, VIR_DOMAIN_VIRT_QEMU, mo= n) < 0) return -1; =20 return 0; diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h index 9fc3f43f32..9059ee3059 100644 --- a/src/qemu/qemu_capspriv.h +++ b/src/qemu/qemu_capspriv.h @@ -104,3 +104,13 @@ virQEMUCapsSetMicrocodeVersion(virQEMUCapsPtr qemuCaps, =20 void virQEMUCapsStripMachineAliases(virQEMUCapsPtr qemuCaps); + +void +virQEMUCapsAddMachine(virQEMUCapsPtr qemuCaps, + virDomainVirtType virtType, + const char *name, + const char *alias, + const char *defaultCPU, + int maxCpus, + bool hotplugCpus, + bool isDefault); diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 546cdae245..6890de101b 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -475,9 +475,12 @@ testCompareXMLToArgv(const void *data) if (qemuProcessPrepareMonitorChr(&monitor_chr, priv->libDir) < 0) goto cleanup; =20 - if (!(info->flags & FLAG_REAL_CAPS) && - testUpdateQEMUCaps(info, vm, driver.caps) < 0) - goto cleanup; + if (!(info->flags & FLAG_REAL_CAPS)) { + if (testUpdateQEMUCaps(info, vm, driver.caps) < 0) + goto cleanup; + if (qemuTestCapsCacheInsert(driver.qemuCapsCache, info->qemuCaps) = < 0) + goto cleanup; + } =20 log =3D virTestLogContentAndReset(); VIR_FREE(log); diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 97f63e7d5d..0ca690a1ed 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -20,149 +20,115 @@ virCPUDefPtr cpuHaswell; virCPUDefPtr cpuPower8; virCPUDefPtr cpuPower9; =20 -typedef enum { - TEST_UTILS_QEMU_BIN_I686, - TEST_UTILS_QEMU_BIN_X86_64, - TEST_UTILS_QEMU_BIN_AARCH64, - TEST_UTILS_QEMU_BIN_ARM, - TEST_UTILS_QEMU_BIN_PPC64, - TEST_UTILS_QEMU_BIN_PPC, - TEST_UTILS_QEMU_BIN_RISCV32, - TEST_UTILS_QEMU_BIN_RISCV64, - TEST_UTILS_QEMU_BIN_S390X -} QEMUBinType; - -static const char *QEMUBinList[] =3D { - "/usr/bin/qemu-system-i386", - "/usr/bin/qemu-system-x86_64", - "/usr/bin/qemu-system-aarch64", - "/usr/bin/qemu-system-arm", - "/usr/bin/qemu-system-ppc64", - "/usr/bin/qemu-system-ppc", - "/usr/bin/qemu-system-riscv32", - "/usr/bin/qemu-system-riscv64", - "/usr/bin/qemu-system-s390x" -}; - - -static virCapsGuestMachinePtr *testQemuAllocMachines(int *nmachines) -{ - virCapsGuestMachinePtr *machines; - static const char *const x86_machines[] =3D { - "pc", "isapc" - }; - - machines =3D virCapabilitiesAllocMachines(x86_machines, - G_N_ELEMENTS(x86_machines)); - if (machines =3D=3D NULL) - return NULL; - - *nmachines =3D G_N_ELEMENTS(x86_machines); =20 - return machines; -} - -/* Newer versions of qemu have versioned machine types to allow - * compatibility with older releases. - * The 'pc' machine type is an alias of the newest machine type. - */ -static virCapsGuestMachinePtr *testQemuAllocNewerMachines(int *nmachines) -{ - virCapsGuestMachinePtr *machines; - char *canonical; - static const char *const x86_machines[] =3D { - "pc-0.11", "pc", "pc-0.10", "isapc" - }; - - canonical =3D g_strdup(x86_machines[0]); - - machines =3D virCapabilitiesAllocMachines(x86_machines, - G_N_ELEMENTS(x86_machines)); - if (machines =3D=3D NULL) { - VIR_FREE(canonical); - return NULL; - } +static const char *qemu_emulators[VIR_ARCH_LAST] =3D { + [VIR_ARCH_I686] =3D "/usr/bin/qemu-system-i386", + [VIR_ARCH_X86_64] =3D "/usr/bin/qemu-system-x86_64", + [VIR_ARCH_AARCH64] =3D "/usr/bin/qemu-system-aarch64", + [VIR_ARCH_ARMV7L] =3D "/usr/bin/qemu-system-arm", + [VIR_ARCH_PPC64] =3D "/usr/bin/qemu-system-ppc64", + [VIR_ARCH_PPC] =3D "/usr/bin/qemu-system-ppc", + [VIR_ARCH_RISCV32] =3D "/usr/bin/qemu-system-riscv32", + [VIR_ARCH_RISCV64] =3D "/usr/bin/qemu-system-riscv64", + [VIR_ARCH_S390X] =3D "/usr/bin/qemu-system-s390x" +}; =20 - machines[1]->canonical =3D canonical; +static const virArch arch_alias[VIR_ARCH_LAST] =3D { + [VIR_ARCH_PPC64LE] =3D VIR_ARCH_PPC64, + [VIR_ARCH_ARMV6L] =3D VIR_ARCH_ARMV7L, +}; =20 - *nmachines =3D G_N_ELEMENTS(x86_machines); +static const char *const i386_machines[] =3D { + "pc", "isapc", NULL +}; +static const char *const x86_64_machines_kvm[] =3D { + "pc", "isapc", NULL +}; +static const char *const x86_64_machines_qemu[] =3D { + "pc-0.11", "pc", "pc-0.10", "isapc", NULL +}; +static const char *const aarch64_machines[] =3D { + "virt", NULL +}; +static const char *const arm_machines[] =3D { + "vexpress-a9", "vexpress-a15", "versatilepb", NULL +}; +static const char *const ppc64_machines[] =3D { + "pseries", NULL +}; +static const char *const ppc_machines[] =3D { + "g3beige", "mac99", "prep", "ppce500", NULL +}; +static const char *const riscv32_machines[] =3D { + "spike_v1.10", "spike_v1.9.1", "sifive_e", "virt", "sifive_u", NULL +}; +static const char *const riscv64_machines[] =3D { + "spike_v1.10", "spike_v1.9.1", "sifive_e", "virt", "sifive_u", NULL +}; +static const char *const s390x_machines[] =3D { + "s390-virtio", "s390-ccw-virtio", NULL +}; =20 - return machines; -} +static const char *const *qemu_machines[VIR_ARCH_LAST] =3D { + [VIR_ARCH_I686] =3D i386_machines, + [VIR_ARCH_X86_64] =3D x86_64_machines_qemu, + [VIR_ARCH_AARCH64] =3D aarch64_machines, + [VIR_ARCH_ARMV7L] =3D arm_machines, + [VIR_ARCH_PPC64] =3D ppc64_machines, + [VIR_ARCH_PPC] =3D ppc_machines, + [VIR_ARCH_RISCV32] =3D riscv32_machines, + [VIR_ARCH_RISCV64] =3D riscv64_machines, + [VIR_ARCH_S390X] =3D s390x_machines, +}; =20 +static const char *const *kvm_machines[VIR_ARCH_LAST] =3D { + [VIR_ARCH_I686] =3D i386_machines, + [VIR_ARCH_X86_64] =3D x86_64_machines_kvm, + [VIR_ARCH_AARCH64] =3D aarch64_machines, + [VIR_ARCH_ARMV7L] =3D arm_machines, + [VIR_ARCH_PPC64] =3D ppc64_machines, + [VIR_ARCH_PPC] =3D ppc_machines, + [VIR_ARCH_RISCV32] =3D riscv32_machines, + [VIR_ARCH_RISCV64] =3D riscv64_machines, + [VIR_ARCH_S390X] =3D s390x_machines, +}; =20 static int -testQemuAddI686Guest(virCapsPtr caps) +testQemuAddGuest(virCapsPtr caps, + virArch arch) { - int nmachines =3D 0; + size_t nmachines; virCapsGuestMachinePtr *machines =3D NULL; virCapsGuestPtr guest; + virArch emu_arch =3D arch; =20 - if (!(machines =3D testQemuAllocMachines(&nmachines))) - goto error; - - if (!(guest =3D virCapabilitiesAddGuest(caps, - VIR_DOMAIN_OSTYPE_HVM, - VIR_ARCH_I686, - QEMUBinList[TEST_UTILS_QEMU_BIN_= I686], - NULL, - nmachines, - machines))) - goto error; - - virCapabilitiesAddGuestFeature(guest, VIR_CAPS_GUEST_FEATURE_TYPE_CPUS= ELECTION); - - machines =3D NULL; - - if (!virCapabilitiesAddGuestDomain(guest, - VIR_DOMAIN_VIRT_QEMU, - NULL, - NULL, - 0, - NULL)) - goto error; - - if (!(machines =3D testQemuAllocMachines(&nmachines))) - goto error; - - if (!virCapabilitiesAddGuestDomain(guest, - VIR_DOMAIN_VIRT_KVM, - QEMUBinList[TEST_UTILS_QEMU_BIN_I68= 6], - NULL, - nmachines, - machines)) - goto error; - - return 0; - - error: - virCapabilitiesFreeMachines(machines, nmachines); - return -1; -} - + if (arch_alias[arch] !=3D VIR_ARCH_NONE) + emu_arch =3D arch_alias[arch]; =20 -static int -testQemuAddX86_64Guest(virCapsPtr caps) -{ - int nmachines =3D 0; - virCapsGuestMachinePtr *machines =3D NULL; - virCapsGuestPtr guest; + if (qemu_emulators[emu_arch] =3D=3D NULL) + return 0; =20 - if (!(machines =3D testQemuAllocNewerMachines(&nmachines))) + nmachines =3D g_strv_length((gchar **)qemu_machines[emu_arch]); + machines =3D virCapabilitiesAllocMachines(qemu_machines[emu_arch], + nmachines); + if (machines =3D=3D NULL) goto error; =20 if (!(guest =3D virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, - VIR_ARCH_X86_64, - QEMUBinList[TEST_UTILS_QEMU_BIN_= X86_64], + arch, + qemu_emulators[emu_arch], NULL, nmachines, machines))) goto error; =20 - virCapabilitiesAddGuestFeature(guest, VIR_CAPS_GUEST_FEATURE_TYPE_CPUS= ELECTION); - machines =3D NULL; + nmachines =3D 0; + + if (arch =3D=3D VIR_ARCH_I686 || + arch =3D=3D VIR_ARCH_X86_64) + virCapabilitiesAddGuestFeature(guest, VIR_CAPS_GUEST_FEATURE_TYPE_= CPUSELECTION); =20 if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, @@ -172,27 +138,20 @@ testQemuAddX86_64Guest(virCapsPtr caps) NULL)) goto error; =20 - if (!(machines =3D testQemuAllocMachines(&nmachines))) + nmachines =3D g_strv_length((char **)kvm_machines[emu_arch]); + machines =3D virCapabilitiesAllocMachines(kvm_machines[emu_arch], + nmachines); + if (machines =3D=3D NULL) goto error; =20 if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM, - QEMUBinList[TEST_UTILS_QEMU_BIN_X86= _64], + qemu_emulators[emu_arch], NULL, nmachines, machines)) goto error; =20 - machines =3D NULL; - - if (!virCapabilitiesAddGuestDomain(guest, - VIR_DOMAIN_VIRT_KVM, - QEMUBinList[TEST_UTILS_QEMU_BIN_X86= _64], - NULL, - 0, - NULL)) - goto error; - return 0; =20 error: @@ -201,295 +160,10 @@ testQemuAddX86_64Guest(virCapsPtr caps) } =20 =20 -static int testQemuAddPPC64Guest(virCapsPtr caps) -{ - static const char *machine[] =3D { "pseries" }; - virCapsGuestMachinePtr *machines =3D NULL; - virCapsGuestPtr guest; - - machines =3D virCapabilitiesAllocMachines(machine, 1); - if (!machines) - goto error; - - guest =3D virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARC= H_PPC64, - QEMUBinList[TEST_UTILS_QEMU_BIN_PPC64], - NULL, 1, machines); - if (!guest) - goto error; - - if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, = NULL, 0, NULL)) - goto error; - if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM, - NULL, NULL, 0, NULL)) - goto error; - - return 0; - - error: - /* No way to free a guest? */ - virCapabilitiesFreeMachines(machines, 1); - return -1; -} - -static int testQemuAddPPC64LEGuest(virCapsPtr caps) -{ - static const char *machine[] =3D { "pseries" }; - virCapsGuestMachinePtr *machines =3D NULL; - virCapsGuestPtr guest; - - machines =3D virCapabilitiesAllocMachines(machine, 1); - if (!machines) - goto error; - - guest =3D virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARC= H_PPC64LE, - QEMUBinList[TEST_UTILS_QEMU_BIN_PPC64], - NULL, 1, machines); - if (!guest) - goto error; - - if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, = NULL, 0, NULL)) - goto error; - if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM, - NULL, NULL, 0, NULL)) - goto error; - - return 0; - - error: - /* No way to free a guest? */ - virCapabilitiesFreeMachines(machines, 1); - return -1; -} - -static int testQemuAddPPCGuest(virCapsPtr caps) -{ - static const char *machine[] =3D { "g3beige", - "mac99", - "prep", - "ppce500" }; - virCapsGuestMachinePtr *machines =3D NULL; - virCapsGuestPtr guest; - - machines =3D virCapabilitiesAllocMachines(machine, 1); - if (!machines) - goto error; - - guest =3D virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARC= H_PPC, - QEMUBinList[TEST_UTILS_QEMU_BIN_PPC], - NULL, 1, machines); - if (!guest) - goto error; - - if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, = NULL, 0, NULL)) - goto error; - if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM, - NULL, NULL, 0, NULL)) - goto error; - - return 0; - - error: - /* No way to free a guest? */ - virCapabilitiesFreeMachines(machines, 1); - return -1; -} - -static int testQemuAddRISCV32Guest(virCapsPtr caps) -{ - static const char *names[] =3D { "spike_v1.10", - "spike_v1.9.1", - "sifive_e", - "virt", - "sifive_u" }; - static const int nmachines =3D G_N_ELEMENTS(names); - virCapsGuestMachinePtr *machines =3D NULL; - virCapsGuestPtr guest; - - machines =3D virCapabilitiesAllocMachines(names, nmachines); - if (!machines) - goto error; - - guest =3D virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARC= H_RISCV32, - QEMUBinList[TEST_UTILS_QEMU_BIN_RISCV3= 2], - NULL, nmachines, machines); - if (!guest) - goto error; - - if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, = NULL, 0, NULL)) - goto error; - - return 0; - - error: - virCapabilitiesFreeMachines(machines, nmachines); - return -1; -} - -static int testQemuAddRISCV64Guest(virCapsPtr caps) -{ - static const char *names[] =3D { "spike_v1.10", - "spike_v1.9.1", - "sifive_e", - "virt", - "sifive_u" }; - static const int nmachines =3D G_N_ELEMENTS(names); - virCapsGuestMachinePtr *machines =3D NULL; - virCapsGuestPtr guest; - - machines =3D virCapabilitiesAllocMachines(names, nmachines); - if (!machines) - goto error; - - guest =3D virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARC= H_RISCV64, - QEMUBinList[TEST_UTILS_QEMU_BIN_RISCV6= 4], - NULL, nmachines, machines); - if (!guest) - goto error; - - if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, = NULL, 0, NULL)) - goto error; - - return 0; - - error: - virCapabilitiesFreeMachines(machines, nmachines); - return -1; -} - -static int testQemuAddS390Guest(virCapsPtr caps) -{ - static const char *s390_machines[] =3D { "s390-virtio", - "s390-ccw-virtio" }; - virCapsGuestMachinePtr *machines =3D NULL; - virCapsGuestPtr guest; - - machines =3D virCapabilitiesAllocMachines(s390_machines, - G_N_ELEMENTS(s390_machines)); - if (!machines) - goto error; - - guest =3D virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARC= H_S390X, - QEMUBinList[TEST_UTILS_QEMU_BIN_S390X], - NULL, - G_N_ELEMENTS(s390_machines), - machines); - if (!guest) - goto error; - - if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, = NULL, 0, NULL)) - goto error; - if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM, - NULL, NULL, 0, NULL)) - goto error; - - return 0; - - error: - virCapabilitiesFreeMachines(machines, G_N_ELEMENTS(s390_machines)); - return -1; -} - -static int testQemuAddArm6Guest(virCapsPtr caps) -{ - static const char *machines[] =3D { "versatilepb" }; - virCapsGuestMachinePtr *capsmachines =3D NULL; - virCapsGuestPtr guest; - - capsmachines =3D virCapabilitiesAllocMachines(machines, - G_N_ELEMENTS(machines)); - if (!capsmachines) - goto error; - - guest =3D virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARC= H_ARMV6L, - QEMUBinList[TEST_UTILS_QEMU_BIN_ARM], - NULL, - G_N_ELEMENTS(machines), - capsmachines); - if (!guest) - goto error; - - if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, = NULL, 0, NULL)) - goto error; - if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM, - NULL, NULL, 0, NULL)) - goto error; - - return 0; - - error: - virCapabilitiesFreeMachines(capsmachines, G_N_ELEMENTS(machines)); - return -1; -} - -static int testQemuAddArm7Guest(virCapsPtr caps) -{ - static const char *machines[] =3D { "vexpress-a9", - "vexpress-a15", - "versatilepb" }; - virCapsGuestMachinePtr *capsmachines =3D NULL; - virCapsGuestPtr guest; - - capsmachines =3D virCapabilitiesAllocMachines(machines, - G_N_ELEMENTS(machines)); - if (!capsmachines) - goto error; - - guest =3D virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARC= H_ARMV7L, - QEMUBinList[TEST_UTILS_QEMU_BIN_ARM], - NULL, - G_N_ELEMENTS(machines), - capsmachines); - if (!guest) - goto error; - - if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, = NULL, 0, NULL)) - goto error; - if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM, - NULL, NULL, 0, NULL)) - goto error; - - return 0; - - error: - virCapabilitiesFreeMachines(capsmachines, G_N_ELEMENTS(machines)); - return -1; -} - -static int testQemuAddAARCH64Guest(virCapsPtr caps) -{ - static const char *machines[] =3D { "virt"}; - virCapsGuestMachinePtr *capsmachines =3D NULL; - virCapsGuestPtr guest; - - capsmachines =3D virCapabilitiesAllocMachines(machines, - G_N_ELEMENTS(machines)); - if (!capsmachines) - goto error; - - guest =3D virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARC= H_AARCH64, - QEMUBinList[TEST_UTILS_QEMU_BIN_AARCH6= 4], - NULL, - G_N_ELEMENTS(machines), - capsmachines); - if (!guest) - goto error; - - if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, = NULL, 0, NULL)) - goto error; - if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM, - NULL, NULL, 0, NULL)) - goto error; - - return 0; - - error: - virCapabilitiesFreeMachines(capsmachines, G_N_ELEMENTS(machines)); - return -1; -} - virCapsPtr testQemuCapsInit(void) { virCapsPtr caps; + size_t i; =20 if (!(caps =3D virCapabilitiesNew(VIR_ARCH_X86_64, false, false))) return NULL; @@ -518,38 +192,10 @@ virCapsPtr testQemuCapsInit(void) if (virTestCapsBuildNUMATopology(caps, 3) < 0) goto cleanup; =20 - if (testQemuAddI686Guest(caps) < 0) - goto cleanup; - - if (testQemuAddX86_64Guest(caps) < 0) - goto cleanup; - - if (testQemuAddPPC64Guest(caps)) - goto cleanup; - - if (testQemuAddPPC64LEGuest(caps)) - goto cleanup; - - if (testQemuAddPPCGuest(caps)) - goto cleanup; - - if (testQemuAddRISCV32Guest(caps) < 0) - goto cleanup; - - if (testQemuAddRISCV64Guest(caps) < 0) - goto cleanup; - - if (testQemuAddS390Guest(caps)) - goto cleanup; - - if (testQemuAddArm6Guest(caps)) - goto cleanup; - - if (testQemuAddArm7Guest(caps)) - goto cleanup; - - if (testQemuAddAARCH64Guest(caps)) - goto cleanup; + for (i =3D 0; i < VIR_ARCH_LAST; i++) { + if (testQemuAddGuest(caps, i) < 0) + goto cleanup; + } =20 if (virTestGetDebug()) { char *caps_str; @@ -658,27 +304,45 @@ void qemuTestDriverFree(virQEMUDriver *driver) int qemuTestCapsCacheInsert(virFileCachePtr cache, virQEMUCapsPtr caps) { - size_t i; - virQEMUCapsPtr tmpCaps; + size_t i, j; =20 - if (caps) { - tmpCaps =3D caps; - } else { - if (!(tmpCaps =3D virQEMUCapsNew())) - return -ENOMEM; - } - - for (i =3D 0; i < G_N_ELEMENTS(QEMUBinList); i++) { - virObjectRef(tmpCaps); - if (virFileCacheInsertData(cache, QEMUBinList[i], tmpCaps) < 0) { + for (i =3D 0; i < G_N_ELEMENTS(qemu_emulators); i++) { + virQEMUCapsPtr tmpCaps; + if (qemu_emulators[i] =3D=3D NULL) + continue; + if (caps) { + tmpCaps =3D virQEMUCapsNewCopy(caps); + } else { + tmpCaps =3D virQEMUCapsNew(); + } + virQEMUCapsSetArch(tmpCaps, i); + for (j =3D 0; qemu_machines[i][j] !=3D NULL; j++) { + virQEMUCapsAddMachine(tmpCaps, + VIR_DOMAIN_VIRT_QEMU, + qemu_machines[i][j], + NULL, + NULL, + 0, + false, + false); + } + for (j =3D 0; kvm_machines[i][j] !=3D NULL; j++) { + virQEMUCapsAddMachine(tmpCaps, + VIR_DOMAIN_VIRT_KVM, + kvm_machines[i][j], + NULL, + NULL, + 0, + false, + false); + virQEMUCapsSet(tmpCaps, QEMU_CAPS_KVM); + } + if (virFileCacheInsertData(cache, qemu_emulators[i], tmpCaps) < 0)= { virObjectUnref(tmpCaps); return -1; } } =20 - if (!caps) - virObjectUnref(tmpCaps); - return 0; } =20 --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 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=1575469301; cv=none; d=zohomail.com; s=zohoarc; b=exsHs5rF9gEkZXO98LLXPQ9qj7MR2Pnrunh6HESz7HG4f/SWcfomYB9mvR3rGfnrA6JehnqVVBH07lqYHuWClReCXuEBXEjaWht95rmoPh/PH9siy2Bj+35fImjVcfX8M05MtYNynWewwxzx7b4Pa+Wg9+NjOL4pPhTMjiakNEg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469301; 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=DvmaOnvlO07bipRt8smI7afrCT7d7MBimzJhXvXiNYM=; b=YmstAAvXcbX2FC3YDkyuAhI8c64NrO03ajWG992HW/Nvvot6ym4d37LjWrF9ZioKWG7SKThDHIszHsuuJzZP9g87wOpTg5cufsZ2raNSN+0rKY6t5WZt24R8T6Ygya7JP48JvWoVe+OjtuNbRa4qWDLQR+iLNlhoVetAInaemJw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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 [205.139.110.61]) by mx.zohomail.com with SMTPS id 157546930100447.56753738093062; Wed, 4 Dec 2019 06:21:41 -0800 (PST) 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-376-XQQTVLW9O4OejSgcmuqJhg-1; Wed, 04 Dec 2019 09:21:31 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 068EA12A7E56; Wed, 4 Dec 2019 14:21:25 +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 D069B600C8; Wed, 4 Dec 2019 14:21:24 +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 634B918089C8; Wed, 4 Dec 2019 14:21:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4ELNR2008088 for ; Wed, 4 Dec 2019 09:21:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3936367E62; Wed, 4 Dec 2019 14:21:23 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id F06C1608F7; Wed, 4 Dec 2019 14:21:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469297; 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=DvmaOnvlO07bipRt8smI7afrCT7d7MBimzJhXvXiNYM=; b=C0ReOlGn14Asznrwc/z3ykLGH9tdpaXU0gIo86cmQiWvLyvylNYreWABI5ne5PSgxzqHwU y25SohpovyuCI8BE/HxIcDRrl55g5TSIpTiwLbvvFEiJWPimwfe1cY9gRpnAIKY3YiqS7+ bc3CvthWMSj2kHA28BkRvD2GyjEUXbs= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:20:46 +0000 Message-Id: <20191204142113.2961028-4-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 03/30] conf: sanitize virDomainSaveStatus & virDomainSaveConfig APIs 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.11 X-MC-Unique: XQQTVLW9O4OejSgcmuqJhg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Our normal practice is for the object type to be the name prefix, and the object instance be the first parameter passed in. Rename these to virDomainObjSave and virDomainDefSave moving their primary parameter to be the first one. Ensure that the xml options are passed into both functions in prep for future work. Finally enforce checking of the return type and mark all parameters as non-NULL. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/bhyve/bhyve_driver.c | 4 +- src/bhyve/bhyve_process.c | 10 ++- src/conf/domain_conf.c | 31 +++++----- src/conf/domain_conf.h | 26 ++++---- src/libvirt_private.syms | 5 +- src/libxl/libxl_domain.c | 2 +- src/libxl/libxl_driver.c | 35 ++++++----- src/libxl/libxl_migration.c | 6 +- src/lxc/lxc_driver.c | 39 ++++++------ src/lxc/lxc_process.c | 6 +- src/qemu/qemu_domain.c | 6 +- src/qemu/qemu_driver.c | 119 ++++++++++++++++++------------------ src/qemu/qemu_hotplug.c | 8 +-- src/qemu/qemu_migration.c | 8 +-- src/qemu/qemu_process.c | 36 +++++------ 15 files changed, 171 insertions(+), 170 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index d40ae1cd23..b8a206bb1e 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -545,8 +545,8 @@ bhyveDomainDefineXMLFlags(virConnectPtr conn, const cha= r *xml, unsigned int flag def =3D NULL; vm->persistent =3D 1; =20 - if (virDomainSaveConfig(BHYVE_CONFIG_DIR, caps, - vm->newDef ? vm->newDef : vm->def) < 0) { + if (virDomainDefSave(vm->newDef ? vm->newDef : vm->def, + privconn->xmlopt, caps, BHYVE_CONFIG_DIR) < 0) { virDomainObjListRemove(privconn->domains, vm); goto cleanup; } diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c index 13123fdce3..c10e5500c9 100644 --- a/src/bhyve/bhyve_process.c +++ b/src/bhyve/bhyve_process.c @@ -211,9 +211,8 @@ virBhyveProcessStart(virConnectPtr conn, virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, reason); priv->mon =3D bhyveMonitorOpen(vm, driver); =20 - if (virDomainSaveStatus(driver->xmlopt, - BHYVE_STATE_DIR, - vm, caps) < 0) + if (virDomainObjSave(vm, driver->xmlopt, caps, + BHYVE_STATE_DIR) < 0) goto cleanup; =20 ret =3D 0; @@ -430,9 +429,8 @@ virBhyveProcessReconnect(virDomainObjPtr vm, vm->def->id =3D -1; virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, VIR_DOMAIN_SHUTOFF_UNKNOWN); - ignore_value(virDomainSaveStatus(data->driver->xmlopt, - BHYVE_STATE_DIR, - vm, caps)); + ignore_value(virDomainObjSave(vm, data->driver->xmlopt, caps, + BHYVE_STATE_DIR)); } =20 virObjectUnref(caps); diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9580884747..87bbb2d263 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -29014,10 +29014,10 @@ virDomainDefCompatibleDevice(virDomainDefPtr def, return 0; } =20 -int -virDomainSaveXML(const char *configDir, - virDomainDefPtr def, - const char *xml) +static int +virDomainDefSaveXML(virDomainDefPtr def, + const char *configDir, + const char *xml) { char uuidstr[VIR_UUID_STRING_BUFLEN]; g_autofree char *configFile =3D NULL; @@ -29042,23 +29042,24 @@ virDomainSaveXML(const char *configDir, } =20 int -virDomainSaveConfig(const char *configDir, - virCapsPtr caps, - virDomainDefPtr def) +virDomainDefSave(virDomainDefPtr def, + virDomainXMLOptionPtr xmlopt G_GNUC_UNUSED, + virCapsPtr caps, + const char *configDir) { g_autofree char *xml =3D NULL; =20 if (!(xml =3D virDomainDefFormat(def, caps, VIR_DOMAIN_DEF_FORMAT_SECU= RE))) return -1; =20 - return virDomainSaveXML(configDir, def, xml); + return virDomainDefSaveXML(def, configDir, xml); } =20 int -virDomainSaveStatus(virDomainXMLOptionPtr xmlopt, - const char *statusDir, - virDomainObjPtr obj, - virCapsPtr caps) +virDomainObjSave(virDomainObjPtr obj, + virDomainXMLOptionPtr xmlopt, + virCapsPtr caps, + const char *statusDir) { unsigned int flags =3D (VIR_DOMAIN_DEF_FORMAT_SECURE | VIR_DOMAIN_DEF_FORMAT_STATUS | @@ -29071,7 +29072,7 @@ virDomainSaveStatus(virDomainXMLOptionPtr xmlopt, if (!(xml =3D virDomainObjFormat(xmlopt, obj, caps, flags))) return -1; =20 - return virDomainSaveXML(statusDir, obj->def, xml); + return virDomainDefSaveXML(obj->def, statusDir, xml); } =20 =20 @@ -30173,7 +30174,7 @@ virDomainObjSetMetadata(virDomainObjPtr vm, if (virDomainDefSetMetadata(def, type, metadata, key, uri) < 0) return -1; =20 - if (virDomainSaveStatus(xmlopt, stateDir, vm, caps) < 0) + if (virDomainObjSave(vm, xmlopt, caps, stateDir) < 0) return -1; } =20 @@ -30182,7 +30183,7 @@ virDomainObjSetMetadata(virDomainObjPtr vm, uri) < 0) return -1; =20 - if (virDomainSaveConfig(configDir, caps, persistentDef) < 0) + if (virDomainDefSave(persistentDef, xmlopt, caps, configDir) < 0) return -1; } =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 49cb6970e6..d1c375092e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3289,17 +3289,21 @@ ssize_t virDomainRedirdevDefFind(virDomainDefPtr de= f, virDomainRedirdevDefPtr redirdev); virDomainRedirdevDefPtr virDomainRedirdevDefRemove(virDomainDefPtr def, si= ze_t idx); =20 -int virDomainSaveXML(const char *configDir, - virDomainDefPtr def, - const char *xml); - -int virDomainSaveConfig(const char *configDir, - virCapsPtr caps, - virDomainDefPtr def); -int virDomainSaveStatus(virDomainXMLOptionPtr xmlopt, - const char *statusDir, - virDomainObjPtr obj, - virCapsPtr caps) G_GNUC_WARN_UNUSED_RESULT; +int virDomainDefSave(virDomainDefPtr def, + virDomainXMLOptionPtr xmlopt, + virCapsPtr caps, + const char *configDir) + G_GNUC_WARN_UNUSED_RESULT + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) + ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); + +int virDomainObjSave(virDomainObjPtr obj, + virDomainXMLOptionPtr xmlopt, + virCapsPtr caps, + const char *statusDir) + G_GNUC_WARN_UNUSED_RESULT + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) + ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); =20 typedef void (*virDomainLoadConfigNotify)(virDomainObjPtr dom, int newDomain, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 0864de030b..7bacf02f0c 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -309,6 +309,7 @@ virDomainDefParseFile; virDomainDefParseNode; virDomainDefParseString; virDomainDefPostParse; +virDomainDefSave; virDomainDefSetMemoryTotal; virDomainDefSetVcpus; virDomainDefSetVcpusMax; @@ -526,6 +527,7 @@ virDomainObjNew; virDomainObjParseFile; virDomainObjParseNode; virDomainObjRemoveTransientDef; +virDomainObjSave; virDomainObjSetDefTransient; virDomainObjSetMetadata; virDomainObjSetState; @@ -555,9 +557,6 @@ virDomainRNGModelTypeToString; virDomainRNGRemove; virDomainRunningReasonTypeFromString; virDomainRunningReasonTypeToString; -virDomainSaveConfig; -virDomainSaveStatus; -virDomainSaveXML; virDomainSCSIDriveAddressIsUsed; virDomainSeclabelTypeFromString; virDomainSeclabelTypeToString; diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 90ea2c9ece..9b9b17b173 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -1463,7 +1463,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver, virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_USER= ); } =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, cfg->caps) = < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->caps, cfg->stateDir) < 0) goto destroy_dom; =20 if (virAtomicIntInc(&driver->nactive) =3D=3D 1 && driver->inhibitCallb= ack) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 44a74e8779..b885cf0d00 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -453,7 +453,7 @@ libxlReconnectDomain(virDomainObjPtr vm, =20 libxlReconnectNotifyNets(vm->def); =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, cfg->caps) = < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->caps, cfg->stateDir) < 0) VIR_WARN("Cannot update XML for running Xen guest %s", vm->def->na= me); =20 /* now that we know it's reconnected call the hook if present */ @@ -1188,7 +1188,7 @@ libxlDomainSuspend(virDomainPtr dom) VIR_DOMAIN_EVENT_SUSPENDED_PAUSED= ); } =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, cfg->caps) = < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->caps, cfg->stateDir) < 0) goto endjob; =20 ret =3D 0; @@ -1242,7 +1242,7 @@ libxlDomainResume(virDomainPtr dom) VIR_DOMAIN_EVENT_RESUMED_UNPAUSED= ); } =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, cfg->caps) = < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->caps, cfg->stateDir) < 0) goto endjob; =20 ret =3D 0; @@ -1667,7 +1667,7 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned = long newmem, virDomainDefSetMemoryTotal(persistentDef, newmem); if (persistentDef->mem.cur_balloon > newmem) persistentDef->mem.cur_balloon =3D newmem; - ret =3D virDomainSaveConfig(cfg->configDir, cfg->caps, persist= entDef); + ret =3D virDomainDefSave(persistentDef, driver->xmlopt, cfg->c= aps, cfg->configDir); goto endjob; } =20 @@ -1700,7 +1700,7 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned = long newmem, if (flags & VIR_DOMAIN_MEM_CONFIG) { sa_assert(persistentDef); persistentDef->mem.cur_balloon =3D newmem; - ret =3D virDomainSaveConfig(cfg->configDir, cfg->caps, persist= entDef); + ret =3D virDomainDefSave(persistentDef, driver->xmlopt, cfg->c= aps, cfg->configDir); goto endjob; } } @@ -2351,13 +2351,13 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned= int nvcpus, ret =3D 0; =20 if (flags & VIR_DOMAIN_VCPU_LIVE) { - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, cfg->ca= ps) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, cfg->caps, cfg->stateDir)= < 0) { VIR_WARN("Unable to save status on vm %s after changing vcpus", vm->def->name); } } if (flags & VIR_DOMAIN_VCPU_CONFIG) { - if (virDomainSaveConfig(cfg->configDir, cfg->caps, def) < 0) { + if (virDomainDefSave(def, driver->xmlopt, cfg->caps, cfg->configDi= r) < 0) { VIR_WARN("Unable to save configuration of vm %s after changing= vcpus", vm->def->name); } @@ -2507,9 +2507,9 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned in= t vcpu, ret =3D 0; =20 if (flags & VIR_DOMAIN_AFFECT_LIVE) { - ret =3D virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, cfg= ->caps); + ret =3D virDomainObjSave(vm, driver->xmlopt, cfg->caps, cfg->state= Dir); } else if (flags & VIR_DOMAIN_AFFECT_CONFIG) { - ret =3D virDomainSaveConfig(cfg->configDir, cfg->caps, targetDef); + ret =3D virDomainDefSave(targetDef, driver->xmlopt, cfg->caps, cfg= ->configDir); } =20 endjob: @@ -2869,9 +2869,8 @@ libxlDomainDefineXMLFlags(virConnectPtr conn, const c= har *xml, unsigned int flag =20 vm->persistent =3D 1; =20 - if (virDomainSaveConfig(cfg->configDir, - cfg->caps, - vm->newDef ? vm->newDef : vm->def) < 0) { + if (virDomainDefSave(vm->newDef ? vm->newDef : vm->def, + driver->xmlopt, cfg->caps, cfg->configDir) < 0) { virDomainObjListRemove(driver->domains, vm); goto cleanup; } @@ -4145,7 +4144,7 @@ libxlDomainAttachDeviceFlags(virDomainPtr dom, const = char *xml, * update domain status forcibly because the domain status may be * changed even if we attach the device failed. */ - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, cfg->ca= ps) < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->caps, cfg->stateDir)= < 0) goto endjob; } =20 @@ -4153,7 +4152,7 @@ libxlDomainAttachDeviceFlags(virDomainPtr dom, const = char *xml, =20 /* Finally, if no error until here, we can save config. */ if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) { - ret =3D virDomainSaveConfig(cfg->configDir, cfg->caps, vmdef); + ret =3D virDomainDefSave(vmdef, driver->xmlopt, cfg->caps, cfg->co= nfigDir); if (!ret) { virDomainObjAssignDef(vm, vmdef, false, NULL); vmdef =3D NULL; @@ -4236,7 +4235,7 @@ libxlDomainDetachDeviceFlags(virDomainPtr dom, const = char *xml, * update domain status forcibly because the domain status may be * changed even if we attach the device failed. */ - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, cfg->ca= ps) < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->caps, cfg->stateDir)= < 0) goto endjob; } =20 @@ -4244,7 +4243,7 @@ libxlDomainDetachDeviceFlags(virDomainPtr dom, const = char *xml, =20 /* Finally, if no error until here, we can save config. */ if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) { - ret =3D virDomainSaveConfig(cfg->configDir, cfg->caps, vmdef); + ret =3D virDomainDefSave(vmdef, driver->xmlopt, cfg->caps, cfg->co= nfigDir); if (!ret) { virDomainObjAssignDef(vm, vmdef, false, NULL); vmdef =3D NULL; @@ -4324,13 +4323,13 @@ libxlDomainUpdateDeviceFlags(virDomainPtr dom, cons= t char *xml, * update domain status forcibly because the domain status may be * changed even if we attach the device failed. */ - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, cfg->ca= ps) < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->caps, cfg->stateDir)= < 0) ret =3D -1; } =20 /* Finally, if no error until here, we can save config. */ if (!ret && (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG)) { - ret =3D virDomainSaveConfig(cfg->configDir, cfg->caps, vmdef); + ret =3D virDomainDefSave(vmdef, driver->xmlopt, cfg->caps, cfg->co= nfigDir); if (!ret) { virDomainObjAssignDef(vm, vmdef, false, NULL); vmdef =3D NULL; diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index 3f87c35b1c..65ff8271a7 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -1326,7 +1326,7 @@ libxlDomainMigrationDstFinish(virConnectPtr dconn, driver->xmlopt, vm, NUL= L))) goto cleanup; =20 - if (virDomainSaveConfig(cfg->configDir, cfg->caps, vmdef) < 0) + if (virDomainDefSave(vmdef, driver->xmlopt, cfg->caps, cfg->config= Dir) < 0) goto cleanup; =20 event =3D virDomainEventLifecycleNewFromObj(vm, @@ -1338,7 +1338,7 @@ libxlDomainMigrationDstFinish(virConnectPtr dconn, event =3D NULL; } =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, cfg->caps) = < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->caps, cfg->stateDir) < 0) goto cleanup; =20 dom =3D virGetDomain(dconn, vm->def->name, vm->def->uuid, vm->def->id); @@ -1388,7 +1388,7 @@ libxlDomainMigrationSrcConfirm(libxlDriverPrivatePtr = driver, VIR_DOMAIN_PAUSED_MIGRATION); event =3D virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVE= NT_SUSPENDED, VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED); - ignore_value(virDomainSaveStatus(driver->xmlopt, cfg->stateDir= , vm, cfg->caps)); + ignore_value(virDomainObjSave(vm, driver->xmlopt, cfg->caps, c= fg->stateDir)); } goto cleanup; } diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 826bf074e3..cb0ab6e0d5 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -443,8 +443,8 @@ lxcDomainDefineXMLFlags(virConnectPtr conn, const char = *xml, unsigned int flags) def =3D NULL; vm->persistent =3D 1; =20 - if (virDomainSaveConfig(cfg->configDir, driver->caps, - vm->newDef ? vm->newDef : vm->def) < 0) { + if (virDomainDefSave(vm->newDef ? vm->newDef : vm->def, + driver->xmlopt, driver->caps, cfg->configDir) < 0= ) { virDomainObjListRemove(driver->domains, vm); goto cleanup; } @@ -677,8 +677,8 @@ static int lxcDomainSetMemoryFlags(virDomainPtr dom, un= signed long newmem, virDomainDefSetMemoryTotal(persistentDef, newmem); if (persistentDef->mem.cur_balloon > newmem) persistentDef->mem.cur_balloon =3D newmem; - if (virDomainSaveConfig(cfg->configDir, driver->caps, - persistentDef) < 0) + if (virDomainDefSave(persistentDef, + driver->xmlopt, driver->caps, cfg->config= Dir) < 0) goto endjob; } } else { @@ -705,14 +705,14 @@ static int lxcDomainSetMemoryFlags(virDomainPtr dom, = unsigned long newmem, } =20 def->mem.cur_balloon =3D newmem; - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, dri= ver->caps) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->st= ateDir) < 0) goto endjob; } =20 if (persistentDef) { persistentDef->mem.cur_balloon =3D newmem; - if (virDomainSaveConfig(cfg->configDir, driver->caps, - persistentDef) < 0) + if (virDomainDefSave(persistentDef, + driver->xmlopt, driver->caps, cfg->config= Dir) < 0) goto endjob; } } @@ -857,11 +857,11 @@ lxcDomainSetMemoryParameters(virDomainPtr dom, #undef VIR_SET_MEM_PARAMETER =20 if (def && - virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) + virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) goto endjob; =20 if (persistentDef && - virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef) <= 0) + virDomainDefSave(persistentDef, driver->xmlopt, driver->caps, cfg-= >configDir) < 0) goto endjob; /* QEMU and LXC implementations are identical */ =20 @@ -1967,12 +1967,13 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr d= om, } } =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) goto endjob; =20 =20 if (persistentDef) { - rc =3D virDomainSaveConfig(cfg->configDir, driver->caps, persisten= tDefCopy); + rc =3D virDomainDefSave(persistentDefCopy, driver->xmlopt, driver-= >caps, + cfg->configDir); if (rc < 0) goto endjob; =20 @@ -2672,7 +2673,7 @@ lxcDomainSetBlkioParameters(virDomainPtr dom, } } =20 - if (virDomainSaveConfig(cfg->configDir, driver->caps, persistentDe= f) < 0) + if (virDomainDefSave(persistentDef, driver->xmlopt, driver->caps, = cfg->configDir) < 0) ret =3D -1; } =20 @@ -3029,7 +3030,7 @@ static int lxcDomainSuspend(virDomainPtr dom) VIR_DOMAIN_EVENT_SUSPENDED_PAUSED= ); } =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) goto endjob; ret =3D 0; =20 @@ -3086,7 +3087,7 @@ static int lxcDomainResume(virDomainPtr dom) VIR_DOMAIN_EVENT_RESUMED_UNPAUSED= ); } =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) goto endjob; ret =3D 0; =20 @@ -4743,7 +4744,7 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr do= m, * changed even if we failed to attach the device. For example, * a new controller may be created. */ - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) { ret =3D -1; goto endjob; } @@ -4751,7 +4752,7 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr do= m, =20 /* Finally, if no error until here, we can save config. */ if (flags & VIR_DOMAIN_AFFECT_CONFIG) { - ret =3D virDomainSaveConfig(cfg->configDir, driver->caps, vmdef); + ret =3D virDomainDefSave(vmdef, driver->xmlopt, driver->caps, cfg-= >configDir); if (!ret) { virDomainObjAssignDef(vm, vmdef, false, NULL); vmdef =3D NULL; @@ -4830,7 +4831,7 @@ static int lxcDomainUpdateDeviceFlags(virDomainPtr do= m, if (lxcDomainUpdateDeviceConfig(vmdef, dev) < 0) goto endjob; =20 - if (virDomainSaveConfig(cfg->configDir, driver->caps, vmdef) < 0) + if (virDomainDefSave(vmdef, driver->xmlopt, driver->caps, cfg->configD= ir) < 0) goto endjob; =20 virDomainObjAssignDef(vm, vmdef, false, NULL); @@ -4917,7 +4918,7 @@ static int lxcDomainDetachDeviceFlags(virDomainPtr do= m, * changed even if we failed to attach the device. For example, * a new controller may be created. */ - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) { ret =3D -1; goto endjob; } @@ -4925,7 +4926,7 @@ static int lxcDomainDetachDeviceFlags(virDomainPtr do= m, =20 /* Finally, if no error until here, we can save config. */ if (flags & VIR_DOMAIN_AFFECT_CONFIG) { - ret =3D virDomainSaveConfig(cfg->configDir, driver->caps, vmdef); + ret =3D virDomainDefSave(vmdef, driver->xmlopt, driver->caps, cfg-= >configDir); if (!ret) { virDomainObjAssignDef(vm, vmdef, false, NULL); vmdef =3D NULL; diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 9b62a93096..cae8bbacb5 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -790,7 +790,7 @@ static void virLXCProcessMonitorInitNotify(virLXCMonito= rPtr mon G_GNUC_UNUSED, } virDomainAuditInit(vm, initpid, inode); =20 - if (virDomainSaveStatus(lxc_driver->xmlopt, cfg->stateDir, vm, lxc_dri= ver->caps) < 0) + if (virDomainObjSave(vm, lxc_driver->xmlopt, lxc_driver->caps, cfg->st= ateDir) < 0) VIR_WARN("Cannot update XML with PID for LXC %s", vm->def->name); =20 virObjectUnlock(vm); @@ -1457,7 +1457,7 @@ int virLXCProcessStart(virConnectPtr conn, =20 /* Write domain status to disk for the controller to * read when it starts */ - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) goto cleanup; =20 /* Allow the child to exec the controller */ @@ -1696,7 +1696,7 @@ virLXCProcessReconnectDomain(virDomainObjPtr vm, =20 virLXCProcessReconnectNotifyNets(vm->def); =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) VIR_WARN("Cannot update XML for running LXC guest %s", vm->def= ->name); =20 /* now that we know it's reconnected call the hook if present */ diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 939e6fc01c..ad08e29bb3 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8168,7 +8168,7 @@ qemuDomainObjSaveStatus(virQEMUDriverPtr driver, virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); =20 if (virDomainObjIsActive(obj)) { - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, obj, driver= ->caps) < 0) + if (virDomainObjSave(obj, driver->xmlopt, driver->caps, cfg->state= Dir) < 0) VIR_WARN("Failed to save status on vm %s", obj->def->name); } =20 @@ -8200,7 +8200,7 @@ qemuDomainSaveConfig(virDomainObjPtr obj) =20 cfg =3D virQEMUDriverGetConfig(driver); =20 - if (virDomainSaveConfig(cfg->configDir, driver->caps, def) < 0) + if (virDomainDefSave(def, driver->xmlopt, driver->caps, cfg->configDir= ) < 0) VIR_WARN("Failed to save config of vm %s", obj->def->name); } =20 @@ -10073,7 +10073,7 @@ qemuDomainSetFakeReboot(virQEMUDriverPtr driver, =20 priv->fakeReboot =3D value; =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) VIR_WARN("Failed to save status on vm %s", vm->def->name); =20 cleanup: diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 594b683b80..b274542c3e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1860,7 +1860,7 @@ static int qemuDomainSuspend(virDomainPtr dom) if (qemuProcessStopCPUs(driver, vm, reason, QEMU_ASYNC_JOB_NONE) <= 0) goto endjob; } - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) goto endjob; ret =3D 0; =20 @@ -1918,7 +1918,7 @@ static int qemuDomainResume(virDomainPtr dom) goto endjob; } } - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) goto endjob; ret =3D 0; =20 @@ -2360,8 +2360,8 @@ static int qemuDomainSetMemoryFlags(virDomainPtr dom,= unsigned long newmem, =20 if (persistentDef->mem.cur_balloon > newmem) persistentDef->mem.cur_balloon =3D newmem; - ret =3D virDomainSaveConfig(cfg->configDir, driver->caps, - persistentDef); + ret =3D virDomainDefSave(persistentDef, driver->xmlopt, driver= ->caps, + cfg->configDir); goto endjob; } =20 @@ -2400,8 +2400,8 @@ static int qemuDomainSetMemoryFlags(virDomainPtr dom,= unsigned long newmem, =20 if (persistentDef) { persistentDef->mem.cur_balloon =3D newmem; - ret =3D virDomainSaveConfig(cfg->configDir, driver->caps, - persistentDef); + ret =3D virDomainDefSave(persistentDef, driver->xmlopt, driver= ->caps, + cfg->configDir); goto endjob; } } @@ -2475,7 +2475,7 @@ static int qemuDomainSetMemoryStatsPeriod(virDomainPt= r dom, int period, } =20 def->memballoon->period =3D period; - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) goto endjob; } =20 @@ -2487,7 +2487,7 @@ static int qemuDomainSetMemoryStatsPeriod(virDomainPt= r dom, int period, goto endjob; } persistentDef->memballoon->period =3D period; - ret =3D virDomainSaveConfig(cfg->configDir, driver->caps, persiste= ntDef); + ret =3D virDomainDefSave(persistentDef, driver->xmlopt, driver->ca= ps, cfg->configDir); goto endjob; } =20 @@ -4201,7 +4201,7 @@ processGuestPanicEvent(virQEMUDriverPtr driver, =20 virObjectEventStateQueue(driver->domainEventState, event); =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) { VIR_WARN("Unable to save status on vm %s after state change", vm->def->name); } @@ -4281,7 +4281,7 @@ processDeviceDeletedEvent(virQEMUDriverPtr driver, goto endjob; } =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) VIR_WARN("unable to save domain status after removing device %s", devAlias); =20 @@ -4649,7 +4649,7 @@ processSerialChangedEvent(virQEMUDriverPtr driver, =20 dev.data.chr->state =3D newstate; =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) VIR_WARN("unable to save status of domain %s after updating state = of " "channel %s", vm->def->name, devAlias); =20 @@ -4975,7 +4975,7 @@ qemuDomainSetVcpusMax(virQEMUDriverPtr driver, if (virDomainDefSetVcpusMax(persistentDef, nvcpus, driver->xmlopt) < 0) return -1; =20 - if (virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef) <= 0) + if (virDomainDefSave(persistentDef, driver->xmlopt, driver->caps, cfg-= >configDir) < 0) return -1; =20 return 0; @@ -5104,7 +5104,7 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm, vcpuinfo->cpumask =3D tmpmap; tmpmap =3D NULL; =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) goto cleanup; =20 if (g_snprintf(paramField, VIR_TYPED_PARAM_FIELD_LENGTH, @@ -5187,7 +5187,7 @@ qemuDomainPinVcpuFlags(virDomainPtr dom, vcpuinfo->cpumask =3D pcpumap; pcpumap =3D NULL; =20 - ret =3D virDomainSaveConfig(cfg->configDir, driver->caps, persiste= ntDef); + ret =3D virDomainDefSave(persistentDef, driver->xmlopt, driver->ca= ps, cfg->configDir); goto endjob; } =20 @@ -5319,7 +5319,7 @@ qemuDomainPinEmulator(virDomainPtr dom, if (!(def->cputune.emulatorpin =3D virBitmapNewCopy(pcpumap))) goto endjob; =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) goto endjob; =20 str =3D virBitmapFormat(pcpumap); @@ -5339,7 +5339,7 @@ qemuDomainPinEmulator(virDomainPtr dom, if (!(persistentDef->cputune.emulatorpin =3D virBitmapNewCopy(pcpu= map))) goto endjob; =20 - ret =3D virDomainSaveConfig(cfg->configDir, driver->caps, persiste= ntDef); + ret =3D virDomainDefSave(persistentDef, driver->xmlopt, driver->ca= ps, cfg->configDir); goto endjob; } =20 @@ -5799,7 +5799,7 @@ qemuDomainPinIOThread(virDomainPtr dom, if (virProcessSetAffinity(iothrid->thread_id, pcpumap) < 0) goto endjob; =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) goto endjob; =20 if (g_snprintf(paramField, VIR_TYPED_PARAM_FIELD_LENGTH, @@ -5832,7 +5832,7 @@ qemuDomainPinIOThread(virDomainPtr dom, iothrid->cpumask =3D cpumask; iothrid->autofill =3D false; =20 - ret =3D virDomainSaveConfig(cfg->configDir, driver->caps, persiste= ntDef); + ret =3D virDomainDefSave(persistentDef, driver->xmlopt, driver->ca= ps, cfg->configDir); goto endjob; } =20 @@ -6250,7 +6250,7 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver, =20 } =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) goto endjob; } =20 @@ -6282,8 +6282,8 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver, break; } =20 - if (virDomainSaveConfig(cfg->configDir, driver->caps, - persistentDef) < 0) + if (virDomainDefSave(persistentDef, driver->xmlopt, driver->caps, + cfg->configDir) < 0) goto endjob; } =20 @@ -6894,7 +6894,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, "%s", _("failed to resume domain")); goto cleanup; } - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) { VIR_WARN("Failed to save status on vm %s", vm->def->name); goto cleanup; } @@ -7608,8 +7608,8 @@ qemuDomainDefineXMLFlags(virConnectPtr conn, =20 vm->persistent =3D 1; =20 - if (virDomainSaveConfig(cfg->configDir, driver->caps, - vm->newDef ? vm->newDef : vm->def) < 0) { + if (virDomainDefSave(vm->newDef ? vm->newDef : vm->def, + driver->xmlopt, driver->caps, cfg->configDir) < 0= ) { if (oldDef) { /* There is backup so this VM was defined before. * Just restore the backup. */ @@ -8674,13 +8674,13 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr= vm, * changed even if we failed to attach the device. For example, * a new controller may be created. */ - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) goto cleanup; } =20 /* Finally, if no error until here, we can save config. */ if (flags & VIR_DOMAIN_AFFECT_CONFIG) { - if (virDomainSaveConfig(cfg->configDir, driver->caps, vmdef) < 0) + if (virDomainDefSave(vmdef, driver->xmlopt, driver->caps, cfg->con= figDir) < 0) goto cleanup; =20 virDomainObjAssignDef(vm, vmdef, false, NULL); @@ -8827,7 +8827,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr d= om, * changed even if we failed to attach the device. For example, * a new controller may be created. */ - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) { ret =3D -1; goto endjob; } @@ -8835,7 +8835,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr d= om, =20 /* Finally, if no error until here, we can save config. */ if (flags & VIR_DOMAIN_AFFECT_CONFIG) { - ret =3D virDomainSaveConfig(cfg->configDir, driver->caps, vmdef); + ret =3D virDomainDefSave(vmdef, driver->xmlopt, driver->caps, cfg-= >configDir); if (!ret) { virDomainObjAssignDef(vm, vmdef, false, NULL); vmdef =3D NULL; @@ -8925,13 +8925,13 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPt= r driver, * changed even if we failed to attach the device. For example, * a new controller may be created. */ - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, caps) <= 0) + if (virDomainObjSave(vm, driver->xmlopt, caps, cfg->stateDir) < 0) goto cleanup; } =20 /* Finally, if no error until here, we can save config. */ if (flags & VIR_DOMAIN_AFFECT_CONFIG) { - if (virDomainSaveConfig(cfg->configDir, caps, vmdef) < 0) + if (virDomainDefSave(vmdef, driver->xmlopt, caps, cfg->configDir) = < 0) goto cleanup; =20 virDomainObjAssignDef(vm, vmdef, false, NULL); @@ -9009,7 +9009,7 @@ qemuDomainDetachDeviceAliasLiveAndConfig(virQEMUDrive= rPtr driver, } =20 if (vmdef) { - if (virDomainSaveConfig(cfg->configDir, caps, vmdef) < 0) + if (virDomainDefSave(vmdef, driver->xmlopt, caps, cfg->configDir) = < 0) goto cleanup; virDomainObjAssignDef(vm, vmdef, false, NULL); vmdef =3D NULL; @@ -9591,7 +9591,7 @@ qemuDomainSetBlkioParameters(virDomainPtr dom, } } =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) goto endjob; } if (ret < 0) @@ -9626,7 +9626,7 @@ qemuDomainSetBlkioParameters(virDomainPtr dom, } } =20 - if (virDomainSaveConfig(cfg->configDir, driver->caps, persistentDe= f) < 0) + if (virDomainDefSave(persistentDef, driver->xmlopt, driver->caps, = cfg->configDir) < 0) ret =3D -1; } =20 @@ -9856,11 +9856,11 @@ qemuDomainSetMemoryParameters(virDomainPtr dom, #undef VIR_SET_MEM_PARAMETER =20 if (def && - virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) + virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) goto endjob; =20 if (persistentDef && - virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef) <= 0) + virDomainDefSave(persistentDef, driver->xmlopt, driver->caps, cfg-= >configDir) < 0) goto endjob; /* QEMU and LXC implementations are identical */ =20 @@ -10123,7 +10123,7 @@ qemuDomainSetNumaParameters(virDomainPtr dom, -1, mode, nodeset) < 0) goto endjob; =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) goto endjob; } =20 @@ -10134,7 +10134,7 @@ qemuDomainSetNumaParameters(virDomainPtr dom, -1, mode, nodeset) < 0) goto endjob; =20 - if (virDomainSaveConfig(cfg->configDir, driver->caps, persistentDe= f) < 0) + if (virDomainDefSave(persistentDef, driver->xmlopt, driver->caps, = cfg->configDir) < 0) goto endjob; } =20 @@ -10316,7 +10316,7 @@ qemuDomainSetPerfEvents(virDomainPtr dom, VIR_TRISTATE_BOOL_YES : VIR_TRISTATE_BOOL_NO; } =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) goto endjob; } =20 @@ -10330,7 +10330,7 @@ qemuDomainSetPerfEvents(virDomainPtr dom, VIR_TRISTATE_BOOL_YES : VIR_TRISTATE_BOOL_NO; } =20 - if (virDomainSaveConfig(cfg->configDir, driver->caps, persistentDe= f) < 0) + if (virDomainDefSave(persistentDef, driver->xmlopt, driver->caps, = cfg->configDir) < 0) goto endjob; } =20 @@ -10792,7 +10792,7 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr = dom, } } =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) + if (virDomainObjSave(vm, driver->xmlopt, caps, cfg->stateDir) < 0) goto endjob; =20 if (eventNparams) { @@ -10802,7 +10802,8 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr = dom, } =20 if (persistentDef) { - rc =3D virDomainSaveConfig(cfg->configDir, driver->caps, persisten= tDefCopy); + rc =3D virDomainDefSave(persistentDefCopy, driver->xmlopt, caps, + cfg->configDir); if (rc < 0) goto endjob; =20 @@ -11640,7 +11641,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, goto endjob; } =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) goto endjob; } =20 @@ -11665,7 +11666,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, } } =20 - if (virDomainSaveConfig(cfg->configDir, driver->caps, persistentDe= f) < 0) + if (virDomainDefSave(persistentDef, driver->xmlopt, driver->caps, = cfg->configDir) < 0) goto endjob; } =20 @@ -14626,7 +14627,7 @@ qemuDomainSnapshotCreateInactiveExternal(virQEMUDri= verPtr driver, defdisk->src =3D g_steal_pointer(&newsrc); } =20 - if (virDomainSaveConfig(cfg->configDir, driver->caps, vm->def) < 0) + if (virDomainDefSave(vm->def, driver->xmlopt, driver->caps, cfg->confi= gDir) < 0) goto cleanup; =20 ret =3D 0; @@ -15563,9 +15564,9 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr= driver, if (rc < 0) goto cleanup; =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0 || - (vm->newDef && virDomainSaveConfig(cfg->configDir, driver->caps, - vm->newDef) < 0)) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0 || + (vm->newDef && virDomainDefSave(vm->newDef, driver->xmlopt, driver= ->caps, + cfg->configDir) < 0)) goto cleanup; =20 ret =3D 0; @@ -16861,8 +16862,8 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr sna= pshot, } } if (ret =3D=3D 0 && defined && vm->persistent && - !(ret =3D virDomainSaveConfig(cfg->configDir, driver->caps, - vm->newDef ? vm->newDef : vm->def))) { + !(ret =3D virDomainDefSave(vm->newDef ? vm->newDef : vm->def, + driver->xmlopt, driver->caps, cfg->config= Dir))) { detail =3D VIR_DOMAIN_EVENT_DEFINED_FROM_SNAPSHOT; virObjectEventStateQueue(driver->domainEventState, virDomainEventLifecycleNewFromObj(vm, @@ -17667,7 +17668,7 @@ qemuDomainBlockJobAbort(virDomainPtr dom, job->state =3D QEMU_BLOCKJOB_STATE_ABORTING; } =20 - ignore_value(virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, dr= iver->caps)); + ignore_value(virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->s= tateDir)); =20 if (!async) { qemuBlockJobUpdate(vm, job, QEMU_ASYNC_JOB_NONE); @@ -19245,8 +19246,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, if (virDomainDiskSetBlockIOTune(disk, &info) < 0) goto endjob; =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, - vm, driver->caps) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) goto endjob; =20 if (eventNparams) { @@ -19271,8 +19271,8 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, if (virDomainDiskSetBlockIOTune(conf_disk, &info) < 0) goto endjob; =20 - if (virDomainSaveConfig(cfg->configDir, driver->caps, - persistentDef) < 0) + if (virDomainDefSave(persistentDef, driver->xmlopt, driver->caps, + cfg->configDir) < 0) goto endjob; } =20 @@ -21873,7 +21873,7 @@ qemuDomainRenameCallback(virDomainObjPtr vm, vm->def->name =3D new_dom_name; new_dom_name =3D NULL; =20 - if (virDomainSaveConfig(cfg->configDir, driver->caps, vm->def) < 0) + if (virDomainDefSave(vm->def, driver->xmlopt, driver->caps, cfg->confi= gDir) < 0) goto rollback; =20 if (virFileExists(old_dom_cfg_file) && @@ -22397,16 +22397,15 @@ qemuDomainSetLifecycleAction(virDomainPtr dom, =20 qemuDomainModifyLifecycleAction(def, type, action); =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, - vm, driver->caps) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) goto endjob; } =20 if (persistentDef) { qemuDomainModifyLifecycleAction(persistentDef, type, action); =20 - if (virDomainSaveConfig(cfg->configDir, driver->caps, - persistentDef) < 0) + if (virDomainDefSave(persistentDef, driver->xmlopt, driver->caps, + cfg->configDir) < 0) goto endjob; } =20 @@ -22701,7 +22700,7 @@ qemuDomainAgentSetResponseTimeout(virDomainPtr dom, QEMU_DOMAIN_PRIVATE(vm)->agentTimeout =3D timeout; =20 if (virDomainObjIsActive(vm) && - virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) + virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) goto cleanup; =20 ret =3D 0; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index d4eacaf099..da32a845e1 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -5980,7 +5980,7 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver, =20 qemuDomainVcpuPersistOrder(vm->def); =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) goto cleanup; =20 ret =3D 0; @@ -6055,7 +6055,7 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver, =20 qemuDomainVcpuPersistOrder(vm->def); =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) goto cleanup; =20 ret =3D 0; @@ -6313,7 +6313,7 @@ qemuDomainSetVcpusInternal(virQEMUDriverPtr driver, if (persistentDef) { qemuDomainSetVcpusConfig(persistentDef, nvcpus, hotpluggable); =20 - if (virDomainSaveConfig(cfg->configDir, driver->caps, persistentDe= f) < 0) + if (virDomainDefSave(persistentDef, driver->xmlopt, driver->caps, = cfg->configDir) < 0) goto cleanup; } =20 @@ -6513,7 +6513,7 @@ qemuDomainSetVcpuInternal(virQEMUDriverPtr driver, if (persistentDef) { qemuDomainSetVcpuConfig(persistentDef, map, state); =20 - if (virDomainSaveConfig(cfg->configDir, driver->caps, persistentDe= f) < 0) + if (virDomainDefSave(persistentDef, driver->xmlopt, driver->caps, = cfg->configDir) < 0) goto cleanup; } =20 diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index dabdda2715..e9470cc62c 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1008,7 +1008,7 @@ qemuMigrationSrcNBDStorageCopy(virQEMUDriverPtr drive= r, tlsAlias, flags) < 0) return -1; =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) { VIR_WARN("Failed to save status on vm %s", vm->def->name); return -1; } @@ -2991,7 +2991,7 @@ qemuMigrationSrcConfirmPhase(virQEMUDriverPtr driver, qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT, priv->job.migParams, priv->job.apiFlags); =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) VIR_WARN("Failed to save status on vm %s", vm->def->name); } =20 @@ -4842,7 +4842,7 @@ qemuMigrationDstPersist(virQEMUDriverPtr driver, priv->qemuCaps))) goto error; =20 - if (virDomainSaveConfig(cfg->configDir, driver->caps, vmdef) < 0 && + if (virDomainDefSave(vmdef, driver->xmlopt, driver->caps, cfg->configD= ir) < 0 && !ignoreSaveError) goto error; =20 @@ -5095,7 +5095,7 @@ qemuMigrationDstFinish(virQEMUDriverPtr driver, } =20 if (virDomainObjIsActive(vm) && - virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) + virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) VIR_WARN("Failed to save status on vm %s", vm->def->name); =20 /* Guest is successfully running, so cancel previous auto destroy */ diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 480fcd075d..79ac5f3d95 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -411,7 +411,7 @@ qemuProcessHandleReset(qemuMonitorPtr mon G_GNUC_UNUSED, if (priv->agent) qemuAgentNotifyEvent(priv->agent, QEMU_AGENT_EVENT_RESET); =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) VIR_WARN("Failed to save status on vm %s", vm->def->name); =20 if (vm->def->onReboot =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY || @@ -493,7 +493,7 @@ qemuProcessFakeReboot(void *opaque) goto endjob; } =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) { VIR_WARN("Unable to save status on vm %s after state change", vm->def->name); } @@ -614,7 +614,7 @@ qemuProcessHandleShutdown(qemuMonitorPtr mon G_GNUC_UNU= SED, VIR_DOMAIN_EVENT_SHUTDOWN, detail); =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) { VIR_WARN("Unable to save status on vm %s after state change", vm->def->name); } @@ -680,7 +680,7 @@ qemuProcessHandleStop(qemuMonitorPtr mon G_GNUC_UNUSED, VIR_WARN("Unable to release lease on %s", vm->def->name); VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState)); =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) { VIR_WARN("Unable to save status on vm %s after state change", vm->def->name); } @@ -726,7 +726,7 @@ qemuProcessHandleResume(qemuMonitorPtr mon G_GNUC_UNUSE= D, VIR_DOMAIN_EVENT_RESUMED, eventDetail); =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) { VIR_WARN("Unable to save status on vm %s after state change", vm->def->name); } @@ -769,7 +769,7 @@ qemuProcessHandleRTCChange(qemuMonitorPtr mon G_GNUC_UN= USED, offset +=3D vm->def->clock.data.variable.adjustment0; vm->def->clock.data.variable.adjustment =3D offset; =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) VIR_WARN("unable to save domain status with RTC change"); } =20 @@ -812,7 +812,7 @@ qemuProcessHandleWatchdog(qemuMonitorPtr mon G_GNUC_UNU= SED, VIR_WARN("Unable to release lease on %s", vm->def->name); VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState)); =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) { VIR_WARN("Unable to save status on vm %s after watchdog event", vm->def->name); } @@ -904,7 +904,7 @@ qemuProcessHandleIOError(qemuMonitorPtr mon G_GNUC_UNUS= ED, VIR_WARN("Unable to release lease on %s", vm->def->name); VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState)); =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) VIR_WARN("Unable to save status on vm %s after IO error", vm->= def->name); } virObjectUnlock(vm); @@ -1149,7 +1149,7 @@ qemuProcessHandleTrayChange(qemuMonitorPtr mon G_GNUC= _UNUSED, else if (reason =3D=3D VIR_DOMAIN_EVENT_TRAY_CHANGE_CLOSE) disk->tray_status =3D VIR_DOMAIN_DISK_TRAY_CLOSED; =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) { VIR_WARN("Unable to save status on vm %s after tray moved even= t", vm->def->name); } @@ -1189,7 +1189,7 @@ qemuProcessHandlePMWakeup(qemuMonitorPtr mon G_GNUC_U= NUSED, VIR_DOMAIN_EVENT_STARTED, VIR_DOMAIN_EVENT_STARTED= _WAKEUP); =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) { VIR_WARN("Unable to save status on vm %s after wakeup event", vm->def->name); } @@ -1227,7 +1227,7 @@ qemuProcessHandlePMSuspend(qemuMonitorPtr mon G_GNUC_= UNUSED, VIR_DOMAIN_EVENT_PMSUSPENDED, VIR_DOMAIN_EVENT_PMSUSPENDED_MEMORY); =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) { VIR_WARN("Unable to save status on vm %s after suspend event", vm->def->name); } @@ -1261,7 +1261,7 @@ qemuProcessHandleBalloonChange(qemuMonitorPtr mon G_G= NUC_UNUSED, vm->def->mem.cur_balloon, actual); vm->def->mem.cur_balloon =3D actual; =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) VIR_WARN("unable to save domain status with balloon change"); =20 virObjectUnlock(vm); @@ -1296,7 +1296,7 @@ qemuProcessHandlePMSuspendDisk(qemuMonitorPtr mon G_G= NUC_UNUSED, VIR_DOMAIN_EVENT_PMSUSPENDED, VIR_DOMAIN_EVENT_PMSUSPENDED_DISK); =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) { VIR_WARN("Unable to save status on vm %s after suspend event", vm->def->name); } @@ -1669,7 +1669,7 @@ qemuProcessHandleMigrationStatus(qemuMonitorPtr mon G= _GNUC_UNUSED, VIR_DOMAIN_EVENT_SUSPEND= ED, VIR_DOMAIN_EVENT_SUSPEND= ED_POSTCOPY); =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) { VIR_WARN("Unable to save status on vm %s after state change", vm->def->name); } @@ -3105,7 +3105,7 @@ qemuProcessUpdateVideoRamSize(virQEMUDriverPtr driver, return -1; =20 cfg =3D virQEMUDriverGetConfig(driver); - ret =3D virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps); + ret =3D virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir); virObjectUnref(cfg); =20 return ret; @@ -6860,7 +6860,7 @@ qemuProcessLaunch(virConnectPtr conn, } =20 VIR_DEBUG("Writing early domain status to disk"); - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) goto cleanup; =20 VIR_DEBUG("Waiting for handshake from child"); @@ -7118,7 +7118,7 @@ qemuProcessFinishStartup(virQEMUDriverPtr driver, } =20 VIR_DEBUG("Writing domain status to disk"); - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) + if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) goto cleanup; =20 if (qemuProcessStartHook(driver, vm, @@ -8221,7 +8221,7 @@ qemuProcessReconnect(void *opaque) } =20 /* update domain state XML with possibly updated state in virDomainObj= */ - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, obj, driver->ca= ps) < 0) + if (virDomainObjSave(obj, driver->xmlopt, driver->caps, cfg->stateDir)= < 0) goto error; =20 /* Run an hook to allow admins to do some magic */ --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 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=1575469386; cv=none; d=zohomail.com; s=zohoarc; b=YZuQUezVsGpJQPzxflud5xrGyq5CLGHbxASSPSfZY41U3Y1LaW2jI/6A0YbZbZ+d9ZteOEhKoekwhQqOaK2/FyQsFpP4GshjRRpe8AWUALTSqI0vi2xkIn5H1XPE/KmmRvUzEFeHnq+VrQ6jBtc9bVesnyP7kz0V9uhayFID1VQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469386; 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=05Jp6TCjihxpxkTT3tjpYGt3kjHAQQNAoa9UOMtNWho=; b=QGyNQVlXtUjRUNXdnhXYVtoplY5nUgkPEVVO5Hug1KaGh+yT0KXjrmqzFUJpgmbjWEvDzZWduFdQiH6VU+cWDVGx6UZRzCDV3wbBZZNcD36QTKnHXyaR40+bo5N/uLkRQxVJinHc6Epu7/QAdzVxLJLduC5aZ3VQjhUwCJygUI0= 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 1575469386525880.6972595315109; Wed, 4 Dec 2019 06:23:06 -0800 (PST) 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-38-ai2i0Vn8Nmi4pZqTFuy8rQ-1; Wed, 04 Dec 2019 09:21:51 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9E1E1DBF2; Wed, 4 Dec 2019 14:21:44 +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 71BB219C6A; Wed, 4 Dec 2019 14:21: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 30D7D5BC17; Wed, 4 Dec 2019 14:21:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4ELOKc008095 for ; Wed, 4 Dec 2019 09:21:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4ED961D1; Wed, 4 Dec 2019 14:21:24 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8CEB467E62; Wed, 4 Dec 2019 14:21:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469385; 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=05Jp6TCjihxpxkTT3tjpYGt3kjHAQQNAoa9UOMtNWho=; b=D2toOxxy5L9agCTI5bdgZbuenfDggTDsqsn5/JbCqqhj+itgoALOLqqSD2CUlph6hmgLwG GjYm7QFMGz8gPqFRYXNz8M5fhF4snfI5Ndc+Yk7Je4pO4MhFmctNkkf+s/WRoASLPSPe4r WltG7+6lvM1+2DEgZA5gXRRL3kjNXM4= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:20:47 +0000 Message-Id: <20191204142113.2961028-5-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 04/30] conf: sanitize virDomainObjFormat & virDomainDefFormat* APIs 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.84 on 10.5.11.23 X-MC-Unique: ai2i0Vn8Nmi4pZqTFuy8rQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Moving their instance parameter to be the first one, and give consistent ordering of other parameters across all functions. Ensure that the xml options are passed into both functions in prep for future work. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/bhyve/bhyve_driver.c | 4 +-- src/conf/checkpoint_conf.c | 4 +-- src/conf/domain_conf.c | 39 ++++++++++++---------- src/conf/domain_conf.h | 28 +++++++++++----- src/conf/snapshot_conf.c | 10 +++--- src/esx/esx_driver.c | 4 +-- src/hyperv/hyperv_driver.c | 3 +- src/libxl/libxl_domain.c | 12 +++---- src/libxl/libxl_driver.c | 8 ++--- src/libxl/libxl_migration.c | 4 +-- src/lxc/lxc_driver.c | 4 +-- src/lxc/lxc_process.c | 12 +++---- src/openvz/openvz_conf.c | 55 +++++++++++++++++++++++++++++++ src/openvz/openvz_conf.h | 1 + src/openvz/openvz_driver.c | 56 ++------------------------------ src/phyp/phyp_driver.c | 2 +- src/qemu/qemu_domain.c | 5 ++- src/security/security_apparmor.c | 2 +- src/test/test_driver.c | 8 +++-- src/vbox/vbox_common.c | 2 +- src/vmware/vmware_driver.c | 4 +-- src/vz/vz_driver.c | 4 +-- tests/Makefile.am | 3 +- tests/lxcconf2xmltest.c | 2 +- tests/openvzutilstest.c | 4 ++- tests/qemuhotplugtest.c | 6 ++-- tests/qemuxml2xmltest.c | 2 +- tests/testutils.c | 2 +- tests/vmx2xmltest.c | 2 +- tests/xlconfigtest.c | 3 +- tests/xmconfigtest.c | 2 +- 31 files changed, 161 insertions(+), 136 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index b8a206bb1e..18b5d1e950 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -495,7 +495,7 @@ bhyveDomainGetXMLDesc(virDomainPtr domain, unsigned int= flags) if (!caps) goto cleanup; =20 - ret =3D virDomainDefFormat(vm->def, caps, + ret =3D virDomainDefFormat(vm->def, privconn->xmlopt, caps, virDomainDefFormatConvertXMLFlags(flags)); =20 virObjectUnref(caps); @@ -1583,7 +1583,7 @@ bhyveConnectDomainXMLFromNative(virConnectPtr conn, if (def =3D=3D NULL) goto cleanup; =20 - xml =3D virDomainDefFormat(def, capabilities, 0); + xml =3D virDomainDefFormat(def, privconn->xmlopt, capabilities, 0); =20 cleanup: virObjectUnref(capabilities); diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c index 36076c13df..cb2d83796c 100644 --- a/src/conf/checkpoint_conf.c +++ b/src/conf/checkpoint_conf.c @@ -489,8 +489,8 @@ virDomainCheckpointDefFormatInternal(virBufferPtr buf, } =20 if (!(flags & VIR_DOMAIN_CHECKPOINT_FORMAT_NO_DOMAIN) && - virDomainDefFormatInternal(def->parent.dom, caps, domainflags, buf, - xmlopt) < 0) + virDomainDefFormatInternal(def->parent.dom, xmlopt, + caps, buf, domainflags) < 0) goto error; =20 virBufferAdjustIndent(buf, -2); diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 87bbb2d263..781bf9d2d4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -23600,8 +23600,8 @@ virDomainDefCheckABIStabilityFlags(virDomainDefPtr = src, error: virErrorPreserveLast(&err); =20 - strSrc =3D virDomainDefFormat(src, NULL, 0); - strDst =3D virDomainDefFormat(dst, NULL, 0); + strSrc =3D virDomainDefFormat(src, xmlopt, NULL, 0); + strDst =3D virDomainDefFormat(dst, xmlopt, NULL, 0); VIR_DEBUG("XMLs that failed stability check were: src=3D\"%s\", dst=3D= \"%s\"", NULLSTR(strSrc), NULLSTR(strDst)); =20 @@ -28286,13 +28286,13 @@ virDomainDefFormatFeatures(virBufferPtr buf, =20 int virDomainDefFormatInternal(virDomainDefPtr def, + virDomainXMLOptionPtr xmlopt, virCapsPtr caps, - unsigned int flags, virBufferPtr buf, - virDomainXMLOptionPtr xmlopt) + unsigned int flags) { - return virDomainDefFormatInternalSetRootName(def, caps, flags, buf, - xmlopt, "domain"); + return virDomainDefFormatInternalSetRootName(def, xmlopt, caps, buf, + "domain", flags); } =20 =20 @@ -28302,11 +28302,11 @@ virDomainDefFormatInternal(virDomainDefPtr def, * Return -1 on failure. */ int virDomainDefFormatInternalSetRootName(virDomainDefPtr def, + virDomainXMLOptionPtr xmlopt, virCapsPtr caps, - unsigned int flags, virBufferPtr buf, - virDomainXMLOptionPtr xmlopt, - const char *rootname) + const char *rootname, + unsigned int flags) { unsigned char *uuid; char uuidstr[VIR_UUID_STRING_BUFLEN]; @@ -28843,12 +28843,15 @@ unsigned int virDomainDefFormatConvertXMLFlags(un= signed int flags) =20 =20 char * -virDomainDefFormat(virDomainDefPtr def, virCapsPtr caps, unsigned int flag= s) +virDomainDefFormat(virDomainDefPtr def, + virDomainXMLOptionPtr xmlopt, + virCapsPtr caps, + unsigned int flags) { virBuffer buf =3D VIR_BUFFER_INITIALIZER; =20 virCheckFlags(VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS, NULL); - if (virDomainDefFormatInternal(def, caps, flags, &buf, NULL) < 0) + if (virDomainDefFormatInternal(def, xmlopt, caps, &buf, flags) < 0) return NULL; =20 return virBufferContentAndReset(&buf); @@ -28856,8 +28859,8 @@ virDomainDefFormat(virDomainDefPtr def, virCapsPtr = caps, unsigned int flags) =20 =20 char * -virDomainObjFormat(virDomainXMLOptionPtr xmlopt, - virDomainObjPtr obj, +virDomainObjFormat(virDomainObjPtr obj, + virDomainXMLOptionPtr xmlopt, virCapsPtr caps, unsigned int flags) { @@ -28883,7 +28886,7 @@ virDomainObjFormat(virDomainXMLOptionPtr xmlopt, xmlopt->privateData.format(&buf, obj) < 0) goto error; =20 - if (virDomainDefFormatInternal(obj->def, caps, flags, &buf, xmlopt) < = 0) + if (virDomainDefFormatInternal(obj->def, xmlopt, caps, &buf, flags) < = 0) goto error; =20 virBufferAdjustIndent(&buf, -2); @@ -29043,13 +29046,13 @@ virDomainDefSaveXML(virDomainDefPtr def, =20 int virDomainDefSave(virDomainDefPtr def, - virDomainXMLOptionPtr xmlopt G_GNUC_UNUSED, + virDomainXMLOptionPtr xmlopt, virCapsPtr caps, const char *configDir) { g_autofree char *xml =3D NULL; =20 - if (!(xml =3D virDomainDefFormat(def, caps, VIR_DOMAIN_DEF_FORMAT_SECU= RE))) + if (!(xml =3D virDomainDefFormat(def, xmlopt, caps, VIR_DOMAIN_DEF_FOR= MAT_SECURE))) return -1; =20 return virDomainDefSaveXML(def, configDir, xml); @@ -29069,7 +29072,7 @@ virDomainObjSave(virDomainObjPtr obj, =20 g_autofree char *xml =3D NULL; =20 - if (!(xml =3D virDomainObjFormat(xmlopt, obj, caps, flags))) + if (!(xml =3D virDomainObjFormat(obj, xmlopt, caps, flags))) return -1; =20 return virDomainDefSaveXML(obj->def, statusDir, xml); @@ -29373,7 +29376,7 @@ virDomainDefCopy(virDomainDefPtr src, format_flags |=3D VIR_DOMAIN_DEF_FORMAT_INACTIVE | VIR_DOMAIN_DEF_= FORMAT_MIGRATABLE; =20 /* Easiest to clone via a round-trip through XML. */ - if (!(xml =3D virDomainDefFormat(src, caps, format_flags))) + if (!(xml =3D virDomainDefFormat(src, xmlopt, caps, format_flags))) return NULL; =20 return virDomainDefParseString(xml, caps, xmlopt, parseOpaque, parse_f= lags); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index d1c375092e..f7a611d5ef 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3101,23 +3101,33 @@ void virDomainIOThreadIDDel(virDomainDefPtr def, un= signed int iothread_id); unsigned int virDomainDefFormatConvertXMLFlags(unsigned int flags); =20 char *virDomainDefFormat(virDomainDefPtr def, + virDomainXMLOptionPtr xmlopt, virCapsPtr caps, - unsigned int flags); -char *virDomainObjFormat(virDomainXMLOptionPtr xmlopt, - virDomainObjPtr obj, + unsigned int flags) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) + ATTRIBUTE_NONNULL(3); +char *virDomainObjFormat(virDomainObjPtr obj, + virDomainXMLOptionPtr xmlopt, virCapsPtr caps, - unsigned int flags); + unsigned int flags) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) + ATTRIBUTE_NONNULL(3); int virDomainDefFormatInternal(virDomainDefPtr def, + virDomainXMLOptionPtr xmlopt, virCapsPtr caps, - unsigned int flags, virBufferPtr buf, - virDomainXMLOptionPtr xmlopt); + unsigned int flags) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) + ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); int virDomainDefFormatInternalSetRootName(virDomainDefPtr def, + virDomainXMLOptionPtr xmlopt, virCapsPtr caps, - unsigned int flags, virBufferPtr buf, - virDomainXMLOptionPtr xmlopt, - const char *rootname); + const char *rootname, + unsigned int flags) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) + ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4) + ATTRIBUTE_NONNULL(5); =20 int virDomainDiskSourceFormat(virBufferPtr buf, virStorageSourcePtr src, diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index a0509041be..0bf7d497e4 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -891,8 +891,8 @@ virDomainSnapshotDefFormatInternal(virBufferPtr buf, } =20 if (def->parent.dom) { - if (virDomainDefFormatInternal(def->parent.dom, caps, domainflags,= buf, - xmlopt) < 0) + if (virDomainDefFormatInternal(def->parent.dom, xmlopt, + caps, buf, domainflags) < 0) goto error; } else if (uuidstr) { virBufferAddLit(buf, "\n"); @@ -903,9 +903,9 @@ virDomainSnapshotDefFormatInternal(virBufferPtr buf, } =20 if (def->parent.inactiveDom) { - if (virDomainDefFormatInternalSetRootName(def->parent.inactiveDom,= caps, - domainflags, buf, xmlopt, - "inactiveDomain") < 0) + if (virDomainDefFormatInternalSetRootName(def->parent.inactiveDom,= xmlopt, + caps, buf, "inactiveDoma= in", + domainflags) < 0) goto error; } =20 diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index f8ee6db75f..81ff502769 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -2648,7 +2648,7 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int= flags) if (powerState !=3D esxVI_VirtualMachinePowerState_PoweredOff) def->id =3D id; =20 - xml =3D virDomainDefFormat(def, priv->caps, + xml =3D virDomainDefFormat(def, priv->xmlopt, priv->caps, virDomainDefFormatConvertXMLFlags(flags)); } =20 @@ -2706,7 +2706,7 @@ esxConnectDomainXMLFromNative(virConnectPtr conn, con= st char *nativeFormat, def =3D virVMXParseConfig(&ctx, priv->xmlopt, priv->caps, nativeConfig= ); =20 if (def) - xml =3D virDomainDefFormat(def, priv->caps, + xml =3D virDomainDefFormat(def, priv->xmlopt, priv->caps, VIR_DOMAIN_DEF_FORMAT_INACTIVE); =20 virDomainDefFree(def); diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 3a2f6602bc..ff9370d728 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -886,7 +886,8 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned in= t flags) =20 /* FIXME: devices section is totally missing */ =20 - xml =3D virDomainDefFormat(def, NULL, + /* XXX xmlopts must be non-NULL */ + xml =3D virDomainDefFormat(def, NULL, NULL, virDomainDefFormatConvertXMLFlags(flags)); =20 cleanup: diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 9b9b17b173..19905442c1 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -844,7 +844,7 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver, =20 /* now that we know it's stopped call the hook if present */ if (virHookPresent(VIR_HOOK_DRIVER_LIBXL)) { - char *xml =3D virDomainDefFormat(vm->def, cfg->caps, 0); + char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, cfg->cap= s, 0); =20 /* we can't stop the operation even if the script raised an error = */ ignore_value(virHookCall(VIR_HOOK_DRIVER_LIBXL, vm->def->name, @@ -913,7 +913,7 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver, =20 /* The "release" hook cleans up additional resources */ if (virHookPresent(VIR_HOOK_DRIVER_LIBXL)) { - char *xml =3D virDomainDefFormat(vm->def, cfg->caps, 0); + char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, cfg->cap= s, 0); =20 /* we can't stop the operation even if the script raised an error = */ ignore_value(virHookCall(VIR_HOOK_DRIVER_LIBXL, vm->def->name, @@ -1320,7 +1320,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver, =20 /* Run an early hook to set-up missing devices */ if (virHookPresent(VIR_HOOK_DRIVER_LIBXL)) { - char *xml =3D virDomainDefFormat(vm->def, cfg->caps, 0); + char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, cfg->cap= s, 0); int hookret; =20 hookret =3D virHookCall(VIR_HOOK_DRIVER_LIBXL, vm->def->name, @@ -1358,7 +1358,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver, =20 /* now that we know it is about to start call the hook if present */ if (virHookPresent(VIR_HOOK_DRIVER_LIBXL)) { - char *xml =3D virDomainDefFormat(vm->def, cfg->caps, 0); + char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, cfg->cap= s, 0); int hookret; =20 hookret =3D virHookCall(VIR_HOOK_DRIVER_LIBXL, vm->def->name, @@ -1443,7 +1443,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver, libxlDomainCreateChannelPTY(vm->def, cfg->ctx); #endif =20 - if ((dom_xml =3D virDomainDefFormat(vm->def, cfg->caps, 0)) =3D=3D NUL= L) + if ((dom_xml =3D virDomainDefFormat(vm->def, driver->xmlopt, cfg->caps= , 0)) =3D=3D NULL) goto destroy_dom; =20 if (libxl_userdata_store(cfg->ctx, domid, "libvirt-xml", @@ -1471,7 +1471,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver, =20 /* finally we can call the 'started' hook script if any */ if (virHookPresent(VIR_HOOK_DRIVER_LIBXL)) { - char *xml =3D virDomainDefFormat(vm->def, cfg->caps, 0); + char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, cfg->cap= s, 0); int hookret; =20 hookret =3D virHookCall(VIR_HOOK_DRIVER_LIBXL, vm->def->name, diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index b885cf0d00..dc0d9b58f3 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -459,7 +459,7 @@ libxlReconnectDomain(virDomainObjPtr vm, /* now that we know it's reconnected call the hook if present */ if (virHookPresent(VIR_HOOK_DRIVER_LIBXL) && STRNEQ("Domain-0", vm->def->name)) { - char *xml =3D virDomainDefFormat(vm->def, cfg->caps, 0); + char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, cfg->cap= s, 0); int hookret; =20 /* we can't stop the operation even if the script raised an error = */ @@ -1828,7 +1828,7 @@ libxlDoDomainSave(libxlDriverPrivatePtr driver, goto cleanup; } =20 - if ((xml =3D virDomainDefFormat(vm->def, cfg->caps, 0)) =3D=3D NULL) + if ((xml =3D virDomainDefFormat(vm->def, driver->xmlopt, cfg->caps, 0)= ) =3D=3D NULL) goto cleanup; xml_len =3D strlen(xml) + 1; =20 @@ -2652,7 +2652,7 @@ libxlDomainGetXMLDesc(virDomainPtr dom, unsigned int = flags) else def =3D vm->def; =20 - ret =3D virDomainDefFormat(def, cfg->caps, + ret =3D virDomainDefFormat(def, driver->xmlopt, cfg->caps, virDomainDefFormatConvertXMLFlags(flags)); =20 cleanup: @@ -2703,7 +2703,7 @@ libxlConnectDomainXMLFromNative(virConnectPtr conn, goto cleanup; } =20 - xml =3D virDomainDefFormat(def, cfg->caps, VIR_DOMAIN_DEF_FORMAT_INACT= IVE); + xml =3D virDomainDefFormat(def, driver->xmlopt, cfg->caps, VIR_DOMAIN_= DEF_FORMAT_INACTIVE); =20 cleanup: virDomainDefFree(def); diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index 65ff8271a7..25a58f8018 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -420,7 +420,7 @@ libxlDomainMigrationSrcBegin(virConnectPtr conn, if (!libxlDomainMigrationIsAllowed(def)) goto endjob; =20 - xml =3D virDomainDefFormat(def, cfg->caps, VIR_DOMAIN_DEF_FORMAT_SECUR= E); + xml =3D virDomainDefFormat(def, driver->xmlopt, cfg->caps, VIR_DOMAIN_= DEF_FORMAT_SECURE); /* Valid xml means success! EndJob in the confirm phase */ if (xml) goto cleanup; @@ -494,7 +494,7 @@ libxlDomainMigrationPrepareAny(virConnectPtr dconn, char *xml; int hookret; =20 - if (!(xml =3D virDomainDefFormat(*def, cfg->caps, + if (!(xml =3D virDomainDefFormat(*def, driver->xmlopt, cfg->caps, VIR_DOMAIN_XML_SECURE | VIR_DOMAIN_XML_MIGRATABLE))) return -1; diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index cb0ab6e0d5..6c12543274 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -987,7 +987,7 @@ static char *lxcDomainGetXMLDesc(virDomainPtr dom, =20 ret =3D virDomainDefFormat((flags & VIR_DOMAIN_XML_INACTIVE) && vm->newDef ? vm->newDef : vm->def, - driver->caps, + driver->xmlopt, driver->caps, virDomainDefFormatConvertXMLFlags(flags)); =20 cleanup: @@ -1019,7 +1019,7 @@ static char *lxcConnectDomainXMLFromNative(virConnect= Ptr conn, if (!(def =3D lxcParseConfigString(nativeConfig, caps, driver->xmlopt)= )) goto cleanup; =20 - xml =3D virDomainDefFormat(def, caps, 0); + xml =3D virDomainDefFormat(def, driver->xmlopt, caps, 0); =20 cleanup: virObjectUnref(caps); diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index cae8bbacb5..c1b8b6aa09 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -171,7 +171,7 @@ static void virLXCProcessCleanup(virLXCDriverPtr driver, =20 /* now that we know it's stopped call the hook if present */ if (virHookPresent(VIR_HOOK_DRIVER_LXC)) { - char *xml =3D virDomainDefFormat(vm->def, driver->caps, 0); + char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, driver->= caps, 0); =20 /* we can't stop the operation even if the script raised an error = */ virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name, @@ -248,7 +248,7 @@ static void virLXCProcessCleanup(virLXCDriverPtr driver, =20 /* The "release" hook cleans up additional resources */ if (virHookPresent(VIR_HOOK_DRIVER_LXC)) { - char *xml =3D virDomainDefFormat(vm->def, driver->caps, 0); + char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, driver->= caps, 0); =20 /* we can't stop the operation even if the script raised an error = */ virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name, @@ -1271,7 +1271,7 @@ int virLXCProcessStart(virConnectPtr conn, =20 /* Run an early hook to set-up missing devices */ if (virHookPresent(VIR_HOOK_DRIVER_LXC)) { - char *xml =3D virDomainDefFormat(vm->def, driver->caps, 0); + char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, driver->= caps, 0); int hookret; =20 hookret =3D virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name, @@ -1379,7 +1379,7 @@ int virLXCProcessStart(virConnectPtr conn, =20 /* now that we know it is about to start call the hook if present */ if (virHookPresent(VIR_HOOK_DRIVER_LXC)) { - char *xml =3D virDomainDefFormat(vm->def, driver->caps, 0); + char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, driver->= caps, 0); int hookret; =20 hookret =3D virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name, @@ -1521,7 +1521,7 @@ int virLXCProcessStart(virConnectPtr conn, =20 /* finally we can call the 'started' hook script if any */ if (virHookPresent(VIR_HOOK_DRIVER_LXC)) { - char *xml =3D virDomainDefFormat(vm->def, driver->caps, 0); + char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, driver->= caps, 0); int hookret; =20 hookret =3D virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name, @@ -1701,7 +1701,7 @@ virLXCProcessReconnectDomain(virDomainObjPtr vm, =20 /* now that we know it's reconnected call the hook if present */ if (virHookPresent(VIR_HOOK_DRIVER_LXC)) { - char *xml =3D virDomainDefFormat(vm->def, driver->caps, 0); + char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, driv= er->caps, 0); int hookret; =20 /* we can't stop the operation even if the script raised an er= ror */ diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 7676656af1..8a05aa0504 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -1078,3 +1078,58 @@ int openvzGetVEID(const char *name) _("Failed to parse vzlist output")); return -1; } + + +static int +openvzDomainDefPostParse(virDomainDefPtr def, + virCapsPtr caps G_GNUC_UNUSED, + unsigned int parseFlags G_GNUC_UNUSED, + void *opaque G_GNUC_UNUSED, + void *parseOpaque G_GNUC_UNUSED) +{ + /* fill the init path */ + if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_EXE && !def->os.init) + def->os.init =3D g_strdup("/sbin/init"); + + return 0; +} + + +static int +openvzDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, + const virDomainDef *def G_GNUC_UNUSED, + virCapsPtr caps G_GNUC_UNUSED, + unsigned int parseFlags G_GNUC_UNUSED, + void *opaque G_GNUC_UNUSED, + void *parseOpaque G_GNUC_UNUSED) +{ + if (dev->type =3D=3D VIR_DOMAIN_DEVICE_CHR && + dev->data.chr->deviceType =3D=3D VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOL= E && + dev->data.chr->targetType =3D=3D VIR_DOMAIN_CHR_CONSOLE_TARGET_TYP= E_NONE) + dev->data.chr->targetType =3D VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_O= PENVZ; + + /* forbid capabilities mode hostdev in this kind of hypervisor */ + if (dev->type =3D=3D VIR_DOMAIN_DEVICE_HOSTDEV && + dev->data.hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIE= S) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("hostdev mode 'capabilities' is not " + "supported in %s"), + virDomainVirtTypeToString(def->virtType)); + return -1; + } + + return 0; +} + + +virDomainDefParserConfig openvzDomainDefParserConfig =3D { + .domainPostParseCallback =3D openvzDomainDefPostParse, + .devicesPostParseCallback =3D openvzDomainDeviceDefPostParse, + .features =3D VIR_DOMAIN_DEF_FEATURE_NAME_SLASH, +}; + +virDomainXMLOptionPtr openvzXMLOption(void) +{ + return virDomainXMLOptionNew(&openvzDomainDefParserConfig, + NULL, NULL, NULL, NULL); +} diff --git a/src/openvz/openvz_conf.h b/src/openvz/openvz_conf.h index cd42d697ce..6463c1704a 100644 --- a/src/openvz/openvz_conf.h +++ b/src/openvz/openvz_conf.h @@ -63,3 +63,4 @@ int strtoI(const char *str); int openvzSetDefinedUUID(int vpsid, unsigned char *uuid); int openvzGetVEID(const char *name); int openvzReadNetworkConf(virDomainDefPtr def, int veid); +virDomainXMLOptionPtr openvzXMLOption(void); diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index e07b3b302d..e479ebf58d 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -110,55 +110,6 @@ openvzDomObjFromDomain(struct openvz_driver *driver, } =20 =20 -static int -openvzDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps G_GNUC_UNUSED, - unsigned int parseFlags G_GNUC_UNUSED, - void *opaque G_GNUC_UNUSED, - void *parseOpaque G_GNUC_UNUSED) -{ - /* fill the init path */ - if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_EXE && !def->os.init) - def->os.init =3D g_strdup("/sbin/init"); - - return 0; -} - - -static int -openvzDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, - const virDomainDef *def G_GNUC_UNUSED, - virCapsPtr caps G_GNUC_UNUSED, - unsigned int parseFlags G_GNUC_UNUSED, - void *opaque G_GNUC_UNUSED, - void *parseOpaque G_GNUC_UNUSED) -{ - if (dev->type =3D=3D VIR_DOMAIN_DEVICE_CHR && - dev->data.chr->deviceType =3D=3D VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOL= E && - dev->data.chr->targetType =3D=3D VIR_DOMAIN_CHR_CONSOLE_TARGET_TYP= E_NONE) - dev->data.chr->targetType =3D VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_O= PENVZ; - - /* forbid capabilities mode hostdev in this kind of hypervisor */ - if (dev->type =3D=3D VIR_DOMAIN_DEVICE_HOSTDEV && - dev->data.hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIE= S) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("hostdev mode 'capabilities' is not " - "supported in %s"), - virDomainVirtTypeToString(def->virtType)); - return -1; - } - - return 0; -} - - -virDomainDefParserConfig openvzDomainDefParserConfig =3D { - .domainPostParseCallback =3D openvzDomainDefPostParse, - .devicesPostParseCallback =3D openvzDomainDeviceDefPostParse, - .features =3D VIR_DOMAIN_DEF_FEATURE_NAME_SLASH, -}; - - /* generate arguments to create OpenVZ container return -1 - error 0 - OK @@ -522,7 +473,7 @@ static char *openvzDomainGetXMLDesc(virDomainPtr dom, u= nsigned int flags) { if (!(vm =3D openvzDomObjFromDomain(driver, dom->uuid))) return NULL; =20 - ret =3D virDomainDefFormat(vm->def, driver->caps, + ret =3D virDomainDefFormat(vm->def, driver->xmlopt, driver->caps, virDomainDefFormatConvertXMLFlags(flags)); =20 virDomainObjEndAPI(&vm); @@ -1360,8 +1311,7 @@ static virDrvOpenStatus openvzConnectOpen(virConnectP= tr conn, if (!(driver->caps =3D openvzCapsInit())) goto cleanup; =20 - if (!(driver->xmlopt =3D virDomainXMLOptionNew(&openvzDomainDefParserC= onfig, - NULL, NULL, NULL, NULL))) + if (!(driver->xmlopt =3D openvzXMLOption())) goto cleanup; =20 if (openvzLoadDomains(driver) < 0) @@ -2117,7 +2067,7 @@ openvzDomainMigrateBegin3Params(virDomainPtr domain, goto cleanup; } =20 - xml =3D virDomainDefFormat(vm->def, driver->caps, + xml =3D virDomainDefFormat(vm->def, driver->xmlopt, driver->caps, VIR_DOMAIN_DEF_FORMAT_SECURE); =20 cleanup: diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index bdfe78e035..5e00ef6448 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -3247,7 +3247,7 @@ phypDomainGetXMLDesc(virDomainPtr dom, unsigned int f= lags) if (virDomainDefSetVcpus(&def, vcpus) < 0) goto err; =20 - return virDomainDefFormat(&def, phyp_driver->caps, + return virDomainDefFormat(&def, phyp_driver->xmlopt, phyp_driver->caps, virDomainDefFormatConvertXMLFlags(flags)); =20 err: diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index ad08e29bb3..91d5e796bb 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9198,9 +9198,8 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr drive= r, } =20 format: - ret =3D virDomainDefFormatInternal(def, caps, - virDomainDefFormatConvertXMLFlags(fla= gs), - buf, driver->xmlopt); + ret =3D virDomainDefFormatInternal(def, driver->xmlopt, caps, buf, + virDomainDefFormatConvertXMLFlags(fla= gs)); =20 cleanup: virDomainDefFree(copy); diff --git a/src/security/security_apparmor.c b/src/security/security_appar= mor.c index 21560b2330..6da79203d7 100644 --- a/src/security/security_apparmor.c +++ b/src/security/security_apparmor.c @@ -168,7 +168,7 @@ load_profile(virSecurityManagerPtr mgr G_GNUC_UNUSED, char *xml =3D NULL; virCommandPtr cmd =3D NULL; =20 - xml =3D virDomainDefFormat(def, NULL, VIR_DOMAIN_DEF_FORMAT_SECURE); + xml =3D virDomainDefFormat(def, NULL, NULL, VIR_DOMAIN_DEF_FORMAT_SECU= RE); if (!xml) goto cleanup; =20 diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 5883722d60..e7ec537bb0 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2177,7 +2177,8 @@ testDomainSaveImageWrite(testDriverPtr driver, int fd =3D -1; g_autofree char *xml =3D NULL; =20 - xml =3D virDomainDefFormat(def, driver->caps, VIR_DOMAIN_DEF_FORMAT_SE= CURE); + xml =3D virDomainDefFormat(def, driver->xmlopt, driver->caps, + VIR_DOMAIN_DEF_FORMAT_SECURE); =20 if (xml =3D=3D NULL) { virReportSystemError(errno, @@ -2466,7 +2467,8 @@ testDomainSaveImageGetXMLDesc(virConnectPtr conn, if ((fd =3D testDomainSaveImageOpen(privconn, path, &def)) < 0) goto cleanup; =20 - ret =3D virDomainDefFormat(def, privconn->caps, VIR_DOMAIN_DEF_FORMAT_= SECURE); + ret =3D virDomainDefFormat(def, privconn->xmlopt, privconn->caps, + VIR_DOMAIN_DEF_FORMAT_SECURE); =20 cleanup: virDomainDefFree(def); @@ -3177,7 +3179,7 @@ static char *testDomainGetXMLDesc(virDomainPtr domain= , unsigned int flags) def =3D (flags & VIR_DOMAIN_XML_INACTIVE) && privdom->newDef ? privdom->newDef : privdom->def; =20 - ret =3D virDomainDefFormat(def, privconn->caps, + ret =3D virDomainDefFormat(def, privconn->xmlopt, privconn->caps, virDomainDefFormatConvertXMLFlags(flags)); =20 virDomainObjEndAPI(&privdom); diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index de98dc5c84..0d22c94e06 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -4126,7 +4126,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, u= nsigned int flags) /* dump USB devices/filters if active */ vboxHostDeviceGetXMLDesc(data, def, machine); =20 - ret =3D virDomainDefFormat(def, data->caps, + ret =3D virDomainDefFormat(def, data->xmlopt, data->caps, virDomainDefFormatConvertXMLFlags(flags)); =20 cleanup: diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index 83974531d5..c0071fc18c 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -935,7 +935,7 @@ vmwareDomainGetXMLDesc(virDomainPtr dom, unsigned int f= lags) if (!(vm =3D vmwareDomObjFromDomain(driver, dom->uuid))) return NULL; =20 - ret =3D virDomainDefFormat(vm->def, driver->caps, + ret =3D virDomainDefFormat(vm->def, driver->xmlopt, driver->caps, virDomainDefFormatConvertXMLFlags(flags)); =20 virDomainObjEndAPI(&vm); @@ -968,7 +968,7 @@ vmwareConnectDomainXMLFromNative(virConnectPtr conn, co= nst char *nativeFormat, def =3D virVMXParseConfig(&ctx, driver->xmlopt, driver->caps, nativeCo= nfig); =20 if (def !=3D NULL) - xml =3D virDomainDefFormat(def, driver->caps, + xml =3D virDomainDefFormat(def, driver->xmlopt, driver->caps, VIR_DOMAIN_DEF_FORMAT_INACTIVE); =20 virDomainDefFree(def); diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 6b925653d5..1166b77b2c 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -728,7 +728,7 @@ vzDomainGetXMLDesc(virDomainPtr domain, unsigned int fl= ags) def =3D (flags & VIR_DOMAIN_XML_INACTIVE) && dom->newDef ? dom->newDef : dom->def; =20 - ret =3D virDomainDefFormat(def, privconn->driver->caps, flags); + ret =3D virDomainDefFormat(def, driver->xmlopt, privconn->driver->caps= , flags); =20 cleanup: virDomainObjEndAPI(&dom); @@ -2872,7 +2872,7 @@ vzDomainMigrateBeginStep(virDomainObjPtr dom, | VZ_MIGRATION_COOKIE_DOMAIN_NAME) < 0) return NULL; =20 - return virDomainDefFormat(dom->def, driver->caps, + return virDomainDefFormat(dom->def, driver->xmlopt, driver->caps, VIR_DOMAIN_XML_MIGRATABLE); } =20 diff --git a/tests/Makefile.am b/tests/Makefile.am index cbe8e86224..465c176ffd 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -747,7 +747,8 @@ if WITH_OPENVZ openvzutilstest_SOURCES =3D \ openvzutilstest.c \ testutils.c testutils.h -openvzutilstest_LDADD =3D $(LDADDS) +openvzutilstest_LDADD =3D $(LDADDS) \ + ../src/libvirt_driver_openvz.la else ! WITH_OPENVZ EXTRA_DIST +=3D openvzutilstest.c endif ! WITH_OPENVZ diff --git a/tests/lxcconf2xmltest.c b/tests/lxcconf2xmltest.c index c52c6e7fd7..7adc23be9f 100644 --- a/tests/lxcconf2xmltest.c +++ b/tests/lxcconf2xmltest.c @@ -42,7 +42,7 @@ testCompareXMLToConfigFiles(const char *xmlfile, if (testSanitizeDef(vmdef) < 0) goto fail; =20 - if (!(actualxml =3D virDomainDefFormat(vmdef, caps, 0))) + if (!(actualxml =3D virDomainDefFormat(vmdef, xmlopt, caps, 0))) goto fail; =20 if (virTestCompareToFile(actualxml, xmlfile) < 0) diff --git a/tests/openvzutilstest.c b/tests/openvzutilstest.c index 83969197c6..f43867ddc9 100644 --- a/tests/openvzutilstest.c +++ b/tests/openvzutilstest.c @@ -98,6 +98,7 @@ testReadNetworkConf(const void *data G_GNUC_UNUSED) " \n" " \n" "\n"; + virDomainXMLOptionPtr xmlopt =3D openvzXMLOption(); =20 if (!(def =3D virDomainDefNew())) goto cleanup; @@ -112,7 +113,7 @@ testReadNetworkConf(const void *data G_GNUC_UNUSED) goto cleanup; } =20 - actual =3D virDomainDefFormat(def, NULL, VIR_DOMAIN_DEF_FORMAT_INACTIV= E); + actual =3D virDomainDefFormat(def, xmlopt, NULL, VIR_DOMAIN_DEF_FORMAT= _INACTIVE); =20 if (actual =3D=3D NULL) { fprintf(stderr, "ERROR: %s\n", virGetLastErrorMessage()); @@ -127,6 +128,7 @@ testReadNetworkConf(const void *data G_GNUC_UNUSED) result =3D 0; =20 cleanup: + virObjectUnref(xmlopt); VIR_FREE(actual); virDomainDefFree(def); =20 diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index 7278a6a6ba..9fbc1e1a64 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -200,7 +200,7 @@ testQemuHotplugCheckResult(virDomainObjPtr vm, char *actual; int ret; =20 - actual =3D virDomainDefFormat(vm->def, driver.caps, + actual =3D virDomainDefFormat(vm->def, driver.xmlopt, driver.caps, VIR_DOMAIN_DEF_FORMAT_SECURE); if (!actual) return -1; @@ -466,7 +466,7 @@ testQemuHotplugCpuFinalize(struct testQemuHotplugCpuDat= a *data) char *configXML =3D NULL; =20 if (data->file_xml_res_live) { - if (!(activeXML =3D virDomainDefFormat(data->vm->def, driver.caps, + if (!(activeXML =3D virDomainDefFormat(data->vm->def, driver.xmlop= t, driver.caps, VIR_DOMAIN_DEF_FORMAT_SECURE)= )) goto cleanup; =20 @@ -475,7 +475,7 @@ testQemuHotplugCpuFinalize(struct testQemuHotplugCpuDat= a *data) } =20 if (data->file_xml_res_conf) { - if (!(configXML =3D virDomainDefFormat(data->vm->newDef, driver.ca= ps, + if (!(configXML =3D virDomainDefFormat(data->vm->newDef, driver.xm= lopt, driver.caps, VIR_DOMAIN_DEF_FORMAT_SECURE | VIR_DOMAIN_DEF_FORMAT_INACTIV= E))) goto cleanup; diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 8b43f35f06..a8f7dd4e1b 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -68,7 +68,7 @@ testCompareStatusXMLToXMLFiles(const void *opaque) goto cleanup; } =20 - if (!(actual =3D virDomainObjFormat(driver.xmlopt, obj, NULL, + if (!(actual =3D virDomainObjFormat(obj, driver.xmlopt, NULL, VIR_DOMAIN_DEF_FORMAT_SECURE | VIR_DOMAIN_DEF_FORMAT_STATUS | VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET | diff --git a/tests/testutils.c b/tests/testutils.c index 387ba55908..ffcb56ca86 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -1140,7 +1140,7 @@ testCompareDomXML2XMLFiles(virCapsPtr caps, virDomain= XMLOptionPtr xmlopt, goto out; } =20 - if (!(actual =3D virDomainDefFormat(def, caps, format_flags))) { + if (!(actual =3D virDomainDefFormat(def, xmlopt, caps, format_flags)))= { result =3D TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_FORMAT; goto out; } diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index ad7b3360c3..72ee2a38c8 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -84,7 +84,7 @@ testCompareFiles(const char *vmx, const char *xml) goto cleanup; } =20 - if (!(formatted =3D virDomainDefFormat(def, caps, + if (!(formatted =3D virDomainDefFormat(def, xmlopt, caps, VIR_DOMAIN_DEF_FORMAT_SECURE))) goto cleanup; =20 diff --git a/tests/xlconfigtest.c b/tests/xlconfigtest.c index 5a094e3b0e..890d8bf2b4 100644 --- a/tests/xlconfigtest.c +++ b/tests/xlconfigtest.c @@ -146,7 +146,8 @@ testCompareFormatXML(const char *xlcfg, const char *xml= , bool replaceVars) if (!(def =3D xenParseXL(conf, caps, xmlopt))) goto fail; =20 - if (!(gotxml =3D virDomainDefFormat(def, caps, VIR_DOMAIN_XML_INACTIVE= | + if (!(gotxml =3D virDomainDefFormat(def, xmlopt, caps, + VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_SECURE))) goto fail; =20 diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c index 82f4908a63..4a4d4192db 100644 --- a/tests/xmconfigtest.c +++ b/tests/xmconfigtest.c @@ -100,7 +100,7 @@ testCompareFormatXML(const char *xmcfg, const char *xml) if (!(def =3D xenParseXM(conf, caps, xmlopt))) goto fail; =20 - if (!(gotxml =3D virDomainDefFormat(def, caps, VIR_DOMAIN_DEF_FORMAT_S= ECURE))) + if (!(gotxml =3D virDomainDefFormat(def, xmlopt, caps, VIR_DOMAIN_DEF_= FORMAT_SECURE))) goto fail; =20 if (virTestCompareToFile(gotxml, xml) < 0) --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 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=1575469445; cv=none; d=zohomail.com; s=zohoarc; b=O9k/PtBPZoYac9hIU+WyWFzlnKckV6S24mywAAw+brDpl4K4OqeVarkrgV0XE7yptzof2QLEugWgryjfFwkLWL5VPdTB1RTr/fqybPjf03u6B8goKOn/iH/Af4kmqwSSABmXjsu6nG25gGwdaDv+BKnfKtR9TspT/AfJ5hrEqnQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469445; 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=oJBRaTjcZOSA8FasxjrlLjDwhGFaXqDcP4ZWSx4Sxgo=; b=PRp9YdIV/GVSg7GJe7pbQuyMlCMw/knutnyIEAH1O+91jIZjk/E5NZ9oxoHJ2x9aGow2tENyN/FgxCCErp97jhrTS+XonC8aZV/KShfvQm6gbCdlshv6/U928hqgr3/Jy8xW4Vy9ZaVVXsRA/JFhK5oqdfwTaxQ3J/Ec3ThCa/s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 157546944583894.77812093066223; Wed, 4 Dec 2019 06:24:05 -0800 (PST) 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-322-AHwdpnB_MaavrkA2eW0tBA-1; Wed, 04 Dec 2019 09:21:44 -0500 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 DD80D8D0933; Wed, 4 Dec 2019 14:21:34 +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 AE0405D6BE; Wed, 4 Dec 2019 14:21:34 +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 5C15A18089D5; Wed, 4 Dec 2019 14:21:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4ELPN9008105 for ; Wed, 4 Dec 2019 09:21:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8E79767E62; Wed, 4 Dec 2019 14:21:25 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id A02281D1; Wed, 4 Dec 2019 14:21:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469444; 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=oJBRaTjcZOSA8FasxjrlLjDwhGFaXqDcP4ZWSx4Sxgo=; b=DTS9olhE5ApetmrjPAOpyfLGZkzQYzg/cV9H3RZ5Ldi2bH6c8lOf/oe4mtWNaP3wUiBl/b +VmGEqPbFfWxRNWnl7SlZ9CenqkgWR8d9U7KH250pEjgoZAz8Ec9pk3aQQHSNbbjvHBXr9 bDk3Wyaz3Cas47UG2nn28pG123HAkCg= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:20:48 +0000 Message-Id: <20191204142113.2961028-6-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 05/30] conf: pass in default architecture via domain XML options 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-MC-Unique: AHwdpnB_MaavrkA2eW0tBA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) When parsing the guest XML we must fill in the default guest arch if it is not already present because later parts of the parsing process need this information. If no arch is specified we lookup the first guest in the capabilities data matching the os type and virt type. In most cases this will result in picking the host architecture but there are some exceptions... - The test driver is hardcoded to always use i686 arch - The VMWare/ESX drivers will always place i686 guests ahead of x86_64 guests in capabilities, so effectively they always use i686 - The QEMU driver can potentially return any arch at all depending on what combination of QEMU binaries are installed. The domain XML hardware configurations are inherently architecture specific in many places. As a result whomever/whatever created the domain XML will have had a particular architecture in mind when specifying the config. In pretty much any sensible case this arch will have been the native host architecture. i686 on x86_64 is the only sensible divergance because both these archs are compatible from a domaain XML config POV. IOW, although the QEMU driver can pick an almost arbitrary arch as its default, in the real world no application or user is likely to be relying on this default arch being anything other than native. With all this in mind, it is reasonable to change the XML parser to allow the default architecture to be passed via the domain XML options struct. If no info is explicitly given then it is safe & sane to pick the host native architecture as the default for the guest. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- docs/formatdomain.html.in | 6 +++++- src/conf/domain_conf.c | 12 +++++++++--- src/conf/domain_conf.h | 1 + src/test/test_driver.c | 1 + src/vmware/vmware_driver.c | 1 + src/vmx/vmx.c | 1 + 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 6df4a8b26e..d7092761c5 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -175,7 +175,11 @@ and machine refe= rring to the machine type. The Capabilities = XML provides details on allowed values for - these. Since 0.0.1 + these. If arch is omitted then for most hypervisor + drivers, the host native arch will be chosen. For the test, + ESX and VMWare hypervisor drivers, howev= er, + the i686 arch will always be chosen even on an + x86_64 host. Since 0.0.1=
loader
The optional loader tag refers to a firmware blob, which is specified by absolute path, diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 781bf9d2d4..1c2b8f26ed 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -19565,6 +19565,7 @@ virDomainCachetuneDefParse(virDomainDefPtr def, static int virDomainDefParseCaps(virDomainDefPtr def, xmlXPathContextPtr ctxt, + virDomainXMLOptionPtr xmlopt, virCapsPtr caps, unsigned int flags) { @@ -19625,6 +19626,13 @@ virDomainDefParseCaps(virDomainDefPtr def, return -1; } =20 + if (def->os.arch =3D=3D VIR_ARCH_NONE) { + if (xmlopt && xmlopt->config.defArch !=3D VIR_ARCH_NONE) + def->os.arch =3D xmlopt->config.defArch; + else + def->os.arch =3D virArchFromHost(); + } + if (!(capsdata =3D virCapabilitiesDomainDataLookup(caps, def->os.type, def->os.arch, def->virtType, @@ -19633,8 +19641,6 @@ virDomainDefParseCaps(virDomainDefPtr def, return -1; virResetLastError(); } else { - if (!def->os.arch) - def->os.arch =3D capsdata->arch; if (!def->os.machine) def->os.machine =3D g_strdup(capsdata->machinetype); } @@ -19792,7 +19798,7 @@ virDomainDefParseXML(xmlDocPtr xml, id =3D -1; def->id =3D (int)id; =20 - if (virDomainDefParseCaps(def, ctxt, caps, flags) < 0) + if (virDomainDefParseCaps(def, ctxt, xmlopt, caps, flags) < 0) goto error; =20 /* Extract domain name */ diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index f7a611d5ef..e1622f2112 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2705,6 +2705,7 @@ struct _virDomainDefParserConfig { /* data */ unsigned int features; /* virDomainDefFeatures */ unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN]; + virArch defArch; }; =20 typedef void *(*virDomainXMLPrivateDataAllocFunc)(void *); diff --git a/src/test/test_driver.c b/src/test/test_driver.c index e7ec537bb0..f2700d90bc 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -424,6 +424,7 @@ testDriverNew(void) VIR_DOMAIN_DEF_FEATURE_USER_ALIAS | VIR_DOMAIN_DEF_FEATURE_FW_AUTOSELECT | VIR_DOMAIN_DEF_FEATURE_NET_MODEL_STRING, + .defArch =3D VIR_ARCH_I686, }; virDomainXMLPrivateDataCallbacks privatecb =3D { .alloc =3D testDomainObjPrivateAlloc, diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index c0071fc18c..bab4fdb82b 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -139,6 +139,7 @@ vmwareDomainDeviceDefPostParse(virDomainDeviceDefPtr de= v G_GNUC_UNUSED, virDomainDefParserConfig vmwareDomainDefParserConfig =3D { .devicesPostParseCallback =3D vmwareDomainDeviceDefPostParse, .domainPostParseCallback =3D vmwareDomainDefPostParse, + .defArch =3D VIR_ARCH_I686, }; =20 static virDomainXMLOptionPtr diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 0ccc4eefe6..c4af7b1ce9 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -556,6 +556,7 @@ static virDomainDefParserConfig virVMXDomainDefParserCo= nfig =3D { .features =3D (VIR_DOMAIN_DEF_FEATURE_WIDE_SCSI | VIR_DOMAIN_DEF_FEATURE_NAME_SLASH | VIR_DOMAIN_DEF_FEATURE_NO_BOOT_ORDER), + .defArch =3D VIR_ARCH_I686, }; =20 struct virVMXDomainDefNamespaceData { --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.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 207.211.31.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=1575469300; cv=none; d=zohomail.com; s=zohoarc; b=Xg3lkIPk2xeGfwgMi0oElVAxp2JRQ0V4sfCvUOnkfvHKXcm4nOvD3BqKMZs6vscqHw8h6k0P9WwNaOaC+pl30F2ltt3S/KikbRLUnZB7fqCiSYZuicC42Y/uM1ycvIm5RPRie34SeUUKQtQignql2ElZf4gqFsU2QRCmhpAl0Ro= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469300; 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=DWZwkazvLxT1K6qvZwj7NFj/UY0HHygGYGQfqtugvDE=; b=gkorywhyPb30Kd0bauOm5oRNb2e/2vEAmfxd4Jl/uG8ww9p1MAkY9lgi2/mhByws72i4BmeqzLOynuinBwh/+RJFI2abEhX4yjp7Wt0OlhQRTwcXP5UMGITyODLy21x/sHfWlDQVG7zR++lsBdm/tjfZOtwhCOSwdLUt1PoHC4E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.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 [207.211.31.120]) by mx.zohomail.com with SMTPS id 1575469300113702.0758953935322; Wed, 4 Dec 2019 06:21:40 -0800 (PST) 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-159-CT7AxKJnMb6UdEKjCpmuKw-1; Wed, 04 Dec 2019 09:21:35 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0C071DBAC; Wed, 4 Dec 2019 14:21:29 +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 B0EB3100194E; Wed, 4 Dec 2019 14:21:28 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 69B2F18089CF; Wed, 4 Dec 2019 14:21:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4ELQmt008116 for ; Wed, 4 Dec 2019 09:21:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id A61E8608F7; Wed, 4 Dec 2019 14:21:26 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF1291D1; Wed, 4 Dec 2019 14:21:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469297; 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=DWZwkazvLxT1K6qvZwj7NFj/UY0HHygGYGQfqtugvDE=; b=OqaLMDTJs4Hpz0nfwufOYm/nrqN8UAVE/s6wlKAg7Ly86Zqog14szLvEpg/pp3P2eX1gYZ rB28sIlaap98eOsfSRNaT0WE5j3JhxndsB3lkqDIBbsME5AA+khW3Ini7luuE+GDazjj8l VEqc5S1jeOf9btv+Hu832blNTzfRltQ= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:20:49 +0000 Message-Id: <20191204142113.2961028-7-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 06/30] conf: move virt type / os type / arch validation to post-parse 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.84 on 10.5.11.22 X-MC-Unique: CT7AxKJnMb6UdEKjCpmuKw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The XML parser currently calls virCapabilitiesDomainDataLookup during parsing to find the domain capabilities matching the triple (virt type, os type, arch) This is, however, bogus with the QEMU driver as it assumes that there is an emulator known to the default driver capabilities that matches this triple. It is entirely possible for the driver to be parsing an XML file with a custom emulator path specified pointing to a binary that doesn't exist in the default driver capabilities. This will, for example be the case on a RHEL host which only installs the host native emulator to /usr/bin. The user can have built a custom QEMU for non-native arches into $HOME and wish to use that. Aside from validation, this call is also used to fill in a machine type for the guest if not otherwise specified. Again, this data may be incorrect for the QEMU driver because it is not taking account of the emulator binary that is referenced. To start fixing this, move the validation to the post-parse callbacks where more intelligent driver specific logic can be applied. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/bhyve/bhyve_domain.c | 7 ++++++- src/conf/capabilities.c | 17 +++++++++++++++++ src/conf/capabilities.h | 7 +++++++ src/conf/domain_conf.c | 19 ++----------------- src/libvirt_private.syms | 1 + src/libxl/libxl_domain.c | 7 ++++++- src/lxc/lxc_domain.c | 5 +++++ src/openvz/openvz_conf.c | 7 ++++++- src/phyp/phyp_driver.c | 9 +++++++-- src/qemu/qemu_domain.c | 19 +++++++++++++++---- src/vmware/vmware_driver.c | 9 +++++++-- src/vmx/vmx.c | 9 +++++++-- src/vz/vz_driver.c | 7 ++++++- 13 files changed, 92 insertions(+), 31 deletions(-) diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c index 7d24bb602f..575f141b53 100644 --- a/src/bhyve/bhyve_domain.c +++ b/src/bhyve/bhyve_domain.c @@ -74,11 +74,16 @@ bhyveDomainDefNeedsISAController(virDomainDefPtr def) =20 static int bhyveDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps G_GNUC_UNUSED, + virCapsPtr caps, unsigned int parseFlags G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED, void *parseOpaque G_GNUC_UNUSED) { + if (!virCapabilitiesDomainSupported(caps, def->os.type, + def->os.arch, + def->virtType)) + return -1; + /* Add an implicit PCI root controller */ if (virDomainDefMaybeAddController(def, VIR_DOMAIN_CONTROLLER_TYPE_PCI= , 0, VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROO= T) < 0) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index ff7d265621..748dd64273 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -816,6 +816,23 @@ virCapabilitiesDomainDataLookup(virCapsPtr caps, } =20 =20 +bool +virCapabilitiesDomainSupported(virCapsPtr caps, + int ostype, + virArch arch, + int virttype) +{ + g_autofree virCapsDomainDataPtr capsdata =3D NULL; + + capsdata =3D virCapabilitiesDomainDataLookup(caps, ostype, + arch, + virttype, + NULL, NULL); + + return capsdata !=3D NULL; +} + + int virCapabilitiesAddStoragePool(virCapsPtr caps, int poolType) diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index 8a7137d7eb..c39fe0de08 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -309,6 +309,13 @@ virCapabilitiesDomainDataLookup(virCapsPtr caps, const char *emulator, const char *machinetype); =20 +bool +virCapabilitiesDomainSupported(virCapsPtr caps, + int ostype, + virArch arch, + int domaintype); + + void virCapabilitiesClearHostNUMACellCPUTopology(virCapsHostNUMACellCPUPtr cpu, size_t ncpus); diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1c2b8f26ed..6abe15f721 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -19565,14 +19565,11 @@ virDomainCachetuneDefParse(virDomainDefPtr def, static int virDomainDefParseCaps(virDomainDefPtr def, xmlXPathContextPtr ctxt, - virDomainXMLOptionPtr xmlopt, - virCapsPtr caps, - unsigned int flags) + virDomainXMLOptionPtr xmlopt) { g_autofree char *virttype =3D NULL; g_autofree char *arch =3D NULL; g_autofree char *ostype =3D NULL; - g_autofree virCapsDomainDataPtr capsdata =3D NULL; =20 virttype =3D virXPathString("string(./@type)", ctxt); ostype =3D virXPathString("string(./os/type[1])", ctxt); @@ -19633,18 +19630,6 @@ virDomainDefParseCaps(virDomainDefPtr def, def->os.arch =3D virArchFromHost(); } =20 - if (!(capsdata =3D virCapabilitiesDomainDataLookup(caps, def->os.type, - def->os.arch, - def->virtType, - NULL, NULL))) { - if (!(flags & VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE)) - return -1; - virResetLastError(); - } else { - if (!def->os.machine) - def->os.machine =3D g_strdup(capsdata->machinetype); - } - return 0; } =20 @@ -19798,7 +19783,7 @@ virDomainDefParseXML(xmlDocPtr xml, id =3D -1; def->id =3D (int)id; =20 - if (virDomainDefParseCaps(def, ctxt, xmlopt, caps, flags) < 0) + if (virDomainDefParseCaps(def, ctxt, xmlopt) < 0) goto error; =20 /* Extract domain name */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 7bacf02f0c..74ca8585ee 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -54,6 +54,7 @@ virCapabilitiesAddStoragePool; virCapabilitiesAllocMachines; virCapabilitiesClearHostNUMACellCPUTopology; virCapabilitiesDomainDataLookup; +virCapabilitiesDomainSupported; virCapabilitiesFormatXML; virCapabilitiesFreeGuest; virCapabilitiesFreeMachines; diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 19905442c1..ad9424155a 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -367,11 +367,16 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr d= ev, =20 static int libxlDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps G_GNUC_UNUSED, + virCapsPtr caps, unsigned int parseFlags G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED, void *parseOpaque G_GNUC_UNUSED) { + if (!virCapabilitiesDomainSupported(caps, def->os.type, + def->os.arch, + def->virtType)) + return -1; + /* Xen PV domains always have a PV console, so add one to the domain c= onfig * via post-parse callback if not explicitly specified in the XML. */ if (def->os.type !=3D VIR_DOMAIN_OSTYPE_HVM && def->nconsoles =3D=3D 0= ) { diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c index 4339d305a9..b505a91c1c 100644 --- a/src/lxc/lxc_domain.c +++ b/src/lxc/lxc_domain.c @@ -356,6 +356,11 @@ virLXCDomainDefPostParse(virDomainDefPtr def, void *opaque G_GNUC_UNUSED, void *parseOpaque G_GNUC_UNUSED) { + if (!virCapabilitiesDomainSupported(caps, def->os.type, + def->os.arch, + def->virtType)) + return -1; + /* check for emulator and create a default one if needed */ if (!def->emulator && !(def->emulator =3D virDomainDefGetDefaultEmulator(def, caps))) diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 8a05aa0504..de8be1ed7d 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -1082,11 +1082,16 @@ int openvzGetVEID(const char *name) =20 static int openvzDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps G_GNUC_UNUSED, + virCapsPtr caps, unsigned int parseFlags G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED, void *parseOpaque G_GNUC_UNUSED) { + if (!virCapabilitiesDomainSupported(caps, def->os.type, + def->os.arch, + def->virtType)) + return -1; + /* fill the init path */ if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_EXE && !def->os.init) def->os.init =3D g_strdup("/sbin/init"); diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 5e00ef6448..218d6f5b5c 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -1061,12 +1061,17 @@ openSSHSession(virConnectPtr conn, virConnectAuthPt= r auth, =20 =20 static int -phypDomainDefPostParse(virDomainDefPtr def G_GNUC_UNUSED, - virCapsPtr caps G_GNUC_UNUSED, +phypDomainDefPostParse(virDomainDefPtr def, + virCapsPtr caps, unsigned int parseFlags G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED, void *parseOpaque G_GNUC_UNUSED) { + if (!virCapabilitiesDomainSupported(caps, def->os.type, + def->os.arch, + def->virtType)) + return -1; + return 0; } =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 91d5e796bb..b0e87a05c2 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4691,7 +4691,7 @@ qemuDomainDefPostParseBasic(virDomainDefPtr def, =20 static int qemuDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps G_GNUC_UNUSED, + virCapsPtr caps, unsigned int parseFlags, void *opaque, void *parseOpaque) @@ -4703,6 +4703,11 @@ qemuDomainDefPostParse(virDomainDefPtr def, * with the capabilities populated. */ virQEMUCapsPtr qemuCaps =3D parseOpaque; =20 + if (!virCapabilitiesDomainSupported(caps, def->os.type, + def->os.arch, + def->virtType)) + return -1; + if (def->os.bootloader || def->os.bootloaderArgs) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("bootloader is not supported by QEMU")); @@ -4710,9 +4715,15 @@ qemuDomainDefPostParse(virDomainDefPtr def, } =20 if (!def->os.machine) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing machine type")); - return -1; + g_autofree virCapsDomainDataPtr capsdata =3D NULL; + + if (!(capsdata =3D virCapabilitiesDomainDataLookup(caps, def->os.t= ype, + def->os.arch, + def->virtType, + NULL, NULL))) { + return -1; + } + def->os.machine =3D g_strdup(capsdata->machinetype); } =20 qemuDomainNVRAMPathGenerate(cfg, def); diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index bab4fdb82b..be0adb1e45 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -116,12 +116,17 @@ vmwareDataFreeFunc(void *data) } =20 static int -vmwareDomainDefPostParse(virDomainDefPtr def G_GNUC_UNUSED, - virCapsPtr caps G_GNUC_UNUSED, +vmwareDomainDefPostParse(virDomainDefPtr def, + virCapsPtr caps, unsigned int parseFlags G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED, void *parseOpaque G_GNUC_UNUSED) { + if (!virCapabilitiesDomainSupported(caps, def->os.type, + def->os.arch, + def->virtType)) + return -1; + return 0; } =20 diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index c4af7b1ce9..c2a06daecb 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -529,12 +529,17 @@ VIR_ENUM_IMPL(virVMXControllerModelSCSI, */ =20 static int -virVMXDomainDefPostParse(virDomainDefPtr def G_GNUC_UNUSED, - virCapsPtr caps G_GNUC_UNUSED, +virVMXDomainDefPostParse(virDomainDefPtr def, + virCapsPtr caps, unsigned int parseFlags G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED, void *parseOpaque G_GNUC_UNUSED) { + if (!virCapabilitiesDomainSupported(caps, def->os.type, + def->os.arch, + def->virtType)) + return -1; + return 0; } =20 diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 1166b77b2c..66b15737a2 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -241,11 +241,16 @@ vzDomainDefAddDefaultInputDevices(virDomainDefPtr def) =20 static int vzDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps G_GNUC_UNUSED, + virCapsPtr caps, unsigned int parseFlags G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED, void *parseOpaque G_GNUC_UNUSED) { + if (!virCapabilitiesDomainSupported(caps, def->os.type, + def->os.arch, + def->virtType)) + return -1; + if (vzDomainDefAddDefaultInputDevices(def) < 0) return -1; =20 --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 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=1575469506; cv=none; d=zohomail.com; s=zohoarc; b=nhqvuqoF6AWhETxv0KeMdXmtV6FG2mBbzRqNjQzB4xotznM8YcQrrtv41KZJlPPDrhTq/tGfXamSFUZl/e1w5ffZLQsj6UNwTnos9utZ9ggA5TvBJT+BJN/uzwX8Xa1NsPmxjh2FtGocoMGBcwnyw0TbQI5LECHvM+pKNo7n6NA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469506; 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=G7Oh3OQDad82g8jQWXKxpBRkE3qsRppaDIw1Cj7Equs=; b=Rwl5YtTPHmGMFsOEn0ndUiLgNRL0U9BOCWG2yezxwcjOpeEeBi3/soLMxVUNlVKo1NlvbQ7dK/5MusICQa9RHQpYDC+kAzdcKlJ6MKYqkl48zCxamb/bpLuOTx4ZwEid70gwlGYDxyccKVYKWWvA/o4AT2/SC4GFCd0C6N3ay6s= 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-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1575469506101475.40214922613427; Wed, 4 Dec 2019 06:25:06 -0800 (PST) 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-82-xj1ApKH4PwKhNDWaVeRo9g-1; Wed, 04 Dec 2019 09:21:42 -0500 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 CC4BA8D0930; Wed, 4 Dec 2019 14:21:34 +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 9D6525D6AE; Wed, 4 Dec 2019 14:21:34 +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 503395BC09; Wed, 4 Dec 2019 14:21:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4ELRgQ008127 for ; Wed, 4 Dec 2019 09:21:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id ABF371D1; Wed, 4 Dec 2019 14:21:27 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B90A608F7; Wed, 4 Dec 2019 14:21:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469502; 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=G7Oh3OQDad82g8jQWXKxpBRkE3qsRppaDIw1Cj7Equs=; b=JOiFJscn2U7rmghhDV9fv3ycZpRJN1hLpIFCYsUIzWtTn/tBsKfI+XsS4s2EFFfZYC1EFX oM1ejYTQWsIJvoS7pcqx2hJrbaeJ9z5+6koMiBymgfVnHNDXbGgHAXvqV2SxJyzvTP7bS7 rSoeQ5U/ZM3FuvZMtfLpERHpxJYFxqc= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:20:50 +0000 Message-Id: <20191204142113.2961028-8-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 07/30] conf: don't use passed in caps in post parse method 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-MC-Unique: xj1ApKH4PwKhNDWaVeRo9g-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) To enable the virCapsPtr parameter to the post parse method to be eliminated, the drivers must fetch the virCapsPtr from their own driver via the opaque parameter, or use an alternative approach to validate the parsed data. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/bhyve/bhyve_domain.c | 10 +++++-- src/esx/esx_driver.c | 2 +- src/libxl/libxl_conf.c | 3 ++- src/libxl/libxl_conf.h | 2 +- src/libxl/libxl_domain.c | 9 ++++--- src/libxl/libxl_driver.c | 2 +- src/lxc/lxc_conf.c | 3 ++- src/lxc/lxc_conf.h | 2 +- src/lxc/lxc_controller.c | 44 ++++++++++++++++++++++++------- src/lxc/lxc_domain.c | 8 ++++-- src/lxc/lxc_driver.c | 2 +- src/openvz/openvz_conf.c | 10 ++++--- src/openvz/openvz_conf.h | 2 +- src/openvz/openvz_driver.c | 2 +- src/phyp/phyp_driver.c | 8 +++--- src/qemu/qemu_capabilities.c | 38 +++++++++++++++++++++++++++ src/qemu/qemu_capabilities.h | 4 +++ src/qemu/qemu_domain.c | 48 +++++++++++++++++++++------------- src/vmware/vmware_driver.c | 11 ++++---- src/vmx/vmx.c | 8 +++--- src/vmx/vmx.h | 2 +- src/vz/vz_driver.c | 15 ++++++----- tests/Makefile.am | 14 +++++++--- tests/libxlxml2domconfigtest.c | 22 +++++----------- tests/lxcconf2xmltest.c | 17 ++++-------- tests/lxcxml2xmltest.c | 13 +++------ tests/openvzutilstest.c | 10 ++++--- tests/testutilslxc.c | 34 +++++++++++++++++++++++- tests/testutilslxc.h | 4 +++ tests/testutilsxen.c | 34 +++++++++++++++++++++++- tests/testutilsxen.h | 9 ++++--- tests/vmx2xmltest.c | 2 +- tests/xlconfigtest.c | 26 ++++++++---------- tests/xmconfigtest.c | 23 +++++++--------- tests/xml2vmxtest.c | 2 +- 35 files changed, 301 insertions(+), 144 deletions(-) diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c index 575f141b53..eebf5a7650 100644 --- a/src/bhyve/bhyve_domain.c +++ b/src/bhyve/bhyve_domain.c @@ -20,6 +20,7 @@ =20 #include =20 +#include "bhyve_driver.h" #include "bhyve_conf.h" #include "bhyve_device.h" #include "bhyve_domain.h" @@ -74,11 +75,16 @@ bhyveDomainDefNeedsISAController(virDomainDefPtr def) =20 static int bhyveDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps, + virCapsPtr _caps G_GNUC_UNUSED, unsigned int parseFlags G_GNUC_UNUSED, - void *opaque G_GNUC_UNUSED, + void *opaque, void *parseOpaque G_GNUC_UNUSED) { + bhyveConnPtr driver =3D opaque; + g_autoptr(virCaps) caps =3D bhyveDriverGetCapabilities(driver); + if (!caps) + return -1; + if (!virCapabilitiesDomainSupported(caps, def->os.type, def->os.arch, def->virtType)) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 81ff502769..2db89c7986 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -928,7 +928,7 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr au= th, if (!priv->caps) goto cleanup; =20 - if (!(priv->xmlopt =3D virVMXDomainXMLConfInit())) + if (!(priv->xmlopt =3D virVMXDomainXMLConfInit(priv->caps))) goto cleanup; =20 conn->privateData =3D priv; diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 37fe360067..132e04b147 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -2470,8 +2470,9 @@ libxlBuildDomainConfig(virPortAllocatorRangePtr graph= icsports, } =20 virDomainXMLOptionPtr -libxlCreateXMLConf(void) +libxlCreateXMLConf(libxlDriverPrivatePtr driver) { + libxlDomainDefParserConfig.priv =3D driver; return virDomainXMLOptionNew(&libxlDomainDefParserConfig, &libxlDomainXMLPrivateDataCallbacks, NULL, NULL, NULL); diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h index 305c8c41ef..4b5d240684 100644 --- a/src/libxl/libxl_conf.h +++ b/src/libxl/libxl_conf.h @@ -207,7 +207,7 @@ libxlMakeUSB(virDomainHostdevDefPtr hostdev, libxl_devi= ce_usbdev *usbdev); #endif =20 virDomainXMLOptionPtr -libxlCreateXMLConf(void); +libxlCreateXMLConf(libxlDriverPrivatePtr driver); =20 #ifdef LIBXL_HAVE_DEVICE_CHANNEL # define LIBXL_ATTR_UNUSED diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index ad9424155a..f202f0fc3e 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -367,12 +367,15 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr d= ev, =20 static int libxlDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags G_GNUC_UNUSED, - void *opaque G_GNUC_UNUSED, + void *opaque, void *parseOpaque G_GNUC_UNUSED) { - if (!virCapabilitiesDomainSupported(caps, def->os.type, + libxlDriverPrivatePtr driver =3D opaque; + g_autoptr(libxlDriverConfig) cfg =3D libxlDriverConfigGet(driver); + + if (!virCapabilitiesDomainSupported(cfg->caps, def->os.type, def->os.arch, def->virtType)) return -1; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index dc0d9b58f3..fac3c1db49 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -769,7 +769,7 @@ libxlStateInitialize(bool privileged, goto error; } =20 - if (!(libxl_driver->xmlopt =3D libxlCreateXMLConf())) + if (!(libxl_driver->xmlopt =3D libxlCreateXMLConf(libxl_driver))) goto error; =20 /* Add Domain-0 */ diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c index de9793e523..2e866973ce 100644 --- a/src/lxc/lxc_conf.c +++ b/src/lxc/lxc_conf.c @@ -207,8 +207,9 @@ virCapsPtr virLXCDriverGetCapabilities(virLXCDriverPtr = driver, =20 =20 virDomainXMLOptionPtr -lxcDomainXMLConfInit(void) +lxcDomainXMLConfInit(virLXCDriverPtr driver) { + virLXCDriverDomainDefParserConfig.priv =3D driver; return virDomainXMLOptionNew(&virLXCDriverDomainDefParserConfig, &virLXCDriverPrivateDataCallbacks, &virLXCDriverDomainXMLNamespace, diff --git a/src/lxc/lxc_conf.h b/src/lxc/lxc_conf.h index 12a201db38..59782d9cb2 100644 --- a/src/lxc/lxc_conf.h +++ b/src/lxc/lxc_conf.h @@ -112,7 +112,7 @@ int virLXCLoadDriverConfig(virLXCDriverConfigPtr cfg, virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver); virCapsPtr virLXCDriverGetCapabilities(virLXCDriverPtr driver, bool refresh); -virDomainXMLOptionPtr lxcDomainXMLConfInit(void); +virDomainXMLOptionPtr lxcDomainXMLConfInit(virLXCDriverPtr driver); =20 static inline void lxcDriverLock(virLXCDriverPtr driver) { diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 2b9d6481df..c869e2e7c4 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -159,11 +159,41 @@ static void virLXCControllerQuitTimer(int timer G_GNU= C_UNUSED, void *opaque) } =20 =20 +static virLXCDriverPtr +virLXCControllerDriverNew(void) +{ + virLXCDriverPtr driver =3D g_new0(virLXCDriver, 1); + + if (virMutexInit(&driver->lock) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("cannot initialize mutex")); + g_free(driver); + return NULL; + } + + driver->caps =3D virLXCDriverCapsInit(NULL); + driver->xmlopt =3D lxcDomainXMLConfInit(driver); + + return driver; +} + + +static void +virLXCControllerDriverFree(virLXCDriverPtr driver) +{ + if (!driver) + return; + virObjectUnref(driver->xmlopt); + virObjectUnref(driver->caps); + virMutexDestroy(&driver->lock); + g_free(driver); +} + + static virLXCControllerPtr virLXCControllerNew(const char *name) { virLXCControllerPtr ctrl =3D NULL; - virCapsPtr caps =3D NULL; - virDomainXMLOptionPtr xmlopt =3D NULL; + virLXCDriverPtr driver =3D NULL; char *configFile =3D NULL; =20 if (VIR_ALLOC(ctrl) < 0) @@ -174,10 +204,7 @@ static virLXCControllerPtr virLXCControllerNew(const c= har *name) =20 ctrl->name =3D g_strdup(name); =20 - if (!(caps =3D virLXCDriverCapsInit(NULL))) - goto error; - - if (!(xmlopt =3D lxcDomainXMLConfInit())) + if (!(driver =3D virLXCControllerDriverNew())) goto error; =20 if ((configFile =3D virDomainConfigFile(LXC_STATE_DIR, @@ -185,7 +212,7 @@ static virLXCControllerPtr virLXCControllerNew(const ch= ar *name) goto error; =20 if ((ctrl->vm =3D virDomainObjParseFile(configFile, - caps, xmlopt, + driver->caps, driver->xmlopt, 0)) =3D=3D NULL) goto error; ctrl->def =3D ctrl->vm->def; @@ -197,8 +224,7 @@ static virLXCControllerPtr virLXCControllerNew(const ch= ar *name) =20 cleanup: VIR_FREE(configFile); - virObjectUnref(caps); - virObjectUnref(xmlopt); + virLXCControllerDriverFree(driver); return ctrl; =20 error: diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c index b505a91c1c..bc54beeadf 100644 --- a/src/lxc/lxc_domain.c +++ b/src/lxc/lxc_domain.c @@ -351,11 +351,15 @@ virDomainXMLPrivateDataCallbacks virLXCDriverPrivateD= ataCallbacks =3D { =20 static int virLXCDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps, + virCapsPtr _caps G_GNUC_UNUSED, unsigned int parseFlags G_GNUC_UNUSED, - void *opaque G_GNUC_UNUSED, + void *opaque, void *parseOpaque G_GNUC_UNUSED) { + virLXCDriverPtr driver =3D opaque; + g_autoptr(virCaps) caps =3D virLXCDriverGetCapabilities(driver, false); + if (!caps) + return -1; if (!virCapabilitiesDomainSupported(caps, def->os.type, def->os.arch, def->virtType)) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 6c12543274..f28e20d756 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1584,7 +1584,7 @@ static int lxcStateInitialize(bool privileged, if (!(caps =3D virLXCDriverGetCapabilities(lxc_driver, true))) goto cleanup; =20 - if (!(lxc_driver->xmlopt =3D lxcDomainXMLConfInit())) + if (!(lxc_driver->xmlopt =3D lxcDomainXMLConfInit(lxc_driver))) goto cleanup; =20 if (!(lxc_driver->closeCallbacks =3D virCloseCallbacksNew())) diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index de8be1ed7d..5060e704a5 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -1082,12 +1082,13 @@ int openvzGetVEID(const char *name) =20 static int openvzDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags G_GNUC_UNUSED, - void *opaque G_GNUC_UNUSED, + void *opaque, void *parseOpaque G_GNUC_UNUSED) { - if (!virCapabilitiesDomainSupported(caps, def->os.type, + struct openvz_driver *driver =3D opaque; + if (!virCapabilitiesDomainSupported(driver->caps, def->os.type, def->os.arch, def->virtType)) return -1; @@ -1133,8 +1134,9 @@ virDomainDefParserConfig openvzDomainDefParserConfig = =3D { .features =3D VIR_DOMAIN_DEF_FEATURE_NAME_SLASH, }; =20 -virDomainXMLOptionPtr openvzXMLOption(void) +virDomainXMLOptionPtr openvzXMLOption(struct openvz_driver *driver) { + openvzDomainDefParserConfig.priv =3D driver; return virDomainXMLOptionNew(&openvzDomainDefParserConfig, NULL, NULL, NULL, NULL); } diff --git a/src/openvz/openvz_conf.h b/src/openvz/openvz_conf.h index 6463c1704a..9892f39481 100644 --- a/src/openvz/openvz_conf.h +++ b/src/openvz/openvz_conf.h @@ -63,4 +63,4 @@ int strtoI(const char *str); int openvzSetDefinedUUID(int vpsid, unsigned char *uuid); int openvzGetVEID(const char *name); int openvzReadNetworkConf(virDomainDefPtr def, int veid); -virDomainXMLOptionPtr openvzXMLOption(void); +virDomainXMLOptionPtr openvzXMLOption(struct openvz_driver *driver); diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index e479ebf58d..9b93bc5ca0 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -1311,7 +1311,7 @@ static virDrvOpenStatus openvzConnectOpen(virConnectP= tr conn, if (!(driver->caps =3D openvzCapsInit())) goto cleanup; =20 - if (!(driver->xmlopt =3D openvzXMLOption())) + if (!(driver->xmlopt =3D openvzXMLOption(driver))) goto cleanup; =20 if (openvzLoadDomains(driver) < 0) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 218d6f5b5c..05860b7dbe 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -1062,12 +1062,13 @@ openSSHSession(virConnectPtr conn, virConnectAuthPt= r auth, =20 static int phypDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags G_GNUC_UNUSED, - void *opaque G_GNUC_UNUSED, + void *opaque, void *parseOpaque G_GNUC_UNUSED) { - if (!virCapabilitiesDomainSupported(caps, def->os.type, + phyp_driverPtr driver =3D opaque; + if (!virCapabilitiesDomainSupported(driver->caps, def->os.type, def->os.arch, def->virtType)) return -1; @@ -1157,6 +1158,7 @@ phypConnectOpen(virConnectPtr conn, if ((phyp_driver->caps =3D phypCapsInit()) =3D=3D NULL) goto failure; =20 + virPhypDriverDomainDefParserConfig.priv =3D phyp_driver; if (!(phyp_driver->xmlopt =3D virDomainXMLOptionNew(&virPhypDriverDoma= inDefParserConfig, NULL, NULL, NULL, NU= LL))) goto failure; diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index c02ff5b941..7a62dfb1a2 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2094,6 +2094,44 @@ virQEMUCapsSetHostModel(virQEMUCapsPtr qemuCaps, } =20 =20 +bool +virQEMUCapsIsArchSupported(virQEMUCapsPtr qemuCaps, + virArch arch) +{ + if (arch =3D=3D qemuCaps->arch) + return true; + + if (qemuCaps->arch =3D=3D VIR_ARCH_X86_64 && arch =3D=3D VIR_ARCH_I686) + return true; + + if (qemuCaps->arch =3D=3D VIR_ARCH_AARCH64 && arch =3D=3D VIR_ARCH_ARM= V7L) + return true; + + if (qemuCaps->arch =3D=3D VIR_ARCH_ARMV7L && arch =3D=3D VIR_ARCH_ARMV= 6L) + return true; + + if (qemuCaps->arch =3D=3D VIR_ARCH_PPC64 && arch =3D=3D VIR_ARCH_PPC64= LE) + return true; + + return false; +} + + +bool +virQEMUCapsIsVirtTypeSupported(virQEMUCapsPtr qemuCaps, + virDomainVirtType virtType) +{ + if (virtType =3D=3D VIR_DOMAIN_VIRT_QEMU) + return true; + + if (virtType =3D=3D VIR_DOMAIN_VIRT_KVM && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) + return true; + + return false; +} + + bool virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps, virArch hostarch, diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 399496796d..a8a5c38d73 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -603,6 +603,10 @@ int virQEMUCapsGetCPUFeatures(virQEMUCapsPtr qemuCaps, bool migratable, char ***features); =20 +bool virQEMUCapsIsArchSupported(virQEMUCapsPtr qemuCaps, + virArch arch); +bool virQEMUCapsIsVirtTypeSupported(virQEMUCapsPtr qemuCaps, + virDomainVirtType virtType); bool virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps, virArch hostarch, virDomainVirtType type, diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index b0e87a05c2..0076349558 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4691,22 +4691,40 @@ qemuDomainDefPostParseBasic(virDomainDefPtr def, =20 static int qemuDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags, void *opaque, - void *parseOpaque) + void *parseOpaque G_GNUC_UNUSED) { virQEMUDriverPtr driver =3D opaque; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - /* Note that qemuCaps may be NULL when this function is called. This - * function shall not fail in that case. It will be re-run on VM start= up - * with the capabilities populated. */ - virQEMUCapsPtr qemuCaps =3D parseOpaque; + g_autoptr(virQEMUCaps) qemuCaps =3D NULL; + + if (!(qemuCaps =3D virQEMUCapsCacheLookup(driver->qemuCapsCache, + def->emulator))) { + return 1; + } + + if (def->os.type !=3D VIR_DOMAIN_OSTYPE_HVM) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Emulator '%s' does not support os type '%s'"), + def->emulator, virDomainOSTypeToString(def->os.type= )); + return -1; + } =20 - if (!virCapabilitiesDomainSupported(caps, def->os.type, - def->os.arch, - def->virtType)) + if (!virQEMUCapsIsArchSupported(qemuCaps, def->os.arch)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Emulator '%s' does not support arch '%s'"), + def->emulator, virArchToString(def->os.arch)); return -1; + } + + if (!virQEMUCapsIsVirtTypeSupported(qemuCaps, def->virtType)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Emulator '%s' does not support virt type '%s'"), + def->emulator, virDomainVirtTypeToString(def->virtT= ype)); + return -1; + } =20 if (def->os.bootloader || def->os.bootloaderArgs) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -4715,15 +4733,9 @@ qemuDomainDefPostParse(virDomainDefPtr def, } =20 if (!def->os.machine) { - g_autofree virCapsDomainDataPtr capsdata =3D NULL; - - if (!(capsdata =3D virCapabilitiesDomainDataLookup(caps, def->os.t= ype, - def->os.arch, - def->virtType, - NULL, NULL))) { - return -1; - } - def->os.machine =3D g_strdup(capsdata->machinetype); + const char *machine =3D virQEMUCapsGetPreferredMachine(qemuCaps, + def->virtType= ); + def->os.machine =3D g_strdup(machine); } =20 qemuDomainNVRAMPathGenerate(cfg, def); diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index be0adb1e45..308a941f8a 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -117,12 +117,13 @@ vmwareDataFreeFunc(void *data) =20 static int vmwareDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED, void *parseOpaque G_GNUC_UNUSED) { - if (!virCapabilitiesDomainSupported(caps, def->os.type, + struct vmware_driver *driver =3D opaque; + if (!virCapabilitiesDomainSupported(driver->caps, def->os.type, def->os.arch, def->virtType)) return -1; @@ -148,11 +149,11 @@ virDomainDefParserConfig vmwareDomainDefParserConfig = =3D { }; =20 static virDomainXMLOptionPtr -vmwareDomainXMLConfigInit(void) +vmwareDomainXMLConfigInit(struct vmware_driver *driver) { virDomainXMLPrivateDataCallbacks priv =3D { .alloc =3D vmwareDataAlloc= Func, .free =3D vmwareDataFreeFunc= }; - + vmwareDomainDefParserConfig.priv =3D driver; return virDomainXMLOptionNew(&vmwareDomainDefParserConfig, &priv, NULL, NULL, NULL); } @@ -235,7 +236,7 @@ vmwareConnectOpen(virConnectPtr conn, if (!(driver->caps =3D vmwareCapsInit())) goto cleanup; =20 - if (!(driver->xmlopt =3D vmwareDomainXMLConfigInit())) + if (!(driver->xmlopt =3D vmwareDomainXMLConfigInit(driver))) goto cleanup; =20 if (vmwareLoadDomains(driver) < 0) diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index c2a06daecb..958b168891 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -530,11 +530,12 @@ VIR_ENUM_IMPL(virVMXControllerModelSCSI, =20 static int virVMXDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps, + virCapsPtr _caps G_GNUC_UNUSED, unsigned int parseFlags G_GNUC_UNUSED, - void *opaque G_GNUC_UNUSED, + void *opaque, void *parseOpaque G_GNUC_UNUSED) { + virCapsPtr caps =3D opaque; if (!virCapabilitiesDomainSupported(caps, def->os.type, def->os.arch, def->virtType)) @@ -612,8 +613,9 @@ static virXMLNamespace virVMXDomainXMLNamespace =3D { }; =20 virDomainXMLOptionPtr -virVMXDomainXMLConfInit(void) +virVMXDomainXMLConfInit(virCapsPtr caps) { + virVMXDomainDefParserConfig.priv =3D caps; return virDomainXMLOptionNew(&virVMXDomainDefParserConfig, NULL, &virVMXDomainXMLNamespace, NULL, NULL); } diff --git a/src/vmx/vmx.h b/src/vmx/vmx.h index 18478ac0ae..63f47822fb 100644 --- a/src/vmx/vmx.h +++ b/src/vmx/vmx.h @@ -29,7 +29,7 @@ =20 typedef struct _virVMXContext virVMXContext; =20 -virDomainXMLOptionPtr virVMXDomainXMLConfInit(void); +virDomainXMLOptionPtr virVMXDomainXMLConfInit(virCapsPtr caps); =20 =20 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *= * * diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 66b15737a2..a0d1efb9dd 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -241,12 +241,13 @@ vzDomainDefAddDefaultInputDevices(virDomainDefPtr def) =20 static int vzDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags G_GNUC_UNUSED, - void *opaque G_GNUC_UNUSED, + void *opaque, void *parseOpaque G_GNUC_UNUSED) { - if (!virCapabilitiesDomainSupported(caps, def->os.type, + vzDriverPtr driver =3D opaque; + if (!virCapabilitiesDomainSupported(driver->caps, def->os.type, def->os.arch, def->virtType)) return -1; @@ -289,10 +290,12 @@ vzDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, static int vzDomainDeviceDefValidate(const virDomainDeviceDef *dev, const virDomainDef *def, - void *opaque G_GNUC_UNUSED) + void *opaque) { + vzDriverPtr driver =3D opaque; + if (dev->type =3D=3D VIR_DOMAIN_DEVICE_DISK) - return vzCheckUnsupportedDisk(def, dev->data.disk, opaque); + return vzCheckUnsupportedDisk(def, dev->data.disk, driver->vzCaps); else if (dev->type =3D=3D VIR_DOMAIN_DEVICE_GRAPHICS) return vzCheckUnsupportedGraphics(dev->data.graphics); =20 @@ -323,7 +326,7 @@ vzDriverObjNew(void) if (!(driver =3D virObjectLockableNew(vzDriverClass))) return NULL; =20 - vzDomainDefParserConfig.priv =3D &driver->vzCaps; + vzDomainDefParserConfig.priv =3D driver; =20 if (!(driver->caps =3D vzBuildCapabilities()) || !(driver->xmlopt =3D virDomainXMLOptionNew(&vzDomainDefParserConfi= g, diff --git a/tests/Makefile.am b/tests/Makefile.am index 465c176ffd..4873b85db3 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1046,11 +1046,17 @@ endif WITH_LXC if WITH_QEMU vircapstest_SOURCES +=3D testutilsqemu.c testutilsqemu.h endif WITH_QEMU +vircapstest_LDADD =3D if WITH_QEMU -vircapstest_LDADD =3D $(qemu_LDADDS) -else ! WITH_QEMU -vircapstest_LDADD =3D $(LDADDS) -endif ! WITH_QEMU +vircapstest_LDADD +=3D ../src/libvirt_driver_qemu_impl.la +if WITH_DTRACE_PROBES +vircapstest_LDADD +=3D ../src/libvirt_qemu_probes.lo +endif WITH_DTRACE_PROBES +endif WITH_QEMU +if WITH_LXC +vircapstest_LDADD +=3D ../src/libvirt_driver_lxc_impl.la +endif WITH_LXC +vircapstest_LDADD +=3D $(LDADDS) =20 libdomaincapsmock_la_SOURCES =3D domaincapsmock.c libdomaincapsmock_la_LDFLAGS =3D $(MOCKLIBS_LDFLAGS) diff --git a/tests/libxlxml2domconfigtest.c b/tests/libxlxml2domconfigtest.c index 5bda6db360..5c8dcf8503 100644 --- a/tests/libxlxml2domconfigtest.c +++ b/tests/libxlxml2domconfigtest.c @@ -41,7 +41,7 @@ =20 # define VIR_FROM_THIS VIR_FROM_LIBXL =20 -static virCapsPtr caps; +static libxlDriverPrivatePtr driver; =20 static int testCompareXMLToDomConfig(const char *xmlfile, @@ -50,19 +50,13 @@ testCompareXMLToDomConfig(const char *xmlfile, int ret =3D -1; libxl_domain_config actualconfig; libxl_domain_config expectconfig; - libxlDriverConfigPtr cfg; xentoollog_logger *log =3D NULL; virPortAllocatorRangePtr gports =3D NULL; - virDomainXMLOptionPtr xmlopt =3D NULL; virDomainDefPtr vmdef =3D NULL; char *actualjson =3D NULL; char *tempjson =3D NULL; char *expectjson =3D NULL; - - if (!(cfg =3D libxlDriverConfigNew())) - return -1; - - cfg->caps =3D caps; + g_autoptr(libxlDriverConfig) cfg =3D libxlDriverConfigGet(driver); =20 libxl_domain_config_init(&actualconfig); libxl_domain_config_init(&expectconfig); @@ -82,10 +76,7 @@ testCompareXMLToDomConfig(const char *xmlfile, if (!(gports =3D virPortAllocatorRangeNew("vnc", 5900, 6000))) goto cleanup; =20 - if (!(xmlopt =3D libxlCreateXMLConf())) - goto cleanup; - - if (!(vmdef =3D virDomainDefParseFile(xmlfile, caps, xmlopt, + if (!(vmdef =3D virDomainDefParseFile(xmlfile, cfg->caps, driver->xmlo= pt, NULL, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; =20 @@ -128,12 +119,9 @@ testCompareXMLToDomConfig(const char *xmlfile, VIR_FREE(tempjson); virDomainDefFree(vmdef); virPortAllocatorRangeFree(gports); - virObjectUnref(xmlopt); libxl_domain_config_dispose(&actualconfig); libxl_domain_config_dispose(&expectconfig); xtl_logger_destroy(log); - cfg->caps =3D NULL; - virObjectUnref(cfg); return ret; } =20 @@ -177,7 +165,7 @@ mymain(void) return EXIT_FAILURE; } =20 - if ((caps =3D testXLInitCaps()) =3D=3D NULL) + if ((driver =3D testXLInitDriver()) =3D=3D NULL) return EXIT_FAILURE; =20 # define DO_TEST(name) \ @@ -216,6 +204,8 @@ mymain(void) =20 unlink("libxl-driver.log"); =20 + testXLFreeDriver(driver); + return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } =20 diff --git a/tests/lxcconf2xmltest.c b/tests/lxcconf2xmltest.c index 7adc23be9f..fffe9cbf1a 100644 --- a/tests/lxcconf2xmltest.c +++ b/tests/lxcconf2xmltest.c @@ -10,8 +10,7 @@ =20 # define VIR_FROM_THIS VIR_FROM_NONE =20 -static virCapsPtr caps; -static virDomainXMLOptionPtr xmlopt; +static virLXCDriverPtr driver; =20 static int testSanitizeDef(virDomainDefPtr vmdef) { @@ -34,7 +33,7 @@ testCompareXMLToConfigFiles(const char *xmlfile, if (virTestLoadFile(configfile, &config) < 0) goto fail; =20 - vmdef =3D lxcParseConfigString(config, caps, xmlopt); + vmdef =3D lxcParseConfigString(config, driver->caps, driver->xmlopt); if ((vmdef && expectError) || (!vmdef && !expectError)) goto fail; =20 @@ -42,7 +41,7 @@ testCompareXMLToConfigFiles(const char *xmlfile, if (testSanitizeDef(vmdef) < 0) goto fail; =20 - if (!(actualxml =3D virDomainDefFormat(vmdef, xmlopt, caps, 0))) + if (!(actualxml =3D virDomainDefFormat(vmdef, driver->xmlopt, driv= er->caps, 0))) goto fail; =20 if (virTestCompareToFile(actualxml, xmlfile) < 0) @@ -109,14 +108,9 @@ mymain(void) { int ret =3D EXIT_SUCCESS; =20 - if (!(caps =3D testLXCCapsInit())) + if (!(driver =3D testLXCDriverInit())) return EXIT_FAILURE; =20 - if (!(xmlopt =3D lxcDomainXMLConfInit())) { - virObjectUnref(caps); - return EXIT_FAILURE; - } - # define DO_TEST(name, expectError) \ do { \ const struct testInfo info =3D { name, expectError }; \ @@ -166,8 +160,7 @@ mymain(void) DO_TEST3("blkiotune", false); DO_TEST3("ethernet", false); =20 - virObjectUnref(xmlopt); - virObjectUnref(caps); + testLXCDriverFree(driver); =20 return ret; } diff --git a/tests/lxcxml2xmltest.c b/tests/lxcxml2xmltest.c index 6a720503a9..7b05f7d016 100644 --- a/tests/lxcxml2xmltest.c +++ b/tests/lxcxml2xmltest.c @@ -16,8 +16,7 @@ =20 # define VIR_FROM_THIS VIR_FROM_NONE =20 -static virCapsPtr caps; -static virDomainXMLOptionPtr xmlopt; +static virLXCDriverPtr driver; =20 struct testInfo { const char *name; @@ -39,7 +38,7 @@ testCompareXMLToXMLHelper(const void *data) xml_out =3D g_strdup_printf("%s/lxcxml2xmloutdata/lxc-%s.xml", abs_srcdir, info->name); =20 - ret =3D testCompareDomXML2XMLFiles(caps, xmlopt, xml_in, + ret =3D testCompareDomXML2XMLFiles(driver->caps, driver->xmlopt, xml_i= n, info->different ? xml_out : xml_in, !info->inactive_only, info->parse_flags, @@ -55,10 +54,7 @@ mymain(void) { int ret =3D 0; =20 - if ((caps =3D testLXCCapsInit()) =3D=3D NULL) - return EXIT_FAILURE; - - if (!(xmlopt =3D lxcDomainXMLConfInit())) + if (!(driver =3D testLXCDriverInit())) return EXIT_FAILURE; =20 # define DO_TEST_FULL(name, is_different, inactive, parse_flags) \ @@ -95,8 +91,7 @@ mymain(void) DO_TEST("initdir"); DO_TEST("inituser"); =20 - virObjectUnref(caps); - virObjectUnref(xmlopt); + testLXCDriverFree(driver); =20 return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/openvzutilstest.c b/tests/openvzutilstest.c index f43867ddc9..681f1a52a0 100644 --- a/tests/openvzutilstest.c +++ b/tests/openvzutilstest.c @@ -98,7 +98,10 @@ testReadNetworkConf(const void *data G_GNUC_UNUSED) " \n" " \n" "\n"; - virDomainXMLOptionPtr xmlopt =3D openvzXMLOption(); + struct openvz_driver driver =3D {0}; + + driver.xmlopt =3D openvzXMLOption(&driver); + driver.caps =3D openvzCapsInit(); =20 if (!(def =3D virDomainDefNew())) goto cleanup; @@ -113,7 +116,7 @@ testReadNetworkConf(const void *data G_GNUC_UNUSED) goto cleanup; } =20 - actual =3D virDomainDefFormat(def, xmlopt, NULL, VIR_DOMAIN_DEF_FORMAT= _INACTIVE); + actual =3D virDomainDefFormat(def, driver.xmlopt, driver.caps, VIR_DOM= AIN_DEF_FORMAT_INACTIVE); =20 if (actual =3D=3D NULL) { fprintf(stderr, "ERROR: %s\n", virGetLastErrorMessage()); @@ -128,7 +131,8 @@ testReadNetworkConf(const void *data G_GNUC_UNUSED) result =3D 0; =20 cleanup: - virObjectUnref(xmlopt); + virObjectUnref(driver.xmlopt); + virObjectUnref(driver.caps); VIR_FREE(actual); virDomainDefFree(def); =20 diff --git a/tests/testutilslxc.c b/tests/testutilslxc.c index eed18304c4..b5e2f542e7 100644 --- a/tests/testutilslxc.c +++ b/tests/testutilslxc.c @@ -6,8 +6,10 @@ # include "viralloc.h" # include "domain_conf.h" =20 +# define VIR_FROM_THIS VIR_FROM_LXC =20 -virCapsPtr testLXCCapsInit(void) +virCapsPtr +testLXCCapsInit(void) { virCapsPtr caps; virCapsGuestPtr guest; @@ -54,4 +56,34 @@ virCapsPtr testLXCCapsInit(void) virObjectUnref(caps); return NULL; } + + +virLXCDriverPtr +testLXCDriverInit(void) +{ + virLXCDriverPtr driver =3D g_new0(virLXCDriver, 1); + + if (virMutexInit(&driver->lock) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", "cannot initialize mutex"); + g_free(driver); + return NULL; + } + + driver->caps =3D testLXCCapsInit(); + driver->xmlopt =3D lxcDomainXMLConfInit(driver); + + return driver; +} + + +void +testLXCDriverFree(virLXCDriverPtr driver) +{ + virObjectUnref(driver->xmlopt); + virObjectUnref(driver->caps); + virMutexDestroy(&driver->lock); + g_free(driver); +} + #endif diff --git a/tests/testutilslxc.h b/tests/testutilslxc.h index 6339f88734..fe170540b5 100644 --- a/tests/testutilslxc.h +++ b/tests/testutilslxc.h @@ -18,7 +18,11 @@ =20 #include "capabilities.h" =20 +#include "lxc/lxc_conf.h" + #define FAKEDEVDIR0 "/fakedevdir0/bla/fasl" #define FAKEDEVDIR1 "/fakedevdir1/bla/fasl" =20 virCapsPtr testLXCCapsInit(void); +virLXCDriverPtr testLXCDriverInit(void); +void testLXCDriverFree(virLXCDriverPtr driver); diff --git a/tests/testutilsxen.c b/tests/testutilsxen.c index 314d96abe8..75cd42ec43 100644 --- a/tests/testutilsxen.c +++ b/tests/testutilsxen.c @@ -6,7 +6,9 @@ #include "testutilshostcpus.h" #include "domain_conf.h" =20 -virCapsPtr +#define VIR_FROM_THIS VIR_FROM_LIBXL + +static virCapsPtr testXLInitCaps(void) { virCapsPtr caps; @@ -79,3 +81,33 @@ testXLInitCaps(void) virObjectUnref(caps); return NULL; } + + +libxlDriverPrivatePtr testXLInitDriver(void) +{ + libxlDriverPrivatePtr driver =3D g_new0(libxlDriverPrivate, 1); + + if (virMutexInit(&driver->lock) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", "cannot initialize mutex"); + g_free(driver); + return NULL; + } + + driver->config =3D libxlDriverConfigNew(); + + driver->config->caps =3D testXLInitCaps(); + + driver->xmlopt =3D libxlCreateXMLConf(driver); + + return driver; +} + +void testXLFreeDriver(libxlDriverPrivatePtr driver) +{ + virObjectUnref(driver->config->caps); + virObjectUnref(driver->config); + virObjectUnref(driver->xmlopt); + virMutexDestroy(&driver->lock); + g_free(driver); +} diff --git a/tests/testutilsxen.h b/tests/testutilsxen.h index 95dadb04c4..a31d3d9047 100644 --- a/tests/testutilsxen.h +++ b/tests/testutilsxen.h @@ -18,7 +18,10 @@ =20 #include "capabilities.h" #ifdef WITH_LIBXL -# include "libxl/libxl_capabilities.h" -#endif +# include "libxl/libxl_conf.h" =20 -virCapsPtr testXLInitCaps(void); +libxlDriverPrivatePtr testXLInitDriver(void); + +void testXLFreeDriver(libxlDriverPrivatePtr driver); + +#endif /* WITH_LIBXL */ diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index 72ee2a38c8..beb82cbd7c 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -186,7 +186,7 @@ mymain(void) if (caps =3D=3D NULL) return EXIT_FAILURE; =20 - if (!(xmlopt =3D virVMXDomainXMLConfInit())) + if (!(xmlopt =3D virVMXDomainXMLConfInit(caps))) return EXIT_FAILURE; =20 ctx.opaque =3D NULL; diff --git a/tests/xlconfigtest.c b/tests/xlconfigtest.c index 890d8bf2b4..d077933ca9 100644 --- a/tests/xlconfigtest.c +++ b/tests/xlconfigtest.c @@ -36,9 +36,7 @@ =20 #define VIR_FROM_THIS VIR_FROM_NONE =20 -static virCapsPtr caps; -static virDomainXMLOptionPtr xmlopt; - +static libxlDriverPrivatePtr driver; =20 /* * This function provides a mechanism to replace variables in test @@ -74,6 +72,7 @@ testCompareParseXML(const char *xlcfg, const char *xml, b= ool replaceVars) int ret =3D -1; virDomainDefPtr def =3D NULL; char *replacedXML =3D NULL; + g_autoptr(libxlDriverConfig) cfg =3D libxlDriverConfigGet(driver); =20 if (VIR_ALLOC_N(gotxlcfgData, wrote) < 0) goto fail; @@ -84,16 +83,16 @@ testCompareParseXML(const char *xlcfg, const char *xml,= bool replaceVars) if (replaceVars) { if (!(replacedXML =3D testReplaceVarsXML(xml))) goto fail; - if (!(def =3D virDomainDefParseString(replacedXML, caps, xmlopt, + if (!(def =3D virDomainDefParseString(replacedXML, cfg->caps, driv= er->xmlopt, NULL, VIR_DOMAIN_XML_INACTIVE)= )) goto fail; } else { - if (!(def =3D virDomainDefParseFile(xml, caps, xmlopt, + if (!(def =3D virDomainDefParseFile(xml, cfg->caps, driver->xmlopt, NULL, VIR_DOMAIN_XML_INACTIVE))) goto fail; } =20 - if (!virDomainDefCheckABIStability(def, def, xmlopt)) { + if (!virDomainDefCheckABIStability(def, def, driver->xmlopt)) { fprintf(stderr, "ABI stability check failed on %s", xml); goto fail; } @@ -133,6 +132,7 @@ testCompareFormatXML(const char *xlcfg, const char *xml= , bool replaceVars) virConnectPtr conn; virDomainDefPtr def =3D NULL; char *replacedXML =3D NULL; + g_autoptr(libxlDriverConfig) cfg =3D libxlDriverConfigGet(driver); =20 conn =3D virGetConnect(); if (!conn) goto fail; @@ -143,10 +143,10 @@ testCompareFormatXML(const char *xlcfg, const char *x= ml, bool replaceVars) if (!(conf =3D virConfReadString(xlcfgData, 0))) goto fail; =20 - if (!(def =3D xenParseXL(conf, caps, xmlopt))) + if (!(def =3D xenParseXL(conf, cfg->caps, driver->xmlopt))) goto fail; =20 - if (!(gotxml =3D virDomainDefFormat(def, xmlopt, caps, + if (!(gotxml =3D virDomainDefFormat(def, driver->xmlopt, cfg->caps, VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_SECURE))) goto fail; @@ -208,10 +208,7 @@ mymain(void) { int ret =3D 0; =20 - if (!(caps =3D testXLInitCaps())) - return EXIT_FAILURE; - - if (!(xmlopt =3D libxlCreateXMLConf())) + if (!(driver =3D testXLInitDriver())) return EXIT_FAILURE; =20 #define DO_TEST_PARSE(name, replace) \ @@ -303,10 +300,9 @@ mymain(void) DO_TEST("usb"); DO_TEST("usbctrl"); =20 - virObjectUnref(caps); - virObjectUnref(xmlopt); + testXLFreeDriver(driver); =20 return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } =20 -VIR_TEST_MAIN(mymain) +VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("xl")) diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c index 4a4d4192db..6971ad76e2 100644 --- a/tests/xmconfigtest.c +++ b/tests/xmconfigtest.c @@ -34,8 +34,7 @@ =20 #define VIR_FROM_THIS VIR_FROM_NONE =20 -static virCapsPtr caps; -static virDomainXMLOptionPtr xmlopt; +static libxlDriverPrivatePtr driver; =20 static int testCompareParseXML(const char *xmcfg, const char *xml) @@ -46,6 +45,7 @@ testCompareParseXML(const char *xmcfg, const char *xml) virConnectPtr conn =3D NULL; int wrote =3D 4096; virDomainDefPtr def =3D NULL; + g_autoptr(libxlDriverConfig) cfg =3D libxlDriverConfigGet(driver); =20 if (VIR_ALLOC_N(gotxmcfgData, wrote) < 0) goto fail; @@ -53,11 +53,11 @@ testCompareParseXML(const char *xmcfg, const char *xml) conn =3D virGetConnect(); if (!conn) goto fail; =20 - if (!(def =3D virDomainDefParseFile(xml, caps, xmlopt, NULL, + if (!(def =3D virDomainDefParseFile(xml, cfg->caps, driver->xmlopt, NU= LL, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto fail; =20 - if (!virDomainDefCheckABIStability(def, def, xmlopt)) { + if (!virDomainDefCheckABIStability(def, def, driver->xmlopt)) { fprintf(stderr, "ABI stability check failed on %s", xml); goto fail; } @@ -90,6 +90,7 @@ testCompareFormatXML(const char *xmcfg, const char *xml) g_autoptr(virConf) conf =3D NULL; int ret =3D -1; virDomainDefPtr def =3D NULL; + g_autoptr(libxlDriverConfig) cfg =3D libxlDriverConfigGet(driver); =20 if (virTestLoadFile(xmcfg, &xmcfgData) < 0) goto fail; @@ -97,10 +98,10 @@ testCompareFormatXML(const char *xmcfg, const char *xml) if (!(conf =3D virConfReadString(xmcfgData, 0))) goto fail; =20 - if (!(def =3D xenParseXM(conf, caps, xmlopt))) + if (!(def =3D xenParseXM(conf, cfg->caps, driver->xmlopt))) goto fail; =20 - if (!(gotxml =3D virDomainDefFormat(def, xmlopt, caps, VIR_DOMAIN_DEF_= FORMAT_SECURE))) + if (!(gotxml =3D virDomainDefFormat(def, driver->xmlopt, cfg->caps, VI= R_DOMAIN_DEF_FORMAT_SECURE))) goto fail; =20 if (virTestCompareToFile(gotxml, xml) < 0) @@ -152,10 +153,7 @@ mymain(void) { int ret =3D 0; =20 - if (!(caps =3D testXLInitCaps())) - return EXIT_FAILURE; - - if (!(xmlopt =3D libxlCreateXMLConf())) + if (!(driver =3D testXLInitDriver())) return EXIT_FAILURE; =20 #define DO_TEST_PARSE(name) \ @@ -225,10 +223,9 @@ mymain(void) DO_TEST("disk-drv-blktap-raw"); DO_TEST("disk-drv-blktap2-raw"); =20 - virObjectUnref(caps); - virObjectUnref(xmlopt); + testXLFreeDriver(driver); =20 return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } =20 -VIR_TEST_MAIN(mymain) +VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("xl")) diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index 8dc37f265a..39781beafd 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -207,7 +207,7 @@ mymain(void) if (caps =3D=3D NULL) return EXIT_FAILURE; =20 - if (!(xmlopt =3D virVMXDomainXMLConfInit())) + if (!(xmlopt =3D virVMXDomainXMLConfInit(caps))) return EXIT_FAILURE; =20 ctx.opaque =3D NULL; --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.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 207.211.31.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=1575469309; cv=none; d=zohomail.com; s=zohoarc; b=ND5HVzAdsO5LFrhkxRRPSEjBVLjuqBL8sgQLicKWwQABfjEAhelfZy/YH9xlMNG9/xNzzFMO6j/HrR1H3LzcWlaG/owR6mGPSiONX3YHdFR5q0c50oESdaB6goqwB0HSaWElXOzZpEO6eUK3ps8Ghry2h1Bi2OkK623xXQv45jE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469309; 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=gLrXFhAtA3MIHkvjptJzEKzlXnfWPY8sFxFuZgmzSh4=; b=NWGxwCKnVnA+Sykplx/XzO2evpG+Pp+DWX/WHHwZ13jWJDDowpJPEACDqiFcfgH0dY6Lvk+2kT72cAljBKcHLQqnYWhHWcMSG/sF9ZOSimFMERc8WQORPhTpDWH/LsGpacSjMEsY2baJoJIMpXdU2qcxA68A4+MBz+kdy7jW84A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.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 [207.211.31.120]) by mx.zohomail.com with SMTPS id 1575469309746418.8525607145772; Wed, 4 Dec 2019 06:21:49 -0800 (PST) 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-69-q2xoeXhMPU2CW8FrISVMzw-1; Wed, 04 Dec 2019 09:21:46 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E0F4F1B18BE4; Wed, 4 Dec 2019 14:21:38 +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 B94D3600CC; Wed, 4 Dec 2019 14:21:38 +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 78BF918089D5; Wed, 4 Dec 2019 14:21:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4ELSr4008137 for ; Wed, 4 Dec 2019 09:21:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id C486B1D1; Wed, 4 Dec 2019 14:21:28 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C15669184; Wed, 4 Dec 2019 14:21:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469308; 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=gLrXFhAtA3MIHkvjptJzEKzlXnfWPY8sFxFuZgmzSh4=; b=d+aTJI5w5SH8oxiRROcqtioDyXvcez2lynAsKbEpL1DXyLW0s/Wmu5rAqGRYxt4yrLxyR+ lXTD19KPda9lHGTBSBeCh7h0Aj5Sg5eTjmjbwgmAIQhl5e/sivYvo1rqf5syi9kp/Wt7Fz 5ZOlz3c6yRJGp+3FQSXRDjjA5hu5BsA= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:20:51 +0000 Message-Id: <20191204142113.2961028-9-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 08/30] conf: pass netprefix in the domain parser config struct 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.11 X-MC-Unique: q2xoeXhMPU2CW8FrISVMzw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Instead of using the virCapsPtr information, pass the driver specific netprefix in the domain parser struct. This eliminates one more use of virCapsPtr from the XML parsing/formatting code. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 24 +++++++----------------- src/conf/domain_conf.h | 3 ++- src/libxl/libxl_domain.c | 1 + 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6abe15f721..b45ca4a4d0 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11446,7 +11446,6 @@ static virDomainNetDefPtr virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, xmlNodePtr node, xmlXPathContextPtr ctxt, - char *prefix, unsigned int flags) { virDomainNetDefPtr def; @@ -11494,6 +11493,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, g_autofree char *vhostuser_type =3D NULL; g_autofree char *trustGuestRxFilters =3D NULL; g_autofree char *vhost_path =3D NULL; + const char *prefix =3D xmlopt ? xmlopt->config.netPrefix : NULL; =20 if (!(def =3D virDomainNetDefNew(xmlopt))) return NULL; @@ -16385,7 +16385,6 @@ virDomainDeviceDefParse(const char *xmlStr, xmlNodePtr node; g_autoptr(xmlXPathContext) ctxt =3D NULL; g_autofree virDomainDeviceDefPtr dev =3D NULL; - char *netprefix; =20 if (!(xml =3D virXMLParseStringCtxt(xmlStr, _("(device_definition)"), = &ctxt))) return NULL; @@ -16428,9 +16427,7 @@ virDomainDeviceDefParse(const char *xmlStr, return NULL; break; case VIR_DOMAIN_DEVICE_NET: - netprefix =3D caps->host.netprefix; - if (!(dev->data.net =3D virDomainNetDefParseXML(xmlopt, node, ctxt, - netprefix, flags))) + if (!(dev->data.net =3D virDomainNetDefParseXML(xmlopt, node, ctxt= , flags))) return NULL; break; case VIR_DOMAIN_DEVICE_INPUT: @@ -19759,7 +19756,6 @@ virDomainDefParseXML(xmlDocPtr xml, bool usb_none =3D false; bool usb_other =3D false; bool usb_master =3D false; - char *netprefix =3D NULL; g_autofree xmlNodePtr *nodes =3D NULL; g_autofree char *tmp =3D NULL; =20 @@ -20872,12 +20868,10 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; if (n && VIR_ALLOC_N(def->nets, n) < 0) goto error; - netprefix =3D caps->host.netprefix; for (i =3D 0; i < n; i++) { virDomainNetDefPtr net =3D virDomainNetDefParseXML(xmlopt, nodes[i], ctxt, - netprefix, flags); if (!net) goto error; @@ -25362,7 +25356,7 @@ virDomainChrSourceReconnectDefFormat(virBufferPtr b= uf, int virDomainNetDefFormat(virBufferPtr buf, virDomainNetDefPtr def, - char *prefix, + virDomainXMLOptionPtr xmlopt, unsigned int flags) { virDomainNetType actualType =3D virDomainNetGetActualType(def); @@ -25372,6 +25366,7 @@ virDomainNetDefFormat(virBufferPtr buf, virDomainHostdevDefPtr hostdef =3D NULL; char macstr[VIR_MAC_STRING_BUFLEN]; g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + const char *prefix =3D xmlopt ? xmlopt->config.netPrefix : NULL; =20 /* publicActual is true if we should report the current state in * def->data.network.actual *instead of* the config (*not* in @@ -28294,7 +28289,7 @@ virDomainDefFormatInternal(virDomainDefPtr def, int virDomainDefFormatInternalSetRootName(virDomainDefPtr def, virDomainXMLOptionPtr xmlopt, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, virBufferPtr buf, const char *rootname, unsigned int flags) @@ -28304,7 +28299,6 @@ virDomainDefFormatInternalSetRootName(virDomainDefP= tr def, const char *type =3D NULL; int n; size_t i; - char *netprefix =3D NULL; =20 virCheckFlags(VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS | VIR_DOMAIN_DEF_FORMAT_STATUS | @@ -28660,10 +28654,8 @@ virDomainDefFormatInternalSetRootName(virDomainDef= Ptr def, if (virDomainFSDefFormat(buf, def->fss[n], flags) < 0) goto error; =20 - if (caps) - netprefix =3D caps->host.netprefix; for (n =3D 0; n < def->nnets; n++) - if (virDomainNetDefFormat(buf, def->nets[n], netprefix, flags) < 0) + if (virDomainNetDefFormat(buf, def->nets[n], xmlopt, flags) < 0) goto error; =20 for (n =3D 0; n < def->nsmartcards; n++) @@ -29834,7 +29826,6 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src, g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; int flags =3D VIR_DOMAIN_DEF_FORMAT_INACTIVE | VIR_DOMAIN_DEF_FORMAT_S= ECURE; int rc =3D -1; - char *netprefix; g_autofree char *xmlStr =3D NULL; =20 switch ((virDomainDeviceType) src->type) { @@ -29848,8 +29839,7 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src, rc =3D virDomainFSDefFormat(&buf, src->data.fs, flags); break; case VIR_DOMAIN_DEVICE_NET: - netprefix =3D caps->host.netprefix; - rc =3D virDomainNetDefFormat(&buf, src->data.net, netprefix, flags= ); + rc =3D virDomainNetDefFormat(&buf, src->data.net, xmlopt, flags); break; case VIR_DOMAIN_DEVICE_INPUT: rc =3D virDomainInputDefFormat(&buf, src->data.input, flags); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e1622f2112..037cebae64 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2706,6 +2706,7 @@ struct _virDomainDefParserConfig { unsigned int features; /* virDomainDefFeatures */ unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN]; virArch defArch; + const char *netPrefix; }; =20 typedef void *(*virDomainXMLPrivateDataAllocFunc)(void *); @@ -3146,7 +3147,7 @@ virDomainDiskBackingStoreFormat(virBufferPtr buf, =20 int virDomainNetDefFormat(virBufferPtr buf, virDomainNetDefPtr def, - char *prefix, + virDomainXMLOptionPtr xmlopt, unsigned int flags); =20 typedef enum { diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index f202f0fc3e..dfac04bf59 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -437,6 +437,7 @@ libxlDomainDefPostParse(virDomainDefPtr def, =20 virDomainDefParserConfig libxlDomainDefParserConfig =3D { .macPrefix =3D { 0x00, 0x16, 0x3e }, + .netPrefix =3D LIBXL_GENERATED_PREFIX_XEN, .devicesPostParseCallback =3D libxlDomainDeviceDefPostParse, .domainPostParseCallback =3D libxlDomainDefPostParse, .features =3D VIR_DOMAIN_DEF_FEATURE_NET_MODEL_STRING, --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.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 207.211.31.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=1575469335; cv=none; d=zohomail.com; s=zohoarc; b=HQs0yJ7gf8Y2ReoeOkO2c/0vIVuZCn7XiPL6sRBA+BGA2QP5X8w4+xNE+b3N7jmeDYMYYGkeoZUwN+Y8XA1H2n4amkZ10TyDWO/dBcyHnvKlyT6OIVo1l7bND0wWbZShbCqIOJbjXhY4xr+PsonFn01dE397TSrky1eAxsThIAw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469335; 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=X2ksm31RmGw47zOTLUXclUt7/OdZ6S/6/CPEojNhQ2g=; b=jtrG7P2+zwKMhHRoDM+YwxhCgFtYnfoHXwhzHo1WHcyzzKrTqtht3zyr2hi5dDE2ZpYx736cNb/bS4f8j1wdfJWR662rd/gz4p3bcIoCmV1Q5yRhI0WHl3C2sQJCtErwg3McHI45xO/Chx9l8qspqKrS8jnAdjqUA7/HjdzevLk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.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 [207.211.31.120]) by mx.zohomail.com with SMTPS id 1575469335405891.6317006088244; Wed, 4 Dec 2019 06:22:15 -0800 (PST) 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-412-4JxVfJFuP02rA_k9k1saTA-1; Wed, 04 Dec 2019 09:21:54 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5BA58DC13; Wed, 4 Dec 2019 14:21:48 +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 3422F19C68; Wed, 4 Dec 2019 14:21:48 +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 D72D862CF5; Wed, 4 Dec 2019 14:21:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4ELUR4008145 for ; Wed, 4 Dec 2019 09:21:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id 002061D1; Wed, 4 Dec 2019 14:21:30 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A60A691A3; Wed, 4 Dec 2019 14:21:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469334; 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=X2ksm31RmGw47zOTLUXclUt7/OdZ6S/6/CPEojNhQ2g=; b=hVrufCiLhASNbgqSZW3LIU2kmGryzwd3LSwvwAmXqlhg1c6AZUjBidoQ1M/Bsg2uY9gyew wChWTEAOQbBhLBqU/y4X2dvGz1AVpvB53Zctm37ruOLwdZTR8KPkZ6P1qu/3LQKauFaFw7 upxSgEU3fEP8dyWSJOf91FkwdJw699I= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:20:52 +0000 Message-Id: <20191204142113.2961028-10-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/30] conf: move seclabel validation into post-parse phase 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.84 on 10.5.11.23 X-MC-Unique: 4JxVfJFuP02rA_k9k1saTA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Currently the disk and chardev seclabels are validated immediately at the time their data is parsed. This forces the parser to fill in the top level secmodel at time of parsing which is an undesirable thing. This validation conceptually should be done in the post-parse phase instead. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 196 ++++++++++++++++++----------------------- src/conf/domain_conf.h | 1 - src/qemu/qemu_driver.c | 2 +- tests/qemublocktest.c | 2 +- 4 files changed, 90 insertions(+), 111 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b45ca4a4d0..f037702ac2 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5936,8 +5936,42 @@ virDomainDiskAddressDiskBusCompatibility(virDomainDi= skBus bus, =20 =20 static int -virDomainDiskDefValidate(const virDomainDiskDef *disk) +virSecurityDeviceLabelDefValidateXML(virSecurityDeviceLabelDefPtr *seclabe= ls, + size_t nseclabels, + virSecurityLabelDefPtr *vmSeclabels, + size_t nvmSeclabels) +{ + virSecurityDeviceLabelDefPtr seclabel; + size_t i; + size_t j; + + for (i =3D 0; i < nseclabels; i++) { + seclabel =3D seclabels[i]; + + /* find the security label that it's being overridden */ + for (j =3D 0; j < nvmSeclabels; j++) { + if (STRNEQ_NULLABLE(vmSeclabels[j]->model, seclabel->model)) + continue; + + if (!vmSeclabels[j]->relabel) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("label overrides require relabeling to be= " + "enabled at the domain level")); + return -1; + } + } + } + + return 0; +} + + +static int +virDomainDiskDefValidate(const virDomainDef *def, + const virDomainDiskDef *disk) { + virStorageSourcePtr next; + /* Validate LUN configuration */ if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_LUN) { /* volumes haven't been translated at this point, so accept them */ @@ -5991,6 +6025,14 @@ virDomainDiskDefValidate(const virDomainDiskDef *dis= k) return -1; } =20 + for (next =3D disk->src; next; next =3D next->backingStore) { + if (virSecurityDeviceLabelDefValidateXML(next->seclabels, + next->nseclabels, + def->seclabels, + def->nseclabels) < 0) + return -1; + } + return 0; } =20 @@ -6014,10 +6056,11 @@ virDomainDefHasUSB(const virDomainDef *def) =20 =20 static int -virDomainChrSourceDefValidate(const virDomainChrSourceDef *def, - const virDomainChrDef *chr_def) +virDomainChrSourceDefValidate(const virDomainChrSourceDef *src_def, + const virDomainChrDef *chr_def, + const virDomainDef *def) { - switch ((virDomainChrType) def->type) { + switch ((virDomainChrType) src_def->type) { case VIR_DOMAIN_CHR_TYPE_NULL: case VIR_DOMAIN_CHR_TYPE_PTY: case VIR_DOMAIN_CHR_TYPE_VC: @@ -6029,7 +6072,7 @@ virDomainChrSourceDefValidate(const virDomainChrSourc= eDef *def, case VIR_DOMAIN_CHR_TYPE_FILE: case VIR_DOMAIN_CHR_TYPE_DEV: case VIR_DOMAIN_CHR_TYPE_PIPE: - if (!def->data.file.path) { + if (!src_def->data.file.path) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing source path attribute for char devic= e")); return -1; @@ -6037,13 +6080,13 @@ virDomainChrSourceDefValidate(const virDomainChrSou= rceDef *def, break; =20 case VIR_DOMAIN_CHR_TYPE_NMDM: - if (!def->data.nmdm.master) { + if (!src_def->data.nmdm.master) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing master path attribute for nmdm devic= e")); return -1; } =20 - if (!def->data.nmdm.slave) { + if (!src_def->data.nmdm.slave) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing slave path attribute for nmdm device= ")); return -1; @@ -6051,19 +6094,19 @@ virDomainChrSourceDefValidate(const virDomainChrSou= rceDef *def, break; =20 case VIR_DOMAIN_CHR_TYPE_TCP: - if (!def->data.tcp.host) { + if (!src_def->data.tcp.host) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing source host attribute for char devic= e")); return -1; } =20 - if (!def->data.tcp.service) { + if (!src_def->data.tcp.service) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing source service attribute for char de= vice")); return -1; } =20 - if (def->data.tcp.listen && def->data.tcp.reconnect.enabled) { + if (src_def->data.tcp.listen && src_def->data.tcp.reconnect.enable= d) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("chardev reconnect is possible only for conne= ct mode")); return -1; @@ -6071,7 +6114,7 @@ virDomainChrSourceDefValidate(const virDomainChrSourc= eDef *def, break; =20 case VIR_DOMAIN_CHR_TYPE_UDP: - if (!def->data.udp.connectService) { + if (!src_def->data.udp.connectService) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing source service attribute for char de= vice")); return -1; @@ -6082,7 +6125,7 @@ virDomainChrSourceDefValidate(const virDomainChrSourc= eDef *def, /* The source path can be auto generated for certain specific * types of channels, but in most cases we should report an * error if the user didn't provide it */ - if (!def->data.nix.path && + if (!src_def->data.nix.path && !(chr_def && chr_def->deviceType =3D=3D VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNE= L && (chr_def->targetType =3D=3D VIR_DOMAIN_CHR_CHANNEL_TARGET_TY= PE_XEN || @@ -6092,7 +6135,7 @@ virDomainChrSourceDefValidate(const virDomainChrSourc= eDef *def, return -1; } =20 - if (def->data.nix.listen && def->data.nix.reconnect.enabled) { + if (src_def->data.nix.listen && src_def->data.nix.reconnect.enable= d) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("chardev reconnect is possible only for conne= ct mode")); return -1; @@ -6100,13 +6143,13 @@ virDomainChrSourceDefValidate(const virDomainChrSou= rceDef *def, break; =20 case VIR_DOMAIN_CHR_TYPE_SPICEPORT: - if (!def->data.spiceport.channel) { + if (!src_def->data.spiceport.channel) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing source channel attribute for char de= vice")); return -1; } - if (strspn(def->data.spiceport.channel, - SERIAL_CHANNEL_NAME_CHARS) < strlen(def->data.spiceport= .channel)) { + if (strspn(src_def->data.spiceport.channel, + SERIAL_CHANNEL_NAME_CHARS) < strlen(src_def->data.spice= port.channel)) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid character in source channel for char= device")); return -1; @@ -6114,6 +6157,12 @@ virDomainChrSourceDefValidate(const virDomainChrSour= ceDef *def, break; } =20 + if (virSecurityDeviceLabelDefValidateXML(src_def->seclabels, + src_def->nseclabels, + def->seclabels, + def->nseclabels) < 0) + return -1; + return 0; } =20 @@ -6130,7 +6179,7 @@ virDomainRedirdevDefValidate(const virDomainDef *def, return -1; } =20 - return virDomainChrSourceDefValidate(redirdev->source, NULL); + return virDomainChrSourceDefValidate(redirdev->source, NULL, def); } =20 =20 @@ -6253,27 +6302,30 @@ virDomainControllerDefValidate(const virDomainContr= ollerDef *controller) =20 =20 static int -virDomainChrDefValidate(const virDomainChrDef *chr) +virDomainChrDefValidate(const virDomainChrDef *chr, + const virDomainDef *def) { - return virDomainChrSourceDefValidate(chr->source, chr); + return virDomainChrSourceDefValidate(chr->source, chr, def); } =20 =20 static int -virDomainSmartcardDefValidate(const virDomainSmartcardDef *smartcard) +virDomainSmartcardDefValidate(const virDomainSmartcardDef *smartcard, + const virDomainDef *def) { if (smartcard->type =3D=3D VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH) - return virDomainChrSourceDefValidate(smartcard->data.passthru, NUL= L); + return virDomainChrSourceDefValidate(smartcard->data.passthru, NUL= L, def); =20 return 0; } =20 =20 static int -virDomainRNGDefValidate(const virDomainRNGDef *rng) +virDomainRNGDefValidate(const virDomainRNGDef *rng, + const virDomainDef *def) { if (rng->backend =3D=3D VIR_DOMAIN_RNG_BACKEND_EGD) - return virDomainChrSourceDefValidate(rng->source.chardev, NULL); + return virDomainChrSourceDefValidate(rng->source.chardev, NULL, de= f); =20 return 0; } @@ -6470,7 +6522,7 @@ virDomainDeviceDefValidateInternal(const virDomainDev= iceDef *dev, { switch ((virDomainDeviceType) dev->type) { case VIR_DOMAIN_DEVICE_DISK: - return virDomainDiskDefValidate(dev->data.disk); + return virDomainDiskDefValidate(def, dev->data.disk); =20 case VIR_DOMAIN_DEVICE_REDIRDEV: return virDomainRedirdevDefValidate(def, dev->data.redirdev); @@ -6482,13 +6534,13 @@ virDomainDeviceDefValidateInternal(const virDomainD= eviceDef *dev, return virDomainControllerDefValidate(dev->data.controller); =20 case VIR_DOMAIN_DEVICE_CHR: - return virDomainChrDefValidate(dev->data.chr); + return virDomainChrDefValidate(dev->data.chr, def); =20 case VIR_DOMAIN_DEVICE_SMARTCARD: - return virDomainSmartcardDefValidate(dev->data.smartcard); + return virDomainSmartcardDefValidate(dev->data.smartcard, def); =20 case VIR_DOMAIN_DEVICE_RNG: - return virDomainRNGDefValidate(dev->data.rng); + return virDomainRNGDefValidate(dev->data.rng, def); =20 case VIR_DOMAIN_DEVICE_HOSTDEV: return virDomainHostdevDefValidate(dev->data.hostdev); @@ -9044,37 +9096,6 @@ virSecurityDeviceLabelDefParseXML(virSecurityDeviceL= abelDefPtr **seclabels_rtn, } =20 =20 -static int -virSecurityDeviceLabelDefValidateXML(virSecurityDeviceLabelDefPtr *seclabe= ls, - size_t nseclabels, - virSecurityLabelDefPtr *vmSeclabels, - size_t nvmSeclabels) -{ - virSecurityDeviceLabelDefPtr seclabel; - size_t i; - size_t j; - - for (i =3D 0; i < nseclabels; i++) { - seclabel =3D seclabels[i]; - - /* find the security label that it's being overridden */ - for (j =3D 0; j < nvmSeclabels; j++) { - if (STRNEQ_NULLABLE(vmSeclabels[j]->model, seclabel->model)) - continue; - - if (!vmSeclabels[j]->relabel) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("label overrides require relabeling to be= " - "enabled at the domain level")); - return -1; - } - } - } - - return 0; -} - - /* Parse the XML definition for a lease */ static virDomainLeaseDefPtr @@ -9703,9 +9724,7 @@ virDomainDiskSourceDefParseAuthValidate(const virStor= ageSource *src) =20 =20 static int -virDomainDiskDefParseValidate(const virDomainDiskDef *def, - virSecurityLabelDefPtr *vmSeclabels, - size_t nvmSeclabels) +virDomainDiskDefParseValidate(const virDomainDiskDef *def) =20 { virStorageSourcePtr next; @@ -9796,12 +9815,6 @@ virDomainDiskDefParseValidate(const virDomainDiskDef= *def, return -1; } } - - if (virSecurityDeviceLabelDefValidateXML(next->seclabels, - next->nseclabels, - vmSeclabels, - nvmSeclabels) < 0) - return -1; } =20 return 0; @@ -9958,8 +9971,6 @@ static virDomainDiskDefPtr virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, xmlNodePtr node, xmlXPathContextPtr ctxt, - virSecurityLabelDefPtr* vmSeclabels, - int nvmSeclabels, unsigned int flags) { virDomainDiskDefPtr def; @@ -10362,7 +10373,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlo= pt, virDomainDiskDefParsePrivateData(ctxt, def, xmlopt) < 0) goto error; =20 - if (virDomainDiskDefParseValidate(def, vmSeclabels, nvmSeclabels) < 0) + if (virDomainDiskDefParseValidate(def) < 0) goto error; =20 cleanup: @@ -12652,9 +12663,7 @@ static int virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def, xmlNodePtr cur, unsigned int flags, virDomainChrDefPtr chr_def, - xmlXPathContextPtr ctxt, - virSecurityLabelDefPtr* vmSeclabels, - int nvmSeclabels) + xmlXPathContextPtr ctxt) { bool logParsed =3D false; bool protocolParsed =3D false; @@ -12737,11 +12746,7 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDe= fPtr def, if (virSecurityDeviceLabelDefParseXML(&def->seclabels, &def->nseclabels, ctxt, - flags) < 0 || - virSecurityDeviceLabelDefValidateXML(def->seclabels, - def->nseclabels, - vmSeclabels, - nvmSeclabels) < 0= ) { + flags) < 0) { ctxt->node =3D saved_node; goto error; } @@ -12878,8 +12883,6 @@ static virDomainChrDefPtr virDomainChrDefParseXML(virDomainXMLOptionPtr xmlopt, xmlXPathContextPtr ctxt, xmlNodePtr node, - virSecurityLabelDefPtr* vmSeclabels, - int nvmSeclabels, unsigned int flags) { xmlNodePtr cur; @@ -12926,7 +12929,7 @@ virDomainChrDefParseXML(virDomainXMLOptionPtr xmlop= t, goto error; =20 if (virDomainChrSourceDefParseXML(def->source, node->children, flags, = def, - ctxt, vmSeclabels, nvmSeclabels) < 0) + ctxt) < 0) goto error; =20 if (def->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_SPICEVMC) { @@ -13057,7 +13060,7 @@ virDomainSmartcardDefParseXML(virDomainXMLOptionPtr= xmlopt, =20 cur =3D node->children; if (virDomainChrSourceDefParseXML(def->data.passthru, cur, flags, - NULL, ctxt, NULL, 0) < 0) + NULL, ctxt) < 0) goto error; =20 if (def->data.passthru->type =3D=3D VIR_DOMAIN_CHR_TYPE_SPICEVMC) { @@ -14692,7 +14695,7 @@ virDomainRNGDefParseXML(virDomainXMLOptionPtr xmlop= t, =20 if (virDomainChrSourceDefParseXML(def->source.chardev, backends[0]->children, flags, - NULL, ctxt, NULL, 0) < 0) + NULL, ctxt) < 0) goto error; break; =20 @@ -15713,7 +15716,7 @@ virDomainRedirdevDefParseXML(virDomainXMLOptionPtr = xmlopt, /* boot gets parsed in virDomainDeviceInfoParseXML * source gets parsed in virDomainChrSourceDefParseXML */ if (virDomainChrSourceDefParseXML(def->source, cur, flags, - NULL, ctxt, NULL, 0) < 0) + NULL, ctxt) < 0) goto error; =20 if (def->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_SPICEVMC) @@ -16413,8 +16416,6 @@ virDomainDeviceDefParse(const char *xmlStr, switch ((virDomainDeviceType) dev->type) { case VIR_DOMAIN_DEVICE_DISK: if (!(dev->data.disk =3D virDomainDiskDefParseXML(xmlopt, node, ct= xt, - def->seclabels, - def->nseclabels, flags))) return NULL; break; @@ -16484,8 +16485,6 @@ virDomainDeviceDefParse(const char *xmlStr, if (!(dev->data.chr =3D virDomainChrDefParseXML(xmlopt, ctxt, node, - def->seclabels, - def->nseclabels, flags))) return NULL; break; @@ -16552,14 +16551,11 @@ virDomainDeviceDefParse(const char *xmlStr, =20 virDomainDiskDefPtr virDomainDiskDefParse(const char *xmlStr, - const virDomainDef *def, virDomainXMLOptionPtr xmlopt, unsigned int flags) { g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; - virSecurityLabelDefPtr *seclabels =3D NULL; - size_t nseclabels =3D 0; =20 if (!(xml =3D virXMLParseStringCtxt(xmlStr, _("(disk_definition)"), &c= txt))) return NULL; @@ -16571,13 +16567,7 @@ virDomainDiskDefParse(const char *xmlStr, return NULL; } =20 - if (def) { - seclabels =3D def->seclabels; - nseclabels =3D def->nseclabels; - } - - return virDomainDiskDefParseXML(xmlopt, ctxt->node, ctxt, - seclabels, nseclabels, flags); + return virDomainDiskDefParseXML(xmlopt, ctxt->node, ctxt, flags); } =20 =20 @@ -20767,8 +20757,6 @@ virDomainDefParseXML(xmlDocPtr xml, virDomainDiskDefPtr disk =3D virDomainDiskDefParseXML(xmlopt, nodes[i], ctxt, - def->seclabels, - def->nseclabel= s, flags); if (!disk) goto error; @@ -20919,8 +20907,6 @@ virDomainDefParseXML(xmlDocPtr xml, virDomainChrDefPtr chr =3D virDomainChrDefParseXML(xmlopt, ctxt, nodes[i], - def->seclabels, - def->nseclabels, flags); if (!chr) goto error; @@ -20947,8 +20933,6 @@ virDomainDefParseXML(xmlDocPtr xml, virDomainChrDefPtr chr =3D virDomainChrDefParseXML(xmlopt, ctxt, nodes[i], - def->seclabels, - def->nseclabels, flags); if (!chr) goto error; @@ -20977,8 +20961,6 @@ virDomainDefParseXML(xmlDocPtr xml, virDomainChrDefPtr chr =3D virDomainChrDefParseXML(xmlopt, ctxt, nodes[i], - def->seclabels, - def->nseclabels, flags); if (!chr) goto error; @@ -20997,8 +20979,6 @@ virDomainDefParseXML(xmlDocPtr xml, virDomainChrDefPtr chr =3D virDomainChrDefParseXML(xmlopt, ctxt, nodes[i], - def->seclabels, - def->nseclabels, flags); if (!chr) goto error; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 037cebae64..e85d3bd5b5 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3044,7 +3044,6 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(const c= har *xmlStr, void *parseOpaque, unsigned int flags); virDomainDiskDefPtr virDomainDiskDefParse(const char *xmlStr, - const virDomainDef *def, virDomainXMLOptionPtr xmlopt, unsigned int flags); virDomainDefPtr virDomainDefParseString(const char *xmlStr, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b274542c3e..891ca28d94 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18435,7 +18435,7 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *d= isk, const char *destxml, } } =20 - if (!(diskdef =3D virDomainDiskDefParse(destxml, vm->def, driver->xmlo= pt, + if (!(diskdef =3D virDomainDiskDefParse(destxml, driver->xmlopt, VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_DISK_SOURCE= ))) goto cleanup; diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index fcdbcefb5d..2c170548ec 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -200,7 +200,7 @@ testQemuDiskXMLToProps(const void *opaque) goto cleanup; =20 /* qemu stores node names in the status XML portion */ - if (!(disk =3D virDomainDiskDefParse(xmlstr, NULL, data->driver->xmlop= t, + if (!(disk =3D virDomainDiskDefParse(xmlstr, data->driver->xmlopt, VIR_DOMAIN_DEF_PARSE_STATUS))) goto cleanup; =20 --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 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=1575469310; cv=none; d=zohomail.com; s=zohoarc; b=CcsI/ZevXXAF6UdY7UnNtAkOBa1OJacQwpab/RnkS9iResRokbaXrBJ/vNDPv2sgbMsgL9rhyVFIw118TrZFuj78v5HGKMIPVW+rZJ5OT5u8Y699dQGEhmYhZasjiaGjpuc/SEJADMDZTQ7ULB63gTuSDIc9tUZDtMR3Q6Rvetk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469310; 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=+4KiFPeW+p9NMPe3AQl24sgm29Rd+fgvyGI34EZ9/sg=; b=dhKmlk1gb0XypLMyBFHZDYKF5uKfcwSJyW/RB0Zg88ltRsLhr5mcIBmxuhFO7uMwLNiYBRbNKrKQ/N73u6yAtZt8Nc3fM62rlfewI8q0uhkwofGGaFkjZSXb8SVYWT/KblEipeQqBYfzkW/cO9N/NbTXa7DRQFIHoI0sFNcpH+c= 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 1575469310970254.7605652442221; Wed, 4 Dec 2019 06:21:50 -0800 (PST) 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-336-nD_0-N0HO1Og7AmkPwQ41w-1; Wed, 04 Dec 2019 09:21:47 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E18858D093F; Wed, 4 Dec 2019 14:21:38 +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 B78ED19C6A; Wed, 4 Dec 2019 14:21:38 +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 1FB685BC19; Wed, 4 Dec 2019 14:21:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4ELVct008157 for ; Wed, 4 Dec 2019 09:21:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4E08D608F7; Wed, 4 Dec 2019 14:21:31 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4DC7E1D1; Wed, 4 Dec 2019 14:21:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469309; 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=+4KiFPeW+p9NMPe3AQl24sgm29Rd+fgvyGI34EZ9/sg=; b=QsDJrZPFrp75b9YsN0ct8PlnZyOXZ7KOr3AJMjB2PrBsi2Ku+ADgMf9WVVEsBT6ueurpB3 uAy4xjXxvLQ+jrJ/gQKiZcXWobpTkpCntcWs1JAAZqR+nUASN/sbtXhS5fKqUd1LLEOI4E 8hC8mHePczakMmTZxF/aZjhnZw2v3/I= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:20:53 +0000 Message-Id: <20191204142113.2961028-11-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 10/30] conf: pass default sec model in parser config 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.84 on 10.5.11.23 X-MC-Unique: nD_0-N0HO1Og7AmkPwQ41w-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Instead of using the virCapsPtr to get the default security model, pass this in via the parser config. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 14 +++++++------- src/conf/domain_conf.h | 1 + src/qemu/qemu_conf.c | 4 +++- src/qemu/qemu_conf.h | 3 ++- src/qemu/qemu_driver.c | 11 ++++++++++- tests/testutilsqemu.c | 2 +- 6 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f037702ac2..8acc91de74 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8911,13 +8911,12 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt, static int virSecurityLabelDefsParseXML(virDomainDefPtr def, xmlXPathContextPtr ctxt, - virCapsPtr caps, + virDomainXMLOptionPtr xmlopt, unsigned int flags) { VIR_XPATH_NODE_AUTORESTORE(ctxt); size_t i =3D 0, j; int n; - virCapsHostPtr host =3D &caps->host; g_autofree xmlNodePtr *list =3D NULL; =20 /* Allocate a security labels based on XML */ @@ -8960,15 +8959,16 @@ virSecurityLabelDefsParseXML(virDomainDefPtr def, */ if (def->nseclabels =3D=3D 1 && !def->seclabels[0]->model && - host->nsecModels > 0) { + xmlopt !=3D NULL && + xmlopt->config.defSecModel !=3D NULL) { if (def->seclabels[0]->type =3D=3D VIR_DOMAIN_SECLABEL_NONE || (def->seclabels[0]->type =3D=3D VIR_DOMAIN_SECLABEL_DYNAMIC && !def->seclabels[0]->baselabel && (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE))) { /* Copy model from host. */ VIR_DEBUG("Found seclabel without a model, using '%s'", - host->secModels[0].model); - def->seclabels[0]->model =3D g_strdup(host->secModels[0].model= ); + xmlopt->config.defSecModel); + def->seclabels[0]->model =3D g_strdup(xmlopt->config.defSecMod= el); =20 if (STREQ(def->seclabels[0]->model, "none") && flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) { @@ -19733,7 +19733,7 @@ virDomainMemorytuneDefParse(virDomainDefPtr def, static virDomainDefPtr virDomainDefParseXML(xmlDocPtr xml, xmlXPathContextPtr ctxt, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, virDomainXMLOptionPtr xmlopt, unsigned int flags) { @@ -19841,7 +19841,7 @@ virDomainDefParseXML(xmlDocPtr xml, /* analysis of security label, done early even though we format it * late, so devices can refer to this for defaults */ if (!(flags & VIR_DOMAIN_DEF_PARSE_SKIP_SECLABEL)) { - if (virSecurityLabelDefsParseXML(def, ctxt, caps, flags) =3D=3D -1) + if (virSecurityLabelDefsParseXML(def, ctxt, xmlopt, flags) =3D=3D = -1) goto error; } =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e85d3bd5b5..af57e288e9 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2707,6 +2707,7 @@ struct _virDomainDefParserConfig { unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN]; virArch defArch; const char *netPrefix; + const char *defSecModel; }; =20 typedef void *(*virDomainXMLPrivateDataAllocFunc)(void *); diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 53658c80e8..053bcc7e02 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1191,9 +1191,11 @@ virQEMUDriverIsPrivileged(virQEMUDriverPtr driver) } =20 virDomainXMLOptionPtr -virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver) +virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver, + const char *defsecmodel) { virQEMUDriverDomainDefParserConfig.priv =3D driver; + virQEMUDriverDomainDefParserConfig.defSecModel =3D defsecmodel; return virDomainXMLOptionNew(&virQEMUDriverDomainDefParserConfig, &virQEMUDriverPrivateDataCallbacks, &virQEMUDriverDomainXMLNamespace, diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 7c56226b8c..8b6c2a95d4 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -366,7 +366,8 @@ int qemuRemoveSharedDisk(virQEMUDriverPtr driver, int qemuSetUnprivSGIO(virDomainDeviceDefPtr dev); =20 int qemuDriverAllocateID(virQEMUDriverPtr driver); -virDomainXMLOptionPtr virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver); +virDomainXMLOptionPtr virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver, + const char *defsecmodel); =20 int qemuTranslateSnapshotDiskSourcePool(virDomainSnapshotDiskDefPtr def); =20 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 891ca28d94..93a92dad36 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -656,6 +656,8 @@ qemuStateInitialize(bool privileged, g_autofree char *memoryBackingPath =3D NULL; bool autostart =3D true; size_t i; + const char *defsecmodel =3D NULL; + g_autofree virSecurityManagerPtr *sec_managers =3D NULL; =20 if (VIR_ALLOC(qemu_driver) < 0) return VIR_DRV_STATE_INIT_ERROR; @@ -916,7 +918,14 @@ qemuStateInitialize(bool privileged, if ((qemu_driver->caps =3D virQEMUDriverCreateCapabilities(qemu_driver= )) =3D=3D NULL) goto error; =20 - if (!(qemu_driver->xmlopt =3D virQEMUDriverCreateXMLConf(qemu_driver))) + if (!(sec_managers =3D qemuSecurityGetNested(qemu_driver->securityMana= ger))) + goto error; + + if (sec_managers[0] !=3D NULL) + defsecmodel =3D qemuSecurityGetModel(sec_managers[0]); + + if (!(qemu_driver->xmlopt =3D virQEMUDriverCreateXMLConf(qemu_driver, + defsecmodel))) goto error; =20 /* If hugetlbfs is present, then we need to create a sub-directory wit= hin diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 0ca690a1ed..c24b3098a5 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -402,7 +402,7 @@ int qemuTestDriverInit(virQEMUDriver *driver) if (!driver->qemuCapsCache) goto error; =20 - driver->xmlopt =3D virQEMUDriverCreateXMLConf(driver); + driver->xmlopt =3D virQEMUDriverCreateXMLConf(driver, "none"); if (!driver->xmlopt) goto error; =20 --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 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=1575469391; cv=none; d=zohomail.com; s=zohoarc; b=Zk1nhDTt7EObq8HGzzU9kLT0tfaqHyB+lxyDoVNT2J7YT21mnnv5qz0iiB1MOBYsWdSAHYbdXy8pviRLnmU2Bg54yQmd3sRckjG5uDj4vEGXq7BTrzDdf2BtCJbTkPxGrXLIfFjSMDKwQDih4rd4LW55NRaHpwkltsRxAs7Kpi0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469391; 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=9DE8hzlyCNL/KBye1JE30+AsY842PDSRDQxJ/pyhkRA=; b=PzLwOEnmk8fCh6phNq69tQ6RVnj3deT3FfQ32fn/4E2W3y2y/DtVF2aJGtZeUDRmleidDT1ZzOZuAa/qOiqk1+G+kYc3wuSOt7qLp/0JIX5OwkeDrnvXdRllPzwWEnNoNpF+Qyk21WmWCfZFhXfoL5BK9+gzKDX4oyGHXDX7F8U= 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 1575469391128484.21333579303575; Wed, 4 Dec 2019 06:23:11 -0800 (PST) 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-19-4I9Zdg5BMV2Sp1zIZtrPtw-1; Wed, 04 Dec 2019 09:21:52 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3820E100EC09; Wed, 4 Dec 2019 14:21: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 097E819C7F; Wed, 4 Dec 2019 14:21: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 B3E99180887A; Wed, 4 Dec 2019 14:21:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4ELWnZ008166 for ; Wed, 4 Dec 2019 09:21:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id B7D54608F7; Wed, 4 Dec 2019 14:21:32 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id B3284691A3; Wed, 4 Dec 2019 14:21:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469389; 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=9DE8hzlyCNL/KBye1JE30+AsY842PDSRDQxJ/pyhkRA=; b=S6Mvkh/V8d+VGcl52bk85Yh67RCVrbKCPDSrmm+KStuxMk/GirQtdzKipa4+GrgpWB8JtV H77d6dQWAvsQZzfqOMLaIlLwQiTA2uZalDlyJkgeqoKWQCl5PkhjQZcj9h9itufDvwb8qC 9riPoaYflSk+3ngIskH/DVnqFF0bDnw= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:20:54 +0000 Message-Id: <20191204142113.2961028-12-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 11/30] conf: drop virCapsPtr param from assign addresses callback 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.84 on 10.5.11.23 X-MC-Unique: 4I9Zdg5BMV2Sp1zIZtrPtw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The virCapsPtr param is not used by any of the virt drivers providing this callback. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/bhyve/bhyve_domain.c | 1 - src/conf/domain_conf.c | 2 +- src/conf/domain_conf.h | 1 - src/qemu/qemu_domain.c | 1 - 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c index eebf5a7650..a321be54f4 100644 --- a/src/bhyve/bhyve_domain.c +++ b/src/bhyve/bhyve_domain.c @@ -167,7 +167,6 @@ bhyveDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, =20 static int bhyveDomainDefAssignAddresses(virDomainDef *def, - virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED, void *parseOpaque G_GNUC_UNUSED) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8acc91de74..8dd1ff1017 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5870,7 +5870,7 @@ virDomainDefPostParse(virDomainDefPtr def, goto cleanup; =20 if (xmlopt->config.assignAddressesCallback) { - ret =3D xmlopt->config.assignAddressesCallback(def, caps, parseFla= gs, + ret =3D xmlopt->config.assignAddressesCallback(def, parseFlags, xmlopt->config.priv, data.parseOpaque); if (virDomainDefPostParseCheckFailure(def, parseFlags, ret) < 0) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index af57e288e9..7e925f45d8 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2660,7 +2660,6 @@ typedef int (*virDomainDeviceDefPostParseCallback)(vi= rDomainDeviceDefPtr dev, * @opaque is opaque data set by driver (usually pointer to driver * private data). */ typedef int (*virDomainDefAssignAddressesCallback)(virDomainDef *def, - virCapsPtr caps, unsigned int parseFlags, void *opaque, void *parseOpaque); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0076349558..362d644475 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8116,7 +8116,6 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr de= v, =20 static int qemuDomainDefAssignAddresses(virDomainDef *def, - virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags G_GNUC_UNUSED, void *opaque, void *parseOpaque) --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 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=1575469322; cv=none; d=zohomail.com; s=zohoarc; b=SBQWGWZnwXX36xjcoM4XTkQC9y8n+QOCv94R6gLYj6wVnlpdzNi+zYarMlRwstrlTPZB26HzPPShM4YUu4LsGyj9fvkZlgQsN2+qCg1fm1VEyK0uqVQ7m3zO9twYpeZJVNCRKQS1JosOlfL11VeGwDlLR41QGp6DZkqY2wcRpl0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469322; 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=wEEkExoeUac8IQYTup2DTMvUu/Y/C+X9uJbBlv3sEPE=; b=h3v6QY1fI8MlmTojbbDi71uEYdj9SVhyScyiR9E111gCYsE8pFbC1ZXKzBXBI1A4rTjmUQG7Ea5nomadbZvR8qyeEF+sysnMMC1Rd4lCocFJpgSjf4FRR4xStYlXI5tVQwGI7+Z7VFEyUjUGvZwFDWr6NSZaxFdegyZyg2xNlcU= 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-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1575469322462551.6645859163477; Wed, 4 Dec 2019 06:22:02 -0800 (PST) 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-257-5RuDMxZUNUqT9evHDVUimQ-1; Wed, 04 Dec 2019 09:21:59 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9FEBE8D0931; Wed, 4 Dec 2019 14:21:52 +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 7355719C68; Wed, 4 Dec 2019 14:21:52 +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 331CF62D12; Wed, 4 Dec 2019 14:21:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4ELaXv008185 for ; Wed, 4 Dec 2019 09:21:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9CDCD691A2; Wed, 4 Dec 2019 14:21:36 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE7DD67E62; Wed, 4 Dec 2019 14:21:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469321; 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=wEEkExoeUac8IQYTup2DTMvUu/Y/C+X9uJbBlv3sEPE=; b=R/ohDAxQ1+fcWlgXem9E/R30mW9O+gSOpbSqidCpbXHRRR3ExEJ8gYpMtJHwWlHj+D+F/o 6PaD1VxSXMeFNFva+6cDjbJY+jfDGfvHCyj3ClmCid9oVaCZj5NHEkkqcUrofJg6OR4Zn0 vCu+P+kWRHs/ptOKUGVnvVnOPMQHZ/o= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:20:55 +0000 Message-Id: <20191204142113.2961028-13-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 12/30] conf: drop virCapsPtr param from basic post parse callback 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.84 on 10.5.11.23 X-MC-Unique: 5RuDMxZUNUqT9evHDVUimQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The QEMU impl of the callback can directly use the QEMU capabilities cache to resolve the emulator binary name, allowing virCapsPtr to be dropped. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 2 +- src/conf/domain_conf.h | 1 - src/qemu/qemu_capabilities.c | 28 ++++++++++++++++++++-------- src/qemu/qemu_capabilities.h | 2 ++ src/qemu/qemu_domain.c | 11 +++++++---- tests/testutilsqemu.c | 16 ++++++++++++++++ 6 files changed, 46 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8dd1ff1017..7327752810 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5824,7 +5824,7 @@ virDomainDefPostParse(virDomainDefPtr def, =20 /* call the basic post parse callback */ if (xmlopt->config.domainPostParseBasicCallback) { - ret =3D xmlopt->config.domainPostParseBasicCallback(def, caps, + ret =3D xmlopt->config.domainPostParseBasicCallback(def, xmlopt->config.p= riv); =20 if (virDomainDefPostParseCheckFailure(def, parseFlags, ret) < 0) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 7e925f45d8..cdbd42351f 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2627,7 +2627,6 @@ typedef enum { * parseOpaque is used. This callback is run prior to * virDomainDefPostParseCallback. */ typedef int (*virDomainDefPostParseBasicCallback)(virDomainDefPtr def, - virCapsPtr caps, void *opaque); =20 /* Called once after everything else has been parsed, for adjusting diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 7a62dfb1a2..bfe59a1eff 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -799,16 +799,12 @@ virQEMUCapsFindBinaryForArch(virArch hostarch, return ret; } =20 -static int -virQEMUCapsInitGuest(virCapsPtr caps, - virFileCachePtr cache, - virArch hostarch, - virArch guestarch) + +char * +virQEMUCapsGetDefaultEmulator(virArch hostarch, + virArch guestarch) { char *binary =3D NULL; - virQEMUCapsPtr qemuCaps =3D NULL; - int ret =3D -1; - /* Check for existence of base emulator, or alternate base * which can be used with magic cpu choice */ @@ -819,6 +815,22 @@ virQEMUCapsInitGuest(virCapsPtr caps, if (virQEMUCapsGuestIsNative(hostarch, guestarch) && !binary) binary =3D g_strdup("/usr/libexec/qemu-kvm"); =20 + return binary; +} + + +static int +virQEMUCapsInitGuest(virCapsPtr caps, + virFileCachePtr cache, + virArch hostarch, + virArch guestarch) +{ + char *binary =3D NULL; + virQEMUCapsPtr qemuCaps =3D NULL; + int ret =3D -1; + + binary =3D virQEMUCapsGetDefaultEmulator(hostarch, guestarch); + /* Ignore binary if extracting version info fails */ if (binary) { if (!(qemuCaps =3D virQEMUCapsCacheLookup(cache, binary))) { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index a8a5c38d73..9b380574f5 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -627,6 +627,8 @@ const char *virQEMUCapsGetMachineDefaultCPU(virQEMUCaps= Ptr qemuCaps, void virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps, virDomainVirtType virtType, const char *machineType); +char * virQEMUCapsGetDefaultEmulator(virArch hostarch, + virArch guestarch); =20 virFileCachePtr virQEMUCapsCacheNew(const char *libDir, const char *cacheDir, diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 362d644475..3c06b8a104 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4677,13 +4677,16 @@ qemuDomainDefTsegPostParse(virDomainDefPtr def, =20 static int qemuDomainDefPostParseBasic(virDomainDefPtr def, - virCapsPtr caps, void *opaque G_GNUC_UNUSED) { + virQEMUDriverPtr driver =3D opaque; + /* check for emulator and create a default one if needed */ - if (!def->emulator && - !(def->emulator =3D virDomainDefGetDefaultEmulator(def, caps))) - return 1; + if (!def->emulator) { + if (!(def->emulator =3D virQEMUCapsGetDefaultEmulator( + driver->hostarch, def->os.arch))) + return 1; + } =20 return 0; } diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index c24b3098a5..38be2cfe42 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -93,6 +93,22 @@ static const char *const *kvm_machines[VIR_ARCH_LAST] = =3D { [VIR_ARCH_S390X] =3D s390x_machines, }; =20 + +char * +virFindFileInPath(const char *file) +{ + if (g_str_has_prefix(file, "qemu-system") || + g_str_equal(file, "qemu-kvm")) { + return g_strdup_printf("/usr/bin/%s", file); + } + + /* Nothing in tests should be relying on real files + * in host OS, so we return NULL as to try to force + * an error in such a case + */ + return NULL; +} + static int testQemuAddGuest(virCapsPtr caps, virArch arch) --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 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=1575469401; cv=none; d=zohomail.com; s=zohoarc; b=mwtTfzfhLuax9ikpjTzxygCjqLZ1V8ALwDowUu38QbZl77okcurasV09r2LGUtqWUp7hLKBTZ54jbI+3iTaX15xsDIjSqsOQz412kg1yaOY5PimMh1jTUB+rR/QCG+pXpO1RZ5Pjf964yLnLZBhQZFRnEbKgojLDdBUBSQfK1EY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469401; 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=5p85a/JdZUwqBkViMqLvrTQLf6TwHblbkD0jXPB8yEM=; b=H6cYcEwC3nTyCuQzEUADCYknAb1reobSafXgcSTT1KMAdra43eDy4cLMbcie5UD3zHcxQmj4ZjzqnU3ZzfrWqNMEgR2UKVGXuuzzoaw2OiZZ3FhEEFsrzCU7gP+m26NflCU5Wonwl8CSBMd6NRTY2hI3w2k5KLy6Eilt596TTuE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1575469401237177.71919601214074; Wed, 4 Dec 2019 06:23:21 -0800 (PST) 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-65-b0j0o0DVPS2wNe2N1ATJMQ-1; Wed, 04 Dec 2019 09:21:55 -0500 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 A7CE1107ACFE; Wed, 4 Dec 2019 14:21: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 8467367E62; Wed, 4 Dec 2019 14:21: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 3C8361800B6F; Wed, 4 Dec 2019 14:21:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4ELbJb008193 for ; Wed, 4 Dec 2019 09:21:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id B9FF8691A7; Wed, 4 Dec 2019 14:21:37 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED49E67E62; Wed, 4 Dec 2019 14:21:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469400; 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=5p85a/JdZUwqBkViMqLvrTQLf6TwHblbkD0jXPB8yEM=; b=d8bDd58BALcc7z68Bw+c/400wN/cX6qr+trXnzw8slT/qGIWu1tUN8lplDBmLs4kJtPRaD WIQQ8u5Pc41/AHdXEECtn9LzLeBozdQ6fQbfnIxQ50u7gt4K04Q2wIzSYZKJmaZ1gvNreI gUge5DHDGmBhV+Ia7XpvcZR5jtolnqE= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:20:56 +0000 Message-Id: <20191204142113.2961028-14-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 13/30] conf: drop virCapsPtr param from post parse data alloc callback 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-MC-Unique: b0j0o0DVPS2wNe2N1ATJMQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The only user of this callback did not require the virCapsPtr parameter. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 4 ++-- src/conf/domain_conf.h | 1 - src/qemu/qemu_domain.c | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7327752810..164c313ac6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5498,7 +5498,7 @@ virDomainDeviceDefPostParseOne(virDomainDeviceDefPtr = dev, int ret; =20 if (!parseOpaque && xmlopt->config.domainPostParseDataAlloc) { - if (xmlopt->config.domainPostParseDataAlloc(def, caps, flags, + if (xmlopt->config.domainPostParseDataAlloc(def, flags, xmlopt->config.priv, &data) < 0) return -1; @@ -5833,7 +5833,7 @@ virDomainDefPostParse(virDomainDefPtr def, =20 if (!data.parseOpaque && xmlopt->config.domainPostParseDataAlloc) { - ret =3D xmlopt->config.domainPostParseDataAlloc(def, caps, parseFl= ags, + ret =3D xmlopt->config.domainPostParseDataAlloc(def, parseFlags, xmlopt->config.priv, &data.parseOpaque); =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index cdbd42351f..86d0b47a66 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2664,7 +2664,6 @@ typedef int (*virDomainDefAssignAddressesCallback)(vi= rDomainDef *def, void *parseOpaque); =20 typedef int (*virDomainDefPostParseDataAlloc)(const virDomainDef *def, - virCapsPtr caps, unsigned int parseFlags, void *opaque, void **parseOpaque); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 3c06b8a104..70683eb83a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8143,7 +8143,6 @@ qemuDomainDefAssignAddresses(virDomainDef *def, =20 static int qemuDomainPostParseDataAlloc(const virDomainDef *def, - virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags G_GNUC_UNUSED, void *opaque, void **parseOpaque) --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.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 207.211.31.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=1575469312; cv=none; d=zohomail.com; s=zohoarc; b=j8LkJOfDX1J8BCvQ3eeXUbU/U2fPl1FeOwaZ2XPEl6QuwVi+APco5dkYJGgc9tQJ8NKcKlNTDOQAIA6/0XED6cwOCWsFTNMNScmSqbe7Hy924GfmBmCrcbA1lkjPYvo4KNIOCz7fdTOlAYloRY/tzfAsvvApZi10Ne+OTdlwFvo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469312; 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=a0RHTFPNcdAXADPJm6UOoG+nCL8oC6PPzJFhbsGgIdg=; b=mX+9jHtQhOKOSGVcrCzavdAdD+JxLQMlsRkPUfnE7UIpZgxMhqj6nKBHveLTmgh9GF/JeDDRwhrhBSmXSogrseHEpA55y6zTsuARSu/M96lAFxW7nDCexKnrgvDN/YsFabdktuTKLpmjXMFeLhsOcjJG18CUv9AHrLFtSJW71I8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.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 [207.211.31.120]) by mx.zohomail.com with SMTPS id 1575469312544393.86613417165347; Wed, 4 Dec 2019 06:21:52 -0800 (PST) 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-21-fBp0fQOiMN2K27HejIVWRA-1; Wed, 04 Dec 2019 09:21:48 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 389678CAFAF; Wed, 4 Dec 2019 14:21:42 +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 0D51B60FC2; Wed, 4 Dec 2019 14:21:42 +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 BCBD75BC1A; Wed, 4 Dec 2019 14:21:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4ELd10008203 for ; Wed, 4 Dec 2019 09:21:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1932E67E62; Wed, 4 Dec 2019 14:21:39 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 27BD7691A2; Wed, 4 Dec 2019 14:21:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469311; 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=a0RHTFPNcdAXADPJm6UOoG+nCL8oC6PPzJFhbsGgIdg=; b=BHwow0XXyXqZjaKCuduX2ONJ+gs7CHSJCs73RUNUdmxfG5W64i5OAg+/7jNHy29RpPNx+P ecJmysvABtI9JgRxleumFBMWss6HJQH0hv5KK0L8zsUmKfIYyP0SuehfHtnt58VUz7cNrL cYAPS6pLlfFS7q5OAXZVu/y16gPX/FI= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:20:57 +0000 Message-Id: <20191204142113.2961028-15-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 14/30] conf: drop virCapsPtr param from post parse callback 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.12 X-MC-Unique: fBp0fQOiMN2K27HejIVWRA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) No impl of this callback requires the virCapsPtr anymore. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/bhyve/bhyve_domain.c | 1 - src/conf/domain_conf.c | 2 +- src/conf/domain_conf.h | 1 - src/libxl/libxl_domain.c | 1 - src/lxc/lxc_domain.c | 1 - src/openvz/openvz_conf.c | 1 - src/phyp/phyp_driver.c | 1 - src/qemu/qemu_domain.c | 1 - src/vmware/vmware_driver.c | 1 - src/vmx/vmx.c | 1 - src/vz/vz_driver.c | 1 - 11 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c index a321be54f4..c8d33b4e00 100644 --- a/src/bhyve/bhyve_domain.c +++ b/src/bhyve/bhyve_domain.c @@ -75,7 +75,6 @@ bhyveDomainDefNeedsISAController(virDomainDefPtr def) =20 static int bhyveDomainDefPostParse(virDomainDefPtr def, - virCapsPtr _caps G_GNUC_UNUSED, unsigned int parseFlags G_GNUC_UNUSED, void *opaque, void *parseOpaque G_GNUC_UNUSED) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 164c313ac6..f2452f6df2 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5849,7 +5849,7 @@ virDomainDefPostParse(virDomainDefPtr def, =20 /* call the domain config callback */ if (xmlopt->config.domainPostParseCallback) { - ret =3D xmlopt->config.domainPostParseCallback(def, caps, parseFla= gs, + ret =3D xmlopt->config.domainPostParseCallback(def, parseFlags, xmlopt->config.priv, data.parseOpaque); if (virDomainDefPostParseCheckFailure(def, parseFlags, ret) < 0) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 86d0b47a66..7a5bfd00ed 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2638,7 +2638,6 @@ typedef int (*virDomainDefPostParseBasicCallback)(vir= DomainDefPtr def, * value and the failure is noted in def->postParseFailed. Drivers should = then * re-run the post parse callback when attempting to use such definition. = */ typedef int (*virDomainDefPostParseCallback)(virDomainDefPtr def, - virCapsPtr caps, unsigned int parseFlags, void *opaque, void *parseOpaque); diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index dfac04bf59..2524d17eb4 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -367,7 +367,6 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, =20 static int libxlDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags G_GNUC_UNUSED, void *opaque, void *parseOpaque G_GNUC_UNUSED) diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c index bc54beeadf..8b27bc95af 100644 --- a/src/lxc/lxc_domain.c +++ b/src/lxc/lxc_domain.c @@ -351,7 +351,6 @@ virDomainXMLPrivateDataCallbacks virLXCDriverPrivateDat= aCallbacks =3D { =20 static int virLXCDomainDefPostParse(virDomainDefPtr def, - virCapsPtr _caps G_GNUC_UNUSED, unsigned int parseFlags G_GNUC_UNUSED, void *opaque, void *parseOpaque G_GNUC_UNUSED) diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 5060e704a5..5057f9652e 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -1082,7 +1082,6 @@ int openvzGetVEID(const char *name) =20 static int openvzDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags G_GNUC_UNUSED, void *opaque, void *parseOpaque G_GNUC_UNUSED) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 05860b7dbe..3c809378c3 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -1062,7 +1062,6 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr = auth, =20 static int phypDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags G_GNUC_UNUSED, void *opaque, void *parseOpaque G_GNUC_UNUSED) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 70683eb83a..6aa50dda0b 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4694,7 +4694,6 @@ qemuDomainDefPostParseBasic(virDomainDefPtr def, =20 static int qemuDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags, void *opaque, void *parseOpaque G_GNUC_UNUSED) diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index 308a941f8a..301f43d9e8 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -117,7 +117,6 @@ vmwareDataFreeFunc(void *data) =20 static int vmwareDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED, void *parseOpaque G_GNUC_UNUSED) diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 958b168891..3f8324ce89 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -530,7 +530,6 @@ VIR_ENUM_IMPL(virVMXControllerModelSCSI, =20 static int virVMXDomainDefPostParse(virDomainDefPtr def, - virCapsPtr _caps G_GNUC_UNUSED, unsigned int parseFlags G_GNUC_UNUSED, void *opaque, void *parseOpaque G_GNUC_UNUSED) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index a0d1efb9dd..f54bdd49db 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -241,7 +241,6 @@ vzDomainDefAddDefaultInputDevices(virDomainDefPtr def) =20 static int vzDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags G_GNUC_UNUSED, void *opaque, void *parseOpaque G_GNUC_UNUSED) --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.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 207.211.31.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=1575469322; cv=none; d=zohomail.com; s=zohoarc; b=RXzLd62TPxWL0Jo1Np5RbeuUl5NmYiw2m750gR547RGdt2o+iRttGt6ychxJ9NrXNUq09/6Ts/1Z0T3JuBBOaGvp02ngyFGCbpEakvzkuXCLdxnGJ6wqAK81QZfFGsJoEEfnPmX/01T26m6PE4Zgmxy9aAwbRgkx4JiyCnEBtPc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469322; 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=LzymBfJZybVXrRs44UmaR0wK35JnSnwXy4AnQpvDVcM=; b=Md8AXH0hBdr+2kouRD+0+GUaovG0Cgn4wpZCe9lXvxdVvwVPSv2H0YZ0zEO6XgnsF/IjRo+Kzcl4GiDqirtNJ+qgOrcn+ESr1GfjXa/DM73EQ5iP0oOy0O4F0E2ApAMQp5XbsoMG4jfmMTHbV19t61gFz7NWwjC9BGb1UJ9om1Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.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 [207.211.31.120]) by mx.zohomail.com with SMTPS id 1575469322607534.4567031141585; Wed, 4 Dec 2019 06:22:02 -0800 (PST) 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-379-oHLe7A6RNiaWQjM-tnoJSw-1; Wed, 04 Dec 2019 09:21:59 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7F3498D092C; Wed, 4 Dec 2019 14:21: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 5AD53600CE; Wed, 4 Dec 2019 14:21: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 171411803C38; Wed, 4 Dec 2019 14:21:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4ELeCP008213 for ; Wed, 4 Dec 2019 09:21:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id 57E3C67E62; Wed, 4 Dec 2019 14:21:40 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 771A1691B2; Wed, 4 Dec 2019 14:21:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469321; 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=LzymBfJZybVXrRs44UmaR0wK35JnSnwXy4AnQpvDVcM=; b=TYiGkHsNsrkSNyh/ATaqvHym2ph/Mb9bQkOgPBZCv2AtUYtSwdjqFJPICNGYlZuXhDvNv6 SlKWdV3JNC7nMtj9DeufJtY8/qNY8rGhcI3uQv2bxVccK85Kp6ua5I1M+PBhrKeWEU5YgU L+evb0Uxa9QfJSrGX8mbNAoJWjuFVl0= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:20:58 +0000 Message-Id: <20191204142113.2961028-16-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 15/30] conf: drop virCapsPtr param from device post parse callback 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.11 X-MC-Unique: oHLe7A6RNiaWQjM-tnoJSw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) None of the impls of this callback require the virCapsPtr param. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/bhyve/bhyve_domain.c | 1 - src/conf/domain_conf.c | 20 +++++++------------- src/conf/domain_conf.h | 1 - src/libxl/libxl_domain.c | 1 - src/lxc/lxc_domain.c | 1 - src/openvz/openvz_conf.c | 1 - src/phyp/phyp_driver.c | 1 - src/qemu/qemu_domain.c | 1 - src/vmware/vmware_driver.c | 1 - src/vmx/vmx.c | 1 - src/vz/vz_driver.c | 1 - 11 files changed, 7 insertions(+), 23 deletions(-) diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c index c8d33b4e00..82910ea261 100644 --- a/src/bhyve/bhyve_domain.c +++ b/src/bhyve/bhyve_domain.c @@ -132,7 +132,6 @@ bhyveDomainDiskDefAssignAddress(bhyveConnPtr driver, static int bhyveDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, const virDomainDef *def, - virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags G_GNUC_UNUSED, void *opaque, void *parseOpaque G_GNUC_UNUSED) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f2452f6df2..ef6c8d3f75 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5207,7 +5207,6 @@ virDomainVsockDefPostParse(virDomainVsockDefPtr vsock) static int virDomainDeviceDefPostParseCommon(virDomainDeviceDefPtr dev, const virDomainDef *def, - virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags G_GNUC_UNUSED, virDomainXMLOptionPtr xmlopt) { @@ -5462,7 +5461,6 @@ virDomainDeviceDefPostParseCheckFeatures(virDomainDev= iceDefPtr dev, static int virDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, const virDomainDef *def, - virCapsPtr caps, unsigned int flags, virDomainXMLOptionPtr xmlopt, void *parseOpaque) @@ -5470,14 +5468,14 @@ virDomainDeviceDefPostParse(virDomainDeviceDefPtr d= ev, int ret; =20 if (xmlopt->config.devicesPostParseCallback) { - ret =3D xmlopt->config.devicesPostParseCallback(dev, def, caps, fl= ags, + ret =3D xmlopt->config.devicesPostParseCallback(dev, def, flags, xmlopt->config.priv, parseOpaque); if (ret < 0) return ret; } =20 - if ((ret =3D virDomainDeviceDefPostParseCommon(dev, def, caps, flags, = xmlopt)) < 0) + if ((ret =3D virDomainDeviceDefPostParseCommon(dev, def, flags, xmlopt= )) < 0) return ret; =20 if (virDomainDeviceDefPostParseCheckFeatures(dev, xmlopt) < 0) @@ -5489,7 +5487,6 @@ virDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, static int virDomainDeviceDefPostParseOne(virDomainDeviceDefPtr dev, const virDomainDef *def, - virCapsPtr caps, unsigned int flags, virDomainXMLOptionPtr xmlopt, void *parseOpaque) @@ -5505,7 +5502,7 @@ virDomainDeviceDefPostParseOne(virDomainDeviceDefPtr = dev, parseOpaque =3D data; } =20 - ret =3D virDomainDeviceDefPostParse(dev, def, caps, flags, xmlopt, par= seOpaque); + ret =3D virDomainDeviceDefPostParse(dev, def, flags, xmlopt, parseOpaq= ue); =20 if (data && xmlopt->config.domainPostParseDataFree) xmlopt->config.domainPostParseDataFree(data); @@ -5515,7 +5512,6 @@ virDomainDeviceDefPostParseOne(virDomainDeviceDefPtr = dev, =20 =20 struct virDomainDefPostParseDeviceIteratorData { - virCapsPtr caps; virDomainXMLOptionPtr xmlopt; void *parseOpaque; unsigned int parseFlags; @@ -5529,7 +5525,7 @@ virDomainDefPostParseDeviceIterator(virDomainDefPtr d= ef, void *opaque) { struct virDomainDefPostParseDeviceIteratorData *data =3D opaque; - return virDomainDeviceDefPostParse(dev, def, data->caps, + return virDomainDeviceDefPostParse(dev, def, data->parseFlags, data->xmlopt, data->parseOpaque); } @@ -5806,7 +5802,7 @@ virDomainDefPostParseCheckFailure(virDomainDefPtr def, =20 int virDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags, virDomainXMLOptionPtr xmlopt, void *parseOpaque) @@ -5814,7 +5810,6 @@ virDomainDefPostParse(virDomainDefPtr def, int ret =3D -1; bool localParseOpaque =3D false; struct virDomainDefPostParseDeviceIteratorData data =3D { - .caps =3D caps, .xmlopt =3D xmlopt, .parseFlags =3D parseFlags, .parseOpaque =3D parseOpaque, @@ -7117,7 +7112,6 @@ virDomainDefValidate(virDomainDefPtr def, virDomainXMLOptionPtr xmlopt) { struct virDomainDefPostParseDeviceIteratorData data =3D { - .caps =3D caps, .xmlopt =3D xmlopt, .parseFlags =3D parseFlags, }; @@ -16379,7 +16373,7 @@ virDomainVsockDefParseXML(virDomainXMLOptionPtr xml= opt, virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr, const virDomainDef *def, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, virDomainXMLOptionPtr xmlopt, void *parseOpaque, unsigned int flags) @@ -16537,7 +16531,7 @@ virDomainDeviceDefParse(const char *xmlStr, } =20 /* callback to fill driver specific device aspects */ - if (virDomainDeviceDefPostParseOne(dev, def, caps, flags, + if (virDomainDeviceDefPostParseOne(dev, def, flags, xmlopt, parseOpaque) < 0) return NULL; =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 7a5bfd00ed..9864296be1 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2648,7 +2648,6 @@ typedef int (*virDomainDefPostParseCallback)(virDomai= nDefPtr def, * private data). */ typedef int (*virDomainDeviceDefPostParseCallback)(virDomainDeviceDefPtr d= ev, const virDomainDef *def, - virCapsPtr caps, unsigned int parseFlags, void *opaque, void *parseOpaque); diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 2524d17eb4..dfc8d8b611 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -278,7 +278,6 @@ virDomainXMLPrivateDataCallbacks libxlDomainXMLPrivateD= ataCallbacks =3D { static int libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, const virDomainDef *def, - virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED, void *parseOpaque G_GNUC_UNUSED) diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c index 8b27bc95af..2439ec4f4b 100644 --- a/src/lxc/lxc_domain.c +++ b/src/lxc/lxc_domain.c @@ -376,7 +376,6 @@ virLXCDomainDefPostParse(virDomainDefPtr def, static int virLXCDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, const virDomainDef *def G_GNUC_UNUSED, - virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED, void *parseOpaque G_GNUC_UNUSED) diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 5057f9652e..a15d68d37f 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -1103,7 +1103,6 @@ openvzDomainDefPostParse(virDomainDefPtr def, static int openvzDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, const virDomainDef *def G_GNUC_UNUSED, - virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED, void *parseOpaque G_GNUC_UNUSED) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 3c809378c3..b22063642e 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -1079,7 +1079,6 @@ phypDomainDefPostParse(virDomainDefPtr def, static int phypDomainDeviceDefPostParse(virDomainDeviceDefPtr dev G_GNUC_UNUSED, const virDomainDef *def G_GNUC_UNUSED, - virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED, void *parseOpaque G_GNUC_UNUSED) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6aa50dda0b..8ac6a0f842 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8032,7 +8032,6 @@ qemuDomainHostdevDefPostParse(virDomainHostdevDefPtr = hostdev, static int qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, const virDomainDef *def, - virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags, void *opaque, void *parseOpaque) diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index 301f43d9e8..eb2fcd438b 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -133,7 +133,6 @@ vmwareDomainDefPostParse(virDomainDefPtr def, static int vmwareDomainDeviceDefPostParse(virDomainDeviceDefPtr dev G_GNUC_UNUSED, const virDomainDef *def G_GNUC_UNUSED, - virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED, void *parseOpaque G_GNUC_UNUSED) diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 3f8324ce89..093092b701 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -546,7 +546,6 @@ virVMXDomainDefPostParse(virDomainDefPtr def, static int virVMXDomainDevicesDefPostParse(virDomainDeviceDefPtr dev G_GNUC_UNUSED, const virDomainDef *def G_GNUC_UNUSED, - virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED, void *parseOpaque G_GNUC_UNUSED) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index f54bdd49db..78aa85825a 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -271,7 +271,6 @@ vzDomainDefValidate(const virDomainDef *def, static int vzDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, const virDomainDef *def, - virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED, void *parseOpaque G_GNUC_UNUSED) --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.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 207.211.31.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=1575469322; cv=none; d=zohomail.com; s=zohoarc; b=S4asxGaxiaYI92IBqaGmn7DCZBF3z0gRnAWw6svnsBBfJVWwrnMrzmxWyrapFmRaFdjNe2siSNlLHZ0je58hfNGE2eBzz1AGW8kqZqKt06Po7DxrpkHqLjxjk7RQa1p79LgvZpWS85DBzZ57LMOmmvyUlDttPk7t6QD9DaMOi/I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469322; 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=FXhCmmhQIIHiXhErMb/UQcUEWjdAHcrBK8odTrXlFFo=; b=LoXduel5vRL3MG55+Fjv6boLAYock/egXXTe5fjH+HFR5Vzzwl4LxqeEifuvo79wtiw4BsxRSGdd/JeQjhg4Ph0M2pbyF953ScmfsvrUOCPWAnEt8G2TzcfhrP2rn69Ipq5FTk2W2W4FcgaMOYzdTjTbFPNxmBNYpityaQO4ovc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.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 [207.211.31.120]) by mx.zohomail.com with SMTPS id 1575469322019451.8557000649654; Wed, 4 Dec 2019 06:22:02 -0800 (PST) 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-429-mjZMzMuhOWGma-WR-J5Lag-1; Wed, 04 Dec 2019 09:21:56 -0500 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 140508D0935; Wed, 4 Dec 2019 14:21:47 +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 DF146694A3; Wed, 4 Dec 2019 14:21:46 +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 9074C5FBF0; Wed, 4 Dec 2019 14:21:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4ELfPi008224 for ; Wed, 4 Dec 2019 09:21:41 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8A5B1691A2; Wed, 4 Dec 2019 14:21:41 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id B0437608F7; Wed, 4 Dec 2019 14:21:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469320; 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=FXhCmmhQIIHiXhErMb/UQcUEWjdAHcrBK8odTrXlFFo=; b=GAFcPpezmFVWlZior76z2LGaaHeSpcKAjHnm2wJ6kLZ+CipTDhIwRiUqIB5whMdQkOFa3F ZmpoNy4it787dmCcyjdq1mAiuUmE7jAlD9iaSOz9u0gYd0L7w9O4wj8N/mK2iR9dI/VT8B vwXV31dKw+BlJse5soiHifCvZSrksgE= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:20:59 +0000 Message-Id: <20191204142113.2961028-17-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 16/30] conf: drop virCapsPtr param from domain validate callback 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-MC-Unique: mjZMzMuhOWGma-WR-J5Lag-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) None of the impls of this callback require the virCapsPtr param. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 4 ++-- src/conf/domain_conf.h | 1 - src/qemu/qemu_domain.c | 1 - src/vz/vz_driver.c | 1 - 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ef6c8d3f75..7431aad0cf 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7107,7 +7107,7 @@ virDomainDefValidateInternal(const virDomainDef *def, */ int virDomainDefValidate(virDomainDefPtr def, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags, virDomainXMLOptionPtr xmlopt) { @@ -7122,7 +7122,7 @@ virDomainDefValidate(virDomainDefPtr def, =20 /* call the domain config callback */ if (xmlopt->config.domainValidateCallback && - xmlopt->config.domainValidateCallback(def, caps, xmlopt->config.pr= iv) < 0) + xmlopt->config.domainValidateCallback(def, xmlopt->config.priv) < = 0) return -1; =20 /* iterate the devices */ diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 9864296be1..bbe73f1182 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2671,7 +2671,6 @@ typedef void (*virDomainDefPostParseDataFree)(void *p= arseOpaque); * for configurations that were previously accepted. This shall not modify= the * config. */ typedef int (*virDomainDefValidateCallback)(const virDomainDef *def, - virCapsPtr caps, void *opaque); =20 /* Called once per device, for adjusting per-device settings while diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 8ac6a0f842..49b6008d5c 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4972,7 +4972,6 @@ qemuDomainValidateCpuCount(const virDomainDef *def, =20 static int qemuDomainDefValidate(const virDomainDef *def, - virCapsPtr caps G_GNUC_UNUSED, void *opaque) { virQEMUDriverPtr driver =3D opaque; diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 78aa85825a..35baab1b82 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -259,7 +259,6 @@ vzDomainDefPostParse(virDomainDefPtr def, =20 static int vzDomainDefValidate(const virDomainDef *def, - virCapsPtr caps G_GNUC_UNUSED, void *opaque) { if (vzCheckUnsupportedControllers(def, opaque) < 0) --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 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=1575469326; cv=none; d=zohomail.com; s=zohoarc; b=RpEfAa7mkX53K9//WmLvC9bLAJyBVU6tW9QI9wC9P4Qc0F7UfUHN27A9ipWMmBHg+PwWk8f5GxjMhp8HACfHaEETxNoOiQqLdADIqIcLB6MneVSSZA8aJiL514OYB3PDcvP/bi7KkgaSeNdVlyY0hKsHxLxdZYjPfn6/GuogN2A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469326; 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=gYntaEa0Lft/sOsJHSD8a0CYX8+nRzy7DDyRoiMXd/s=; b=hRP5+y0W09+VayrTKOMIgTAxxyqKQfXqP8+OFctv7eqlb/U0Q+A90LNUnUfckT7CX+7vZ8kgmF9tUNxvAGaWL2qm2mXtPLT0y3MH4wN/qKQeOyRbEQl07erwwe4Yodk6otmeJ34Kc8yLeH6HJ1PKMG/tyz9ojp5Tzz1s3JewRNc= 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 1575469326668159.00456109495622; Wed, 4 Dec 2019 06:22:06 -0800 (PST) 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-153-BK-1H2jQOiW-UcqG_mPExA-1; Wed, 04 Dec 2019 09:22:01 -0500 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 7B0E2801E7E; Wed, 4 Dec 2019 14:21:55 +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 4EE2E67E62; Wed, 4 Dec 2019 14:21:55 +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 03D8A1803B48; Wed, 4 Dec 2019 14:21:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4ELgr7008234 for ; Wed, 4 Dec 2019 09:21:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id D740D608F7; Wed, 4 Dec 2019 14:21:42 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id EFED167E62; Wed, 4 Dec 2019 14:21:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469324; 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=gYntaEa0Lft/sOsJHSD8a0CYX8+nRzy7DDyRoiMXd/s=; b=EmNXn0hANZJ+qiZbYvE7Zl/Q6zbJGSIl2lOjfgYAF+FtQyUTkJXqM2TztFgazYnfHxpEfK 1yT8zw8ABQWOmXJLHqfT4cPdwpi1SoJboXLm5HBDMUx4afxFdal3hT5pSR5L21FiA98Vf8 EU2MqzcdGqkuJLQ8k6uSMcRUYLSgpuU= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:21:00 +0000 Message-Id: <20191204142113.2961028-18-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 17/30] conf: drop virCapsPtr param from domain formatting APIs 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-MC-Unique: BK-1H2jQOiW-UcqG_mPExA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) This parameter is now unused and can be removed entirely. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/bhyve/bhyve_driver.c | 16 ++-------------- src/conf/checkpoint_conf.c | 4 ++-- src/conf/domain_conf.c | 26 +++++++++++--------------- src/conf/domain_conf.h | 4 ---- src/conf/snapshot_conf.c | 6 +++--- src/esx/esx_driver.c | 4 ++-- src/hyperv/hyperv_driver.c | 2 +- src/libxl/libxl_domain.c | 12 ++++++------ src/libxl/libxl_driver.c | 8 ++++---- src/libxl/libxl_migration.c | 4 ++-- src/lxc/lxc_driver.c | 4 ++-- src/lxc/lxc_process.c | 12 ++++++------ src/openvz/openvz_driver.c | 4 ++-- src/phyp/phyp_driver.c | 2 +- src/qemu/qemu_domain.c | 2 +- src/security/security_apparmor.c | 2 +- src/test/test_driver.c | 6 +++--- src/vbox/vbox_common.c | 2 +- src/vmware/vmware_driver.c | 4 ++-- src/vz/vz_driver.c | 4 ++-- tests/bhyveargv2xmltest.c | 2 +- tests/lxcconf2xmltest.c | 2 +- tests/openvzutilstest.c | 2 +- tests/qemuhotplugtest.c | 6 +++--- tests/qemuxml2xmltest.c | 2 +- tests/testutils.c | 2 +- tests/vmx2xmltest.c | 2 +- tests/xlconfigtest.c | 2 +- tests/xmconfigtest.c | 2 +- 29 files changed, 65 insertions(+), 85 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 18b5d1e950..8432044b60 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -480,7 +480,6 @@ bhyveDomainGetXMLDesc(virDomainPtr domain, unsigned int= flags) { bhyveConnPtr privconn =3D domain->conn->privateData; virDomainObjPtr vm; - virCapsPtr caps =3D NULL; char *ret =3D NULL; =20 virCheckFlags(VIR_DOMAIN_XML_COMMON_FLAGS, NULL); @@ -491,14 +490,9 @@ bhyveDomainGetXMLDesc(virDomainPtr domain, unsigned in= t flags) if (virDomainGetXMLDescEnsureACL(domain->conn, vm->def, flags) < 0) goto cleanup; =20 - caps =3D bhyveDriverGetCapabilities(privconn); - if (!caps) - goto cleanup; - - ret =3D virDomainDefFormat(vm->def, privconn->xmlopt, caps, + ret =3D virDomainDefFormat(vm->def, privconn->xmlopt, virDomainDefFormatConvertXMLFlags(flags)); =20 - virObjectUnref(caps); cleanup: virDomainObjEndAPI(&vm); return ret; @@ -1561,7 +1555,6 @@ bhyveConnectDomainXMLFromNative(virConnectPtr conn, char *xml =3D NULL; virDomainDefPtr def =3D NULL; bhyveConnPtr privconn =3D conn->privateData; - virCapsPtr capabilities =3D NULL; unsigned caps =3D bhyveDriverGetCaps(conn); =20 virCheckFlags(0, NULL); @@ -1569,10 +1562,6 @@ bhyveConnectDomainXMLFromNative(virConnectPtr conn, if (virConnectDomainXMLFromNativeEnsureACL(conn) < 0) return NULL; =20 - capabilities =3D bhyveDriverGetCapabilities(privconn); - if (!capabilities) - return NULL; - if (STRNEQ(nativeFormat, BHYVE_CONFIG_FORMAT_ARGV)) { virReportError(VIR_ERR_INVALID_ARG, _("unsupported config type %s"), nativeFormat); @@ -1583,10 +1572,9 @@ bhyveConnectDomainXMLFromNative(virConnectPtr conn, if (def =3D=3D NULL) goto cleanup; =20 - xml =3D virDomainDefFormat(def, privconn->xmlopt, capabilities, 0); + xml =3D virDomainDefFormat(def, privconn->xmlopt, 0); =20 cleanup: - virObjectUnref(capabilities); virDomainDefFree(def); return xml; } diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c index cb2d83796c..37cc8e5e6c 100644 --- a/src/conf/checkpoint_conf.c +++ b/src/conf/checkpoint_conf.c @@ -446,7 +446,7 @@ virDomainCheckpointDiskDefFormat(virBufferPtr buf, static int virDomainCheckpointDefFormatInternal(virBufferPtr buf, virDomainCheckpointDefPtr def, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, virDomainXMLOptionPtr xmlopt, unsigned int flags) { @@ -490,7 +490,7 @@ virDomainCheckpointDefFormatInternal(virBufferPtr buf, =20 if (!(flags & VIR_DOMAIN_CHECKPOINT_FORMAT_NO_DOMAIN) && virDomainDefFormatInternal(def->parent.dom, xmlopt, - caps, buf, domainflags) < 0) + buf, domainflags) < 0) goto error; =20 virBufferAdjustIndent(buf, -2); diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7431aad0cf..44e56976d9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -23559,8 +23559,8 @@ virDomainDefCheckABIStabilityFlags(virDomainDefPtr = src, error: virErrorPreserveLast(&err); =20 - strSrc =3D virDomainDefFormat(src, xmlopt, NULL, 0); - strDst =3D virDomainDefFormat(dst, xmlopt, NULL, 0); + strSrc =3D virDomainDefFormat(src, xmlopt, 0); + strDst =3D virDomainDefFormat(dst, xmlopt, 0); VIR_DEBUG("XMLs that failed stability check were: src=3D\"%s\", dst=3D= \"%s\"", NULLSTR(strSrc), NULLSTR(strDst)); =20 @@ -28247,11 +28247,10 @@ virDomainDefFormatFeatures(virBufferPtr buf, int virDomainDefFormatInternal(virDomainDefPtr def, virDomainXMLOptionPtr xmlopt, - virCapsPtr caps, virBufferPtr buf, unsigned int flags) { - return virDomainDefFormatInternalSetRootName(def, xmlopt, caps, buf, + return virDomainDefFormatInternalSetRootName(def, xmlopt, buf, "domain", flags); } =20 @@ -28263,7 +28262,6 @@ virDomainDefFormatInternal(virDomainDefPtr def, int virDomainDefFormatInternalSetRootName(virDomainDefPtr def, virDomainXMLOptionPtr xmlopt, - virCapsPtr caps G_GNUC_UNUSED, virBufferPtr buf, const char *rootname, unsigned int flags) @@ -28802,13 +28800,12 @@ unsigned int virDomainDefFormatConvertXMLFlags(un= signed int flags) char * virDomainDefFormat(virDomainDefPtr def, virDomainXMLOptionPtr xmlopt, - virCapsPtr caps, unsigned int flags) { virBuffer buf =3D VIR_BUFFER_INITIALIZER; =20 virCheckFlags(VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS, NULL); - if (virDomainDefFormatInternal(def, xmlopt, caps, &buf, flags) < 0) + if (virDomainDefFormatInternal(def, xmlopt, &buf, flags) < 0) return NULL; =20 return virBufferContentAndReset(&buf); @@ -28818,7 +28815,6 @@ virDomainDefFormat(virDomainDefPtr def, char * virDomainObjFormat(virDomainObjPtr obj, virDomainXMLOptionPtr xmlopt, - virCapsPtr caps, unsigned int flags) { g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; @@ -28843,7 +28839,7 @@ virDomainObjFormat(virDomainObjPtr obj, xmlopt->privateData.format(&buf, obj) < 0) goto error; =20 - if (virDomainDefFormatInternal(obj->def, xmlopt, caps, &buf, flags) < = 0) + if (virDomainDefFormatInternal(obj->def, xmlopt, &buf, flags) < 0) goto error; =20 virBufferAdjustIndent(&buf, -2); @@ -29004,12 +29000,12 @@ virDomainDefSaveXML(virDomainDefPtr def, int virDomainDefSave(virDomainDefPtr def, virDomainXMLOptionPtr xmlopt, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, const char *configDir) { g_autofree char *xml =3D NULL; =20 - if (!(xml =3D virDomainDefFormat(def, xmlopt, caps, VIR_DOMAIN_DEF_FOR= MAT_SECURE))) + if (!(xml =3D virDomainDefFormat(def, xmlopt, VIR_DOMAIN_DEF_FORMAT_SE= CURE))) return -1; =20 return virDomainDefSaveXML(def, configDir, xml); @@ -29018,7 +29014,7 @@ virDomainDefSave(virDomainDefPtr def, int virDomainObjSave(virDomainObjPtr obj, virDomainXMLOptionPtr xmlopt, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, const char *statusDir) { unsigned int flags =3D (VIR_DOMAIN_DEF_FORMAT_SECURE | @@ -29029,7 +29025,7 @@ virDomainObjSave(virDomainObjPtr obj, =20 g_autofree char *xml =3D NULL; =20 - if (!(xml =3D virDomainObjFormat(obj, xmlopt, caps, flags))) + if (!(xml =3D virDomainObjFormat(obj, xmlopt, flags))) return -1; =20 return virDomainDefSaveXML(obj->def, statusDir, xml); @@ -29319,7 +29315,7 @@ virDomainUSBDeviceDefForeach(virDomainDefPtr def, * snapshots). */ virDomainDefPtr virDomainDefCopy(virDomainDefPtr src, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, virDomainXMLOptionPtr xmlopt, void *parseOpaque, bool migratable) @@ -29333,7 +29329,7 @@ virDomainDefCopy(virDomainDefPtr src, format_flags |=3D VIR_DOMAIN_DEF_FORMAT_INACTIVE | VIR_DOMAIN_DEF_= FORMAT_MIGRATABLE; =20 /* Easiest to clone via a round-trip through XML. */ - if (!(xml =3D virDomainDefFormat(src, xmlopt, caps, format_flags))) + if (!(xml =3D virDomainDefFormat(src, xmlopt, format_flags))) return NULL; =20 return virDomainDefParseString(xml, caps, xmlopt, parseOpaque, parse_f= lags); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index bbe73f1182..b98fe5eba5 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3098,26 +3098,22 @@ unsigned int virDomainDefFormatConvertXMLFlags(unsi= gned int flags); =20 char *virDomainDefFormat(virDomainDefPtr def, virDomainXMLOptionPtr xmlopt, - virCapsPtr caps, unsigned int flags) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); char *virDomainObjFormat(virDomainObjPtr obj, virDomainXMLOptionPtr xmlopt, - virCapsPtr caps, unsigned int flags) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); int virDomainDefFormatInternal(virDomainDefPtr def, virDomainXMLOptionPtr xmlopt, - virCapsPtr caps, virBufferPtr buf, unsigned int flags) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); int virDomainDefFormatInternalSetRootName(virDomainDefPtr def, virDomainXMLOptionPtr xmlopt, - virCapsPtr caps, virBufferPtr buf, const char *rootname, unsigned int flags) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 0bf7d497e4..015d54a128 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -838,7 +838,7 @@ static int virDomainSnapshotDefFormatInternal(virBufferPtr buf, const char *uuidstr, virDomainSnapshotDefPtr def, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, virDomainXMLOptionPtr xmlopt, unsigned int flags) { @@ -892,7 +892,7 @@ virDomainSnapshotDefFormatInternal(virBufferPtr buf, =20 if (def->parent.dom) { if (virDomainDefFormatInternal(def->parent.dom, xmlopt, - caps, buf, domainflags) < 0) + buf, domainflags) < 0) goto error; } else if (uuidstr) { virBufferAddLit(buf, "\n"); @@ -904,7 +904,7 @@ virDomainSnapshotDefFormatInternal(virBufferPtr buf, =20 if (def->parent.inactiveDom) { if (virDomainDefFormatInternalSetRootName(def->parent.inactiveDom,= xmlopt, - caps, buf, "inactiveDoma= in", + buf, "inactiveDomain", domainflags) < 0) goto error; } diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 2db89c7986..8e3da589c9 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -2648,7 +2648,7 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int= flags) if (powerState !=3D esxVI_VirtualMachinePowerState_PoweredOff) def->id =3D id; =20 - xml =3D virDomainDefFormat(def, priv->xmlopt, priv->caps, + xml =3D virDomainDefFormat(def, priv->xmlopt, virDomainDefFormatConvertXMLFlags(flags)); } =20 @@ -2706,7 +2706,7 @@ esxConnectDomainXMLFromNative(virConnectPtr conn, con= st char *nativeFormat, def =3D virVMXParseConfig(&ctx, priv->xmlopt, priv->caps, nativeConfig= ); =20 if (def) - xml =3D virDomainDefFormat(def, priv->xmlopt, priv->caps, + xml =3D virDomainDefFormat(def, priv->xmlopt, VIR_DOMAIN_DEF_FORMAT_INACTIVE); =20 virDomainDefFree(def); diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index ff9370d728..c9d22ec7c4 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -887,7 +887,7 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned in= t flags) /* FIXME: devices section is totally missing */ =20 /* XXX xmlopts must be non-NULL */ - xml =3D virDomainDefFormat(def, NULL, NULL, + xml =3D virDomainDefFormat(def, NULL, virDomainDefFormatConvertXMLFlags(flags)); =20 cleanup: diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index dfc8d8b611..f4f1781bae 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -851,7 +851,7 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver, =20 /* now that we know it's stopped call the hook if present */ if (virHookPresent(VIR_HOOK_DRIVER_LIBXL)) { - char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, cfg->cap= s, 0); + char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, 0); =20 /* we can't stop the operation even if the script raised an error = */ ignore_value(virHookCall(VIR_HOOK_DRIVER_LIBXL, vm->def->name, @@ -920,7 +920,7 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver, =20 /* The "release" hook cleans up additional resources */ if (virHookPresent(VIR_HOOK_DRIVER_LIBXL)) { - char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, cfg->cap= s, 0); + char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, 0); =20 /* we can't stop the operation even if the script raised an error = */ ignore_value(virHookCall(VIR_HOOK_DRIVER_LIBXL, vm->def->name, @@ -1327,7 +1327,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver, =20 /* Run an early hook to set-up missing devices */ if (virHookPresent(VIR_HOOK_DRIVER_LIBXL)) { - char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, cfg->cap= s, 0); + char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, 0); int hookret; =20 hookret =3D virHookCall(VIR_HOOK_DRIVER_LIBXL, vm->def->name, @@ -1365,7 +1365,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver, =20 /* now that we know it is about to start call the hook if present */ if (virHookPresent(VIR_HOOK_DRIVER_LIBXL)) { - char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, cfg->cap= s, 0); + char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, 0); int hookret; =20 hookret =3D virHookCall(VIR_HOOK_DRIVER_LIBXL, vm->def->name, @@ -1450,7 +1450,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver, libxlDomainCreateChannelPTY(vm->def, cfg->ctx); #endif =20 - if ((dom_xml =3D virDomainDefFormat(vm->def, driver->xmlopt, cfg->caps= , 0)) =3D=3D NULL) + if ((dom_xml =3D virDomainDefFormat(vm->def, driver->xmlopt, 0)) =3D= =3D NULL) goto destroy_dom; =20 if (libxl_userdata_store(cfg->ctx, domid, "libvirt-xml", @@ -1478,7 +1478,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver, =20 /* finally we can call the 'started' hook script if any */ if (virHookPresent(VIR_HOOK_DRIVER_LIBXL)) { - char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, cfg->cap= s, 0); + char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, 0); int hookret; =20 hookret =3D virHookCall(VIR_HOOK_DRIVER_LIBXL, vm->def->name, diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index fac3c1db49..ed754452f0 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -459,7 +459,7 @@ libxlReconnectDomain(virDomainObjPtr vm, /* now that we know it's reconnected call the hook if present */ if (virHookPresent(VIR_HOOK_DRIVER_LIBXL) && STRNEQ("Domain-0", vm->def->name)) { - char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, cfg->cap= s, 0); + char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, 0); int hookret; =20 /* we can't stop the operation even if the script raised an error = */ @@ -1828,7 +1828,7 @@ libxlDoDomainSave(libxlDriverPrivatePtr driver, goto cleanup; } =20 - if ((xml =3D virDomainDefFormat(vm->def, driver->xmlopt, cfg->caps, 0)= ) =3D=3D NULL) + if ((xml =3D virDomainDefFormat(vm->def, driver->xmlopt, 0)) =3D=3D NU= LL) goto cleanup; xml_len =3D strlen(xml) + 1; =20 @@ -2652,7 +2652,7 @@ libxlDomainGetXMLDesc(virDomainPtr dom, unsigned int = flags) else def =3D vm->def; =20 - ret =3D virDomainDefFormat(def, driver->xmlopt, cfg->caps, + ret =3D virDomainDefFormat(def, driver->xmlopt, virDomainDefFormatConvertXMLFlags(flags)); =20 cleanup: @@ -2703,7 +2703,7 @@ libxlConnectDomainXMLFromNative(virConnectPtr conn, goto cleanup; } =20 - xml =3D virDomainDefFormat(def, driver->xmlopt, cfg->caps, VIR_DOMAIN_= DEF_FORMAT_INACTIVE); + xml =3D virDomainDefFormat(def, driver->xmlopt, VIR_DOMAIN_DEF_FORMAT_= INACTIVE); =20 cleanup: virDomainDefFree(def); diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index 25a58f8018..f9bd004b2e 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -420,7 +420,7 @@ libxlDomainMigrationSrcBegin(virConnectPtr conn, if (!libxlDomainMigrationIsAllowed(def)) goto endjob; =20 - xml =3D virDomainDefFormat(def, driver->xmlopt, cfg->caps, VIR_DOMAIN_= DEF_FORMAT_SECURE); + xml =3D virDomainDefFormat(def, driver->xmlopt, VIR_DOMAIN_DEF_FORMAT_= SECURE); /* Valid xml means success! EndJob in the confirm phase */ if (xml) goto cleanup; @@ -494,7 +494,7 @@ libxlDomainMigrationPrepareAny(virConnectPtr dconn, char *xml; int hookret; =20 - if (!(xml =3D virDomainDefFormat(*def, driver->xmlopt, cfg->caps, + if (!(xml =3D virDomainDefFormat(*def, driver->xmlopt, VIR_DOMAIN_XML_SECURE | VIR_DOMAIN_XML_MIGRATABLE))) return -1; diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index f28e20d756..4639e603e0 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -987,7 +987,7 @@ static char *lxcDomainGetXMLDesc(virDomainPtr dom, =20 ret =3D virDomainDefFormat((flags & VIR_DOMAIN_XML_INACTIVE) && vm->newDef ? vm->newDef : vm->def, - driver->xmlopt, driver->caps, + driver->xmlopt, virDomainDefFormatConvertXMLFlags(flags)); =20 cleanup: @@ -1019,7 +1019,7 @@ static char *lxcConnectDomainXMLFromNative(virConnect= Ptr conn, if (!(def =3D lxcParseConfigString(nativeConfig, caps, driver->xmlopt)= )) goto cleanup; =20 - xml =3D virDomainDefFormat(def, driver->xmlopt, caps, 0); + xml =3D virDomainDefFormat(def, driver->xmlopt, 0); =20 cleanup: virObjectUnref(caps); diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index c1b8b6aa09..cd8ee4975b 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -171,7 +171,7 @@ static void virLXCProcessCleanup(virLXCDriverPtr driver, =20 /* now that we know it's stopped call the hook if present */ if (virHookPresent(VIR_HOOK_DRIVER_LXC)) { - char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, driver->= caps, 0); + char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, 0); =20 /* we can't stop the operation even if the script raised an error = */ virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name, @@ -248,7 +248,7 @@ static void virLXCProcessCleanup(virLXCDriverPtr driver, =20 /* The "release" hook cleans up additional resources */ if (virHookPresent(VIR_HOOK_DRIVER_LXC)) { - char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, driver->= caps, 0); + char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, 0); =20 /* we can't stop the operation even if the script raised an error = */ virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name, @@ -1271,7 +1271,7 @@ int virLXCProcessStart(virConnectPtr conn, =20 /* Run an early hook to set-up missing devices */ if (virHookPresent(VIR_HOOK_DRIVER_LXC)) { - char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, driver->= caps, 0); + char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, 0); int hookret; =20 hookret =3D virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name, @@ -1379,7 +1379,7 @@ int virLXCProcessStart(virConnectPtr conn, =20 /* now that we know it is about to start call the hook if present */ if (virHookPresent(VIR_HOOK_DRIVER_LXC)) { - char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, driver->= caps, 0); + char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, 0); int hookret; =20 hookret =3D virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name, @@ -1521,7 +1521,7 @@ int virLXCProcessStart(virConnectPtr conn, =20 /* finally we can call the 'started' hook script if any */ if (virHookPresent(VIR_HOOK_DRIVER_LXC)) { - char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, driver->= caps, 0); + char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, 0); int hookret; =20 hookret =3D virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name, @@ -1701,7 +1701,7 @@ virLXCProcessReconnectDomain(virDomainObjPtr vm, =20 /* now that we know it's reconnected call the hook if present */ if (virHookPresent(VIR_HOOK_DRIVER_LXC)) { - char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, driv= er->caps, 0); + char *xml =3D virDomainDefFormat(vm->def, driver->xmlopt, 0); int hookret; =20 /* we can't stop the operation even if the script raised an er= ror */ diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 9b93bc5ca0..33c28a2721 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -473,7 +473,7 @@ static char *openvzDomainGetXMLDesc(virDomainPtr dom, u= nsigned int flags) { if (!(vm =3D openvzDomObjFromDomain(driver, dom->uuid))) return NULL; =20 - ret =3D virDomainDefFormat(vm->def, driver->xmlopt, driver->caps, + ret =3D virDomainDefFormat(vm->def, driver->xmlopt, virDomainDefFormatConvertXMLFlags(flags)); =20 virDomainObjEndAPI(&vm); @@ -2067,7 +2067,7 @@ openvzDomainMigrateBegin3Params(virDomainPtr domain, goto cleanup; } =20 - xml =3D virDomainDefFormat(vm->def, driver->xmlopt, driver->caps, + xml =3D virDomainDefFormat(vm->def, driver->xmlopt, VIR_DOMAIN_DEF_FORMAT_SECURE); =20 cleanup: diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index b22063642e..a5cb1b91b3 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -3252,7 +3252,7 @@ phypDomainGetXMLDesc(virDomainPtr dom, unsigned int f= lags) if (virDomainDefSetVcpus(&def, vcpus) < 0) goto err; =20 - return virDomainDefFormat(&def, phyp_driver->xmlopt, phyp_driver->caps, + return virDomainDefFormat(&def, phyp_driver->xmlopt, virDomainDefFormatConvertXMLFlags(flags)); =20 err: diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 49b6008d5c..926ec80ec8 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9219,7 +9219,7 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr drive= r, } =20 format: - ret =3D virDomainDefFormatInternal(def, driver->xmlopt, caps, buf, + ret =3D virDomainDefFormatInternal(def, driver->xmlopt, buf, virDomainDefFormatConvertXMLFlags(fla= gs)); =20 cleanup: diff --git a/src/security/security_apparmor.c b/src/security/security_appar= mor.c index 6da79203d7..21560b2330 100644 --- a/src/security/security_apparmor.c +++ b/src/security/security_apparmor.c @@ -168,7 +168,7 @@ load_profile(virSecurityManagerPtr mgr G_GNUC_UNUSED, char *xml =3D NULL; virCommandPtr cmd =3D NULL; =20 - xml =3D virDomainDefFormat(def, NULL, NULL, VIR_DOMAIN_DEF_FORMAT_SECU= RE); + xml =3D virDomainDefFormat(def, NULL, VIR_DOMAIN_DEF_FORMAT_SECURE); if (!xml) goto cleanup; =20 diff --git a/src/test/test_driver.c b/src/test/test_driver.c index f2700d90bc..630cfa1574 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2178,7 +2178,7 @@ testDomainSaveImageWrite(testDriverPtr driver, int fd =3D -1; g_autofree char *xml =3D NULL; =20 - xml =3D virDomainDefFormat(def, driver->xmlopt, driver->caps, + xml =3D virDomainDefFormat(def, driver->xmlopt, VIR_DOMAIN_DEF_FORMAT_SECURE); =20 if (xml =3D=3D NULL) { @@ -2468,7 +2468,7 @@ testDomainSaveImageGetXMLDesc(virConnectPtr conn, if ((fd =3D testDomainSaveImageOpen(privconn, path, &def)) < 0) goto cleanup; =20 - ret =3D virDomainDefFormat(def, privconn->xmlopt, privconn->caps, + ret =3D virDomainDefFormat(def, privconn->xmlopt, VIR_DOMAIN_DEF_FORMAT_SECURE); =20 cleanup: @@ -3180,7 +3180,7 @@ static char *testDomainGetXMLDesc(virDomainPtr domain= , unsigned int flags) def =3D (flags & VIR_DOMAIN_XML_INACTIVE) && privdom->newDef ? privdom->newDef : privdom->def; =20 - ret =3D virDomainDefFormat(def, privconn->xmlopt, privconn->caps, + ret =3D virDomainDefFormat(def, privconn->xmlopt, virDomainDefFormatConvertXMLFlags(flags)); =20 virDomainObjEndAPI(&privdom); diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 0d22c94e06..1feb76c0a5 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -4126,7 +4126,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, u= nsigned int flags) /* dump USB devices/filters if active */ vboxHostDeviceGetXMLDesc(data, def, machine); =20 - ret =3D virDomainDefFormat(def, data->xmlopt, data->caps, + ret =3D virDomainDefFormat(def, data->xmlopt, virDomainDefFormatConvertXMLFlags(flags)); =20 cleanup: diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index eb2fcd438b..b30c8847d3 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -940,7 +940,7 @@ vmwareDomainGetXMLDesc(virDomainPtr dom, unsigned int f= lags) if (!(vm =3D vmwareDomObjFromDomain(driver, dom->uuid))) return NULL; =20 - ret =3D virDomainDefFormat(vm->def, driver->xmlopt, driver->caps, + ret =3D virDomainDefFormat(vm->def, driver->xmlopt, virDomainDefFormatConvertXMLFlags(flags)); =20 virDomainObjEndAPI(&vm); @@ -973,7 +973,7 @@ vmwareConnectDomainXMLFromNative(virConnectPtr conn, co= nst char *nativeFormat, def =3D virVMXParseConfig(&ctx, driver->xmlopt, driver->caps, nativeCo= nfig); =20 if (def !=3D NULL) - xml =3D virDomainDefFormat(def, driver->xmlopt, driver->caps, + xml =3D virDomainDefFormat(def, driver->xmlopt, VIR_DOMAIN_DEF_FORMAT_INACTIVE); =20 virDomainDefFree(def); diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 35baab1b82..a76c56334d 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -733,7 +733,7 @@ vzDomainGetXMLDesc(virDomainPtr domain, unsigned int fl= ags) def =3D (flags & VIR_DOMAIN_XML_INACTIVE) && dom->newDef ? dom->newDef : dom->def; =20 - ret =3D virDomainDefFormat(def, driver->xmlopt, privconn->driver->caps= , flags); + ret =3D virDomainDefFormat(def, driver->xmlopt, flags); =20 cleanup: virDomainObjEndAPI(&dom); @@ -2877,7 +2877,7 @@ vzDomainMigrateBeginStep(virDomainObjPtr dom, | VZ_MIGRATION_COOKIE_DOMAIN_NAME) < 0) return NULL; =20 - return virDomainDefFormat(dom->def, driver->xmlopt, driver->caps, + return virDomainDefFormat(dom->def, driver->xmlopt, VIR_DOMAIN_XML_MIGRATABLE); } =20 diff --git a/tests/bhyveargv2xmltest.c b/tests/bhyveargv2xmltest.c index 5e39face33..735cc4b338 100644 --- a/tests/bhyveargv2xmltest.c +++ b/tests/bhyveargv2xmltest.c @@ -77,7 +77,7 @@ testCompareXMLToArgvFiles(const char *xmlfile, goto fail; } =20 - if (vmdef && !(actualxml =3D virDomainDefFormat(vmdef, driver.caps, 0)= )) + if (vmdef && !(actualxml =3D virDomainDefFormat(vmdef, driver.xmlopt, = 0))) goto fail; =20 if (vmdef && virTestCompareToFile(actualxml, xmlfile) < 0) diff --git a/tests/lxcconf2xmltest.c b/tests/lxcconf2xmltest.c index fffe9cbf1a..ba0c7a1a0c 100644 --- a/tests/lxcconf2xmltest.c +++ b/tests/lxcconf2xmltest.c @@ -41,7 +41,7 @@ testCompareXMLToConfigFiles(const char *xmlfile, if (testSanitizeDef(vmdef) < 0) goto fail; =20 - if (!(actualxml =3D virDomainDefFormat(vmdef, driver->xmlopt, driv= er->caps, 0))) + if (!(actualxml =3D virDomainDefFormat(vmdef, driver->xmlopt, 0))) goto fail; =20 if (virTestCompareToFile(actualxml, xmlfile) < 0) diff --git a/tests/openvzutilstest.c b/tests/openvzutilstest.c index 681f1a52a0..c395b9dc19 100644 --- a/tests/openvzutilstest.c +++ b/tests/openvzutilstest.c @@ -116,7 +116,7 @@ testReadNetworkConf(const void *data G_GNUC_UNUSED) goto cleanup; } =20 - actual =3D virDomainDefFormat(def, driver.xmlopt, driver.caps, VIR_DOM= AIN_DEF_FORMAT_INACTIVE); + actual =3D virDomainDefFormat(def, driver.xmlopt, VIR_DOMAIN_DEF_FORMA= T_INACTIVE); =20 if (actual =3D=3D NULL) { fprintf(stderr, "ERROR: %s\n", virGetLastErrorMessage()); diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index 9fbc1e1a64..b1e53505be 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -200,7 +200,7 @@ testQemuHotplugCheckResult(virDomainObjPtr vm, char *actual; int ret; =20 - actual =3D virDomainDefFormat(vm->def, driver.xmlopt, driver.caps, + actual =3D virDomainDefFormat(vm->def, driver.xmlopt, VIR_DOMAIN_DEF_FORMAT_SECURE); if (!actual) return -1; @@ -466,7 +466,7 @@ testQemuHotplugCpuFinalize(struct testQemuHotplugCpuDat= a *data) char *configXML =3D NULL; =20 if (data->file_xml_res_live) { - if (!(activeXML =3D virDomainDefFormat(data->vm->def, driver.xmlop= t, driver.caps, + if (!(activeXML =3D virDomainDefFormat(data->vm->def, driver.xmlop= t, VIR_DOMAIN_DEF_FORMAT_SECURE)= )) goto cleanup; =20 @@ -475,7 +475,7 @@ testQemuHotplugCpuFinalize(struct testQemuHotplugCpuDat= a *data) } =20 if (data->file_xml_res_conf) { - if (!(configXML =3D virDomainDefFormat(data->vm->newDef, driver.xm= lopt, driver.caps, + if (!(configXML =3D virDomainDefFormat(data->vm->newDef, driver.xm= lopt, VIR_DOMAIN_DEF_FORMAT_SECURE | VIR_DOMAIN_DEF_FORMAT_INACTIV= E))) goto cleanup; diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index a8f7dd4e1b..f849869735 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -68,7 +68,7 @@ testCompareStatusXMLToXMLFiles(const void *opaque) goto cleanup; } =20 - if (!(actual =3D virDomainObjFormat(obj, driver.xmlopt, NULL, + if (!(actual =3D virDomainObjFormat(obj, driver.xmlopt, VIR_DOMAIN_DEF_FORMAT_SECURE | VIR_DOMAIN_DEF_FORMAT_STATUS | VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET | diff --git a/tests/testutils.c b/tests/testutils.c index ffcb56ca86..94a0e9068f 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -1140,7 +1140,7 @@ testCompareDomXML2XMLFiles(virCapsPtr caps, virDomain= XMLOptionPtr xmlopt, goto out; } =20 - if (!(actual =3D virDomainDefFormat(def, xmlopt, caps, format_flags)))= { + if (!(actual =3D virDomainDefFormat(def, xmlopt, format_flags))) { result =3D TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_FORMAT; goto out; } diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index beb82cbd7c..8d7b8ba2a4 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -84,7 +84,7 @@ testCompareFiles(const char *vmx, const char *xml) goto cleanup; } =20 - if (!(formatted =3D virDomainDefFormat(def, xmlopt, caps, + if (!(formatted =3D virDomainDefFormat(def, xmlopt, VIR_DOMAIN_DEF_FORMAT_SECURE))) goto cleanup; =20 diff --git a/tests/xlconfigtest.c b/tests/xlconfigtest.c index d077933ca9..cdc2c37ed3 100644 --- a/tests/xlconfigtest.c +++ b/tests/xlconfigtest.c @@ -146,7 +146,7 @@ testCompareFormatXML(const char *xlcfg, const char *xml= , bool replaceVars) if (!(def =3D xenParseXL(conf, cfg->caps, driver->xmlopt))) goto fail; =20 - if (!(gotxml =3D virDomainDefFormat(def, driver->xmlopt, cfg->caps, + if (!(gotxml =3D virDomainDefFormat(def, driver->xmlopt, VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_SECURE))) goto fail; diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c index 6971ad76e2..f8652e228c 100644 --- a/tests/xmconfigtest.c +++ b/tests/xmconfigtest.c @@ -101,7 +101,7 @@ testCompareFormatXML(const char *xmcfg, const char *xml) if (!(def =3D xenParseXM(conf, cfg->caps, driver->xmlopt))) goto fail; =20 - if (!(gotxml =3D virDomainDefFormat(def, driver->xmlopt, cfg->caps, VI= R_DOMAIN_DEF_FORMAT_SECURE))) + if (!(gotxml =3D virDomainDefFormat(def, driver->xmlopt, VIR_DOMAIN_DE= F_FORMAT_SECURE))) goto fail; =20 if (virTestCompareToFile(gotxml, xml) < 0) --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 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=1575469386; cv=none; d=zohomail.com; s=zohoarc; b=JQ1xeE/E4Js5oMwjJD7O+Wec5Db7MbEE73e+ztCkLczgNBzv0qiwZvC5eAUQJ89fWWhCM15M8f9ix9kGwA3TJttXqp/405iKjmhDGFMUsh/vTmQCulWlBHL33egf5pwZH4q6+KhjPEhWipoeYDOw95akxfOwb3ELmEOfT38mZq8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469386; 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=0kZvKlMScBHszglQrKuhbMRO5fGc9dKHlPplwPjE+xM=; b=BFw52dTbIdvWx6A3g7pEFGCk3ocDFGxN92URa3Nb7sSoc44Qa9kvTMsFJg1XtMG0uqFuG2SqD8xU1Sm4QdFrAB0VwKrZj7Ik2Yzeqnl95R10JgpfB5MBtp3OrGeUDwLc5RrngLzPQMwwE8Nri3fNHQPuAncG1tZHK7GVeYljc7Q= 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 1575469386932693.1432841550155; Wed, 4 Dec 2019 06:23:06 -0800 (PST) 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-278-ZIKEFnnaOxGHFQuXrAEfVA-1; Wed, 04 Dec 2019 09:22:04 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 486C9DBEF; Wed, 4 Dec 2019 14:21:57 +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 1C35819C68; Wed, 4 Dec 2019 14:21:57 +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 CC56218034EA; Wed, 4 Dec 2019 14:21:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4ELiLm008241 for ; Wed, 4 Dec 2019 09:21:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id 10F04691B7; Wed, 4 Dec 2019 14:21:44 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E8F4608F7; Wed, 4 Dec 2019 14:21:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469385; 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=0kZvKlMScBHszglQrKuhbMRO5fGc9dKHlPplwPjE+xM=; b=BddSR/xLEDsNUnAmup/0gCK6zleCVRqHob95KmHSGuRi4DAwqypUu0a5VIdW7WplXtNKcb cWiV853wect0aW+e9axKwSJYMPakEwuLZWTEuvDMR56jvLGC2uoPuSQKJmpQwaRqacirLk QutFv6OJHKOMzYWxRCtP2vy5wKuM71w= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:21:01 +0000 Message-Id: <20191204142113.2961028-19-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 18/30] conf: drop virCapsPtr param from domain post parse & validate APIs 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.84 on 10.5.11.23 X-MC-Unique: ZIKEFnnaOxGHFQuXrAEfVA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 10 ++++------ src/conf/domain_conf.h | 2 -- src/libxl/xen_xl.c | 2 +- src/libxl/xen_xm.c | 2 +- src/lxc/lxc_native.c | 4 ++-- src/qemu/qemu_driver.c | 12 ++++++------ src/qemu/qemu_process.c | 4 ++-- src/vmx/vmx.c | 4 ++-- 8 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 44e56976d9..b1384a1487 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5802,7 +5802,6 @@ virDomainDefPostParseCheckFailure(virDomainDefPtr def, =20 int virDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags, virDomainXMLOptionPtr xmlopt, void *parseOpaque) @@ -7107,7 +7106,6 @@ virDomainDefValidateInternal(const virDomainDef *def, */ int virDomainDefValidate(virDomainDefPtr def, - virCapsPtr caps G_GNUC_UNUSED, unsigned int parseFlags, virDomainXMLOptionPtr xmlopt) { @@ -21518,11 +21516,11 @@ virDomainObjParseXML(xmlDocPtr xml, parseOpaque =3D xmlopt->privateData.getParseOpaque(obj); =20 /* callback to fill driver specific domain aspects */ - if (virDomainDefPostParse(obj->def, caps, flags, xmlopt, parseOpaque) = < 0) + if (virDomainDefPostParse(obj->def, flags, xmlopt, parseOpaque) < 0) goto error; =20 /* validate configuration */ - if (virDomainDefValidate(obj->def, caps, flags, xmlopt) < 0) + if (virDomainDefValidate(obj->def, flags, xmlopt) < 0) goto error; =20 return obj; @@ -21607,11 +21605,11 @@ virDomainDefParseNode(xmlDocPtr xml, return NULL; =20 /* callback to fill driver specific domain aspects */ - if (virDomainDefPostParse(def, caps, flags, xmlopt, parseOpaque) < 0) + if (virDomainDefPostParse(def, flags, xmlopt, parseOpaque) < 0) return NULL; =20 /* validate configuration */ - if (virDomainDefValidate(def, caps, flags, xmlopt) < 0) + if (virDomainDefValidate(def, flags, xmlopt) < 0) return NULL; =20 return g_steal_pointer(&def); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index b98fe5eba5..4f3c9fdc8b 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2783,7 +2783,6 @@ virDomainSCSIDriveAddressIsUsed(const virDomainDef *d= ef, const virDomainDeviceDriveAddress *addr); =20 int virDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps, unsigned int parseFlags, virDomainXMLOptionPtr xmlopt, void *parseOpaque); @@ -2796,7 +2795,6 @@ int virDomainDeviceValidateAliasForHotplug(virDomainO= bjPtr vm, bool virDomainDeviceAliasIsUserAlias(const char *aliasStr); =20 int virDomainDefValidate(virDomainDefPtr def, - virCapsPtr caps, unsigned int parseFlags, virDomainXMLOptionPtr xmlopt); =20 diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index 396adf6dac..18ea4a8d95 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -1213,7 +1213,7 @@ xenParseXL(virConfPtr conf, if (xenParseXLChannel(conf, def) < 0) goto cleanup; =20 - if (virDomainDefPostParse(def, caps, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE, + if (virDomainDefPostParse(def, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE, xmlopt, NULL) < 0) goto cleanup; =20 diff --git a/src/libxl/xen_xm.c b/src/libxl/xen_xm.c index 88cf9ac5b0..1b462d0487 100644 --- a/src/libxl/xen_xm.c +++ b/src/libxl/xen_xm.c @@ -467,7 +467,7 @@ xenParseXM(virConfPtr conf, if (xenParseXMInputDevs(conf, def) < 0) goto cleanup; =20 - if (virDomainDefPostParse(def, caps, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE, + if (virDomainDefPostParse(def, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE, xmlopt, NULL) < 0) goto cleanup; =20 diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index 7e696fd2f0..e9b83653b5 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -1055,7 +1055,7 @@ lxcSetCapDrop(virDomainDefPtr def, virConfPtr propert= ies) =20 virDomainDefPtr lxcParseConfigString(const char *config, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, virDomainXMLOptionPtr xmlopt) { virDomainDefPtr vmdef =3D NULL; @@ -1166,7 +1166,7 @@ lxcParseConfigString(const char *config, /* lxc.cap.drop */ lxcSetCapDrop(vmdef, properties); =20 - if (virDomainDefPostParse(vmdef, caps, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE, + if (virDomainDefPostParse(vmdef, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE, xmlopt, NULL) < 0) goto error; =20 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 93a92dad36..32eae175ed 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8101,7 +8101,7 @@ qemuCheckDiskConfigAgainstDomain(const virDomainDef *= def, static int qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, virQEMUCapsPtr qemuCaps, unsigned int parse_flags, virDomainXMLOptionPtr xmlopt) @@ -8301,7 +8301,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, return -1; } =20 - if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, qemuCaps) = < 0) + if (virDomainDefPostParse(vmdef, parse_flags, xmlopt, qemuCaps) < 0) return -1; =20 return 0; @@ -8311,7 +8311,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, static int qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, virQEMUCapsPtr qemuCaps, unsigned int parse_flags, virDomainXMLOptionPtr xmlopt) @@ -8494,7 +8494,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, return -1; } =20 - if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, qemuCaps) = < 0) + if (virDomainDefPostParse(vmdef, parse_flags, xmlopt, qemuCaps) < 0) return -1; =20 return 0; @@ -8503,7 +8503,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, static int qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, virQEMUCapsPtr qemuCaps, unsigned int parse_flags, virDomainXMLOptionPtr xmlopt) @@ -8602,7 +8602,7 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef, return -1; } =20 - if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, qemuCaps) = < 0) + if (virDomainDefPostParse(vmdef, parse_flags, xmlopt, qemuCaps) < 0) return -1; =20 return 0; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 79ac5f3d95..33ebdce01e 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5382,7 +5382,7 @@ qemuProcessStartValidate(virQEMUDriverPtr driver, * VM that was running before (migration, snapshots, save). It's more * important to start such VM than keep the configuration clean */ if ((flags & VIR_QEMU_PROCESS_START_NEW) && - virDomainDefValidate(vm->def, caps, 0, driver->xmlopt) < 0) + virDomainDefValidate(vm->def, 0, driver->xmlopt) < 0) return -1; =20 if (qemuProcessStartValidateGraphics(vm) < 0) @@ -5581,7 +5581,7 @@ qemuProcessInit(virQEMUDriverPtr driver, VIR_DEBUG("re-running the post parse callback"); =20 /* we don't have the private copy of qemuCaps at this point */ - if (virDomainDefPostParse(vm->def, caps, 0, driver->xmlopt, NULL) = < 0) + if (virDomainDefPostParse(vm->def, 0, driver->xmlopt, NULL) < 0) goto cleanup; } =20 diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 093092b701..df5eafbd44 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -1276,7 +1276,7 @@ virVMXConfigScanResultsCollector(const char* name, virDomainDefPtr virVMXParseConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, const char *vmx) { bool success =3D false; @@ -1845,7 +1845,7 @@ virVMXParseConfig(virVMXContext *ctx, } } =20 - if (virDomainDefPostParse(def, caps, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE, + if (virDomainDefPostParse(def, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE, xmlopt, NULL) < 0) goto cleanup; =20 --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 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=1575469333; cv=none; d=zohomail.com; s=zohoarc; b=WcG9prq0TiWPilYBoM7pNFo1CygkuxNUwy6/gEJBEJYfYCMrk1PaWYUuLvxOjjdQhFBpTmf8dKIaqf/xU4suIETekLHuIjeXGHlT7Z81cNoUoXTs6O15I5ZaObDRLihJpFOvDPHYNa7R7cFlQNFNNHxecyidyNx3tIakA/rqBws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469333; 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=ZU7HC0sZSjcOZk0DM9q3a4uj56tKjwUaYcPII0KPidc=; b=K1PEnwcKfNsQkMz2zGxvRFWm3UojE1lUL6qGkzyN9UndbFc2dKG4JcUOsD7AzJLLT8rcBxvjI8CjQbXAbzcKDmEAzuV+Dxd0iqLbxVl7GkWr63R7s6iBdN4/vv2y0nXl08NyALakqBuZFGEqwkul3YtC/KOaXzR2l/kMRJeG2Wo= 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-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1575469333963153.19817980182825; Wed, 4 Dec 2019 06:22:13 -0800 (PST) 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-385-7B5UbOF2Nv-4diE9oZpfoQ-1; Wed, 04 Dec 2019 09:22:10 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0F76EDBED; Wed, 4 Dec 2019 14:22:01 +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 DD1DF600CD; Wed, 4 Dec 2019 14:22:00 +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 8E61E18034F0; Wed, 4 Dec 2019 14:22:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4ELjmm008255 for ; Wed, 4 Dec 2019 09:21:45 -0500 Received: by smtp.corp.redhat.com (Postfix) id 44D24691B4; Wed, 4 Dec 2019 14:21:45 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D20E608F7; Wed, 4 Dec 2019 14:21:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469332; 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=ZU7HC0sZSjcOZk0DM9q3a4uj56tKjwUaYcPII0KPidc=; b=hZz2rZBYSZdHolN9OWLAzhq5RSriFnSS1gp9zLRwXR+cJYZfS17JcqLF6QIvKGY5jOW/tK A4E7RdZYaEDtIJEUHOhcPGM585/mnGPUQcVtQdGBv5AFN7VOzg9JwlX0NVALBkf2dlQyGx HwnjfzY/S14Z6ujEh7VBD28oKfZj22Q= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:21:02 +0000 Message-Id: <20191204142113.2961028-20-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 19/30] conf: drop virCapsPtr param from domain parse APIs 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.11 X-MC-Unique: 7B5UbOF2Nv-4diE9oZpfoQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/bhyve/bhyve_driver.c | 17 +++--------- src/conf/checkpoint_conf.c | 4 +-- src/conf/domain_conf.c | 29 +++++++------------- src/conf/domain_conf.h | 6 ----- src/conf/snapshot_conf.c | 6 ++--- src/conf/virdomainobjlist.c | 8 +++--- src/esx/esx_driver.c | 4 +-- src/libxl/libxl_domain.c | 4 +-- src/libxl/libxl_driver.c | 18 ++++++------- src/libxl/libxl_migration.c | 7 +++-- src/lxc/lxc_controller.c | 2 +- src/lxc/lxc_driver.c | 10 +++---- src/openvz/openvz_driver.c | 8 +++--- src/phyp/phyp_driver.c | 4 +-- src/qemu/qemu_checkpoint.c | 4 +-- src/qemu/qemu_domain.c | 7 +---- src/qemu/qemu_driver.c | 46 ++++++++------------------------ src/qemu/qemu_migration.c | 21 +++------------ src/qemu/qemu_migration_cookie.c | 8 +----- src/security/virt-aa-helper.c | 2 +- src/test/test_driver.c | 10 +++---- src/vbox/vbox_common.c | 6 ++--- src/vmware/vmware_driver.c | 4 +-- src/vz/vz_driver.c | 4 +-- tests/bhyvexml2argvtest.c | 2 +- tests/domainconftest.c | 2 +- tests/libxlxml2domconfigtest.c | 2 +- tests/qemuagenttest.c | 2 +- tests/qemuhotplugtest.c | 3 +-- tests/qemumemlocktest.c | 2 +- tests/qemusecuritytest.c | 1 - tests/qemuxml2argvtest.c | 2 +- tests/qemuxml2xmltest.c | 2 +- tests/securityselinuxlabeltest.c | 2 +- tests/testutils.c | 5 ++-- tests/xlconfigtest.c | 4 +-- tests/xmconfigtest.c | 2 +- tests/xml2vmxtest.c | 2 +- 38 files changed, 97 insertions(+), 175 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 8432044b60..0e627f2dc8 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -519,7 +519,7 @@ bhyveDomainDefineXMLFlags(virConnectPtr conn, const cha= r *xml, unsigned int flag if (!caps) return NULL; =20 - if ((def =3D virDomainDefParseString(xml, caps, privconn->xmlopt, + if ((def =3D virDomainDefParseString(xml, privconn->xmlopt, NULL, parse_flags)) =3D=3D NULL) goto cleanup; =20 @@ -681,7 +681,6 @@ bhyveConnectDomainXMLToNative(virConnectPtr conn, bhyveConnPtr privconn =3D conn->privateData; virDomainDefPtr def =3D NULL; virCommandPtr cmd =3D NULL, loadcmd =3D NULL; - virCapsPtr caps =3D NULL; char *ret =3D NULL; =20 virCheckFlags(0, NULL); @@ -695,10 +694,7 @@ bhyveConnectDomainXMLToNative(virConnectPtr conn, goto cleanup; } =20 - if (!(caps =3D bhyveDriverGetCapabilities(privconn))) - goto cleanup; - - if (!(def =3D virDomainDefParseString(xmlData, caps, privconn->xmlopt, + if (!(def =3D virDomainDefParseString(xmlData, privconn->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIV= E))) goto cleanup; =20 @@ -741,7 +737,6 @@ bhyveConnectDomainXMLToNative(virConnectPtr conn, virCommandFree(loadcmd); virCommandFree(cmd); virDomainDefFree(def); - virObjectUnref(caps); return ret; } =20 @@ -898,7 +893,6 @@ bhyveDomainCreateXML(virConnectPtr conn, virDomainDefPtr def =3D NULL; virDomainObjPtr vm =3D NULL; virObjectEventPtr event =3D NULL; - virCapsPtr caps =3D NULL; unsigned int start_flags =3D 0; unsigned int parse_flags =3D VIR_DOMAIN_DEF_PARSE_INACTIVE; =20 @@ -910,11 +904,7 @@ bhyveDomainCreateXML(virConnectPtr conn, if (flags & VIR_DOMAIN_START_AUTODESTROY) start_flags |=3D VIR_BHYVE_PROCESS_START_AUTODESTROY; =20 - caps =3D bhyveDriverGetCapabilities(privconn); - if (!caps) - return NULL; - - if ((def =3D virDomainDefParseString(xml, caps, privconn->xmlopt, + if ((def =3D virDomainDefParseString(xml, privconn->xmlopt, NULL, parse_flags)) =3D=3D NULL) goto cleanup; =20 @@ -947,7 +937,6 @@ bhyveDomainCreateXML(virConnectPtr conn, dom =3D virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id); =20 cleanup: - virObjectUnref(caps); virDomainDefFree(def); virDomainObjEndAPI(&vm); virObjectEventStateQueue(privconn->domainEventState, event); diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c index 37cc8e5e6c..581e382b6d 100644 --- a/src/conf/checkpoint_conf.c +++ b/src/conf/checkpoint_conf.c @@ -121,7 +121,7 @@ virDomainCheckpointDiskDefParseXML(xmlNodePtr node, */ static virDomainCheckpointDefPtr virDomainCheckpointDefParse(xmlXPathContextPtr ctxt, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, virDomainXMLOptionPtr xmlopt, void *parseOpaque, unsigned int flags) @@ -170,7 +170,7 @@ virDomainCheckpointDefParse(xmlXPathContextPtr ctxt, return NULL; } def->parent.dom =3D virDomainDefParseNode(ctxt->node->doc, dom= ainNode, - caps, xmlopt, parseOpa= que, + xmlopt, parseOpaque, domainflags); if (!def->parent.dom) return NULL; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b1384a1487..00b5da8d52 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16371,7 +16371,6 @@ virDomainVsockDefParseXML(virDomainXMLOptionPtr xml= opt, virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr, const virDomainDef *def, - virCapsPtr caps G_GNUC_UNUSED, virDomainXMLOptionPtr xmlopt, void *parseOpaque, unsigned int flags) @@ -19725,7 +19724,6 @@ virDomainMemorytuneDefParse(virDomainDefPtr def, static virDomainDefPtr virDomainDefParseXML(xmlDocPtr xml, xmlXPathContextPtr ctxt, - virCapsPtr caps G_GNUC_UNUSED, virDomainXMLOptionPtr xmlopt, unsigned int flags) { @@ -21430,7 +21428,6 @@ virDomainDefParseXML(xmlDocPtr xml, static virDomainObjPtr virDomainObjParseXML(xmlDocPtr xml, xmlXPathContextPtr ctxt, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, unsigned int flags) { @@ -21457,7 +21454,7 @@ virDomainObjParseXML(xmlDocPtr xml, =20 oldnode =3D ctxt->node; ctxt->node =3D config; - obj->def =3D virDomainDefParseXML(xml, ctxt, caps, xmlopt, flags); + obj->def =3D virDomainDefParseXML(xml, ctxt, xmlopt, flags); ctxt->node =3D oldnode; if (!obj->def) goto error; @@ -21534,7 +21531,6 @@ virDomainObjParseXML(xmlDocPtr xml, static virDomainDefPtr virDomainDefParse(const char *xmlStr, const char *filename, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, void *parseOpaque, unsigned int flags) @@ -21556,7 +21552,7 @@ virDomainDefParse(const char *xmlStr, goto cleanup; } =20 - def =3D virDomainDefParseNode(xml, root, caps, xmlopt, parseOpaque, fl= ags); + def =3D virDomainDefParseNode(xml, root, xmlopt, parseOpaque, flags); =20 cleanup: xmlFreeDoc(xml); @@ -21566,29 +21562,26 @@ virDomainDefParse(const char *xmlStr, =20 virDomainDefPtr virDomainDefParseString(const char *xmlStr, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, void *parseOpaque, unsigned int flags) { - return virDomainDefParse(xmlStr, NULL, caps, xmlopt, parseOpaque, flag= s); + return virDomainDefParse(xmlStr, NULL, xmlopt, parseOpaque, flags); } =20 virDomainDefPtr virDomainDefParseFile(const char *filename, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, void *parseOpaque, unsigned int flags) { - return virDomainDefParse(NULL, filename, caps, xmlopt, parseOpaque, fl= ags); + return virDomainDefParse(NULL, filename, xmlopt, parseOpaque, flags); } =20 =20 virDomainDefPtr virDomainDefParseNode(xmlDocPtr xml, xmlNodePtr root, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, void *parseOpaque, unsigned int flags) @@ -21601,7 +21594,7 @@ virDomainDefParseNode(xmlDocPtr xml, =20 ctxt->node =3D root; =20 - if (!(def =3D virDomainDefParseXML(xml, ctxt, caps, xmlopt, flags))) + if (!(def =3D virDomainDefParseXML(xml, ctxt, xmlopt, flags))) return NULL; =20 /* callback to fill driver specific domain aspects */ @@ -21619,7 +21612,6 @@ virDomainDefParseNode(xmlDocPtr xml, virDomainObjPtr virDomainObjParseNode(xmlDocPtr xml, xmlNodePtr root, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, unsigned int flags) { @@ -21637,13 +21629,12 @@ virDomainObjParseNode(xmlDocPtr xml, return NULL; =20 ctxt->node =3D root; - return virDomainObjParseXML(xml, ctxt, caps, xmlopt, flags); + return virDomainObjParseXML(xml, ctxt, xmlopt, flags); } =20 =20 virDomainObjPtr virDomainObjParseFile(const char *filename, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, unsigned int flags) { @@ -21653,7 +21644,7 @@ virDomainObjParseFile(const char *filename, =20 if ((xml =3D virXMLParseFile(filename))) { obj =3D virDomainObjParseNode(xml, xmlDocGetRootElement(xml), - caps, xmlopt, flags); + xmlopt, flags); xmlFreeDoc(xml); } =20 @@ -29330,7 +29321,7 @@ virDomainDefCopy(virDomainDefPtr src, if (!(xml =3D virDomainDefFormat(src, xmlopt, format_flags))) return NULL; =20 - return virDomainDefParseString(xml, caps, xmlopt, parseOpaque, parse_f= lags); + return virDomainDefParseString(xml, xmlopt, parseOpaque, parse_flags); } =20 virDomainDefPtr @@ -29787,7 +29778,7 @@ virDomainNetFindByName(virDomainDefPtr def, virDomainDeviceDefPtr virDomainDeviceDefCopy(virDomainDeviceDefPtr src, const virDomainDef *def, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, virDomainXMLOptionPtr xmlopt, void *parseOpaque) { @@ -29875,7 +29866,7 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src, return NULL; =20 xmlStr =3D virBufferContentAndReset(&buf); - return virDomainDeviceDefParse(xmlStr, def, caps, xmlopt, parseOpaque, + return virDomainDeviceDefParse(xmlStr, def, xmlopt, parseOpaque, VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE); } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 4f3c9fdc8b..5255c8190e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3032,7 +3032,6 @@ typedef enum { =20 virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr, const virDomainDef *def, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, void *parseOpaque, unsigned int flags); @@ -3040,28 +3039,23 @@ virDomainDiskDefPtr virDomainDiskDefParse(const cha= r *xmlStr, virDomainXMLOptionPtr xmlopt, unsigned int flags); virDomainDefPtr virDomainDefParseString(const char *xmlStr, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, void *parseOpaque, unsigned int flags); virDomainDefPtr virDomainDefParseFile(const char *filename, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, void *parseOpaque, unsigned int flags); virDomainDefPtr virDomainDefParseNode(xmlDocPtr doc, xmlNodePtr root, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, void *parseOpaque, unsigned int flags); virDomainObjPtr virDomainObjParseNode(xmlDocPtr xml, xmlNodePtr root, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, unsigned int flags); virDomainObjPtr virDomainObjParseFile(const char *filename, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, unsigned int flags); =20 diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 015d54a128..af882c6048 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -222,7 +222,7 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node, */ static virDomainSnapshotDefPtr virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, virDomainXMLOptionPtr xmlopt, void *parseOpaque, bool *current, @@ -301,7 +301,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, goto cleanup; } def->parent.dom =3D virDomainDefParseNode(ctxt->node->doc, dom= ainNode, - caps, xmlopt, parseOpa= que, + xmlopt, parseOpaque, domainflags); if (!def->parent.dom) goto cleanup; @@ -314,7 +314,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, * parent.dom for config and live XML. */ if ((inactiveDomNode =3D virXPathNode("./inactiveDomain", ctxt))) { def->parent.inactiveDom =3D virDomainDefParseNode(ctxt->node->= doc, inactiveDomNode, - caps, xmlopt, = NULL, domainflags); + xmlopt, NULL, = domainflags); if (!def->parent.inactiveDom) goto cleanup; } diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c index 744dd87296..ae18a4544f 100644 --- a/src/conf/virdomainobjlist.c +++ b/src/conf/virdomainobjlist.c @@ -483,7 +483,7 @@ virDomainObjListRename(virDomainObjListPtr doms, =20 static virDomainObjPtr virDomainObjListLoadConfig(virDomainObjListPtr doms, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, virDomainXMLOptionPtr xmlopt, const char *configDir, const char *autostartDir, @@ -499,7 +499,7 @@ virDomainObjListLoadConfig(virDomainObjListPtr doms, =20 if ((configFile =3D virDomainConfigFile(configDir, name)) =3D=3D NULL) goto error; - if (!(def =3D virDomainDefParseFile(configFile, caps, xmlopt, NULL, + if (!(def =3D virDomainDefParseFile(configFile, xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE | VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARS= E_FAIL))) @@ -536,7 +536,7 @@ static virDomainObjPtr virDomainObjListLoadStatus(virDomainObjListPtr doms, const char *statusDir, const char *name, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, virDomainXMLOptionPtr xmlopt, virDomainLoadConfigNotify notify, void *opaque) @@ -548,7 +548,7 @@ virDomainObjListLoadStatus(virDomainObjListPtr doms, if ((statusFile =3D virDomainConfigFile(statusDir, name)) =3D=3D NULL) goto error; =20 - if (!(obj =3D virDomainObjParseFile(statusFile, caps, xmlopt, + if (!(obj =3D virDomainObjParseFile(statusFile, xmlopt, VIR_DOMAIN_DEF_PARSE_STATUS | VIR_DOMAIN_DEF_PARSE_ACTUAL_NET | VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES= | diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 8e3da589c9..9cfdd3bf49 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -2744,7 +2744,7 @@ esxConnectDomainXMLToNative(virConnectPtr conn, const= char *nativeFormat, if (virtualHW_version < 0) return NULL; =20 - def =3D virDomainDefParseString(domainXml, priv->caps, priv->xmlopt, + def =3D virDomainDefParseString(domainXml, priv->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE); =20 if (!def) @@ -2960,7 +2960,7 @@ esxDomainDefineXMLFlags(virConnectPtr conn, const cha= r *xml, unsigned int flags) return NULL; =20 /* Parse domain XML */ - def =3D virDomainDefParseString(xml, priv->caps, priv->xmlopt, + def =3D virDomainDefParseString(xml, priv->xmlopt, NULL, parse_flags); =20 if (!def) diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index f4f1781bae..fea20ba477 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -732,7 +732,7 @@ libxlDomainManagedSavePath(libxlDriverPrivatePtr driver= , virDomainObjPtr vm) */ int libxlDomainSaveImageOpen(libxlDriverPrivatePtr driver, - libxlDriverConfigPtr cfg, + libxlDriverConfigPtr cfg G_GNUC_UNUSED, const char *from, virDomainDefPtr *ret_def, libxlSavefileHeaderPtr ret_hdr) @@ -780,7 +780,7 @@ libxlDomainSaveImageOpen(libxlDriverPrivatePtr driver, goto error; } =20 - if (!(def =3D virDomainDefParseString(xml, cfg->caps, driver->xmlopt, = NULL, + if (!(def =3D virDomainDefParseString(xml, driver->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE= ))) goto error; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index ed754452f0..abf359ad1b 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -1042,7 +1042,7 @@ libxlDomainCreateXML(virConnectPtr conn, const char *= xml, if (flags & VIR_DOMAIN_START_VALIDATE) parse_flags |=3D VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA; =20 - if (!(def =3D virDomainDefParseString(xml, cfg->caps, driver->xmlopt, + if (!(def =3D virDomainDefParseString(xml, driver->xmlopt, NULL, parse_flags))) goto cleanup; =20 @@ -2730,7 +2730,7 @@ libxlConnectDomainXMLToNative(virConnectPtr conn, con= st char * nativeFormat, goto cleanup; =20 if (!(def =3D virDomainDefParseString(domainXml, - cfg->caps, driver->xmlopt, NULL, + driver->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto cleanup; =20 @@ -2850,7 +2850,7 @@ libxlDomainDefineXMLFlags(virConnectPtr conn, const c= har *xml, unsigned int flag if (flags & VIR_DOMAIN_DEFINE_VALIDATE) parse_flags |=3D VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA; =20 - if (!(def =3D virDomainDefParseString(xml, cfg->caps, driver->xmlopt, + if (!(def =3D virDomainDefParseString(xml, driver->xmlopt, NULL, parse_flags))) goto cleanup; =20 @@ -4116,7 +4116,7 @@ libxlDomainAttachDeviceFlags(virDomainPtr dom, const = char *xml, =20 if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) { if (!(dev =3D virDomainDeviceDefParse(xml, vm->def, - cfg->caps, driver->xmlopt, NUL= L, + driver->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE)= )) goto endjob; =20 @@ -4133,7 +4133,7 @@ libxlDomainAttachDeviceFlags(virDomainPtr dom, const = char *xml, /* If dev exists it was created to modify the domain config. Free = it. */ virDomainDeviceDefFree(dev); if (!(dev =3D virDomainDeviceDefParse(xml, vm->def, - cfg->caps, driver->xmlopt, NUL= L, + driver->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE)= )) goto endjob; =20 @@ -4205,7 +4205,7 @@ libxlDomainDetachDeviceFlags(virDomainPtr dom, const = char *xml, =20 if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) { if (!(dev =3D virDomainDeviceDefParse(xml, vm->def, - cfg->caps, driver->xmlopt, NUL= L, + driver->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_SKIP_VALI= DATE))) goto endjob; @@ -4223,7 +4223,7 @@ libxlDomainDetachDeviceFlags(virDomainPtr dom, const = char *xml, /* If dev exists it was created to modify the domain config. Free = it. */ virDomainDeviceDefFree(dev); if (!(dev =3D virDomainDeviceDefParse(xml, vm->def, - cfg->caps, driver->xmlopt, NUL= L, + driver->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_SKIP_VALI= DATE))) goto endjob; @@ -4293,7 +4293,7 @@ libxlDomainUpdateDeviceFlags(virDomainPtr dom, const = char *xml, =20 if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) { if (!(dev =3D virDomainDeviceDefParse(xml, vm->def, - cfg->caps, driver->xmlopt, NUL= L, + driver->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE)= )) goto cleanup; =20 @@ -4312,7 +4312,7 @@ libxlDomainUpdateDeviceFlags(virDomainPtr dom, const = char *xml, /* If dev exists it was created to modify the domain config. Free = it. */ virDomainDeviceDefFree(dev); if (!(dev =3D virDomainDeviceDefParse(xml, vm->def, - cfg->caps, driver->xmlopt, NUL= L, + driver->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE)= )) goto cleanup; =20 diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index f9bd004b2e..d744816510 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -402,7 +402,7 @@ libxlDomainMigrationSrcBegin(virConnectPtr conn, goto endjob; =20 if (xmlin) { - if (!(tmpdef =3D virDomainDefParseString(xmlin, cfg->caps, + if (!(tmpdef =3D virDomainDefParseString(xmlin, driver->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTI= VE | @@ -450,7 +450,7 @@ libxlDomainMigrationDstPrepareDef(libxlDriverPrivatePtr= driver, return NULL; } =20 - if (!(def =3D virDomainDefParseString(dom_xml, cfg->caps, driver->xmlo= pt, + if (!(def =3D virDomainDefParseString(dom_xml, driver->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE= ))) @@ -477,7 +477,6 @@ libxlDomainMigrationPrepareAny(virConnectPtr dconn, bool *taint_hook) { libxlDriverPrivatePtr driver =3D dconn->privateData; - libxlDriverConfigPtr cfg =3D libxlDriverConfigGet(driver); =20 if (libxlMigrationEatCookie(cookiein, cookieinlen, mig) < 0) return -1; @@ -514,7 +513,7 @@ libxlDomainMigrationPrepareAny(virConnectPtr dconn, virDomainDefPtr newdef; =20 VIR_DEBUG("Using hook-filtered domain XML: %s", *xmlout); - newdef =3D virDomainDefParseString(*xmlout, cfg->caps, dri= ver->xmlopt, + newdef =3D virDomainDefParseString(*xmlout, driver->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INAC= TIVE | VIR_DOMAIN_DEF_PARSE_SKIP= _VALIDATE); diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index c869e2e7c4..e572c3f5fd 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -212,7 +212,7 @@ static virLXCControllerPtr virLXCControllerNew(const ch= ar *name) goto error; =20 if ((ctrl->vm =3D virDomainObjParseFile(configFile, - driver->caps, driver->xmlopt, + driver->xmlopt, 0)) =3D=3D NULL) goto error; ctrl->def =3D ctrl->vm->def; diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 4639e603e0..1ef15bfcf8 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -416,7 +416,7 @@ lxcDomainDefineXMLFlags(virConnectPtr conn, const char = *xml, unsigned int flags) if (!(caps =3D virLXCDriverGetCapabilities(driver, false))) goto cleanup; =20 - if (!(def =3D virDomainDefParseString(xml, caps, driver->xmlopt, + if (!(def =3D virDomainDefParseString(xml, driver->xmlopt, NULL, parse_flags))) goto cleanup; =20 @@ -1164,7 +1164,7 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn, if (!(caps =3D virLXCDriverGetCapabilities(driver, false))) goto cleanup; =20 - if (!(def =3D virDomainDefParseString(xml, caps, driver->xmlopt, + if (!(def =3D virDomainDefParseString(xml, driver->xmlopt, NULL, parse_flags))) goto cleanup; =20 @@ -4699,7 +4699,7 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr do= m, goto endjob; =20 dev =3D dev_copy =3D virDomainDeviceDefParse(xml, vm->def, - caps, driver->xmlopt, NULL, + driver->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE= ); if (dev =3D=3D NULL) goto endjob; @@ -4818,7 +4818,7 @@ static int lxcDomainUpdateDeviceFlags(virDomainPtr do= m, if (!(caps =3D virLXCDriverGetCapabilities(driver, false))) goto endjob; =20 - if (!(dev =3D virDomainDeviceDefParse(xml, vm->def, caps, driver->xmlo= pt, NULL, + if (!(dev =3D virDomainDeviceDefParse(xml, vm->def, driver->xmlopt, NU= LL, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto endjob; =20 @@ -4882,7 +4882,7 @@ static int lxcDomainDetachDeviceFlags(virDomainPtr do= m, goto endjob; =20 dev =3D dev_copy =3D virDomainDeviceDefParse(xml, vm->def, - caps, driver->xmlopt, NULL, + driver->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE= | VIR_DOMAIN_DEF_PARSE_SKIP_VAL= IDATE); if (dev =3D=3D NULL) diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 33c28a2721..0c472601d3 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -858,7 +858,7 @@ openvzDomainDefineXMLFlags(virConnectPtr conn, const ch= ar *xml, unsigned int fla parse_flags |=3D VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA; =20 openvzDriverLock(driver); - if ((vmdef =3D virDomainDefParseString(xml, driver->caps, driver->xmlo= pt, + if ((vmdef =3D virDomainDefParseString(xml, driver->xmlopt, NULL, parse_flags)) =3D=3D NULL) goto cleanup; =20 @@ -948,7 +948,7 @@ openvzDomainCreateXML(virConnectPtr conn, const char *x= ml, parse_flags |=3D VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA; =20 openvzDriverLock(driver); - if ((vmdef =3D virDomainDefParseString(xml, driver->caps, driver->xmlo= pt, + if ((vmdef =3D virDomainDefParseString(xml, driver->xmlopt, NULL, parse_flags)) =3D=3D NULL) goto cleanup; =20 @@ -1909,7 +1909,7 @@ openvzDomainUpdateDeviceFlags(virDomainPtr dom, const= char *xml, if (!(def =3D virDomainObjGetOneDef(vm, flags))) goto cleanup; =20 - dev =3D virDomainDeviceDefParse(xml, def, driver->caps, driver->xmlopt= , NULL, + dev =3D virDomainDeviceDefParse(xml, def, driver->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE); if (!dev) goto cleanup; @@ -2113,7 +2113,7 @@ openvzDomainMigratePrepare3Params(virConnectPtr dconn, goto error; } =20 - if (!(def =3D virDomainDefParseString(dom_xml, driver->caps, driver->x= mlopt, + if (!(def =3D virDomainDefParseString(dom_xml, driver->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE= ))) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index a5cb1b91b3..640d90585a 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -1684,7 +1684,7 @@ phypDomainAttachDeviceFlags(virDomainPtr domain, =20 def->os.type =3D VIR_DOMAIN_OSTYPE_LINUX; =20 - dev =3D virDomainDeviceDefParse(xml, def, phyp_driver->caps, NULL, NUL= L, + dev =3D virDomainDeviceDefParse(xml, def, NULL, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE); if (!dev) goto cleanup; @@ -3531,7 +3531,7 @@ phypDomainCreateXML(virConnectPtr conn, if (flags & VIR_DOMAIN_START_VALIDATE) parse_flags |=3D VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA; =20 - if (!(def =3D virDomainDefParseString(xml, phyp_driver->caps, + if (!(def =3D virDomainDefParseString(xml, phyp_driver->xmlopt, NULL, parse_flags))) diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c index d5af6b99bf..a601030637 100644 --- a/src/qemu/qemu_checkpoint.c +++ b/src/qemu/qemu_checkpoint.c @@ -239,7 +239,7 @@ qemuCheckpointDiscardAllMetadata(virQEMUDriverPtr drive= r, /* Called inside job lock */ static int qemuCheckpointPrepare(virQEMUDriverPtr driver, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, virDomainObjPtr vm, virDomainCheckpointDefPtr def) { @@ -253,7 +253,7 @@ qemuCheckpointPrepare(virQEMUDriverPtr driver, if (!(xml =3D qemuDomainDefFormatLive(driver, priv->qemuCaps, vm->def, priv->origCPU, true, true)) || - !(def->parent.dom =3D virDomainDefParseString(xml, caps, driver->x= mlopt, + !(def->parent.dom =3D virDomainDefParseString(xml, driver->xmlopt, priv->qemuCaps, VIR_DOMAIN_DEF_PARSE_I= NACTIVE | VIR_DOMAIN_DEF_PARSE_S= KIP_VALIDATE))) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 926ec80ec8..4c589eec05 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8976,17 +8976,12 @@ qemuDomainDefFromXML(virQEMUDriverPtr driver, virQEMUCapsPtr qemuCaps, const char *xml) { - virCapsPtr caps; virDomainDefPtr def; =20 - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - return NULL; - - def =3D virDomainDefParseString(xml, caps, driver->xmlopt, qemuCaps, + def =3D virDomainDefParseString(xml, driver->xmlopt, qemuCaps, VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE); =20 - virObjectUnref(caps); return def; } =20 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 32eae175ed..00788e7aca 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1748,7 +1748,6 @@ static virDomainPtr qemuDomainCreateXML(virConnectPtr= conn, virObjectEventPtr event =3D NULL; virObjectEventPtr event2 =3D NULL; unsigned int start_flags =3D VIR_QEMU_PROCESS_START_COLD; - g_autoptr(virCaps) caps =3D NULL; unsigned int parse_flags =3D VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_ABI_UPDATE; =20 @@ -1765,10 +1764,7 @@ static virDomainPtr qemuDomainCreateXML(virConnectPt= r conn, =20 virNWFilterReadLockFilterUpdates(); =20 - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - goto cleanup; - - if (!(def =3D virDomainDefParseString(xml, caps, driver->xmlopt, + if (!(def =3D virDomainDefParseString(xml, driver->xmlopt, NULL, parse_flags))) goto cleanup; =20 @@ -3277,13 +3273,9 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, int ret =3D -1; virObjectEventPtr event =3D NULL; qemuDomainObjPrivatePtr priv =3D vm->privateData; - g_autoptr(virCaps) caps =3D NULL; virQEMUSaveDataPtr data =3D NULL; qemuDomainSaveCookiePtr cookie =3D NULL; =20 - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - goto cleanup; - if (!qemuMigrationSrcIsAllowed(driver, vm, false, 0)) goto cleanup; =20 @@ -3326,7 +3318,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, if (xmlin) { virDomainDefPtr def =3D NULL; =20 - if (!(def =3D virDomainDefParseString(xmlin, caps, driver->xmlopt, + if (!(def =3D virDomainDefParseString(xmlin, driver->xmlopt, priv->qemuCaps, VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_SKIP_VALI= DATE))) { @@ -6581,12 +6573,8 @@ qemuDomainSaveImageUpdateDef(virQEMUDriverPtr driver, virDomainDefPtr ret =3D NULL; virDomainDefPtr newdef_migr =3D NULL; virDomainDefPtr newdef =3D NULL; - g_autoptr(virCaps) caps =3D NULL; - - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - goto cleanup; =20 - if (!(newdef =3D virDomainDefParseString(newxml, caps, driver->xmlopt,= NULL, + if (!(newdef =3D virDomainDefParseString(newxml, driver->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto cleanup; =20 @@ -6659,7 +6647,6 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, virQEMUSaveHeaderPtr header; virDomainDefPtr def =3D NULL; int oflags =3D open_write ? O_RDWR : O_RDONLY; - g_autoptr(virCaps) caps =3D NULL; size_t xml_len; size_t cookie_len; =20 @@ -6673,9 +6660,6 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, oflags |=3D directFlag; } =20 - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - goto error; - if ((fd =3D qemuOpenFile(driver, NULL, path, oflags, NULL)) < 0) goto error; if (bypass_cache && @@ -6770,7 +6754,7 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, } =20 /* Create a domain from this XML */ - if (!(def =3D virDomainDefParseString(data->xml, caps, driver->xmlopt,= qemuCaps, + if (!(def =3D virDomainDefParseString(data->xml, driver->xmlopt, qemuC= aps, VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE= ))) goto error; @@ -7343,7 +7327,6 @@ static char *qemuConnectDomainXMLToNative(virConnectP= tr conn, virCommandPtr cmd =3D NULL; char *ret =3D NULL; size_t i; - g_autoptr(virCaps) caps =3D NULL; =20 virCheckFlags(0, NULL); =20 @@ -7356,13 +7339,10 @@ static char *qemuConnectDomainXMLToNative(virConnec= tPtr conn, goto cleanup; } =20 - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - goto cleanup; - if (!(vm =3D virDomainObjNew(driver->xmlopt))) goto cleanup; =20 - if (!(vm->def =3D virDomainDefParseString(xmlData, caps, driver->xmlop= t, NULL, + if (!(vm->def =3D virDomainDefParseString(xmlData, driver->xmlopt, NUL= L, VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_ABI_UPDAT= E))) goto cleanup; @@ -7587,7 +7567,6 @@ qemuDomainDefineXMLFlags(virConnectPtr conn, virDomainPtr dom =3D NULL; virObjectEventPtr event =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - g_autoptr(virCaps) caps =3D NULL; unsigned int parse_flags =3D VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_ABI_UPDATE; =20 @@ -7596,10 +7575,7 @@ qemuDomainDefineXMLFlags(virConnectPtr conn, if (flags & VIR_DOMAIN_DEFINE_VALIDATE) parse_flags |=3D VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA; =20 - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - goto cleanup; - - if (!(def =3D virDomainDefParseString(xml, caps, driver->xmlopt, + if (!(def =3D virDomainDefParseString(xml, driver->xmlopt, NULL, parse_flags))) goto cleanup; =20 @@ -8641,7 +8617,7 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr v= m, if (!vmdef) goto cleanup; =20 - if (!(devConf =3D virDomainDeviceDefParse(xml, vmdef, caps, + if (!(devConf =3D virDomainDeviceDefParse(xml, vmdef, driver->xmlopt, priv->qemu= Caps, parse_flags))) goto cleanup; @@ -8662,7 +8638,7 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr v= m, } =20 if (flags & VIR_DOMAIN_AFFECT_LIVE) { - if (!(devLive =3D virDomainDeviceDefParse(xml, vm->def, caps, + if (!(devLive =3D virDomainDeviceDefParse(xml, vm->def, driver->xmlopt, priv->qemu= Caps, parse_flags))) goto cleanup; @@ -8793,7 +8769,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr d= om, !(flags & VIR_DOMAIN_AFFECT_LIVE)) parse_flags |=3D VIR_DOMAIN_DEF_PARSE_INACTIVE; =20 - dev =3D dev_copy =3D virDomainDeviceDefParse(xml, vm->def, caps, + dev =3D dev_copy =3D virDomainDeviceDefParse(xml, vm->def, driver->xmlopt, priv->qemuCap= s, parse_flags); if (dev =3D=3D NULL) @@ -8890,7 +8866,7 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr = driver, !(flags & VIR_DOMAIN_AFFECT_LIVE)) parse_flags |=3D VIR_DOMAIN_DEF_PARSE_INACTIVE; =20 - dev =3D dev_copy =3D virDomainDeviceDefParse(xml, vm->def, caps, + dev =3D dev_copy =3D virDomainDeviceDefParse(xml, vm->def, driver->xmlopt, priv->qemuCap= s, parse_flags); if (dev =3D=3D NULL) @@ -15930,7 +15906,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, if (!(xml =3D qemuDomainDefFormatLive(driver, priv->qemuCaps, vm->def, priv->origCPU, true, true)) || - !(def->parent.dom =3D virDomainDefParseString(xml, caps, drive= r->xmlopt, + !(def->parent.dom =3D virDomainDefParseString(xml, driver->xml= opt, priv->qemuCaps, VIR_DOMAIN_DEF_PAR= SE_INACTIVE | VIR_DOMAIN_DEF_PAR= SE_SKIP_VALIDATE))) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index e9470cc62c..9086a3a95a 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1945,7 +1945,6 @@ qemuMigrationSrcBeginPhase(virQEMUDriverPtr driver, qemuMigrationCookiePtr mig =3D NULL; virDomainDefPtr def =3D NULL; qemuDomainObjPrivatePtr priv =3D vm->privateData; - virCapsPtr caps =3D NULL; unsigned int cookieFlags =3D QEMU_MIGRATION_COOKIE_LOCKSTATE; =20 VIR_DEBUG("driver=3D%p, vm=3D%p, xmlin=3D%s, dname=3D%s," @@ -1955,9 +1954,6 @@ qemuMigrationSrcBeginPhase(virQEMUDriverPtr driver, cookieout, cookieoutlen, nmigrate_disks, migrate_disks, flags); =20 - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - goto cleanup; - /* Only set the phase if we are inside QEMU_ASYNC_JOB_MIGRATION_OUT. * Otherwise we will start the async job later in the perform phase lo= sing * change protection. @@ -2074,7 +2070,7 @@ qemuMigrationSrcBeginPhase(virQEMUDriverPtr driver, } =20 if (xmlin) { - if (!(def =3D virDomainDefParseString(xmlin, caps, driver->xmlopt,= priv->qemuCaps, + if (!(def =3D virDomainDefParseString(xmlin, driver->xmlopt, priv-= >qemuCaps, VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_SKIP_VALI= DATE))) goto cleanup; @@ -2090,7 +2086,6 @@ qemuMigrationSrcBeginPhase(virQEMUDriverPtr driver, =20 cleanup: qemuMigrationCookieFree(mig); - virObjectUnref(caps); virDomainDefFree(def); return rv; } @@ -2289,7 +2284,6 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver, char *xmlout =3D NULL; unsigned int cookieFlags; unsigned int startFlags; - virCapsPtr caps =3D NULL; qemuProcessIncomingDefPtr incoming =3D NULL; bool taint_hook =3D false; bool stopProcess =3D false; @@ -2340,9 +2334,6 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver, goto cleanup; } =20 - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - goto cleanup; - if (!qemuMigrationSrcIsAllowedHostdev(*def)) goto cleanup; =20 @@ -2371,7 +2362,7 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver, virDomainDefPtr newdef; =20 VIR_DEBUG("Using hook-filtered domain XML: %s", xmlout); - newdef =3D virDomainDefParseString(xmlout, caps, driver->x= mlopt, NULL, + newdef =3D virDomainDefParseString(xmlout, driver->xmlopt,= NULL, VIR_DOMAIN_DEF_PARSE_INAC= TIVE | VIR_DOMAIN_DEF_PARSE_SKIP= _VALIDATE); if (!newdef) @@ -2619,7 +2610,6 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver, virDomainObjEndAPI(&vm); virObjectEventStateQueue(driver->domainEventState, event); qemuMigrationCookieFree(mig); - virObjectUnref(caps); virNWFilterUnlockFilterUpdates(); virErrorRestore(&origErr); return ret; @@ -2857,7 +2847,6 @@ qemuMigrationAnyPrepareDef(virQEMUDriverPtr driver, const char *dname, char **origname) { - virCapsPtr caps =3D NULL; virDomainDefPtr def; char *name =3D NULL; =20 @@ -2867,10 +2856,7 @@ qemuMigrationAnyPrepareDef(virQEMUDriverPtr driver, return NULL; } =20 - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - return NULL; - - if (!(def =3D virDomainDefParseString(dom_xml, caps, driver->xmlopt, + if (!(def =3D virDomainDefParseString(dom_xml, driver->xmlopt, qemuCaps, VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE= ))) @@ -2882,7 +2868,6 @@ qemuMigrationAnyPrepareDef(virQEMUDriverPtr driver, } =20 cleanup: - virObjectUnref(caps); if (def && origname) *origname =3D name; else diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index 33b3529f8c..9cfb08951c 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -1198,10 +1198,6 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr m= ig, xmlNodePtr *nodes =3D NULL; size_t i; int n; - virCapsPtr caps =3D NULL; - - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - goto error; =20 /* We don't store the uuid, name, hostname, or hostuuid * values. We just compare them to local data to do some @@ -1330,7 +1326,7 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mi= g, goto error; } mig->persistent =3D virDomainDefParseNode(doc, nodes[0], - caps, driver->xmlopt, qemu= Caps, + driver->xmlopt, qemuCaps, VIR_DOMAIN_DEF_PARSE_INACT= IVE | VIR_DOMAIN_DEF_PARSE_ABI_U= PDATE_MIGRATION | VIR_DOMAIN_DEF_PARSE_SKIP_= VALIDATE); @@ -1369,13 +1365,11 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr = mig, !(mig->caps =3D qemuMigrationCookieCapsXMLParse(ctxt))) goto error; =20 - virObjectUnref(caps); return 0; =20 error: VIR_FREE(tmp); VIR_FREE(nodes); - virObjectUnref(caps); return -1; } =20 diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 820db5b911..c93dddb228 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -690,7 +690,7 @@ get_definition(vahControl * ctl, const char *xmlStr) } =20 ctl->def =3D virDomainDefParseString(xmlStr, - ctl->caps, ctl->xmlopt, NULL, + ctl->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_SKIP_SECLABEL | VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE); =20 diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 630cfa1574..c5c533d369 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -945,7 +945,7 @@ testParseDomains(testDriverPtr privconn, goto error; =20 def =3D virDomainDefParseNode(ctxt->doc, node, - privconn->caps, privconn->xmlopt, NULL, + privconn->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE); if (!def) goto error; @@ -1678,7 +1678,7 @@ testDomainCreateXML(virConnectPtr conn, const char *x= ml, parse_flags |=3D VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA; =20 virObjectLock(privconn); - if ((def =3D virDomainDefParseString(xml, privconn->caps, privconn->xm= lopt, + if ((def =3D virDomainDefParseString(xml, privconn->xmlopt, NULL, parse_flags)) =3D=3D NULL) goto cleanup; =20 @@ -2294,7 +2294,7 @@ testDomainSaveImageOpen(testDriverPtr driver, } xml[len] =3D '\0'; =20 - if (!(def =3D virDomainDefParseString(xml, driver->caps, driver->xmlop= t, NULL, + if (!(def =3D virDomainDefParseString(xml, driver->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE= ))) goto error; @@ -2437,7 +2437,7 @@ testDomainSaveImageDefineXML(virConnectPtr conn, goto cleanup; VIR_FORCE_CLOSE(fd); =20 - if ((newdef =3D virDomainDefParseString(dxml, privconn->caps, privconn= ->xmlopt, NULL, + if ((newdef =3D virDomainDefParseString(dxml, privconn->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE)) = =3D=3D NULL) goto cleanup; =20 @@ -3989,7 +3989,7 @@ static virDomainPtr testDomainDefineXMLFlags(virConne= ctPtr conn, if (flags & VIR_DOMAIN_DEFINE_VALIDATE) parse_flags |=3D VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA; =20 - if ((def =3D virDomainDefParseString(xml, privconn->caps, privconn->xm= lopt, + if ((def =3D virDomainDefParseString(xml, privconn->xmlopt, NULL, parse_flags)) =3D=3D NULL) goto cleanup; =20 diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 1feb76c0a5..1703120928 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -1858,7 +1858,7 @@ vboxDomainDefineXMLFlags(virConnectPtr conn, const ch= ar *xml, unsigned int flags if (!data->vboxObj) return ret; =20 - if (!(def =3D virDomainDefParseString(xml, data->caps, data->xmlopt, + if (!(def =3D virDomainDefParseString(xml, data->xmlopt, NULL, parse_flags))) return ret; =20 @@ -4257,7 +4257,7 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr do= m, =20 def->os.type =3D VIR_DOMAIN_OSTYPE_HVM; =20 - dev =3D virDomainDeviceDefParse(xml, def, data->caps, data->xmlopt, NU= LL, + dev =3D virDomainDeviceDefParse(xml, def, data->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE); if (dev =3D=3D NULL) goto cleanup; @@ -4376,7 +4376,7 @@ static int vboxDomainDetachDevice(virDomainPtr dom, c= onst char *xml) =20 def->os.type =3D VIR_DOMAIN_OSTYPE_HVM; =20 - dev =3D virDomainDeviceDefParse(xml, def, data->caps, data->xmlopt, NU= LL, + dev =3D virDomainDeviceDefParse(xml, def, data->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE); if (dev =3D=3D NULL) diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index b30c8847d3..32c81b13a0 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -421,7 +421,7 @@ vmwareDomainDefineXMLFlags(virConnectPtr conn, const ch= ar *xml, unsigned int fla ctx.datacenterPath =3D NULL; =20 vmwareDriverLock(driver); - if ((vmdef =3D virDomainDefParseString(xml, driver->caps, driver->xmlo= pt, + if ((vmdef =3D virDomainDefParseString(xml, driver->xmlopt, NULL, parse_flags)) =3D=3D NULL) goto cleanup; =20 @@ -683,7 +683,7 @@ vmwareDomainCreateXML(virConnectPtr conn, const char *x= ml, =20 vmwareDriverLock(driver); =20 - if ((vmdef =3D virDomainDefParseString(xml, driver->caps, driver->xmlo= pt, + if ((vmdef =3D virDomainDefParseString(xml, driver->xmlopt, NULL, parse_flags)) =3D=3D NULL) goto cleanup; =20 diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index a76c56334d..0acdcb9760 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -792,7 +792,7 @@ vzDomainDefineXMLFlags(virConnectPtr conn, const char *= xml, unsigned int flags) if (flags & VIR_DOMAIN_DEFINE_VALIDATE) parse_flags |=3D VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA; =20 - if ((def =3D virDomainDefParseString(xml, driver->caps, driver->xmlopt, + if ((def =3D virDomainDefParseString(xml, driver->xmlopt, NULL, parse_flags)) =3D=3D NULL) goto cleanup; =20 @@ -2992,7 +2992,7 @@ vzDomainMigratePrepare3Params(virConnectPtr conn, | VZ_MIGRATION_COOKIE_DOMAIN_NAME) < 0) goto cleanup; =20 - if (!(def =3D virDomainDefParseString(dom_xml, driver->caps, driver->x= mlopt, + if (!(def =3D virDomainDefParseString(dom_xml, driver->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto cleanup; diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c index f5dbb4e154..3c9c61f024 100644 --- a/tests/bhyvexml2argvtest.c +++ b/tests/bhyvexml2argvtest.c @@ -35,7 +35,7 @@ static int testCompareXMLToArgvFiles(const char *xml, if (!(conn =3D virGetConnect())) goto out; =20 - if (!(vmdef =3D virDomainDefParseFile(xml, driver.caps, driver.xmlopt, + if (!(vmdef =3D virDomainDefParseFile(xml, driver.xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIV= E))) { if (flags & FLAG_EXPECT_PARSE_ERROR) { ret =3D 0; diff --git a/tests/domainconftest.c b/tests/domainconftest.c index f48c3ca682..754ef2eb3d 100644 --- a/tests/domainconftest.c +++ b/tests/domainconftest.c @@ -49,7 +49,7 @@ static int testGetFilesystem(const void *opaque) filename =3D g_strdup_printf("%s/domainconfdata/%s.xml", abs_srcdir, data->filename); =20 - if (!(def =3D virDomainDefParseFile(filename, caps, xmlopt, NULL, 0))) + if (!(def =3D virDomainDefParseFile(filename, xmlopt, NULL, 0))) goto cleanup; =20 fsdef =3D virDomainGetFilesystemForTarget(def, diff --git a/tests/libxlxml2domconfigtest.c b/tests/libxlxml2domconfigtest.c index 5c8dcf8503..35f0ce8f7d 100644 --- a/tests/libxlxml2domconfigtest.c +++ b/tests/libxlxml2domconfigtest.c @@ -76,7 +76,7 @@ testCompareXMLToDomConfig(const char *xmlfile, if (!(gports =3D virPortAllocatorRangeNew("vnc", 5900, 6000))) goto cleanup; =20 - if (!(vmdef =3D virDomainDefParseFile(xmlfile, cfg->caps, driver->xmlo= pt, + if (!(vmdef =3D virDomainDefParseFile(xmlfile, driver->xmlopt, NULL, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; =20 diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c index 9dbbfb3cfe..d8824b8f09 100644 --- a/tests/qemuagenttest.c +++ b/tests/qemuagenttest.c @@ -185,7 +185,7 @@ testQemuAgentGetFSInfoCommon(virDomainXMLOptionPtr xmlo= pt, =20 domain_filename =3D g_strdup_printf("%s/qemuagentdata/fsinfo.xml", abs= _srcdir); =20 - if (!(ret_def =3D virDomainDefParseFile(domain_filename, driver.caps, = xmlopt, + if (!(ret_def =3D virDomainDefParseFile(domain_filename, xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACT= IVE))) goto cleanup; =20 diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index b1e53505be..e80545056d 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -87,7 +87,6 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt, return -1; =20 if (!((*vm)->def =3D virDomainDefParseString(domxml, - driver.caps, driver.xmlopt, NULL, parseFlags))) @@ -277,7 +276,7 @@ testQemuHotplug(const void *data) device_parse_flags =3D VIR_DOMAIN_DEF_PARSE_INACTIVE; =20 if (!(dev =3D virDomainDeviceDefParse(device_xml, vm->def, - caps, driver.xmlopt, NULL, + driver.xmlopt, NULL, device_parse_flags))) goto cleanup; =20 diff --git a/tests/qemumemlocktest.c b/tests/qemumemlocktest.c index 55f65dcb6a..986dfb77bd 100644 --- a/tests/qemumemlocktest.c +++ b/tests/qemumemlocktest.c @@ -37,7 +37,7 @@ testCompareMemLock(const void *data) xml =3D g_strdup_printf("%s/qemumemlockdata/qemumemlock-%s.xml", abs_s= rcdir, info->name); =20 - if (!(def =3D virDomainDefParseFile(xml, driver.caps, driver.xmlopt, N= ULL, + if (!(def =3D virDomainDefParseFile(xml, driver.xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE))) { goto cleanup; } diff --git a/tests/qemusecuritytest.c b/tests/qemusecuritytest.c index 8c0a48bb65..380c3fed8c 100644 --- a/tests/qemusecuritytest.c +++ b/tests/qemusecuritytest.c @@ -68,7 +68,6 @@ prepareObjects(virQEMUDriverPtr driver, return -1; =20 if (!(vm->def =3D virDomainDefParseString(domxml, - driver->caps, driver->xmlopt, NULL, 0))) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 6890de101b..fe8fa776be 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -450,7 +450,7 @@ testCompareXMLToArgv(const void *data) =20 parseFlags |=3D VIR_DOMAIN_DEF_PARSE_INACTIVE; if (!(vm->def =3D virDomainDefParseFile(info->infile, - driver.caps, driver.xmlopt, + driver.xmlopt, NULL, parseFlags))) { if (flags & FLAG_EXPECT_PARSE_ERROR) goto ok; diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index f849869735..e5bbd8dec4 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -58,7 +58,7 @@ testCompareStatusXMLToXMLFiles(const void *opaque) char *actual =3D NULL; int ret =3D -1; =20 - if (!(obj =3D virDomainObjParseFile(data->infile, driver.caps, driver.= xmlopt, + if (!(obj =3D virDomainObjParseFile(data->infile, driver.xmlopt, VIR_DOMAIN_DEF_PARSE_STATUS | VIR_DOMAIN_DEF_PARSE_ACTUAL_NET | VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES= | diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabelt= est.c index cbc7018e27..192f2dc84f 100644 --- a/tests/securityselinuxlabeltest.c +++ b/tests/securityselinuxlabeltest.c @@ -175,7 +175,7 @@ testSELinuxLoadDef(const char *testname) xmlfile =3D g_strdup_printf("%s/securityselinuxlabeldata/%s.xml", abs_= srcdir, testname); =20 - if (!(def =3D virDomainDefParseFile(xmlfile, driver.caps, driver.xmlop= t, + if (!(def =3D virDomainDefParseFile(xmlfile, driver.xmlopt, NULL, 0))) goto cleanup; =20 diff --git a/tests/testutils.c b/tests/testutils.c index 94a0e9068f..c55450de96 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -1107,7 +1107,8 @@ virDomainXMLOptionPtr virTestGenericDomainXMLConfInit= (void) =20 =20 int -testCompareDomXML2XMLFiles(virCapsPtr caps, virDomainXMLOptionPtr xmlopt, +testCompareDomXML2XMLFiles(virCapsPtr caps G_GNUC_UNUSED, + virDomainXMLOptionPtr xmlopt, const char *infile, const char *outfile, bool l= ive, unsigned int parseFlags, testCompareDomXML2XMLResult expectResult) @@ -1129,7 +1130,7 @@ testCompareDomXML2XMLFiles(virCapsPtr caps, virDomain= XMLOptionPtr xmlopt, if (!live) format_flags |=3D VIR_DOMAIN_DEF_FORMAT_INACTIVE; =20 - if (!(def =3D virDomainDefParseFile(infile, caps, xmlopt, NULL, parse_= flags))) { + if (!(def =3D virDomainDefParseFile(infile, xmlopt, NULL, parse_flags)= )) { result =3D TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE; goto out; } diff --git a/tests/xlconfigtest.c b/tests/xlconfigtest.c index cdc2c37ed3..3c0469be85 100644 --- a/tests/xlconfigtest.c +++ b/tests/xlconfigtest.c @@ -83,11 +83,11 @@ testCompareParseXML(const char *xlcfg, const char *xml,= bool replaceVars) if (replaceVars) { if (!(replacedXML =3D testReplaceVarsXML(xml))) goto fail; - if (!(def =3D virDomainDefParseString(replacedXML, cfg->caps, driv= er->xmlopt, + if (!(def =3D virDomainDefParseString(replacedXML, driver->xmlopt, NULL, VIR_DOMAIN_XML_INACTIVE)= )) goto fail; } else { - if (!(def =3D virDomainDefParseFile(xml, cfg->caps, driver->xmlopt, + if (!(def =3D virDomainDefParseFile(xml, driver->xmlopt, NULL, VIR_DOMAIN_XML_INACTIVE))) goto fail; } diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c index f8652e228c..7e324eb5d2 100644 --- a/tests/xmconfigtest.c +++ b/tests/xmconfigtest.c @@ -53,7 +53,7 @@ testCompareParseXML(const char *xmcfg, const char *xml) conn =3D virGetConnect(); if (!conn) goto fail; =20 - if (!(def =3D virDomainDefParseFile(xml, cfg->caps, driver->xmlopt, NU= LL, + if (!(def =3D virDomainDefParseFile(xml, driver->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto fail; =20 diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index 39781beafd..8f0a2a72a4 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -74,7 +74,7 @@ testCompareFiles(const char *xml, const char *vmx, int vi= rtualHW_version) char *formatted =3D NULL; virDomainDefPtr def =3D NULL; =20 - def =3D virDomainDefParseFile(xml, caps, xmlopt, NULL, + def =3D virDomainDefParseFile(xml, xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE); =20 if (def =3D=3D NULL) --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 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=1575469333; cv=none; d=zohomail.com; s=zohoarc; b=nwGF0YvOwdGvoLUQ2hfhmc4pWLcBFbZdZoRZFsA7v8yoqe9wGyEkf1y9ScMFdgtloACSLXOVBJ9T0K6LxjjLx22HctdhuS3u8jFjFCoOnK5QYv0pZpFj7ddTCLOJqUd1tnTO6jptBNlRkg1pmJjBP5REqC/RXcb/k44VXgxaS+Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469333; 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=TfXqdtSWiWvawojcuv8d6DOl7keN1OMIsj+gIc//mIQ=; b=YqD8IA+LOhRK7I4/7JH83JoAivbVYFO1YF7M01cTTq1Gmu83JTZuduQA9UPuRWON08qIpegW5wOSUvR8sFUcvfN0lhvO0AMeJ8ILYj8J/g2MRQDqJ1+KPa0V0057V4hi/QLcGXJe3ObzswV4rk228tJKR/0dc49YoF4dE86AbqM= 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-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1575469333329720.0646439411088; Wed, 4 Dec 2019 06:22:13 -0800 (PST) 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-89-Fw5onOs7NcyqlT8F27d41A-1; Wed, 04 Dec 2019 09:22:07 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CDFF9800D5C; Wed, 4 Dec 2019 14:21:59 +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 A5539600CE; Wed, 4 Dec 2019 14:21:59 +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 5E03565D21; Wed, 4 Dec 2019 14:21:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4ELkcB008266 for ; Wed, 4 Dec 2019 09:21:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9C86D691B0; Wed, 4 Dec 2019 14:21:46 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 92CA8608F7; Wed, 4 Dec 2019 14:21:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469332; 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=TfXqdtSWiWvawojcuv8d6DOl7keN1OMIsj+gIc//mIQ=; b=e9nBjQusfpS41ratAVR/ReOZABy2KlvOmqB8vIyXS5UziJZAEjDJrfZxo8g8lNcnbgoLTs nK4zzoV3m49qXkkOGpLhVKBHnV+xICJTnKbt3bpGxDQYIFIP9OBVDzdqqaqzcKCYZSPZvl W0ZU7efDtmxshj/EECUif8BZe/GGRnc= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:21:03 +0000 Message-Id: <20191204142113.2961028-21-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 20/30] conf: drop virCapsPtr param from domain APIs for copying config 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.11 X-MC-Unique: Fw5onOs7NcyqlT8F27d41A-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 17 ++++++----------- src/conf/domain_conf.h | 9 ++------- src/libxl/libxl_domain.c | 6 +++--- src/libxl/libxl_driver.c | 15 ++++++--------- src/libxl/libxl_migration.c | 3 +-- src/lxc/lxc_driver.c | 22 ++++++---------------- src/lxc/lxc_process.c | 2 +- src/qemu/qemu_domain.c | 7 +------ src/qemu/qemu_driver.c | 26 +++++++++++--------------- src/qemu/qemu_migration.c | 2 +- src/qemu/qemu_process.c | 2 +- src/test/test_driver.c | 7 ++----- tests/qemuhotplugtest.c | 2 +- 13 files changed, 42 insertions(+), 78 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 00b5da8d52..011e104220 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3670,8 +3670,7 @@ virDomainObjWaitUntil(virDomainObjPtr vm, * @return 0 on success, -1 on failure */ int -virDomainObjSetDefTransient(virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, +virDomainObjSetDefTransient(virDomainXMLOptionPtr xmlopt, virDomainObjPtr domain, void *parseOpaque) { @@ -3683,7 +3682,7 @@ virDomainObjSetDefTransient(virCapsPtr caps, if (domain->newDef) return 0; =20 - if (!(domain->newDef =3D virDomainDefCopy(domain->def, caps, xmlopt, + if (!(domain->newDef =3D virDomainDefCopy(domain->def, xmlopt, parseOpaque, false))) goto out; =20 @@ -3721,13 +3720,12 @@ virDomainObjRemoveTransientDef(virDomainObjPtr doma= in) * @return NULL on error, virDOmainDefPtr on success */ virDomainDefPtr -virDomainObjGetPersistentDef(virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, +virDomainObjGetPersistentDef(virDomainXMLOptionPtr xmlopt, virDomainObjPtr domain, void *parseOpaque) { if (virDomainObjIsActive(domain) && - virDomainObjSetDefTransient(caps, xmlopt, domain, parseOpaque) < 0) + virDomainObjSetDefTransient(xmlopt, domain, parseOpaque) < 0) return NULL; =20 if (domain->newDef) @@ -29304,7 +29302,6 @@ virDomainUSBDeviceDefForeach(virDomainDefPtr def, * snapshots). */ virDomainDefPtr virDomainDefCopy(virDomainDefPtr src, - virCapsPtr caps G_GNUC_UNUSED, virDomainXMLOptionPtr xmlopt, void *parseOpaque, bool migratable) @@ -29326,14 +29323,13 @@ virDomainDefCopy(virDomainDefPtr src, =20 virDomainDefPtr virDomainObjCopyPersistentDef(virDomainObjPtr dom, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, void *parseOpaque) { virDomainDefPtr cur; =20 - cur =3D virDomainObjGetPersistentDef(caps, xmlopt, dom, parseOpaque); - return virDomainDefCopy(cur, caps, xmlopt, parseOpaque, false); + cur =3D virDomainObjGetPersistentDef(xmlopt, dom, parseOpaque); + return virDomainDefCopy(cur, xmlopt, parseOpaque, false); } =20 =20 @@ -29778,7 +29774,6 @@ virDomainNetFindByName(virDomainDefPtr def, virDomainDeviceDefPtr virDomainDeviceDefCopy(virDomainDeviceDefPtr src, const virDomainDef *def, - virCapsPtr caps G_GNUC_UNUSED, virDomainXMLOptionPtr xmlopt, void *parseOpaque) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 5255c8190e..1aac01a386 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2895,7 +2895,6 @@ void virDomainShmemDefFree(virDomainShmemDefPtr def); void virDomainDeviceDefFree(virDomainDeviceDefPtr def); virDomainDeviceDefPtr virDomainDeviceDefCopy(virDomainDeviceDefPtr src, const virDomainDef *def, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, void *parseOpaque); virDomainDeviceInfoPtr virDomainDeviceGetInfo(virDomainDeviceDefPtr device= ); @@ -2936,14 +2935,12 @@ void virDomainObjAssignDef(virDomainObjPtr domain, virDomainDefPtr def, bool live, virDomainDefPtr *oldDef); -int virDomainObjSetDefTransient(virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, +int virDomainObjSetDefTransient(virDomainXMLOptionPtr xmlopt, virDomainObjPtr domain, void *parseOpaque); void virDomainObjRemoveTransientDef(virDomainObjPtr domain); virDomainDefPtr -virDomainObjGetPersistentDef(virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, +virDomainObjGetPersistentDef(virDomainXMLOptionPtr xmlopt, virDomainObjPtr domain, void *parseOpaque); =20 @@ -2960,12 +2957,10 @@ virDomainDefPtr virDomainObjGetOneDefState(virDomai= nObjPtr vm, virDomainDefPtr virDomainObjGetOneDef(virDomainObjPtr vm, unsigned int fla= gs); =20 virDomainDefPtr virDomainDefCopy(virDomainDefPtr src, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, void *parseOpaque, bool migratable); virDomainDefPtr virDomainObjCopyPersistentDef(virDomainObjPtr dom, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, void *parseOpaque); =20 diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index fea20ba477..0ad511c373 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -1322,7 +1322,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver, VIR_FREE(managed_save_path); } =20 - if (virDomainObjSetDefTransient(cfg->caps, driver->xmlopt, vm, NULL) <= 0) + if (virDomainObjSetDefTransient(driver->xmlopt, vm, NULL) < 0) goto cleanup; =20 /* Run an early hook to set-up missing devices */ @@ -1550,8 +1550,8 @@ libxlDomainDefCheckABIStability(libxlDriverPrivatePtr= driver, g_autoptr(libxlDriverConfig) cfg =3D libxlDriverConfigGet(driver); bool ret =3D false; =20 - if (!(migratableDefSrc =3D virDomainDefCopy(src, cfg->caps, driver->xm= lopt, NULL, true)) || - !(migratableDefDst =3D virDomainDefCopy(dst, cfg->caps, driver->xm= lopt, NULL, true))) + if (!(migratableDefSrc =3D virDomainDefCopy(src, driver->xmlopt, NULL,= true)) || + !(migratableDefDst =3D virDomainDefCopy(dst, driver->xmlopt, NULL,= true))) goto cleanup; =20 ret =3D virDomainDefCheckABIStability(migratableDefSrc, diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index abf359ad1b..11a08ed68a 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -1601,7 +1601,7 @@ libxlDomainGetMaxMemory(virDomainPtr dom) * domain configuration if needed. Return -1 on error. */ static int -virDomainLiveConfigHelperMethod(virCapsPtr caps, +virDomainLiveConfigHelperMethod(virCapsPtr caps G_GNUC_UNUSED, virDomainXMLOptionPtr xmlopt, virDomainObjPtr dom, unsigned int *flags, @@ -1611,7 +1611,7 @@ virDomainLiveConfigHelperMethod(virCapsPtr caps, return -1; =20 if (*flags & VIR_DOMAIN_AFFECT_CONFIG) { - if (!(*persistentDef =3D virDomainObjGetPersistentDef(caps, xmlopt= , dom, NULL))) { + if (!(*persistentDef =3D virDomainObjGetPersistentDef(xmlopt, dom,= NULL))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Get persistent config failed")); return -1; @@ -2298,7 +2298,7 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned i= nt nvcpus, goto endjob; } =20 - if (!(def =3D virDomainObjGetPersistentDef(cfg->caps, driver->xmlopt, = vm, NULL))) + if (!(def =3D virDomainObjGetPersistentDef(driver->xmlopt, vm, NULL))) goto endjob; =20 maplen =3D VIR_CPU_MAPLEN(nvcpus); @@ -4121,8 +4121,7 @@ libxlDomainAttachDeviceFlags(virDomainPtr dom, const = char *xml, goto endjob; =20 /* Make a copy for updated domain. */ - if (!(vmdef =3D virDomainObjCopyPersistentDef(vm, cfg->caps, - driver->xmlopt, NULL))) + if (!(vmdef =3D virDomainObjCopyPersistentDef(vm, driver->xmlopt, = NULL))) goto endjob; =20 if (libxlDomainAttachDeviceConfig(vmdef, dev) < 0) @@ -4211,8 +4210,7 @@ libxlDomainDetachDeviceFlags(virDomainPtr dom, const = char *xml, goto endjob; =20 /* Make a copy for updated domain. */ - if (!(vmdef =3D virDomainObjCopyPersistentDef(vm, cfg->caps, - driver->xmlopt, NULL))) + if (!(vmdef =3D virDomainObjCopyPersistentDef(vm, driver->xmlopt, = NULL))) goto endjob; =20 if (libxlDomainDetachDeviceConfig(vmdef, dev) < 0) @@ -4298,8 +4296,7 @@ libxlDomainUpdateDeviceFlags(virDomainPtr dom, const = char *xml, goto cleanup; =20 /* Make a copy for updated domain. */ - if (!(vmdef =3D virDomainObjCopyPersistentDef(vm, cfg->caps, - driver->xmlopt, NULL))) + if (!(vmdef =3D virDomainObjCopyPersistentDef(vm, driver->xmlopt, = NULL))) goto cleanup; =20 if ((ret =3D libxlDomainUpdateDeviceConfig(vmdef, dev)) < 0) diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index d744816510..0d10da1811 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -1321,8 +1321,7 @@ libxlDomainMigrationDstFinish(virConnectPtr dconn, virDomainDefPtr vmdef; =20 vm->persistent =3D 1; - if (!(vmdef =3D virDomainObjGetPersistentDef(cfg->caps, - driver->xmlopt, vm, NUL= L))) + if (!(vmdef =3D virDomainObjGetPersistentDef(driver->xmlopt, vm, N= ULL))) goto cleanup; =20 if (virDomainDefSave(vmdef, driver->xmlopt, cfg->caps, cfg->config= Dir) < 0) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 1ef15bfcf8..55945bafcd 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1907,7 +1907,7 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom, =20 if (persistentDef) { /* Make a copy for updated domain. */ - persistentDefCopy =3D virDomainObjCopyPersistentDef(vm, caps, driv= er->xmlopt, NULL); + persistentDefCopy =3D virDomainObjCopyPersistentDef(vm, driver->xm= lopt, NULL); if (!persistentDefCopy) goto endjob; } @@ -4673,7 +4673,6 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr do= m, unsigned int flags) { virLXCDriverPtr driver =3D dom->conn->privateData; - virCapsPtr caps =3D NULL; virDomainObjPtr vm =3D NULL; virDomainDefPtr vmdef =3D NULL; virDomainDeviceDefPtr dev =3D NULL, dev_copy =3D NULL; @@ -4692,9 +4691,6 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr do= m, if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0) goto cleanup; =20 - if (!(caps =3D virLXCDriverGetCapabilities(driver, false))) - goto endjob; - if (virDomainObjUpdateModificationImpact(vm, &flags) < 0) goto endjob; =20 @@ -4711,14 +4707,14 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr = dom, * to CONFIG takes one instance. */ dev_copy =3D virDomainDeviceDefCopy(dev, vm->def, - caps, driver->xmlopt, NULL); + driver->xmlopt, NULL); if (!dev_copy) goto endjob; } =20 if (flags & VIR_DOMAIN_AFFECT_CONFIG) { /* Make a copy for updated domain. */ - vmdef =3D virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt, = NULL); + vmdef =3D virDomainObjCopyPersistentDef(vm, driver->xmlopt, NULL); if (!vmdef) goto endjob; =20 @@ -4768,7 +4764,6 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr do= m, virDomainDeviceDefFree(dev_copy); virDomainDeviceDefFree(dev); virDomainObjEndAPI(&vm); - virObjectUnref(caps); virObjectUnref(cfg); return ret; } @@ -4787,7 +4782,6 @@ static int lxcDomainUpdateDeviceFlags(virDomainPtr do= m, unsigned int flags) { virLXCDriverPtr driver =3D dom->conn->privateData; - virCapsPtr caps =3D NULL; virDomainObjPtr vm =3D NULL; virDomainDefPtr vmdef =3D NULL; virDomainDeviceDefPtr dev =3D NULL; @@ -4815,15 +4809,12 @@ static int lxcDomainUpdateDeviceFlags(virDomainPtr = dom, goto endjob; } =20 - if (!(caps =3D virLXCDriverGetCapabilities(driver, false))) - goto endjob; - if (!(dev =3D virDomainDeviceDefParse(xml, vm->def, driver->xmlopt, NU= LL, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto endjob; =20 /* Make a copy for updated domain. */ - if (!(vmdef =3D virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt= , NULL))) + if (!(vmdef =3D virDomainObjCopyPersistentDef(vm, driver->xmlopt, NULL= ))) goto endjob; =20 /* virDomainDefCompatibleDevice call is delayed until we know the @@ -4845,7 +4836,6 @@ static int lxcDomainUpdateDeviceFlags(virDomainPtr do= m, virDomainDefFree(vmdef); virDomainDeviceDefFree(dev); virDomainObjEndAPI(&vm); - virObjectUnref(caps); virObjectUnref(cfg); return ret; } @@ -4895,14 +4885,14 @@ static int lxcDomainDetachDeviceFlags(virDomainPtr = dom, * to CONFIG takes one instance. */ dev_copy =3D virDomainDeviceDefCopy(dev, vm->def, - caps, driver->xmlopt, NULL); + driver->xmlopt, NULL); if (!dev_copy) goto endjob; } =20 if (flags & VIR_DOMAIN_AFFECT_CONFIG) { /* Make a copy for updated domain. */ - vmdef =3D virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt, = NULL); + vmdef =3D virDomainObjCopyPersistentDef(vm, driver->xmlopt, NULL); if (!vmdef) goto endjob; =20 diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index cd8ee4975b..e648d490c8 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -1266,7 +1266,7 @@ int virLXCProcessStart(virConnectPtr conn, * report implicit runtime defaults in the XML, like vnc listen/socket */ VIR_DEBUG("Setting current domain def as transient"); - if (virDomainObjSetDefTransient(caps, driver->xmlopt, vm, NULL) < 0) + if (virDomainObjSetDefTransient(driver->xmlopt, vm, NULL) < 0) goto cleanup; =20 /* Run an early hook to set-up missing devices */ diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 4c589eec05..3abd37e25d 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9035,17 +9035,13 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr dri= ver, { int ret =3D -1; virDomainDefPtr copy =3D NULL; - virCapsPtr caps =3D NULL; =20 virCheckFlags(VIR_DOMAIN_XML_COMMON_FLAGS | VIR_DOMAIN_XML_UPDATE_CPU,= -1); =20 - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - goto cleanup; - if (!(flags & (VIR_DOMAIN_XML_UPDATE_CPU | VIR_DOMAIN_XML_MIGRATABLE))) goto format; =20 - if (!(copy =3D virDomainDefCopy(def, caps, driver->xmlopt, qemuCaps, + if (!(copy =3D virDomainDefCopy(def, driver->xmlopt, qemuCaps, flags & VIR_DOMAIN_XML_MIGRATABLE))) goto cleanup; =20 @@ -9219,7 +9215,6 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr drive= r, =20 cleanup: virDomainDefFree(copy); - virObjectUnref(caps); return ret; } =20 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 00788e7aca..a3b470d7b8 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8612,7 +8612,7 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr v= m, * rely on the correct vm->def or vm->newDef being passed, so call the * device parse based on which definition is in use */ if (flags & VIR_DOMAIN_AFFECT_CONFIG) { - vmdef =3D virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt, + vmdef =3D virDomainObjCopyPersistentDef(vm, driver->xmlopt, priv->qemuCaps); if (!vmdef) goto cleanup; @@ -8781,7 +8781,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr d= om, * create a deep copy of device as adding * to CONFIG takes one instance. */ - dev_copy =3D virDomainDeviceDefCopy(dev, vm->def, caps, + dev_copy =3D virDomainDeviceDefCopy(dev, vm->def, driver->xmlopt, priv->qemuCaps); if (!dev_copy) goto endjob; @@ -8789,7 +8789,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr d= om, =20 if (flags & VIR_DOMAIN_AFFECT_CONFIG) { /* Make a copy for updated domain. */ - vmdef =3D virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt, + vmdef =3D virDomainObjCopyPersistentDef(vm, driver->xmlopt, priv->qemuCaps); if (!vmdef) goto endjob; @@ -8878,7 +8878,7 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr = driver, * create a deep copy of device as adding * to CONFIG takes one instance. */ - dev_copy =3D virDomainDeviceDefCopy(dev, vm->def, caps, + dev_copy =3D virDomainDeviceDefCopy(dev, vm->def, driver->xmlopt, priv->qemuCaps); if (!dev_copy) goto cleanup; @@ -8886,7 +8886,7 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr = driver, =20 if (flags & VIR_DOMAIN_AFFECT_CONFIG) { /* Make a copy for updated domain. */ - vmdef =3D virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt, = priv->qemuCaps); + vmdef =3D virDomainObjCopyPersistentDef(vm, driver->xmlopt, priv->= qemuCaps); if (!vmdef) goto cleanup; =20 @@ -8967,7 +8967,7 @@ qemuDomainDetachDeviceAliasLiveAndConfig(virQEMUDrive= rPtr driver, if (persistentDef) { virDomainDeviceDef dev; =20 - if (!(vmdef =3D virDomainObjCopyPersistentDef(vm, caps, driver->xm= lopt, + if (!(vmdef =3D virDomainObjCopyPersistentDef(vm, driver->xmlopt, priv->qemuCaps))) goto cleanup; =20 @@ -10570,7 +10570,7 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr = dom, =20 if (persistentDef) { /* Make a copy for updated domain. */ - if (!(persistentDefCopy =3D virDomainObjCopyPersistentDef(vm, caps, + if (!(persistentDefCopy =3D virDomainObjCopyPersistentDef(vm, driver->xm= lopt, priv->qemu= Caps))) goto endjob; @@ -15913,7 +15913,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, goto endjob; =20 if (vm->newDef) { - def->parent.inactiveDom =3D virDomainDefCopy(vm->newDef, caps, + def->parent.inactiveDom =3D virDomainDefCopy(vm->newDef, driver->xmlopt, pri= v->qemuCaps, true); if (!def->parent.inactiveDom) goto endjob; @@ -16441,7 +16441,6 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr sna= pshot, virDomainDefPtr config =3D NULL; virDomainDefPtr inactiveConfig =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D NULL; - g_autoptr(virCaps) caps =3D NULL; bool was_stopped =3D false; qemuDomainSaveCookiePtr cookie; virCPUDefPtr origCPU =3D NULL; @@ -16478,9 +16477,6 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr sna= pshot, if (virDomainRevertToSnapshotEnsureACL(snapshot->domain->conn, vm->def= ) < 0) goto cleanup; =20 - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - goto cleanup; - if (qemuDomainHasBlockjob(vm, false)) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("domain has active block job")); @@ -16532,14 +16528,14 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr s= napshot, } =20 if (snap->def->dom) { - config =3D virDomainDefCopy(snap->def->dom, caps, + config =3D virDomainDefCopy(snap->def->dom, driver->xmlopt, priv->qemuCaps, true); if (!config) goto endjob; } =20 if (snap->def->inactiveDom) { - inactiveConfig =3D virDomainDefCopy(snap->def->inactiveDom, caps, + inactiveConfig =3D virDomainDefCopy(snap->def->inactiveDom, driver->xmlopt, priv->qemuCaps, = true); if (!inactiveConfig) goto endjob; @@ -16552,7 +16548,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr sna= pshot, */ if (snapdef->state =3D=3D VIR_DOMAIN_SNAPSHOT_RUNNING || snapdef->state =3D=3D VIR_DOMAIN_SNAPSHOT_PAUSED) { - inactiveConfig =3D virDomainDefCopy(snap->def->dom, caps, + inactiveConfig =3D virDomainDefCopy(snap->def->dom, driver->xmlopt, priv->qemuCa= ps, true); if (!inactiveConfig) goto endjob; diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 9086a3a95a..1a6c179999 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -4823,7 +4823,7 @@ qemuMigrationDstPersist(virQEMUDriverPtr driver, oldDef =3D vm->newDef; vm->newDef =3D qemuMigrationCookieGetPersistent(mig); =20 - if (!(vmdef =3D virDomainObjGetPersistentDef(caps, driver->xmlopt, vm, + if (!(vmdef =3D virDomainObjGetPersistentDef(driver->xmlopt, vm, priv->qemuCaps))) goto error; =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 33ebdce01e..0302d0489b 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5600,7 +5600,7 @@ qemuProcessInit(virQEMUDriverPtr driver, * report implicit runtime defaults in the XML, like vnc listen/socket */ VIR_DEBUG("Setting current domain def as transient"); - if (virDomainObjSetDefTransient(caps, driver->xmlopt, vm, priv->qemuCa= ps) < 0) + if (virDomainObjSetDefTransient(driver->xmlopt, vm, priv->qemuCaps) < = 0) goto cleanup; =20 if (flags & VIR_QEMU_PROCESS_START_PRETEND) { diff --git a/src/test/test_driver.c b/src/test/test_driver.c index c5c533d369..02f6175e2f 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -696,8 +696,7 @@ testDomainStartState(testDriverPtr privconn, virDomainObjSetState(dom, VIR_DOMAIN_RUNNING, reason); dom->def->id =3D virAtomicIntAdd(&privconn->nextDomID, 1); =20 - if (virDomainObjSetDefTransient(privconn->caps, - privconn->xmlopt, + if (virDomainObjSetDefTransient(privconn->xmlopt, dom, NULL) < 0) { goto cleanup; } @@ -8571,7 +8570,6 @@ testDomainSnapshotCreateXML(virDomainPtr domain, goto cleanup; } else { if (!(def->parent.dom =3D virDomainDefCopy(vm->def, - privconn->caps, privconn->xmlopt, NULL, true))) @@ -8794,7 +8792,7 @@ testDomainRevertToSnapshot(virDomainSnapshotPtr snaps= hot, =20 virDomainSnapshotSetCurrent(vm->snapshots, NULL); =20 - config =3D virDomainDefCopy(snap->def->dom, privconn->caps, + config =3D virDomainDefCopy(snap->def->dom, privconn->xmlopt, NULL, true); if (!config) goto cleanup; @@ -9027,7 +9025,6 @@ testDomainCheckpointCreateXML(virDomainPtr domain, goto cleanup; } else { if (!(def->parent.dom =3D virDomainDefCopy(vm->def, - privconn->caps, privconn->xmlopt, NULL, true))) diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index e80545056d..8e7273b673 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -427,7 +427,7 @@ testQemuHotplugCpuPrepare(const char *test, =20 /* create vm->newDef */ data->vm->persistent =3D true; - if (virDomainObjSetDefTransient(caps, driver.xmlopt, data->vm, NULL) <= 0) + if (virDomainObjSetDefTransient(driver.xmlopt, data->vm, NULL) < 0) goto error; =20 priv =3D data->vm->privateData; --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 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=1575469326; cv=none; d=zohomail.com; s=zohoarc; b=NVucZvjFx7pmtkrKNdWrLfarps2I+70EIymOCVsvaVEQoqGRNjMBow+ZsOqJlZLgnc1+SPWAkis1o+w2SRj0Jg393hyF4wCugoBGbM6ndW/d3qSeFI/lXsJ7HWWqI7ziBSQNN4c6Ki2jcByEBvxmPgzPRxLsCZz317nmHobHETo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469326; 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=41BIC4YAg5YSz6QfXqzP4V0454AN6ukyUiFAoLeRFqw=; b=KzmBDM7+gtaDZPbO02UgYK/ewhnbG1ASiZqZuNot4/67U23slXtVk5SDJr1Nbaj/MTvElcQ5sZoUoUFnTZQ4yapKc7uG8ggFhy/IMtqfjhvDud68oDpiQzR19P50R9taSMyWsJbMBdykmVcadc5vH4BUb3bvzHtoqyzXknpWjaY= 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-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1575469326124119.65894818667334; Wed, 4 Dec 2019 06:22:06 -0800 (PST) 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-347-utrZMZrINkWiLk7THs0-rg-1; Wed, 04 Dec 2019 09:22:00 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1CA11800C75; Wed, 4 Dec 2019 14:21: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 DA43E5C553; Wed, 4 Dec 2019 14:21:50 +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 61B0A180CB3B; Wed, 4 Dec 2019 14:21:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4ELmHe008279 for ; Wed, 4 Dec 2019 09:21:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1D88E67E62; Wed, 4 Dec 2019 14:21:48 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1801A608F7; Wed, 4 Dec 2019 14:21:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469322; 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=41BIC4YAg5YSz6QfXqzP4V0454AN6ukyUiFAoLeRFqw=; b=BHInODpc32tZDACmDyuNIhDBEvzyqCSzCXXNhkRhV3pjQbIi1Jhf/7MrIuT1HE9NZ1xxKS TerKypqHaIfUANMy8ub/b+YGYuen60MAIRrMM8h+IzWLTUEv76ExfAyPtv9REOFLUPLwXf zMdLcHt6E99LbNOlYS8mVHWjgk1zCsc= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:21:04 +0000 Message-Id: <20191204142113.2961028-22-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 21/30] conf: drop virCapsPtr param from APIs for saving domains 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.16 X-MC-Unique: utrZMZrINkWiLk7THs0-rg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/bhyve/bhyve_driver.c | 9 +-- src/bhyve/bhyve_process.c | 16 +----- src/conf/domain_conf.c | 7 +-- src/conf/domain_conf.h | 3 - src/libxl/libxl_domain.c | 2 +- src/libxl/libxl_driver.c | 34 +++++------ src/libxl/libxl_migration.c | 6 +- src/lxc/lxc_driver.c | 39 ++++++------- src/lxc/lxc_process.c | 6 +- src/qemu/qemu_domain.c | 6 +- src/qemu/qemu_driver.c | 110 +++++++++++++++++------------------- src/qemu/qemu_hotplug.c | 8 +-- src/qemu/qemu_migration.c | 8 +-- src/qemu/qemu_process.c | 36 ++++++------ src/test/test_driver.c | 2 +- 15 files changed, 128 insertions(+), 164 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 0e627f2dc8..eecd6532f7 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -540,7 +540,7 @@ bhyveDomainDefineXMLFlags(virConnectPtr conn, const cha= r *xml, unsigned int flag vm->persistent =3D 1; =20 if (virDomainDefSave(vm->newDef ? vm->newDef : vm->def, - privconn->xmlopt, caps, BHYVE_CONFIG_DIR) < 0) { + privconn->xmlopt, BHYVE_CONFIG_DIR) < 0) { virDomainObjListRemove(privconn->domains, vm); goto cleanup; } @@ -1063,7 +1063,6 @@ bhyveDomainSetMetadata(virDomainPtr dom, { bhyveConnPtr privconn =3D dom->conn->privateData; virDomainObjPtr vm; - virCapsPtr caps =3D NULL; int ret =3D -1; =20 virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | @@ -1075,10 +1074,7 @@ bhyveDomainSetMetadata(virDomainPtr dom, if (virDomainSetMetadataEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; =20 - if (!(caps =3D bhyveDriverGetCapabilities(privconn))) - goto cleanup; - - ret =3D virDomainObjSetMetadata(vm, type, metadata, key, uri, caps, + ret =3D virDomainObjSetMetadata(vm, type, metadata, key, uri, privconn->xmlopt, BHYVE_STATE_DIR, BHYVE_CONFIG_DIR, flags); =20 @@ -1090,7 +1086,6 @@ bhyveDomainSetMetadata(virDomainPtr dom, =20 =20 cleanup: - virObjectUnref(caps); virDomainObjEndAPI(&vm); return ret; } diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c index c10e5500c9..519604f898 100644 --- a/src/bhyve/bhyve_process.c +++ b/src/bhyve/bhyve_process.c @@ -110,14 +110,9 @@ virBhyveProcessStart(virConnectPtr conn, bhyveConnPtr privconn =3D conn->privateData; bhyveDomainObjPrivatePtr priv =3D vm->privateData; int ret =3D -1, rc; - virCapsPtr caps =3D NULL; =20 logfile =3D g_strdup_printf("%s/%s.log", BHYVE_LOG_DIR, vm->def->name); =20 - caps =3D bhyveDriverGetCapabilities(privconn); - if (!caps) - goto cleanup; - if ((logfd =3D open(logfile, O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR)) < 0) { virReportSystemError(errno, @@ -211,14 +206,13 @@ virBhyveProcessStart(virConnectPtr conn, virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, reason); priv->mon =3D bhyveMonitorOpen(vm, driver); =20 - if (virDomainObjSave(vm, driver->xmlopt, caps, + if (virDomainObjSave(vm, driver->xmlopt, BHYVE_STATE_DIR) < 0) goto cleanup; =20 ret =3D 0; =20 cleanup: - virObjectUnref(caps); if (devicemap !=3D NULL) { rc =3D unlink(devmap_file); if (rc < 0 && errno !=3D ENOENT) @@ -384,7 +378,6 @@ virBhyveProcessReconnect(virDomainObjPtr vm, char *expected_proctitle =3D NULL; bhyveDomainObjPrivatePtr priv =3D vm->privateData; int ret =3D -1; - virCapsPtr caps =3D NULL; =20 if (!virDomainObjIsActive(vm)) return 0; @@ -392,10 +385,6 @@ virBhyveProcessReconnect(virDomainObjPtr vm, if (!vm->pid) return 0; =20 - caps =3D bhyveDriverGetCapabilities(data->driver); - if (!caps) - return -1; - virObjectLock(vm); =20 kp =3D kvm_getprocs(data->kd, KERN_PROC_PID, vm->pid, &nprocs); @@ -429,11 +418,10 @@ virBhyveProcessReconnect(virDomainObjPtr vm, vm->def->id =3D -1; virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, VIR_DOMAIN_SHUTOFF_UNKNOWN); - ignore_value(virDomainObjSave(vm, data->driver->xmlopt, caps, + ignore_value(virDomainObjSave(vm, data->driver->xmlopt, BHYVE_STATE_DIR)); } =20 - virObjectUnref(caps); virObjectUnlock(vm); VIR_FREE(expected_proctitle); =20 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 011e104220..64084d37d5 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -28987,7 +28987,6 @@ virDomainDefSaveXML(virDomainDefPtr def, int virDomainDefSave(virDomainDefPtr def, virDomainXMLOptionPtr xmlopt, - virCapsPtr caps G_GNUC_UNUSED, const char *configDir) { g_autofree char *xml =3D NULL; @@ -29001,7 +29000,6 @@ virDomainDefSave(virDomainDefPtr def, int virDomainObjSave(virDomainObjPtr obj, virDomainXMLOptionPtr xmlopt, - virCapsPtr caps G_GNUC_UNUSED, const char *statusDir) { unsigned int flags =3D (VIR_DOMAIN_DEF_FORMAT_SECURE | @@ -30093,7 +30091,6 @@ virDomainObjSetMetadata(virDomainObjPtr vm, const char *metadata, const char *key, const char *uri, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, const char *stateDir, const char *configDir, @@ -30112,7 +30109,7 @@ virDomainObjSetMetadata(virDomainObjPtr vm, if (virDomainDefSetMetadata(def, type, metadata, key, uri) < 0) return -1; =20 - if (virDomainObjSave(vm, xmlopt, caps, stateDir) < 0) + if (virDomainObjSave(vm, xmlopt, stateDir) < 0) return -1; } =20 @@ -30121,7 +30118,7 @@ virDomainObjSetMetadata(virDomainObjPtr vm, uri) < 0) return -1; =20 - if (virDomainDefSave(persistentDef, xmlopt, caps, configDir) < 0) + if (virDomainDefSave(persistentDef, xmlopt, configDir) < 0) return -1; } =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 1aac01a386..a4d80c0863 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3280,7 +3280,6 @@ virDomainRedirdevDefPtr virDomainRedirdevDefRemove(vi= rDomainDefPtr def, size_t i =20 int virDomainDefSave(virDomainDefPtr def, virDomainXMLOptionPtr xmlopt, - virCapsPtr caps, const char *configDir) G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) @@ -3288,7 +3287,6 @@ int virDomainDefSave(virDomainDefPtr def, =20 int virDomainObjSave(virDomainObjPtr obj, virDomainXMLOptionPtr xmlopt, - virCapsPtr caps, const char *statusDir) G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) @@ -3538,7 +3536,6 @@ int virDomainObjSetMetadata(virDomainObjPtr vm, const char *metadata, const char *key, const char *uri, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, const char *stateDir, const char *configDir, diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 0ad511c373..ff9502d3bb 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -1470,7 +1470,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver, virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_USER= ); } =20 - if (virDomainObjSave(vm, driver->xmlopt, cfg->caps, cfg->stateDir) < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto destroy_dom; =20 if (virAtomicIntInc(&driver->nactive) =3D=3D 1 && driver->inhibitCallb= ack) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 11a08ed68a..cdb1296aa3 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -453,7 +453,7 @@ libxlReconnectDomain(virDomainObjPtr vm, =20 libxlReconnectNotifyNets(vm->def); =20 - if (virDomainObjSave(vm, driver->xmlopt, cfg->caps, cfg->stateDir) < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) VIR_WARN("Cannot update XML for running Xen guest %s", vm->def->na= me); =20 /* now that we know it's reconnected call the hook if present */ @@ -1188,7 +1188,7 @@ libxlDomainSuspend(virDomainPtr dom) VIR_DOMAIN_EVENT_SUSPENDED_PAUSED= ); } =20 - if (virDomainObjSave(vm, driver->xmlopt, cfg->caps, cfg->stateDir) < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto endjob; =20 ret =3D 0; @@ -1242,7 +1242,7 @@ libxlDomainResume(virDomainPtr dom) VIR_DOMAIN_EVENT_RESUMED_UNPAUSED= ); } =20 - if (virDomainObjSave(vm, driver->xmlopt, cfg->caps, cfg->stateDir) < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto endjob; =20 ret =3D 0; @@ -1667,7 +1667,7 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned = long newmem, virDomainDefSetMemoryTotal(persistentDef, newmem); if (persistentDef->mem.cur_balloon > newmem) persistentDef->mem.cur_balloon =3D newmem; - ret =3D virDomainDefSave(persistentDef, driver->xmlopt, cfg->c= aps, cfg->configDir); + ret =3D virDomainDefSave(persistentDef, driver->xmlopt, cfg->c= onfigDir); goto endjob; } =20 @@ -1700,7 +1700,7 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned = long newmem, if (flags & VIR_DOMAIN_MEM_CONFIG) { sa_assert(persistentDef); persistentDef->mem.cur_balloon =3D newmem; - ret =3D virDomainDefSave(persistentDef, driver->xmlopt, cfg->c= aps, cfg->configDir); + ret =3D virDomainDefSave(persistentDef, driver->xmlopt, cfg->c= onfigDir); goto endjob; } } @@ -2351,13 +2351,13 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned= int nvcpus, ret =3D 0; =20 if (flags & VIR_DOMAIN_VCPU_LIVE) { - if (virDomainObjSave(vm, driver->xmlopt, cfg->caps, cfg->stateDir)= < 0) { + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) { VIR_WARN("Unable to save status on vm %s after changing vcpus", vm->def->name); } } if (flags & VIR_DOMAIN_VCPU_CONFIG) { - if (virDomainDefSave(def, driver->xmlopt, cfg->caps, cfg->configDi= r) < 0) { + if (virDomainDefSave(def, driver->xmlopt, cfg->configDir) < 0) { VIR_WARN("Unable to save configuration of vm %s after changing= vcpus", vm->def->name); } @@ -2507,9 +2507,9 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned in= t vcpu, ret =3D 0; =20 if (flags & VIR_DOMAIN_AFFECT_LIVE) { - ret =3D virDomainObjSave(vm, driver->xmlopt, cfg->caps, cfg->state= Dir); + ret =3D virDomainObjSave(vm, driver->xmlopt, cfg->stateDir); } else if (flags & VIR_DOMAIN_AFFECT_CONFIG) { - ret =3D virDomainDefSave(targetDef, driver->xmlopt, cfg->caps, cfg= ->configDir); + ret =3D virDomainDefSave(targetDef, driver->xmlopt, cfg->configDir= ); } =20 endjob: @@ -2870,7 +2870,7 @@ libxlDomainDefineXMLFlags(virConnectPtr conn, const c= har *xml, unsigned int flag vm->persistent =3D 1; =20 if (virDomainDefSave(vm->newDef ? vm->newDef : vm->def, - driver->xmlopt, cfg->caps, cfg->configDir) < 0) { + driver->xmlopt, cfg->configDir) < 0) { virDomainObjListRemove(driver->domains, vm); goto cleanup; } @@ -4143,7 +4143,7 @@ libxlDomainAttachDeviceFlags(virDomainPtr dom, const = char *xml, * update domain status forcibly because the domain status may be * changed even if we attach the device failed. */ - if (virDomainObjSave(vm, driver->xmlopt, cfg->caps, cfg->stateDir)= < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto endjob; } =20 @@ -4151,7 +4151,7 @@ libxlDomainAttachDeviceFlags(virDomainPtr dom, const = char *xml, =20 /* Finally, if no error until here, we can save config. */ if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) { - ret =3D virDomainDefSave(vmdef, driver->xmlopt, cfg->caps, cfg->co= nfigDir); + ret =3D virDomainDefSave(vmdef, driver->xmlopt, cfg->configDir); if (!ret) { virDomainObjAssignDef(vm, vmdef, false, NULL); vmdef =3D NULL; @@ -4233,7 +4233,7 @@ libxlDomainDetachDeviceFlags(virDomainPtr dom, const = char *xml, * update domain status forcibly because the domain status may be * changed even if we attach the device failed. */ - if (virDomainObjSave(vm, driver->xmlopt, cfg->caps, cfg->stateDir)= < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto endjob; } =20 @@ -4241,7 +4241,7 @@ libxlDomainDetachDeviceFlags(virDomainPtr dom, const = char *xml, =20 /* Finally, if no error until here, we can save config. */ if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) { - ret =3D virDomainDefSave(vmdef, driver->xmlopt, cfg->caps, cfg->co= nfigDir); + ret =3D virDomainDefSave(vmdef, driver->xmlopt, cfg->configDir); if (!ret) { virDomainObjAssignDef(vm, vmdef, false, NULL); vmdef =3D NULL; @@ -4320,13 +4320,13 @@ libxlDomainUpdateDeviceFlags(virDomainPtr dom, cons= t char *xml, * update domain status forcibly because the domain status may be * changed even if we attach the device failed. */ - if (virDomainObjSave(vm, driver->xmlopt, cfg->caps, cfg->stateDir)= < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) ret =3D -1; } =20 /* Finally, if no error until here, we can save config. */ if (!ret && (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG)) { - ret =3D virDomainDefSave(vmdef, driver->xmlopt, cfg->caps, cfg->co= nfigDir); + ret =3D virDomainDefSave(vmdef, driver->xmlopt, cfg->configDir); if (!ret) { virDomainObjAssignDef(vm, vmdef, false, NULL); vmdef =3D NULL; @@ -6526,7 +6526,7 @@ libxlDomainSetMetadata(virDomainPtr dom, if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) goto cleanup; =20 - ret =3D virDomainObjSetMetadata(vm, type, metadata, key, uri, cfg->cap= s, + ret =3D virDomainObjSetMetadata(vm, type, metadata, key, uri, driver->xmlopt, cfg->stateDir, cfg->configDir, flags); =20 diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index 0d10da1811..404c437a22 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -1324,7 +1324,7 @@ libxlDomainMigrationDstFinish(virConnectPtr dconn, if (!(vmdef =3D virDomainObjGetPersistentDef(driver->xmlopt, vm, N= ULL))) goto cleanup; =20 - if (virDomainDefSave(vmdef, driver->xmlopt, cfg->caps, cfg->config= Dir) < 0) + if (virDomainDefSave(vmdef, driver->xmlopt, cfg->configDir) < 0) goto cleanup; =20 event =3D virDomainEventLifecycleNewFromObj(vm, @@ -1336,7 +1336,7 @@ libxlDomainMigrationDstFinish(virConnectPtr dconn, event =3D NULL; } =20 - if (virDomainObjSave(vm, driver->xmlopt, cfg->caps, cfg->stateDir) < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto cleanup; =20 dom =3D virGetDomain(dconn, vm->def->name, vm->def->uuid, vm->def->id); @@ -1386,7 +1386,7 @@ libxlDomainMigrationSrcConfirm(libxlDriverPrivatePtr = driver, VIR_DOMAIN_PAUSED_MIGRATION); event =3D virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVE= NT_SUSPENDED, VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED); - ignore_value(virDomainObjSave(vm, driver->xmlopt, cfg->caps, c= fg->stateDir)); + ignore_value(virDomainObjSave(vm, driver->xmlopt, cfg->stateDi= r)); } goto cleanup; } diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 55945bafcd..3467b07538 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -444,7 +444,7 @@ lxcDomainDefineXMLFlags(virConnectPtr conn, const char = *xml, unsigned int flags) vm->persistent =3D 1; =20 if (virDomainDefSave(vm->newDef ? vm->newDef : vm->def, - driver->xmlopt, driver->caps, cfg->configDir) < 0= ) { + driver->xmlopt, cfg->configDir) < 0) { virDomainObjListRemove(driver->domains, vm); goto cleanup; } @@ -678,7 +678,7 @@ static int lxcDomainSetMemoryFlags(virDomainPtr dom, un= signed long newmem, if (persistentDef->mem.cur_balloon > newmem) persistentDef->mem.cur_balloon =3D newmem; if (virDomainDefSave(persistentDef, - driver->xmlopt, driver->caps, cfg->config= Dir) < 0) + driver->xmlopt, cfg->configDir) < 0) goto endjob; } } else { @@ -705,14 +705,14 @@ static int lxcDomainSetMemoryFlags(virDomainPtr dom, = unsigned long newmem, } =20 def->mem.cur_balloon =3D newmem; - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->st= ateDir) < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto endjob; } =20 if (persistentDef) { persistentDef->mem.cur_balloon =3D newmem; if (virDomainDefSave(persistentDef, - driver->xmlopt, driver->caps, cfg->config= Dir) < 0) + driver->xmlopt, cfg->configDir) < 0) goto endjob; } } @@ -857,11 +857,11 @@ lxcDomainSetMemoryParameters(virDomainPtr dom, #undef VIR_SET_MEM_PARAMETER =20 if (def && - virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) + virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto endjob; =20 if (persistentDef && - virDomainDefSave(persistentDef, driver->xmlopt, driver->caps, cfg-= >configDir) < 0) + virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir) < = 0) goto endjob; /* QEMU and LXC implementations are identical */ =20 @@ -1967,12 +1967,12 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr d= om, } } =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto endjob; =20 =20 if (persistentDef) { - rc =3D virDomainDefSave(persistentDefCopy, driver->xmlopt, driver-= >caps, + rc =3D virDomainDefSave(persistentDefCopy, driver->xmlopt, cfg->configDir); if (rc < 0) goto endjob; @@ -2673,7 +2673,7 @@ lxcDomainSetBlkioParameters(virDomainPtr dom, } } =20 - if (virDomainDefSave(persistentDef, driver->xmlopt, driver->caps, = cfg->configDir) < 0) + if (virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir= ) < 0) ret =3D -1; } =20 @@ -3030,7 +3030,7 @@ static int lxcDomainSuspend(virDomainPtr dom) VIR_DOMAIN_EVENT_SUSPENDED_PAUSED= ); } =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto endjob; ret =3D 0; =20 @@ -3087,7 +3087,7 @@ static int lxcDomainResume(virDomainPtr dom) VIR_DOMAIN_EVENT_RESUMED_UNPAUSED= ); } =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto endjob; ret =3D 0; =20 @@ -4740,7 +4740,7 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr do= m, * changed even if we failed to attach the device. For example, * a new controller may be created. */ - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) { ret =3D -1; goto endjob; } @@ -4748,7 +4748,7 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr do= m, =20 /* Finally, if no error until here, we can save config. */ if (flags & VIR_DOMAIN_AFFECT_CONFIG) { - ret =3D virDomainDefSave(vmdef, driver->xmlopt, driver->caps, cfg-= >configDir); + ret =3D virDomainDefSave(vmdef, driver->xmlopt, cfg->configDir); if (!ret) { virDomainObjAssignDef(vm, vmdef, false, NULL); vmdef =3D NULL; @@ -4822,7 +4822,7 @@ static int lxcDomainUpdateDeviceFlags(virDomainPtr do= m, if (lxcDomainUpdateDeviceConfig(vmdef, dev) < 0) goto endjob; =20 - if (virDomainDefSave(vmdef, driver->xmlopt, driver->caps, cfg->configD= ir) < 0) + if (virDomainDefSave(vmdef, driver->xmlopt, cfg->configDir) < 0) goto endjob; =20 virDomainObjAssignDef(vm, vmdef, false, NULL); @@ -4908,7 +4908,7 @@ static int lxcDomainDetachDeviceFlags(virDomainPtr do= m, * changed even if we failed to attach the device. For example, * a new controller may be created. */ - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) { ret =3D -1; goto endjob; } @@ -4916,7 +4916,7 @@ static int lxcDomainDetachDeviceFlags(virDomainPtr do= m, =20 /* Finally, if no error until here, we can save config. */ if (flags & VIR_DOMAIN_AFFECT_CONFIG) { - ret =3D virDomainDefSave(vmdef, driver->xmlopt, driver->caps, cfg-= >configDir); + ret =3D virDomainDefSave(vmdef, driver->xmlopt, cfg->configDir); if (!ret) { virDomainObjAssignDef(vm, vmdef, false, NULL); vmdef =3D NULL; @@ -5207,7 +5207,6 @@ lxcDomainSetMetadata(virDomainPtr dom, virLXCDriverPtr driver =3D dom->conn->privateData; virDomainObjPtr vm; virLXCDriverConfigPtr cfg =3D NULL; - virCapsPtr caps =3D NULL; int ret =3D -1; =20 virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | @@ -5221,13 +5220,10 @@ lxcDomainSetMetadata(virDomainPtr dom, if (virDomainSetMetadataEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; =20 - if (!(caps =3D virLXCDriverGetCapabilities(driver, false))) - goto cleanup; - if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0) goto cleanup; =20 - ret =3D virDomainObjSetMetadata(vm, type, metadata, key, uri, caps, + ret =3D virDomainObjSetMetadata(vm, type, metadata, key, uri, driver->xmlopt, cfg->stateDir, cfg->configDir, flags); =20 @@ -5241,7 +5237,6 @@ lxcDomainSetMetadata(virDomainPtr dom, =20 cleanup: virDomainObjEndAPI(&vm); - virObjectUnref(caps); virObjectUnref(cfg); return ret; } diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index e648d490c8..3688973abf 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -790,7 +790,7 @@ static void virLXCProcessMonitorInitNotify(virLXCMonito= rPtr mon G_GNUC_UNUSED, } virDomainAuditInit(vm, initpid, inode); =20 - if (virDomainObjSave(vm, lxc_driver->xmlopt, lxc_driver->caps, cfg->st= ateDir) < 0) + if (virDomainObjSave(vm, lxc_driver->xmlopt, cfg->stateDir) < 0) VIR_WARN("Cannot update XML with PID for LXC %s", vm->def->name); =20 virObjectUnlock(vm); @@ -1457,7 +1457,7 @@ int virLXCProcessStart(virConnectPtr conn, =20 /* Write domain status to disk for the controller to * read when it starts */ - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto cleanup; =20 /* Allow the child to exec the controller */ @@ -1696,7 +1696,7 @@ virLXCProcessReconnectDomain(virDomainObjPtr vm, =20 virLXCProcessReconnectNotifyNets(vm->def); =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) VIR_WARN("Cannot update XML for running LXC guest %s", vm->def= ->name); =20 /* now that we know it's reconnected call the hook if present */ diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 3abd37e25d..ee99759ded 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8189,7 +8189,7 @@ qemuDomainObjSaveStatus(virQEMUDriverPtr driver, virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); =20 if (virDomainObjIsActive(obj)) { - if (virDomainObjSave(obj, driver->xmlopt, driver->caps, cfg->state= Dir) < 0) + if (virDomainObjSave(obj, driver->xmlopt, cfg->stateDir) < 0) VIR_WARN("Failed to save status on vm %s", obj->def->name); } =20 @@ -8221,7 +8221,7 @@ qemuDomainSaveConfig(virDomainObjPtr obj) =20 cfg =3D virQEMUDriverGetConfig(driver); =20 - if (virDomainDefSave(def, driver->xmlopt, driver->caps, cfg->configDir= ) < 0) + if (virDomainDefSave(def, driver->xmlopt, cfg->configDir) < 0) VIR_WARN("Failed to save config of vm %s", obj->def->name); } =20 @@ -10083,7 +10083,7 @@ qemuDomainSetFakeReboot(virQEMUDriverPtr driver, =20 priv->fakeReboot =3D value; =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) VIR_WARN("Failed to save status on vm %s", vm->def->name); =20 cleanup: diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a3b470d7b8..91cf3fb21a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1865,7 +1865,7 @@ static int qemuDomainSuspend(virDomainPtr dom) if (qemuProcessStopCPUs(driver, vm, reason, QEMU_ASYNC_JOB_NONE) <= 0) goto endjob; } - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto endjob; ret =3D 0; =20 @@ -1923,7 +1923,7 @@ static int qemuDomainResume(virDomainPtr dom) goto endjob; } } - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto endjob; ret =3D 0; =20 @@ -2365,7 +2365,7 @@ static int qemuDomainSetMemoryFlags(virDomainPtr dom,= unsigned long newmem, =20 if (persistentDef->mem.cur_balloon > newmem) persistentDef->mem.cur_balloon =3D newmem; - ret =3D virDomainDefSave(persistentDef, driver->xmlopt, driver= ->caps, + ret =3D virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir); goto endjob; } @@ -2405,7 +2405,7 @@ static int qemuDomainSetMemoryFlags(virDomainPtr dom,= unsigned long newmem, =20 if (persistentDef) { persistentDef->mem.cur_balloon =3D newmem; - ret =3D virDomainDefSave(persistentDef, driver->xmlopt, driver= ->caps, + ret =3D virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir); goto endjob; } @@ -2480,7 +2480,7 @@ static int qemuDomainSetMemoryStatsPeriod(virDomainPt= r dom, int period, } =20 def->memballoon->period =3D period; - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto endjob; } =20 @@ -2492,7 +2492,7 @@ static int qemuDomainSetMemoryStatsPeriod(virDomainPt= r dom, int period, goto endjob; } persistentDef->memballoon->period =3D period; - ret =3D virDomainDefSave(persistentDef, driver->xmlopt, driver->ca= ps, cfg->configDir); + ret =3D virDomainDefSave(persistentDef, driver->xmlopt, cfg->confi= gDir); goto endjob; } =20 @@ -4202,7 +4202,7 @@ processGuestPanicEvent(virQEMUDriverPtr driver, =20 virObjectEventStateQueue(driver->domainEventState, event); =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) { + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) { VIR_WARN("Unable to save status on vm %s after state change", vm->def->name); } @@ -4282,7 +4282,7 @@ processDeviceDeletedEvent(virQEMUDriverPtr driver, goto endjob; } =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) VIR_WARN("unable to save domain status after removing device %s", devAlias); =20 @@ -4650,7 +4650,7 @@ processSerialChangedEvent(virQEMUDriverPtr driver, =20 dev.data.chr->state =3D newstate; =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) VIR_WARN("unable to save status of domain %s after updating state = of " "channel %s", vm->def->name, devAlias); =20 @@ -4976,7 +4976,7 @@ qemuDomainSetVcpusMax(virQEMUDriverPtr driver, if (virDomainDefSetVcpusMax(persistentDef, nvcpus, driver->xmlopt) < 0) return -1; =20 - if (virDomainDefSave(persistentDef, driver->xmlopt, driver->caps, cfg-= >configDir) < 0) + if (virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir) < = 0) return -1; =20 return 0; @@ -5105,7 +5105,7 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm, vcpuinfo->cpumask =3D tmpmap; tmpmap =3D NULL; =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto cleanup; =20 if (g_snprintf(paramField, VIR_TYPED_PARAM_FIELD_LENGTH, @@ -5188,7 +5188,7 @@ qemuDomainPinVcpuFlags(virDomainPtr dom, vcpuinfo->cpumask =3D pcpumap; pcpumap =3D NULL; =20 - ret =3D virDomainDefSave(persistentDef, driver->xmlopt, driver->ca= ps, cfg->configDir); + ret =3D virDomainDefSave(persistentDef, driver->xmlopt, cfg->confi= gDir); goto endjob; } =20 @@ -5320,7 +5320,7 @@ qemuDomainPinEmulator(virDomainPtr dom, if (!(def->cputune.emulatorpin =3D virBitmapNewCopy(pcpumap))) goto endjob; =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto endjob; =20 str =3D virBitmapFormat(pcpumap); @@ -5340,7 +5340,7 @@ qemuDomainPinEmulator(virDomainPtr dom, if (!(persistentDef->cputune.emulatorpin =3D virBitmapNewCopy(pcpu= map))) goto endjob; =20 - ret =3D virDomainDefSave(persistentDef, driver->xmlopt, driver->ca= ps, cfg->configDir); + ret =3D virDomainDefSave(persistentDef, driver->xmlopt, cfg->confi= gDir); goto endjob; } =20 @@ -5800,7 +5800,7 @@ qemuDomainPinIOThread(virDomainPtr dom, if (virProcessSetAffinity(iothrid->thread_id, pcpumap) < 0) goto endjob; =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto endjob; =20 if (g_snprintf(paramField, VIR_TYPED_PARAM_FIELD_LENGTH, @@ -5833,7 +5833,7 @@ qemuDomainPinIOThread(virDomainPtr dom, iothrid->cpumask =3D cpumask; iothrid->autofill =3D false; =20 - ret =3D virDomainDefSave(persistentDef, driver->xmlopt, driver->ca= ps, cfg->configDir); + ret =3D virDomainDefSave(persistentDef, driver->xmlopt, cfg->confi= gDir); goto endjob; } =20 @@ -6251,7 +6251,7 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver, =20 } =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto endjob; } =20 @@ -6283,7 +6283,7 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver, break; } =20 - if (virDomainDefSave(persistentDef, driver->xmlopt, driver->caps, + if (virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir) < 0) goto endjob; } @@ -6887,7 +6887,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, "%s", _("failed to resume domain")); goto cleanup; } - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) { VIR_WARN("Failed to save status on vm %s", vm->def->name); goto cleanup; } @@ -7594,7 +7594,7 @@ qemuDomainDefineXMLFlags(virConnectPtr conn, vm->persistent =3D 1; =20 if (virDomainDefSave(vm->newDef ? vm->newDef : vm->def, - driver->xmlopt, driver->caps, cfg->configDir) < 0= ) { + driver->xmlopt, cfg->configDir) < 0) { if (oldDef) { /* There is backup so this VM was defined before. * Just restore the backup. */ @@ -8659,13 +8659,13 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr= vm, * changed even if we failed to attach the device. For example, * a new controller may be created. */ - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto cleanup; } =20 /* Finally, if no error until here, we can save config. */ if (flags & VIR_DOMAIN_AFFECT_CONFIG) { - if (virDomainDefSave(vmdef, driver->xmlopt, driver->caps, cfg->con= figDir) < 0) + if (virDomainDefSave(vmdef, driver->xmlopt, cfg->configDir) < 0) goto cleanup; =20 virDomainObjAssignDef(vm, vmdef, false, NULL); @@ -8812,7 +8812,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr d= om, * changed even if we failed to attach the device. For example, * a new controller may be created. */ - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) { ret =3D -1; goto endjob; } @@ -8820,7 +8820,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr d= om, =20 /* Finally, if no error until here, we can save config. */ if (flags & VIR_DOMAIN_AFFECT_CONFIG) { - ret =3D virDomainDefSave(vmdef, driver->xmlopt, driver->caps, cfg-= >configDir); + ret =3D virDomainDefSave(vmdef, driver->xmlopt, cfg->configDir); if (!ret) { virDomainObjAssignDef(vm, vmdef, false, NULL); vmdef =3D NULL; @@ -8910,13 +8910,13 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPt= r driver, * changed even if we failed to attach the device. For example, * a new controller may be created. */ - if (virDomainObjSave(vm, driver->xmlopt, caps, cfg->stateDir) < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto cleanup; } =20 /* Finally, if no error until here, we can save config. */ if (flags & VIR_DOMAIN_AFFECT_CONFIG) { - if (virDomainDefSave(vmdef, driver->xmlopt, caps, cfg->configDir) = < 0) + if (virDomainDefSave(vmdef, driver->xmlopt, cfg->configDir) < 0) goto cleanup; =20 virDomainObjAssignDef(vm, vmdef, false, NULL); @@ -8994,7 +8994,7 @@ qemuDomainDetachDeviceAliasLiveAndConfig(virQEMUDrive= rPtr driver, } =20 if (vmdef) { - if (virDomainDefSave(vmdef, driver->xmlopt, caps, cfg->configDir) = < 0) + if (virDomainDefSave(vmdef, driver->xmlopt, cfg->configDir) < 0) goto cleanup; virDomainObjAssignDef(vm, vmdef, false, NULL); vmdef =3D NULL; @@ -9576,7 +9576,7 @@ qemuDomainSetBlkioParameters(virDomainPtr dom, } } =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto endjob; } if (ret < 0) @@ -9611,7 +9611,7 @@ qemuDomainSetBlkioParameters(virDomainPtr dom, } } =20 - if (virDomainDefSave(persistentDef, driver->xmlopt, driver->caps, = cfg->configDir) < 0) + if (virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir= ) < 0) ret =3D -1; } =20 @@ -9841,11 +9841,11 @@ qemuDomainSetMemoryParameters(virDomainPtr dom, #undef VIR_SET_MEM_PARAMETER =20 if (def && - virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) + virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto endjob; =20 if (persistentDef && - virDomainDefSave(persistentDef, driver->xmlopt, driver->caps, cfg-= >configDir) < 0) + virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir) < = 0) goto endjob; /* QEMU and LXC implementations are identical */ =20 @@ -10108,7 +10108,7 @@ qemuDomainSetNumaParameters(virDomainPtr dom, -1, mode, nodeset) < 0) goto endjob; =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto endjob; } =20 @@ -10119,7 +10119,7 @@ qemuDomainSetNumaParameters(virDomainPtr dom, -1, mode, nodeset) < 0) goto endjob; =20 - if (virDomainDefSave(persistentDef, driver->xmlopt, driver->caps, = cfg->configDir) < 0) + if (virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir= ) < 0) goto endjob; } =20 @@ -10301,7 +10301,7 @@ qemuDomainSetPerfEvents(virDomainPtr dom, VIR_TRISTATE_BOOL_YES : VIR_TRISTATE_BOOL_NO; } =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto endjob; } =20 @@ -10315,7 +10315,7 @@ qemuDomainSetPerfEvents(virDomainPtr dom, VIR_TRISTATE_BOOL_YES : VIR_TRISTATE_BOOL_NO; } =20 - if (virDomainDefSave(persistentDef, driver->xmlopt, driver->caps, = cfg->configDir) < 0) + if (virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir= ) < 0) goto endjob; } =20 @@ -10513,7 +10513,6 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr = dom, int ret =3D -1; int rc; g_autoptr(virQEMUDriverConfig) cfg =3D NULL; - g_autoptr(virCaps) caps =3D NULL; qemuDomainObjPrivatePtr priv; virObjectEventPtr event =3D NULL; virTypedParameterPtr eventParams =3D NULL; @@ -10559,9 +10558,6 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr = dom, goto cleanup; } =20 - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - goto cleanup; - if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; =20 @@ -10777,7 +10773,7 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr = dom, } } =20 - if (virDomainObjSave(vm, driver->xmlopt, caps, cfg->stateDir) < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto endjob; =20 if (eventNparams) { @@ -10787,7 +10783,7 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr = dom, } =20 if (persistentDef) { - rc =3D virDomainDefSave(persistentDefCopy, driver->xmlopt, caps, + rc =3D virDomainDefSave(persistentDefCopy, driver->xmlopt, cfg->configDir); if (rc < 0) goto endjob; @@ -11626,7 +11622,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, goto endjob; } =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto endjob; } =20 @@ -11651,7 +11647,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, } } =20 - if (virDomainDefSave(persistentDef, driver->xmlopt, driver->caps, = cfg->configDir) < 0) + if (virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir= ) < 0) goto endjob; } =20 @@ -14612,7 +14608,7 @@ qemuDomainSnapshotCreateInactiveExternal(virQEMUDri= verPtr driver, defdisk->src =3D g_steal_pointer(&newsrc); } =20 - if (virDomainDefSave(vm->def, driver->xmlopt, driver->caps, cfg->confi= gDir) < 0) + if (virDomainDefSave(vm->def, driver->xmlopt, cfg->configDir) < 0) goto cleanup; =20 ret =3D 0; @@ -15549,8 +15545,8 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr= driver, if (rc < 0) goto cleanup; =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0 || - (vm->newDef && virDomainDefSave(vm->newDef, driver->xmlopt, driver= ->caps, + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0 || + (vm->newDef && virDomainDefSave(vm->newDef, driver->xmlopt, cfg->configDir) < 0)) goto cleanup; =20 @@ -16844,7 +16840,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr sna= pshot, } if (ret =3D=3D 0 && defined && vm->persistent && !(ret =3D virDomainDefSave(vm->newDef ? vm->newDef : vm->def, - driver->xmlopt, driver->caps, cfg->config= Dir))) { + driver->xmlopt, cfg->configDir))) { detail =3D VIR_DOMAIN_EVENT_DEFINED_FROM_SNAPSHOT; virObjectEventStateQueue(driver->domainEventState, virDomainEventLifecycleNewFromObj(vm, @@ -17649,7 +17645,7 @@ qemuDomainBlockJobAbort(virDomainPtr dom, job->state =3D QEMU_BLOCKJOB_STATE_ABORTING; } =20 - ignore_value(virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->s= tateDir)); + ignore_value(virDomainObjSave(vm, driver->xmlopt, cfg->stateDir)); =20 if (!async) { qemuBlockJobUpdate(vm, job, QEMU_ASYNC_JOB_NONE); @@ -19227,7 +19223,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, if (virDomainDiskSetBlockIOTune(disk, &info) < 0) goto endjob; =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto endjob; =20 if (eventNparams) { @@ -19252,7 +19248,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, if (virDomainDiskSetBlockIOTune(conf_disk, &info) < 0) goto endjob; =20 - if (virDomainDefSave(persistentDef, driver->xmlopt, driver->caps, + if (virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir) < 0) goto endjob; } @@ -19513,7 +19509,6 @@ qemuDomainSetMetadata(virDomainPtr dom, virQEMUDriverPtr driver =3D dom->conn->privateData; virDomainObjPtr vm; g_autoptr(virQEMUDriverConfig) cfg =3D NULL; - g_autoptr(virCaps) caps =3D NULL; int ret =3D -1; =20 virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | @@ -19527,13 +19522,10 @@ qemuDomainSetMetadata(virDomainPtr dom, if (virDomainSetMetadataEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; =20 - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - goto cleanup; - if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; =20 - ret =3D virDomainObjSetMetadata(vm, type, metadata, key, uri, caps, + ret =3D virDomainObjSetMetadata(vm, type, metadata, key, uri, driver->xmlopt, cfg->stateDir, cfg->configDir, flags); =20 @@ -21854,7 +21846,7 @@ qemuDomainRenameCallback(virDomainObjPtr vm, vm->def->name =3D new_dom_name; new_dom_name =3D NULL; =20 - if (virDomainDefSave(vm->def, driver->xmlopt, driver->caps, cfg->confi= gDir) < 0) + if (virDomainDefSave(vm->def, driver->xmlopt, cfg->configDir) < 0) goto rollback; =20 if (virFileExists(old_dom_cfg_file) && @@ -22378,14 +22370,14 @@ qemuDomainSetLifecycleAction(virDomainPtr dom, =20 qemuDomainModifyLifecycleAction(def, type, action); =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto endjob; } =20 if (persistentDef) { qemuDomainModifyLifecycleAction(persistentDef, type, action); =20 - if (virDomainDefSave(persistentDef, driver->xmlopt, driver->caps, + if (virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir) < 0) goto endjob; } @@ -22681,7 +22673,7 @@ qemuDomainAgentSetResponseTimeout(virDomainPtr dom, QEMU_DOMAIN_PRIVATE(vm)->agentTimeout =3D timeout; =20 if (virDomainObjIsActive(vm) && - virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) + virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto cleanup; =20 ret =3D 0; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index da32a845e1..930f4283c8 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -5980,7 +5980,7 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver, =20 qemuDomainVcpuPersistOrder(vm->def); =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto cleanup; =20 ret =3D 0; @@ -6055,7 +6055,7 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver, =20 qemuDomainVcpuPersistOrder(vm->def); =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto cleanup; =20 ret =3D 0; @@ -6313,7 +6313,7 @@ qemuDomainSetVcpusInternal(virQEMUDriverPtr driver, if (persistentDef) { qemuDomainSetVcpusConfig(persistentDef, nvcpus, hotpluggable); =20 - if (virDomainDefSave(persistentDef, driver->xmlopt, driver->caps, = cfg->configDir) < 0) + if (virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir= ) < 0) goto cleanup; } =20 @@ -6513,7 +6513,7 @@ qemuDomainSetVcpuInternal(virQEMUDriverPtr driver, if (persistentDef) { qemuDomainSetVcpuConfig(persistentDef, map, state); =20 - if (virDomainDefSave(persistentDef, driver->xmlopt, driver->caps, = cfg->configDir) < 0) + if (virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir= ) < 0) goto cleanup; } =20 diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 1a6c179999..c7f9acadeb 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1008,7 +1008,7 @@ qemuMigrationSrcNBDStorageCopy(virQEMUDriverPtr drive= r, tlsAlias, flags) < 0) return -1; =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) { VIR_WARN("Failed to save status on vm %s", vm->def->name); return -1; } @@ -2976,7 +2976,7 @@ qemuMigrationSrcConfirmPhase(virQEMUDriverPtr driver, qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT, priv->job.migParams, priv->job.apiFlags); =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) VIR_WARN("Failed to save status on vm %s", vm->def->name); } =20 @@ -4827,7 +4827,7 @@ qemuMigrationDstPersist(virQEMUDriverPtr driver, priv->qemuCaps))) goto error; =20 - if (virDomainDefSave(vmdef, driver->xmlopt, driver->caps, cfg->configD= ir) < 0 && + if (virDomainDefSave(vmdef, driver->xmlopt, cfg->configDir) < 0 && !ignoreSaveError) goto error; =20 @@ -5080,7 +5080,7 @@ qemuMigrationDstFinish(virQEMUDriverPtr driver, } =20 if (virDomainObjIsActive(vm) && - virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) + virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) VIR_WARN("Failed to save status on vm %s", vm->def->name); =20 /* Guest is successfully running, so cancel previous auto destroy */ diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 0302d0489b..7a0cbc109f 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -411,7 +411,7 @@ qemuProcessHandleReset(qemuMonitorPtr mon G_GNUC_UNUSED, if (priv->agent) qemuAgentNotifyEvent(priv->agent, QEMU_AGENT_EVENT_RESET); =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) VIR_WARN("Failed to save status on vm %s", vm->def->name); =20 if (vm->def->onReboot =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY || @@ -493,7 +493,7 @@ qemuProcessFakeReboot(void *opaque) goto endjob; } =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) { + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) { VIR_WARN("Unable to save status on vm %s after state change", vm->def->name); } @@ -614,7 +614,7 @@ qemuProcessHandleShutdown(qemuMonitorPtr mon G_GNUC_UNU= SED, VIR_DOMAIN_EVENT_SHUTDOWN, detail); =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) { + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) { VIR_WARN("Unable to save status on vm %s after state change", vm->def->name); } @@ -680,7 +680,7 @@ qemuProcessHandleStop(qemuMonitorPtr mon G_GNUC_UNUSED, VIR_WARN("Unable to release lease on %s", vm->def->name); VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState)); =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) { VIR_WARN("Unable to save status on vm %s after state change", vm->def->name); } @@ -726,7 +726,7 @@ qemuProcessHandleResume(qemuMonitorPtr mon G_GNUC_UNUSE= D, VIR_DOMAIN_EVENT_RESUMED, eventDetail); =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) { VIR_WARN("Unable to save status on vm %s after state change", vm->def->name); } @@ -769,7 +769,7 @@ qemuProcessHandleRTCChange(qemuMonitorPtr mon G_GNUC_UN= USED, offset +=3D vm->def->clock.data.variable.adjustment0; vm->def->clock.data.variable.adjustment =3D offset; =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) VIR_WARN("unable to save domain status with RTC change"); } =20 @@ -812,7 +812,7 @@ qemuProcessHandleWatchdog(qemuMonitorPtr mon G_GNUC_UNU= SED, VIR_WARN("Unable to release lease on %s", vm->def->name); VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState)); =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) { VIR_WARN("Unable to save status on vm %s after watchdog event", vm->def->name); } @@ -904,7 +904,7 @@ qemuProcessHandleIOError(qemuMonitorPtr mon G_GNUC_UNUS= ED, VIR_WARN("Unable to release lease on %s", vm->def->name); VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState)); =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) VIR_WARN("Unable to save status on vm %s after IO error", vm->= def->name); } virObjectUnlock(vm); @@ -1149,7 +1149,7 @@ qemuProcessHandleTrayChange(qemuMonitorPtr mon G_GNUC= _UNUSED, else if (reason =3D=3D VIR_DOMAIN_EVENT_TRAY_CHANGE_CLOSE) disk->tray_status =3D VIR_DOMAIN_DISK_TRAY_CLOSED; =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) { VIR_WARN("Unable to save status on vm %s after tray moved even= t", vm->def->name); } @@ -1189,7 +1189,7 @@ qemuProcessHandlePMWakeup(qemuMonitorPtr mon G_GNUC_U= NUSED, VIR_DOMAIN_EVENT_STARTED, VIR_DOMAIN_EVENT_STARTED= _WAKEUP); =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) { VIR_WARN("Unable to save status on vm %s after wakeup event", vm->def->name); } @@ -1227,7 +1227,7 @@ qemuProcessHandlePMSuspend(qemuMonitorPtr mon G_GNUC_= UNUSED, VIR_DOMAIN_EVENT_PMSUSPENDED, VIR_DOMAIN_EVENT_PMSUSPENDED_MEMORY); =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) { VIR_WARN("Unable to save status on vm %s after suspend event", vm->def->name); } @@ -1261,7 +1261,7 @@ qemuProcessHandleBalloonChange(qemuMonitorPtr mon G_G= NUC_UNUSED, vm->def->mem.cur_balloon, actual); vm->def->mem.cur_balloon =3D actual; =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) VIR_WARN("unable to save domain status with balloon change"); =20 virObjectUnlock(vm); @@ -1296,7 +1296,7 @@ qemuProcessHandlePMSuspendDisk(qemuMonitorPtr mon G_G= NUC_UNUSED, VIR_DOMAIN_EVENT_PMSUSPENDED, VIR_DOMAIN_EVENT_PMSUSPENDED_DISK); =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) { VIR_WARN("Unable to save status on vm %s after suspend event", vm->def->name); } @@ -1669,7 +1669,7 @@ qemuProcessHandleMigrationStatus(qemuMonitorPtr mon G= _GNUC_UNUSED, VIR_DOMAIN_EVENT_SUSPEND= ED, VIR_DOMAIN_EVENT_SUSPEND= ED_POSTCOPY); =20 - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir) < 0) { + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) { VIR_WARN("Unable to save status on vm %s after state change", vm->def->name); } @@ -3105,7 +3105,7 @@ qemuProcessUpdateVideoRamSize(virQEMUDriverPtr driver, return -1; =20 cfg =3D virQEMUDriverGetConfig(driver); - ret =3D virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateD= ir); + ret =3D virDomainObjSave(vm, driver->xmlopt, cfg->stateDir); virObjectUnref(cfg); =20 return ret; @@ -6860,7 +6860,7 @@ qemuProcessLaunch(virConnectPtr conn, } =20 VIR_DEBUG("Writing early domain status to disk"); - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto cleanup; =20 VIR_DEBUG("Waiting for handshake from child"); @@ -7118,7 +7118,7 @@ qemuProcessFinishStartup(virQEMUDriverPtr driver, } =20 VIR_DEBUG("Writing domain status to disk"); - if (virDomainObjSave(vm, driver->xmlopt, driver->caps, cfg->stateDir) = < 0) + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto cleanup; =20 if (qemuProcessStartHook(driver, vm, @@ -8221,7 +8221,7 @@ qemuProcessReconnect(void *opaque) } =20 /* update domain state XML with possibly updated state in virDomainObj= */ - if (virDomainObjSave(obj, driver->xmlopt, driver->caps, cfg->stateDir)= < 0) + if (virDomainObjSave(obj, driver->xmlopt, cfg->stateDir) < 0) goto error; =20 /* Run an hook to allow admins to do some magic */ diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 02f6175e2f..788d5d3676 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -4066,7 +4066,7 @@ static int testDomainSetMetadata(virDomainPtr dom, return -1; =20 ret =3D virDomainObjSetMetadata(privdom, type, metadata, key, uri, - privconn->caps, privconn->xmlopt, + privconn->xmlopt, NULL, NULL, flags); =20 if (ret =3D=3D 0) { --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 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=1575469335; cv=none; d=zohomail.com; s=zohoarc; b=egtrXN/pLCn/ZY+PvKP92TqxFE/rU+An4V+Gaj+KchOlsPRDY3YvIsj2zhV1/tLaW2d8jyTfCB9u5hrL6ck6RU6SQb7FkeCyMkgifJ6T0T9qDDXoLtDcC0VPonyuT2KN/MZzLsHmXth9MsLcpKP7tiveN1quudj/2LLbDklbxGE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469335; 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=o5XMjCIxybWhIfnGW0XM5rUiYFtU8/cMx2njIZHJewk=; b=d9VkY4VJg+tmPflH9lXvIIvmuI93c0/FKJwufb/BJ+Nhk6N1OooswHfDOPH0ujA/IvrL4S8xESXLJtD+BU4RSS6FGWNJDtIVnF2Co0Nci4r33eZzlUTwvJUc3C4abGU4RC/QDXVa6OoH3zoqd0WGK34A+c8+Ejfy0T9qQRGLDx4= 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-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1575469335129529.0305341408587; Wed, 4 Dec 2019 06:22:15 -0800 (PST) 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-353-MwJ-E3VMPNyCv2_YFZu-Gg-1; Wed, 04 Dec 2019 09:22:11 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 59FE6800D5E; Wed, 4 Dec 2019 14:22:04 +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 1E17D600CE; Wed, 4 Dec 2019 14:22:04 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A696765D31; Wed, 4 Dec 2019 14:22:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4ELn7i008290 for ; Wed, 4 Dec 2019 09:21:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2CA57608F7; Wed, 4 Dec 2019 14:21:49 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 706D867E62; Wed, 4 Dec 2019 14:21:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469333; 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=o5XMjCIxybWhIfnGW0XM5rUiYFtU8/cMx2njIZHJewk=; b=MhcBcMtmave0lRV+SkGFihbIS3D6210UbzlpX/7LCL31lySY6/waBxmubXph36MGsJo1ua /49Km8X5NM6LdcE64DIJtIalHbjDzr4ZUq/+vFF18A9tzlKjfdHPhBcfcKIhkL9cpNgoE0 3gUUnz8Qt/dabsQmhQmoKkmlXsanUM4= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:21:05 +0000 Message-Id: <20191204142113.2961028-23-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 22/30] conf: drop virCapsPtr param from domain obj list APIs 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.11 X-MC-Unique: MwJ-E3VMPNyCv2_YFZu-Gg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/bhyve/bhyve_driver.c | 2 -- src/conf/virdomainobjlist.c | 5 ----- src/conf/virdomainobjlist.h | 1 - src/libxl/libxl_driver.c | 3 --- src/lxc/lxc_driver.c | 14 -------------- src/qemu/qemu_driver.c | 8 +------- 6 files changed, 1 insertion(+), 32 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index eecd6532f7..a764b4d4ed 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -1249,7 +1249,6 @@ bhyveStateInitialize(bool privileged, if (virDomainObjListLoadAllConfigs(bhyve_driver->domains, BHYVE_STATE_DIR, NULL, true, - bhyve_driver->caps, bhyve_driver->xmlopt, NULL, NULL) < 0) goto cleanup; @@ -1257,7 +1256,6 @@ bhyveStateInitialize(bool privileged, if (virDomainObjListLoadAllConfigs(bhyve_driver->domains, BHYVE_CONFIG_DIR, BHYVE_AUTOSTART_DIR, false, - bhyve_driver->caps, bhyve_driver->xmlopt, NULL, NULL) < 0) goto cleanup; diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c index ae18a4544f..417025ae9f 100644 --- a/src/conf/virdomainobjlist.c +++ b/src/conf/virdomainobjlist.c @@ -483,7 +483,6 @@ virDomainObjListRename(virDomainObjListPtr doms, =20 static virDomainObjPtr virDomainObjListLoadConfig(virDomainObjListPtr doms, - virCapsPtr caps G_GNUC_UNUSED, virDomainXMLOptionPtr xmlopt, const char *configDir, const char *autostartDir, @@ -536,7 +535,6 @@ static virDomainObjPtr virDomainObjListLoadStatus(virDomainObjListPtr doms, const char *statusDir, const char *name, - virCapsPtr caps G_GNUC_UNUSED, virDomainXMLOptionPtr xmlopt, virDomainLoadConfigNotify notify, void *opaque) @@ -586,7 +584,6 @@ virDomainObjListLoadAllConfigs(virDomainObjListPtr doms, const char *configDir, const char *autostartDir, bool liveStatus, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, virDomainLoadConfigNotify notify, void *opaque) @@ -616,13 +613,11 @@ virDomainObjListLoadAllConfigs(virDomainObjListPtr do= ms, dom =3D virDomainObjListLoadStatus(doms, configDir, entry->d_name, - caps, xmlopt, notify, opaque); else dom =3D virDomainObjListLoadConfig(doms, - caps, xmlopt, configDir, autostartDir, diff --git a/src/conf/virdomainobjlist.h b/src/conf/virdomainobjlist.h index da5ec8a57c..6150e13aa4 100644 --- a/src/conf/virdomainobjlist.h +++ b/src/conf/virdomainobjlist.h @@ -66,7 +66,6 @@ int virDomainObjListLoadAllConfigs(virDomainObjListPtr do= ms, const char *configDir, const char *autostartDir, bool liveStatus, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, virDomainLoadConfigNotify notify, void *opaque); diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index cdb1296aa3..568277c714 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -781,7 +781,6 @@ libxlStateInitialize(bool privileged, cfg->stateDir, cfg->autostartDir, true, - cfg->caps, libxl_driver->xmlopt, NULL, NULL) < 0) goto error; @@ -793,7 +792,6 @@ libxlStateInitialize(bool privileged, cfg->configDir, cfg->autostartDir, false, - cfg->caps, libxl_driver->xmlopt, NULL, NULL) < 0) goto error; @@ -833,7 +831,6 @@ libxlStateReload(void) cfg->configDir, cfg->autostartDir, true, - cfg->caps, libxl_driver->xmlopt, NULL, libxl_driver); =20 diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 3467b07538..b40a96b4ce 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1529,7 +1529,6 @@ static int lxcStateInitialize(bool privileged, virStateInhibitCallback callback G_GNUC_UNUS= ED, void *opaque G_GNUC_UNUSED) { - virCapsPtr caps =3D NULL; virLXCDriverConfigPtr cfg =3D NULL; bool autostart =3D true; =20 @@ -1581,9 +1580,6 @@ static int lxcStateInitialize(bool privileged, if (!(lxc_driver->hostdevMgr =3D virHostdevManagerGetDefault())) goto cleanup; =20 - if (!(caps =3D virLXCDriverGetCapabilities(lxc_driver, true))) - goto cleanup; - if (!(lxc_driver->xmlopt =3D lxcDomainXMLConfInit(lxc_driver))) goto cleanup; =20 @@ -1605,7 +1601,6 @@ static int lxcStateInitialize(bool privileged, if (virDomainObjListLoadAllConfigs(lxc_driver->domains, cfg->stateDir, NULL, true, - caps, lxc_driver->xmlopt, NULL, NULL) < 0) goto cleanup; @@ -1616,7 +1611,6 @@ static int lxcStateInitialize(bool privileged, if (virDomainObjListLoadAllConfigs(lxc_driver->domains, cfg->configDir, cfg->autostartDir, false, - caps, lxc_driver->xmlopt, NULL, NULL) < 0) goto cleanup; @@ -1627,11 +1621,9 @@ static int lxcStateInitialize(bool privileged, if (autostart) virLXCProcessAutostartAll(lxc_driver); =20 - virObjectUnref(caps); return VIR_DRV_STATE_INIT_COMPLETE; =20 cleanup: - virObjectUnref(caps); lxcStateCleanup(); return VIR_DRV_STATE_INIT_ERROR; } @@ -1659,23 +1651,17 @@ static int lxcStateReload(void) { virLXCDriverConfigPtr cfg =3D NULL; - virCapsPtr caps =3D NULL; =20 if (!lxc_driver) return 0; =20 - if (!(caps =3D virLXCDriverGetCapabilities(lxc_driver, false))) - return -1; - cfg =3D virLXCDriverGetConfig(lxc_driver); =20 virDomainObjListLoadAllConfigs(lxc_driver->domains, cfg->configDir, cfg->autostartDir, false, - caps, lxc_driver->xmlopt, lxcNotifyLoadDomain, lxc_driver); - virObjectUnref(caps); virObjectUnref(cfg); return 0; } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 91cf3fb21a..0aefe8cd2a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -972,7 +972,6 @@ qemuStateInitialize(bool privileged, if (virDomainObjListLoadAllConfigs(qemu_driver->domains, cfg->stateDir, NULL, true, - qemu_driver->caps, qemu_driver->xmlopt, NULL, NULL) < 0) goto error; @@ -994,7 +993,6 @@ qemuStateInitialize(bool privileged, if (virDomainObjListLoadAllConfigs(qemu_driver->domains, cfg->configDir, cfg->autostartDir, false, - qemu_driver->caps, qemu_driver->xmlopt, NULL, NULL) < 0) goto error; @@ -1059,19 +1057,15 @@ static int qemuStateReload(void) { g_autoptr(virQEMUDriverConfig) cfg =3D NULL; - g_autoptr(virCaps) caps =3D NULL; =20 if (!qemu_driver) return 0; =20 - if (!(caps =3D virQEMUDriverGetCapabilities(qemu_driver, false))) - return 0; - cfg =3D virQEMUDriverGetConfig(qemu_driver); virDomainObjListLoadAllConfigs(qemu_driver->domains, cfg->configDir, cfg->autostartDir, false, - caps, qemu_driver->xmlopt, + qemu_driver->xmlopt, qemuNotifyLoadDomain, qemu_driver); return 0; } --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.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 207.211.31.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=1575469395; cv=none; d=zohomail.com; s=zohoarc; b=P5Rc7o4SMPZCL5UbotWKOsNoX14LfDPRWg3PuAjCms9kOCFXAu0p+oOhPUaxbJdbvRtxQAN9EVvjiWMiBP063UdazgCzI4b3OJE14LqIPRxdNKFikMmDav17Xk/vj2HooBXS3FkS1oLEaRjU13uwQ1sS/9yRTw1pvruCgIf+BV4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469395; 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=04HcYFNIJBv9ffoXeeXcygFbFlTFmz/FYB06vOdsFkE=; b=GzZw1Teiu3LsGAYxIt8dW6YTdk/NA9E3lZRHeux4YYFuV9bzk9nQeyoGH53GYb3tvVuCZTQlsX5dO9dx0HWdh1thLpypVKTq4cKgu9wtYqhTJH2If3sVNSEKtsxEZItCdTB19Nqq3tZj6SJjR4sVUs9BTZ4RkujeDvR2+75P/Rg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.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 [207.211.31.120]) by mx.zohomail.com with SMTPS id 1575469395709265.67688594647893; Wed, 4 Dec 2019 06:23:15 -0800 (PST) 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-347-KfK-OwChPtCi55YLSnnO6w-1; Wed, 04 Dec 2019 09:22:19 -0500 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 7F655183B704; Wed, 4 Dec 2019 14:22:06 +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 4BDDC691B2; Wed, 4 Dec 2019 14:22:06 +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 0177C65D34; Wed, 4 Dec 2019 14:22:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4ELo55008298 for ; Wed, 4 Dec 2019 09:21:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7406F691B2; Wed, 4 Dec 2019 14:21:50 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 88EEB608F7; Wed, 4 Dec 2019 14:21:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469394; 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=04HcYFNIJBv9ffoXeeXcygFbFlTFmz/FYB06vOdsFkE=; b=PJtp5LuQ0OAtkjGYXVeFkMh6fhF5aK73Vl8VVCtSaih/laDy/cuD3fHP5nIz11HiwE2xsN XueT8SvnhXFGjvs7MYftj/JKwn7n5IUIhk2BjLmVRxZ1IN4DF4YdfmS+vERpj4QMCR/Fp3 /rPmqTen2RdDpt2JN/Bq2I/YfNNDw/w= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:21:06 +0000 Message-Id: <20191204142113.2961028-24-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 23/30] conf: drop virCapsPtr param from snapshot & checkpoint APIs 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-MC-Unique: KfK-OwChPtCi55YLSnnO6w-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/conf/checkpoint_conf.c | 15 ++++----------- src/conf/checkpoint_conf.h | 2 -- src/conf/snapshot_conf.c | 14 ++++---------- src/conf/snapshot_conf.h | 3 --- src/esx/esx_driver.c | 4 ++-- src/qemu/qemu_checkpoint.c | 8 ++++---- src/qemu/qemu_domain.c | 4 ++-- src/qemu/qemu_driver.c | 20 ++++---------------- src/test/test_driver.c | 8 +++----- src/vbox/vbox_common.c | 6 ++---- tests/qemudomaincheckpointxml2xmltest.c | 4 ++-- tests/qemudomainsnapshotxml2xmltest.c | 4 ++-- 12 files changed, 29 insertions(+), 63 deletions(-) diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c index 581e382b6d..26bcfc16b7 100644 --- a/src/conf/checkpoint_conf.c +++ b/src/conf/checkpoint_conf.c @@ -115,13 +115,10 @@ virDomainCheckpointDiskDefParseXML(xmlNodePtr node, return 0; } =20 -/* flags is bitwise-or of virDomainCheckpointParseFlags. If flags - * does not include VIR_DOMAIN_CHECKPOINT_PARSE_REDEFINE, then caps - * is ignored. +/* flags is bitwise-or of virDomainCheckpointParseFlags. */ static virDomainCheckpointDefPtr virDomainCheckpointDefParse(xmlXPathContextPtr ctxt, - virCapsPtr caps G_GNUC_UNUSED, virDomainXMLOptionPtr xmlopt, void *parseOpaque, unsigned int flags) @@ -201,7 +198,6 @@ virDomainCheckpointDefParse(xmlXPathContextPtr ctxt, static virDomainCheckpointDefPtr virDomainCheckpointDefParseNode(xmlDocPtr xml, xmlNodePtr root, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, void *parseOpaque, unsigned int flags) @@ -227,12 +223,11 @@ virDomainCheckpointDefParseNode(xmlDocPtr xml, return NULL; =20 ctxt->node =3D root; - return virDomainCheckpointDefParse(ctxt, caps, xmlopt, parseOpaque, fl= ags); + return virDomainCheckpointDefParse(ctxt, xmlopt, parseOpaque, flags); } =20 virDomainCheckpointDefPtr virDomainCheckpointDefParseString(const char *xmlStr, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, void *parseOpaque, unsigned int flags) @@ -244,7 +239,7 @@ virDomainCheckpointDefParseString(const char *xmlStr, if ((xml =3D virXMLParse(NULL, xmlStr, _("(domain_checkpoint)")))) { xmlKeepBlanksDefault(keepBlanksDefault); ret =3D virDomainCheckpointDefParseNode(xml, xmlDocGetRootElement(= xml), - caps, xmlopt, parseOpaque, f= lags); + xmlopt, parseOpaque, flags); xmlFreeDoc(xml); } xmlKeepBlanksDefault(keepBlanksDefault); @@ -446,7 +441,6 @@ virDomainCheckpointDiskDefFormat(virBufferPtr buf, static int virDomainCheckpointDefFormatInternal(virBufferPtr buf, virDomainCheckpointDefPtr def, - virCapsPtr caps G_GNUC_UNUSED, virDomainXMLOptionPtr xmlopt, unsigned int flags) { @@ -505,7 +499,6 @@ virDomainCheckpointDefFormatInternal(virBufferPtr buf, =20 char * virDomainCheckpointDefFormat(virDomainCheckpointDefPtr def, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, unsigned int flags) { @@ -514,7 +507,7 @@ virDomainCheckpointDefFormat(virDomainCheckpointDefPtr = def, virCheckFlags(VIR_DOMAIN_CHECKPOINT_FORMAT_SECURE | VIR_DOMAIN_CHECKPOINT_FORMAT_NO_DOMAIN | VIR_DOMAIN_CHECKPOINT_FORMAT_SIZE, NULL); - if (virDomainCheckpointDefFormatInternal(&buf, def, caps, xmlopt, + if (virDomainCheckpointDefFormatInternal(&buf, def, xmlopt, flags) < 0) return NULL; =20 diff --git a/src/conf/checkpoint_conf.h b/src/conf/checkpoint_conf.h index 982096abed..ee5d210593 100644 --- a/src/conf/checkpoint_conf.h +++ b/src/conf/checkpoint_conf.h @@ -74,7 +74,6 @@ virDomainCheckpointFormatConvertXMLFlags(unsigned int fla= gs); =20 virDomainCheckpointDefPtr virDomainCheckpointDefParseString(const char *xmlStr, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, void *parseOpaque, unsigned int flags); @@ -84,7 +83,6 @@ virDomainCheckpointDefNew(void); =20 char * virDomainCheckpointDefFormat(virDomainCheckpointDefPtr def, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, unsigned int flags); =20 diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index af882c6048..2bd4d6a276 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -216,13 +216,11 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node, } =20 /* flags is bitwise-or of virDomainSnapshotParseFlags. - * If flags does not include VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE, then - * caps are ignored. If flags does not include + * If flags does not include * VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL, then current is ignored. */ static virDomainSnapshotDefPtr virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, - virCapsPtr caps G_GNUC_UNUSED, virDomainXMLOptionPtr xmlopt, void *parseOpaque, bool *current, @@ -420,7 +418,6 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, virDomainSnapshotDefPtr virDomainSnapshotDefParseNode(xmlDocPtr xml, xmlNodePtr root, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, void *parseOpaque, bool *current, @@ -449,12 +446,11 @@ virDomainSnapshotDefParseNode(xmlDocPtr xml, return NULL; =20 ctxt->node =3D root; - return virDomainSnapshotDefParse(ctxt, caps, xmlopt, parseOpaque, curr= ent, flags); + return virDomainSnapshotDefParse(ctxt, xmlopt, parseOpaque, current, f= lags); } =20 virDomainSnapshotDefPtr virDomainSnapshotDefParseString(const char *xmlStr, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, void *parseOpaque, bool *current, @@ -467,7 +463,7 @@ virDomainSnapshotDefParseString(const char *xmlStr, if ((xml =3D virXMLParse(NULL, xmlStr, _("(domain_snapshot)")))) { xmlKeepBlanksDefault(keepBlanksDefault); ret =3D virDomainSnapshotDefParseNode(xml, xmlDocGetRootElement(xm= l), - caps, xmlopt, parseOpaque, + xmlopt, parseOpaque, current, flags); xmlFreeDoc(xml); } @@ -838,7 +834,6 @@ static int virDomainSnapshotDefFormatInternal(virBufferPtr buf, const char *uuidstr, virDomainSnapshotDefPtr def, - virCapsPtr caps G_GNUC_UNUSED, virDomainXMLOptionPtr xmlopt, unsigned int flags) { @@ -931,7 +926,6 @@ virDomainSnapshotDefFormatInternal(virBufferPtr buf, char * virDomainSnapshotDefFormat(const char *uuidstr, virDomainSnapshotDefPtr def, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, unsigned int flags) { @@ -940,7 +934,7 @@ virDomainSnapshotDefFormat(const char *uuidstr, virCheckFlags(VIR_DOMAIN_SNAPSHOT_FORMAT_SECURE | VIR_DOMAIN_SNAPSHOT_FORMAT_INTERNAL | VIR_DOMAIN_SNAPSHOT_FORMAT_CURRENT, NULL); - if (virDomainSnapshotDefFormatInternal(&buf, uuidstr, def, caps, + if (virDomainSnapshotDefFormatInternal(&buf, uuidstr, def, xmlopt, flags) < 0) return NULL; =20 diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index b0b52e6a34..c02d0fa263 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -107,14 +107,12 @@ typedef enum { unsigned int virDomainSnapshotFormatConvertXMLFlags(unsigned int flags); =20 virDomainSnapshotDefPtr virDomainSnapshotDefParseString(const char *xmlStr, - virCapsPtr caps, virDomainXMLOption= Ptr xmlopt, void *parseOpaque, bool *current, unsigned int flags= ); virDomainSnapshotDefPtr virDomainSnapshotDefParseNode(xmlDocPtr xml, xmlNodePtr root, - virCapsPtr caps, virDomainXMLOptionPt= r xmlopt, void *parseOpaque, bool *current, @@ -122,7 +120,6 @@ virDomainSnapshotDefPtr virDomainSnapshotDefParseNode(x= mlDocPtr xml, virDomainSnapshotDefPtr virDomainSnapshotDefNew(void); char *virDomainSnapshotDefFormat(const char *uuidstr, virDomainSnapshotDefPtr def, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, unsigned int flags); int virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr snapshot, diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 9cfdd3bf49..0ede65279a 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -4075,7 +4075,7 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const= char *xmlDesc, if (esxVI_EnsureSession(priv->primary) < 0) return NULL; =20 - def =3D virDomainSnapshotDefParseString(xmlDesc, priv->caps, + def =3D virDomainSnapshotDefParseString(xmlDesc, priv->xmlopt, NULL, NULL, parse_= flags); =20 if (!def) @@ -4176,7 +4176,7 @@ esxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snap= shot, =20 virUUIDFormat(snapshot->domain->uuid, uuid_string); =20 - xml =3D virDomainSnapshotDefFormat(uuid_string, &def, priv->caps, priv= ->xmlopt, + xml =3D virDomainSnapshotDefFormat(uuid_string, &def, priv->xmlopt, 0); =20 cleanup: diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c index a601030637..2101932a28 100644 --- a/src/qemu/qemu_checkpoint.c +++ b/src/qemu/qemu_checkpoint.c @@ -78,7 +78,7 @@ qemuCheckpointObjFromCheckpoint(virDomainObjPtr vm, static int qemuCheckpointWriteMetadata(virDomainObjPtr vm, virDomainMomentObjPtr checkpoint, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, virDomainXMLOptionPtr xmlopt, const char *checkpointDir) { @@ -88,7 +88,7 @@ qemuCheckpointWriteMetadata(virDomainObjPtr vm, g_autofree char *chkDir =3D NULL; g_autofree char *chkFile =3D NULL; =20 - newxml =3D virDomainCheckpointDefFormat(def, caps, xmlopt, flags); + newxml =3D virDomainCheckpointDefFormat(def, xmlopt, flags); if (newxml =3D=3D NULL) return -1; =20 @@ -494,7 +494,7 @@ qemuCheckpointCreateXML(virDomainPtr domain, return NULL; } =20 - if (!(def =3D virDomainCheckpointDefParseString(xmlDesc, caps, driver-= >xmlopt, + if (!(def =3D virDomainCheckpointDefParseString(xmlDesc, driver->xmlop= t, priv->qemuCaps, parse_fl= ags))) return NULL; /* Unlike snapshots, the RNG schema already ensured a sane filename. */ @@ -548,7 +548,7 @@ qemuCheckpointGetXMLDesc(virDomainObjPtr vm, chkdef =3D virDomainCheckpointObjGetDef(chk); =20 format_flags =3D virDomainCheckpointFormatConvertXMLFlags(flags); - return virDomainCheckpointDefFormat(chkdef, driver->caps, driver->xmlo= pt, + return virDomainCheckpointDefFormat(chkdef, driver->xmlopt, format_flags); } =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index ee99759ded..594c4d5400 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9714,7 +9714,7 @@ qemuFindQemuImgBinary(virQEMUDriverPtr driver) int qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm, virDomainMomentObjPtr snapshot, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, virDomainXMLOptionPtr xmlopt, const char *snapshotDir) { @@ -9730,7 +9730,7 @@ qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm, if (virDomainSnapshotGetCurrent(vm->snapshots) =3D=3D snapshot) flags |=3D VIR_DOMAIN_SNAPSHOT_FORMAT_CURRENT; virUUIDFormat(vm->def->uuid, uuidstr); - newxml =3D virDomainSnapshotDefFormat(uuidstr, def, caps, xmlopt, flag= s); + newxml =3D virDomainSnapshotDefFormat(uuidstr, def, xmlopt, flags); if (newxml =3D=3D NULL) return -1; =20 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 0aefe8cd2a..b544bed7c1 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -393,7 +393,6 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm, VIR_DOMAIN_SNAPSHOT_PARSE_DISKS | VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL); int ret =3D -1; - g_autoptr(virCaps) caps =3D NULL; int direrr; qemuDomainObjPrivatePtr priv; =20 @@ -409,9 +408,6 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm, goto cleanup; } =20 - if (!(caps =3D virQEMUDriverGetCapabilities(qemu_driver, false))) - goto cleanup; - VIR_INFO("Scanning for snapshots for domain %s in %s", vm->def->name, snapDir); =20 @@ -440,7 +436,7 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm, continue; } =20 - def =3D virDomainSnapshotDefParseString(xmlStr, caps, + def =3D virDomainSnapshotDefParseString(xmlStr, qemu_driver->xmlopt, priv->qemuCaps, &cur, flags); @@ -506,7 +502,6 @@ qemuDomainCheckpointLoad(virDomainObjPtr vm, virDomainMomentObjPtr current =3D NULL; unsigned int flags =3D VIR_DOMAIN_CHECKPOINT_PARSE_REDEFINE; int ret =3D -1; - g_autoptr(virCaps) caps =3D NULL; int direrr; qemuDomainObjPrivatePtr priv; =20 @@ -521,9 +516,6 @@ qemuDomainCheckpointLoad(virDomainObjPtr vm, goto cleanup; } =20 - if (!(caps =3D virQEMUDriverGetCapabilities(qemu_driver, false))) - goto cleanup; - VIR_INFO("Scanning for checkpoints for domain %s in %s", vm->def->name, chkDir); =20 @@ -552,7 +544,7 @@ qemuDomainCheckpointLoad(virDomainObjPtr vm, continue; } =20 - def =3D virDomainCheckpointDefParseString(xmlStr, caps, + def =3D virDomainCheckpointDefParseString(xmlStr, qemu_driver->xmlopt, priv->qemuCaps, flags); @@ -15751,7 +15743,6 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, int align_location =3D VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL; bool align_match =3D true; g_autoptr(virQEMUDriverConfig) cfg =3D NULL; - g_autoptr(virCaps) caps =3D NULL; qemuDomainObjPrivatePtr priv; virDomainSnapshotState state; g_autoptr(virDomainSnapshotDef) def =3D NULL; @@ -15792,9 +15783,6 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0) goto cleanup; =20 - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - goto cleanup; - if (!vm->persistent && (flags & VIR_DOMAIN_SNAPSHOT_CREATE_HALT)) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("cannot halt after transient domain snapshot")); @@ -15807,7 +15795,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_VALIDATE) parse_flags |=3D VIR_DOMAIN_SNAPSHOT_PARSE_VALIDATE; =20 - if (!(def =3D virDomainSnapshotDefParseString(xmlDesc, caps, driver->x= mlopt, + if (!(def =3D virDomainSnapshotDefParseString(xmlDesc, driver->xmlopt, priv->qemuCaps, NULL, pars= e_flags))) goto cleanup; =20 @@ -16336,7 +16324,7 @@ qemuDomainSnapshotGetXMLDesc(virDomainSnapshotPtr s= napshot, virUUIDFormat(snapshot->domain->uuid, uuidstr); =20 xml =3D virDomainSnapshotDefFormat(uuidstr, virDomainSnapshotObjGetDef= (snap), - driver->caps, driver->xmlopt, + driver->xmlopt, virDomainSnapshotFormatConvertXMLFlag= s(flags)); =20 cleanup: diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 788d5d3676..f3d6061625 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -884,7 +884,6 @@ testParseDomainSnapshots(testDriverPtr privconn, goto error; =20 def =3D virDomainSnapshotDefParseNode(ctxt->doc, node, - privconn->caps, privconn->xmlopt, NULL, &cur, @@ -8413,7 +8412,7 @@ testDomainSnapshotGetXMLDesc(virDomainSnapshotPtr sna= pshot, virUUIDFormat(snapshot->domain->uuid, uuidstr); =20 xml =3D virDomainSnapshotDefFormat(uuidstr, virDomainSnapshotObjGetDef= (snap), - privconn->caps, privconn->xmlopt, + privconn->xmlopt, virDomainSnapshotFormatConvertXMLFlag= s(flags)); =20 cleanup: @@ -8557,7 +8556,6 @@ testDomainSnapshotCreateXML(virDomainPtr domain, parse_flags |=3D VIR_DOMAIN_SNAPSHOT_PARSE_VALIDATE; =20 if (!(def =3D virDomainSnapshotDefParseString(xmlDesc, - privconn->caps, privconn->xmlopt, NULL, NULL, parse_flags))) @@ -9013,7 +9011,7 @@ testDomainCheckpointCreateXML(virDomainPtr domain, goto cleanup; } =20 - if (!(def =3D virDomainCheckpointDefParseString(xmlDesc, privconn->cap= s, + if (!(def =3D virDomainCheckpointDefParseString(xmlDesc, privconn->xmlopt, NULL, parse_flags))) goto cleanup; @@ -9216,7 +9214,7 @@ testDomainCheckpointGetXMLDesc(virDomainCheckpointPtr= checkpoint, } =20 format_flags =3D virDomainCheckpointFormatConvertXMLFlags(flags); - xml =3D virDomainCheckpointDefFormat(chkdef, privconn->caps, + xml =3D virDomainCheckpointDefFormat(chkdef, privconn->xmlopt, format_flags); =20 cleanup: diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 1703120928..2930a2f0e1 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -5301,7 +5301,6 @@ vboxSnapshotRedefine(virDomainPtr dom, currentSnapshotXmlFilePath =3D g_strdup_printf("%s%s.xml", machineLocationPath, = snapshotMachineDesc->currentSnapshot); char *snapshotContent =3D virDomainSnapshotDefFormat(NULL, def, - data->caps, data->xmlopt, VIR_DOMAIN_SNAP= SHOT_FORMAT_SECURE); if (snapshotContent =3D=3D NULL) { @@ -5431,7 +5430,7 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom, if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_VALIDATE) parse_flags |=3D VIR_DOMAIN_SNAPSHOT_PARSE_VALIDATE; =20 - if (!(def =3D virDomainSnapshotDefParseString(xmlDesc, data->caps, + if (!(def =3D virDomainSnapshotDefParseString(xmlDesc, data->xmlopt, NULL, NULL, parse_flags))) goto cleanup; @@ -6244,7 +6243,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSn= apshotPtr snapshot, =20 virUUIDFormat(dom->uuid, uuidstr); memcpy(defdom->uuid, dom->uuid, VIR_UUID_BUFLEN); - ret =3D virDomainSnapshotDefFormat(uuidstr, def, data->caps, data->xml= opt, 0); + ret =3D virDomainSnapshotDefFormat(uuidstr, def, data->xmlopt, 0); =20 cleanup: VBOX_RELEASE(parent); @@ -6858,7 +6857,6 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapsho= tPtr snapshot) goto cleanup; } def =3D virDomainSnapshotDefParseString(defXml, - data->caps, data->xmlopt, NULL, NULL, VIR_DOMAIN_SNAPSHOT_PARSE_DISKS | VIR_DOMAIN_SNAPSHOT_PARSE_REDEFI= NE); diff --git a/tests/qemudomaincheckpointxml2xmltest.c b/tests/qemudomainchec= kpointxml2xmltest.c index 49e8cddeb3..4d6904a592 100644 --- a/tests/qemudomaincheckpointxml2xmltest.c +++ b/tests/qemudomaincheckpointxml2xmltest.c @@ -53,7 +53,7 @@ testCompareXMLToXMLFiles(const char *inxml, virTestLoadFile(outxml, &outXmlData) < 0) return -1; =20 - if (!(def =3D virDomainCheckpointDefParseString(inXmlData, driver.caps, + if (!(def =3D virDomainCheckpointDefParseString(inXmlData, driver.xmlopt, NULL, parseflags))) { if (flags & TEST_INVALID) @@ -91,7 +91,7 @@ testCompareXMLToXMLFiles(const char *inxml, if (!def->parent.dom) formatflags |=3D VIR_DOMAIN_CHECKPOINT_FORMAT_NO_DOMAIN; =20 - if (!(actual =3D virDomainCheckpointDefFormat(def, driver.caps, + if (!(actual =3D virDomainCheckpointDefFormat(def, driver.xmlopt, formatflags))) return -1; diff --git a/tests/qemudomainsnapshotxml2xmltest.c b/tests/qemudomainsnapsh= otxml2xmltest.c index fd3bb04e26..6bff5d14f5 100644 --- a/tests/qemudomainsnapshotxml2xmltest.c +++ b/tests/qemudomainsnapshotxml2xmltest.c @@ -54,7 +54,7 @@ testCompareXMLToXMLFiles(const char *inxml, if (virTestLoadFile(outxml, &outXmlData) < 0) goto cleanup; =20 - if (!(def =3D virDomainSnapshotDefParseString(inXmlData, driver.caps, + if (!(def =3D virDomainSnapshotDefParseString(inXmlData, driver.xmlopt, NULL, &cur, parseflags))) goto cleanup; @@ -69,7 +69,7 @@ testCompareXMLToXMLFiles(const char *inxml, def->state =3D VIR_DOMAIN_RUNNING; } =20 - if (!(actual =3D virDomainSnapshotDefFormat(uuid, def, driver.caps, + if (!(actual =3D virDomainSnapshotDefFormat(uuid, def, driver.xmlopt, formatflags))) goto cleanup; --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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.61 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=1575469455; cv=none; d=zohomail.com; s=zohoarc; b=GrQVCR5me7TiLkth3yPAx6k4kVkpYxtfJNZdqpW+UXhGmIc8oPh7mK2k7YUULyPZcMlY0C+/jtEw7y0JTTsfDdihcdB5Lqx1Olg2w723RBvSsJkBbWPIvhHM0qgbEQOmTgCRol1WLWOczYIONADPCToBFG1RCw8NJ/Zn6leWZQg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469455; 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=UVVoKCfqqG+g0KVH/zZbgbCp5JMzUZ2EGo/bB3OhX+c=; b=L4vFU++DYlvhDCmSmzHTPZGBTx4Ktel2p7KCARqIweQ+MD8z0hcMNlXa1FAAC3ubOFyg7apDXOhT+xYv5oBjl7F1FE3qDIIgh8hUQeXMiUqS+W+fOUEzwzVSEclKzSarkSSWOdqsPR49hUB+uduQzSyPzJyX0DaDJphytZv1smw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1575469455199389.85784669008615; Wed, 4 Dec 2019 06:24:15 -0800 (PST) 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-245-3DmIqytwOKeB6_mCTdpEpg-1; Wed, 04 Dec 2019 09:22:17 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3DE378D0928; Wed, 4 Dec 2019 14:22:10 +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 18889600D5; Wed, 4 Dec 2019 14:22:10 +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 C29DA18034F9; Wed, 4 Dec 2019 14:22:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4ELpXb008314 for ; Wed, 4 Dec 2019 09:21:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id ABD4F691B7; Wed, 4 Dec 2019 14:21:51 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB6AD691B1; Wed, 4 Dec 2019 14:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469454; 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=UVVoKCfqqG+g0KVH/zZbgbCp5JMzUZ2EGo/bB3OhX+c=; b=iFxzIEgwGH1yA4LF64wfwWaNGyIGJkYE8ezMOkHHePfsm4kLvoL96IV57ly6XujEW7F0eQ 0/HCDiOBcSn2V9qLTuMxW7GBSg5FFiYmzNH6WMokaEIGlqWQGSpl81YdGEOFF5uC5ISnvd YX9yi1l5Zb78/4m/hdmdr5TfZLEt14k= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:21:07 +0000 Message-Id: <20191204142113.2961028-25-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 24/30] qemu: drop virCapsPtr param & vars from many APIs 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.11 X-MC-Unique: 3DmIqytwOKeB6_mCTdpEpg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Now that the domain XML APIs don't use virCapsPtr we can stop passing it around many QEMU driver methods. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/qemu/qemu_checkpoint.c | 24 +++++++---------------- src/qemu/qemu_checkpoint.h | 1 - src/qemu/qemu_domain.c | 3 +-- src/qemu/qemu_domain.h | 1 - src/qemu/qemu_driver.c | 39 +++++++++----------------------------- src/qemu/qemu_process.c | 10 ---------- 6 files changed, 17 insertions(+), 61 deletions(-) diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c index 2101932a28..30f65630ca 100644 --- a/src/qemu/qemu_checkpoint.c +++ b/src/qemu/qemu_checkpoint.c @@ -78,7 +78,6 @@ qemuCheckpointObjFromCheckpoint(virDomainObjPtr vm, static int qemuCheckpointWriteMetadata(virDomainObjPtr vm, virDomainMomentObjPtr checkpoint, - virCapsPtr caps G_GNUC_UNUSED, virDomainXMLOptionPtr xmlopt, const char *checkpointDir) { @@ -197,7 +196,7 @@ qemuCheckpointDiscard(virQEMUDriverPtr driver, virDomainCheckpointSetCurrent(vm->checkpoints, NULL); if (update_parent && parent) { virDomainCheckpointSetCurrent(vm->checkpoints, parent); - if (qemuCheckpointWriteMetadata(vm, parent, driver->caps, + if (qemuCheckpointWriteMetadata(vm, parent, driver->xmlopt, cfg->checkpointDir) < 0) { VIR_WARN("failed to set parent checkpoint '%s' as current", @@ -239,7 +238,6 @@ qemuCheckpointDiscardAllMetadata(virQEMUDriverPtr drive= r, /* Called inside job lock */ static int qemuCheckpointPrepare(virQEMUDriverPtr driver, - virCapsPtr caps G_GNUC_UNUSED, virDomainObjPtr vm, virDomainCheckpointDefPtr def) { @@ -373,7 +371,6 @@ qemuCheckpointRedefine(virQEMUDriverPtr driver, int qemuCheckpointCreateCommon(virQEMUDriverPtr driver, virDomainObjPtr vm, - virCapsPtr caps, virDomainCheckpointDefPtr *def, virJSONValuePtr *actions, virDomainMomentObjPtr *chk) @@ -381,7 +378,7 @@ qemuCheckpointCreateCommon(virQEMUDriverPtr driver, g_autoptr(virJSONValue) tmpactions =3D NULL; virDomainMomentObjPtr parent; =20 - if (qemuCheckpointPrepare(driver, caps, vm, *def) < 0) + if (qemuCheckpointPrepare(driver, vm, *def) < 0) return -1; =20 if ((parent =3D virDomainCheckpointGetCurrent(vm->checkpoints))) @@ -406,14 +403,13 @@ qemuCheckpointCreateCommon(virQEMUDriverPtr driver, static virDomainMomentObjPtr qemuCheckpointCreate(virQEMUDriverPtr driver, virDomainObjPtr vm, - virCapsPtr caps, virDomainCheckpointDefPtr *def) { g_autoptr(virJSONValue) actions =3D NULL; virDomainMomentObjPtr chk =3D NULL; int rc; =20 - if (qemuCheckpointCreateCommon(driver, vm, caps, def, &actions, &chk) = < 0) + if (qemuCheckpointCreateCommon(driver, vm, def, &actions, &chk) < 0) return NULL; =20 qemuDomainObjEnterMonitor(driver, vm); @@ -437,7 +433,7 @@ qemuCheckpointCreateFinalize(virQEMUDriverPtr driver, if (update_current) virDomainCheckpointSetCurrent(vm->checkpoints, chk); =20 - if (qemuCheckpointWriteMetadata(vm, chk, driver->caps, + if (qemuCheckpointWriteMetadata(vm, chk, driver->xmlopt, cfg->checkpointDir) < 0) { /* if writing of metadata fails, error out rather than trying @@ -469,7 +465,6 @@ qemuCheckpointCreateXML(virDomainPtr domain, bool redefine =3D flags & VIR_DOMAIN_CHECKPOINT_CREATE_REDEFINE; unsigned int parse_flags =3D 0; g_autoptr(virQEMUDriverConfig) cfg =3D NULL; - g_autoptr(virCaps) caps =3D NULL; g_autoptr(virDomainCheckpointDef) def =3D NULL; =20 virCheckFlags(VIR_DOMAIN_CHECKPOINT_CREATE_REDEFINE, NULL); @@ -485,9 +480,6 @@ qemuCheckpointCreateXML(virDomainPtr domain, return NULL; } =20 - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - return NULL; - if (!virDomainObjIsActive(vm)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("cannot create checkpoint for inactive domain")); @@ -506,7 +498,7 @@ qemuCheckpointCreateXML(virDomainPtr domain, if (redefine) { chk =3D qemuCheckpointRedefine(driver, vm, &def, &update_current); } else { - chk =3D qemuCheckpointCreate(driver, vm, caps, &def); + chk =3D qemuCheckpointCreate(driver, vm, &def); } =20 if (!chk) @@ -557,7 +549,6 @@ struct virQEMUCheckpointReparent { const char *dir; virDomainMomentObjPtr parent; virDomainObjPtr vm; - virCapsPtr caps; virDomainXMLOptionPtr xmlopt; int err; }; @@ -579,7 +570,7 @@ qemuCheckpointReparentChildren(void *payload, if (rep->parent->def) moment->def->parent_name =3D g_strdup(rep->parent->def->name); =20 - rep->err =3D qemuCheckpointWriteMetadata(rep->vm, moment, rep->caps, + rep->err =3D qemuCheckpointWriteMetadata(rep->vm, moment, rep->xmlopt, rep->dir); return 0; } @@ -639,7 +630,7 @@ qemuCheckpointDelete(virDomainObjPtr vm, if (rem.found) { virDomainCheckpointSetCurrent(vm->checkpoints, chk); if (flags & VIR_DOMAIN_CHECKPOINT_DELETE_CHILDREN_ONLY) { - if (qemuCheckpointWriteMetadata(vm, chk, driver->caps, + if (qemuCheckpointWriteMetadata(vm, chk, driver->xmlopt, cfg->checkpointDir) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -655,7 +646,6 @@ qemuCheckpointDelete(virDomainObjPtr vm, rep.parent =3D chk->parent; rep.vm =3D vm; rep.err =3D 0; - rep.caps =3D driver->caps; rep.xmlopt =3D driver->xmlopt; virDomainMomentForEachChild(chk, qemuCheckpointReparentChildren, &rep); diff --git a/src/qemu/qemu_checkpoint.h b/src/qemu/qemu_checkpoint.h index d0ea8f000f..00548beec9 100644 --- a/src/qemu/qemu_checkpoint.h +++ b/src/qemu/qemu_checkpoint.h @@ -57,7 +57,6 @@ qemuCheckpointDelete(virDomainObjPtr vm, int qemuCheckpointCreateCommon(virQEMUDriverPtr driver, virDomainObjPtr vm, - virCapsPtr caps, virDomainCheckpointDefPtr *def, virJSONValuePtr *actions, virDomainMomentObjPtr *chk); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 594c4d5400..84813ded40 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9714,7 +9714,6 @@ qemuFindQemuImgBinary(virQEMUDriverPtr driver) int qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm, virDomainMomentObjPtr snapshot, - virCapsPtr caps G_GNUC_UNUSED, virDomainXMLOptionPtr xmlopt, const char *snapshotDir) { @@ -9887,7 +9886,7 @@ qemuDomainSnapshotDiscard(virQEMUDriverPtr driver, snap->def->parent_name); } else { virDomainSnapshotSetCurrent(vm->snapshots, parentsnap); - if (qemuDomainSnapshotWriteMetadata(vm, parentsnap, driver= ->caps, + if (qemuDomainSnapshotWriteMetadata(vm, parentsnap, driver->xmlopt, cfg->snapshotDir) < 0)= { VIR_WARN("failed to set parent snapshot '%s' as curren= t", diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index f626d3a54c..3bbb0b2e44 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -763,7 +763,6 @@ const char *qemuFindQemuImgBinary(virQEMUDriverPtr driv= er); =20 int qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm, virDomainMomentObjPtr snapshot, - virCapsPtr caps, virDomainXMLOptionPtr xmlopt, const char *snapshotDir); =20 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b544bed7c1..ae6facc829 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8063,7 +8063,6 @@ qemuCheckDiskConfigAgainstDomain(const virDomainDef *= def, static int qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev, - virCapsPtr caps G_GNUC_UNUSED, virQEMUCapsPtr qemuCaps, unsigned int parse_flags, virDomainXMLOptionPtr xmlopt) @@ -8273,7 +8272,6 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, static int qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev, - virCapsPtr caps G_GNUC_UNUSED, virQEMUCapsPtr qemuCaps, unsigned int parse_flags, virDomainXMLOptionPtr xmlopt) @@ -8465,7 +8463,6 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, static int qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev, - virCapsPtr caps G_GNUC_UNUSED, virQEMUCapsPtr qemuCaps, unsigned int parse_flags, virDomainXMLOptionPtr xmlopt) @@ -8582,7 +8579,6 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr v= m, virDomainDeviceDefPtr devConf =3D NULL; virDomainDeviceDefPtr devLive =3D NULL; int ret =3D -1; - g_autoptr(virCaps) caps =3D NULL; unsigned int parse_flags =3D VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_ABI_UPDATE; =20 @@ -8591,9 +8587,6 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr v= m, =20 cfg =3D virQEMUDriverGetConfig(driver); =20 - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - goto cleanup; - /* The config and live post processing address auto-generation algorit= hms * rely on the correct vm->def or vm->newDef being passed, so call the * device parse based on which definition is in use */ @@ -8617,7 +8610,7 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr v= m, false) < 0) goto cleanup; =20 - if (qemuDomainAttachDeviceConfig(vmdef, devConf, caps, priv->qemuC= aps, + if (qemuDomainAttachDeviceConfig(vmdef, devConf, priv->qemuCaps, parse_flags, driver->xmlopt) < 0) goto cleanup; @@ -8723,7 +8716,6 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr d= om, bool force =3D (flags & VIR_DOMAIN_DEVICE_MODIFY_FORCE) !=3D 0; int ret =3D -1; g_autoptr(virQEMUDriverConfig) cfg =3D NULL; - g_autoptr(virCaps) caps =3D NULL; unsigned int parse_flags =3D 0; =20 virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | @@ -8734,9 +8726,6 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr d= om, =20 cfg =3D virQEMUDriverGetConfig(driver); =20 - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - goto cleanup; - if (!(vm =3D qemuDomainObjFromDomain(dom))) goto cleanup; =20 @@ -8782,7 +8771,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr d= om, =20 /* virDomainDefCompatibleDevice call is delayed until we know the * device we're going to update. */ - if ((ret =3D qemuDomainUpdateDeviceConfig(vmdef, dev, caps, priv->= qemuCaps, + if ((ret =3D qemuDomainUpdateDeviceConfig(vmdef, dev, priv->qemuCa= ps, parse_flags, driver->xmlopt)) < 0) goto endjob; @@ -8833,7 +8822,6 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr = driver, unsigned int flags) { qemuDomainObjPrivatePtr priv =3D vm->privateData; - g_autoptr(virCaps) caps =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D NULL; virDomainDeviceDefPtr dev =3D NULL, dev_copy =3D NULL; unsigned int parse_flags =3D VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE; @@ -8843,9 +8831,6 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr = driver, virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG, -1); =20 - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - goto cleanup; - cfg =3D virQEMUDriverGetConfig(driver); =20 if ((flags & VIR_DOMAIN_AFFECT_CONFIG) && @@ -8876,7 +8861,7 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr = driver, if (!vmdef) goto cleanup; =20 - if (qemuDomainDetachDeviceConfig(vmdef, dev, caps, priv->qemuCaps, + if (qemuDomainDetachDeviceConfig(vmdef, dev, priv->qemuCaps, parse_flags, driver->xmlopt) < 0) goto cleanup; @@ -8927,7 +8912,6 @@ qemuDomainDetachDeviceAliasLiveAndConfig(virQEMUDrive= rPtr driver, unsigned int flags) { qemuDomainObjPrivatePtr priv =3D vm->privateData; - g_autoptr(virCaps) caps =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D NULL; virDomainDefPtr def =3D NULL; virDomainDefPtr persistentDef =3D NULL; @@ -8938,9 +8922,6 @@ qemuDomainDetachDeviceAliasLiveAndConfig(virQEMUDrive= rPtr driver, virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG, -1); =20 - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - goto cleanup; - cfg =3D virQEMUDriverGetConfig(driver); =20 if ((flags & VIR_DOMAIN_AFFECT_CONFIG) && @@ -8960,7 +8941,7 @@ qemuDomainDetachDeviceAliasLiveAndConfig(virQEMUDrive= rPtr driver, if (virDomainDefFindDevice(vmdef, alias, &dev, true) < 0) goto cleanup; =20 - if (qemuDomainDetachDeviceConfig(vmdef, &dev, caps, priv->qemuCaps, + if (qemuDomainDetachDeviceConfig(vmdef, &dev, priv->qemuCaps, parse_flags, driver->xmlopt) < 0) goto cleanup; } @@ -15987,7 +15968,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, if (snapshot && !(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) { if (update_current) virDomainSnapshotSetCurrent(vm->snapshots, snap); - if (qemuDomainSnapshotWriteMetadata(vm, snap, driver->caps, + if (qemuDomainSnapshotWriteMetadata(vm, snap, driver->xmlopt, cfg->snapshotDir) < 0) { /* if writing of metadata fails, error out rather than trying @@ -16813,7 +16794,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr sna= pshot, cleanup: if (ret =3D=3D 0) { virDomainSnapshotSetCurrent(vm->snapshots, snap); - if (qemuDomainSnapshotWriteMetadata(vm, snap, driver->caps, + if (qemuDomainSnapshotWriteMetadata(vm, snap, driver->xmlopt, cfg->snapshotDir) < 0) { virDomainSnapshotSetCurrent(vm->snapshots, NULL); @@ -16847,11 +16828,10 @@ struct _virQEMUMomentReparent { const char *dir; virDomainMomentObjPtr parent; virDomainObjPtr vm; - virCapsPtr caps; virDomainXMLOptionPtr xmlopt; int err; int (*writeMetadata)(virDomainObjPtr, virDomainMomentObjPtr, - virCapsPtr, virDomainXMLOptionPtr, const char *); + virDomainXMLOptionPtr, const char *); }; =20 =20 @@ -16871,7 +16851,7 @@ qemuDomainMomentReparentChildren(void *payload, if (rep->parent->def) moment->def->parent_name =3D g_strdup(rep->parent->def->name); =20 - rep->err =3D rep->writeMetadata(rep->vm, moment, rep->caps, rep->xmlop= t, + rep->err =3D rep->writeMetadata(rep->vm, moment, rep->xmlopt, rep->dir); return 0; } @@ -16942,7 +16922,7 @@ qemuDomainSnapshotDelete(virDomainSnapshotPtr snaps= hot, if (rem.found) { virDomainSnapshotSetCurrent(vm->snapshots, snap); if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) { - if (qemuDomainSnapshotWriteMetadata(vm, snap, driver->caps, + if (qemuDomainSnapshotWriteMetadata(vm, snap, driver->xmlopt, cfg->snapshotDir) < 0)= { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -16958,7 +16938,6 @@ qemuDomainSnapshotDelete(virDomainSnapshotPtr snaps= hot, rep.parent =3D snap->parent; rep.vm =3D vm; rep.err =3D 0; - rep.caps =3D driver->caps; rep.xmlopt =3D driver->xmlopt; rep.writeMetadata =3D qemuDomainSnapshotWriteMetadata; virDomainMomentForEachChild(snap, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 7a0cbc109f..4287ed0830 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6725,7 +6725,6 @@ qemuProcessLaunch(virConnectPtr conn, virCommandPtr cmd =3D NULL; struct qemuProcessHookData hookData; virQEMUDriverConfigPtr cfg; - virCapsPtr caps =3D NULL; size_t nnicindexes =3D 0; int *nicindexes =3D NULL; size_t i; @@ -6762,9 +6761,6 @@ qemuProcessLaunch(virConnectPtr conn, /* We don't increase cfg's reference counter here. */ hookData.cfg =3D cfg; =20 - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - goto cleanup; - VIR_DEBUG("Creating domain log file"); if (!(logCtxt =3D qemuDomainLogContextNew(driver, vm, QEMU_DOMAIN_LOG_CONTEXT_MODE_S= TART))) { @@ -7042,7 +7038,6 @@ qemuProcessLaunch(virConnectPtr conn, virCommandFree(cmd); virObjectUnref(logCtxt); virObjectUnref(cfg); - virObjectUnref(caps); VIR_FREE(nicindexes); return ret; } @@ -8007,7 +8002,6 @@ qemuProcessReconnect(void *opaque) size_t i; unsigned int stopFlags =3D 0; bool jobStarted =3D false; - virCapsPtr caps =3D NULL; bool retry =3D true; bool tryMonReconn =3D false; =20 @@ -8022,9 +8016,6 @@ qemuProcessReconnect(void *opaque) cfg =3D virQEMUDriverGetConfig(driver); priv =3D obj->privateData; =20 - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - goto error; - if (qemuDomainObjBeginJob(driver, obj, QEMU_JOB_MODIFY) < 0) goto error; jobStarted =3D true; @@ -8255,7 +8246,6 @@ qemuProcessReconnect(void *opaque) } virDomainObjEndAPI(&obj); virObjectUnref(cfg); - virObjectUnref(caps); virNWFilterUnlockFilterUpdates(); virIdentitySetCurrent(NULL); return; --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 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=1575469345; cv=none; d=zohomail.com; s=zohoarc; b=XLXxZrO5MB/Pg5QHr/DsV9L+oE4k5/btjEFTZ9beYBm1izy5J+cJufuGPoH7lL/7aty95gdjbC4rHRui4L7iWnjAK9oNmr1m78Slo/PyhrbUG3ZrQXDvUjb6Dw3MLNAFUFMpYr7ZEFrcjGE5tGn5YNywgMkdzWBqDQ8I1wra+gM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469345; 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=qnCiO+r1TLCZSZ8vTFzeJMLTP+jY4imfToQ7nFA8duA=; b=l8uugxcuTeVYefWz2iIVw3i4jm1QN0KzdOYLJmB6cpuT6MQ7+LJr64+29tsAfMhRoqThqr5eNBn7PDB7IdRbSPSDcmvz0xCqmprgijKSThxBPiBSVU4y6LGrkwAali2Vhp0u55kg6N0w+W6AdQ9CYhYU2hXk/AG7e1QWYluiDZk= 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-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1575469345892484.06417822549975; Wed, 4 Dec 2019 06:22:25 -0800 (PST) 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-341-x2GRrRjiPliSRwHnQCt3kg-1; Wed, 04 Dec 2019 09:22:22 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id C69A7DC2A; Wed, 4 Dec 2019 14:22:14 +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 971215C1B2; Wed, 4 Dec 2019 14:22:14 +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 4C5911803500; Wed, 4 Dec 2019 14:22:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4ELta2008334 for ; Wed, 4 Dec 2019 09:21:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id 69788691B2; Wed, 4 Dec 2019 14:21:55 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 85C66608F7; Wed, 4 Dec 2019 14:21:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469344; 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=qnCiO+r1TLCZSZ8vTFzeJMLTP+jY4imfToQ7nFA8duA=; b=InhXfR09oUSd3w+S9tjuvTEIp4hNXB88d6HRonW+/f6/oWaz+YuchkHgwHyXS1TlLIyDGz Lq5W/pNIrDVw2G3WlC5CXpWpiyvweavCXywHoqR7fPr7s6SrO5V5csOzLr7gkEypdaQ8Qo +BncuJebmpV1gKfomHfotcoc8PKzecY= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:21:08 +0000 Message-Id: <20191204142113.2961028-26-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 25/30] conf: move NUMA capabilities into self contained object 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.16 X-MC-Unique: x2GRrRjiPliSRwHnQCt3kg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The NUMA cells are stored directly in the virCapsHostPtr struct. This moves them into their own struct allowing them to be stored independantly of the rest of the host capabilities. The change is used as an excuse to switch the representation to use a GPtrArray too. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/conf/capabilities.c | 200 +++++++++++++++++++-------------- src/conf/capabilities.h | 27 +++-- src/conf/virconftypes.h | 3 + src/libvirt_private.syms | 10 +- src/libxl/libxl_capabilities.c | 20 ++-- src/lxc/lxc_conf.c | 6 +- src/openvz/openvz_conf.c | 2 +- src/phyp/phyp_driver.c | 7 +- src/qemu/qemu_capabilities.c | 6 +- src/qemu/qemu_domain.c | 11 +- src/qemu/qemu_migration.c | 5 - src/qemu/qemu_process.c | 2 +- src/test/test_driver.c | 9 +- src/vbox/vbox_common.c | 2 +- src/vmware/vmware_conf.c | 2 +- src/vz/vz_driver.c | 2 +- tests/testutils.c | 23 ++-- tests/testutils.h | 3 +- tests/testutilsqemu.c | 2 +- tests/vircaps2xmltest.c | 6 +- tests/vircapstest.c | 11 +- 21 files changed, 194 insertions(+), 165 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 748dd64273..7021283310 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -182,14 +182,19 @@ virCapabilitiesFreeStoragePool(virCapsStoragePoolPtr = pool) =20 =20 void -virCapabilitiesFreeNUMAInfo(virCapsPtr caps) +virCapabilitiesHostNUMAUnref(virCapsHostNUMAPtr caps) { - size_t i; + if (g_atomic_int_dec_and_test(&caps->refs)) { + g_ptr_array_unref(caps->cells); + + VIR_FREE(caps); + } +} =20 - for (i =3D 0; i < caps->host.nnumaCell; i++) - virCapabilitiesFreeHostNUMACell(caps->host.numaCell[i]); - VIR_FREE(caps->host.numaCell); - caps->host.nnumaCell =3D 0; +void +virCapabilitiesHostNUMARef(virCapsHostNUMAPtr caps) +{ + g_atomic_int_inc(&caps->refs); } =20 static void @@ -234,7 +239,8 @@ virCapsDispose(void *object) VIR_FREE(caps->host.features[i]); VIR_FREE(caps->host.features); =20 - virCapabilitiesFreeNUMAInfo(caps); + if (caps->host.numa) + virCapabilitiesHostNUMAUnref(caps->host.numa); =20 for (i =3D 0; i < caps->host.nmigrateTrans; i++) VIR_FREE(caps->host.migrateTrans[i]); @@ -320,7 +326,7 @@ virCapabilitiesSetNetPrefix(virCapsPtr caps, =20 =20 /** - * virCapabilitiesAddHostNUMACell: + * virCapabilitiesHostNUMAAddCell: * @caps: capabilities to extend * @num: ID number of NUMA cell * @mem: Total size of memory in the NUMA node (in KiB) @@ -334,8 +340,8 @@ virCapabilitiesSetNetPrefix(virCapsPtr caps, * Registers a new NUMA cell for a host, passing in a * array of CPU IDs belonging to the cell */ -int -virCapabilitiesAddHostNUMACell(virCapsPtr caps, +void +virCapabilitiesHostNUMAAddCell(virCapsHostNUMAPtr caps, int num, unsigned long long mem, int ncpus, @@ -345,14 +351,7 @@ virCapabilitiesAddHostNUMACell(virCapsPtr caps, int npageinfo, virCapsHostNUMACellPageInfoPtr pageinfo) { - virCapsHostNUMACellPtr cell; - - if (VIR_RESIZE_N(caps->host.numaCell, caps->host.nnumaCell_max, - caps->host.nnumaCell, 1) < 0) - return -1; - - if (VIR_ALLOC(cell) < 0) - return -1; + virCapsHostNUMACellPtr cell =3D g_new0(virCapsHostNUMACell, 1); =20 cell->num =3D num; cell->mem =3D mem; @@ -363,9 +362,7 @@ virCapabilitiesAddHostNUMACell(virCapsPtr caps, cell->npageinfo =3D npageinfo; cell->pageinfo =3D pageinfo; =20 - caps->host.numaCell[caps->host.nnumaCell++] =3D cell; - - return 0; + g_ptr_array_add(caps->cells, cell); } =20 =20 @@ -857,9 +854,8 @@ virCapabilitiesAddStoragePool(virCapsPtr caps, =20 =20 static int -virCapabilitiesFormatNUMATopology(virBufferPtr buf, - size_t ncells, - virCapsHostNUMACellPtr *cells) +virCapabilitiesHostNUMAFormat(virCapsHostNUMAPtr caps, + virBufferPtr buf) { size_t i; size_t j; @@ -867,48 +863,49 @@ virCapabilitiesFormatNUMATopology(virBufferPtr buf, =20 virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, 2); - virBufferAsprintf(buf, "\n", ncells); + virBufferAsprintf(buf, "\n", caps->cells->len); virBufferAdjustIndent(buf, 2); - for (i =3D 0; i < ncells; i++) { - virBufferAsprintf(buf, "\n", cells[i]->num); + for (i =3D 0; i < caps->cells->len; i++) { + virCapsHostNUMACellPtr cell =3D g_ptr_array_index(caps->cells, i); + virBufferAsprintf(buf, "\n", cell->num); virBufferAdjustIndent(buf, 2); =20 /* Print out the numacell memory total if it is available */ - if (cells[i]->mem) + if (cell->mem) virBufferAsprintf(buf, "%llu\n", - cells[i]->mem); + cell->mem); =20 - for (j =3D 0; j < cells[i]->npageinfo; j++) { + for (j =3D 0; j < cell->npageinfo; j++) { virBufferAsprintf(buf, "%llu\n", - cells[i]->pageinfo[j].size, - cells[i]->pageinfo[j].avail); + cell->pageinfo[j].size, + cell->pageinfo[j].avail); } =20 - if (cells[i]->nsiblings) { + if (cell->nsiblings) { virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, 2); - for (j =3D 0; j < cells[i]->nsiblings; j++) { + for (j =3D 0; j < cell->nsiblings; j++) { virBufferAsprintf(buf, "\= n", - cells[i]->siblings[j].node, - cells[i]->siblings[j].distance); + cell->siblings[j].node, + cell->siblings[j].distance); } virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); } =20 - virBufferAsprintf(buf, "\n", cells[i]->ncpus); + virBufferAsprintf(buf, "\n", cell->ncpus); virBufferAdjustIndent(buf, 2); - for (j =3D 0; j < cells[i]->ncpus; j++) { - virBufferAsprintf(buf, "cpus[j].id); + for (j =3D 0; j < cell->ncpus; j++) { + virBufferAsprintf(buf, "cpus[j].id); =20 - if (cells[i]->cpus[j].siblings) { - if (!(siblings =3D virBitmapFormat(cells[i]->cpus[j].sibli= ngs))) + if (cell->cpus[j].siblings) { + if (!(siblings =3D virBitmapFormat(cell->cpus[j].siblings)= )) return -1; =20 virBufferAsprintf(buf, " socket_id=3D'%d' core_id=3D'%d' siblin= gs=3D'%s'", - cells[i]->cpus[j].socket_id, - cells[i]->cpus[j].core_id, + cell->cpus[j].socket_id, + cell->cpus[j].core_id, siblings); VIR_FREE(siblings); } @@ -1187,9 +1184,8 @@ virCapabilitiesFormatHostXML(virCapsHostPtr host, virBufferAsprintf(buf, "%s\n", host->netprefix); =20 - if (host->nnumaCell && - virCapabilitiesFormatNUMATopology(buf, host->nnumaCell, - host->numaCell) < 0) + if (host->numa && + virCapabilitiesHostNUMAFormat(host->numa, buf) < 0) goto error; =20 if (virCapabilitiesFormatCaches(buf, &host->cache) < 0) @@ -1394,14 +1390,15 @@ virCapabilitiesFormatXML(virCapsPtr caps) =20 /* get the maximum ID of cpus in the host */ static unsigned int -virCapabilitiesGetHostMaxcpu(virCapsPtr caps) +virCapabilitiesHostNUMAGetMaxcpu(virCapsHostNUMAPtr caps) { unsigned int maxcpu =3D 0; size_t node; size_t cpu; =20 - for (node =3D 0; node < caps->host.nnumaCell; node++) { - virCapsHostNUMACellPtr cell =3D caps->host.numaCell[node]; + for (node =3D 0; node < caps->cells->len; node++) { + virCapsHostNUMACellPtr cell =3D + g_ptr_array_index(caps->cells, node); =20 for (cpu =3D 0; cpu < cell->ncpus; cpu++) { if (cell->cpus[cpu].id > maxcpu) @@ -1414,19 +1411,19 @@ virCapabilitiesGetHostMaxcpu(virCapsPtr caps) =20 /* set cpus of a numa node in the bitmask */ static int -virCapabilitiesGetCpusForNode(virCapsPtr caps, - size_t node, - virBitmapPtr cpumask) +virCapabilitiesHostNUMAGetCellCpus(virCapsHostNUMAPtr caps, + size_t node, + virBitmapPtr cpumask) { virCapsHostNUMACellPtr cell =3D NULL; size_t cpu; size_t i; /* The numa node numbers can be non-contiguous. Ex: 0,1,16,17. */ - for (i =3D 0; i < caps->host.nnumaCell; i++) { - if (caps->host.numaCell[i]->num =3D=3D node) { - cell =3D caps->host.numaCell[i]; + for (i =3D 0; i < caps->cells->len; i++) { + cell =3D g_ptr_array_index(caps->cells, i); + if (cell->num =3D=3D node) break; - } + cell =3D NULL; } =20 for (cpu =3D 0; cell && cpu < cell->ncpus; cpu++) { @@ -1443,11 +1440,11 @@ virCapabilitiesGetCpusForNode(virCapsPtr caps, } =20 virBitmapPtr -virCapabilitiesGetCpusForNodemask(virCapsPtr caps, - virBitmapPtr nodemask) +virCapabilitiesHostNUMAGetCpus(virCapsHostNUMAPtr caps, + virBitmapPtr nodemask) { virBitmapPtr ret =3D NULL; - unsigned int maxcpu =3D virCapabilitiesGetHostMaxcpu(caps); + unsigned int maxcpu =3D virCapabilitiesHostNUMAGetMaxcpu(caps); ssize_t node =3D -1; =20 if (!(ret =3D virBitmapNew(maxcpu + 1))) @@ -1455,7 +1452,7 @@ virCapabilitiesGetCpusForNodemask(virCapsPtr caps, =20 =20 while ((node =3D virBitmapNextSetBit(nodemask, node)) >=3D 0) { - if (virCapabilitiesGetCpusForNode(caps, node, ret) < 0) { + if (virCapabilitiesHostNUMAGetCellCpus(caps, node, ret) < 0) { virBitmapFree(ret); return NULL; } @@ -1591,7 +1588,7 @@ virCapabilitiesGetNUMAPagesInfo(int node, =20 =20 static int -virCapabilitiesInitNUMAFake(virCapsPtr caps) +virCapabilitiesHostNUMAInitFake(virCapsHostNUMAPtr caps) { virNodeInfo nodeinfo; virCapsHostNUMACellCPUPtr cpus; @@ -1631,16 +1628,18 @@ virCapabilitiesInitNUMAFake(virCapsPtr caps) } } =20 - if (virCapabilitiesAddHostNUMACell(caps, 0, - nodeinfo.memory, + caps =3D g_new0(virCapsHostNUMA, 1); + caps->cells =3D g_ptr_array_new_with_free_func( + (GDestroyNotify)virCapabilitiesFreeHostNUMACell); + virCapabilitiesHostNUMAAddCell(caps, 0, + nodeinfo.memory, #ifdef __linux__ - onlinecpus, cpus, + onlinecpus, cpus, #else - ncpus, cpus, + ncpus, cpus, #endif - 0, NULL, - 0, NULL) < 0) - goto error; + 0, NULL, + 0, NULL); =20 return 0; =20 @@ -1651,8 +1650,9 @@ virCapabilitiesInitNUMAFake(virCapsPtr caps) return -1; } =20 -int -virCapabilitiesInitNUMA(virCapsPtr caps) + +static int +virCapabilitiesHostNUMAInitReal(virCapsHostNUMAPtr caps) { int n; unsigned long long memory; @@ -1665,12 +1665,8 @@ virCapabilitiesInitNUMA(virCapsPtr caps) int ret =3D -1; int ncpus =3D 0; int cpu; - bool topology_failed =3D false; int max_node; =20 - if (!virNumaIsAvailable()) - return virCapabilitiesInitNUMAFake(caps); - if ((max_node =3D virNumaGetMaxNode()) < 0) goto cleanup; =20 @@ -1690,10 +1686,8 @@ virCapabilitiesInitNUMA(virCapsPtr caps) =20 for (i =3D 0; i < virBitmapSize(cpumap); i++) { if (virBitmapIsBitSet(cpumap, i)) { - if (virCapabilitiesFillCPUInfo(i, cpus + cpu++) < 0) { - topology_failed =3D true; - virResetLastError(); - } + if (virCapabilitiesFillCPUInfo(i, cpus + cpu++) < 0) + goto cleanup; } } =20 @@ -1707,11 +1701,10 @@ virCapabilitiesInitNUMA(virCapsPtr caps) virNumaGetNodeMemory(n, &memory, NULL); memory >>=3D 10; =20 - if (virCapabilitiesAddHostNUMACell(caps, n, memory, - ncpus, cpus, - nsiblings, siblings, - npageinfo, pageinfo) < 0) - goto cleanup; + virCapabilitiesHostNUMAAddCell(caps, n, memory, + ncpus, cpus, + nsiblings, siblings, + npageinfo, pageinfo); =20 cpus =3D NULL; siblings =3D NULL; @@ -1723,9 +1716,6 @@ virCapabilitiesInitNUMA(virCapsPtr caps) ret =3D 0; =20 cleanup: - if ((topology_failed || ret < 0) && cpus) - virCapabilitiesClearHostNUMACellCPUTopology(cpus, ncpus); - virBitmapFree(cpumap); VIR_FREE(cpus); VIR_FREE(siblings); @@ -1733,6 +1723,44 @@ virCapabilitiesInitNUMA(virCapsPtr caps) return ret; } =20 + +virCapsHostNUMAPtr +virCapabilitiesHostNUMANew(void) +{ + virCapsHostNUMAPtr caps =3D NULL; + + caps =3D g_new0(virCapsHostNUMA, 1); + caps->refs =3D 1; + caps->cells =3D g_ptr_array_new_with_free_func( + (GDestroyNotify)virCapabilitiesFreeHostNUMACell); + + return caps; +} + + +virCapsHostNUMAPtr +virCapabilitiesHostNUMANewHost(void) +{ + virCapsHostNUMAPtr caps =3D virCapabilitiesHostNUMANew(); + + if (virNumaIsAvailable()) { + if (virCapabilitiesHostNUMAInitReal(caps) =3D=3D 0) + return caps; + + virCapabilitiesHostNUMAUnref(caps); + caps =3D virCapabilitiesHostNUMANew(); + VIR_WARN("Failed to query host NUMA topology, faking single NUMA n= ode"); + } + + if (virCapabilitiesHostNUMAInitFake(caps) < 0) { + virCapabilitiesHostNUMAUnref(caps); + return NULL; + } + + return caps; +} + + int virCapabilitiesInitPages(virCapsPtr caps) { diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index c39fe0de08..f604e7b95e 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -113,6 +113,11 @@ struct _virCapsHostNUMACell { virCapsHostNUMACellPageInfoPtr pageinfo; }; =20 +struct _virCapsHostNUMA { + gint refs; + GPtrArray *cells; +}; + struct _virCapsHostSecModelLabel { char *type; char *label; @@ -168,9 +173,8 @@ struct _virCapsHost { size_t nmigrateTrans; size_t nmigrateTrans_max; char **migrateTrans; - size_t nnumaCell; - size_t nnumaCell_max; - virCapsHostNUMACellPtr *numaCell; + + virCapsHostNUMAPtr numa; =20 virResctrlInfoPtr resctrl; =20 @@ -225,7 +229,11 @@ virCapabilitiesNew(virArch hostarch, bool liveMigrate); =20 void -virCapabilitiesFreeNUMAInfo(virCapsPtr caps); +virCapabilitiesHostNUMAUnref(virCapsHostNUMAPtr caps); +void +virCapabilitiesHostNUMARef(virCapsHostNUMAPtr caps); + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virCapsHostNUMA, virCapabilitiesHostNUMAUnre= f); =20 int virCapabilitiesAddHostFeature(virCapsPtr caps, @@ -239,8 +247,8 @@ int virCapabilitiesSetNetPrefix(virCapsPtr caps, const char *prefix); =20 -int -virCapabilitiesAddHostNUMACell(virCapsPtr caps, +void +virCapabilitiesHostNUMAAddCell(virCapsHostNUMAPtr caps, int num, unsigned long long mem, int ncpus, @@ -323,14 +331,15 @@ virCapabilitiesClearHostNUMACellCPUTopology(virCapsHo= stNUMACellCPUPtr cpu, char * virCapabilitiesFormatXML(virCapsPtr caps); =20 -virBitmapPtr virCapabilitiesGetCpusForNodemask(virCapsPtr caps, - virBitmapPtr nodemask); +virBitmapPtr virCapabilitiesHostNUMAGetCpus(virCapsHostNUMAPtr caps, + virBitmapPtr nodemask); =20 int virCapabilitiesGetNodeInfo(virNodeInfoPtr nodeinfo); =20 int virCapabilitiesInitPages(virCapsPtr caps); =20 -int virCapabilitiesInitNUMA(virCapsPtr caps); +virCapsHostNUMAPtr virCapabilitiesHostNUMANew(void); +virCapsHostNUMAPtr virCapabilitiesHostNUMANewHost(void); =20 bool virCapsHostCacheBankEquals(virCapsHostCacheBankPtr a, virCapsHostCacheBankPtr b); diff --git a/src/conf/virconftypes.h b/src/conf/virconftypes.h index 462842f324..2c91d3f331 100644 --- a/src/conf/virconftypes.h +++ b/src/conf/virconftypes.h @@ -66,6 +66,9 @@ typedef virCapsHostMemBW *virCapsHostMemBWPtr; typedef struct _virCapsHostMemBWNode virCapsHostMemBWNode; typedef virCapsHostMemBWNode *virCapsHostMemBWNodePtr; =20 +typedef struct _virCapsHostNUMA virCapsHostNUMA; +typedef virCapsHostNUMA *virCapsHostNUMAPtr; + typedef struct _virCapsHostNUMACell virCapsHostNUMACell; typedef virCapsHostNUMACell *virCapsHostNUMACellPtr; =20 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 74ca8585ee..0465ce8fc1 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -49,7 +49,6 @@ virCapabilitiesAddGuestFeature; virCapabilitiesAddGuestFeatureWithToggle; virCapabilitiesAddHostFeature; virCapabilitiesAddHostMigrateTransport; -virCapabilitiesAddHostNUMACell; virCapabilitiesAddStoragePool; virCapabilitiesAllocMachines; virCapabilitiesClearHostNUMACellCPUTopology; @@ -58,13 +57,16 @@ virCapabilitiesDomainSupported; virCapabilitiesFormatXML; virCapabilitiesFreeGuest; virCapabilitiesFreeMachines; -virCapabilitiesFreeNUMAInfo; -virCapabilitiesGetCpusForNodemask; virCapabilitiesGetNodeInfo; virCapabilitiesHostInitIOMMU; +virCapabilitiesHostNUMAAddCell; +virCapabilitiesHostNUMAGetCpus; +virCapabilitiesHostNUMANew; +virCapabilitiesHostNUMANewHost; +virCapabilitiesHostNUMARef; +virCapabilitiesHostNUMAUnref; virCapabilitiesHostSecModelAddBaseLabel; virCapabilitiesInitCaches; -virCapabilitiesInitNUMA; virCapabilitiesInitPages; virCapabilitiesNew; virCapabilitiesSetHostCPU; diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c index c920c2aec5..e2327474fa 100644 --- a/src/libxl/libxl_capabilities.c +++ b/src/libxl/libxl_capabilities.c @@ -320,6 +320,7 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCapsPtr caps) } } =20 + caps->host.numa =3D virCapabilitiesHostNUMANew(); for (i =3D 0; i < nr_nodes; i++) { if (numa_info[i].size =3D=3D LIBXL_NUMAINFO_INVALID_ENTRY) continue; @@ -337,15 +338,11 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCapsPtr caps) } } =20 - if (virCapabilitiesAddHostNUMACell(caps, i, - numa_info[i].size / 1024, - nr_cpus_node[i], cpus[i], - nr_siblings, siblings, - 0, NULL) < 0) { - virCapabilitiesClearHostNUMACellCPUTopology(cpus[i], - nr_cpus_node[i]); - goto cleanup; - } + virCapabilitiesHostNUMAAddCell(caps->host.numa, i, + numa_info[i].size / 1024, + nr_cpus_node[i], cpus[i], + nr_siblings, siblings, + 0, NULL); =20 /* This is safe, as the CPU list is now stored in the NUMA cell */ cpus[i] =3D NULL; @@ -357,7 +354,10 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCapsPtr caps) if (ret !=3D 0) { for (i =3D 0; cpus && i < nr_nodes; i++) VIR_FREE(cpus[i]); - virCapabilitiesFreeNUMAInfo(caps); + if (caps->host.numa) { + virCapabilitiesHostNUMAUnref(caps->host.numa); + caps->host.numa =3D NULL; + } VIR_FREE(siblings); } =20 diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c index 2e866973ce..2df1537b22 100644 --- a/src/lxc/lxc_conf.c +++ b/src/lxc/lxc_conf.c @@ -70,10 +70,8 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver) * unexpected failures. We don't want to break the lxc * driver in this scenario, so log errors & carry on */ - if (virCapabilitiesInitNUMA(caps) < 0) { - virCapabilitiesFreeNUMAInfo(caps); - VIR_WARN("Failed to query host NUMA topology, disabling NUMA capab= ilities"); - } + if (!(caps->host.numa =3D virCapabilitiesHostNUMANewHost())) + goto error; =20 if (virCapabilitiesInitCaches(caps) < 0) VIR_WARN("Failed to get host CPU cache info"); diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index a15d68d37f..971adaf71c 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -155,7 +155,7 @@ virCapsPtr openvzCapsInit(void) false, false)) =3D=3D NULL) goto no_memory; =20 - if (virCapabilitiesInitNUMA(caps) < 0) + if (!(caps->host.numa =3D virCapabilitiesHostNUMANewHost())) goto no_memory; =20 if (virCapabilitiesInitCaches(caps) < 0) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 640d90585a..6bd37a6925 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -322,11 +322,8 @@ phypCapsInit(void) * unexpected failures. We don't want to break the QEMU * driver in this scenario, so log errors & carry on */ - if (virCapabilitiesInitNUMA(caps) < 0) { - virCapabilitiesFreeNUMAInfo(caps); - VIR_WARN - ("Failed to query host NUMA topology, disabling NUMA capabilit= ies"); - } + if (!(caps->host.numa =3D virCapabilitiesHostNUMANewHost())) + goto no_memory; =20 if (virCapabilitiesInitCaches(caps) < 0) VIR_WARN("Failed to get host CPU cache info"); diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index bfe59a1eff..ea3558a3db 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1036,10 +1036,8 @@ virQEMUCapsInit(virFileCachePtr cache) * unexpected failures. We don't want to break the QEMU * driver in this scenario, so log errors & carry on */ - if (virCapabilitiesInitNUMA(caps) < 0) { - virCapabilitiesFreeNUMAInfo(caps); - VIR_WARN("Failed to query host NUMA topology, disabling NUMA capab= ilities"); - } + if (!(caps->host.numa =3D virCapabilitiesHostNUMANewHost())) + goto error; =20 if (virCapabilitiesInitCaches(caps) < 0) VIR_WARN("Failed to get host CPU cache info"); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 84813ded40..e1cbffa935 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2941,8 +2941,11 @@ qemuDomainObjPrivateXMLParseAutomaticPlacement(xmlXP= athContextPtr ctxt, /* Figure out how big the nodeset bitmap needs to be. * This is necessary because NUMA node IDs are not guaranteed to * start from 0 or be densely allocated */ - for (i =3D 0; i < caps->host.nnumaCell; i++) - nodesetSize =3D MAX(nodesetSize, caps->host.numaCell[i]->num + 1); + for (i =3D 0; i < caps->host.numa->cells->len; i++) { + virCapsHostNUMACellPtr cell =3D + g_ptr_array_index(caps->host.numa->cells, i); + nodesetSize =3D MAX(nodesetSize, cell->num + 1); + } =20 if (nodeset && virBitmapParse(nodeset, &priv->autoNodeset, nodesetSize) < 0) @@ -2954,8 +2957,8 @@ qemuDomainObjPrivateXMLParseAutomaticPlacement(xmlXPa= thContextPtr ctxt, } else { /* autoNodeset is present in this case, since otherwise we wouldn't * reach this code */ - if (!(priv->autoCpuset =3D virCapabilitiesGetCpusForNodemask(caps, - priv->a= utoNodeset))) + if (!(priv->autoCpuset =3D virCapabilitiesHostNUMAGetCpus(caps->ho= st.numa, + priv->auto= Nodeset))) goto cleanup; } =20 diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index c7f9acadeb..bb10e8b2ef 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -4809,16 +4809,12 @@ qemuMigrationDstPersist(virQEMUDriverPtr driver, { virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); qemuDomainObjPrivatePtr priv =3D vm->privateData; - virCapsPtr caps =3D NULL; virDomainDefPtr vmdef; virDomainDefPtr oldDef =3D NULL; unsigned int oldPersist =3D vm->persistent; virObjectEventPtr event; int ret =3D -1; =20 - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - goto cleanup; - vm->persistent =3D 1; oldDef =3D vm->newDef; vm->newDef =3D qemuMigrationCookieGetPersistent(mig); @@ -4842,7 +4838,6 @@ qemuMigrationDstPersist(virQEMUDriverPtr driver, =20 cleanup: virDomainDefFree(oldDef); - virObjectUnref(caps); virObjectUnref(cfg); return ret; =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 4287ed0830..623ea761e1 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6161,7 +6161,7 @@ qemuProcessPrepareDomainNUMAPlacement(virDomainObjPtr= vm, /* numad may return a nodeset that only contains cpus but cgroups don'= t play * well with that. Set the autoCpuset from all cpus from that nodeset,= but * assign autoNodeset only with nodes containing memory. */ - if (!(priv->autoCpuset =3D virCapabilitiesGetCpusForNodemask(caps, num= adNodeset))) + if (!(priv->autoCpuset =3D virCapabilitiesHostNUMAGetCpus(caps->host.n= uma, numadNodeset))) goto cleanup; =20 virBitmapIntersect(numadNodeset, hostMemoryNodeset); diff --git a/src/test/test_driver.c b/src/test/test_driver.c index f3d6061625..2e4ecfd0ff 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -302,6 +302,7 @@ testBuildCapabilities(virConnectPtr conn) caps->host.pagesSize[caps->host.nPagesSize++] =3D 2048; caps->host.pagesSize[caps->host.nPagesSize++] =3D 1024 * 1024; =20 + caps->host.numa =3D virCapabilitiesHostNUMANew(); for (i =3D 0; i < privconn->numCells; i++) { virCapsHostNUMACellCPUPtr cpu_cells; virCapsHostNUMACellPageInfoPtr pages; @@ -326,10 +327,10 @@ testBuildCapabilities(virConnectPtr conn) =20 pages[0].avail =3D privconn->cells[i].mem / pages[0].size; =20 - if (virCapabilitiesAddHostNUMACell(caps, i, privconn->cells[i].mem, - privconn->cells[i].numCpus, - cpu_cells, 0, NULL, nPages, pag= es) < 0) - goto error; + virCapabilitiesHostNUMAAddCell(caps->host.numa, + i, privconn->cells[i].mem, + privconn->cells[i].numCpus, + cpu_cells, 0, NULL, nPages, pages); } =20 for (i =3D 0; i < G_N_ELEMENTS(guest_types); i++) { diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 2930a2f0e1..5957ae52c4 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -76,7 +76,7 @@ vboxCapsInit(void) false, false)) =3D=3D NULL) goto no_memory; =20 - if (virCapabilitiesInitNUMA(caps) < 0) + if (!(caps->host.numa =3D virCapabilitiesHostNUMANewHost())) goto no_memory; =20 if (virCapabilitiesInitCaches(caps) < 0) diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c index ef7696a496..9f7d874c12 100644 --- a/src/vmware/vmware_conf.c +++ b/src/vmware/vmware_conf.c @@ -71,7 +71,7 @@ vmwareCapsInit(void) false, false)) =3D=3D NULL) goto error; =20 - if (virCapabilitiesInitNUMA(caps) < 0) + if (!(caps->host.numa =3D virCapabilitiesHostNUMANewHost())) goto error; =20 if (virCapabilitiesInitCaches(caps) < 0) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 0acdcb9760..9e8ea676e0 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -116,7 +116,7 @@ vzBuildCapabilities(void) false, false)) =3D=3D NULL) return NULL; =20 - if (virCapabilitiesInitNUMA(caps) < 0) + if (!(caps->host.numa =3D virCapabilitiesHostNUMANewHost())) goto error; =20 if (virCapabilitiesInitCaches(caps) < 0) diff --git a/tests/testutils.c b/tests/testutils.c index c55450de96..7a0d306eb7 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -1053,10 +1053,10 @@ virCapsPtr virTestGenericCapsInit(void) * Build NUMA topology with cell id starting from (0 + seq) * for testing */ -int -virTestCapsBuildNUMATopology(virCapsPtr caps, - int seq) +virCapsHostNUMAPtr +virTestCapsBuildNUMATopology(int seq) { + virCapsHostNUMAPtr caps =3D virCapabilitiesHostNUMANew(); virCapsHostNUMACellCPUPtr cell_cpus =3D NULL; int core_id, cell_id; int id; @@ -1077,22 +1077,21 @@ virTestCapsBuildNUMATopology(virCapsPtr caps, } id++; =20 - if (virCapabilitiesAddHostNUMACell(caps, cell_id + seq, - MAX_MEM_IN_CELL, - MAX_CPUS_IN_CELL, cell_cpus, - VIR_ARCH_NONE, NULL, - VIR_ARCH_NONE, NULL) < 0) - goto error; + virCapabilitiesHostNUMAAddCell(caps, cell_id + seq, + MAX_MEM_IN_CELL, + MAX_CPUS_IN_CELL, cell_cpus, + VIR_ARCH_NONE, NULL, + VIR_ARCH_NONE, NULL); =20 cell_cpus =3D NULL; } =20 - return 0; + return caps; =20 error: - virCapabilitiesClearHostNUMACellCPUTopology(cell_cpus, MAX_CPUS_IN_CEL= L); + virCapabilitiesHostNUMAUnref(caps); VIR_FREE(cell_cpus); - return -1; + return NULL; } =20 static virDomainDefParserConfig virTestGenericDomainDefParserConfig =3D { diff --git a/tests/testutils.h b/tests/testutils.h index c3f2cee85f..dcb7cc4c04 100644 --- a/tests/testutils.h +++ b/tests/testutils.h @@ -157,8 +157,7 @@ int virTestMain(int argc, #define VIR_TEST_MOCK(mock) (abs_builddir "/.libs/lib" mock "mock" MOCK_EX= T) =20 virCapsPtr virTestGenericCapsInit(void); -int virTestCapsBuildNUMATopology(virCapsPtr caps, - int seq); +virCapsHostNUMAPtr virTestCapsBuildNUMATopology(int seq); virDomainXMLOptionPtr virTestGenericDomainXMLConfInit(void); =20 typedef enum { diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 38be2cfe42..731775adc0 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -205,7 +205,7 @@ virCapsPtr testQemuCapsInit(void) * Build a NUMA topology with cell_id (NUMA node id * being 3(0 + 3),4(1 + 3), 5 and 6 */ - if (virTestCapsBuildNUMATopology(caps, 3) < 0) + if (!(caps->host.numa =3D virTestCapsBuildNUMATopology(3))) goto cleanup; =20 for (i =3D 0; i < VIR_ARCH_LAST; i++) { diff --git a/tests/vircaps2xmltest.c b/tests/vircaps2xmltest.c index 32c8f95303..6c08a26ec4 100644 --- a/tests/vircaps2xmltest.c +++ b/tests/vircaps2xmltest.c @@ -58,8 +58,10 @@ test_virCapabilities(const void *opaque) if (!caps) goto cleanup; =20 - if (virCapabilitiesInitNUMA(caps) < 0 || - virCapabilitiesInitCaches(caps) < 0) + if (!(caps->host.numa =3D virCapabilitiesHostNUMANewHost())) + goto cleanup; + + if (virCapabilitiesInitCaches(caps) < 0) goto cleanup; =20 virFileWrapperClearPrefixes(); diff --git a/tests/vircapstest.c b/tests/vircapstest.c index 8c5982c9ac..6251ade1a1 100644 --- a/tests/vircapstest.c +++ b/tests/vircapstest.c @@ -35,27 +35,22 @@ test_virCapabilitiesGetCpusForNodemask(const void *data= G_GNUC_UNUSED) const char *nodestr =3D "3,4,5,6"; virBitmapPtr nodemask =3D NULL; virBitmapPtr cpumap =3D NULL; - virCapsPtr caps =3D NULL; + g_autoptr(virCapsHostNUMA) caps =3D NULL; int mask_size =3D 8; int ret =3D -1; =20 - - if (!(caps =3D virCapabilitiesNew(VIR_ARCH_X86_64, false, false))) - goto error; - - if (virTestCapsBuildNUMATopology(caps, 3) < 0) + if (!(caps =3D virTestCapsBuildNUMATopology(3))) goto error; =20 if (virBitmapParse(nodestr, &nodemask, mask_size) < 0) goto error; =20 - if (!(cpumap =3D virCapabilitiesGetCpusForNodemask(caps, nodemask))) + if (!(cpumap =3D virCapabilitiesHostNUMAGetCpus(caps, nodemask))) goto error; =20 ret =3D 0; =20 error: - virObjectUnref(caps); virBitmapFree(nodemask); virBitmapFree(cpumap); return ret; --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 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=1575469386; cv=none; d=zohomail.com; s=zohoarc; b=fYRE4IXozRp/KCVVW3yaOxDAQlVAXjBxYFdMeGFnOfBDADRrNWv47FF9bgmB02+nnPvpjKWsnf7Iie0Tv/0YxhzN9t2sE4nR88TCIa5wD3HYKBSguxZPviJk9LzpZAoj4qPDsp+rsbhPl4RgKT7S90OwfK7GliYe9J4Xypq/ir8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469386; 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=QrlWOa+/E+AlB636csld4xbYWY27gs9oZ2PTO5jthMM=; b=C7MqeEy2WxDJTdOwFOVNQ793kCoH/813cr9+YvhKgljlngTf1D9wzNQHXKxtWwz/Xn4gC7JakNtUzY19YCMvIG7PqE9YI9w/ew3MhP2woxEX4ys8XvK8Juw6CfFqJ/gk1IVo0gfnqPthVw1nS4bf2sMxkN86taONFRY5Mz4udk8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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 [205.139.110.61]) by mx.zohomail.com with SMTPS id 1575469386757944.0687898044557; Wed, 4 Dec 2019 06:23:06 -0800 (PST) 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-347-q77AFnKxP8K_RHuUItkmJQ-1; Wed, 04 Dec 2019 09:22:07 -0500 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 D1A3818036B1; Wed, 4 Dec 2019 14:21:58 +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 AC141691B1; Wed, 4 Dec 2019 14:21:58 +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 64CF365D1E; Wed, 4 Dec 2019 14:21:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4ELvok008348 for ; Wed, 4 Dec 2019 09:21:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id 58D22691B0; Wed, 4 Dec 2019 14:21:57 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id C2C5067E62; Wed, 4 Dec 2019 14:21:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469385; 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=QrlWOa+/E+AlB636csld4xbYWY27gs9oZ2PTO5jthMM=; b=Y3IQgDLuooTGRHptY017qTqmXNOiwxFwB+0m7c+aknXOnRFvQbW/G/1cWhA6BxnYzMiooG iryDCMlBf5PXBzUj9DjPDBwIpp5FbLvvRW1SGkzyK6dpNOj5AaHOH8qt5NOBhNjBpLQky1 oejjNTvdT5BiMQ6pl2tNaF1CwhR2dik= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:21:09 +0000 Message-Id: <20191204142113.2961028-27-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 26/30] qemu: use NUMA capabilities object directly 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-MC-Unique: q77AFnKxP8K_RHuUItkmJQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Avoid grabbing the whole virCapsPtr object when we only need the NUMA information. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/qemu/qemu_capabilities.c | 7 ------- src/qemu/qemu_conf.c | 17 +++++++++++++++ src/qemu/qemu_conf.h | 6 ++++++ src/qemu/qemu_domain.c | 10 ++++----- src/qemu/qemu_process.c | 40 +++++++++++++++--------------------- tests/testutilsqemu.c | 18 +++++++++++----- 6 files changed, 57 insertions(+), 41 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index ea3558a3db..66bee49d6f 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1032,13 +1032,6 @@ virQEMUCapsInit(virFileCachePtr cache) true, true)) =3D=3D NULL) goto error; =20 - /* Some machines have problematic NUMA topology causing - * unexpected failures. We don't want to break the QEMU - * driver in this scenario, so log errors & carry on - */ - if (!(caps->host.numa =3D virCapabilitiesHostNUMANewHost())) - goto error; - if (virCapabilitiesInitCaches(caps) < 0) VIR_WARN("Failed to get host CPU cache info"); =20 diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 053bcc7e02..ba3001ccd0 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1204,6 +1204,22 @@ virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver, } =20 =20 +virCapsHostNUMAPtr +virQEMUDriverGetHostNUMACaps(virQEMUDriverPtr driver) +{ + qemuDriverLock(driver); + + if (!driver->hostnuma) + driver->hostnuma =3D virCapabilitiesHostNUMANewHost(); + + qemuDriverUnlock(driver); + + virCapabilitiesHostNUMARef(driver->hostnuma); + + return driver->hostnuma; +} + + virCapsPtr virQEMUDriverCreateCapabilities(virQEMUDriverPtr driver) { size_t i, j; @@ -1255,6 +1271,7 @@ virCapsPtr virQEMUDriverCreateCapabilities(virQEMUDri= verPtr driver) "DOI \"%s\"", model, doi); } =20 + caps->host.numa =3D virQEMUDriverGetHostNUMACaps(driver); return g_steal_pointer(&caps); } =20 diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 8b6c2a95d4..2d03df9171 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -262,6 +262,11 @@ struct _virQEMUDriver { */ virCapsPtr caps; =20 + /* Lazy initialized on first use, immutable thereafter. + * Require lock to get the pointer & do optional initialization + */ + virCapsHostNUMAPtr hostnuma; + /* Immutable value */ virArch hostarch; =20 @@ -319,6 +324,7 @@ virQEMUDriverConfigSetDefaults(virQEMUDriverConfigPtr c= fg); virQEMUDriverConfigPtr virQEMUDriverGetConfig(virQEMUDriverPtr driver); bool virQEMUDriverIsPrivileged(virQEMUDriverPtr driver); =20 +virCapsHostNUMAPtr virQEMUDriverGetHostNUMACaps(virQEMUDriverPtr driver); virCapsPtr virQEMUDriverCreateCapabilities(virQEMUDriverPtr driver); virCapsPtr virQEMUDriverGetCapabilities(virQEMUDriverPtr driver, bool refresh); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e1cbffa935..a18da01bf9 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2922,7 +2922,7 @@ qemuDomainObjPrivateXMLParseAutomaticPlacement(xmlXPa= thContextPtr ctxt, qemuDomainObjPrivatePtr pri= v, virQEMUDriverPtr driver) { - virCapsPtr caps =3D NULL; + g_autoptr(virCapsHostNUMA) caps =3D NULL; char *nodeset; char *cpuset; int nodesetSize =3D 0; @@ -2935,15 +2935,15 @@ qemuDomainObjPrivateXMLParseAutomaticPlacement(xmlX= PathContextPtr ctxt, if (!nodeset && !cpuset) return 0; =20 - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) + if (!(caps =3D virQEMUDriverGetHostNUMACaps(driver))) goto cleanup; =20 /* Figure out how big the nodeset bitmap needs to be. * This is necessary because NUMA node IDs are not guaranteed to * start from 0 or be densely allocated */ - for (i =3D 0; i < caps->host.numa->cells->len; i++) { + for (i =3D 0; i < caps->cells->len; i++) { virCapsHostNUMACellPtr cell =3D - g_ptr_array_index(caps->host.numa->cells, i); + g_ptr_array_index(caps->cells, i); nodesetSize =3D MAX(nodesetSize, cell->num + 1); } =20 @@ -2957,7 +2957,7 @@ qemuDomainObjPrivateXMLParseAutomaticPlacement(xmlXPa= thContextPtr ctxt, } else { /* autoNodeset is present in this case, since otherwise we wouldn't * reach this code */ - if (!(priv->autoCpuset =3D virCapabilitiesHostNUMAGetCpus(caps->ho= st.numa, + if (!(priv->autoCpuset =3D virCapabilitiesHostNUMAGetCpus(caps, priv->auto= Nodeset))) goto cleanup; } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 623ea761e1..cc89ff8571 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6129,14 +6129,14 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def, =20 =20 static int -qemuProcessPrepareDomainNUMAPlacement(virDomainObjPtr vm, - virCapsPtr caps) +qemuProcessPrepareDomainNUMAPlacement(virQEMUDriverPtr driver, + virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv =3D vm->privateData; - char *nodeset =3D NULL; - virBitmapPtr numadNodeset =3D NULL; - virBitmapPtr hostMemoryNodeset =3D NULL; - int ret =3D -1; + g_autofree char *nodeset =3D NULL; + g_autoptr(virBitmap) numadNodeset =3D NULL; + g_autoptr(virBitmap) hostMemoryNodeset =3D NULL; + g_autoptr(virCapsHostNUMA) caps =3D NULL; =20 /* Get the advisory nodeset from numad if 'placement' of * either or is 'auto'. @@ -6148,33 +6148,30 @@ qemuProcessPrepareDomainNUMAPlacement(virDomainObjP= tr vm, virDomainDefGetMemoryTotal(vm-= >def)); =20 if (!nodeset) - goto cleanup; + return -1; =20 if (!(hostMemoryNodeset =3D virNumaGetHostMemoryNodeset())) - goto cleanup; + return -1; =20 VIR_DEBUG("Nodeset returned from numad: %s", nodeset); =20 if (virBitmapParse(nodeset, &numadNodeset, VIR_DOMAIN_CPUMASK_LEN) < 0) - goto cleanup; + return -1; + + if (!(caps =3D virQEMUDriverGetHostNUMACaps(driver))) + return -1; =20 /* numad may return a nodeset that only contains cpus but cgroups don'= t play * well with that. Set the autoCpuset from all cpus from that nodeset,= but * assign autoNodeset only with nodes containing memory. */ - if (!(priv->autoCpuset =3D virCapabilitiesHostNUMAGetCpus(caps->host.n= uma, numadNodeset))) - goto cleanup; + if (!(priv->autoCpuset =3D virCapabilitiesHostNUMAGetCpus(caps, numadN= odeset))) + return -1; =20 virBitmapIntersect(numadNodeset, hostMemoryNodeset); =20 priv->autoNodeset =3D g_steal_pointer(&numadNodeset); =20 - ret =3D 0; - - cleanup: - VIR_FREE(nodeset); - virBitmapFree(numadNodeset); - virBitmapFree(hostMemoryNodeset); - return ret; + return 0; } =20 =20 @@ -6252,10 +6249,6 @@ qemuProcessPrepareDomain(virQEMUDriverPtr driver, size_t i; qemuDomainObjPrivatePtr priv =3D vm->privateData; virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); - virCapsPtr caps; - - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - goto cleanup; =20 priv->machineName =3D qemuDomainGetMachineName(vm); if (!priv->machineName) @@ -6271,7 +6264,7 @@ qemuProcessPrepareDomain(virQEMUDriverPtr driver, } virDomainAuditSecurityLabel(vm, true); =20 - if (qemuProcessPrepareDomainNUMAPlacement(vm, caps) < 0) + if (qemuProcessPrepareDomainNUMAPlacement(driver, vm) < 0) goto cleanup; } =20 @@ -6359,7 +6352,6 @@ qemuProcessPrepareDomain(virQEMUDriverPtr driver, =20 ret =3D 0; cleanup: - virObjectUnref(caps); virObjectUnref(cfg); return ret; } diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 731775adc0..fb9b85747a 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -109,6 +109,18 @@ virFindFileInPath(const char *file) return NULL; } =20 + +virCapsHostNUMAPtr +virCapabilitiesHostNUMANewHost(void) +{ + /* + * Build a NUMA topology with cell_id (NUMA node id + * being 3(0 + 3),4(1 + 3), 5 and 6 + */ + return virTestCapsBuildNUMATopology(3); +} + + static int testQemuAddGuest(virCapsPtr caps, virArch arch) @@ -201,11 +213,7 @@ virCapsPtr testQemuCapsInit(void) =20 qemuTestSetHostCPU(caps, NULL); =20 - /* - * Build a NUMA topology with cell_id (NUMA node id - * being 3(0 + 3),4(1 + 3), 5 and 6 - */ - if (!(caps->host.numa =3D virTestCapsBuildNUMATopology(3))) + if (!(caps->host.numa =3D virCapabilitiesHostNUMANewHost())) goto cleanup; =20 for (i =3D 0; i < VIR_ARCH_LAST; i++) { --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 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=1575469396; cv=none; d=zohomail.com; s=zohoarc; b=nvSklxI3lOOGB6jdoCwsAcuNfa3pdIM9Da0mvYsnAfwJKkAxPnC5sWMgSfFFXkDZ5Ho80Lm1kJWUW42S3fnLMluFicx6jmEziYCrY5lZXXP+mj+ZLRdFDRyXHcEaSQBT2w4L81x9loGrGhmiMZUM2H0J0VPhfIuEgVvdMt59CKk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469396; 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=ULLRoWis+raiGGrezSxEtuqZR1bLVp8WhFVEIM+qRog=; b=cdG2Q/bwK0dR7nyD95/TMW0J1+paNo/Y7BPeIQRc7crZGXY1MP5UYHmWGIxEXZipzd4AjoqpglwGLgdmcEbPgwVBTSZZif2UxUF5Hsl9tFZMyfFmofVFQJGcn4Nl27ml7wg02cUT2Tgj2pLJOYnV9Ynr7K0q/0RR8rwHRKUklNI= 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-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1575469396753692.2181326312377; Wed, 4 Dec 2019 06:23:16 -0800 (PST) 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-265-RjXWtCUTM7u90Ijlkxcv9A-1; Wed, 04 Dec 2019 09:22:16 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6EF3B800C7B; Wed, 4 Dec 2019 14:22:08 +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 42C44600C8; Wed, 4 Dec 2019 14:22:08 +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 EF19765D36; Wed, 4 Dec 2019 14:22:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4ELwF6008360 for ; Wed, 4 Dec 2019 09:21:58 -0500 Received: by smtp.corp.redhat.com (Postfix) id 97FD1691A3; Wed, 4 Dec 2019 14:21:58 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id B24DF67E62; Wed, 4 Dec 2019 14:21:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469395; 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=ULLRoWis+raiGGrezSxEtuqZR1bLVp8WhFVEIM+qRog=; b=HJZr9zwYpsiyvsy5Qaex8ByEHKaMRq7Qidkm1KnHMJPrPaue4FzDdBRvFupthU1sVKkMh6 Qsej01iUaMgzWCy3BcCok2PWitGpQwICbWFhxpxWrjmTOZQGbUfCQQjbuPlfN1oGftX6AY 0rLMxeA+WlUz5MSnqjd4vuwWxrCbiTY= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:21:10 +0000 Message-Id: <20191204142113.2961028-28-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 27/30] conf: make virCPUDef into a ref counted struct 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.11 X-MC-Unique: RjXWtCUTM7u90Ijlkxcv9A-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Annoyingly there was no existing constructor, and identifying all the places which do a VIR_ALLOC(cpu) is a bit error prone. Hopefully this has found & converted them all. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/conf/cpu_conf.c | 29 ++++++++++++++++++++++------- src/conf/cpu_conf.h | 4 ++++ src/cpu/cpu.c | 3 +-- src/cpu/cpu_arm.c | 5 +---- src/cpu/cpu_ppc64.c | 3 +-- src/cpu/cpu_x86.c | 6 ++---- src/libvirt_private.syms | 2 ++ src/libxl/libxl_capabilities.c | 3 +-- src/libxl/xen_xl.c | 11 +++-------- src/qemu/qemu_capabilities.c | 8 ++------ src/qemu/qemu_domain.c | 2 +- src/vmx/vmx.c | 3 +-- tests/cputest.c | 11 +++-------- 13 files changed, 44 insertions(+), 46 deletions(-) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 4542bcb7bd..7490d6bf73 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -82,6 +82,13 @@ VIR_ENUM_IMPL(virCPUCacheMode, ); =20 =20 +virCPUDefPtr virCPUDefNew(void) +{ + virCPUDefPtr cpu =3D g_new0(virCPUDef, 1); + cpu->refs =3D 1; + return cpu; +} + void virCPUDefFreeFeatures(virCPUDefPtr def) { @@ -104,16 +111,24 @@ virCPUDefFreeModel(virCPUDefPtr def) virCPUDefFreeFeatures(def); } =20 +void +virCPUDefRef(virCPUDefPtr def) +{ + g_atomic_int_inc(&def->refs); +} + void virCPUDefFree(virCPUDefPtr def) { if (!def) return; =20 - virCPUDefFreeModel(def); - VIR_FREE(def->cache); - VIR_FREE(def->tsc); - VIR_FREE(def); + if (g_atomic_int_dec_and_test(&def->refs)) { + virCPUDefFreeModel(def); + VIR_FREE(def->cache); + VIR_FREE(def->tsc); + VIR_FREE(def); + } } =20 =20 @@ -214,9 +229,10 @@ virCPUDefCopyWithoutModel(const virCPUDef *cpu) { virCPUDefPtr copy; =20 - if (!cpu || VIR_ALLOC(copy) < 0) + if (!cpu) return NULL; =20 + copy =3D virCPUDefNew(); copy->type =3D cpu->type; copy->mode =3D cpu->mode; copy->match =3D cpu->match; @@ -340,8 +356,7 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt, goto cleanup; } =20 - if (VIR_ALLOC(def) < 0) - goto cleanup; + def =3D virCPUDefNew(); =20 if (type =3D=3D VIR_CPU_TYPE_AUTO) { if (virXPathBoolean("boolean(./arch)", ctxt)) { diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h index 96fda3e6b3..ec3d2379cf 100644 --- a/src/conf/cpu_conf.h +++ b/src/conf/cpu_conf.h @@ -122,6 +122,7 @@ struct _virCPUCacheDef { typedef struct _virCPUDef virCPUDef; typedef virCPUDef *virCPUDefPtr; struct _virCPUDef { + int refs; int type; /* enum virCPUType */ int mode; /* enum virCPUMode */ int match; /* enum virCPUMatch */ @@ -142,6 +143,7 @@ struct _virCPUDef { virHostCPUTscInfoPtr tsc; }; =20 +virCPUDefPtr virCPUDefNew(void); =20 void ATTRIBUTE_NONNULL(1) virCPUDefFreeFeatures(virCPUDefPtr def); @@ -149,6 +151,8 @@ virCPUDefFreeFeatures(virCPUDefPtr def); void ATTRIBUTE_NONNULL(1) virCPUDefFreeModel(virCPUDefPtr def); =20 +void +virCPUDefRef(virCPUDefPtr def); void virCPUDefFree(virCPUDefPtr def); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virCPUDef, virCPUDefFree); diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index 40f725fd21..a2ae5b8c07 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -393,8 +393,7 @@ virCPUGetHost(virArch arch, if (!(driver =3D cpuGetSubDriver(arch))) return NULL; =20 - if (VIR_ALLOC(cpu) < 0) - return NULL; + cpu =3D virCPUDefNew(); =20 switch (type) { case VIR_CPU_TYPE_HOST: diff --git a/src/cpu/cpu_arm.c b/src/cpu/cpu_arm.c index 70dba6021c..ee5802198f 100644 --- a/src/cpu/cpu_arm.c +++ b/src/cpu/cpu_arm.c @@ -211,10 +211,7 @@ virCPUarmBaseline(virCPUDefPtr *cpus, { virCPUDefPtr cpu =3D NULL; =20 - if (VIR_ALLOC(cpu) < 0) { - virCPUDefFree(cpu); - return NULL; - } + cpu =3D virCPUDefNew(); =20 cpu->model =3D g_strdup(cpus[0]->model); =20 diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c index 3236a9616e..818f1ec699 100644 --- a/src/cpu/cpu_ppc64.c +++ b/src/cpu/cpu_ppc64.c @@ -757,8 +757,7 @@ virCPUppc64Baseline(virCPUDefPtr *cpus, } } =20 - if (VIR_ALLOC(cpu) < 0) - goto error; + cpu =3D virCPUDefNew(); =20 cpu->model =3D g_strdup(model->name); =20 diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index c83cab0c53..1e913cc9fa 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -775,8 +775,7 @@ x86DataToCPU(const virCPUx86Data *data, virCPUx86Data modelData =3D VIR_CPU_X86_DATA_INIT; virCPUx86VendorPtr vendor; =20 - if (VIR_ALLOC(cpu) < 0) - goto error; + cpu =3D virCPUDefNew(); =20 cpu->model =3D g_strdup(model->name); =20 @@ -2807,8 +2806,7 @@ virCPUx86Baseline(virCPUDefPtr *cpus, if (!(base_model =3D x86ModelFromCPU(cpus[0], map, -1))) goto error; =20 - if (VIR_ALLOC(cpu) < 0) - goto error; + cpu =3D virCPUDefNew(); =20 cpu->type =3D VIR_CPU_TYPE_GUEST; cpu->match =3D VIR_CPU_MATCH_EXACT; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 0465ce8fc1..defa527306 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -104,8 +104,10 @@ virCPUDefFreeModel; virCPUDefIsEqual; virCPUDefListFree; virCPUDefListParse; +virCPUDefNew; virCPUDefParseXML; virCPUDefParseXMLString; +virCPUDefRef; virCPUDefStealModel; virCPUDefUpdateFeature; virCPUModeTypeToString; diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c index e2327474fa..e9f958cd8a 100644 --- a/src/libxl/libxl_capabilities.c +++ b/src/libxl/libxl_capabilities.c @@ -169,8 +169,7 @@ libxlCapsInitCPU(virCapsPtr caps, libxl_physinfo *phy_i= nfo, if (!phy_info->hw_cap[0]) return 0; =20 - if (VIR_ALLOC(cpu) < 0) - goto error; + cpu =3D virCPUDefNew(); =20 host_pae =3D phy_info->hw_cap[0] & LIBXL_X86_FEATURE_PAE_MASK; if (host_pae && diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index 18ea4a8d95..cdff71f11b 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -177,10 +177,7 @@ xenParseXLOS(virConfPtr conf, virDomainDefPtr def, vir= CapsPtr caps) } =20 if (!def->cpu) { - virCPUDefPtr cpu; - if (VIR_ALLOC(cpu) < 0) - return -1; - + virCPUDefPtr cpu =3D virCPUDefNew(); cpu->mode =3D VIR_CPU_MODE_HOST_PASSTHROUGH; cpu->type =3D VIR_CPU_TYPE_GUEST; cpu->nfeatures =3D 0; @@ -266,8 +263,7 @@ xenParseXLCPUID(virConfPtr conf, virDomainDefPtr def) return 0; =20 if (!def->cpu) { - if (VIR_ALLOC(def->cpu) < 0) - goto cleanup; + def->cpu =3D virCPUDefNew(); def->cpu->mode =3D VIR_CPU_MODE_HOST_PASSTHROUGH; def->cpu->type =3D VIR_CPU_TYPE_GUEST; def->cpu->nfeatures =3D 0; @@ -445,8 +441,7 @@ xenParseXLVnuma(virConfPtr conf, if (!virDomainNumaSetNodeCount(numa, nr_nodes)) goto cleanup; =20 - if (VIR_ALLOC(cpu) < 0) - goto cleanup; + cpu =3D virCPUDefNew(); =20 list =3D list->list; while (list) { diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 66bee49d6f..16c4331b13 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2720,8 +2720,7 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps, if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION)) return 0; =20 - if (VIR_ALLOC(cpu) < 0) - goto cleanup; + cpu =3D virCPUDefNew(); =20 cpu->model =3D g_strdup(model); =20 @@ -3355,10 +3354,7 @@ virQEMUCapsInitCPUModel(virQEMUCapsPtr qemuCaps, static virCPUDefPtr virQEMUCapsNewHostCPUModel(void) { - virCPUDefPtr cpu; - - if (VIR_ALLOC(cpu) < 0) - return NULL; + virCPUDefPtr cpu =3D virCPUDefNew(); =20 cpu->type =3D VIR_CPU_TYPE_GUEST; cpu->mode =3D VIR_CPU_MODE_CUSTOM; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index a18da01bf9..29a417e931 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4481,7 +4481,7 @@ qemuDomainDefSetDefaultCPU(virDomainDefPtr def, } =20 if (!def->cpu) - def->cpu =3D g_new0(virCPUDef, 1); + def->cpu =3D virCPUDefNew(); =20 def->cpu->type =3D VIR_CPU_TYPE_GUEST; =20 diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index df5eafbd44..37211b7c62 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -1475,8 +1475,7 @@ virVMXParseConfig(virVMXContext *ctx, goto cleanup; =20 if (coresPerSocket > 1) { - if (VIR_ALLOC(cpu) < 0) - goto cleanup; + cpu =3D virCPUDefNew(); =20 cpu->type =3D VIR_CPU_TYPE_GUEST; cpu->mode =3D VIR_CPU_MODE_CUSTOM; diff --git a/tests/cputest.c b/tests/cputest.c index b883ba7b80..fd86344ea4 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -482,8 +482,7 @@ cpuTestMakeQEMUCaps(const struct data *data) if (!(testMon =3D qemuMonitorTestNewFromFile(json, driver.xmlopt, true= ))) goto error; =20 - if (VIR_ALLOC(cpu) < 0) - goto cleanup; + cpu =3D virCPUDefNew(); =20 cpu->model =3D g_strdup("host"); =20 @@ -584,9 +583,7 @@ cpuTestCPUID(bool guest, const void *arg) !(hostData =3D virCPUDataParse(host))) goto cleanup; =20 - if (VIR_ALLOC(cpu) < 0) - goto cleanup; - + cpu =3D virCPUDefNew(); cpu->arch =3D hostData->arch; if (guest) { cpu->type =3D VIR_CPU_TYPE_GUEST; @@ -889,9 +886,7 @@ cpuTestJSONCPUID(const void *arg) if (!(qemuCaps =3D cpuTestMakeQEMUCaps(data))) goto cleanup; =20 - if (VIR_ALLOC(cpu) < 0) - goto cleanup; - + cpu =3D virCPUDefNew(); cpu->arch =3D data->arch; cpu->type =3D VIR_CPU_TYPE_GUEST; cpu->match =3D VIR_CPU_MATCH_EXACT; --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.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 207.211.31.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=1575469342; cv=none; d=zohomail.com; s=zohoarc; b=CANNBnRqcDYuJKdtjbhYsCUjsvK0gn9ANa0PvxLVY8JlTQMTKl+h2Kc0tZzlrRwrbbG6BbZQBgE77gyBXXX8zCoC9ZoXX7CdL3CYENhG30gsbL/y8T9gEJkB3PC4qkqg0HcE5ssFflLtItrV8sLGbiHJiMoz2Hs+IOjkeaDInq8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469342; 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=k2M6nfWt8NXGdfAo2DtK/BH/kz/LkfsrGNPMBhfyKC8=; b=BXslEjpoj9ohU1c3+EYHuOTbspym6Fwr6kh5ZP1kMhLcaLeUD4hwN0E9IYyb7EPJmg3NDLtpkyI704nJZt49NvA0mwkf73doTHJJm5y1C7Xq+sEJQtLOcopeoyukiXND8+bOcmPFcotxVJh4Y8t4WVGSf9QDgmfGTO+vs9iAocw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.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 [207.211.31.120]) by mx.zohomail.com with SMTPS id 157546934227858.26177089487146; Wed, 4 Dec 2019 06:22:22 -0800 (PST) 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-239-98Ay-cA7M7CccBFksuyYsQ-1; Wed, 04 Dec 2019 09:22:18 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 38FDFDC20; Wed, 4 Dec 2019 14:22:12 +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 0DD8E5DA7C; Wed, 4 Dec 2019 14:22:12 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C052418034FD; Wed, 4 Dec 2019 14:22:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4ELxcP008373 for ; Wed, 4 Dec 2019 09:21:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id D4DFA67E62; Wed, 4 Dec 2019 14:21:59 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id F2E09691B1; Wed, 4 Dec 2019 14:21:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469341; 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=k2M6nfWt8NXGdfAo2DtK/BH/kz/LkfsrGNPMBhfyKC8=; b=S0VbkcFIg+IHc9tWWb3oE06wtRjdnYtIDrreXjYipsnACYgzX3P+R3f90MyEVPQ79OK4ma cbNkz7vxvPZfQNpnNnfBtjp6VGY0q9bfaq0WyTYCYC7gXrjuG1UG7Y/uU+1yze3DOtbXSU p+xonG+QhMJFjBHRpDRyE5cJJR3lgnU= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:21:11 +0000 Message-Id: <20191204142113.2961028-29-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 28/30] qemu: use host CPU object directly 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.14 X-MC-Unique: 98Ay-cA7M7CccBFksuyYsQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Avoid grabbing the whole virCapsPtr object when we only need the host CPU information. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/qemu/qemu_capabilities.c | 3 -- src/qemu/qemu_conf.c | 17 +++++++++ src/qemu/qemu_conf.h | 6 ++++ src/qemu/qemu_driver.c | 6 ++-- src/qemu/qemu_process.c | 68 +++++++++++++++--------------------- tests/domaincapstest.c | 14 +++----- tests/qemucapabilitiestest.c | 9 ++--- tests/qemuxml2argvtest.c | 8 ++--- tests/testutilsqemu.c | 49 +++++++++++--------------- tests/testutilsqemu.h | 5 ++- 10 files changed, 89 insertions(+), 96 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 16c4331b13..1b395a2570 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1035,9 +1035,6 @@ virQEMUCapsInit(virFileCachePtr cache) if (virCapabilitiesInitCaches(caps) < 0) VIR_WARN("Failed to get host CPU cache info"); =20 - if (!(caps->host.cpu =3D virCPUProbeHost(caps->host.arch))) - VIR_WARN("Failed to get host CPU"); - /* Add the power management features of the host */ if (virNodeSuspendGetTargetMask(&caps->host.powerMgmt) < 0) VIR_WARN("Failed to get host power management capabilities"); diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index ba3001ccd0..9df4ae1230 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1220,6 +1220,22 @@ virQEMUDriverGetHostNUMACaps(virQEMUDriverPtr driver) } =20 =20 +virCPUDefPtr +virQEMUDriverGetHostCPU(virQEMUDriverPtr driver) +{ + qemuDriverLock(driver); + + if (!driver->hostcpu) + driver->hostcpu =3D virCPUProbeHost(virArchFromHost()); + + qemuDriverUnlock(driver); + + virCPUDefRef(driver->hostcpu); + + return driver->hostcpu; +} + + virCapsPtr virQEMUDriverCreateCapabilities(virQEMUDriverPtr driver) { size_t i, j; @@ -1272,6 +1288,7 @@ virCapsPtr virQEMUDriverCreateCapabilities(virQEMUDri= verPtr driver) } =20 caps->host.numa =3D virQEMUDriverGetHostNUMACaps(driver); + caps->host.cpu =3D virQEMUDriverGetHostCPU(driver); return g_steal_pointer(&caps); } =20 diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 2d03df9171..d2e0bd97e1 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -267,6 +267,11 @@ struct _virQEMUDriver { */ virCapsHostNUMAPtr hostnuma; =20 + /* Lazy initialized on first use, immutable thereafter. + * Require lock to get the pointer & do optional initialization + */ + virCPUDefPtr hostcpu; + /* Immutable value */ virArch hostarch; =20 @@ -325,6 +330,7 @@ virQEMUDriverConfigPtr virQEMUDriverGetConfig(virQEMUDr= iverPtr driver); bool virQEMUDriverIsPrivileged(virQEMUDriverPtr driver); =20 virCapsHostNUMAPtr virQEMUDriverGetHostNUMACaps(virQEMUDriverPtr driver); +virCPUDefPtr virQEMUDriverGetHostCPU(virQEMUDriverPtr driver); virCapsPtr virQEMUDriverCreateCapabilities(virQEMUDriverPtr driver); virCapsPtr virQEMUDriverGetCapabilities(virQEMUDriverPtr driver, bool refresh); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ae6facc829..1fe310e16c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13354,7 +13354,7 @@ qemuConnectCompareCPU(virConnectPtr conn, unsigned int flags) { virQEMUDriverPtr driver =3D conn->privateData; - g_autoptr(virCaps) caps =3D NULL; + g_autoptr(virCPUDef) cpu =3D NULL; bool failIncompatible; =20 virCheckFlags(VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATIBLE, @@ -13365,10 +13365,10 @@ qemuConnectCompareCPU(virConnectPtr conn, =20 failIncompatible =3D !!(flags & VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATI= BLE); =20 - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) + if (!(cpu =3D virQEMUDriverGetHostCPU(driver))) return VIR_CPU_COMPARE_ERROR; =20 - return virCPUCompareXML(driver->hostarch, caps->host.cpu, + return virCPUCompareXML(driver->hostarch, cpu, xmlDesc, failIncompatible); } =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index cc89ff8571..3a3860b1a3 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5291,12 +5291,13 @@ qemuProcessStartValidateDisks(virDomainObjPtr vm, =20 =20 static int -qemuProcessStartValidateTSC(virDomainObjPtr vm, - virCapsPtr caps) +qemuProcessStartValidateTSC(virQEMUDriverPtr driver, + virDomainObjPtr vm) { size_t i; unsigned long long freq =3D 0; virHostCPUTscInfoPtr tsc; + g_autoptr(virCPUDef) cpu =3D NULL; =20 for (i =3D 0; i < vm->def->clock.ntimers; i++) { virDomainTimerDefPtr timer =3D vm->def->clock.timers[i]; @@ -5313,12 +5314,13 @@ qemuProcessStartValidateTSC(virDomainObjPtr vm, =20 VIR_DEBUG("Requested TSC frequency %llu Hz", freq); =20 - if (!caps->host.cpu || !caps->host.cpu->tsc) { + cpu =3D virQEMUDriverGetHostCPU(driver); + if (!cpu || !cpu->tsc) { VIR_DEBUG("Host TSC frequency could not be probed"); return 0; } =20 - tsc =3D caps->host.cpu->tsc; + tsc =3D cpu->tsc; VIR_DEBUG("Host TSC frequency %llu Hz, scaling %s", tsc->frequency, virTristateBoolTypeToString(tsc->scaling)); =20 @@ -5356,7 +5358,6 @@ static int qemuProcessStartValidate(virQEMUDriverPtr driver, virDomainObjPtr vm, virQEMUCapsPtr qemuCaps, - virCapsPtr caps, unsigned int flags) { if (!(flags & VIR_QEMU_PROCESS_START_PRETEND)) { @@ -5424,7 +5425,7 @@ qemuProcessStartValidate(virQEMUDriverPtr driver, if (qemuProcessStartValidateDisks(vm, qemuCaps) < 0) return -1; =20 - if (qemuProcessStartValidateTSC(vm, caps) < 0) + if (qemuProcessStartValidateTSC(driver, vm) < 0) return -1; =20 VIR_DEBUG("Checking for any possible (non-fatal) issues"); @@ -5555,7 +5556,6 @@ qemuProcessInit(virQEMUDriverPtr driver, bool migration, unsigned int flags) { - virCapsPtr caps =3D NULL; qemuDomainObjPrivatePtr priv =3D vm->privateData; int stopFlags; virCPUDefPtr origCPU =3D NULL; @@ -5572,9 +5572,6 @@ qemuProcessInit(virQEMUDriverPtr driver, goto cleanup; } =20 - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - goto cleanup; - /* in case when the post parse callback failed we need to re-run it on= the * old config prior we start the VM */ if (vm->def->postParseFailed) { @@ -5592,7 +5589,7 @@ qemuProcessInit(virQEMUDriverPtr driver, if (qemuDomainUpdateCPU(vm, updatedCPU, &origCPU) < 0) goto cleanup; =20 - if (qemuProcessStartValidate(driver, vm, priv->qemuCaps, caps, flags) = < 0) + if (qemuProcessStartValidate(driver, vm, priv->qemuCaps, flags) < 0) goto cleanup; =20 /* Do this upfront, so any part of the startup process can add @@ -5632,7 +5629,6 @@ qemuProcessInit(virQEMUDriverPtr driver, =20 cleanup: virCPUDefFree(origCPU); - virObjectUnref(caps); return ret; =20 stop: @@ -7803,20 +7799,20 @@ static int qemuProcessRefreshCPU(virQEMUDriverPtr driver, virDomainObjPtr vm) { - virCapsPtr caps =3D virQEMUDriverGetCapabilities(driver, false); qemuDomainObjPrivatePtr priv =3D vm->privateData; - virCPUDefPtr host =3D NULL; - virCPUDefPtr cpu =3D NULL; - int ret =3D -1; + g_autoptr(virCPUDef) host =3D NULL; + g_autoptr(virCPUDef) hostmig =3D NULL; + g_autoptr(virCPUDef) cpu =3D NULL; =20 - if (!caps) - return -1; + if (!virQEMUCapsGuestIsNative(driver->hostarch, vm->def->os.arch)) + return 0; =20 - if (!virQEMUCapsGuestIsNative(driver->hostarch, vm->def->os.arch) || - !caps->host.cpu || - !vm->def->cpu) { - ret =3D 0; - goto cleanup; + if (!vm->def->cpu) + return 0; + + if (!(host =3D virQEMUDriverGetHostCPU(driver))) { + virResetLastError(); + return 0; } =20 /* If the domain with a host-model CPU was started by an old libvirt @@ -7825,20 +7821,20 @@ qemuProcessRefreshCPU(virQEMUDriverPtr driver, * running domain. */ if (vm->def->cpu->mode =3D=3D VIR_CPU_MODE_HOST_MODEL) { - if (!(host =3D virCPUCopyMigratable(caps->host.cpu->arch, caps->ho= st.cpu))) - goto cleanup; + if (!(hostmig =3D virCPUCopyMigratable(host->arch, host))) + return -1; =20 - if (!(cpu =3D virCPUDefCopyWithoutModel(host)) || - virCPUDefCopyModelFilter(cpu, host, false, + if (!(cpu =3D virCPUDefCopyWithoutModel(hostmig)) || + virCPUDefCopyModelFilter(cpu, hostmig, false, virQEMUCapsCPUFilterFeatures, - &caps->host.cpu->arch) < 0) - goto cleanup; + &host->arch) < 0) + return -1; =20 if (virCPUUpdate(vm->def->os.arch, vm->def->cpu, cpu) < 0) - goto cleanup; + return -1; =20 if (qemuProcessUpdateCPU(driver, vm, QEMU_ASYNC_JOB_NONE) < 0) - goto cleanup; + return -1; } else if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_E= XPANSION)) { /* We only try to fix CPUs when the libvirt/QEMU combo used to sta= rt * the domain did not know about query-cpu-model-expansion in which @@ -7846,16 +7842,10 @@ qemuProcessRefreshCPU(virQEMUDriverPtr driver, * doesn't know about. */ if (qemuDomainFixupCPUs(vm, &priv->origCPU) < 0) - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - virCPUDefFree(cpu); - virCPUDefFree(host); - virObjectUnref(caps); - return ret; + return 0; } =20 =20 diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index 94e5831706..a4a443b1d6 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -54,8 +54,7 @@ fillStringValues(virDomainCapsStringValuesPtr values, ...) # include "testutilshostcpus.h" =20 static int -fakeHostCPU(virCapsPtr caps, - virArch arch) +fakeHostCPU(virArch arch) { virCPUDefPtr cpu; =20 @@ -66,7 +65,7 @@ fakeHostCPU(virCapsPtr caps, return -1; } =20 - qemuTestSetHostCPU(caps, cpu); + qemuTestSetHostCPU(NULL, arch, cpu); =20 return 0; } @@ -80,17 +79,15 @@ fillQemuCaps(virDomainCapsPtr domCaps, { int ret =3D -1; char *path =3D NULL; - virCapsPtr caps =3D NULL; virQEMUCapsPtr qemuCaps =3D NULL; virDomainCapsLoaderPtr loader =3D &domCaps->os.loader; virDomainVirtType virtType; =20 - if (!(caps =3D virCapabilitiesNew(domCaps->arch, false, false)) || - fakeHostCPU(caps, domCaps->arch) < 0) + if (fakeHostCPU(domCaps->arch) < 0) goto cleanup; =20 path =3D g_strdup_printf("%s/%s.%s.xml", TEST_QEMU_CAPS_PATH, name, ar= ch); - if (!(qemuCaps =3D qemuTestParseCapabilities(caps, path))) + if (!(qemuCaps =3D qemuTestParseCapabilitiesArch(domCaps->arch, path))) goto cleanup; =20 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) @@ -106,7 +103,7 @@ fillQemuCaps(virDomainCapsPtr domCaps, if (!domCaps->machine) domCaps->machine =3D g_strdup(virQEMUCapsGetPreferredMachine(qemuC= aps, virtType)); =20 - if (virQEMUCapsFillDomainCaps(qemuCaps, caps->host.arch, domCaps, + if (virQEMUCapsFillDomainCaps(qemuCaps, domCaps->arch, domCaps, false, cfg->firmwares, cfg->nfirmwares) < 0) @@ -134,7 +131,6 @@ fillQemuCaps(virDomainCapsPtr domCaps, =20 ret =3D 0; cleanup: - virObjectUnref(caps); virObjectUnref(qemuCaps); VIR_FREE(path); return ret; diff --git a/tests/qemucapabilitiestest.c b/tests/qemucapabilitiestest.c index 3d3e6b6d57..b38c0f6f65 100644 --- a/tests/qemucapabilitiestest.c +++ b/tests/qemucapabilitiestest.c @@ -144,7 +144,6 @@ testQemuCapsCopy(const void *opaque) int ret =3D -1; const testQemuData *data =3D opaque; char *capsFile =3D NULL; - virCapsPtr caps =3D NULL; virQEMUCapsPtr orig =3D NULL; virQEMUCapsPtr copy =3D NULL; char *actual =3D NULL; @@ -153,11 +152,8 @@ testQemuCapsCopy(const void *opaque) data->outputDir, data->prefix, data->versio= n, data->archName); =20 - if (!(caps =3D virCapabilitiesNew(virArchFromString(data->archName), - false, false))) - goto cleanup; - - if (!(orig =3D qemuTestParseCapabilities(caps, capsFile))) + if (!(orig =3D qemuTestParseCapabilitiesArch( + virArchFromString(data->archName), capsFile))) goto cleanup; =20 if (!(copy =3D virQEMUCapsNewCopy(orig))) @@ -173,7 +169,6 @@ testQemuCapsCopy(const void *opaque) =20 cleanup: VIR_FREE(capsFile); - virObjectUnref(caps); virObjectUnref(orig); virObjectUnref(copy); VIR_FREE(actual); diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index fe8fa776be..ba4a92ec0a 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1733,7 +1733,7 @@ mymain(void) DO_TEST_FAILURE("cpu-s390-features", QEMU_CAPS_KVM); qemuTestSetHostArch(&driver, VIR_ARCH_NONE); =20 - qemuTestSetHostCPU(driver.caps, cpuHaswell); + qemuTestSetHostCPU(&driver, driver.hostarch, cpuHaswell); DO_TEST("cpu-Haswell", QEMU_CAPS_KVM); DO_TEST("cpu-Haswell2", QEMU_CAPS_KVM); DO_TEST("cpu-Haswell3", QEMU_CAPS_KVM); @@ -1744,7 +1744,7 @@ mymain(void) DO_TEST_CAPS_VER("cpu-tsc-frequency", "4.0.0"); DO_TEST_CAPS_VER("cpu-translation", "4.0.0"); DO_TEST_CAPS_LATEST("cpu-translation"); - qemuTestSetHostCPU(driver.caps, NULL); + qemuTestSetHostCPU(&driver, driver.hostarch, NULL); =20 DO_TEST("encrypted-disk", QEMU_CAPS_QCOW2_LUKS, QEMU_CAPS_OBJECT_SECRE= T); DO_TEST("encrypted-disk-usage", QEMU_CAPS_QCOW2_LUKS, QEMU_CAPS_OBJECT= _SECRET); @@ -1873,12 +1873,12 @@ mymain(void) QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE, QEMU_CAPS_KVM); =20 - qemuTestSetHostCPU(driver.caps, cpuPower9); + qemuTestSetHostCPU(&driver, driver.hostarch, cpuPower9); DO_TEST("pseries-cpu-compat-power9", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE, QEMU_CAPS_DEVICE_SPAPR_VTY); - qemuTestSetHostCPU(driver.caps, NULL); + qemuTestSetHostCPU(&driver, driver.hostarch, NULL); =20 qemuTestSetHostArch(&driver, VIR_ARCH_NONE); =20 diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index fb9b85747a..6fd121855d 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -205,14 +205,6 @@ virCapsPtr testQemuCapsInit(void) caps->host.secModels[0].model =3D g_strdup("none"); caps->host.secModels[0].doi =3D g_strdup("0"); =20 - if (!(cpuDefault =3D virCPUDefCopy(&cpuDefaultData)) || - !(cpuHaswell =3D virCPUDefCopy(&cpuHaswellData)) || - !(cpuPower8 =3D virCPUDefCopy(&cpuPower8Data)) || - !(cpuPower9 =3D virCPUDefCopy(&cpuPower9Data))) - goto cleanup; - - qemuTestSetHostCPU(caps, NULL); - if (!(caps->host.numa =3D virCapabilitiesHostNUMANewHost())) goto cleanup; =20 @@ -237,9 +229,6 @@ virCapsPtr testQemuCapsInit(void) =20 cleanup: caps->host.cpu =3D NULL; - virCPUDefFree(cpuDefault); - virCPUDefFree(cpuHaswell); - virCPUDefFree(cpuPower8); virObjectUnref(caps); return NULL; } @@ -255,16 +244,15 @@ qemuTestSetHostArch(virQEMUDriverPtr driver, virTestHostArch =3D arch; driver->hostarch =3D virArchFromHost(); driver->caps->host.arch =3D virArchFromHost(); - qemuTestSetHostCPU(driver->caps, NULL); + qemuTestSetHostCPU(driver, arch, NULL); } =20 =20 void -qemuTestSetHostCPU(virCapsPtr caps, +qemuTestSetHostCPU(virQEMUDriverPtr driver, + virArch arch, virCPUDefPtr cpu) { - virArch arch =3D caps->host.arch; - if (!cpu) { if (ARCH_IS_X86(arch)) cpu =3D cpuDefault; @@ -274,11 +262,19 @@ qemuTestSetHostCPU(virCapsPtr caps, =20 unsetenv("VIR_TEST_MOCK_FAKE_HOST_CPU"); if (cpu) { - caps->host.arch =3D cpu->arch; if (cpu->model) setenv("VIR_TEST_MOCK_FAKE_HOST_CPU", cpu->model, 1); } - caps->host.cpu =3D cpu; + if (driver) { + if (cpu) + driver->caps->host.arch =3D cpu->arch; + driver->caps->host.cpu =3D cpu; + + virCPUDefFree(driver->hostcpu); + if (cpu) + virCPUDefRef(cpu); + driver->hostcpu =3D cpu; + } } =20 =20 @@ -300,17 +296,6 @@ qemuTestParseCapabilitiesArch(virArch arch, } =20 =20 -virQEMUCapsPtr -qemuTestParseCapabilities(virCapsPtr caps, - const char *capsFile) -{ - if (!caps) - return NULL; - - return qemuTestParseCapabilitiesArch(caps->host.arch, capsFile); -} - - void qemuTestDriverFree(virQEMUDriver *driver) { virMutexDestroy(&driver->lock); @@ -382,6 +367,12 @@ int qemuTestDriverInit(virQEMUDriver *driver) =20 memset(driver, 0, sizeof(*driver)); =20 + if (!(cpuDefault =3D virCPUDefCopy(&cpuDefaultData)) || + !(cpuHaswell =3D virCPUDefCopy(&cpuHaswellData)) || + !(cpuPower8 =3D virCPUDefCopy(&cpuPower8Data)) || + !(cpuPower9 =3D virCPUDefCopy(&cpuPower9Data))) + return -1; + if (virMutexInit(&driver->lock) < 0) return -1; =20 @@ -439,6 +430,8 @@ int qemuTestDriverInit(virQEMUDriver *driver) if (!(driver->securityManager =3D virSecurityManagerNewStack(mgr))) goto error; =20 + qemuTestSetHostCPU(driver, driver->hostarch, NULL); + return 0; =20 error: diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h index 8dcc930ac3..edee6e450c 100644 --- a/tests/testutilsqemu.h +++ b/tests/testutilsqemu.h @@ -72,8 +72,6 @@ virDomainXMLOptionPtr testQemuXMLConfInit(void); =20 virQEMUCapsPtr qemuTestParseCapabilitiesArch(virArch arch, const char *capsFile); -virQEMUCapsPtr qemuTestParseCapabilities(virCapsPtr caps, - const char *capsFile); =20 extern virCPUDefPtr cpuDefault; extern virCPUDefPtr cpuHaswell; @@ -82,7 +80,8 @@ extern virCPUDefPtr cpuPower9; =20 void qemuTestSetHostArch(virQEMUDriverPtr driver, virArch arch); -void qemuTestSetHostCPU(virCapsPtr caps, +void qemuTestSetHostCPU(virQEMUDriverPtr driver, + virArch arch, virCPUDefPtr cpu); =20 int qemuTestDriverInit(virQEMUDriver *driver); --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 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=1575469346; cv=none; d=zohomail.com; s=zohoarc; b=Bo6OZovoVOuut1/2Qw94KlXE0QMX9+E5884FE2a5q4isAha8wOmy/TZU+FRY7yOOX5xvjrdAV0i104JoQmKcMj1/PmvWDDVMvs9HZ1QtdHv9bou4xTLgPk7nNxQfba423GOBP/lBCnpdYQY68rzB979P5Su7wNrnmCax7SX0lng= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469346; 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=y3VAL/dilg68dJ8fe8HNocSacOgmlVJdkUy4AObjO2c=; b=gjKCp9Wlo/cHTuSzAavGyowGPWkMqXWWeaWdR0bTkLi72cFiczJiBJG1JVe5CQCJWUAVAmfZ/pMUTJJ+DANXqTbvfUGB/gtQHysd2bBRr2MU/Lf7Tb1qApv358L9USYudlzMWjutZf0p0BI/+alxhgWNwkExjVEJuAcAES9IlaU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1575469346032216.9624468815323; Wed, 4 Dec 2019 06:22:26 -0800 (PST) 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-214-We7p1xk6O0Cx8BgE8Jz1iA-1; Wed, 04 Dec 2019 09:22:22 -0500 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 4E16C1005514; Wed, 4 Dec 2019 14:22:16 +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 1FC97691B3; Wed, 4 Dec 2019 14:22:16 +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 C5CDE65D3A; Wed, 4 Dec 2019 14:22:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4EM1O8008385 for ; Wed, 4 Dec 2019 09:22:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id 75DF6691A3; Wed, 4 Dec 2019 14:22:01 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6EFCC67E62; Wed, 4 Dec 2019 14:22:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469344; 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=y3VAL/dilg68dJ8fe8HNocSacOgmlVJdkUy4AObjO2c=; b=KA7QZj5zGu5RlsUEe2Ww3oSMWaN+tLiXB+KacaWcH6oin40y8FlNo7tfrGVJV44KhOtifJ xZiuQrD95CqaxTXmjCpLz4RusCqRmQZaG5jN4jImvbSKa5i+tcV690YgNI0jovxoZEy6Yn QAgPXaiW3Wh16GrClfjf/x6AzFYodjQ= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:21:12 +0000 Message-Id: <20191204142113.2961028-30-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 29/30] qemu: directly create virResctrlInfo ignoring capabilities 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-MC-Unique: We7p1xk6O0Cx8BgE8Jz1iA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) We always refresh the capabilities object when using virResctrlInfo during process startup. This is undesirable overhead, because we can just directly create a virResctrlInfo instead. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/qemu/qemu_process.c | 24 ++++++++---------------- src/util/virresctrl.h | 2 ++ 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 3a3860b1a3..2b35680abc 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -2724,29 +2724,24 @@ qemuProcessSetupEmulator(virDomainObjPtr vm) =20 =20 static int -qemuProcessResctrlCreate(virQEMUDriverPtr driver, - virDomainObjPtr vm) +qemuProcessResctrlCreate(virDomainObjPtr vm) { - int ret =3D -1; size_t i =3D 0; - virCapsPtr caps =3D NULL; qemuDomainObjPrivatePtr priv =3D vm->privateData; + g_autoptr(virResctrlInfo) resctrl =3D NULL; =20 if (!vm->def->nresctrls) return 0; =20 - /* Force capability refresh since resctrl info can change - * XXX: move cache info into virresctrl so caps are not needed */ - caps =3D virQEMUDriverGetCapabilities(driver, true); - if (!caps) + if (!(resctrl =3D virResctrlInfoNew())) return -1; =20 for (i =3D 0; i < vm->def->nresctrls; i++) { size_t j =3D 0; - if (virResctrlAllocCreate(caps->host.resctrl, + if (virResctrlAllocCreate(resctrl, vm->def->resctrls[i]->alloc, priv->machineName) < 0) - goto cleanup; + return -1; =20 for (j =3D 0; j < vm->def->resctrls[i]->nmonitors; j++) { virDomainResctrlMonDefPtr mon =3D NULL; @@ -2754,14 +2749,11 @@ qemuProcessResctrlCreate(virQEMUDriverPtr driver, mon =3D vm->def->resctrls[i]->monitors[j]; if (virResctrlMonitorCreate(mon->instance, priv->machineName) < 0) - goto cleanup; + return -1; } } =20 - ret =3D 0; - cleanup: - virObjectUnref(caps); - return ret; + return 0; } =20 =20 @@ -6882,7 +6874,7 @@ qemuProcessLaunch(virConnectPtr conn, goto cleanup; =20 VIR_DEBUG("Setting up resctrl"); - if (qemuProcessResctrlCreate(driver, vm) < 0) + if (qemuProcessResctrlCreate(vm) < 0) goto cleanup; =20 VIR_DEBUG("Setting up managed PR daemon"); diff --git a/src/util/virresctrl.h b/src/util/virresctrl.h index 3dd7c96348..759320d0fd 100644 --- a/src/util/virresctrl.h +++ b/src/util/virresctrl.h @@ -100,6 +100,8 @@ typedef virResctrlInfo *virResctrlInfoPtr; virResctrlInfoPtr virResctrlInfoNew(void); =20 +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virResctrlInfo, virObjectUnref); + int virResctrlInfoGetCache(virResctrlInfoPtr resctrl, unsigned int level, --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 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=1575469448; cv=none; d=zohomail.com; s=zohoarc; b=M39uVDi6p2vWEFlOfnHmVor6C8lk2rT5gTJQfMoAzDpayxXeeHcn0L+jX/MagtVKza1T2wF/XL51yq2xq0Q6CsxxHuvbOzwUVD9wD1bHRquzUmExAWjlyTqrbMqLw+c/olihzMD96dIMegZxEiR3lABzdR3/BgTwsEXSalsXH1I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469448; 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=qkJ9oums/pq4ZFCOWu/VGy9o83pXdVRT0IuGSyVuAb0=; b=ZqVjnnqzqyGmsdql1/lf4rEJSQ74e1jA3AmpHBYTqwo4e6BG9fNyrj5w1A5ACipEcw7zBMQMM+kASftkfRjR7dJmvy+cVzJKPJckcpyDcRsjYt8INvoHA6/ujnx860FklTYYDbmq6ik7wmo75KGDN+oGG4Diimwg8uq8hK9m2jc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 157546944814028.753669216586786; Wed, 4 Dec 2019 06:24:08 -0800 (PST) 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-116-vEVhx6jEPCuUEdSTR3sMBg-1; Wed, 04 Dec 2019 09:22:26 -0500 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 14961183B714; Wed, 4 Dec 2019 14:22:20 +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 E5E43691BC; Wed, 4 Dec 2019 14:22:19 +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 98DAB180350C; Wed, 4 Dec 2019 14:22:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4EM2Pt008394 for ; Wed, 4 Dec 2019 09:22:02 -0500 Received: by smtp.corp.redhat.com (Postfix) id A3688691A3; Wed, 4 Dec 2019 14:22:02 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id C03DF67E62; Wed, 4 Dec 2019 14:22:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469446; 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=qkJ9oums/pq4ZFCOWu/VGy9o83pXdVRT0IuGSyVuAb0=; b=S8CG3mck7tT3l75oToeQJPhIO7Rp6Y80e69lqe+9gzHmENwA36sCvp7n9B3GfmbRV2oETj NE+zonwXHOHQeguYnDjS5kysaKbY1z/nZEUkfkI3KpMQXmItYyXy11SV3p1X/ir/Ttgnxz NCBdG1XeufiRtZD8XXlc2C6qusJBPx8= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:21:13 +0000 Message-Id: <20191204142113.2961028-31-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 30/30] qemu: stop creating capabilities at driver 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: , 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-MC-Unique: vEVhx6jEPCuUEdSTR3sMBg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Now that nearly all internal APIs use the QEMU capabilities or other QEMU driver data directly, there's no compelling benefit to create virCapsPtr at driver startup. Skipping this means we don't probe capabilities for all 30 system emulator targets at startup, only those emulators which are referenced by an XML doc. This massively improves libvirtd startup time when the capabilities cache is not populated. It even improves startup time when the cache is up to date, as we don't bother to load files from the cache until we need them. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/qemu/qemu_conf.c | 13 +++++++------ src/qemu/qemu_driver.c | 3 --- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 9df4ae1230..c24c99d129 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1318,13 +1318,14 @@ virCapsPtr virQEMUDriverGetCapabilities(virQEMUDriv= erPtr driver, driver->caps =3D caps; } else { qemuDriverLock(driver); - } =20 - if (driver->caps->nguests =3D=3D 0 && !refresh) { - VIR_DEBUG("Capabilities didn't detect any guests. Forcing a " - "refresh."); - qemuDriverUnlock(driver); - return virQEMUDriverGetCapabilities(driver, true); + if (driver->caps =3D=3D NULL || + driver->caps->nguests =3D=3D 0) { + VIR_DEBUG("Capabilities didn't detect any guests. Forcing a " + "refresh."); + qemuDriverUnlock(driver); + return virQEMUDriverGetCapabilities(driver, true); + } } =20 ret =3D virObjectRef(driver->caps); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 1fe310e16c..f50af3ee94 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -907,9 +907,6 @@ qemuStateInitialize(bool privileged, if (!qemu_driver->qemuCapsCache) goto error; =20 - if ((qemu_driver->caps =3D virQEMUDriverCreateCapabilities(qemu_driver= )) =3D=3D NULL) - goto error; - if (!(sec_managers =3D qemuSecurityGetNested(qemu_driver->securityMana= ger))) goto error; =20 --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list