From nobody Wed May 1 19:39:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508400855680620.5545870260813; Thu, 19 Oct 2017 01:14:15 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 92CD7C0587D1; Thu, 19 Oct 2017 08:14:14 +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 5EE33BA7C2; Thu, 19 Oct 2017 08:14: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 1A7281800C91; Thu, 19 Oct 2017 08:14:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9J8BTQc007346 for ; Thu, 19 Oct 2017 04:11:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id A4417A4319; Thu, 19 Oct 2017 08:11:29 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2CC609AA4B for ; Thu, 19 Oct 2017 08:11:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 92CD7C0587D1 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 19 Oct 2017 10:10:56 +0200 Message-Id: <34cb8032bc3c671390c2218fbb9bb0185fa6392d.1508399823.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 01/14] conf: Fix virDomainDeviceGetInfo const correctness 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 19 Oct 2017 08:14:15 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This function is not changing passed domain definition. Therefore, mark the argument as 'const'. Signed-off-by: Michal Privoznik --- src/conf/domain_conf.c | 2 +- src/conf/domain_conf.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 25d48f977..31684df54 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3501,7 +3501,7 @@ int virDomainDeviceAddressIsValid(virDomainDeviceInfo= Ptr info, } =20 virDomainDeviceInfoPtr -virDomainDeviceGetInfo(virDomainDeviceDefPtr device) +virDomainDeviceGetInfo(const virDomainDeviceDef *device) { switch ((virDomainDeviceType) device->type) { case VIR_DOMAIN_DEVICE_DISK: diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a42efcfa6..1e007346f 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2756,7 +2756,7 @@ virDomainDeviceDefPtr virDomainDeviceDefCopy(virDomai= nDeviceDefPtr src, virDomainXMLOptionPtr xmlopt); int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info, int type); -virDomainDeviceInfoPtr virDomainDeviceGetInfo(virDomainDeviceDefPtr device= ); +virDomainDeviceInfoPtr virDomainDeviceGetInfo(const virDomainDeviceDef *de= vice); void virDomainTPMDefFree(virDomainTPMDefPtr def); =20 typedef int (*virDomainDeviceInfoCallback)(virDomainDefPtr def, --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 19:39:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508400805248641.068004272521; Thu, 19 Oct 2017 01:13:25 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 14A52C04B952; Thu, 19 Oct 2017 08:13:24 +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 E52419AA4B; Thu, 19 Oct 2017 08:13:23 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9F096410B3; Thu, 19 Oct 2017 08:13:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9J8BUjG007356 for ; Thu, 19 Oct 2017 04:11:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 75E4FA4319; Thu, 19 Oct 2017 08:11:30 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id F22969AA4B for ; Thu, 19 Oct 2017 08:11:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 14A52C04B952 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 19 Oct 2017 10:10:57 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 02/14] virDomainObjGetOneDefState: Fix error message 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 19 Oct 2017 08:13:24 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" It looks like the error message was copied from virsh, because that's where we have @ctl. Nevertheless, it's @flags which is invalid, not @ctl. Signed-off-by: Michal Privoznik --- src/conf/domain_conf.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 31684df54..b3feddc39 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3418,12 +3418,13 @@ virDomainObjGetOneDefState(virDomainObjPtr vm, unsigned int flags, bool *live) { - if (flags & VIR_DOMAIN_AFFECT_LIVE && flags & VIR_DOMAIN_AFFECT_CONFIG= ) { - virReportInvalidArg(ctl, "%s", - _("Flags 'VIR_DOMAIN_AFFECT_LIVE' and " - "'VIR_DOMAIN_AFFECT_CONFIG' are mutually= " - "exclusive")); - return NULL; + if (flags & VIR_DOMAIN_AFFECT_LIVE && + flags & VIR_DOMAIN_AFFECT_CONFIG) { + virReportInvalidArg(flags, "%s", + _("Flags 'VIR_DOMAIN_AFFECT_LIVE' and " + "'VIR_DOMAIN_AFFECT_CONFIG' are mutually " + "exclusive")); + return NULL; } =20 if (virDomainObjUpdateModificationImpact(vm, &flags) < 0) --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 19:39:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508400857552624.2394899058802; Thu, 19 Oct 2017 01:14:17 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 830FE7E422; Thu, 19 Oct 2017 08:14:16 +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 6222CAAE74; Thu, 19 Oct 2017 08:14:16 +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 28A923FAEE; Thu, 19 Oct 2017 08:14:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9J8BVqN007361 for ; Thu, 19 Oct 2017 04:11:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id 46D33A42EE; Thu, 19 Oct 2017 08:11:31 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id C39B89AA4B for ; Thu, 19 Oct 2017 08:11:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 830FE7E422 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 19 Oct 2017 10:10:58 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 03/14] qemuAssignDeviceAliases: Use qemuAssignDeviceRNGAlias for assigning RNG aliases 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 19 Oct 2017 08:14:17 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We have a special function for assigning aliases to RNG devices. Use that instead of plain virAsprintf(). Signed-off-by: Michal Privoznik --- src/qemu/qemu_alias.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index 72df1083f..eca1dc64c 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -501,7 +501,7 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCap= sPtr qemuCaps) return -1; } for (i =3D 0; i < def->nrngs; i++) { - if (virAsprintf(&def->rngs[i]->info.alias, "rng%zu", i) < 0) + if (qemuAssignDeviceRNGAlias(def, def->rngs[i]) < 0) return -1; } if (def->tpm) { --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 19:39:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508400860425737.3014309481207; Thu, 19 Oct 2017 01:14:20 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 1E85EC02C738; Thu, 19 Oct 2017 08:14:19 +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 D921CAB704; Thu, 19 Oct 2017 08:14:18 +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 A35373D3F4; Thu, 19 Oct 2017 08:14:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9J8BWXq007366 for ; Thu, 19 Oct 2017 04:11:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2DC1E9AA4B; Thu, 19 Oct 2017 08:11:32 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA082A42EE for ; Thu, 19 Oct 2017 08:11:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1E85EC02C738 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 19 Oct 2017 10:10:59 +0200 Message-Id: <68f1116761ddcc7101e4a983c58087b9808b6376.1508399823.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 04/14] qemu: Move device alias assignment to separate functions 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 19 Oct 2017 08:14:19 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Let's move all the virAsprintf()-s into separate functions for better structure of the code. Later, when somebody wants to generate a device alias, all they need is to expose the function. Signed-off-by: Michal Privoznik --- src/qemu/qemu_alias.c | 80 +++++++++++++++++++++++++++++++++++++++++++++--= ---- 1 file changed, 72 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index eca1dc64c..33bd4c10d 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -286,6 +286,70 @@ qemuAssignDeviceNetAlias(virDomainDefPtr def, } =20 =20 +static int +qemuAssignDeviceFSAlias(virDomainFSDefPtr fss, + int idx) +{ + return virAsprintf(&fss->info.alias, "fs%d", idx); +} + + +static int +qemuAssignDeviceSoundAlias(virDomainSoundDefPtr sound, + int idx) +{ + return virAsprintf(&sound->info.alias, "sound%d", idx); +} + + +static int +qemuAssignDeviceVideoAlias(virDomainVideoDefPtr video, + int idx) +{ + return virAsprintf(&video->info.alias, "video%d", idx); +} + + +static int +qemuAssignDeviceInputAlias(virDomainInputDefPtr input, + int idx) +{ + return virAsprintf(&input->info.alias, "input%d", idx); +} + + +static int +qemuAssignDeviceHubAlias(virDomainHubDefPtr hub, + int idx) +{ + return virAsprintf(&hub->info.alias, "hub%d", idx); +} + + +static int +qemuAssignDeviceSmartcardAlias(virDomainSmartcardDefPtr smartcard, + int idx) +{ + return virAsprintf(&smartcard->info.alias, "smartcard%d", idx); +} + + +static int +qemuAssingDeviceMemballoonAlias(virDomainMemballoonDefPtr memballoon, + int idx) +{ + return virAsprintf(&memballoon->info.alias, "balloon%d", idx); +} + + +static int +qemuAssignDeviceTPMAlias(virDomainTPMDefPtr tpm, + int idx) +{ + return virAsprintf(&tpm->info.alias, "tpm%d", idx); +} + + int qemuAssignDeviceRedirdevAlias(virDomainDefPtr def, virDomainRedirdevDefPtr redirdev, @@ -431,11 +495,11 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUC= apsPtr qemuCaps) } =20 for (i =3D 0; i < def->nfss; i++) { - if (virAsprintf(&def->fss[i]->info.alias, "fs%zu", i) < 0) + if (qemuAssignDeviceFSAlias(def->fss[i], i) < 0) return -1; } for (i =3D 0; i < def->nsounds; i++) { - if (virAsprintf(&def->sounds[i]->info.alias, "sound%zu", i) < 0) + if (qemuAssignDeviceSoundAlias(def->sounds[i], i) < 0) return -1; } for (i =3D 0; i < def->nhostdevs; i++) { @@ -453,7 +517,7 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCap= sPtr qemuCaps) return -1; } for (i =3D 0; i < def->nvideos; i++) { - if (virAsprintf(&def->videos[i]->info.alias, "video%zu", i) < 0) + if (qemuAssignDeviceVideoAlias(def->videos[i], i) < 0) return -1; } for (i =3D 0; i < def->ncontrollers; i++) { @@ -461,7 +525,7 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCap= sPtr qemuCaps) return -1; } for (i =3D 0; i < def->ninputs; i++) { - if (virAsprintf(&def->inputs[i]->info.alias, "input%zu", i) < 0) + if (qemuAssignDeviceInputAlias(def->inputs[i], i) < 0) return -1; } for (i =3D 0; i < def->nparallels; i++) { @@ -481,7 +545,7 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCap= sPtr qemuCaps) return -1; } for (i =3D 0; i < def->nhubs; i++) { - if (virAsprintf(&def->hubs[i]->info.alias, "hub%zu", i) < 0) + if (qemuAssignDeviceHubAlias(def->hubs[i], i) < 0) return -1; } for (i =3D 0; i < def->nshmems; i++) { @@ -489,7 +553,7 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCap= sPtr qemuCaps) return -1; } for (i =3D 0; i < def->nsmartcards; i++) { - if (virAsprintf(&def->smartcards[i]->info.alias, "smartcard%zu", i= ) < 0) + if (qemuAssignDeviceSmartcardAlias(def->smartcards[i], i) < 0) return -1; } if (def->watchdog) { @@ -497,7 +561,7 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCap= sPtr qemuCaps) return -1; } if (def->memballoon) { - if (virAsprintf(&def->memballoon->info.alias, "balloon%d", 0) < 0) + if (qemuAssingDeviceMemballoonAlias(def->memballoon, 0) < 0) return -1; } for (i =3D 0; i < def->nrngs; i++) { @@ -505,7 +569,7 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCap= sPtr qemuCaps) return -1; } if (def->tpm) { - if (virAsprintf(&def->tpm->info.alias, "tpm%d", 0) < 0) + if (qemuAssignDeviceTPMAlias(def->tpm, 0) < 0) return -1; } for (i =3D 0; i < def->nmems; i++) { --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 19:39:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508400752115356.9279334666069; Thu, 19 Oct 2017 01:12:32 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id D2DB93E2D1; Thu, 19 Oct 2017 08:12: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 AA77D693C0; Thu, 19 Oct 2017 08:12: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 59C771800C91; Thu, 19 Oct 2017 08:12:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9J8BX5f007375 for ; Thu, 19 Oct 2017 04:11:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id F39E09AA4B; Thu, 19 Oct 2017 08:11:32 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C08DA42EE for ; Thu, 19 Oct 2017 08:11:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D2DB93E2D1 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 19 Oct 2017 10:11:00 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 05/14] qemu: Be tolerant to preexisting aliases 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 19 Oct 2017 08:12:31 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In the future, some aliases might be already parsed therefore we should avoid overwriting them. Signed-off-by: Michal Privoznik --- src/qemu/qemu_alias.c | 57 +++++++++++++++++++++++++++++++++++++++++++++= ++-- src/qemu/qemu_hotplug.c | 6 ++---- 2 files changed, 57 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index 33bd4c10d..7a3983afa 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -93,6 +93,9 @@ qemuAssignDeviceChrAlias(virDomainDefPtr def, { const char *prefix =3D NULL; =20 + if (chr->info.alias) + return 0; + switch ((virDomainChrDeviceType) chr->deviceType) { case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: prefix =3D "parallel"; @@ -128,6 +131,9 @@ qemuAssignDeviceControllerAlias(virDomainDefPtr domainD= ef, { const char *prefix =3D virDomainControllerTypeToString(controller->typ= e); =20 + if (controller->info.alias) + return 0; + if (controller->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI) { if (!virQEMUCapsHasPCIMultiBus(qemuCaps, domainDef)) { /* qemus that don't support multiple PCI buses have @@ -182,6 +188,9 @@ qemuAssignDeviceDiskAlias(virDomainDefPtr def, const char *prefix =3D virDomainDiskBusTypeToString(disk->bus); int controllerModel =3D -1; =20 + if (disk->info.alias) + return 0; + if (disk->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) { if (disk->bus =3D=3D VIR_DOMAIN_DISK_BUS_SCSI) { controllerModel =3D @@ -223,6 +232,9 @@ qemuAssignDeviceHostdevAlias(virDomainDefPtr def, char **alias, int idx) { + if (*alias) + return 0; + if (idx =3D=3D -1) { size_t i; =20 @@ -259,6 +271,9 @@ qemuAssignDeviceNetAlias(virDomainDefPtr def, int idx) { =20 + if (net->info.alias) + return 0; + /* uses "hostdevN" as the alias * We must use "-1" as the index because the caller doesn't know * that we're now looking for a unique hostdevN rather than netN @@ -290,6 +305,9 @@ static int qemuAssignDeviceFSAlias(virDomainFSDefPtr fss, int idx) { + if (fss->info.alias) + return 0; + return virAsprintf(&fss->info.alias, "fs%d", idx); } =20 @@ -298,6 +316,9 @@ static int qemuAssignDeviceSoundAlias(virDomainSoundDefPtr sound, int idx) { + if (sound->info.alias) + return 0; + return virAsprintf(&sound->info.alias, "sound%d", idx); } =20 @@ -306,6 +327,9 @@ static int qemuAssignDeviceVideoAlias(virDomainVideoDefPtr video, int idx) { + if (video->info.alias) + return 0; + return virAsprintf(&video->info.alias, "video%d", idx); } =20 @@ -314,6 +338,9 @@ static int qemuAssignDeviceInputAlias(virDomainInputDefPtr input, int idx) { + if (input->info.alias) + return 0; + return virAsprintf(&input->info.alias, "input%d", idx); } =20 @@ -322,6 +349,9 @@ static int qemuAssignDeviceHubAlias(virDomainHubDefPtr hub, int idx) { + if (hub->info.alias) + return 0; + return virAsprintf(&hub->info.alias, "hub%d", idx); } =20 @@ -330,6 +360,9 @@ static int qemuAssignDeviceSmartcardAlias(virDomainSmartcardDefPtr smartcard, int idx) { + if (smartcard->info.alias) + return 0; + return virAsprintf(&smartcard->info.alias, "smartcard%d", idx); } =20 @@ -338,6 +371,9 @@ static int qemuAssingDeviceMemballoonAlias(virDomainMemballoonDefPtr memballoon, int idx) { + if (memballoon->info.alias) + return 0; + return virAsprintf(&memballoon->info.alias, "balloon%d", idx); } =20 @@ -346,6 +382,9 @@ static int qemuAssignDeviceTPMAlias(virDomainTPMDefPtr tpm, int idx) { + if (tpm->info.alias) + return 0; + return virAsprintf(&tpm->info.alias, "tpm%d", idx); } =20 @@ -355,6 +394,9 @@ qemuAssignDeviceRedirdevAlias(virDomainDefPtr def, virDomainRedirdevDefPtr redirdev, int idx) { + if (redirdev->info.alias) + return 0; + if (idx =3D=3D -1) { size_t i; idx =3D 0; @@ -384,6 +426,9 @@ qemuAssignDeviceRNGAlias(virDomainDefPtr def, int maxidx =3D 0; int idx; =20 + if (rng->info.alias) + return 0; + for (i =3D 0; i < def->nrngs; i++) { if ((idx =3D qemuDomainDeviceAliasIndex(&def->rngs[i]->info, "rng"= )) >=3D maxidx) maxidx =3D idx + 1; @@ -418,6 +463,9 @@ qemuAssignDeviceMemoryAlias(virDomainDefPtr def, int idx; const char *prefix; =20 + if (mem->info.alias) + return 0; + if (mem->model =3D=3D VIR_DOMAIN_MEMORY_MODEL_DIMM) prefix =3D "dimm"; else @@ -444,6 +492,9 @@ qemuAssignDeviceShmemAlias(virDomainDefPtr def, virDomainShmemDefPtr shmem, int idx) { + if (shmem->info.alias) + return 0; + if (idx =3D=3D -1) { size_t i; idx =3D 0; @@ -474,6 +525,9 @@ qemuAssignDeviceWatchdogAlias(virDomainWatchdogDefPtr w= atchdog) { /* Currently, there's just one watchdog per domain */ =20 + if (watchdog->info.alias) + return 0; + if (VIR_STRDUP(watchdog->info.alias, "watchdog0") < 0) return -1; return 0; @@ -508,8 +562,7 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCap= sPtr qemuCaps) * linked to a NetDef, they will share an info and the alias * will already be set, so don't try to set it again. */ - if (!def->hostdevs[i]->info->alias && - qemuAssignDeviceHostdevAlias(def, &def->hostdevs[i]->info->ali= as, -1) < 0) + if (qemuAssignDeviceHostdevAlias(def, &def->hostdevs[i]->info->ali= as, -1) < 0) return -1; } for (i =3D 0; i < def->nredirdevs; i++) { diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 0288986d8..d556c9be0 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -4980,10 +4980,8 @@ qemuDomainDetachThisHostDevice(virQEMUDriverPtr driv= er, { int ret =3D -1; =20 - if (!detach->info->alias) { - if (qemuAssignDeviceHostdevAlias(vm->def, &detach->info->alias, -1= ) < 0) - return -1; - } + if (qemuAssignDeviceHostdevAlias(vm->def, &detach->info->alias, -1) < = 0) + return -1; =20 switch (detach->source.subsys.type) { case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 19:39:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508400808368557.0922668536753; Thu, 19 Oct 2017 01:13:28 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 3D52861470; Thu, 19 Oct 2017 08:13:27 +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 194B3BA7C4; Thu, 19 Oct 2017 08:13:27 +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 D0D5B410BB; Thu, 19 Oct 2017 08:13:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9J8BYdg007390 for ; Thu, 19 Oct 2017 04:11:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id F2C06A4301; Thu, 19 Oct 2017 08:11:33 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 542D3A42FE for ; Thu, 19 Oct 2017 08:11:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3D52861470 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 19 Oct 2017 10:11:01 +0200 Message-Id: <978c2cafdb752e470092d3b3656e398e269afdae.1508399823.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 06/14] conf: Pass xmlopt down to virDomainDeviceInfoParseXML 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 19 Oct 2017 08:13:27 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This function is going to make decisions based on the features set per each driver. For that we need the virDomainXMLOption object. Signed-off-by: Michal Privoznik --- src/conf/domain_conf.c | 165 ++++++++++++++++++++++++++++++---------------= ---- 1 file changed, 102 insertions(+), 63 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b3feddc39..f4de4e288 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6402,7 +6402,8 @@ virDomainDeviceAddressParseXML(xmlNodePtr address, * @param node XML nodeset to parse for device address definition */ static int -virDomainDeviceInfoParseXML(xmlNodePtr node, +virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED, + xmlNodePtr node, virHashTablePtr bootHash, virDomainDeviceInfoPtr info, unsigned int flags) @@ -9177,7 +9178,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, } def->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; } else { - if (virDomainDeviceInfoParseXML(node, bootHash, &def->info, + if (virDomainDeviceInfoParseXML(xmlopt, node, bootHash, &def->info, flags | VIR_DOMAIN_DEF_PARSE_ALLOW= _BOOT) < 0) goto error; } @@ -9514,7 +9515,8 @@ virDomainControllerModelTypeToString(virDomainControl= lerDefPtr def, * @param node XML nodeset to parse for controller definition */ static virDomainControllerDefPtr -virDomainControllerDefParseXML(xmlNodePtr node, +virDomainControllerDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr node, xmlXPathContextPtr ctxt, unsigned int flags) { @@ -9663,7 +9665,8 @@ virDomainControllerDefParseXML(xmlNodePtr node, if (def->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_USB && def->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE) { VIR_DEBUG("Ignoring device address for none model usb controller"); - } else if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) = < 0) { + } else if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, + &def->info, flags) < 0) { goto error; } =20 @@ -9890,7 +9893,8 @@ virDomainNetGenerateMAC(virDomainXMLOptionPtr xmlopt, * @param node XML nodeset to parse for disk definition */ static virDomainFSDefPtr -virDomainFSDefParseXML(xmlNodePtr node, +virDomainFSDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr node, xmlXPathContextPtr ctxt, unsigned int flags) { @@ -10047,7 +10051,7 @@ virDomainFSDefParseXML(xmlNodePtr node, def->dst =3D target; target =3D NULL; =20 - if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, &def->info, flags)= < 0) goto error; =20 cleanup: @@ -10568,7 +10572,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, } def->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; } else { - if (virDomainDeviceInfoParseXML(node, bootHash, &def->info, + if (virDomainDeviceInfoParseXML(xmlopt, node, bootHash, &def->info, flags | VIR_DOMAIN_DEF_PARSE_ALLOW= _BOOT | VIR_DOMAIN_DEF_PARSE_ALLOW_ROM) = < 0) goto error; @@ -11835,7 +11839,8 @@ virDomainChrDefParseXML(virDomainXMLOptionPtr xmlop= t, if (def->deviceType =3D=3D VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL && def->targetType =3D=3D VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD= ) { VIR_DEBUG("Ignoring device address for gustfwd channel"); - } else if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) = < 0) { + } else if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, + &def->info, flags) < 0) { goto error; } =20 @@ -11972,7 +11977,7 @@ virDomainSmartcardDefParseXML(virDomainXMLOptionPtr= xmlopt, goto error; } =20 - if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, &def->info, flags)= < 0) goto error; if (def->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && def->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID) { @@ -12005,7 +12010,8 @@ virDomainSmartcardDefParseXML(virDomainXMLOptionPtr= xmlopt, * */ static virDomainTPMDefPtr -virDomainTPMDefParseXML(xmlNodePtr node, +virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr node, xmlXPathContextPtr ctxt, unsigned int flags) { @@ -12074,7 +12080,7 @@ virDomainTPMDefParseXML(xmlNodePtr node, goto error; } =20 - if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, &def->info, flags)= < 0) goto error; =20 cleanup: @@ -12093,7 +12099,8 @@ virDomainTPMDefParseXML(xmlNodePtr node, } =20 static virDomainPanicDefPtr -virDomainPanicDefParseXML(xmlNodePtr node, +virDomainPanicDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr node, unsigned int flags) { virDomainPanicDefPtr panic; @@ -12102,7 +12109,8 @@ virDomainPanicDefParseXML(xmlNodePtr node, if (VIR_ALLOC(panic) < 0) return NULL; =20 - if (virDomainDeviceInfoParseXML(node, NULL, &panic->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, + &panic->info, flags) < 0) goto error; =20 model =3D virXMLPropString(node, "model"); @@ -12125,7 +12133,8 @@ virDomainPanicDefParseXML(xmlNodePtr node, =20 /* Parse the XML definition for an input device */ static virDomainInputDefPtr -virDomainInputDefParseXML(const virDomainDef *dom, +virDomainInputDefParseXML(virDomainXMLOptionPtr xmlopt, + const virDomainDef *dom, xmlNodePtr node, xmlXPathContextPtr ctxt, unsigned int flags) @@ -12236,7 +12245,7 @@ virDomainInputDefParseXML(const virDomainDef *dom, } } =20 - if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, &def->info, flags)= < 0) goto error; =20 if (def->bus =3D=3D VIR_DOMAIN_INPUT_BUS_USB && @@ -12276,7 +12285,9 @@ virDomainInputDefParseXML(const virDomainDef *dom, =20 /* Parse the XML definition for a hub device */ static virDomainHubDefPtr -virDomainHubDefParseXML(xmlNodePtr node, unsigned int flags) +virDomainHubDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr node, + unsigned int flags) { virDomainHubDefPtr def; char *type =3D NULL; @@ -12298,7 +12309,7 @@ virDomainHubDefParseXML(xmlNodePtr node, unsigned i= nt flags) goto error; } =20 - if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, &def->info, flags)= < 0) goto error; =20 cleanup: @@ -13375,7 +13386,8 @@ virDomainSoundCodecDefParseXML(xmlNodePtr node) =20 =20 static virDomainSoundDefPtr -virDomainSoundDefParseXML(xmlNodePtr node, +virDomainSoundDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr node, xmlXPathContextPtr ctxt, unsigned int flags) { @@ -13427,7 +13439,7 @@ virDomainSoundDefParseXML(xmlNodePtr node, } } =20 - if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, &def->info, flags)= < 0) goto error; =20 cleanup: @@ -13444,7 +13456,8 @@ virDomainSoundDefParseXML(xmlNodePtr node, =20 =20 static virDomainWatchdogDefPtr -virDomainWatchdogDefParseXML(xmlNodePtr node, +virDomainWatchdogDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr node, unsigned int flags) { =20 @@ -13480,7 +13493,7 @@ virDomainWatchdogDefParseXML(xmlNodePtr node, } } =20 - if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, &def->info, flags)= < 0) goto error; =20 cleanup: @@ -13592,7 +13605,7 @@ virDomainRNGDefParseXML(virDomainXMLOptionPtr xmlop= t, break; } =20 - if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, &def->info, flags)= < 0) goto error; =20 if (virDomainVirtioOptionsParseXML(virXPathNode("./driver", ctxt), @@ -13615,7 +13628,8 @@ virDomainRNGDefParseXML(virDomainXMLOptionPtr xmlop= t, =20 =20 static virDomainMemballoonDefPtr -virDomainMemballoonDefParseXML(xmlNodePtr node, +virDomainMemballoonDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr node, xmlXPathContextPtr ctxt, unsigned int flags) { @@ -13661,7 +13675,8 @@ virDomainMemballoonDefParseXML(xmlNodePtr node, =20 if (def->model =3D=3D VIR_DOMAIN_MEMBALLOON_MODEL_NONE) VIR_DEBUG("Ignoring device address for none model Memballoon"); - else if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < = 0) + else if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, + &def->info, flags) < 0) goto error; =20 if (virDomainVirtioOptionsParseXML(virXPathNode("./driver", ctxt), @@ -13682,7 +13697,8 @@ virDomainMemballoonDefParseXML(xmlNodePtr node, } =20 static virDomainNVRAMDefPtr -virDomainNVRAMDefParseXML(xmlNodePtr node, +virDomainNVRAMDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr node, unsigned int flags) { virDomainNVRAMDefPtr def; @@ -13690,7 +13706,7 @@ virDomainNVRAMDefParseXML(xmlNodePtr node, if (VIR_ALLOC(def) < 0) return NULL; =20 - if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, &def->info, flags)= < 0) goto error; =20 return def; @@ -13701,7 +13717,8 @@ virDomainNVRAMDefParseXML(xmlNodePtr node, } =20 static virDomainShmemDefPtr -virDomainShmemDefParseXML(xmlNodePtr node, +virDomainShmemDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr node, xmlXPathContextPtr ctxt, unsigned int flags) { @@ -13785,7 +13802,7 @@ virDomainShmemDefParseXML(xmlNodePtr node, goto cleanup; } =20 - if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, &def->info, flags)= < 0) goto cleanup; =20 =20 @@ -14206,7 +14223,8 @@ virDomainVideoDriverDefParseXML(xmlNodePtr node) } =20 static virDomainVideoDefPtr -virDomainVideoDefParseXML(xmlNodePtr node, +virDomainVideoDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr node, xmlXPathContextPtr ctxt, const virDomainDef *dom, unsigned int flags) @@ -14320,7 +14338,7 @@ virDomainVideoDefParseXML(xmlNodePtr node, } } =20 - if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, &def->info, flags)= < 0) goto error; =20 def->driver =3D virDomainVideoDriverDefParseXML(node); @@ -14388,7 +14406,7 @@ virDomainHostdevDefParseXML(virDomainXMLOptionPtr x= mlopt, } =20 if (def->info->type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { - if (virDomainDeviceInfoParseXML(node, bootHash, def->info, + if (virDomainDeviceInfoParseXML(xmlopt, node, bootHash, def->info, flags | VIR_DOMAIN_DEF_PARSE_ALLO= W_BOOT | VIR_DOMAIN_DEF_PARSE_ALLOW_ROM) = < 0) goto error; @@ -14475,7 +14493,7 @@ virDomainRedirdevDefParseXML(virDomainXMLOptionPtr = xmlopt, if (def->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_SPICEVMC) def->source->data.spicevmc =3D VIR_DOMAIN_CHR_SPICEVMC_USBREDIR; =20 - if (virDomainDeviceInfoParseXML(node, bootHash, &def->info, + if (virDomainDeviceInfoParseXML(xmlopt, node, bootHash, &def->info, flags | VIR_DOMAIN_DEF_PARSE_ALLOW_BOO= T) < 0) goto error; =20 @@ -14887,7 +14905,8 @@ virDomainMemoryTargetDefParseXML(xmlNodePtr node, =20 =20 static virDomainMemoryDefPtr -virDomainMemoryDefParseXML(xmlNodePtr memdevNode, +virDomainMemoryDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr memdevNode, xmlXPathContextPtr ctxt, unsigned int flags) { @@ -14941,7 +14960,8 @@ virDomainMemoryDefParseXML(xmlNodePtr memdevNode, if (virDomainMemoryTargetDefParseXML(node, ctxt, def) < 0) goto error; =20 - if (virDomainDeviceInfoParseXML(memdevNode, NULL, &def->info, flags) <= 0) + if (virDomainDeviceInfoParseXML(xmlopt, memdevNode, + NULL, &def->info, flags) < 0) goto error; =20 ctxt->node =3D save; @@ -15081,7 +15101,7 @@ virDomainDeviceDefParse(const char *xmlStr, goto error; break; case VIR_DOMAIN_DEVICE_FS: - if (!(dev->data.fs =3D virDomainFSDefParseXML(node, ctxt, flags))) + if (!(dev->data.fs =3D virDomainFSDefParseXML(xmlopt, node, ctxt, = flags))) goto error; break; case VIR_DOMAIN_DEVICE_NET: @@ -15091,20 +15111,23 @@ virDomainDeviceDefParse(const char *xmlStr, goto error; break; case VIR_DOMAIN_DEVICE_INPUT: - if (!(dev->data.input =3D virDomainInputDefParseXML(def, node, + if (!(dev->data.input =3D virDomainInputDefParseXML(xmlopt, def, n= ode, ctxt, flags))) goto error; break; case VIR_DOMAIN_DEVICE_SOUND: - if (!(dev->data.sound =3D virDomainSoundDefParseXML(node, ctxt, fl= ags))) + if (!(dev->data.sound =3D virDomainSoundDefParseXML(xmlopt, node, + ctxt, flags))) goto error; break; case VIR_DOMAIN_DEVICE_WATCHDOG: - if (!(dev->data.watchdog =3D virDomainWatchdogDefParseXML(node, fl= ags))) + if (!(dev->data.watchdog =3D virDomainWatchdogDefParseXML(xmlopt, + node, flag= s))) goto error; break; case VIR_DOMAIN_DEVICE_VIDEO: - if (!(dev->data.video =3D virDomainVideoDefParseXML(node, ctxt, de= f, flags))) + if (!(dev->data.video =3D virDomainVideoDefParseXML(xmlopt, node, + ctxt, def, flags= ))) goto error; break; case VIR_DOMAIN_DEVICE_HOSTDEV: @@ -15114,8 +15137,8 @@ virDomainDeviceDefParse(const char *xmlStr, goto error; break; case VIR_DOMAIN_DEVICE_CONTROLLER: - if (!(dev->data.controller =3D virDomainControllerDefParseXML(node= , ctxt, - flags)= )) + if (!(dev->data.controller =3D virDomainControllerDefParseXML(xmlo= pt, node, + ctxt, = flags))) goto error; break; case VIR_DOMAIN_DEVICE_GRAPHICS: @@ -15123,7 +15146,7 @@ virDomainDeviceDefParse(const char *xmlStr, goto error; break; case VIR_DOMAIN_DEVICE_HUB: - if (!(dev->data.hub =3D virDomainHubDefParseXML(node, flags))) + if (!(dev->data.hub =3D virDomainHubDefParseXML(xmlopt, node, flag= s))) goto error; break; case VIR_DOMAIN_DEVICE_REDIRDEV: @@ -15151,29 +15174,32 @@ virDomainDeviceDefParse(const char *xmlStr, goto error; break; case VIR_DOMAIN_DEVICE_MEMBALLOON: - if (!(dev->data.memballoon =3D virDomainMemballoonDefParseXML(node, + if (!(dev->data.memballoon =3D virDomainMemballoonDefParseXML(xmlo= pt, + node, ctxt, flags)= )) goto error; break; case VIR_DOMAIN_DEVICE_NVRAM: - if (!(dev->data.nvram =3D virDomainNVRAMDefParseXML(node, flags))) + if (!(dev->data.nvram =3D virDomainNVRAMDefParseXML(xmlopt, node, = flags))) goto error; break; case VIR_DOMAIN_DEVICE_SHMEM: - if (!(dev->data.shmem =3D virDomainShmemDefParseXML(node, ctxt, fl= ags))) + if (!(dev->data.shmem =3D virDomainShmemDefParseXML(xmlopt, node, + ctxt, flags))) goto error; break; case VIR_DOMAIN_DEVICE_TPM: - if (!(dev->data.tpm =3D virDomainTPMDefParseXML(node, ctxt, flags)= )) + if (!(dev->data.tpm =3D virDomainTPMDefParseXML(xmlopt, node, ctxt= , flags))) goto error; break; case VIR_DOMAIN_DEVICE_PANIC: - if (!(dev->data.panic =3D virDomainPanicDefParseXML(node, flags))) + if (!(dev->data.panic =3D virDomainPanicDefParseXML(xmlopt, node, = flags))) goto error; break; case VIR_DOMAIN_DEVICE_MEMORY: - if (!(dev->data.memory =3D virDomainMemoryDefParseXML(node, ctxt, = flags))) + if (!(dev->data.memory =3D virDomainMemoryDefParseXML(xmlopt, node, + ctxt, flags))) goto error; break; case VIR_DOMAIN_DEVICE_IOMMU: @@ -18750,7 +18776,8 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; =20 for (i =3D 0; i < n; i++) { - virDomainControllerDefPtr controller =3D virDomainControllerDefPar= seXML(nodes[i], + virDomainControllerDefPtr controller =3D virDomainControllerDefPar= seXML(xmlopt, + = nodes[i], = ctxt, = flags); =20 @@ -18816,7 +18843,9 @@ virDomainDefParseXML(xmlDocPtr xml, if (n && VIR_ALLOC_N(def->fss, n) < 0) goto error; for (i =3D 0; i < n; i++) { - virDomainFSDefPtr fs =3D virDomainFSDefParseXML(nodes[i], ctxt, + virDomainFSDefPtr fs =3D virDomainFSDefParseXML(xmlopt, + nodes[i], + ctxt, flags); if (!fs) goto error; @@ -18980,7 +19009,8 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; =20 for (i =3D 0; i < n; i++) { - virDomainInputDefPtr input =3D virDomainInputDefParseXML(def, + virDomainInputDefPtr input =3D virDomainInputDefParseXML(xmlopt, + def, nodes[i], ctxt, flags); @@ -19022,7 +19052,8 @@ virDomainDefParseXML(xmlDocPtr xml, if (n && VIR_ALLOC_N(def->sounds, n) < 0) goto error; for (i =3D 0; i < n; i++) { - virDomainSoundDefPtr sound =3D virDomainSoundDefParseXML(nodes[i], + virDomainSoundDefPtr sound =3D virDomainSoundDefParseXML(xmlopt, + nodes[i], ctxt, flags); if (!sound) @@ -19041,7 +19072,8 @@ virDomainDefParseXML(xmlDocPtr xml, virDomainVideoDefPtr video; ssize_t insertAt =3D -1; =20 - if (!(video =3D virDomainVideoDefParseXML(nodes[i], ctxt, def, fla= gs))) + if (!(video =3D virDomainVideoDefParseXML(xmlopt, nodes[i], + ctxt, def, flags))) goto error; =20 if (video->primary) { @@ -19110,8 +19142,9 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; } if (n > 0) { - virDomainWatchdogDefPtr watchdog =3D - virDomainWatchdogDefParseXML(nodes[0], flags); + virDomainWatchdogDefPtr watchdog; + + watchdog =3D virDomainWatchdogDefParseXML(xmlopt, nodes[0], flags); if (!watchdog) goto error; =20 @@ -19129,8 +19162,9 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; } if (n > 0) { - virDomainMemballoonDefPtr memballoon =3D - virDomainMemballoonDefParseXML(nodes[0], ctxt, flags); + virDomainMemballoonDefPtr memballoon; + + memballoon =3D virDomainMemballoonDefParseXML(xmlopt, nodes[0], ct= xt, flags); if (!memballoon) goto error; =20 @@ -19164,7 +19198,7 @@ virDomainDefParseXML(xmlDocPtr xml, } =20 if (n > 0) { - if (!(def->tpm =3D virDomainTPMDefParseXML(nodes[0], ctxt, flags))) + if (!(def->tpm =3D virDomainTPMDefParseXML(xmlopt, nodes[0], ctxt,= flags))) goto error; } VIR_FREE(nodes); @@ -19178,7 +19212,7 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; } else if (n =3D=3D 1) { virDomainNVRAMDefPtr nvram =3D - virDomainNVRAMDefParseXML(nodes[0], flags); + virDomainNVRAMDefParseXML(xmlopt, nodes[0], flags); if (!nvram) goto error; def->nvram =3D nvram; @@ -19191,7 +19225,9 @@ virDomainDefParseXML(xmlDocPtr xml, if (n && VIR_ALLOC_N(def->hubs, n) < 0) goto error; for (i =3D 0; i < n; i++) { - virDomainHubDefPtr hub =3D virDomainHubDefParseXML(nodes[i], flags= ); + virDomainHubDefPtr hub; + + hub =3D virDomainHubDefParseXML(xmlopt, nodes[i], flags); if (!hub) goto error; =20 @@ -19247,7 +19283,9 @@ virDomainDefParseXML(xmlDocPtr xml, if (n && VIR_ALLOC_N(def->panics, n) < 0) goto error; for (i =3D 0; i < n; i++) { - virDomainPanicDefPtr panic =3D virDomainPanicDefParseXML(nodes[i],= flags); + virDomainPanicDefPtr panic; + + panic =3D virDomainPanicDefParseXML(xmlopt, nodes[i], flags); if (!panic) goto error; =20 @@ -19265,7 +19303,7 @@ virDomainDefParseXML(xmlDocPtr xml, for (i =3D 0; i < n; i++) { virDomainShmemDefPtr shmem; ctxt->node =3D nodes[i]; - shmem =3D virDomainShmemDefParseXML(nodes[i], ctxt, flags); + shmem =3D virDomainShmemDefParseXML(xmlopt, nodes[i], ctxt, flags); if (!shmem) goto error; =20 @@ -19281,7 +19319,8 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; =20 for (i =3D 0; i < n; i++) { - virDomainMemoryDefPtr mem =3D virDomainMemoryDefParseXML(nodes[i], + virDomainMemoryDefPtr mem =3D virDomainMemoryDefParseXML(xmlopt, + nodes[i], ctxt, flags); if (!mem) --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 19:39:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508400755751127.71692667155958; Thu, 19 Oct 2017 01:12:35 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 733C57EA9B; Thu, 19 Oct 2017 08:12:34 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 524A25F74D; Thu, 19 Oct 2017 08:12:34 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1A4FF1800C99; Thu, 19 Oct 2017 08:12:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9J8BYDX007397 for ; Thu, 19 Oct 2017 04:11:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id C386AA4301; Thu, 19 Oct 2017 08:11:34 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C5B5A42FE for ; Thu, 19 Oct 2017 08:11:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 733C57EA9B Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 19 Oct 2017 10:11:02 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 07/14] conf: Parse user supplied aliases 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 19 Oct 2017 08:12:35 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" If driver that is calling the parse supports user supplied aliases, they can be parsed even for inactive XMLs. However, to avoid any clashes with aliases that libvirt generates, the user ones have to have "ua-" prefix. Signed-off-by: Michal Privoznik --- src/conf/domain_conf.c | 13 +++++++++++-- src/conf/domain_conf.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f4de4e288..f1386c116 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6398,6 +6398,10 @@ virDomainDeviceAddressParseXML(xmlNodePtr address, } =20 =20 +#define USER_ALIAS_PREFIX "ua-" +#define USER_ALIAS_CHARS \ + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-" + /* Parse the XML definition for a device address * @param node XML nodeset to parse for device address definition */ @@ -6424,7 +6428,6 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xml= opt ATTRIBUTE_UNUSED, while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE) { if (alias =3D=3D NULL && - !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) && virXMLNodeNameEqual(cur, "alias")) { alias =3D cur; } else if (address =3D=3D NULL && @@ -6446,8 +6449,14 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xm= lopt ATTRIBUTE_UNUSED, cur =3D cur->next; } =20 - if (alias) + if (alias) { info->alias =3D virXMLPropString(alias, "name"); + if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE && + (!STRPREFIX(info->alias, USER_ALIAS_PREFIX) || + !(xmlopt->config.features & VIR_DOMAIN_DEF_FEATURE_USER_ALIAS= ) || + strspn(info->alias, USER_ALIAS_CHARS) < strlen(info->alias))) + VIR_FREE(info->alias); + } =20 if (master) { info->mastertype =3D VIR_DOMAIN_CONTROLLER_MASTER_USB; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 1e007346f..5ff85057f 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2508,6 +2508,7 @@ typedef enum { VIR_DOMAIN_DEF_FEATURE_OFFLINE_VCPUPIN =3D (1 << 2), VIR_DOMAIN_DEF_FEATURE_NAME_SLASH =3D (1 << 3), VIR_DOMAIN_DEF_FEATURE_INDIVIDUAL_VCPUS =3D (1 << 4), + VIR_DOMAIN_DEF_FEATURE_USER_ALIAS =3D (1 << 5), } virDomainDefFeatures; =20 =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 19:39:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 150840081108491.84036778796371; Thu, 19 Oct 2017 01:13:31 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id D121C820F8; Thu, 19 Oct 2017 08:13:29 +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 A818BA650F; Thu, 19 Oct 2017 08:13:29 +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 70F503FC71; Thu, 19 Oct 2017 08:13:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9J8BZfd007402 for ; Thu, 19 Oct 2017 04:11:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 95DC6A42FE; Thu, 19 Oct 2017 08:11:35 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D2A2A4301 for ; Thu, 19 Oct 2017 08:11:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D121C820F8 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 19 Oct 2017 10:11:03 +0200 Message-Id: <1553a61474245f2179e116578becd4dea9d89759.1508399823.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 08/14] conf: Validate user supplied aliases 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 19 Oct 2017 08:13:30 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" They have to be unique within the domain. As usual, backwards compatibility takes its price. In this particular situation we have a device that is represented twice in a domain and so is its alias. Signed-off-by: Michal Privoznik --- src/conf/domain_conf.c | 148 +++++++++++++++++++++++++++++++++++++++++++= +++- src/conf/domain_conf.h | 5 ++ src/libvirt_private.syms | 1 + src/qemu/qemu_driver.c | 3 + 4 files changed, 155 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f1386c116..0cf67dff1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5458,6 +5458,145 @@ virDomainDeviceDefValidateInternal(const virDomainD= eviceDef *dev, } =20 =20 +struct virDomainDefValidateAliasesData { + virHashTablePtr aliases; +}; + + +static int +virDomainDeviceDefValidateAliasesIterator(virDomainDefPtr def, + virDomainDeviceDefPtr dev, + virDomainDeviceInfoPtr info, + void *opaque) +{ + struct virDomainDefValidateAliasesData *data =3D opaque; + const char *alias =3D info->alias; + + if (!alias) + return 0; + + /* Some crazy backcompat for consoles. */ + if (def->nserials && def->nconsoles && + def->consoles[0]->deviceType =3D=3D VIR_DOMAIN_CHR_DEVICE_TYPE_CON= SOLE && + def->consoles[0]->targetType =3D=3D VIR_DOMAIN_CHR_CONSOLE_TARGET_= TYPE_SERIAL && + dev->type =3D=3D VIR_DOMAIN_DEVICE_CHR && + virDomainChrEquals(def->serials[0], dev->data.chr)) + return 0; + + if (virHashLookup(data->aliases, alias)) { + virReportError(VIR_ERR_XML_ERROR, + _("non unique alias detected: %s"), + alias); + return -1; + } + + if (virHashAddEntry(data->aliases, alias, (void *) 1) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to construct table of device aliases")); + return -1; + } + + return 0; +} + + +/** + * virDomainDefValidateAliases: + * + * Check for uniqueness of device aliases. If @aliases is not + * NULL return hash table of all the aliases in it. + * + * Returns 0 on success, + * -1 otherwise (with error reported). + */ +static int +virDomainDefValidateAliases(virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED, + const virDomainDef *def, + virHashTablePtr *aliases, + unsigned int parseFlags) +{ + struct virDomainDefValidateAliasesData data; + int ret =3D -1; + + /* validate configuration only in certain places */ + if (parseFlags & VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE) + return 0; + + /* We are not storing copies of aliases. Don't free them. */ + if (!(data.aliases =3D virHashCreate(10, NULL))) + goto cleanup; + + if (virDomainDeviceInfoIterateInternal((virDomainDefPtr) def, + virDomainDeviceDefValidateAlias= esIterator, + true, &data) < 0) + goto cleanup; + + if (aliases) { + *aliases =3D data.aliases; + data.aliases =3D NULL; + } + + ret =3D 0; + cleanup: + virHashFree(data.aliases); + return ret; +} + + +static int +virDomainDeviceValidateAliasImpl(virDomainXMLOptionPtr xmlopt, + const virDomainDef *def, + const virDomainDeviceDef *dev) +{ + virHashTablePtr aliases =3D NULL; + virDomainDeviceInfoPtr info =3D virDomainDeviceGetInfo(dev); + int ret =3D -1; + + if (!info || !info->alias) + return 0; + + if (virDomainDefValidateAliases(xmlopt, def, &aliases, 0) < 0) + goto cleanup; + + if (virHashLookup(aliases, info->alias)) { + virReportError(VIR_ERR_XML_ERROR, + _("non unique alias detected: %s"), + info->alias); + goto cleanup; + } + + ret =3D 0; + cleanup: + + virHashFree(aliases); + return ret; +} + + +int +virDomainDeviceValidateAliasForHotplug(virDomainXMLOptionPtr xmlopt, + virDomainObjPtr vm, + const virDomainDeviceDef *dev, + unsigned int flags) +{ + virDomainDefPtr persDef =3D NULL; + virDomainDefPtr liveDef =3D NULL; + + if (virDomainObjGetDefs(vm, flags, &liveDef, &persDef) < 0) + return -1; + + if (persDef && + virDomainDeviceValidateAliasImpl(xmlopt, vm->def, dev) < 0) + return -1; + + if (liveDef && + virDomainDeviceValidateAliasImpl(xmlopt, vm->newDef, dev) < 0) + return -1; + + return 0; +} + + static int virDomainDeviceDefValidate(const virDomainDeviceDef *dev, const virDomainDef *def, @@ -5615,7 +5754,9 @@ virDomainDefCheckDuplicateDriveAddresses(const virDom= ainDef *def) =20 =20 static int -virDomainDefValidateInternal(const virDomainDef *def) +virDomainDefValidateInternal(virDomainXMLOptionPtr xmlopt, + const virDomainDef *def, + unsigned int parseFlags) { if (virDomainDefCheckDuplicateDiskInfo(def) < 0) return -1; @@ -5626,6 +5767,9 @@ virDomainDefValidateInternal(const virDomainDef *def) if (virDomainDefGetVcpusTopology(def, NULL) < 0) return -1; =20 + if (virDomainDefValidateAliases(xmlopt, def, NULL, parseFlags) < 0) + return -1; + if (def->iommu && def->iommu->intremap =3D=3D VIR_TRISTATE_SWITCH_ON && (def->features[VIR_DOMAIN_FEATURE_IOAPIC] !=3D VIR_TRISTATE_SWITCH= _ON || @@ -5690,7 +5834,7 @@ virDomainDefValidate(virDomainDefPtr def, true, &data) < 0) return -1; =20 - if (virDomainDefValidateInternal(def) < 0) + if (virDomainDefValidateInternal(xmlopt, def, parseFlags) < 0) return -1; =20 return 0; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 5ff85057f..2b90e98cb 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2659,6 +2659,11 @@ int virDomainDefPostParse(virDomainDefPtr def, virDomainXMLOptionPtr xmlopt, void *parseOpaque); =20 +int virDomainDeviceValidateAliasForHotplug(virDomainXMLOptionPtr xmlopt, + virDomainObjPtr vm, + const virDomainDeviceDef *dev, + unsigned int flags); + int virDomainDefValidate(virDomainDefPtr def, virCapsPtr caps, unsigned int parseFlags, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 3b5df28e5..8449e9685 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -294,6 +294,7 @@ virDomainDeviceFindControllerModel; virDomainDeviceGetInfo; virDomainDeviceInfoIterate; virDomainDeviceTypeToString; +virDomainDeviceValidateAliasForHotplug; virDomainDiskBusTypeToString; virDomainDiskByAddress; virDomainDiskByName; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index fb4d72236..dcd2c2109 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8375,6 +8375,9 @@ qemuDomainAttachDeviceLiveAndConfig(virConnectPtr con= n, if (dev =3D=3D NULL) goto cleanup; =20 + if (virDomainDeviceValidateAliasForHotplug(driver->xmlopt, vm, dev, fl= ags) < 0) + goto cleanup; + if (flags & VIR_DOMAIN_AFFECT_CONFIG && flags & VIR_DOMAIN_AFFECT_LIVE) { /* If we are affecting both CONFIG and LIVE --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 19:39:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15084008134591020.322858255931; Thu, 19 Oct 2017 01:13:33 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 7E3E16CB38; Thu, 19 Oct 2017 08:13:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5724DB470E; Thu, 19 Oct 2017 08:13:32 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 15FF23FAD8; Thu, 19 Oct 2017 08:13:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9J8Barx007412 for ; Thu, 19 Oct 2017 04:11:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7970FA4301; Thu, 19 Oct 2017 08:11:36 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01DBCA42FE for ; Thu, 19 Oct 2017 08:11:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7E3E16CB38 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 19 Oct 2017 10:11:04 +0200 Message-Id: <3201b3e7c011e48d502f113680590a4104757333.1508399823.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 09/14] virDomainDeviceInfoCheckABIStability: Check for alias too 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 19 Oct 2017 08:13:32 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Since we'll be passing user's input onto qemu command line, we have to make sure aliases don't change during migration and all the other places where ABI is checked. Aliases are part of ABI now. Signed-off-by: Michal Privoznik --- src/conf/domain_conf.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 0cf67dff1..cb80939af 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -19870,6 +19870,13 @@ virDomainDeviceInfoCheckABIStability(virDomainDevi= ceInfoPtr src, return false; } =20 + if (STRNEQ_NULLABLE(src->alias, dst->alias)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target device alias %s does not match source %s"= ), + NULLSTR(src->alias), NULLSTR(dst->alias)); + return false; + } + switch ((virDomainDeviceAddressType) src->type) { case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: if (src->addr.pci.domain !=3D dst->addr.pci.domain || --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 19:39:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508400864123441.78488160224583; Thu, 19 Oct 2017 01:14:24 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 332ED3E2CC; Thu, 19 Oct 2017 08:14:23 +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 15844AB70A; Thu, 19 Oct 2017 08:14:23 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D4A033FC74; Thu, 19 Oct 2017 08:14:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9J8BbWB007425 for ; Thu, 19 Oct 2017 04:11:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4B046A42FE; Thu, 19 Oct 2017 08:11:37 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id C74FBA4319 for ; Thu, 19 Oct 2017 08:11:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 332ED3E2CC Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 19 Oct 2017 10:11:05 +0200 Message-Id: <53a6c6588197483fb7ccb606367ea185f87c7cbc.1508399823.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 10/14] qemuxml2argvdata: Drop device aliases 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 19 Oct 2017 08:14:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The qemuxml2argvtest expects the domain XMLs to be inactive ones. Therefore we should pass inactive XMLs. Signed-off-by: Michal Privoznik --- tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftp.xml | 1 - tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftps.xml | 1 - tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-http.xml | 1 - tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-https.xml | 1 - tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-tftp.xml | 1 - tests/qemuxml2argvdata/qemuxml2argv-usb-redir-filter.xml | 1 - 6 files changed, 6 deletions(-) diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftp.xml= b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftp.xml index df41e5832..b4e331160 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftp.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftp.xml @@ -26,7 +26,6 @@ -
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftps.xm= l b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftps.xml index 57049a266..4e6ca1bad 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftps.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftps.xml @@ -26,7 +26,6 @@ -
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-http.xm= l b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-http.xml index 8a1286cb1..0eed65672 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-http.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-http.xml @@ -26,7 +26,6 @@ -
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-https.x= ml b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-https.xml index 41b5a89b6..cd92fe44a 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-https.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-https.xml @@ -26,7 +26,6 @@ -
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-tftp.xm= l b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-tftp.xml index e2cb4a006..1c3b185b0 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-tftp.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-tftp.xml @@ -26,7 +26,6 @@ -
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-redir-filter.xml b/tes= ts/qemuxml2argvdata/qemuxml2argv-usb-redir-filter.xml index 32fb890a1..0bc15f0df 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-usb-redir-filter.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-redir-filter.xml @@ -33,7 +33,6 @@
-
--=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 19:39:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508400758584453.8713633898111; Thu, 19 Oct 2017 01:12:38 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 4E3C67EAA1; Thu, 19 Oct 2017 08: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 2C5447C920; Thu, 19 Oct 2017 08: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 E572F180BACD; Thu, 19 Oct 2017 08:12:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9J8BcJ7007437 for ; Thu, 19 Oct 2017 04:11:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 222CCA6507; Thu, 19 Oct 2017 08:11:38 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9DA48A6502 for ; Thu, 19 Oct 2017 08:11:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4E3C67EAA1 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 19 Oct 2017 10:11:06 +0200 Message-Id: <18c991a60a2c159be56dd08af8fbe891febd56fe.1508399823.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 11/14] qemuhotplugtest: Load active XML 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 19 Oct 2017 08:12:37 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The point of this test is to load live XML and test hotplug. But even though the XMLs we are parsing are live, the parsing is done with VIR_DOMAIN_DEF_PARSE_INACTIVE flag. Signed-off-by: Michal Privoznik --- tests/qemuhotplugtest.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index df28a7fbd..8d77c0056 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -62,6 +62,7 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt, { int ret =3D -1; qemuDomainObjPrivatePtr priv =3D NULL; + const unsigned int parseFlags =3D 0; =20 if (!(*vm =3D virDomainObjNew(xmlopt))) goto cleanup; @@ -87,7 +88,7 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt, driver.caps, driver.xmlopt, NULL, - VIR_DOMAIN_DEF_PARSE_INACTI= VE))) + parseFlags))) goto cleanup; =20 if (qemuDomainAssignAddresses((*vm)->def, priv->qemuCaps, --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 19:39:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508400866847121.80860666547176; Thu, 19 Oct 2017 01:14:26 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id B6BE9A797; Thu, 19 Oct 2017 08:14:25 +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 981C9AB710; Thu, 19 Oct 2017 08:14:25 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5EE581800C9B; Thu, 19 Oct 2017 08:14:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9J8BcWq007447 for ; Thu, 19 Oct 2017 04:11:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id E5EDFA6508; Thu, 19 Oct 2017 08:11:38 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6ED6EA42EF for ; Thu, 19 Oct 2017 08:11:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B6BE9A797 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 19 Oct 2017 10:11:07 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 12/14] conf: Format alias even for inactive XMLs 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 19 Oct 2017 08:14:26 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We need to format alias even for inactive XMLs since that's the way how users are going to identify their devices. Signed-off-by: Michal Privoznik --- src/conf/domain_conf.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index cb80939af..7efbf55b0 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5916,10 +5916,9 @@ virDomainDeviceInfoFormat(virBufferPtr buf, =20 virBufferAddLit(buf, "/>\n"); } - if (info->alias && - !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)) { + + if (info->alias) virBufferAsprintf(buf, "\n", info->alias); - } =20 if (info->mastertype =3D=3D VIR_DOMAIN_CONTROLLER_MASTER_USB) { virBufferAsprintf(buf, "\n", --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 19:39:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508400869665958.6883125489384; Thu, 19 Oct 2017 01:14:29 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 74B95B64F; Thu, 19 Oct 2017 08:14:28 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 51875AD226; Thu, 19 Oct 2017 08:14:28 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 19291410AD; Thu, 19 Oct 2017 08:14:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9J8BdE5007454 for ; Thu, 19 Oct 2017 04:11:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id CA1C6A6509; Thu, 19 Oct 2017 08:11:39 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 52D65A42EF for ; Thu, 19 Oct 2017 08:11:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 74B95B64F Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 19 Oct 2017 10:11:08 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 13/14] docs: Document user aliases 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 19 Oct 2017 08:14:28 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik --- docs/formatdomain.html.in | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index b7e145e0f..57dd46dc5 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2249,6 +2249,29 @@ =20 +

+ To help users identifying devices they care about, every + device can have direct child alias element + which then has name attribute where users can + store identifier for the device. The identifier has to have + "ua-" prefix and must be unique within the domain. Additionally, the + identifier must consist only of the following characters: + [a-zA-Z0-9_-]. + Since 3.9.0 +

+ +
+<devices>
+  <disk type=3D'file'>
+    <alias name=3D'ua-myDisk'/>
+  </disk>
+  <interface type=3D'network' trustGuestRxFilters=3D'yes'>
+    <alias name=3D'ua-myNIC'/>
+  </interface>
+  ...
+</devices>
+
+

Hard drives, floppy disks, CDROMs

=20

--=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 19:39:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508400761021154.50096542819506; Thu, 19 Oct 2017 01:12:41 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id EAB547EA99; Thu, 19 Oct 2017 08:12:39 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C2C2BB7303; Thu, 19 Oct 2017 08:12:39 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8D079410B2; Thu, 19 Oct 2017 08:12:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9J8BeRE007461 for ; Thu, 19 Oct 2017 04:11:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id C9D0EA6509; Thu, 19 Oct 2017 08:11:40 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 52795A42EF for ; Thu, 19 Oct 2017 08:11:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EAB547EA99 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 19 Oct 2017 10:11:09 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 14/14] qemu: Parse alias from inactive XMLs 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 19 Oct 2017 08:12:40 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1434451 This way users can uniquely identify devices at define time. Signed-off-by: Michal Privoznik --- src/qemu/qemu_domain.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 05e8b96aa..0ddbea3b7 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4095,7 +4095,8 @@ virDomainDefParserConfig virQEMUDriverDomainDefParser= Config =3D { =20 .features =3D VIR_DOMAIN_DEF_FEATURE_MEMORY_HOTPLUG | VIR_DOMAIN_DEF_FEATURE_OFFLINE_VCPUPIN | - VIR_DOMAIN_DEF_FEATURE_INDIVIDUAL_VCPUS, + VIR_DOMAIN_DEF_FEATURE_INDIVIDUAL_VCPUS | + VIR_DOMAIN_DEF_FEATURE_USER_ALIAS, }; =20 =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list