From nobody Sun Feb 8 18:30:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1590009166; cv=none; d=zohomail.com; s=zohoarc; b=iLDXoZlWzEdEsJZS4JOmSebOEbO3sRDh527v2zvBS5FLeKqHNd8zoWfgzQFYn2EWONg1nISUTxlNZfFEwjziJg0zdDYnFdi0aWkAewkXTDIQHieifZKZwltvhT8jxxilWi3NHt2g2fpJo3GVfHrnHHfj187H9sTtptisjdlbMLk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590009166; h=Content-Type:Content-Transfer-Encoding:Cc: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=Tx8JZWl3WZom+eyi2ciowItd+wi/sfs24bsNhE5xSUg=; b=kz3796ZdJ4dg320JmLSVetydFehvG8Mq+Fd2QSk4SzlN65pawzwX9IG3N5kkVS1VNZt5mqRza2FwiRVDPaO8PWt3ZmZPrSCCf1YypnNzh4cspCyKGXexK019D93J3Rj0bLmOxwtTMPu6YthxIoJA1SGc/zK675jOiYlVUFxF3ak= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1590009166650904.3471884209672; Wed, 20 May 2020 14:12:46 -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-113-XiUvLq-JOGi3lVwEetJtEw-1; Wed, 20 May 2020 17:12:42 -0400 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 B957464AD4; Wed, 20 May 2020 21:12:37 +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 98E0482E7E; Wed, 20 May 2020 21:12: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 6AA6C180530A; Wed, 20 May 2020 21:12:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 04KLCZfG002159 for ; Wed, 20 May 2020 17:12:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 870322157F25; Wed, 20 May 2020 21:12:35 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 82FD62166BA2 for ; Wed, 20 May 2020 21:12:31 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 69CF2800296 for ; Wed, 20 May 2020 21:12:31 +0000 (UTC) Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-400-focS_L-ONGeJsXlrEo6sHA-1; Wed, 20 May 2020 17:12:28 -0400 Received: by mail-qt1-f170.google.com with SMTP id a23so3851835qto.1 for ; Wed, 20 May 2020 14:12:28 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:fbf2:bc5e:c314:af31:7070]) by smtp.gmail.com with ESMTPSA id z14sm2992031qki.83.2020.05.20.14.12.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2020 14:12:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590009165; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=Tx8JZWl3WZom+eyi2ciowItd+wi/sfs24bsNhE5xSUg=; b=Y1gsiACAlrYJFmn7i4FDvoZDCIdAqW7IUbC3nLKDwuFx8mTD/J+ha1gj46LBSZQ7xeSdOm X6eRLbub7Ie0rE74BcY6bFZroeMEEwI9ALtaKWUm29pUIxMKVZ+I1m/WpiZIrSUdmP2tVE WmaUDWvp9y3of95+Lr5u5Y35f3LWcQg= X-MC-Unique: XiUvLq-JOGi3lVwEetJtEw-1 X-MC-Unique: focS_L-ONGeJsXlrEo6sHA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Tx8JZWl3WZom+eyi2ciowItd+wi/sfs24bsNhE5xSUg=; b=oeBNF/m9l/QBMED3IwHdorJYAGNrnap7qLmVbBEfnDI3hUUlQ/2LMflPHwY+2ymSZe uA1BDSkpVfkI9LE6yU5hF1s8189/ZwQOLtOwgXkIogrnszIUs1vYX0pQdh/kirmw3Nj/ XBvezcLiP3yNAH9uPHOOS8CXzt8IofZRC1YN/67yk310xpPHFHaDgJBPgx0nTcGzUJfM wgbe/4TQy679gR4dtzBv2bycpidEEpS7evEdggBsWHvD1IkC7hk6YpeZqs1ck1IcZjvJ yo36Wfm6tw5pi0DozGFnudz4xJiD3n9UicC2shUixX74vqjsPcZiL0uYyAgxBiBN/RIv ZqPA== X-Gm-Message-State: AOAM532ycacM/i7dHokodXOYFsqL8pXJbjSJz4r6vm+D47ogEl1YlnZy 0JeMq/pDvZdNkl/z6JskGBfaLGyT X-Google-Smtp-Source: ABdhPJyAq4tCVTt0CwfKTGrVTL4ltESqujXADtJfibQF68uah5Du602/YUMY1y3HJKmlq3gcW5ptgA== X-Received: by 2002:ac8:6f5a:: with SMTP id n26mr7882172qtv.303.1590009148075; Wed, 20 May 2020 14:12:28 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 11/21] Introduce qemuDomainDeviceParseXMLMany Date: Wed, 20 May 2020 18:11:33 -0300 Message-Id: <20200520211143.2980117-12-danielhb413@gmail.com> In-Reply-To: <20200520211143.2980117-1-danielhb413@gmail.com> References: <20200520211143.2980117-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza , sbhat@linux.ibm.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 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" From: Shivaprasad G Bhat Signed-off-by: Shivaprasad G Bhat Signed-off-by: Daniel Henrique Barboza --- src/qemu/qemu_domain.c | 74 ++++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_domain.h | 7 ++++ 2 files changed, 81 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index d5e3d1a3cc..0471a37803 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -13391,6 +13391,80 @@ qemuProcessEventFree(struct qemuProcessEvent *even= t) } =20 =20 +static bool isPCIMultifunctionDeviceXML(const char *xml) +{ + xmlDocPtr xmlptr; + + if (!(xmlptr =3D virXMLParse(NULL, xml, _("(device_definition)")))) { + /* We report error anyway later */ + return false; + } + + return STREQ((const char *)(xmlDocGetRootElement(xmlptr))->name, "devic= es"); +} + +static +int qemuDomainValidateMultifunctionDeviceList(virDomainDeviceDefListPtr de= vlist) +{ + size_t i; + + for (i =3D 0; i < devlist->count; i++) { + virDomainDeviceInfoPtr info =3D virDomainDeviceGetInfo(devlist->de= vs[i]); + + if (info->type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && + info->type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + return -1; + } + + if (devlist->devs[i]->type =3D=3D VIR_DOMAIN_DEVICE_HOSTDEV) { + virDomainHostdevDefPtr hostdev =3D devlist->devs[i]->data.hostd= ev; + + if (hostdev->source.subsys.type !=3D VIR_DOMAIN_HOSTDEV_SUBSYS_= TYPE_PCI) + return -1; + } + } + + return 0; +} + + +virDomainDeviceDefListPtr +qemuDomainDeviceParseXMLMany(const char *xml, + virDomainDeviceDefListDataPtr data, + void *parseOpaque, + unsigned int parse_flags) +{ + virDomainDeviceDefListPtr devlist =3D NULL; + + if (isPCIMultifunctionDeviceXML(xml)) { + if (!(devlist =3D virDomainDeviceDefParseXMLMany(xml, data->def, + data->xmlopt, + parseOpaque, + parse_flags))) + return NULL; + + if (qemuDomainValidateMultifunctionDeviceList(devlist) < 0) + goto cleanup; + } else { + virDomainDeviceDefPtr dev =3D virDomainDeviceDefParse(xml, data->d= ef, + data->xmlopt, + parseOpaque, + parse_flags); + if (!dev || VIR_ALLOC(devlist) < 0) + return NULL; + + if (VIR_APPEND_ELEMENT(devlist->devs, devlist->count, dev) < 0) + goto cleanup; + } + + return devlist; + + cleanup: + virDomainDeviceDefListFree(devlist); + return NULL; +} + + char * qemuDomainGetManagedPRSocketPath(qemuDomainObjPrivatePtr priv) { diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index b601d52126..31c843de96 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1291,6 +1291,13 @@ qemuDomainNVRAMPathGenerate(virQEMUDriverConfigPtr c= fg, virDomainEventSuspendedDetailType qemuDomainPausedReasonToSuspendedEvent(virDomainPausedReason reason); =20 + +virDomainDeviceDefListPtr +qemuDomainDeviceParseXMLMany(const char *xml, + virDomainDeviceDefListDataPtr data, + void *parseOpaque, + unsigned int parse_flags); + int qemuDomainValidateActualNetDef(const virDomainNetDef *net, virQEMUCapsPtr qemuCaps); --=20 2.26.2