From nobody Mon Feb 9 03:48:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1653311351; cv=none; d=zohomail.com; s=zohoarc; b=HAImZgOqtJEoVfYr5u5wxATUpPp35eNlDObCYy81pwSQQYu67Ye4HLvNiB4NJ/4q9FjCNFHsx8AkcOweckGXnKEeKKDXe17Dicc8kGgxmOu5dQxUaF047b6Z3ZZN7go5RYvUYcQBaYyRmP+GyyOzjRyDa2Bhoj6uUs+hypozMjQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653311351; 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=onUA+Q1Kl4uGTPpAucpEk7K7yJUl5y+k9F6OX9h1xD0=; b=k8AGklYTb9DUy3IcLXw1Kc3EMtMVMwcN0v8n0VEA2w1FI6nqwa9IU3MJi9b5lcH6BWE8BtFblp40HmjeM7O8IGMaCJfm3PUsGYTQeMY3fMQVfEn6Uh3yYEcUDMdscrZPWeLhZLqx76YO9XmQMn0VLDpxqfClbDmm4M5IxCOHvtU= 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 1653311351479777.7189371112537; Mon, 23 May 2022 06:09:11 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-641-aKY77S_tPD2HUJU-TRCXlA-1; Mon, 23 May 2022 09:09:08 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CEB1C101A52C; Mon, 23 May 2022 13:08:59 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA5D91121319; Mon, 23 May 2022 13:08:59 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 85749194705A; Mon, 23 May 2022 13:08:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 84B761947059 for ; Mon, 23 May 2022 13:08:57 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 66A65400E115; Mon, 23 May 2022 13:08:57 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0DD9A40C1438 for ; Mon, 23 May 2022 13:08:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653311350; 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=onUA+Q1Kl4uGTPpAucpEk7K7yJUl5y+k9F6OX9h1xD0=; b=F/buaSmbBlLc/BAtgOCHLfndmP4n+yM4OpOyzHZ3+sqwplVZgKlG42+xSFOgcf8nWQ1Bep O8G5pMml8q3keribDPQ8cl1LaWm6TIiKYwUb2xroxtFZs8h1ejFVv8KXksyXuYR883uoMn ZgdejyrpvdVOZXKHYeXqIUrELiH2nR4= X-MC-Unique: aKY77S_tPD2HUJU-TRCXlA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 03/17] virDomainBackupDefParse: Switch to virXMLPropEnumDefault() Date: Mon, 23 May 2022 15:08:38 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 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: 1653311352616100001 Content-Type: text/plain; charset="utf-8"; x-default="true" The virDomainBackupDefParse() function uses old style of parsing XML (virXMLPropString + str2enum conversion). Use virXMLPropEnumDefault() which encapsulates those steps. Signed-off-by: Michal Privoznik Reviewed-by: Boris Fiuczynski --- src/conf/backup_conf.c | 16 ++++++---------- src/conf/backup_conf.h | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c index 2a7fa95e0c..11d533a905 100644 --- a/src/conf/backup_conf.c +++ b/src/conf/backup_conf.c @@ -201,22 +201,18 @@ virDomainBackupDefParse(xmlXPathContextPtr ctxt, g_autoptr(virDomainBackupDef) def =3D NULL; g_autofree xmlNodePtr *nodes =3D NULL; xmlNodePtr node =3D NULL; - g_autofree char *mode =3D NULL; bool push; size_t i; int n; =20 def =3D g_new0(virDomainBackupDef, 1); =20 - def->type =3D VIR_DOMAIN_BACKUP_TYPE_PUSH; - - if ((mode =3D virXMLPropString(ctxt->node, "mode"))) { - if ((def->type =3D virDomainBackupTypeFromString(mode)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown backup mode '%s'"), mode); - return NULL; - } - } + if (virXMLPropEnumDefault(ctxt->node, "mode", + virDomainBackupTypeFromString, + VIR_XML_PROP_NONZERO, + &def->type, + VIR_DOMAIN_BACKUP_TYPE_PUSH) < 0) + return NULL; =20 push =3D def->type =3D=3D VIR_DOMAIN_BACKUP_TYPE_PUSH; =20 diff --git a/src/conf/backup_conf.h b/src/conf/backup_conf.h index dc66b75892..413488e123 100644 --- a/src/conf/backup_conf.h +++ b/src/conf/backup_conf.h @@ -76,7 +76,7 @@ struct _virDomainBackupDiskDef { typedef struct _virDomainBackupDef virDomainBackupDef; struct _virDomainBackupDef { /* Public XML. */ - int type; /* virDomainBackupType */ + virDomainBackupType type; char *incremental; virStorageNetHostDef *server; /* only when type =3D=3D PULL */ virTristateBool tls; /* use TLS for NBD */ --=20 2.35.1