From nobody Sun Feb 8 15:30:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1637253260; cv=none; d=zohomail.com; s=zohoarc; b=UgXb9mTil8KtHCcQqjPg5Of5d1JUvlpN8VuPEOm2oOwqgITgig65AH+7ARrpSUzsKUpMb3p4fyQvVYBaRq/Npx56xfoGzWcih1Lb65iUeDZX4GEV/P7IAGzAnFDe+jfTXc2K6DVTP7KRIrI9EPM7EsDZjWXUriWKzwr/M92Gc+M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637253260; 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=EEfC1KN2bWqrRzdNJDgm1yKXnDNIZb7V9c9X0F6Zjd4=; b=VaX1fF67ypugVAKvLl3a3QY2dCZjvPA1XKudNHgEKpTejVmBdArawyzbUP5r+z6Xb4yR4ABQ70SShpEzklBRaEmZKhtHmeb4B309Rg735h0SyJs7HW6OUJwZBOlTBIF65UO86NQrkPuLxEcIRdTP4PO+7geSLgcD9QkQqzrJN+0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1637253260161683.5854310508805; Thu, 18 Nov 2021 08:34:20 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-209-EJwaGmIhOyW4pK9uT3vuFw-1; Thu, 18 Nov 2021 11:34:17 -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 71EDF10151E7; Thu, 18 Nov 2021 16:34:11 +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 529D65E272; Thu, 18 Nov 2021 16:34:11 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 233C14EA2F; Thu, 18 Nov 2021 16:34: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 1AIGXvuA028103 for ; Thu, 18 Nov 2021 11:33:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id 01AF55BAFB; Thu, 18 Nov 2021 16:33:57 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 519CE608BA for ; Thu, 18 Nov 2021 16:33:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637253259; 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=EEfC1KN2bWqrRzdNJDgm1yKXnDNIZb7V9c9X0F6Zjd4=; b=W7YoGnqYyoyvgLDXFWedqKVnHZg3bG7o57KyXRdScw3z8RRlZqht5EtmgrY/rCzLVhr0K1 nFMxfpp102po/+PhDYELg3Y5Axolce9s7hsdA+m7n8HbjMo9eogitaou9DO5AQydzOtueO m0c46KM24H/Tkq/J863aDg77wMb8sRI= X-MC-Unique: EJwaGmIhOyW4pK9uT3vuFw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/16] conf: Convert 'chr' in virDomainShmemDef to proper pointer Date: Thu, 18 Nov 2021 17:33:34 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1637253262112100001 Content-Type: text/plain; charset="utf-8" The main reason is to ensure that the private data are properly allocated for every instance. Signed-off-by: Peter Krempa --- src/conf/domain_audit.c | 2 +- src/conf/domain_conf.c | 17 ++++++++++------- src/conf/domain_conf.h | 2 +- src/qemu/qemu_command.c | 2 +- src/qemu/qemu_domain.c | 6 +++--- src/qemu/qemu_hotplug.c | 2 +- 6 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c index b08233fa49..69c5792b07 100644 --- a/src/conf/domain_audit.c +++ b/src/conf/domain_audit.c @@ -898,7 +898,7 @@ virDomainAuditShmem(virDomainObj *vm, { char uuidstr[VIR_UUID_STRING_BUFLEN]; char *vmname =3D virAuditEncode("vm", vm->def->name); - const char *srcpath =3D virDomainChrSourceDefGetPath(&def->server.chr); + const char *srcpath =3D virDomainChrSourceDefGetPath(def->server.chr); const char *virt =3D virDomainAuditGetVirtType(vm->def); char *shmpath =3D NULL; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index da0c64b460..52f513f488 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3069,7 +3069,7 @@ void virDomainShmemDefFree(virDomainShmemDef *def) return; virDomainDeviceInfoClear(&def->info); - virDomainChrSourceDefClear(&def->server.chr); + virObjectUnref(def->server.chr); g_free(def->name); g_free(def); } @@ -13665,11 +13665,14 @@ virDomainShmemDefParseXML(virDomainXMLOption *xml= opt, if ((server =3D virXPathNode("./server[1]", ctxt))) { g_autofree char *tmp =3D NULL; + if (!(def->server.chr =3D virDomainChrSourceDefNew(xmlopt))) + return NULL; + def->server.enabled =3D true; - def->server.chr.type =3D VIR_DOMAIN_CHR_TYPE_UNIX; - def->server.chr.data.nix.listen =3D false; + def->server.chr->type =3D VIR_DOMAIN_CHR_TYPE_UNIX; + def->server.chr->data.nix.listen =3D false; if ((tmp =3D virXMLPropString(server, "path"))) - def->server.chr.data.nix.path =3D virFileSanitizePath(tmp); + def->server.chr->data.nix.path =3D virFileSanitizePath(tmp); } if ((msi =3D virXPathNode("./msi[1]", ctxt))) { @@ -16814,8 +16817,8 @@ virDomainShmemDefEquals(virDomainShmemDef *src, return false; if (src->server.enabled) { - if (STRNEQ_NULLABLE(src->server.chr.data.nix.path, - dst->server.chr.data.nix.path)) + if (STRNEQ_NULLABLE(src->server.chr->data.nix.path, + dst->server.chr->data.nix.path)) return false; } @@ -25868,7 +25871,7 @@ virDomainShmemDefFormat(virBuffer *buf, if (def->server.enabled) { virBufferAddLit(buf, "server.chr.data.ni= x.path); + virBufferEscapeString(buf, " path=3D'%s'", def->server.chr->data.n= ix.path); virBufferAddLit(buf, "/>\n"); } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ab9a7d66f8..3cb68c5d0a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1997,7 +1997,7 @@ struct _virDomainShmemDef { virDomainShmemRole role; struct { bool enabled; - virDomainChrSourceDef chr; + virDomainChrSourceDef *chr; } server; struct { bool enabled; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f97cdc70ab..60336947b5 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9368,7 +9368,7 @@ qemuBuildShmemCommandLine(virLogManager *logManager, if (shmem->server.enabled) { chardev =3D qemuBuildChrChardevStr(logManager, secManager, cmd, cfg, def, - &shmem->server.chr, + shmem->server.chr, shmem->info.alias, qemuCaps, cdevflags); if (!chardev) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index fb203bc830..e69215cee2 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9964,11 +9964,11 @@ void qemuDomainPrepareShmemChardev(virDomainShmemDef *shmem) { if (!shmem->server.enabled || - shmem->server.chr.data.nix.path) + shmem->server.chr->data.nix.path) return; - shmem->server.chr.data.nix.path =3D g_strdup_printf("/var/lib/libvirt/= shmem-%s-sock", - shmem->name); + shmem->server.chr->data.nix.path =3D g_strdup_printf("/var/lib/libvirt= /shmem-%s-sock", + shmem->name); } diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 3df0a1f17a..0e798dc237 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -3064,7 +3064,7 @@ qemuDomainAttachShmemDevice(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); if (shmem->server.enabled) { - if (qemuHotplugChardevAttach(priv->mon, charAlias, &shmem->server.= chr) < 0) + if (qemuHotplugChardevAttach(priv->mon, charAlias, shmem->server.c= hr) < 0) goto exit_monitor; } else { if (qemuMonitorAddObject(priv->mon, &props, &memAlias) < 0) --=20 2.31.1