From nobody Fri Apr 26 20:53:22 2024 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=1637253304; cv=none; d=zohomail.com; s=zohoarc; b=kIm9X7X8crUkYPbCu/ed/8o46R0uVLAfTeBWAyZ6NHsga5LBF3Y/w/TKnwFuEv1OvFg2Jv9UE4vxKEmKDmBqbyoDyXau0MIy4TFVyoudOLpp/dBOI6acBEAYnLVLnVU4NMsfLCyH9ORzYkwlzvWv2skVrr0N6BWEleiaKeWz1xc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637253304; 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=hUeG5pPoCy47wWiN1U4d0vN7dWXhFZKmPv2qclRQL5U=; b=ackdL2WzEzRklMy+1q8pLscmwyCOsBFpeVUJod8l7OusKxjkdgL1rAEsXKtwC/rs7npH/yyQKHJlZK9xtHuhlw5zRWmTxAcxYeTLzZT7dj0TZBHg45jNE6z/boACNWKkkltaJPx8TH8epBRykaQPHvTKsjqJaud+KZ/hKHp8pZc= 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 1637253304322876.7388377463037; Thu, 18 Nov 2021 08:35:04 -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-583-a8YJewWiMyyaFNjt4J8ZAA-1; Thu, 18 Nov 2021 11:34:23 -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 41E8C8799F3; Thu, 18 Nov 2021 16:34:17 +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 1E6C3ADF9; Thu, 18 Nov 2021 16:34:17 +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 D7BBA4EA3C; Thu, 18 Nov 2021 16:34:16 +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 1AIGXlmd028021 for ; Thu, 18 Nov 2021 11:33:47 -0500 Received: by smtp.corp.redhat.com (Postfix) id 835EF608BA; Thu, 18 Nov 2021 16:33:47 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id CCB801B5C0 for ; Thu, 18 Nov 2021 16:33:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637253303; 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=hUeG5pPoCy47wWiN1U4d0vN7dWXhFZKmPv2qclRQL5U=; b=AGXJV7qIAckxZ6gPFkAXPPSk+3yflqHY9zzvpwWU0v2IARQe5XmV3O1pquyp4+vyRFdi6S rRwZbWo0OTTpbCveFL516CtZw02TowmRCseRINE7qf2beu/2SftkYvPzrzTanWWsUJgE3r i11d4TH1rjtknL+96j2XLFlXbA3E6FQ= X-MC-Unique: a8YJewWiMyyaFNjt4J8ZAA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/16] qemuBuildCommandLine: Properly check return value of qemuBuildShmemCommandLine Date: Thu, 18 Nov 2021 17:33:26 +0100 Message-Id: <3e5f9a7b9e1ca1a676140b23f60a6538d703b9ff.1637253107.git.pkrempa@redhat.com> 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: 1637253305676100001 Content-Type: text/plain; charset="utf-8" Use the customary '< 0' check for return value. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 713304dd22..24dd00af9b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10882,7 +10882,7 @@ qemuBuildCommandLine(virQEMUDriver *driver, for (i =3D 0; i < def->nshmems; i++) { if (qemuBuildShmemCommandLine(logManager, secManager, cmd, cfg, def, def->shmems[i], qemuCaps, - chardevStdioLogd)) + chardevStdioLogd) < 0) return NULL; } --=20 2.31.1 From nobody Fri Apr 26 20:53:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1637253238; cv=none; d=zohomail.com; s=zohoarc; b=FmrR0JZqtfsPYAmkkiT5xbKlT3LOMT6BBrVckGZzhMvR2+s6ZmdhcfzWbnwwOXfjp0MbuZYemkAEvM7saSEieJj4krHckszA2snH78teuvAaR68AhIZMO+Jg7xAaoJdHXXPHe476FeyStH35Jj9ttPgqh1hMd4OVbFaORcqwJeA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637253238; 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=piOAKEkFOe6sJQTbKckl3Kc+iOwNhOlzKSNzdGQZmdI=; b=FPNxupZwYamZ0oPgiiexX1/DsnVEmjy3vIOr4GbtuuzEqcuQXmT47FxYZ4F5s4o7zYNjApDGFbTFBP/JDIRjgMepT80nqk422437AziwK9IqXOGDwWfAffiPXg41TFWctx/LdMmCfElm1NXzmEVyXnWkuQbhK56L3MqmZam4B9U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 163725323873697.32945088075826; Thu, 18 Nov 2021 08:33:58 -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-258-qRNmKV40P4aSt1-HUaEdqA-1; Thu, 18 Nov 2021 11:33:55 -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 45B8F1922960; Thu, 18 Nov 2021 16:33: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 085DD5F4ED; Thu, 18 Nov 2021 16:33: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 8DAEF4E58E; Thu, 18 Nov 2021 16:33: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 1AIGXm1v028033 for ; Thu, 18 Nov 2021 11:33:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id BFF3E1B5C0; Thu, 18 Nov 2021 16:33:48 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0935C608BA for ; Thu, 18 Nov 2021 16:33:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637253237; 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=piOAKEkFOe6sJQTbKckl3Kc+iOwNhOlzKSNzdGQZmdI=; b=K87Ro7G3ki2tNuu7td3J23JjWX09yh4L54l6caa/uHXQsffH4Lt7z2VRwg/a9bjcNO2JNs EPzr7+lZ3OjmffO7jC0kcm/Ede7oOBT+mOgG6Qk+g8X2mBlWanTzKIsMvftt0/qJOb3VUK WHo1eFpPNnlnqMKtH/7E+ougRxi9xQY= X-MC-Unique: qRNmKV40P4aSt1-HUaEdqA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/16] qemu: hotplug: Add wrapper for qemuMonitorAttachCharDev Date: Thu, 18 Nov 2021 17:33:27 +0100 Message-Id: <74b82116ac8c1a6a86e9d15178e3badd92615dde.1637253107.git.pkrempa@redhat.com> 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.15 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: 1637253240010100002 Content-Type: text/plain; charset="utf-8" Add a simple wrapper for 'qemuMonitorAttachCharDev' named 'qemuHotplugChardevAttach' which will simplify the moving of the character device property generator out of the monitor code. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 328b06245f..6f667dfb76 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -193,6 +193,15 @@ qemuDomainDetachExtensionDevice(qemuMonitor *mon, } +static int +qemuHotplugChardevAttach(qemuMonitor *mon, + const char *alias, + virDomainChrSourceDef *def) +{ + return qemuMonitorAttachCharDev(mon, alias, def); +} + + static int qemuHotplugWaitForTrayEject(virDomainObj *vm, virDomainDiskDef *disk) @@ -1459,7 +1468,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, } if (actualType =3D=3D VIR_DOMAIN_NET_TYPE_VHOSTUSER) { - if (qemuMonitorAttachCharDev(priv->mon, charDevAlias, net->data.vh= ostuser) < 0) { + if (qemuHotplugChardevAttach(priv->mon, charDevAlias, net->data.vh= ostuser) < 0) { ignore_value(qemuDomainObjExitMonitor(driver, vm)); virDomainAuditNet(vm, NULL, net, "attach", false); goto cleanup; @@ -1980,9 +1989,7 @@ int qemuDomainAttachRedirdevDevice(virQEMUDriver *dri= ver, qemuDomainObjEnterMonitor(driver, vm); - if (qemuMonitorAttachCharDev(priv->mon, - charAlias, - redirdev->source) < 0) + if (qemuHotplugChardevAttach(priv->mon, charAlias, redirdev->source) <= 0) goto exit_monitor; chardevAdded =3D true; @@ -2242,7 +2249,7 @@ int qemuDomainAttachChrDevice(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); - if (qemuMonitorAttachCharDev(priv->mon, charAlias, chr->source) < 0) + if (qemuHotplugChardevAttach(priv->mon, charAlias, chr->source) < 0) goto exit_monitor; chardevAttached =3D true; @@ -2350,8 +2357,7 @@ qemuDomainAttachRNGDevice(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); if (rng->backend =3D=3D VIR_DOMAIN_RNG_BACKEND_EGD && - qemuMonitorAttachCharDev(priv->mon, charAlias, - rng->source.chardev) < 0) + qemuHotplugChardevAttach(priv->mon, charAlias, rng->source.chardev= ) < 0) goto exit_monitor; chardevAdded =3D true; @@ -3058,8 +3064,7 @@ qemuDomainAttachShmemDevice(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); if (shmem->server.enabled) { - if (qemuMonitorAttachCharDev(priv->mon, charAlias, - &shmem->server.chr) < 0) + if (qemuHotplugChardevAttach(priv->mon, charAlias, &shmem->server.= chr) < 0) goto exit_monitor; } else { if (qemuMonitorAddObject(priv->mon, &props, &memAlias) < 0) @@ -3472,7 +3477,7 @@ qemuDomainAttachFSDevice(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); - if (qemuMonitorAttachCharDev(priv->mon, charAlias, chardev) < 0) + if (qemuHotplugChardevAttach(priv->mon, charAlias, chardev) < 0) goto exit_monitor; chardevAdded =3D true; --=20 2.31.1 From nobody Fri Apr 26 20:53:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1637253254; cv=none; d=zohomail.com; s=zohoarc; b=l2sZZ+X5z9X9G3zT2vofp+F0FgnrbVMYV/gvCUG7In6GK8ZOAN1XshZVXpKswI+ja1BXc0afDlgaMIGKtPRuW/y1rH2/TQz9iTZhDPAe7tea3tW7jP3Hp1QZ+8BNzsB5PXHpTmex8Qnmi1cYMlfxPsD5toRjEjR9vKcEh8kazOg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637253254; 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=utWonSkdjXy9veijF3/S6u3rpgg/vkEdnkwKopUpT9c=; b=PQPCTJxT7iiK/omhtzW8X1Jl92SvX3YGl2bSYdTPV/bRvgTdSnJiv11IhaIBbaZr/+PVn2IYh/XdFxqRfHbWQPKyFkLQIV27drJcdooOR2ZXYqbMDosm4tVkDIvOYDbDNnW2c3ceXo+xSxtEAqrdPlV3rdEaP0SiRng3+7p6qFA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1637253254300224.5345115796764; Thu, 18 Nov 2021 08:34:14 -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-394-w5tztWqwPnm97PWYl3J9UA-1; Thu, 18 Nov 2021 11:34: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 E54818799EF; Thu, 18 Nov 2021 16:34:06 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C76BB179B3; Thu, 18 Nov 2021 16:34: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 8AF291832DD4; Thu, 18 Nov 2021 16:34:06 +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 1AIGXnpM028038 for ; Thu, 18 Nov 2021 11:33:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id EA2C51B5C0; Thu, 18 Nov 2021 16:33:49 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 41D34608BA for ; Thu, 18 Nov 2021 16:33:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637253253; 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=utWonSkdjXy9veijF3/S6u3rpgg/vkEdnkwKopUpT9c=; b=U5OSvh8p/SWzKVuTKSlpWC51eicZIdXLMfTGj28vvIfGbUHbRgX4fPJdELiz6VH4owGVYV BOCdPyiUhg15g4ycc/G6mGx6Ec+aj36uG2B6grxlavW96A+rqe+OvjiznrJCHQ6RqeU1N7 J0akxawl5TqPOeEjCOJ/AwSp02tZQCQ= X-MC-Unique: w5tztWqwPnm97PWYl3J9UA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/16] qemuMonitorJSONAddDeviceProps: Simplify construction of the command Date: Thu, 18 Nov 2021 17:33:28 +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.11 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: 1637253255209100005 Content-Type: text/plain; charset="utf-8" Use 'qemuMonitorJSONMakeCommandInternal' instead of 'qemuMonitorJSONMakeCommand' + 'virJSONValueObjectAppend'. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor_json.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index a3bdfaaf0d..2cfae2276d 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4154,11 +4154,8 @@ qemuMonitorJSONAddDeviceProps(qemuMonitor *mon, g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; - if (!(cmd =3D qemuMonitorJSONMakeCommand("device_add", NULL))) - return -1; - - if (virJSONValueObjectAppend(cmd, "arguments", props) < 0) - return -1; + if (!(cmd =3D qemuMonitorJSONMakeCommandInternal("device_add", props)= )) + return -1; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) return -1; --=20 2.31.1 From nobody Fri Apr 26 20:53:22 2024 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=1637253271; cv=none; d=zohomail.com; s=zohoarc; b=cPkTMbOR6LNBnmdIn5ouYn5jkE2gaWwZdnMV2E3sPYzENSZ4s+fDsrkDycfimFOLCegDGQEvRSGS5Z6dYRi+S2yOUQ0auR0qID2vyyhgqog7AK58fmIp+I45bfU63PGnh2/3XvvYRLbR7PiG7POh+iskVWIJ5d9gCng9lYy4DL8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637253271; 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=Vp1Bg7xYP1Z39Pi4nQKG9mJpNjidCWFoX8UljiUZsr4=; b=eQdeDgxQaQtlyIcp/H4Ut8HiLUSePNbboohNf1lbKtop/HpcyFrfzs627vHN0uFaAL55enCcO4uC2GPiO7Svhz886p8TDgVMTlWiOoobS0YJvX5kxE2vKeGvSRXS0K3wGUON2+RLcDb/19LEjb9hshkXacw5RZzSPBS5Q+fC+R0= 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 1637253271099476.2669059484281; Thu, 18 Nov 2021 08:34:31 -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-379-g97_i0-YO2-OtcgLgw_etA-1; Thu, 18 Nov 2021 11:34:28 -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 3C6791922960; Thu, 18 Nov 2021 16:34:17 +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 4D2F95F4F6; Thu, 18 Nov 2021 16:34:23 +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 1E3261832DF5; Thu, 18 Nov 2021 16:34:23 +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 1AIGXp9R028053 for ; Thu, 18 Nov 2021 11:33:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2818A608BA; Thu, 18 Nov 2021 16:33:51 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 774135BAE6 for ; Thu, 18 Nov 2021 16:33:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637253270; 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=Vp1Bg7xYP1Z39Pi4nQKG9mJpNjidCWFoX8UljiUZsr4=; b=gy0h7p/HKdzeFTw+6Ku2s2Ep0bAyI4GZcMh/y/XSCmdYB589JaZbP3XVpPJPAPUFG9LCNc 0244Jv8J7LunhP7RFaTd8VRe4bUaHgx/jMG/kBg344xLwyoC1+CubIOxQo/SSpT2lfEcXA OXJx1gIAKve10fH5++1sRbyV9uKakUM= X-MC-Unique: g97_i0-YO2-OtcgLgw_etA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/16] qemuMonitorJSONAttachCharDevCommand: Format only the properties Date: Thu, 18 Nov 2021 17:33:29 +0100 Message-Id: <11e7457f09d3eec552e7e5fce89de8aeb664e335.1637253107.git.pkrempa@redhat.com> 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.15 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: 1637253271896100003 Content-Type: text/plain; charset="utf-8" Move the addition of the command wrapper to qemuMonitorJSONAttachCharDev and rename the function to qemuMonitorJSONAttachCharDevGetProps. Signed-off-by: Peter Krempa --- src/qemu/qemu_monitor_json.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 2cfae2276d..b036cc4112 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -6609,9 +6609,10 @@ qemuMonitorJSONBuildChrChardevReconnect(virJSONValue= *object, } static virJSONValue * -qemuMonitorJSONAttachCharDevCommand(const char *chrID, - const virDomainChrSourceDef *chr) +qemuMonitorJSONAttachCharDevGetProps(const char *chrID, + const virDomainChrSourceDef *chr) { + g_autoptr(virJSONValue) props =3D NULL; g_autoptr(virJSONValue) backend =3D virJSONValueNewObject(); g_autoptr(virJSONValue) data =3D virJSONValueNewObject(); g_autoptr(virJSONValue) addr =3D NULL; @@ -6760,10 +6761,13 @@ qemuMonitorJSONAttachCharDevCommand(const char *chr= ID, virJSONValueObjectAppend(backend, "data", &data) < 0) return NULL; - return qemuMonitorJSONMakeCommand("chardev-add", - "s:id", chrID, - "a:backend", &backend, - NULL); + if (virJSONValueObjectAdd(&props, + "s:id", chrID, + "a:backend", &backend, + NULL) < 0) + return NULL; + + return g_steal_pointer(&props); } @@ -6774,8 +6778,12 @@ qemuMonitorJSONAttachCharDev(qemuMonitor *mon, { g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; + g_autoptr(virJSONValue) props =3D NULL; + + if (!(props =3D qemuMonitorJSONAttachCharDevGetProps(chrID, chr))) + return -1; - if (!(cmd =3D qemuMonitorJSONAttachCharDevCommand(chrID, chr))) + if (!(cmd =3D qemuMonitorJSONMakeCommandInternal("chardev-add", &props= ))) return -1; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) --=20 2.31.1 From nobody Fri Apr 26 20:53:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1637253251; cv=none; d=zohomail.com; s=zohoarc; b=autXiY3e+4la/Lxq1oqFjZu1jhacWBbU0hoIzgmA9Zs6tWb+4b3fXUfZlluJstmH5Gc4VssP7q6YP+mJTjT4klc8PaymCgcBXJ5Q8sEYWxpeVj2GeYQ6pKT4M2p6PwUwZh9N05ke278edt2k1TwkJx2IDuBdBG1z67i+KbOCJGU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637253251; 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=u7XGDcpPtjSEapJv447yqknBeTpaaeQMt6YFi71cbJs=; b=R7ljJiKrhHY58pzt2uIMLUGqYo8r0aAynb9/n0f8fb0HJs/KipaKEdlUu2NXsm3rb5qtVxsNY7JiuhB6gjyWRU2/6Num3Cfnf7yopx25ouwIhMDoa7/azVc+sMoQ4HzYyQq/dssbR9+mAyoj0iPSHabJre0rMkvQNn60VH0c9OM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1637253251611386.2282584937799; Thu, 18 Nov 2021 08:34:11 -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-92-mV0CG-u-M5yzAN_J16sDCA-1; Thu, 18 Nov 2021 11:34:09 -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 6DE831922966; Thu, 18 Nov 2021 16:33:56 +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 1A0325BAE0; Thu, 18 Nov 2021 16:34: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 D11C0180BAD1; Thu, 18 Nov 2021 16:34: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 1AIGXqAq028058 for ; Thu, 18 Nov 2021 11:33:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id 55FB81B5C0; Thu, 18 Nov 2021 16:33:52 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id A1BFF608BA for ; Thu, 18 Nov 2021 16:33:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637253250; 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=u7XGDcpPtjSEapJv447yqknBeTpaaeQMt6YFi71cbJs=; b=NCwxCJM9AeDHjPEl9y2R3wDlT1qyBnoiscwah0jsYUU1ZjO1fRLC4rZoD4Fhpb/udY5R1R JunNbdZn5bTkg/E2vYkzxEQWOCqW/Ex7XFEm4FlqCpq8Nxz8WonZZ6pVFNTP+9xkyyGUe9 mfvkf84HOgIlxRuyS3lrYb2uKItT+78= X-MC-Unique: mV0CG-u-M5yzAN_J16sDCA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/16] qemuMonitorJSONAttachCharDevGetProps: Simplify handling of unsupported types Date: Thu, 18 Nov 2021 17:33:30 +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.13 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: 1637253252820100001 Content-Type: text/plain; charset="utf-8" Use 'virReportEnumRangeError' for the invalid cases and keep the original error for known but unsupported chardevs. Signed-off-by: Peter Krempa --- src/qemu/qemu_monitor_json.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index b036cc4112..1ced942161 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -6737,16 +6737,14 @@ qemuMonitorJSONAttachCharDevGetProps(const char *ch= rID, case VIR_DOMAIN_CHR_TYPE_PIPE: case VIR_DOMAIN_CHR_TYPE_STDIO: case VIR_DOMAIN_CHR_TYPE_NMDM: + virReportError(VIR_ERR_OPERATION_FAILED, + _("Hotplug unsupported for char device type '%s'"), + virDomainChrTypeToString(chr->type)); + return NULL; + case VIR_DOMAIN_CHR_TYPE_LAST: - if (virDomainChrTypeToString(chr->type)) { - virReportError(VIR_ERR_OPERATION_FAILED, - _("Hotplug unsupported for char device type '%s= '"), - virDomainChrTypeToString(chr->type)); - } else { - virReportError(VIR_ERR_OPERATION_FAILED, - _("Hotplug unsupported for char device type '%d= '"), - chr->type); - } + default: + virReportEnumRangeError(virDomainChrType, chr->type); return NULL; } --=20 2.31.1 From nobody Fri Apr 26 20:53:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1637253309; cv=none; d=zohomail.com; s=zohoarc; b=LoEoUCkLxQdRwaFObPJxiDQ2qYVhWW5KC9Y4RxBhpJ6BzZSgjKtXMO0vxBz+qJJ/zmZpkacrtjatwmgU9NgtQh5dILkMeYRdO3CdQEBuYFHiPIrF1SvnWRRench/nBiKbgt8LeWX9NsnTwRRtok7MsaQIxztBv+5+Sv4yH7+Gxo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637253309; 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=XtmkAxNs/vmZK5XkSRlmhx5/zpXcfMKgXxHcEYsjAd8=; b=E6/BAn2ot+krS1pQCbcpjxi8XVYrK7WyERhzuFjkCLHPq0uNrnJMJewJpFR5hr34X7yecNBdMGsZzU1fsAs9ud7mSk/1pXInZI6UGfgdO7yRyJgC2pSynKqhbONUAMZB9FS4w2WSSh0PLAMp2qLUBu0nLWWjQFTqWQc5OXxZG7M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1637253309057108.26328883530925; Thu, 18 Nov 2021 08:35:09 -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-38-uZuZ-vQuPsar1NxiCF6v5Q-1; Thu, 18 Nov 2021 11:34:34 -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 73B4BA40C3; Thu, 18 Nov 2021 16:34: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 4721B5F4ED; Thu, 18 Nov 2021 16:34: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 17BCC1832DFB; Thu, 18 Nov 2021 16:34: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 1AIGXr1D028066 for ; Thu, 18 Nov 2021 11:33:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id 72DD01B5C0; Thu, 18 Nov 2021 16:33:53 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC20A608BA for ; Thu, 18 Nov 2021 16:33:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637253308; 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=XtmkAxNs/vmZK5XkSRlmhx5/zpXcfMKgXxHcEYsjAd8=; b=FUV9ewVbG9xZ3ynoNOLkUHtvw2aQDax5lCdITW55KuAdA3Lt/k0PxSjs8z1bZ13uvk9YCw WZieI5td6Jab5mHUeiPF0tabDjLWwOHSPWMMVsmvw/pmvbldBzGyYPnanVN6rbXuQhYkQQ P5u83q4E8rXQ3ocA80lChRs7dZu1sAU= X-MC-Unique: uZuZ-vQuPsar1NxiCF6v5Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/16] qemuMonitorJSONAttachCharDevGetProps: Modernize construction of JSON objects Date: Thu, 18 Nov 2021 17:33:31 +0100 Message-Id: <68bff02bb58a65fa76b7a1a26925d50a0dc84d30.1637253107.git.pkrempa@redhat.com> 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.15 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: 1637253310348100001 Content-Type: text/plain; charset="utf-8" Use 'virJSONValueObjectAdd' instead of the step-by-step manual JSON object building. Signed-off-by: Peter Krempa --- src/qemu/qemu_monitor_json.c | 195 ++++++++++++++++++----------------- 1 file changed, 99 insertions(+), 96 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 1ced942161..a9e87de4d3 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -6598,139 +6598,139 @@ int qemuMonitorJSONGetTPMTypes(qemuMonitor *mon, return qemuMonitorJSONGetStringArray(mon, "query-tpm-types", tpmtypes); } -static int -qemuMonitorJSONBuildChrChardevReconnect(virJSONValue *object, - const virDomainChrSourceReconnectD= ef *def) -{ - if (def->enabled !=3D VIR_TRISTATE_BOOL_YES) - return 0; - - return virJSONValueObjectAppendNumberUint(object, "reconnect", def->ti= meout); -} static virJSONValue * qemuMonitorJSONAttachCharDevGetProps(const char *chrID, const virDomainChrSourceDef *chr) { g_autoptr(virJSONValue) props =3D NULL; - g_autoptr(virJSONValue) backend =3D virJSONValueNewObject(); - g_autoptr(virJSONValue) data =3D virJSONValueNewObject(); - g_autoptr(virJSONValue) addr =3D NULL; - const char *backend_type =3D NULL; - const char *host; - const char *port; - g_autofree char *tlsalias =3D NULL; - bool telnet; + g_autoptr(virJSONValue) backend =3D NULL; + g_autoptr(virJSONValue) backendData =3D virJSONValueNewObject(); + const char *backendType =3D NULL; switch ((virDomainChrType)chr->type) { case VIR_DOMAIN_CHR_TYPE_NULL: - backend_type =3D "null"; - break; - case VIR_DOMAIN_CHR_TYPE_VC: - backend_type =3D "vc"; - break; - case VIR_DOMAIN_CHR_TYPE_PTY: - backend_type =3D "pty"; + backendType =3D virDomainChrTypeToString(chr->type); break; case VIR_DOMAIN_CHR_TYPE_FILE: - backend_type =3D "file"; - if (virJSONValueObjectAppendString(data, "out", chr->data.file.pat= h) < 0) - return NULL; - if (virJSONValueObjectAdd(&data, + backendType =3D "file"; + + if (virJSONValueObjectAdd(&backendData, + "s:out", chr->data.file.path, "T:append", chr->data.file.append, NULL) < 0) return NULL; + break; case VIR_DOMAIN_CHR_TYPE_DEV: - backend_type =3D STRPREFIX(chrID, "parallel") ? "parallel" : "seri= al"; - if (virJSONValueObjectAppendString(data, "device", - chr->data.file.path) < 0) - return NULL; - break; + if (STRPREFIX(chrID, "parallel")) + backendType =3D "parallel"; + else + backendType =3D "serial"; - case VIR_DOMAIN_CHR_TYPE_TCP: - backend_type =3D "socket"; - addr =3D qemuMonitorJSONBuildInetSocketAddress(chr->data.tcp.host, - chr->data.tcp.service= ); - if (!addr || - virJSONValueObjectAppend(data, "addr", &addr) < 0) + if (virJSONValueObjectAdd(&backendData, + "s:device", chr->data.file.path, + NULL) < 0) return NULL; - telnet =3D chr->data.tcp.protocol =3D=3D VIR_DOMAIN_CHR_TCP_PROTOC= OL_TELNET; + break; - if (chr->data.tcp.listen && - virJSONValueObjectAppendBoolean(data, "wait", false) < 0) - return NULL; + case VIR_DOMAIN_CHR_TYPE_UNIX: + case VIR_DOMAIN_CHR_TYPE_TCP: { + g_autofree char *tlsalias =3D NULL; + g_autoptr(virJSONValue) addr =3D NULL; + virTristateBool waitval =3D VIR_TRISTATE_BOOL_ABSENT; + virTristateBool telnet =3D VIR_TRISTATE_BOOL_ABSENT; + bool server =3D false; + int reconnect =3D -1; + + backendType =3D "socket"; + + if (chr->type =3D=3D VIR_DOMAIN_CHR_TYPE_TCP) { + telnet =3D virTristateBoolFromBool(chr->data.tcp.protocol =3D= =3D VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET); + + if (chr->data.tcp.listen) { + server =3D true; + waitval =3D VIR_TRISTATE_BOOL_NO; + } - if (virJSONValueObjectAppendBoolean(data, "telnet", telnet) < 0 || - virJSONValueObjectAppendBoolean(data, "server", chr->data.tcp.= listen) < 0) - return NULL; - if (chr->data.tcp.tlscreds) { - if (!(tlsalias =3D qemuAliasTLSObjFromSrcAlias(chrID))) + if (chr->data.tcp.tlscreds && + !(tlsalias =3D qemuAliasTLSObjFromSrcAlias(chrID))) return NULL; - if (virJSONValueObjectAppendString(data, "tls-creds", tlsalias= ) < 0) + if (!(addr =3D qemuMonitorJSONBuildInetSocketAddress(chr->data= .tcp.host, + chr->data.t= cp.service))) return NULL; - } - - if (qemuMonitorJSONBuildChrChardevReconnect(data, &chr->data.tcp.r= econnect) < 0) - return NULL; - break; - case VIR_DOMAIN_CHR_TYPE_UDP: - backend_type =3D "udp"; - host =3D chr->data.udp.connectHost; - if (!host) - host =3D ""; - addr =3D qemuMonitorJSONBuildInetSocketAddress(host, - chr->data.udp.connect= Service); - if (!addr || - virJSONValueObjectAppend(data, "remote", &addr) < 0) - return NULL; + if (chr->data.tcp.reconnect.enabled =3D=3D VIR_TRISTATE_BOOL_Y= ES) + reconnect =3D chr->data.tcp.reconnect.timeout; + else if (chr->data.tcp.reconnect.enabled =3D=3D VIR_TRISTATE_B= OOL_NO) + reconnect =3D 0; + } else { + if (chr->data.nix.listen) { + server =3D true; + waitval =3D VIR_TRISTATE_BOOL_NO; + } - host =3D chr->data.udp.bindHost; - port =3D chr->data.udp.bindService; - if (host || port) { - if (!host) - host =3D ""; - if (!port) - port =3D ""; - addr =3D qemuMonitorJSONBuildInetSocketAddress(host, port); - if (!addr || - virJSONValueObjectAppend(data, "local", &addr) < 0) + if (!(addr =3D qemuMonitorJSONBuildUnixSocketAddress(chr->data= .nix.path))) return NULL; + + if (chr->data.nix.reconnect.enabled =3D=3D VIR_TRISTATE_BOOL_Y= ES) + reconnect =3D chr->data.tcp.reconnect.timeout; + else if (chr->data.nix.reconnect.enabled =3D=3D VIR_TRISTATE_B= OOL_NO) + reconnect =3D 0; } + + if (virJSONValueObjectAdd(&backendData, + "a:addr", &addr, + "T:wait", waitval, + "T:telnet", telnet, + "b:server", server, + "S:tls-creds", tlsalias, + "k:reconnect", reconnect, + NULL) < 0) + return NULL; + } break; - case VIR_DOMAIN_CHR_TYPE_UNIX: - backend_type =3D "socket"; - addr =3D qemuMonitorJSONBuildUnixSocketAddress(chr->data.nix.path); - if (!addr || - virJSONValueObjectAppend(data, "addr", &addr) < 0) - return NULL; + case VIR_DOMAIN_CHR_TYPE_UDP: { + g_autoptr(virJSONValue) local =3D NULL; + g_autoptr(virJSONValue) remote =3D NULL; - if (chr->data.nix.listen && - virJSONValueObjectAppendBoolean(data, "wait", false) < 0) - return NULL; + backendType =3D "udp"; - if (virJSONValueObjectAppendBoolean(data, "server", chr->data.nix.= listen) < 0) + if (!(remote =3D qemuMonitorJSONBuildInetSocketAddress(NULLSTR_EMP= TY(chr->data.udp.connectHost), + chr->data.udp= .connectService))) return NULL; - if (qemuMonitorJSONBuildChrChardevReconnect(data, &chr->data.nix.r= econnect) < 0) + if (chr->data.udp.bindHost || chr->data.udp.bindService) { + if (!(local =3D qemuMonitorJSONBuildInetSocketAddress(NULLSTR_= EMPTY(chr->data.udp.bindHost), + NULLSTR_EM= PTY(chr->data.udp.bindService)))) + return NULL; + } + + if (virJSONValueObjectAdd(&backendData, + "a:remote", &remote, + "A:local", &local, + NULL) < 0) return NULL; + } break; + case VIR_DOMAIN_CHR_TYPE_SPICEVMC: - backend_type =3D "spicevmc"; + backendType =3D "spicevmc"; - if (virJSONValueObjectAppendString(data, "type", - virDomainChrSpicevmcTypeToStrin= g(chr->data.spicevmc)) < 0) + if (virJSONValueObjectAdd(&backendData, + "s:type", virDomainChrSpicevmcTypeToStri= ng(chr->data.spicevmc), + NULL) < 0) return NULL; + break; case VIR_DOMAIN_CHR_TYPE_SPICEPORT: @@ -6748,15 +6748,18 @@ qemuMonitorJSONAttachCharDevGetProps(const char *ch= rID, return NULL; } - if (chr->logfile && - virJSONValueObjectAdd(&data, - "s:logfile", chr->logfile, - "T:logappend", chr->logappend, - NULL) < 0) - return NULL; + if (chr->logfile) { + if (virJSONValueObjectAdd(&backendData, + "S:logfile", chr->logfile, + "T:logappend", chr->logappend, + NULL) < 0) + return NULL; + } - if (virJSONValueObjectAppendString(backend, "type", backend_type) < 0 = || - virJSONValueObjectAppend(backend, "data", &data) < 0) + if (virJSONValueObjectAdd(&backend, + "s:type", backendType, + "A:data", &backendData, + NULL) < 0) return NULL; if (virJSONValueObjectAdd(&props, --=20 2.31.1 From nobody Fri Apr 26 20:53:22 2024 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=1637253284; cv=none; d=zohomail.com; s=zohoarc; b=G/TfS6n6pR872Fpx9d4Aqg/8tNa+W20RDckfIi9GFDm+5U6dT/zNK8iO60/bFdwUMjdCUCujcMe/SQ+5OGLQLQniflWt4xWerTdEybslEQic9z6dPojFMM/aMOZBacSDxKChYLd3r/VsMVru2o+DfsNF+VwcueLE5uCTxcPmaeY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637253284; 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=3e0MIZ8yYFiWP+5w/p5EpScpUukCEhlQvHLwCocknzk=; b=VpC58GjI7B7aecXhcafc+IyQocJEOTCxkw6NOThXZD02aVRTz982CDB8RXMmoTld+PZiuuLcxDCSUHkNHxBJtmyvI8yG6BQWaeER4eAc5Ca8hfTfgSMW/wiwymWpa3F3QRg9mcn11NbRIcX98liFHxPVVgm40Q7EeZAmx5A9bJs= 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 1637253284576638.2028317412158; Thu, 18 Nov 2021 08:34:44 -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-401-49t4vnWMPbGoL3Cwoz5cyA-1; Thu, 18 Nov 2021 11:34:39 -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 9364310151E1; Thu, 18 Nov 2021 16:34: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 71E4C694B4; Thu, 18 Nov 2021 16:34: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 3D20D1832DFD; Thu, 18 Nov 2021 16:34: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 1AIGXsNB028083 for ; Thu, 18 Nov 2021 11:33:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id A7B11608BA; Thu, 18 Nov 2021 16:33:54 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id E81BF1B5C0 for ; Thu, 18 Nov 2021 16:33:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637253283; 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=3e0MIZ8yYFiWP+5w/p5EpScpUukCEhlQvHLwCocknzk=; b=QiA4j8aXZt6+56LWre+4e8Mll5rXJc4U8NzLGzkUvpbIQK0ObBx+3xzIRtDIWS4ApV/+Rp kW47dFz+VG4aMC9w/IA/PEClTaztqqv4vAbeE4Hdgb4dYMKR5yklBFFAi8Nk4FkmROV1P3 eKsV5mAfQ/BAafxAZuT8+JgVKS8tcu0= X-MC-Unique: 49t4vnWMPbGoL3Cwoz5cyA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/16] qemu: command: Rename qemuBuildHostNetStr -> qemuBuildHostNetProps Date: Thu, 18 Nov 2021 17:33:32 +0100 Message-Id: <284c0f3de511f5ff707f617db4633b1af750e686.1637253107.git.pkrempa@redhat.com> 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.13 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: 1637253285920100001 Content-Type: text/plain; charset="utf-8" The function is already returning JSON properties, rename it accordingly. Signed-off-by: Peter Krempa --- src/qemu/qemu_command.c | 22 +++++++++++----------- src/qemu/qemu_command.h | 15 ++++++++------- src/qemu/qemu_hotplug.c | 8 ++++---- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 24dd00af9b..9293a413e6 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3936,13 +3936,13 @@ qemuBuildNicDevProps(virDomainDef *def, virJSONValue * -qemuBuildHostNetStr(virDomainNetDef *net, - char **tapfd, - size_t tapfdSize, - char **vhostfd, - size_t vhostfdSize, - const char *slirpfd, - const char *vdpadev) +qemuBuildHostNetProps(virDomainNetDef *net, + char **tapfd, + size_t tapfdSize, + char **vhostfd, + size_t vhostfdSize, + const char *slirpfd, + const char *vdpadev) { bool is_tap =3D false; virDomainNetType netType =3D virDomainNetGetActualType(net); @@ -8975,10 +8975,10 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, if (chardev) virCommandAddArgList(cmd, "-chardev", chardev, NULL); - if (!(hostnetprops =3D qemuBuildHostNetStr(net, - tapfdName, tapfdSize, - vhostfdName, vhostfdSize, - slirpfdName, vdpafdName))) + if (!(hostnetprops =3D qemuBuildHostNetProps(net, + tapfdName, tapfdSize, + vhostfdName, vhostfdSize, + slirpfdName, vdpafdName))) goto cleanup; if (qemuBuildNetdevCommandlineFromJSON(cmd, hostnetprops, qemuCaps) < = 0) diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 81fd24406d..c544c9ec67 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -87,13 +87,14 @@ qemuBuildChrDeviceProps(const virDomainDef *vmdef, virJSONValue * qemuBuildChannelGuestfwdNetdevProps(virDomainChrDef *chr); -virJSONValue *qemuBuildHostNetStr(virDomainNetDef *net, - char **tapfd, - size_t tapfdSize, - char **vhostfd, - size_t vhostfdSize, - const char *slirpfd, - const char *vdpadev); +virJSONValue * +qemuBuildHostNetProps(virDomainNetDef *net, + char **tapfd, + size_t tapfdSize, + char **vhostfd, + size_t vhostfdSize, + const char *slirpfd, + const char *vdpadev); /* Current, best practice */ virJSONValue * diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 6f667dfb76..3df0a1f17a 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1459,10 +1459,10 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, vdpafdName =3D g_strdup_printf("/dev/fdset/%d", fdinfo.fdset); } - if (!(netprops =3D qemuBuildHostNetStr(net, - tapfdName, tapfdSize, - vhostfdName, vhostfdSize, - slirpfdName, vdpafdName))) { + if (!(netprops =3D qemuBuildHostNetProps(net, + tapfdName, tapfdSize, + vhostfdName, vhostfdSize, + slirpfdName, vdpafdName))) { ignore_value(qemuDomainObjExitMonitor(driver, vm)); goto cleanup; } --=20 2.31.1 From nobody Fri Apr 26 20:53:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1637253306; cv=none; d=zohomail.com; s=zohoarc; b=fOsqOpt/ypgMvEs41sKY/2jarv4Hpj7Z3LBmxjFJEJWKzr3u8GYFbHBVZQ7/e9I2wLh8pUpG0497SSDbBOjsGDx7JPYAdeyAIE6qMBEe/Vnm3/XTI5uPtKpshj8467sUqZZ+UwYGhNSBipw3xjBKgdLmItYzyBVVyWRtMDBmXqw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637253306; 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=6x75IcfdKSUsbjk81qlLKQ2GZc3UA5IIFArq5q34G20=; b=l7qFx9b7YGKzIAWkHgR6fy1PLzOCF8hXbd/iP93C1qvtTP3I9THufpIGVaZT1aPk+u561H8zgR1rnaVgVySDH1iinE5q2v8FRUaVqcupcotmpGj+NdSa73qp8PiGj/S2UDBrNHoo6kM8nG+i8yG68nmVjlt5Qk5K1AqSgRMg6xs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1637253306296462.6589315515894; Thu, 18 Nov 2021 08:35:06 -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-30-vYwpPVmJPtaNCU9HS61tZw-1; Thu, 18 Nov 2021 11:34: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 32E20804145; Thu, 18 Nov 2021 16:34:14 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 16DFD5BB0D; Thu, 18 Nov 2021 16:34: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 CDDC84EA38; Thu, 18 Nov 2021 16:34:13 +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 1AIGXtHJ028091 for ; Thu, 18 Nov 2021 11:33:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id C806B1B5C0; Thu, 18 Nov 2021 16:33:55 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 21332608BA for ; Thu, 18 Nov 2021 16:33:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637253305; 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=6x75IcfdKSUsbjk81qlLKQ2GZc3UA5IIFArq5q34G20=; b=V3n6t2eowiqgsb7w2o6Y4kdM1ZOSh0VjBDt88SZKpAM0L5Iozm3GO6kW4QR1ixKZRmoz9C Yqw1yzAaQrbdAtygSaDIeKpg8ucKDd+YPQjKVVoxZoAsBMX82WwFcQ9mmb4Zwgw5VaErmg Q+lAjOMCc6roU9+pCKjv0cQ1Cr5vbD4= X-MC-Unique: vYwpPVmJPtaNCU9HS61tZw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/16] qemuBuildChrChardevStr: Use proper type for the switch statement Date: Thu, 18 Nov 2021 17:33:33 +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.13 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: 1637253307822100003 Content-Type: text/plain; charset="utf-8" Add the missing cases. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 9293a413e6..f97cdc70ab 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5137,7 +5137,7 @@ qemuBuildChrChardevStr(virLogManager *logManager, if (!(charAlias =3D qemuAliasChardevFromDevAlias(alias))) return NULL; - switch (dev->type) { + switch ((virDomainChrType) dev->type) { case VIR_DOMAIN_CHR_TYPE_NULL: virBufferAsprintf(&buf, "null,id=3D%s", charAlias); break; @@ -5290,6 +5290,8 @@ qemuBuildChrChardevStr(virLogManager *logManager, dev->data.spiceport.channel); break; + case VIR_DOMAIN_CHR_TYPE_NMDM: + case VIR_DOMAIN_CHR_TYPE_LAST: default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unsupported chardev '%s'"), --=20 2.31.1 From nobody Fri Apr 26 20:53:22 2024 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 From nobody Fri Apr 26 20:53:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1637253265; cv=none; d=zohomail.com; s=zohoarc; b=MKX4W1w0+2n00HPnUTXChnCS3Nl/WJQ97f0bmCHIDXrujRnSKnaX6AhHYwqSBvYr3VECtda4oT9AVFpJA1subxx6rLN2pm1goUvHH2d6m5+d5uEOMvnOzHpJpmFv0Sl1CQjU3uL5DITeG1IiHN1qETZS/93Tzd/NmxQfAlV7cIw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637253265; 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=TQoOvDar+cMYIuisHFzETJTtY25o4UeIfRn8t6xnyo8=; b=drwXD1/9352Tp/rqXRaRPkXuMgzFsnrjf4pIdq+we14Ob/NiJOqI+6cM+oQg6yA7nXjvgwrEYOHsggPQZMTlOgpJ0i99tmZSvQm9oj3EMAQb47cWp67Ku9r8/1Mdu9BxI7fpxoBOwVswVYqt+KwYxGaWV+td6nEFDwfBSwpNr8w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1637253265238705.2039142641423; Thu, 18 Nov 2021 08:34:25 -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-420-xhIS5lOGMkeOW6ok8LNoDQ-1; Thu, 18 Nov 2021 11:34:22 -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 760FA10151EE; Thu, 18 Nov 2021 16:34:17 +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 59CC41048126; Thu, 18 Nov 2021 16:34:17 +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 271D31832DDB; Thu, 18 Nov 2021 16:34:17 +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 1AIGY5r6028139 for ; Thu, 18 Nov 2021 11:34:05 -0500 Received: by smtp.corp.redhat.com (Postfix) id 191995BB12; Thu, 18 Nov 2021 16:34:05 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6485E5BAE0 for ; Thu, 18 Nov 2021 16:33:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637253264; 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=TQoOvDar+cMYIuisHFzETJTtY25o4UeIfRn8t6xnyo8=; b=G5rLu+dgN3NNi1Yu5eKm9OTBUKxlxujc0p1hiZ6+B8Y/heL1GhAzf+bbu1StKKaM7tI/by WYDeHuJ9JSbGfwDGiOfv6wMdFwTsxPzysuWnkYjoINeesPtUdbVSpu631Wsr0NbnCNzhMY hp4gaLct7ScEV60gUv2mLSBcTKB2g5g= X-MC-Unique: xhIS5lOGMkeOW6ok8LNoDQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/16] qemuDomainAddChardevTLSObjects: Refactor cleanup Date: Thu, 18 Nov 2021 17:33:35 +0100 Message-Id: <762b542473663ff498ca1a7af91260d31da17021.1637253107.git.pkrempa@redhat.com> 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.84 on 10.5.11.22 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: 1637253267520100001 Content-Type: text/plain; charset="utf-8" Switch to automatic memory clearing for the two virJSONValues and remove the 'cleanup' label and 'ret' variable. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 0e798dc237..c4f11edf6b 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1863,25 +1863,22 @@ qemuDomainAddChardevTLSObjects(virQEMUDriver *drive= r, char **tlsAlias, const char **secAlias) { - int ret =3D -1; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); qemuDomainObjPrivate *priv =3D vm->privateData; qemuDomainChrSourcePrivate *chrSourcePriv; qemuDomainSecretInfo *secinfo =3D NULL; - virJSONValue *tlsProps =3D NULL; - virJSONValue *secProps =3D NULL; + g_autoptr(virJSONValue) tlsProps =3D NULL; + g_autoptr(virJSONValue) secProps =3D NULL; /* NB: This may alter haveTLS based on cfg */ qemuDomainPrepareChardevSourceTLS(dev, cfg); if (dev->type !=3D VIR_DOMAIN_CHR_TYPE_TCP || - dev->data.tcp.haveTLS !=3D VIR_TRISTATE_BOOL_YES) { - ret =3D 0; - goto cleanup; - } + dev->data.tcp.haveTLS !=3D VIR_TRISTATE_BOOL_YES) + return 0; if (qemuDomainSecretChardevPrepare(cfg, priv, devAlias, dev) < 0) - goto cleanup; + return -1; if ((chrSourcePriv =3D QEMU_DOMAIN_CHR_SOURCE_PRIVATE(dev))) secinfo =3D chrSourcePriv->secinfo; @@ -1890,27 +1887,22 @@ qemuDomainAddChardevTLSObjects(virQEMUDriver *drive= r, *secAlias =3D secinfo->alias; if (!(*tlsAlias =3D qemuAliasTLSObjFromSrcAlias(charAlias))) - goto cleanup; + return -1; if (qemuDomainGetTLSObjects(secinfo, cfg->chardevTLSx509certdir, dev->data.tcp.listen, cfg->chardevTLSx509verify, *tlsAlias, &tlsProps, &secProps) < 0) - goto cleanup; + return -1; + dev->data.tcp.tlscreds =3D true; if (qemuDomainAddTLSObjects(driver, vm, QEMU_ASYNC_JOB_NONE, &secProps, &tlsProps) < 0) - goto cleanup; - - ret =3D 0; - - cleanup: - virJSONValueFree(tlsProps); - virJSONValueFree(secProps); + return -1; - return ret; + return 0; } --=20 2.31.1 From nobody Fri Apr 26 20:53:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1637253268; cv=none; d=zohomail.com; s=zohoarc; b=dzqsP+AEB3biN4CQBQCJ9tHsquCvKxP6ELH7IZAz6WG3NFVp+oLqUPbuqRuZTfwgyGA0ceJa/pyZz+KOrTj1b1oKQVKcdr5jPdFTCK/KC0fgHISqwpmkk2/1NLEbsTJElGr7OlVmXNNRdQ+IgsQnlPwlJeWr6+zWWadga97b1jk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637253268; 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=O64G2j/GZmyVmYEdKBKtumQjso8PYo9muZe3pk3Wewk=; b=gIe7M8pgx+DCCWou48fN/dRx/OoszYMnO2xZSa5qrDwctLW53VTuDFDqmjycu9p1u/uHPTKNXOb0DiSBrfYhRfoseHraKhcQ+OvCiefIZnV48NHk6c7erN2riUSg2sngRTG+cyHoQCrouL45GGc6jqkhVB2DsrGfTJc1omZR2DM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1637253268152988.0378333910372; Thu, 18 Nov 2021 08:34:28 -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-238--sQ0iEy-Ouy8AxLgihztiw-1; Thu, 18 Nov 2021 11:34:25 -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 23618804145; Thu, 18 Nov 2021 16:34: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 0419C5E274; Thu, 18 Nov 2021 16:34:20 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id BD9761832DF0; Thu, 18 Nov 2021 16:34: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 1AIGY6fP028158 for ; Thu, 18 Nov 2021 11:34:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id 513245BB12; Thu, 18 Nov 2021 16:34:06 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E6625BAE0 for ; Thu, 18 Nov 2021 16:34:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637253267; 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=O64G2j/GZmyVmYEdKBKtumQjso8PYo9muZe3pk3Wewk=; b=HNwd4+fXcIUohG1HrVjkIf0nK+bvlx46WL9vMUk+l5ZzUSLhHKP8iAVQ3nCaNjXiCkFEZp WIvpW0Eh66wtiEBtifO+8f7YoJDMl5Ky2pc/2/hIJ3XuCMiREj6OlZT3B/njmcBXDrorsu 8e+cWN4mcgpJtAEoO2ey/wDwI/f6QtQ= X-MC-Unique: -sQ0iEy-Ouy8AxLgihztiw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/16] qemuDomainEnsurePCIAddress: Don't pass virQEMUDriver explicitly Date: Thu, 18 Nov 2021 17:33:36 +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: 1637253268623100003 Content-Type: text/plain; charset="utf-8" The function is already getting 'virDomainObj' which has already the driver pointer present. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain_address.c | 13 +++++-------- src/qemu/qemu_domain_address.h | 8 +++----- src/qemu/qemu_hotplug.c | 21 ++++++++++----------- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index c43ad23cf5..9abe2b84c8 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -3034,8 +3034,7 @@ qemuAssignMemoryDeviceSlot(virDomainMemoryDef *mem, int -qemuDomainAssignMemoryDeviceSlot(virQEMUDriver *driver, - virDomainObj *vm, +qemuDomainAssignMemoryDeviceSlot(virDomainObj *vm, virDomainMemoryDef *mem) { g_autoptr(virBitmap) slotmap =3D NULL; @@ -3052,7 +3051,7 @@ qemuDomainAssignMemoryDeviceSlot(virQEMUDriver *drive= r, case VIR_DOMAIN_MEMORY_MODEL_VIRTIO_PMEM: case VIR_DOMAIN_MEMORY_MODEL_VIRTIO_MEM: - return qemuDomainEnsurePCIAddress(vm, &dev, driver); + return qemuDomainEnsurePCIAddress(vm, &dev); break; case VIR_DOMAIN_MEMORY_MODEL_NONE: @@ -3232,8 +3231,7 @@ qemuDomainAssignAddresses(virDomainDef *def, */ int qemuDomainEnsurePCIAddress(virDomainObj *obj, - virDomainDeviceDef *dev, - virQEMUDriver *driver) + virDomainDeviceDef *dev) { qemuDomainObjPrivate *priv =3D obj->privateData; virDomainDeviceInfo *info =3D virDomainDeviceGetInfo(dev); @@ -3241,7 +3239,7 @@ qemuDomainEnsurePCIAddress(virDomainObj *obj, if (!info) return 0; - qemuDomainFillDevicePCIConnectFlags(obj->def, dev, priv->qemuCaps, dri= ver); + qemuDomainFillDevicePCIConnectFlags(obj->def, dev, priv->qemuCaps, pri= v->driver); qemuDomainFillDevicePCIExtensionFlags(dev, info, priv->qemuCaps); @@ -3272,7 +3270,6 @@ qemuDomainEnsureVirtioAddress(bool *releaseAddr, virDomainDeviceInfo *info =3D virDomainDeviceGetInfo(dev); qemuDomainObjPrivate *priv =3D vm->privateData; virDomainCCWAddressSet *ccwaddrs =3D NULL; - virQEMUDriver *driver =3D priv->driver; int ret =3D -1; if (!info->type) { @@ -3289,7 +3286,7 @@ qemuDomainEnsureVirtioAddress(bool *releaseAddr, goto cleanup; } else if (!info->type || info->type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { - if (qemuDomainEnsurePCIAddress(vm, dev, driver) < 0) + if (qemuDomainEnsurePCIAddress(vm, dev) < 0) goto cleanup; *releaseAddr =3D true; } diff --git a/src/qemu/qemu_domain_address.h b/src/qemu/qemu_domain_address.h index df7e7fca99..4c360a0f70 100644 --- a/src/qemu/qemu_domain_address.h +++ b/src/qemu/qemu_domain_address.h @@ -45,9 +45,8 @@ int qemuDomainAssignAddresses(virDomainDef *def, ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); int qemuDomainEnsurePCIAddress(virDomainObj *obj, - virDomainDeviceDef *dev, - virQEMUDriver *driver) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); + virDomainDeviceDef *dev) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); void qemuDomainFillDeviceIsolationGroup(virDomainDef *def, virDomainDeviceDef *dev) @@ -56,8 +55,7 @@ void qemuDomainFillDeviceIsolationGroup(virDomainDef *def, void qemuDomainReleaseDeviceAddress(virDomainObj *vm, virDomainDeviceInfo *info); -int qemuDomainAssignMemoryDeviceSlot(virQEMUDriver *driver, - virDomainObj *vm, +int qemuDomainAssignMemoryDeviceSlot(virDomainObj *vm, virDomainMemoryDef *mem); void qemuDomainReleaseMemoryDeviceSlot(virDomainObj *vm, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index c4f11edf6b..d44523fe7e 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1254,7 +1254,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, if (virDomainCCWAddressAssign(&net->info, ccwaddrs, !net->info.addr.ccw.assigned) < 0) goto cleanup; - } else if (qemuDomainEnsurePCIAddress(vm, &dev, driver) < 0) { + } else if (qemuDomainEnsurePCIAddress(vm, &dev) < 0) { goto cleanup; } @@ -1706,7 +1706,7 @@ qemuDomainAttachHostPCIDevice(virQEMUDriver *driver, /* Isolation groups are only relevant for pSeries guests */ qemuDomainFillDeviceIsolationGroup(vm->def, &dev); - if (qemuDomainEnsurePCIAddress(vm, &dev, driver) < 0) + if (qemuDomainEnsurePCIAddress(vm, &dev) < 0) goto error; releaseaddr =3D true; @@ -2131,8 +2131,7 @@ qemuDomainChrRemove(virDomainDef *vmdef, */ static int qemuDomainAttachChrDeviceAssignAddr(virDomainObj *vm, - virDomainChrDef *chr, - virQEMUDriver *driver) + virDomainChrDef *chr) { virDomainDef *def =3D vm->def; qemuDomainObjPrivate *priv =3D vm->privateData; @@ -2146,7 +2145,7 @@ qemuDomainAttachChrDeviceAssignAddr(virDomainObj *vm, } else if (chr->deviceType =3D=3D VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && chr->targetType =3D=3D VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PC= I) { - if (qemuDomainEnsurePCIAddress(vm, &dev, driver) < 0) + if (qemuDomainEnsurePCIAddress(vm, &dev) < 0) return -1; return 1; @@ -2204,7 +2203,7 @@ int qemuDomainAttachChrDevice(virQEMUDriver *driver, if (qemuAssignDeviceChrAlias(vmdef, chr, -1) < 0) goto cleanup; - if ((rc =3D qemuDomainAttachChrDeviceAssignAddr(vm, chr, driver)) < 0) + if ((rc =3D qemuDomainAttachChrDeviceAssignAddr(vm, chr)) < 0) goto cleanup; if (rc =3D=3D 1) need_release =3D true; @@ -2442,7 +2441,7 @@ qemuDomainAttachMemory(virQEMUDriver *driver, if (qemuDomainDefValidateMemoryHotplug(vm->def, mem) < 0) goto cleanup; - if (qemuDomainAssignMemoryDeviceSlot(driver, vm, mem) < 0) + if (qemuDomainAssignMemoryDeviceSlot(vm, mem) < 0) goto cleanup; releaseaddr =3D true; @@ -2777,7 +2776,7 @@ qemuDomainAttachSCSIVHostDevice(virQEMUDriver *driver, if (hostdev->info->type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE || hostdev->info->type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { - if (qemuDomainEnsurePCIAddress(vm, &dev, driver) < 0) + if (qemuDomainEnsurePCIAddress(vm, &dev) < 0) goto cleanup; } else if (hostdev->info->type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_C= CW) { if (!(ccwaddrs =3D virDomainCCWAddressSetCreateFromDomain(vm->def)= )) @@ -2870,7 +2869,7 @@ qemuDomainAttachMediatedDevice(virQEMUDriver *driver, switch (hostdev->source.subsys.u.mdev.model) { case VIR_MDEV_MODEL_TYPE_VFIO_PCI: - if (qemuDomainEnsurePCIAddress(vm, &dev, driver) < 0) + if (qemuDomainEnsurePCIAddress(vm, &dev) < 0) return -1; break; case VIR_MDEV_MODEL_TYPE_VFIO_CCW: { @@ -3039,7 +3038,7 @@ qemuDomainAttachShmemDevice(virQEMUDriver *driver, if ((shmem->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE || shmem->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) && - (qemuDomainEnsurePCIAddress(vm, &dev, driver) < 0)) + (qemuDomainEnsurePCIAddress(vm, &dev) < 0)) return -1; if (!(devProps =3D qemuBuildShmemDevProps(vm->def, shmem))) @@ -3136,7 +3135,7 @@ qemuDomainAttachWatchdog(virQEMUDriver *driver, return -1; if (watchdog->model =3D=3D VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB) { - if (qemuDomainEnsurePCIAddress(vm, &dev, driver) < 0) + if (qemuDomainEnsurePCIAddress(vm, &dev) < 0) goto cleanup; releaseAddress =3D true; } else { --=20 2.31.1 From nobody Fri Apr 26 20:53:22 2024 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=1637253271; cv=none; d=zohomail.com; s=zohoarc; b=ZEl1ADAzrIj7C4+O7I7/kZKUD58KmB1lsj5sh/QtCgCKPVOwI8lZarAPIs9wIP9/PlPV3QyUDvj9+ltreOW/7VqiYWwhBii/oLZ0Lup4gLqxgDStgweW5AXtxuHmpIiB49YgsmGHn2Gff78DFtBjjBRzaW0lHjn8I09/bfYDUss= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637253271; 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=JC8mteV2iyq2XMfeTJy8ZtCl7qNpolCJMSlLLwO6ZSQ=; b=L3xspkQMai1kD+Rt32/KP8/ELV0F0jbpAKcwuowN6/6MbwbzL56xcghfUU+FSCTW+GQtw/LoGVF1fQGxpxanuVYoZt5ze9wq0vTBkBFPwKfZUwLKKgxJcGlgpNDB7hjoH75JEgt1MHaZ/C865Nk+qR4CFJ+n0zpih9ZkwsVlI9g= 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 1637253271284665.8418271152776; Thu, 18 Nov 2021 08:34:31 -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-175-Prcc8bbpPA2jh4GwvR7KCQ-1; Thu, 18 Nov 2021 11:34:28 -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 481A11922966; Thu, 18 Nov 2021 16:34:17 +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 5080360BF1; Thu, 18 Nov 2021 16:34:23 +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 1C9BE4EA3F; Thu, 18 Nov 2021 16:34:23 +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 1AIGY7XR028173 for ; Thu, 18 Nov 2021 11:34:07 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8E6F3608BA; Thu, 18 Nov 2021 16:34:07 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id D894A6FEED for ; Thu, 18 Nov 2021 16:34:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637253270; 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=JC8mteV2iyq2XMfeTJy8ZtCl7qNpolCJMSlLLwO6ZSQ=; b=KoT9BBlm/s6iiRe4nBDaxzWKQHUIQX7fPfudE9rwt6v7SDGXI0rw4v/U1BygdaVSwZQOiI 3QCy+k5y8Kx7qvQZ7MV3AoqD9057n45UYU3LDOo4aGASRXuBQyjkc2jaAQQPPkc3G4rL2L fvQ1rjUgPpZRAZFtYi1jI5OOoMmD2dQ= X-MC-Unique: Prcc8bbpPA2jh4GwvR7KCQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/16] qemuDomainAttachChrDeviceAssignAddr: Simplify return value handling Date: Thu, 18 Nov 2021 17:33:37 +0100 Message-Id: <22a3906fa23a81db64f43fd295c7cfc596f0d2cb.1637253107.git.pkrempa@redhat.com> 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.12 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: 1637253271938100004 Content-Type: text/plain; charset="utf-8" Rather than returning a different error code if the device address needs to be released pass in the 'need_release' flag via a pointer. Signed-off-by: Peter Krempa --- src/qemu/qemu_hotplug.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index d44523fe7e..5e44210aff 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2125,13 +2125,12 @@ qemuDomainChrRemove(virDomainDef *vmdef, return ret; } -/* Returns 1 if the address will need to be released later, - * -1 on error - * 0 otherwise - */ + + static int qemuDomainAttachChrDeviceAssignAddr(virDomainObj *vm, - virDomainChrDef *chr) + virDomainChrDef *chr, + bool *need_release) { virDomainDef *def =3D vm->def; qemuDomainObjPrivate *priv =3D vm->privateData; @@ -2147,13 +2146,16 @@ qemuDomainAttachChrDeviceAssignAddr(virDomainObj *v= m, chr->targetType =3D=3D VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PC= I) { if (qemuDomainEnsurePCIAddress(vm, &dev) < 0) return -1; - return 1; + *need_release =3D true; + return 0; } else if (chr->deviceType =3D=3D VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && chr->targetType =3D=3D VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_US= B) { if (virDomainUSBAddressEnsure(priv->usbaddrs, &chr->info) < 0) return -1; - return 1; + + *need_release =3D true; + return 0; } else if (chr->deviceType =3D=3D VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL && chr->targetType =3D=3D VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_V= IRTIO) { @@ -2176,7 +2178,7 @@ int qemuDomainAttachChrDevice(virQEMUDriver *driver, virDomainObj *vm, virDomainChrDef *chr) { - int ret =3D -1, rc; + int ret =3D -1; qemuDomainObjPrivate *priv =3D vm->privateData; virErrorPtr orig_err; virDomainDef *vmdef =3D vm->def; @@ -2203,10 +2205,8 @@ int qemuDomainAttachChrDevice(virQEMUDriver *driver, if (qemuAssignDeviceChrAlias(vmdef, chr, -1) < 0) goto cleanup; - if ((rc =3D qemuDomainAttachChrDeviceAssignAddr(vm, chr)) < 0) + if (qemuDomainAttachChrDeviceAssignAddr(vm, chr, &need_release) < 0) goto cleanup; - if (rc =3D=3D 1) - need_release =3D true; if (qemuDomainNamespaceSetupChardev(vm, chr, &teardowndevice) < 0) goto cleanup; --=20 2.31.1 From nobody Fri Apr 26 20:53:22 2024 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=1637253272; cv=none; d=zohomail.com; s=zohoarc; b=I4aeYJNfZ1/60t2wDMtLxelK/KpZ5cYjN1IyCh9s2w8q6mwGNQvyBJ/b5YZcbbVcXpp8yjOqBlUtXUnJyBsu0u835lUwcn0anHoCfDhyQOe1/0nqgiwIdllH/Hhf5VeQvL9gVjq31DDbv/J/93jjuQNEeAXiXUItVoc2yWOrUB0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637253272; 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=3cgKSHLMmGkE1qE1e46URlJiOJR/EJTMZHS3Gv0GPCk=; b=dOb12AioBI2C+ku7aPKI/l2/ppX7ttqMjriB9vXrg61Z/xXi/swOenKjbPi8GPmKDnJQ37ZDiGMalYHHyJ+pBYNuaJcFEyDi4q4bSYvzq/BgWlP8134wG7e5SqttSGt+x9FsIlahT/nPcw5Nv7L9HdEMg2bYbYkVohXiG6FoTcM= 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 1637253272832179.9448240220364; Thu, 18 Nov 2021 08:34:32 -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-357-kK0xa9e3P56u8QSqvnmP3w-1; Thu, 18 Nov 2021 11:34:30 -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 600211922964; Thu, 18 Nov 2021 16:34:19 +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 1A44B5F4F5; Thu, 18 Nov 2021 16:34:25 +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 DE6751832DF8; Thu, 18 Nov 2021 16:34: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 1AIGY8wM028212 for ; Thu, 18 Nov 2021 11:34:08 -0500 Received: by smtp.corp.redhat.com (Postfix) id C9D065BB0D; Thu, 18 Nov 2021 16:34:08 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 187BF5BAE0 for ; Thu, 18 Nov 2021 16:34:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637253271; 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=3cgKSHLMmGkE1qE1e46URlJiOJR/EJTMZHS3Gv0GPCk=; b=co32YrmwTZiT4ZWMFlrk183QCzu+J3Zm3PM7YrG3AeE1ROCKC7wFqot4X5uwqY2VZ6Vuhl mYmSPGvIKDPCwtOZO4WuR+86s1in5pSUz+LG4ptkMUO9R6GfrJD81sD9I2aPxpKj3NJoVe E5GuUDraUKWe96awFqJ2mxDYBvsQp+g= X-MC-Unique: kK0xa9e3P56u8QSqvnmP3w-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 13/16] qemuDomainAttachChrDevice: Drop 'dev' variable Date: Thu, 18 Nov 2021 17:33:38 +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.15 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: 1637253273287100007 Content-Type: text/plain; charset="utf-8" It's referenced only once and it's a shortcut to the chardev source thus can be used directly. Signed-off-by: Peter Krempa --- src/qemu/qemu_hotplug.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 5e44210aff..3373ec2cdf 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2184,7 +2184,6 @@ int qemuDomainAttachChrDevice(virQEMUDriver *driver, virDomainDef *vmdef =3D vm->def; g_autoptr(virJSONValue) devprops =3D NULL; g_autoptr(virJSONValue) netdevprops =3D NULL; - virDomainChrSourceDef *dev =3D chr->source; g_autofree char *charAlias =3D NULL; bool chardevAttached =3D false; bool teardowncgroup =3D false; @@ -2233,7 +2232,7 @@ int qemuDomainAttachChrDevice(virQEMUDriver *driver, if (qemuDomainChrPreInsert(vmdef, chr) < 0) goto cleanup; - if (qemuDomainAddChardevTLSObjects(driver, vm, dev, + if (qemuDomainAddChardevTLSObjects(driver, vm, chr->source, chr->info.alias, charAlias, &tlsAlias, &secAlias) < 0) goto audit; --=20 2.31.1 From nobody Fri Apr 26 20:53:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1637253287; cv=none; d=zohomail.com; s=zohoarc; b=LqjMNj5jVCvXubb6fK8X2X2M7pKFV2gXxgEm1wRnm2l8LRhZ6xBnvD0eJuiu2VSuSEJhwo1EP5cCxQbDt1eaNwEyyXdwkf/VFb5/UEY+gWGL8hT+F6N5abpkIFytNW+esRmD73vHum9uzVehpGSNXUTc1ntbJ+zHoawwy81vQNU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637253287; 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=fdyqSgjkb3GbXSOZ/+4UHgxqSX5z0vHROoAu724Bqdc=; b=RlH07FptpwGrXzdsImyzE0KZewIRGKJS4/vKZLJwmQ+LX7F5KAi0T8dCUXBGttFydPHO2bJ9q4/5KzRC+juqCBM3vhDJQ+keKK2eSyEIGFOujnKHU5NtWPkuRxsunlSiFCJ1mH4j1U59FUbQCr06RGz0RIML6fE0WWCWoT4r1OE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1637253287345960.5877604785451; Thu, 18 Nov 2021 08:34:47 -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-400-oysQyUOSMHiSp9dWSDBPDw-1; Thu, 18 Nov 2021 11:34: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 8B89BA40C1; Thu, 18 Nov 2021 16:34:39 +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 70E515D705; Thu, 18 Nov 2021 16:34: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 13ADC4EA76; Thu, 18 Nov 2021 16:34: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 1AIGYAI0028223 for ; Thu, 18 Nov 2021 11:34:10 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0D1F9608BA; Thu, 18 Nov 2021 16:34:10 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 54E181B5C0 for ; Thu, 18 Nov 2021 16:34:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637253286; 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=fdyqSgjkb3GbXSOZ/+4UHgxqSX5z0vHROoAu724Bqdc=; b=WuIlyXxXB3w0QS7An5ifLYV/ZFyvW5zRUFE3lBqXvtTSN8zL/SrU5pm+371AeQvOy2naGj et5lxLFo94fsMqxN6cDP9ZHxUhNm1Mk3V6ZnGC2f47AjX2XPIRakKoBYApUvPRutDumSg+ KjuKZ/uCO6Zsf6xN5dtSWr2LuGr6+ts= X-MC-Unique: oysQyUOSMHiSp9dWSDBPDw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 14/16] qemuBuildStorageSourceAttachPrepare(Drive|Chardev): Unexport Date: Thu, 18 Nov 2021 17:33:39 +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.15 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: 1637253288178100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa --- src/qemu/qemu_command.c | 4 ++-- src/qemu/qemu_command.h | 7 ------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 60336947b5..f3b02d3438 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -11104,7 +11104,7 @@ qemuBuildHotpluggableCPUProps(const virDomainVcpuDe= f *vcpu) * Prepare qemuBlockStorageSourceAttachData *for use with the old approach * using -drive/drive_add. See qemuBlockStorageSourceAttachPrepareBlockdev. */ -qemuBlockStorageSourceAttachData * +static qemuBlockStorageSourceAttachData * qemuBuildStorageSourceAttachPrepareDrive(virDomainDiskDef *disk, virQEMUCaps *qemuCaps) { @@ -11127,7 +11127,7 @@ qemuBuildStorageSourceAttachPrepareDrive(virDomainD= iskDef *disk, * Prepare qemuBlockStorageSourceAttachData *for vhost-user disk * to be used with -chardev. */ -qemuBlockStorageSourceAttachData * +static qemuBlockStorageSourceAttachData * qemuBuildStorageSourceAttachPrepareChardev(virDomainDiskDef *disk) { g_autoptr(qemuBlockStorageSourceAttachData) data =3D NULL; diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index c544c9ec67..7dec2cb4af 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -106,13 +106,6 @@ qemuBuildNicDevProps(virDomainDef *def, char *qemuDeviceDriveHostAlias(virDomainDiskDef *disk); bool qemuDiskBusIsSD(int bus); -qemuBlockStorageSourceAttachData * -qemuBuildStorageSourceAttachPrepareDrive(virDomainDiskDef *disk, - virQEMUCaps *qemuCaps); - -qemuBlockStorageSourceAttachData * -qemuBuildStorageSourceAttachPrepareChardev(virDomainDiskDef *disk); - int qemuBuildStorageSourceAttachPrepareCommon(virStorageSource *src, qemuBlockStorageSourceAttachData= *data); --=20 2.31.1 From nobody Fri Apr 26 20:53:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1637253306; cv=none; d=zohomail.com; s=zohoarc; b=gqfMa6pbgzdmb8ZUkPzhaoc0uukDgtmXbwrIhRoPQp/5/KCJlONOVzdcHKLzSWgXKFdtWeki0Tsu6uN107uln4yR9Hru/8vOHPXXNXeSpBqxNqLK8kaSVzSjwwhYDKandtH9oi5qTa7OlmdmR7z7YOt9pDAra0yuUu27Krd/0zE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637253306; 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=SBzyibbEFjvtIqyEARxfDGDAA3YS3LvWz9oxmSY+vq0=; b=CdFZeTKd7ZN6IRhIMZkV5ZJtkiqcazoOBEu/cvdpeJV4RxmSZxUQ7QBvfNMOxNYDxhisggHBSy1UNHTk7y9cy30GLGWv6Dv+DFzamKxoRJwZ6ovEYBOjrbLZiBec+R3LoqB9KUv83W4FgAny5bHayLebBZ2hObcTaNtCmiedRzU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1637253306624810.0746286323547; Thu, 18 Nov 2021 08:35:06 -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-598-IVaoAIVMNoyTa08CH53vKg-1; Thu, 18 Nov 2021 11:34:33 -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 A11D7101F00B; Thu, 18 Nov 2021 16:34:28 +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 7CD3E19733; Thu, 18 Nov 2021 16:34: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 479E64EA42; Thu, 18 Nov 2021 16:34: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 1AIGYDfc028249 for ; Thu, 18 Nov 2021 11:34:13 -0500 Received: by smtp.corp.redhat.com (Postfix) id F3FB85BAE0; Thu, 18 Nov 2021 16:34:12 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 296D11B5C0 for ; Thu, 18 Nov 2021 16:34:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637253305; 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=SBzyibbEFjvtIqyEARxfDGDAA3YS3LvWz9oxmSY+vq0=; b=UR+P+pPmdBdoSb3N5yTv0Qh4hgJoK41DLYaLhsl/bbjAM/km61D4TJZStRT7X/tz468M+/ DzO57TKiMWg3Sgp6mNDhbQYbH3basBK5ktGOL3lCKa5sRdJplevRTmly793awob4fOuP7t M0ghL7jHR//rBFJ5KR7K81RRV9i/edM= X-MC-Unique: IVaoAIVMNoyTa08CH53vKg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 15/16] conf: Properly instantiate virDomainChrSourceDef in virDomainTPMDef Date: Thu, 18 Nov 2021 17:33:40 +0100 Message-Id: <4b67ffb6e10603910fa4cbc9c8187fab7771a299.1637253108.git.pkrempa@redhat.com> 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.84 on 10.5.11.23 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: 1637253308032100004 Content-Type: text/plain; charset="utf-8" 'virDomainChrSourceDef' contains private data so 'virDomainChrSourceDefNew' must be used to allocate it. 'virDomainTPMDef' was using it directly which won't work with the chardev helper functions. Convert it to a pointer to properly allocate private data. Signed-off-by: Peter Krempa --- src/conf/domain_audit.c | 4 ++-- src/conf/domain_conf.c | 14 +++++++++----- src/conf/domain_conf.h | 4 ++-- src/qemu/qemu_cgroup.c | 2 +- src/qemu/qemu_command.c | 6 +++--- src/qemu/qemu_namespace.c | 2 +- src/qemu/qemu_tpm.c | 10 +++++----- src/security/security_dac.c | 6 +++--- src/security/security_selinux.c | 6 +++--- tests/qemuxml2argvtest.c | 6 +++--- 10 files changed, 32 insertions(+), 28 deletions(-) diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c index 69c5792b07..17a01c51ba 100644 --- a/src/conf/domain_audit.c +++ b/src/conf/domain_audit.c @@ -536,7 +536,7 @@ virDomainAuditTPM(virDomainObj *vm, virDomainTPMDef *tp= m, switch (tpm->type) { case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: - path =3D tpm->data.passthrough.source.data.file.path; + path =3D tpm->data.passthrough.source->data.file.path; if (!(device =3D virAuditEncode("device", VIR_AUDIT_STR(path)))) { VIR_WARN("OOM while encoding audit message"); goto cleanup; @@ -547,7 +547,7 @@ virDomainAuditTPM(virDomainObj *vm, virDomainTPMDef *tp= m, virt, reason, vmname, uuidstr, device); break; case VIR_DOMAIN_TPM_TYPE_EMULATOR: - path =3D tpm->data.emulator.source.data.nix.path; + path =3D tpm->data.emulator.source->data.nix.path; if (!(device =3D virAuditEncode("device", VIR_AUDIT_STR(path)))) { VIR_WARN("OOM while encoding audit message"); goto cleanup; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 52f513f488..7231d8fc3f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3211,10 +3211,10 @@ void virDomainTPMDefFree(virDomainTPMDef *def) switch (def->type) { case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: - virDomainChrSourceDefClear(&def->data.passthrough.source); + virObjectUnref(def->data.passthrough.source); break; case VIR_DOMAIN_TPM_TYPE_EMULATOR: - virDomainChrSourceDefClear(&def->data.emulator.source); + virObjectUnref(def->data.emulator.source); g_free(def->data.emulator.storagepath); g_free(def->data.emulator.logfile); break; @@ -11831,13 +11831,17 @@ virDomainTPMDefParseXML(virDomainXMLOption *xmlop= t, switch (def->type) { case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: + if (!(def->data.passthrough.source =3D virDomainChrSourceDefNew(xm= lopt))) + goto error; path =3D virXPathString("string(./backend/device/@path)", ctxt); if (!path) path =3D g_strdup(VIR_DOMAIN_TPM_DEFAULT_DEVICE); - def->data.passthrough.source.data.file.path =3D g_steal_pointer(&p= ath); - def->data.passthrough.source.type =3D VIR_DOMAIN_CHR_TYPE_DEV; + def->data.passthrough.source->type =3D VIR_DOMAIN_CHR_TYPE_DEV; + def->data.passthrough.source->data.file.path =3D g_steal_pointer(&= path); break; case VIR_DOMAIN_TPM_TYPE_EMULATOR: + if (!(def->data.emulator.source =3D virDomainChrSourceDefNew(xmlop= t))) + goto error; secretuuid =3D virXPathString("string(./backend/encryption/@secret= )", ctxt); if (secretuuid) { if (virUUIDParse(secretuuid, def->data.emulator.secretuuid) < = 0) { @@ -25456,7 +25460,7 @@ virDomainTPMDefFormat(virBuffer *buf, virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); virBufferEscapeString(buf, "\n", - def->data.passthrough.source.data.file.path); + def->data.passthrough.source->data.file.path= ); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); break; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 3cb68c5d0a..c1b2a814aa 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1381,10 +1381,10 @@ struct _virDomainTPMDef { int version; /* virDomainTPMVersion */ union { struct { - virDomainChrSourceDef source; + virDomainChrSourceDef *source; } passthrough; struct { - virDomainChrSourceDef source; + virDomainChrSourceDef *source; char *storagepath; char *logfile; unsigned char secretuuid[VIR_UUID_BUFLEN]; diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index 471cbc3b8f..1e7b562b33 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -340,7 +340,7 @@ qemuSetupTPMCgroup(virDomainObj *vm, switch (dev->type) { case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: - ret =3D qemuSetupChrSourceCgroup(vm, &dev->data.passthrough.source= ); + ret =3D qemuSetupChrSourceCgroup(vm, dev->data.passthrough.source); break; case VIR_DOMAIN_TPM_TYPE_EMULATOR: case VIR_DOMAIN_TPM_TYPE_LAST: diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f3b02d3438..623e3a20a9 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9947,7 +9947,7 @@ qemuBuildTPMBackendStr(virCommand *cmd, switch (tpm->type) { case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: - tpmdev =3D tpm->data.passthrough.source.data.file.path; + tpmdev =3D tpm->data.passthrough.source->data.file.path; if (!(cancel_path =3D virTPMCreateCancelPath(tpmdev))) return NULL; @@ -9972,7 +9972,7 @@ qemuBuildTPMBackendStr(virCommand *cmd, virBufferAddLit(&buf, ",chardev=3Dchrtpm"); *chardev =3D g_strdup_printf("socket,id=3Dchrtpm,path=3D%s", - tpm->data.emulator.source.data.nix.path= ); + tpm->data.emulator.source->data.nix.pat= h); break; case VIR_DOMAIN_TPM_TYPE_LAST: @@ -10041,7 +10041,7 @@ qemuBuildTPMProxyCommandLine(virCommand *cmd, if (virJSONValueObjectAdd(&props, "s:driver", virDomainTPMModelTypeToString(tp= m->model), "s:id", tpm->info.alias, - "s:host-path", tpm->data.passthrough.source.= data.file.path, + "s:host-path", tpm->data.passthrough.source-= >data.file.path, NULL) < 0) return -1; diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c index f1aaca86b1..23b1160c5e 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -422,7 +422,7 @@ qemuDomainSetupTPM(virDomainTPMDef *dev, { switch (dev->type) { case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: - *paths =3D g_slist_prepend(*paths, g_strdup(dev->data.passthrough.= source.data.file.path)); + *paths =3D g_slist_prepend(*paths, g_strdup(dev->data.passthrough.= source->data.file.path)); break; case VIR_DOMAIN_TPM_TYPE_EMULATOR: diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 7d05394356..62f54f56ab 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -332,11 +332,11 @@ qemuTPMEmulatorPrepareHost(virDomainTPMDef *tpm, return -1; /* create the socket filename */ - if (!tpm->data.emulator.source.data.nix.path && - !(tpm->data.emulator.source.data.nix.path =3D + if (!tpm->data.emulator.source->data.nix.path && + !(tpm->data.emulator.source->data.nix.path =3D qemuTPMCreateEmulatorSocket(swtpmStateDir, shortName))) return -1; - tpm->data.emulator.source.type =3D VIR_DOMAIN_CHR_TYPE_UNIX; + tpm->data.emulator.source->type =3D VIR_DOMAIN_CHR_TYPE_UNIX; return 0; } @@ -716,7 +716,7 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm, secretuuid) < 0) goto error; - unlink(tpm->data.emulator.source.data.nix.path); + unlink(tpm->data.emulator.source->data.nix.path); cmd =3D virCommandNew(swtpm); if (!cmd) @@ -726,7 +726,7 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm, virCommandAddArgList(cmd, "socket", "--daemon", "--ctrl", NULL); virCommandAddArgFormat(cmd, "type=3Dunixio,path=3D%s,mode=3D0600", - tpm->data.emulator.source.data.nix.path); + tpm->data.emulator.source->data.nix.path); virCommandAddArg(cmd, "--tpmstate"); virCommandAddArgFormat(cmd, "dir=3D%s,mode=3D0600", diff --git a/src/security/security_dac.c b/src/security/security_dac.c index 1733d63410..e9e316551e 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -1686,12 +1686,12 @@ virSecurityDACSetTPMFileLabel(virSecurityManager *m= gr, switch (tpm->type) { case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: ret =3D virSecurityDACSetChardevLabelHelper(mgr, def, - &tpm->data.passthrough.s= ource, + tpm->data.passthrough.so= urce, false, false); break; case VIR_DOMAIN_TPM_TYPE_EMULATOR: ret =3D virSecurityDACSetChardevLabelHelper(mgr, def, - &tpm->data.emulator.sour= ce, + tpm->data.emulator.sourc= e, false, false); break; case VIR_DOMAIN_TPM_TYPE_LAST: @@ -1712,7 +1712,7 @@ virSecurityDACRestoreTPMFileLabel(virSecurityManager = *mgr, switch (tpm->type) { case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: ret =3D virSecurityDACRestoreChardevLabelHelper(mgr, def, - &tpm->data.passthrou= gh.source, + tpm->data.passthroug= h.source, false, false); break; case VIR_DOMAIN_TPM_TYPE_EMULATOR: diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index 622a8f4c02..840a05844e 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1637,7 +1637,7 @@ virSecuritySELinuxSetTPMFileLabel(virSecurityManager = *mgr, switch (tpm->type) { case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: - tpmdev =3D tpm->data.passthrough.source.data.file.path; + tpmdev =3D tpm->data.passthrough.source->data.file.path; rc =3D virSecuritySELinuxSetFilecon(mgr, tpmdev, seclabel->imagela= bel, false); if (rc < 0) return -1; @@ -1656,7 +1656,7 @@ virSecuritySELinuxSetTPMFileLabel(virSecurityManager = *mgr, } break; case VIR_DOMAIN_TPM_TYPE_EMULATOR: - tpmdev =3D tpm->data.emulator.source.data.nix.path; + tpmdev =3D tpm->data.emulator.source->data.nix.path; rc =3D virSecuritySELinuxSetFilecon(mgr, tpmdev, seclabel->imagela= bel, false); if (rc < 0) return -1; @@ -1685,7 +1685,7 @@ virSecuritySELinuxRestoreTPMFileLabelInt(virSecurityM= anager *mgr, switch (tpm->type) { case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: - tpmdev =3D tpm->data.passthrough.source.data.file.path; + tpmdev =3D tpm->data.passthrough.source->data.file.path; rc =3D virSecuritySELinuxRestoreFileLabel(mgr, tpmdev, false); if ((cancel_path =3D virTPMCreateCancelPath(tpmdev)) !=3D NULL) { diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 161e7efa62..1d0d6e14ba 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -450,9 +450,9 @@ testCompareXMLToArgvCreateArgs(virQEMUDriver *drv, if (vm->def->tpms[i]->type !=3D VIR_DOMAIN_TPM_TYPE_EMULATOR) continue; - VIR_FREE(vm->def->tpms[i]->data.emulator.source.data.file.path); - vm->def->tpms[i]->data.emulator.source.data.file.path =3D g_strdup= ("/dev/test"); - vm->def->tpms[i]->data.emulator.source.type =3D VIR_DOMAIN_CHR_TYP= E_FILE; + VIR_FREE(vm->def->tpms[i]->data.emulator.source->data.file.path); + vm->def->tpms[i]->data.emulator.source->data.file.path =3D g_strdu= p("/dev/test"); + vm->def->tpms[i]->data.emulator.source->type =3D VIR_DOMAIN_CHR_TY= PE_FILE; } for (i =3D 0; i < vm->def->nvideos; i++) { --=20 2.31.1 From nobody Fri Apr 26 20:53:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1637253281; cv=none; d=zohomail.com; s=zohoarc; b=BZ2ohtoH/TgOAyjUqZSH58eEoi8nDv76DLiew/W06v1kFdDj2poZutkOEuHNAAG/+m9lnJ9iEdbh1lbcJLCmEV5KjX7P/fXS+FgtVlCtLoBpFzQSljiHan12ckwzkiIXZfrr/0IDuwR3dnA6XG6041LOhYBno89vQNnmhvzJ3X0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637253281; 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=H8kwUuePDfF40T0Fofo6imv6lYW20Y88az6BlCa2Ocs=; b=AW4F3YcFd95xUOSJJ01Qm1CYQERU5+wd1tTEszBMB41QdIFNr47DXkXJbNSBgyREhIZ9lzaQO55RjeHn0Q9TiZUAqxTUliCuPw7clXWWZemnhFD913f6MAzNw5+ujX9bC4IzApI8Gn7cATHjVIbt5Ds+ahLeU8v+hFuMo5ypK9g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1637253281487143.9650668969416; Thu, 18 Nov 2021 08:34:41 -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-420-V42zecKINDiMKMiG6ZORtQ-1; Thu, 18 Nov 2021 11:34:38 -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 ADD05804147; Thu, 18 Nov 2021 16:34:32 +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 8F7B65F4ED; Thu, 18 Nov 2021 16:34:32 +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 59DC94EA45; Thu, 18 Nov 2021 16:34:32 +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 1AIGYE4k028287 for ; Thu, 18 Nov 2021 11:34:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2A26B5BB12; Thu, 18 Nov 2021 16:34:14 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 76F0E5BAFF for ; Thu, 18 Nov 2021 16:34:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637253280; 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=H8kwUuePDfF40T0Fofo6imv6lYW20Y88az6BlCa2Ocs=; b=ZdUBCnnacbVhfdNMTKMHZAXwFa+QMgUwzv/aqAn/iMzAKR6Hkq4/bDgAMyT2mS4nB/w9qK iuFBLI21zbDzOtvepqE7nMQJnpQ07hICpJWWRjG8LmSFv/YN+x0p85eKtQYc9/PuUS6WEw qwXFCCFoVhn2IU19D19EaItR4SuplkQ= X-MC-Unique: V42zecKINDiMKMiG6ZORtQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 16/16] qemuxml2argvtest: Fix type for faked chardev backing a TPM Date: Thu, 18 Nov 2021 17:33:41 +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.15 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: 1637253283549100001 Content-Type: text/plain; charset="utf-8" The test filled the chardev type to VIR_DOMAIN_CHR_TYPE_FILE and thus set the 'data.emulator.source->data.file.path' pointer, but the commandline formatter is unconditionally expecting VIR_DOMAIN_CHR_TYPE_UNIX and thus reading 'data.emulator.source->data.nix.path'. Since it's an union it happened to land in the correct place. Fix the faked data. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemuxml2argvtest.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 1d0d6e14ba..a5d162958e 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -450,9 +450,9 @@ testCompareXMLToArgvCreateArgs(virQEMUDriver *drv, if (vm->def->tpms[i]->type !=3D VIR_DOMAIN_TPM_TYPE_EMULATOR) continue; - VIR_FREE(vm->def->tpms[i]->data.emulator.source->data.file.path); - vm->def->tpms[i]->data.emulator.source->data.file.path =3D g_strdu= p("/dev/test"); - vm->def->tpms[i]->data.emulator.source->type =3D VIR_DOMAIN_CHR_TY= PE_FILE; + VIR_FREE(vm->def->tpms[i]->data.emulator.source->data.nix.path); + vm->def->tpms[i]->data.emulator.source->type =3D VIR_DOMAIN_CHR_TY= PE_UNIX; + vm->def->tpms[i]->data.emulator.source->data.nix.path =3D g_strdup= ("/dev/test"); } for (i =3D 0; i < vm->def->nvideos; i++) { --=20 2.31.1