From nobody Mon Apr 29 13:11:19 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=1643018885; cv=none; d=zohomail.com; s=zohoarc; b=Jxom9ZMUtLZPlpLGz06VUov3YFVMzsVfryB2Y7DYJVM7E43YOZCN3yMSnH7CC+0FO0z3OfNDPGFOkS0YAYoUHZf0tTvoE++dLKPSpeh1WYIa0mluBKCpCEyM5bTXJk5daM9wWQbWdeJJ0ykpwWzr0WfZy1qarUIycIlwKMhyjxg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643018885; 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=3K0F55t696sPYV3WctJxiiRFo+60rXtrU7a0UBoE3tY=; b=VGxKzmY/12TnugXKOlvaEirf8tJbzbWH3ynYbPjSwigAnG8xJcqMfI5vGN46zoAaHGb1wJp7bzCedBTHaHsByx1yeHoS7XnuJRrYReLh9UuoBWRisYgTwOApMBiyhuPMYNRSgvnGkadm52+kYjZnWAN2p9ejoRJktuDJQGLjBA8= 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 1643018885115903.2532873851839; Mon, 24 Jan 2022 02:08:05 -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-395-KqN4NT5-MLy10APPfcpYYA-1; Mon, 24 Jan 2022 05:08:00 -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 3B2F9801B33; Mon, 24 Jan 2022 10:07:54 +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 24FDB7B9D9; Mon, 24 Jan 2022 10:07:53 +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 97EC14BB7C; Mon, 24 Jan 2022 10:07:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20OA7kRu021055 for ; Mon, 24 Jan 2022 05:07:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8CCF06D03D; Mon, 24 Jan 2022 10:07:46 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id F3EF86F120 for ; Mon, 24 Jan 2022 10:07:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643018884; 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=3K0F55t696sPYV3WctJxiiRFo+60rXtrU7a0UBoE3tY=; b=DPJCpFVl5GXGsVC+5z0ARJDGeu9VDi1B0i6FuVHXmiOcLepMGARdjYn/rKTc5HtOpZdGeJ uhqdCOMs4gaNmUEQamHIfcSs2nnyQQH4d3keOfp6M+DWyMf0bQ7+Y5NQA4fDYIkUI7BQ78 51IWzyvhzdS9nuHKBrAFmVK3/jYxRmc= X-MC-Unique: KqN4NT5-MLy10APPfcpYYA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 01/11] virDomainInputDefParseXML: Move validation into validator Date: Mon, 24 Jan 2022 11:07:23 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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: 1643018886849100001 Content-Type: text/plain; charset="utf-8" There is some code that validates whether parsed @bus makes sense (e.g. some hypervisors have their own type of bus). But this code should not live in the parser, but validator rather. That way, we can also validate that the value we compute (if user didn't provide any) is valid. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 56 ------------------------------- src/conf/domain_validate.c | 67 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 65 insertions(+), 58 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b39136119f..73c6ac6a88 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11856,62 +11856,6 @@ virDomainInputDefParseXML(virDomainXMLOption *xmlo= pt, goto error; } =20 - if (dom->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM) { - if (def->bus =3D=3D VIR_DOMAIN_INPUT_BUS_PS2 && - def->type !=3D VIR_DOMAIN_INPUT_TYPE_MOUSE && - def->type !=3D VIR_DOMAIN_INPUT_TYPE_KBD) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("ps2 bus does not support %s input device= "), - type); - goto error; - } - if (def->bus =3D=3D VIR_DOMAIN_INPUT_BUS_XEN) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unsupported input bus %s"), - bus); - goto error; - } - } else if (dom->os.type =3D=3D VIR_DOMAIN_OSTYPE_XEN || - dom->os.type =3D=3D VIR_DOMAIN_OSTYPE_XENPVH) { - if (def->bus !=3D VIR_DOMAIN_INPUT_BUS_XEN) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unsupported input bus %s"), - bus); - goto error; - } - if (def->type !=3D VIR_DOMAIN_INPUT_TYPE_MOUSE && - def->type !=3D VIR_DOMAIN_INPUT_TYPE_KBD) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("xen bus does not support %s input device= "), - type); - goto error; - } - } else { - if (dom->virtType =3D=3D VIR_DOMAIN_VIRT_VZ || - dom->virtType =3D=3D VIR_DOMAIN_VIRT_PARALLELS) { - if (def->bus !=3D VIR_DOMAIN_INPUT_BUS_PARALLELS) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("parallels containers don't support " - "input bus %s"), - bus); - goto error; - } - - if (def->type !=3D VIR_DOMAIN_INPUT_TYPE_MOUSE && - def->type !=3D VIR_DOMAIN_INPUT_TYPE_KBD) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("parallels bus does not support " - "%s input device"), - type); - goto error; - } - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Input devices are not supported by this " - "virtualization driver.")); - goto error; - } - } } else { if (dom->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM) { if ((def->type =3D=3D VIR_DOMAIN_INPUT_TYPE_MOUSE || diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index e9baf1d41a..e443a17b0e 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -2112,8 +2112,71 @@ virDomainVsockDefValidate(const virDomainVsockDef *v= sock) =20 =20 static int -virDomainInputDefValidate(const virDomainInputDef *input) +virDomainInputDefValidate(const virDomainInputDef *input, + const virDomainDef *def) { + switch (def->os.type) { + case VIR_DOMAIN_OSTYPE_HVM: + if (input->bus =3D=3D VIR_DOMAIN_INPUT_BUS_PS2 && + input->type !=3D VIR_DOMAIN_INPUT_TYPE_MOUSE && + input->type !=3D VIR_DOMAIN_INPUT_TYPE_KBD) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("ps2 bus does not support %s input device"), + virDomainInputTypeToString(input->type)); + return -1; + } + if (input->bus =3D=3D VIR_DOMAIN_INPUT_BUS_XEN) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unsupported input bus %s"), + virDomainInputBusTypeToString(input->bus)); + return -1; + } + break; + + case VIR_DOMAIN_OSTYPE_XEN: + case VIR_DOMAIN_OSTYPE_XENPVH: + if (input->bus !=3D VIR_DOMAIN_INPUT_BUS_XEN) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unsupported input bus %s"), + virDomainInputBusTypeToString(input->bus)); + return -1; + } + if (input->type !=3D VIR_DOMAIN_INPUT_TYPE_MOUSE && + input->type !=3D VIR_DOMAIN_INPUT_TYPE_KBD) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("xen bus does not support %s input device"), + virDomainInputTypeToString(input->type)); + return -1; + } + break; + + default: + if (def->virtType =3D=3D VIR_DOMAIN_VIRT_VZ || + def->virtType =3D=3D VIR_DOMAIN_VIRT_PARALLELS) { + if (input->bus !=3D VIR_DOMAIN_INPUT_BUS_PARALLELS) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("parallels containers don't support " + "input bus %s"), + virDomainInputBusTypeToString(input->bus)); + return -1; + } + + if (input->type !=3D VIR_DOMAIN_INPUT_TYPE_MOUSE && + input->type !=3D VIR_DOMAIN_INPUT_TYPE_KBD) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("parallels bus does not support " + "%s input device"), + virDomainInputTypeToString(input->type)); + return -1; + } + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Input devices are not supported by this " + "virtualization driver.")); + return -1; + } + } + switch ((virDomainInputType) input->type) { case VIR_DOMAIN_INPUT_TYPE_MOUSE: case VIR_DOMAIN_INPUT_TYPE_TABLET: @@ -2296,7 +2359,7 @@ virDomainDeviceDefValidateInternal(const virDomainDev= iceDef *dev, return virDomainVsockDefValidate(dev->data.vsock); =20 case VIR_DOMAIN_DEVICE_INPUT: - return virDomainInputDefValidate(dev->data.input); + return virDomainInputDefValidate(dev->data.input, def); =20 case VIR_DOMAIN_DEVICE_SHMEM: return virDomainShmemDefValidate(dev->data.shmem); --=20 2.34.1 From nobody Mon Apr 29 13:11:19 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=1643018898; cv=none; d=zohomail.com; s=zohoarc; b=BoH80nblrO2kfe1LeS6znCqdbhjU2bbGFbr6hPtKwXXNyJynpwo9pv0IixrSu90b7twSsnjWqbpar88jUrit90vtbiP90HYlHfEzb426hNe+tnDVkaqQPupRA9uPtWZxdqpz3hg27q+fywXU3g5Yxq2t0eS8g2g9pBFCTTeKocE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643018898; 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=k5oMl9Oo/Gz0dR7bM2vIw/GubfvzoAY3tLW7mG7Gl2M=; b=TmO61Bn2mu/bFVNWyM6TTx40k6IG6BQc+k0JAJNLUmuN7RgOB+8gRwBSeBqOJu0TtkBBXaGOgpwaUfwXMzMSKf1kkE1SD1DnCcu8szp66oj4KguH88xtDWViG0pjto6/d9exWRN1BKOKvY54j5iu+qyuc9wO4Bav9pyMnDexsx4= 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 1643018898801937.4390224106525; Mon, 24 Jan 2022 02:08:18 -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-661-Q0vZWQm3OdmM9SH7NZsgZQ-1; Mon, 24 Jan 2022 05:08:14 -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 AB85B51081; Mon, 24 Jan 2022 10:08:09 +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 8322F73171; Mon, 24 Jan 2022 10:08:09 +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 EC2FE1809CB8; Mon, 24 Jan 2022 10:08:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20OA7lTb021063 for ; Mon, 24 Jan 2022 05:07:47 -0500 Received: by smtp.corp.redhat.com (Postfix) id 828B46F119; Mon, 24 Jan 2022 10:07:47 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA9066D03D for ; Mon, 24 Jan 2022 10:07:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643018898; 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=k5oMl9Oo/Gz0dR7bM2vIw/GubfvzoAY3tLW7mG7Gl2M=; b=WHj7WKNA2+xmdLEfsDlOvswMl2MsCOf9uQKydxQmEc0pMtod8x4UB01dpdjP6HDqo2+QlC FC4P5q2QgnZLPSBsZqiWTYDGXSZtt+Zkdo/rEUtZDItVv0gy2qifAQLwlss1WBoP9yLvB0 sXs5QodJYgb2G8Uu0yRiHJcbZGE84Qg= X-MC-Unique: Q0vZWQm3OdmM9SH7NZsgZQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 02/11] virDomainChrSourceDefCopy: Copy more struct members Date: Mon, 24 Jan 2022 11:07:24 +0100 Message-Id: <0791f09c3dcfb5a131ec98f1e3b3fdffe150ad54.1643018556.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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: 1643018901482100001 Content-Type: text/plain; charset="utf-8" The aim of virDomainChrSourceDefCopy() is to make a deep copy of given virDomainChrSourceDef. However, some types were not copied at all (VIR_DOMAIN_CHR_TYPE_SPICEVMC and VIR_DOMAIN_CHR_TYPE_SPICEPORT) and some members weren't copied either (@logfile, @logappend). After this, there are still some members that are not copied (seclabels and private data), but the sole caller qemuProcessFindCharDevicePTYsMonitor() doesn't seem to care. Therefore, just document this behavior so that future user is aware. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 73c6ac6a88..5387cd271a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2731,8 +2731,9 @@ virDomainChrSourceDefClear(virDomainChrSourceDef *def) VIR_FREE(def->logfile); } =20 -/* Deep copies the contents of src into dest. Return -1 and report - * error on failure. */ +/* Almost deep copies the contents of src into dest. Some parts are not co= pied + * though. + * Returns -1 and report error on failure. */ int virDomainChrSourceDefCopy(virDomainChrSourceDef *dest, virDomainChrSourceDef *src) @@ -2742,7 +2743,11 @@ virDomainChrSourceDefCopy(virDomainChrSourceDef *des= t, =20 virDomainChrSourceDefClear(dest); =20 - switch (src->type) { + dest->type =3D src->type; + dest->logfile =3D g_strdup(src->logfile); + dest->logappend =3D src->logappend; + + switch ((virDomainChrType)src->type) { case VIR_DOMAIN_CHR_TYPE_FILE: case VIR_DOMAIN_CHR_TYPE_PTY: case VIR_DOMAIN_CHR_TYPE_DEV: @@ -2782,10 +2787,22 @@ virDomainChrSourceDefCopy(virDomainChrSourceDef *de= st, dest->data.nmdm.slave =3D g_strdup(src->data.nmdm.slave); =20 break; + + case VIR_DOMAIN_CHR_TYPE_SPICEVMC: + dest->data.spicevmc =3D src->data.spicevmc; + break; + + case VIR_DOMAIN_CHR_TYPE_SPICEPORT: + dest->data.spiceport.channel =3D g_strdup(src->data.spiceport.chan= nel); + break; + + case VIR_DOMAIN_CHR_TYPE_NULL: + case VIR_DOMAIN_CHR_TYPE_VC: + case VIR_DOMAIN_CHR_TYPE_STDIO: + case VIR_DOMAIN_CHR_TYPE_LAST: + break; } =20 - dest->type =3D src->type; - return 0; } =20 --=20 2.34.1 From nobody Mon Apr 29 13:11:19 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=1643018909; cv=none; d=zohomail.com; s=zohoarc; b=cdA5ZJQ7CjMZTUL6Xd6sqkRkjvfEezHOg/gTU9fzXYejP1LDcg5V8pRfA+VP0rWRYWNyQrb+UkpAmY/ysTWhLVPRRWaQxYGRQ0vn7fQlA7PXB3jP6etKz2KUQ3yDd4QvxhT5mzV0CxaDSREuNckABZzGitVcE/fmqKFF0mIvE8c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643018909; 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=1/keO1E8qPvWs0f1uKn9Nv5oMpJBOYaUDwqHJvFN6Lw=; b=RMdGNNgFnza+pV5THqROZlp86dciRxfQjV8QCFCRRw+dblf4xAKHsssRsy+LGwGU0ioTcnfENCdAPz/D6fe6zkrpBoaWL1qkRUyBt2mEMUdwpFtukv4c/v6xpVrXb8TwCf5XbwJqGwFtxk63RSQD08FD7fg5yWGTYj3Z+f/+4xQ= 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 1643018909960868.4062291667467; Mon, 24 Jan 2022 02:08:29 -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-614-rtKCpEfoNJWmLbgxLuyd0w-1; Mon, 24 Jan 2022 05:08:18 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2BD731091DA1; Mon, 24 Jan 2022 10:08:13 +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 0E2F260C45; Mon, 24 Jan 2022 10:08:13 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D46104CA9B; Mon, 24 Jan 2022 10:08:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20OA7tkL021081 for ; Mon, 24 Jan 2022 05:07:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id DA4456D03D; Mon, 24 Jan 2022 10:07:55 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4CAEC6F120 for ; Mon, 24 Jan 2022 10:07:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643018909; 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=1/keO1E8qPvWs0f1uKn9Nv5oMpJBOYaUDwqHJvFN6Lw=; b=fHgQiEji3sG6eewVZz4u+VtSxgr88wS9l5PejomtK5br0I1WWHxgX0q3UJ7sLeqNUy/p+a /UpWNWTVwvwKlxaWRydcwuvfZh2II1SKHHg6fNNVbIt+urHj09RiME0wQkvj/M+TY2KUTF rNp2HvZHErLtxQ5S/XRd1iIOTK3os3A= X-MC-Unique: rtKCpEfoNJWmLbgxLuyd0w-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 03/11] virDomainChrSourceDefCopy: Don't check arguments against NULL Date: Mon, 24 Jan 2022 11:07:25 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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: 1643018911910100003 Content-Type: text/plain; charset="utf-8" The only caller of this function (qemuProcessFindCharDevicePTYsMonitor()) doesn't pass NULL. Remove corresponding check from virDomainChrSourceDefCopy(). Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 3 --- src/conf/domain_conf.h | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5387cd271a..e4abe1854f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2738,9 +2738,6 @@ int virDomainChrSourceDefCopy(virDomainChrSourceDef *dest, virDomainChrSourceDef *src) { - if (!dest || !src) - return -1; - virDomainChrSourceDefClear(dest); =20 dest->type =3D src->type; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 3e63d2513b..9bf54eee48 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3348,7 +3348,8 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainSmartcardDef, = virDomainSmartcardDefFree); void virDomainChrDefFree(virDomainChrDef *def); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainChrDef, virDomainChrDefFree); int virDomainChrSourceDefCopy(virDomainChrSourceDef *dest, - virDomainChrSourceDef *src); + virDomainChrSourceDef *src) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); void virDomainSoundCodecDefFree(virDomainSoundCodecDef *def); ssize_t virDomainSoundDefFind(const virDomainDef *def, const virDomainSoundDef *sound); --=20 2.34.1 From nobody Mon Apr 29 13:11:19 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=1643019004; cv=none; d=zohomail.com; s=zohoarc; b=JRiGtGDmyAmWnZdjGG2SRIWMRzpaAgJEoUifuLYq7xjEUybdjKC6DfAGaaYK9zrNxeB56MSXnsv9aIA6U3clXpwEfv1JuW2xeEjcFOVlUYHWez+ApiBcJxWDbb1i5Ci0gE9bpo5dOUFT5R3IzCXC+uVVMyL9vqx/d/0q4vzbRjE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643019004; 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=dGYLxtAmf289Oq5DkclbJZ85zC6+gg9VC3DFWZ3tOlU=; b=IgQmEgpgipEcmJPTu+GxzLky79hSbZ8/f7AMJsTdpgCkBH8yscVT0pbZhxzYY8/I/arjLpoCEXQeCDf5/YdQ0Rp0r9MYyyZBnxSRx9iHpUdTKdkIN4thtNF+SkUH3C8a6jks1NA0Afm4x7ItJRleeGLjUEiosi6llt1H/xLpU8M= 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 1643019004011818.8775923620718; Mon, 24 Jan 2022 02:10: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-451-2UYUSqrDOWeppcEZEZ-lSQ-1; Mon, 24 Jan 2022 05:09:59 -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 941381083F69; Mon, 24 Jan 2022 10:09:53 +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 764987B9F4; Mon, 24 Jan 2022 10:09:53 +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 46B581806D1D; Mon, 24 Jan 2022 10:09:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20OA7up6021089 for ; Mon, 24 Jan 2022 05:07:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id CDB366F120; Mon, 24 Jan 2022 10:07:56 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 41EFC6D03D for ; Mon, 24 Jan 2022 10:07:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643019003; 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=dGYLxtAmf289Oq5DkclbJZ85zC6+gg9VC3DFWZ3tOlU=; b=ZUPhL3PzV1mGef5bOYQ788wgArE29HPFecDzg3tha+MD4rVUD4y7QfAO9zBAyOGIHWu/5q b/EC+mWedo/A8nrw/7yggbcsaHTPjMr1nHmn4fkxyhAiTyXivJQGA8JRI085nOk4EbEWxV +YbkfH0LJeLXwuepS8/Z7bxjtCZYl0U= X-MC-Unique: 2UYUSqrDOWeppcEZEZ-lSQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 04/11] virDomainChrSourceDefCopy: return void Date: Mon, 24 Jan 2022 11:07:26 +0100 Message-Id: <4efee5a80b0f59514ceaa7917c77dd98986e070f.1643018556.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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: 1643019009729100003 Content-Type: text/plain; charset="utf-8" This function never returns an error, make it void then. And while at it, make the @src argument const to make it obvious it's never changed inside the function. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 9 +++------ src/conf/domain_conf.h | 4 ++-- src/qemu/qemu_process.c | 5 ++--- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e4abe1854f..bb887d4a3b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2732,11 +2732,10 @@ virDomainChrSourceDefClear(virDomainChrSourceDef *d= ef) } =20 /* Almost deep copies the contents of src into dest. Some parts are not co= pied - * though. - * Returns -1 and report error on failure. */ -int + * though. */ +void virDomainChrSourceDefCopy(virDomainChrSourceDef *dest, - virDomainChrSourceDef *src) + const virDomainChrSourceDef *src) { virDomainChrSourceDefClear(dest); =20 @@ -2799,8 +2798,6 @@ virDomainChrSourceDefCopy(virDomainChrSourceDef *dest, case VIR_DOMAIN_CHR_TYPE_LAST: break; } - - return 0; } =20 static void diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 9bf54eee48..764e025448 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3347,8 +3347,8 @@ void virDomainSmartcardDefFree(virDomainSmartcardDef = *def); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainSmartcardDef, virDomainSmartcardDef= Free); void virDomainChrDefFree(virDomainChrDef *def); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainChrDef, virDomainChrDefFree); -int virDomainChrSourceDefCopy(virDomainChrSourceDef *dest, - virDomainChrSourceDef *src) +void virDomainChrSourceDefCopy(virDomainChrSourceDef *dest, + const virDomainChrSourceDef *src) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); void virDomainSoundCodecDefFree(virDomainSoundCodecDef *def); ssize_t virDomainSoundDefFind(const virDomainDef *def, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 336f0bab2e..c9ceec4e19 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -2129,9 +2129,8 @@ qemuProcessFindCharDevicePTYsMonitor(virDomainObj *vm, chr->targetType =3D=3D VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERI= AL) { /* yes, the first console is just an alias for serials[0] */ i =3D 1; - if (virDomainChrSourceDefCopy(chr->source, - ((vm->def->serials[0])->source))= < 0) - return -1; + virDomainChrSourceDefCopy(chr->source, + ((vm->def->serials[0])->source)); } } =20 --=20 2.34.1 From nobody Mon Apr 29 13:11:19 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=1643018955; cv=none; d=zohomail.com; s=zohoarc; b=mt0Y/rIPYpWvNAhae59EKjAFa8n+N+ITXNt2a5eojijZhWG09Ek/1huki31TEk4EFIa6s4MiwCiBsKcoKq3UNHIb2GbnVsay+On2MZ3A5jRZJM6Mb9xzY0yWnyDJ3MuD7jbWYe0Q9EX/akiXAKRNHSn5Mte9PBeC1jCG41DKzeY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643018955; 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=znYDeMNs68cBZYSQl3CkJWmxHCBJIGFGZWaSX1AiMW8=; b=T/Kjyrd2+0QXbgI7rQuQ71f1fSyKRS+p4Ff64OXSHwf9tUOWE/S5ocftFQ5ib/WyfjuizD9+k75c1sbqHbXwL0+QZZaBdWNWv6qxBhFm7PVhyV+n+d5eeXlg7JL/akQiyNXBWDbqHlHDwtRkvY75YtX8WYJcl5L7EcXdBQ3R+Dk= 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 1643018955192344.0365825390844; Mon, 24 Jan 2022 02:09:15 -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-424-SKfcDSYnPAuZVjvmoW1K5w-1; Mon, 24 Jan 2022 05:09:12 -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 92591192CC47; Mon, 24 Jan 2022 10:09:07 +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 7073510595B9; Mon, 24 Jan 2022 10:09:07 +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 4086F180B617; Mon, 24 Jan 2022 10:09:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20OA7vWx021096 for ; Mon, 24 Jan 2022 05:07:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id C33BF6F120; Mon, 24 Jan 2022 10:07:57 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 361306D03D for ; Mon, 24 Jan 2022 10:07:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643018954; 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=znYDeMNs68cBZYSQl3CkJWmxHCBJIGFGZWaSX1AiMW8=; b=h0pRfdL32DzlB84X8q+ealOpe3t9VeJnaT8oCtBRUq7HKP025uxePIEBW5szHFakNBheCT 8ppfoCq6exrMaS2MqHAeFGGEZcRuYaJhGV/hm2924nkobtsOUvy59WHt756iw55eVRuJyI 6dvHDQs4TkKjotgdVy7vKktxDtRmJq0= X-MC-Unique: SKfcDSYnPAuZVjvmoW1K5w-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 05/11] conf: Fix type of @present in _virDomainTimerDef struct Date: Mon, 24 Jan 2022 11:07:27 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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: 1643018958307100001 Content-Type: text/plain; charset="utf-8" In the _virDomainTimerDef structure we have @present member which is like virTristateBool, except it's an integer and has values shifted by one. This is harder to read. Retype the member to virTristateBool which we are familiar with. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 27 ++++++++++----------------- src/conf/domain_conf.h | 2 +- src/libxl/libxl_conf.c | 2 +- src/libxl/xen_common.c | 13 +++++++++---- src/lxc/lxc_cgroup.c | 2 +- src/lxc/lxc_controller.c | 2 +- src/qemu/qemu_command.c | 20 ++++++++++---------- src/qemu/qemu_validate.c | 6 +++--- 8 files changed, 36 insertions(+), 38 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index bb887d4a3b..fbe21c4fd2 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11998,7 +11998,6 @@ virDomainTimerDefParseXML(xmlNodePtr node, xmlNodePtr catchup; int ret; g_autofree char *name =3D NULL; - g_autofree char *present =3D NULL; g_autofree char *tickpolicy =3D NULL; g_autofree char *track =3D NULL; g_autofree char *mode =3D NULL; @@ -12019,16 +12018,10 @@ virDomainTimerDefParseXML(xmlNodePtr node, goto error; } =20 - def->present =3D -1; /* unspecified */ - if ((present =3D virXMLPropString(node, "present")) !=3D NULL) { - bool state =3D false; - if (virStringParseYesNo(present, &state) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown timer present value '%s'"), present); - goto error; - } - def->present =3D state ? 1 : 0; - } + if (virXMLPropTristateBool(node, "present", + VIR_XML_PROP_NONE, + &def->present) < 0) + goto error; =20 def->tickpolicy =3D -1; tickpolicy =3D virXMLPropString(node, "tickpolicy"); @@ -20481,8 +20474,9 @@ virDomainTimerDefCheckABIStability(virDomainTimerDe= f *src, =20 if (src->present !=3D dst->present) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target timer presence %d does not match source %= d"), - dst->present, src->present); + _("Target timer presence %s does not match source %= s"), + virTristateBoolTypeToString(dst->present), + virTristateBoolTypeToString(src->present)); return false; } =20 @@ -26119,10 +26113,9 @@ virDomainTimerDefFormat(virBuffer *buf, } virBufferAsprintf(buf, "present =3D=3D 0) { - virBufferAddLit(buf, " present=3D'no'"); - } else if (def->present =3D=3D 1) { - virBufferAddLit(buf, " present=3D'yes'"); + if (def->present) { + virBufferAsprintf(buf, " present=3D'%s'", + virTristateBoolTypeToString(def->present)); } =20 if (def->tickpolicy !=3D -1) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 764e025448..f995cbc045 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2409,7 +2409,7 @@ struct _virDomainTimerCatchupDef { =20 struct _virDomainTimerDef { int name; - int present; /* unspecified =3D -1, no =3D 0, yes =3D 1 */ + virTristateBool present; int tickpolicy; /* none|catchup|merge|discard */ =20 virDomainTimerCatchupDef catchup; diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 561171126c..5d87b999f2 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -423,7 +423,7 @@ libxlMakeDomBuildInfo(virDomainDef *def, virDomainTimerNameTypeToString(clock.timers= [i]->name)); return -1; } - if (clock.timers[i]->present =3D=3D 1) + if (clock.timers[i]->present =3D=3D VIR_TRISTATE_BOOL_YES) libxl_defbool_set(&b_info->u.hvm.hpet, 1); break; =20 diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index c3fa98b71d..0679f441cc 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -553,7 +553,7 @@ xenParseHypervisorFeatures(virConf *conf, virDomainDef = *def) =20 timer =3D g_new0(virDomainTimerDef, 1); timer->name =3D VIR_DOMAIN_TIMER_NAME_TSC; - timer->present =3D 1; + timer->present =3D VIR_TRISTATE_BOOL_YES; timer->tickpolicy =3D -1; timer->mode =3D VIR_DOMAIN_TIMER_MODE_AUTO; timer->track =3D -1; @@ -625,7 +625,11 @@ xenParseHypervisorFeatures(virConf *conf, virDomainDef= *def) =20 timer =3D g_new0(virDomainTimerDef, 1); timer->name =3D VIR_DOMAIN_TIMER_NAME_HPET; - timer->present =3D val; + if (val =3D=3D 1) { + timer->present =3D VIR_TRISTATE_BOOL_YES; + } else { + timer->present =3D VIR_TRISTATE_BOOL_NO; + } timer->tickpolicy =3D -1; timer->mode =3D -1; timer->track =3D -1; @@ -2112,9 +2116,10 @@ xenFormatHypervisorFeatures(virConf *conf, virDomain= Def *def) =20 case VIR_DOMAIN_TIMER_NAME_HPET: if (hvm) { - int enable_hpet =3D def->clock.timers[i]->present !=3D 0; + int enable_hpet =3D def->clock.timers[i]->present !=3D VIR= _TRISTATE_BOOL_NO; =20 - /* disable hpet if 'present' is 0, enable otherwise */ + /* disable hpet if 'present' is VIR_TRISTATE_BOOL_NO, enab= le + * otherwise */ if (xenConfigSetInt(conf, "hpet", enable_hpet) < 0) return -1; } else { diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c index 736b2000ff..d31fff5f98 100644 --- a/src/lxc/lxc_cgroup.c +++ b/src/lxc/lxc_cgroup.c @@ -332,7 +332,7 @@ static int virLXCCgroupSetupDeviceACL(virDomainDef *def, const char *dev =3D NULL; =20 /* Check if "present" is set to "no" otherwise enable it. */ - if (!timer->present) + if (timer->present =3D=3D VIR_TRISTATE_BOOL_NO) continue; =20 switch ((virDomainTimerNameType)timer->name) { diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 3c930eaacd..c4e3b66751 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -1510,7 +1510,7 @@ virLXCControllerSetupTimers(virLXCController *ctrl) dev_t dev; =20 /* Check if "present" is set to "no" otherwise enable it. */ - if (!timer->present) + if (timer->present =3D=3D VIR_TRISTATE_BOOL_NO) continue; =20 switch ((virDomainTimerNameType)timer->name) { diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 52ea148a0f..a62d3f36ae 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6293,15 +6293,14 @@ qemuBuildClockCommandLine(virCommand *cmd, break; =20 case VIR_DOMAIN_TIMER_NAME_HPET: - /* the only meaningful attribute for hpet is "present". If - * present is -1, that means it wasn't specified, and - * should be left at the default for the - * hypervisor. "default" when -no-hpet exists is "yes", - * and when -no-hpet doesn't exist is "no". "confusing"? - * "yes"! */ + /* the only meaningful attribute for hpet is "present". If pre= sent + * is VIR_TRISTATE_BOOL_ABSENT, that means it wasn't specified= , and + * should be left at the default for the hypervisor. "default"= when + * -no-hpet exists is VIR_TRISTATE_BOOL_YES, and when -no-hpet + * doesn't exist is VIR_TRISTATE_BOOL_NO. "confusing"? "yes"= ! */ =20 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NO_HPET)) { - if (def->clock.timers[i]->present =3D=3D 0) + if (def->clock.timers[i]->present =3D=3D VIR_TRISTATE_BOOL= _NO) virCommandAddArg(cmd, "-no-hpet"); } break; @@ -6638,13 +6637,14 @@ qemuBuildCpuCommandLine(virCommand *cmd, =20 switch ((virDomainTimerNameType)timer->name) { case VIR_DOMAIN_TIMER_NAME_KVMCLOCK: - if (timer->present !=3D -1) { + if (timer->present !=3D VIR_TRISTATE_BOOL_ABSENT) { + /* QEMU expects on/off -> virTristateSwitch. */ virBufferAsprintf(&buf, ",kvmclock=3D%s", - timer->present ? "on" : "off"); + virTristateSwitchTypeToString(timer->pre= sent)); } break; case VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK: - if (timer->present =3D=3D 1) + if (timer->present =3D=3D VIR_TRISTATE_BOOL_YES) virBufferAddLit(&buf, ",hv-time=3Don"); break; case VIR_DOMAIN_TIMER_NAME_TSC: diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 0a879f0115..b62e49a5bc 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -411,7 +411,7 @@ qemuValidateDomainDefClockTimers(const virDomainDef *de= f, case VIR_DOMAIN_TIMER_NAME_TSC: case VIR_DOMAIN_TIMER_NAME_KVMCLOCK: case VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK: - if (!ARCH_IS_X86(def->os.arch) && timer->present =3D=3D 1) { + if (!ARCH_IS_X86(def->os.arch) && timer->present =3D=3D VIR_TR= ISTATE_BOOL_YES) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Configuring the '%s' timer is not suppor= ted " "for virtType=3D%s arch=3D%s machine=3D%s= guests"), @@ -489,7 +489,7 @@ qemuValidateDomainDefClockTimers(const virDomainDef *de= f, /* no hpet timer available. The only possible action is to raise an error if present=3D"yes" */ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_NO_HPET) && - timer->present =3D=3D 1) { + timer->present =3D=3D VIR_TRISTATE_BOOL_YES) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("hpet timer is not supported")); return -1; @@ -508,7 +508,7 @@ qemuValidateDomainDefClockTimers(const virDomainDef *de= f, def->os.machine); return -1; } - if (timer->present =3D=3D 0) { + if (timer->present =3D=3D VIR_TRISTATE_BOOL_NO) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("The '%s' timer can't be disabled"), virDomainTimerNameTypeToString(timer->name)= ); --=20 2.34.1 From nobody Mon Apr 29 13:11:19 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=1643018957; cv=none; d=zohomail.com; s=zohoarc; b=cF+xQgfrXgQbtNzw+ZZ6axdOfOPpS5Tj7I6lJRm3j8aRq60loI8jI/YggXrJrMe6taulOzGkLq55YHL4slPnQiB8qlCxpWQZUkiFJvdjUFRI7aMcx+Xkmt8+6X6RUo+101RzpsQZXuIutaOH0AY7omgHfXF1JoXcOjTKsidFRhs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643018957; 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=rWuZUEyww6H35x8o74eMJntwbv3SAYfJ8hHg1th05FI=; b=Csm1AQIHw/oCUSlQ/ZuEaSuMwnhivQkVKMO3jz0ecAwWNOEjuKSOUUap3yQcJNgctWgcQs0pLtHRdwnEcxCnwT2S3be4jSbLqnnrPprMSc/vltxPsMOJ6yyjy2G51oo8NQBGCH2bF8/agC+zwyW/FE1TZGwxt0Y00cCjt+xrU/c= 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 1643018957554738.5148190144793; Mon, 24 Jan 2022 02:09:17 -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-300-49kCG9wENQSoEAwaqeWg2w-1; Mon, 24 Jan 2022 05:09:15 -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 807681091DAD; Mon, 24 Jan 2022 10:09:10 +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 6076660C4F; Mon, 24 Jan 2022 10:09:10 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 318E94A7C9; Mon, 24 Jan 2022 10:09:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20OA8Bxa021125 for ; Mon, 24 Jan 2022 05:08:11 -0500 Received: by smtp.corp.redhat.com (Postfix) id C5D1C6F12B; Mon, 24 Jan 2022 10:08:11 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 390416F125 for ; Mon, 24 Jan 2022 10:07:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643018956; 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=rWuZUEyww6H35x8o74eMJntwbv3SAYfJ8hHg1th05FI=; b=SXOGhI8oBkgooo9E8zL/EqlK+kgdhon5tVnRJxdl930Bs5K9moG+oBucSIkymJi0zilo1E PNUANG7ouLqCHFuhLixKH7yUlzsIHH13ctA3nWSGLJu/HGkXVOTfYrrqza9LiD+AqLUK5M nGEk6DdFH2rwwGZy0js5UtDsuyRhTJc= X-MC-Unique: 49kCG9wENQSoEAwaqeWg2w-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 06/11] conf: Fix @tickpolicy member of _virDomainTimerDef struct Date: Mon, 24 Jan 2022 11:07:28 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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: 1643018959532100003 Content-Type: text/plain; charset="utf-8" The @tickpolicy member of the _virDomainTimerDef struct stores values of the virDomainTimerTickpolicyType enum, or -1 for the default value (when user provided no value in XML). This is needlessly complicated. Introduce new value to the enum which reflects the default state. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 19 ++++++------------- src/conf/domain_conf.h | 5 +++-- src/libxl/xen_common.c | 4 ++-- src/qemu/qemu_command.c | 6 +++--- src/qemu/qemu_validate.c | 6 +++--- 5 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index fbe21c4fd2..ec12c6d8dd 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1196,6 +1196,7 @@ VIR_ENUM_IMPL(virDomainTimerTrack, =20 VIR_ENUM_IMPL(virDomainTimerTickpolicy, VIR_DOMAIN_TIMER_TICKPOLICY_LAST, + "none", "delay", "catchup", "merge", @@ -4970,7 +4971,7 @@ virDomainDefPostParseTimer(virDomainDef *def) =20 if (timer->name =3D=3D VIR_DOMAIN_TIMER_NAME_KVMCLOCK || timer->name =3D=3D VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK) { - if (timer->tickpolicy !=3D -1) { + if (timer->tickpolicy) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("timer %s doesn't support setting of " "timer tickpolicy"), @@ -12023,10 +12024,9 @@ virDomainTimerDefParseXML(xmlNodePtr node, &def->present) < 0) goto error; =20 - def->tickpolicy =3D -1; tickpolicy =3D virXMLPropString(node, "tickpolicy"); if (tickpolicy !=3D NULL) { - if ((def->tickpolicy =3D virDomainTimerTickpolicyTypeFromString(ti= ckpolicy)) < 0) { + if ((def->tickpolicy =3D virDomainTimerTickpolicyTypeFromString(ti= ckpolicy)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown timer tickpolicy '%s'"), tickpolicy); goto error; @@ -26118,16 +26118,9 @@ virDomainTimerDefFormat(virBuffer *buf, virTristateBoolTypeToString(def->present)); } =20 - if (def->tickpolicy !=3D -1) { - const char *tickpolicy - =3D virDomainTimerTickpolicyTypeToString(def->tickpolicy); - if (!tickpolicy) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected timer tickpolicy %d"), - def->tickpolicy); - return -1; - } - virBufferAsprintf(buf, " tickpolicy=3D'%s'", tickpolicy); + if (def->tickpolicy) { + virBufferAsprintf(buf, " tickpolicy=3D'%s'", + virDomainTimerTickpolicyTypeToString(def->tickpo= licy)); } =20 if ((def->name =3D=3D VIR_DOMAIN_TIMER_NAME_PLATFORM) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index f995cbc045..1ccc63706a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2371,7 +2371,8 @@ typedef enum { } virDomainTimerTrackType; =20 typedef enum { - VIR_DOMAIN_TIMER_TICKPOLICY_DELAY =3D 0, + VIR_DOMAIN_TIMER_TICKPOLICY_NONE =3D 0, + VIR_DOMAIN_TIMER_TICKPOLICY_DELAY, VIR_DOMAIN_TIMER_TICKPOLICY_CATCHUP, VIR_DOMAIN_TIMER_TICKPOLICY_MERGE, VIR_DOMAIN_TIMER_TICKPOLICY_DISCARD, @@ -2410,7 +2411,7 @@ struct _virDomainTimerCatchupDef { struct _virDomainTimerDef { int name; virTristateBool present; - int tickpolicy; /* none|catchup|merge|discard */ + int tickpolicy; /* enum virDomainTimerTickpolicyType */ =20 virDomainTimerCatchupDef catchup; =20 diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index 0679f441cc..4c8bf39ddc 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -554,7 +554,7 @@ xenParseHypervisorFeatures(virConf *conf, virDomainDef = *def) timer =3D g_new0(virDomainTimerDef, 1); timer->name =3D VIR_DOMAIN_TIMER_NAME_TSC; timer->present =3D VIR_TRISTATE_BOOL_YES; - timer->tickpolicy =3D -1; + timer->tickpolicy =3D VIR_DOMAIN_TIMER_TICKPOLICY_NONE; timer->mode =3D VIR_DOMAIN_TIMER_MODE_AUTO; timer->track =3D -1; if (STREQ_NULLABLE(tscmode, "always_emulate")) @@ -630,7 +630,7 @@ xenParseHypervisorFeatures(virConf *conf, virDomainDef = *def) } else { timer->present =3D VIR_TRISTATE_BOOL_NO; } - timer->tickpolicy =3D -1; + timer->tickpolicy =3D VIR_DOMAIN_TIMER_TICKPOLICY_NONE; timer->mode =3D -1; timer->track =3D -1; =20 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index a62d3f36ae..f0429532f8 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6206,7 +6206,7 @@ qemuBuildClockArgStr(virDomainClockDef *def) } =20 switch (def->timers[i]->tickpolicy) { - case -1: + case VIR_DOMAIN_TIMER_TICKPOLICY_NONE: case VIR_DOMAIN_TIMER_TICKPOLICY_DELAY: /* This is the default - missed ticks delivered when next scheduled, at normal rate */ @@ -6269,7 +6269,7 @@ qemuBuildClockCommandLine(virCommand *cmd, =20 case VIR_DOMAIN_TIMER_NAME_PIT: switch (def->clock.timers[i]->tickpolicy) { - case -1: + case VIR_DOMAIN_TIMER_TICKPOLICY_NONE: case VIR_DOMAIN_TIMER_TICKPOLICY_DELAY: /* delay is the default if we don't have kernel (kvm-pit), otherwise, the default is catchup. */ @@ -6659,7 +6659,7 @@ qemuBuildCpuCommandLine(virCommand *cmd, case VIR_DOMAIN_TIMER_TICKPOLICY_DISCARD: virBufferAddLit(&buf, ",kvm-no-adjvtime=3Don"); break; - case -1: + case VIR_DOMAIN_TIMER_TICKPOLICY_NONE: case VIR_DOMAIN_TIMER_TICKPOLICY_CATCHUP: case VIR_DOMAIN_TIMER_TICKPOLICY_MERGE: break; diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index b62e49a5bc..f52217497a 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -441,7 +441,7 @@ qemuValidateDomainDefClockTimers(const virDomainDef *de= f, } =20 switch (timer->tickpolicy) { - case -1: + case VIR_DOMAIN_TIMER_TICKPOLICY_NONE: case VIR_DOMAIN_TIMER_TICKPOLICY_DELAY: /* This is the default - missed ticks delivered when next scheduled, at normal rate */ @@ -461,7 +461,7 @@ qemuValidateDomainDefClockTimers(const virDomainDef *de= f, =20 case VIR_DOMAIN_TIMER_NAME_PIT: switch (timer->tickpolicy) { - case -1: + case VIR_DOMAIN_TIMER_TICKPOLICY_NONE: case VIR_DOMAIN_TIMER_TICKPOLICY_DELAY: case VIR_DOMAIN_TIMER_TICKPOLICY_DISCARD: break; @@ -523,7 +523,7 @@ qemuValidateDomainDefClockTimers(const virDomainDef *de= f, } =20 switch (timer->tickpolicy) { - case -1: + case VIR_DOMAIN_TIMER_TICKPOLICY_NONE: case VIR_DOMAIN_TIMER_TICKPOLICY_DELAY: case VIR_DOMAIN_TIMER_TICKPOLICY_DISCARD: break; --=20 2.34.1 From nobody Mon Apr 29 13:11:19 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=1643018909; cv=none; d=zohomail.com; s=zohoarc; b=m6PKQPOkyhSdNv+5CDXYqHIl+2hY8W/9m5vYVVqLtQDwaHh0lAKhERKEDYshCoEP3zFP3csPEkvIW2IyhVY9gY6Ak2DxTIbpWm8xlt4vGqWQm6qaURqIdUzWQd/1ZYe7Ko4kDEYYBuS5GfYdRYiIZj7Ln7HWdnjNR3r0SKesIh0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643018909; 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=GG2dtsOwz22AugOaaTbx+eJjskpWONIR9L2y0bqzIIU=; b=myCq3/T7dsTyfdXbwiqRoxKLwB8DKNUTopPH6n/oe1HbhGLlw8m79slkTrH2+4AM7P5dtSt2t6mk2EjGrQb+C/VEpnEc3jilyGc6I4FYHbe6+3Xt5wkci22y2gT+AhYXNs2FhGdYlifjSrjUnm2X/cTryD+ibmeVxap6MIcLg20= 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 1643018909694940.8576003978427; Mon, 24 Jan 2022 02:08:29 -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-588-vLESTgA_O4WgkJu1RssIXg-1; Mon, 24 Jan 2022 05:08:25 -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 8ED1085EE62; Mon, 24 Jan 2022 10:08: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 6ADFB73172; Mon, 24 Jan 2022 10:08: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 39C741809CBA; Mon, 24 Jan 2022 10:08:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20OA8IGl021159 for ; Mon, 24 Jan 2022 05:08:18 -0500 Received: by smtp.corp.redhat.com (Postfix) id 836146D03D; Mon, 24 Jan 2022 10:08:18 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA0EA6F948 for ; Mon, 24 Jan 2022 10:08:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643018909; 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=GG2dtsOwz22AugOaaTbx+eJjskpWONIR9L2y0bqzIIU=; b=fvHQ/QxiDXZWG0EZo2oM2clNe6x9jtpxD2Jl/RGUN08o74F3XxOJ8qw2Llx+eQVp5/KWuj 2K2h4zdVDqwkQQwFtr6hebKPnT5Ujk6Q5eaWvEDrHHEIeG6TtBpCqpbXbv+DhWarnJMCxe 1ZFdOOBJowgYrN1TCt4bIJzX5mT9LE8= X-MC-Unique: vLESTgA_O4WgkJu1RssIXg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 07/11] conf: Fix @track member of _virDomainTimerDef struct Date: Mon, 24 Jan 2022 11:07:29 +0100 Message-Id: <4504ddb3e1601ab61d2ae6240dcdd4143d35561a.1643018556.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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: 1643018911618100001 Content-Type: text/plain; charset="utf-8" The @track member of the _virDomainTimerDef struct stores values of the virDomainTimerTrackType enum, or -1 for the default value (when user provided no value in XML). This is needlessly complicated. Introduce new value to the enum which reflects the default state. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 22 ++++++---------------- src/conf/domain_conf.h | 5 +++-- src/libxl/xen_common.c | 4 ++-- src/qemu/qemu_command.c | 2 +- src/qemu/qemu_validate.c | 2 +- 5 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ec12c6d8dd..848efa30b8 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1188,6 +1188,7 @@ VIR_ENUM_IMPL(virDomainTimerName, =20 VIR_ENUM_IMPL(virDomainTimerTrack, VIR_DOMAIN_TIMER_TRACK_LAST, + "none", "boot", "guest", "wall", @@ -5010,7 +5011,7 @@ virDomainDefPostParseTimer(virDomainDef *def) =20 if (timer->name !=3D VIR_DOMAIN_TIMER_NAME_PLATFORM && timer->name !=3D VIR_DOMAIN_TIMER_NAME_RTC) { - if (timer->track !=3D -1) { + if (timer->track !=3D VIR_DOMAIN_TIMER_TRACK_NONE) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("timer %s doesn't support setting of " "timer track"), @@ -12033,10 +12034,9 @@ virDomainTimerDefParseXML(xmlNodePtr node, } } =20 - def->track =3D -1; track =3D virXMLPropString(node, "track"); if (track !=3D NULL) { - if ((def->track =3D virDomainTimerTrackTypeFromString(track)) < 0)= { + if ((def->track =3D virDomainTimerTrackTypeFromString(track)) <=3D= 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown timer track '%s'"), track); goto error; @@ -26123,19 +26123,9 @@ virDomainTimerDefFormat(virBuffer *buf, virDomainTimerTickpolicyTypeToString(def->tickpo= licy)); } =20 - if ((def->name =3D=3D VIR_DOMAIN_TIMER_NAME_PLATFORM) - || (def->name =3D=3D VIR_DOMAIN_TIMER_NAME_RTC)) { - if (def->track !=3D -1) { - const char *track - =3D virDomainTimerTrackTypeToString(def->track); - if (!track) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected timer track %d"), - def->track); - return -1; - } - virBufferAsprintf(buf, " track=3D'%s'", track); - } + if (def->track !=3D VIR_DOMAIN_TIMER_TRACK_NONE) { + virBufferAsprintf(buf, " track=3D'%s'", + virDomainTimerTrackTypeToString(def->track)); } =20 if (def->name =3D=3D VIR_DOMAIN_TIMER_NAME_TSC) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 1ccc63706a..17ebface32 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2362,7 +2362,8 @@ typedef enum { } virDomainTimerNameType; =20 typedef enum { - VIR_DOMAIN_TIMER_TRACK_BOOT =3D 0, + VIR_DOMAIN_TIMER_TRACK_NONE =3D 0, + VIR_DOMAIN_TIMER_TRACK_BOOT, VIR_DOMAIN_TIMER_TRACK_GUEST, VIR_DOMAIN_TIMER_TRACK_WALL, VIR_DOMAIN_TIMER_TRACK_REALTIME, @@ -2416,7 +2417,7 @@ struct _virDomainTimerDef { virDomainTimerCatchupDef catchup; =20 /* track is only valid for name=3D'platform|rtc' */ - int track; /* boot|guest|wall */ + int track; /* enum virDomainTimerTrackType */ =20 /* frequency & mode are only valid for name=3D'tsc' */ unsigned long long frequency; /* in Hz, unspecified =3D 0 */ diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index 4c8bf39ddc..78f3b78ac8 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -556,7 +556,7 @@ xenParseHypervisorFeatures(virConf *conf, virDomainDef = *def) timer->present =3D VIR_TRISTATE_BOOL_YES; timer->tickpolicy =3D VIR_DOMAIN_TIMER_TICKPOLICY_NONE; timer->mode =3D VIR_DOMAIN_TIMER_MODE_AUTO; - timer->track =3D -1; + timer->track =3D VIR_DOMAIN_TIMER_TRACK_NONE; if (STREQ_NULLABLE(tscmode, "always_emulate")) timer->mode =3D VIR_DOMAIN_TIMER_MODE_EMULATE; else if (STREQ_NULLABLE(tscmode, "native")) @@ -632,7 +632,7 @@ xenParseHypervisorFeatures(virConf *conf, virDomainDef = *def) } timer->tickpolicy =3D VIR_DOMAIN_TIMER_TICKPOLICY_NONE; timer->mode =3D -1; - timer->track =3D -1; + timer->track =3D VIR_DOMAIN_TIMER_TRACK_NONE; =20 def->clock.timers[def->clock.ntimers - 1] =3D timer; } diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f0429532f8..bd32921c04 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6190,7 +6190,7 @@ qemuBuildClockArgStr(virDomainClockDef *def) for (i =3D 0; i < def->ntimers; i++) { if (def->timers[i]->name =3D=3D VIR_DOMAIN_TIMER_NAME_RTC) { switch (def->timers[i]->track) { - case -1: /* unspecified - use hypervisor default */ + case VIR_DOMAIN_TIMER_TRACK_NONE: /* unspecified - use hypervi= sor default */ break; case VIR_DOMAIN_TIMER_TRACK_BOOT: return NULL; diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index f52217497a..3bf39f8d93 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -428,7 +428,7 @@ qemuValidateDomainDefClockTimers(const virDomainDef *de= f, =20 case VIR_DOMAIN_TIMER_NAME_RTC: switch (timer->track) { - case -1: /* unspecified - use hypervisor default */ + case VIR_DOMAIN_TIMER_TRACK_NONE: /* unspecified - use hypervi= sor default */ case VIR_DOMAIN_TIMER_TRACK_GUEST: case VIR_DOMAIN_TIMER_TRACK_WALL: case VIR_DOMAIN_TIMER_TRACK_REALTIME: --=20 2.34.1 From nobody Mon Apr 29 13:11:19 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=1643019006; cv=none; d=zohomail.com; s=zohoarc; b=OLB5HaEN/Zpky0EIDgZkp7A0njW8ySJDUIfI4FI4YyUwXRXUNvPtuGF8VGcUN0rFd0j4TUXUbliBvm7WMZOTCfwzY4z3x9HAQSMfRKyl3uWOMCPhPAmpRMfn9zy1t+cfZgppKaPz9cVW0lE8KEPOjZr0ljU3q54CJaY3jc7sGb0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643019006; 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=o88W377kwiJndX8IxT6p409YAu0SNvqlhq+XcoDCiq4=; b=fvJ/LnPrui34hdOO8rNVbgLHF94ZCKSfQGlxPli5dYVobO/pyrWq/zwX/nCpbfvSbiYuTVS9kKGSGgqactJC8e/pFZhJZoHmZytQ4yJdubivz/3OJvIGy3qYfr3lpgcj6elw/vkD9pfy/DncAh2T9kxy9dK1DztsWc4K3BEzCfA= 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 164301900604317.540665100724368; Mon, 24 Jan 2022 02:10: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-385--BbO0e15M4aozQzDEDZAjg-1; Mon, 24 Jan 2022 05:10:01 -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 A90451006ABE; Mon, 24 Jan 2022 10:09: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 30FC37D490; Mon, 24 Jan 2022 10:09:56 +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 DFC0A1806D2C; Mon, 24 Jan 2022 10:09:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20OA8OQw021185 for ; Mon, 24 Jan 2022 05:08:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id 872B26F94E; Mon, 24 Jan 2022 10:08:24 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id EDEED6F94C for ; Mon, 24 Jan 2022 10:08:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643019005; 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=o88W377kwiJndX8IxT6p409YAu0SNvqlhq+XcoDCiq4=; b=W0+bblMxP0dGLQFDaGehJz6fLe2Jt/Cxf1+AF6KXv/t5kI3OlvyuQINEIEmg+Agl0ysDGP lw7MvowsY8N7nmx22lRPJT4ZVKUPrJ3qMco068WXHofLq8L7n+UoSa8goK6WdkrlQ59njg ZQ2sEYuzGPZxjOwJ9iXkXlIYVZX1FSA= X-MC-Unique: -BbO0e15M4aozQzDEDZAjg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 08/11] conf: Fix @mode member of _virDomainTimerDef struct Date: Mon, 24 Jan 2022 11:07:30 +0100 Message-Id: <36f5e060e9525da46377094613c2f905f2f5b52e.1643018556.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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: 1643019012753100001 Content-Type: text/plain; charset="utf-8" The @mode member of the _virDomainTimerDef struct stores values of the virDomainTimerModeType enum, or -1 for the default value (when user provided no value in XML). This is needlessly complicated. Introduce new value to the enum which reflects the default state. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 19 ++++++------------- src/conf/domain_conf.h | 5 +++-- src/libxl/xen_common.c | 2 +- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 848efa30b8..c0851f4f60 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1206,6 +1206,7 @@ VIR_ENUM_IMPL(virDomainTimerTickpolicy, =20 VIR_ENUM_IMPL(virDomainTimerMode, VIR_DOMAIN_TIMER_MODE_LAST, + "none", "auto", "native", "emulate", @@ -5000,7 +5001,7 @@ virDomainDefPostParseTimer(virDomainDef *def) return -1; } =20 - if (timer->mode !=3D -1) { + if (timer->mode) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("timer %s doesn't support setting of " "timer mode"), @@ -12052,10 +12053,9 @@ virDomainTimerDefParseXML(xmlNodePtr node, goto error; } =20 - def->mode =3D -1; mode =3D virXMLPropString(node, "mode"); if (mode !=3D NULL) { - if ((def->mode =3D virDomainTimerModeTypeFromString(mode)) < 0) { + if ((def->mode =3D virDomainTimerModeTypeFromString(mode)) <=3D 0)= { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown timer mode '%s'"), mode); goto error; @@ -26132,16 +26132,9 @@ virDomainTimerDefFormat(virBuffer *buf, if (def->frequency > 0) virBufferAsprintf(buf, " frequency=3D'%llu'", def->frequency); =20 - if (def->mode !=3D -1) { - const char *mode - =3D virDomainTimerModeTypeToString(def->mode); - if (!mode) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected timer mode %d"), - def->mode); - return -1; - } - virBufferAsprintf(buf, " mode=3D'%s'", mode); + if (def->mode) { + virBufferAsprintf(buf, " mode=3D'%s'", + virDomainTimerModeTypeToString(def->mode)); } } =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 17ebface32..6291587ac4 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2382,7 +2382,8 @@ typedef enum { } virDomainTimerTickpolicyType; =20 typedef enum { - VIR_DOMAIN_TIMER_MODE_AUTO =3D 0, + VIR_DOMAIN_TIMER_MODE_NONE =3D 0, + VIR_DOMAIN_TIMER_MODE_AUTO, VIR_DOMAIN_TIMER_MODE_NATIVE, VIR_DOMAIN_TIMER_MODE_EMULATE, VIR_DOMAIN_TIMER_MODE_PARAVIRT, @@ -2421,7 +2422,7 @@ struct _virDomainTimerDef { =20 /* frequency & mode are only valid for name=3D'tsc' */ unsigned long long frequency; /* in Hz, unspecified =3D 0 */ - int mode; /* auto|native|emulate|paravirt */ + int mode; /* enum virDomainTimerModeType */ }; =20 typedef enum { diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index 78f3b78ac8..5a1fab857f 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -631,7 +631,7 @@ xenParseHypervisorFeatures(virConf *conf, virDomainDef = *def) timer->present =3D VIR_TRISTATE_BOOL_NO; } timer->tickpolicy =3D VIR_DOMAIN_TIMER_TICKPOLICY_NONE; - timer->mode =3D -1; + timer->mode =3D VIR_DOMAIN_TIMER_MODE_NONE; timer->track =3D VIR_DOMAIN_TIMER_TRACK_NONE; =20 def->clock.timers[def->clock.ntimers - 1] =3D timer; --=20 2.34.1 From nobody Mon Apr 29 13:11:19 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=1643018962; cv=none; d=zohomail.com; s=zohoarc; b=HXgNvXZFvyFijJAoO/K6WjsNHmVSDQw99Uhg7EjSikydcoOYjwGy1tUS30cF9OFI0L0c9yu7Sr4ns2jeDRv5r91bUPMucxmGzRMy8+IYjAlvklWb+j08eSjVafO4wHVExc+6gRZSsDREe7t0LKLTBf+jWcKZVA75alfMjhW95CU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643018962; 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=WpOqb9hiq5vCWP5csbTTt8S43pM8uGz0QyGoRAxdZ3w=; b=XGhdDx5YKSyhPX4ZCaAO+ztb8RoATBTZ0XrISkQtPLZ3XwjMb8IW8m59VFyl4+5TDLusj+mLOLOEiVRs8h5rBmAk0JiibU0IzvbtUhrh865LHanDTyb8BYPVWk8vh3sWcZRWclNI647EM0sWYSd4hklAQ2jjmKhk+Ds9ffYOHlM= 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 1643018962365694.6898799248085; Mon, 24 Jan 2022 02:09:22 -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-622-PhgZgJtRPf-ksbhMaMXb3A-1; Mon, 24 Jan 2022 05:09:18 -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 429CC1091DBA; Mon, 24 Jan 2022 10:09:13 +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 E70C41F420; Mon, 24 Jan 2022 10:09:12 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A803F4A7CB; Mon, 24 Jan 2022 10:09:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20OA8ra9021310 for ; Mon, 24 Jan 2022 05:08:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id A1CC76F119; Mon, 24 Jan 2022 10:08:53 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1324C6D03D for ; Mon, 24 Jan 2022 10:08:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643018961; 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=WpOqb9hiq5vCWP5csbTTt8S43pM8uGz0QyGoRAxdZ3w=; b=do40/yZ4gSbpWqjgLwfeWfMN93lz58wSj/75HD8Hyewn4Z3Ae0o/Crm86piEhboNNLAPyJ zwjvB/chWOEf0nIO4jd1ZbX2ZfLmaazewjs8DfNZZZLDkm/sWYMoU5x3AvvWxd7jNRDBOQ mPWEsP28qn9OTezN2cZoM9LAt3reyKI= X-MC-Unique: PhgZgJtRPf-ksbhMaMXb3A-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 09/11] conf: Rework virDomainTimerDefFormat() Date: Mon, 24 Jan 2022 11:07:31 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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: 1643018965408100001 Content-Type: text/plain; charset="utf-8" Use virXMLFormatElement() to simplify virDomainTimerDefFormat(). Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 48 +++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c0851f4f60..55626a6d01 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -26104,57 +26104,47 @@ static int virDomainTimerDefFormat(virBuffer *buf, virDomainTimerDef *def) { - const char *name =3D virDomainTimerNameTypeToString(def->name); + virBuffer timerAttr =3D VIR_BUFFER_INITIALIZER; + virBuffer timerChld =3D VIR_BUFFER_INIT_CHILD(buf); + virBuffer catchupAttr =3D VIR_BUFFER_INITIALIZER; =20 - if (!name) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected timer name %d"), def->name); - return -1; - } - virBufferAsprintf(buf, "name)); =20 if (def->present) { - virBufferAsprintf(buf, " present=3D'%s'", + virBufferAsprintf(&timerAttr, " present=3D'%s'", virTristateBoolTypeToString(def->present)); } =20 if (def->tickpolicy) { - virBufferAsprintf(buf, " tickpolicy=3D'%s'", + virBufferAsprintf(&timerAttr, " tickpolicy=3D'%s'", virDomainTimerTickpolicyTypeToString(def->tickpo= licy)); } =20 if (def->track !=3D VIR_DOMAIN_TIMER_TRACK_NONE) { - virBufferAsprintf(buf, " track=3D'%s'", + virBufferAsprintf(&timerAttr, " track=3D'%s'", virDomainTimerTrackTypeToString(def->track)); } =20 if (def->name =3D=3D VIR_DOMAIN_TIMER_NAME_TSC) { if (def->frequency > 0) - virBufferAsprintf(buf, " frequency=3D'%llu'", def->frequency); + virBufferAsprintf(&timerAttr, " frequency=3D'%llu'", def->freq= uency); =20 if (def->mode) { - virBufferAsprintf(buf, " mode=3D'%s'", + virBufferAsprintf(&timerAttr, " mode=3D'%s'", virDomainTimerModeTypeToString(def->mode)); } } =20 - if (def->catchup.threshold =3D=3D 0 && def->catchup.slew =3D=3D 0 && - def->catchup.limit =3D=3D 0) { - virBufferAddLit(buf, "/>\n"); - } else { - virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); - virBufferAddLit(buf, "catchup.threshold > 0) - virBufferAsprintf(buf, " threshold=3D'%lu'", def->catchup.thre= shold); - if (def->catchup.slew > 0) - virBufferAsprintf(buf, " slew=3D'%lu'", def->catchup.slew); - if (def->catchup.limit > 0) - virBufferAsprintf(buf, " limit=3D'%lu'", def->catchup.limit); - virBufferAddLit(buf, "/>\n"); - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - } + if (def->catchup.threshold > 0) + virBufferAsprintf(&catchupAttr, " threshold=3D'%lu'", def->catchup= .threshold); + if (def->catchup.slew > 0) + virBufferAsprintf(&catchupAttr, " slew=3D'%lu'", def->catchup.slew= ); + if (def->catchup.limit > 0) + virBufferAsprintf(&catchupAttr, " limit=3D'%lu'", def->catchup.lim= it); + + virXMLFormatElement(&timerChld, "catchup", &catchupAttr, NULL); + virXMLFormatElement(buf, "timer", &timerAttr, &timerChld); =20 return 0; } --=20 2.34.1 From nobody Mon Apr 29 13:11:19 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=1643019002; cv=none; d=zohomail.com; s=zohoarc; b=Yw4Hnumcxp+S/Z/FfOXop6D+W3t+oFKNE364c8EgILVJg6ibWX/lj7uOIn4Hu6TvCpmgtGHjQdYrXx6R0Kg3Dg2W8qKspOe2ICmqQOWmjB5ujDXBhJJXQI0Ch/dcpboG+oZnr0ylexNBKghfs88cbfLncZjCDcQ3xhxisWbSCu4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643019002; 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=Ae9NULY/eeGXOxW+i8Mt98ZciAjjwx+8O0KHklwoXkM=; b=LyT/iqP9dqy0UIlFEF1izoT15iyvY31cXxmlJAMSR00xFroUVNgPF/UkB95qReruZHxq9vSW1Vu8Sc6vTJyeE+vg1rn4Up0z2cNud9ZCoQ9tGCHS/nU8O7FnRDRRXm6bDMIbw3ygsZwnFrlBUPV83rN32gqdShk+iqxpX+uoWuM= 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 1643019002628985.9725477260682; Mon, 24 Jan 2022 02:10:02 -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-563-oV-g6itFMfSNcYL0L696HQ-1; Mon, 24 Jan 2022 05:09:35 -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 7A5A283DD21; Mon, 24 Jan 2022 10:09:30 +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 596E57B9ED; Mon, 24 Jan 2022 10:09:30 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 280FE1806D1C; Mon, 24 Jan 2022 10:09:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20OA9SY2021614 for ; Mon, 24 Jan 2022 05:09:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id A923A6F12B; Mon, 24 Jan 2022 10:09:28 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1BCBB6F167 for ; Mon, 24 Jan 2022 10:08:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643019001; 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=Ae9NULY/eeGXOxW+i8Mt98ZciAjjwx+8O0KHklwoXkM=; b=DCulnLup17F7THdhWiiXboiWz3FuJmFPSkGlWzQX2s2cYDjNQqzE7MuKmwTDD+L4twIPFq /z9FUcEWqruT37EvcEMW/C9QTTIVyLloYg24eWn0vmreOCeUqccthAqAgGd0FDEdFIXtgC cirLn4nTGDuzhFDe7cnGq5G96KdnH48= X-MC-Unique: oV-g6itFMfSNcYL0L696HQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 10/11] virDomainTimerDefFormat: return void Date: Mon, 24 Jan 2022 11:07:32 +0100 Message-Id: <108aed6ae046c5a63fac78089010ea98a585cb8f.1643018556.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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: 1643019008565100001 Content-Type: text/plain; charset="utf-8" This function never returns an error, make it void then. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 55626a6d01..a5fa3acd32 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -26100,7 +26100,7 @@ virDomainInputDefFormat(virBuffer *buf, } =20 =20 -static int +static void virDomainTimerDefFormat(virBuffer *buf, virDomainTimerDef *def) { @@ -26145,8 +26145,6 @@ virDomainTimerDefFormat(virBuffer *buf, =20 virXMLFormatElement(&timerChld, "catchup", &catchupAttr, NULL); virXMLFormatElement(buf, "timer", &timerAttr, &timerChld); - - return 0; } =20 static void @@ -28191,8 +28189,7 @@ virDomainDefFormatInternalSetRootName(virDomainDef = *def, virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); for (n =3D 0; n < def->clock.ntimers; n++) { - if (virDomainTimerDefFormat(buf, def->clock.timers[n]) < 0) - return -1; + virDomainTimerDefFormat(buf, def->clock.timers[n]); } virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); --=20 2.34.1 From nobody Mon Apr 29 13:11:19 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=1643018986; cv=none; d=zohomail.com; s=zohoarc; b=UpgcakTmJXmliIR7h0hVL96OtxczQzBuVyaBWPYVwjp8hnv1GPCSWPv62Hq7A8yP7jUFihUcSY8NnBu/Z9G9tYVGKTZd/j0hjoynUA9qVFBFhjMIO/wOYqam9MfDOZStylJnDy5iwl7C9NTdMnp1c/Yb0rpNsfi1rzA8Ek2rsTI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643018986; 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=K9Ufnwo5g1t3v4P6n0jBosYc892QoCb5v8TULiS/kJg=; b=UFN9BI49TZIHdFYAE1dAA7tNHc163BjgUPxrzLaUB393rVbn/znM3tQqy863s9xkijSN95YOPaGMD4oAsFdJLhY2IIZ4/BdhlWjeWNXLrgzki8Ro4TEkPyyBVpfRvttkfwR00nCOjSS/o0tJopWLV/OZR9Lsf5E6f1mTyGfsCds= 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 1643018986015991.1594107332967; Mon, 24 Jan 2022 02:09:46 -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-586-iDjNRDfjPGet9BcsumuGBw-1; Mon, 24 Jan 2022 05:09:41 -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 362EF85EE61; Mon, 24 Jan 2022 10:09:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 132DC70D5B; Mon, 24 Jan 2022 10:09:37 +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 A891D4A7CA; Mon, 24 Jan 2022 10:09:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20OA9a8X021659 for ; Mon, 24 Jan 2022 05:09:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1FCE96F16B; Mon, 24 Jan 2022 10:09:36 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 86EC76F169 for ; Mon, 24 Jan 2022 10:09:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643018985; 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=K9Ufnwo5g1t3v4P6n0jBosYc892QoCb5v8TULiS/kJg=; b=TtRkFsT37osoMUq0SykSLv2qewnCwKcFHEKAoofZ5JrYcDGvIAK+Aq/Wf58PrYVVPr0QO7 l3f/WQXQDt/h/klRmi1QydbTphDDoDMZ5kaFgMxEybP6+DOY8jApzB+a7W3SO/aA593uCq QQOlXmY1Z9asVf73KYZGjmbERIkLLhg= X-MC-Unique: iDjNRDfjPGet9BcsumuGBw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 11/11] conf: Separate out virDomainClockDef formatting Date: Mon, 24 Jan 2022 11:07:33 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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: 1643018987669100001 Content-Type: text/plain; charset="utf-8" Currently, virDomainClockDef is formatted inside virDomainDefFormatInternalSetRootName() which is already long enough. Move the code into a new function (virDomainClockDefFormat()) and make the code use virXMLFormatElement() while at it. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 75 +++++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 33 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a5fa3acd32..79cc58f8d7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -26147,6 +26147,47 @@ virDomainTimerDefFormat(virBuffer *buf, virXMLFormatElement(buf, "timer", &timerAttr, &timerChld); } =20 + +static void +virDomainClockDefFormat(virBuffer *buf, + const virDomainClockDef *def, + unsigned int flags) +{ + virBuffer clockAttr =3D VIR_BUFFER_INITIALIZER; + virBuffer clockChld =3D VIR_BUFFER_INIT_CHILD(buf); + size_t n; + + virBufferAsprintf(&clockAttr, " offset=3D'%s'", + virDomainClockOffsetTypeToString(def->offset)); + switch (def->offset) { + case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME: + case VIR_DOMAIN_CLOCK_OFFSET_UTC: + if (def->data.utc_reset) + virBufferAddLit(&clockAttr, " adjustment=3D'reset'"); + break; + case VIR_DOMAIN_CLOCK_OFFSET_VARIABLE: + virBufferAsprintf(&clockAttr, " adjustment=3D'%lld' basis=3D'%s'", + def->data.variable.adjustment, + virDomainClockBasisTypeToString(def->data.variab= le.basis)); + if (flags & VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST && + def->data.variable.adjustment0) { + virBufferAsprintf(&clockAttr, " adjustment0=3D'%lld'", + def->data.variable.adjustment0); + } + break; + case VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE: + virBufferEscapeString(&clockAttr, " timezone=3D'%s'", def->data.ti= mezone); + break; + } + + for (n =3D 0; n < def->ntimers; n++) { + virDomainTimerDefFormat(&clockChld, def->timers[n]); + } + + virXMLFormatElement(buf, "clock", &clockAttr, &clockChld); +} + + static void virDomainGraphicsAuthDefFormatAttr(virBuffer *buf, virDomainGraphicsAuthDef *def, @@ -28161,39 +28202,7 @@ virDomainDefFormatInternalSetRootName(virDomainDef= *def, if (virCPUDefFormatBufFull(buf, def->cpu, def->numa) < 0) return -1; =20 - virBufferAsprintf(buf, "clock.offset)); - switch (def->clock.offset) { - case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME: - case VIR_DOMAIN_CLOCK_OFFSET_UTC: - if (def->clock.data.utc_reset) - virBufferAddLit(buf, " adjustment=3D'reset'"); - break; - case VIR_DOMAIN_CLOCK_OFFSET_VARIABLE: - virBufferAsprintf(buf, " adjustment=3D'%lld' basis=3D'%s'", - def->clock.data.variable.adjustment, - virDomainClockBasisTypeToString(def->clock.data.= variable.basis)); - if (flags & VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST) { - if (def->clock.data.variable.adjustment0) - virBufferAsprintf(buf, " adjustment0=3D'%lld'", - def->clock.data.variable.adjustment0); - } - break; - case VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE: - virBufferEscapeString(buf, " timezone=3D'%s'", def->clock.data.tim= ezone); - break; - } - if (def->clock.ntimers =3D=3D 0) { - virBufferAddLit(buf, "/>\n"); - } else { - virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); - for (n =3D 0; n < def->clock.ntimers; n++) { - virDomainTimerDefFormat(buf, def->clock.timers[n]); - } - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - } + virDomainClockDefFormat(buf, &def->clock, flags); =20 if (virDomainEventActionDefFormat(buf, def->onPoweroff, "on_poweroff", --=20 2.34.1