From nobody Sun Feb 8 13:38:39 2026 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=1616070425; cv=none; d=zohomail.com; s=zohoarc; b=l6S7SCPaX/ewy88JfTvN3ebfuaTtzR++Sih7Mj+9YcvRekhG+fBY88TwHkCR31MyP1mwXryVJixN7rgsT4s9Wc2NEjJZ7XUd0xN6x7pTv9IrMayeVrCeBLYhB/PC3SdPprHpbtVAqJ2or+D2Kctpro87qV+gv2z8fWwPAQM9ptI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616070425; 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=09dcLqLDhK+CwNlPcqT3xRzGPJnPIRw6Q4JhcTMDaeA=; b=U9rrTHiNp/Qx+pxxZsq3u7PUCQ3XDgy3oAQz6T8q/onLZZPJ1qDJHx3Nna77eChJvUle4u6uaE8yP6imi7o7e5I8a2e901vx4Th5AQXFlx5LfXzeaUpdOyUr0tGz/9AmdI8Lz8bFSjysnfD1+R6U1ooIAY2gN6D5OU6hC7WXZIs= 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) header.from= 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 1616070425122466.5682728570172; Thu, 18 Mar 2021 05:27:05 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-48-tpeWcYZUPVekcnfuJp7Cig-1; Thu, 18 Mar 2021 08:27:01 -0400 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 E3D691083E8A; Thu, 18 Mar 2021 12:26:55 +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 BD879610F0; Thu, 18 Mar 2021 12:26:55 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7A4B74A7C9; Thu, 18 Mar 2021 12:26:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12ICQrOV024656 for ; Thu, 18 Mar 2021 08:26:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id F2E965C582; Thu, 18 Mar 2021 12:26:52 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.192.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7323D5C239 for ; Thu, 18 Mar 2021 12:26:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616070424; 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=09dcLqLDhK+CwNlPcqT3xRzGPJnPIRw6Q4JhcTMDaeA=; b=S1O3aOXP25c1d/MJrkX1YkosmdNwpaxNIlGJv+//CCxBI+m8C4CbxPUYZaFqBV0kgcRNIt B3pMIQYeZjzFhT00vFr+nlYxC2FgZXr6XGjDyTMdHa3pA9oXCk2TWuNx62Z+jPf4oB8UFo qWl9etnSEtGCN7s/U2Xgw0jszf2ljR8= X-MC-Unique: tpeWcYZUPVekcnfuJp7Cig-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 2/9] conf: introduce virDomainDefParseBootInitOptions Date: Thu, 18 Mar 2021 13:26:39 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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) Content-Type: text/plain; charset="utf-8" Extract the code to it's own function. Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 109 +++++++++++++++++++++++------------------ 1 file changed, 61 insertions(+), 48 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 47756ff0be..31b908d8fe 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -19523,12 +19523,70 @@ virDomainVcpuParse(virDomainDefPtr def, } =20 =20 +static int +virDomainDefParseBootInitOptions(virDomainDefPtr def, + xmlXPathContextPtr ctxt) +{ + char *name =3D NULL; + size_t i; + int n; + g_autofree xmlNodePtr *nodes =3D NULL; + + def->os.init =3D virXPathString("string(./os/init[1])", ctxt); + def->os.cmdline =3D virXPathString("string(./os/cmdline[1])", ctxt); + def->os.initdir =3D virXPathString("string(./os/initdir[1])", ctxt); + def->os.inituser =3D virXPathString("string(./os/inituser[1])", ctxt); + def->os.initgroup =3D virXPathString("string(./os/initgroup[1])", ctxt= ); + + if ((n =3D virXPathNodeSet("./os/initarg", ctxt, &nodes)) < 0) + return -1; + + def->os.initargv =3D g_new0(char *, n+1); + for (i =3D 0; i < n; i++) { + if (!nodes[i]->children || + !nodes[i]->children->content) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("No data supplied for element")); + return -1; + } + def->os.initargv[i] =3D g_strdup((const char *)nodes[i]->children-= >content); + } + def->os.initargv[n] =3D NULL; + VIR_FREE(nodes); + + if ((n =3D virXPathNodeSet("./os/initenv", ctxt, &nodes)) < 0) + return -1; + + def->os.initenv =3D g_new0(virDomainOSEnvPtr, n+1); + for (i =3D 0; i < n; i++) { + if (!(name =3D virXMLPropString(nodes[i], "name"))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("No name supplied for element")); + return -1; + } + + if (!nodes[i]->children || + !nodes[i]->children->content) { + virReportError(VIR_ERR_XML_ERROR, + _("No value supplied for = element"), + name); + return -1; + } + + def->os.initenv[i] =3D g_new0(virDomainOSEnv, 1); + def->os.initenv[i]->name =3D name; + def->os.initenv[i]->value =3D g_strdup((const char *)nodes[i]->chi= ldren->content); + } + def->os.initenv[n] =3D NULL; + + return 0; +} + + static int virDomainDefParseBootOptions(virDomainDefPtr def, xmlXPathContextPtr ctxt) { - char *name =3D NULL; - size_t i; int n; g_autofree xmlNodePtr *nodes =3D NULL; g_autofree char *tmp =3D NULL; @@ -19543,53 +19601,8 @@ virDomainDefParseBootOptions(virDomainDefPtr def, */ =20 if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_EXE) { - def->os.init =3D virXPathString("string(./os/init[1])", ctxt); - def->os.cmdline =3D virXPathString("string(./os/cmdline[1])", ctxt= ); - def->os.initdir =3D virXPathString("string(./os/initdir[1])", ctxt= ); - def->os.inituser =3D virXPathString("string(./os/inituser[1])", ct= xt); - def->os.initgroup =3D virXPathString("string(./os/initgroup[1])", = ctxt); - - if ((n =3D virXPathNodeSet("./os/initarg", ctxt, &nodes)) < 0) + if (virDomainDefParseBootInitOptions(def, ctxt) < 0) return -1; - - def->os.initargv =3D g_new0(char *, n+1); - for (i =3D 0; i < n; i++) { - if (!nodes[i]->children || - !nodes[i]->children->content) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("No data supplied for element")= ); - return -1; - } - def->os.initargv[i] =3D g_strdup((const char *)nodes[i]->child= ren->content); - } - def->os.initargv[n] =3D NULL; - VIR_FREE(nodes); - - if ((n =3D virXPathNodeSet("./os/initenv", ctxt, &nodes)) < 0) - return -1; - - def->os.initenv =3D g_new0(virDomainOSEnvPtr, n+1); - for (i =3D 0; i < n; i++) { - if (!(name =3D virXMLPropString(nodes[i], "name"))) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("No name supplied for element"= )); - return -1; - } - - if (!nodes[i]->children || - !nodes[i]->children->content) { - virReportError(VIR_ERR_XML_ERROR, - _("No value supplied for element"), - name); - return -1; - } - - def->os.initenv[i] =3D g_new0(virDomainOSEnv, 1); - def->os.initenv[i]->name =3D name; - def->os.initenv[i]->value =3D g_strdup((const char *)nodes[i]-= >children->content); - } - def->os.initenv[n] =3D NULL; - VIR_FREE(nodes); } =20 if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_XEN || --=20 2.30.2